Repository navigation
refactor: adopt Statlib's klBerReal - #378
Merged
lmlexplore-automation[bot] merged 2 commits intoNov 14, 2026
Merged
lmlexplore-automation[bot] merged 2 commits into
lmlexplore-automation[bot] merged 2 commits into
Conversation
Import Statlib.ForMathlib.InformationTheory.KullbackLeibler.Bernoulli in LMLExplore/InformationTheory/KullbackLeibler/Bernoulli.lean and delete LMLExplore.klBerReal with the lemmas Statlib provides: klBerReal_def (now klBerReal_apply), klBerReal_self, klBerReal_one_left, klBerReal_one_sub_one_sub (now klBerReal_one_sub) and klBerReal_eq_neg_binEntropy_sub. Every other klBerReal lemma of LMLExplore is now about InformationTheory.klBerReal; files that use it open InformationTheory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0196ftMV379vy48QfzHBVNvo
RemyDegenne
commented
Nov 14, 2026
RemyDegenne
commented
Nov 14, 2026
Contributor
Author
AI review — approvedEach 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 |
Rename LMLExplore.klBerReal_nonneg to klBerReal_nonneg_of_klBer_ne_top so it no longer shares a name with Statlib's InformationTheory.klBerReal_nonneg, and use Statlib's klBerReal_eq_of_ne in klBer_add_klBer_le. Co-Authored-By: Claude Code <noreply@github.com>
Merged
via the queue into
LeanMachineLearning:main
with commit Nov 14, 2026
2e0e3ce
24 of 27 checks passed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Statlib's
Statlib/ForMathlib/InformationTheory/KullbackLeibler/Bernoulli.leandefines the real binary relative entropyInformationTheory.klBerReal p q = p * log (p / q) + (1 - p) * log ((1 - p) / (1 - q))with the same body asLMLExplore.klBerReal, and five of its basic lemmas. This PR makesLMLExplore/InformationTheory/KullbackLeibler/Bernoulli.leanimport that Statlib file, deletes the LMLExplore copies, and moves every use to the Statlib declarations. The files that useklBerRealwithout already openingInformationTheorynow open it:Bandits/Concentration.lean,Bandits/KLUCB.lean,InformationTheory/KrichevskyTrofimov.lean,Probability/Distributions/ExponentialFamily/Bernoulli.lean,Probability/Moments/KLChernoff.leanandSequentialLearning/BernoulliDeviation.lean.Now that #354 has merged, the Statlib file can be imported: it imports Statlib's Bernoulli file, which used to clash with
LMLExplore/Probability/Distributions/Bernoulli.lean.Removed public declarations
LMLExplore.klBerRealInformationTheory.klBerReal(same body, so the two are definitionally equal)LMLExplore.klBerReal_defInformationTheory.klBerReal_applyLMLExplore.klBerReal_selfInformationTheory.klBerReal_self(also@[simp])LMLExplore.klBerReal_one_leftInformationTheory.klBerReal_one_left(also@[simp])LMLExplore.klBerReal_one_sub_one_subInformationTheory.klBerReal_one_sub. Same statement, but Statlib's lemma is not@[simp]. No simp call in LMLExplore needed it.LMLExplore.klBerReal_eq_neg_binEntropy_sub(right-hand side-binEntropy p - (p * log q + (1 - p) * log (1 - q)))InformationTheory.klBerReal_eq_neg_binEntropy_sub(right-hand side-binEntropy p - p * log q - (1 - p) * log (1 - q)). The four uses, in the continuity, derivative and strict convexity proofs, recover the old form with.trans (sub_sub _ _ _).Renamed public declarations
LMLExplore.klBerReal_nonnegLMLExplore.klBerReal_nonneg_of_klBer_ne_top(same statement; renamed so that a bareklBerReal_nonnegunderopen InformationTheoryno longer has two candidates with different hypotheses)klBer_add_klBer_lenow uses Statlib'sInformationTheory.klBerReal_eq_of_neinstead of re-deriving it.What stays in LMLExplore
ℝ≥0∞-valuedLMLExplore.klBerand its whole API:klDiv_bernoulliMeasure(klDiv Ber(x, y, p) Ber(x, y, q) = klBer p qfor allp q : I, including the infinite cases, so Statlib'sklDiv_bernoulliMeasure_eq_klBerReal, which assumesq ∉ {0, 1}, is a special case of it together withklBer_eq_ofReal_klBerReal), the data processing inequalities,klUpper,klLower, monotonicity, convexity, continuity and measurability. Statlib, LML, Tau Ceti and Mathlib have noklBer.LMLExplore.klBerReal_nonneg, renamed toLMLExplore.klBerReal_nonneg_of_klBer_ne_top(see below). It only assumesp, q ∈ [0, 1]andklBer p q ≠ ∞, so it is more general than Statlib'sInformationTheory.klBerReal_nonneg(which assumes0 < q < 1).klBerReal_*lemmas, which have no Statlib counterpart:klBerReal_eq_zero_iff,klBerReal_le_sq_sub_div,two_mul_sq_le_klBerReal,mul_klBerReal_div_eq_log, continuity, derivatives, strict monotonicity and convexity,klBerReal_one_sub_right, the limits at0and1,mul_klFun_div_le_klBerReal, and so on. They are unchanged, but are now stated aboutInformationTheory.klBerReal.The module docstring now names the Statlib definition and its basic API, and its list of definitions and main statements drops the removed declarations.
Checks run
scripts/build.sh --iofailon the whole library (8551 jobs): succeeds, with no warnings.#lint in LMLExplore, run from a scratch file that imports the eight changed modules: all checks pass.lake exe axioms: no duplicate declarations against the 5613 dependency modules, and every declaration is within the allowlist.grepoverLMLExplore/:klBerReal_def,klBerReal_one_sub_one_subandLMLExplore.klBerRealno longer appear anywhere.Fixes #331
Roadmap: none
🤖 Generated with Claude Code