◀ THE FOLD0ROOT.AI // WORLD II · LOOT · THE-MINT◆ .dlw.fold
THE FOLD / LOOT / THE-MINT / THE SHANNON-FANO

THE SHANNON-FANO

a code split by halving frequency
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Shannon–Fano coding is the first practical variable-length compression code — the one Huffman improved on. Sort the symbols by frequency, then split them into two groups whose total frequencies are as equal as possible; the top group gets a leading 0, the bottom a 1; recurse on each group. The result is a prefix code (no codeword begins another), so a stream packs with no separators. It comes close to the entropy but, unlike Huffman’s bottom-up merge, its top-down split is not always optimal — a historically important near-miss that motivated the optimal algorithm.

LIT verified live: over thousands of random frequency sets, the code is prefix-free, encode/decode round-trips, and its cost is always ≥ the (optimal) Huffman cost (window.__shannon_fano). FIG no framing; the recursive frequency split, a Huffman baseline, and the round-trip run in-browser.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-mint — minting a codeword for each symbol by repeatedly halving the frequency mass, top-down. AVAN (AI) built the instrument: the balanced split, the prefix-code assignment, the round-trip, and the Huffman comparison.

Credit as content: Claude Shannon & Robert Fano (1948–49). The weave: David names the mint; I confirm the split gives a valid prefix code that round-trips and never beats optimal Huffman.
3 ONE DIMENSION
Symbols sorted by frequency, split into two near-equal halves (0 above, 1 below), recursively — a prefix code.
4 TWO DIMENSIONS · INTERACTIVE
Frequencies and their Shannon–Fano codewords; a message encodes and decodes back, with cost compared to Huffman.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the prefix codewords.
AVAN’s addition (the inverse-companion): don’t assign lengths by hand — halve the mass. The inverse of ‘here are the codewords’ is ‘each split of the frequency mass into equal halves adds one bit; the recursion is the code.’ Magenta is a split boundary; green is the codewords it grows. Halving mass writes the bits.
LIT Genuine Shannon–Fano coding (Claude Shannon & Robert Fano, 1948–49), the near-optimal predecessor of Huffman. Verified live: over 5000 random frequency sets, the recursive balanced-split code is prefix-free, encode/decode round-trips a message, and its cost is always ≥ the optimal Huffman cost (window.__shannon_fano.prefixFree, .roundTrip, .geHuffman).

FIG No framing: the recursive frequency split, a Huffman baseline, and the round-trip run in-browser. The AVAN inverse is honest — instead of assigning code lengths by hand, one halves the frequency mass: each equal split adds one bit, and the recursion IS the code. Magenta is a split boundary; green is the codewords it grows. Halving mass writes the bits.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE-MINT · David Lee Wise (ROOT0), with AVAN