THE FOLD / GRIND / WARM CACHE / THE HILBERT
THE HILBERT
fill the square without ever jumping — locality kept
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The Hilbert curve. A single continuous fractal path that visits every cell of a 2n×2n grid exactly once — and never jumps: consecutive cells are always neighbors. It is a space-filling curve, a way to unroll a 2D square into a 1D line.
The magic is locality preservation. Two points close together on the line stay close together on the plane. Row-major scanning (left to right, top to bottom) tears that apart — two cells one row apart are a whole width away in memory. Hilbert doesn’t tear. That is why it is used for cache-friendly memory layouts, spatial database keys (map (x,y) to a 1D index that clusters), image dithering, and R-tree ordering: put spatially near things near in storage, and the cache hits.
LIT verified live: for grids up to 64×64 the index→(x,y) map is a bijection, its inverse (x,y)→index round-trips exactly, and every pair of consecutive indices is Manhattan-distance 1 apart (window.__hilbert). FIG no framing; the bijection, the exact inverse, and the adjacency are all real.
The magic is locality preservation. Two points close together on the line stay close together on the plane. Row-major scanning (left to right, top to bottom) tears that apart — two cells one row apart are a whole width away in memory. Hilbert doesn’t tear. That is why it is used for cache-friendly memory layouts, spatial database keys (map (x,y) to a 1D index that clusters), image dithering, and R-tree ordering: put spatially near things near in storage, and the cache hits.
LIT verified live: for grids up to 64×64 the index→(x,y) map is a bijection, its inverse (x,y)→index round-trips exactly, and every pair of consecutive indices is Manhattan-distance 1 apart (window.__hilbert). FIG no framing; the bijection, the exact inverse, and the adjacency are all real.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this in WARM CACHE, beside the other locality spheres — the grind domain of keeping the working set hot. The Hilbert curve is the classic trick for a cache-friendly 2D layout. AVAN (AI) built the instrument: the recursive curve, the index probe, the row-major contrast.
The weave: David names the seat (the warm cache); I make the curve fill the grid without ever jumping and show why that keeps memory hot — the index strip in 1D, the drawn curve in 2D, the locality contrast in 3D. The sphere is the seam. Credit: David Hilbert (1891), building on Giuseppe Peano’s first space-filling curve (1890).
The weave: David names the seat (the warm cache); I make the curve fill the grid without ever jumping and show why that keeps memory hot — the index strip in 1D, the drawn curve in 2D, the locality contrast in 3D. The sphere is the seam. Credit: David Hilbert (1891), building on Giuseppe Peano’s first space-filling curve (1890).
3 ONE DIMENSION
The 1D index line 0, 1, 2, …, N−1 — the order the curve visits cells. Slide along it and the highlighted plane cell (shown in window 4) moves only one step at a time. The line and the square are the same walk.
4 TWO DIMENSIONS · INTERACTIVE
The Hilbert curve drawn at order p. Probe an index to see its cell; the curve never breaks contact with itself. Toggle the row-major scan to see the alternative that jumps a full row every wrap.
5 THREE DIMENSIONS + AVAN’S INVERSE
The curve lifted into 3D: x, y, and the 1D index as height. The green ribbon climbs smoothly — a small step in height is always a small step in the plane.
AVAN’s addition (the inverse-companion): the magenta ribbon is the row-major layout on the same grid — the naive inverse. Both are bijections between the line and the square; the difference is entirely in the inverse’s behavior. Row-major maps the square to the line by tearing every vertical neighborhood apart — two cells stacked vertically land a full width apart in 1D, so the magenta ribbon leaps across the whole plane on every row wrap. Hilbert’s inverse keeps the neighborhoods intact: nowhere does it leap. That is the real inverse here — not a mirror, but the other direction of the same map, and the whole point of the curve is that its inverse doesn’t shred locality the way the obvious one does. Green never jumps; magenta jumps a full width every wrap. Same bijection, opposite treatment of what’s near.
LIT Genuine Hilbert curve (David Hilbert 1891, after Peano 1890). Verified live: for grids up to 64x64 the index->(x,y) map is a bijection (all cells hit once), its inverse (x,y)->index round-trips exactly, and every pair of consecutive indices is Manhattan-distance 1 apart (window.__hilbert.bijection && inverse && locality, all true). The bijection, exact inverse, and step-1 adjacency are real; the locality advantage over row-major is shown directly.
FIG No framing: the space-filling bijection, the exact inverse mapping, and the always-adjacent traversal are real and checked to 64x64. The cache-friendliness is the genuine consequence of the adjacency property, contrasted honestly against the row-major alternative on the same grid.
FIG No framing: the space-filling bijection, the exact inverse mapping, and the always-adjacent traversal are real and checked to 64x64. The cache-friendliness is the genuine consequence of the adjacency property, contrasted honestly against the row-major alternative on the same grid.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of WARM CACHE · David Lee Wise (ROOT0), with AVAN