Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 5: minimizers of Lδ-contr\mathcal{L}_{\delta\text{-contr}}Lδ-contr​ recover the latents on a convex body up to an invertible affine map

Proved
ContrastiveInverts.delta_contrastive_identifies_affine

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

contrastive-learningidentifiabilityinfoncenonlinear-icavon-mises-fisher

Let ZZZ be a convex body in RN\mathbb{R}^NRN, N≤KN\le KN≤K, and τ>0\tau>0τ>0. Let δ\deltaδ be a metric induced by a norm, or a semi-metric j∘δ′j\circ\delta'j∘δ′ of such a metric as in Lemma 1. Let the marginal be uniform and the conditional be as in eq. (5), p(z~∣z)=Cp(z)−1e−δ(z~,z)p(\tilde z\mid z)=C_p(z)^{-1}e^{-\delta(\tilde z,z)}p(z~∣z)=Cp​(z)−1e−δ(z~,z). Let the mixing function ggg be differentiable and injective on ZZZ with g(Z)⊆X⊆RKg(Z)\subseteq\mathcal X\subseteq\mathbb{R}^Kg(Z)⊆X⊆RK.

Let F\mathcal FF be a class of encoders f:X→Zf:\mathcal X\to Zf:X→Z with f∘gf\circ gf∘g measurable on ZZZ. Assume the form of qh(z~∣z)=Cq(z)−1e−δ(h(z~),h(z))/τq_h(\tilde z\mid z)=C_q(z)^{-1}e^{-\delta(h(\tilde z),h(z))/\tau}qh​(z~∣z)=Cq​(z)−1e−δ(h(z~),h(z))/τ 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. If f∈Ff\in\mathcal Ff∈F is differentiable on X\mathcal XX and minimises lim⁡M→∞(Lδ-contr(f;τ,M)−log⁡M)\lim_{M\to\infty}(\mathcal{L}_{\delta\text{-contr}}(f;\tau,M)-\log M)limM→∞​(Lδ-contr​(f;τ,M)−logM) over F\mathcal FF, then h=f∘gh=f\circ gh=f∘g is invertible and affine: there is an invertible affine map AAA of RN\mathbb{R}^NRN with

f(g(z))=A(z)for all z∈Z.f(g(z))=A(z)\qquad\text{for all }z\in Z.f(g(z))=A(z)for all z∈Z.

So the latent sources are recovered up to an affine transformation.

Formalization Note "Invertible" is stated as invertibility of the affine map AAA on RN\mathbb{R}^NRN. The paper's h=f∘g:Z→Zh=f\circ g:Z\to Zh=f∘g:Z→Z is encoded by encoders with values in ZZZ.

Preamble
import Mathlib
import Definitions.Def_ContrastiveInverts_Basic

open MeasureTheory Filter Topology
Formal statement
namespace ContrastiveInverts

