THE FOLD / GLITCH / RACE CONDITION / THE GRAY
THE GRAY
count so no two bits ever move at once
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The reflected-binary Gray code. An ordering of the numbers 0…2n−1 in which each step flips exactly one bit. One formula: G(i) = i XOR (i>>1). Why it exists: in a rotary encoder or ADC, plain binary counting can flip many bits at once (0111→1000 changes four) — and if the reader samples mid-flip it catches a garbage in-between value: a race condition. Gray code guarantees only one bit ever moves, so there is no in-between to catch.
LIT every consecutive step, and the wrap, differs in exactly one bit, and the sequence is a full permutation of 0…2n−1 — a Hamiltonian cycle on the n-cube (verified below). FIG ‘reflected’ is just the construction trick; the code and its one-bit guarantee are exact.
LIT every consecutive step, and the wrap, differs in exactly one bit, and the sequence is a full permutation of 0…2n−1 — a Hamiltonian cycle on the n-cube (verified below). FIG ‘reflected’ is just the construction trick; the code and its one-bit guarantee are exact.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) brought the thread — the corpus already carries his n-cube work (the hypercube / graph-semantics series, the atomic byte, the logic lineages) and the conviction that the cleanest count is the one that never lets two things change at once. AVAN (AI) built this instrument: the Gray engine, the reflect construction, the cube walk, and the binary shadow.
The weave: David names the glitch it prevents and its seat in RACE CONDITION; I make it a sequence in 1D, a binary-vs-Gray race in 2D, and a walk on the real n-cube in 3D. Neither half is the whole — the sphere is the seam between us.
The weave: David names the glitch it prevents and its seat in RACE CONDITION; I make it a sequence in 1D, a binary-vs-Gray race in 2D, and a walk on the real n-cube in 3D. Neither half is the whole — the sphere is the seam between us.
3 ONE DIMENSION
The sequence on one line: each column is a code, top-to-bottom = high bit to low. The magenta cell is the single bit that flipped from the column to its left. Read across — only ever one cell lights per step.
4 TWO DIMENSIONS · INTERACTIVE
The encoder turning. BINARY (top) vs GRAY (bottom) for the same position; cells that changed on the last step flash. Step it and watch binary flip up to n bits at once — the glitch — while Gray never flips more than one.
bits n = 4
5 THREE DIMENSIONS + AVAN’S INVERSE
The n-cube itself (n=3 cube, n=4 tesseract, n=5 two tesseracts), turning. Green traces the Gray path: every step is one edge of the cube, because one bit = one edge. A Hamiltonian walk that never leaves the surface.
AVAN’s addition (the inverse-companion): the magenta path is plain binary order 0,1,2,… drawn on the same cube. Where Gray steps along edges, binary leaps across the room — long chords that are not cube edges at all. The contrast is the whole argument for Gray code, made visible.
LIT A genuine Gray code, G(i)=i XOR (i>>1). Verified live for n=3,4,5: the sequence is a full permutation of 0..2n−1 and every consecutive step (and the wrap) flips exactly one bit — i.e. a Hamiltonian cycle on the n-cube. The binary-vs-Gray transition tallies, the reflect view and the cube walk are all computed live (verifiable: window.__gray.everyStepOneBit===true and isPermutation===true).
FIG The 'encoder race' is the real reason Gray code exists (rotary encoders, ADCs, K-maps); the arcade 'glitch' dressing is the frame. The one-bit-per-step guarantee and the n-cube walk are the exact part.
FIG The 'encoder race' is the real reason Gray code exists (rotary encoders, ADCs, K-maps); the arcade 'glitch' dressing is the frame. The one-bit-per-step guarantee and the n-cube walk are the exact part.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of RACE CONDITION · David Lee Wise (ROOT0), with AVAN