Skip to content

feat: test martingales for which e-BH on running maxima rejects with probability 2Kα/(K+1), so that the bounds 4α/3 and 3α/2 are attained - #453

Closed
RemyDegenne wants to merge 5 commits into
LeanMachineLearning:mainfrom
RemyDegenne:evr/ebh-running-maxima-attained
Closed

RemyDegenne wants to merge 5 commits into
LeanMachineLearning:mainfrom
RemyDegenne:evr/ebh-running-maxima-attained

Conversation

@RemyDegenne

@RemyDegenne RemyDegenne commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This pull request constructs, for every finite type ι of K hypotheses and every level α ≤ (K + 1) / (2 * K), test martingales for one filtration, with every hypothesis true, for which e-BH at level α applied to the running maxima ⨆ n, M i n rejects with probability exactly 2 * K * α / (K + 1). For two and three hypotheses this shows that the upper bounds 4 * α / 3 and 3 * α / 2 of #429 are attained. It adds the subject file LMLExplore/EValues/MultipleTesting/RunningMaxima/LowerBound.lean, next to the two files of #429, and the general infrastructure it uses as public declarations in their natural homes (listed below): four new files and additions to three existing ones. It removes or renames no declaration.

Main declarations

  • exists_isTestMartingale_measure_exists_selfConsistent_iSup_eq (ι : Type*) [Fintype ι] (hα : α ≤ (Fintype.card ι + 1) / (2 * Fintype.card ι)): there are Ω : Type, a measurable space, a probability measure P, a filtration ℱ and M : ι → ℕ → Ω → ℝ≥0∞ with every M i a test martingale for ℱ and {P}, and P {ω | ∃ R : Finset ι, R.Nonempty ∧ ∀ i ∈ R, (Fintype.card ι : ℝ≥0∞) ≤ α * R.card * ⨆ n, M i n ω} = 2 * Fintype.card ι * α / (Fintype.card ι + 1).
  • exists_isTestMartingale_measure_exists_selfConsistent_iSup_eq_of_card_eq_two (hι : Fintype.card ι = 2) (hα : α ≤ 3 / 4): the same with probability 4 * α / 3, the bound of measure_exists_selfConsistent_iSup_le_of_card_eq_two.
  • exists_isTestMartingale_measure_exists_selfConsistent_iSup_eq_of_card_eq_three (hι : Fintype.card ι = 3) (hα : α ≤ 2 / 3): the same with probability 3 * α / 2, the bound of measure_exists_selfConsistent_iSup_le_of_card_eq_three.
  • exists_isTestMartingale_lt_measure_exists_selfConsistent_iSup (hι : 2 ≤ Fintype.card ι) (hα0 : α ≠ 0) (hα1 : α < 1): the same objects with α < P {…}: e-BH on running maxima does not control the false discovery rate at its level.

The rest of LowerBound.lean (the ladder construction and its cycle lemma) is private.

