Theorem 1: converges to the cross-entropy between latent distributions
ProvedContrastiveInverts.infonce_limit_cross_entropy_sphereLet , , and let the latents lie on with uniform marginal and von Mises–Fisher conditional , . Let map injectively into the observation space , and let be differentiable on an open neighbourhood of . Let the encoder map into the sphere of radius , and let be measurable on . Then, for every ,
where is the surface area of and .
So, up to a constant, the InfoNCE objective with many negatives is the cross-entropy between the true conditional of positive pairs and the conditional that the encoder induces on the latents.
Formalization Note The loss is written on latents: a positive pair of observations is and the negatives are , so . The standing assumptions of Appendix A.1.1 (injectivity and differentiability of , model sphere of radius ) are included although the limit uses only the boundedness and measurability of . Measurability of is the standing convention that makes the expectations defined.
import Mathlib import Definitions.Def_ContrastiveInverts_Basic open MeasureTheory Filter Topology
namespace ContrastiveInverts
theorem infonce_limit_cross_entropy_sphere {N K : ℕ} (hN : 0 < N) (hNK : N ≤ K)
(τ κ r : ℝ) (hτ : 0 < τ) (hκ : 0 < κ) (hr : 0 < r)
(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 : Vec K → Vec N) (hf : ∀ x ∈ X, f x ∈ Metric.sphere (0 : Vec N) r)
(hmeas : Measurable (fun z : Sph N => f (g z))) :
Tendsto (fun M : ℕ => infoNCE κ τ (f ∘ g) M - Real.log M + Real.log (sphereArea N)) atTop
(𝓝 (sphCrossEntropy κ τ (f ∘ g))) := by sorry
end ContrastiveInvertsRead-back
What the Lean code literally says, in plain math · claude-opus-5-5
Setting and variables. Fix natural numbers and with . Write and for the Euclidean spaces with the standard inner product , and let be the unit sphere. When , consists of two points. Fix real numbers with
Let be an arbitrary set; no measurability or other regularity is assumed. Let and be functions satisfying the following:
- for every .
- is injective on .
- There is an open set with on which is (Fréchet) differentiable.
- for every . No condition is imposed on outside .
- The map from (with its Borel -algebra) to is measurable.
Put . Everything below evaluates only at points of , where .
Measures on the sphere. is the surface measure on . Concretely, it assigns to the value times the Lebesgue measure of the cone . For this is counting measure on the two points. The quantity is its total mass as a real number. The uniform probability measure is
Ground-truth conditional (von Mises–Fisher). For ,
Model conditional. For ,
Cross-entropy (the limit value). The expected cross-entropy is
Positive-pair law. is the measure on whose density with respect to is . Here is the first coordinate (the anchor) and is the second.
InfoNCE with negatives. For ,
The negatives are independent and uniform on . For the sum is empty and the integrand is .
Conventions. All integrals above follow two conventions:
- An integral is defined to be when its integrand is not integrable.
- is the real logarithm extended by and for . In particular at .
Conclusion. Under all the above hypotheses, the real sequence
converges as , and its limit equals .
The conclusion depends on and only through the values of on . The hypotheses on , the injectivity and differentiability of , and the condition do not appear in the conclusion itself.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.