Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 4.3: the unsupervised loss bounds the mean classifier loss

Proved
ContrastiveUnsupervised.mean_classifier_loss_le_unsup_loss

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

contrastive-learninggeneralization-boundslatent-classesrademacher-complexityrepresentation-learning

Let C\mathcal CC be a countable set of latent classes with distribution ρ\rhoρ, let each class ccc have a data distribution Dc\mathcal D_cDc​, and let τ=∑cρ(c)2<1\tau=\sum_c\rho(c)^2<1τ=∑c​ρ(c)2<1 be the probability that two independent classes coincide. Let ℓ\ellℓ be the hinge or the logistic loss, and let f:X→Rdf:\mathcal X\to\mathbb R^df:X→Rd be measurable and bounded. Then, for binary tasks with uniform label distribution and one negative sample,

Lsupμ(f)≤11−τ(Lun(f)−τ).L^\mu_{sup}(f)\le\frac{1}{1-\tau}\big(L_{un}(f)-\tau\big).Lsupμ​(f)≤1−τ1​(Lun​(f)−τ).

The contrastive loss is therefore a surrogate for the average loss of the mean classifier.

Formalization Note The paper states the lemma for f∈Ff\in\mathcal Ff∈F, which only gives boundedness and measurability. Those are the hypotheses here. The hypothesis τ<1\tau<1τ<1 is implicit in the paper.

Preamble
import Mathlib
import Definitions.Def_ContrastiveUnsupervised_Basic

open MeasureTheory Filter Topology

universe u v
Formal statement
namespace ContrastiveUnsupervised

theorem mean_classifier_loss_le_unsup_loss {X : Type*} [MeasurableSpace X] {C : Type*}
    [Countable C] {d : ℕ} (D : C → Measure X) (ρ : C → ℝ) (hDρ : IsLatentClassModel D ρ)
    (hτ : collisionProb ρ < 1) (hinge : Bool) (f : X → Rep d) (R : ℝ) (hf : IsBoundedRep f R) :
    avgMeanSupLoss (stdLoss hinge) D ρ 1 f ≤
      (unsupLoss hinge D ρ 1 f - collisionProb ρ) / (1 - collisionProb ρ) := 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.1, Lemma 4.3, p. 4
Read-back

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

Setting and hypotheses. The statement is quantified over the following data:

  • a measurable space XXX (the data space);
  • a countable (finite or countably infinite) type CCC of latent classes;
  • a dimension d∈Nd \in \mathbb{N}d∈N, with d=0d = 0d=0 allowed;
  • a family (Dc)c∈C(D_c)_{c \in C}(Dc​)c∈C​ of measures on XXX;
  • a function ρ:C→R\rho : C \to \mathbb{R}ρ:C→R;
  • a Boolean flag selecting the loss ℓ\ellℓ;
  • a function f:X→Rdf : X \to \mathbb{R}^df:X→Rd, where Rd\mathbb{R}^dRd carries the Euclidean norm and inner product;
  • a real number RRR.

The hypotheses are:

  1. Latent class model. Every DcD_cDc​ is a probability measure, ρ(c)≥0\rho(c) \ge 0ρ(c)≥0 for all ccc, and ∑c∈Cρ(c)=1\sum_{c \in C} \rho(c) = 1∑c∈C​ρ(c)=1 as an unconditionally convergent sum.
  2. Collision probability. The collision probability τ:=∑c∈Cρ(c)2\tau := \sum_{c \in C} \rho(c)^2τ:=∑c∈C​ρ(c)2 satisfies τ<1\tau < 1τ<1, so ρ\rhoρ is not concentrated on a single class.
  3. Bounded representation. fff is measurable and ∥f(x)∥≤R\|f(x)\| \le R∥f(x)∥≤R for every x∈Xx \in Xx∈X.

The number RRR appears only in hypothesis 3, not in the conclusion. Since the DcD_cDc​ are probability measures and the ρ(c)\rho(c)ρ(c) sum to 111, the space XXX is nonempty, so hypothesis 3 forces R≥0R \ge 0R≥0.

The loss ℓ\ellℓ. The flag selects one of two losses of a single real score vvv:

  • the hinge loss ℓ(v)=max⁡{0, 1−v}\ell(v) = \max\{0,\, 1 - v\}ℓ(v)=max{0,1−v};
  • the logistic loss ℓ(v)=log⁡2(1+e−v)\ell(v) = \log_2(1 + e^{-v})ℓ(v)=log2​(1+e−v).

