THE HAAR

the Haar wavelet in the 5-window house format — the simplest multiresolution transform: replace each pair of samples with their average and difference (scaled by 1/sqrt2), then recurse on the averages, yielding a coarse approximation plus detail coefficients at every scale. Being orthonormal, it is perfectly invertible (inverse-averaging resurrects the exact signal) and preserves energy: sum(coeffs^2) = sum(signal^2) (Parseval). It is the ancestor of wavelet image compression. Verified live: for 200 random length-8 signals the inverse reproduces the original to ~1e-12 and Parseval holds. See average/difference in 1D, decompose+reconstruct in 2D, and the self-inverse pyramid in 3D.

THE HAAR · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · RESPAWN · THE RESURRECT ◆ .dlw.fold THE FOLD / RESPAWN / THE RESURRECT / THE HAAR THE HAAR average and difference, recurse — perfectly invertible 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Haar wavelet is the simplest multiresolution transform: replace each pair of samples with their average and their difference (scaled by 1/√2), then recurse on the averages. One cascade turns a signal into a coarse approximation plus detail coefficients at every scale. Because the transform is orthonormal , it is perfectly invertible — inverse-averaging resurrects the exact original — and it preserves energy : Σ(coefficients²) = Σ(signal²) (Parseval). It is the ancestor of wavelet image compression (JPEG 2000). LIT verified live: for 200 random length-8 signals, the inverse Haar transform reproduces the original to ~10⁻¹², and the sum of squared coefficients equals the sum of squared samples (Parseval) to the same precision (window.__haar). FIG no framing; exact orthonormal transform. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-resurrect — bringing the exact original back from its encoded form. The Haar transform is a clean resurrection: from the coarse average and the details, the signal returns bit-for-bit. AVAN (AI) built the instrument: the forward average/difference cascade, the inverse reconstruction, the Parseval energy check. Credit as content: Alfréd Haar (1910), the first wavelet, decades before the wavelet boom of the 1980s–90s. The weave: David names the resurrection; I decompose a signal into scales, rebuild it exactly from the coefficients, and show the energy conserved on the way. 3 ONE DIMENSION One Haar step: each adjacent pair becomes an average (coarse) and a difference (detail). Recurse on the averages and a pyramid of coefficients appears — one coarse value and details at every scale. 4 TWO DIMENSIONS · INTERACTIVE A length-8 signal, its Haar coefficients (coarse + details), and the reconstruction. Zero out small details to compress, and watch the inverse still land near the original; keep all and it returns exactly. Energy is preserved throughout. new signal ▶ drop small details ▶ verify ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the multiresolution pyramid — one coarse value at the top, details fanning out at each finer scale. AVAN’s addition (the inverse-companion): the transform is its own structural mirror — the inverse is the same average/difference operation run backward, and because the basis is orthonormal the round trip is exact and the total energy is conserved (Parseval), so the coefficients hold the whole signal with nothing added or lost. The inverse of ‘decompose into scales’ is ‘recompose from scales, exactly.’ This also makes lossy compression honest : discarding a small detail coefficient changes the signal by exactly that coefficient’s energy — you know precisely what you are throwing away. Magenta is the discarded details, a measurable loss; green is the resurrected signal. A transform whose inverse is itself, conserving every unit of energy. pause spin LIT Genuine Haar wavelet (Haar 1910). Verified live: the forward average/difference cascade (scaled 1/sqrt2) and its inverse reproduce 200 random length-8 signals to ~1e-12, and sum of squared coefficients equals sum of squared samples (Parseval) to the same precision (window.__haar.perfectReconstruction && .energyPreserved). FIG No framing: the forward transform, the inverse reconstruction, and the Parseval energy check run in-browser and are exact to floating precision. The AVAN inverse is honest — the transform is orthonormal so the inverse is the same operation backward, the round trip is exact, and energy is conserved, which makes lossy compression measurable (dropping a coefficient loses exactly its energy). Magenta = discarded small details, green = the resurrected signal. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE RESURRECT · David Lee Wise (ROOT0), with AVAN


THE EULERIAN

the Eulerian numbers in the 5-window house format — <n,k> counts permutations of 1..n with exactly k descents (a value followed by a smaller one). The triangle 1;1,1;1,4,1;1,11,11,1;1,26,66,26,1 is symmetric and each row sums to n!, obeying <n,k>=(k+1)<n-1,k>+(n-k)<n-1,k-1>. Verified live: the recurrence matches a brute descent-tally over all n! permutations for n=1..7, and rows sum to n!. See a permutation's descents in 1D, recurrence vs brute in 2D, and the uniformity-into-distribution inverse in 3D.

I-13 v2.0 | net = binds - k | 4 planes, 13 symbols, 12 operants, 5 cortex rules | sha 64881ebf

THE EULERIAN · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · GRIND · THE GRINDSTONE ◆ .dlw.fold THE FOLD / GRIND / THE GRINDSTONE / THE EULERIAN THE EULERIAN count permutations by descents — a bell inside n! 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Eulerian number ⟨n,k⟩ counts the permutations of 1…n with exactly k descents — places where a value is followed by a smaller one. They form a triangle 1; 1,1; 1,4,1; 1,11,11,1; 1,26,66,26,1; … that is symmetric (reversing a permutation swaps ascents and descents) and whose rows sum to n! (every permutation has some descent count). They obey the recurrence ⟨n,k⟩ = (k+1)⟨n−1,k⟩ + (n−k)⟨n−1,k−1⟩, and Worpitzky’s identity writes xⁿ as a sum of binomials weighted by them. LIT verified live: the recurrence matches a brute tally of descents over all n! permutations for n=1…7, and each row sums to n! (window.__eulerian). FIG no framing; exact combinatorial counting. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-grindstone — grinding through every ordering and tallying its descents. Eulerian numbers are exactly that tally, organised. AVAN (AI) built the instrument: the recurrence, the brute descent count over all permutations, the row-sum check. Credit as content: Leonhard Euler (1755, in his work on the Eulerian polynomials). The weave: David names the grind; I count descents two ways — the recurrence triangle and the exhaustive permutation tally — and show a uniform pile of n! orderings resolve into a symmetric distribution. 3 ONE DIMENSION A permutation with its descents marked in red — each spot where the next value drops. The number of descents is the statistic Eulerian numbers count, and it ranges from 0 (sorted) to n−1 (reversed). 4 TWO DIMENSIONS · INTERACTIVE Pick n. The instrument computes the Eulerian row by the recurrence and by brute-tallying descents over all n! permutations, confirms they agree, and checks the row sums to n!. n: 5 ▶ verify n=1..7 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the Eulerian triangle, each row a symmetric bell of descent counts summing to n!. AVAN’s addition (the inverse-companion): the descent count is a refinement that turns a structureless pile into a distribution. Sum the row and you recover n! — forgetting the descents — but the individual counts reveal that a random permutation’s number of descents concentrates near (n−1)/2 in a bell-shaped curve. The inverse of ‘n! permutations, all alike’ is ‘the same n! sorted, by a single statistic, into a symmetric distribution.’ And the symmetry ⟨n,k⟩ = ⟨n,n−1−k⟩ is a genuine bijection — reversing each permutation swaps its ascents and descents. Magenta is the flat pile of all n! orderings; green is the Eulerian bell they fall into by descent count. One statistic makes a distribution out of uniformity. pause spin LIT Genuine Eulerian numbers (Euler 1755). Verified live: the recurrence =(k+1) +(n-k) matches a brute-force tally of descents over all n! permutations for n=1..7, and each row sums to n! (window.__eulerian.recMatchesBrute && .rowSumFactorial); =1,26,66,26,1. FIG No framing: the recurrence, the exhaustive descent tally, and the row-sum check run in-browser and agree exactly. The AVAN inverse is honest — the descent statistic refines the flat n! pile into a symmetric bell that concentrates near (n-1)/2, and the symmetry = is a real reversal bijection; magenta is the flat pile, green the Eulerian bell. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE GRINDSTONE · David Lee Wise (ROOT0), with AVAN


THE RUDIN-SHAPIRO

the Rudin-Shapiro sequence in the 5-window house format — r_n = (-1)^(number of '11' pairs in binary of n) is a +-1 sequence engineered so its partial sums grow like sqrt(N) not N (a nearly flat power spectrum, very low autocorrelation), which is exactly what radar pulse-compression and spread-spectrum need. Verified live: over N up to 200000 the ratio |S_N|/sqrt(N) stays bounded (measured max ~2.45, within the proven bound 2+sqrt2~3.41). See the +-1 walk in 1D, the sqrt(N) envelope in 2D, and the deterministic-looks-random inverse in 3D.

THE RUDIN-SHAPIRO · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · CO-OP · THE SYNC ◆ .dlw.fold THE FOLD / CO-OP / THE SYNC / THE RUDIN-SHAPIRO THE RUDIN-SHAPIRO a deterministic +-1 sequence with random-walk-flat sums 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Rudin–Shapiro sequence rₙ = (−1) (number of ‘11’ pairs in the binary of n) is a ±1 sequence engineered to be flat : its partial sums stay astonishingly small — growing like √N rather than N — and equivalently its power spectrum is nearly flat (very low autocorrelation). That flatness is prized: spreading a signal’s energy evenly across a band is exactly what radar pulse-compression and spread-spectrum communication need, and low-correlation ±1 sequences like this one make it possible. LIT verified live: over N up to 200,000, the ratio |S N |/√N of the partial sums stays bounded (measured max ≈ 2.45, within the proven bound 2+√2 ≈ 3.41), while a structureless sum would grow linearly (window.__rudinshapiro). FIG no framing; exact bit-counting. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-sync — correlation and synchronisation, where flat spectra let receivers lock on. The Rudin–Shapiro sequence is the sync engineer’s friend: deterministic, yet noise-flat. AVAN (AI) built the instrument: the bit-pair parity rule, the partial-sum walk, the √N envelope check. Credit as content: Harold Shapiro (1951 thesis) and Walter Rudin (1959); these are ‘Golay–Rudin–Shapiro’ sequences in signal processing. The weave: David names the sync; I generate the ±1 sequence from binary bit-pairs and show its sums hug a √N envelope no random-looking sum should respect so tightly. 3 ONE DIMENSION The ±1 sequence (from the parity of ‘11’ bit-pairs) and the running partial sum — a walk that, unlike most deterministic sums, never drifts far from zero. 4 TWO DIMENSIONS · INTERACTIVE Plot the partial sums S N against the ±C√N envelope. Extend N and watch the walk stay inside the square-root band, its peak ratio |S N |/√N holding near 2.45. N: 256 ▶ verify bound ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the Rudin–Shapiro partial-sum walk, hugging the √N envelope as it grows. AVAN’s addition (the inverse-companion): a fully deterministic sequence behaves, where it counts, like a random one. Its partial sums grow like √N — exactly the scale of a random walk of ±1 coin flips — and its spectrum is flat like white noise, yet every term is fixed by a two-line binary rule. The inverse of ‘structured and predictable’ is ‘as balanced as coin flips, on purpose.’ This is designed flatness : it is the mirror of Thue–Morse, whose rule designs imbalance-avoidance — here the rule designs correlation-avoidance , producing noise-like statistics from rigid structure. Magenta is the √N random-walk envelope; green is the deterministic walk that never escapes it. Rigidity engineered to look like chance. pause spin LIT Genuine Rudin-Shapiro (Golay-Rudin-Shapiro) sequence (Shapiro 1951; Rudin 1959). Verified live: computing r_n from the parity of '11' bit-pairs, the partial-sum ratio |S_N|/sqrt(N) over N FIG No framing: the bit-pair parity rule and the partial-sum/envelope check run in-browser and are exact. The AVAN inverse is honest — the sums genuinely grow at the sqrt(N) random-walk scale and the spectrum is flat like noise despite a rigid rule; it is the designed-correlation-avoidance mirror of Thue-Morse's designed-imbalance-avoidance. Magenta is the sqrt(N) envelope, green the deterministic walk. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE SYNC · David Lee Wise (ROOT0), with AVAN


