Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 4.4: the same-class loss is controlled by the intraclass deviation

Proved
ContrastiveUnsupervised.same_class_loss_le_deviation

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

contrastive-learninggeneralization-boundslatent-classesrademacher-complexityrepresentation-learning

There is an absolute constant c′>0c'>0c′>0 such that for every latent class model (ρ\rhoρ a distribution on a countable set of classes, Dc\mathcal D_cDc​ the class distributions), either loss (hinge or logistic), and every measurable bounded f:X→Rdf:\mathcal X\to\mathbb R^df:X→Rd,

Lun=(f)−1≤c′ s(f).L^=_{un}(f)-1\le c'\,s(f).Lun=​(f)−1≤c′s(f).

Here Lun=(f)=Ec∼ν, x,x+,x−∼Dc3 ℓ(f(x)⊤(f(x+)−f(x−)))L^=_{un}(f)=\mathbb E_{c\sim\nu,\ x,x^+,x^-\sim\mathcal D_c^3}\,\ell(f(x)^\top(f(x^+)-f(x^-)))Lun=​(f)=Ec∼ν, x,x+,x−∼Dc3​​ℓ(f(x)⊤(f(x+)−f(x−))) with ν(c)∝ρ(c)2\nu(c)\propto\rho(c)^2ν(c)∝ρ(c)2, and s(f)=Ec∼ν[∥Σ(f,c)∥2 Ex∼Dc∥f(x)∥]s(f)=\mathbb E_{c\sim\nu}\big[\sqrt{\|\Sigma(f,c)\|_2}\,\mathbb E_{x\sim\mathcal D_c}\|f(x)\|\big]s(f)=Ec∼ν​[∥Σ(f,c)∥2​​Ex∼Dc​​∥f(x)∥] is the intraclass deviation.

Formalization Note The constant c′c'c′ is universal, as in the paper's use of the lemma in Theorem 4.5.

Preamble
import Mathlib
import Definitions.Def_ContrastiveUnsupervised_Basic

open MeasureTheory Filter Topology

universe u v
Formal statement
namespace ContrastiveUnsupervised

theorem same_class_loss_le_deviation :
    ∃ c' : ℝ, 0 < c' ∧
      ∀ {X : Type u} [MeasurableSpace X] {C : Type v} [Countable C] {d : ℕ}
        (D : C → Measure X) (ρ : C → ℝ), IsLatentClassModel D ρ →
        ∀ (hinge : Bool) (f : X → Rep d) (R : ℝ), IsBoundedRep f R →
          unsupLossEq hinge D ρ f - 1 ≤ c' * intraclassDeviation D ρ f := by sorry

end ContrastiveUnsupervised
Source
Arora, Khandeparkar, Khodak, Plevrakis and Saunshi, A Theoretical Analysis of Contrastive Unsupervised Representation Learning, arXiv:1902.09229v1 (2019), Section 4.2, Lemma 4.4, eq. (9), p. 5; proof in Appendix A.1, p. 11
Read-back

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

The statement asserts that there is a single real constant c′>0c' > 0c′>0 such that the inequality below holds in every setting of the following kind:

  • XXX is any type of data points with a σ\sigmaσ-algebra.
  • CCC is any countable type of "latent classes".
  • d∈Nd \in \mathbb{N}d∈N is any dimension, including d=0d = 0d=0.
  • D=(Dc)c∈CD = (D_c)_{c \in C}D=(Dc​)c∈C​ assigns a measure DcD_cDc​ on XXX to each class.
  • ρ:C→R\rho : C \to \mathbb{R}ρ:C→R is a real-valued function on the classes.

The constant c′c'c′ is chosen once, before all of these, so it may not depend on XXX, CCC, ddd, DDD, ρ\rhoρ, the loss choice, fff or RRR.

Hypotheses. The pair (D,ρ)(D, \rho)(D,ρ) is required to be a latent class model:

  • every DcD_cDc​ is a probability measure;
  • ρ(c)≥0\rho(c) \ge 0ρ(c)≥0 for every ccc;
  • ρ\rhoρ is summable with sum exactly 111.

Then, for every Boolean switch selecting the loss ℓ\ellℓ (hinge or logistic), every map f:X→Rdf : X \to \mathbb{R}^df:X→Rd and every real RRR, the statement assumes that fff is measurable and ∥f(x)∥≤R\|f(x)\| \le R∥f(x)∥≤R for all x∈Xx \in Xx∈X (Euclidean norm).

