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 #

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

@[deprecated InformationTheory.IsUniquelyDecodable.finsetSum_one_div_card_pow_length_le_one (since := "2026-08-16")]
theorem InformationTheory.kraft_mcmillan_inequality {α : Type u_1} {S : Finset (List α)} [Fintype α] [Nonempty α] (h : IsUniquelyDecodable S) :
wS, (1 / (Fintype.card α)) ^ w.length 1

Alias of InformationTheory.IsUniquelyDecodable.finsetSum_one_div_card_pow_length_le_one.


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