◀ THE FOLD0ROOT.AI // WORLD II · CO-OP · THE MERGE◆ .dlw.fold
THE FOLD / CO-OP / THE MERGE / THE CANTOR PAIRING

THE CANTOR PAIRING

weave two numbers into one, and back
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The Cantor pairing function weaves two natural numbers into one, reversibly: π(x,y) = (x+y)(x+y+1)/2 + y. It walks the infinite grid along diagonals, assigning 0,1,2,… to each cell, so every pair (x,y) gets a unique number and every number decodes back to exactly one pair. It is a genuine bijection ℕ² → ℕ — a proof, in one formula, that the plane of pairs is no bigger than the line of counting numbers.

LIT verified live: over all pairs in 0–200, unpair(pair(x,y)) returns exactly (x,y), and no two pairs collide to the same number (window.__cantor). FIG no framing; exact integer arithmetic.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-merge — two streams becoming one without loss, so the one can always be split back into the exact two. The Cantor pairing is that lossless merge. AVAN (AI) built the instrument: the diagonal-index formula, the triangular-root inverse, and the round-trip and no-collision checks.

Credit as content: Georg Cantor (diagonal enumeration, 1870s). The weave: David names the-merge; I fold (x,y) into one index by counting along diagonals, invert it via the triangular root, and confirm the merge is lossless — every number splits back into exactly the pair it came from.
3 ONE DIMENSION
Number the grid cells along successive diagonals: (0,0)→0, (1,0)→1, (0,1)→2, (2,0)→3… Every pair gets one index; every index decodes to one pair.
4 TWO DIMENSIONS · INTERACTIVE
The diagonal enumeration of the grid; pick a cell to see its index, and the round-trip checked.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: two numbers folded into one, reversibly.
AVAN’s addition (the inverse-companion): merge two numbers into a single key that can be split back exactly — index the diagonals of the grid, and invert with the triangular root. The inverse of ‘store a pair as two fields’ is ‘fold it into one bijective key and unfold on demand.’ Magenta is the second field you no longer store; green is the single lossless index. Two into one, and back.
LIT Genuine Cantor pairing function (Georg Cantor, diagonal enumeration, 1870s). Verified live: over every pair (x,y) with 0≤x,y≤200, the triangular-root inverse recovers exactly (x,y) from π(x,y) (window.__cantor.roundTrip), and all 201²=40401 indices are distinct — the map is injective (window.__cantor.injective) — exact integer arithmetic.

FIG No framing: the diagonal-index formula, the triangular-root inverse, and the round-trip and no-collision checks run in-browser and agree exactly. The AVAN inverse is honest — folding (x,y) into one bijective key that unfolds on demand genuinely replaces storing two fields; magenta is the second field no longer stored, green the single lossless index. A bijection ℕ²→ℕ.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE MERGE · David Lee Wise (ROOT0), with AVAN