Theorem 4.5 (as proved): guaranteed average binary classification
ProvedContrastiveUnsupervised.binary_contrastive_guaranteeLet be a countable set of latent classes with distribution and class distributions , and let . Let be the hinge or the logistic loss. Let be a pointwise separable class of measurable with , . Let be an empirical minimizer, for every training set of tuples (one negative sample). There are absolute constants and such that, for every , with probability at least over the training set of tuples drawn from , for all ,
where , , , is the unsupervised loss conditioned on , and is the intraclass deviation.
This is the paper's main guarantee: if some contrasts different classes well and is concentrated within classes, the empirical minimizer of the contrastive loss does well on average binary classification.
Formalization Note and are averages over pairs of distinct classes with uniform label distribution, and uses the best linear classifier. The paper's is an absolute constant , and "with probability at least " means that the outer measure of the failure set is at most . The statement is restricted to because the proof (Mohri et al., Theorem 3.1, and Hoeffding) produces and . These are only for bounded away from ; for the two forms agree up to the constant. Pointwise separability of and measurability of each are standing conventions the paper does not state. The hypothesis is implicit in the paper's division by .
import Mathlib import Definitions.Def_ContrastiveUnsupervised_Basic open MeasureTheory Filter Topology universe u v
namespace ContrastiveUnsupervised
theorem binary_contrastive_guarantee :
∃ K c' : ℝ, 0 < c' ∧
∀ {X : Type u} [MeasurableSpace X] {C : Type v} [Countable C] {d : ℕ}
(D : C → Measure X) (ρ : C → ℝ), IsLatentClassModel D ρ → collisionProb ρ < 1 →
∀ (hinge : Bool) (R : ℝ), 0 < R →
∀ (F : Set (X → Rep d)), (∀ f ∈ F, IsBoundedRep f R) → IsPointwiseSeparable F →
∀ (M : ℕ), 1 ≤ M →
∀ (fhat : (Fin M → X × X × (Fin 1 → X)) → X → Rep d),
(∀ S, fhat S ∈ F ∧ ∀ f ∈ F, empUnsupLoss hinge 1 (fhat S) S ≤ empUnsupLoss hinge 1 f S) →
∀ δ : ℝ, 0 < δ → δ ≤ 1 / 2 →
sampleMeasure D ρ 1 M {S | ¬ ∀ f ∈ F,
avgSupLoss (stdLoss hinge) D ρ 1 (fhat S) ≤
avgMeanSupLoss (stdLoss hinge) D ρ 1 (fhat S) ∧
avgMeanSupLoss (stdLoss hinge) D ρ 1 (fhat S) ≤
unsupLossNeq hinge D ρ 1 f +
c' * (collisionProb ρ / (1 - collisionProb ρ)) * intraclassDeviation D ρ f +
1 / (1 - collisionProb ρ) * genError K R 1 M (rademacherAvg F S) δ} ≤
ENNReal.ofReal δ := by sorry
end ContrastiveUnsupervisedRead-back
What the Lean code literally says, in plain math · claude-opus-5-5
Claim. There exist real constants and , with and no sign condition on , such that the following holds for every configuration described below. The constants do not depend on any of the data.
Setting and hypotheses.
-
is any measurable space, is any countable type of "classes", and is a natural number. Representations take values in with the Euclidean norm and inner product.
-
assigns a measure on to each class, and . The pair is assumed to be a latent class model: each is a probability measure, for all , and .
-
The collision probability satisfies .
-
A Boolean flag selects the loss used throughout. For a finite index set and vector :
- hinge: , with when ;
- logistic: .
On a single coordinate these become and respectively.
-
is a real number.
-
is a set of functions with two properties:
- every is measurable and satisfies for all ;
- is pointwise separable: there is a countable such that every is a pointwise limit, at every , of some sequence in .
-
is a natural number, the sample size.
-
A training sample is , with exactly one negative sample per tuple.
-
maps each sample to a function . It is assumed that for every sample (not merely almost every), and is an exact minimizer of the empirical loss over :
Here the empirical loss is
No measurability of is assumed.
- is a real number with .
Distribution of the sample. Define
One tuple has law . The sample has law .
Conclusion. Let be the set of samples for which the following statement fails:
For every , both
and
Then . If is not measurable, is its outer measure.
The left-hand sides involve only the data-dependent . The right-hand side is evaluated at an arbitrary comparator . The first inequality is also part of the event, sitting inside the quantifier over .
The quantities, unfolded (one negative sample, so -way tasks):
- Class mean: .
- Supervised loss of a task. Take a task with uniform label weights and a classifier given by rows . Its loss is
where is the other class of .
- is the infimum of this over all row assignments .
- is its value at the mean classifier .
- Averaged supervised losses. Average over ordered pairs with , weighted by , normalized by the total such weight:
and is defined the same way with .
- Unsupervised loss on distinct classes. With and independent:
- Intraclass deviation:
Here is the covariance matrix of under , and is the spectral (operator) norm.
- Rademacher average. Let range uniformly over all sign patterns . Then
where .
- Generalization term. It arises from the general expression
at , which reduces to the term displayed in the conclusion. Its sign follows the sign of .
Degenerate and edge cases.
- Junk-value conventions. These are the formalization's defaults:
- a divergent infinite sum is treated as ;
- a non-integrable function has integral ;
- an infimum or supremum of a set unbounded in that direction, or of an empty set, is .
- Positivity of . The hypotheses force . The normalizing sums over distinct pairs equal when the series converge.
- . All representations are and .
- Unattainable minimum. The exact-minimizer hypothesis on must hold at every sample. If for some no minimizer of exists in , no such exists and the statement is vacuous for that .
- Range of . Since , we have .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.