Repository navigation
refactor: adopt Statlib's Bernoulli measure lemmas and Bernoulli kernel - #354
RemyDegenne wants to merge 2 commits into
Conversation
Import Statlib.ForMathlib.Probability.Distributions.Bernoulli in LMLExplore/Probability/Distributions/Bernoulli.lean and delete the LMLExplore copies of lemmas it provides: lintegral_bernoulliMeasure, bernoulliMeasure_symm (now bernoulliMeasure_swap) and bernoulliMeasure_eq_smul_add_smul. Rename LMLExplore's more general bernoulliMeasure_absolutelyContinuous to bernoulliMeasure_absolutelyContinuous_of_imp, since Statlib owns the name. Define LMLExplore.bernoulliKernel as Statlib's bernoulliKernel 1 0 precomposed with the clamp Set.projIcc 0 1, and prove bernoulliKernel_comp from bernoulliKernel_comp_eq_bernoulliMeasure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0196ftMV379vy48QfzHBVNvo
There was a problem hiding this comment.
🟡 proof-quality — request_changes claude/claude-opus-5-5
Undocumented defeq: bernoulliKernel_apply is still (rfl) even though bernoulliKernel is now Kernel.comap of Statlib's kernel; other proofs are acceptable.
LMLExplore/Probability/Distributions/Bernoulli.lean:163—bernoulliKernel_applyis closed by(rfl), which unfolds bothKernel.comapand Statlib'sProbabilityTheory.bernoulliKerneldefinition. Changing either wrapper upstream would break it. Fix: Prove it by rewriting with the API lemmas instead:by rw [bernoulliKernel, Kernel.comap_apply, ProbabilityTheory.bernoulliKernel_apply](orsimp [bernoulliKernel]).
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 · 20s · 99.6k in (89.7k cache read, 9.8k cache write) / 1.9k out tokens · reviewing this diff · rubric
AI review — changes requestedEach 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.
♻️ = approved on an earlier commit, re-run before merge. Reviewing this diff at head |
…I lemmas Co-Authored-By: Claude Code <noreply@github.com>
Statlib's new
Statlib/ForMathlib/Probability/Distributions/Bernoulli.leanprovides several lemmas thatLMLExplore/Probability/Distributions/Bernoulli.leanalso had, three of them under the same fully qualified name, so the two files could not be imported together. This PR makesLMLExplore/Probability/Distributions/Bernoulli.leanimport the Statlib file (in place ofTauCeti.Probability.Distributions.Bernoulli.Measurabilityand the redundantMathlib.Probability.Distributions.Bernoulli), deletes the LMLExplore copies, and moves every use to the Statlib declarations.Removed or renamed public declarations
ProbabilityTheory.lintegral_bernoulliMeasure(LMLExplore)ProbabilityTheory.lintegral_bernoulliMeasure(Statlib). Same name and statement, so the use inSequentialLearning/BernoulliDeviation.leanneeds no change.ProbabilityTheory.bernoulliMeasure_symm x y p : Ber(x, y, σ p) = Ber(y, x, p)ProbabilityTheory.bernoulliMeasure_swap y x p(Statlib)ProbabilityTheory.bernoulliMeasure_eq_smul_add_smul(LMLExplore: weightsa b : ℝ≥0witha + b = 1, acting throughℝ≥0∞)ProbabilityTheory.bernoulliMeasure_eq_smul_add_smul(Statlib: weightstand1 - twitht ≤ 1). Its only use,LMLExplore.klBer_mul_add_mul_le, now passest := aand rewrites1 - a = b.ProbabilityTheory.bernoulliMeasure_absolutelyContinuous(LMLExplore)ProbabilityTheory.bernoulliMeasure_absolutelyContinuous_of_imp, since Statlib owns the name (see below).What stays in LMLExplore
bernoulliMeasure_absolutelyContinuous_of_imp:Ber(x, y, p) ≪ Ber(x, y, q)fromq = 0 → p = 0andq = 1 → p = 1, with noMeasurableSingletonClassand nox ≠ y. Statlib'sbernoulliMeasure_absolutelyContinuousassumes[MeasurableSingletonClass 𝓧],x ≠ y,q ≠ 0andq ≠ 1. Both implications then hold vacuously, so Statlib's lemma is a special case of this one. Its docstring now names the difference.bernoulliMeasure_absolutelyContinuous_iff,integrableExpSet_bernoulliMeasure,tilted_bernoulliMeasure,LMLExplore.ae_mem_uIcc_bernoulliMeasureandLMLExplore.hasSubgaussianMGF_bernoulliMeasure, which have no Statlib counterpart. They are unchanged.LMLExplore.bernoulliKernel : Kernel ℝ ℝ,x ↦ Ber(1, 0, projIcc x), withbernoulliKernel_apply(stillrfl), itsIsMarkovKernelinstance andbernoulliKernel_compfor laws onℝsupported on[0, 1].LMLExplore.klBer_integral_le_klDivuses this statement. The kernel is now defined as(ProbabilityTheory.bernoulliKernel (1 : ℝ) 0).comap (Set.projIcc 0 1 zero_le_one) _.bernoulliKernel_compis now proved from Statlib'sbernoulliKernel_comp_eq_bernoulliMeasure, applied to the image ofρunder the clamp, which replaces the earlier hand computation of the two masses. The kernel is still a separate object from Statlib's, because it is defined onℝrather than onI.The module docstring now says what the file adds to the Statlib file, and its list of main statements drops the removed lemmas.
Checks run
scripts/build.sh --iofailon the whole library: succeeds, with no warnings.#lint in LMLExplore, run from a scratch file that imports the two changed modules: no errors.grepoverLMLExplore/:bernoulliMeasure_symmno longer appears anywhere.bernoulliMeasure_absolutelyContinuousappears only in the new docstring, which names Statlib's lemma on purpose.Fixes #330
Roadmap: none
🤖 Generated with Claude Code
https://claude.ai/code/session_0196ftMV379vy48QfzHBVNvo