Shannon entropy on a finite type, and the H-theorem in entropy form #
Category: 1-Mathlib (CSD-free; staged as a Mathlib-upstream candidate). BACKLOG #110, the residue #109 named.
Mathlib has the Kullback–Leibler divergence but no Shannon entropy of a measure — not for a finite type, not anywhere. #109 proved the arrow of time in its divergence form, which is the general one; this file supplies the identity that turns it into the textbook statement, and the two classical consequences.
What is proved #
measureEntropy μ = ∑ x, negMulLog (μ.real {x})— Shannon entropy of a measure on a finite type;- ★★
withDensity_uniformOn_univ— the density of a measure against the uniform law iscard · μ{x}, which is the Radon–Nikodym computation the identity needs and the only real work here. It holds for any measure on a finite type, not only a probability measure, and so doabsolutelyContinuous_uniformOn_univand ★★llr_uniformOn_univ_ae— hence the log-likelihood ratio against the uniform law islog (card · μ{x})almost everywhere; - ★★★
integral_llr_uniformOn_univand ★★★klDiv_uniformOn_univ— the identity:klDiv μ uniform = ENNReal.ofReal (log card − measureEntropy μ). The vanishing of the two correction terms is what makes it clean: both measures are probability measures; - ★★
measureEntropy_le_log_card— the maximum-entropy theorem, from Gibbs' inequality, and ★measureEntropy_uniformOn_univ— the uniform law attains it, so the bound is tight; - ★★★
monotone_measureEntropy_compIterate— the H-theorem in entropy form: under a Markov kernel that fixes the uniform law, Shannon entropy is non-decreasing, monotonically along the whole trajectory. This is the classical statement, and it is #109's divergence form composed with the identity above.
Honest scope #
⚠️ The uniform reference is not optional. Entropy increases along a kernel that fixes the uniform law; a kernel with some other stationary law moves entropy either way, and what is monotone then is the divergence from that law (#109), not the entropy. The two statements coincide only here.
⚠️ Finite type only. measureEntropy sums over Fintype.card α point masses. Differential
entropy, countable types with infinite entropy, and the conditional and joint entropies are all
untouched.
⚠️ No convergence, and no rate. Monotone is not strictly increasing, and nothing says the entropy
reaches log card: a kernel can be the identity.
References: T. Cover, J. Thomas, Elements of Information Theory, 2nd ed., Thm 2.6.4 (maximum
entropy) and §4.4 (the H-theorem for a doubly stochastic chain);
Mathlib.InformationTheory.KullbackLeibler.Basic (klDiv, llr,
integral_llr_add_sub_measure_univ_nonneg = Gibbs), Mathlib.Probability.UniformOn;
KlDivArrow.lean (#109's Cat-1 half).
Shannon entropy of a measure on a finite type: −∑ p log p over the point masses.
Instances For
Every measure on a finite type is the sum of its point masses, restricted.
The density against the uniform law #
★★ The density of a law against the uniform law is card · μ{x}. This is the Radon–Nikodym
computation the entropy identity runs on, and the only real work in this file.
★★ So the log-likelihood ratio against the uniform law is log (card · μ{x}), almost
everywhere.
The identity, and the two classical consequences #
★★★ The entropy identity, in integral form.
★★★ The identity: the divergence from the uniform law is log card − entropy. The two
correction terms in klDiv's definition vanish because both measures are probability measures.
★★ The maximum-entropy theorem: no law on a finite type has entropy above log card. This is
Gibbs' inequality read through the identity.
★ And the uniform law attains it, so the bound is tight.
The H-theorem in entropy form #
★★★ The H-theorem in entropy form. Under a Markov kernel that fixes the uniform law, Shannon entropy is non-decreasing, monotonically along the whole trajectory.
This is the classical statement, and it is #109's divergence form (antitone_klDiv_compIterate)
composed with the identity: klDiv · uniform and measureEntropy move in opposite directions, and
the maximum-entropy bound is what licenses stripping ENNReal.ofReal.