← All solved theorems
Asymptotic Equipartition Property (AEP) and Weak Typicality
proved in Lean
For long sequences from a memoryless source, nearly all the probability sits on a typical set of about 2 to the power nH sequences, each roughly equally likely. This is why the entropy H measures how far data can be compressed.
Claude E. Shannon; Brockway McMillan; Leo Breiman (1948) · Ch. 3–4 · AEP, Typicality & Entropy Rates · Cover & Thomas, Theorems 3.1.1 & 3.1.2
Statement
For an i.i.d. finite source $X^n \sim P^n$ and the weakly typical set $A_\varepsilon^{(n)} = \{x^n : 2^{-n(H(P)+\varepsilon)} \le P^n(x^n) \le 2^{-n(H(P)-\varepsilon)}\}$:
- $1 - P^n(A_\varepsilon^{(n)}) \le \frac{V(P)}{n \varepsilon^2} \to 0$ (explicit varentropy Chebyshev bound).
- $|A_\varepsilon^{(n)}| \le 2^{n(H(P) + \varepsilon)}$ for all $n$.
- $|A_\varepsilon^{(n)}| \ge (1 - \delta) 2^{n(H(P) - \varepsilon)}$ for all sufficiently large $n$.
How the proof works
The idea is the weak law of large numbers: the per-symbol surprisal is an average of independent terms, so Chebyshev's inequality concentrates it around the entropy. Proved completely via finite-sum independence of the centered surprisals $Z_i = -\log_2 P(X_i) - H(P)$ with explicit variance varentropy P.
Lean declarations (4)
The key theorems in the Lean library. Each is compiled with Lean 4, uses only the standard axioms propext, Classical.choice and Quot.sound, and is re-checked by leanchecker. Click a name to see the full proof on GitHub.
theorem iidDist_prob_not_typical_le (P : ProbDist α) {n : ℕ} (hn : 0 < n) {ε : ℝ} (hε : 0 < ε) :
1 - ∑ x ∈ weakTypicalSet P n ε, (iidDist P n).pmf x ≤
varentropy P / ((n : ℝ) * ε ^ 2) := by …
theorem aep_typical_prob_tendsto_one (P : ProbDist α) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) :
∃ N : ℕ, ∀ n ≥ N, 1 - δ ≤ ∑ x ∈ weakTypicalSet P n ε, (iidDist P n).pmf x := by …
theorem weakTypicalSet_card_le (P : ProbDist α) (n : ℕ) (ε : ℝ) :
((weakTypicalSet P n ε).card : ℝ) ≤ (2 : ℝ) ^ ((n : ℝ) * (shannonEntropy P + ε)) := by …
theorem weakTypicalSet_card_ge (P : ProbDist α) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) :
∃ N : ℕ, ∀ n ≥ N,
(1 - δ) * (2 : ℝ) ^ ((n : ℝ) * (shannonEntropy P - ε)) ≤
((weakTypicalSet P n ε).card : ℝ) := by …
Related open problems (3)
Open problems that build on, generalize, or are analogous to this theorem.