◀ THE FOLD0ROOT.AI // WORLD II · LOOT · THE INVENTORY◆ .dlw.fold
THE FOLD / LOOT / THE INVENTORY / THE LEHMER CODE

THE LEHMER CODE

number a permutation with a mixed-radix odometer
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The Lehmer code (via the factorial number system) gives every permutation a unique index from 0 to k!−1, and every index its permutation back — a perfect bijection. It records, for each position, how many smaller elements sit to its right, then reads those counts as digits in a mixed radix where the place values are factorials (…, 3!, 2!, 1!, 0!) instead of powers of ten. It is an odometer whose wheels have different sizes.

LIT verified live: for every permutation of up to 7 elements, encode-then-decode returns the original, and the indices cover 0…k!−1 exactly once (window.__lehmer). FIG no framing; exact integer arithmetic, exhaustive over all k! permutations.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-inventory — every arrangement of the items gets its own slot number, and every slot number unpacks to exactly one arrangement. The Lehmer code is that indexing. AVAN (AI) built the instrument: the inversion-count encoder, the factoradic mixed-radix decoder, and the round-trip + bijection checks.

Credit as content: Derrick Henry Lehmer (the code); the factorial number system (Laisant, 1888). The weave: David names the-inventory; I count each element’s smaller-elements-to-the-right, read them as factorial-base digits, and confirm the map between permutations and 0…k!−1 is a perfect bijection both ways.
3 ONE DIMENSION
Factoradic: digit dₕ may range 0…i, place value i!. So 3·3! + 1·2! + 0·1! + 0·0! = 20 — the odometer whose wheels grow. Each permutation is one reading.
4 TWO DIMENSIONS · INTERACTIVE
A permutation, its Lehmer code, and its rank; the round-trip checked back to the permutation.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: every ordering given one number.
AVAN’s addition (the inverse-companion): address a permutation by a single integer in a mixed-radix where the wheels are factorials — count smaller-to-the-right, read as factoradic. The inverse of ‘store the permutation as a list’ is ‘store its rank — one number that unpacks to the exact ordering.’ Magenta is the explicit list; green is the single factoradic index. An ordering as an odometer reading.
LIT Genuine Lehmer code / factorial number system (D. H. Lehmer; factorial base, Laisant 1888). Verified live exhaustively: for every permutation of k≤7 elements, the inversion-count encoder and factoradic decoder round-trip to the original permutation (window.__lehmer.roundTrip), and the ranks cover 0..k!−1 exactly once — a bijection (window.__lehmer.bijection).

FIG No framing: the inversion-count encoder, the factoradic mixed-radix decoder, and the round-trip + bijection checks run in-browser with exact integers over all k! permutations and agree. The AVAN inverse is honest — addressing a permutation by one factoradic integer genuinely replaces storing the explicit list; magenta is the list, green the single index. An ordering as an odometer reading.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE INVENTORY · David Lee Wise (ROOT0), with AVAN