Skip to content

feat: the Wald inequality at the bipolar rate and the lower bound on expected stopping times - #441

Open
RemyDegenne wants to merge 15 commits into
LeanMachineLearning:mainfrom
RemyDegenne:evr/bipolar-rate-stopping-times
Open

RemyDegenne wants to merge 15 commits into
LeanMachineLearning:mainfrom
RemyDegenne:evr/bipolar-rate-stopping-times

Conversation

@RemyDegenne

@RemyDegenne RemyDegenne commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This pull request proves the Wald inequality at the bipolar rate for the e-processes of an i.i.d. null, and its consequence, the lower bound log (1/α) / d on the expected number of observations of a sequential test of level α, where d = bipolarRate Q₁ S₁. It adds two new files in LMLExplore/EValues/BipolarRate/: Round.lean holds the restarted rounds and the Wald inequality for a round, and StoppingTime.lean holds the Wald inequality for e-processes and the lower bound. It also adds LMLExplore/Analysis/SpecialFunctions/Log/TruncLog.lean, LMLExplore/MeasureTheory/Integral/EReal.lean and LMLExplore/Logic/Function/DependsOn.lean, and public general lemmas in three existing files (listed below). No existing declaration is removed or renamed.

Main declarations

Write Q = Measure.infinitePi fun _ ↦ Q₁. The observations are the coordinates of ℕ → 𝓧 with Filtration.piLE, and the null is (fun P ↦ Measure.infinitePi fun _ ↦ P) '' S₁ with ∀ P ∈ S₁, IsProbabilityMeasure P, as in LMLExplore/EValues/BipolarRate/EProcess.lean.

  • IsEProcess.eintegral_log_stoppedValue_le_mul_bipolarRate: for an e-process E for the i.i.d. null and a stopping time τ : (ℕ → 𝓧) → ℕ,
    ∫ᵉ ω, ENNReal.log (E (τ ω) ω) ∂Q ≤ ((∫⁻ ω, (τ ω : ℝ≥0∞) + 1 ∂Q : ℝ≥0∞) : EReal) * bipolarRate Q₁ S₁.
    No assumption on Q₁ and none on the expectation of τ: when it is infinite the right side is ⊤, or 0 if d = 0. With τ constant, this is IsEProcess.eintegral_log_le_mul_bipolarRate of feat: e-processes for an i.i.d. null grow at most at the bipolar rate in expectation [RR26, Lemma 3.3] #413.
  • toENNReal_log_inv_div_bipolarRate_le_lintegral: for a probability measure Q₁, a stopping time τ : (ℕ → 𝓧) → WithTop ℕ and α : ℝ≥0∞ with Measure.infinitePi (fun _ ↦ P) {ω | τ ω ≠ ⊤} ≤ α for every P ∈ S₁,
    (ENNReal.log α⁻¹).toENNReal / (bipolarRate Q₁ S₁).toENNReal ≤ ∫⁻ ω, ENat.toENNReal (τ ω) + 1 ∂Q.
    For d = 0 and α < 1, and for α = 0 and d < ∞, the expected number of observations is infinite.

