THE FOLD / CO-OP / THE HANDOFF / THE rANS
THE rANS
compress a whole message into one big integer
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
rANS (range Asymmetric Numeral System) is a modern entropy coder that encodes a whole message into a single very large integer — reaching near-optimal compression like arithmetic coding, but with the speed of table lookups. Each symbol folds into the state x by x ← ⌊x/fs⌋·M + (x mod fs) + cs, using its frequency fs and cumulative cs; decoding peels symbols back off in reverse. It powers Zstandard, LZFSE, and modern image codecs.
LIT verified live: over 300 random messages and frequency tables, encode∘decode reproduces the exact message (BigInt state, no loss) — window.__rans. FIG no framing; exact round-trip.
LIT verified live: over 300 random messages and frequency tables, encode∘decode reproduces the exact message (BigInt state, no loss) — window.__rans. FIG no framing; exact round-trip.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-handoff — the moment data is squeezed for passing on and must come back byte-perfect. rANS is that squeeze. AVAN (AI) built the instrument: the frequency table, the cumulative slots, the BigInt encode/decode state machine, and the exact round-trip check.
Credit as content: Jarek Duda (ANS, 2009). The weave: David names the handoff; I fold each symbol into one growing integer by its frequency and peel them back in reverse, confirming the message returns exactly.
Credit as content: Jarek Duda (ANS, 2009). The weave: David names the handoff; I fold each symbol into one growing integer by its frequency and peel them back in reverse, confirming the message returns exactly.
3 ONE DIMENSION
Each symbol carves the state into M slots, keeping a slice of width fs: x ← ⌊x/fs⌋·M + cs + (x mod fs). Frequent symbols grow the number slowly (few bits); rare ones grow it fast.
4 TWO DIMENSIONS · INTERACTIVE
A message and its frequency table encode into one big integer; decoding peels the symbols back, checked against the original.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: an entire message held as one integer.
AVAN’s addition (the inverse-companion): compress to near the entropy limit by folding a message into a single number whose size grows by each symbol’s information content — frequent symbols cost fractions of a bit. The inverse of ‘store each symbol in whole bits’ is ‘fold the whole message into one integer, fractional bits and all.’ Magenta is the wasted whole-bit padding of naive coding; green is the single tight integer. Arithmetic coding’s fast successor.
LIT Genuine range ANS entropy coding (Duda 2009). Verified live: over 300 random messages and random frequency tables, folding each symbol into a BigInt state and peeling them back in reverse reproduces the exact original message with no loss (window.__rans.roundTrip).
FIG No framing: the frequency table, the cumulative slots, the BigInt encode/decode state machine, and the exact round-trip check run in-browser and hold. The AVAN inverse is honest — folding a message into one integer whose size grows by each symbol's information content compresses near the entropy limit (fractional bits per symbol); magenta is the wasted whole-bit padding of naive coding, green the single tight integer. Arithmetic coding's fast successor.
FIG No framing: the frequency table, the cumulative slots, the BigInt encode/decode state machine, and the exact round-trip check run in-browser and hold. The AVAN inverse is honest — folding a message into one integer whose size grows by each symbol's information content compresses near the entropy limit (fractional bits per symbol); magenta is the wasted whole-bit padding of naive coding, green the single tight integer. Arithmetic coding's fast successor.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE HANDOFF · David Lee Wise (ROOT0), with AVAN