[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"ZYun1Muoda":3},"# Ergodic theory in Lean 4\n\n[![Build](https://github.com/marcmorningstar/lean4-ergodic-theory/actions/workflows/push.yml/badge.svg)](https://github.com/marcmorningstar/lean4-ergodic-theory/actions/workflows/push.yml)\n[![Blueprint](https://github.com/marcmorningstar/lean4-ergodic-theory/actions/workflows/blueprint.yml/badge.svg)](https://github.com/marcmorningstar/lean4-ergodic-theory/actions/workflows/blueprint.yml)\n\nA Lean 4 / Mathlib formalization of parts of smooth and measurable ergodic theory: the Oseledets\nmultiplicative ergodic theorem (one-sided, two-sided, singular and continuous-time versions),\nKolmogorov–Sinai entropy theory up to Krieger's finite generator theorem, the Margulis–Ruelle\ninequality and a version of Pesin's entropy formula, and Livšic theory. A separate library in the\nsame repository, `OperatorEntropy`, formalizes finite-dimensional quantum relative entropy (Lieb's\njoint convexity, data processing, Petz's theorem, Alicki–Fannes entropy); it does not depend on\n`ErgodicTheory`.\n\n[Blueprint](https://marcmorningstar.github.io/lean4-ergodic-theory/blueprint/) ·\n[Blueprint (PDF)](https://marcmorningstar.github.io/lean4-ergodic-theory/blueprint.pdf) ·\n[Dependency graph](https://marcmorningstar.github.io/lean4-ergodic-theory/blueprint/dep_graph_document.html)\n\n## AI authorship\n\nThis project is 100% AI-written. All Lean code, all proofs, the blueprint and this\ndocumentation were generated by Anthropic's Claude models, working under the direction of the\nrepository owner. Every proof is checked by Lean's kernel, so the proofs are correct relative\nto the Lean statements. Whether the Lean statements say what the surrounding prose claims has\nbeen audited by AI, not reviewed by a human expert. Read the Lean\nstatement of any result you intend to rely on; the table below gives the hypotheses as they appear\nin the source.\n\n## Main results\n\nNames are in the `ErgodicTheory` namespace (omitted), except those starting with\n`OperatorEntropy.`, which belong to the `OperatorEntropy` library and namespace. \"a.e.\" is with\nrespect to the invariant measure; `log⁺‖A‖ ∈ L¹` abbreviates `IntegrableLogNorm A μ`.\n\n| Result | Lean declaration | Hypotheses |\n|---|---|---|\n| Oseledets MET, one-sided (filtration) | [`oseledets_filtration`](ErgodicTheory/MultiplicativeErgodic.lean) | `μ` 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 |\n| Oseledets MET, two-sided (splitting) | [`oseledets_splitting`](ErgodicTheory/TwoSided/Splitting.lean), [`oseledets_splitting_angle`](ErgodicTheory/TwoSided/SplittingAngle.lean) | 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 |\n| Oseledets MET for singular cocycles | [`oseledets_filtration_singular`](ErgodicTheory/Lyapunov/Singular/Oseledets.lean) | `μ` probability, `T` ergodic, `A` measurable, `log⁺‖A‖ ∈ L¹`; no invertibility. Exponents in `[−∞, ∞)`, `A(x)Vᵢ(x) ⊆ Vᵢ(Tx)`, rates in `EReal` with `log 0 = −∞` |\n| Oseledets MET for flows | [`oseledets_flow`](ErgodicTheory/Continuous/MultiplicativeErgodicFlow.lean) | 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 |\n| Kingman; Furstenberg–Kesten | [`tendsto_kingman_ergodic_iInf`](ErgodicTheory/Ergodic/Kingman/Limit.lean), [`furstenbergKesten_norm_eq_iInf`](ErgodicTheory/Cocycle/FurstenbergKestenLimit.lean) | 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⁽ⁿ⁾‖` |\n| Kolmogorov–Sinai generator theorems | [`Entropy.ksEntropy_eq_ksEntropyPartition_of_generatingMod0`](ErgodicTheory/Entropy/GeneratorTheorem.lean), [`Entropy.ksEntropy_eq_ksEntropyPartition_of_isGeneratingTwoSidedMod0`](ErgodicTheory/Krieger/GeneratorEntropy.lean) | 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)` |\n| Shannon–McMillan–Breiman | [`Krieger.ae_tendsto_div_infoFun`](ErgodicTheory/Krieger/SMB/BreimanTelescoping.lean) | standard Borel probability space, `T` ergodic, `P` a finite partition. `−(1/n) log μ(Pₙ(x)) → h(T, P)` a.e. |\n| Abramov–Rokhlin formula | [`Entropy.abramov_rokhlin`](ErgodicTheory/Entropy/AbramovRokhlin.lean) | 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, ∞]` |\n| Krieger's finite generator theorem | [`Krieger.krieger_finite_generator`](ErgodicTheory/Krieger/FiniteGenerator.lean) | measure-preserving automorphism of a standard Borel probability space, ergodic, aperiodic, `h(e) \u003C log k` (in `EReal`, so `h(e)` is finite). There is a two-sided generator mod 0 with `k` cells |\n| Margulis–Ruelle inequality | [`margulisRuelle_sharp`](ErgodicTheory/Entropy/Ruelle/MargulisRuelleSharp.lean) | `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) ≤ ∑ λᵢ⁺` |\n| Pesin entropy formula, absolutely continuous case | [`sumAllExp_le_ksEntropy_le_sumPosExp`](ErgodicTheory/Smooth/Pesin/PesinFormula.lean), [`pesin_entropy_formula_of_ae_eq`](ErgodicTheory/Smooth/Pesin/PesinFormula.lean) | `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`](ErgodicTheory/Examples/ChebyshevDegree.lean), `h = log n` for the Chebyshev polynomial `Tₙ`, `n ≥ 2`, with the arcsine law; [`Examples.Chebyshev.ksEntropy_chebProd`](ErgodicTheory/Examples/ChebyshevProduct.lean), `h = log m + log n` for `(x, y) ↦ (Tₘ(x), Tₙ(y))` on `ℝ²` (exponents `log m`, `log n`) |\n| Arnold cat map | [`CatMapToral.catTorus_ksEntropy_eq`](ErgodicTheory/Examples/CatMap/Entropy.lean), [`CatMapToral.catTorus_mixing`](ErgodicTheory/Examples/CatMap/Mixing.lean) | 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 |\n| Livšic theorem, abstract | [`isHolderCoboundary_iff`](ErgodicTheory/Livsic/Abstract.lean) | 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 \u003C r ≤ 1`. `φ` is a Hölder coboundary iff all periodic sums vanish |\n| Livšic: measurable rigidity, suspension flows | [`Livsic.livsic_measurable_rigidity_biShift`](ErgodicTheory/Livsic/Rigidity/MeasurableBernoulli.lean), [`livsic_holderFlow_constRoof`](ErgodicTheory/Livsic/Flow/HolderConstRoof.lean) | 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 |\n| Dimension of Bernoulli measures | [`Multifractal.measureDimH_bern_eq_Hnu_div_log_two`](ErgodicTheory/Multifractal/Bernoulli/Dimension.lean) | any probability `ν` on a finite alphabet; one-sided shift with the metric `2^{−n}`. `dim_H(ν^ℕ) = dim_*(ν^ℕ) = H(ν)/log 2` |\n| Data-processing inequality; Lieb | [`OperatorEntropy.KrausChannel.relEntropy_le`](OperatorEntropy/DataProcessing/Kraus.lean), [`OperatorEntropy.Lieb.relEntropyMat_jointly_convex`](OperatorEntropy/Lieb/JointConvexity.lean), [`OperatorEntropy.relEntropy_mix_le`](OperatorEntropy/Lieb/JointConvexityStates.lean) | 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`) |\n| Petz's theorem | [`OperatorEntropy.petz_recovery_iff`](OperatorEntropy/Petz/Compression.lean) | 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`) |\n| Alicki–Fannes entropy, finite dimension | [`OperatorEntropy.AlickiFannes.alfDynamicalEntropy_eq_zero`](OperatorEntropy/AlickiFannes/FiniteDimZero.lean) | any unital `⋆`-endomorphism of `M_d(ℂ)` and any state: the Alicki–Fannes dynamical entropy is `0` (the correlation matrices have rank `≤ d²`) |\n| Alicki–Fannes entropy of classical systems | [`Quantum.ksEntropy_eq_alfDynamicalEntropy`](ErgodicTheory/Quantum/ClassicalUpperBound.lean), [`Quantum.ksEntropy_eq_alfDynamicalEntropySimple`](ErgodicTheory/Quantum/ClassicalSimple.lean) | `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 |\n\nEvery declaration in this table is guarded in the axiom audit described below.\n\n## Scope and known limitations\n\n- **Smooth results live on `ℝᵈ`, not on manifolds.** The Margulis–Ruelle inequality and the Pesin\n  formula are stated for `C¹` self-maps of `EuclideanSpace ℝ (Fin d)` and invariant measures with\n  compact support. Maps of the circle or the torus are therefore not instances: the doubling map\n  and the cat map are treated by separate direct computations\n  (`Examples.Rokhlin.pesin_formula_doublingMap`, `CatMapToral.catTorus_ksEntropy_eq`). The\n  instances of the abstract Pesin theorem in the library are the Chebyshev polynomials `Tₙ`\n  (`n ≥ 2`) on `ℝ¹` with the arcsine law on `[−1, 1]`, and the products `(x, y) ↦ (Tₘ(x), Tₙ(y))`\n  on `ℝ²` with the product arcsine law; all are polynomial maps, factors of toral endomorphisms\n  through `θ ↦ cos 2πθ`. For piecewise differentiable, uniformly expanding maps with an absolutely\n  continuous ergodic measure and a partition generating mod 0, `pesin_formula_expanding` gives\n  `h_μ(T) = ∑ λᵢ⁺ = ∫ log|det A| dμ` without `C¹` or compact support; its instance is the doubling\n  map `x ↦ 2x mod 1` of `[0, 1)` (`Examples.Rokhlin.ksEntropy_doublingInterval`, `h = log 2`).\n- **The Pesin formula is not the general theorem.** Without a sign condition the library proves\n  only the two bounds `∑ λᵢ ≤ h_μ(T) ≤ ∑ λᵢ⁺` (`sumAllExp_le_ksEntropy_le_sumPosExp`), which differ\n  by `−∑ λᵢ⁻`. The equality `pesin_entropy_formula_of_ae_eq` assumes that every Lyapunov exponent\n  is nonnegative (`hspec`, equivalently `inf_n (1/n) ∫ log‖(A⁽ⁿ⁾)⁻¹‖ dμ ≤ 0`); the variants\n  replace `hspec` by sufficient conditions or cover a nonpositive spectrum and dimension one. The\n  general case of an absolutely continuous measure with exponents of both signs requires\n  Ledrappier–Young theory, which is not formalized. All versions also assume `μ ≪ Lebesgue` with\n  `log⁺` of the density integrable (the original `pesin_entropy_formula_of_ae_eq` asks for `log`\n  integrable), compact support, and a finite partition into injectivity domains of `T`. Read the\n  statement before quoting it.\n- **Krieger's theorem** is proved for ergodic, aperiodic automorphisms of standard Borel\n  probability spaces with `h \u003C log k` (strict, hence finite entropy). The countable-generator\n  theorem (Krieger, Keane–Serafin) is not formalized.\n- **Livšic for flows** is proved for suspension flows with constant roof (and, in Hölder form, for\n  variable Lipschitz roofs, `livsic_holderFlow_varRoof`); the abstract discrete theorem takes the\n  closing property as a hypothesis.\n- **Quantum layer.** The `OperatorEntropy` library is finite-dimensional (matrix algebras). The\n  Connes–Narnhofer–Thirring entropy is not formalized; the Alicki–Fannes entropy is, and on\n  `M_d(ℂ)` it is `0` for every dynamics (`alfDynamicalEntropy_eq_zero`). For a classical\n  measure-preserving system, `ErgodicTheory.Quantum` defines the Alicki–Fannes entropy of\n  `(L^∞(μ), f ↦ f ∘ T, ∫ · dμ)` over finite bounded measurable partitions of unity and proves that\n  it equals the Kolmogorov–Sinai entropy (`ksEntropy_eq_alfDynamicalEntropy`, Alicki–Fannes 1994).\n  The quantum Bernoulli shift (`quantumBernoulliShift`) is a family of finite-level states\n  `ρ^{⊗n}` on the matrix algebras `M_{2ⁿ}`, consistent and shift invariant; the C\\*-inductive\n  limit `⊗_ℕ M₂` is not constructed, and its mean entropy is a limit over the finite levels.\n  Strong subadditivity of the von Neumann entropy is not formalized.\n- **Prose-only remarks.** The Takens–Verbitskiy remark that dynamical Rényi entropies of order\n  `q ≠ 1` are not monotone under general factor maps is stated in docstrings and the blueprint\n  only; it is not a Lean theorem. Some module docstrings mention other standard facts that are not\n  formalized; only Lean declarations count.\n- **Code quality.** Both libraries build with Mathlib's standard linter set and warnings as\n  errors. Mathlib's environment linter (`lake exe runLinter ErgodicTheory` and\n  `lake exe runLinter OperatorEntropy`, or `make lint`) reports no findings. Seven\n  `maxHeartbeats` bumps (to 1.6M or 3.2M) remain, each with a justifying comment; see\n  [docs/mathlib-conventions.md](docs/mathlib-conventions.md).\n\n## Size\n\n| Library | Modules | Lines | `theorem`/`lemma` | `def`/`abbrev` | structures and classes |\n|---|---|---|---|---|---|\n| `ErgodicTheory` | 389 | about 113,600 | 3,881 | 657 | 29 |\n| `OperatorEntropy` | 66 | about 16,200 | 683 | 130 | 5 |\n\nRoot files (`ErgodicTheory.lean`, `OperatorEntropy.lean`) are not counted. Module renames since\nthe tag `v4.36.0` are listed in [docs/module-renames.md](docs/module-renames.md). Counted, for\n`D` = `ErgodicTheory` and `D` = `OperatorEntropy`, by\n\n```bash\nF=$(find $D -name '*.lean'); echo \"$F\" | wc -l; cat $F | wc -l\ncat $F | grep -cE '^\\s*(@\\[[^]]*\\]\\s*)?(private |protected )?(noncomputable )?(theorem|lemma) '\ncat $F | grep -cE '^\\s*(@\\[[^]]*\\]\\s*)?(private |protected )?(noncomputable )?(def|abbrev) '\ncat $F | grep -cE '^\\s*(structure|class) '\n```\n\n## Using it as a dependency\n\nAdd to your `lakefile.toml` (this provides both libraries, `ErgodicTheory` and\n`OperatorEntropy`):\n\n```toml\n[[require]]\nname = \"ErgodicTheory\"\ngit = \"https://github.com/marcmorningstar/lean4-ergodic-theory.git\"\nrev = \"v4.36.0\"\n```\n\nRelease tags follow the Lean toolchain version, as in Mathlib and Batteries: the tag `v4.36.0` is\nthe release for Lean 4.36.0 and Mathlib `v4.36.0`. Your project must use the same Lean and Mathlib\nversions.\n\n## Building\n\nLean `v4.36.0` (`lean-toolchain`) and Mathlib `v4.36.0` (exact commit in `lake-manifest.json`).\n\n```bash\nlake exe cache get   # download the precompiled Mathlib cache\nlake build           # builds both libraries and the axiom audit\n```\n\nBoth libraries use the Lean module system (`module` headers, `public import`, as in Mathlib); they\ncan be imported from module and from non-module files.\n\nThe blueprint (requires a TeX distribution, graphviz and `pip install leanblueprint`):\n\n```bash\nleanblueprint pdf && leanblueprint web    # writes blueprint/lean_decls\nlake exe checkdecls blueprint/lean_decls  # every \\lean{...} name exists\n```\n\n## Axiom audit\n\n`test/AxiomAudit.lean` is a separate library that is built by every `lake build`. For 935\ndeclarations, including all of the above, it contains a block\n\n```lean\n/-- info: 'ErgodicTheory.oseledets_filtration' depends on axioms: [propext, Classical.choice, Quot.sound] -/\n#guard_msgs in\n#print axioms ErgodicTheory.oseledets_filtration\n```\n\nso the build fails if any of them depends on `sorryAx` or on any axiom beyond the three standard\nones. The audit says nothing about whether a statement is the intended one; that is what the table\nabove and the blueprint are for. CI runs `lake build` (including the audit) and `checkdecls` on\nevery push to `main` and every pull request.\n\n## Layout\n\n```\nErgodicTheory/\n  Cocycle/ Ergodic/             linear cocycles, Birkhoff, Kingman, Furstenberg–Kesten\n  Lyapunov/                     Lyapunov exponents and the one-sided MET\n    Filtration/ Forward/ Ruelle/  reductions of the filtration theorem, forward flag, Ruelle bounds\n    Singular/                   singular cocycles: exponents, Kernel/, Rank/, Borel/ measurability\n    Extensions/                 spectrum, exponent sums, det identity, inverse, restriction, ...\n  TwoSided/                     two-sided splitting\n  Continuous/                   flows and the flow MET; Entropy/ (Abramov flow entropy)\n    Suspension/                 suspension flows: Cocycle/, Exponent/, Metric/, TimeOne/, Livsic/\n  Entropy/                      Kolmogorov–Sinai entropy, generators, Abramov–Rokhlin\n    Partition/ Conditional/     static and conditional Shannon entropy of partitions\n    KolmogorovSinai/ Relative/  KS entropy and relative (conditional) KS entropy\n    Product/ Ruelle/            products with identity factors; Margulis–Ruelle inequality\n  Krieger/                      Krieger's generator theorem; Tower/, SMB/, Coding/\n  Smooth/ Examples/             derivative cocycle, Pesin formula; doubling, Chebyshev, CatMap/\n  Livsic/                       Livšic theory; BiShift/, Rigidity/, Flow/\n  Multifractal/                 Rényi entropies and dimensions; Bernoulli/, Renyi/, Flow/\n  MeasureTheory/                descriptive set theory\n  Quantum/                      Alicki–Fannes entropy of classical systems vs. Kolmogorov–Sinai\n                                entropy (the only modules importing OperatorEntropy)\nOperatorEntropy/                library OperatorEntropy: quantum relative entropy; Lieb/,\n                                DataProcessing/, Petz/, AlickiFannes/, GrowingTower/, Analysis/\ntest/AxiomAudit.lean            axiom audit\nblueprint/                      leanblueprint sources and bibliography\n```\n\n## License and citation\n\nApache 2.0, see [LICENSE](LICENSE). To cite this repository use the metadata in\n[CITATION.cff](CITATION.cff) (GitHub shows a \"Cite this repository\" button). Changes between\nversions are listed in [CHANGELOG.md](CHANGELOG.md).\n",1795981097795]