Binomial partial sums bounded via the binary entropy function
Provedchoose_sum_le_exp_mul_binEntropyby xbgxjack · Sep 9, 2026 · Mathlib 0df444a (Lean v4.33.1)
binomial-coefficientscombinatoricsentropykleitmanspencer
Let n,k be natural numbers with 0<n and 2k≤n, and let λ=k/n∈[0,1/2]. Then the volume of the Hamming ball of radius k in {0,1}n is bounded via the binary entropy function H(λ)=−λlnλ−(1−λ)ln(1−λ) (Real.binEntropy, measured in nats) by
i=0∑k(in)≤enH(k/n)=enH(λ).
This is the classical volume bound on Hamming balls (equivalently, on partial sums of binomial coefficients) used throughout coding theory and combinatorics: it converts a bound on the size of a subset of the hypercube contained in (or compared against) a Hamming ball into an entropy bound, and conversely. The proof is elementary: for j≤k and λ≤1/2, the term λj(1−λ)n−j of the binomial expansion of 1=(λ+(1−λ))n is at least λk(1−λ)n−k, so (∑i=0k(in))λk(1−λ)n−k≤∑j=0k(jn)λj(1−λ)n−j≤1, and rearranging with λ=k/n gives the stated bound after converting λ−k(1−λ)−(n−k) into exponential-of-entropy form.
Formalization Note. Entropy is measured in nats (Real.binEntropy uses natural log, as in Mathlib's Analysis.SpecialFunctions.BinaryEntropy), so the bound reads enH(λ) rather than 2nH2(λ); the two forms are equivalent up to the base of the logarithm. This connects Mathlib's Real.binEntropy to Nat.choose for the first time, and is the tool needed to bound the size of a 'bad' bin-pattern set by a volume-of-Hamming-ball argument in entropy-compression proofs such as Spencer's partial-colouring method and Kleitman's diameter theorem.
Preamble
import Mathlib
open Finset
Formal statement
theorem choose_sum_le_exp_mul_binEntropy (n k : ℕ) (hn : 0 < n) (hk2 : 2 * k ≤ n) :
(∑ i ∈ Finset.range (k + 1), (n.choose i : ℝ)) ≤ Real.exp (n * Real.binEntropy ((k : ℝ) / n)) := by sorrySource
Classical bound on partial sums of binomial coefficients via the entropy function, see e.g. F.J. MacWilliams, N.J.A. Sloane, The Theory of Error-Correcting Codes (North-Holland, 1977), Ch. 10, Corollary 9 (sum_{i<=k} C(n,i) <= 2^{n H2(k/n)} for k<=n/2); or T. Cover, J. Thomas, Elements of Information Theory, 2nd ed., Lemma 11.1.2 for the asymptotic equipartition / volume-of-ball statement. Restated here in nats via Mathlib's Real.binEntropy. Used (as the volume-of-Hamming-ball estimate) in J. Spencer, Six standard deviations suffice, Trans. Amer. Math. Soc. 289 (1985), eq. (2.15)-(2.19) and in the entropy form of D. Kleitman's diameter theorem (eq. 2.22 of the same paper).
View graph