Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proposition 6.2: blocks of similar points give a tighter surrogate

Proved
ContrastiveUnsupervised.block_loss_sandwich

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ρ, τ=∑cρ(c)2<1\tau=\sum_c\rho(c)^2<1τ=∑c​ρ(c)2<1, let ℓ\ellℓ be the hinge or logistic loss, let b≥1b\ge1b≥1, and let f:X→Rdf:\mathcal X\to\mathbb R^df:X→Rd be measurable and bounded. With the block loss

Lunblock(f)=E[ℓ(f(x)⊤(∑if(xi+)b−∑if(xi−)b))],L^{block}_{un}(f)=\mathbb E\Big[\ell\Big(f(x)^\top\Big(\frac{\sum_if(x_i^+)}{b}-\frac{\sum_if(x_i^-)}{b}\Big)\Big)\Big],Lunblock​(f)=E[ℓ(f(x)⊤(b∑i​f(xi+​)​−b∑i​f(xi−​)​))],

where x,x1+,…,xb+x,x_1^+,\dots,x_b^+x,x1+​,…,xb+​ are i.i.d. from Dc+\mathcal D_{c^+}Dc+​, x1−,…,xb−x_1^-,\dots,x_b^-x1−​,…,xb−​ are i.i.d. from Dc−\mathcal D_{c^-}Dc−​, and c+,c−∼ρ2c^+,c^-\sim\rho^2c+,c−∼ρ2,

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

Here LsupL_{sup}Lsup​ is the average binary supervised loss and LunL_{un}Lun​ uses one negative sample. Averaging over blocks gives a tighter surrogate than single pairs.

Formalization Note The block size b≥1b\ge1b≥1 and τ<1\tau<1τ<1 are implicit in the paper.

Preamble
import Mathlib
import Definitions.Def_ContrastiveUnsupervised_Basic

open MeasureTheory Filter Topology

universe u v
Formal statement
namespace ContrastiveUnsupervised

