Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 2: minimizers of the InfoNCE loss invert the generative process on the hypersphere up to an orthogonal transformation and scaling

Proved
ContrastiveInverts.contrastive_learning_inverts_on_sphere

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

contrastive-learningidentifiabilityinfoncenonlinear-icavon-mises-fisher

Let N≥1N\ge1N≥1, N≤KN\le KN≤K, τ>0\tau>0τ>0 and κ>0\kappa>0κ>0. Let the latents lie on Z=SN−1Z=\mathbb{S}^{N-1}Z=SN−1 with uniform marginal and von Mises–Fisher conditional p(z~∣z)=Cp−1eκz⊤z~p(\tilde z\mid z)=C_p^{-1}e^{\kappa z^\top\tilde z}p(z~∣z)=Cp−1​eκz⊤z~. Let the mixing function ggg map ZZZ injectively into X⊆RK\mathcal{X}\subseteq\mathbb{R}^KX⊆RK and be differentiable on an open neighbourhood of ZZZ.

Let F\mathcal FF be a class of encoders f:X→SτκN−1f:\mathcal{X}\to\mathbb{S}^{N-1}_{\sqrt{\tau\kappa}}f:X→Sτκ​N−1​, each with f∘gf\circ gf∘g measurable on ZZZ. Assume the model's form of qhq_hqh​ matches ppp: some f0∈Ff_0\in\mathcal Ff0​∈F has qf0∘g=pq_{f_0\circ g}=pqf0​∘g​=p on Z×ZZ\times ZZ×Z. Let f∈Ff\in\mathcal Ff∈F be differentiable on X\mathcal XX, with h=f∘gh=f\circ gh=f∘g differentiable on an open neighbourhood of ZZZ, and let fff minimise the contrastive loss for M→∞M\to\inftyM→∞ over F\mathcal FF:

