The divergence from the uniform law is at most its chi-squared distance #
Category: 1-Mathlib (CSD-free). BACKLOG #130's first half.
Mathlib has the Kullback-Leibler divergence and no comparison inequality for it. The one a rate
argument reaches for is the chi-squared bound: klDiv is at most the chi-squared distance, which is
quadratic in the deviation and therefore converts an L² estimate into a divergence estimate.
Against the uniform law on a finite type with n points the chi-squared distance is
n · ∑ (p x − 1/n)², and that is the form proved here.
- ★★★
log_card_sub_measureEntropy_le_chiSq— the real-valued inequalitylog n − H(μ) ≤ n · ∑ (μ{x} − 1/n)²; - ★★★
klDiv_uniformOn_univ_le_chiSq— the same read throughklDiv_uniformOn_univ, which is the statement a consumer uses.
How it goes #
Both sides are the same sum, compared pointwise. Writing p x for μ.real {x}:
- the left side is
∑ p x · log (n · p x), because∑ p x = 1turnslog ninto∑ p x · log nand thep x = 0terms contribute nothing to either half; log t ≤ t − 1(Real.log_le_sub_one_of_pos) att = n · p x, multiplied byp x ≥ 0, givesp x · log (n · p x) ≤ p x · (n · p x − 1)— the only analysis in the file;- and
∑ p x · (n · p x − 1) = n · ∑ p x² − 1is equal ton · ∑ (p x − 1/n)², again by∑ p x = 1. So the inequality is tight exactly wherelog t = t − 1, atp x = 1/n.
Honest scope #
⚠️ Uniform reference only. The general bound klDiv μ ν ≤ ∑ (μ{x} − ν{x})²/ν{x} needs the
Radon-Nikodym derivative of μ against an arbitrary ν, which FiniteEntropy.lean computes only
for the uniform law (withDensity_uniformOn_univ). A consumer whose reference is uniform as a
theorem can use this; one whose reference is merely believed uniform has to carry that as a
hypothesis.
⚠️ Finite type only, and both measures are probability measures: klDiv's correction terms are
dropped by klDiv_uniformOn_univ, which assumes it.
⚠️ It is an inequality, not an equivalence. The chi-squared distance can be arbitrarily larger
than the divergence, so a chi-squared bound that fails to tend to zero says nothing about klDiv.
References #
T. Cover, J. Thomas, Elements of Information Theory, 2nd ed., §11.6 (the chi-squared comparison);
FiniteEntropy.lean (measureEntropy, klDiv_uniformOn_univ, sum_measureReal_singleton);
Mathlib.Analysis.SpecialFunctions.Log.Basic (Real.log_le_sub_one_of_pos);
specs/future-work.md; specs/BACKLOG.md #130, #118.
★★★ The entropy defect is at most the chi-squared distance from the uniform law.
log n − H(μ) ≤ n · ∑ (μ{x} − 1/n)², where n is the cardinality. Both sides are the same sum
read two ways, compared pointwise by log t ≤ t − 1.
★★★ The chi-squared bound on the divergence from the uniform law. This is the form a rate
argument consumes: an L² estimate on the point masses bounds klDiv, at the cost of one factor of
the cardinality.