Information and communication theory, circuits Source coding and data compression Theorem
Kraft–McMillan inequality
Statement
Let be an integer, let be an alphabet with symbols, and let be positive integers.
- If there is a uniquely decodable code over with codewords of lengths , then .
- If , then there is a prefix code over with codewords of lengths .
Remarks
Part 1 is due to McMillan and part 2 to Kraft. Since every prefix code is uniquely decodable, the inequality, the existence of a prefix code and the existence of a uniquely decodable code with the given lengths are all equivalent.
For part 2, sort the lengths so that and pick codewords one by one as leaves of the complete -ary tree. The inequality guarantees that a free node of depth remains at each step. For part 1, let and . Expanding groups the terms by the total length of codewords, and unique decodability allows at most such sequences for each . So for every , which forces .
Example: the binary variable-length code is a prefix code, and . Without unique decodability part 1 fails: the code has , and the string can be read as one codeword or as two.
Going deeper
For a student
The inequality turns questions about codes into questions about numbers. For example, the minimum expected length of a uniquely decodable code is found by minimizing subject to . This leads to the lower bound by the entropy in Shannon's source coding theorem. Part 1 also shows that nothing is lost by restricting to prefix codes, which can be decoded symbol by symbol.
Where this leads
3 pages build on this one.
Further reading
About this page
| Tag | G1ZAWMBNE1 |
|---|---|
| URI | m2://G1ZAWMBNE1 |
| Kind | statement, theorem |
| Writing | W0 stub |
| MSC | 94A45, 94A29, 68P30 |
| Status | This copy of the site has no build data. Run m2 status G1ZAWMBNE1. |
| Same as | |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
- a source with a locator (0 of 1)
- edge uses out: each definition that the statement needs (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.