Class means. For each class ccc, the class mean is the Bochner integral

μc=∫Xf(x) dDc(x)∈Rd.\mu_c = \int_X f(x)\, dD_c(x) \in \mathbb{R}^d .μc​=∫X​f(x)dDc​(x)∈Rd.

Left-hand side: average mean-classifier loss on 2-way tasks. For an ordered pair of distinct classes a≠ba \ne ba=b, the task {a,b}\{a, b\}{a,b} has uniform labels (weight 12\tfrac1221​ each). Its loss under the mean classifier is

Lsup⁡μ({a,b},f)=12∫Xℓ(⟨μa−μb, f(x)⟩) dDa(x)+12∫Xℓ(⟨μb−μa, f(x)⟩) dDb(x).L^\mu_{\sup}(\{a,b\}, f) = \tfrac12 \int_X \ell\big(\langle \mu_a - \mu_b,\, f(x)\rangle\big)\, dD_a(x) + \tfrac12 \int_X \ell\big(\langle \mu_b - \mu_a,\, f(x)\rangle\big)\, dD_b(x).Lsupμ​({a,b},f)=21​∫X​ℓ(⟨μa​−μb​,f(x)⟩)dDa​(x)+21​∫X​ℓ(⟨μb​−μa​,f(x)⟩)dDb​(x).

The left-hand side averages this over ordered pairs of distinct classes:

Lsup⁡μ(f)=∑a≠bρ(a)ρ(b) Lsup⁡μ({a,b},f)∑a≠bρ(a)ρ(b).L^\mu_{\sup}(f) = \frac{\displaystyle\sum_{a \ne b} \rho(a)\rho(b)\, L^\mu_{\sup}(\{a,b\}, f)}{\displaystyle\sum_{a \ne b} \rho(a)\rho(b)} .Lsupμ​(f)=a=b∑​ρ(a)ρ(b)a=b∑​ρ(a)ρ(b)Lsupμ​({a,b},f)​.

Both sums run over ordered pairs (a,b)∈C2(a, b) \in C^2(a,b)∈C2 with a≠ba \ne ba=b. Under hypothesis 1, the denominator equals 1−τ1 - \tau1−τ, which is positive by hypothesis 2.

Right-hand side: contrastive loss with one negative sample. A training triple (x,x+,x−)(x, x^+, x^-)(x,x+,x−) is drawn from Dsim⊗DnegD_{\text{sim}} \otimes D_{\text{neg}}Dsim​⊗Dneg​, where

  • Dsim=∑cρ(c) Dc⊗DcD_{\text{sim}} = \sum_c \rho(c)\, D_c \otimes D_cDsim​=∑c​ρ(c)Dc​⊗Dc​ is the law of the similar pair (x,x+)(x, x^+)(x,x+);
  • Dneg=∑cρ(c) DcD_{\text{neg}} = \sum_c \rho(c)\, D_cDneg​=∑c​ρ(c)Dc​ is the law of the negative sample x−x^-x−, drawn independently of the pair.

The unsupervised loss is

Lun(f)=E[ℓ(⟨f(x), f(x+)−f(x−)⟩)].L_{\text{un}}(f) = \mathbb{E}\Big[\ell\big(\langle f(x),\, f(x^+) - f(x^-)\rangle\big)\Big].Lun​(f)=E[ℓ(⟨f(x),f(x+)−f(x−)⟩)].

Conclusion. Under hypotheses 1–3, for either choice of loss,

Lsup⁡μ(f)  ≤  Lun(f)−τ1−τ.L^\mu_{\sup}(f) \;\le\; \frac{L_{\text{un}}(f) - \tau}{1 - \tau}.Lsupμ​(f)≤1−τLun​(f)−τ​.

Conventions. All integrals are Bochner integrals, which take the value 000 when the integrand is not integrable. All infinite sums are unconditional, and an infinite sum is taken to be 000 when the family is not summable. Division by 000 would give 000, but the denominators here are positive under hypothesis 2.

Degenerate case. When d=0d = 0d=0, fff is the zero map and every score is 000. Every loss value is then ℓ(0)=1\ell(0) = 1ℓ(0)=1, for both the hinge and the logistic loss.

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