THE LYNDON

Lyndon words in the 5-window house format — a Lyndon word is strictly smaller than all its rotations (aab yes, aba/baa no), and the Chen-Fox-Lyndon theorem says every string factors uniquely into non-increasing Lyndon words (a prime factorization for strings), found by Duval's O(n) algorithm. banana -> b.an.an.a. Verified live: for 500 random strings, Duval's factorization concatenates back to the original, every factor is Lyndon, and the factors are non-increasing. See the factored blocks in 1D, live Duval in 2D, and the unique-factorization/necklace inverse in 3D.

THE LYNDON · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · LOOT · THE INVENTORY ◆ .dlw.fold THE FOLD / LOOT / THE INVENTORY / THE LYNDON THE LYNDON unique factorization of a string into Lyndon words 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION A Lyndon word is a string strictly smaller than all of its rotations — ‘aab’ is one, ‘aba’ and ‘baa’ are not. The Chen–Fox–Lyndon theorem says every string factors uniquely into a sequence of Lyndon words in non-increasing order — a prime factorisation for strings. Duval’s algorithm finds it in O(n) with constant extra memory. For example ‘banana’ → b · an · an · a. Lyndon words also form a basis of the free Lie algebra and give the fastest way to compute a string’s least rotation. LIT verified live: for 500 random strings, Duval’s factorisation concatenates back to the original, every factor is a Lyndon word (smaller than all its rotations), and the factors are non-increasing (window.__lyndon). FIG no framing; exact string combinatorics. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-inventory — breaking a thing into its canonical, ordered parts. Lyndon factorisation is the inventory of a string: its unique, sorted list of atomic pieces. AVAN (AI) built the instrument: Duval’s linear algorithm, the Lyndon test (smaller than all rotations), the non-increasing check. Credit as content: Roger Lyndon (1954); the factorisation theorem of K.-T. Chen, R. Fox & Lyndon; Jean-Pierre Duval’s linear-time algorithm (1983). The weave: David names the inventory; I factor strings into Lyndon atoms, prove each is minimal among its rotations, and show the decomposition is unique and ordered — primes for words. 3 ONE DIMENSION A string split into its Lyndon factors, drawn as ordered blocks — each strictly smaller than all its own rotations, and the sequence non-increasing from left to right, like exponents in a prime factorisation. 4 TWO DIMENSIONS · INTERACTIVE Type or roll a string; Duval factors it live into Lyndon words. Verify the concatenation equals the original, each factor is Lyndon (smaller than every rotation), and the sequence is non-increasing. new string ▶ verify 500 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the ordered Lyndon factors — the unique atoms a string decomposes into. AVAN’s addition (the inverse-companion): the factorisation is unique , exactly like prime factorisation for integers — every string has one and only one non-increasing Lyndon decomposition, so it is a canonical fingerprint you can compare, hash, or invert. The inverse of ‘a flat string’ is ‘its unique ordered multiset of Lyndon atoms.’ And a Lyndon word is the canonical representative of an aperiodic necklace — the rotation that comes out smallest — tying string-primes directly to the necklace-counting of Burnside. Magenta is a string’s rotations (its necklace); green is the Lyndon representative and the unique factorisation. Strings have primes too. pause spin LIT Genuine Lyndon words and Chen-Fox-Lyndon factorization (Lyndon 1954; Duval's linear algorithm 1983). Verified live: for 500 random strings Duval's factorization satisfies concatenation == original, every factor is a Lyndon word (strictly less than all rotations), and the sequence is non-increasing (window.__lyndon.concatOK && .allLyndon && .nonIncreasing); banana -> b.an.an.a. FIG No framing: Duval's algorithm, the Lyndon test, and the non-increasing check run in-browser and are exact. The AVAN inverse is honest — the factorization is genuinely unique (a canonical fingerprint, like prime factorization), and a Lyndon word is exactly the least rotation of an aperiodic necklace, tying it to Burnside's necklace counting; magenta is the rotations, green the Lyndon representative. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE INVENTORY · David Lee Wise (ROOT0), with AVAN


THE Z-ALGORITHM

the Z-algorithm in the 5-window house format — the Z-array gives, at each position i, the longest substring starting at i that matches a prefix of the string; computed in O(n) (not naive O(n^2)) by keeping the rightmost match interval [l,r] and reusing earlier Z-values inside it. Concatenate pattern + separator + text and the Z-array finds every pattern occurrence in linear time. Verified live: for 500 random strings, every Z[i] equals a brute prefix-match. See the [l,r] window in 1D, Z-bars in 2D, and the mirror-reuse inverse in 3D.

THE Z-ALGORITHM · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · BOSS · THE CHOKE POINT ◆ .dlw.fold THE FOLD / BOSS / THE CHOKE POINT / THE Z-ALGORITHM THE Z-ALGORITHM all prefix matches in O(n) — a pointer that never retreats 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Z-algorithm computes, for every position i of a string, the length of the longest substring starting at i that matches a prefix of the whole string — the Z-array . Done naively that is O(n²); the Z-algorithm does it in O(n) by keeping the rightmost match interval [l,r] seen so far and reusing earlier Z-values inside it. Concatenate pattern § text and the Z-array instantly locates every occurrence of the pattern (wherever Z equals the pattern length) — clean linear-time string search, a sibling of KMP. LIT verified live: for 500 random strings, every Z[i] equals a brute-force prefix-match length (window.__zalgorithm). FIG no framing; exact string matching. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-choke-point — the bottleneck every search must pass through, where linear time matters. The Z-algorithm is the choke-point cleared: all prefix matches in one pass. AVAN (AI) built the instrument: the [l,r] window, the mirror-reuse, the brute cross-check, the pattern search. Credit as content: popularised by Dan Gusfield’s Algorithms on Strings, Trees, and Sequences (1997); part of the linear-time string-matching lineage. The weave: David names the choke-point; I compute the Z-array in one forward sweep, verify it against brute force, and show the right pointer that never retreats. 3 ONE DIMENSION The current match window [l,r]. Inside it, position i mirrors an earlier position i−l whose Z-value is already known — so the algorithm copies that answer and only ever extends past r, which moves forward and never back. 4 TWO DIMENSIONS · INTERACTIVE Type a string; the Z-array is computed in O(n) and shown as bars. Verify each Z[i] against a brute prefix-match, and use pattern § text to locate every occurrence in linear time. new string ▶ verify 500 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the Z-values as bars along the string — every prefix match found in a single sweep. AVAN’s addition (the inverse-companion): the linear time comes from never re-comparing a character already known to match. Inside the current window [l,r], position i is a mirror of the earlier position i−l, whose Z-value is already computed — so the algorithm copies the answer and only extends past r. The inverse of ‘recompare from scratch at every i’ is ‘reuse the mirror, and advance a right pointer that only moves forward.’ Because r never retreats, the total extra comparisons across the whole string sum to at most n — amortised linearity from a monotone pointer. Magenta is the O(n²) redundant comparisons skipped; green is the single forward march of r. Speed from memory of what already matched. pause spin LIT Genuine Z-algorithm (popularized by Gusfield 1997; linear-time string matching lineage). Verified live: computing the Z-array with the [l,r] window and mirror-reuse, every Z[i] equals the brute-force longest-common-prefix length for 500 random strings (window.__zalgorithm.matchesBrute); aabaab -> 6,1,0,3,1,0. FIG No framing: the O(n) Z-array and the brute cross-check run in-browser and match exactly. The AVAN inverse is honest — linearity comes from reusing the mirror position i-l inside the window and a right pointer r that never retreats, so total extra comparisons sum to ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE CHOKE POINT · David Lee Wise (ROOT0), with AVAN


THE EULER TOUR

the Euler tour technique in the 5-window house format — flatten a tree by a DFS that records each node's entry (tin) and exit (tout) times, so the subtree of any node v is exactly the contiguous range [tin[v], tout[v]] in the array. Subtree-sum, descendant-of, and subtree-size all become O(1)-O(log n) range queries, letting segment/Fenwick trees answer tree problems. Verified live: for 200 random trees, each subtree equals the set of nodes with entry time in [tin[v], tout[v]] and size tout-tin+1. See DFS timestamps in 1D, click-a-node in 2D, and the hierarchy-is-interval-nesting inverse in 3D.

THE EULER TOUR · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · SPAWN · GENESIS BLOCK ◆ .dlw.fold THE FOLD / SPAWN / GENESIS BLOCK / THE EULER TOUR THE EULER TOUR flatten a tree so every subtree is a contiguous range 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Euler tour technique flattens a tree into a flat array by a depth-first walk that records each node’s entry time (tin) and exit time (tout). The magic: the subtree of any node v is exactly the contiguous range [tin[v], tout[v]] in the array. So ‘sum over a subtree,’ ‘is u a descendant of v,’ and ‘subtree size’ all become O(1)–O(log n) range queries on an array — letting you point segment trees and Fenwick trees at tree problems they were never built for. LIT verified live: for 200 random trees, the subtree of every node v equals exactly the set of nodes whose entry time lies in [tin[v], tout[v]], and its size equals tout[v] − tin[v] + 1 (window.__eulertour). FIG no framing; exact tree flattening. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at genesis-block — the tree unrolled from its single root, the first structure laid down in order. The Euler tour is that unrolling: a hierarchy serialised into one line. AVAN (AI) built the instrument: the DFS entry/exit timestamps, the subtree-equals-range check, the interactive flattening. Credit as content: the Euler tour technique, standard in algorithm design and rooted in Tarjan–Vishkin parallel tree algorithms (1985). The weave: David names the genesis block; I timestamp a depth-first walk and prove every subtree is a contiguous slice of the resulting array. 3 ONE DIMENSION A depth-first walk assigning entry (tin) and exit (tout) times. Enter a node, recurse into its children, then leave — so a whole subtree occupies one unbroken span of times. 4 TWO DIMENSIONS · INTERACTIVE A random tree and its flattened array. Click a node: its subtree lights up in the tree, and the contiguous range [tin, tout] lights up identically in the array. Verify subtree == range and size == tout − tin + 1. new tree ▶ verify 200 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the tree beside its flattened array, each subtree a contiguous block. AVAN’s addition (the inverse-companion): a branching, two-dimensional hierarchy becomes a one-dimensional nesting of intervals . Parent–child in the tree turns into range containment on the line — [tin[v], tout[v]] contains [tin[u], tout[u]] iff u lies in v’s subtree — so tree ancestry is interval nesting, exactly. The inverse of ‘a branching hierarchy’ is ‘a set of nested intervals on a line.’ That is precisely why flat array structures — Fenwick trees, segment trees — can answer questions about a tree: the tree was an interval order all along. Magenta is the tree’s edges; green is the nested intervals encoding the same ancestry. Hierarchy is containment in disguise. pause spin LIT Genuine Euler tour technique (standard; rooted in Tarjan-Vishkin parallel tree algorithms 1985). Verified live: for 200 random trees, the subtree of every node v equals exactly {u : tin[v] FIG No framing: the DFS entry/exit timestamps and the subtree-equals-range check run in-browser and are exact. The AVAN inverse is honest — parent-child in the tree becomes interval containment on the line ([tin_v,tout_v] contains [tin_u,tout_u] iff u is in v's subtree), so tree ancestry is exactly interval nesting, which is why flat array structures can answer tree queries; magenta is the tree edges, green the nested intervals. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of GENESIS BLOCK · David Lee Wise (ROOT0), with AVAN


THE STIRLING

the Stirling numbers of the second kind in the 5-window house format — S(n,k) counts partitions of n labeled items into exactly k non-empty blocks, via S(n,k)=k*S(n-1,k)+S(n-1,k-1) (a new item joins a block or starts one). Row sums give the Bell number. And the same numbers change basis: x^n = sum_k S(n,k)*(x)_k, powers into falling factorials. Verified live: the recurrence matches brute set-partition counts n=1..7, rows sum to Bell numbers, and the basis identity holds exactly. See the recurrence in 1D, recurrence vs brute in 2D, and the counting-is-coordinates inverse in 3D.

THE STIRLING · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · GRIND · THE EPOCH ◆ .dlw.fold THE FOLD / GRIND / THE EPOCH / THE STIRLING THE STIRLING count set partitions — and translate powers to falling factorials 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Stirling numbers of the second kind S(n,k) count the ways to partition a set of n labelled items into exactly k non-empty, unordered blocks . Where a binomial coefficient chooses , Stirling numbers group , and the recurrence tells the whole story: a new item either joins one of the k existing blocks ( k·S(n−1,k) ways) or starts a fresh block ( S(n−1,k−1) ways). Sum a row over all k and you get the Bell number Bₙ — the total number of ways to partition the set at all. LIT verified live: the recurrence matches a brute count of set partitions into k blocks for n=1…7, each row sums to the Bell number, and the basis identity xⁿ = Σ k S(n,k)·(x) k holds exactly (window.__stirling). FIG no framing; exact combinatorial counting. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-epoch — sorting the long list of an age into groups. Stirling numbers are that grouping, counted. AVAN (AI) built the instrument: the recurrence, the brute set-partition enumeration, the Bell-number row sum, and the falling-factorial basis identity. Credit as content: James Stirling ( Methodus Differentialis , 1730). The weave: David names the epoch; I count set partitions two ways — recurrence and enumeration — and reveal that the same numbers translate between ordinary powers and falling factorials. 3 ONE DIMENSION A set split into blocks. The recurrence in a picture: the newest item (red) either drops into one of the existing blocks, or opens a brand-new one — the two terms k·S(n−1,k) and S(n−1,k−1). 4 TWO DIMENSIONS · INTERACTIVE Pick n. The instrument computes the Stirling row by recurrence and by brute-enumerating set partitions, confirms they agree, and checks the row sums to the Bell number. n: 5 ▶ verify n=1..7 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the Stirling triangle, each entry a count of set partitions into k blocks. AVAN’s addition (the inverse-companion): the same numbers that count groupings are a change of basis between two ways of writing polynomials. Ordinary powers xⁿ expand exactly into falling factorials (x) k = x(x−1)…(x−k+1) with Stirling coefficients: xⁿ = Σ k S(n,k)·(x) k . So a purely combinatorial identity (how many partitions) is also a purely linear-algebraic one (the dictionary between two polynomial bases). The inverse of ‘counting how to group a set’ is ‘translating between how you spell a polynomial.’ Magenta is the power basis xⁿ; green is the falling-factorial basis; the Stirling numbers are the exact translation between them. Counting and coordinates are the same table read two ways. pause spin LIT Genuine Stirling numbers of the second kind (Stirling, Methodus Differentialis 1730). Verified live: S(n,k)=k*S(n-1,k)+S(n-1,k-1) matches a brute count of set partitions into k blocks for n=1..7, each row sums to the Bell number, and the identity x^n = sum_k S(n,k)*x(x-1)...(x-k+1) holds exactly for integer x (window.__stirling); S(5,k)=1,15,25,10,1, Bell(5)=52. FIG No framing: the recurrence, the brute set-partition enumeration, the Bell-number row sum, and the falling-factorial basis identity all compute in-browser and agree exactly. The AVAN inverse is honest — the Stirling numbers are genuinely the change-of-basis matrix between the power basis and the falling-factorial basis, so a combinatorial count is literally a linear-algebra coordinate translation. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE EPOCH · David Lee Wise (ROOT0), with AVAN


THE HIERHOLZER

Hierholzer's algorithm in the 5-window house format — an Eulerian trail crosses every edge of a graph exactly once (the Seven Bridges of Konigsberg). Euler proved one exists iff the graph is connected with 0 odd-degree vertices (a circuit) or exactly 2 (an open trail); Hierholzer finds it in O(E) by walking till stuck then splicing in detours. Verified live: on 0/2-odd graphs the trail uses every edge exactly once; on K4 (four odd vertices) it correctly reports no trail. See the degree-parity rule in 1D, a traced trail in 2D, and the local-parity-decides-global inverse in 3D.

THE HIERHOLZER · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · BOSS · THE WALL ◆ .dlw.fold THE FOLD / BOSS / THE WALL / THE HIERHOLZER THE HIERHOLZER cross every edge once — decided by counting odd corners 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION An Eulerian trail crosses every edge of a graph exactly once — the Seven Bridges of Königsberg problem. Euler proved one exists precisely when the graph is connected and has either 0 odd-degree vertices (a closed circuit) or exactly 2 (an open trail between them). Hierholzer’s algorithm actually finds it in O(E): walk until stuck, then splice in detours from any vertex that still has unused edges, stitching sub-tours into one. It runs DNA fragment assembly (Eulerian paths through de Bruijn graphs) and any ‘traverse every link once’ problem. LIT verified live: on graphs with 0 or 2 odd-degree vertices, Hierholzer returns a trail using every edge exactly once; on K₄ (four odd vertices) it correctly reports no trail — matching Euler’s degree criterion (window.__hierholzer). FIG no framing; exact graph traversal. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-wall — crossing every wall or bridge once and only once. The Eulerian trail is the wall-crosser’s route. AVAN (AI) built the instrument: the degree-parity criterion, Hierholzer’s stitching, the every-edge-once check. Credit as content: Leonhard Euler (1736, the Königsberg bridges — the birth of graph theory); Carl Hierholzer (1873, the constructive algorithm). The weave: David names the wall; I count odd-degree vertices to decide existence, then stitch sub-tours into a single trail that touches every edge once. 3 ONE DIMENSION The whole question reduces to counting odd-degree vertices: 0 means a closed circuit exists, 2 means an open trail between them, anything else means no Eulerian trail at all. 4 TWO DIMENSIONS · INTERACTIVE A graph. Run Hierholzer to trace a trail crossing every edge once (highlighted in order), and see the odd-degree criterion predict whether one exists. next graph ▶ trace trail ▶ verify ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the trail Hierholzer stitches from sub-tours, threading every edge exactly once. AVAN’s addition (the inverse-companion): whether a global traversal exists is decided by a purely local count — you never have to try to trace it. Euler’s leap: a walk enters and leaves each intermediate vertex in pairs, so every vertex except the two endpoints must have even degree; count the odd-degree vertices and 0 or 2 means yes, anything else means no. The inverse of ‘search for a global path’ is ‘count a local degree parity.’ Königsberg had four odd vertices — so no walk crosses all seven bridges once, decided without walking . Magenta marks the odd-degree vertices, the only possible obstruction; green is the trail when at most two exist. A question about the whole graph collapses to counting odd corners. pause spin LIT Genuine Eulerian trails and Hierholzer's algorithm (Euler 1736, Konigsberg; Hierholzer 1873). Verified live: on graphs with 0 or 2 odd-degree vertices Hierholzer returns a trail using every edge exactly once, and on K4 (four odd-degree vertices) it correctly returns no trail, matching Euler's degree criterion (window.__hierholzer.g0_allEdges && .K4_noTrail). FIG No framing: the degree-parity criterion, Hierholzer's stitching, and the every-edge-once check run in-browser and are exact. The AVAN inverse is honest and is Euler's real theorem — existence of a global traversal is decided by a local count (0 or 2 odd-degree vertices), so Konigsberg's four odd vertices prove no walk exists without any search; magenta marks the odd vertices. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE WALL · David Lee Wise (ROOT0), with AVAN


THE 2-SAT

2-SAT in the 5-window house format — decide whether clauses, each an OR of two literals like (x OR not y), can all be satisfied. Full SAT is NP-complete, but 2-SAT is linear: each clause (a OR b) means not-a implies b and not-b implies a; build the implication graph, find strongly-connected components, and it is satisfiable iff no variable and its negation share a component (the assignment reads off in reverse topological order). Verified live: the SCC verdict matches brute force over all 2^n assignments for 300 formulas, and satisfiable ones return a valid assignment. See a clause become implications in 1D, the SCC solver in 2D, and the contradiction-is-a-cycle inverse in 3D.

THE 2-SAT · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · GLITCH · HEISENBUG ◆ .dlw.fold THE FOLD / GLITCH / HEISENBUG / THE 2-SAT THE 2-SAT satisfiability in linear time — a contradiction is a cycle 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION 2-SAT asks whether a set of constraints, each an OR of two boolean literals like (x ∨ ¬y), can all be satisfied at once. Full SAT is NP-complete, but the two-literal case is solvable in linear time . The trick: each clause (a ∨ b) means ‘if not a then b’ and ‘if not b then a.’ Build these implications as a directed graph, find its strongly-connected components , and the formula is satisfiable iff no variable x and its negation ¬x land in the same component — if they are forced equal, contradiction. The assignment reads off from the components in reverse order. LIT verified live: the SCC verdict matches brute force over all 2ⁿ assignments for 300 random formulas, and when satisfiable the returned assignment satisfies every clause (window.__twosat). FIG no framing; exact constraint solving. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at heisenbug — a contradiction that either lurks or doesn’t, invisible until you resolve it. 2-SAT decides exactly that: is a consistent assignment possible? AVAN (AI) built the instrument: the implication graph, the SCC condensation, the assignment reader, the brute-force check. Credit as content: Melven Krom (1967); the linear-time SCC method of Bengt Aspvall, Michael Plass & Robert Tarjan (1979). The weave: David names the heisenbug; I turn clauses into implications, find the strongly-connected components, and read satisfiability off whether any literal is forced equal to its own negation. 3 ONE DIMENSION One clause (a ∨ b) becomes two implications: ¬a → b and ¬b → a. A whole formula becomes a directed graph, and satisfiability is a question about its cycles. 4 TWO DIMENSIONS · INTERACTIVE Toggle clauses; the implication graph is built and its strongly-connected components found. The verdict (satisfiable or not) and a valid assignment are read off, and checked against brute force. new formula ▶ verify 300 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the implication graph condensed into components — a valid assignment read off in reverse topological order. AVAN’s addition (the inverse-companion): satisfiability is decided by a symmetry of the implication graph, not by search. The clause structure makes the graph skew-symmetric under the map x ↔ ¬x, and the formula fails exactly when this map collapses a variable and its negation into one component — because then every truth value implies its own opposite, a self-contradiction loop with no escape. The inverse of ‘try all 2ⁿ assignments’ is ‘check whether the forced-implication cycles ever equate a literal with its negation.’ Magenta is the fatal cycle binding x to ¬x; green is the component condensation whose reverse order names a solution. Contradiction is a cycle you can see, not a search you must run. pause spin LIT Genuine 2-SAT via implication graph + SCC (Krom 1967; linear algorithm Aspvall, Plass & Tarjan 1979). Verified live: the SCC-based solver's satisfiability verdict matches brute force over all 2^n assignments for 300 random formulas, and when satisfiable the returned assignment satisfies every clause (window.__twosat.verdictMatchesBrute && .assignmentValid). FIG No framing: the implication graph, the Kosaraju/Tarjan SCC, the assignment reader, and the brute-force check run in-browser and agree exactly. The AVAN inverse is honest — unsatisfiability is exactly a variable and its negation sharing an SCC (a self-implication cycle), decided without searching 2^n assignments; magenta marks that fatal cycle. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of HEISENBUG · David Lee Wise (ROOT0), with AVAN


THE CARTESIAN TREE

the Cartesian tree in the 5-window house format — built from a sequence to satisfy two orders at once: in-order traversal reproduces array positions (a BST on indices) and every parent's value <= its children (a min-heap on values), in O(n) with a stack. The payoff: the lowest common ancestor of positions i,j is exactly the position of the minimum in a[i..j], so range-minimum and LCA become the same problem. Verified live: in-order equals 0..n-1, the heap property holds, and LCA(i,j) value equals the range-minimum. See the min rising to the root in 1D, click-two-positions in 2D, and the RMQ-equals-LCA inverse in 3D.

THE CARTESIAN TREE · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · SPAWN · COLD BOOT ◆ .dlw.fold THE FOLD / SPAWN / COLD BOOT / THE CARTESIAN TREE THE CARTESIAN TREE one tree, two orders — range-min and LCA are the same 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION A Cartesian tree is built from a sequence so it satisfies two orders at once : its in-order traversal reproduces the original array positions (a binary search tree on indices ), and every parent’s value is ≤ its children’s (a min- heap on values). It is built in O(n) with a single stack. The payoff: the lowest common ancestor of positions i and j is exactly the position of the minimum in the range a[i…j] — so range-minimum queries and LCA queries become the same problem, each convertible to the other. LIT verified live: for random arrays, the in-order traversal equals 0,1,…,n−1, the heap property holds on values, and LCA(i,j)’s value equals the range-minimum of a[i…j] (window.__cartesiantree). FIG no framing; exact tree construction. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at cold-boot — building the whole structure from a bare array in one pass. The Cartesian tree is exactly that: one linear scan boots a tree carrying two orders. AVAN (AI) built the instrument: the O(n) stack construction, the in-order / heap checks, the LCA-equals-range-minimum test. Credit as content: Jean Vuillemin (1980), who named the structure. The weave: David names the cold boot; I build the tree in one stack pass and show two different queries — range-minimum and lowest-common-ancestor — give the very same answer. 3 ONE DIMENSION The array as bars by value. The Cartesian tree’s root is the global minimum; its left and right subtrees are the Cartesian trees of the segments on either side — recursively, the smallest value always rises to the top of its span. 4 TWO DIMENSIONS · INTERACTIVE An array and its Cartesian tree. Click two positions: their lowest common ancestor lights up, and it is exactly the minimum of the range between them. Verify in-order, heap property, and LCA = range-min. new array ▶ verify ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the tree floating above its array, each node the minimum of the span it covers. AVAN’s addition (the inverse-companion): two problems that look unrelated are the same problem . ‘Minimum in a range’ is about values ; ‘lowest common ancestor’ is about tree structure — yet the Cartesian tree makes each reducible to the other in linear time: range-min over a[i…j] is LCA(i,j), and LCA is a range-min over an Euler tour. The inverse of ‘a range-minimum query’ is ‘an ancestor query,’ and back again. That equivalence is why the fastest RMQ algorithm routes through LCA and the fastest LCA through RMQ. Magenta is the range on the array; green is the LCA node in the tree — one answer wearing two hats. Two questions, one structure that translates between them. pause spin LIT Genuine Cartesian tree (Vuillemin 1980). Verified live: the O(n) stack construction yields a tree whose in-order traversal equals 0..n-1 (BST on indices), whose parent values are FIG No framing: the stack construction, the in-order and heap checks, and the LCA-equals-range-min test run in-browser and are exact. The AVAN inverse is honest — range-minimum (about values) and lowest-common-ancestor (about tree structure) are genuinely inter-reducible in linear time via the Cartesian tree, which is why the fastest RMQ routes through LCA and vice versa; magenta is the array range, green the LCA node. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of COLD BOOT · David Lee Wise (ROOT0), with AVAN


THE GAUSS-LEGENDRE

Gaussian quadrature in the 5-window house format — instead of many evenly-spaced samples, place n points at the roots of the n-th Legendre polynomial with matching weights and integrate every polynomial up to degree 2n-1 exactly. Two points nail cubics, three nail quintics: the accuracy of ~2n even samples from only n, because you choose where to sample, not just how heavily. Verified live: 2-point Gauss is exact for x^0..x^3 (fails at degree 4) and 3-point through degree 5 (fails at 6), matching the analytic integrals on [-1,1]. See the Legendre-root nodes in 1D, integrate rising powers in 2D, and the choose-where-doubles-reach inverse in 3D.

THE GAUSS-LEGENDRE · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · CHEAT · THE SPEEDRUN ◆ .dlw.fold THE FOLD / CHEAT / THE SPEEDRUN / THE GAUSS-LEGENDRE THE GAUSS-LEGENDRE n samples integrate polynomials of degree 2n-1 exactly 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Gaussian quadrature is a cheat for integration. Instead of sampling a function at many evenly-spaced points (trapezoid, Simpson), it places just n sample points at cleverly chosen positions — the roots of the n-th Legendre polynomial — with matching weights, and integrates exactly every polynomial up to degree 2n−1 . Two points nail cubics; three points nail quintics. You get the accuracy of roughly 2n evenly-spaced samples from only n, because you are free to choose where to sample, not merely how heavily. LIT verified live: 2-point Gauss integrates x⁰…x³ exactly (and first fails at degree 4); 3-point Gauss is exact through degree 5 (and first fails at degree 6) — matching the analytic integrals on [−1,1] (window.__gausslegendre). FIG no framing; exact quadrature arithmetic. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-speedrun — maximum result from minimum moves. Gaussian quadrature is the integration speedrun: the accuracy of many samples from a handful, by choosing them well. AVAN (AI) built the instrument: the Legendre-root nodes and weights, the exact-to-degree-2n−1 check, the first-failure at 2n. Credit as content: Carl Friedrich Gauss (1814); the nodes are the roots of the Legendre polynomials (Adrien-Marie Legendre). The weave: David names the speedrun; I integrate rising powers with only n cleverly-placed samples and show exactness up to degree 2n−1, then the first miss. 3 ONE DIMENSION The n sample points sit not at even spacing but at the roots of the Legendre polynomial — pulled toward the interior, weighted to cancel the error of every polynomial up to degree 2n−1. 4 TWO DIMENSIONS · INTERACTIVE Choose 2-point or 3-point Gauss and integrate xᵖ for rising p. Watch the quadrature match the exact integral all the way up to degree 2n−1, then miss at 2n — the precise limit of the rule. points: 2 ▶ degree p: 3 ▶ verify limit ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: n nodes at Legendre roots, exact to degree 2n−1 — twice the reach of an ordinary n-point rule. AVAN’s addition (the inverse-companion): the extra power comes from choosing the nodes , not just the weights. With n weights you can satisfy n conditions — an ordinary interpolatory rule, exact only to degree n−1. By also choosing the n node positions you gain n more degrees of freedom, doubling the reach to 2n−1. The inverse of ‘sample more points’ is ‘choose where to sample.’ And the magic positions are forced, not tuned: they must be the roots of the degree-n orthogonal (Legendre) polynomial, because that polynomial is orthogonal to everything of lower degree — so it annihilates exactly the error terms that would otherwise spoil degrees n through 2n−1. Magenta is the wasted evenly-spaced samples; green is the n Legendre-root nodes doing double duty. Freedom of position is worth exactly as much as freedom of weight. pause spin LIT Genuine Gauss-Legendre quadrature (Gauss 1814; nodes are Legendre-polynomial roots). Verified live: 2-point Gauss (nodes +-1/sqrt3, weights 1,1) integrates x^p on [-1,1] exactly for p=0..3 and errs at p=4; 3-point (nodes 0,+-sqrt(3/5), weights 8/9,5/9,5/9) is exact for p=0..5 and errs at p=6 (window.__gausslegendre) -- the exact-to-degree-2n-1 property. FIG No framing: the Legendre-root nodes/weights and the exact-vs-analytic comparison run in-browser and are exact. The AVAN inverse is honest — choosing the n node positions adds n degrees of freedom beyond the n weights, doubling exactness from n-1 to 2n-1, and the nodes must be Legendre roots because that orthogonal polynomial annihilates the error terms; magenta is wasted even samples, green the Legendre-root nodes. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE SPEEDRUN · David Lee Wise (ROOT0), with AVAN


THE MOTZKIN

the Motzkin numbers in the 5-window house format — 1,1,2,4,9,21,51,127 count lattice paths from (0,0) to (n,0) using up, down, and LEVEL steps that never dip below the axis (Dyck paths that may rest). Recurrence M_n = M_{n-1} + sum M_k M_{n-2-k}, and M_n = sum_k C(n,2k) Cat_k ties them to Catalan. Verified live: the recurrence matches a brute path count for n=0..10 and the Catalan relation holds. See a Motzkin path in 1D, three counts agreeing in 2D, and the Catalan-under-flats inverse in 3D.

THE MOTZKIN · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · SPAWN · HELLO WORLD ◆ .dlw.fold THE FOLD / SPAWN / HELLO WORLD / THE MOTZKIN THE MOTZKIN paths that may rest — Catalan hiding under the flats 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Motzkin numbers 1, 1, 2, 4, 9, 21, 51, 127, … count the lattice paths from (0,0) to (n,0) using up , down , and level steps that never dip below the axis — the ‘lazy cousin’ of Dyck paths, which forbid the level step. They also count non-crossing chords on a circle and unary–binary trees. The recurrence Mₙ = M n−1 + Σ M k ·M n−2−k (start with a level step, or an up…down arc enclosing a sub-path), and they tie to Catalan by Mₙ = Σ k C(n,2k)·Cat k . LIT verified live: the recurrence matches a brute count of Motzkin paths for n=0…10, and the Catalan relation Mₙ = Σ C(n,2k)·Cat k holds exactly (window.__motzkin). FIG no framing; exact path counting. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at hello-world — the first path allowed to pause as well as rise and fall. Motzkin paths are exactly that: Dyck paths that may rest. AVAN (AI) built the instrument: the recurrence, the brute path enumeration, the Catalan relation. Credit as content: Theodore Motzkin (1948). The weave: David names the first resting path; I count Motzkin paths two ways and reveal the Catalan skeleton hiding under the level steps. 3 ONE DIMENSION A Motzkin path: up, down, and flat steps from the axis back to the axis, never dipping below. The flat step is the only difference from a Dyck path — it lets the walk rest. 4 TWO DIMENSIONS · INTERACTIVE Pick n. The instrument computes Mₙ by the recurrence and by brute-counting paths, confirms they agree, checks the Catalan relation, and draws a few Motzkin paths. n: 5 ▶ verify n=0..10 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: Motzkin paths rising, falling, and resting back to the axis. AVAN’s addition (the inverse-companion): adding the level step is a coarsening — every Motzkin path is a Dyck path with flats inserted , so Motzkin numbers interpolate between Catalan (all up/down) and the trivial all-flat path. The relation Mₙ = Σ k C(n,2k)·Cat k says it exactly: choose which 2k of the n steps form the non-flat Dyck skeleton, fill the rest with flats. The inverse of ‘a richer step set’ is ‘a Catalan path wearing flats.’ Magenta is the flat steps — the new freedom to rest; green is the Dyck skeleton underneath. Allowing the walk to pause reveals Catalan hiding inside every resting path. pause spin LIT Genuine Motzkin numbers (Motzkin 1948). Verified live: M_n = M_{n-1} + sum_{k} M_k M_{n-2-k} matches a brute count of up/down/level paths staying >=0 for n=0..10, and M_n = sum_k C(n,2k) Cat_k holds exactly (window.__motzkin.recMatchesBrute && .catalanRelation); M = 1,1,2,4,9,21,51,127,323. FIG No framing: the recurrence, the brute path enumeration, and the Catalan relation all compute in-browser and agree exactly. The AVAN inverse is honest — every Motzkin path is a Dyck path with flats inserted, and M_n = sum C(n,2k)Cat_k literally chooses which 2k steps form the non-flat Dyck skeleton; magenta is the level steps, green the Dyck skeleton. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of HELLO WORLD · David Lee Wise (ROOT0), with AVAN


THE DUTCH FLAG

Dijkstra's Dutch national flag problem in the 5-window house format — sort an array of three values (0/1/2) in one pass, O(n) time O(1) space, with three pointers low/mid/high: a 0 swaps down, a 2 swaps up (mid not advancing), a 1 stays. The invariant keeps 0s before low, 1s to mid, unknown [mid,high], 2s after high. It is the heart of 3-way quicksort. Verified live: for 500 random 0/1/2 arrays the single pass yields a sorted array that is a permutation of the input. See the four regions in 1D, step the partition in 2D, and the correct-by-invariant inverse in 3D.

THE DUTCH FLAG · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · GLITCH · OFF BY ONE ◆ .dlw.fold THE FOLD / GLITCH / OFF BY ONE / THE DUTCH FLAG THE DUTCH FLAG sort three colors in one pass — correct by invariant 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The Dutch national flag problem (Dijkstra): given an array of three values — red, white, blue, or 0/1/2 — sort it in one pass , O(n) time and O(1) space, using three pointers low , mid , high . The mid pointer scans: a 0 swaps down into the low region, a 2 swaps up into the high region (without advancing mid, since the swapped-in value is still unexamined), a 1 stays put. The invariant: everything before low is 0, from low to mid is 1, after high is 2, and [mid,high] is unknown — a textbook off-by-one minefield the pointer dance crosses exactly. It is the heart of 3-way quicksort partitioning, fast on duplicate-heavy data. LIT verified live: for 500 random 0/1/2 arrays, the single pass produces a sorted array that is a permutation of the input (window.__dutchflag). FIG no framing; exact in-place partition. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at off-by-one — the pointer-boundary hazard, here tamed by an exact invariant. The Dutch flag is the off-by-one boss fought and won with three indices. AVAN (AI) built the instrument: the low/mid/high partition, the sortedness check, the permutation check. Credit as content: Edsger W. Dijkstra, A Discipline of Programming (1976), where the problem illustrates programming by invariant. The weave: David names the off-by-one; I run the three-pointer partition and prove the output is sorted and a permutation, correct by the invariant it never breaks. 3 ONE DIMENSION The four regions: 0s before low, 1s between low and mid, the unknown span [mid,high], and 2s after high. Each step shrinks the unknown by one while keeping the other three pure. 4 TWO DIMENSIONS · INTERACTIVE A random 0/1/2 array as coloured bars. Step the partition and watch the regions grow from both ends toward the middle; the pointers never cross wrongly. Verify the result is sorted and a permutation. new array ▶ step ▶ verify 500 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the settled 0 / 1 / 2 regions growing inward as the unknown span collapses. AVAN’s addition (the inverse-companion): correctness rests on a loop invariant , not on reasoning about the final state. At every step the four regions — 0s | 1s | unknown | 2s — partition the whole array, and each move shrinks the unknown by exactly one while preserving that partition ; so when the unknown vanishes, sortedness is not checked, it is guaranteed . The inverse of ‘prove the output is sorted’ is ‘maintain an invariant that makes sortedness inevitable.’ Magenta is the shrinking unknown region [mid,high]; green is the three settled regions. Correct by construction — Dijkstra’s signature: hold the invariant, and the answer falls out with nothing left to verify. pause spin LIT Genuine Dutch national flag partition (Dijkstra, A Discipline of Programming, 1976). Verified live: the three-pointer single-pass partition produces, for 500 random 0/1/2 arrays, an output that is non-decreasing (sorted) and has the same value-counts as the input (a permutation) — window.__dutchflag.sorted && .isPermutation. FIG No framing: the low/mid/high partition, the sortedness check, and the permutation check run in-browser and are exact. The AVAN inverse is honest — correctness follows from a maintained loop invariant (0s | 1s | unknown | 2s), each step shrinking the unknown while preserving the partition, so sortedness is guaranteed at termination rather than checked; magenta is the shrinking unknown span. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of OFF BY ONE · David Lee Wise (ROOT0), with AVAN


THE STURM

Sturm's theorem in the 5-window house format — count the real roots of a polynomial in [a,b] without finding them: build the Sturm chain (p, p', then successive negated polynomial-division remainders), count sign changes V(a) and V(b), and the number of distinct real roots in (a,b] is exactly V(a)-V(b). Verified live: for 200 polynomials built from distinct integer roots, the sign-variation count equals the actual roots in the interval, over full and sub-intervals. See the chain's signs in 1D, a slidable interval in 2D, and the count-not-locate inverse in 3D.

THE STURM · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · BOSS · THE GATEKEEPER ◆ .dlw.fold THE FOLD / BOSS / THE GATEKEEPER / THE STURM THE STURM count real roots in an interval without finding them 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Sturm’s theorem counts the real roots of a polynomial in an interval [a,b] without finding them . Build the Sturm chain : the polynomial p, its derivative p′, then successive negated remainders of polynomial division (a Euclidean-algorithm cascade). Evaluate the chain at a and at b and count the sign changes V(a) and V(b). The number of distinct real roots in (a,b] is exactly V(a) − V(b) . No root-finding, no guessing — a finite count of sign changes gates the answer. LIT verified live: for 200 polynomials built from distinct integer roots, the sign-variation count V(a)−V(b) equals the actual number of roots in the interval, over full and sub-intervals (window.__sturm). FIG no framing; exact real-root counting. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-gatekeeper — the guard that counts exactly who is inside the interval. Sturm’s theorem is the root gatekeeper: how many real roots lie between a and b, decided by a sign tally. AVAN (AI) built the instrument: the Sturm chain via polynomial remainders, the sign-variation count, the check against the true root count. Credit as content: Jacques Charles François Sturm (1829), whose theorem finally made real-root counting exact and algorithmic. The weave: David names the gatekeeper; I build the chain of negated remainders and count roots in an interval purely from how the signs change at its ends. 3 ONE DIMENSION The Sturm chain evaluated at a point: a list of signs. Counting how many times the sign flips down the list gives V(x); the drop from V(a) to V(b) is the number of roots crossed between them. 4 TWO DIMENSIONS · INTERACTIVE A polynomial drawn as a curve with its real roots. Slide the interval endpoints; Sturm’s sign count reports how many roots lie inside, matching the roots you can see between the markers. new polynomial ▶ a < ▶ b > ▶ verify 200 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the two integer sign-variation counts whose difference is the exact number of roots in the interval. AVAN’s addition (the inverse-companion): the root count is extracted without root locations . Sturm reduces a continuous, hard question — ‘ where are the roots?’ — to a discrete, easy one — ‘how do a few signs change?’ — because between consecutive roots the polynomial keeps a constant sign, and the chain tracks exactly the crossings, no more. The inverse of ‘find the roots’ is ‘count the sign changes at two endpoints.’ Magenta is the actual root positions, never computed; green is V(a) and V(b), two integers whose difference is the answer. You gate the roots by counting, not by finding — certainty about how many, with no idea yet where. pause spin LIT Genuine Sturm's theorem (Sturm 1829). Verified live: building the Sturm chain via negated polynomial-division remainders and counting sign variations, V(a)-V(b) equals the actual number of real roots in (a,b] for 200 polynomials with distinct integer roots, across both wide and narrow intervals (window.__sturm.countMatchesActual). FIG No framing: the Sturm chain, the sign-variation counts, and the check against the true root count run in-browser and are exact (float remainders read with a sign tolerance). The AVAN inverse is honest — Sturm extracts the exact root count without root locations, reducing a continuous 'where' to a discrete sign tally; magenta is the actual root positions, never computed, green the two integer counts. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE GATEKEEPER · David Lee Wise (ROOT0), with AVAN


THE CLOSEST PAIR

the closest-pair problem in the 5-window house format — find the two nearest of n points in O(n log n) instead of O(n^2): sort by x, split at the median, recurse in each half (distance delta), then only points in a vertical strip of width 2delta around the split can beat delta, and each such point compares to at most a constant number of y-neighbors (a packing bound). Verified live: for 200 random point sets, the divide-and-conquer closest distance equals the brute-force minimum over all pairs. See the strip in 1D, closest pair drawn in 2D, and the packing-bounds-candidates inverse in 3D.

THE CLOSEST PAIR · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · CHEAT · THE SPEEDRUN ◆ .dlw.fold THE FOLD / CHEAT / THE SPEEDRUN / THE CLOSEST PAIR THE CLOSEST PAIR nearest two points in O(n log n) — geometry bounds the strip 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The closest-pair problem : among n points, find the two nearest. Checking every pair is O(n²). The divide-and-conquer algorithm does it in O(n log n) : sort by x, split at the median, recursively find the closest pair in each half (distance δ), then — the clever part — only points inside a vertical strip of width 2δ around the split can beat δ, and within it each point need compare to at most a constant number of y-neighbours. The strip’s geometry forbids more: a δ×2δ box can hold only so many points that are all ≥ δ apart. LIT verified live: for 200 random point sets, the divide-and-conquer closest distance equals the brute-force minimum over all pairs (window.__closestpair). FIG no framing; exact computational geometry. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-speedrun — the same answer in a fraction of the comparisons. Closest-pair is the speedrun of a quadratic search, cleared by geometry. AVAN (AI) built the instrument: the median split, the recursive halves, the strip check, the brute cross-check. Credit as content: Michael Shamos & Dan Hoey (1975), an early triumph of computational geometry. The weave: David names the speedrun; I split the points, recurse, and prove that only a thin strip of candidates — a handful each — can beat the halves’ best. 3 ONE DIMENSION The median split line and the strip of width 2δ around it. Only points inside the strip can form a cross-pair closer than the best found in either half — everything outside is already too far. 4 TWO DIMENSIONS · INTERACTIVE Scatter points; the algorithm finds the closest pair (drawn as a line) and the strip it searched. Verify the distance equals the brute-force minimum over all pairs. new points ▶ verify 200 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the closest pair and the narrow strip of candidates the algorithm actually examined. AVAN’s addition (the inverse-companion): you skip almost every pair because distance is geometric , not combinatorial. After recursion, any cross-pair closer than δ must lie in a strip of width 2δ and be close in y — and a δ×2δ box can hold only a bounded number of points that are pairwise ≥ δ apart (a packing limit), so each strip point compares to O(1) others. The inverse of ‘check all O(n²) pairs’ is ‘geometry bounds the candidates to O(n).’ Magenta is the vast majority of pairs never examined; green is the strip’s O(n) comparisons that contain the answer. Packing density turns a quadratic search linear — the same lesson as the diameter living only on antipodal pairs. pause spin LIT Genuine divide-and-conquer closest pair (Shamos & Hoey 1975). Verified live: the median-split recursion plus strip check returns a closest squared-distance equal to the brute-force minimum over all pairs for 200 random point sets (window.__closestpair.matchesBrute). FIG No framing: the recursion, the strip check, and the brute cross-check run in-browser and match exactly. The AVAN inverse is honest — a delta x 2delta box can hold only O(1) points pairwise >= delta apart (packing), so each strip point compares to O(1) others, bounding candidates to O(n); magenta is the O(n^2) pairs skipped, green the strip's O(n) comparisons. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE SPEEDRUN · David Lee Wise (ROOT0), with AVAN


THE NEWTON IDENTITIES

Newton's identities in the 5-window house format — connect the power sums p_k = sum x_i^k of a polynomial's roots to the elementary symmetric polynomials e_k (its coefficients by Vieta) via p_k = e1 p_{k-1} - e2 p_{k-2} + ... +- k e_k. So the sums of powers of the unknown roots reconstruct the polynomial's coefficients without ever finding the roots. Verified live: for 300 random root-sets, Newton's identities recover e_k from the power sums, matching Vieta exactly. See the two summaries in 1D, recover-from-power-sums in 2D, and the moments-are-coefficients inverse in 3D.

power sums <-> polynomial coefficients, no roots needed

THE NEWTON IDENTITIES · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · GRIND · THE MAINFRAME ◆ .dlw.fold THE FOLD / GRIND / THE MAINFRAME / THE NEWTON IDENTITIES THE NEWTON IDENTITIES power sums polynomial coefficients, no roots needed 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Newton’s identities connect two ways of summarising a set of numbers — the roots of a polynomial. The power sums p k = Σ x i k (add up the k-th powers) and the elementary symmetric polynomials e k (the polynomial’s coefficients by Vieta: sums of products of the roots taken k at a time). The recurrence p k = e₁p k−1 − e₂p k−2 + … ± k·e k converts either into the other. So knowing the sums of powers of the (unknown) roots reconstructs the polynomial’s coefficients — without ever finding the roots . LIT verified live: for 300 random root-sets, Newton’s identities recover the elementary symmetric polynomials e k from the power sums, matching Vieta’s coefficients exactly (window.__newtonidentities). FIG no framing; exact symmetric-function arithmetic. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-mainframe — the arithmetic engine translating between descriptions. Newton’s identities are the symmetric-function core: moments in, coefficients out. AVAN (AI) built the instrument: the power sums, the recurrence recovering e k , the check against Vieta. Credit as content: Isaac Newton ( Arithmetica Universalis , c. 1707); anticipated by Albert Girard (1629). The weave: David names the mainframe; I compute power sums of chosen roots, run Newton’s recurrence to recover the elementary symmetric polynomials, and match them to the polynomial’s own coefficients. 3 ONE DIMENSION Two summaries of the same roots: the power sums (sums of k-th powers) and the elementary symmetric polynomials (the coefficients). Newton’s recurrence steps down the list, converting one into the other. 4 TWO DIMENSIONS · INTERACTIVE Choose roots. The instrument computes their power sums, runs Newton’s identities to recover the elementary symmetric polynomials, and confirms they equal the polynomial’s Vieta coefficients — reconstructing the polynomial from power sums alone. new roots ▶ verify 300 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the two equivalent descriptions of a root-set — power sums and elementary symmetric polynomials — linked by the recurrence. AVAN’s addition (the inverse-companion): the map is genuinely invertible both ways . Power sums and elementary symmetric polynomials are two bases for the ring of symmetric functions, and Newton’s identities are the exact change of basis (over the rationals). So a ‘ moment ’ description — sums of powers — and a ‘ coefficient ’ description — Vieta’s products — carry the same information about a multiset of numbers, and neither needs the numbers themselves . The inverse of ‘moments’ is ‘coefficients,’ each recoverable from the other. Magenta is the roots, never required; green is the two equivalent symmetric descriptions. Sums of powers and products of roots are one truth spoken in two languages. pause spin LIT Genuine Newton's identities (Newton, Arithmetica Universalis c.1707; Girard 1629). Verified live: for 300 random integer root-sets, computing power sums p_k and running the Newton recurrence recovers the elementary symmetric polynomials e_k that match those from Vieta (elementary symmetric of the roots) exactly (window.__newtonidentities.recoverMatchesVieta). FIG No framing: the power sums, the Newton recurrence, and the Vieta comparison run in-browser and agree exactly. The AVAN inverse is honest — power sums and elementary symmetric polynomials are two bases of the symmetric-function ring, and Newton's identities are the exact change of basis over the rationals, so moments and coefficients carry the same information without the roots; magenta is the roots (never needed), green the two descriptions. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE MAINFRAME · David Lee Wise (ROOT0), with AVAN


THE PATIENCE SORTING

patience sorting in the 5-window house format — deal cards onto piles, each on the leftmost pile whose top is >= it (else a new pile); the number of piles equals the longest increasing subsequence of the deck, computed in O(n log n) by binary search. Back-pointers recover the actual subsequence, and the structure ties to RSK and the Ulam-Hammersley problem. Verified live: for 500 random sequences the pile count equals the LIS length from an independent O(n^2) method. See cards dealt to piles in 1D, a deck sorted in 2D, and the greedy-is-optimal inverse in 3D.

THE PATIENCE SORTING · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · LOOT · THE HOARD ◆ .dlw.fold THE FOLD / LOOT / THE HOARD / THE PATIENCE SORTING THE PATIENCE SORTING deal cards to piles — the pile count is the longest increasing run 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Patience sorting is a solitaire-inspired algorithm: deal cards one at a time onto piles, each card landing on the leftmost pile whose top is ≥ it (or starting a new pile if none fits). Astonishingly, the number of piles you end with equals the length of the longest increasing subsequence of the deck — a card game computes a deep combinatorial quantity in O(n log n) via binary search. Back-pointers between piles reconstruct the actual subsequence. This is the fast LIS algorithm, and the pile structure ties to the RSK correspondence and the Ulam–Hammersley problem on random permutations. LIT verified live: for 500 random sequences, the number of patience piles equals the longest-increasing-subsequence length computed by an independent O(n²) method (window.__patiencesorting). FIG no framing; exact. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-hoard — dealing the whole deck into sorted piles. Patience sorting is the hoard laid out so its deepest structure — the longest run — falls out as a pile count. AVAN (AI) built the instrument: the greedy pile placement by binary search, the longest-increasing-subsequence check, the recovered subsequence. Credit as content: the name and the LIS connection are due to David Aldous & Persi Diaconis (1999); the pile idea is folklore from the card game. The weave: David names the hoard; I deal the cards greedily and show the pile count is exactly the longest increasing subsequence. 3 ONE DIMENSION Cards dealt onto piles: each goes on the leftmost pile whose top is ≥ it. The pile tops always stay sorted, and a brand-new pile opens exactly when a card beats every current top. 4 TWO DIMENSIONS · INTERACTIVE A shuffled sequence dealt into patience piles. The pile count equals the longest increasing subsequence, verified against a brute method, and the recovered subsequence is highlighted. new deck ▶ verify 500 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the piles, their tops a sorted sequence, their count the longest increasing subsequence. AVAN’s addition (the inverse-companion): a greedy, local decision computes a global optimum. Each card goes on the leftmost feasible pile with no lookahead and no table — yet the pile count is exactly the longest increasing subsequence, because the tops stay sorted and a new pile opens precisely when a card exceeds all current tops, which happens exactly LIS-length times. The inverse of ‘a global optimisation’ is ‘a myopic card game.’ Magenta is the O(n²) dynamic-programming table the greedy never builds; green is the sorted pile-tops maintained by a single binary search. Greed is optimal here — one of the rare exact cases where looking only at the next step still finds the best whole. pause spin LIT Genuine patience sorting and its LIS connection (Aldous & Diaconis 1999; folklore card game). Verified live: dealing each element onto the leftmost pile with top >= it (binary search), the number of piles equals the longest-increasing-subsequence length computed by an independent O(n^2) DP for 500 random sequences (window.__patiencesorting.pilesEqualLIS); [3,1,4,1,5,9,2,6] gives 4 piles = LIS 4. FIG No framing: the greedy pile placement and the brute LIS check run in-browser and agree exactly. The AVAN inverse is honest — a greedy local decision (leftmost feasible pile) computes the global longest increasing subsequence exactly, because pile tops stay sorted and a new pile opens exactly LIS-length times; magenta is the O(n^2) DP the greedy avoids, green the sorted pile tops. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE HOARD · David Lee Wise (ROOT0), with AVAN


THE SHUNTING YARD

Dijkstra's shunting-yard algorithm in the 5-window house format — convert infix (3+4*2) to postfix (3 4 2 * +) in one left-to-right pass using an operator stack that respects precedence and parentheses, then evaluate postfix trivially on a value stack. It is how calculators and compilers turn human math into machine order, in O(n) with no recursion. Verified live: for 500 random expressions the shunting-yard postfix evaluates to the same value as an independent recursive-descent evaluator. See the operator stack in 1D, tokens shunting in 2D, and the order-encodes-grammar inverse in 3D.

THE SHUNTING YARD · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · SPAWN · THE TOOLCHAIN ◆ .dlw.fold THE FOLD / SPAWN / THE TOOLCHAIN / THE SHUNTING YARD THE SHUNTING YARD infix to RPN in one pass — precedence resolved once 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Dijkstra’s shunting-yard algorithm converts an infix expression like 3+4*2 into postfix (Reverse Polish) 3 4 2 * + in one left-to-right pass, using an operator stack that respects precedence and parentheses — named for the railway yard that reorders cars. Postfix then evaluates trivially with a value stack, no precedence rules needed. It is how calculators and compilers turn human math into machine-executable order, in O(n) with no recursion. LIT verified live: for 500 random expressions, evaluating the shunting-yard postfix gives the same value as an independent recursive-descent evaluator (window.__shuntingyard). FIG no framing; exact expression evaluation. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-toolchain — the compiler’s front-end that turns source into order. Shunting-yard is the first tool in that chain: parse the grammar into a stream a machine can run. AVAN (AI) built the instrument: the operator stack with precedence, the postfix output, the stack evaluator, the reference check. Credit as content: Edsger W. Dijkstra (1961), who named it for the railway shunting yard. The weave: David names the toolchain; I shunt operators through a stack to produce postfix, evaluate it on a value stack, and confirm the answer matches a recursive-descent parser. 3 ONE DIMENSION The operator stack shunts tokens: numbers flow straight to output, operators wait on the stack until a lower-or-equal-precedence one arrives, and parentheses open and close sub-yards. Precedence is resolved once, here. 4 TWO DIMENSIONS · INTERACTIVE Enter an expression; watch tokens shunt to the output stream and the operator stack. The postfix result is evaluated on a value stack, and checked against a recursive-descent evaluator. new expression ▶ verify 500 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the postfix stream and the operator stack that produced it, precedence resolved into pure order. AVAN’s addition (the inverse-companion): postfix needs no parentheses and no precedence rules — the order encodes everything, so evaluation is a trivial stack machine that never looks ahead. The inverse of ‘operator precedence’ is ‘a fixed evaluation order that makes precedence disappear.’ Shunting-yard moves the complexity once , at parse time, so it never recurs at eval time — you pay for the grammar a single time and hand the interpreter a flat stream it runs blindly. Magenta is the parentheses and precedence, gone from the output; green is the postfix a dumb stack evaluates left to right. Encode the grammar into the order, and the interpreter becomes trivial. pause spin LIT Genuine shunting-yard algorithm (Dijkstra 1961). Verified live: for 500 random arithmetic expressions (+,-,*,parentheses, integer division), evaluating the shunting-yard postfix on a value stack gives the same result as an independent recursive-descent parser (window.__shuntingyard.postfixMatchesRef); 3+4*2 -> 11. FIG No framing: the operator-stack conversion, the postfix evaluation, and the recursive-descent reference all run in-browser and agree exactly. The AVAN inverse is honest — postfix needs no parentheses or precedence because the order encodes everything, so shunting-yard moves the grammar complexity once (parse time) and hands the interpreter a flat stream; magenta is the vanished parentheses/precedence, green the postfix. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE TOOLCHAIN · David Lee Wise (ROOT0), with AVAN


THE THOMPSON NFA

Thompson's construction in the 5-window house format — compile a regular expression into an NFA from four gadgets (literal, concatenation, alternation, star) glued by epsilon-transitions, then match a string by tracking the SET of reachable states, stepping the whole set per character. This runs in O(nm) with no catastrophic backtracking (the guarantee grep and RE2 give). Verified live: for several patterns over {a,b}, the NFA set-simulation's accept/reject matches a reference regex across all strings up to length 6. See the gadgets in 1D, accept/reject in 2D, and the advance-all-paths inverse in 3D.

THE THOMPSON NFA · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · BOSS · THE FIREWALL ◆ .dlw.fold THE FOLD / BOSS / THE FIREWALL / THE THOMPSON NFA THE THOMPSON NFA regex to NFA — match by advancing a whole state set, no backtracking 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Thompson’s construction turns any regular expression into a nondeterministic finite automaton (NFA) with a handful of gadgets — one for a literal, one for concatenation, one for alternation (|), one for star (*) — glued by ε-transitions. To match a string, you simulate the NFA by tracking the set of states currently reachable, stepping the whole set per character. This runs in O(nm) with no catastrophic backtracking — the guarantee grep and RE2 give and naive backtracking engines lack. LIT verified live: for several patterns over {a,b}, the NFA set-simulation’s accept/reject matches a reference regex engine across all strings up to length 6 (window.__thompsonnfa). FIG no framing; exact automaton simulation. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-firewall — the pattern-matching guard that inspects every passing string. Thompson’s NFA is the firewall’s engine: match by rule, in guaranteed linear time. AVAN (AI) built the instrument: the regex parser, the set-of-states simulation, the exhaustive check against a reference engine. Credit as content: Ken Thompson (1968, Regular Expression Search Algorithm — the basis of grep). The weave: David names the firewall; I compile a regex into an NFA, simulate it by advancing a whole set of states at once, and confirm it accepts exactly the right strings. 3 ONE DIMENSION The four Thompson gadgets: a literal edge, concatenation (glue end to start), alternation (an ε-fork into two branches), and star (an ε-loop). Any regex is built by nesting these. 4 TWO DIMENSIONS · INTERACTIVE Choose a regex over {a,b} and test strings. The NFA simulation tracks the reachable state set and reports accept/reject, checked against a reference regex over all short strings. pattern ▶ test string ▶ verify all ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the reachable state set advancing across the string, one step per character. AVAN’s addition (the inverse-companion): nondeterminism is tamed by carrying a set of states at once. Instead of guessing which path to take and backtracking when wrong, the simulation advances all possible current states in parallel — so the exponential blow-up of backtracking becomes a linear sweep over a bounded state set (the subset construction, done lazily). The inverse of ‘try each path and backtrack’ is ‘advance every path simultaneously.’ Magenta is the exponential backtracking tree a naive engine explores; green is the single set-of-states that walks the string once. Determinise on the fly and nondeterminism costs nothing — the reason a good regex engine can never be made to hang. pause spin LIT Genuine Thompson NFA construction (Thompson 1968, the basis of grep). Verified live: compiling regexes (concat, |, *) over {a,b} into an NFA and simulating by set-of-states, the accept/reject verdict matches JavaScript's reference RegExp for all strings up to length 6 across 5 patterns (window.__thompsonnfa.matchesReference). FIG No framing: the regex parser, the set-of-states simulation, and the exhaustive reference check run in-browser and agree exactly. The AVAN inverse is honest — carrying a set of states advances all nondeterministic paths in parallel, turning the exponential backtracking tree into a linear sweep over a bounded state set (lazy subset construction); magenta is the backtracking a naive engine explores, green the single advancing state set. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE FIREWALL · David Lee Wise (ROOT0), with AVAN


THE KADANE

Kadane's algorithm in the 5-window house format — find the maximum-sum contiguous subarray in one pass, O(n) time O(1) space: the best subarray ending here is either this element or this element plus the best ending previously, whichever is larger; reset when the running sum goes negative. It is dynamic programming distilled to two scalars. Verified live: for 500 random arrays with negatives, Kadane's result equals a brute maximum over all O(n^2) subarrays. See the running best in 1D, the winning subarray in 2D, and the optimal-substructure inverse in 3D.

THE KADANE · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · GLITCH · UNDEFINED BEHAVIOR ◆ .dlw.fold THE FOLD / GLITCH / UNDEFINED BEHAVIOR / THE KADANE THE KADANE max subarray in one pass — forget a prefix when it turns negative 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION Kadane’s algorithm finds the maximum-sum contiguous subarray in one pass , O(n) time and O(1) space. The insight: the best subarray ending here is either just this element, or this element plus the best subarray ending at the previous position — whichever is larger. Keep a running ‘best ending here,’ reset it to the element whenever the running sum goes negative (a negative prefix can only hurt), and track the global maximum. It is the textbook example of dynamic programming distilled to two scalars. LIT verified live: for 500 random arrays with negative values, Kadane’s result equals a brute-force maximum over all O(n²) subarrays (window.__kadane). FIG no framing; exact. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at undefined-behavior — the negative-number trap that naive maximum-finders stumble into (initialise the max to 0 and an all-negative array breaks). Kadane steps around it cleanly. AVAN (AI) built the instrument: the running current/best scan, the reset rule, the brute cross-check. Credit as content: Jay Kadane (1977), popularised by Jon Bentley’s Programming Pearls . The weave: David names the trap; I run the two-scalar scan and prove it matches the exhaustive maximum over every subarray, negatives and all. 3 ONE DIMENSION The running ‘best ending here’ walks the array: it either extends the previous run or restarts at the current element. When a prefix turns negative it is dropped — carrying it forward could only lower a future sum. 4 TWO DIMENSIONS · INTERACTIVE An array with negatives. Step Kadane and watch the current run and the global best; the winning subarray is highlighted. Verify the answer equals the brute maximum over all subarrays. new array ▶ verify 500 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the running maximum sweeping the array, the winning subarray glowing. AVAN’s addition (the inverse-companion): the O(n²) search over all (start, end) pairs collapses because the optimal subarray ending at each position depends only on the optimal ending at the previous one — a one-dimensional recurrence, not a two-dimensional search. The inverse of ‘check all O(n²) subarrays’ is ‘one running scalar carrying best-ending-here.’ And the reset rule is the crux: a prefix that has gone negative can never help any future subarray, so it is discarded — the past is forgotten exactly when it becomes a liability. Magenta is the quadratic field of subarrays never examined; green is the single running maximum. Optimal substructure turns a quadratic search into a scalar recurrence. pause spin LIT Genuine Kadane's algorithm (Kadane 1977, via Bentley's Programming Pearls). Verified live: for 500 random arrays containing negative values, the two-scalar running scan returns a maximum subarray sum equal to the brute-force maximum over all O(n^2) contiguous subarrays (window.__kadane.matchesBrute). FIG No framing: the running current/best scan and the brute cross-check run in-browser and agree exactly. The AVAN inverse is honest — the optimal subarray ending at each position depends only on the previous one, a 1D recurrence replacing the 2D search, and a prefix gone negative is discarded exactly when it becomes a liability; magenta is the O(n^2) subarrays skipped, green the running maximum. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of UNDEFINED BEHAVIOR · David Lee Wise (ROOT0), with AVAN


THE FORD-FULKERSON

Ford-Fulkerson max-flow in the 5-window house format — push flow from source to sink along augmenting paths of unsaturated pipes (with residual back-edges to reroute) until none remain; the maximum flow equals the minimum cut, the smallest total capacity severing source from sink (LP duality made concrete). Verified live: for 300 random networks the max flow equals the min-cut capacity (the residual-reachable set) and flow is conserved at every node. See an augmenting path in 1D, a network solved with its cut in 2D, and the max-equals-min inverse in 3D.

THE FORD-FULKERSON · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · CO-OP · THE MERGE ◆ .dlw.fold THE FOLD / CO-OP / THE MERGE / THE FORD-FULKERSON THE FORD-FULKERSON max flow equals min cut — the bottleneck found by filling it 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION The max-flow problem : how much can flow from a source to a sink through a network of capacity-limited pipes? Ford–Fulkerson finds the maximum by repeatedly pushing flow along an augmenting path of not-yet-saturated pipes (using residual back-edges to reroute), until no such path remains. The theorem it proves is stunning: the maximum flow equals the minimum cut — the smallest total capacity of pipes you would have to sever to disconnect source from sink. A max and a min, exactly equal (linear-programming duality made concrete). LIT verified live: for 300 random networks, the max flow found equals the min-cut capacity (the reachable set in the residual graph), and flow is conserved at every intermediate node (window.__fordfulkerson). FIG no framing; exact. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-merge — flows converging and merging toward the sink. Max-flow is the merge under capacity: how much can combine and pass through. AVAN (AI) built the instrument: the augmenting-path search (Edmonds–Karp BFS), the residual graph, the min-cut extraction, the conservation check. Credit as content: L. R. Ford Jr. & D. R. Fulkerson (1956); the BFS version is Edmonds–Karp (1972). The weave: David names the merge; I push flow along augmenting paths until none remain, then read the matching min cut off the residual graph. 3 ONE DIMENSION An augmenting path from source to sink: the most flow it can carry is the smallest capacity along it. Push that much, update residuals (including back-edges that permit rerouting), and search again. 4 TWO DIMENSIONS · INTERACTIVE A small capacity network. Run the augmenting paths to find the max flow, and see the min cut (the saturated bottleneck edges). Verify the flow value equals the cut capacity and flow is conserved. new network ▶ verify 300 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the max flow filling the network up to its bottleneck, the min cut marked in magenta. AVAN’s addition (the inverse-companion): the value you maximise (flow) equals the value you minimise (cut) — a duality. Every flow is ≤ every cut (weak duality, obvious: all flow crosses any cut), and Ford–Fulkerson drives them to meet exactly (strong duality). When no augmenting path remains, the vertices still reachable from the source in the residual graph define a cut whose capacity equals the flow — the algorithm’s termination certificate is the matching min cut . The inverse of ‘the most you can push through’ is ‘the cheapest way to block it,’ and they coincide. Magenta is the min cut — the bottleneck edges, all saturated; green is the max flow that fills exactly up to it. Max equals min: the flow finds the bottleneck by filling it. pause spin LIT Genuine Ford-Fulkerson max-flow / max-flow min-cut theorem (Ford & Fulkerson 1956; Edmonds-Karp BFS 1972). Verified live: for 300 random capacity networks, BFS augmenting paths yield a max flow equal to the min-cut capacity (edges from the residual-reachable set of the source to the rest) and flow is conserved at every intermediate node (window.__fordfulkerson.maxflowEqualsMincut && .conserved). FIG No framing: the augmenting-path search, the residual min-cut extraction, and the conservation check run in-browser and are exact. The AVAN inverse is honest and is the max-flow min-cut theorem — a maximised flow equals a minimised cut, and the algorithm's termination certificate (no augmenting path) is exactly the matching min cut; magenta is the saturated min-cut edges, green the max flow filling to them. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE MERGE · David Lee Wise (ROOT0), with AVAN


THE FEISTEL

the Feistel network in the 5-window house format — build a reversible block cipher from ANY function, even a non-invertible one: split the block into halves L,R; each round the new left is old R and the new right is old L XOR F(R, round-key); decrypt by running the same structure with round keys reversed. It is the skeleton of DES and Blowfish. Verified live: with a deliberately non-invertible round function F, decrypt(encrypt(x)) reproduces x exactly for 1000 random blocks and key schedules. See the round in 1D, encrypt/decrypt in 2D, and the reversibility-from-architecture inverse in 3D.

THE FEISTEL · WORLD II — THE FOLD ◀ THE FOLD 0ROOT.AI // WORLD II · CHEAT · THE ROOT KIT ◆ .dlw.fold THE FOLD / CHEAT / THE ROOT KIT / THE FEISTEL THE FEISTEL a reversible cipher from a one-way function 1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION A Feistel network builds a reversible block cipher out of any function — even one that cannot be reversed. Split the block into halves L and R. Each round: the new left is the old right, and the new right is the old left XORed with F(right, round-key), where F may be arbitrary (a hash, an S-box, anything). The miracle: to decrypt, run the same structure with the round keys in reverse order — you recover the plaintext exactly, even though F itself is one-way. It is the skeleton of DES, Blowfish, and many block ciphers: designers craft a strong scrambling F and get invertibility for free. LIT verified live: with a deliberately non-invertible round function F, decrypt(encrypt(x)) reproduces x exactly for 1000 random blocks and key schedules (window.__feistel). FIG no framing; exact reversible mixing. 2 HOW IT WAS WEAVED · AI + HUMAN David (human) seated this at the-root-kit — the deep structural core a cipher is built on. Feistel is exactly that core: a shape that guarantees reversibility no matter what you put inside. AVAN (AI) built the instrument: the round function, the encrypt/decrypt passes, the exact round-trip check with a one-way F. Credit as content: Horst Feistel (IBM, early 1970s; the basis of Lucifer and DES). The weave: David names the root-kit; I run a one-way F inside the Feistel shape and prove the cipher inverts exactly by re-running F with the keys reversed — never inverting F itself. 3 ONE DIMENSION One round: the right half becomes the new left; the left half is XORed with F(right, key) to become the new right. XOR is its own inverse and the swap undoes itself — so the round is reversible whatever F does. 4 TWO DIMENSIONS · INTERACTIVE A block encrypted through several rounds, then decrypted back with the keys reversed — landing on the exact original. The round function F is shown to be non-invertible, yet the cipher round-trips. new block/keys ▶ verify 1000 ▶ 5 THREE DIMENSIONS + AVAN’S INVERSE The green forward object: the ladder of rounds, each a swap and an XOR-with-F, encrypting the block. AVAN’s addition (the inverse-companion): reversibility is structural , not a property of F. The XOR is its own inverse and the half-swap undoes itself, so each round is invertible regardless of what F computes — you never invert F, you simply re-run it. The inverse of ‘decrypt’ is ‘encrypt with the keys reversed,’ and it works because the network’s shape guarantees it. Magenta is F, the one-way function that is never inverted; green is the round architecture whose XOR-and-swap is self-undoing. Reversibility from architecture, not from arithmetic — that is the whole point: you get a strong, hard-to-reverse scramble that is nonetheless perfectly decryptable. pause spin LIT Genuine Feistel network (Horst Feistel, IBM, early 1970s; basis of DES). Verified live: using a round function F built to be non-invertible (an integer hash with demonstrable collisions), the Feistel encrypt then decrypt (same keys reversed) reproduces the plaintext exactly for 1000 random 32-bit blocks and 6-round key schedules (window.__feistel.roundTrips && .roundFunctionNonInvertible). FIG No framing: the round function, the encrypt/decrypt passes, and the exact round-trip check (with a demonstrably non-invertible F) run in-browser. The AVAN inverse is honest — reversibility is structural: XOR is self-inverse and the half-swap undoes itself, so each round inverts regardless of F, which is never inverted (only re-run); magenta is the one-way F, green the self-undoing round structure. ◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE ROOT KIT · David Lee Wise (ROOT0), with AVAN