Other public declarations:

  • LMLExplore/EValues/BipolarRate/Round.lean:
    • DependsOnBefore σ f (with dependsOnBefore_iff): f is determined by the first σ observations.
    • integral_truncLog_le_bipolarRate_mul, the Wald inequality for a round.
    • The restart construction itself stays private.
  • LMLExplore/Analysis/SpecialFunctions/Log/TruncLog.lean (new): ENNReal.truncLog c x, the logarithm of x : ℝ≥0∞ truncated above at c, as a real number, with ENNReal.truncLog_def, ENNReal.measurable_truncLog, ENNReal.truncLog_of_ne, ENNReal.truncLog_top and ENNReal.truncLog_zero (both @[simp]), ENNReal.integrable_truncLog_comp, ENNReal.truncLog_le, ENNReal.min_log_le_truncLog, ENNReal.log_le_truncLog, ENNReal.abs_truncLog_le, ENNReal.ofReal_exp_truncLog_le and ENNReal.min_log_le_truncLog_sub.
  • LMLExplore/Probability/ProductMeasure.lean: MeasureTheory.Measure.infinitePi_of_not_isProbabilityMeasure (the infinite product is 0 unless every factor is a probability measure), MeasureTheory.shift_iterate_eqOn (sequences that agree on the first t terms have shifts by s that agree on the first t - s), MeasureTheory.measurePreserving_shift_iterate, indepFun_initSeg_shift_iterate, lintegral_mul_comp_shift_iterate and integral_mul_comp_shift_iterate, about the shift (shift 𝓧)^[t] under Measure.infinitePi.
  • LMLExplore/Probability/Process/Stopping.lean: MeasureTheory.IsStoppingTime.measurable_nat, IsStoppingTime.natCast_min, IsStoppingTime.toNat_min (with the cast lemma ENat.natCast_toNat_min) and IsStoppingTime.eq_of_forall_le (the last one for Filtration.piLE).
  • LMLExplore/Logic/Function/DependsOn.lean: dependsOn_indicator_of_eqOn, for any Pi type and coordinate set s: if membership in A and f on A are determined by the coordinates in s, so is A.indicator f.
  • LMLExplore/MeasureTheory/Integral/EReal.lean: MeasureTheory.eintegral_le_of_forall_min_le, monotone convergence for the truncations min f k under ∫ᵉ, and MeasureTheory.eintegral_min_log_le_integral_truncLog_sub, mixing with a constant in expectation: ∫ᵉ min (log E) k ≤ ∫ truncLog k ((1 - ε) E + ε) - log (1 - ε) under a probability measure. The latter was a private lemma of LMLExplore/EValues/BipolarRate/Universal.lean, whose private copy is deleted; it is now used there and in StoppingTime.lean.
  • LMLExplore/EValues/BipolarRate/Basic.lean: ProbabilityTheory.coe_toReal_bipolarRate.

Roadmap coverage (EValues, Layer 6, item 3)

Covered: from the first bullet ("Lower bound"), the lower bound 𝔼_Q[τ + 1] ≥ log (1/α) / d for every level-α sequential test, for any S₁ and Q₁, with an infinite expectation when d = 0, and the Wald inequality 𝔼_Q[log E_τ] ≤ d 𝔼_Q[τ + 1] in EReal for every e-process and every stopping time with values in ℕ, with Statlib's ∫ᵉ on the left. The lower bound is derived from the Wald inequality, applied to the e-process ε + (1 - ε) α⁻¹ 𝟙{τ ≤ n} at the stopping times min τ k, as the roadmap describes. The form with KL_inf(Q₁, S₁) in place of d follows from bipolarRate_le_iInf_klDiv and is not stated separately.

Left: the almost sure form liminf (τ (exp (-n)) / n) ≥ 1 / KL_inf(Q₁, S₁) of the same bullet [ARR26, Theorem 3.1]; the second bullet (tests attaining the bound with d to first order); first passage times; the upper bound [ARR26, Theorem 4.1]; regret and follow-the-leader bets. Row R10 of the paper project does not contain them. The other half of row R10, the almost sure bound limsup (1/n) log (M n) ≤ d of Layer 6, item 1, is ported in a separate pull request.

