Alphabeta Math
TheoremStatement: Literature-sourcedProof: AI-adaptedPipeline-generatedprecheck pass
How statement and proof provenance work

The first chip identifies the source of the statement or construction; the second identifies the source of its local proof or verification.

  • Literature-sourced: the exact statement appears in a cited source; only wording and notation differ.
  • AI-adapted: a semantically identical restatement of literature-sourced material, modulo indexing, notation, and boundary cases adopted by the library.
  • AI-generated: a genuinely novel statement formulated by AI, with no source for the claim itself.

These labels describe origin, not correctness: citations and verification chips remain separate evidence.

The deterministic Huffman code is prefix-optimal

Statement

For every finite full-support source, the algorithm Deterministic binary Huffman coding terminates, returns a binary prefix code, and minimizes Lp(C) among all binary prefix codes on the same alphabet. For a one-symbol source it returns the one-bit codeword 0, which is optimal among codes with nonempty codewords.

Facts & Assumptions

Given: A finite full-support source (m,p) and the deterministic algorithm Deterministic binary Huffman coding.

[F1]

Finite discrete sources and product blocks: The alphabet has m≥1 symbols, every source weight pi is positive, and ∑ipi=1.

[F2]

Binary prefix codes and their code trees: The code tree is the finite trie of codeword prefixes, and a prefix code has distinct codeword leaves with no codeword a proper prefix of another.

[F3]

Finite binary source codes, extension, and expected length: Every codeword is nonempty and Lp(C)=∑ipiℓi.

[F4]

Binary Kraft criterion for finite positive codeword lengths: A finite positive integer length list with Kraft sum at most one is realized by a binary prefix code.

[F5]

Deterministic binary Huffman coding: Order active nodes lexicographically by (weight, serial number), using the ordinary order on real weights and then integer serials.

[F6]

Deterministic binary Huffman coding: Remove the first two nodes. Make a new parent whose left child is the first removed node and whose right child is the second, whose weight is their sum, and whose serial is the next unused integer.

[F7]

Deterministic binary Huffman coding: If m=1, return the one-bit codeword CH(1)=0.

Proof

technique · Induct on list size $m\ge2$: for every finite list of at least two positive weights with distinct serial numbers and total weight one, every sequence of minimum-weight merges, including every tie resolution, gives an optimal prefix code. The base case is size two; the one-symbol source is handled separately in step 1.1. A reduced list retains positive weights, total weight one, and distinct serials because each parent receives a fresh serial. The original source and each reduced active list are instances of this claim
1.1F2F3F7given

If m=1, the algorithm returns 0 by [F7]. Every codeword is nonempty by [F3], so every one-symbol code has expected length at least 1; the returned code is prefix-free by [F2] and attains that value.

1.2F2F6givenalgebra

Suppose m≥2. Every merge removes two nodes and adds one, so the active count decreases by exactly one; after m−1 merges there is one root. Each original symbol remains one leaf, and the only new nodes are internal parents by [F6]. Distinct leaves cannot lie on one root-to-leaf path, so their path words are distinct and neither is a prefix of another. Every path has positive length because the root is internal. Thus [F2] gives a binary prefix code.

1.3F1F3F4givenchoosealgebra

An optimal prefix code exists. For every integer m≥1, m≤2m by induction: it holds at m=1, and 2m+1≥2m≥m+1. Thus [F4] applied to the length list (m,…,m) gives a finite prefix code, since its Kraft sum m2−m≤1; let its cost be L0. Any code with cost at most L0 has 1≤ℓi≤L0/pi for every i, because pi>0 and all summands in Lp are nonnegative. Only finitely many positive integer length vectors satisfy these bounds, and at least one is realized. A least cost among those realized vectors exists and is a global minimum because every code outside the set has cost greater than L0.

1.4F1F3F6givenbase

For an active list of size two and total weight one, the algorithm merges its two nodes into a root with two leaves, giving lengths 1,1 and cost 1. Every binary source code has nonempty words by [F3], so every competing prefix code has both lengths at least one and cost at least the sum of the weights, namely 1 by [F1]. Thus the size-two case is optimal.

1.5givenassume-hypih

Suppose the active list has size m≥3 and assume as induction hypothesis that every sequence of minimum-weight merges on a positive normalized list of size m−1 with distinct serials gives an optimal code.

2.1F1F2step 1.3algebra

In an optimal code tree, no internal vertex has exactly one child: contracting its sole edge preserves the leaves and their incomparability, so [F2] still gives a prefix code, while every codeword below the vertex loses one bit. At least one symbol is below it by the trie definition, and its positive weight by [F1] makes the expected length strictly smaller, a contradiction. Hence every internal vertex has two children. Choose a leaf of maximal depth d. Its sibling cannot be internal, since that sibling would have a descendant leaf deeper than d; it is therefore another leaf at depth d.

2.2F5F6step 1.5induction

The first selected pair a,b gives a reduced list of size m−1 with positive weights summing to one and distinct serials. Its subsequent merges are minimum-weight choices by [F5] and [F6]. The induction hypothesis in step 1.5 therefore makes the reduced tree optimal for its weights.

3.1F1F2F5F6step 2.1givenalgebra

Let a,b be the two symbols selected by the algorithm for its first merge; [F5] and [F6] make them two symbols of least weight. Place them at a sibling pair of leaves at depth d without increasing cost. If a is currently at depth e≤d and a symbol x of weight px≥pa occupies the chosen depth-d leaf, swapping them changes the two cost terms from pae+pxd to pad+pxe, a difference (pa−px)(d−e)≤0. Then place b in the sibling leaf by the same calculation, since its current occupant has weight at least pb. Relabeling leaves preserves the prefix property; the original code was optimal, so the resulting code is still optimal.

4.1F1F2F3step 3.1algebra

Contract the two sibling leaves labeled a,b to one leaf z with weight pz=pa+pb. The contracted tree is a prefix code on the reduced alphabet and its cost is the original cost minus pa+pb, since both leaf depths decrease by one. Conversely, expanding any reduced prefix code by replacing the codeword for z with its two children labeled a,b preserves the prefix property and increases cost by pa+pb. Therefore contraction sends an optimal original code to an optimal reduced code, and expanding an optimal reduced code gives an optimal original code.

5.1step 1.2step 4.1step 1.4step 2.2discharge-induction: step 2.2∎

By step 4.1, expansion of that reduced tree is optimal for the original weights. The algorithm terminates and returns a prefix code by step 1.2; the base case step 1.4 and the induction step prove its optimality for every m≥2.

Depends on

Used by

Cited to discharge well-definedness by Deterministic binary Huffman coding.

Dependency tree · two levels

7 results within two dependency steps of this one, each drawn at its shortest distance from it. An arrow runs from a result to what uses it, so the chart reads left to right and ends at this result, which carries a heavier outline. Every node is a link to that result. Click elsewhere on the chart to enlarge it.

Sources