Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 1: the weights of the linear model evolve by W˙=−G\dot W=-GW˙=−G

Proved
DimensionalCollapse.linear_weight_flow

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

contrastive-learninggradient-flowinfonceself-supervised-learningsingular-values

Let (xi,xi′)i=1N(x_i,x_i')_{i=1}^N(xi​,xi′​)i=1N​ be inputs in Rn\mathbb{R}^nRn, and let W(t)∈Rd×nW(t)\in\mathbb{R}^{d\times n}W(t)∈Rd×n be the weight of the linear model z=Wxz=Wxz=Wx trained on the InfoNCE loss L(W)L(W)L(W) by gradient flow. If at time ttt

W˙(t)=−∂L∂W(W(t)),\dot W(t)=-\frac{\partial L}{\partial W}\big(W(t)\big),W˙(t)=−∂W∂L​(W(t)),

then

W˙(t)=−G,G=∑i(gzixi⊤+gzi′xi′⊤),\dot W(t)=-G,\qquad G=\sum_i\big(g_{z_i}x_i^\top+g_{z_i'}x_i'^\top\big),W˙(t)=−G,G=i∑​(gzi​​xi⊤​+gzi′​​xi′⊤​),

where gzi,gzi′g_{z_i},g_{z_i'}gzi​​,gzi′​​ are the gradients of the loss with respect to the embeddings zi=W(t)xiz_i=W(t)x_izi​=W(t)xi​, zi′=W(t)xi′z_i'=W(t)x_i'zi′​=W(t)xi′​.

This is the chain rule for the linear model, and it reduces the training dynamics to the gradients on the embeddings.

Formalization Note Derivatives in time are taken entrywise, and the hypothesis is required only at the time ttt where the conclusion is drawn.

Preamble
import Mathlib
import Definitions.Def_DimensionalCollapse_Basic

open Matrix Filter Topology
Formal statement
namespace DimensionalCollapse

theorem linear_weight_flow {N n d : ℕ} (x x' : Fin N → Fin n → ℝ)
    (W : ℝ → Matrix (Fin d) (Fin n) ℝ) (t : ℝ)
    (hW : ∀ a b, HasDerivAt (fun s => W s a b) (-(matGrad (linLoss x x') (W t)) a b) t) :
    ∀ a b, HasDerivAt (fun s => W s a b) (-(Gmat x x' (W t)) a b) t := 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 1, eq. (3), p. 4; proof in Appendix B.1, p. 13
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, take the following data:

  • two families of input 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;
  • a time-dependent weight matrix s↦W(s)∈Rd×ns \mapsto W(s) \in \mathbb{R}^{d\times n}s↦W(s)∈Rd×n, defined for all real sss;
  • a time t∈Rt \in \mathbb{R}t∈R.

The loss. For embeddings z1,…,zN,z1′,…,zN′∈Rdz_1,\dots,z_N, z'_1,\dots,z'_N \in \mathbb{R}^dz1​,…,zN​,z1′​,…,zN′​∈Rd, with ∣v∣2=∑cvc2|v|^2 = \sum_c v_c^2∣v∣2=∑c​vc2​, define

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

The loss is

L(z,z′)=−∑i=1Nlog⁡e−∣zi−zi′∣2/2Zi(z,z′).\mathcal{L}(z,z') = -\sum_{i=1}^N \log \frac{e^{-|z_i - z'_i|^2/2}}{Z_i(z,z')}.L(z,z′)=−i=1∑N​logZi​(z,z′)e−∣zi​−zi′​∣2/2​.

Some features of this definition:

  • The "negatives" in ZiZ_iZi​ are only the zjz_jzj​ with j≠ij\neq ij=i, never the zj′z'_jzj′​.
  • Zi>0Z_i > 0Zi​>0 always, so the logarithm is of a positive number.
  • The linear-model loss is L(M)=L(Mx,Mx′)L(M) = \mathcal{L}(Mx, Mx')L(M)=L(Mx,Mx′) for M∈Rd×nM \in \mathbb{R}^{d\times n}M∈Rd×n, where (Mx)i=Mxi(Mx)_i = M x_i(Mx)i​=Mxi​ and (Mx′)i=Mxi′(Mx')_i = M x'_i(Mx′)i​=Mxi′​.

Derivatives. All partial derivatives below are one-variable derivatives at 000. By convention, such a derivative is taken to be 000 if the one-variable function is not differentiable there.

  • The matrix gradient ∇L(M)∈Rd×n\nabla L(M) \in \mathbb{R}^{d\times n}∇L(M)∈Rd×n has (a,b)(a,b)(a,b) entry dds∣s=0L(M+sEab)\frac{d}{ds}\big|_{s=0} L(M + s E_{ab})dsd​​s=0​L(M+sEab​), where EabE_{ab}Eab​ is the matrix unit.
  • For embeddings (z,z′)(z,z')(z,z′), gzi∈Rdg_{z_i}\in\mathbb{R}^dgzi​​∈Rd has ccc-th entry dds∣s=0L(z with zi replaced by zi+sec,  z′)\frac{d}{ds}\big|_{s=0}\mathcal{L}(z \text{ with } z_i \text{ replaced by } z_i + s e_c,\; z')dsd​​s=0​L(z with zi​ replaced by zi​+sec​,z′). Here ece_cec​ is the ccc-th standard basis vector, and all other zjz_jzj​ and all z′z'z′ are held fixed.
  • gzi′g_{z'_i}gzi′​​ is defined the same way, perturbing only zi′z'_izi′​. So zzz and z′z'z′ are treated as independent variables.

The matrix GGG. For M∈Rd×nM \in \mathbb{R}^{d\times n}M∈Rd×n, define

G(M)=∑i=1N(gzi xi⊤+gzi′ xi′⊤),G(M) = \sum_{i=1}^N \left( g_{z_i}\, x_i^{\top} + g_{z'_i}\, x_i'^{\top} \right),G(M)=i=1∑N​(gzi​​xi⊤​+gzi′​​xi′⊤​),

with the gradients evaluated at z=Mxz = Mxz=Mx and z′=Mx′z' = Mx'z′=Mx′.

Hypothesis. For every entry (a,b)(a,b)(a,b), the scalar function s↦W(s)abs \mapsto W(s)_{ab}s↦W(s)ab​ is differentiable at the single time ttt, with

dds∣s=tW(s)ab=−(∇L(W(t)))ab.\frac{d}{ds}\Big|_{s=t} W(s)_{ab} = -\big(\nabla L(W(t))\big)_{ab}.dsd​​s=t​W(s)ab​=−(∇L(W(t)))ab​.

Nothing is assumed about WWW at any other time.

Conclusion. For every entry (a,b)(a,b)(a,b), s↦W(s)abs\mapsto W(s)_{ab}s↦W(s)ab​ is differentiable at ttt, with

dds∣s=tW(s)ab=−(G(W(t)))ab.\frac{d}{ds}\Big|_{s=t} W(s)_{ab} = -\big(G(W(t))\big)_{ab}.dsd​​s=t​W(s)ab​=−(G(W(t)))ab​.

Derivatives are unique. So, given the hypothesis, the conclusion is equivalent to the matrix identity ∇L(W(t))=G(W(t))\nabla L(W(t)) = G(W(t))∇L(W(t))=G(W(t)) holding at the single matrix W(t)W(t)W(t).

Edge cases.

  • If d=0d = 0d=0 or n=0n = 0n=0, the matrices have no entries, and both hypothesis and conclusion are empty.
  • If N=0N = 0N=0, the loss is identically 000, and ∇L\nabla L∇L and GGG are both the zero matrix.
  • The hypothesis is satisfiable for any data, for example by W(s)=W0−(s−t) ∇L(W0)W(s) = W_0 - (s-t)\,\nabla L(W_0)W(s)=W0​−(s−t)∇L(W0​).
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