Notes for reviewers

  • How the proof goes. A round is a duration σ ≥ 1, bounded, and a payoff V ≥ δ > 0, both determined by the observations of the round, with expectation at most 1 on each event {σ ≤ n} under the i.i.d. null. The round is restarted on the fresh observations each time it ends (Tau Ceti's TauCeti.Probability.shift, iterated). Within the first N observations, the geometric mixture over j of the products of the payoffs of the first j rounds, on the event that they end by time N, is an N-sample e-variable: by induction on j, splitting along the value t of the restart time, using that under an i.i.d. law the first t observations are independent of (shift 𝓧)^[t]. Its expected logarithm under Q is at most maxLogGrowth Q₁ S₁ N ≤ N d (eintegral_log_le_maxLogGrowth_of_dependsOn). Bounding the logarithm of the mixture below by its term at the number of completed rounds, and a Wald argument (the rounds that start within the first N observations use more than N of them), give 𝔼[truncated log V] ≤ d 𝔼[σ] as N → ∞. For the Wald inequality, the round is the e-process at min τ k mixed with a constant, (1 - ε) E_{min τ k} + ε; then k → ∞ (dominated convergence), the truncation level → ∞ (monotone convergence for ∫ᵉ) and ε → 0. The proof needs neither the law of large numbers nor the strong Markov property, and the case d = 0 with an infinite expectation of τ needs no separate argument, since the bound for min τ k is 0 for every k.
  • No published source. Both statements with the bipolar rate have no published source: the roadmap cites them [EVR26, Note 01], and the bounds of [ARR26] and [WSJ26] have KL_inf(Q₁, S₁), which can be larger [RR26, Proposition 5.4]. The proofs are rewrites of the Lean proofs of the paper project (EValuesResearch/Results/BipolarRate.lean, BipolarRateAux.lean), specialized to stopping times with values in ℕ and bounded rounds, which removes the infinite restart times and the separate argument for d = 0 of the source.
  • Deviations from the roadmap's wording.
    • The Wald inequality is written 𝔼[τ + 1] * d, not d 𝔼[τ + 1], as IsEProcess.eintegral_log_le_mul_bipolarRate writes (n + 1) * d.
    • The lower bound is a division in ℝ≥0∞, with log (1/α) as (ENNReal.log α⁻¹).toENNReal (so 0 for α ≥ 1 and ∞ for α = 0) and d as (bipolarRate Q₁ S₁).toENNReal. The product form log (1/α) ≤ d * 𝔼[τ + 1] in EReal would be false for d = 0, where 𝔼[τ + 1] = ∞ and 0 * ⊤ = 0.
    • The level is P^ℕ {τ ≠ ⊤} ≤ α, the roadmap's P (τ < ∞) ≤ α with LMLExplore's ≠ ⊤. The expected number of observations of a WithTop ℕ-valued τ is ∫⁻ ENat.toENNReal (τ ω) + 1, since WithTop ℕ has no coercion to ℝ≥0∞.
  • Hypotheses. The Wald inequality assumes nothing on Q₁: if Q₁ is not a probability measure, its i.i.d. law is 0 and both sides are 0. The lower bound needs IsProbabilityMeasure Q₁. Both need the members of S₁ to be probability measures: the e-process condition is about the laws P^ℕ, and d about the laws P^n.
  • General helpers. The general facts about the shift, about ℕ-valued stopping times and about the ∫ᵉ truncations are public, in the generic files listed above. sum_indicator_eq_indicator_le stays private: it is Mathlib's Finset.sum_ite_eq after unfolding Set.indicator.
  • Open pull requests. None of the open pull requests contains these statements or the helpers used here. The concurrent port of the other half of row R10 (the almost sure bound) can use the public facts on the shift under Measure.infinitePi in LMLExplore/Probability/ProductMeasure.lean.

Roadmap: EValues
Paper: RemyDegenne/evalues_research
Item: R10

🤖 Generated with Claude Code

https://claude.ai/code/session_0196ftMVbgjSJzPQEwdek3kM

…expected stopping times

For i.i.d. observations, an e-process E for the i.i.d. null of S₁ and a stopping time τ with
values in ℕ satisfy E_Q[log E_τ] ≤ E_Q[τ + 1] * bipolarRate Q₁ S₁ in EReal, with no
integrability assumption on τ. Its case of the e-process ε + (1 - ε) α⁻¹ 𝟙{τ ≤ n} gives the lower
bound log (1/α) / bipolarRate Q₁ S₁ ≤ E_Q[τ + 1] for every sequential test τ of level α.
EValues roadmap, Layer 6, item 3 (expected stopping times), first bullet.

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 Wald inequality ∫ᵉ log E_τ ≤ 𝔼_Q[τ+1]·d and the lower bound log(1/α)/d ≤ 𝔼_Q[τ+1] (in ℝ≥0∞) state what EValues Layer 6 item 3 asks for, and their edge cases (d=0, d=⊤, α=0, α≥1, non-probability Q₁) are right. DependsOnBefore and the round lemma's hypotheses are consumed and given a real witness in StoppingTime.lean, and no part of the result is hidden in assumptions.
🟡 reuse changes requested claude/claude-opus-5-5 StoppingTime.lean re-derives inline the mixing-in-expectation bound that Universal.lean already proves as a private lemma, which this PR left private while moving the rest of the truncLog API out of that file. No other located Mathlib or LMLExplore declaration duplicates the new API; Statlib and TauCeti sources were not available to check.
✅ scope approved claude/claude-opus-5-5 Delivers both target statements of EValues Layer 6, item 3, first bullet (README.md:984-995): the Wald inequality at the bipolar rate and the lower bound log(1/α)/d ≤ 𝔼_Q[τ+1], by the restart argument the roadmap describes. All helpers and the moves out of the private section of Universal.lean are on that path, so the PR is one topic.
✅ attribution approved claude/claude-opus-5-5 Round.lean and StoppingTime.lean credit [EVR26, Note 01] and the paper-project files they adapt (BipolarRate.lean, BipolarRateAux.lean, commit dd4072f), and cite [ARR26] and [RR26] for the KL_inf bounds. The helpers moved out of Universal.lean are routine, Universal.lean still credits the paper project for its proofs (lines 77-85), and the roadmap is credited only in the PR description.
✅ api-design approved claude/claude-opus-5-5 General helpers (shift/independence under infinitePi, ℕ-valued stopping-time lemmas, eintegral truncation monotone convergence, dependsOn_indicator_of_eqOn, truncLog) are public in generic homes, the remaining private helpers are specific to the restart argument or restate Mathlib's Finset.sum_ite_eq, and truncLog and DependsOnBefore have characterizing lemmas with @[simp] on their normal forms. Universal.lean's private copies were deleted with no compatibility surface left.
🟡 generality changes requested claude/claude-opus-5-5 Statements sit at the natural level and the general helpers are factored out once, but one helper is still proved twice: it stays private in Universal.lean and StoppingTime.lean proves it again inline.
✅ placement approved claude/claude-opus-5-5 The prior finding is resolved: ENat.natCast_toNat_min now lives in LMLExplore/Data/ENat/Basic.lean and Stopping.lean imports it. The other new material (TruncLog, the EReal integral truncation lemma, DependsOn indicator, shift lemmas in ProductMeasure, ℕ-valued stopping-time lemmas, round-specific DependsOnBefore in Round.lean) is in its natural home, and the added imports (e.g. FactorsThrough for dependsOn_of_piLE, StoppedValue for measurable_apply_of_countable) are used.
✅ naming approved claude/claude-opus-5-5 Names describe their conclusions in standard terminology and follow nearby declarations (measurable_nat/measurable_enat, natCast_min/min_natCast, eintegral_log_stoppedValue_le_mul_bipolarRate/eintegral_log_le_mul_bipolarRate). Namespaces are correct and no notation is introduced.
✅ documentation approved claude/claude-opus-5-5 Every new file has an accurate module docstring and every public declaration has a docstring that matches its statement. The edge cases described for the lower bound (d = 0, d = ∞, α = 0, α ≥ 1) agree with the ℝ≥0∞ statement, and nothing left in Universal.lean or ProductMeasure.lean is stale.
🟡 proof-quality changes requested claude/claude-opus-5-5 Proofs are mostly robust and well structured, with no undocumented change/show; however the mixing-with-a-constant-in-expectation step is re-derived inline in StoppingTime.lean while the identical lemma stays private in Universal.lean.

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

Reviewing this diff at head 959458a. rubrics @ 7d59664. CLI @ 7d59664. Review spend: $5.01.

@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 and others added 2 commits November 15, 2026 17:23
… its file

Move the facts on the shift under `Measure.infinitePi` to
`Probability/ProductMeasure.lean`, the `ℕ`-valued stopping-time lemmas to
`Probability/Process/Stopping.lean` and monotone convergence for truncations
under `∫ᵉ` to the new `MeasureTheory/Integral/EReal.lean`, all public. Use
Mathlib's `EReal.le_of_forall_lt_iff_le` and `Finset.sum_ite_eq` instead of
re-deriving them. Factor the repeated proof steps into lemmas and split the
long proofs. Cite [EVR26, Note 01] and the paper project the proofs are
adapted from. Move the restarted rounds and the Wald inequality for a round to
`EValues/BipolarRate/Round.lean`, keeping each new file under 1000 lines.

Co-Authored-By: Claude Code <noreply@github.com>
…ping-times

# Conflicts:
#	LMLExplore/Probability/ProductMeasure.lean
@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
- Delete the thin wrapper measurable_comp_shift_iterate and use
  measurable_apply_of_countable at its uses.
- Use IsStoppingTime.measurable_nat in Adapted.measurable_apply_stoppingTime.
- Add Measure.infinitePi_of_not_isProbabilityMeasure instead of unfolding
  Measure.infinitePi.
- Add integrable_truncLog_comp and a private integrable_natCast_of_le to
  remove the repeated bounded-integrability arguments.
- Add truncLog_def and the simp lemmas truncLog_zero and truncLog_top.
- Drop an unused import and make the shift import private in Round.lean.

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-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 labels Nov 15, 2026
…ping-times

# Conflicts:
#	LMLExplore/Probability/ProductMeasure.lean
@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-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 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
@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
abs_truncLog_le, integrable_truncLog_comp and the Wald inequality for a
round integral_truncLog_le_bipolarRate_mul no longer assume
log δ ≤ c, via the new lower bound ENNReal.min_log_le_truncLog.

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
@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
@lmlexplore-automation
lmlexplore-automation Bot added this pull request to the merge queue Nov 15, 2026
@lmlexplore-automation lmlexplore-automation Bot added ready-to-merge Current head passes all automated merge prerequisites; queue reservations may delay entry and removed awaiting-review CI is green; waiting for review verdicts labels Nov 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 15, 2026
@lmlexplore-automation
lmlexplore-automation Bot added this pull request to the merge queue Nov 15, 2026
@lmlexplore-automation

Copy link
Copy Markdown

⚠️ This PR no longer merges into main. Rebase it onto current main (or merge main into it) and push — nothing downstream can make progress until then, since a green build and an approving review on this head still cannot merge.

Do check what the conflict actually is before resolving it mechanically. If main has since landed its own version of something this PR adds, part of it may be superseded, and the right answer is to drop that part — or close the PR — rather than to reconcile the text. That is an authoring decision.

…ping-times

# Conflicts:
#	LMLExplore/Probability/ProductMeasure.lean
@RemyDegenne

Copy link
Copy Markdown
Contributor Author

Merged main (69fc27a) into this branch (959458a).

  • LMLExplore/Probability/ProductMeasure.lean: textual conflict; kept both main's MeasureTheory.dependsOn_comp_shift_iterate and this PR's shift_iterate_eqOn / indepFun_initSeg_shift_iterate / integral_mul_comp_shift_iterate, with module docs listing all of them.
  • LMLExplore/EValues/BipolarRate/StoppingTime.lean: LMLExplore.EValues.EProcess moved to LMLExplore.EValues.EProcess.Basic on main; import updated.
  • LMLExplore/EValues/BipolarRate/Universal.lean (new on main) carried private copies of declarations this PR makes public: the ENNReal.truncLog API (truncLog, measurable_truncLog, truncLog_of_ne, truncLog_top, truncLog_le, log_le_truncLog, ofReal_exp_truncLog_le, min_log_le_truncLog_sub), MeasureTheory.eintegral_le_of_forall_min_le and MeasureTheory.indepFun_initSeg_shift_iterate. The private copies are deleted and the file now imports LMLExplore.Analysis.SpecialFunctions.Log.TruncLog and LMLExplore.MeasureTheory.Integral.EReal. No public declaration is removed or renamed.

Local checks (not CI): scope: full: deleted module: LMLExplore/EValues/EProcess.lean, Build completed successfully (9123 jobs)., local-axioms: checked 44 changed module(s), 1311 declaration(s); 0 violation(s).

Make eintegral_min_log_le_integral_truncLog_sub public in
LMLExplore/MeasureTheory/Integral/EReal.lean, delete its private copy in
Universal.lean, and use it in the Wald inequality of StoppingTime.lean
instead of the inline re-derivation.

Co-Authored-By: Claude Code <noreply@github.com>

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

awaiting-review CI is green; waiting for review verdicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant