MathLabs
TheoremProved

Shannon's noiseless source coding theorem

Statement

For a source XX with entropy H(X)H(X), every prefix code has average codeword length LL satisfying L≥H(X)L \ge H(X), and there exists a prefix code with H(X)≤L<H(X)+1H(X) \le L < H(X) + 1.

Why is it true?

The lower bound says entropy is a hard floor: no lossless prefix code can, on average, beat H(X)H(X) bits per symbol, because doing better would require the code-induced distribution to differ from XX's true distribution in a way Gibbs' inequality forbids. The upper bound says this floor is nearly achievable: rounding each ideal length −log⁡2pi-\log_2 p_i up to an integer wastes less than one bit on average.

Proof sketch

For the lower bound, let lil_i be the lengths of any prefix code, so ∑i=1n2−li≤1\sum_{i=1}^n 2^{-l_i} \le 1. Define qi=2−li/Zq_i = 2^{-l_i}/Z where Z=∑j2−lj≤1Z=\sum_j 2^{-l_j} \le 1, so qq is a probability distribution. By Gibbs' inequality, 0≤D(p∥q)=∑ipilog⁡2(pi/qi)=∑ipilog⁡2pi−∑ipilog⁡2(2−li/Z)=−H(X)+∑ipili+log⁡2Z0 \le D(p\|q) = \sum_i p_i \log_2(p_i/q_i) = \sum_i p_i\log_2 p_i - \sum_i p_i \log_2(2^{-l_i}/Z) = -H(X) + \sum_i p_i l_i + \log_2 Z. Since Z≤1Z \le 1, log⁡2Z≤0\log_2 Z \le 0, so 0≤−H(X)+L+log⁡2Z≤−H(X)+L0 \le -H(X) + L + \log_2 Z \le -H(X) + L, which rearranges to L≥H(X)L \ge H(X).

For the upper bound (achievability), choose li=⌈−log⁡2pi⌉l_i = \lceil -\log_2 p_i \rceil for each ii (round the ideal length up to the nearest integer). These lengths satisfy Kraft's inequality since 2−li≤2−(−log⁡2pi)=pi2^{-l_i} \le 2^{-(-\log_2 p_i)} = p_i, so ∑i2−li≤∑ipi=1\sum_i 2^{-l_i} \le \sum_i p_i = 1; by the Kraft–McMillan construction such lengths can always be realized as an actual prefix code (build the code by assigning binary strings level by level in a binary tree).

By definition of ceiling, li<−log⁡2pi+1l_i < -\log_2 p_i + 1. Multiplying by pi≥0p_i \ge 0 and summing over ii gives L=∑ipili<∑ipi(−log⁡2pi+1)=H(X)+1L = \sum_i p_i l_i < \sum_i p_i(-\log_2 p_i + 1) = H(X) + 1.

Combining both parts, this construction achieves H(X)≤L<H(X)+1H(X) \le L < H(X) + 1.

Topics that use this theorem

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. Claude E. Shannon (1948). A Mathematical Theory of Communication
  2. Thomas M. Cover, Joy A. Thomas (2006). Elements of Information Theory
  3. David J. C. MacKay (2003). Information Theory, Inference, and Learning Algorithms
  4. Erdal Arıkan (2009). Channel Polarization: A Method for Constructing Capacity-Achieving Codes for Symmetric Binary-Input Memoryless Channels · arXiv:0807.3917