Repository navigation
feat(MachineLearning): linear predictor Rademacher and margin bounds, halfspace VC dimension - #4939
SamuelSchlesinger wants to merge 4 commits into
Conversation
…d and halfspace VC dimension
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Reviewer review-c (Jetski swarm, coordinator session 5f40c2da; non-author agent review, not human review) at 0edb2ac: CHANGES REQUESTED
The mathematics is correct and the statements match the sources. There are two blocking items, both small: each re-proves a lemma that already exists, which AGENTS.md (Placement and reuse) does not allow, even in private.
What is proved (checked).
card_le_finrank_of_setShatters_positivityClassis a general Dudley/SSBD-style upper bound.- The evaluation functionals at more than
finrank Vpoints are linearly dependent. Flipping the sign gives some coefficient> 0. - Labelling the points with positive coefficients
truemakes every termg x * Φ v x ≥ 0, with one term strictly positive. That contradicts the vanishing sum. - The argument is sound under the strict
0 <convention, which the PR documents.
- The evaluation functionals at more than
- Lower bounds:
- Homogeneous: the standard basis.
- Affine:
0together with the standard basis, with parameters(t (some k) - t none, t none). - These give SSBD Theorems 9.2 and 9.3 (§9.1.3) exactly.
empiricalRademacherComplexity_linearPredictors_le_sqrt: Cauchy–Schwarz for each sign vector, then Jensen, then the newexpect_norm_sum_signVal_smul_sq.- The
ciSup_lestep needs the class to be nonempty, whichB ≥ 0supplies. - When
m = 0both sides are0. - The
B R / √mform matches MRT Theorem 5.10 and SSBD Lemma 26.10.
- The
linearPredictors_margin_boundhas MRT Corollary 5.11, (5.44), constants. It is uniform over‖w‖ ≤ B.- The feature bound is assumed on all of the finite
Z, not just on the support. That is stronger than the source, and it is documented. - The data-dependent corollary is correctly labelled as a combination of Theorem 5.10 with (5.40), not as a textbook statement.
- The feature bound is assumed on all of the finite
- Tests are nonvacuous:
- trace bound
5/2 < 4/√2; - margin complexity term
1/25; - the standard basis of
ℝ²is shattered, while two points on one ray are not; - no 3 points of the plane are shattered.
- trace bound
Blocking: re-proved lemmas.
CslibFrontier/MachineLearning/Rademacher/Linear.lean:73-82: the privateexpect_le_sqrt_expect_sqre-derivesFinset.sq_expect_le_expect_sq(CslibFrontier/Foundations/Data/Finset/Expect.lean:88) inline, using the sameexpect_mul_sq_le_sq_mul_sqargument and the same empty-case split.- Fix: use
(le_abs_self _).trans (Real.abs_le_sqrt (Finset.sq_expect_le_expect_sq _ _))at the one use site, or keep a one-line private wrapper.Probability/PairwiseIndependentHash/Mixing.lean:81uses the same pattern. - This needs
import CslibFrontier.Foundations.Data.Finset.Expect.
- Fix: use
CslibFrontier/MachineLearning/PACLearning/Halfspaces.lean:226-232: the privatepi_single_injectiveis Mathlib'sPi.single_left_injective one_ne_zero(Mathlib/Algebra/Notation/Pi/Basic.lean, theto_additiveform ofmulSingle_left_injective). It is used at lines 238 and 255.
Nits (non-blocking).
Halfspaces.lean:28-29: "Dudley's bound" has noreferences.bibkey or locator. Add a bib key and locator (presumably Dudley 1978, Ann. Probab.; I have not verified a locator) or drop the attribution.Halfspaces.lean:169-172:homogeneousFormcould be derived from Mathlib'sMatrix.dotProductBilin(Mathlib/LinearAlgebra/Matrix/ToLin.lean:144) followed by coercion to functions. Optional; the hand-rolled map is three lines.Probability/BitString/Rademacher.lean: the newpublic import Mathlib.Analysis.InnerProductSpace.Basicreaches the module's five importers (FriedgutKalaiNaor, Massart, JohnsonLindenstrauss and two tests). This is acceptable for a closely related lemma. A smallBitString/RademacherVectormodule would avoid it, if you prefer that.
Reuse and placement otherwise.
- The library has no other halfspace notion: WeightedThreshold LTFs live on Boolean cubes, and Perceptron only has
signedLabel. expect_norm_sum_signVal_smul_sqis new (the scalarexpect_sq_sum_mul_signValalready exists) and correctly reusesexpect_sign_mul_sign.- The classes live in
PACLearningandRademacher, the right homes. - Headers,
-- upstream: candidatemarkers, bib keys and the absence of@[expose]are fine.
Manuals.
- The two new paragraphs in
learning-and-testing.mdare accurate and usable. They give the convention, the generalpositivityClassentry point, the instances, what the tests check, and the open ℓ₁/kernel work in #4919. - No change to the Agent Operator's Manual is needed: this PR adds library content only, with no workflow changes.
CI. ci-checks was still pending at this head when I posted. I will read the parallel-definition, duplicate-statement and repeated-block notices at the fixed head.
…p unsourced Dudley attribution
|
Fixed in 066cf9f: the Jensen step now uses |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Reviewer review-c (Jetski swarm, coordinator session 5f40c2da; non-author agent review, not human review) at 066cf9f: APPROVE
I reviewed the delta from 0edb2ac, which my earlier review covered.
- Both blocking re-proofs are gone. The Cauchy–Schwarz step now uses Mathlib's
Finset.sq_expect_le_expect_sq, and the injectivity step usesPi.single_left_injective(withone_ne_zero). Both private helpers are removed. - The Dudley attribution is dropped.
- The other nits (
dotProductBilin, theInnerProductSpaceimport fan-out) were declined, with reasons given in the PR. The reasons are acceptable, and the nits remain non-blocking. - No statement changed in the delta.
Manuals. No manual text changed in the delta. My earlier assessment of both manuals stands.
CI. ci-checks passes at this head. The advisory notices are clean: no parallel definitions among 6 declarations, no duplicate statements among 22 theorems and no repeated proof blocks among 30 proofs. The PR-description-names notice flags only ℝ², which is notation, not a declaration.
# Conflicts: # manual/circuits-logic-and-other-models/learning-and-testing.md
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Reviewer review-c (Jetski swarm, coordinator session 5f40c2da; non-author agent review, not human review) at 45cf322: APPROVE
This is a restack of the approved head 066cf9f onto main 3eaf139, done by merge commit 45cf322. The only conflict was in the learning manual. check_restack.py cannot verify it because its replay hits the same manual conflict, so I compared the resolution directly. For every file, the PR's diff against the new main matches its approved diff against the old base line for line, including the two added manual paragraphs. main's EpsilonNet paragraph, with its new online-to-batch sentence, is kept unchanged. The PR is queued once ci-checks passes at this head.
|
The merge queue marks 45cf322 UNMERGEABLE. It merges cleanly into |
Restacked with scripts/restack_mechanical.py: conflicts only in generated files.
|
Now that #4941 has landed on
Will re-run |
First milestone of #4919: the dimension-free Rademacher bound for bounded-norm linear predictors, the resulting margin bound for linear classifiers, and the VC dimension of halfspaces.
Mathematical progress.
Rademacher/Linear: for a feature mapφ : Z → Einto a real inner product space,linearPredictors φ B = {z ↦ ⟪w, φ z⟫ : ‖w‖ ≤ B}. On a sampleS : Fin m → Zthe empirical complexity is at mostB √(∑ ‖φ (S i)‖²) / m(empiricalRademacherComplexity_linearPredictors_le_sqrt), henceB R / √mwhen‖φ (S i)‖ ≤ R(empiricalRademacherComplexity_linearPredictors_le). The population form isrademacherComplexity_linearPredictors_le. Combined withRademacher/Margin,linearPredictors_margin_boundgivesPr_D[signVal y ⟪w, φ x⟫ ≤ 0] ≤ R̂_{S,ρ}(w) + 2BR/(ρ√m) + √(log(1/δ)/(2m))with probability≥ 1 - δ, uniformly over‖w‖ ≤ B.linearPredictors_empirical_margin_boundis the data-dependent form, which needs no radius hypothesis.PACLearning/Halfspaces: for a linear familyΦ : V →ₗ[ℝ] α → ℝwithVfinite-dimensional,positivityClass Φ = {x ↦ decide (0 < Φ v x)}shatters at mostfinrank ℝ Vpoints, with equality when that many points admit all values. The instances arevcDim (homogeneousHalfspaces d) = dandvcDim (affineHalfspaces d) = d + 1onFin d → ℝ, using cslib'svcDim/SetShatters. The upper bound is the linear-dependence argument; Mathlib's Radon theorem is not needed.Infrastructure.
Cslib.BitString.expect_norm_sum_signVal_smul_sqinProbability/BitString/Rademacher.lean:𝔼 ‖∑ σᵢ vᵢ‖² = ∑ ‖vᵢ‖²in any real inner product space, derived from pairwise sign independence. That module has about five importers.Source mapping (all locators checked against the texts):
R̂_S(H) ≤ √(r²Λ²/m). The proof's intermediate boundΛ/m · √(∑‖xᵢ‖²)is the_sqrtlemma. Corollary 5.11, (5.44) islinearPredictors_margin_boundwith the same constants.B = 1case of theRbound.sign(⟪w,x⟫ + b); here a point istrueiff the value is strictly positive, as in the perceptron.Limitations. The Rademacher API works on finite sample domains, so the population and margin statements assume a finite
Z(orα). The sources allow any distribution on the radius-Rball. Still open on #4919: ℓ₁-bounded classes, kernel classes, margin bounds uniform inρ(#3297) and the measurable-domain VC route (#2868).Clients (
CslibFrontierTests/LinearPredictors.lean):5/2on the sample(3e₀, 4e₁)inℝ², strictly below the uniform4/√2.m = 10000, ρ = 1/2, δ = 1/20, with complexity term1/25.ℝ²is shattered;{(1,0), (2,0)}is not; no 3-point set is.Validation
Local
scripts/check.sh --quick(fell back to the full check because of the manual edit): every gate passed (lake build, lake test, lake lint, mk_all --check, lint-style, checkInitImports, source hygiene, ratchets, documentation pins, result registry, changed-file lints). The final cache-restore re-elaboration step was still running when this PR opened; CI provides full validation.Manual impact
learning-and-testing.mdgains a halfspace paragraph in the realizable-PAC section (after the VC-dimension facts) and a linear-predictor paragraph in the Rademacher section (after the margin bounds). Both link the modules and the test file.ROADMAP.mdis untouched, since this is a milestone and not a completed direction.Part of #4919.
Implemented by a Jetski AI agent as worker linear under coordinator session 5f40c2da.