InformationTheory.Shannon.Huffman.Optimality
Huffman optimality — Cover–Thomas #
Proves that huffmanLength minimizes expected codeword length among all Kraft-feasible
length functions, via the sibling property and n → n-1 strong induction.
Main statements #
exists_deepest_leaf— a deepest leaf ofhuffmanLength Palways exists.exists_sibling_min_pair— the sibling property: the two minimum-probability elements have equal Huffman length.huffmanLength_optimal_aux— induction motor:huffmanLength Pis optimal among Kraft-feasible length functions, given swap normalization as a hypothesis.
Implementation notes #
The proof uses a hybrid design: the merged alphabet is α' := { x : α // x ≠ b } (a Subtype),
and mergedMeasure assigns probability P{a} + P{b} to the merged element and P{x} elsewhere.
mergedMeasure is constructed as Measure.sum (fun x => f x • Measure.dirac x) so that
Measure.sum_smul_dirac_singleton applies directly.
The induction step avoids a per-symbol depth identity (which would be false for a general
Huffman tree) and instead uses the cost-level equality expectedLength_merged_cost_bridge.
References #
- T. M. Cover and J. A. Thomas, Elements of Information Theory (2nd ed.), Wiley, 2006.
Deepest leaf and sibling property helpers #
InformationTheory.Shannon.Huffman.exists_deepest_leaf
sourceA deepest leaf of huffmanLength P exists when Fintype.card α ≥ 1.
Used by
InformationTheory.Shannon.Huffman.huffmanLength_eq_of_min_prob_pair
sourceUsed by
Sibling property #
InformationTheory.Shannon.Huffman.exists_sibling_min_pair
sourceSibling property: the two minimum-probability elements have equal huffmanLength.
Returns a = global-min probability and b = second-min probability.
Used by
Merged measure on the reduced alphabet #
InformationTheory.Shannon.Huffman.mergedMeasure
sourceMerged probability measure on α' := { x : α // x ≠ b }: assigns P{a} + P{b} to
the merged element and P{x} to all other elements.
Equations
Instances For
Used by
InformationTheory.Shannon.Huffman.mergedMeasure_real
sourceUsed by
InformationTheory.Shannon.Huffman.kraft_sum_mergedLength_eq
sourceUsed by
InformationTheory.Shannon.Huffman.expectedLength_eq_mergedMeasure_mergedLength_add
sourceUsed by
InformationTheory.Shannon.Huffman.expectedLength_bridge_R
sourceUsed by
Probability measure instances for mergedMeasure #
InformationTheory.Shannon.Huffman.mergedMeasure_isProbabilityMeasure
sourcemergedMeasure P a b hab is a probability measure (since
P is and the singleton masses sum to 1 on α').
Used by
InformationTheory.Shannon.Huffman.mergedMeasure_pos
sourcePositivity of mergedMeasure on singletons (from positivity of P).
Used by
InformationTheory.Shannon.Huffman.swap_step_le
sourceUsed by
Swap normalization hypothesis #
InformationTheory.Shannon.Huffman.SwapNormalizationHypothesis
sourceInterface predicate for the swap normalization step used by huffmanLength_optimal_aux.
Given least-prob pair (a, b) with a = global-min and b = second-min, any
Kraft-feasible ll can be normalized to l_norm with l_norm a = l_norm b,
non-increasing expected length, and Kraft ≤ 1.
The constructive proof is swap_normalization_proof in StrongForm.lean.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Cost-level bridge #
InformationTheory.Shannon.Huffman.initMultiset_mergedMeasure_snd_map_eq
sourceUsed by
InformationTheory.Shannon.Huffman.expectedLength_merged_cost_bridge
sourceCost-level bridge:
expectedLength P (huffmanLength P) = expectedLength (mergedMeasure P a b hab) (huffmanLength (mergedMeasure P a b hab)) + (P.real {a} + P.real {b}).
@audit:ok
Used by
InformationTheory.Shannon.Huffman.huffmanLength_le_one_of_card_le_two
sourceUsed by
InformationTheory.Shannon.Huffman.two_le_normalizedLength_of_card_ge_three
sourceUsed by
InformationTheory.Shannon.Huffman.huffmanLength_optimal_aux
sourceStrong-induction motor for Huffman optimality.
Takes h_swap : SwapNormalizationHypothesis as an argument; the headline huffmanLength_optimal
in StrongForm.lean supplies swap_normalization_proof to discharge it unconditionally.
@audit:ok