diff --git a/research/bit-cellzero-old-elimination/PROOF.md b/research/bit-cellzero-old-elimination/PROOF.md new file mode 100644 index 0000000000..13a5f2c0cb --- /dev/null +++ b/research/bit-cellzero-old-elimination/PROOF.md @@ -0,0 +1,209 @@ +# Actual whole-array cell0 carry without the two OLD adapters + +## 1. Exact source and changed premise + +The pinned helper462/frame506 matcher is S8, lifted as A=S8 tensor I_f, +N=8f, D=N², q an odd prime, w>=2, Q=q^(w-1), b=ceil(log2 q). +Exact rational inspection gives + + S8[:,0]=2e5, S8^-1[:,0]=e4, + A[:,0]=2e_(5f), A^-1[:,0]=e_(4f). + +Consequently, in row0, the forward new low cell0 is 2u mod q and its +high carry is floor(2u/q) in {0,1}, u=G0[0,5f]. The inverse low cell0 is +v=G0[0,4f] and its carry is zero. These statements hold for every low matrix, +hence every invertible G0 and every lane count f. No rational-quarter case +occurs in this column. The independent source check computes S8^-1 and checks +the columns; the tensor identity is the all-f proof. Inverse here means the +actual inverse LOW factor; it is not the inverse of the isolated forward carry +layer without that factor's other high operations. + +PR3343 already implements bounded signed one-axis rotation by encoded splits +and two monotone buckets, with a paid source-level O(BQS+I) proof. We reuse that +geometry and credit it. A proposed new arbitrary-offset primitive was withdrawn: +this actual column never has an unbounded carry. The missing task in PR5332 +and PR5487 is the physical source-to-consumer join. This package supplies a +literal whole-T array controller, not a new rotation algorithm. + +## 2. Whole-T contract + +Let T be a positive runtime count, d a fixed positive compile-time fiber depth, +Z a positive runtime spectator extent, S=Q^(d-1)Z, H=QS, V=TH. The compiler +parameters are q,f,d and direction; default d=D. Its input banks are: + +- one marked Boolean payload in lexicographic [T]×[Q]^d×[Z] order, length V; +- one marked old-low cache, T successive row-major N×N low matrices, each digit + encoded in exactly b LSB-first bits, total TDb bits; +- canonical marked positive binary T,Q,Z descriptors; +- distinct owned blank work banks and a blank low0-output bank. + +All input heads start at their first data cell. Marks use the retained literal +machine alphabet. The actual application sets d=D, T=|GL_N(F_q)|, Q=q^(w-1), +and takes the existing complete cache in the same low-type order as its payload. +It does not require per-fiber markers, supplied S/H counts, a free transpose, +a callback, a free gather, a type lookup or an OLD oracle. Each cache record +need only be correctly paired with its payload fiber; GL enumeration is not +performed by the running machine. GL membership is a source premise, not a +validation claim. The generic contract also permits other positive Q and d; +reduced fixtures using it are labelled and do not materialize GL8 payloads. + +The result in the **same original payload owner** is + + out[t,(x+C_t mod Q),z] = in[t,x,z], 0<=z=q, writes its new-low + result to the advancing low0-output bank, and chooses the C=0/1 branch. + Every branch then advances to the next cache record, paying exactly the + fixed record traversal. It neither changes nor retires the old cache. +3. Start split lengths (Q,0). For C=1 one literal transfer gives (Q-1,1). + Split the local bank into its first (Q-C)S and last CS bits. Emit the latter + then the former into a separate local output, consuming the buckets. This + is precisely the bounded PR3343 geometry, implemented by PR2776 microcode. + For C=0 it still makes and accounts for distinct local output. +4. Copy the complete local output to the advancing global output bank. Erase + all local banks, their markers and both split lengths. Advance the type + counter. Global source/cache positions now begin the next paired fiber. + +The loop invariant is: the first t output fibers have the stated permutation, +the first t low0 digits have been emitted, global source/cache heads have moved +by tH and tDb, all earlier private fibers are blank, and old cache/source bytes +are unchanged. Each step preserves it. At t=T the code checks the two global +input endpoints, closes and rewinds the output, cache and low0 result, rewinds +the original source, then overwrites that same source by a sequential consuming +copy of the global output. It erases the global output including its marker, +restores the source head, and erases all persistent counters. The final owner +identity is unchanged; no later owner swap or disposal is left implicit. + +`initialize_actual_T` supplies an optional literal initializer for the actual +fixed T=product_(i=0)^(N-1)(q^N-q^i). It writes that compiled constant into a +blank descriptor using <=4 bit_length(T)+6 transitions and then returns the +head. Since bit_length(T)<=Db, its cost is <=4Db+6. It enumerates no matrices. +Its one tape can be mapped to the controller's T input. If the caller already +owns that descriptor, initialization is not repeated. + +## 4. Complete conservative tariffs + +Let d>=1, V=TQ^d Z, and K=TDb. For the literal table, including descriptor +conversion/product construction, every full-array pass, staging, installation, +rewind and private erasure, the following intentionally loose bounds hold: + + transitions <= 2048(d+1)V + 32K + 256(d+1), + visited cells <= (d+20)V + 2K + 128(d+1). + +These are not measured-fit constants. Here is a sufficient path-count ledger. +The retained converter costs c(n)=24n-7 popcount(n)+15 bit_length(n)+12<=44n. +A retained S-bit record copy costs at most 12S+4; its unary length loop and +rewind add at most 6k+7 to k records, so one segment costs <=22kS+7 for k>0, +and <=7 when k=0. Every rewind of a marked tape at relative position h is +3h transitions. Backward erasure through the origin costs <=4(h+1). + +- All initial unary conversions and the nested suffix construction fit + 256(d+1)V. Each of at most d nesting levels traverses at most the final S + tuples plus its Q or Z counter extents; Q,Z,T,S<=V. Initial markers and + conversions are included. +- Within a fiber, staging and the split/merge together use five segments, + totalling at most 66H+35. Consuming append uses 6H+1. All local resets, + markers, Q conversion, length transfer and erasures bring the total below + 512H, with small constant work absorbed using H>=1. This includes private + bucket regions even though their symbols have already been consumed. +- The digit decoder and fixed-stride movement cost <=8Db+16 per record; + the final whole-cache and low-result rewinds together cost <=4K+8. With + T<=V their aggregate is bounded by 16K+32V+16. +- Final whole-owner installation/erasure and head returns cost <=32V+16. + Persistent counter cleanup fits 64(d+1)V+64(d+1). + +Adding these bounds is below the displayed transition allowance. The optional +actual-T initializer adds <=4Db+6 separately, or may be absorbed by unused +slack in 32K. No data-dependent host step is omitted from these paths. + +For space, the global source/output consume 2V, and local source/output/buckets +at most 4H. Across different fibers the separate bucket maxima can sum to H+S, so their +visited regions are not bounded by a single live H. The suffix counter has S cells; Q-loop counters have (d-1)Q, +the split counters at most Q+1, type/Z counters T+Z, conversion scratch at +most max(log2 T,log2 Q,log2 Z)+1, and descriptor widths at most T+Q+Z. +The old cache and retained low0 result total K+Tb<=2K. Markers, endpoints, +visited erased tails and the fixed extra cells fit 128(d+1). These pieces fit +(d+20)V+2K+128(d+1); erased cells remain charged. The same upper bound absorbs +actual-T initialization. No numerical work word or recursive child is used. + +Pre-input table size is O(qDb+d), including explicit cache strides per decoded +value, and is independent of T,Q,Z,w. This is a nonzero q,f-dependent compiler +cost. Default depth D can be generated without enumerating GL_N(q). + +## 5. Source invoice and exact boundary + +PR5332's first0 adapter was two completed OLD swaps around the later-target +c=0 shear, with real installation/transport. On T fibers its conditional bill +was 2T A_OLD(H,w)+A_later0+M_adapter. The new whole-array cell0 layer has no +OLD invocations and the explicit A_join above, so under the same source/cache +ordering contract the replacement difference is + + Delta = A_join - (2T A_OLD(H,w)+A_later0+M_adapter). + +This signed equation does not assert Delta<0 for every tariff or size. It +removes two OLD dependencies per fiber from this added repair; it is not a +change to the selected primitive's recursive child profile. No selected +receipt is repriced. If a downstream caller expands these OLDs into recursive +paid calls, it must recompute its **entire signed invoice** with A_join and its +real allocation/preparation costs before claiming any saving or new kappa. + +All other high linear movement, other coordinate carries, complete low-type +commit/cache retirement, caller allocation/backing, native refinement and P3 +remain outside this package. Existing correctly paired full old-cache bytes are +input, not freely generated here. This contribution closes the contiguous-T +cell0 layer including its local fiber boundaries and final installation; it +does not claim the complete LOW route or supplier. + +## Evidence and remaining questions + +Forty full-array fixtures run in two independent interpreters; arbitrary bits, +complete small basis inputs, several T fibers, nonzero spectators, actual +q5/w4 carry1 selection, inverse selection and f2 strides are included. Depth64 +and256 table controls use Q1 and are explicitly not actual odd-q GL payload +replays. No full GL8 or Q^64 array is materialized. The all-size result rests +on the loop invariants and tariff proof above, not these reduced tests. +Source corruption, wrong result writes, wrong selector direction, occupied +workspace and trailing cache controls reject in normal and optimized modes. + +Next: link the remaining high/carry/low-commit layers in source order with their +complete signed invoice and actual backing reserve. Repeating rotation or +bounded-carry arithmetic is unnecessary. A selected-stage gain requires that +larger caller proof, not this component's zero OLD count. + +Credit Tekalign/PR3343 and Jose Manuel/PR2915 for bounded carry geometry; +David Arias/PR2776 for literal machine/counter macros; PR5332/5487 for source +carry and low-commit boundaries; retained BIT/ROW lineage. Loader follows the +authenticated PR5019 loading pattern. Prepared by JoyboyBrian with substantial +OpenAI Codex assistance. Apache-2.0. No independent human/formal acceptance. diff --git a/research/bit-cellzero-old-elimination/README.md b/research/bit-cellzero-old-elimination/README.md new file mode 100644 index 0000000000..adc23b2ca5 --- /dev/null +++ b/research/bit-cellzero-old-elimination/README.md @@ -0,0 +1,63 @@ +# Close the actual whole-array cell0 carry edge + +The actual helper462/frame506 cell0 forward carry is always0 or1; its inverse +carry is0. PR3343 already supplies the bounded rotation geometry. This package +joins the actual low-cache selector to a literal controller across the complete +contiguous T-type payload, paying for nested suffix construction, local fiber +markers/staging, global output, same-owner installation and all private cleanup. +It removes the two completed OLD adapters from this particular carry edge. +It does not introduce a new rotation primitive. + +For N=8f,D=N² and the actual T=|GL_N(F_q)|, the default table accepts a contiguous +[T]×[Q]^D×[Z] payload and paired complete old-low cache. Runtime T,Q,Z stay on +tapes. No S/H descriptor, per-fiber marked bank, GL enumeration, host gather or +OLD callback is supplied. The old cache survives unchanged for later cells; +new low0 digits remain separately owned. A literal initializer can install the +fixed actual T without enumerating matrices. + +[PROOF.md](PROOF.md) proves exact source columns, the all-size layout/lifecycle +and conservative complete bounds. With generic compile-time depth d and V=TQ^dZ: + +- Transitions: at most2048(d+1)V+32TDb+256(d+1). +- Visited cells: at most(d+20)V+2TDb+128(d+1), including erased regions. +- Fixed tape count:17+d; table independent of runtime T,Q,Z,w. + +The signed replacement bill is explicitly A_join−(2T A_OLD+A_later0+M_adapter), +with no assumption that this is numerically negative for all tariffs. Other +high/carry layers, full low commit, enclosing backing/stock, native refinement +and P3 remain. No selected receipt, recursive profile, supplier or kappa changes. + +## Reproduce + +```sh +python3.12 -I -W error -B research/bit-cellzero-old-elimination/verify.py +python3.12 -I -O -W error -B research/bit-cellzero-old-elimination/verify.py +python3.12 -B scripts/research_package.py --package research/bit-cellzero-old-elimination +``` + +Expected `PASS_ACTUAL_CELLZERO_WHOLE_T_JOIN`. Standard library only. SOURCES.json +pins every executable/proof input; the loader authenticates bytes before imports. +TABLE.json.gz pins both actual q5,f1,D64 tables. RESULT.json records40 full-array +fixtures in independent sparse/dense interpreters,668689 transitions,3 literal +actual-T initializers and7 rejecting source/semantic controls. + +Small fixtures vary T, complete payload, spectators, direction and f2 cache +stride. Actual q5,w4 carry1 uses reduced depth1. Actual depth64/256 structural +controls use Q1, not admissible full odd-q GL payloads. No GL8 or Q^64 array is +materialized. The written proof supplies the quantified statement; tests are +corroboration, not independent human or proof-kernel acceptance. + +## Open next questions + +Join the remaining actual high/carry/low-commit layers and derive the entire +signed caller invoice with its backing reserve. This component already pays +its whole-T boundaries; repeating bounded rotations is unnecessary. TASK.json +states the concrete next steps and unresolved dependencies. + +## Credit + +Tekalign/PR3343 and Jose Manuel/PR2915 supply bounded carry geometry; David +Arias/PR2776 supplies literal machine/counter macros; PR5332/5487 identify the +source and low-commit boundary. The authenticated loader follows PR5019. +Retained BIT/ROW lineage and predecessor attribution remain unchanged. +JoyboyBrian, with substantial OpenAI Codex assistance; Apache-2.0. diff --git a/research/bit-cellzero-old-elimination/RESULT.json b/research/bit-cellzero-old-elimination/RESULT.json new file mode 100644 index 0000000000..44ebfd1eff --- /dev/null +++ b/research/bit-cellzero-old-elimination/RESULT.json @@ -0,0 +1,558 @@ +{ + "actual_T_initializers": [ + { + "bits": 101, + "f": 1, + "q": 3, + "steps": 410 + }, + { + "bits": 595, + "f": 2, + "q": 5, + "steps": 2386 + }, + { + "bits": 180, + "f": 1, + "q": 7, + "steps": 726 + } + ], + "cases": 40, + "cases_detail": [ + { + "Q": 3, + "T": 3, + "Z": 1, + "bits": 9, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 3470, + "visited": 468 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 54, + "depth": 2, + "f": 1, + "instructions": 1126, + "inverse": false, + "q": 3, + "steps": 7370, + "visited": 620 + }, + { + "Q": 5, + "T": 3, + "Z": 1, + "bits": 375, + "depth": 3, + "f": 1, + "instructions": 1214, + "inverse": false, + "q": 3, + "steps": 34279, + "visited": 1632 + }, + { + "Q": 3, + "T": 3, + "Z": 1, + "bits": 9, + "depth": 1, + "f": 1, + "instructions": 1042, + "inverse": true, + "q": 3, + "steps": 3463, + "visited": 466 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 54, + "depth": 2, + "f": 1, + "instructions": 1130, + "inverse": true, + "q": 3, + "steps": 7363, + "visited": 613 + }, + { + "Q": 5, + "T": 3, + "Z": 1, + "bits": 375, + "depth": 3, + "f": 1, + "instructions": 1218, + "inverse": true, + "q": 3, + "steps": 34272, + "visited": 1606 + }, + { + "Q": 3, + "T": 5, + "Z": 1, + "bits": 15, + "depth": 1, + "f": 1, + "instructions": 1607, + "inverse": false, + "q": 5, + "steps": 6991, + "visited": 1069 + }, + { + "Q": 3, + "T": 5, + "Z": 2, + "bits": 90, + "depth": 2, + "f": 1, + "instructions": 1695, + "inverse": false, + "q": 5, + "steps": 13291, + "visited": 1281 + }, + { + "Q": 5, + "T": 5, + "Z": 1, + "bits": 625, + "depth": 3, + "f": 1, + "instructions": 1783, + "inverse": false, + "q": 5, + "steps": 57570, + "visited": 2720 + }, + { + "Q": 3, + "T": 5, + "Z": 1, + "bits": 15, + "depth": 1, + "f": 1, + "instructions": 1619, + "inverse": true, + "q": 5, + "steps": 6977, + "visited": 1067 + }, + { + "Q": 3, + "T": 5, + "Z": 2, + "bits": 90, + "depth": 2, + "f": 1, + "instructions": 1707, + "inverse": true, + "q": 5, + "steps": 13277, + "visited": 1274 + }, + { + "Q": 5, + "T": 5, + "Z": 1, + "bits": 625, + "depth": 3, + "f": 1, + "instructions": 1795, + "inverse": true, + "q": 5, + "steps": 57556, + "visited": 2694 + }, + { + "Q": 3, + "T": 7, + "Z": 1, + "bits": 21, + "depth": 1, + "f": 1, + "instructions": 1967, + "inverse": false, + "q": 7, + "steps": 9701, + "visited": 1473 + }, + { + "Q": 3, + "T": 7, + "Z": 2, + "bits": 126, + "depth": 2, + "f": 1, + "instructions": 2055, + "inverse": false, + "q": 7, + "steps": 18401, + "visited": 1745 + }, + { + "Q": 5, + "T": 7, + "Z": 1, + "bits": 875, + "depth": 3, + "f": 1, + "instructions": 2143, + "inverse": false, + "q": 7, + "steps": 80050, + "visited": 3612 + }, + { + "Q": 3, + "T": 7, + "Z": 1, + "bits": 21, + "depth": 1, + "f": 1, + "instructions": 1985, + "inverse": true, + "q": 7, + "steps": 9680, + "visited": 1471 + }, + { + "Q": 3, + "T": 7, + "Z": 2, + "bits": 126, + "depth": 2, + "f": 1, + "instructions": 2073, + "inverse": true, + "q": 7, + "steps": 18380, + "visited": 1738 + }, + { + "Q": 5, + "T": 7, + "Z": 1, + "bits": 875, + "depth": 3, + "f": 1, + "instructions": 2161, + "inverse": true, + "q": 7, + "steps": 80029, + "visited": 3586 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 3, + "T": 3, + "Z": 2, + "bits": 18, + "depth": 1, + "f": 1, + "instructions": 1038, + "inverse": false, + "q": 3, + "steps": 4254, + "visited": 499 + }, + { + "Q": 125, + "T": 3, + "Z": 2, + "bits": 750, + "depth": 1, + "f": 1, + "instructions": 1607, + "inverse": false, + "q": 5, + "steps": 83881, + "visited": 3022 + }, + { + "Q": 3, + "T": 3, + "Z": 1, + "bits": 27, + "depth": 2, + "f": 2, + "instructions": 4515, + "inverse": false, + "q": 5, + "steps": 12818, + "visited": 2454 + }, + { + "Q": 1, + "T": 2, + "Z": 2, + "bits": 4, + "depth": 64, + "f": 1, + "instructions": 7151, + "inverse": false, + "q": 5, + "steps": 7241, + "visited": 644 + }, + { + "Q": 1, + "T": 2, + "Z": 2, + "bits": 4, + "depth": 256, + "f": 2, + "instructions": 26867, + "inverse": false, + "q": 5, + "steps": 26057, + "visited": 2372 + } + ], + "dual_interpreter_cases": 40, + "full_GL8_materialized": false, + "large_depth_compile": { + "depth": 1024, + "f": 4, + "instructions": 96762 + }, + "max_steps": 83881, + "new_kappa": false, + "rejecting_controls": 7, + "source_columns": "2e5 and e4; tensor lane proven", + "status": "PASS_ACTUAL_CELLZERO_WHOLE_T_JOIN", + "total_steps": 668689 +} diff --git a/research/bit-cellzero-old-elimination/SOURCES.json b/research/bit-cellzero-old-elimination/SOURCES.json new file mode 100644 index 0000000000..07a5ec142e --- /dev/null +++ b/research/bit-cellzero-old-elimination/SOURCES.json @@ -0,0 +1,60 @@ +{ + "schema_version": 1, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "fc3d4ba105e1f097d0d7d051a308281e86ab1446", + "sha256": "66974efdced4083c00025f97d95d83909a226cdf801edb9301c195c6641f6903" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/bit-low-carry-lowering/PROOF.md", + "usage": "input", + "git_blob": "26b76b3665c6ff6c85376c43a8d764967e4805f7", + "sha256": "68350bf98ebd512dffcf3ae06a13ff27dc69beec19f15b952f099c55ed13a00a" + }, + { + "path": "research/bit-row-route-generator/PROGRAM.json.gz", + "usage": "input", + "git_blob": "2df37028f46614301118980ad14d2b3f80e43c31", + "sha256": "83448ca22ef773847b748d62f19ea80b2a51c53913ce22624003b6170be7044c" + }, + { + "path": "research/fixed-tape-ordered-shear/counters.py", + "usage": "input", + "git_blob": "c4878a7a7e3f390d193df496a579e4a788f25e32", + "sha256": "2b51181a3efd403be14111ed2d556ba10e63a8939756e69d488d12344d5a7ad1" + }, + { + "path": "research/fixed-tape-ordered-shear/machine.py", + "usage": "input", + "git_blob": "6ed03865cdb646d40573c132f841afbe335daba0", + "sha256": "04b7b76b9f06653d94d2158196cdd1bed7883dd1f59fcbc81a486e3ffb248681" + }, + { + "path": "research/fixed-tape-ordered-shear/shear.py", + "usage": "input", + "git_blob": "b814b6f77b03f12577464df91be6c4f103d1722c", + "sha256": "84d60e552bb35657b3c5e63b4ab21846a90d71dfd22c8a46cd01acba76475818" + }, + { + "path": "research/high-carry-streams/PROOF.md", + "usage": "input", + "git_blob": "2c42df2eb52c9ad66e82b44b69a9c2d6ef97a9a8", + "sha256": "9cd6e413448c5e253ab4771b8cbcbb40baca76450ac3234346b0998a4065479a" + }, + { + "path": "research/high-carry-streams/rotation.py", + "usage": "input", + "git_blob": "12d84ff8ccb7550788ed215502512571c07bff11", + "sha256": "23cad9cae470cc5631a6971fef88ceaa877af2a01224974ba85fbad35357c9bc" + } + ] +} diff --git a/research/bit-cellzero-old-elimination/TABLE.json.gz b/research/bit-cellzero-old-elimination/TABLE.json.gz new file mode 100644 index 0000000000..5af64555ad Binary files /dev/null and b/research/bit-cellzero-old-elimination/TABLE.json.gz differ diff --git a/research/bit-cellzero-old-elimination/TASK.json b/research/bit-cellzero-old-elimination/TASK.json new file mode 100644 index 0000000000..26b11e0674 --- /dev/null +++ b/research/bit-cellzero-old-elimination/TASK.json @@ -0,0 +1,80 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "priority_revision": 7, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Does one quantified step of the proposed #4100 all-size construction hold at its actual caller?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/unconditional-batched-crt/README.md" + ], + "methods": [ + "Prove one missing implication with explicit quantified hypotheses.", + "Find an exact counterexample at the claimed interface boundary." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read PROOF.md and AUDIT.md in #4100. Select one distinct obligation: CRT total repair, native/free-algebra lifting, precision/conditioning, or complete fixed-tape cost. This is an author-submitted proof, not an accepted unconditional theorem.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Check live handoffs; name one proposition, its caller, quantified domain and dependency closure. Independently prove the implication or exhibit a precise gap/counterexample. Prioritize CRT.md total repair or COMPLEX.md free-algebra lift only if unclaimed. Stop at the chosen obligation; do not substitute finite samples or root arithmetic for an all-size proof, or launch the complete package by default.", + "bottleneck_link": "Finite supplier improvements are useful only under the retained transfer obligations.", + "allowed_variations": [ + "One CRT repair, native lift, precision/conditioning or tape-cost proposition, with its exact caller." + ], + "scope_change_triggers": [ + "Replacing a quantified obligation with another finite smoke test.", + "Treating archive intake, an author PASS receipt or a finite composed fixture as discharge of the universal hypotheses." + ], + "overlap_terms": [ + "uniform transfer", + "all-size", + "precision", + "4100", + "unconditional-batched-crt" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Actual helper462/frame506 whole-T cell0 carry layer without the two completed OLD adapters, reusing bounded rotation geometry.", + "scope_change_reason": "Initial unbounded-runtime-carry proposal was withdrawn after PR3343/source comparison: actual column0 carry is only0/1. The new scope closes the source-specific whole-array physical join rather than inventing rotation.", + "bottleneck_link": "Eliminates an explicitly paid cell0 adapter dependency from the partial physical LOW boundary; no selected recursive profile or kappa change.", + "budget_minutes": 60, + "stop_rule": "A column lemma or per-fiber isolated-bank result alone is insufficient; require paid markerless whole-T staging, full source/cache binding, installation and complete bill.", + "outcome": "completed", + "evidence": "PROOF.md; literal kernel.py; authenticated predecessor macros; actual-depth TABLE.json.gz;40 dual-interpreter whole-array fixtures and3 actual-T initializers in RESULT.json.", + "author": "JoyboyBrian, with substantial OpenAI Codex assistance", + "ai_assistance": "OpenAI Codex assisted source comparison, proof, implementation, testing and writing.", + "open_questions": [ + { + "question": "Can the remaining high/carry/low-commit layers be joined in actual source order with a full invoice?", + "why_it_matters": "The cell0 layer alone does not complete LOW or a native supplier.", + "first_step": "Bind one actual complete LOW factor through the remaining paid high routing, cache lifetime and low commit.", + "blocked_by": "Other high operations/OLD implementations and actual backing reserve remain." + }, + { + "question": "Does the complete signed caller invoice improve after this replacement?", + "why_it_matters": "Removing two local OLD dependencies does not imply a selected-stage or kappa gain.", + "first_step": "Expand all affected caller costs including the new whole-array scans and global storage.", + "blocked_by": "No completed enclosing source/native tariff is supplied." + } + ] +} diff --git a/research/bit-cellzero-old-elimination/VALIDATION.md b/research/bit-cellzero-old-elimination/VALIDATION.md new file mode 100644 index 0000000000..2cc5926846 --- /dev/null +++ b/research/bit-cellzero-old-elimination/VALIDATION.md @@ -0,0 +1,36 @@ +# Validation and exact limits + +Author checks: macOS, CPython3.12, standard library only. Registered normal and +optimized runs pass, authenticating every declared input before executable +source imports. Exact tables and RESULT.json are read-only comparison inputs. + +-40 complete contiguous-T fixtures, all compared between retained sparse and +independent expanding-array interpreters:668689 transitions total, maximum83881. +The oracle gathers by coordinates without using the split/merge traversal. +-3 actual GL-type-count initializers run in both interpreters with exact +4 bit_length(T)+6 transition counts. No GL matrices are enumerated. +-Actual source S8 and its independently computed rational inverse have the +claimed first columns. f2 fixtures exercise the actual strided cache selector. +-Complete small basis families, zero/nonzero carries, forward/inverse direction, +several low-type fibers, spectators and owner/cache/head restoration are checked. +-7 controls reject: source-byte corruption, two invalid compiler parameters, +wrong payload write, wrong source direction, occupied global workspace and +trailing cache data. These checks use explicit exceptions, not assert. +-Default f4/D1024 builds96762 instructions without Python recursion. This checks +compiler domain, not execution of the astronomical actual odd-Q payload. + +Independent agent review found a recursive pre-input assembly limit and an +understated intermediate bucket-space subtotal. Assembly is now iterative with +identical existing table bytes; the visited subtotal is4H. The displayed +(d+20)V+2TDb+128(d+1) bound already covered this correction. Independent review +is AI-assisted and is not human or proof-kernel acceptance. + +Actual q5,w4 selection is exercised at reduced fiber depth1. Depth64/256 +structural controls use Q1 and are not actual admitted odd-q GL8 executions. +The all-size odd-Q/full-T statement rests on the written proof and source +contract; no full GL8 or Q^64 payload was materialized. No native, Lean, Docker, +complete multiplication, global allocator or P3 replay is claimed. + +Final committed-byte/source-history and explicit-input export checks, followed +by read-only Git-free normal/optimized replay, are performed before handoff. +These checks establish reproducibility and packaging, not scientific admission. diff --git a/research/bit-cellzero-old-elimination/VERIFY.json b/research/bit-cellzero-old-elimination/VERIFY.json new file mode 100644 index 0000000000..af532b821d --- /dev/null +++ b/research/bit-cellzero-old-elimination/VERIFY.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/bit-low-carry-lowering/PROOF.md", + "research/bit-row-route-generator/PROGRAM.json.gz", + "research/fixed-tape-ordered-shear/counters.py", + "research/fixed-tape-ordered-shear/machine.py", + "research/fixed-tape-ordered-shear/shear.py", + "research/high-carry-streams/PROOF.md", + "research/high-carry-streams/rotation.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 30, + "checks": "Actual source columns, fixed tables,40 whole-array fixtures in2 interpreters,3 actual-T initializers, source and semantic controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 30, + "checks": "Same source/endpoint/resource checks with assertions disabled." + } + ] +} diff --git a/research/bit-cellzero-old-elimination/kernel.py b/research/bit-cellzero-old-elimination/kernel.py new file mode 100644 index 0000000000..e88db4e9f2 --- /dev/null +++ b/research/bit-cellzero-old-elimination/kernel.py @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Actual whole-T cell0 join; PR3343 split/merge, PR2776 literal macros. +JoyboyBrian, substantial OpenAI Codex assistance. +""" +from math import isqrt + +LOW, CACHE, LOCAL, GLOBAL = 14,15,16,17 + + +def build(modules, q, f=1, inverse=False, depth=None): + if type(q) is not int or q<3 or any(q%a==0 for a in range(2,isqrt(q)+1)): + raise ValueError('fixed odd prime') + if type(f) is not int or f<1 or type(inverse) is not bool: + raise ValueError('fixed lane count/direction') + n=8*f;cells=n*n;bits=(q-1).bit_length() + if depth is None:depth=cells + if type(depth) is not int or depth<1:raise ValueError('positive fiber depth') + # Nonstandard depth is an explicitly labelled generic calibration, not GL_N payload. + b,m,c=(modules[k] for k in ('shear','machine','counters')) + loops=list(range(18,18+depth-1));a=m.Assembler(18+depth-1) + fail=a.fresh('invalid_cellzero_contract') + persistent=[b.P_COUNT,b.G_COUNT,b.S_COUNT,b.BINARY_WORK]+loops + private=[LOCAL,b.OUTPUT,b.SPLIT_A,b.SPLIT_B,b.LEFT_LENGTH,b.RIGHT_LENGTH] + def initialize(tape): + good=a.fresh('blank_origin');a.branch(tape,{m.BLANK:good},fail);a.label(good) + a.write(tape,m.LEFT);a.move(tape,1) + for tape in [LOW,GLOBAL]+persistent:initialize(tape) + for src,dst in [(b.P_INPUT,b.P_COUNT),(b.S_INPUT,b.G_COUNT)]+[(b.Q_INPUT,t) for t in loops]: + c.emit_binary_to_unary(a,src,b.BINARY_WORK,dst,a.fresh('extent')) + nested=[] + for tape in loops+[b.G_COUNT]: + c.emit_rewind(a,tape,a.fresh('product_return')) + loop,body,end=(a.fresh(s) for s in ('product_loop','product_body','product_end')) + a.label(loop);a.branch(tape,{m.UNIT:body,m.RIGHT:end},fail);a.label(body) + nested.append((tape,loop,end)) + a.write(b.S_COUNT,m.UNIT);a.move(b.S_COUNT,1) + for tape,loop,end in reversed(nested): + a.move(tape,1);a.goto(loop);a.label(end) + a.write(b.S_COUNT,m.RIGHT) + outer,body,done,rotate0,rotate1,after=(a.fresh(s) for s in ('types','type','types_done','rotate0','rotate1','after_rotate')) + a.label(outer);a.branch(b.P_COUNT,{m.UNIT:body,m.RIGHT:done},fail);a.label(body) + for tape in private:initialize(tape) + c.emit_binary_to_unary(a,b.Q_INPUT,b.BINARY_WORK,b.LEFT_LENGTH,a.fresh('Q')) + a.write(b.RIGHT_LENGTH,m.RIGHT) + b._segment(a,b.LEFT_LENGTH,b.SOURCE,LOCAL,False,fail,a.fresh('stage_fiber')) + a.write(LOCAL,m.RIGHT);c.emit_rewind(a,LOCAL,a.fresh('local_return')) + selected=(4 if inverse else 5)*f + for _ in range(selected*bits):a.move(CACHE,1) + # A finite radix decoder; the running program reads no host integer. + labels={(k,v):a.fresh('digit') for k in range(bits+1) for v in range(1<=q:a.goto(fail);continue + low=v if inverse else (2*v)%q + carry=0 if inverse else (2*v)//q + for _ in range((cells-selected-1)*bits):a.move(CACHE,1) + for k in range(bits):a.write(LOW,m.ONE if (low>>k)&1 else m.ZERO);a.move(LOW,1) + a.goto(rotate1 if carry else rotate0) + def rotation(carry,label): + a.label(label) + # LEFT_LENGTH already ends at RIGHT after staging the full fiber. + if carry:b._decrease_left_increase_right(a,fail,a.fresh('bounded_one')) + gather=((b.LEFT_LENGTH,LOCAL,b.SPLIT_A,False),(b.RIGHT_LENGTH,LOCAL,b.SPLIT_B,False)) + emit=((b.RIGHT_LENGTH,b.SPLIT_B,b.OUTPUT,True),(b.LEFT_LENGTH,b.SPLIT_A,b.OUTPUT,True)) + for length,src,dst,consume in gather:b._segment(a,length,src,dst,consume,fail,a.fresh('split')) + good=a.fresh('complete_local');a.branch(LOCAL,{m.RIGHT:good},fail);a.label(good) + for tape in (b.SPLIT_A,b.SPLIT_B):a.write(tape,m.RIGHT);c.emit_rewind(a,tape,a.fresh('bucket_return')) + for length,src,dst,consume in emit:b._segment(a,length,src,dst,consume,fail,a.fresh('merge')) + a.write(b.OUTPUT,m.RIGHT);c.emit_rewind(a,b.OUTPUT,a.fresh('output_return'));a.goto(after) + rotation(0,rotate0);rotation(1,rotate1);a.label(after) + def copy_consuming(src,dst,prefix): + loop,z,o,end=(a.fresh(prefix+s) for s in ('loop','zero','one','end')) + a.label(loop);a.branch(src,{m.ZERO:z,m.ONE:o,m.RIGHT:end},fail) + for label,symbol in ((z,m.ZERO),(o,m.ONE)): + a.label(label);a.write(dst,symbol);a.write(src,m.BLANK) + a.move(src,1);a.move(dst,1);a.goto(loop) + a.label(end) + copy_consuming(b.OUTPUT,GLOBAL,'append') + for tape in private:b._erase_back_to_origin(a,tape,a.fresh('clear_fiber')) + a.move(b.P_COUNT,1);a.goto(outer) + a.label(done) + for tape in (b.SOURCE,CACHE): + good=a.fresh('whole_bank_complete');a.branch(tape,{m.RIGHT:good},fail);a.label(good) + for tape in (LOW,GLOBAL):a.write(tape,m.RIGHT);c.emit_rewind(a,tape,a.fresh('owned_return')) + c.emit_rewind(a,CACHE,a.fresh('cache_return'));c.emit_rewind(a,b.SOURCE,a.fresh('owner_return')) + copy_consuming(GLOBAL,b.SOURCE,'install') + b._erase_back_to_origin(a,GLOBAL,a.fresh('retire_global')) + c.emit_rewind(a,b.SOURCE,a.fresh('installed_return')) + # Some persistent counters stop at their ends; move all to ends before erase. + for tape in persistent: + c.emit_rewind(a,tape,a.fresh('cleanup_return')) + if tape!=b.BINARY_WORK:b._seek_right(a,tape,fail,a.fresh('cleanup_end')) + b._erase_back_to_origin(a,tape,a.fresh('cleanup')) + a.halt();a.label(fail);a.reject('valid full T cache/payload, positive extents and owned workspace') + return a.finish() + + +def initialize_actual_T(modules,q,f=1): + """Pre-input finite code installs the fixed GL_(8f)(q) count; no GL enumeration.""" + if type(f) is not int or f<1:raise ValueError('fixed positive f') + n=8*f + if type(q) is not int or q<3 or any(q%a==0 for a in range(2,isqrt(q)+1)) or f<1: + raise ValueError('fixed admitted q,f') + total=1 + for i in range(n):total*=q**n-q**i + m=modules['machine'];a=m.Assembler(1);fail=a.fresh('occupied_count') + good=a.fresh('blank');a.branch(0,{m.BLANK:good},fail);a.label(good) + a.write(0,m.LEFT);a.move(0,1) + for i in range(total.bit_length()): + good=a.fresh('blank');a.branch(0,{m.BLANK:good},fail);a.label(good) + a.write(0,m.ONE if (total>>i)&1 else m.ZERO);a.move(0,1) + good=a.fresh('blank');a.branch(0,{m.BLANK:good},fail);a.label(good);a.write(0,m.RIGHT) + for _ in range(total.bit_length()):a.move(0,-1) + a.halt();a.label(fail);a.reject('owned blank T descriptor') + return a.finish() diff --git a/research/bit-cellzero-old-elimination/loader.py b/research/bit-cellzero-old-elimination/loader.py new file mode 100644 index 0000000000..02aed787cc --- /dev/null +++ b/research/bit-cellzero-old-elimination/loader.py @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Authenticate the actual source bytes before loading the retained macros.""" +import hashlib +import json +from pathlib import Path +import sys +import types + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def authenticate(overrides=None): + overrides = overrides or {} + manifest = json.loads((HERE / 'SOURCES.json').read_text()) + contents = {} + for row in manifest['files']: + if row['usage'] != 'input': + continue + raw = overrides.get(row['path'], (ROOT / row['path']).read_bytes()) + need(hashlib.sha256(raw).hexdigest() == row['sha256'], 'source SHA256: ' + row['path']) + need(hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() == row['git_blob'], + 'source Git blob: ' + row['path']) + contents[row['path']] = raw + return contents + + +def load_macros(contents): + modules = {} + names = ('machine', 'counters', 'shear') + need(all(name not in sys.modules for name in names), 'no preloaded predecessor modules') + try: + for name in names: + path = 'research/fixed-tape-ordered-shear/' + name + '.py' + module = types.ModuleType(name) + module.__file__ = str(ROOT / path) + sys.modules[name] = module + exec(compile(contents[path], module.__file__, 'exec'), module.__dict__) + modules[name] = module + finally: + for name in names: + sys.modules.pop(name, None) + return modules diff --git a/research/bit-cellzero-old-elimination/verify.py b/research/bit-cellzero-old-elimination/verify.py new file mode 100644 index 0000000000..9db6254167 --- /dev/null +++ b/research/bit-cellzero-old-elimination/verify.py @@ -0,0 +1,152 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Whole-array coordinate oracle and independent literal table execution.""" +from pathlib import Path +import sys,json,gzip,hashlib +from fractions import Fraction +HERE=Path(__file__).resolve().parent +sys.path.insert(0,str(HERE)) +from loader import authenticate,load_macros,need +from kernel import build,initialize_actual_T,LOW,CACHE + + +def invert(a): + n=len(a);r=[list(row)+[Fraction(i==j) for j in range(n)] for i,row in enumerate(a)] + for c in range(n): + pivot=next(i for i in range(c,n) if r[i][c]);r[c],r[pivot]=r[pivot],r[c] + v=r[c][c];r[c]=[x/v for x in r[c]] + for i in range(n): + if i!=c: + v=r[i][c];r[i]=[x-v*y for x,y in zip(r[i],r[c])] + return [row[n:] for row in r] + + +def dense(program,initial,limit): + """Independent expanding-array interpreter; producer Machine is unused.""" + tapes=[];heads=[];visited=[] + for cells,head in initial: + n=max(cells,default=0)+2;t=[0]*n + for k,v in cells.items():t[k]=v + tapes.append(t);heads.append(head);visited.append(set()) + pc=program.entry;steps=0 + while steps=0,'no negative fixture head') + while len(tapes[i])<=h:tapes[i].append(0) + visited[i].add(h) + if op=='branch':pc=dict(row[2]).get(tapes[i][h],row[3]);continue + if op=='write':tapes[i][h]=row[2] + elif op=='move':heads[i]+=row[2];visited[i].add(heads[i]) + else:raise ValueError('unknown instruction') + pc+=1 + else:raise ValueError('dense external step cap') + return [(dict((k,v) for k,v in enumerate(t) if v),h) for t,h in zip(tapes,heads)],steps,sum(map(len,visited)) + + +def fixture(mod, q,f,Q,Z,depth,values,seed,basis=None): + m=mod['machine'];n=8*f;D=n*n;b=(q-1).bit_length();T=len(values);H=Q**depth*Z + cache=[] + for v in values: + row=[int(i==j) for i in range(n) for j in range(n)] + row[5*f]=v;row[4*f]=(v+1)%q + cache.extend(row) + payload=[((i*i+seed+3*i)^(i>>1))&1 for i in range(T*H)] + if basis is not None:payload=[int(i==basis) for i in range(T*H)] + return cache,payload + + +def run_case(mod,q,f,Q,Z,depth,values,inverse=False,seed=1,basis=None,dual=True,mutate=None,dirty=False,trailing=False): + m=mod['machine'];D=(8*f)**2;b=(q-1).bit_length();T=len(values);H=Q**depth*Z;V=T*H + cache,payload=fixture(mod,q,f,Q,Z,depth,values,seed,basis) + program=build(mod,q,f,inverse,depth) + if mutate:program=mutate(program) + bank=[m.Tape() for _ in range(program.tapes)] + bank[0]=m.marked(m.ONE if x else m.ZERO for x in payload) + bank[4]=m.binary(T);bank[5]=m.binary(Q);bank[7]=m.binary(Z) + bank[CACHE]=m.marked(m.ONE if (x>>k)&1 else m.ZERO for x in cache for k in range(b)) + if dirty:bank[17]=m.marked([m.ONE]) + if trailing: + last=max(bank[CACHE].cells);bank[CACHE].cells[last]=m.ZERO;bank[CACHE].cells[last+1]=m.RIGHT + initial=[(dict(t.cells),t.head) for t in bank] + bound=2048*(depth+1)*V+32*T*D*b+256*(depth+1) + space=(depth+20)*V+2*T*D*b+128*(depth+1) + machine=m.Machine(program,bank).run(bound) + result=[(dict(t.cells),t.head) for t in bank] + if dual: + other,steps,visited=dense(program,initial,bound) + need(other==result and steps==machine.steps and visited==sum(map(len,machine.visits)),'independent interpreters agree') + S=Q**(depth-1)*Z;wanted=[0]*V;lows=[] + for t in range(T): + v=cache[t*D+(4 if inverse else 5)*f] + carry=0 if inverse else (2*v)//q;lows.append(v if inverse else 2*v%q) + for x in range(Q): + for z in range(S):wanted[t*H+((x+carry)%Q)*S+z]=payload[t*H+x*S+z] + expected=m.marked(m.ONE if x else m.ZERO for x in wanted) + need(result[0]==(expected.cells,1),'whole T output installed at original owner') + lowout=m.marked(m.ONE if (x>>k)&1 else m.ZERO for x in lows for k in range(b)) + need(result[LOW]==(lowout.cells,1),'actual low0 result retained') + for t in (4,5,7,CACHE):need(result[t]==initial[t],'preserved input/cache/head') + for t in set(range(program.tapes))-{0,4,5,7,CACHE,LOW}: + need(result[t]==({},0),'private erase and origin') + need(machine.steps<=bound and sum(map(len,machine.visits))<=space,'complete tariff envelopes') + return {'q':q,'f':f,'Q':Q,'Z':Z,'depth':depth,'T':T,'inverse':inverse,'bits':V,'steps':machine.steps,'visited':sum(map(len,machine.visits)),'instructions':len(program.instructions)} + + +def main(): + contents=authenticate();mod=load_macros(contents) + source=json.loads(gzip.decompress(contents['research/bit-row-route-generator/PROGRAM.json.gz'])) + S=[[Fraction(v) for v in row] for row in source['matcher']];A=invert(S) + need([row[0] for row in S]==[Fraction(2*(j==5)) for j in range(8)],'actual forward column0') + need([row[0] for row in A]==[Fraction(j==4) for j in range(8)],'actual inverse column0') + tables=json.loads(gzip.decompress((HERE/'TABLE.json.gz').read_bytes())) + expected_tables={str(inverse):json.loads(json.dumps({'tapes':p.tapes,'entry':p.entry,'instructions':p.instructions})) + for inverse in (False,True) for p in [build(mod,5,1,inverse)]} + need(tables==expected_tables,'actual depth64 finite tables match compiler') + initializers=[] + for q,f in [(3,1),(5,2),(7,1)]: + m=mod['machine'];p=initialize_actual_T(mod,q,f);run=m.Machine(p).run() + n=8*f;T=1 + for i in range(n):T*=q**n-q**i + expected=m.binary(T) + need(run.tapes[0].cells==expected.cells and run.tapes[0].head==1,'actual T initializer') + need(run.steps==4*T.bit_length()+6,'initializer exact cost') + other,steps,visited=dense(p,[({},0)],run.steps+1) + need(other==[(expected.cells,1)] and steps==run.steps,'independent T initialization') + initializers.append({'q':q,'f':f,'steps':steps,'bits':T.bit_length()}) + large=build(mod,3,4) + need(large.tapes==1041,'default f4/D1024 compiler has no recursion limit') + cases=[] + for q in (3,5,7): + for inverse in (False,True): + for Q,Z,depth in [(3,1,1),(3,2,2),(5,1,3)]: + cases.append(run_case(mod,q,1,Q,Z,depth,list(range(q)),inverse)) + for i in range(18):cases.append(run_case(mod,3,1,3,2,1,[0,2,1],basis=i)) + cases.append(run_case(mod,5,1,125,2,1,[3,0,4],False)) + cases.append(run_case(mod,5,2,3,1,2,[3,0,4],False)) + # Actual D compiler depths, Q1 only: structural microcode controls, not actual odd-q payload runs. + for f in (1,2):cases.append(run_case(mod,5,f,1,2,(8*f)**2,[3,0],False)) + controls=0 + raw=contents['research/high-carry-streams/rotation.py'] + try:authenticate({'research/high-carry-streams/rotation.py':raw+b'\n# corruption\n'}) + except ValueError:controls+=1 + else:raise ValueError('source mutation escaped') + for q,f in [(2,1),(5,0)]: + try:build(mod,q,f) + except ValueError:controls+=1 + else:raise ValueError('invalid compiler parameter escaped') + def wrong_payload(program): + code=list(program.instructions) + pos=next(i for i,row in enumerate(code) if row==('write',0,mod['machine'].ZERO)) + code[pos]=('write',0,mod['machine'].ONE) + return mod['machine'].Program(tuple(code),program.tapes,program.entry) + for options in ({'mutate':wrong_payload},{'mutate':lambda p:build(mod,5,1,True,1)}, {'dirty':True},{'trailing':True}): + try:run_case(mod,5,1,5,2,1,[3,0,4],**options) + except ValueError:controls+=1 + else:raise ValueError('semantic mutation escaped') + receipt={'status':'PASS_ACTUAL_CELLZERO_WHOLE_T_JOIN','cases':len(cases),'total_steps':sum(c['steps'] for c in cases),'max_steps':max(c['steps'] for c in cases),'dual_interpreter_cases':len(cases),'source_columns':'2e5 and e4; tensor lane proven','rejecting_controls':controls,'full_GL8_materialized':False,'new_kappa':False,'cases_detail':cases,'actual_T_initializers':initializers,'large_depth_compile':{'f':4,'depth':1024,'instructions':len(large.instructions)}} + if (HERE/'RESULT.json').exists():need(receipt==json.loads((HERE/'RESULT.json').read_text()),'committed receipt') + print(json.dumps(receipt,sort_keys=True,indent=2)) + +if __name__=='__main__':main()