theorem block_loss_sandwich {X : Type*} [MeasurableSpace X] {C : Type*} [Countable C] {d : ℕ}
    (D : C → Measure X) (ρ : C → ℝ) (hDρ : IsLatentClassModel D ρ) (hτ : collisionProb ρ < 1)
    (hinge : Bool) (b : ℕ) (hb : 1 ≤ b) (f : X → Rep d) (R : ℝ) (hf : IsBoundedRep f R) :
    avgSupLoss (stdLoss hinge) D ρ 1 f ≤
        1 / (1 - collisionProb ρ) * (blockUnsupLoss hinge D ρ b f - collisionProb ρ) ∧
      1 / (1 - collisionProb ρ) * (blockUnsupLoss hinge D ρ b f - collisionProb ρ) ≤
        1 / (1 - collisionProb ρ) * (unsupLoss hinge D ρ 1 f - 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 6.3, Proposition 6.2, eq. (12), p. 7; proof in Appendix A.4, p. 13
Read-back

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

Setting. The statement involves:

  • a measurable space XXX (the data space);
  • a countable type CCC (the latent classes);
  • a dimension d∈Nd \in \mathbb Nd∈N, with representations in Rd\mathbb R^dRd carrying the Euclidean norm and inner product;
  • 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 switch selecting the loss;
  • a natural number bbb;
  • a function f:X→Rdf : X \to \mathbb R^df:X→Rd;
  • a real number RRR.

Hypotheses.

  1. Every DcD_cDc​ is a probability measure, ρ(c)≥0\rho(c) \ge 0ρ(c)≥0 for all ccc, and ∑cρ(c)=1\sum_{c} \rho(c) = 1∑c​ρ(c)=1 (so ρ\rhoρ is a probability distribution on CCC).
  2. The collision probability τ:=∑c∈Cρ(c)2\tau := \sum_{c\in C} \rho(c)^2τ:=∑c∈C​ρ(c)2 satisfies τ<1\tau < 1τ<1. Equivalently, ρ\rhoρ is not concentrated on a single class.
  3. b≥1b \ge 1b≥1.
  4. 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 nowhere else, so this simply requires fff to be bounded and measurable.

The loss ℓ\ellℓ. It acts on a scalar vvv (or on a family of scalars indexed by a single "other" index). If the switch is set to hinge, ℓ(v)=max⁡{0, 1−v}\ell(v) = \max\{0,\, 1 - v\}ℓ(v)=max{0,1−v}. Otherwise ℓ\ellℓ is the logistic loss ℓ(v)=log⁡2(1+e−v)\ell(v) = \log_2(1 + e^{-v})ℓ(v)=log2​(1+e−v).

Throughout, an integral of a non-integrable function is taken to be 000, and an infinite sum over classes that does not converge is taken to be 000.

Quantity 1: the average supervised loss on 2-way tasks. It is defined as

Lsup(f)=∑(c1,c2)∈C2, c1≠c2ρ(c1)ρ(c2) Lsup({c1,c2},f)∑(c1,c2)∈C2, c1≠c2ρ(c1)ρ(c2).L_{\mathrm{sup}}(f) = \frac{\sum_{(c_1,c_2)\in C^2,\ c_1\ne c_2} \rho(c_1)\rho(c_2)\, L_{\mathrm{sup}}(\{c_1,c_2\}, f)}{\sum_{(c_1,c_2)\in C^2,\ c_1\ne c_2} \rho(c_1)\rho(c_2)}.Lsup​(f)=∑(c1​,c2​)∈C2, c1​=c2​​ρ(c1​)ρ(c2​)∑(c1​,c2​)∈C2, c1​=c2​​ρ(c1​)ρ(c2​)Lsup​({c1​,c2​},f)​.

The sums run over ordered pairs of distinct classes. The supervised loss of a task T={c1,c2}T = \{c_1, c_2\}T={c1​,c2​} is

Lsup(T,f)=inf⁡W:C→Rd ∑c∈T12∫Xℓ(⟨Wc,f(x)⟩−⟨Wc′,f(x)⟩) dDc(x).L_{\mathrm{sup}}(T, f) = \inf_{W : C \to \mathbb R^d}\ \sum_{c\in T} \tfrac12 \int_X \ell\big(\langle W_c, f(x)\rangle - \langle W_{c'}, f(x)\rangle\big)\, dD_c(x).Lsup​(T,f)=W:C→Rdinf​ c∈T∑​21​∫X​ℓ(⟨Wc​,f(x)⟩−⟨Wc′​,f(x)⟩)dDc​(x).

Here:

  • c′c'c′ denotes the other element of TTT;
  • 12\tfrac1221​ is the uniform label weight 1/∣T∣1/|T|1/∣T∣;
  • the infimum is over all assignments of a vector Wc∈RdW_c \in \mathbb R^dWc​∈Rd to each class, i.e. over all linear classifiers.

Quantity 2: the block contrastive loss. It is defined as

Lunblock(f)=∑c+∈C∑c−∈Cρ(c+)ρ(c−) E[ℓ(⟨f(x), 1b∑i=1bf(xi+)−1b∑i=1bf(xi−)⟩)].L^{\mathrm{block}}_{\mathrm{un}}(f) = \sum_{c^+\in C}\sum_{c^-\in C} \rho(c^+)\rho(c^-)\ \mathbb E\Big[\ell\Big(\Big\langle f(x),\ \tfrac1b\sum_{i=1}^b f(x^+_i) - \tfrac1b\sum_{i=1}^b f(x^-_i)\Big\rangle\Big)\Big].Lunblock​(f)=c+∈C∑​c−∈C∑​ρ(c+)ρ(c−) E[ℓ(⟨f(x), b1​i=1∑b​f(xi+​)−b1​i=1∑b​f(xi−​)⟩)].

The expectation is over independent samples x,x1+,…,xb+∼Dc+x, x^+_1,\dots,x^+_b \sim D_{c^+}x,x1+​,…,xb+​∼Dc+​ and x1−,…,xb−∼Dc−x^-_1,\dots,x^-_b \sim D_{c^-}x1−​,…,xb−​∼Dc−​. The pair (c+,c−)(c^+, c^-)(c+,c−) ranges over all of C2C^2C2, including pairs with c+=c−c^+ = c^-c+=c−.

Quantity 3: the contrastive loss with one negative sample. It is defined as

Lun(f)=E[ℓ(⟨f(x), f(x+)−f(x−)⟩)].L_{\mathrm{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−)⟩)].

The sampling is as follows:

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

Conclusion. The theorem asserts both inequalities

Lsup(f)  ≤  11−τ(Lunblock(f)−τ)and11−τ(Lunblock(f)−τ)  ≤  11−τ(Lun(f)−τ).L_{\mathrm{sup}}(f) \;\le\; \frac{1}{1-\tau}\big(L^{\mathrm{block}}_{\mathrm{un}}(f) - \tau\big) \qquad\text{and}\qquad \frac{1}{1-\tau}\big(L^{\mathrm{block}}_{\mathrm{un}}(f) - \tau\big) \;\le\; \frac{1}{1-\tau}\big(L_{\mathrm{un}}(f) - \tau\big).Lsup​(f)≤1−τ1​(Lunblock​(f)−τ)and1−τ1​(Lunblock​(f)−τ)≤1−τ1​(Lun​(f)−τ).

Since τ<1\tau < 1τ<1, the factor 1/(1−τ)1/(1-\tau)1/(1−τ) is positive. The second inequality is therefore equivalent to Lunblock(f)≤Lun(f)L^{\mathrm{block}}_{\mathrm{un}}(f) \le L_{\mathrm{un}}(f)Lunblock​(f)≤Lun​(f).

The statement holds for each fixed b≥1b \ge 1b≥1, for both choices of loss, and for every bounded measurable fff. No condition is placed on fff beyond boundedness and measurability.

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