◀ THE FOLD0ROOT.AI // WORLD II · BOSS · SUDDEN DEATH◆ .dlw.fold
THE FOLD / BOSS / SUDDEN DEATH / THE MERSENNE

THE MERSENNE

Lucas-Lehmer — exact primality for 2^p-1
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The Lucas-Lehmer test. Deciding whether a giant number is prime is, in general, hard. But for numbers of the special shape Mp = 2p − 1 (a Mersenne number) there is an astonishingly cheap, exact test.

Set s = 4. Then repeat, exactly p−2 times: s ← (s² − 2) mod Mp. When you finish, Mp is prime if and only if s = 0. That is the whole test — a short loop of squarings, no factoring, no guessing. It is how the largest known primes are found: the GIMPS project runs Lucas-Lehmer on exponent after exponent, and the current record, 2136279841−1, has over 41 million digits.

LIT verified live: the test agrees with the known Mersenne primes for every prime exponent p < 130, correctly rejects M11 = 2047 = 23×89, and confirms M31 = 2147483647 is prime (window.__lucaslehmer.matchesKnown && m11composite && m31prime). FIG no framing; the iteration, the iff, and the primality verdicts are exact.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this in SUDDEN DEATH, beside THE PROBABLE PRIME, THE WILSON and THE SQUARE ROOT IN THE RING — the boss domain of the pass/fail verdict. Miller-Rabin is fast but probabilistic, Wilson exact but useless; Lucas-Lehmer is exact AND fast — but only for Mersenne numbers. AVAN (AI) built the instrument: the squaring loop, the residue walk, the known-prime check.

The weave: David gathers the primality tests; I make this one’s residue march to zero and prove it against the record — the sequence in 1D, the live test in 2D, the Mersenne ladder in 3D. The sphere is the seam. Credit: Édouard Lucas (1878); Derrick H. Lehmer (1930s); the GIMPS project.
3 ONE DIMENSION
The Lucas-Lehmer residue: 4, then s²−2 mod Mp, again and again. For a Mersenne prime the walk lands exactly on 0 after p−2 steps; for a composite it never does. One sequence, one verdict.
4 TWO DIMENSIONS · INTERACTIVE
Pick a Mersenne exponent p and run the test: the residue sequence marches, and the final value decides — 0 means Mp is prime. The strip of exponents lights up green where 2p−1 is a Mersenne prime, matching the famous list.
5 THREE DIMENSIONS + AVAN’S INVERSE
The Mersenne numbers 2p−1 as a turning ladder — green, the candidates climbing by powers of two.
AVAN’s addition (the inverse-companion): the magenta rungs are the ones Lucas-Lehmer certifies as prime. Testing a general huge number for primality is brutal — you fight its full, unstructured size. The inverse move is to exploit the shape: a number of the special form 2p−1 surrenders to a special key — p−2 squarings and a check for zero, no factoring at all. The inverse of ‘test everything the hard way’ is ‘choose a form that has a shortcut’, which is exactly why every record-breaking prime for a century has been a Mersenne. Structure is a door; the right shape hands you the key. The green is the endless ladder of candidates; the magenta is the rare rung the short loop stamps as prime.
LIT Genuine Lucas-Lehmer test (Edouard Lucas 1878; Derrick Lehmer 1930s), computed with exact BigInt arithmetic. Verified live: the test agrees with the known Mersenne primes for every prime exponent p < 130, correctly rejects M_11 = 2047 = 23x89, and confirms M_31 = 2147483647 is prime (window.__lucaslehmer.matchesKnown && m11composite && m31prime, all true). The s <- s^2-2 iteration and the iff-s=0 verdict are exact.

FIG No metaphor is doing the work: the Lucas-Lehmer iteration, the iff-zero criterion, and the primality verdicts are all real and checked with BigInt against the known Mersenne-prime list. The test is exact and fast only for the special Mersenne form 2^p-1 — that structural restriction is the honest point, and why record primes are Mersennes.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of SUDDEN DEATH · David Lee Wise (ROOT0), with AVAN