lim⁡M→∞(Lcontr(f;τ,M)−log⁡M)≤lim⁡M→∞(Lcontr(f′;τ,M)−log⁡M)for all f′∈F.\lim_{M\to\infty}\big(\mathcal{L}_{\mathsf{contr}}(f;\tau,M)-\log M\big)\le\lim_{M\to\infty}\big(\mathcal{L}_{\mathsf{contr}}(f';\tau,M)-\log M\big)\quad\text{for all }f'\in\mathcal F.M→∞lim​(Lcontr​(f;τ,M)−logM)≤M→∞lim​(Lcontr​(f′;τ,M)−logM)for all f′∈F.

Then hhh is linear on ZZZ: there is an orthogonal map UUU of RN\mathbb{R}^NRN with

f(g(z))=τκ  Uzfor all z∈Z.f(g(z))=\sqrt{\tau\kappa}\;Uz\qquad\text{for all }z\in Z.f(g(z))=τκ​Uzfor all z∈Z.

So fff recovers the latent sources up to an orthogonal linear transformation and the constant scaling factor τκ\sqrt{\tau\kappa}τκ​.

Formalization Note "The assumed form of qhq_hqh​ matches that of ppp" is encoded as in Proposition 1: the encoders map into the sphere of radius τκ\sqrt{\tau\kappa}τκ​, and the class contains an encoder whose qhq_hqh​ equals ppp. Minimisation is over this class, whose members are required to give measurable hhh, so that every objective in the comparison is defined. Following Section 3, ggg is only required to map ZZZ into X\mathcal XX.

Preamble
import Mathlib
import Definitions.Def_ContrastiveInverts_Basic

open MeasureTheory Filter Topology
Formal statement
namespace ContrastiveInverts

theorem contrastive_learning_inverts_on_sphere {N K : ℕ} (hN : 0 < N) (hNK : N ≤ K)
    (τ κ : ℝ) (hτ : 0 < τ) (hκ : 0 < κ)
    (X : Set (Vec K)) (g : Vec N → Vec K) (hgX : ∀ z ∈ Metric.sphere (0 : Vec N) 1, g z ∈ X)
    (hg_inj : Set.InjOn g (Metric.sphere (0 : Vec N) 1))
    (hg_diff : ∃ U : Set (Vec N), IsOpen U ∧ Metric.sphere (0 : Vec N) 1 ⊆ U ∧
      DifferentiableOn ℝ g U)
    (F : Set (Vec K → Vec N))
    (hF : ∀ f' ∈ F, (∀ x ∈ X, f' x ∈ Metric.sphere (0 : Vec N) (Real.sqrt (τ * κ))) ∧
      Measurable (fun z : Sph N => f' (g z)))
    (hflex : ∃ f₀ ∈ F, ∀ z ∈ Metric.sphere (0 : Vec N) 1, ∀ z' ∈ Metric.sphere (0 : Vec N) 1,
      sphModelCond τ (f₀ ∘ g) z z' = vmfCond N κ z z')
    (f : Vec K → Vec N) (hfF : f ∈ F) (hf_diff : DifferentiableOn ℝ f X)
    (hh_diff : ∃ U : Set (Vec N), IsOpen U ∧ Metric.sphere (0 : Vec N) 1 ⊆ U ∧
      DifferentiableOn ℝ (f ∘ g) U)
    (hmin : ∀ f' ∈ F, infoNCELimit κ τ (f ∘ g) ≤ infoNCELimit κ τ (f' ∘ g)) :
    ∃ U : Vec N ≃ₗᵢ[ℝ] Vec N, ∀ z ∈ Metric.sphere (0 : Vec N) 1,
      f (g z) = Real.sqrt (τ * κ) • U z := by sorry

end ContrastiveInverts
Source
Zimmermann, Sharma, Schneider, Bethge and Brendel, Contrastive Learning Inverts the Data Generating Process, ICML 2021, arXiv:2102.08850v4, Section 3.2, Theorem 2, p. 4; restated with proof in Appendix A.1.2, Theorem 2, p. 15; standing assumptions of Appendix A.1.1, p. 13
Read-back

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

Setting. Fix natural numbers N,KN, KN,K with 0<N≤K0 < N \le K0<N≤K, and real numbers τ>0\tau > 0τ>0, κ>0\kappa > 0κ>0. Write:

  • RN\mathbb{R}^NRN and RK\mathbb{R}^KRK for Euclidean spaces with the standard inner product ⟨⋅,⋅⟩\langle \cdot,\cdot\rangle⟨⋅,⋅⟩;
  • SN−1={z∈RN:∥z∥=1}S^{N-1} = \{z \in \mathbb{R}^N : \|z\| = 1\}SN−1={z∈RN:∥z∥=1} for the unit sphere;
  • σ\sigmaσ for the measure on SN−1S^{N-1}SN−1 induced from Lebesgue measure on RN\mathbb{R}^NRN by the cone construction. For a set AAA it is σ(A)=N⋅Leb{rx:x∈A, 0<r<1}\sigma(A) = N \cdot \mathrm{Leb}\{ r x : x \in A,\ 0 < r < 1\}σ(A)=N⋅Leb{rx:x∈A, 0<r<1}. This is the surface measure; for N=1N = 1N=1, where S0={±1}S^0 = \{\pm 1\}S0={±1}, it gives mass 111 to each point.
  • u=σ(SN−1)−1 σu = \sigma(S^{N-1})^{-1}\,\sigmau=σ(SN−1)−1σ for the normalized uniform measure on SN−1S^{N-1}SN−1.

Hypotheses. The theorem is given the following data and assumptions:

  • An arbitrary set X⊆RKX \subseteq \mathbb{R}^KX⊆RK, with no openness, measurability or other condition.
  • A map g:RN→RKg : \mathbb{R}^N \to \mathbb{R}^Kg:RN→RK such that:
    • g(z)∈Xg(z) \in Xg(z)∈X for every z∈SN−1z \in S^{N-1}z∈SN−1;
    • ggg is injective on SN−1S^{N-1}SN−1;
    • ggg is differentiable at every point of some open set U⊇SN−1U \supseteq S^{N-1}U⊇SN−1.
  • A set F\mathcal{F}F of maps RK→RN\mathbb{R}^K \to \mathbb{R}^NRK→RN such that every f′∈Ff' \in \mathcal{F}f′∈F:
    • maps every point of XXX into the sphere of radius τκ\sqrt{\tau\kappa}τκ​ about 000 in RN\mathbb{R}^NRN;
    • makes z↦f′(g(z))z \mapsto f'(g(z))z↦f′(g(z)) measurable as a function on SN−1S^{N-1}SN−1.
  • Realizability: there exists f0∈Ff_0 \in \mathcal{F}f0​∈F such that, with h0=f0∘gh_0 = f_0 \circ gh0​=f0​∘g,
qh0(z′∣z)=p(z′∣z)for all z,z′∈SN−1.q_{h_0}(z' \mid z) = p(z' \mid z) \quad \text{for all } z, z' \in S^{N-1}.qh0​​(z′∣z)=p(z′∣z)for all z,z′∈SN−1.

The two conditionals are defined by

qh(z′∣z)=e⟨h(z′),h(z)⟩/τ∫SN−1e⟨h(w),h(z)⟩/τ dσ(w),p(z′∣z)=eκ⟨z,z′⟩∫SN−1eκ⟨z,w⟩ dσ(w).q_h(z' \mid z) = \frac{e^{\langle h(z'), h(z)\rangle/\tau}}{\int_{S^{N-1}} e^{\langle h(w), h(z)\rangle/\tau}\, d\sigma(w)}, \qquad p(z' \mid z) = \frac{e^{\kappa \langle z, z'\rangle}}{\int_{S^{N-1}} e^{\kappa\langle z, w\rangle}\, d\sigma(w)}.qh​(z′∣z)=∫SN−1​e⟨h(w),h(z)⟩/τdσ(w)e⟨h(z′),h(z)⟩/τ​,p(z′∣z)=∫SN−1​eκ⟨z,w⟩dσ(w)eκ⟨z,z′⟩​.
  • A map f∈Ff \in \mathcal{F}f∈F such that:
    • fff is differentiable on XXX in the relative sense (within XXX at each point of XXX);
    • h:=f∘gh := f \circ gh:=f∘g is differentiable at every point of some open set containing SN−1S^{N-1}SN−1.
  • Minimality: for every f′∈Ff' \in \mathcal{F}f′∈F,
