Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 2: X=Σ^0−Σ^1X=\hat\Sigma_0-\hat\Sigma_1X=Σ^0​−Σ^1​ is a difference of two PSD matrices

Proved
DimensionalCollapse.X_difference_of_psd

by Xeroth · Nov 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

contrastive-learninggradient-flowinfonceself-supervised-learningsingular-values

For inputs xi,xi′∈Rnx_i,x_i'\in\mathbb{R}^nxi​,xi′​∈Rn and any linear model W∈Rd×nW\in\mathbb{R}^{d\times n}W∈Rd×n, with the softmax weights αij\alpha_{ij}αij​ computed from z=Wxz=Wxz=Wx, z′=Wx′z'=Wx'z′=Wx′, the matrix XXX is a difference of two positive semidefinite matrices:

X=Σ^0−Σ^1,Σ^0=∑i,jαij(xi−xj)(xi−xj)⊤⪰0,Σ^1=∑i(1−αii)(xi′−xi)(xi′−xi)⊤⪰0.X=\hat\Sigma_0-\hat\Sigma_1,\qquad \hat\Sigma_0=\sum_{i,j}\alpha_{ij}(x_i-x_j)(x_i-x_j)^\top\succeq0,\qquad \hat\Sigma_1=\sum_i(1-\alpha_{ii})(x_i'-x_i)(x_i'-x_i)^\top\succeq0 .X=Σ^0​−Σ^1​,Σ^0​=i,j∑​αij​(xi​−xj​)(xi​−xj​)⊤⪰0,Σ^1​=i∑​(1−αii​)(xi′​−xi​)(xi′​−xi​)⊤⪰0.

Here Σ^0\hat\Sigma_0Σ^0​ is a weighted covariance of the data and Σ^1\hat\Sigma_1Σ^1​ a weighted covariance of the augmentation, so the strength of the augmentation decides whether XXX is positive definite.

Formalization Note XXX is taken in the form of Appendix B.2; see the note on eqs. (4)–(5).

Preamble
import Mathlib
import Definitions.Def_DimensionalCollapse_Basic

open Matrix Filter Topology
Formal statement
namespace DimensionalCollapse

