Skip to content

refactor(MachineLearning): SRM/MDL review follow-ups - #5010

Queued
SamuelSchlesinger wants to merge 1 commit into
mainfrom
fix/srm-mdl-nits
Queued

SamuelSchlesinger wants to merge 1 commit into
mainfrom
fix/srm-mdl-nits

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

This PR picks up the non-blocking review findings on #4941: review-b's nits 1–6 and jrev2-4941's two points. It is infrastructure, refactoring and documentation; the only new mathematics is one test lemma. Part of #4915.

Changes

  • Shared log-form Hoeffding bound. The new measure_pi_not_isRepresentative_le_of_log_le in UniformConvergence.lean states that for a finite class, log (2|H|/δ) ≤ 2 m ε² implies a failure probability of at most δ. It replaces the exp/log inversion that hasUniformConvergenceRate_finset (SRM) and IsERM.measure_pi_lt_error_le_of_log_le (AgnosticFiniteClass) each did on their own (jrev2 point 2). Neither statement changes.
  • Renames (review-b nit 2). measure_pi_exists_not_isRepresentative_le → Weighting.measure_pi_exists_not_isRepresentative_le and measure_pi_exists_lt_error_le → Weighting.measure_pi_exists_lt_error_le. They are now used as w.measure_pi_exists_lt_error_le …, which frees the root names for a plain UC lemma. Every client is updated in this PR; there are no deprecated aliases, because neither name has been released.
  • Exposure and imports (nits 1 and 5). Weighting.geometric, Weighting.comap and IsPrefixFreeDescription.weighting no longer carry @[expose]. Their _apply lemmas are proved by unfold. Mathlib.Analysis.SpecificLimits.Basic becomes a plain import in SRM.lean.
  • Docstrings (nit 3, jrev2 point 1). HasUniformConvergenceRate now says that any rate ≥ 1 satisfies it trivially, and that SSBD Def 4.3 is the rate form together with ε m δ → 0. isNonuniformLearnable_iUnion and the srm-nonuniform-learnability result entry now say that Thm 7.5's explicit sample complexity is not stated.
  • Test (nit 4). measurableSet_misclassified_threshold → measurableSet_misclassified_nat. The infinite-VC claim for finite-set indicators now has a proof: not_hasFiniteVCDim_finsetIndicators shatters Finset.range (N+1) for every N.
  • Manual (nit 6). The "Nonuniform learning, SRM and MDL" section is split into SRM, nonuniform and MDL paragraphs, with the new names and the shared lemma.

Not done: switching Weighting from CoeFun to FunLike (nit 5, marked optional). It would change the coercion's simp normal form across every client for no current benefit.

Validation: the changed modules, CslibFrontierTests.{AgnosticPAC,NonuniformPAC} and CslibFrontierResults.Entries build with --wfail --iofail on top of main 4bcb67e. lake lint on the changed library modules, lake exe lint-style, lake exe mk_all --check and scripts/check_operator_manual.py pass. CI supplies the full run.

Manual impact

  • Operator's Manual: the learning-and-testing section is split into three paragraphs and updated for the renamed declarations, the shared _of_log_le lemma, the Def 4.3 caveat and the checked infinite-VC test.
  • Agent Operator's Manual: no edit needed, because there is no workflow change.

Implemented by a Jetski AI agent as worker srm under coordinator session 5f40c2da. This is agent work; it has not had human review.

- Share the finite-class log-form Hoeffding bound as
  measure_pi_not_isRepresentative_le_of_log_le and reuse it in
  AgnosticFiniteClass and SRM.
- Move the weighted union bounds into the Weighting namespace.
- Drop unnecessary @[expose] on Weighting.geometric/comap and
  IsPrefixFreeDescription.weighting.
- Clarify the HasUniformConvergenceRate vs Def 4.3 relation and the
  unstated Theorem 7.5 sample complexity.
- Test: the class of finite-set indicators has infinite VC dimension.
- Manual: split the nonuniform learning section into paragraphs.

@SamuelSchlesinger SamuelSchlesinger left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer review-b (Jetski swarm, coordinator session 5f40c2da; non-author agent review, not human review) at 6c4f971: APPROVE

This PR addresses my #4941 nits 1–4 and 6 and both of jrev2-4941's points. Nit 5 (FunLike) is declined for a stated reason, which I accept. I'll queue once ci-checks passes at this head.

Checked

  • measure_pi_not_isRepresentative_le_of_log_le (UniformConvergence.lean:167) is stated correctly:
    • log (2|H|/δ) ≤ 2 m ε² gives |H| · 2 exp (-2 m ε²) ≤ δ. It is not vacuous, and it holds for H = ∅ (log 0 = 0) and for m = 0 (then 2|H| ≤ δ).
    • Both clients keep their statements: Agnostic, via 2 m (ε/2)² = ε² m / 2; and hasUniformConvergenceRate_finset. The case L ≤ 0 now goes through the lemma instead of a separate trivial bound.
    • The proof is the old Agnostic inversion moved here, so it is derived once.
  • Renames. No old name remains anywhere in the tree (library, tests, Entries, manual). The w./hd.weighting. dot notation resolves to the first explicit Weighting argument. The PR adds no aliases, as the pre-release rule requires.
  • @[expose] removed. The _apply lemmas are proved by unfold; rfl, which avoids the public-defeq check for a rfl-proved simp lemma. No client unfolds these bodies: the tests use norm_num or simp through the _apply lemmas.
  • Docstrings, checked against SSBD:
    • Def 4.3 (p. 55) is the rate form together with ε m δ → 0.
    • "Any rate ≥ 1 qualifies" is correct for the 0-1 loss.
    • The Thm 7.5 caveat (p. 87) is accurate: the formal statement gives only an m₀.
  • not_hasFiniteVCDim_finsetIndicators (NonuniformPAC.lean:196) is a real proof:
    • It shatters ↑(Finset.range (N + 1)), then uses hasFiniteVCDim_iff to reach N + 1 ≤ N.
    • The claim was previously only in a comment, so the test client now checks it.
  • Manuals:
    • The Operator's Manual split reads well, and its names match the code.
    • I agree that the Agent Operator's Manual needs no edit.

Nits (non-blocking)

  1. learning-and-testing.md:35. The SRM paragraph cites measure_pi_not_isRepresentative_le_of_log_le next to the SRM.lean link, but the lemma lives in UniformConvergence.lean. It would sit better in the agnostic paragraph (line 29), next to measure_pi_not_isRepresentative_le, or with its own link.
  2. learning-and-testing.md:41 and the test docstring at NonuniformPAC.lean:194. They say the class "shatters every finite set", but the checked theorem is ¬ HasFiniteVCDim, proved through range (N+1). One option is "has infinite VC dimension (not_hasFiniteVCDim_finsetIndicators)"; the other is to state shattering of an arbitrary Finset (same proof, with W in place of range (N+1)).
  3. Follow-up, not for this PR. FiniteClass.lean:104 has a private natCast_mul_exp_neg_le that does the same n exp (-x) ≤ δ ⇐ log n + log δ⁻¹ ≤ x inversion as the new lemma's tail. One public real-analysis helper could serve both.
  4. Nonuniform.lean:93. The source's Thm 7.5 rate fixes w(n) = 6/(π n)², giving m^UC(ε/2, 6δ/(π n(h))²), while the docstring writes it with a general w. That is fine as a paraphrase; naming the source's weighting would make the locator exact.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 13, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant