← All solved theorems
Gibbs' Inequality and Non-negativity of KL Divergence
proved in Lean
The KL divergence, a measure of how different two probability distributions are, is never negative and is zero only when the distributions are identical. Almost every converse bound in information theory rests on this fact.
Josiah Willard Gibbs; Solomon Kullback and Richard Leibler (1951) · Ch. 2 · Entropy, Divergence & Inequalities · Cover & Thomas, Theorem 2.6.3; bridged to Mathlib.InformationTheory.klDiv
Statement
For any two probability distributions $P, Q$ on a finite alphabet $\mathcal{X}$ with $P \ll Q$, the Kullback–Leibler divergence satisfies $$D(P \| Q) = \sum_{x \in \mathcal{X}} P(x) \log_2 \frac{P(x)}{Q(x)} \ge 0,$$ with equality $D(P \| Q) = 0$ if and only if $P = Q$.
How the proof works
The classical proof applies Jensen's inequality to the concave logarithm (equivalently, log t ≤ t − 1). Proved by constructing an exact bridge from InfoTheory.Core.ProbDist to Mathlib's PMF and MeasureTheory.Measure, identifying Real.log 2 * klDivergence P Q with (InformationTheory.klDiv (toMeasure P) (toMeasure Q)).toReal, and inheriting both non-negativity and the strict equality characterization directly from Mathlib's InformationTheory.klDiv.
Lean declarations (3)
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.
lemma klDivergence_eq_toReal_klDiv [MeasurableSpace α] [DiscreteMeasurableSpace α]
(P Q : ProbDist α) (hac : AbsCont P Q) :
Real.log 2 * klDivergence P Q =
(InformationTheory.klDiv (toMeasure P) (toMeasure Q)).toReal := by …
theorem klDivergence_nonneg (P Q : ProbDist α) (hac : AbsCont P Q) :
0 ≤ klDivergence P Q := by …
theorem klDivergence_eq_zero_iff (P Q : ProbDist α) (hac : AbsCont P Q) :
klDivergence P Q = 0 ↔ P = Q := by …
Related open problems (5)
Open problems that build on, generalize, or are analogous to this theorem.