Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 3.2: spectral contrastive loss

Proved
SpectralContrastive.spectral_contrastive_loss_eq_mf

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

cheeger-inequalitycontrastive-learninglinear-probeself-supervised-learningspectral-graph-theory

Consider the finite data model with augmentation graph weights wxx′w_{xx'}wxx′​ and degrees wx>0w_x>0wx​>0. For a feature map f:X→Rkf:\mathcal X\to\mathbb R^kf:X→Rk, let F∈RN×kF\in\mathbb R^{N\times k}F∈RN×k have rows ux=wx1/2f(x)u_x=w_x^{1/2}f(x)ux​=wx1/2​f(x). Then there is a constant ccc, depending only on the graph and not on fff, such that for every fff

Lmf(F)=∥A‾−FF⊤∥F2=L(f)+c,L(f)=−2 Ex,x+[f(x)⊤f(x+)]+Ex,x−[(f(x)⊤f(x−))2].\mathcal L_{\mathrm{mf}}(F)=\|\overline A-FF^\top\|_F^2=\mathcal L(f)+c,\qquad \mathcal L(f)=-2\,\mathbb E_{x,x^+}[f(x)^\top f(x^+)]+\mathbb E_{x,x^-}[(f(x)^\top f(x^-))^2].Lmf​(F)=∥A−FF⊤∥F2​=L(f)+c,L(f)=−2Ex,x+​[f(x)⊤f(x+)]+Ex,x−​[(f(x)⊤f(x−))2].

So minimizing the spectral contrastive loss is the same as computing a rank-kkk factorization of the normalized adjacency matrix.

Preamble
import Mathlib
import Definitions.Def_SpectralContrastive_Basic

open Matrix
Formal statement
namespace SpectralContrastive

theorem spectral_contrastive_loss_eq_mf {Xbar X : Type*} [Fintype Xbar] [Fintype X]
    [DecidableEq X] {k : ℕ} (P : Xbar → ℝ) (A : Xbar → X → ℝ) (hM : IsAugModel P A) :
    ∃ c : ℝ, ∀ f : X → Fin k → ℝ,
      mfLoss (augWeight P A) (fun x i => Real.sqrt (degree (augWeight P A) x) * f x i) =
        scLoss P A f + c := by sorry

end SpectralContrastive
Source
HaoChen, Wei, Gaidon and Ma, Provable Guarantees for Self-Supervised Deep Learning with Spectral Contrastive Loss, arXiv:2106.04156v7 (NeurIPS 2021), Section 3.2, Lemma 3.2, eqs. (4), (6), (7), p. 9; also eqs. (20)-(21), p. 30
Read-back

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

Let Xˉ\bar{\mathcal X}Xˉ and X\mathcal XX be arbitrary finite types, with decidable equality on X\mathcal XX, and let k≥0k \ge 0k≥0 be a natural number. The case k=0k = 0k=0 is allowed. Let P:Xˉ→RP : \bar{\mathcal X} \to \mathbb RP:Xˉ→R and A:Xˉ×X→RA : \bar{\mathcal X} \times \mathcal X \to \mathbb RA:Xˉ×X→R be arbitrary real-valued functions, written P(xˉ)P(\bar x)P(xˉ) and A(x∣xˉ)A(x \mid \bar x)A(x∣xˉ). They are subject to a single hypothesis: (P,A)(P, A)(P,A) is an augmentation model, meaning all of the following hold.

  • P(xˉ)≥0P(\bar x) \ge 0P(xˉ)≥0 for every xˉ\bar xxˉ, and ∑xˉP(xˉ)=1\sum_{\bar x} P(\bar x) = 1∑xˉ​P(xˉ)=1.
  • A(x∣xˉ)≥0A(x \mid \bar x) \ge 0A(x∣xˉ)≥0 for all xˉ,x\bar x, xxˉ,x, and ∑xA(x∣xˉ)=1\sum_{x} A(x \mid \bar x) = 1∑x​A(x∣xˉ)=1 for every xˉ∈Xˉ\bar x \in \bar{\mathcal X}xˉ∈Xˉ. This includes those xˉ\bar xxˉ with P(xˉ)=0P(\bar x) = 0P(xˉ)=0.
  • For every x∈Xx \in \mathcal Xx∈X there is some xˉ\bar xxˉ with P(xˉ)>0P(\bar x) > 0P(xˉ)>0 and A(x∣xˉ)>0A(x \mid \bar x) > 0A(x∣xˉ)>0.

These conditions force both Xˉ\bar{\mathcal X}Xˉ and X\mathcal XX to be nonempty. They are satisfiable, for example with one-point sets. PPP is not required to have full support.

From these data the statement builds the augmentation-graph weights and the degrees:

wxx′=∑xˉP(xˉ) A(x∣xˉ) A(x′∣xˉ),wx=∑x′wxx′.w_{xx'} = \sum_{\bar x} P(\bar x)\, A(x \mid \bar x)\, A(x' \mid \bar x), \qquad w_x = \sum_{x'} w_{xx'}.wxx′​=xˉ∑​P(xˉ)A(x∣xˉ)A(x′∣xˉ),wx​=x′∑​wxx′​.

It also builds the normalized adjacency matrix:

Aˉxx′=wxx′wx wx′.\bar A_{xx'} = \frac{w_{xx'}}{\sqrt{w_x\, w_{x'}}}.Aˉxx′​=wx​wx′​​wxx′​​.

Here division by 000 is taken to give 000, and ⋅\sqrt{\cdot}⋅​ of a negative number is taken to be 000. Under the hypotheses, however, every wxx′≥0w_{xx'} \ge 0wxx′​≥0 and every wx>0w_x > 0wx​>0.

For an embedding f:X→Rkf : \mathcal X \to \mathbb R^kf:X→Rk, write ⟨f(x),f(x′)⟩=∑i=1kf(x)if(x′)i\langle f(x), f(x')\rangle = \sum_{i=1}^k f(x)_i f(x')_i⟨f(x),f(x′)⟩=∑i=1k​f(x)i​f(x′)i​. Two losses are involved.

The matrix factorization loss is evaluated at the rescaled embedding F(x)=wx f(x)F(x) = \sqrt{w_x}\, f(x)F(x)=wx​​f(x):

Lmf(F)=∑x,x′∈X(Aˉxx′−wx wx′ ⟨f(x),f(x′)⟩)2.L_{\mathrm{mf}}(F) = \sum_{x, x' \in \mathcal X} \Big( \bar A_{xx'} - \sqrt{w_x}\,\sqrt{w_{x'}}\, \langle f(x), f(x')\rangle \Big)^2 .Lmf​(F)=x,x′∈X∑​(Aˉxx′​−wx​​wx′​​⟨f(x),f(x′)⟩)2.

The spectral contrastive loss of fff is

L(f)=−2∑xˉP(xˉ)∑x,x′A(x∣xˉ)A(x′∣xˉ) ⟨f(x),f(x′)⟩  +  ∑xˉ,xˉ′P(xˉ)P(xˉ′)∑x,x′A(x∣xˉ)A(x′∣xˉ′) ⟨f(x),f(x′)⟩2.L(f) = -2 \sum_{\bar x} P(\bar x) \sum_{x, x'} A(x \mid \bar x) A(x' \mid \bar x)\, \langle f(x), f(x')\rangle \;+\; \sum_{\bar x, \bar x'} P(\bar x) P(\bar x') \sum_{x, x'} A(x \mid \bar x) A(x' \mid \bar x')\, \langle f(x), f(x')\rangle^2 .L(f)=−2xˉ∑​P(xˉ)x,x′∑​A(x∣xˉ)A(x′∣xˉ)⟨f(x),f(x′)⟩+xˉ,xˉ′∑​P(xˉ)P(xˉ′)x,x′∑​A(x∣xˉ)A(x′∣xˉ′)⟨f(x),f(x′)⟩2.

The theorem asserts the following. Under the augmentation-model hypothesis, there exists a real constant ccc, depending only on PPP, AAA, the types, and kkk, such that for every f:X→Rkf : \mathcal X \to \mathbb R^kf:X→Rk:

Lmf(x↦wx f(x))=L(f)+c.L_{\mathrm{mf}}\big(x \mapsto \sqrt{w_x}\, f(x)\big) = L(f) + c .Lmf​(x↦wx​​f(x))=L(f)+c.

The quantifier order is ∃c ∀f\exists c\ \forall f∃c ∀f, so ccc does not depend on fff. The value of ccc is not specified; only its existence is asserted. When k=0k = 0k=0, every inner product is 000, and the statement holds trivially with c=∑x,x′Aˉxx′2c = \sum_{x,x'} \bar A_{xx'}^2c=∑x,x′​Aˉxx′2​.

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

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 23, 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