L∞(f∘g)≤L∞(f′∘g).\mathcal{L}_\infty(f \circ g) \le \mathcal{L}_\infty(f' \circ g).L∞​(f∘g)≤L∞​(f′∘g).

The objective L∞\mathcal{L}_\inftyL∞​. For h:RN→RNh : \mathbb{R}^N \to \mathbb{R}^Nh:RN→RN and M∈NM \in \mathbb{N}M∈N, define

L(h;M)=∫−log⁡e⟨h(z),h(z~)⟩/τe⟨h(z),h(z~)⟩/τ+∑i=1Me⟨h(z),h(zi−)⟩/τ  d(Ppos⊗u⊗M)((z,z~),(z1−,…,zM−)).\mathcal{L}(h; M) = \int -\log \frac{e^{\langle h(z), h(\tilde z)\rangle/\tau}}{e^{\langle h(z), h(\tilde z)\rangle/\tau} + \sum_{i=1}^{M} e^{\langle h(z), h(z_i^-)\rangle/\tau}} \; d\big(P_{\mathrm{pos}} \otimes u^{\otimes M}\big)\big((z,\tilde z),(z_1^-,\dots,z_M^-)\big).L(h;M)=∫−loge⟨h(z),h(z~)⟩/τ+∑i=1M​e⟨h(z),h(zi−​)⟩/τe⟨h(z),h(z~)⟩/τ​d(Ppos​⊗u⊗M)((z,z~),(z1−​,…,zM−​)).

The ingredients are:

  • PposP_{\mathrm{pos}}Ppos​ is the measure on SN−1×SN−1S^{N-1} \times S^{N-1}SN−1×SN−1 with density p(z~∣z)p(\tilde z \mid z)p(z~∣z) with respect to u⊗σu \otimes \sigmau⊗σ.
  • The MMM negatives zi−z_i^-zi−​ are independent and uniform.
  • The integral is a Bochner integral, so it is defined to be 000 if the integrand is not integrable.

Then

L∞(h)=lim⁡M→∞(L(h;M)−log⁡M),\mathcal{L}_\infty(h) = \lim_{M \to \infty} \big(\mathcal{L}(h; M) - \log M\big),L∞​(h)=M→∞lim​(L(h;M)−logM),

taken over natural numbers MMM, with the convention log⁡0=0\log 0 = 0log0=0. If this sequence does not converge, L∞(h)\mathcal{L}_\infty(h)L∞​(h) is an unspecified junk value rather than "undefined". In that case the minimality hypothesis compares such junk values.

Minimality is required only against competitors in F\mathcal{F}F, and only in terms of L∞\mathcal{L}_\inftyL∞​.

Conclusion. There exists a linear isometric automorphism UUU of RN\mathbb{R}^NRN, that is, an orthogonal map (rotations and reflections are both allowed), such that

f(g(z))=τκ  Uzfor every z∈SN−1.f(g(z)) = \sqrt{\tau\kappa}\; U z \quad \text{for every } z \in S^{N-1}.f(g(z))=τκ​Uzfor every z∈SN−1.

Nothing is asserted about f∘gf \circ gf∘g off the unit sphere, or about fff off g(SN−1)g(S^{N-1})g(SN−1).

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