New public infrastructure

  • LMLExplore/EValues/TestSupermartingale/Finite.lean (new): Doob martingales on a finite space. ProbabilityTheory.fiberAvg w f Z y (the w-weighted average of Z over the fiber f ⁻¹' {y}, 0 on a fiber of weight 0), fiberAvg_def, fiberAvg_eq_zero_of_sum_eq_zero, sum_mul_fiberAvg, ProbabilityTheory.fiberFiltration info hinfo (the filtration MeasurableSpace.comap (info t) ⊤ for refining maps info t), measurableSet_fiberFiltration_iff, and isTestMartingale_fiberAvg (the fiber averages of Z form a test martingale for ∑ ω, w ω • δ_ω when ∑ ω, w ω * Z ω ≤ 1).
  • LMLExplore/Data/Int/Interval.lean (new): Int.card_le_toNat_of_forall_lt_add, a finite set of integers whose elements are less than d apart has at most d.toNat elements.
  • LMLExplore/Data/Fintype/BigOperators.lean (new): Fintype.card_filter_forall, #{f : ∀ i, α i | ∀ i, Q i (f i)} = ∏ i, #{a | Q i a}.
  • LMLExplore/Data/Nat/Mod.lean (new): Nat.add_mod_eq_iff, (h + u) % K = x ↔ h = (x + K - u) % K for h, u, x < K.
  • LMLExplore/Algebra/BigOperators/Intervals.lean (existing): LMLExplore.prod_range_add_mod and its additive version LMLExplore.sum_range_add_mod, ∑ x < K, f ((z + x) % K) = ∑ x < K, f x. Also LMLExplore.two_mul_sum_range_sub, 2 * ∑ i < n + 1, (n + 1 - i) = (n + 1) * (n + 2) (Gauss' formula for the reflected indices).
  • LMLExplore/MeasureTheory/Measure/Weighted.lean (existing): setLIntegral_sum_smul_dirac, the set lower integral against ∑ k, w k • δ_{x k} with weights in ℝ≥0∞.
  • LMLExplore/MeasureTheory/MeasurableSpace/Constructions.lean (existing): MeasurableSpace.measurableSet_comap_top_iff, the measurable sets of MeasurableSpace.comap f ⊤ are the unions of fibers of f.

Roadmap coverage (EValues, Layer 8, item 3)

Covered: the second half of the bullet "E-BH applied to the running maxima ⨆ n, M i n of test supermartingales for a common filtration …", that is, "for every K and every α ≤ (K + 1) / (2 * K) some K test martingales for a common filtration make it reject with probability 2 * K * α / (K + 1), so that the two bounds are attained", and the first sentence of the bullet ("does not control the false discovery rate at α" [TGdH25]) as a corollary. The upper bounds of the bullet are merged (#429). With this pull request the bullet is complete. The rest of item 3 (closed e-BH, closed BH, closed testing, online e-BH, SeqE-Guard) and the rest of Layer 8 are left.

The construction has no published source: the roadmap cites it [EVR26, Note 18]. The proof here is a rewrite of its Lean proof in the paper project (EValuesResearch/Results/RunningMaxima.lean, commit ffba78a), which the module docstrings of LowerBound.lean and TestSupermartingale/Finite.lean credit. The same file was in the first version of #429 and was moved out when that pull request exceeded the scope limit; this is that file, adapted to main.

Notes for reviewers

  • The e-BH event is written out, exactly as in feat: e-BH on the running maxima of test supermartingales rejects with probability at most 4α/3 for two hypotheses and 3α/2 for three #429: some nonempty R with (Fintype.card ι : ℝ≥0∞) ≤ α * R.card * ⨆ n, M i n ω for every i ∈ R. E-BH and self-consistent sets belong to Layer 8.2, which is not built yet.
  • Deviations from the roadmap's wording. "Some K test martingales" is any finite type ι with K = Fintype.card ι, as in the upper bounds, rather than Fin K; the construction works on Fin K and transports along Fintype.equivFinOfCardEq with measure_exists_selfConsistent_le_of_equiv of feat: e-BH on the running maxima of test supermartingales rejects with probability at most 4α/3 for two hypotheses and 3α/2 for three #429 (used in both directions). "Every hypothesis true" is the null {P} for every hypothesis, the smallest null. The sample space is in Type. "So that the two bounds are attained" is stated as the two corollaries …_of_card_eq_two (α ≤ 3 / 4, probability 4 * α / 3) and …_of_card_eq_three (α ≤ 2 / 3, probability 3 * α / 2), with the same right-hand sides as the upper bounds. K = 0 and α = 0 are allowed (constant test martingales 1, probability 0). The non-control corollary holds for every 0 < α < 1, not only α ≤ (K + 1) / (2 * K): above that level the construction at the level (K + 1) / (2 * K) rejects with probability 1, and the rejection event grows with the level.
  • How the construction goes. On a finite space Bool × Fin K × (Fin K → Fin K): a coin that is true with probability 2 * K * α / (K + 1), a uniform cyclic shift of the positions of the processes and uniform heights of the K players. The player at position l climbs during the times K * l, …, K * l + K - 1, which reveal its height. Each process is the Doob martingale of its terminal value K / α, earned when the coin is true, the players before it have not won and its height is the top one; at height h it is then worth K / ((K - h) * α), so e-BH rejects exactly when the coin is true. The initial expectations are at most 1 by a cycle lemma: among the K cyclic shifts of any heights, at most K - j leave the first j players without a win, which bounds the probability that they do not win by (K - j) / K.
  • Why the new infrastructure. LMLExplore's lintegral_sum_smul_dirac (in MeasureTheory/Measure/Weighted.lean) has real weights ENNReal.ofReal (w k) and integrates over the whole space; the construction needs ℝ≥0∞ weights and set integrals, hence setLIntegral_sum_smul_dirac. A search of Mathlib, Tau Ceti, LML and Statlib found no lemma characterizing the measurable sets of MeasurableSpace.comap f ⊤ as the unions of fibers of f, no counting lemma for functions with a coordinatewise condition beyond Fintype.card_piFinset, no shift-invariance of sums over a period of residues and no Nat.add_mod_eq_iff. The constant test martingale is isTestMartingale_one.
  • Overlaps with open pull requests. None: no open pull request touches multiple testing or the files used here.

Roadmap: EValues
Paper: RemyDegenne/evalues_research
Item: R39

🤖 Generated with Claude Code

https://claude.ai/code/session_0196ftMVbgjSJzPQEwdek3kM

…probability 2Kα/(K+1), so that the bounds 4α/3 and 3α/2 are attained

For every finite type of K hypotheses and every level α ≤ (K + 1)/(2K), test martingales for one
filtration, with every hypothesis true, make e-BH at level α applied to their running maxima
reject with probability exactly 2Kα/(K + 1). For two and three hypotheses this attains the merged
upper bounds 4α/3 and 3α/2, and for at least two hypotheses and every level 0 < α < 1 the
rejection probability exceeds α. This serves the EValues roadmap, Layer 8, item 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0196ftMVbgjSJzPQEwdek3kM
@lmlexplore-automation lmlexplore-automation Bot added awaiting-CI CI has not yet reported on the latest commit awaiting-review CI is green; waiting for review verdicts and removed awaiting-CI CI has not yet reported on the latest commit labels Nov 15, 2026
@RemyDegenne

RemyDegenne commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

AI review — changes requested

Each rubric is judged independently by multiple review agents; the PR merges only once every rubric is green — any rubric that is not green (changes requested, blocked, errored, stale, or not yet run) blocks the merge. See the rubrics.

⚠️ This review ran from a rubrics checkout that differs from the published rubrics (out of date, pinned, or locally edited), so its findings may reflect different rules.

rubric state judge summary
✅ correctness approved claude/claude-opus-5-5 The main theorem and its three corollaries state exact rejection probabilities (or a strict excess over α) under a genuine probability measure, for test martingales on one common filtration, with the same event and martingale notion as the merged upper bounds. The new infrastructure lemmas state the intended facts, and I found no vacuity, weakened hypothesis or faked prerequisite.
🟡 reuse changes requested claude/claude-opus-5-5 The new infrastructure has no counterpart in Mathlib or LMLExplore, and the construction reuses the existing API. However, setLIntegral_sum_smul_dirac re-proves Mathlib's setLIntegral_dirac for each summand instead of calling it.
✅ scope approved claude/claude-opus-5-5 The PR proves the remaining half of the EValues Layer 8 item 3 bullet 'E-BH applied to the running maxima' (README.md:1174–1180): the 2Kα/(K+1) construction, the attained 4α/3 and 3α/2 bounds, and the non-control corollary. Every new helper (fiberAvg/fiberFiltration, the counting and modular lemmas, setLIntegral_sum_smul_dirac, measurableSet_comap_top_iff) is a used, proximate prerequisite of that single construction.
✅ attribution approved claude/claude-opus-5-5 The subject file credits the paper-project Lean proof (EValuesResearch/Results/RunningMaxima.lean, commit ffba78a), the notes [EVR26, Notes 10 and 18], [WR22] and [TGdH25]. The previously missing credit in TestSupermartingale/Finite.lean is now present, and the remaining helper lemmas are routine.
✅ api-design approved claude/claude-opus-5-5 The earlier finding is resolved: two_mul_sum_range_sub is now public in Algebra/BigOperators/Intervals.lean, and every remaining private declaration depends on the ladder construction. The new definitions fiberAvg and fiberFiltration have their characterizing lemmas, unexposed bodies and no free data.
🟡 generality changes requested claude/claude-opus-5-5 The public statements are at the natural level, and the card_eq_two/card_eq_three corollaries are derived from the general theorem; only two_mul_sum_range_sub is under-generalized, being stated for n + 1 where the formula holds for every n.
✅ placement approved claude/claude-opus-5-5 Each new declaration sits in its natural home and the construction-specific ladder material stays private in the RunningMaxima/LowerBound subject file. No import is evidently unused or overly broad.
✅ naming approved claude/claude-opus-5-5 New names describe their conclusions in standard Mathlib terminology, extend the #429 naming family consistently, match statement strength (_iff are genuine iffs, _eq are equalities), and sit in appropriate namespaces; no notation is introduced.
✅ documentation approved claude/claude-opus-5-5 Each new file has a module docstring giving its content and purpose, and the public declarations have accurate docstrings that do not overclaim. No roadmap or process narrative appears in the files; credit to the paper project is given as a reference.
✅ proof-quality approved claude/claude-opus-5-5 Proofs are short, rely on robust automation (omega, simp, Finset counting lemmas) with structured calc steps, and use no undocumented definitional equality; the new infrastructure is factored into reusable lemmas.

♻️ = approved on an earlier commit, re-run before merge.

Reviewing this diff at head f4ad5dd. rubrics @ 7d59664. CLI @ 7d59664. Review spend: $1.54.

@lmlexplore-automation lmlexplore-automation Bot added awaiting-author A review requested changes; author action needed and removed awaiting-review CI is green; waiting for review verdicts labels Nov 15, 2026
…te EVR26 Note 18

Move `measurableSet_comap_top_iff` to `MeasureTheory/MeasurableSpace/Constructions.lean`
(as `MeasurableSpace.measurableSet_comap_top_iff`), `setLIntegral_sum_smul_dirac` to
`MeasureTheory/Measure/Weighted.lean` (generalised to points `x k`), and
`card_le_of_forall_lt_add` to the new `Data/Int/Interval.lean` (as
`Int.card_le_toNat_of_forall_lt_add`), all public. Cite [EVR26, Note 18], reword the
non-control bullet as an existence statement, factor the fiber sum of `ladder_climb`
and the uniform weight sum, and replace bare `rfl` closes and long rewrite chains.

Co-Authored-By: Claude Code <noreply@github.com>
@lmlexplore-automation lmlexplore-automation Bot added awaiting-CI CI has not yet reported on the latest commit awaiting-review CI is green; waiting for review verdicts awaiting-author A review requested changes; author action needed and removed awaiting-author A review requested changes; author action needed awaiting-CI CI has not yet reported on the latest commit awaiting-review CI is green; waiting for review verdicts labels Nov 15, 2026
… helpers of the e-BH lower bound

Move `fiberAvg`, `sum_mul_fiberAvg`, `fiberFiltration` and `isTestMartingale_fiberAvg` to the new
public module `LMLExplore/EValues/TestSupermartingale/Finite.lean`, with `fiberAvg_def`,
`fiberAvg_of_sum_eq_zero` and `measurableSet_fiberFiltration_iff`. Make the general helpers public
in their natural homes: `Fintype.card_filter_forall` (new `Data/Fintype/BigOperators.lean`),
`LMLExplore.sum_range_add_mod` / `prod_range_add_mod` (`Algebra/BigOperators/Intervals.lean`) and
`Nat.add_mod_eq_iff` (new `Data/Nat/Mod.lean`).

Split `ladder_climb` into `sum_ladderWeight_climb`, `sum_ladderWeight_mul_ladderValue_climb` and
`prod_card_climb`, without the `set`-defeq `rfl` and the goal-closing `ring_nf`; derive
`two_mul_sum_range_sub` from `Finset.sum_range_reflect` and `Finset.sum_range_id_mul_two`; close
the three-hypothesis corollary with `ENNReal.div_eq_div_iff`.

Co-Authored-By: Claude Code <noreply@github.com>
@lmlexplore-automation lmlexplore-automation Bot added awaiting-CI CI has not yet reported on the latest commit awaiting-review CI is green; waiting for review verdicts and removed awaiting-author A review requested changes; author action needed awaiting-CI CI has not yet reported on the latest commit labels Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🟡 naming — request_changes claude/claude-opus-5-5

The new names describe their conclusions in Mathlib terms and sit in the right namespaces, except that fiberAvg_of_sum_eq_zero leaves its conclusion = 0 out of its name.

  • LMLExplore/EValues/TestSupermartingale/Finite.lean:66 — fiberAvg_of_sum_eq_zero proves fiberAvg w f Z y = 0, but the name never says eq_zero, so it reads as an unfolding lemma rather than a vanishing lemma. Fix: Rename to fiberAvg_eq_zero_of_sum_eq_zero, and update the module docstring and the PR description.

Reply in this thread to contest a finding; that re-runs only this rubric and posts an answer here. (To fix it, just push a commit — that re-reviews on its own. To contest again after an answer, post a NEW reply rather than editing an old one.)

claude/claude-opus-5-5 · 26s · 126k in (110.1k cache read, 15.9k cache write) / 2.5k out tokens · reviewing this diff · rubric · ⚠️ rubrics checkout differs from published main

@lmlexplore-automation lmlexplore-automation Bot added awaiting-author A review requested changes; author action needed and removed awaiting-review CI is green; waiting for review verdicts labels Nov 15, 2026
…q_zero

Co-Authored-By: Claude Code <noreply@github.com>
@lmlexplore-automation lmlexplore-automation Bot added awaiting-CI CI has not yet reported on the latest commit and removed awaiting-author A review requested changes; author action needed labels Nov 15, 2026
@lmlexplore-automation lmlexplore-automation Bot added awaiting-review CI is green; waiting for review verdicts awaiting-author A review requested changes; author action needed and removed awaiting-CI CI has not yet reported on the latest commit awaiting-review CI is green; waiting for review verdicts labels Nov 15, 2026
…rvals, credit the paper project in TestSupermartingale.Finite

Co-Authored-By: Claude Code <noreply@github.com>
@lmlexplore-automation lmlexplore-automation Bot added awaiting-CI CI has not yet reported on the latest commit awaiting-review CI is green; waiting for review verdicts and removed awaiting-author A review requested changes; author action needed awaiting-CI CI has not yet reported on the latest commit labels Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🟡 reuse — request_changes claude/claude-opus-5-5

The new infrastructure has no counterpart in Mathlib or LMLExplore, and the construction reuses the existing API. However, setLIntegral_sum_smul_dirac re-proves Mathlib's setLIntegral_dirac for each summand instead of calling it.

  • LMLExplore/MeasureTheory/Measure/Weighted.lean:191 — The per-summand step rw [Measure.restrict_smul, lintegral_smul_measure, restrict_dirac]; split_ifs <;> simp [lintegral_dirac] re-proves Mathlib's MeasureTheory.setLIntegral_dirac (restrict_dirac + lintegral_dirac). Fix: Replace the step with rw [Measure.restrict_smul, lintegral_smul_measure, setLIntegral_dirac]; split_ifs <;> simp, or simp [Measure.restrict_smul, lintegral_smul_measure, setLIntegral_dirac, mul_ite].

Reply in this thread to contest a finding; that re-runs only this rubric and posts an answer here. (To fix it, just push a commit — that re-reviews on its own. To contest again after an answer, post a NEW reply rather than editing an old one.)

claude/claude-opus-5-5 · 44s · 396.1k in (372.2k cache read, 23.9k cache write) / 3.8k out tokens · reviewing this diff · rubric · ⚠️ rubrics checkout differs from published main

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🟡 generality — request_changes claude/claude-opus-5-5

The public statements are at the natural level, and the card_eq_two/card_eq_three corollaries are derived from the general theorem; only two_mul_sum_range_sub is under-generalized, being stated for n + 1 where the formula holds for every n.

  • LMLExplore/Algebra/BigOperators/Intervals.lean:102 — two_mul_sum_range_sub is stated only for range (n + 1) with (n + 1 - i) and (n + 1) * (n + 2). That is the successor case of Gauss' formula, which holds for every n. Fix: State it as theorem two_mul_sum_range_sub (n : ℕ) : 2 * ∑ i ∈ range n, (n - i) = n * (n + 1) (the same sum_range_reflect proof works) and call it at n + 1 in LowerBound.lean:601. Update the module docstring entry to match.

Reply in this thread to contest a finding; that re-runs only this rubric and posts an answer here. (To fix it, just push a commit — that re-reviews on its own. To contest again after an answer, post a NEW reply rather than editing an old one.)

claude/claude-opus-5-5 · 26s · 107.5k in (100.7k cache read, 6.8k cache write) / 2.3k out tokens · reviewing this diff · rubric · ⚠️ rubrics checkout differs from published main

@lmlexplore-automation lmlexplore-automation Bot added awaiting-author A review requested changes; author action needed and removed awaiting-review CI is green; waiting for review verdicts labels Nov 15, 2026
@RemyDegenne

Copy link
Copy Markdown
Contributor Author

Closing after 3 repair attempts left review findings unresolved at head f4ad5dd7adfd0cf1287819f77ab44317ea449411. The branch is retained; a fresh attempt can address the remaining findings using the current review rubric.

@lmlexplore-automation lmlexplore-automation Bot removed the awaiting-author A review requested changes; author action needed label Nov 15, 2026
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