Shannon Entropy Characterization in Lean
This repository formalizes Shannon's finite-alphabet characterization theorem from Shannon (1948), Appendix 2.
The central result is:
- For any uncertainty functional
Hsatisfying the Shannon-style axiom bundle (continuity, strict monotonicity on uniform distributions, grouping, and relabel invariance), there is a positive constantKsuch thatH(p) = -K * Σ p_i log p_i. - Equivalently, for any base
b > 1, there isKb > 0such thatH(p) = -Kb * Σ p_i log_b p_i.
Formalization Scope
- Finite alphabets only.
- Real-valued probability vectors with explicit simplex proofs.
- Proof structure follows Shannon's Appendix-2 phases:
- Equiprobable case (
A(n)behaves logarithmically). - Rational probabilities via grouped equiprobable refinement.
- Extension to real probabilities via continuity and rational approximation.
- Equiprobable case (
Main Theorems
Characterization (Appendix 2)
entropyNat_unique:Shannon/Entropy/Final.leanentropyBase_unique:Shannon/Entropy/Final.lean
Converse
entropyNat_shannonAxioms:entropyNatsatisfiesShannonEntropyAxioms—Shannon/Entropy/Converse.lean
Section 6 Properties
entropyNat_eq_zero_iff: H = 0 iff deterministic —Shannon/Entropy/Properties.leanentropyNat_eq_log_card_iff: H = log|α| iff uniform —Shannon/Entropy/Properties.leanentropyNat_joint_le_add: subadditivity H(X,Y) ≤ H(X) + H(Y) —Shannon/Entropy/Properties.leanentropyNat_doublyStochastic_le: Schur-concavity H(Ap) ≥ H(p) —Shannon/Entropy/Properties.leancondEntropy_le_entropyNat: conditioning reduces entropy —Shannon/Entropy/Properties.leancondEntropy_nonneg: conditional entropy ≥ 0 —Shannon/Entropy/Properties.leanchain_rule: H(X,Y) = H(X) + H_X(Y) —Shannon/Entropy/Joint.leanentropyNat_prodDist: H(X×Y) = H(X) + H(Y) —Shannon/Entropy/Joint.lean
Module Layout
Shannon/Entropy/Core.leanFoundations: probability distributions, axiom bundle, core constructions.Shannon/Entropy/Uniform.leanPhase 1: equiprobable characterization.Shannon/Entropy/Rational.leanPhase 2: rational case + worked(1/2, 1/3, 1/6)grouping example.Shannon/Entropy/Approx.leanPhase 3: floor-count rational approximants and convergence lemmas.Shannon/Entropy/Final.leanFinal uniqueness theorems.Shannon/Entropy/Gibbs.leanGibbs inequality, negMulLog bridge, entropy nonnegativity, uniform entropy.Shannon/Entropy/Joint.leanJoint distributions, marginals, conditional entropy, chain rule.Shannon/Entropy/Properties.leanSection 6 properties: deterministic iff, uniform iff, subadditivity, Schur-concavity, conditioning.Shannon/Entropy/Converse.leanConverse:entropyNatsatisfies the Shannon axioms, completing the iff characterization.Shannon/Entropy.leanFacade import.Shannon.leanProject entrypoint.
How To Read The Proof
If you want to read this like a paper:
- Start in
Shannon/Entropy/Core.leanfor definitions and axioms. - Read
Shannon/Entropy/Uniform.leanfor the equiprobable logarithm law (Apos H n = K * log n). - Read
Shannon/Entropy/Rational.leanfor rational distributions via grouping. - Read
Shannon/Entropy/Approx.leanfor the continuity bridge (approxProb p N → p). - Finish in
Shannon/Entropy/Final.leanfor the final uniqueness theorems. - Continue to
Shannon/Entropy/Gibbs.leanfor the Gibbs inequality. - Read
Shannon/Entropy/Joint.leanfor joint distributions and the chain rule. - Read
Shannon/Entropy/Properties.leanfor the Section 6 entropy properties. - Read
Shannon/Entropy/Converse.leanfor the proof thatentropyNatsatisfies the axioms.
For pedagogical context, see the worked decomposition theorem in
Shannon/Entropy/Rational.lean:
worked_grouping_identityworkedCompose_masses
Build and Verify
Requirements:
- Lean toolchain from
lean-toolchain - Lake (bundled with Lean)
Commands:
lake build
CI workflow:
.github/workflows/lean_action_ci.yml(Lean Action CI)
Notes on Axioms
Shannon's symmetry principle ("depends only on probabilities, not labels") is represented explicitly as:
ShannonEntropyAxioms.relabelInvariant
This makes permutation/relabeling steps fully explicit in Lean proofs.
AI Assistance
This project was developed with substantial assistance from Claude (Anthropic). Claude contributed to proof development, code structure, and documentation throughout the formalization effort.
Reference
- Claude E. Shannon, A Mathematical Theory of Communication (1948).
The repository includes
shannon1948.pdffor study context.
License
This project is licensed under the MIT License. See LICENSE.