From 8b549ca6557ccbb3017b104b27ea35051f990416 Mon Sep 17 00:00:00 2001 From: Jerry Jiaheng Chen <80299683+CubeJerry@users.noreply.github.com> Date: Thu, 12 Nov 2026 11:00:45 +0800 Subject: [PATCH] Implement the outer layer phase sweep from its actual encoded header with a fixed finite tape program --- research/literal-layer-phase/JOIN-RESULT.json | 191 ++++ research/literal-layer-phase/NOTICE.md | 29 + research/literal-layer-phase/OVERLAP.md | 32 + .../literal-layer-phase/PR-DESCRIPTION.md | 90 ++ research/literal-layer-phase/PR-TITLE.txt | 1 + research/literal-layer-phase/PROOF.md | 346 ++++++ research/literal-layer-phase/README.md | 118 +++ research/literal-layer-phase/RESULT.json | 298 ++++++ research/literal-layer-phase/REVIEW.md | 67 ++ research/literal-layer-phase/SOURCES.json | 77 ++ research/literal-layer-phase/TASK.json | 38 + research/literal-layer-phase/VALIDATION.json | 91 ++ research/literal-layer-phase/VERIFY.json | 85 ++ research/literal-layer-phase/compose.py | 153 +++ .../independent/DENSE-RESULT.json | 14 + .../independent/SOURCE-BINDINGS.json | 71 ++ .../independent/dense_check.py | 127 +++ .../independent/peer/RESULT.json | 389 +++++++ .../independent/peer/REVIEW.md | 184 ++++ .../independent/peer/check.py | 278 +++++ .../independent/peer/replay.py | 15 + .../inputs/controller_reference.py | 112 ++ research/literal-layer-phase/oracles.py | 57 + research/literal-layer-phase/phase.py | 343 ++++++ .../reference/02-streams.tex | 208 ++++ .../reference/05-layers.tex | 996 ++++++++++++++++++ .../reference/literal-egress-patterns.py | 391 +++++++ .../reference/selected-application.md | 420 ++++++++ .../reference/selected-result.json | 113 ++ .../reference/sequential-monomial-phase.py | 125 +++ .../reference/sequential-monomial-proof.md | 167 +++ research/literal-layer-phase/verify.py | 276 +++++ 32 files changed, 5902 insertions(+) create mode 100644 research/literal-layer-phase/JOIN-RESULT.json create mode 100644 research/literal-layer-phase/NOTICE.md create mode 100644 research/literal-layer-phase/OVERLAP.md create mode 100644 research/literal-layer-phase/PR-DESCRIPTION.md create mode 100644 research/literal-layer-phase/PR-TITLE.txt create mode 100644 research/literal-layer-phase/PROOF.md create mode 100644 research/literal-layer-phase/README.md create mode 100644 research/literal-layer-phase/RESULT.json create mode 100644 research/literal-layer-phase/REVIEW.md create mode 100644 research/literal-layer-phase/SOURCES.json create mode 100644 research/literal-layer-phase/TASK.json create mode 100644 research/literal-layer-phase/VALIDATION.json create mode 100644 research/literal-layer-phase/VERIFY.json create mode 100644 research/literal-layer-phase/compose.py create mode 100644 research/literal-layer-phase/independent/DENSE-RESULT.json create mode 100644 research/literal-layer-phase/independent/SOURCE-BINDINGS.json create mode 100644 research/literal-layer-phase/independent/dense_check.py create mode 100644 research/literal-layer-phase/independent/peer/RESULT.json create mode 100644 research/literal-layer-phase/independent/peer/REVIEW.md create mode 100644 research/literal-layer-phase/independent/peer/check.py create mode 100644 research/literal-layer-phase/independent/peer/replay.py create mode 100644 research/literal-layer-phase/inputs/controller_reference.py create mode 100644 research/literal-layer-phase/oracles.py create mode 100644 research/literal-layer-phase/phase.py create mode 100644 research/literal-layer-phase/reference/02-streams.tex create mode 100644 research/literal-layer-phase/reference/05-layers.tex create mode 100644 research/literal-layer-phase/reference/literal-egress-patterns.py create mode 100644 research/literal-layer-phase/reference/selected-application.md create mode 100644 research/literal-layer-phase/reference/selected-result.json create mode 100644 research/literal-layer-phase/reference/sequential-monomial-phase.py create mode 100644 research/literal-layer-phase/reference/sequential-monomial-proof.md create mode 100644 research/literal-layer-phase/verify.py diff --git a/research/literal-layer-phase/JOIN-RESULT.json b/research/literal-layer-phase/JOIN-RESULT.json new file mode 100644 index 0000000000..dfe19b3ce0 --- /dev/null +++ b/research/literal-layer-phase/JOIN-RESULT.json @@ -0,0 +1,191 @@ +{ + "cases": 10, + "coefficients": 316, + "limitations": [ + "Exact C and its common-grid format preparation are test oracles, not implementations.", + "Only the two phase tables and pinned egress execute as literal programs." + ], + "rows": [ + { + "coefficients": 2, + "egress_steps": 4152, + "final_phase_steps": 1409, + "initial_phase_steps": 1409, + "parameters": [ + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 3 + ], + "physical_tapes": 36 + }, + { + "coefficients": 4, + "egress_steps": 9184, + "final_phase_steps": 2392, + "initial_phase_steps": 2392, + "parameters": [ + 1, + 3, + 1, + 2, + 1, + 1, + 1, + 1, + 3 + ], + "physical_tapes": 36 + }, + { + "coefficients": 8, + "egress_steps": 19746, + "final_phase_steps": 4207, + "initial_phase_steps": 4207, + "parameters": [ + 1, + 4, + 1, + 3, + 1, + 1, + 1, + 1, + 3 + ], + "physical_tapes": 36 + }, + { + "coefficients": 16, + "egress_steps": 43388, + "final_phase_steps": 7574, + "initial_phase_steps": 7574, + "parameters": [ + 1, + 5, + 1, + 4, + 1, + 1, + 1, + 1, + 3 + ], + "physical_tapes": 36 + }, + { + "coefficients": 2, + "egress_steps": 3947, + "final_phase_steps": 1746, + "initial_phase_steps": 1746, + "parameters": [ + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 4 + ], + "physical_tapes": 36 + }, + { + "coefficients": 4, + "egress_steps": 8430, + "final_phase_steps": 3015, + "initial_phase_steps": 3015, + "parameters": [ + 2, + 2, + 1, + 2, + 1, + 1, + 1, + 1, + 4 + ], + "physical_tapes": 36 + }, + { + "coefficients": 8, + "egress_steps": 19085, + "final_phase_steps": 5153, + "initial_phase_steps": 5153, + "parameters": [ + 2, + 3, + 1, + 3, + 1, + 1, + 1, + 1, + 4 + ], + "physical_tapes": 36 + }, + { + "coefficients": 16, + "egress_steps": 42154, + "final_phase_steps": 9461, + "initial_phase_steps": 9461, + "parameters": [ + 2, + 4, + 1, + 4, + 1, + 1, + 1, + 1, + 4 + ], + "physical_tapes": 36 + }, + { + "coefficients": 128, + "egress_steps": 282261, + "final_phase_steps": 60257, + "initial_phase_steps": 60257, + "parameters": [ + 2, + 3, + 2, + 2, + 2, + 2, + 2, + 1, + 4 + ], + "physical_tapes": 36 + }, + { + "coefficients": 128, + "egress_steps": 282698, + "final_phase_steps": 60366, + "initial_phase_steps": 60366, + "parameters": [ + 2, + 3, + 2, + 2, + 2, + 2, + 2, + 2, + 4 + ], + "physical_tapes": 36 + } + ], + "status": "PASS_LITERAL_PHASE_EGRESS_JOIN" +} diff --git a/research/literal-layer-phase/NOTICE.md b/research/literal-layer-phase/NOTICE.md new file mode 100644 index 0000000000..c70ad1c229 --- /dev/null +++ b/research/literal-layer-phase/NOTICE.md @@ -0,0 +1,29 @@ +# Attribution and source notices + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +New package material is Apache-2.0. Exact predecessor files retain their +original notices and license statements. + +The canonical header and simultaneous-layer definitions are frozen from +`e54523517d0f03e58352e647c403a5af3e525a57`. The algebraic phase identity, +Gamma encoding, Gaussian unit phases and binary-counter amortization are +credited methods; no broad mathematical or literature priority is claimed. + +Ali Romman authored the retained sequential monomial producer in +CrocSwap/integer-mult-bounds#5375, following Jose Manuel's #2250 Gaussian +source, JoyboyBrian's #5329 recipe, Cinna Davis's cached chirp work and +Ryanson Jonathan's #4325 odometer audit. The two exact reference files are +included for scope and provenance and are not imported by the new sweep. + +The literal Builder/Machine export is pinned to CubeJerry's commit +`9dfe6747b8553fd11b408f2b045c5954ef1e6eaa`. Gamma, trace, staging and +cleanup patterns follow the literal layer egress package at CubeJerry's +verified commit `51ab0539059214fcfa044938c36a0b6017232be5`. Its exact +source is included as a reference and compiled, with an exact graph digest +check, solely by the optional finite join verifier. + +The parent research agent independently implemented `independent/dense_check.py` +with a separate dense interpreter and Cartesian-address arithmetic oracle. +The separate `compiler_exits` agent reviews the universal geometry, costs +and history. These are independent AI-assisted checks; human or proof-kernel +acceptance is not represented by either review. diff --git a/research/literal-layer-phase/OVERLAP.md b/research/literal-layer-phase/OVERLAP.md new file mode 100644 index 0000000000..472e26e86f --- /dev/null +++ b/research/literal-layer-phase/OVERLAP.md @@ -0,0 +1,32 @@ +# Bounded overlap and precise new scope + +Base: `e54523517d0f03e58352e647c403a5af3e525a57`, checked for this second wave +by the orchestrator. This task was assigned explicitly; no catalogue reroll. + +Canonical research tree metadata identifies `sequential-monomial-phase`. +Its exact PROOF.md and phase.py were retrieved at the base and authenticated +against Git blobs `42ffd4007c1416eb4a45e47d181194d3e87742bb` and +`26126045289a3dceeb8d096c984d536613e5345f`. Live metadata confirms +#5375 merged from `9b1aa6b75515a2767fdab6b80eda3284bd1f5809` by Ali Romman. +Its proof explicitly retains supplied-mask production, one-coefficient +grammar, same-owner preservation, mixed packing and literal-table lowering. + +Targeted all-state PR queries for `"sequential-monomial-phase"`, +`"phase sweep" "header"`, and `"phase" "Gamma"` were read during this +wave. The exact-package query returns #5375; the other bounded results did +not provide this actual nine-Gamma fixed-table sweep. The orchestrator also +checked literal/phase leads and active claims before assigning this scope. +These are bounded metadata/body checks, not complete historical diff coverage +or a guarantee against unpublished overlap. + +The preceding egress contribution is verified on CubeJerry's remote at +`51ab0539059214fcfa044938c36a0b6017232be5`, branch +`research/literal-layer-egress-20261112-0132`. Its runtime source is included +as an exact reference and its emitted table is checked in the finite join. +It explicitly leaves both S_D sweeps supplied. No upstream PR is invented. + +The new claim is restricted to the linear outer phase of canonical +`05-layers.tex`, with generated identical K-bit masks at a common rho, +variable D, complete P/S/r grammar, literal MSB integer rotations, original +owner commit, successful cleanup and retained backing. It does not claim +the #5375 general quadratic recipe or a complete C/layer/multiplier. diff --git a/research/literal-layer-phase/PR-DESCRIPTION.md b/research/literal-layer-phase/PR-DESCRIPTION.md new file mode 100644 index 0000000000..5955708afd --- /dev/null +++ b/research/literal-layer-phase/PR-DESCRIPTION.md @@ -0,0 +1,90 @@ +## Result and why it matters + +The canonical simultaneous layer still needs two diagonal S_D phase sweeps. +The pinned [literal egress](https://github.com/CubeJerry/integer-mult-bounds/tree/51ab0539059214fcfa044938c36a0b6017232be5/research/literal-layer-egress) +supplies b^D and the final toward-zero projection but explicitly leaves these +sweeps supplied. This package implements that actual boundary in one fixed +2,146-location program on twenty tapes. + +It reads the nine-Gamma header, constructs the selected-bit mask, enumerates +implicit `[P] x [2^K]^D x [S]` addresses, repeats phases over r coefficients, +and returns exact w-bit MSB Gaussian rotations on the original DATA owner. +Every parameter, counter and payload operation executes through local-symbol +branches, one-cell writes, unit moves and fixed jumps. No runtime address, +decoded parameter, supplied mask or input-sized lookup is used. + +For E header bits, N=Mr coefficients and V=2Nw payload bits: + +``` +T <= 65536(E+p+d+DK+Nw+1) +private historical backing <= K0+4V+32(E+p+d+DK+w+1). +``` + +These include all setup, source reads, coefficient work, repetition, +staging, original-owner commit, returns and erasures. Carry-prefix work is +O(P*2^(DK)); unary r/P/S acquisition is paid because each is at most N. +The complete boundary is O(V) in the selected source bands. Success returns +all heads and private banks; numerical range rejection preserves the full +public input before commit. No rejection cleanup is claimed. + +## Novelty and predecessor credit + +Ali Romman's #5375 proves sequential monomial phases with a supplied active +mask, fixed recipe dimension, source-level counter/consumer and one Gaussian +coefficient per record. It leaves geometry production, packed repetition, +literal lowering and complete caller binding open. The new result supplies +header-produced geometry, variable D on a fixed inventory, r/P/S grammar, +literal MSB rotations and same-owner cleanup for the specific outer S_D. +Counter amortization and Gaussian phase algebra remain credited methods. + +The egress and new sweep can use distinct private banks plus two public +tapes: 36 fixed tapes total, with the phase bank reused for the final pass. +An exact C service and its paid common-grid conversion remain explicit +premises. No complete layer or multiplier is claimed. + +Credit @CubeJerry / Jerry Chen; Ali Romman #5375; Jose Manuel #2250; +JoyboyBrian #5329; Cinna Davis; Ryanson Jonathan #4325; the canonical +header/layer authors; and CubeJerry's pinned literal controller and egress +packages. Substantial OpenAI assistance contributed construction, proof, +implementation and separate agent review. Human/proof-kernel acceptance +is unclaimed. Apache-2.0; predecessor notices are retained. + +## Exact source and checks + +Base `e54523517d0f03e58352e647c403a5af3e525a57`. Exact paths, commits, Git +blobs and SHA256 values are in SOURCES.json. Only +`research/literal-layer-phase/` is added; frozen source and selected records +are unchanged. + +```sh +python -I -W error -B research/literal-layer-phase/verify.py +python -I -W error -O -B research/literal-layer-phase/verify.py +python -I -W error -B research/literal-layer-phase/compose.py +python -I -W error -O -B research/literal-layer-phase/compose.py +``` + +Expected: `PASS_LITERAL_LAYER_PHASE` and `PASS_LITERAL_PHASE_EGRESS_JOIN`. +The main run covers 319 packets / 29,586 coefficients, 52 geometries, all +256 signed three-bit pairs isolated at four phases, 31 range rejections, +five invalid controls, seven detected actual-program mutations and stable +history reuse after growth and shrinkage. The separate join executes both +literal phase sweeps and the pinned egress around a clearly labelled +**test-only exact C oracle**: ten disk-grid tensors / 316 coefficients +match a direct normalized Walsh tensor and one final projection. + +Independent review and a separately implemented dense interpreter are +recorded in REVIEW.md and the included review receipts. The dense review +passes 24 packets and three semantic mutations. The separate universal and +structural review accepts the proof and checks 15 successful runs, 2,084 +record entries and the exact counter movement census; its three controls +include a numerically correct full-width scan that violates the cost claim. +Universal claims rest on the written proof; finite checks corroborate them. +Hosted CI and formal proof-kernel acceptance are separate. + +## Limits and open obligation + +**No new kappa. All five global assumptions remain.** An executable exact C +consumer, canonical-order return, common-grid conversion, owner allocation, +compiler/native admission, packed permutations and integer recovery remain +unimplemented by this package. The next useful join should supply C at this +precise header/owner/width interface with a complete physical invoice. diff --git a/research/literal-layer-phase/PR-TITLE.txt b/research/literal-layer-phase/PR-TITLE.txt new file mode 100644 index 0000000000..508ff58f0c --- /dev/null +++ b/research/literal-layer-phase/PR-TITLE.txt @@ -0,0 +1 @@ +Implement the outer layer phase sweep from its actual encoded header with a fixed finite tape program diff --git a/research/literal-layer-phase/PROOF.md b/research/literal-layer-phase/PROOF.md new file mode 100644 index 0000000000..5d330f4537 --- /dev/null +++ b/research/literal-layer-phase/PROOF.md @@ -0,0 +1,346 @@ +# A literal outer phase sweep generated by the actual layer header + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +Apache-2.0. This is a scoped constructive proof with finite corroboration; +independent human and proof-kernel acceptance are not claimed. No new kappa. + +## 1. Exact source, novelty and full-cost gate + +Canonical base is `e54523517d0f03e58352e647c403a5af3e525a57`. +`upstream/build/sections/05-layers.tex`, the `phase-butterfly-layer` identity +and `simultaneous-layer` proposition, require + +\[ +H_0^{\otimes D}=b^D\mathcal S_D C^{\otimes D}\mathcal S_D, +\qquad b=(1-i)/2, +\qquad (\mathcal S_Dz)(x)=i^{x_1+\cdots+x_D}z(x). +\] + +The address set is `[P] x [2^K]^D x [S]` in lexicographic order, with r +Gaussian coefficients at each address. Each x_j is bit rho of its K-bit +chunk, numbered from the least significant end. The actual header is + +\[ +\Gamma(p)\Gamma(d)\Gamma(r)\Gamma(D)\Gamma(P)\Gamma(S) +\Gamma(K)\Gamma(\rho+1)\Gamma(w). +\] + +Canonical `02-streams.tex` defines Gamma(v) as `0^(bit_length(v)-1) bin(v)` +for positive v. Both exact sources are included with authenticated pins. + +Ali Romman's [#5375](https://github.com/CrocSwap/integer-mult-bounds/pull/5375) +already supplies a sequential finite-symbol monomial phase producer, a +binary-counter amortization proof and a Gaussian consumer. Its recipe size +m is fixed; its active-position mask is supplied; its demonstrated consumer +has one coefficient per record and separate consumed-input/output owners. +It explicitly leaves mask manufacture, packed repetition, mixed-width +interfaces and literal transition-table lowering open. Its phase identity, +Gaussian arithmetic and odometer argument are credited, not rediscovered. + +The preceding [literal egress package](https://github.com/CubeJerry/integer-mult-bounds/tree/51ab0539059214fcfa044938c36a0b6017232be5/research/literal-layer-egress) +supplies the b^D normalizer and one final toward-zero projection, while both +S_D sweeps remain supplied. The current contribution supplies those sweeps +at their actual common-width boundary. It generates the mask from the header, +handles variable D on a fixed tape inventory, implements all P/S/r +repetition, and installs exact integer Gaussian rotations on the same owner. +Its literal Gamma, trace, staging and cleanup patterns credit that package. + +Put L=DK, Q=2^L, M=PQS, N=Mr, V=2Nw and E=header length. The optimistic +complete budget passed before construction: unary r,P,S acquisition costs +O(r+P+S)<=O(N); mask construction costs O(L); an incrementally maintained +phase costs O(PQ+L), including carry returns; coefficient work and installation +cost O(Nw). Thus no source-band amortization of an extra per-record DK factor +is needed. The theorem below proves the literal bound and retains all histories. + +## 2. Literal theorem and admitted windows + +Assume positive p,d,r,D,P,S,K,w, with D<=d, 0<=rho=p+2. The program +receives the nine Gamma words on HEADER and exactly N Gaussian pairs on DATA, +real before imaginary, each component a signed w-bit two's-complement integer +written MSB first. DATA has a blank at offset V. Header exterior after its +ninth word may contain arbitrary symbols; the program does not scan it. + +Twenty physical tapes are distinct. Eighteen private tapes have blank owned +guards at offset -1 and blank bodies wherever this call visits. All heads +start at their supplied, arbitrarily translated origins. Opaque exterior +outside these windows is preserved. Whole-window blankness is a supplied +ownership premise, not established by reading only the origin. Entry histories +and exterior backing remain charged; no object reset grants fresh memory. + +One fixed table with **2,146 instruction locations**, four symbols +`{blank,0,1,|}`, twenty tapes and no input parameters performs the sweep. Its +only instructions are scanned-symbol branch, one-cell write, unit move, +fixed goto and halt. Python generates the finite graph; no decoded header +value, address, variable-width recipe or payload integer enters runtime control. +Undefined local-symbol branches reject; a designated empty branch is the +explicit range/header-domain sink. A simultaneous multitape transition table +can expand every local read over other tapes' four symbols, a fixed expansion. + +If all required rotated components fit w signed bits, the table replaces DATA +on its original owner by S_D DATA, preserves HEADER and every exterior symbol, +restores every head and erases every private body and owned guard. Otherwise, +numerical range rejection occurs before the first DATA write, preserving the +entire public input. No head return, cleanup or restart after rejection is +promised. Malformed headers, false ownership premises and resource-fault +recovery are outside the successful theorem; finite invalid-input controls +do not extend that theorem silently. + +Unlike a supplied-length phase iterator, this program derives its complete +cardinality from the header. It rejects a missing payload bit and checks for +the blank end immediately after the last required component, before commit. +No N, V, M or precomputed phase stream is supplied to execution. + +## 3. Header interpretation and generated geometry + +The unary Gamma decoder maintains the value of the consumed binary prefix. +The initial one writes unary 1; a following t replaces v by 2v+t using +DOUBLE, erases the old value, and restores both heads. LENGTH stores the +number of Gamma tail digits still to consume. HTRACE records exactly one +marker per HEADER move. Returning along it erases the trace and restores +HEADER without knowing E or reading exterior. + +All nine parameters are decoded, including r,P,S. Expanding these three +values is legitimate here because each is at most N; a huge header value +is accompanied by the correspondingly huge complete admitted payload. +The theorem does not claim constant work in their encoded lengths alone. +Unary parallel scans check D<=d and w>=p+2. + +For each of the D chunks, scan K unary symbols. Advance SELECT, whose length +is rho+1, until its next scanned symbol is blank. Write a one to MASK at that +position and zeroes elsewhere in the chunk. The before/after finite state +ensures there is exactly one active position. If K ends before the active +position, reject. At the chunk boundary rewind both K and SELECT; advance D. +In parallel write a zero to COUNT at every mask cell. + +Consequently both bodies have length L=DK, COUNT is zero and + +\[ +\operatorname{MASK}[j]=1\quad\Longleftrightarrow\quad j\bmod K=\rho. +\] + +These bodies are LSB first. The first K positions describe the last address +chunk, the next K the preceding one, and so forth. This matches lexicographic +enumeration of the D chunks. Since the selected phase is the sum over chunks, +the identical mask recipe needs no stored chunk identifier. All initial +geometry parameters except the repetition and width tapes are now erased. + +## 4. Complete enumeration and four-state phase invariant + +At a counter value u, maintain in finite control + +\[ +q=\sum_{j=0}^{L-1}\operatorname{MASK}[j]\operatorname{COUNT}[j]\pmod4. +\] + +It starts at zero. Increment the complete binary counter from its LSB. +Flipping old bit b at an active mask position changes q by 1-2b; an inactive +flip changes nothing. Each update is a fixed transition among four states. +A zero-to-one flip ends the carry; return both heads over the changed prefix. +A one-to-zero flip advances to the next bit. Reaching the blank after L +symbols means all bits wrapped to zero. Rewind both heads; q is again zero. + +This proves the phase invariant by each individual bit flip. Standard binary +induction proves exact enumeration 0,...,Q-1, with no skipped or duplicated +chunk addresses. Every chunk address is retained for S spectator records and +r coefficients per record, using unary head positions as loop counters. An +r-boundary rewinds that counter; an S-boundary rewinds S and advances COUNT. +A complete Q-wrap advances P. At P's end the stream has consumed exactly +P Q S r=N pairs. No loop index or decoded parameter lives in host control. + +The complete-domain bit-flip count, including final wrap, is 2Q-2: bit j +changes Q/2^j times, and summing j=0,...,L-1 gives that geometric sum. +Every return traverses only the just-changed prefix. There is no per-record +full-L rewind or hidden scan of historical capacity. The complete counter +bill for P repetitions is therefore O(PQ), even when D and K vary. + +## 5. Signed coefficient action, staging and original-owner return + +Load w bits each into REAL and IMAG, logging every DATA move in DTRACE. +WIDTH is a unary ruler; each load restores it. The four phase cases are + +| q | Returned real | Returned imaginary | +| --- | --- | --- | +| 0 | a | c | +| 1 | -c | a | +| 2 | -a | -c | +| 3 | c | -a | + +For a required negation, seek the component's LSB, complement and add one +while walking backward. Its carry is one bit. Retain the last old and new +bits in finite control. At the left marker these are the original and new +sign bits. Both are one exactly for the unrepresentable negation of +-2^(w-1); reject then. Otherwise this is exact integer negation, including +zero. Thus the guard is necessary and sufficient for every required output +component, rather than merely a modular-encoding check. + +Append both resulting components to OUTPUT in MSB order and correct +real/imaginary order, erasing REAL and IMAG as consumed. Their heads return +over their erased bodies. All results are staged until every required pair +and the header-derived payload-end check have passed. Therefore an overflow +late in the stream preserves every public input bit, including earlier pairs. + +DTRACE then returns DATA and erases itself. OUTPUT is rewound. Its V bits +are copied to the original DATA owner while OUTPUT is erased, with every +DATA move written again to DTRACE. Both fields have the same width and +length; no owner swap, free copying or uncharged size change occurs. Return +DATA using DTRACE and OUTPUT over its erased body. Erase the retained unary +parameters, MASK, COUNT and all eighteen private guards. This proves complete +successful retirement and exact head restoration. + +## 6. Universal complete instruction bound + +Each read, write, move and goto costs one literal instruction. A marker is +written and erased by ordinary instructions. The fixed table's generation +cost F is separate and independent of all parameters. It is not an input-sized +source-access oracle. + +The basic exact loop allowances are: rewind a length-t prefix in 3t+3; +clear it in 7t+4; return a public head using a length-t trace in 5t+3. +One unary prefix update v->2v+b uses at most 47v+35 helper instructions +plus a constant Gamma-wrapper cost. Previous prefix values sum to less than +the final value and the number of digits is at most that value. This proves +linear cost in the decoded values and E, including DOUBLE/LENGTH retirement. + +Geometry generation and its initial returns cost at most 64(L+1): each +chunk's K and SELECT scans/returns cost O(K), since rho+1<=K. There are +D chunks. Comparisons and parameter retirement are linear in the unary +values. In particular, r+P+S<=3N, D,K,rho+1<=L. A sufficient combined +allowance for every header, geometry, marker, comparison and parameter +initialization/retirement operation is + +\[ +4096(E+p+d+L+N+w+1). +\] + +One component load costs at most 15w+7. One negation, including its LSB +search, costs at most 7w+5. One staging/erasing/return pass costs at most +9w+4. Even a pair needing both negations costs at most 62w+32 before its +constant repetition control. The complete r and S rewinds add O(N), since +the total lengths traversed over all record boundaries are N and M. + +One counter increment changing t bits costs at most 12t+10, including both +returns and the complete-wrap handling. Across P domains this is less than +34PQ. Since PQ<=M<=N, a sufficient combined allowance for all coefficient +work, repetition and odometer work is + +\[ +512N(w+1). +\] + +The two DATA returns, two OUTPUT rewinds and paid original-owner copy cost +24V+13, bounded by 32V+32. Final private parameter cleanup is already in the +metadata allowance. Using V=2Nw, N>=2, w>=3 and N+w<=Nw gives the claimed +conservative complete bound + +\[ +\boxed{T\le65536(E+p+d+DK+Nw+1).} +\] + +A numerical range rejection executes a prefix of this bounded pass, so obeys +the same bound for a complete legal-width packet. Finite malformed-input +tests demonstrate their particular detection behavior; no general +resource-recovery theorem is inferred. + +In the source family, E=O(p), d=Theta(p^epsilon) with epsilon<1, and w>=p+2. +Moreover DK<=2^(DK)<=M<=N. Hence T=O(Nw)=O(V). This conclusion does not need +r to dominate a separately incurred DK cost per record. It includes +initialization, parameter acquisition, source reads, all returns, staging, +copying, erasure and repeat-loop work. + +## 7. Retained historical backing and repeated calls + +Offsets below are relative to each role's current origin. Every private +role visits its owned guard at -1 and at most the following nonnegative +extent, inclusive of the blank at the indicated endpoint. + +| Role | Maximum nonnegative offset | +| --- | --- | +| OUTPUT, DTRACE | V each | +| HTRACE | E | +| LENGTH | maximum Gamma prefix length, at most E | +| DOUBLE | max of the nine decoded parameters | +| Each of nine unary parameter roles | its own decoded value | +| MASK, COUNT | DK each | +| REAL, IMAG | w each | + +There are exactly eighteen private roles: the table counts the nine +parameter roles separately, and no coefficient or address creates another +physical role. Every listed extent remains charged after erasure. If K0 +is their total initial physical history, union with the above visited +intervals gives an upper bound by K0 plus the sum of the eighteen interval +lengths. For L=DK, the latter is at most + +\[ +3V+2E+2p+2d+6L+4w+36. +\] + +To see this, bound DOUBLE's extent by p+d+L+w+(r+P+S). The terms involving +r,P,S, including their own unary roles, total at most 6N<=V. The two +full-payload roles contribute 2V. The remaining terms have the displayed +linear bounds. In particular, the simpler published envelope is + +\[ +\boxed{K_0+4V+32(E+p+d+DK+w+1).} +\] + +Public DATA/HEADER and unrelated exterior reservations are separate paid +caller backing. This bounds retained history, not live nonblank bits. +It applies to arbitrary translated origins and arbitrary entry histories +under the blankness/ownership premise. + +Success leaves all newly visited private cells blank. Existing untouched +tails remain as they were. Consequently a bank whose old longer tails were +blank can serve a smaller later call without rescanning historical capacity; +growing and regrowing calls only add newly reached intervals. The same +eighteen tape identities and histories can persist over any finite sequence +of successful calls. Cumulative history is the union of absolute visited +windows per role. At fixed role origins, this is equivalently bounded using +the maximum reached extent of each role; no maximum of total per-call +footprints is substituted. If origins change between calls, retain the +absolute per-role union and separately pay the caller's head transport. +Source acquisition/re-encoding between calls is separately paid caller work. +Failure reuse and stale external-handle authority are unclaimed. + +## 8. Join to the literal egress and limits + +Initial source disk-grid inputs have component numerators of magnitude at +most 2^p. With w>=p+2, every signed permutation and negation required by S_D +fits. S_D preserves the complex disk exactly, with no numerical rounding. +After a supplied exact C tensor and the existing literal b^D/Q_p egress, +the same disk guarantee holds before the final S_D sweep. Therefore both +uses of the new program succeed on intended admitted layer inputs. + +Componentwise toward-zero Q_p commutes with signed real/imaginary +permutations, since trunc_0 is odd. Scalar b^D also commutes with S_D. +Thus a correctly bound exact C producer, followed by the literal egress +and this final sweep, returns exactly Q_p(H0^tensor D z), with only that +one projection. The old header and original address/coefficient order +must survive the supplied C service. Its w-to-common-grid conversion, +recursive children, precision proof, backing and complete cost remain paid +premises. The sweep does not construct that service. + +One may reserve distinct private inventories for the phase table (18 roles) +and the egress table (16 roles), sharing the two public tapes. This uses +36 fixed tapes, retains both histories and avoids unproved workspace +aliasing. The phase inventory can be reused for the final sweep after its +successful initial retirement. The known boundary passes have total O(V) +time and added history in the source bands. This is a concrete interface +reduction, not a complete multiplier or a new asymptotic kappa. + +All five global assumptions retain their status. This package supplies no +arbitrary mixed-width monomial wrapper, affine routing, tensor C compiler, +source allocation theorem, native all-column admission, packed permutation +or integer recovery. It is not a general quadratic phase provider. + +## Open next questions + +1. Join an actual completed C consumer to the two literal S sweeps and the + pinned literal egress, preserving canonical order, original header, + common-grid width and all physical owners. The remaining C service must + be executable, not an unpriced mathematical transform. +2. Can shared private inventories reduce the 36-tape constructive wrapper + without invalidating historical backing or entry blankness? This is + optional economy, not a prerequisite for the fixed-tape result. +3. Can other source monomial recipes generate their active masks and + repetition grammar at a comparable literal interface? The linear S_D + phase here does not settle variable-dimensional quadratic recipes. diff --git a/research/literal-layer-phase/README.md b/research/literal-layer-phase/README.md new file mode 100644 index 0000000000..f372d2ebfd --- /dev/null +++ b/research/literal-layer-phase/README.md @@ -0,0 +1,118 @@ +# Generate the outer layer phase from its real encoded header + +This package implements the required `S_D` boundary in one fixed literal +20-tape program. It consumes the actual nine-Gamma layer header, generates +its selected-bit geometry, enumerates implicit `[P] x [2^K]^D x [S]` +addresses, repeats each phase over r Gaussian coefficients, and installs +the exact w-bit integer rotations on the original DATA owner. + +**No new kappa.** This is a local constructive interface result. All five +global assumptions and the selected conditional multiplication bound retain +their status. The recursive C service, common-grid conversion, owner +allocation, compiler/native admission, permutations and integer recovery +remain separate obligations. + +## Exact result + +The canonical base is `e54523517d0f03e58352e647c403a5af3e525a57`. +For positive header parameters, D<=d, 0<=rho=p+2, let + +``` +L=DK, Q=2^L, M=PQS, N=Mr, V=2Nw, E=header bit length. +``` + +The table has 2,146 instruction locations and alphabet `{blank,0,1,|}`. +There is no decoded runtime parameter, address oracle, input-sized lookup, +supplied active mask, or host payload arithmetic. Successful execution +preserves HEADER, restores all twenty heads, erases all eighteen private +bodies/guards, and returns `i^(sum selected bits)` times every coefficient +on the same public owner. If a required negation cannot fit, the complete +public input is unchanged; failure cleanup and recovery are unclaimed. + +The [proof](PROOF.md) establishes complete bounds + +``` +time <= 65536(E+p+d+DK+Nw+1) +private retained history <= K0+4V+32(E+p+d+DK+w+1). +``` + +All source access, parameter acquisition, copies, rewinds, staging, commit, +erasures and repetition loops are included. Unary r/P/S acquisition is paid +because each is at most N. Full binary carries and prefix returns cost +O(P*2^(DK)); there is no per-record DK scan. In the selected source bands +the complete time and added private backing are O(V). Entry blankness is a +whole-window premise, and erasure never resets physical history. + +## Relationship to prior work + +Ali Romman's [#5375](https://github.com/CrocSwap/integer-mult-bounds/pull/5375) +already supplies sequential monomial phases with a supplied active-position +mask, fixed recipe dimension and one coefficient per record. Its counter +amortization and Gaussian arithmetic retain full credit. The present result +constructs its geometry from the actual header, supports variable D on a +fixed tape inventory, supplies r/P/S repetition and lowers the complete +same-owner sweep to a fixed literal graph. + +CubeJerry's pinned [literal normalization/egress package](https://github.com/CubeJerry/integer-mult-bounds/tree/51ab0539059214fcfa044938c36a0b6017232be5/research/literal-layer-egress) +implements b^D and the single required toward-zero projection. It leaves +both S_D sweeps supplied; this package fills that boundary. Its literal +Gamma/trace/cleanup patterns are credited. No upstream PR number is assigned +to that remote contribution in these frozen notes. + +The phase table uses eighteen private roles, and the egress uses sixteen. +Two public tapes plus distinct private banks give a direct 36-tape wrapper. +The phase bank is retired and reused for the final sweep. A correctly bound +exact C producer and paid format conversion remain premises. The complete +known boundary work is O(V), with both histories retained. + +## Reproduction and evidence + +Standard-library Python, from the repository root: + +```sh +python -I -W error -B research/literal-layer-phase/verify.py +python -I -W error -O -B research/literal-layer-phase/verify.py +python -I -W error -B research/literal-layer-phase/compose.py +python -I -W error -O -B research/literal-layer-phase/compose.py +``` + +Expected markers are `PASS_LITERAL_LAYER_PHASE` and +`PASS_LITERAL_PHASE_EGRESS_JOIN`. `--write` regenerates the committed +receipts; default checks only print them. `VERIFY.json` registers the checks. + +The main check runs 319 packets containing 29,586 coefficients, including +52 geometries, all 256 signed three-bit pairs isolated at four phase values, +31 correct range rejections, five malformed/domain controls and seven +detected mutations of the actual emitted table. It checks translated origins, +opaque exterior, exact original-owner writes, and grow/shrink/regrow use of +the same private histories. Independent Cartesian-address and integer +oracles are in `oracles.py`; the runtime table never calls them. + +The separate join check executes literal S, a **test-only exact C oracle**, +the pinned literal egress and literal S again, using the original public +owner and 36 distinct tapes. Ten source disk-grid tensors, with 316 +coefficients, agree with a direct normalized Walsh tensor followed by one +toward-zero projection. This verifies the interfaces and preserves the +unimplemented-C obligation. It does not time the host oracle as machine work. + +Finite coverage supports the written universal proof; it does not replace +it. Two separate AI-assisted reviews accepted the scoped result: a dense +Gaussian/address interpreter and a universal/structural interpreter checking +the exact carry movement census. Their source, receipts and accepted hashes +are recorded in `REVIEW.md` and `independent/`. Hosted CI, human review and +formal proof-kernel acceptance remain separate. + +## Open next questions + +The next useful join is an executable C consumer with exact header, +canonical address order, common-grid output and complete physical cost. +Other questions are shared-bank economy under preserved histories and +header-generated geometry for more general quadratic monomial phases. +See the proof's final section for exact scope. + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance in +construction, proof, implementation, independent agent review and checking. +Credit Ali Romman / #5375; Jose Manuel / #2250; JoyboyBrian / #5329; Cinna +Davis and Ryanson Jonathan / #4325; the canonical layer/header authors; +and CubeJerry's frozen literal controller and egress packages. All retained +predecessor notices are preserved. Apache-2.0. diff --git a/research/literal-layer-phase/RESULT.json b/research/literal-layer-phase/RESULT.json new file mode 100644 index 0000000000..d03784e662 --- /dev/null +++ b/research/literal-layer-phase/RESULT.json @@ -0,0 +1,298 @@ +{ + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "carry_census": [ + { + "bit_changes": 2, + "length": 1, + "records": 2 + }, + { + "bit_changes": 6, + "length": 2, + "records": 4 + }, + { + "bit_changes": 14, + "length": 3, + "records": 8 + }, + { + "bit_changes": 30, + "length": 4, + "records": 16 + }, + { + "bit_changes": 62, + "length": 5, + "records": 32 + }, + { + "bit_changes": 126, + "length": 6, + "records": 64 + }, + { + "bit_changes": 254, + "length": 7, + "records": 128 + }, + { + "bit_changes": 510, + "length": 8, + "records": 256 + }, + { + "bit_changes": 1022, + "length": 9, + "records": 512 + }, + { + "bit_changes": 2046, + "length": 10, + "records": 1024 + }, + { + "bit_changes": 4094, + "length": 11, + "records": 2048 + }, + { + "bit_changes": 8190, + "length": 12, + "records": 4096 + }, + { + "bit_changes": 16382, + "length": 13, + "records": 8192 + }, + { + "bit_changes": 32766, + "length": 14, + "records": 16384 + }, + { + "bit_changes": 65534, + "length": 15, + "records": 32768 + }, + { + "bit_changes": 131070, + "length": 16, + "records": 65536 + } + ], + "coefficients": 29586, + "detected_semantic_mutations": [ + "inactive flips change phase", + "carry loses subtraction", + "mask producer omits active bit", + "coefficient repetition bypassed", + "signed minimum wraps silently", + "header return omitted", + "original owner return omitted" + ], + "exhaustive_numeric_cases": 256, + "geometry_cases": 52, + "invalid_controls": [ + { + "count": 4, + "label": "D exceeds d", + "outcome": "reject", + "parameters": [ + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 3 + ], + "steps": 379 + }, + { + "count": 4, + "label": "rho exceeds block", + "outcome": "reject", + "parameters": [ + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 3, + 3 + ], + "steps": 547 + }, + { + "count": 2, + "label": "insufficient final width", + "outcome": "reject", + "parameters": [ + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3 + ], + "steps": 404 + }, + { + "count": 2, + "label": "extra payload bit", + "outcome": "reject", + "parameters": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3 + ], + "steps": 871 + }, + { + "count": 2, + "label": "truncated payload", + "outcome": "reject", + "parameters": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3 + ], + "steps": 708 + } + ], + "limits": [ + "Universal correctness rests on the written proof, not finite coverage.", + "No recursive C, payload permutation, compiler admission or full multiplier.", + "No source acquisition cost or failure recovery is silently supplied." + ], + "maximum_transitions": 1750100, + "numerical_rejections": 31, + "private_roles": 18, + "program_instructions": 2146, + "program_sha256": "50505d6bd350224021d88d8e7e142a3188649a1d391c34ade732fced19336624", + "reuse_sequence": [ + { + "count": 512, + "history_bound": 23440, + "outcome": "success", + "parameters": [ + 2, + 3, + 2, + 3, + 2, + 2, + 2, + 2, + 4 + ], + "private_history": 13194, + "steps": 240966, + "time_bound": 136904704 + }, + { + "count": 2, + "history_bound": 13818, + "outcome": "success", + "parameters": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3 + ], + "private_history": 13194, + "steps": 1312, + "time_bound": 1376256 + }, + { + "count": 2, + "history_bound": 47226, + "outcome": "success", + "parameters": [ + 1, + 1025, + 1, + 1, + 1, + 1, + 1, + 1, + 3 + ], + "private_history": 14630, + "steps": 57008, + "time_bound": 69795840 + }, + { + "count": 384, + "history_bound": 31366, + "outcome": "success", + "parameters": [ + 2, + 2, + 3, + 2, + 1, + 2, + 3, + 2, + 5 + ], + "private_history": 14630, + "steps": 215659, + "time_bound": 128319488 + }, + { + "count": 2, + "history_bound": 15254, + "outcome": "success", + "parameters": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3 + ], + "private_history": 14630, + "steps": 1312, + "time_bound": 1376256 + } + ], + "runs": 319, + "seed": "0x53757350", + "source_pins": 8, + "source_sha256": "9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23", + "status": "PASS_LITERAL_LAYER_PHASE", + "tapes": 20, + "total_transitions": 15792872 +} diff --git a/research/literal-layer-phase/REVIEW.md b/research/literal-layer-phase/REVIEW.md new file mode 100644 index 0000000000..da88cb2177 --- /dev/null +++ b/research/literal-layer-phase/REVIEW.md @@ -0,0 +1,67 @@ +# Independent review disposition + +**Accepted within the scoped literal phase-sweep theorem.** Two separate +AI-assisted reviews checked complementary obligations. Neither constitutes +human acceptance or proof-kernel certification. No global foundational +assumption or multiplication-exponent improvement is claimed. + +The frozen scientific source SHA256 is +`9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23`. +The 2,146-location emitted table SHA256 is +`50505d6bd350224021d88d8e7e142a3188649a1d391c34ade732fced19336624`. +The accepted proof SHA256 is +`05581d135d43df6e7e9a1b9c2fd93b91a5ab1e10fc631a78ba7245c32c083aaf`. + +## Separate dense arithmetic review + +The lead research agent implemented a separate dense tape interpreter and +Cartesian-address integer oracle. It executed 24 packets, accepted 15, +covered 1,860 coefficients in its numerical/reuse fixtures and executed +1,828,138 transitions. Three mutations of the actual table were rejected. +Its checks include all four phase-specific signed-minimum cases, K/rho/P/S/r +variations, exact-cardinality failures, header-domain guards, original owner, +opaque exterior and stable private identities across growth and shrinkage. + +The unchanged checker and executed receipt are +`independent/dense_check.py` and `independent/DENSE-RESULT.json`. Run: + +```sh +python -I -W error -B research/literal-layer-phase/independent/dense_check.py research/literal-layer-phase/phase.py +``` + +## Separate universal and structural review + +The `compiler_exits` research agent independently read the full source, +instruction semantics and universal proof, then implemented another graph +interpreter concentrating on geometry, repetitions, ownership and costs. +It does not call the author's interpreter, arithmetic oracle or verifier. +The complete accepted review, unchanged script and original receipt are +preserved in `independent/peer/`. + +Its 15 successful runs cover 2,084 record entries and 2,175,819 transitions. +It derives and checks the exact per-tape COUNT/MASK move census +`4L+8+P(6Q-4)`, including initialization and retirement. Three mutations +were detected, including a functionally correct full-width carry-return +scan that violates the claimed amortized accounting. + +One wording correction was requested and incorporated: a per-role maximum +extent describes repeated calls at fixed origins; changing origins retain +absolute history unions and separately paid head transport. Scientific code +was unchanged. Read [the full independent review](independent/peer/REVIEW.md). + +The small launcher below changes only the unchanged review script's package +path, preserving its exact source hash and proof checks: + +```sh +python -I -W error -B research/literal-layer-phase/independent/peer/replay.py research/literal-layer-phase +``` + +## Author checks and retained limits + +The author normal and optimized receipts agree exactly for 319 main packets +and ten literal wrapper joins. All executed commands and durations are in +VALIDATION.json. The join's exact C oracle remains explicitly test-only. +Independent review accepts the stated finite-symbol service and cost/history +proof, with complete packet, ownership and source-format premises. Failure +cleanup, actual C implementation, allocation, compiler/native admission, +arbitrary affine routing and a complete multiplication theorem remain open. diff --git a/research/literal-layer-phase/SOURCES.json b/research/literal-layer-phase/SOURCES.json new file mode 100644 index 0000000000..fd183f97dd --- /dev/null +++ b/research/literal-layer-phase/SOURCES.json @@ -0,0 +1,77 @@ +{ + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "local": "reference/05-layers.tex", + "path": "upstream/build/sections/05-layers.tex", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "blob": "5ce8b3c83c455f221bb84858a97230b0285644aa", + "repository": "CrocSwap/integer-mult-bounds", + "bytes": 46811, + "sha256": "20cfc8d12099d4e4ed9e3e7eeb6162edd9b6e0e076f24693364cd24377252594" + }, + { + "local": "reference/02-streams.tex", + "path": "upstream/build/sections/02-streams.tex", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "blob": "088fceea1867abc76271d7efe7532b779fee9039", + "repository": "CrocSwap/integer-mult-bounds", + "bytes": 11311, + "sha256": "606c80db61cad13aa0c3b6060dc4b88dbbe7ac60cdd831aa93f28d908fd09dab" + }, + { + "local": "reference/selected-result.json", + "path": "certificates/selected-result.json", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "repository": "CrocSwap/integer-mult-bounds", + "bytes": 4803, + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "local": "inputs/controller_reference.py", + "path": "research/selected-rank-control/controller_reference.py", + "commit": "9dfe6747b8553fd11b408f2b045c5954ef1e6eaa", + "blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72", + "repository": "CubeJerry/integer-mult-bounds", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "local": "reference/selected-application.md", + "path": "docs/research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "repository": "CrocSwap/integer-mult-bounds", + "blob": "3dd1af2285e597676725e85ad4f65e7ad326d695", + "bytes": 25533, + "sha256": "4501502c2ceb9759b20372435fe4beb51082c5a5e2910c1fd5dbe6edca415055" + }, + { + "local": "reference/sequential-monomial-proof.md", + "path": "research/sequential-monomial-phase/PROOF.md", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "blob": "42ffd4007c1416eb4a45e47d181194d3e87742bb", + "repository": "CrocSwap/integer-mult-bounds", + "bytes": 8719, + "sha256": "aed63dc425a410627a290b2e0251b27bc1befce85614cefbb8a82f199a1d2764" + }, + { + "local": "reference/sequential-monomial-phase.py", + "path": "research/sequential-monomial-phase/phase.py", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "blob": "26126045289a3dceeb8d096c984d536613e5345f", + "repository": "CrocSwap/integer-mult-bounds", + "bytes": 5710, + "sha256": "256aa42f38e496bf91347078d8e2c731ee35b03fc0528f536a946f215f79fcd7" + }, + { + "local": "reference/literal-egress-patterns.py", + "path": "research/literal-layer-egress/egress.py", + "commit": "51ab0539059214fcfa044938c36a0b6017232be5", + "repository": "CubeJerry/integer-mult-bounds", + "blob": "2b69954884f1c4d5bc77b8a234d3538e521b605b", + "bytes": 13230, + "sha256": "5875981b27bbb131a1e13ffca7f7eb920aa85b90699e6d40a85bd3902ff073e7" + } + ] +} diff --git a/research/literal-layer-phase/TASK.json b/research/literal-layer-phase/TASK.json new file mode 100644 index 0000000000..e04f85e4e8 --- /dev/null +++ b/research/literal-layer-phase/TASK.json @@ -0,0 +1,38 @@ +{ + "task": "header-derived-literal-layer-phase", + "wave": 2, + "tracks": [ + 20, + 85 + ], + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "worker": "crt_reusable_history", + "status": "verified; accepted independent dense and universal reviews; ready for orchestrator publication", + "worktree": "/workspace/scratch/be42ab5b7196/worker-c2", + "branch": "research/literal-layer-phase-be42-wave2", + "started_utc": "2026-11-12T02:15:05.362943+00:00", + "claim": "One fixed literal table consumes the actual nine-Gamma layer header, builds its active-bit mask and implicit address counter, applies i^(sum selected bits) to every actual w-bit Gaussian coefficient on the same owner, and restores header/private heads and contents on success.", + "budget": "O(E+p+d+DK+Mrw) time; unary r,P,S acquisition <=O(Mr); fixed tape count; all histories retained. O(V) in selected source bands.", + "method": "Header-generated mask, flattened binary counter with four-state incremental phase, unary r/S/P repetitions, whole-output staging, paid original-owner commit.", + "exclusions": [ + "No C layer, address permutation, compiler/native admission, global proof-assumption removal or new kappa.", + "No host decoded runtime parameter, address oracle, mask oracle or input-sized phase lookup.", + "No cleanup after invalid inputs or resource faults." + ], + "stopping_rule": "Stop if the complete source budget fails, a matching header-derived fixed program is found, or finite-control lowering cannot be completed. One scoped pivot allowed.", + "next_action": "Commit the scoped package; orchestrator verifies the fork branch and prepares an upstream compare URL. Begin separately assigned Wave3 only after this freeze.", + "science_sha256": "9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23", + "table_sha256": "50505d6bd350224021d88d8e7e142a3188649a1d391c34ade732fced19336624", + "updated_utc": "2026-11-12T02:54:16.978814+00:00", + "verified_findings": [ + "One fixed 2146-location table derives the exact outer phase and full packet count from the actual header.", + "319 packets, 52 geometries, signed minima, cardinality failures, seven table mutations and history reuse pass.", + "Both literal phase sweeps join the pinned B1 egress around an explicitly test-only exact C oracle in ten full disk-grid tensors.", + "Root independently reimplemented a dense interpreter and Cartesian oracle; 24 packets and three table mutations pass." + ], + "independent_reviews": [ + "independent/DENSE-RESULT.json", + "independent/peer/REVIEW.md", + "independent/peer/RESULT.json" + ] +} diff --git a/research/literal-layer-phase/VALIDATION.json b/research/literal-layer-phase/VALIDATION.json new file mode 100644 index 0000000000..9c226c628c --- /dev/null +++ b/research/literal-layer-phase/VALIDATION.json @@ -0,0 +1,91 @@ +{ + "python": "3.12.14 (main, Aug 25 2026, 14:00:49) [Clang 22.1.3 ]", + "checks": [ + { + "command": [ + "/opt/codex/runtimes/codex-primary-runtime/dependencies/python/bin/python", + "-I", + "-W", + "error", + "-B", + "research/literal-layer-phase/verify.py", + "--write" + ], + "status": "PASS_LITERAL_LAYER_PHASE", + "seconds": 17.636, + "stdout_sha256": "eef3f49e82019279093ad7f90d6f6142e7a460c571596ce38bdae61a8e6c74eb" + }, + { + "command": [ + "/opt/codex/runtimes/codex-primary-runtime/dependencies/python/bin/python", + "-I", + "-W", + "error", + "-O", + "-B", + "research/literal-layer-phase/verify.py" + ], + "status": "PASS_LITERAL_LAYER_PHASE", + "seconds": 17.631, + "stdout_sha256": "eef3f49e82019279093ad7f90d6f6142e7a460c571596ce38bdae61a8e6c74eb" + }, + { + "command": [ + "/opt/codex/runtimes/codex-primary-runtime/dependencies/python/bin/python", + "-I", + "-W", + "error", + "-B", + "research/literal-layer-phase/compose.py", + "--write" + ], + "status": "PASS_LITERAL_PHASE_EGRESS_JOIN", + "seconds": 0.857, + "stdout_sha256": "76e3ee15e922ce6eb3468b56c49c0d3a665524a78ec002cf8bfe8369b1cf7481" + }, + { + "command": [ + "/opt/codex/runtimes/codex-primary-runtime/dependencies/python/bin/python", + "-I", + "-W", + "error", + "-O", + "-B", + "research/literal-layer-phase/compose.py" + ], + "status": "PASS_LITERAL_PHASE_EGRESS_JOIN", + "seconds": 1.3, + "stdout_sha256": "76e3ee15e922ce6eb3468b56c49c0d3a665524a78ec002cf8bfe8369b1cf7481" + }, + { + "command": [ + "/opt/codex/runtimes/codex-primary-runtime/dependencies/python/bin/python", + "-I", + "-W", + "error", + "-B", + "research/literal-layer-phase/independent/dense_check.py", + "research/literal-layer-phase/phase.py" + ], + "status": "PASS_INDEPENDENT_DENSE_PHASE", + "seconds": 0.99, + "stdout_sha256": "b1566bb3b827cdd133fe9452324da83830bf1757755dacdce1fcf54de18a5908" + }, + { + "command": [ + "/opt/codex/runtimes/codex-primary-runtime/dependencies/python/bin/python", + "-I", + "-W", + "error", + "-B", + "research/literal-layer-phase/independent/peer/replay.py", + "research/literal-layer-phase" + ], + "status": "PASS_INDEPENDENT_PHASE_STRUCTURE_REVIEW", + "seconds": 2.296, + "stdout_sha256": "36dbbba5ab8520692f227b27da18cf5cd96aa74874e0b54087debaefa4a45199", + "receipt_matches": "independent/peer/RESULT.json" + } + ], + "independent_review": "accepted: root dense arithmetic review plus separate universal/structural/cost/history review" +} diff --git a/research/literal-layer-phase/VERIFY.json b/research/literal-layer-phase/VERIFY.json new file mode 100644 index 0000000000..15893f2523 --- /dev/null +++ b/research/literal-layer-phase/VERIFY.json @@ -0,0 +1,85 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Actual fixed table, exact Cartesian arithmetic, all source pins, 319 packets, 7 semantic mutants and retained histories" + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Actual fixed table, exact Cartesian arithmetic, all source pins, 319 packets, 7 semantic mutants and retained histories under optimized Python" + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/compose.py" + ], + "timeout_seconds": 60, + "checks": "Two literal S sweeps and pinned literal egress around an explicitly supplied exact C oracle; 10 full source tensors" + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-O", + "-B", + "{package}/compose.py" + ], + "timeout_seconds": 60, + "checks": "Two literal S sweeps and pinned literal egress around an explicitly supplied exact C oracle; 10 full source tensors under optimized Python" + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/independent/dense_check.py", + "{package}/phase.py" + ], + "timeout_seconds": 60, + "checks": "Root independent dense interpreter and Cartesian-address integer oracle: 24 packets, three semantic mutations, same-history reuse." + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/independent/peer/replay.py", + "{package}" + ], + "timeout_seconds": 60, + "checks": "Unchanged independent graph interpreter with relocated package path; exact counter movement census, history, ownership and three controls including a functionally correct unpriced full scan." + } + ] +} diff --git a/research/literal-layer-phase/compose.py b/research/literal-layer-phase/compose.py new file mode 100644 index 0000000000..273303786f --- /dev/null +++ b/research/literal-layer-phase/compose.py @@ -0,0 +1,153 @@ +"""Finite wrapper join: literal S, exact test oracle C, literal egress, literal S. + +This supplies no executable C consumer. The oracle and its common-grid source +preparation are explicit outside services, not part of a physical time claim. +""" +from pathlib import Path +import hashlib +import json +import random +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import phase as P +import oracles as O +from verify import need, run_case, extents + + +def egress_table(): + reference = HERE/'reference/literal-egress-patterns.py' + source = reference.read_bytes() + need(hashlib.sha256(source).hexdigest() == + '5875981b27bbb131a1e13ffca7f7eb920aa85b90699e6d40a85bd3902ff073e7', 'pinned egress source') + # Relocate only the compile-time package directory to the shared exact + # machine export. The unchanged source must emit its exact pinned table. + namespace = {'__file__': str(HERE/'phase.py'), '__name__': 'pinned_egress_reference'} + exec(compile(source, str(reference), 'exec'), namespace) + code, _ = namespace['compile_egress']() + digest = hashlib.sha256(json.dumps(code, separators=(',', ':'), sort_keys=True).encode()).hexdigest() + need(digest == 'd3021bc0d7b378741e64ae768171f5aec1f289b15265f4463e7b91b887f11243', 'pinned egress graph') + return code + + +def gaussian_multiply(a, b): + return a[0]*b[0]-a[1]*b[1], a[0]*b[1]+a[1]*b[0] + + +def exact_tensor(values, parameters, kind): + """Direct small Cartesian sum, unrelated to the literal odometer.""" + _, global_d, r, dimension, outer, spectator, block, rho1, _ = parameters + Q = 1 << (dimension*block) + positions = [j*block+rho1-1 for j in range(dimension)] + active_mask = sum(1 << j for j in positions) + out = [] + for a in range(outer): + for destination in range(Q): + base = destination & ~active_mask + for s in range(spectator): + for coefficient in range(r): + total_real = total_imag = 0 + for source in range(1 << dimension): + address = base + kernel = (1, 0) + sign = 1 + for j, position in enumerate(positions): + x, y = (source >> j) & 1, (destination >> position) & 1 + address |= x << position + kernel = gaussian_multiply(kernel, (1, 1 if x == y else -1)) + sign *= -1 if x and y else 1 + index = ((a*Q+address)*spectator+s)*r+coefficient + real, imag = values[index] + if kind == 'C': + real, imag = gaussian_multiply(kernel, (real, imag)) + else: + real, imag = sign*real, sign*imag + total_real += real + total_imag += imag + if kind == 'C': + factor = 1 << (global_d-dimension) + out.append((factor*total_real, factor*total_imag)) + else: + def toward_zero(value): + q = abs(value)//(1 << dimension) + return -q if value < 0 else q + out.append((toward_zero(total_real), toward_zero(total_imag))) + return out + + +def run_join(parameters, source, phase_code, egress_code): + p, d, _, _, _, _, _, _, w = parameters + H = p+2*d+4 + N = O.cardinality(parameters) + V, guarded = 2*N*w, 2*N*H + first, tapes = run_case(phase_code, parameters, source, public_reserve=guarded) + starts = [t.head for t in tapes] + initial_private = [dict(t.cells) for t in tapes[2:]] + header_before = dict(tapes[P.HEADER].cells) + data = tapes[P.DATA] + actual_first = O.decode(''.join(data.cells[data.origin+j] for j in range(V)), w) + supplied_C = exact_tensor(actual_first, parameters, 'C') + need(O.fits(supplied_C, H), 'common-grid producer range') + # Explicit supplied C plus format pass, in the pre-reserved same-owner + # window. This host computation is NOT claimed as a literal C implementation. + data.cells = {k: v for k, v in data.cells.items() + if k < data.origin or k > data.origin+guarded} + data.cells.update({data.origin+j: b for j, b in enumerate(O.encode(supplied_C, H))}) + data.begin(data.origin, guarded, public=True) + tapes[P.HEADER].begin(starts[P.HEADER], len(O.header(parameters)), public=True) + egress_tapes = [tapes[P.HEADER], data] + for i in range(16): + origin = 370+13*i + egress_tapes.append(P.Tape({origin-2: '1'}, origin)) + egress_heads = [t.head for t in egress_tapes] + egress_private = [dict(t.cells) for t in egress_tapes[2:]] + need(len({id(t) for t in tapes+egress_tapes[2:]}) == 36, 'distinct fixed inventories') + machine = P.Machine(egress_code, egress_tapes) + machine.run(65536*(len(O.header(parameters))+p+d+parameters[3]+w+N*(H+w+1)+1)) + need(all(t.head == h for t, h in zip(egress_tapes, egress_heads)), 'egress head return') + need([dict(t.cells) for t in egress_tapes[2:]] == egress_private, 'egress private return') + need(all(data.cells.get(data.origin+j, P.BLANK) == P.BLANK for j in range(V, guarded+1)), + 'egress old common-grid tail cleanup') + for i, t in enumerate(tapes): + t.begin(starts[i], extents(parameters)[i], public=i<2) + final = P.Machine(phase_code, tapes) + final.run(65536*(len(O.header(parameters))+p+d+parameters[3]*parameters[6]+N*w+1)) + actual = O.decode(''.join(data.cells[data.origin+j] for j in range(V)), w) + expected = exact_tensor(source, parameters, 'H0') + need(actual == expected, 'literal wrappers versus direct normalized Walsh tensor') + need(tapes[P.HEADER].cells == header_before, 'composition header preservation') + need(all(t.head == h for t, h in zip(tapes, starts)), 'final phase head return') + need([dict(t.cells) for t in tapes[2:]] == initial_private, 'same phase inventory retired twice') + need(data.cells.get(data.origin+guarded+1) == '1' and + data.cells.get(data.origin+guarded+2) == '|', 'parent-reservation exterior') + return dict(parameters=parameters, coefficients=N, + initial_phase_steps=first['steps'], egress_steps=machine.steps, + final_phase_steps=final.steps, physical_tapes=36) + + +def main(): + phase_code, _ = P.compile_phase() + egress_code = egress_table() + rng = random.Random(0x7350) + rows = [] + parameters_list = [(p, D+p % 2, 1, D, 1, 1, 1, 1, p+2) + for p in (1, 2) for D in range(1, 5)] + parameters_list += [(2, 3, 2, 2, 2, 2, 2, rho+1, 4) for rho in (0, 1)] + for parameters in parameters_list: + radius = 1 << parameters[0] + disk = [(a, c) for a in range(-radius, radius+1) for c in range(-radius, radius+1) + if a*a+c*c <= radius*radius] + source = [rng.choice(disk) for _ in range(O.cardinality(parameters))] + rows.append(run_join(parameters, source, phase_code, egress_code)) + receipt = dict(status='PASS_LITERAL_PHASE_EGRESS_JOIN', cases=len(rows), + coefficients=sum(r['coefficients'] for r in rows), rows=rows, + limitations=['Exact C and its common-grid format preparation are test oracles, not implementations.', + 'Only the two phase tables and pinned egress execute as literal programs.']) + if '--write' in sys.argv: + (HERE/'JOIN-RESULT.json').write_text(json.dumps(receipt, indent=2, sort_keys=True)+'\n') + print(json.dumps(receipt, sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/literal-layer-phase/independent/DENSE-RESULT.json b/research/literal-layer-phase/independent/DENSE-RESULT.json new file mode 100644 index 0000000000..ca409a8a10 --- /dev/null +++ b/research/literal-layer-phase/independent/DENSE-RESULT.json @@ -0,0 +1,14 @@ +{ + "accepted": 15, + "cases": 24, + "coefficients": 1860, + "controls": [ + "mask", + "commit", + "cleanup" + ], + "locations": 2146, + "phase_sha256": "9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23", + "status": "PASS_INDEPENDENT_DENSE_PHASE", + "transitions": 1828138 +} diff --git a/research/literal-layer-phase/independent/SOURCE-BINDINGS.json b/research/literal-layer-phase/independent/SOURCE-BINDINGS.json new file mode 100644 index 0000000000..bfb0afe842 --- /dev/null +++ b/research/literal-layer-phase/independent/SOURCE-BINDINGS.json @@ -0,0 +1,71 @@ +{ + "status": "PASS", + "package": "literal-layer-phase", + "method": "Exact git commit:path bytes; recomputed SHA256 and Git blob; frozen copies compared", + "rows": [ + { + "path": "upstream/build/sections/05-layers.tex", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bytes": 46811, + "sha256": "20cfc8d12099d4e4ed9e3e7eeb6162edd9b6e0e076f24693364cd24377252594", + "git_blob": "5ce8b3c83c455f221bb84858a97230b0285644aa", + "pass": true + }, + { + "path": "upstream/build/sections/02-streams.tex", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bytes": 11311, + "sha256": "606c80db61cad13aa0c3b6060dc4b88dbbe7ac60cdd831aa93f28d908fd09dab", + "git_blob": "088fceea1867abc76271d7efe7532b779fee9039", + "pass": true + }, + { + "path": "certificates/selected-result.json", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bytes": 4803, + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "pass": true + }, + { + "path": "research/selected-rank-control/controller_reference.py", + "commit": "9dfe6747b8553fd11b408f2b045c5954ef1e6eaa", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "git_blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72", + "pass": true + }, + { + "path": "docs/research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bytes": 25533, + "sha256": "4501502c2ceb9759b20372435fe4beb51082c5a5e2910c1fd5dbe6edca415055", + "git_blob": "3dd1af2285e597676725e85ad4f65e7ad326d695", + "pass": true + }, + { + "path": "research/sequential-monomial-phase/PROOF.md", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bytes": 8719, + "sha256": "aed63dc425a410627a290b2e0251b27bc1befce85614cefbb8a82f199a1d2764", + "git_blob": "42ffd4007c1416eb4a45e47d181194d3e87742bb", + "pass": true + }, + { + "path": "research/sequential-monomial-phase/phase.py", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bytes": 5710, + "sha256": "256aa42f38e496bf91347078d8e2c731ee35b03fc0528f536a946f215f79fcd7", + "git_blob": "26126045289a3dceeb8d096c984d536613e5345f", + "pass": true + }, + { + "path": "research/literal-layer-egress/egress.py", + "commit": "51ab0539059214fcfa044938c36a0b6017232be5", + "bytes": 13230, + "sha256": "5875981b27bbb131a1e13ffca7f7eb920aa85b90699e6d40a85bd3902ff073e7", + "git_blob": "2b69954884f1c4d5bc77b8a234d3538e521b605b", + "pass": true + } + ] +} diff --git a/research/literal-layer-phase/independent/dense_check.py b/research/literal-layer-phase/independent/dense_check.py new file mode 100644 index 0000000000..bc3d0a3082 --- /dev/null +++ b/research/literal-layer-phase/independent/dense_check.py @@ -0,0 +1,127 @@ +"""Independent dense CPU and Cartesian phase oracle; Apache-2.0. +Prepared for CubeJerry with OpenAI assistance. No author CPU/tests execute. +""" +from pathlib import Path +from itertools import product +import hashlib,importlib.util,json,sys +class Rejected(Exception):pass + +def load(path): + spec=importlib.util.spec_from_file_location('phase_subject',path) + m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);return m + +def gamma(n): + s=format(n,'b');return '0'*(len(s)-1)+s + +def bits(n,w): + if not -(1<<(w-1))<=n<(1<<(w-1)):raise OverflowError('signed range') + return format(n%(1<>rho)&1 for c in chunks)%4 + for suffix in range(S):phases.extend([q]*r) + return params,phases,[((j*17)%61-30,(j*29)%59-29) for j in range(len(phases))] + +def expected_bits(phases,pairs,w): + output='' + for q,(x,y) in zip(phases,pairs): + for _ in range(q):x,y=-y,x + output+=bits(x,w)+bits(y,w) + return output + +def exercise(code,params,phases,pairs,alter=None,cpu=None): + w=params[-1];header=''.join(gamma(x) for x in params);data=''.join(bits(x,w)+bits(y,w) for x,y in pairs) + try:expected=expected_bits(phases,pairs,w) + except OverflowError:expected=None + if alter=='extra':data+='1';expected=None + if alter=='short':data=data[:-1];expected=None + if alter=='bad_domain':expected=None + if cpu is None:cpu=CPU(header,data) + else:cpu.supply(header,data) + start=cpu.steps + try:cpu.run(code) + except Rejected: + if expected is not None:raise AssertionError('unexpected literal rejection') + if cpu.rows[0]!=cpu.before[0] or cpu.rows[1]!=cpu.before[1]:raise AssertionError('public mutation before rejection') + return cpu,cpu.steps-start,False + if expected is None:raise AssertionError('missed rejection') + cpu.check(expected);return cpu,cpu.steps-start,True + +def main(): + path=Path(sys.argv[1]).resolve();m=load(path);code,alphabet=m.compile_phase() + if set(alphabet)!=set('_01|'):raise AssertionError('alphabet') + cases=steps=accepted=coefficients=0 + shapes=[(1,1,0),(2,2,0),(2,2,1),(3,2,1),(2,3,2),(4,1,0),(1,5,3),(3,1,0)] + for j,(D,K,rho) in enumerate(shapes): + params,phases,pairs=fixture(D,K,rho,1+j%2,1+(j//2)%2,1+j%3) + _,n,ok=exercise(code,params,phases,pairs);steps+=n;cases+=1;accepted+=ok;coefficients+=len(pairs) + params,phases,baseline=fixture(3,1,0,1,1,1,w=3,p=1) + for q in range(4): + position=phases.index(q) + for component in (0,1): + pairs=[(0,0)]*len(phases);pair=[0,0];pair[component]=-4;pairs[position]=tuple(pair) + _,n,ok=exercise(code,params,phases,pairs);steps+=n;cases+=1;accepted+=ok;coefficients+=len(pairs) + params,phases,pairs=fixture(2,2,1,2,3,2) + for alteration in ('extra','short'): + _,n,ok=exercise(code,params,phases,pairs,alteration);steps+=n;cases+=1;accepted+=ok + for index,value in ((1,1),(7,3),(8,5)): + invalid=list(params);invalid[index]=value + _,n,ok=exercise(code,tuple(invalid),phases,[(0,0)]*len(phases),'bad_domain');steps+=n;cases+=1;accepted+=ok + cpu=None;identities=None + for shape in [(3,2,1,2,2,3),(1,1,0,1,1,1),(3,2,0,1,2,2)]: + params,phases,pairs=fixture(*shape) + if cpu is None:cpu=CPU('', '',capacity=50000);identities=tuple(map(id,cpu.rows)) + cpu,n,ok=exercise(code,params,phases,pairs,cpu=cpu);steps+=n;cases+=1;accepted+=ok;coefficients+=len(pairs) + if tuple(map(id,cpu.rows))!=identities:raise AssertionError('backing replaced') + controls=[] + for name,tape,old,new in [('mask',m.MASK,'1','0'),('commit',m.DATA,'0','1'),('cleanup',m.OUTPUT,'_','1')]: + mutant=[('write',tape,new) if ins==('write',tape,old) else ins for ins in code] + if mutant==code:raise AssertionError('empty mutation') + params,phases,pairs=fixture(3,1,0,1,2,2) + try:exercise(mutant,params,phases,pairs) + except (AssertionError,Rejected):controls.append(name) + else:raise AssertionError('undetected '+name) + print(json.dumps({'status':'PASS_INDEPENDENT_DENSE_PHASE','cases':cases,'accepted':accepted,'coefficients':coefficients,'transitions':steps,'locations':len(code),'controls':controls,'phase_sha256':hashlib.sha256(path.read_bytes()).hexdigest()},sort_keys=True)) +if __name__=='__main__':main() diff --git a/research/literal-layer-phase/independent/peer/RESULT.json b/research/literal-layer-phase/independent/peer/RESULT.json new file mode 100644 index 0000000000..1ebb6db45f --- /dev/null +++ b/research/literal-layer-phase/independent/peer/RESULT.json @@ -0,0 +1,389 @@ +{ + "alphabet": [ + "_", + "0", + "1", + "|" + ], + "cases": [ + { + "budget_base": 21, + "counter_moves": 20, + "flips": 2, + "history_after": 121, + "history_before": 92, + "parameters": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 3 + ], + "payload_bits": 12, + "records": 2, + "steps": 1312 + }, + { + "budget_base": 1192, + "counter_moves": 208, + "flips": 60, + "history_after": 4735, + "history_before": 92, + "parameters": [ + 2, + 4, + 3, + 2, + 2, + 3, + 2, + 0, + 4 + ], + "payload_bits": 2304, + "records": 96, + "steps": 131952 + }, + { + "budget_base": 3887, + "counter_moves": 1172, + "flips": 378, + "history_after": 15499, + "history_before": 92, + "parameters": [ + 3, + 6, + 2, + 3, + 3, + 2, + 2, + 1, + 5 + ], + "payload_bits": 7680, + "records": 384, + "steps": 441300 + }, + { + "budget_base": 127, + "counter_moves": 208, + "flips": 60, + "history_after": 501, + "history_before": 92, + "parameters": [ + 1, + 4, + 1, + 4, + 2, + 1, + 1, + 0, + 3 + ], + "payload_bits": 192, + "records": 32, + "steps": 13941 + }, + { + "budget_base": 805, + "counter_moves": 208, + "flips": 60, + "history_after": 3196, + "history_before": 92, + "parameters": [ + 2, + 1, + 3, + 1, + 2, + 2, + 4, + 3, + 4 + ], + "payload_bits": 1536, + "records": 64, + "steps": 85762 + }, + { + "budget_base": 1064, + "counter_moves": 800, + "flips": 254, + "history_after": 4229, + "history_before": 92, + "parameters": [ + 2, + 3, + 1, + 1, + 1, + 2, + 7, + 6, + 4 + ], + "payload_bits": 2048, + "records": 256, + "steps": 118795 + }, + { + "budget_base": 5159, + "counter_moves": 3112, + "flips": 1022, + "history_after": 20613, + "history_before": 92, + "parameters": [ + 3, + 3, + 2, + 3, + 1, + 1, + 3, + 0, + 5 + ], + "payload_bits": 10240, + "records": 512, + "steps": 596560 + }, + { + "budget_base": 143, + "counter_moves": 52, + "flips": 10, + "history_after": 587, + "history_before": 92, + "parameters": [ + 1, + 1, + 1, + 1, + 5, + 4, + 1, + 0, + 3 + ], + "payload_bits": 240, + "records": 40, + "steps": 14930 + }, + { + "budget_base": 1478, + "counter_moves": 116, + "flips": 30, + "history_after": 5894, + "history_before": 92, + "parameters": [ + 2, + 2, + 5, + 2, + 1, + 3, + 2, + 1, + 6 + ], + "payload_bits": 2880, + "records": 48, + "steps": 159084 + }, + { + "budget_base": 160, + "counter_moves": 36, + "flips": 6, + "history_after": 536, + "history_before": 92, + "parameters": [ + 17, + 29, + 1, + 2, + 1, + 1, + 1, + 0, + 19 + ], + "payload_bits": 152, + "records": 4, + "steps": 12602 + }, + { + "budget_base": 293, + "counter_moves": 20, + "flips": 2, + "history_after": 649, + "history_before": 92, + "parameters": [ + 1, + 257, + 1, + 1, + 1, + 1, + 1, + 0, + 3 + ], + "payload_bits": 12, + "records": 2, + "steps": 15450 + }, + { + "budget_base": 209, + "counter_moves": 20, + "flips": 2, + "history_after": 905, + "history_before": 92, + "parameters": [ + 1, + 1, + 31, + 1, + 1, + 1, + 1, + 0, + 3 + ], + "payload_bits": 372, + "records": 2, + "steps": 22724 + } + ], + "functionally_correct_full_scan_mutant": { + "budget_base": 221, + "counter_moves": 344, + "flips": 60, + "history_after": 881, + "history_before": 92, + "parameters": [ + 1, + 2, + 1, + 2, + 2, + 2, + 2, + 0, + 3 + ], + "payload_bits": 384, + "records": 64, + "steps": 25539 + }, + "instruction_locations": 2146, + "mutations": [ + { + "diagnostic": "generated mask", + "mutation": "wrong generated mask" + }, + { + "diagnostic": "private body or guard not retired", + "mutation": "missing counter retirement" + }, + { + "diagnostic": "exact carry/return move census", + "mutation": "unpriced full-width carry return" + } + ], + "opcodes": { + "goto": 398, + "halt": 1, + "move": 1030, + "read": 349, + "write": 368 + }, + "program_sha256": "50505d6bd350224021d88d8e7e142a3188649a1d391c34ade732fced19336624", + "proof_sha256": "05581d135d43df6e7e9a1b9c2fd93b91a5ab1e10fc631a78ba7245c32c083aaf", + "record_entries": 2084, + "rejection_checks": [ + { + "rejected": true, + "steps": 76416 + }, + { + "rejected": true, + "steps": 76141 + } + ], + "reuse": [ + { + "budget_base": 3887, + "counter_moves": 1172, + "flips": 378, + "history_after": 15499, + "history_before": 92, + "parameters": [ + 3, + 6, + 2, + 3, + 3, + 2, + 2, + 1, + 5 + ], + "payload_bits": 7680, + "records": 384, + "steps": 441300 + }, + { + "budget_base": 21, + "counter_moves": 20, + "flips": 2, + "history_after": 15499, + "history_before": 15499, + "parameters": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 3 + ], + "payload_bits": 12, + "records": 2, + "steps": 1312 + }, + { + "budget_base": 1064, + "counter_moves": 800, + "flips": 254, + "history_after": 15505, + "history_before": 15499, + "parameters": [ + 2, + 3, + 1, + 1, + 1, + 2, + 7, + 6, + 4 + ], + "payload_bits": 2048, + "records": 256, + "steps": 118795 + } + ], + "reviewer_script_sha256": "9f0a1230039ee5d72a306c31884768d0670bff70bfb0a6d5ff89460a60bc4031", + "scope": "Independent interpreter and structural/cost/history evidence; root separately verifies Gaussian arithmetic.", + "source_sha256": "9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23", + "status": "PASS_INDEPENDENT_PHASE_STRUCTURE_REVIEW", + "successful_runs": 15, + "successful_steps": 2175819 +} diff --git a/research/literal-layer-phase/independent/peer/REVIEW.md b/research/literal-layer-phase/independent/peer/REVIEW.md new file mode 100644 index 0000000000..cd14e77bad --- /dev/null +++ b/research/literal-layer-phase/independent/peer/REVIEW.md @@ -0,0 +1,184 @@ +# Independent review of the header-derived literal phase sweep + +**Decision: accept the scoped literal phase-sweep theorem.** No change to +the frozen scientific program was required. One historical-space wording +ambiguity was identified and corrected in the proof: a sum of maximum +reached extents per role applies to repeated calls at fixed origins; +arbitrary changing origins require the union of absolute visited windows +and separately paid caller head transport. The reviewed proof contains +that distinction. + +This review is additional OpenAI-assisted evidence. It is neither human +acceptance nor proof-kernel certification. It supplies no tensor-C service, +native arbitrary-column admission, source allocator, failure cleanup, +general phase provider, complete multiplier, or new kappa. + +## Reviewed bytes and method + +- `phase.py`: `9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23`. +- Generated table: 2,146 instruction locations, SHA256 + `50505d6bd350224021d88d8e7e142a3188649a1d391c34ade732fced19336624`. +- Corrected `PROOF.md`: `05581d135d43df6e7e9a1b9c2fd93b91a5ab1e10fc631a78ba7245c32c083aaf`. +- Canonical dependency base: `e54523517d0f03e58352e647c403a5af3e525a57`. + +I inspected the entire generator, the frozen elementary instruction +semantics, and the complete universal proof. The accompanying `check.py` +executes the generated graph in a separately written interpreter. It does +not call the author's `Machine`, `Tape`, arithmetic oracle, or verifier. +The frozen Builder only supplies the table under review; every transition +thereafter is independently interpreted as a local read, one-cell write, +unit move, fixed jump or halt. Static checks reject variable tape selectors, +nonunit moves, unknown opcodes and nonliteral branches. All verification +observations are outside the measured program and never choose its steps. + +The lead's independently constructed dense Gaussian/address oracle is +complementary evidence and is not claimed as this review's execution. +This review deliberately uses zero payloads to isolate geometry, repetitions, +phase-state invariants, costs, public-owner installation and retained history. +Signed Gaussian correctness was also checked directly from the finite cases +in the source, as explained below. + +## Universal control and geometry argument + +The nine Gamma decoders operate on the supplied header, including r,P,S. +Each following binary digit replaces unary v by unary 2v+b through explicit +copy, erase and return loops. The old prefix values sum to less than the +final value. Decoding therefore costs linear work in the decoded values +plus encoded header length, without a hidden binary-to-unary constant-time +step. On admitted complete packets, r,P,S are each at most N, while D,K and +rho+1 are at most L=DK. The p,d terms remain explicit until the source-band +specialization. HEADER is never written; its movement is exactly 2E. + +For each chunk, SELECT reaches its blank immediately after rho+1 unary +symbols, writes the unique active mask bit, and stops affecting subsequent +positions. BLOCK then finishes exactly K cells. Both unary heads return at +each chunk boundary. The DIM loop creates exactly D chunks, hence L cells +on both MASK and COUNT. Reversing the ordering of whole chunks in the LSB +counter does not alter the sum of the selected bit of every chunk. The +lexicographic source order and generated counter are consistent. + +The finite phase state is q=sum(MASK[j]*COUNT[j]) modulo four. Each flip +of an old bit b changes it by (1-2b)*MASK[j]. A complete wrap returns the +counter to zero and necessarily returns q to zero. COEFF performs exactly +r pairs per spectator entry; SPECTATOR performs exactly S entries before +one counter increment; OUTER advances only after a whole 2^L domain. +These loops give P*2^L*S*r pairs without an externally supplied N. + +The final read of DATA requires a blank immediately after the last header- +derived component. Every missing component instead rejects during a literal +load. This check occurs before any DATA write, so the complete cardinality +guard is not merely a host-side fixture check. + +## Independent amortization and constant audit + +For L>=1 and Q=2^L, one complete domain has exactly 2Q-2 counter-bit flips, +including its final wrap. An increment changing t bits advances COUNT and +MASK by t cells each. Each rewind traverses only that changed prefix, with +t+2 unit moves per tape, not the remaining counter suffix. Consequently +each tape uses 2t+2 moves for that increment. Including initialization, +geometry generation, final clearing and guard operations, the *exact* +successful-program move count for each of COUNT and MASK is + +``` +4L + 8 + P(6Q - 4). +``` + +This census is derived independently of the author verifier and checked +against every executed transition. It directly detects a hidden full-width +scan in a carry return, even if all numerical outputs remain correct. + +I recomputed the elementary instruction allowances from the table pattern: +rewind uses 3t+3, clear uses 7t+4, and a trace return uses 5t+3. The two +unary copies and old-value erasure for v->2v+b cost +47v+17b+18 <= 47v+35, before the fixed Gamma wrapper. Geometry costs at +most 35L+10 by summing the before/active/after paths and all rewinds, hence +fits the proof's 64(L+1) allowance. + +The exact successful component bounds are 15w+7 for load, 7w+5 for +negation, and 9w+4 for staging/erasure/return. A pair with two negations is +therefore at most 62w+32 before repetition control. A nonwrapping counter +increment costs 12t+7 and a wrapping one 12t+10, so the complete counter +bill is below 34PQ. Full r/S rewinds cost O(N), because their total scanned +unary lengths are N and M. The two payload-head returns, two OUTPUT rewinds +and original-owner copying cost 24V+13 after the payload-end guard. That +single guard is absorbed by the remaining constant slack. + +These direct loop bills fit the supplied 4096 metadata and 512 coefficient/ +repetition allowances. Using V=2Nw, N>=2, w>=3 and N+w<=Nw leaves ample +margin under `65536(E+p+d+DK+Nw+1)`. This is a proof from the fixed graph's +loops, not extrapolation from observed ratios or interpreter timings. + +## Arithmetic, owner return and history + +The four cases are respectively (a,c), (-c,a), (-a,-c), and (c,-a). +Negation walks from the least significant end using one carry bit, retaining +the final old and new sign bits. Both are one exactly when negating the +most-negative signed integer; thus the guard rejects precisely an +unrepresentable required component. A component that is only swapped may +retain that value. No data-dependent integer arithmetic occurs outside +literal symbols and finite state. + +Every transformed pair is staged privately. DATA is written only after all +coefficients and the final cardinality guard pass. The program then writes +exactly V bits on that original owner and erases the private copy. DATA has +exactly 4V moves on success; HEADER has exactly E reads and 2E moves. +All private heads and public heads return to their respective origins. +The entire private bodies and guards visited by the successful call are +erased. Failure cleanup and successful reentry after a rejection remain +unclaimed, correctly. + +The eighteen-role extent table is exhaustive. Summing endpoint-plus-two +lengths gives the claimed intermediate bound +`3V+2E+2p+2d+6DK+4w+36`: the combined r/P/S contributions are at most +6N<=V. Adding entry history gives the published larger envelope. Clearing +cells never removes that historical backing. At fixed role origins, +successive calls retain the maximum reached extent on each individual role; +at changing origins the corrected proof retains absolute unions instead. +The review does not treat maximum total per-call footprint as cumulative +history and does not infer blank owned windows from a single origin probe. + +## Executed evidence and sensitivity + +Warning-strict ordinary and optimized runs produce byte-identical receipts: + +```sh +python -I -W error -B /workspace/scratch/be42ab5b7196/reviews/c2-peer/check.py +python -I -O -W error -B /workspace/scratch/be42ab5b7196/reviews/c2-peer/check.py +``` + +For a copied or published package, the portable entry point retains the +unchanged checker while explicitly selecting its package directory: + +```sh +python -I -W error -B replay.py /path/to/research/literal-layer-phase +``` + +That entry point was also executed and produced the identical receipt. + +`RESULT.json` reports 15 successful runs (12 fresh geometries and three +calls on the same private objects), 2,084 complete address-record entries +and 2,175,819 interpreted transitions. Tests include variable D,K,rho, +non-power-of-two r/P/S, a unary d=257, and shifted tape origins with opaque +exterior symbols. At every record entry, direct observation checks the +generated mask, counter value, phase state, P/S positions, r reset and +complete coefficient consumption. Successful calls check exact source +reads, writes and moves, full retirement, head restoration and both published +resource envelopes. + +The reuse sequence retains histories 92 -> 15499 -> 15499 -> 15505. +The small middle call takes exactly as many instructions as its fresh-bank +counterpart, despite the old larger blank tails. No private object, origin, +head or history is reset by the harness between those calls. Public source +replacement between calls is explicitly separate caller acquisition. +Extra-payload and missing-bit packets reject before any public write. + +Three independent semantic mutations are detected with the intended +diagnostics: a wrong generated mask, omitted COUNT retirement, and a full- +width scan inserted into each ordinary carry return. The last mutant first +passes all functional geometry/owner/cleanup checks when the exact move +census is disabled; it fails that census when enabled. This demonstrates +that the amortization check is not just a rerun of numerical correctness. + +These bounded observations corroborate the universal loop argument. They +do not replace it, enlarge the admitted ownership domain, prove successful +recovery from rejection, or discharge the remaining layer/outer interfaces. diff --git a/research/literal-layer-phase/independent/peer/check.py b/research/literal-layer-phase/independent/peer/check.py new file mode 100644 index 0000000000..5ea18e4f73 --- /dev/null +++ b/research/literal-layer-phase/independent/peer/check.py @@ -0,0 +1,278 @@ +"""Independent literal-graph structural, amortization and history review. + +No author interpreter, oracle or verifier is called. Numerical Gaussian +correctness is separately reviewed by the lead agent. OpenAI-assisted. +""" +from collections import Counter +import hashlib +import importlib.util +import json +from pathlib import Path +import sys +import types + +PACKAGE = Path('/workspace/scratch/be42ab5b7196/worker-c2/research/literal-layer-phase') +EXPECTED = '9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23' +EXPECTED_TABLE = '50505d6bd350224021d88d8e7e142a3188649a1d391c34ade732fced19336624' +BLANK = '_' + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def gamma(n): + word = bin(n)[2:] + return '0' * (len(word) - 1) + word + + +def load_subject(): + source = (PACKAGE / 'phase.py').read_bytes() + need(hashlib.sha256(source).hexdigest() == EXPECTED, 'source pin') + spec = importlib.util.spec_from_file_location('peer_phase_subject', PACKAGE / 'phase.py') + module = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = module + spec.loader.exec_module(module) + return module + + +class Surface: + def __init__(self, origin, index): + self.origin = origin + self.head = origin + self.low = origin - (1 if index >= 2 else 0) + self.high = origin + (index % 7 if index >= 2 else 0) + self.cells = {origin - 2: '|', origin + 1000000: '1'} + + def get(self): + return self.cells.get(self.head, BLANK) + + def move(self, amount): + self.head += amount + self.low = min(self.low, self.head) + self.high = max(self.high, self.head) + + +def table_hash(code): + return hashlib.sha256(json.dumps(code, sort_keys=True, separators=(',', ':')).encode()).hexdigest() + + +def validate_graph(code): + operations = Counter() + for instruction in code: + opcode, *args = instruction + need(opcode in ('read', 'write', 'move', 'goto', 'halt'), 'nonliteral opcode') + operations[opcode] += 1 + if opcode in ('read', 'write', 'move'): + need(type(args[0]) is int and 0 <= args[0] < 20, 'unfixed tape selector') + if opcode == 'read': + need(set(args[1]) <= {'_', '0', '1', '|'}, 'unfixed read alphabet') + need(all(type(v) is int and 0 <= v < len(code) for v in args[1].values()), 'unfixed branch') + if opcode == 'write': + need(args[1] in ('_', '0', '1', '|'), 'unfixed write alphabet') + if opcode == 'move': + need(args[1] in (-1, 1), 'nonunit move') + if opcode == 'goto': + need(type(args[0]) is int and 0 <= args[0] < len(code), 'unfixed jump') + return dict(sorted(operations.items())) + + +def fresh_surfaces(): + return [Surface((i * 19) - 113, i) for i in range(20)] + + +def set_public(tape, word, *, header=False): + # Separately paid caller acquisition; private histories/heads never reset. + tape.cells = {tape.origin - 2: '|', tape.origin + 1000000: '1'} + for i, symbol in enumerate(word): + tape.cells[tape.origin + i] = symbol + if header: + tape.cells[tape.origin + len(word)] = '|' + + +def execute(code, parameters, *, surfaces=None, extra=False, missing=False, + expect_reject=False, check_counter_bill=True): + p, d, r, D, P, S, K, rho, w = parameters + L, Q = D * K, 2 ** (D * K) + N, V = P * Q * S * r, 2 * P * Q * S * r * w + words = (p, d, r, D, P, S, K, rho + 1, w) + header = ''.join(map(gamma, words)) + packet = '0' * V + ('0' if extra else '') + if missing: + packet = packet[:-1] + tapes = fresh_surfaces() if surfaces is None else surfaces + need(all(t.head == t.origin for t in tapes), 'entry head') + private_before = [dict(t.cells) for t in tapes[2:]] + history_before = sum(t.high - t.low + 1 for t in tapes[2:]) + set_public(tapes[0], header, header=True) + set_public(tapes[1], packet) + public_before = [dict(t.cells) for t in tapes[:2]] + records = [i for i, ins in enumerate(code) + if ins[0] == 'read' and ins[1] == 11 and set(ins[2]) == {'_', '1'} + and tuple(code[i + 1][:2]) == ('read', 8) and ins[2]['1'] == i + 1] + need(len(records) == 4, 'four phase-entry locations') + phase_at = dict(zip(records, range(4))) + counters = {'read': Counter(), 'write': Counter(), 'move': Counter()} + flips = 0 + record_ordinal = 0 + pc, steps, rejected = 0, 0, False + for _ in range(5000000): + if pc in phase_at and tapes[11].get() == '1': + position = record_ordinal + actual_bits = [tapes[16].cells.get(tapes[16].origin + j, BLANK) for j in range(L)] + actual_mask = [tapes[15].cells.get(tapes[15].origin + j, BLANK) for j in range(L)] + need(actual_mask == ['1' if j % K == rho else '0' for j in range(L)], 'generated mask') + need(all(b in ('0', '1') for b in actual_bits), 'counter shape') + value = sum((b == '1') << j for j, b in enumerate(actual_bits)) + phase = sum(b == '1' and m == '1' for b, m in zip(actual_bits, actual_mask)) % 4 + need(value == (position // S) % Q, 'full-domain address order') + need(phase_at[pc] == phase, 'incremental phase invariant') + need(tapes[10].head - tapes[10].origin == position // (Q * S), 'P repetition') + need(tapes[11].head - tapes[11].origin == position % S, 'S repetition') + need(tapes[8].head == tapes[8].origin, 'r repeat reset') + need(tapes[1].head - tapes[1].origin == 2 * w * r * position, 'r complete coefficients') + record_ordinal += 1 + opcode, *args = code[pc] + pc += 1 + steps += 1 + if opcode == 'halt': + break + if opcode == 'goto': + pc = args[0] + continue + tape = tapes[args[0]] + counters[opcode][args[0]] += 1 + if opcode == 'read': + symbol = tape.get() + if symbol not in args[1]: + rejected = True + break + pc = args[1][symbol] + elif opcode == 'write': + old = tape.get() + if args[0] == 16 and old in ('0', '1') and args[1] in ('0', '1'): + need(old != args[1], 'counter flip') + flips += 1 + if args[1] == BLANK: + tape.cells.pop(tape.head, None) + else: + tape.cells[tape.head] = args[1] + else: + tape.move(args[1]) + else: + raise ValueError('review execution cap') + need(rejected == expect_reject, 'rejection outcome') + need(counters['write'][0] == 0, 'header was written') + if rejected: + need(counters['write'][1] == 0 and [dict(t.cells) for t in tapes[:2]] == public_before, + 'rejection modified public input') + return {'rejected': True, 'steps': steps} + need(record_ordinal == P * Q * S, 'exact full record cardinality') + need(counters['read'][1] == V + 1 and counters['write'][1] == V, 'payload read/write cardinality') + need(counters['read'][0] == len(header), 'header source-read extent') + need(counters['move'][1] == 4 * V and counters['move'][0] == 2 * len(header), 'paid public returns') + need([dict(t.cells) for t in tapes[:2]] == public_before, 'zero packet/public exterior changed') + need([dict(t.cells) for t in tapes[2:]] == private_before, 'private body or guard not retired') + need(all(t.head == t.origin for t in tapes), 'head not restored') + need(flips == P * (2 * Q - 2), 'geometric ripple flip census') + if check_counter_bill: + expected_moves = 4 * L + 8 + P * (6 * Q - 4) + need(counters['move'][15] == counters['move'][16] == expected_moves, 'exact carry/return move census') + budget = len(header) + p + d + L + N * w + 1 + need(steps <= 65536 * budget, 'complete literal time envelope') + history_after = sum(t.high - t.low + 1 for t in tapes[2:]) + need(history_before <= history_after <= history_before + 4 * V + 32 * (len(header) + p + d + L + w + 1), + 'retained history envelope') + return {'parameters': parameters, 'steps': steps, 'records': record_ordinal, + 'flips': flips, 'counter_moves': counters['move'][16], + 'history_before': history_before, 'history_after': history_after, + 'budget_base': budget, 'payload_bits': V} + + +def changed_graph(label, old, new): + source = (PACKAGE / 'phase.py').read_text() + need(source.count(old) == 1, 'mutation anchor ' + label) + module = types.ModuleType('phase_peer_mutant_' + label) + module.__file__ = str(PACKAGE / 'phase.py') + sys.modules[module.__name__] = module + exec(compile(source.replace(old, new), module.__file__, 'exec'), module.__dict__) + return module.compile_phase()[0] + + +def diagnostic(label, action, expected): + try: + action() + except ValueError as error: + need(expected in str(error), 'unexpected failure for ' + label + ': ' + str(error)) + return {'mutation': label, 'diagnostic': str(error)} + raise ValueError('mutation escaped ' + label) + + +def main(): + subject = load_subject() + code, alphabet = subject.compile_phase() + need(len(code) == 2146 and table_hash(code) == EXPECTED_TABLE, 'frozen literal graph') + opcodes = validate_graph(code) + cases = [ + (1, 1, 1, 1, 1, 1, 1, 0, 3), + (2, 4, 3, 2, 2, 3, 2, 0, 4), + (3, 6, 2, 3, 3, 2, 2, 1, 5), + (1, 4, 1, 4, 2, 1, 1, 0, 3), + (2, 1, 3, 1, 2, 2, 4, 3, 4), + (2, 3, 1, 1, 1, 2, 7, 6, 4), + (3, 3, 2, 3, 1, 1, 3, 0, 5), + (1, 1, 1, 1, 5, 4, 1, 0, 3), + (2, 2, 5, 2, 1, 3, 2, 1, 6), + (17, 29, 1, 2, 1, 1, 1, 0, 19), + (1, 257, 1, 1, 1, 1, 1, 0, 3), + (1, 1, 31, 1, 1, 1, 1, 0, 3), + ] + runs = [execute(code, case) for case in cases] + surfaces = fresh_surfaces() + identities = tuple(map(id, surfaces)) + reuse = [] + for case in (cases[2], cases[0], cases[5]): + reuse.append(execute(code, case, surfaces=surfaces)) + need(tuple(map(id, surfaces)) == identities, 'physical role identity changed') + need(reuse[1]['steps'] == runs[0]['steps'], 'small call rescanned historical capacity') + rejection = [execute(code, cases[1], extra=True, expect_reject=True), + execute(code, cases[1], missing=True, expect_reject=True)] + fixture = (1, 2, 1, 2, 2, 2, 2, 0, 3) + bad_mask = changed_graph('wrong_mask', "('mask_active', ONE, 'build_after')", + "('mask_active', '0', 'build_after')") + mutants = [diagnostic('wrong generated mask', lambda: execute(bad_mask, fixture), 'generated mask')] + bad_cleanup = changed_graph('missing_cleanup', 'for tape in (MASK, COUNT):', 'for tape in (MASK,):') + mutants.append(diagnostic('missing counter retirement', lambda: execute(bad_cleanup, fixture), + 'private body or guard not retired')) + long_scan = """a.mark('advanced'+str(mode)) + a.mark('peer_scan'+str(mode)) + a.op('read', COUNT, {'0': 'peer_step'+str(mode), ONE: 'peer_step'+str(mode), + BLANK: 'peer_done'+str(mode)}) + a.mark('peer_step'+str(mode)) + a.op('move', COUNT, 1) + a.op('move', MASK, 1) + a.op('goto', 'peer_scan'+str(mode)) + a.mark('peer_done'+str(mode)) + a.rewind(COUNT, BITS)""" + bad_carry = changed_graph('full_scan_return', + "a.mark('advanced'+str(mode))\n a.rewind(COUNT, BITS)", long_scan) + functional = execute(bad_carry, fixture, check_counter_bill=False) + mutants.append(diagnostic('unpriced full-width carry return', lambda: execute(bad_carry, fixture), + 'exact carry/return move census')) + output = {'status': 'PASS_INDEPENDENT_PHASE_STRUCTURE_REVIEW', 'source_sha256': EXPECTED, + 'program_sha256': EXPECTED_TABLE, + 'proof_sha256': hashlib.sha256((PACKAGE / 'PROOF.md').read_bytes()).hexdigest(), + 'reviewer_script_sha256': hashlib.sha256(Path(__file__).read_bytes()).hexdigest(), + 'instruction_locations': len(code), 'opcodes': opcodes, 'alphabet': alphabet, + 'cases': runs, 'reuse': reuse, 'rejection_checks': rejection, 'mutations': mutants, + 'functionally_correct_full_scan_mutant': functional, + 'successful_runs': len(runs) + len(reuse), + 'record_entries': sum(x['records'] for x in runs + reuse), + 'successful_steps': sum(x['steps'] for x in runs + reuse), + 'scope': 'Independent interpreter and structural/cost/history evidence; root separately verifies Gaussian arithmetic.'} + print(json.dumps(output, indent=2, sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/literal-layer-phase/independent/peer/replay.py b/research/literal-layer-phase/independent/peer/replay.py new file mode 100644 index 0000000000..e45570a685 --- /dev/null +++ b/research/literal-layer-phase/independent/peer/replay.py @@ -0,0 +1,15 @@ +"""Portable entry point for the unchanged independent review checker.""" +import argparse +import importlib.util +from pathlib import Path +import sys + +parser = argparse.ArgumentParser() +parser.add_argument('package', type=Path, help='path to research/literal-layer-phase') +arguments = parser.parse_args() +spec = importlib.util.spec_from_file_location('independent_phase_review', Path(__file__).with_name('check.py')) +module = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = module +spec.loader.exec_module(module) +module.PACKAGE = arguments.package.resolve() +module.main() diff --git a/research/literal-layer-phase/inputs/controller_reference.py b/research/literal-layer-phase/inputs/controller_reference.py new file mode 100644 index 0000000000..3ab6d0361f --- /dev/null +++ b/research/literal-layer-phase/inputs/controller_reference.py @@ -0,0 +1,112 @@ +"""Finite three-tape online rank-recursion control; Apache-2.0. +Only PC and local symbols affect execution. Metrics/event logs are observers. +""" +from dataclasses import dataclass, field +BLANK, ONE, MARK = '_', '1', '|' +WIDTH, CHILD, STACK = range(3) + +class Builder: + def __init__(self): self.code, self.labels, self.serial = [], {}, 0 + def mark(self,n): + if n in self.labels: raise ValueError('duplicate label') + self.labels[n]=len(self.code) + def op(self,*x): self.code.append(x) + def rewind(self,t,symbols): + self.serial+=1; loop=f'rw{self.serial}'; done=loop+'done' + self.op('move',t,-1); self.mark(loop) + self.op('read',t,{s:loop+'step' for s in symbols}|{MARK:done}) + self.mark(loop+'step'); self.op('move',t,-1); self.op('goto',loop) + self.mark(done); self.op('move',t,1) + def finish(self,alphabet): + result=[] + for op,*a in self.code: + if op=='goto': a[0]=self.labels[a[0]] + elif op=='read': a[1]={s:self.labels[n] for s,n in a[1].items()} + result.append((op,*a)) + return tuple(result),tuple(alphabet) + +def compile_controller(m,ranks): + """Parameters are compile-time constants, absent from run-time state.""" + if type(m) is not int or m<2 or not ranks: raise ValueError('bad fixed profile') + if any(type(r) is not int or not 1<=r=budget: raise ValueError('finite verifier budget') + self.step() + return self + +def initial_tapes(width,origins=(0,0,0),ancestor=('0','1','t0','_','|','0')): + if width<1: raise ValueError('positive width') + u,c,p=origins + return [Tape({u-1:MARK,**{u+i:ONE for i in range(width)}},u),Tape({c-1:MARK},c), + Tape({p-1:MARK,**{p-2-i:s for i,s in enumerate(ancestor) if s!=BLANK}},p)] diff --git a/research/literal-layer-phase/oracles.py b/research/literal-layer-phase/oracles.py new file mode 100644 index 0000000000..022b231e65 --- /dev/null +++ b/research/literal-layer-phase/oracles.py @@ -0,0 +1,57 @@ +"""Independent exact arithmetic and explicit-address verification oracles. + +These are test-only Python computations, never executed by the literal table. +They enumerate the source Cartesian address space rather than simulate carries. +""" +from itertools import product + + +def gamma(value): + bits = bin(value)[2:] + return '0'*(len(bits)-1)+bits + + +def header(parameters): + return ''.join(gamma(v) for v in parameters) + + +def cardinality(parameters): + _, _, r, dimension, outer, spectator, block, _, _ = parameters + return r*outer*spectator*(1 << (dimension*block)) + + +def phase_codes(parameters): + _, _, r, dimension, outer, spectator, block, offset1, _ = parameters + for _ in range(outer): + for coordinate in product(range(1 << block), repeat=dimension): + phase = sum((x >> (offset1-1)) & 1 for x in coordinate) + for _ in range(spectator): + for _ in range(r): + yield phase + + +def rotate(pair, phase): + a, c = pair + for _ in range(phase): + a, c = -c, a + return a, c + + +def expected(parameters, values): + return [rotate(pair, phase) for pair, phase in zip(values, phase_codes(parameters))] + + +def encode(values, width): + return ''.join(format(x % (1 << width), f'0{width}b') for pair in values for x in pair) + + +def decode(word, width): + values = [] + for start in range(0, len(word), width): + value = int(word[start:start+width], 2) + values.append(value-(1 << width) if value >= 1 << (width-1) else value) + return list(zip(values[::2], values[1::2])) + + +def fits(values, width): + return all(-(1 << (width-1)) <= x < (1 << (width-1)) for pair in values for x in pair) diff --git a/research/literal-layer-phase/phase.py b/research/literal-layer-phase/phase.py new file mode 100644 index 0000000000..c6e8769534 --- /dev/null +++ b/research/literal-layer-phase/phase.py @@ -0,0 +1,343 @@ +"""Header-derived literal S_D phase sweep on implicit layer addresses. + +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Apache-2.0. Gaussian phases and counter amortization are credited prior work; +see PROOF.md. Python constructs one fixed graph, never an input-sized graph. +Only scanned symbols, fixed jumps, one-cell writes and unit moves execute. +""" +from pathlib import Path +import hashlib +import sys + +HERE = Path(__file__).resolve().parent +MACHINE = HERE / 'inputs' / 'controller_reference.py' +EXPECTED_MACHINE = 'e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73' +if hashlib.sha256(MACHINE.read_bytes()).hexdigest() != EXPECTED_MACHINE: + raise ValueError('frozen literal machine source drift') +sys.path.insert(0, str(MACHINE.parent)) +from controller_reference import Builder, Machine, Tape, BLANK, ONE, MARK + +(HEADER, DATA, OUTPUT, HTRACE, LENGTH, DOUBLE, PREC, GLOBAL, COEFF, DIM, + OUTER, SPECTATOR, BLOCK, SELECT, WIDTH, MASK, COUNT, REAL, IMAG, DTRACE) = range(20) +PRIVATE = tuple(range(2, 20)) +BITS = ('0', ONE) + + +def fresh(a, stem): + a.serial += 1 + return stem + str(a.serial) + + +def clear(a, tape, symbols=(ONE,)): + k = fresh(a, 'clear') + a.mark(k) + a.op('read', tape, {s: k+'bit' for s in symbols} | {BLANK: k+'done'}) + a.mark(k+'bit') + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(tape, (BLANK,)) + + +def unary_copy(a, source, target, *, repeat=1, extra=0, erase=False): + k = fresh(a, 'copy') + a.mark(k) + a.op('read', source, {ONE: k+'bit', BLANK: k+'done'}) + a.mark(k+'bit') + for _ in range(repeat): + a.op('write', target, ONE) + a.op('move', target, 1) + if erase: + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('goto', k) + a.mark(k+'done') + for _ in range(extra): + a.op('write', target, ONE) + a.op('move', target, 1) + a.rewind(source, (BLANK,) if erase else (ONE,)) + a.rewind(target, (ONE,)) + + +def header_step(a): + a.op('write', HTRACE, ONE) + a.op('move', HTRACE, 1) + a.op('move', HEADER, 1) + + +def gamma(a, target): + """Actual positive Gamma code to unary, using only literal operations.""" + k = fresh(a, 'gamma') + a.mark(k+'prefix') + a.op('read', HEADER, {'0': k+'zero', ONE: k+'one'}) + a.mark(k+'zero') + a.op('write', LENGTH, ONE) + a.op('move', LENGTH, 1) + header_step(a) + a.op('goto', k+'prefix') + a.mark(k+'one') + header_step(a) + a.op('write', target, ONE) + a.op('move', LENGTH, -1) + a.mark(k+'tail') + a.op('read', LENGTH, {ONE: k+'tailbit', MARK: k+'done'}) + a.mark(k+'tailbit') + a.op('write', LENGTH, BLANK) + a.op('read', HEADER, {str(b): k+'digit'+str(b) for b in (0, 1)}) + for b in (0, 1): + a.mark(k+'digit'+str(b)) + unary_copy(a, target, DOUBLE, repeat=2, extra=b) + clear(a, target) + unary_copy(a, DOUBLE, target, erase=True) + header_step(a) + a.op('move', LENGTH, -1) + a.op('goto', k+'tail') + a.mark(k+'done') + a.op('move', LENGTH, 1) + + +def trace_return(a, tape, trace): + k = fresh(a, 'return') + a.op('move', trace, -1) + a.mark(k) + a.op('read', trace, {ONE: k+'bit', MARK: k+'done'}) + a.mark(k+'bit') + a.op('write', trace, BLANK) + a.op('move', trace, -1) + a.op('move', tape, -1) + a.op('goto', k) + a.mark(k+'done') + a.op('move', trace, 1) + + +def make_geometry(a): + """Generate D K-bit chunks with active position rho, all LSB first.""" + a.mark('build_chunk') + a.op('read', DIM, {ONE: 'build_before', BLANK: 'geometry_done'}) + a.mark('build_before') + a.op('read', BLOCK, {ONE: 'build_select', BLANK: 'reject'}) + a.mark('build_select') + a.op('read', SELECT, {ONE: 'select_step'}) + a.mark('select_step') + a.op('move', SELECT, 1) + a.op('read', SELECT, {ONE: 'mask_before', BLANK: 'mask_active'}) + a.mark('build_after') + a.op('read', BLOCK, {ONE: 'mask_after', BLANK: 'chunk_done'}) + for name, bit, nxt in (('mask_before', '0', 'build_before'), + ('mask_active', ONE, 'build_after'), + ('mask_after', '0', 'build_after')): + a.mark(name) + a.op('write', MASK, bit) + a.op('move', MASK, 1) + a.op('write', COUNT, '0') + a.op('move', COUNT, 1) + a.op('move', BLOCK, 1) + a.op('goto', nxt) + a.mark('chunk_done') + a.rewind(BLOCK, (ONE,)) + a.rewind(SELECT, (ONE,)) + a.op('move', DIM, 1) + a.op('goto', 'build_chunk') + a.mark('geometry_done') + a.rewind(DIM, (ONE,)) + a.rewind(MASK, BITS) + a.rewind(COUNT, BITS) + + +def load_component(a, target): + k = fresh(a, 'load') + a.mark(k) + a.op('read', WIDTH, {ONE: k+'bit', BLANK: k+'done'}) + a.mark(k+'bit') + a.op('read', DATA, {str(b): k+str(b) for b in (0, 1)}) + for b in (0, 1): + a.mark(k+str(b)) + a.op('write', target, str(b)) + a.op('move', target, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('move', WIDTH, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(WIDTH, (ONE,)) + a.rewind(target, BITS) + + +def negate(a, tape): + """Exact w-bit integer negation; reject the unrepresentable minimum.""" + k = fresh(a, 'neg') + a.mark(k+'seek') + a.op('read', tape, {'0': k+'step', ONE: k+'step', BLANK: k+'last'}) + a.mark(k+'step') + a.op('move', tape, 1) + a.op('goto', k+'seek') + a.mark(k+'last') + a.op('move', tape, -1) + a.op('goto', k+'c1x0y0') + for carry in (0, 1): + for old_sign in (0, 1): + for new_sign in (0, 1): + name = k+f'c{carry}x{old_sign}y{new_sign}' + a.mark(name) + a.op('read', tape, {str(b): name+'b'+str(b) for b in (0, 1)} | + {MARK: 'reject' if old_sign and new_sign else k+'done'}) + for bit in (0, 1): + total = 1-bit+carry + digit, nxt = total % 2, total//2 + a.mark(name+'b'+str(bit)) + a.op('write', tape, str(digit)) + a.op('move', tape, -1) + a.op('goto', k+f'c{nxt}x{bit}y{digit}') + a.mark(k+'done') + a.op('move', tape, 1) + + +def stage_component(a, tape): + k = fresh(a, 'stage') + a.mark(k) + a.op('read', tape, {str(b): k+str(b) for b in (0, 1)} | {BLANK: k+'done'}) + for b in (0, 1): + a.mark(k+str(b)) + a.op('write', OUTPUT, str(b)) + a.op('move', OUTPUT, 1) + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(tape, (BLANK,)) + + +def advance(a): + """Full binary increment; phase is always fixed four-state control.""" + for mode in range(4): + name = 'advance'+str(mode) + a.mark(name) + a.op('read', COUNT, {str(b): name+'b'+str(b) for b in (0, 1)} | + {BLANK: 'overflow'+str(mode)}) + for bit in (0, 1): + a.mark(name+'b'+str(bit)) + a.op('read', MASK, {str(active): name+f'b{bit}m{active}' for active in (0, 1)}) + for active in (0, 1): + a.mark(name+f'b{bit}m{active}') + nxt = (mode + (1-2*bit)*active) % 4 + a.op('write', COUNT, str(1-bit)) + a.op('move', COUNT, 1) + a.op('move', MASK, 1) + a.op('goto', 'advance'+str(nxt) if bit else 'advanced'+str(nxt)) + for mode in range(4): + a.mark('advanced'+str(mode)) + a.rewind(COUNT, BITS) + a.rewind(MASK, BITS) + a.op('goto', 'record'+str(mode)) + a.mark('overflow'+str(mode)) + a.op('read', MASK, {BLANK: 'wrapped'+str(mode)}) + a.mark('wrapped'+str(mode)) + if mode: + a.op('goto', 'reject') + else: + a.rewind(COUNT, BITS) + a.rewind(MASK, BITS) + a.op('move', OUTER, 1) + a.op('read', OUTER, {ONE: 'record0', BLANK: 'finish'}) + + +def compile_phase(): + a = Builder() + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, MARK) + a.op('move', tape, 1) + # Actual header: p,d,r,D,P,S,K,rho+1,w. Runtime values stay on tapes. + for target in (PREC, GLOBAL, COEFF, DIM, OUTER, SPECTATOR, BLOCK, SELECT, WIDTH): + gamma(a, target) + trace_return(a, HEADER, HTRACE) + a.mark('dimension_check') + a.op('read', DIM, {ONE: 'dimension_global', BLANK: 'dimension_ok'}) + a.mark('dimension_global') + a.op('read', GLOBAL, {ONE: 'dimension_step', BLANK: 'reject'}) + a.mark('dimension_step') + a.op('move', DIM, 1) + a.op('move', GLOBAL, 1) + a.op('goto', 'dimension_check') + a.mark('dimension_ok') + a.rewind(DIM, (ONE,)) + a.rewind(GLOBAL, (ONE,)) + a.mark('width_check') + a.op('read', PREC, {ONE: 'width_precision', BLANK: 'width_extra0'}) + a.mark('width_precision') + a.op('read', WIDTH, {ONE: 'width_step', BLANK: 'reject'}) + a.mark('width_step') + a.op('move', PREC, 1) + a.op('move', WIDTH, 1) + a.op('goto', 'width_check') + for i in range(2): + a.mark('width_extra'+str(i)) + a.op('read', WIDTH, {ONE: 'width_more'+str(i), BLANK: 'reject'}) + a.mark('width_more'+str(i)) + a.op('move', WIDTH, 1) + a.rewind(PREC, (ONE,)) + a.rewind(WIDTH, (ONE,)) + make_geometry(a) + for tape in (PREC, GLOBAL, DIM, BLOCK, SELECT): + clear(a, tape) + a.op('goto', 'record0') + for mode in range(4): + a.mark('record'+str(mode)) + a.op('read', SPECTATOR, {ONE: 'coefficient'+str(mode), BLANK: 'record_end'+str(mode)}) + a.mark('coefficient'+str(mode)) + a.op('read', COEFF, {ONE: 'payload'+str(mode), BLANK: 'coefficient_end'+str(mode)}) + a.mark('payload'+str(mode)) + load_component(a, REAL) + load_component(a, IMAG) + if mode in (2, 3): + negate(a, REAL) + if mode in (1, 2): + negate(a, IMAG) + order = (IMAG, REAL) if mode % 2 else (REAL, IMAG) + for tape in order: + stage_component(a, tape) + a.op('move', COEFF, 1) + a.op('goto', 'coefficient'+str(mode)) + a.mark('coefficient_end'+str(mode)) + a.rewind(COEFF, (ONE,)) + a.op('move', SPECTATOR, 1) + a.op('goto', 'record'+str(mode)) + a.mark('record_end'+str(mode)) + a.rewind(SPECTATOR, (ONE,)) + a.op('goto', 'advance'+str(mode)) + advance(a) + a.mark('finish') + # Header-derived geometry determines cardinality, not a host oracle. + a.op('read', DATA, {BLANK: 'verified', '0': 'reject', ONE: 'reject'}) + a.mark('verified') + trace_return(a, DATA, DTRACE) + a.rewind(OUTPUT, BITS) + a.mark('commit') + a.op('read', OUTPUT, {str(b): 'commit'+str(b) for b in (0, 1)} | {BLANK: 'committed'}) + for bit in ('0', ONE): + a.mark('commit'+bit) + a.op('write', DATA, bit) + a.op('write', OUTPUT, BLANK) + a.op('move', OUTPUT, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('goto', 'commit') + a.mark('committed') + trace_return(a, DATA, DTRACE) + a.rewind(OUTPUT, (BLANK,)) + a.rewind(OUTER, (ONE,)) + for tape in (OUTER, COEFF, SPECTATOR, WIDTH): + clear(a, tape) + for tape in (MASK, COUNT): + clear(a, tape, BITS) + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('halt') + a.mark('reject') + a.op('read', HEADER, {}) + return a.finish((BLANK, '0', ONE, MARK)) diff --git a/research/literal-layer-phase/reference/02-streams.tex b/research/literal-layer-phase/reference/02-streams.tex new file mode 100644 index 0000000000..088fceea18 --- /dev/null +++ b/research/literal-layer-phase/reference/02-streams.tex @@ -0,0 +1,208 @@ +\section{The machine model and elementary streams} +\label{sec:streams} + +A machine has one fixed finite alphabet and one fixed finite number of +one-dimensional tapes. A step reads and writes at most one cell on each +tape and moves each head by at most one cell. Fixed tracks and finitely +many work tapes change time by a fixed factor. We distinguish moving one +digit in a fixed radix, which needs a bounded number of scans, from +interchanging fields whose numbers of digits grow. The latter permutation +will be realized in Section~\ref{sec:tape-interchange} by computing XOR +combinations of intermediate data streams. The present section supplies +the elementary scans it uses. Every scan includes its counters and the +return of its tape heads. + +\subsection{Array order and elementary scans} + +For a positive integer $a$ write $[a]=\{0,\ldots,a-1\}$. +An array with address set $[a_1]\times\cdots\times[a_t]$ is stored in +lexicographic order, with the first coordinate most significant. Its +entries are bits unless a record width is specified. A trailing record +of $B$ bits can equivalently be regarded as a final address field $[B]$. +An address is implicit in an entry's position in this ordered stream; it +is not stored beside every data bit. +The \emph{logical volume} $V$ is the number of stored data bits. Work +tapes and duplicate streams are charged in time but do not increase $V$ +in recurrences. All the fields discussed below are nonempty. A call +with an empty array is handled directly. + +An address permutation $f$ moves the entry at $x$ to $f(x)$. Thus its +action on an array $A$ is $(fA)(f(x))=A(x)$. Adjacent fields which are +irrelevant to an operation may be replaced by a single field whose length +is their product. In particular, the elementary procedures below have a +fixed number of formal address fields even when a surrounding algorithm +has a growing list of coordinates. Lengths and positions are supplied in +canonical binary on descriptor tapes; no additional tape head is attached to an +address coordinate. Each elementary call receives a fixed number of +collapsed canonical lengths. Constructing them from a longer surrounding +list is work of the caller; recursive calls below construct their own +collapsed descriptors within their stated bounds. + +When one address field is designated as a row field, collapse the fields +before it to a prefix $[P]$ and those after it to a suffix $[B]$. If the +row field has range $[R]$, a \emph{row} at prefix $p$ and row index $r$ +is the complete consecutive block $\{p\}\times\{r\}\times[B]$. +Every row therefore contains $B$ bits in the same suffix order. + +For headers that concatenate a list of positive integer parameters, we use +the self-delimiting code +\begin{equation} + b_v=\lfloor\log_2v\rfloor+1,\qquad + \Gamma(v)=0^{b_v-1}\operatorname{bin}_{b_v}(v),\qquad + |\Gamma(v)|=2b_v-1\quad(v\ge1). + \label{eq:integer-descriptor-code} +\end{equation} +The initial zeroes specify how many further bits follow the first one, +so concatenated codes can be read in order. We use this code when an +interface specifies a header; elementary calls still receive the fixed +number of canonical binary lengths described above. + +\begin{lemma}[Elementary stream operations] +\label{lem:elementary-streams} +Fix a radix $q\ge2$. Each of the following operations on an array of +volume $V$ takes $O(V)$ steps on a fixed number of one-dimensional tapes: +\begin{enumerate} +\item any fixed permutation of the pair of digit values at two specified +radix-$q$ positions, whether or not the positions are adjacent; +\item moving one specified radix-$q$ digit to another position, preserving +the order of the intervening positions; +\item splitting on a specified radix-$q$ digit, applying a fixed +pointwise map to aligned streams, and merging them back; +\item for positive integers $P,R,B$, within each prefix of an array on +$[P]\times[R]\times[B]$, splitting +whole rows cyclically into a fixed number $W$ of streams, and, when $W$ +divides $R$, merging those streams in any fixed order of the row classes. +\end{enumerate} +The bounds include shape preparation, counter initialization and resets, +and returning or clearing the visited portions of work tapes. Their +constants may depend on the fixed radix, the fixed pointwise map, and the +fixed number of row classes. +\end{lemma} + +\begin{proof} +For the first operation split into $q^2$ streams according to the two +specified digits. With these digits fixed, the order of all remaining +digits is unchanged by the permutation. Enumerate output addresses in +their required order and read the stream prescribed by the two preimage +digits. For a digit move use $q$ streams instead. The same observation +shows that splitting on one digit gives streams with the same remaining +address set in the same order. Scan their aligned entries, apply the +fixed pointwise map, and merge according to the output digit; this proves +the third operation. For the fourth, write $r=Wg+w$, where +$0\le w0,\quad 0<\epsilon<1. +\] +The exponents and comparison constants are fixed, and we impose their +further restrictions in Proposition~\ref{prop:simultaneous-layer}. +Two consequences explain the layout. The polynomial length $r$ grows +faster than every fixed power of $p$, so a scan of a record pays for +polynomial work on its address. Also $K/\log p\to\infty$, which will +make the exceptional set in a packed change of address bits small enough +to repair by sorting. We will obtain cost $O(Vd^{\lambda'})$, with +$\lambda'<1$ and $V$ the logical bit volume, whereas separate butterfly +factors would require $D$ whole-array passes. + +We first construct tensor products of the auxiliary two-point kernel +$C$ from Proposition~\ref{prop:complex-motif-interface}. Its phase +frames express a $C$ tensor product using smaller groups of +selected bits, separated by binary changes of basis. We implement those +changes by moving whole address chunks. Splitting complete rows among +the network's wire roles then reduces the volume of each recursive +call. Finally, we bound the intermediate dyadic values and convert the +completed $C$ layer to the normalized $H_0$ layer. The entire layer is +evaluated exactly before one final truncation. + +\subsection{Phase frames for a simultaneous butterfly layer} +\label{subsec:phase-frames} + +Hold the unselected address bits fixed and regard the stored complex +values on one wire role as a function of the selected bits. The phase +identities below express an edge's residual operator as a product of +two-point kernels on selected directions. + +Put +\[ + H_0=\frac12\begin{pmatrix}1&1\\1&-1\end{pmatrix},\qquad + H=\sqrt2 H_0,\qquad \mathsf S=\operatorname{diag}(1,i),\qquad + Z=\operatorname{diag}(1,-1). +\] +For the bit-flip matrix $X=\bigl(\begin{smallmatrix}0&1\\1&0\end{smallmatrix}\bigr)$, +define +\begin{equation}\label{eq:phase-C} + C=H\mathsf SH=aI+bX,\qquad a=\frac{1+i}{2},\quad b=\frac{1-i}{2}. +\end{equation} +Direct multiplication gives +\begin{equation}\label{eq:phase-basic-identities} + H_0=b\mathsf SC\mathsf S,\qquad C^2=X,\qquad C^4=I,\qquad + C^{-1}=bI+aX=-iZCZ. +\end{equation} +In particular, $C=iZC^{-1}Z$. These identities use only Gaussian dyadic +coefficients. The Hadamard matrices in the definition of +$\mathcal C_U$ are used to prove identities; they need not be executed +by the machine. + +Consider an edge from label $U_-$ to label $U_+$, and choose an +orthonormal basis $v_1,\ldots,v_{\rho_{\rm edge}}$ of its residual. +Proposition~\ref{prop:complex-motif-interface} gives the frame change +\[ + \mathcal C_{U_+}\mathcal C_{U_-}^{-1} + =\prod_{j=1}^{\rho_{\rm edge}}(aI+bX_{v_j})^{\epsilon_j}, + \qquad \epsilon_j\in\{1,-1\}. +\] +Here $(X_vf)(x)=f(x+v)$, and we write $C_v=aI+bX_v$. +The number of directional kernels is precisely +$\rho_{\rm edge}$, including on decreasing edges. The next step puts those directions +into coordinate positions without performing a general transpose. + +\paragraph{Implementing an arbitrary residual basis.} +For $M\in\operatorname{GL}(m,\mathbb F_2)$, let $\mathcal P_M$ be the +address permutation that moves the value at $x$ to $Mx$. Thus +$(\mathcal P_Mf)(x)=f(M^{-1}x)$, and +\begin{equation}\label{eq:phase-conjugation} + \mathcal P_MX_v\mathcal P_M^{-1}=X_{Mv}. +\end{equation} +Extend $v_1,\ldots,v_{\rho_{\rm edge}}$ to a basis of $\mathbb F_2^m$ and take these vectors as +the first $\rho_{\rm edge}$ columns of $M$. The displayed edge identity +then becomes +\begin{equation}\label{eq:phase-edge-coordinate} + \mathcal C_{U_+}\mathcal C_{U_-}^{-1} + =\mathcal P_M\left(\prod_{j=1}^{\rho_{\rm edge}}C_{e_j}^{\epsilon_j}\right) + \mathcal P_M^{-1}, +\end{equation} +where $e_j$ is the $j$th standard basis vector. The matrix $M$ need not +preserve the dot product: equation~\eqref{eq:phase-conjugation} only +uses its invertibility. + +For the array layout used below, take a group of $e=mf$ consecutive +axis chunks and divide it into $m$ consecutive slots of $f$ chunks, +numbered in physical order. +Number the chunks within each slot by $j=0,\ldots,f-1$, starting at +its least significant end. Write $x_{h,j}$ for the selected bit in +chunk $j$ of slot $h$, where $1\le h\le m$. Column $j$ is the vector +$(x_{1,j},\ldots,x_{m,j})$. A frame on this group is the tensor +product of the same phase frame +$\mathcal C_U$ of Proposition~\ref{prop:complex-motif-interface} +on these $f$ columns. + +To implement \eqref{eq:phase-edge-coordinate} on the group, first apply +$\mathcal P_M^{-1}$ separately to each column. For each +$1\le h\le\rho_{\rm edge}$, apply $(C^{\epsilon_h})^{\otimes f}$ to the +$f$ bits $x_{h,0},\ldots,x_{h,f-1}$. This is one child operation +on the $f$ axes in slot $h$. Finally apply $\mathcal P_M$ to every +column. A negative directional kernel still requires only one +forward child, because +\begin{equation}\label{eq:phase-inverse-child} + (C^{-1})^{\otimes f} + =(-i)^f Z^{\otimes f}C^{\otimes f}Z^{\otimes f}. +\end{equation} +The rightmost phase is applied first. All inverse wrappers are address +signs and constant fourth-root phases, so they add no recursive calls. + +Gaussian elimination expresses any $M\in\operatorname{GL}(m,\mathbb F_2)$ +as a product of at most $m(m-1)+3m$ elementary row additions: one clears +at most $m-1$ other entries per pivot, and each row swap is three row +additions. Reversing the elimination gives the required product since +each row addition is an involution. The number is a constant because +$m$ is fixed. Adding row $h'$ to row $h$ in every column applies +$x_{h,j}\leftarrow x_{h,j}\mathbin\oplus x_{h',j}$ for every +$0\le j1$, these segments +are disjoint, and the highest one ends immediately below $j_{f-1}$. +Write their initial values in $y$ and $z$ as +\[ + u_i=2g_i+a_i,\qquad w_i=2h_i+b_i, + \qquad a_i,b_i\in\{0,1\}. +\] +The values $g_i,h_i\in\{0,\ldots,2^{K-1}-1\}$ are the guard values. The +control for this pair of segments is the selected bit $c_i=x_{j_i}$. + +Apply each line of \eqref{eq:eight-packed-additions} simultaneously to all +these segment pairs. Physically, a line updating $y$ by sign $\varepsilon$ +and testing parity $b$ of $z$ is the single cyclic shift +\begin{equation} +\label{eq:packed-cyclic-shift} + y\longleftarrow y+ + \varepsilon\sum_{i=0}^{f-2}2^{j_i} + [\,x_{j_i}=1\,][\,z_{j_i}=b\,] + \pmod{2^L}. +\end{equation} +For a line updating $z$, interchange $y$ and $z$ in this formula. +The shift offset never depends on its target chunk, so each line is a +bijection of the rectangle. Let $S_0$ be their composition. It fixes +the spectator coordinates. + +Let $\mathcal B$ consist of the addresses for which +at least one used guard value, in either $y$ or $z$, fails +\begin{equation} +\label{eq:packed-guard-interval} + 10\le g\le 2^{K-1}-11. +\end{equation} +At an address outside $\mathcal B$, each segment initially lies in +$[20,2^K-21]$. Even displacement eight keeps it inside +$[0,2^K-1]$. Inductively, each packed addition therefore agrees with all +the independent segment additions: no segment carries into or borrows +from the next segment. When $f>1$, the bits below $j_0$ and above the +highest used segment are untouched as well. By +\eqref{eq:eight-packed-result}, $S_0$ +then agrees with the ideal permutation $T_0$ that performs the required +XORs at $j_0,\ldots,j_{f-2}$ and fixes all other address coordinates. + +There are exactly twenty excluded values for each guard in +\eqref{eq:packed-guard-interval}. Since its complete range has +$2^{K-1}$ values, the union bound over the $2(f-1)$ guards gives +\begin{equation} +\label{eq:packed-bad-fraction} + |\mathcal B|\le\delta_{\rm bad}M. +\end{equation} +Indeed, the complete $y,z$ ranges give the same guard distribution at +each choice of spectator coordinates. No record value enters this count. + +The ideal map $T_0$ preserves all guard values and therefore preserves +$\mathcal B$. Both $T_0$ and $S_0$ are bijections, and they agree off +$\mathcal B$. Taking complements in the finite rectangle gives +\[ + S_0(\mathcal B^c)=T_0(\mathcal B^c)=\mathcal B^c, + \qquad S_0(\mathcal B)=\mathcal B. +\] +Thus $T_0S_0^{-1}$ fixes $\mathcal B^c$ and permutes $\mathcal B$. +It remains to implement the rotations and this correction on tapes. + +For one rotation, move its target to the rightmost of the three chunk +positions if necessary. Let $P^{\rm sw}$ be the product of the record +field lengths before the earlier exchanged chunk, let $G^{\rm sw}$ +be the product between the exchanged chunks, and let $B^{\rm sw}$ be +$R$ times the product after the later one. Empty products are one. +The bit array has exactly the shape +\[ + [P^{\rm sw}]\times[2^L]\times[G^{\rm sw}] + \times[2^L]\times[B^{\rm sw}]. +\] +The third chunk lies inside one collapsed spectator interval. +Pass only $L$ and these three positive canonical lengths to +Lemma~\ref{lem:chunk-swap}. Each length is at most $V$, so the local +descriptor has $O(A_{\rm rect})$ bits. The swap costs $O(VL^\tau)$, including +its own padding and cleanup. + +The equal chunk lengths leave the field-length list unchanged by a +completed swap. Keep the permutation of the logical names $x,y,z$ in +finite local state. With the target now after its two controls, collapse +the remaining intervals to obtain +\[ + [\Lambda_0]\times[2^L]_{\rm control\,1}\times[\Lambda_1] + \times[2^L]_{\rm control\,2}\times[\Lambda_2] + \times[2^L]_{\rm target}\times[B_{\rm rot}], +\] +where $B_{\rm rot}$ includes the payload and every displayed spectator +length is positive. Their product with the chunk lengths is $V$. +Together with $K,f,\rho$ and the finite name permutation, these fixed +canonical lengths form an $O(A_{\rm rect})$-bit local descriptor. The offset +routine receives the two current $L$-bit logical control values. A scan +of at most $f\le L$ selected positions evaluates +\eqref{eq:packed-cyclic-shift} in $L^{O(1)}$ time, without reading the +target or spectator values. Lemma~\ref{lem:ordered-affine-streams} +therefore gives an $O(V)$ rotation: its offset work is absorbed by the +$2^L$ nonempty target blocks in each fiber. Undo the swap after the +rotation. The local descriptors and name permutation are updated at +completed swap boundaries; the primitives use their own descriptors +inside padded layouts. +There are at most sixteen swaps and eight rotations in $S_0$. + +To implement the correction, scan the stream with a record-rank counter. +All chunk names are back in their original positions. Dividing the +current rank through the fixed seven field lengths recovers the three +chunk values and their mixed-radix record strides. The strides exclude +the $R$ payload bits. All involved integers have $O(A_{\rm rect})$ bits, so +schoolbook arithmetic, descriptor copying, and resets take at most +$O(A_{\rm rect}^3)$ per record. Test membership in $\mathcal B$ and extract just +those records. For a current exceptional address $q$, compute +$q'=T_0(S_0^{-1}(q))$ by reversing the eight modular additions with +negated offsets, then applying the selected XORs directly. Each reversed +mask uses the current controls of that reversed line. There are at most +$f\le L\le A_{\rm rect}$ selected positions, so this calculation also fits +$O(A_{\rm rect}^3)$ time. + +If $q_h,q'_h$ are the current and destination values of chunk +$h\in\{x,y,z\}$ and $\sigma_h$ is its record stride, the fixed +spectator coordinates give +\[ + \operatorname{rank}(q')=\operatorname{rank}(q)+ + \sum_{h\in\{x,y,z\}}(q'_h-q_h)\sigma_h. +\] +The differences are signed. Attach this destination rank, padded to +$\lceil\log_2M\rceil\le A_{\rm rect}$ bits, to the extracted record, and mark its +hole on a fixed track of the full stream. Hold the full stream untouched +while stable binary radix sorting scans only the extracted records and +keys, least significant key bit first. Since $T_0S_0^{-1}$ permutes +$\mathcal B$, these keys are distinct and are exactly the ranks of the +marked holes. One forward full-stream scan reinserts the sorted records. +This implements $T_0$ everywhere. + +Finally apply the two-bit XOR to $x_{j_{f-1}},y_{j_{f-1}}$ by +Lemma~\ref{lem:elementary-streams}, splitting those chunks at the +selected positions and collapsing the other intervals. Its descriptor +again has a fixed number of positive lengths, each at most $V$. +This costs $O(V)$ and supplies the omitted selected position. When +$f=1$, $S_0,T_0$ are identities, $\mathcal B$ is empty, and this last +step is the entire algorithm. + +The movement costs $O(V(L^\tau+1))$. A fixed number of full record scans +costs $O(MA_{\rm rect}^3+V)$, and the at most $A_{\rm rect}$ radix passes cost +$O(|\mathcal B|A_{\rm rect}(R+A_{\rm rect}))$; skip them when the extracted bank is empty. +The initial descriptor has a fixed number of canonical integers of +$O(A_{\rm rect})$ bits, so its preparation is covered by $O(MA_{\rm rect}^3)$. +All counters, positioning, rewinds, and cleanup are included. +Equation~\eqref{eq:packed-bad-fraction} proves +\eqref{eq:packed-rectangle-time} on a fixed number of tapes. +After division by $V=MR$, its additional terms are bounded by +$A_{\rm rect}^3/R$ and +$80(f-1)2^{-K}A_{\rm rect}(1+A_{\rm rect}/R)$. Under the stated family bounds +the first tends to zero, and the second is +$O(p^2 2^{-K}(1+A_{\rm rect}/R))=o(1)$. This proves the final assertion. +\end{proof} + +\paragraph{Application to a fixed binary change of basis.} +An invertible matrix over $\mathbb F_2$ of fixed order $m\ge3$ is a +product of a fixed number of elementary row additions; a row exchange +is three such additions. In one invocation of the finite network on +$e=mf$ axes, slot $h$ consists of $f$ consecutive $K$-bit axis chunks. +It therefore has address-bit width $L=fK$, and its selected bits +$x_{h,j}$ occupy positions $\rho+jK$ for $0\le j1$. +For these fixed choices +there are a cutoff $p_0$, one fixed finite-alphabet multitape procedure, +and an implicit time constant with the following guarantee. The cutoff +and time constant may depend on the fixed rational parameters +and these constants. For every choice of positive integers $p,d,r$ +with $p\ge p_0$ and +\[ + a_dp^\epsilon\le d\le b_dp^\epsilon,\qquad + 2^{a_rp/d}\le r\le 2^{b_rp/d}, +\] +put $K=\lfloor d^c\rfloor$, and let $1\le D\le d$, $P,S\ge1$, and +$0\le\rho gS` with fixed +rational S. It does not exclude q-dependent cover entries, discard nonunit +pivots without charging the bad classes, or permit weights depending on a +child's fresh cover/roles. External weights may depend on exposed ancestors. + +Use the repaired power 768, cutoff 15, floor 16, logarithm power 617, +`H_B=296630000000000`, and the two separate 10^-10 losses. The covered +saving is .0038525298. Freeze two ordinary backends in order: + +``` +.0034 -> .0038507 -> .00385248. +``` + +The first backend is the selected completed .0034 interface, including its +spectators, restored stock and radix boundary. Each subsequent algorithm +uses only its completed predecessor for ordinary maps/high-part exchanges, +with atom exponent ρ=1/250. Its source-bound cost is +`O(C V [e^(1-ρ) + e^((1-ρ)(1-covered)+ρ(1-previous)) + e^ρ log e])`. +The exact positive bootstrap gaps were checked previously. C is the new +finite constant, not one. Freeze each backend's threshold before using it +in the next step; smaller widths use the predecessor. This dependency is +acyclic and supplies the weaker .00376669 used by the complex outer ledger. + +Reserve the full input-dependent row stock with +`D_stock(e)=2+ceil(log_(N_B)(max(1,ceil(e/ceil(e^ρ)))))` and +`W(w)^D_stock(e) S_old`, as in the pinned delayed-cover proof. The high-digit +reserve is `O_fixed(w log e)`. Internal BIT recursion preserves the entire +external complex factor and restores its own borrowed stock. The fixed two +backend levels are not substituted for the input-dependent recursion depth. + +## 4. Exact fixed-rational scalar service + +Choose the per-native-call scale-1125 route, not the independently rounded +ADD implementation. Multiply each actual public entrance by S=1125, execute +the literal word, and divide each completed output by S. All 53,280 boundary +conversions are counted. The previously checked row and pre-product invariant +proves odd divisibility on the common grid described below. + +For a fixed reduced scalar a/b, multiply an unsigned magnitude bit stream +least-significant-bit first. Its state is carry c, and the transition on bit +u emits `(c+|a|u) mod2` and retains `floor((c+|a|u)/2)`. The carry remains +between 0 and |a|; append `bitlength(|a|)+1` zero bits. Reverse direction +for division by fixed positive b. From remainder r and bit u, form `2r+u`, +emit its comparison with b, and keep the remainder after subtracting b when +necessary. Here `0<=r=1, +integer logarithmic degree d0 and positive rational slack δ in the retained +outer bounds, choose an integer j beyond `4d0/δ` with +`C(j+1)^d0 <= 2^(δj)` and freeze the input threshold at least 2^j. Subsequent +ratios decrease, so the inequality holds thereafter. Choose j on a multiple +of δ's denominator to make this an integer comparison. Likewise the retained +record fiber `2^(Omega(p^(1-epsilon)))` eventually exceeds every new fixed +descriptor polynomial; choose the cutoff after its constants/degrees. +Take the maximum of these finitely many cutoffs, the scalar-fit boundary, +stock conditions and the primitive-family cutoffs. No input-dependent +algorithm or growing tape alphabet is introduced by this choice. + +## 7. Compiler funding and outer conclusion + +The independently checked complex invoice has tested price +`C=.00363005817007=κ+7g`, `g=10^-14`. Use product power 1920, cutoff 11, +completion floor 12, offset 1/7 and actual ambient `153^1920`. +The certified bounds give `alpha<1-10^-27`, `gamma,delta<31/32` and +`1/(1+1920·10^-27)+4(31/32)^1920<1`. The separated paid ceiling is below +the target floor. Whole-job completion and integer splitting retain all +their arrays, paid positions and fresh adapters. + +The ambient-cap proof supplies the source band `(N/A,N]` with A=153^1920; +no target of rank A is needed. Logarithm power 2228 and +`H_C=14174600000000000000` give the checked uniform saving `κ+6g`. +All 54 strict and four functional outer predicates pass; their minimum +positive margin is 10^-15. The completed BIT saving .00385248 supplies the +weaker .00376669 premise with ample positive margin. Section 6 changes finite +constants and eventual thresholds, leaving these rank and exponent inequalities +unchanged. The resulting conclusion is the conditional bound + +`T(n)=O(n (log n)^(1-.00363005817))`. + +The five assumptions are still native_all_columns, owned_erasure, compiler, +precision_tape and analytic_recovery. Local owned ascent, global LAMBDA, +mixed/shared native calls and exact odd division have explicit applications +within those assumptions above. The conclusion does not admit arbitrary +rounded providers, the old numerical tape-cost cap, or newer words with the +same headline/interface names. Any changed source needs its affected checks. + +## Attribution and open next questions + +CubeJerry supplied #7000/#7001 and the precision, owned-ascent, global-LAMBDA +and compiler-application work. DreamingOfClouds supplied the shared native, +two-chain and helper constructions; Ali Romman supplied the helper-basis +lineage. Retain zxv's rational BIT/native/compiler work, Jacob Alan Sussman's +mixed integer compiler, icekylinx/Dugongue's frame theory, Cinna Davis, +Matarener, Chris R/Clear1nsight and all unchanged NOTICE attributions. +The phase-polynomial route method and common-grid induction are credited +reuses; the current occurrence map, complete catalogue closure, exact-scalar +application and finite-cost/root-boundary substitutions are this review's work. +Prepared for Douglas Colkitt with substantial OpenAI Codex assistance, +Apache-2.0; no separate human or formal-kernel verification. + +Open next questions: implement the complete fixed-tape dispatcher rather than +its conditional grammar; tighten the deliberately loose scalar/route constants; +and transfer this application to later changed words using exact-source deltas. +Those questions do not turn an archived successor into an admitted result. diff --git a/research/literal-layer-phase/reference/selected-result.json b/research/literal-layer-phase/reference/selected-result.json new file mode 100644 index 0000000000..75d77b328e --- /dev/null +++ b/research/literal-layer-phase/reference/selected-result.json @@ -0,0 +1,113 @@ +{ + "status": "Selected maintainer-reviewed conditional shared-native construction with exact-source application audit", + "kappa": "363005817/100000000000", + "decimal": "0.00363005817", + "source_prs": [ + 7000, + 7001, + 6936, + 6937, + 6980, + 6970, + 6985, + 6914, + 6912, + 6916, + 6726, + 6834, + 6030, + 5907, + 5827, + 5811, + 5960, + 5599, + 5565, + 5580, + 5569, + 5561, + 5551, + 5545, + 5544, + 5550, + 5567, + 2305, + 2152, + 2219, + 5398, + 5400, + 4610, + 5241, + 4470, + 4447, + 4441, + 4440, + 4416, + 4433, + 4359, + 4268, + 3945, + 4085, + 2979, + 4076, + 4088, + 1673, + 1758, + 1786, + 23, + 555, + 589 + ], + "source_manifest": "certificates/frontier7000-source.json", + "certificate": "certificates/frontier7000/CLAIM.json", + "certificate_sha256": "3f8add8252adb223b60418ec69351a69b6b5edfe601ec1c6b4b65cd9e2afd9b2", + "proof": "docs/research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md", + "proof_supplements": { + "research/p104-shared-native-helper-splits/retained/compiler/PROOF.md": "95cc9e31bc030ec94b04decddcca2d28ee98cfec0ca7803b54666b2b76a5c9ab", + "research/p104-shared-native-helper-splits/retained/compiler/bit-audit/PROOF.md": "ab5a2a5da1aab0193e286de8e16bc62840be760679c1f9e70218ce13225f69cf", + "research/kappa-rebuild/architecture/FINITE-PRECOMPILATION.md": "4cb32f6b8e388ecf6ed41b5bbdeeb4539cb40c8424f194974afea58f7e0921e8", + "research/final4610-independent-admission/SPECIALIZATION.md": "70430114f744108223bc1d44b98bc25b696c4b408b7b044c2a8bbdfdb434ac5c", + "research/odd-native-common-grid/PROOF.md": "b710cc953163ebe282fce7cf0a426744c155a0d5acbfb9bf7d67e81195b66a1e", + "notes/batched-bit-rows.tex": "ef72c0ead19373cbc19c8a3aacb44dd0f75353ee5f4d055f775a986a4878022c", + "notes/compact-control-movement.tex": "b963c3d2f4e1b7059aa289bb4b4ac89b688920bcf42f5b20d7698cdef0132cc6", + "notes/general-clifford-frames.tex": "c9bb9655b594583c6b4bab8cb485233f1d1e588f83858cf1e4c3530cee8fed54", + "upstream/build/sections/05-layers.tex": "20cfc8d12099d4e4ed9e3e7eeb6162edd9b6e0e076f24693364cd24377252594", + "notes/batched-complex-rows.tex": "64c70926a8705874f1c9b42a2f703e42cad4e90f927f544458cfdf729540236c", + "docs/research/pr-intake-evidence/pr7000-admission/PROOF-REVIEW.md": "00db61669b9f54266ece13db2bc3351d634cb202575d323ba360907f5edf68d9", + "docs/research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md": "4501502c2ceb9759b20372435fe4beb51082c5a5e2910c1fd5dbe6edca415055" + }, + "review": "docs/research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md", + "validation": "docs/research/pr-intake-evidence/pr7000-application/VALIDATION.json", + "reproduce": "make frontier7000-verify", + "scope": "Conditional shared-native mixed caller with exact common-grid scalar service; five inherited assumptions. No materialized uniform word, complete multiplier, independent human proof or formal-kernel acceptance.", + "previous_kappa": "781451/250000000", + "previous_record": "certificates/checkpoints/frontier6030.json", + "audited_source_head": "93effe2a135bf57b9e484cb630d8dd057159aec9", + "BIT_source_head": "d777f3a0aa2878bea0478918923dabcf86b9878b", + "source_certificate": "research/shared-wire-split-composition/FULL-RESULT.json", + "source_certificate_sha256": "d9ba709fa5dcefffe3f3abdcf34600ce188224703cfd743e6db8b58ba4816cb7", + "replay_mode": "Eleven unchanged exact-source executions reused from the preceding admission review; seven fresh serial application/scalar/full-native executions. Earlier monolithic timeout retained separately. Complete isolated cold replay supplied; five framework assumptions retained.", + "contributors": "docs/research/community-frontier7000-contributors.md", + "assumptions": [ + { + "id": "native_all_columns", + "statement": "Retained native operators, phase conventions, spectators and whole-job adapters work at every positive column multiplicity." + }, + { + "id": "owned_erasure", + "statement": "Owned streams and suspended centers obey the retained allocation, erasure and ownership contracts." + }, + { + "id": "compiler", + "statement": "The finite mixed-target compiler and chronological product, completion and splitting satisfy the retained uniform closure contract." + }, + { + "id": "precision_tape", + "statement": "Retained fixed-tape movement and precision/storage prescriptions apply to the new fixed finite template." + }, + { + "id": "analytic_recovery", + "statement": "Analytic decomposition, fine-prime avoidance and exact integer recovery follow the retained upstream/outer framework." + } + ], + "integration": "docs/research/pr-intake-evidence/pr7000-application/INTEGRATION.json" +} diff --git a/research/literal-layer-phase/reference/sequential-monomial-phase.py b/research/literal-layer-phase/reference/sequential-monomial-phase.py new file mode 100644 index 0000000000..2612604528 --- /dev/null +++ b/research/literal-layer-phase/reference/sequential-monomial-phase.py @@ -0,0 +1,125 @@ +"""Sequential counter production of source Gaussian monomial phases. + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +The tensor phase follows Jose Manuel's retained monomial implementation. +Counter amortization retains Cinna Davis and the PR4325 audit's credit. +""" +ZERO,ONE,LEFT,END,BLANK=range(5) + + +def need(ok,message): + if not ok:raise ValueError(message) + + +class Meter: + def __init__(self):self.reads=self.writes=self.moves=0 + @property + def total(self):return self.reads+self.writes+self.moves + + +class Tape: + """Hardware model; only current-symbol operations are algorithm inputs.""" + def __init__(self,prefix=(),meter=None): + self.cells=list(prefix)+[LEFT];self.head=len(self.cells);self.floor=self.head-1 + self.meter=meter if meter is not None else Meter() + def read(self): + need(self.head>=self.floor,'ancestor read');self.meter.reads+=1 + return self.cells[self.head] if self.head=self.floor,'owned finite-symbol write');self.meter.writes+=1 + while len(self.cells)<=self.head:self.cells.append(BLANK) + self.cells[self.head]=value + def move(self,direction): + need(direction in (-1,1),'unit move');self.head+=direction;self.meter.moves+=1 + need(self.head>=self.floor,'ancestor crossed') + + +def emit(tape,value):tape.write(value);tape.move(1) + + +def rewind(tape): + tape.move(-1) + while tape.read()!=LEFT:tape.move(-1) + tape.move(1) + + +class Phases: + """The recipe is compiled data; mask length and addresses stay on tapes.""" + def __init__(self,recipe,mask,counters): + self.alpha=tuple(recipe['linear_Z4']);self.quadratic=tuple(recipe['quadratic_rows']) + self.counters=tuple(counters);self.mask=mask;self.phase=0;self.done=False + m=len(self.alpha) + need(m>=1 and len(self.quadratic)==len(self.counters)==m,'compiled recipe extent') + need(all(type(a) is int and 0<=a<4 for a in self.alpha),'compiled linear phases') + need(all(type(a) is int and 0<=a<1<>max(i,j))&1: + other=tape.read();need(other in (ZERO,ONE),'aligned binary counter') + delta+=2*other + self.phase=(self.phase+delta)%4 + self.counters[i].write(1-bit) + if bit==0:self.restore_heads();return True + for tape in self.counters:tape.move(1) + self.mask.move(1) + for tape in self.counters:need(tape.read()==END,'equal counter extents') + self.restore_heads() + self.done=True + return False + def close(self): + need(self.done,'complete phase consumption') + for tape in self.counters: + while (symbol:=tape.read())!=END: + need(symbol in (ZERO,ONE),'counter cleanup');emit(tape,BLANK) + emit(tape,BLANK);need(tape.read()==BLANK,'counter end');rewind(tape) + + +def apply_phase(source,producer,coefficient_bits,TapeClass,copy,inverse=False): + """Retained Gaussian coefficient loop, driven by physical phase overflow. + + This is adapted from the pinned monomial.phase_pass. Sequential coefficient + primitives and their precision contract remain inherited. + """ + need(coefficient_bits>=2,'Gaussian coefficient extent') + source.rewind();out=TapeClass(source.meter);real=TapeClass(source.meter);imag=TapeClass(source.meter) + def coefficient(tape,negative): + if negative: + carry=1 + for _ in range(coefficient_bits): + value=(1-tape.read(1)[0])+carry + out.write(bytes((value&1,)));carry=value>>1 + else:copy(tape,out,coefficient_bits) + tape.finish() + while True: + phase=(-producer.phase if inverse else producer.phase)%4 + source.meter.control_evaluations+=1 + copy(source,real,coefficient_bits);copy(source,imag,coefficient_bits) + real.rewind();imag.rewind() + if phase==0:coefficient(real,False);coefficient(imag,False) + elif phase==1:coefficient(imag,True);coefficient(real,False) + elif phase==2:coefficient(real,True);coefficient(imag,True) + else:coefficient(imag,False);coefficient(real,True) + real.erase();imag.erase() + if not producer.advance():break + source.finish();source.erase();out.rewind();producer.close();return out diff --git a/research/literal-layer-phase/reference/sequential-monomial-proof.md b/research/literal-layer-phase/reference/sequential-monomial-proof.md new file mode 100644 index 0000000000..42ffd4007c --- /dev/null +++ b/research/literal-layer-phase/reference/sequential-monomial-proof.md @@ -0,0 +1,167 @@ +# Sequential production of the actual monomial phase + +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. + +## Source contract and result + +Jose Manuel's [PR #2250](https://github.com/CrocSwap/integer-mult-bounds/pull/2250) +implements the Gaussian monomial with the retained +[source phase formula](https://github.com/CrocSwap/integer-mult-bounds/blob/7c472563474e60185e6ca101a17622133d047e56/research/selected-complex-compact-adapters/monomial.py). +Its phase_pass calls tensor_phase on decoded addresses. This package replaces +that address oracle with sequential counter tapes. The retained algebra and +Gaussian coefficient operations are not new results. + +Fix a compiled recipe of dimension m>=1. Its linear coefficients alpha_i are +in Z/4, its quadratic bits Q_ij use only i=1 binary symbols followed by END. Its +ones identify active low-bit positions in each of m equal-width fields. +For the source geometry, b=fK and the ones are rho+jK, 0<=j=1 bits. Each changed bit costs +at most m+2 reads/writes for the mask, old bit, cross terms and update. Carry +movement costs at most (m+1)t. The final rewinds cost at most +(m+1)(2t+3). END checks cost at most m+1. The total is at most +(4m+5)t+4(m+1), hence at most 9(m+1)t. + +Across all R increments, including the final wrap, the global mb-bit counter +changes exactly 2R-2 bits. Grouping them by field does not change that sum. +Therefore all advance operations cost less than 18(m+1)R. Counter cleanup +costs m(5b+9), including each erased END, blank check and final rewind. +Combining these quantities gives the stated conservative bound. + +The owned counter bodies use m(b+1) cells, plus their LEFT markers. The +borrowed mask uses b+1 body cells plus its LEFT marker. Blank counter backing +remains physical capacity after cleanup. Fixed recipe tables contain O(m^2) +compiled bits. There is no R-entry phase cache. The caller consumes each +four-state output before advancing; it must pay for any retained copy. + +## Actual Gaussian consumer + +apply_phase retains the source's real/imaginary coefficient loop, with two +coefficient scratch tapes and one-bit negation carry. Its loop is driven by +physical counter overflow, not layout.records or layout.decode. It consumes +one Gaussian coefficient per record in the demonstrated ABI. Multiple packed +coefficients require a separately bound repetition grammar. + +For coefficient width p>=2 and V=2pR payload bits, the retained coefficient +path uses exactly 18V source tape actions when erases are counted as one +operation per erased cell. This includes input consumption and erasure, +coefficient scratch cleanup, and output head return. The new complete local +phase/coefficient interval therefore costs at most + +```text +18V + 32(m+1)(R+b+1). +``` + +The input is owned and consumed. A caller which must preserve it needs a paid +copy. Borrowed mask and dirty counter ancestors are preserved. The output is +separately owned; its V cells and the two p-cell coefficient scratch bodies +remain charged. Coefficient primitives retain their source representation +and precision assumptions. Equality is exact modulo 2^p; ordinary Gaussian +integer interpretation also needs the source's symmetric headroom condition. + +For an inverse monomial, apply the negative phase after the affine inverse +has recovered the input coordinates. This producer does not authorize phase +evaluation on unrecovered output coordinates. Zero-coefficient equal-width +spectator fields can be inserted into the compiled recipe; their counters +still determine physical record order. Other mixed-width packing geometries +remain a caller integration obligation. + +## Evidence and limits + +The actual recipe is the retained family 65689/event 8814 right recipe, with +offset 426 and absolute phase 1. Its affine map is not executed by this package; +only its phase is supplied here. The source binding and native scalar theorem +remain inherited from the pinned package, not independently rederived. + +The verifier checks 224 generic complete domains with 9760 records. Three +actual source domains contain 512,262144,262144 records. They cover f=1,K=1, +f=2,K=1, and f=1,K=2,rho=1, including inactive bits and the nonzero tensor +constant. Six 1024-record payload cases include an independent spectator bit, +both signs and dirty ancestor lengths 16,257,4096. They match the unchanged +source output, a separate modular Gaussian oracle and every coefficient +meter field. Each adds 120506 physical phase actions. Six malformed-state +controls reject. Failed ABI calls need not restore partial work. + +Mask manufacture, arbitrary mixed-width caller packing, affine routing, +recursive C, physical owner allocation, production codebook, full monomial +invoice, native/stock/precision and outer recovery remain separate. No full +147-bit production payload was materialized. The complete kappa calculation +and selected frontier are unchanged. Independent human and proof-kernel +acceptance remain open. diff --git a/research/literal-layer-phase/verify.py b/research/literal-layer-phase/verify.py new file mode 100644 index 0000000000..f098adb13e --- /dev/null +++ b/research/literal-layer-phase/verify.py @@ -0,0 +1,276 @@ +"""Bounded execution, source pins, address oracle and failure controls.""" +from pathlib import Path +import hashlib +import json +import random +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import phase as P +import oracles as O + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +class AuditTape(P.Tape): + """Observers enforce current owned windows; no observer enters control.""" + def begin(self, origin, extent, public=False): + self.origin, self.extent, self.public = origin, extent, public + self.epoch_low = self.epoch_high = origin + self.write_count = 0 + + def check(self): + need(self.origin-(not self.public) <= self.head <= self.origin+self.extent, + 'current-window head bound') + + def read(self): + self.check() + return super().read() + + def write(self, symbol): + self.check() + self.write_count += 1 + super().write(symbol) + + def move(self, direction): + need(direction in (-1, 1), 'literal unit move') + super().move(direction) + self.check() + self.epoch_low = min(self.epoch_low, self.head) + self.epoch_high = max(self.epoch_high, self.head) + + +def extents(parameters): + p, d, r, dimension, outer, spectator, block, select, width = parameters + volume = 2*width*O.cardinality(parameters) + E = len(O.header(parameters)) + result = [E, volume, volume, E, max(v.bit_length()-1 for v in parameters), + max(parameters), p, d, r, dimension, outer, spectator, block, + select, width, dimension*block, dimension*block, width, width, volume] + return result + + +def run_case(code, parameters, values=None, *, offset=0, tapes=None, + expected_reject=False, source_edit=None, public_reserve=0): + width = parameters[-1] + count = O.cardinality(parameters) + if values is None: + values = [(1, -1)]*count + need(len(values) == count, 'oracle input cardinality') + predicted = O.expected(parameters, values) + fitting = O.fits(predicted, width) + E = len(O.header(parameters)) + volume = 2*count*width + capacities = extents(parameters) + if tapes is None: + tapes = [] + for i in range(20): + origin = offset+11*i-71 + cells = {origin-4: '0', origin-3: '|', origin-2: '1'} + tape = AuditTape(cells, origin) + # Initial history includes opaque prefixes and a paid clean old tail. + tape.low, tape.high = origin-4, origin+307 + tapes.append(tape) + identities = tuple(map(id, tapes)) + starts = [t.head for t in tapes] + old_history = [(t.low, t.high) for t in tapes] + initial_private = sum(t.high-t.low+1 for t in tapes[2:]) + for i, tape in enumerate(tapes): + tape.begin(starts[i], capacities[i], public=i<2) + for i, word in ((P.HEADER, O.header(parameters)), (P.DATA, O.encode(values, width))): + # Caller source acquisition/re-encoding is outside the measured table. + tape = tapes[i] + tape.cells = {k: v for k, v in tape.cells.items() if k < tape.origin or k >= tape.origin+900_000} + if i == P.DATA and source_edit is not None: + word = source_edit(word) + tape.cells.update({tape.origin+j: bit for j, bit in enumerate(word)}) + suffix = len(word) if i == P.HEADER else max(volume, len(word), public_reserve)+1 + tape.cells.update({tape.origin+suffix: '1', tape.origin+suffix+1: '|'}) + before = [dict(t.cells) for t in tapes] + budget = 65536*(E+parameters[0]+parameters[1]+parameters[3]*parameters[6]+count*width+1) + machine = P.Machine(code, tapes) + failed = False + try: + machine.run(budget) + except ValueError as error: + need(str(error) == 'invalid scanned symbol', 'unexpected failure: '+str(error)) + failed = True + if expected_reject or not fitting: + need(failed, 'invalid/range packet accepted') + need(tapes[P.DATA].cells == before[P.DATA], 'rejection changed public DATA') + need(tapes[P.DATA].write_count == 0, 'rejection wrote DATA before commit') + return dict(parameters=parameters, count=count, steps=machine.steps, outcome='reject'), tapes + need(not failed, 'valid fitting packet rejected') + need(tuple(map(id, tapes)) == identities, 'changed tape ownership') + need(all(t.head == head for t, head in zip(tapes, starts)), 'head return') + output = ''.join(tapes[P.DATA].cells.get(starts[P.DATA]+j, P.BLANK) for j in range(volume)) + need(output == O.encode(predicted, width), 'explicit-address Gaussian result') + need(tapes[P.HEADER].cells == before[P.HEADER], 'header preservation') + wanted = dict(before[P.DATA]) + wanted.update({starts[P.DATA]+j: bit for j, bit in enumerate(output)}) + need(tapes[P.DATA].cells == wanted, 'public exterior preservation') + for i in P.PRIVATE: + need(tapes[i].cells == before[i], 'private retirement/exterior preservation') + need(all(t.low <= lo and t.high >= hi for t, (lo, hi) in zip(tapes, old_history)), 'history reset') + history = sum(t.high-t.low+1 for t in tapes[2:]) + bound = initial_private+4*volume+32*(E+parameters[0]+parameters[1]+parameters[3]*parameters[6]+width+1) + need(history <= bound, 'historical backing envelope') + need(machine.steps <= budget, 'instruction envelope') + need(tapes[P.DATA].write_count == volume, 'whole original-owner install') + return dict(parameters=parameters, count=count, steps=machine.steps, outcome='success', + private_history=history, time_bound=budget, history_bound=bound), tapes + + +def mutant(old, new): + source = (HERE/'phase.py').read_text() + need(source.count(old) == 1, 'unique semantic mutation anchor') + namespace = {'__file__': str(HERE/'phase.py'), '__name__': 'disposable_phase_mutant'} + exec(compile(source.replace(old, new), '', 'exec'), namespace) + return namespace['compile_phase']()[0] + + +def main(): + pins = json.loads((HERE/'SOURCES.json').read_text()) + for pin in pins['files']: + data = (HERE/pin['local']).read_bytes() + need(len(data) == pin['bytes'], 'source byte count') + need(hashlib.sha256(data).hexdigest() == pin['sha256'], 'source SHA256') + need(hashlib.sha1(b'blob '+str(len(data)).encode()+b'\0'+data).hexdigest() == pin['blob'], 'source Git blob') + code, alphabet = P.compile_phase() + need(len(code) == 2146, 'fixed graph size') + for instruction in code: + op = instruction[0] + need(op in ('read', 'write', 'move', 'goto', 'halt'), 'literal opcode') + if op in ('read', 'write', 'move'): + need(type(instruction[1]) is int and 0 <= instruction[1] < 20, 'fixed tape selector') + if op == 'move': + need(instruction[2] in (-1, 1), 'unit displacement') + if op == 'goto': + need(type(instruction[1]) is int and 0 <= instruction[1] < len(code), 'fixed target') + if op == 'read': + need(all(symbol in alphabet and type(target) is int and 0 <= target < len(code) + for symbol, target in instruction[2].items()), 'local finite transition') + rng = random.Random(0x53757350) + runs = [] + geometry_count = 0 + for dimension in range(1, 5): + for block in range(1, 5): + if dimension*block > 8: + continue + for rho in range(block): + for r, outer, spectator in ((1, 1, 1), (2, 2, 3)): + precision = 2+(dimension+block) % 2 + width = precision+2+(rho % 2) + parameters = (precision, dimension+block % 2, r, dimension, + outer, spectator, block, rho+1, width) + bound = (1 << (width-1))-1 + values = [(rng.randint(-bound, bound), rng.randint(-bound, bound)) + for _ in range(O.cardinality(parameters))] + receipt, _ = run_case(code, parameters, values, offset=geometry_count-81) + runs.append(receipt) + geometry_count += 1 + # Isolate every signed 3-bit Gaussian pair at each possible phase. + numeric_count = 0 + numeric_parameters = (1, 3, 1, 3, 1, 1, 1, 1, 3) + target_addresses = (0, 1, 3, 7) + for mode, address in enumerate(target_addresses): + for real in range(-4, 4): + for imag in range(-4, 4): + values = [(0, 0)]*8 + values[address] = (real, imag) + receipt, _ = run_case(code, numeric_parameters, values, offset=17-mode) + runs.append(receipt) + numeric_count += 1 + for parameters in ((1, 1, 31, 1, 1, 1, 1, 1, 3), + (1, 1, 1, 1, 29, 1, 1, 1, 3), + (1, 1, 1, 1, 1, 37, 1, 1, 3), + (3, 1, 1, 1, 1, 1, 8, 8, 5), + (127, 129, 1, 1, 1, 1, 1, 1, 129), + (1, 1025, 1, 1, 1, 1, 1, 1, 3)): + receipt, _ = run_case(code, parameters) + runs.append(receipt) + # Source re-encoding is caller work; private owner/history objects persist. + tapes = None + reuse = [] + for parameters in ((2, 3, 2, 3, 2, 2, 2, 2, 4), + (1, 1, 1, 1, 1, 1, 1, 1, 3), + (1, 1025, 1, 1, 1, 1, 1, 1, 3), + (2, 2, 3, 2, 1, 2, 3, 2, 5), + (1, 1, 1, 1, 1, 1, 1, 1, 3)): + receipt, tapes = run_case(code, parameters, tapes=tapes, offset=-99) + runs.append(receipt) + reuse.append(receipt) + invalid = [] + for label, parameters, edit in ( + ('D exceeds d', (1, 1, 1, 2, 1, 1, 1, 1, 3), None), + ('rho exceeds block', (1, 1, 1, 1, 1, 1, 2, 3, 3), None), + ('insufficient final width', (2, 1, 1, 1, 1, 1, 1, 1, 3), None), + ('extra payload bit', (1, 1, 1, 1, 1, 1, 1, 1, 3), lambda word: word+'0'), + ('truncated payload', (1, 1, 1, 1, 1, 1, 1, 1, 3), lambda word: word[:-1])): + receipt, _ = run_case(code, parameters, expected_reject=True, source_edit=edit) + invalid.append(dict(label=label, **receipt)) + cases = ( + ('inactive flips change phase', + 'nxt = (mode + (1-2*bit)*active) % 4', + 'nxt = (mode + (1-2*bit)) % 4', (1, 2, 1, 2, 1, 1, 2, 2, 3), None), + ('carry loses subtraction', + 'nxt = (mode + (1-2*bit)*active) % 4', + 'nxt = (mode + active) % 4', (1, 2, 1, 2, 1, 1, 1, 1, 3), None), + ('mask producer omits active bit', + "('mask_active', ONE, 'build_after')", + "('mask_active', '0', 'build_after')", (1, 1, 1, 1, 1, 1, 2, 2, 3), None), + ('coefficient repetition bypassed', + "a.op('goto', 'coefficient'+str(mode))", + "a.op('goto', 'coefficient_end'+str(mode))", (1, 1, 2, 1, 1, 1, 1, 1, 3), None), + ('signed minimum wraps silently', + "{MARK: 'reject' if old_sign and new_sign else k+'done'}", + "{MARK: k+'done'}", (1, 1, 1, 1, 1, 1, 1, 1, 3), [(0, 0), (0, -4)]), + ('header return omitted', + 'trace_return(a, HEADER, HTRACE)', + "a.op('goto', 'dimension_check')", (1, 1, 1, 1, 1, 1, 1, 1, 3), None), + ('original owner return omitted', + "a.mark('committed')\n trace_return(a, DATA, DTRACE)", + "a.mark('committed')", (1, 1, 1, 1, 1, 1, 1, 1, 3), None)) + detected = [] + for label, old, new, parameters, values in cases: + broken = mutant(old, new) + try: + run_case(broken, parameters, values) + except ValueError: + detected.append(label) + else: + raise ValueError('undetected semantic mutation: '+label) + # Count XOR changes independently of the producer's carry loops. + carry_counts = [] + for length in range(1, 17): + records = 1 << length + actual = sum((x ^ ((x+1) % records)).bit_count() for x in range(records)) + need(actual == 2*records-2, 'exact complete-domain carry census') + carry_counts.append(dict(length=length, records=records, bit_changes=actual)) + receipt = dict(status='PASS_LITERAL_LAYER_PHASE', base=pins['base'], + program_instructions=len(code), tapes=20, private_roles=18, + source_sha256=hashlib.sha256((HERE/'phase.py').read_bytes()).hexdigest(), + program_sha256=hashlib.sha256(json.dumps(code, separators=(',', ':'), sort_keys=True).encode()).hexdigest(), + source_pins=len(pins['files']), geometry_cases=geometry_count, + exhaustive_numeric_cases=numeric_count, runs=len(runs), + coefficients=sum(r['count'] for r in runs), + numerical_rejections=sum(r['outcome']=='reject' for r in runs), + total_transitions=sum(r['steps'] for r in runs), + maximum_transitions=max(r['steps'] for r in runs), + invalid_controls=invalid, detected_semantic_mutations=detected, + reuse_sequence=reuse, carry_census=carry_counts, + seed='0x53757350', + limits=['Universal correctness rests on the written proof, not finite coverage.', + 'No recursive C, payload permutation, compiler admission or full multiplier.', + 'No source acquisition cost or failure recovery is silently supplied.']) + if '--write' in sys.argv: + (HERE/'RESULT.json').write_text(json.dumps(receipt, indent=2, sort_keys=True)+'\n') + print(json.dumps(receipt, sort_keys=True)) + + +if __name__ == '__main__': + main()