Some consequences of these hypotheses:

  • CCC must be nonempty, since an empty sum cannot equal 111.
  • XXX must be nonempty, since a probability measure on an empty space cannot exist.
  • So the bound forces R≥0R \ge 0R≥0.
  • RRR itself does not appear in the conclusion; it only guarantees that fff is bounded.

The loss. With one negative sample, the scalar loss ℓ(v)\ell(v)ℓ(v) of a score v∈Rv \in \mathbb{R}v∈R is

ℓ(v)=max⁡{0, 1−v}(hinge),ℓ(v)=log⁡2 ⁣(1+e−v)(logistic).\ell(v) = \max\{0,\, 1 - v\} \quad \text{(hinge)}, \qquad \ell(v) = \log_2\!\left(1 + e^{-v}\right) \quad \text{(logistic)}.ℓ(v)=max{0,1−v}(hinge),ℓ(v)=log2​(1+e−v)(logistic).

Collision probability. Write τ=∑c∈Cρ(c)2\tau = \sum_{c \in C} \rho(c)^2τ=∑c∈C​ρ(c)2.

Same-class unsupervised loss. The quantity on the left is

Lun=(f)=1τ∑c∈Cρ(c)2 Ex, x+, x−∼Dc i.i.d.[ℓ(f(x)⊤(f(x+)−f(x−)))].L^{=}_{\mathrm{un}}(f) = \frac{1}{\tau} \sum_{c \in C} \rho(c)^2 \, \mathbb{E}_{x,\, x^+,\, x^- \sim D_c \text{ i.i.d.}}\Big[\ell\big(f(x)^\top (f(x^+) - f(x^-))\big)\Big].Lun=​(f)=τ1​c∈C∑​ρ(c)2Ex,x+,x−∼Dc​ i.i.d.​[ℓ(f(x)⊤(f(x+)−f(x−)))].

Here xxx, x+x^+x+ and the single negative sample x−x^-x− are all drawn independently from the same class distribution DcD_cDc​.

Intraclass deviation. The quantity on the right is

s(f)=1τ∑c∈Cρ(c)2 ∥Σ(f,c)∥2  Ex∼Dc∥f(x)∥,s(f) = \frac{1}{\tau} \sum_{c \in C} \rho(c)^2 \, \sqrt{\|\Sigma(f,c)\|_2}\; \mathbb{E}_{x \sim D_c}\|f(x)\|,s(f)=τ1​c∈C∑​ρ(c)2∥Σ(f,c)∥2​​Ex∼Dc​​∥f(x)∥,

built from the following pieces:

  • μc=Ex∼Dc[f(x)]∈Rd\mu_c = \mathbb{E}_{x \sim D_c}[f(x)] \in \mathbb{R}^dμc​=Ex∼Dc​​[f(x)]∈Rd is the class mean.
  • Σ(f,c)\Sigma(f,c)Σ(f,c) is the d×dd \times dd×d matrix with entries
Σ(f,c)ij=Ex∼Dc[(f(x)i−μc,i)(f(x)j−μc,j)],\Sigma(f,c)_{ij} = \mathbb{E}_{x \sim D_c}\big[(f(x)_i - \mu_{c,i})(f(x)_j - \mu_{c,j})\big],Σ(f,c)ij​=Ex∼Dc​​[(f(x)i​−μc,i​)(f(x)j​−μc,j​)],

that is, the covariance of f(x)f(x)f(x) under DcD_cDc​.

  • ∥⋅∥2\|\cdot\|_2∥⋅∥2​ is the spectral (operator) norm of a matrix acting on Euclidean Rd\mathbb{R}^dRd.

Conventions. The definitions use these default values in degenerate cases:

  • an expectation of a non-integrable function is taken to be 000;
  • a non-summable sum over CCC is taken to be 000;
  • division by 000 gives 000;
  • the square root of a negative number is 000.

Conclusion. Under all the hypotheses above,

Lun=(f)−1  ≤  c′⋅s(f).L^{=}_{\mathrm{un}}(f) - 1 \;\le\; c' \cdot s(f).Lun=​(f)−1≤c′⋅s(f).

Edge case d=0d = 0d=0. Here fff is identically 000, every score is 000, and ℓ(0)=1\ell(0) = 1ℓ(0)=1 for both losses. So the left side is 000 and s(f)=0s(f) = 0s(f)=0.

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