Ergodic theory in Lean 4
A Lean 4 / Mathlib formalization of parts of smooth and measurable ergodic theory: the Oseledets
multiplicative ergodic theorem (one-sided, two-sided, singular and continuous-time versions),
Kolmogorov–Sinai entropy theory up to Krieger's finite generator theorem, the Margulis–Ruelle
inequality and a version of Pesin's entropy formula, and Livšic theory. A separate library in the
same repository, OperatorEntropy, formalizes finite-dimensional quantum relative entropy (Lieb's
joint convexity, data processing, Petz's theorem, Alicki–Fannes entropy); it does not depend on
ErgodicTheory.
Blueprint · Blueprint (PDF) · Dependency graph
AI authorship
This project is 100% AI-written. All Lean code, all proofs, the blueprint and this documentation were generated by Anthropic's Claude models, working under the direction of the repository owner. Every proof is checked by Lean's kernel, so the proofs are correct relative to the Lean statements. Whether the Lean statements say what the surrounding prose claims has been audited by AI, not reviewed by a human expert. Read the Lean statement of any result you intend to rely on; the table below gives the hypotheses as they appear in the source.
Main results
Names are in the ErgodicTheory namespace (omitted), except those starting with
OperatorEntropy., which belong to the OperatorEntropy library and namespace. "a.e." is with
respect to the invariant measure; log⁺‖A‖ ∈ L¹ abbreviates IntegrableLogNorm A μ.
| Result | Lean declaration | Hypotheses |
|---|---|---|
| Oseledets MET, one-sided (filtration) | oseledets_filtration | μ probability, T ergodic; A : X → Mat_d(ℝ) measurable, det A(x) ≠ 0 for all x, log⁺‖A‖, log⁺‖A⁻¹‖ ∈ L¹. Gives exponents λ₁ > ⋯ > λ_k, a measurable flag, a.e. equivariant, with exact growth rates on each layer |
| Oseledets MET, two-sided (splitting) | oseledets_splitting, oseledets_splitting_angle | as above with T : X ≃ᵐ X invertible. Measurable equivariant direct sum ⊕ Eᵢ(x) with forward rate λᵢ and backward rate −λᵢ; the _angle version adds: angles between ⊕_{i∈I} Eᵢ and ⊕_{j∉I} Eⱼ are a.e. positive and (1/n) log sin∠ → 0 along orbits |
| Oseledets MET for singular cocycles | oseledets_filtration_singular | μ probability, T ergodic, A measurable, log⁺‖A‖ ∈ L¹; no invertibility. Exponents in [−∞, ∞), A(x)Vᵢ(x) ⊆ Vᵢ(Tx), rates in EReal with log 0 = −∞ |
| Oseledets MET for flows | oseledets_flow | ergodic measure-preserving ℝ-flow on a probability space with countably generated σ-algebra, jointly measurable in (t, x); jointly measurable GL_d(ℝ)-valued cocycle with log⁺‖A_s‖, log⁺‖A_s⁻¹‖ ≤ g, g' ∈ L¹ for s ∈ [0, 1]. Equivariance holds at every point and every time |
| Kingman; Furstenberg–Kesten | tendsto_kingman_ergodic_iInf, furstenbergKesten_norm_eq_iInf | Kingman: T ergodic, g an integrable subadditive cocycle with (1/n)∫gₙ bounded below; the a.e. limit is inf_n (1/n)∫gₙ. Furstenberg–Kesten: hypotheses of the first row; (1/n) log‖A⁽ⁿ⁾‖ converges a.e. to inf_n (1/n)∫log‖A⁽ⁿ⁾‖ |
| Kolmogorov–Sinai generator theorems | Entropy.ksEntropy_eq_ksEntropyPartition_of_generatingMod0, Entropy.ksEntropy_eq_ksEntropyPartition_of_isGeneratingTwoSidedMod0 | standard Borel probability space, T measure-preserving (an automorphism in the two-sided case), finite partition generating mod 0; no ergodicity. h(T) = h(T, P) |
| Shannon–McMillan–Breiman | Krieger.ae_tendsto_div_infoFun | standard Borel probability space, T ergodic, P a finite partition. −(1/n) log μ(Pₙ(x)) → h(T, P) a.e. |
| Abramov–Rokhlin formula | Entropy.abramov_rokhlin | factor map π from a measure-preserving system on a standard Borel probability space onto one on a countably generated probability space. h(T) = h(S) + h(T ∣ π⁻¹𝓑) in [0, ∞] |
| Krieger's finite generator theorem | Krieger.krieger_finite_generator | measure-preserving automorphism of a standard Borel probability space, ergodic, aperiodic, h(e) < log k (in EReal, so h(e) is finite). There is a two-sided generator mod 0 with k cells |
| Margulis–Ruelle inequality | margulisRuelle_sharp | T : ℝᵈ → ℝᵈ of class C¹, d ≥ 1, DT(x) invertible for all x; μ ergodic invariant probability with μ(Kᶜ) = 0 for a compact K; log⁺‖DT‖, log⁺‖DT⁻¹‖ ∈ L¹. h_μ(T) ≤ ∑ λᵢ⁺ |
| Pesin entropy formula, absolutely continuous case | sumAllExp_le_ksEntropy_le_sumPosExp, pesin_entropy_formula_of_ae_eq | T : ℝᵈ → ℝᵈ C¹, μ ergodic invariant probability, compact support, μ ≪ Lebesgue with log⁺(dμ/dx) ∈ L¹(μ); a finite partition on whose cells T is injective; a measurable invertible cocycle A with log⁺‖A‖, log⁺‖A⁻¹‖ ∈ L¹ and A = DT μ-a.e. Then ∑ λᵢ ≤ h_μ(T) ≤ ∑ λᵢ⁺ for any spectrum. h_μ(T) = ∑ λᵢ⁺ if all Lyapunov exponents of A are nonnegative (hspec) (pesin_entropy_formula_of_sign; pesin_entropy_formula_of_ae_eq is this case with log(dμ/dx) ∈ L¹(μ)) or all nonpositive; hspec holds iff inf_n (1/n) ∫ log‖(A⁽ⁿ⁾)⁻¹‖ dμ ≤ 0 (exponents_nonneg_iff_iInf_nonpos), e.g. if ‖v‖ ≤ ‖DₓT v‖ a.e. (pesin_entropy_formula_of_noncontracting); for d = 1 no spectral hypothesis is needed (pesin_entropy_formula_one_dim). Instances: Examples.Chebyshev.ksEntropy_chebN, h = log n for the Chebyshev polynomial Tₙ, n ≥ 2, with the arcsine law; Examples.Chebyshev.ksEntropy_chebProd, h = log m + log n for (x, y) ↦ (Tₘ(x), Tₙ(y)) on ℝ² (exponents log m, log n) |
| Arnold cat map | CatMapToral.catTorus_ksEntropy_eq, CatMapToral.catTorus_mixing | no hypotheses: h(cat) = log((3+√5)/2) for Haar measure on 𝕋² (direct computation: grid lower bound, Adler–Weiss partition upper bound); strong mixing for Haar measure |
| Livšic theorem, abstract | isHolderCoboundary_iff | compact metric X, T continuous with a dense forward orbit and an exponential closing property (a hypothesis, verified for the full shifts, subshifts of finite type, the doubling map and the cat map), φ r-Hölder, 0 < r ≤ 1. φ is a Hölder coboundary iff all periodic sums vanish |
| Livšic: measurable rigidity, suspension flows | Livsic.livsic_measurable_rigidity_biShift, livsic_holderFlow_constRoof | two-sided full shift on a finite alphabet with a fully supported Bernoulli measure, φ Hölder: a measurable a.e. solution exists iff periodic sums vanish. Suspension flow with roof 1 over a Lipschitz measurable automorphism T : X ≃ᵐ X of a compact metric space of diameter ≤ 1, with closing property and dense orbit, F Hölder for the Bowen–Walters metric: F is a Hölder flow coboundary iff the induced base observable has vanishing periodic sums |
| Dimension of Bernoulli measures | Multifractal.measureDimH_bern_eq_Hnu_div_log_two | any probability ν on a finite alphabet; one-sided shift with the metric 2^{−n}. dim_H(ν^ℕ) = dim_*(ν^ℕ) = H(ν)/log 2 |
| Data-processing inequality; Lieb | OperatorEntropy.KrausChannel.relEntropy_le, OperatorEntropy.Lieb.relEntropyMat_jointly_convex, OperatorEntropy.relEntropy_mix_le | DPI: every channel M_n → M_m in Kraus form, all density matrices, EReal-valued Umegaki relative entropy (⊤ when supp ρ ⊄ supp σ). Joint convexity: positive definite matrices (relEntropyMat_jointly_convex) and all density matrices with the EReal-valued relative entropy (relEntropy_mix_le) |
| Petz's theorem | OperatorEntropy.petz_recovery_iff | channel M_n → M_m in Kraus form, supp ρ ⊆ supp σ. The Petz map (generalised-inverse form) recovers ρ from Λρ iff D(Λρ‖Λσ) = D(ρ‖σ); for all states, it recovers ρ iff supp ρ ⊆ supp σ and D(Λρ‖Λσ) = D(ρ‖σ) (petz_recovery_iff_supportLE_and_relEntropy_eq) |
| Alicki–Fannes entropy, finite dimension | OperatorEntropy.AlickiFannes.alfDynamicalEntropy_eq_zero | any unital ⋆-endomorphism of M_d(ℂ) and any state: the Alicki–Fannes dynamical entropy is 0 (the correlation matrices have rank ≤ d²) |
| Alicki–Fannes entropy of classical systems | Quantum.ksEntropy_eq_alfDynamicalEntropy, Quantum.ksEntropy_eq_alfDynamicalEntropySimple | T measure-preserving on a probability space, viewed as (L^∞(μ), f ↦ f ∘ T, ∫ · dμ); partitions of unity are finite families of measurable f i : X → ℂ with ‖f i‖ ≤ 1 and ∑ ‖f i‖² = 1 a.e. h_KS(T) equals the Alicki–Fannes entropy over all such partitions of unity, and also over those whose functions take finitely many values |
Every declaration in this table is guarded in the axiom audit described below.
Scope and known limitations
- Smooth results live on
ℝᵈ, not on manifolds. The Margulis–Ruelle inequality and the Pesin formula are stated forC¹self-maps ofEuclideanSpace ℝ (Fin d)and invariant measures with compact support. Maps of the circle or the torus are therefore not instances: the doubling map and the cat map are treated by separate direct computations (Examples.Rokhlin.pesin_formula_doublingMap,CatMapToral.catTorus_ksEntropy_eq). The instances of the abstract Pesin theorem in the library are the Chebyshev polynomialsTₙ(n ≥ 2) onℝ¹with the arcsine law on[−1, 1], and the products(x, y) ↦ (Tₘ(x), Tₙ(y))onℝ²with the product arcsine law; all are polynomial maps, factors of toral endomorphisms throughθ ↦ cos 2πθ. For piecewise differentiable, uniformly expanding maps with an absolutely continuous ergodic measure and a partition generating mod 0,pesin_formula_expandinggivesh_μ(T) = ∑ λᵢ⁺ = ∫ log|det A| dμwithoutC¹or compact support; its instance is the doubling mapx ↦ 2x mod 1of[0, 1)(Examples.Rokhlin.ksEntropy_doublingInterval,h = log 2). - The Pesin formula is not the general theorem. Without a sign condition the library proves
only the two bounds
∑ λᵢ ≤ h_μ(T) ≤ ∑ λᵢ⁺(sumAllExp_le_ksEntropy_le_sumPosExp), which differ by−∑ λᵢ⁻. The equalitypesin_entropy_formula_of_ae_eqassumes that every Lyapunov exponent is nonnegative (hspec, equivalentlyinf_n (1/n) ∫ log‖(A⁽ⁿ⁾)⁻¹‖ dμ ≤ 0); the variants replacehspecby sufficient conditions or cover a nonpositive spectrum and dimension one. The general case of an absolutely continuous measure with exponents of both signs requires Ledrappier–Young theory, which is not formalized. All versions also assumeμ ≪ Lebesguewithlog⁺of the density integrable (the originalpesin_entropy_formula_of_ae_eqasks forlogintegrable), compact support, and a finite partition into injectivity domains ofT. Read the statement before quoting it. - Krieger's theorem is proved for ergodic, aperiodic automorphisms of standard Borel
probability spaces with
h < log k(strict, hence finite entropy). The countable-generator theorem (Krieger, Keane–Serafin) is not formalized. - Livšic for flows is proved for suspension flows with constant roof (and, in Hölder form, for
variable Lipschitz roofs,
livsic_holderFlow_varRoof); the abstract discrete theorem takes the closing property as a hypothesis. - Quantum layer. The
OperatorEntropylibrary is finite-dimensional (matrix algebras). The Connes–Narnhofer–Thirring entropy is not formalized; the Alicki–Fannes entropy is, and onM_d(ℂ)it is0for every dynamics (alfDynamicalEntropy_eq_zero). For a classical measure-preserving system,ErgodicTheory.Quantumdefines the Alicki–Fannes entropy of(L^∞(μ), f ↦ f ∘ T, ∫ · dμ)over finite bounded measurable partitions of unity and proves that it equals the Kolmogorov–Sinai entropy (ksEntropy_eq_alfDynamicalEntropy, Alicki–Fannes 1994). The quantum Bernoulli shift (quantumBernoulliShift) is a family of finite-level statesρ^{⊗n}on the matrix algebrasM_{2ⁿ}, consistent and shift invariant; the C*-inductive limit⊗_ℕ M₂is not constructed, and its mean entropy is a limit over the finite levels. Strong subadditivity of the von Neumann entropy is not formalized. - Prose-only remarks. The Takens–Verbitskiy remark that dynamical Rényi entropies of order
q ≠ 1are not monotone under general factor maps is stated in docstrings and the blueprint only; it is not a Lean theorem. Some module docstrings mention other standard facts that are not formalized; only Lean declarations count. - Code quality. Both libraries build with Mathlib's standard linter set and warnings as
errors. Mathlib's environment linter (
lake exe runLinter ErgodicTheoryandlake exe runLinter OperatorEntropy, ormake lint) reports no findings. SevenmaxHeartbeatsbumps (to 1.6M or 3.2M) remain, each with a justifying comment; see docs/mathlib-conventions.md.
Size
| Library | Modules | Lines | theorem/lemma | def/abbrev | structures and classes |
|---|---|---|---|---|---|
ErgodicTheory | 389 | about 113,600 | 3,881 | 657 | 29 |
OperatorEntropy | 66 | about 16,200 | 683 | 130 | 5 |
Root files (ErgodicTheory.lean, OperatorEntropy.lean) are not counted. Module renames since
the tag v4.36.0 are listed in docs/module-renames.md. Counted, for
D = ErgodicTheory and D = OperatorEntropy, by
F=$(find $D -name '*.lean'); echo "$F" | wc -l; cat $F | wc -l
cat $F | grep -cE '^\s*(@\[[^]]*\]\s*)?(private |protected )?(noncomputable )?(theorem|lemma) '
cat $F | grep -cE '^\s*(@\[[^]]*\]\s*)?(private |protected )?(noncomputable )?(def|abbrev) '
cat $F | grep -cE '^\s*(structure|class) '
Using it as a dependency
Add to your lakefile.toml (this provides both libraries, ErgodicTheory and
OperatorEntropy):
[[require]]
name = "ErgodicTheory"
git = "https://github.com/marcmorningstar/lean4-ergodic-theory.git"
rev = "v4.36.0"
Release tags follow the Lean toolchain version, as in Mathlib and Batteries: the tag v4.36.0 is
the release for Lean 4.36.0 and Mathlib v4.36.0. Your project must use the same Lean and Mathlib
versions.
Building
Lean v4.36.0 (lean-toolchain) and Mathlib v4.36.0 (exact commit in lake-manifest.json).
lake exe cache get # download the precompiled Mathlib cache
lake build # builds both libraries and the axiom audit
Both libraries use the Lean module system (module headers, public import, as in Mathlib); they
can be imported from module and from non-module files.
The blueprint (requires a TeX distribution, graphviz and pip install leanblueprint):
leanblueprint pdf && leanblueprint web # writes blueprint/lean_decls
lake exe checkdecls blueprint/lean_decls # every \lean{...} name exists
Axiom audit
test/AxiomAudit.lean is a separate library that is built by every lake build. For 935
declarations, including all of the above, it contains a block
/-- info: 'ErgodicTheory.oseledets_filtration' depends on axioms: [propext, Classical.choice, Quot.sound] -/
#guard_msgs in
#print axioms ErgodicTheory.oseledets_filtration
so the build fails if any of them depends on sorryAx or on any axiom beyond the three standard
ones. The audit says nothing about whether a statement is the intended one; that is what the table
above and the blueprint are for. CI runs lake build (including the audit) and checkdecls on
every push to main and every pull request.
Layout
ErgodicTheory/
Cocycle/ Ergodic/ linear cocycles, Birkhoff, Kingman, Furstenberg–Kesten
Lyapunov/ Lyapunov exponents and the one-sided MET
Filtration/ Forward/ Ruelle/ reductions of the filtration theorem, forward flag, Ruelle bounds
Singular/ singular cocycles: exponents, Kernel/, Rank/, Borel/ measurability
Extensions/ spectrum, exponent sums, det identity, inverse, restriction, ...
TwoSided/ two-sided splitting
Continuous/ flows and the flow MET; Entropy/ (Abramov flow entropy)
Suspension/ suspension flows: Cocycle/, Exponent/, Metric/, TimeOne/, Livsic/
Entropy/ Kolmogorov–Sinai entropy, generators, Abramov–Rokhlin
Partition/ Conditional/ static and conditional Shannon entropy of partitions
KolmogorovSinai/ Relative/ KS entropy and relative (conditional) KS entropy
Product/ Ruelle/ products with identity factors; Margulis–Ruelle inequality
Krieger/ Krieger's generator theorem; Tower/, SMB/, Coding/
Smooth/ Examples/ derivative cocycle, Pesin formula; doubling, Chebyshev, CatMap/
Livsic/ Livšic theory; BiShift/, Rigidity/, Flow/
Multifractal/ Rényi entropies and dimensions; Bernoulli/, Renyi/, Flow/
MeasureTheory/ descriptive set theory
Quantum/ Alicki–Fannes entropy of classical systems vs. Kolmogorov–Sinai
entropy (the only modules importing OperatorEntropy)
OperatorEntropy/ library OperatorEntropy: quantum relative entropy; Lieb/,
DataProcessing/, Petz/, AlickiFannes/, GrowingTower/, Analysis/
test/AxiomAudit.lean axiom audit
blueprint/ leanblueprint sources and bibliography
License and citation
Apache 2.0, see LICENSE. To cite this repository use the metadata in CITATION.cff (GitHub shows a "Cite this repository" button). Changes between versions are listed in CHANGELOG.md.