# Exact rational stacks and history-reversible binary transitions Matthew Alan Newman (@NVE024) supplied the treeOS.universal/1.1 definition and the Python reference. This note derives the canonical denominator for its particular coefficient and documents the website implementation and replay. The date of a website deployment and a live execution by Grok are outside the replay. ## Wire contract A seed is [P,[u,a,L,R],H]. The immutable rule table P consists of [u,a,v,b,d], indexed from zero. Each input (u,a) matches at most one rule. An unmatched pair halts without adding history. States are unsigned 32-bit integers, symbols are 0 or 1, and moves are −1, 0, or +1. Lists L and R run from farthest to nearest. Popping beyond their stored extent reads an implicit zero. Stored edge zeros are meaningful. History H contains [ruleIndex,readStackWasEmpty] pairs in time order. For a stationary move the Boolean is false. For hop(seed,n,src,dst), src and dst independently select bit lists (0) or coded triples (1) for both stacks. A positive n means up to n moves, zero validates and converts, and a negative n undoes exactly |n| entries. An overlong undo fails. The second return value counts moves actually performed and is nonnegative in both directions. ## Why decoding is exact Write q=A/B with A=169974885672389 and B=500000000000000. For the empty word E(ε)=1/2. For appending a bit t, E(wt)=q E(w)+(1−q)t. Every code lies strictly in (0,1). At the last append, t=0 places the result in (0,q) and t=1 places it in (1−q,1). The strict inequality q<1/2 separates both intervals from 1/2. The decoder therefore determines t uniquely from which side of 1/2 contains the code, subtracts (1−q)t and divides by q. This undoes one append. Induct on the recorded depth, requiring the last value to be exactly 1/2. Reversing the recovered bits returns the original list. Conversely, each accepted sequence of inverse steps can be read forward to reproduce its input. Thus the map is a bijection between finite bit stacks and the canonical, admissible triples. Rational inputs such as the initial midpoint with a positive depth are rejected. ## An exact denominator for every word Claim: the positive reduced denominator at depth n is exactly Dₙ=2Bⁿ, independent of the word. The empty stack gives N₀/D₀=1/2. If Nₙ/Dₙ is its current representation, then the next numerator and denominator before reduction are Nₙ₊₁ = A Nₙ + (B−A)t Dₙ Dₙ₊₁ = B Dₙ. A is odd and Dₙ is even, so induction from N₀=1 makes every numerator odd. The only primes dividing B are 2 and 5. For the first step, N₁ is either A or 2B−A, both coprime to B. For n≥1, B divides Dₙ. Reducing the recurrence modulo any prime dividing B gives Nₙ₊₁ ≡ A Nₙ. Since A is coprime to B, induction proves that no such prime divides any numerator. The denominator has no other prime factors, so the displayed fraction is already reduced. This proves the claim for both branches and all depths. Consequences. The denominator alone determines the depth for this coefficient. Its integer value grows exponentially and its storage in bits grows linearly: bit_length(Dₙ)=floor(1+n log₂ B)+1. At depth 400 the denominator alone occupies 19,533 binary digits or 4,884 hexadecimal digits, while the raw stack contains 400 bits. The lab preserves the original triple for interoperability. The browser uses the exact denominator formula and verifies every inverse numerator lands on an integer in the open predecessor interval. Python uses arbitrary-precision Fraction arithmetic and reduces at each step. These independent implementations produce the same hex strings on the tested inputs. ## The lost distinction and its witness Consider rule [0,0,1,1,1]. With an empty right stack, it writes 1, pushes that 1 onto the left stack and reads an implicit blank. With a right stack [0], the same rule pops a stored zero. Both cases produce the identical bare configuration [1,0,[1],[]]. Their history entries differ: [0,true] for the blank and [0,false] for the stored zero. Undo uses the bit to recover the exact predecessor in each case. A scan of the tape as an infinite sequence of symbols would render both predecessor tapes alike. For a moving rule, the inverse verifies the destination state, pops the written bit from the stack that received it, and checks its value. If the Boolean is true, it verifies that the active symbol is zero and the opposite stack is empty. Otherwise it pushes the active symbol back on that stack. It restores (u,a) from the rule. For a stationary rule it checks the destination state, written symbol and false Boolean, then restores (u,a). Each case is the exact inverse of the corresponding forward transition on its augmented state. Applying this argument once per history entry proves restoration for any finite valid trace. The reference hop unwinds the whole history on a copy before accepting even a zero-step call. A successful unwind establishes existence of a predecessor consistent with the supplied log. In the preceding example, replacing true with false yields another consistent history from a different start. Evidence tying the run to a particular original seed must supply that starting seed or an independently trusted commitment. E and D alone check the history's structure; hop does the consistency replay. ## Worked seed Program P = [[0,0,1,1,1],[1,0,2,1,-1]]. A request for 23 forward steps returns actual_steps=2. | Completed steps | State | Scanned bit | L | R | New history entry | |---:|---:|---:|---|---|---| | 0 | 0 | 0 | [] | [] | — | | 1 | 1 | 0 | [1] | [] | [0,true] | | 2 | 2 | 1 | [] | [1] | [1,false] | The second rule writes 1 and moves left onto the first stored 1. No rule starts from (2,1). Undo twice restores the initial seed, including the exact list lengths. The files in examples provide the final wire representation in both modes. ## Review of the supplied checks The Python harness enumerates all 511 words of length 0 through 8 and one alternating word of length 400. The tape loop enumerates 2 input symbols × 2 written symbols × 3 directions × 4 left stacks × 4 right stacks = 192 primitive cases. For every case it checks four source/destination mode pairs against an integer-indexed tape and checks undo. The guards stay active under python -O. Both interpreter modes were run for this release. The web parity suite also uses an absolute-position tape and separately tracks the visited extent, so stored edge zeros survive in its expected output. It checks multistep runs from 100 deterministically generated programs, all four transport pairs, full reversal, invalid triples, invalid histories and alternate consistent histories. The detailed call counts are in the JSON report. The reference JSON-clones in hop; native Python tuples can consequently normalize to lists while E rejects them. The reference valid unpacks the top level before checking its type. A malformed native value can therefore yield different exception types. The browser accepts the specified JSON arrays and validates exact numeric tokens on import. The Python API accepts n greater than 23; its metadata supplies an example budget. The website limits each forward request to 23, stacks to 512 bits, history to 4,096 entries, programs to 2,048 rules and input text to 262,144 UTF-16 code units. In either implementation each new call checks the supplied log from the beginning of its recorded execution by unwinding it in reverse. Repeated one-step calls on an ever-growing history incur quadratic cumulative validation work in the step count, even with fixed-size rules. The rational codec introduces its own large-integer costs. The finite checks establish behavior on the declared cases. A universality result concerns the abstract model with unbounded tape and time. This handoff contains no universal interpreter construction or simulation theorem establishing that result for a specific rule table.