theorem delta_contrastive_identifies_affine {N K : ℕ} (hNK : N ≤ K) (Z : Set (Vec N))
    (hZ : IsConvexBody Z) (τ : ℝ) (hτ : 0 < τ)
    (δ : Vec N → Vec N → ℝ) (hδ : IsNormSemimetric δ)
    (X : Set (Vec K)) (g : Vec N → Vec K) (hgX : ∀ z ∈ Z, g z ∈ X) (hg_inj : Set.InjOn g Z)
    (hg_diff : DifferentiableOn ℝ g Z)
    (F : Set (Vec K → Vec N))
    (hF : ∀ f' ∈ F, (∀ x ∈ X, f' x ∈ Z) ∧ AEMeasurable (f' ∘ g) (volume.restrict Z))
    (hflex : ∃ f₀ ∈ F, ∀ z ∈ Z, ∀ z' ∈ Z,
      bodyModelCond τ δ Z (f₀ ∘ g) z z' = expCond 1 δ Z z z')
    (f : Vec K → Vec N) (hfF : f ∈ F) (hf_diff : DifferentiableOn ℝ f X)
    (hmin : ∀ f' ∈ F,
      deltaInfoNCELimit 1 δ τ δ Z (f ∘ g) ≤ deltaInfoNCELimit 1 δ τ δ Z (f' ∘ g)) :
    ∃ A : Vec N ≃ᵃ[ℝ] Vec N, ∀ z ∈ Z, f (g z) = A 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.3, Theorem 5, eqs. (5)-(7), p. 5; restated with proof in Appendix A.2.4, Theorem 5, p. 18; standing assumptions of Appendix A.2.1, p. 15
Read-back

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

Setting. Fix natural numbers N≤KN \le KN≤K (N=0N = 0N=0 is not excluded). Write RN\mathbb{R}^NRN and RK\mathbb{R}^KRK for the Euclidean spaces with the standard inner product, and vol⁡\operatorname{vol}vol for Lebesgue measure on RN\mathbb{R}^NRN. The data of the statement are the following.

  • Latent space. Z⊆RNZ \subseteq \mathbb{R}^NZ⊆RN is a convex body: convex, compact, and with nonempty interior.
  • Temperature. τ\tauτ is a real number with τ>0\tau > 0τ>0.
  • Similarity. δ:RN×RN→R\delta : \mathbb{R}^N \times \mathbb{R}^N \to \mathbb{R}δ:RN×RN→R is a norm-induced semimetric. There exist ν:RN→R\nu : \mathbb{R}^N \to \mathbb{R}ν:RN→R and j:R→Rj : \mathbb{R} \to \mathbb{R}j:R→R such that δ(a,b)=j(ν(a−b))\delta(a,b) = j\big(\nu(a-b)\big)δ(a,b)=j(ν(a−b)) for all a,ba, ba,b, where:
    • ν\nuν is a norm (not necessarily Euclidean): ν(x)=0  ⟺  x=0\nu(x) = 0 \iff x = 0ν(x)=0⟺x=0, ν(cx)=∣c∣ ν(x)\nu(cx) = |c|\,\nu(x)ν(cx)=∣c∣ν(x), and ν(x+y)≤ν(x)+ν(y)\nu(x+y) \le \nu(x) + \nu(y)ν(x+y)≤ν(x)+ν(y);
    • jjj restricts to a bijection of [0,∞)[0,\infty)[0,∞) onto itself, is continuous on [0,∞)[0,\infty)[0,∞), and satisfies j(0)=0j(0) = 0j(0)=0. Its values off [0,∞)[0,\infty)[0,∞) are unconstrained.
    • In particular, δ≥0\delta \ge 0δ≥0 and δ(a,b)=δ(b,a)\delta(a,b) = \delta(b,a)δ(a,b)=δ(b,a).
  • Generator. X⊆RKX \subseteq \mathbb{R}^KX⊆RK is a set and g:RN→RKg : \mathbb{R}^N \to \mathbb{R}^Kg:RN→RK is a map such that:
    • g(z)∈Xg(z) \in Xg(z)∈X for every z∈Zz \in Zz∈Z;
    • ggg is injective on ZZZ;
    • ggg is differentiable on ZZZ, in the sense of differentiability within ZZZ at each point of ZZZ.
    • XXX is not required to equal g(Z)g(Z)g(Z).
  • Model class. FFF is a set of maps RK→RN\mathbb{R}^K \to \mathbb{R}^NRK→RN. Every f′∈Ff' \in Ff′∈F maps XXX into ZZZ, and f′∘gf' \circ gf′∘g is almost-everywhere measurable with respect to Lebesgue measure restricted to ZZZ.
  • Learned encoder. f:RK→RNf : \mathbb{R}^K \to \mathbb{R}^Nf:RK→RN is an element of FFF that is differentiable on XXX.

Auxiliary objects. Write μZ=vol⁡(Z)−1 vol⁡∣Z\mu_Z = \operatorname{vol}(Z)^{-1}\,\operatorname{vol}|_ZμZ​=vol(Z)−1vol∣Z​ for the uniform probability measure on ZZZ. For h:RN→RNh : \mathbb{R}^N \to \mathbb{R}^Nh:RN→RN and z,z~∈RNz, \tilde z \in \mathbb{R}^Nz,z~∈RN, define the following.

  • The ground-truth conditional, with rate λ=1\lambda = 1λ=1:
p(z~∣z)=e−δ(z~,z)∫Ze−δ(z,w) dw.p(\tilde z \mid z) = \frac{e^{-\delta(\tilde z, z)}}{\int_Z e^{-\delta(z, w)}\,dw}.p(z~∣z)=∫Z​e−δ(z,w)dwe−δ(z~,z)​.
  • The model conditional:
qh(z~∣z)=e−δ(h(z~),h(z))/τ∫Ze−δ(h(w),h(z))/τ dw.q_h(\tilde z \mid z) = \frac{e^{-\delta(h(\tilde z), h(z))/\tau}}{\int_Z e^{-\delta(h(w), h(z))/\tau}\,dw}.qh​(z~∣z)=∫Z​e−δ(h(w),h(z))/τdwe−δ(h(z~),h(z))/τ​.

All integrals are Bochner integrals. A non-integrable integrand gives the value 000, and division by 000 gives 000.

Next, define the positive-pair law. PPP is the measure on RN×RN\mathbb{R}^N \times \mathbb{R}^NRN×RN with density max⁡(p(z~∣z),0)\max\big(p(\tilde z \mid z), 0\big)max(p(z~∣z),0) with respect to μZ⊗vol⁡∣Z\mu_Z \otimes \operatorname{vol}|_ZμZ​⊗vol∣Z​.

For M∈NM \in \mathbb{N}M∈N, the contrastive loss is

L(h;M)=∫−log⁡e−δ(h(z),h(z~))/τe−δ(h(z),h(z~))/τ+∑i=1Me−δ(h(z),h(zi−))/τ  d(P⊗μZ⊗M)((z,z~),(z1−,…,zM−)).\mathcal{L}(h; M) = \int -\log \frac{e^{-\delta(h(z), h(\tilde z))/\tau}}{e^{-\delta(h(z), h(\tilde z))/\tau} + \sum_{i=1}^{M} e^{-\delta(h(z), h(z_i^-))/\tau}}\; d\big(P \otimes \mu_Z^{\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(P⊗μZ⊗M​)((z,z~),(z1−​,…,zM−​)).

Here (z,z~)∼P(z, \tilde z) \sim P(z,z~)∼P and z1−,…,zM−z_1^-, \dots, z_M^-z1−​,…,zM−​ are independent and uniform on ZZZ. This integral is again 000 if the integrand is not integrable.

The limiting objective is

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),

with the convention log⁡0=0\log 0 = 0log0=0. If this limit does not exist, L∞(h)\mathcal{L}_\infty(h)L∞​(h) is an unspecified real number.

Hypotheses on the model class and on fff.

  • (Realizability.) There exists f0∈Ff_0 \in Ff0​∈F such that, for all z,z′∈Zz, z' \in Zz,z′∈Z,
qf0∘g(z′∣z)=p(z′∣z),q_{f_0 \circ g}(z' \mid z) = p(z' \mid z),qf0​∘g​(z′∣z)=p(z′∣z),

as an equality of real numbers. The same δ\deltaδ appears in both conditionals; the model side carries τ\tauτ and the ground-truth side carries λ=1\lambda = 1λ=1.

  • (Minimality.) For every f′∈Ff' \in Ff′∈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).

Conclusion. There exists an invertible affine map A:RN→RNA : \mathbb{R}^N \to \mathbb{R}^NA:RN→RN, that is, A(z)=Lz+bA(z) = Lz + bA(z)=Lz+b with LLL an invertible linear map and b∈RNb \in \mathbb{R}^Nb∈RN, such that

f(g(z))=A(z)for every z∈Z.f(g(z)) = A(z) \quad \text{for every } z \in Z.f(g(z))=A(z)for every z∈Z.
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