Documentation

Mathlib.InformationTheory.Coding.KraftMcMillan

Kraft-McMillan Inequality #

This file proves the Kraft-McMillan inequality for uniquely decodable codes.

Main definitions #

Main results #

The proof uses a counting argument: the r-th power of the Kraft sum counts concatenations of r codewords, weighted by length. Since the code is uniquely decodable, these concatenations are distinct, and the count is bounded by the number of strings of each length.

References #

theorem InformationTheory.kraft_mcmillan_inequality {α : Type u_1} {S : Finset (List α)} [Fintype α] [Nonempty α] (h : UniquelyDecodable S) :
wS, (1 / (Fintype.card α)) ^ w.length 1

Kraft-McMillan Inequality: If S is a finite uniquely decodable code, then Σ D^{-|w|} ≤ 1.