Lemma 4.2 (as proved): generalization bound for the unsupervised loss
ProvedContrastiveUnsupervised.unsup_generalization_boundLet 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 is an absolute constant such that, for every , with probability at least over the training set of tuples drawn from , for all ,
where .
Formalization Note 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 unsup_generalization_bound :
∃ K : ℝ, ∀ {X : Type u} [MeasurableSpace X] {C : Type v} [Countable C] {d : ℕ}
(D : C → Measure X) (ρ : C → ℝ), IsLatentClassModel D ρ →
∀ (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,
unsupLoss hinge D ρ 1 (fhat S) ≤
unsupLoss hinge D ρ 1 f + 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
There is a single real constant (no sign or size condition is imposed on it) such that the following holds uniformly for all choices of the data below. is chosen before all of them and may not depend on any of them.
Data and hypotheses.
-
is any type with a σ-algebra (the data space).
-
is any countable type (the latent classes).
-
is a dimension, possibly . Representations take values in with the Euclidean norm and inner product.
-
is a family of measures on , and . They form a latent class model:
- every is a probability measure;
- for all ;
- (unconditional summability to ).
This forces and to be nonempty.
-
A boolean choice selects the loss on a single real score :
- hinge: ;
- logistic: .
-
is a real number.
-
is a set of functions . Every is measurable and satisfies for all .
-
is pointwise separable: there is a countable such that every is the pointwise limit of some sequence in .
-
is a natural number (the sample size).
-
is any map from samples to representations, where a sample is . For every sample (not just almost every), and is an exact empirical-risk minimizer over :
No measurability of is assumed. If is empty, this hypothesis cannot be satisfied.
- is a real number with .
The losses.
The empirical loss is
The population loss is the integral of against , where:
- is the law of ;
- is the law of .
This integral is taken to be by convention if the integrand is not integrable.
The Rademacher term.
Label the three points of the -th tuple as , , . The term is
Here the supremum is a real supremum, with the convention that it equals when the set is empty or unbounded above. When the term is .
The error term.
With natural logarithm, the error term is
This is the general formula with , where and .
Conclusion.
Let the sample be drawn from , i.e., independent tuples. Consider the set of samples for which there exists some with
The statement is that this set has measure at most . The set is not required to be measurable; for a non-measurable set, the measure means the outer measure.
Equivalently, outside a set of outer measure at most ,
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.