← All solved theorems
Method of Types and Sanov's Large-Deviations Theorem
proved in Lean
Sorting sequences by their empirical letter frequencies (types) gives sharp counting estimates. Sanov's theorem follows: the probability that a sample's frequencies fall in a set E decays exponentially, at a rate set by the smallest KL divergence from E.
Imre Csiszár; Ivan N. Sanov (1957) · Ch. 11 · Method of Types & Statistics · Cover & Thomas, Theorems 11.1.1–11.1.4 & 11.4.1
Statement
For sequences of length $n \ge 1$ over a finite alphabet $\mathcal{X}$:
- The number of empirical types satisfies $|\mathcal{P}_n(\mathcal{X})| \le (n + 1)^{|\mathcal{X}|}$.
- Every $x^n$ of type $P$ with $P \ll Q$ has exact probability $Q^n(x^n) = 2^{-n(H(P) + D(P \| Q))}$.
- Each type class $T(P)$ satisfies $(n+1)^{-|\mathcal{X}|} 2^{n H(P)} \le |T(P)| \le 2^{n H(P)}$, and whenever $P \ll Q$, $(n+1)^{-|\mathcal{X}|} 2^{-n D(P \| Q)} \le Q^n(T(P)) \le 2^{-n D(P \| Q)}$.
- Sanov's Theorem (Upper, Lower, and Asymptotic Limit): For any set $E$ of distributions such that $D(P \| Q) \ge d$ whenever $P \in E$ and $P \ll Q$, $Q^n(\{x^n : \hat P_{x^n} \in E\}) \le (n+1)^{|\mathcal{X}|} 2^{-n d}$; for any $\ell_\infty$-interior point $P \in E$ with $P \ll Q$, eventually $Q^n(\{x^n : \hat P_{x^n} \in E\}) \ge 2^{-n(D(P \| Q) + \delta)}$; and when $d$ is approached by $\ell_\infty$-interior points $P \in E$ with $P \ll Q$, $-\frac{1}{n}\log_2 Q^n(\{x^n : \hat P_{x^n} \in E\}) \to d$ (valid for arbitrary $Q$, including distributions with zero-mass atoms).
How the proof works
The lower bound on $|T(P)|$ uses exact multinomial counting $|T(P)| \prod_a N(a|x)! = n!$ to show $P^n(T(P)) = \max_{P'} P^n(T(P')) \ge (n+1)^{-|\mathcal{X}|}$. Sanov's lower bound and limit constructively approximate any interior $P \in E$ by empirical types $P_n \ll P$ (exists_empiricalType_approx) and combine typeClass_prob_ge with continuity of $D(\cdot \| Q)$.
Lean declarations (9)
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 card_typesSet_le (α : Type*) [Fintype α] {n : ℕ} (hn : 0 < n) :
(typesSet α hn).card ≤ (n + 1) ^ (Fintype.card α) := by …
theorem iidDist_pmf_eq_type {n : ℕ} (hn : 0 < n) (x : Fin n → α) (Q : ProbDist α)
(hac : AbsCont (empiricalType hn x) Q) :
(iidDist Q n).pmf x =
(2 : ℝ) ^ (-((n : ℝ) * (shannonEntropy (empiricalType hn x) +
klDivergence (empiricalType hn x) Q))) := by …
theorem typeClass_card_le {n : ℕ} (hn : 0 < n) (P : ProbDist α) :
((typeClass hn P).card : ℝ) ≤ (2 : ℝ) ^ ((n : ℝ) * shannonEntropy P) := by …
theorem typeClass_card_ge {n : ℕ} (hn : 0 < n) {P : ProbDist α} (hP : P ∈ typesSet α hn) :
((n + 1 : ℝ) ^ (Fintype.card α))⁻¹ * (2 : ℝ) ^ ((n : ℝ) * shannonEntropy P) ≤
((typeClass hn P).card : ℝ) := by …
theorem typeClass_prob_le {n : ℕ} (hn : 0 < n) (P Q : ProbDist α) (hac : AbsCont P Q) :
∑ x ∈ typeClass hn P, (iidDist Q n).pmf x ≤
(2 : ℝ) ^ (-((n : ℝ) * klDivergence P Q)) := by …
theorem typeClass_prob_ge {n : ℕ} (hn : 0 < n) {P : ProbDist α} (hP : P ∈ typesSet α hn)
(Q : ProbDist α) (hac : AbsCont P Q) :
((n + 1 : ℝ) ^ (Fintype.card α))⁻¹ * (2 : ℝ) ^ (-((n : ℝ) * klDivergence P Q)) ≤
∑ x ∈ typeClass hn P, (iidDist Q n).pmf x := by …
theorem sanov_upper_bound {n : ℕ} (hn : 0 < n) (E : Set (ProbDist α))
[DecidablePred (· ∈ E)] (Q : ProbDist α) {d : ℝ}
(hd : ∀ P ∈ E, AbsCont P Q → d ≤ klDivergence P Q) :
∑ x ∈ Finset.univ.filter (fun x => empiricalType hn x ∈ E), (iidDist Q n).pmf x ≤
((n + 1 : ℝ) ^ (Fintype.card α)) * (2 : ℝ) ^ (-((n : ℝ) * d)) := by …
theorem sanov_lower_bound_interior (E : Set (ProbDist α)) [DecidablePred (· ∈ E)]
(P Q : ProbDist α) (hac : AbsCont P Q)
(hP_int : ∃ r > 0, ∀ P' : ProbDist α, (∀ a : α, |P'.pmf a - P.pmf a| < r) → P' ∈ E)
{δ : ℝ} (hδ : 0 < δ) :
∃ N : ℕ, ∀ (n : ℕ) (hn : 0 < n), N ≤ n →
(2 : ℝ) ^ (-((n : ℝ) * (klDivergence P Q + δ))) ≤
∑ x ∈ Finset.univ.filter (fun x => empiricalType hn x ∈ E), (iidDist Q n).pmf x := by …
theorem sanov_theorem_tendsto (E : Set (ProbDist α)) [DecidablePred (· ∈ E)]
(Q : ProbDist α) {d : ℝ}
(hd_le : ∀ P ∈ E, AbsCont P Q → d ≤ klDivergence P Q)
(hreg : ∀ ε > 0, ∃ P : ProbDist α,
AbsCont P Q ∧
(∃ r > 0, ∀ P' : ProbDist α, (∀ a : α, |P'.pmf a - P.pmf a| < r) → P' ∈ E) ∧
klDivergence P Q < d + ε) :
Filter.Tendsto
(fun n : ℕ =>
-(log2 (∑ x ∈ Finset.univ.filter (fun x => empiricalType (Nat.succ_pos n) x ∈ E),
(iidDist Q (n + 1)).pmf x)) / ((n + 1 : ℕ) : ℝ))
Filter.atTop (nhds d) := by …
Related open problems (4)
Open problems that build on, generalize, or are analogous to this theorem.