theorem X_difference_of_psd {N n d : ℕ} (x x' : Fin N → Fin n → ℝ)
    (W : Matrix (Fin d) (Fin n) ℝ) :
    Xmat x x' W = Sigma0 x x' W - Sigma1 x x' W ∧
      (Sigma0 x x' W).PosSemidef ∧ (Sigma1 x x' W).PosSemidef := by sorry

end DimensionalCollapse
Source
Jing, Vincent, LeCun and Tian, Understanding Dimensional Collapse in Contrastive Self-supervised Learning, ICLR 2022, arXiv:2110.09348v3, Section 4.2, Lemma 2, eq. (7), p. 4; proof in Appendix B.2, p. 14
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

For any natural numbers N,n,dN, n, dN,n,d, any two families of vectors x1,…,xN∈Rnx_1, \dots, x_N \in \mathbb{R}^nx1​,…,xN​∈Rn and x1′,…,xN′∈Rnx'_1, \dots, x'_N \in \mathbb{R}^nx1′​,…,xN′​∈Rn, and any real d×nd \times nd×n matrix WWW, three things hold simultaneously:

X=Σ^0−Σ^1,Σ^0⪰0,Σ^1⪰0.X = \hat\Sigma_0 - \hat\Sigma_1, \qquad \hat\Sigma_0 \succeq 0, \qquad \hat\Sigma_1 \succeq 0 .X=Σ^0​−Σ^1​,Σ^0​⪰0,Σ^1​⪰0.

There are no further hypotheses. The statement is claimed for every choice of data and every WWW, including N=0N = 0N=0, n=0n = 0n=0 and d=0d = 0d=0.

Embeddings and weights. All three matrices depend on WWW only through the weights αij\alpha_{ij}αij​, which are computed from the embeddings

zi=Wxi,zi′=Wxi′∈Rd.z_i = W x_i, \qquad z'_i = W x'_i \in \mathbb{R}^d .zi​=Wxi​,zi′​=Wxi′​∈Rd.

Write ∣v∣2=∑cvc2|v|^2 = \sum_c v_c^2∣v∣2=∑c​vc2​ for the squared Euclidean norm. For each iii, define

Zi=∑j≠ie−∣zi−zj∣2/2+e−∣zi−zi′∣2/2.Z_i = \sum_{j \ne i} e^{-|z_i - z_j|^2/2} + e^{-|z_i - z'_i|^2/2}.Zi​=j=i∑​e−∣zi​−zj​∣2/2+e−∣zi​−zi′​∣2/2.

The "negatives" zjz_jzj​ here come from the same (unprimed) family as ziz_izi​. Then set

αij=e−∣zi−zj∣2/2Zi (j≠i),αii=e−∣zi−zi′∣2/2Zi.\alpha_{ij} = \frac{e^{-|z_i - z_j|^2/2}}{Z_i} \ (j \ne i), \qquad \alpha_{ii} = \frac{e^{-|z_i - z'_i|^2/2}}{Z_i}.αij​=Zi​e−∣zi​−zj​∣2/2​ (j=i),αii​=Zi​e−∣zi​−zi′​∣2/2​.

Since ZiZ_iZi​ contains a strictly positive term, there is no division by zero. Each αij\alpha_{ij}αij​ lies in (0,1](0,1](0,1], and ∑jαij=1\sum_j \alpha_{ij} = 1∑j​αij​=1 for each iii.

When d=0d = 0d=0, all embeddings are the zero vector, so every αij=1/N\alpha_{ij} = 1/Nαij​=1/N. When N=1N = 1N=1, α11=1\alpha_{11} = 1α11​=1.

The three matrices. All three are n×nn \times nn×n.

X=∑i=1N(∑j≠iαij (xi′−xj)+∑j≠iαji (xi−xj)) xi⊤  −  ∑i=1N(1−αii) (xi′−xi) xi′⊤,X = \sum_{i=1}^N \Big( \sum_{j \ne i} \alpha_{ij}\,(x'_i - x_j) + \sum_{j \ne i} \alpha_{ji}\,(x_i - x_j) \Big)\, x_i^{\top} \;-\; \sum_{i=1}^N (1 - \alpha_{ii})\,(x'_i - x_i)\, {x'_i}^{\top},X=i=1∑N​(j=i∑​αij​(xi′​−xj​)+j=i∑​αji​(xi​−xj​))xi⊤​−i=1∑N​(1−αii​)(xi′​−xi​)xi′​⊤, Σ^0=∑i=1N∑j=1Nαij (xi−xj)(xi−xj)⊤,\hat\Sigma_0 = \sum_{i=1}^N \sum_{j=1}^N \alpha_{ij}\,(x_i - x_j)(x_i - x_j)^{\top},Σ^0​=i=1∑N​j=1∑N​αij​(xi​−xj​)(xi​−xj​)⊤, Σ^1=∑i=1N(1−αii) (xi′−xi)(xi′−xi)⊤.\hat\Sigma_1 = \sum_{i=1}^N (1 - \alpha_{ii})\,(x'_i - x_i)(x'_i - x_i)^{\top}.Σ^1​=i=1∑N​(1−αii​)(xi′​−xi​)(xi′​−xi​)⊤.

Three details of these definitions:

  • In XXX, the second inner sum uses the weight αji\alpha_{ji}αji​, with the indices transposed.
  • In Σ^0\hat\Sigma_0Σ^0​, the double sum ranges over all pairs, including j=ij = ij=i. Those terms are zero because xi−xi=0x_i - x_i = 0xi​−xi​=0, even though αii\alpha_{ii}αii​ is the positive-pair weight.
  • Outer products are of the form uv⊤u v^{\top}uv⊤, with uuu indexing rows and vvv indexing columns.

Meaning of "positive semidefinite". Here M⪰0M \succeq 0M⪰0 means both:

  • MMM is symmetric, and
  • v⊤Mv≥0v^{\top} M v \ge 0v⊤Mv≥0 for every v∈Rnv \in \mathbb{R}^nv∈Rn.

Degenerate cases.

  • If N=0N = 0N=0, all three matrices are the zero matrix.
  • If n=0n = 0n=0, they are empty 0×00 \times 00×0 matrices.
  • If N=1N = 1N=1, one has Σ^0=Σ^1=X=0\hat\Sigma_0 = \hat\Sigma_1 = X = 0Σ^0​=Σ^1​=X=0.

What the statement does not involve. It refers to no gradient, no loss, and no relation between XXX and any gradient matrix. It is purely an identity and positivity claim about these explicitly defined matrices.

Human review
  • Endorsed by Shuze Chen · Nov 24, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 24, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me