Repository navigation
feat: the Wald inequality at the bipolar rate and the lower bound on expected stopping times #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RemyDegenne
wants to merge
15
commits into
LeanMachineLearning:main
Choose a base branch
from
RemyDegenne:evr/bipolar-rate-stopping-times
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9e87f47
feat: the Wald inequality at the bipolar rate and the lower bound on …
RemyDegenne 96cbf0f
refactor: expose the general helpers of the Wald inequality and split…
RemyDegenne 11205fd
Merge remote-tracking branch 'origin/main' into evr/bipolar-rate-stop…
RemyDegenne a861ea3
refactor: address review on the Wald inequality at the bipolar rate
RemyDegenne a759378
Merge remote-tracking branch 'origin/main' into evr/bipolar-rate-stop…
RemyDegenne 5c1610d
Merge remote-tracking branch 'origin/main' into evr/bipolar-rate-stop…
RemyDegenne 54afa21
refactor: export dependsOn_indicator_of_eqOn and shift_iterate_eqOn
RemyDegenne 7bcde86
Merge remote-tracking branch 'origin/main' into evr/bipolar-rate-stop…
RemyDegenne 4eada51
refactor: move truncLog to a generic file and factor two helpers
RemyDegenne 7ed4eb9
Merge remote-tracking branch 'origin/main' into evr/bipolar-rate-stop…
RemyDegenne 324e88e
refactor: drop the truncation-level assumption from the truncLog bounds
RemyDegenne 8316990
Merge remote-tracking branch 'origin/main' into evr/bipolar-rate-stop…
RemyDegenne daa6239
refactor: move ENat.natCast_toNat_min to an ENat file
RemyDegenne 959458a
Merge remote-tracking branch 'origin/main' into evr/bipolar-rate-stop…
RemyDegenne f5956bc
refactor: share the mixing-with-a-constant bound for extended integrals
RemyDegenne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| /- | ||
| Copyright (c) 2026 LMLExplore contributors. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: LMLExplore contributors | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.Analysis.SpecialFunctions.Log.ENNRealLogExp | ||
| public import Mathlib.MeasureTheory.Constructions.BorelSpace.Real | ||
| public import Mathlib.MeasureTheory.Integral.IntegrableOn | ||
|
|
||
| /-! | ||
| # The truncated logarithm of an extended nonnegative real | ||
|
|
||
| `ENNReal.truncLog c x` is the logarithm `ENNReal.log x` of `x : ℝ≥0∞` truncated above at `c : ℝ`, | ||
| as a real number: `(min (log x) c).toReal`. It is `c` at `∞` and `0` at `0` (the real part of | ||
| `log 0 = ⊥`), and `min (Real.log x.toReal) c` otherwise. Unlike `ENNReal.log`, it is a real | ||
| function, bounded on `{x | δ ≤ x}` for `δ > 0`, hence integrable under a finite measure when | ||
| composed with a measurable function bounded below by `δ`. | ||
|
|
||
| ## Main definitions | ||
|
|
||
| * `ENNReal.truncLog c x`: the logarithm of `x : ℝ≥0∞` truncated above at `c`, as a real number. | ||
|
|
||
| ## Main statements | ||
|
|
||
| * `ENNReal.truncLog_of_ne`: `truncLog c x = min (Real.log x.toReal) c` for `x ≠ 0, ∞`. | ||
| * `ENNReal.abs_truncLog_le`, `ENNReal.integrable_truncLog_comp`: on `{x | δ ≤ x}`, the truncated | ||
| logarithm is bounded, hence integrable under a finite measure. | ||
| * `ENNReal.ofReal_exp_truncLog_le`: `exp (truncLog c x) ≤ x`. | ||
| * `ENNReal.min_log_le_truncLog_sub`: mixing `x` with a constant `ε` costs at most `- log (1 - ε)` | ||
| in truncated logarithm. | ||
| -/ | ||
|
|
||
| public section | ||
|
|
||
| open MeasureTheory | ||
|
|
||
| open scoped ENNReal | ||
|
|
||
| namespace ENNReal | ||
|
|
||
| /-- The logarithm truncated above at `c`, as a real number. -/ | ||
| noncomputable def truncLog (c : ℝ) (x : ℝ≥0∞) : ℝ := (min (ENNReal.log x) c).toReal | ||
|
|
||
| /-- The definition of the truncated logarithm, `truncLog c x = (min (log x) c).toReal`. -/ | ||
| lemma truncLog_def (c : ℝ) (x : ℝ≥0∞) : truncLog c x = (min (ENNReal.log x) c).toReal := by | ||
| rw [truncLog] | ||
|
|
||
| /-- The truncated logarithm is measurable. -/ | ||
| lemma measurable_truncLog (c : ℝ) : Measurable (truncLog c) := | ||
| measurable_ereal_toReal.comp (ENNReal.measurable_log.min measurable_const) | ||
|
|
||
| /-- The truncated logarithm of a positive finite number. -/ | ||
| lemma truncLog_of_ne {c : ℝ} {x : ℝ≥0∞} (h0 : x ≠ 0) (htop : x ≠ ∞) : | ||
| truncLog c x = min (Real.log x.toReal) c := by | ||
| rw [truncLog, ENNReal.log_pos_real h0 htop, ← EReal.coe_strictMono.monotone.map_min, | ||
| EReal.toReal_coe] | ||
|
|
||
| /-- The truncated logarithm of `∞` is the truncation level. -/ | ||
| @[simp] | ||
| lemma truncLog_top (c : ℝ) : truncLog c ∞ = c := by simp [truncLog] | ||
|
|
||
| /-- The truncated logarithm of `0` is `0`, the real part of `⊥ = log 0`. -/ | ||
| @[simp] | ||
| lemma truncLog_zero (c : ℝ) : truncLog c 0 = 0 := by simp [truncLog] | ||
|
|
||
| /-- The truncated logarithm is at most the truncation level. -/ | ||
| lemma truncLog_le {c : ℝ} {x : ℝ≥0∞} (h0 : x ≠ 0) : truncLog c x ≤ c := by | ||
| by_cases htop : x = ∞ | ||
| · rw [htop, truncLog_top] | ||
| · rw [truncLog_of_ne h0 htop] | ||
| exact min_le_right _ _ | ||
|
|
||
| /-- The truncated logarithm of `x ≥ δ` is at least `min (log δ) c`. -/ | ||
| lemma min_log_le_truncLog {c δ : ℝ} (hδ : 0 < δ) {x : ℝ≥0∞} (hx : ENNReal.ofReal δ ≤ x) : | ||
| min (Real.log δ) c ≤ truncLog c x := by | ||
| have h0 : x ≠ 0 := (lt_of_lt_of_le (ENNReal.ofReal_pos.2 hδ) hx).ne' | ||
| by_cases htop : x = ∞ | ||
| · rw [htop, truncLog_top] | ||
| exact min_le_right _ _ | ||
| · rw [truncLog_of_ne h0 htop] | ||
| exact min_le_min_right c (Real.log_le_log hδ ((ENNReal.ofReal_le_iff_le_toReal htop).1 hx)) | ||
|
|
||
| /-- The truncated logarithm of `x ≥ δ` is at least `log δ`, if `log δ ≤ c`. -/ | ||
| lemma log_le_truncLog {c δ : ℝ} (hδ : 0 < δ) {x : ℝ≥0∞} (hx : ENNReal.ofReal δ ≤ x) | ||
| (hc : Real.log δ ≤ c) : Real.log δ ≤ truncLog c x := | ||
| (min_eq_left hc).symm.le.trans (min_log_le_truncLog hδ hx) | ||
|
|
||
| /-- The truncated logarithm of `x ≥ δ` is bounded in absolute value. -/ | ||
| lemma abs_truncLog_le {c δ : ℝ} (hδ : 0 < δ) {x : ℝ≥0∞} (hx : ENNReal.ofReal δ ≤ x) : | ||
| |truncLog c x| ≤ max |Real.log δ| |c| := | ||
| abs_le.2 ⟨(le_min ((neg_le_neg (le_max_left _ _)).trans (neg_abs_le _)) | ||
| ((neg_le_neg (le_max_right _ _)).trans (neg_abs_le _))).trans (min_log_le_truncLog hδ hx), | ||
| (truncLog_le (lt_of_lt_of_le (ENNReal.ofReal_pos.2 hδ) hx).ne').trans | ||
| ((le_abs_self c).trans (le_max_right _ _))⟩ | ||
|
|
||
| /-- The truncated logarithm of a measurable function bounded below by `δ > 0` is integrable | ||
| under a finite measure. -/ | ||
| lemma integrable_truncLog_comp {Ω : Type*} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} | ||
| [IsFiniteMeasure μ] {c δ : ℝ} (hδ : 0 < δ) {V : Ω → ℝ≥0∞} (hVm : Measurable V) | ||
| (hVδ : ∀ ω, ENNReal.ofReal δ ≤ V ω) : | ||
| Integrable (fun ω ↦ truncLog c (V ω)) μ := | ||
| Integrable.of_bound ((measurable_truncLog c).comp hVm).aestronglyMeasurable | ||
| (max |Real.log δ| |c|) (ae_of_all _ fun ω ↦ (Real.norm_eq_abs _).trans_le | ||
| (abs_truncLog_le hδ (hVδ ω))) | ||
|
|
||
| /-- The exponential of the truncated logarithm of `x` is at most `x`. -/ | ||
| lemma ofReal_exp_truncLog_le {c : ℝ} {x : ℝ≥0∞} (h0 : x ≠ 0) : | ||
| ENNReal.ofReal (Real.exp (truncLog c x)) ≤ x := by | ||
| by_cases htop : x = ∞ | ||
| · rw [htop] | ||
| exact le_top | ||
| · rw [truncLog_of_ne h0 htop] | ||
| calc ENNReal.ofReal (Real.exp (min (Real.log x.toReal) c)) | ||
| _ ≤ ENNReal.ofReal (Real.exp (Real.log x.toReal)) := | ||
| ENNReal.ofReal_le_ofReal (Real.exp_le_exp.2 (min_le_left _ _)) | ||
| _ = x := by | ||
| rw [Real.exp_log (ENNReal.toReal_pos h0 htop), ENNReal.ofReal_toReal htop] | ||
|
|
||
| /-- Mixing with a constant: `min (log x) c ≤ truncLog c ((1 - ε) x + ε) - log (1 - ε)`. -/ | ||
| lemma min_log_le_truncLog_sub {ε : ℝ} (hε0 : 0 < ε) (hε1 : ε < 1) (c : ℝ) (x : ℝ≥0∞) : | ||
| min (ENNReal.log x) c ≤ | ||
| ((truncLog c (ENNReal.ofReal (1 - ε) * x + ENNReal.ofReal ε) - Real.log (1 - ε) : ℝ) : | ||
| EReal) := by | ||
| have hlog : Real.log (1 - ε) ≤ 0 := Real.log_nonpos (by linarith) (by linarith) | ||
| by_cases h0 : x = 0 | ||
| · simp [h0] | ||
| by_cases htop : x = ∞ | ||
| · have : ENNReal.ofReal (1 - ε) * x + ENNReal.ofReal ε = ∞ := by | ||
| rw [htop, ENNReal.mul_top (ENNReal.ofReal_pos.2 (by linarith)).ne', top_add] | ||
| rw [this, truncLog_top] | ||
| exact (min_le_right _ _).trans (EReal.coe_le_coe_iff.2 (by linarith)) | ||
| have hε' : ENNReal.ofReal ε ≠ 0 := (ENNReal.ofReal_pos.2 hε0).ne' | ||
| have hV0 : ENNReal.ofReal (1 - ε) * x + ENNReal.ofReal ε ≠ 0 := by simp [hε'] | ||
| have hVtop : ENNReal.ofReal (1 - ε) * x + ENNReal.ofReal ε ≠ ∞ := | ||
| ENNReal.add_ne_top.2 ⟨ENNReal.mul_ne_top ENNReal.ofReal_ne_top htop, ENNReal.ofReal_ne_top⟩ | ||
| have hVreal : (ENNReal.ofReal (1 - ε) * x + ENNReal.ofReal ε).toReal = | ||
| (1 - ε) * x.toReal + ε := by | ||
| rw [ENNReal.toReal_add (ENNReal.mul_ne_top ENNReal.ofReal_ne_top htop) ENNReal.ofReal_ne_top, | ||
| ENNReal.toReal_mul, ENNReal.toReal_ofReal (by linarith), ENNReal.toReal_ofReal hε0.le] | ||
| rw [truncLog_of_ne hV0 hVtop, hVreal, ENNReal.log_pos_real h0 htop, | ||
| ← EReal.coe_strictMono.monotone.map_min, EReal.coe_le_coe_iff] | ||
| have hx : 0 < x.toReal := ENNReal.toReal_pos h0 htop | ||
| have hL : Real.log (1 - ε) + Real.log x.toReal ≤ Real.log ((1 - ε) * x.toReal + ε) := by | ||
| rw [← Real.log_mul (by linarith) hx.ne'] | ||
| exact Real.log_le_log (_root_.mul_pos (by linarith) hx) (by linarith) | ||
| rw [← min_sub_sub_right] | ||
| exact le_min ((min_le_left _ _).trans (by linarith)) ((min_le_right _ _).trans (by linarith)) | ||
|
|
||
| end ENNReal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /- | ||
| Copyright (c) 2026 LMLExplore contributors. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: LMLExplore contributors | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.Data.ENat.Basic | ||
|
|
||
| /-! | ||
| # The minimum of an extended natural number and a natural number | ||
|
|
||
| ## Main statements | ||
|
|
||
| * `ENat.natCast_toNat_min`: the minimum of `t : WithTop ℕ` and the cast `(n : WithTop ℕ)` is | ||
| finite, so its value as a natural number casts back to it. | ||
| -/ | ||
|
|
||
| public section | ||
|
|
||
| namespace ENat | ||
|
|
||
| /-- The minimum of `t : WithTop ℕ` and the cast `(n : WithTop ℕ)` is finite, so its value as a | ||
| natural number casts back to it. -/ | ||
| theorem natCast_toNat_min (t : WithTop ℕ) (n : ℕ) : | ||
| ((ENat.toNat (min t n) : ℕ) : WithTop ℕ) = min t n := | ||
| ENat.natCast_toNat (ne_top_of_le_ne_top (ENat.natCast_ne_top n) (min_le_right _ _)) | ||
|
|
||
| end ENat |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.