From 80f02b1057a4b199870ff68181ba4d4226fd2438 Mon Sep 17 00:00:00 2001 From: JoyboyBrian <122925040+JoyboyBrian@users.noreply.github.com> Date: Sat, 24 Oct 2026 21:00:11 -0700 Subject: [PATCH 1/2] Implement complete-fiber low commit and paid cache retirement --- research/bit-full-fiber-low-commit/PROOF.md | 180 +++++++++++++++++ research/bit-full-fiber-low-commit/README.md | 86 ++++++++ .../bit-full-fiber-low-commit/RESULT.json | 190 ++++++++++++++++++ .../bit-full-fiber-low-commit/SOURCES.json | 72 +++++++ research/bit-full-fiber-low-commit/TASK.json | 74 +++++++ .../bit-full-fiber-low-commit/VERIFY.json | 40 ++++ .../bit-full-fiber-low-commit/controller.py | 122 +++++++++++ research/bit-full-fiber-low-commit/loader.py | 35 ++++ .../type_compiler.py | 52 +++++ research/bit-full-fiber-low-commit/verify.py | 152 ++++++++++++++ 10 files changed, 1003 insertions(+) create mode 100644 research/bit-full-fiber-low-commit/PROOF.md create mode 100644 research/bit-full-fiber-low-commit/README.md create mode 100644 research/bit-full-fiber-low-commit/RESULT.json create mode 100644 research/bit-full-fiber-low-commit/SOURCES.json create mode 100644 research/bit-full-fiber-low-commit/TASK.json create mode 100644 research/bit-full-fiber-low-commit/VERIFY.json create mode 100644 research/bit-full-fiber-low-commit/controller.py create mode 100644 research/bit-full-fiber-low-commit/loader.py create mode 100644 research/bit-full-fiber-low-commit/type_compiler.py create mode 100644 research/bit-full-fiber-low-commit/verify.py diff --git a/research/bit-full-fiber-low-commit/PROOF.md b/research/bit-full-fiber-low-commit/PROOF.md new file mode 100644 index 0000000000..2006e2c0b3 --- /dev/null +++ b/research/bit-full-fiber-low-commit/PROOF.md @@ -0,0 +1,180 @@ +# Full-fiber low-type commit on a literal fixed-tape machine + +## Actual consumer and precise closure boundary + +The pinned PR4989 helper462/frame506 route writes a cover address as +`G=G0+qG1`, N=8f, D=N^2, with G0 in GL_N(F_q). After its emitted high linear +word and old-low carry shifts, `low_type_commit` changes the low label to +`G0 S mod q`, where S is the actual S8 tensor I_f, or its inverse. The inherited +interpreter updates this label with host matrix arithmetic. The physical +full-array representation is a contiguous bit stream indexed in order by + +`(G0, G1[0], ..., G1[D-1], z)` + +with low types in lexicographic row-major order, every high coordinate in +`[Q]`, Q=q^(w-1), and the complete remaining spectator tuple flattened into +`[Z]`. Thus T=|GL_N(F_q)|, H=Q^D Z and V=T H. All bits are arbitrary. There is +no tagged-record restriction and no sparse payload assumption. + +This package implements exactly the missing low-type commit consumer, source +installation, and old-cache retirement. The unchanged high-coordinate and +carry suppliers are **named composition premises** below. No literal composed +machine for every high leaf, first-coordinate OLD repair, native call, P3 stock +or full selected supplier is claimed. This distinction is intentional: a +physical full-fiber consumer is a new result beyond descriptor preparation, +while a complete route would additionally need those actual supplier calls +and their caller binding. The low-commit machine is not merely an API join. + +## Finite type compilation and layout binding + +For an admitted odd prime q, the compiler reduces the rational source S modulo +q, checking all denominators are units and S invertible. It enumerates every +q^(N^2) matrix in lexicographic order and retains the invertible ones by modular +elimination. The ordered list L has exactly T elements. It computes +`pi(i)=index(L[i] S mod q)`; inverse direction uses S^-1. Right multiplication +is a bijection of GL, so pi is a permutation. `compile_types` performs exactly +this pre-input operation; it accepts no runtime width or payload. + +The compiler also emits the canonical b-bit digits of every old low matrix, +b=ceil(log2 q), giving an owned old-cache stream of K=T D b bits. This is a +complete low-type cache layout; the old label is an enumerated finite control +case, not copied productive payload. Its allocation and initialization are +not free: the separate `compile_cache` program checks blank cells, writes and returns +the marked K-bit cache in at most 5K+16 transitions before any descriptor use. It remains live throughout all dependent +old-low descriptor reads and until the completed low-commit output is installed. +The commit stage consumes that correctly owned marked cache, checks every bit +against its compiler-known old value, and only then proceeds. This is an +explicit boundary: a caller with only one per-fiber cache must serialize that +layout conversion and pay K; it may not claim this machine accepts its old +single-cache ABI unchanged. + +The instruction program unrolls pi^-1 as finite state control, with no runtime +permutation table lookup. Its length is O(T^2+K+D). A conservative pre-input +work envelope is O(q^D N^3 (log q)^2 + T D log q + T^2 + D) exact bit operations, +plus rational source reduction and inverse preparation. Schoolbook modular +elimination may be bounded more loosely by an additional log q factor without +changing the fixed-parameter conclusion. No GL8(Fq) enumeration is executed in +our bounded validation, and these enormous finite constants are not asserted +practical or already admitted by P3. + +## Machine contract and generated fiber length + +The seven-symbol instruction set, assembler, binary-to-unary macro and primary +interpreter are retained byte-for-byte from David Arias's PR2776 line. Every +runtime instruction is a single-symbol branch, single-cell write, unit move, +fixed jump, halt or reject. There are D+8 tapes: the owned source, blank output, +preserved canonical binary Q and Z descriptors, owned old cache, binary work, +fiber-length counter, D high-coordinate counters and one spectator counter. +All physical tape roles are distinct. Each has an independently supplied origin. +The source and cache have LEFT/RIGHT delimiters and initial head at first bit; +all private tapes start wholly blank at origin. Supplying blank ownership is a +premise, not inferred from inspection of one cell. Invalid-input rejection need +not roll back a partially written source. + +The machine first initializes private left markers and validates all K old-cache +bits and its right endpoint, returning that head. It converts Q to each of D +unary counters and Z to one unary counter using the inherited paid converter. +Nested unit-counter loops emit one UNIT on the H tape for each tuple of high +coordinates and spectator value. There are exactly Q^D Z leaves. The program +then appends RIGHT and restores every loop counter and H head. No runtime +multiplication, exponentiation, random addressing or free extent table occurs. +The finite compiler emits the loop nests iteratively, so it has no recursive +Python-depth limitation in D. Q=1 is supported as a calibration boundary; +actual source routes have Q>=3. The proof covers all positive Q,Z and D>=1. + +## Complete payload permutation, installation and cache lifetime + +A segment loop advances the source head exactly H cells by consuming and +rewinding the unary H counter. A copy segment branches on every source bit, +writes that bit to the next output cell, and advances both heads. A skip segment +only validates and advances the source. The machine first scans all T source +segments and requires RIGHT at exactly V; this validates complete shape before +source mutation. + +For output block k it rewinds the preserved source, skips pi^-1(k) segments, +and copies its next segment. Exactly one complete block goes to each output +position. Within each block every high coordinate and spectator position is +unchanged, so the push map is `(i,h,z)->(pi(i),h,z)` for arbitrary payload bits. +This is a sequential multipass construction. The potentially T-fold rescan +cost is charged, not hidden behind a gather primitive. + +After output completion, source and output heads are returned. One sequential +pass overwrites each original source cell from output while erasing that output +cell. The source right marker is checked at the same length. The output RIGHT +and LEFT markers are erased and its head returns to its blank origin. The +source remains the same physical owner, with transformed contents and original +head. Only now is the old-cache region erased, including both markers, and its +head returned to its allocation origin. All unary counters and binary work are +also erased and returned. The Q,Z descriptors are unchanged byte-for-byte with +their original heads. No productive output or old cache is discarded before its +last read. Erasure of the old cache is legal because it is owned control data, +not an arbitrary borrowed stream. + +## Explicit transition and visited-space bounds + +Write K=TDb for the source-specific old cache, or any declared finite cache +length for the generic commit. One converter costs at most 44n transitions. +The D Q counters and Z therefore cost at most 44(DQ+Z), at most 44(D+1)H. +The nested emission loops and their rewinds cost at most 16(D+1)H: at each +level the sum of its iterations and rewind lengths is at most a constant times +H, because every prefix has at least one completion. Initialization and final +counter erasure add at most 16(D+1)H+32(D+1). + +A segment costs at most 16H+8 including its H-counter rewind, whether copied +or skipped. Validation uses T segments. Gathering uses +`sum_k (pi^-1(k)+1)=T(T+1)/2` segments, plus T source rewinds, each at most +3V+3. Output/source installation, marker removal and returns cost at most +24V+24. Cache validation and retirement cost at most 8K+8. With H>=1 and +V=TH, the following deliberately loose envelope covers all these instructions: + +`transitions <= 128(T+D+1)V + 8K + 128D`. + +The implemented separate cache initializer adds at most 5K+16. For fixed +N,q, both terms are O_(N,q)(V), since K=TDb<=Db V. This does not assert a small +constant or a whole supplier recurrence. + +Source and output consume at most 2V+4 visited cells; the H counter consumes +H+2; D Q counters, Z counter, binary work and input descriptors consume at most +(D+3)H+O(D); old cache consumes K+2. The conservative checked envelope is + +`visited cells <= (D+5)V + 2K + 64(D+1)`. + +It includes cells subsequently erased. Tape translations change no interval +length. Runtime width enters through Q and payload H, not program size. + +## Composition with the actual carry route, without hiding unresolved leaves + +Let the supplied high linear route map G1 to `G1 S mod Q` while preserving +old G0. For each of D cells the supplied descriptor/carry routine adds +`C=(G0 S_mod(qQ) - (G0 S_mod(qQ) mod q))/q mod Q`, calculated from the **old** +low cache. This is exactly the pinned PR4989 arithmetic. After all those +shifts, low commit moves the whole high/spectator block from G0 to G0S mod q. +The rebuilt address is therefore `(G0+qG1) S mod qQ`. Inverse source direction +uses the inverse matrix, its own old cache and its own carry values; it cannot +reuse forward descriptors. Thus composition is an all-input group permutation +under these explicit upstream primitive contracts. + +The inherited frontend costs at most +`T D (64Db + 256 bit_length(Q) + 2048)` transitions for actual S8 tensor I_f. +With correctly isolated complete fibers, the inherited later-target shear +contributes at most 1024 D V. Translating high coordinate zero still requires +the two completed OLD swaps around its later-target shear, costing +`2 T A_OLD(H,w)` plus actual installations. Those OLD calls, isolation, complete +high-route leaves, descriptor construction for all extents, and their physical +caller integration are **not implemented by the low-commit machine** and are +not zero. Its new K cache and finite-state constants must also enter P3. The +full route cannot be declared physically admitted from this local result. + +## Evidence and scope + +The verifier executes both directions on **all 48 low types of GL2(F3)**, with +complete high/spectator payloads for Q=1 and Q=3, D=4, Z=1 or 2, translated +origins and arbitrary bit patterns. A separate exact local interpreter agrees +with the inherited machine on reduced complete cases. All eight bit inputs of +a three-block case are exhausted. Source-bound S8 forward/inverse modular +checks cover actual N=8 low inputs, q=3/5/7 and w=2/4; those are source-binding +checks, not executions of the astronomically large actual full GL8 array. +The written loop/ownership invariants, not finite extrapolation, give the all-Q +statement. Missing source bits, stale old cache, zero extent and nonpermutation +compiler inputs reject. No native, selected-frontier, Lean or Docker replay is +claimed. All predecessor mathematical and machine assumptions remain explicit. diff --git a/research/bit-full-fiber-low-commit/README.md b/research/bit-full-fiber-low-commit/README.md new file mode 100644 index 0000000000..2219b783cc --- /dev/null +++ b/research/bit-full-fiber-low-commit/README.md @@ -0,0 +1,86 @@ +# Literal complete-fiber low commit and old-cache retirement + +The actual helper462/frame506 route's `low_type_commit` now has a physical +consumer on a complete array: it moves each old-low block G0 to G0S modulo q, +preserves every high/spectator position inside that block, installs the result +into the same source owner and erases the old cache and private storage. +All runtime instructions are local symbol operations and unit head moves. + +[PROOF.md](PROOF.md) specifies the actual layout and universal loop invariants. +For T low types, D high coordinates, runtime Q,Z, V=T Q^D Z and K=TDb old-cache +bits, the commit costs at most `128(T+D+1)V+8K+128D` transitions and +`(D+5)V+2K+64(D+1)` visited cells. A separate literal initializer prepares the +complete old cache in at most `5K+16` transitions. Runtime extent multiplication +is performed by nested tape loops, not a host arithmetic instruction. Finite +compilation and repeated source scans are explicitly charged; these large +constants are not optimized or admitted P3 coefficients. + +**This completes the physical low-commit consumer, not the entire physical +route.** Composition with the old-low carry frontend and high linear route is +proved under their named contracts. Complete high-leaf implementation, actual +per-fiber isolation and descriptor linking, the first-coordinate two-OLD-swap +repair, native/ROW callers and P3 remain open. The changed full-cache layout +costs K owned bits and must be bound by any caller replacing a single-cache +layout. No new kappa, supplier admission or selected-frontier change follows. +The selected conditional record remains PR5413, 0.003027288235. + +## Reproduce + +Standard-library Python 3.12: + +```sh +python3.12 -I -B research/bit-full-fiber-low-commit/verify.py +python3.12 -I -O -B research/bit-full-fiber-low-commit/verify.py +python3.12 -B scripts/research_package.py --package research/bit-full-fiber-low-commit +``` + +Expected: `PASS_FULL_FIBER_LOW_COMMIT`. Ordinary replay is read-only and checks +[RESULT.json](RESULT.json); explicit `--write-result` regenerates it. +Both directions execute the complete 48-type GL2(F3) domain at Q=1 or 3 and +Z=1 or 2, including every high/spectator bit and translated tape origins. +An independent local interpreter agrees with the retained machine on small +complete cases; all eight inputs of a three-block bit example are exhausted. +Actual S8 source checks use q=3,5,7 and w=2,4. They bind the mathematical source +map, not a materialization of the enormous full GL8 payload. Six controls reject +invalid type tables, dimensions, cache bits, stale old data, short payloads and +zero extents. The written invariants establish all-width correctness; bounded +fixtures are not presented as its proof. + +## Source and scope + +Scientific base `32890bc5de034ab8fc93ac88ead7279a6a416d04`, priority 7. +Canonical investigation: [Discussion4945](https://github.com/CrocSwap/integer-mult-bounds/discussions/4945#discussioncomment-19172863). +The root checked 342 open PR bodies and 4,736 Discussion records and the released +preceding complete-low claim before assignment. Local checks found the explicit +unfinished full-fiber obligation in `bit-low-carry-lowering`. Arbitrary diffs +and unpublished work remain outside overlap coverage. Only this new package +changes; predecessor bytes and the selected record remain untouched. + +The contribution narrows the assigned full-route objective to a completed, +priced physical low-commit stage after checking that its actual high/carry and +first-coordinate supplier dependencies are not implemented here. This is a +useful completed stage rather than a claim that all P2 obligations are closed. +[TASK.json](TASK.json) preserves the scope and remaining work. + +## Open next questions + +Bind the actual per-low high/carry calls to the prepared full-cache layout, +including source-fiber isolation, every runtime descriptor, the two OLD swaps +for cell0 and installation/erasure at every call. Begin with the actual +helper462/frame506 source and the cell0 carry1/cell5 carry124 fixtures, then +price the entire composition using the new cache and commit constants. The +missing linked physical calls and P3 envelope block a full-route claim; more +low-permutation samples or a smaller block-rescan constant do not resolve them. + +## Credit + +JoyboyBrian, with substantial OpenAI Codex assistance. Apache-2.0. +David Arias PR2776 supplies the literal machine, assembler and paid converter; +Charles Bethin retains the unit-carry predecessor; JoyboyBrian PR4989/5019 and +the retained carry frontend supply the actual route, runtime shear and source +carry obligations. Preserve Chris R/Clear1nsight PR4957, ai-nanachi +PR4760/4814/4326, rohanarun PR185/199, Maxime Fleury PR204, Cinna Davis, zxv, +Jacob Alan Sussman, Mark/Matarener and the retained ordinary/ROW/native/tape +lineage. The new contribution is the literal complete-payload low consumer, +its installation/retirement proof and explicit source-layout cost. No +independent human or proof-kernel review is claimed. diff --git a/research/bit-full-fiber-low-commit/RESULT.json b/research/bit-full-fiber-low-commit/RESULT.json new file mode 100644 index 0000000000..abe64dedd4 --- /dev/null +++ b/research/bit-full-fiber-low-commit/RESULT.json @@ -0,0 +1,190 @@ +{ + "code_hashes": { + "PROOF.md": "505a8470fcaae2dcf000f6427ec9d8926f34115ca17391cc928260b4f927c60f", + "controller.py": "21112808749b1894715e27f2f5b12e04b405ebdd0fa38805ccaf530fe9864c49", + "loader.py": "adee3e66f16cf3e98eb1bf0faab036042cf9b7fe4c5075b8dd028fec32143465", + "type_compiler.py": "f12d827b3655981f9149d1b523bf009c30306d2bc5f89d135a386443d8ab5dfb", + "verify.py": "3becb634a2b6f34796b8340c1e4f57efc982ef0cc728185c4c9a271d90b8bda2" + }, + "controls": [ + "duplicate_type", + "zero_dimension", + "bad_cache", + "stale_cache", + "short_payload", + "zero_extent" + ], + "physical": [ + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 1544, + "dimensions": 4, + "endpoint_sha256": "29fc8beb5c86ab0ae39b9e58e1a80c30f22d7c2d16be4c9fdc54d4d49b38adaa", + "instructions": 13947, + "steps": 24383, + "types": 48, + "visited": 513, + "volume": 48 + }, + { + "Q": 3, + "Z": 1, + "cache_prepare_steps": 1544, + "dimensions": 4, + "endpoint_sha256": "8afaa41ea2eebbad49c73d98e9470bf1a3c40017ed3cd7e536558057c26b98a5", + "instructions": 13947, + "steps": 1173503, + "types": 48, + "visited": 8283, + "volume": 3888 + }, + { + "Q": 3, + "Z": 2, + "cache_prepare_steps": 1544, + "dimensions": 4, + "endpoint_sha256": "f33308eb7276e9e94101cce70709b21309d42894191554c2422bffe3504a1516", + "instructions": 13947, + "steps": 2335575, + "types": 48, + "visited": 16142, + "volume": 7776 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 1544, + "dimensions": 4, + "endpoint_sha256": "d3175696959f4ac5ee8b9596f36f37a91c653923e22819bc8a94b85e5d04f6f8", + "instructions": 13947, + "steps": 24383, + "types": 48, + "visited": 513, + "volume": 48 + }, + { + "Q": 3, + "Z": 1, + "cache_prepare_steps": 1544, + "dimensions": 4, + "endpoint_sha256": "945367fd71a927dea49696a58f86efdf32fd81d851379bc365ed41994596df7f", + "instructions": 13947, + "steps": 1173503, + "types": 48, + "visited": 8283, + "volume": 3888 + }, + { + "Q": 3, + "Z": 2, + "cache_prepare_steps": 1544, + "dimensions": 4, + "endpoint_sha256": "c95998c7204bfb8de5b19ef182208335dbbd4bc73adf4c07dc19f6d90aa0b040", + "instructions": 13947, + "steps": 2335575, + "types": 48, + "visited": 16142, + "volume": 7776 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "709e80c88487a2411e1ee4dfb9f22a861492d20c4765150c0c794abd70f8147c", + "instructions": 377, + "steps": 449, + "types": 3, + "visited": 34, + "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "cf7605ed1bc735f6c825554154627467e1cac9df54cee8699218ed434603c568", + "instructions": 377, + "steps": 447, + "types": 3, + "visited": 34, + "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "fb50dc0717ff266cf9baf82b1ce7a1c2ef6d9247859680b11a19fb7077f5f222", + "instructions": 377, + "steps": 447, + "types": 3, + "visited": 34, + "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "85f90dfea1d8027e1463e5ca971a250110a20df0119d204a74220bc63516d15b", + "instructions": 377, + "steps": 445, + "types": 3, + "visited": 34, + "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "faee935763044f124d7526755a5058a33f9402a595994d59eddd4be8546ff201", + "instructions": 377, + "steps": 447, + "types": 3, + "visited": 34, + "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "fbb59ed10e9cd4ff45a12c5bb92cbd80df984ba1fe60f26a30febf218e2f0f5e", + "instructions": 377, + "steps": 445, + "types": 3, + "visited": 34, + "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "9f44ac6acb8a37b00b615dc89259d306035be82dee7db2b472e4c48326195440", + "instructions": 377, + "steps": 445, + "types": 3, + "visited": 34, + "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 24, + "dimensions": 1, + "endpoint_sha256": "75c8fd04ad916aec3e3d5cb76a452b116b3d4d0912a0a485e9fb8e3d240e210c", + "instructions": 377, + "steps": 443, + "types": 3, + "visited": 34, + "volume": 3 + } + ], + "schema_version": 1, + "scope": "complete low-type block consumer; high/carry suppliers remain explicit inherited contracts", + "source_cases": 768 +} diff --git a/research/bit-full-fiber-low-commit/SOURCES.json b/research/bit-full-fiber-low-commit/SOURCES.json new file mode 100644 index 0000000000..e3bc54b392 --- /dev/null +++ b/research/bit-full-fiber-low-commit/SOURCES.json @@ -0,0 +1,72 @@ +{ + "schema_version": 1, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "fc3d4ba105e1f097d0d7d051a308281e86ab1446", + "sha256": "66974efdced4083c00025f97d95d83909a226cdf801edb9301c195c6641f6903" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/bit-low-carry-lowering/PROOF.md", + "usage": "input", + "git_blob": "26b76b3665c6ff6c85376c43a8d764967e4805f7", + "sha256": "68350bf98ebd512dffcf3ae06a13ff27dc69beec19f15b952f099c55ed13a00a" + }, + { + "path": "research/bit-low-carry-lowering/controller.py", + "usage": "input", + "git_blob": "0144b35116e83a3894f3644daa99a25f775bb65e", + "sha256": "6f5aad2752a3fd9e79428179ca41599574f17c409af61086c9ecbb47ccf49e3b" + }, + { + "path": "research/bit-low-carry-lowering/offset.py", + "usage": "input", + "git_blob": "52d7c2aa9034676ffb5e801cc60f9ef247712aa1", + "sha256": "0eaa1a7d6719427c217f5f8370b025faa9213a378be59e03b16fdc2ff5744d6a" + }, + { + "path": "research/bit-row-route-generator/PROGRAM.json.gz", + "usage": "input", + "git_blob": "2df37028f46614301118980ad14d2b3f80e43c31", + "sha256": "83448ca22ef773847b748d62f19ea80b2a51c53913ce22624003b6170be7044c" + }, + { + "path": "research/bit-row-route-generator/PROOF.md", + "usage": "input", + "git_blob": "358ba70e944e8bbef3504da5d59089255b4ded9f", + "sha256": "b620b2fbca0261972f96585f5adfd170fc0aa9591a9952d8cc6d7aac327737c3" + }, + { + "path": "research/bit-row-route-generator/interpreter.py", + "usage": "input", + "git_blob": "90f79f9d7e7bf57d392ca51232596809d51fc0a8", + "sha256": "10b68232a7b642e7746393b505326fbf6832e7d64c1e0ddc3858835ae74283f9" + }, + { + "path": "research/fixed-tape-affine-shear/PROOF.md", + "usage": "input", + "git_blob": "3b2e34e6ee633c99e9a812cbbf1c2dbd8b646a96", + "sha256": "4437de82c86f6e90e9652875e86f0c88ef39ef950a301594fb0c29e1284f6ae4" + }, + { + "path": "research/fixed-tape-ordered-shear/counters.py", + "usage": "input", + "git_blob": "c4878a7a7e3f390d193df496a579e4a788f25e32", + "sha256": "2b51181a3efd403be14111ed2d556ba10e63a8939756e69d488d12344d5a7ad1" + }, + { + "path": "research/fixed-tape-ordered-shear/machine.py", + "usage": "input", + "git_blob": "6ed03865cdb646d40573c132f841afbe335daba0", + "sha256": "04b7b76b9f06653d94d2158196cdd1bed7883dd1f59fcbc81a486e3ffb248681" + } + ] +} diff --git a/research/bit-full-fiber-low-commit/TASK.json b/research/bit-full-fiber-low-commit/TASK.json new file mode 100644 index 0000000000..eb142cba39 --- /dev/null +++ b/research/bit-full-fiber-low-commit/TASK.json @@ -0,0 +1,74 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "priority_revision": 7, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Does one quantified step of the proposed #4100 all-size construction hold at its actual caller?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/unconditional-batched-crt/README.md" + ], + "methods": [ + "Prove one missing implication with explicit quantified hypotheses.", + "Find an exact counterexample at the claimed interface boundary." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read PROOF.md and AUDIT.md in #4100. Select one distinct obligation: CRT total repair, native/free-algebra lifting, precision/conditioning, or complete fixed-tape cost. This is an author-submitted proof, not an accepted unconditional theorem.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Check live handoffs; name one proposition, its caller, quantified domain and dependency closure. Independently prove the implication or exhibit a precise gap/counterexample. Prioritize CRT.md total repair or COMPLEX.md free-algebra lift only if unclaimed. Stop at the chosen obligation; do not substitute finite samples or root arithmetic for an all-size proof, or launch the complete package by default.", + "bottleneck_link": "Finite supplier improvements are useful only under the retained transfer obligations.", + "allowed_variations": [ + "One CRT repair, native lift, precision/conditioning or tape-cost proposition, with its exact caller." + ], + "scope_change_triggers": [ + "Replacing a quantified obligation with another finite smoke test.", + "Treating archive intake, an author PASS receipt or a finite composed fixture as discharge of the universal hypotheses." + ], + "overlap_terms": [ + "uniform transfer", + "all-size", + "precision", + "4100", + "unconditional-batched-crt" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Literal complete low-type payload permutation, same-owner installation and old-cache retirement at the helper462/frame506 full-array layout.", + "scope_change_reason": "Close the remaining physical low-commit stage with explicit full-cache and finite-state cost; broader high/carry linking and first-coordinate OLD repair remain inherited and are not claimed complete.", + "bottleneck_link": "Removes the unimplemented complete payload low-type permutation from P2 while retaining every unresolved actual caller and P3 cost.", + "budget_minutes": 60, + "stop_rule": "Stop after the complete low-commit physical consumer and its actual source composition proof; no full-route or supplier claim from inherited unlinked high/carry leaves.", + "outcome": "partial", + "evidence": "PROOF.md, controller.py, RESULT.json", + "author": "JoyboyBrian", + "ai_assistance": "Substantial OpenAI Codex assistance; no independent human review claimed.", + "open_questions": [ + { + "question": "Can the actual complete high/carry route be linked to this physical low-commit consumer and full-cache layout within the complete supplier tariff?", + "why_it_matters": "Low commit alone does not discharge full P2 or admit the selected source caller.", + "first_step": "Bind source helper462/frame506 per-low isolation, runtime descriptors, cell0 OLD-swap repair and all intermediate installations, then combine the exact complete invoice.", + "blocked_by": "Missing linked physical high/carry/OLD calls and updated P3 constants; unknown costs are not zero." + } + ] +} diff --git a/research/bit-full-fiber-low-commit/VERIFY.json b/research/bit-full-fiber-low-commit/VERIFY.json new file mode 100644 index 0000000000..9474931238 --- /dev/null +++ b/research/bit-full-fiber-low-commit/VERIFY.json @@ -0,0 +1,40 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/bit-low-carry-lowering/PROOF.md", + "research/bit-low-carry-lowering/controller.py", + "research/bit-low-carry-lowering/offset.py", + "research/bit-row-route-generator/PROGRAM.json.gz", + "research/bit-row-route-generator/PROOF.md", + "research/bit-row-route-generator/interpreter.py", + "research/fixed-tape-affine-shear/PROOF.md", + "research/fixed-tape-ordered-shear/counters.py", + "research/fixed-tape-ordered-shear/machine.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Complete GL2 full-payload forward/inverse tape execution, independent interpreter, actual S8 source map, descriptors/owned erasure, full movement bill and failure controls" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Complete GL2 full-payload forward/inverse tape execution, independent interpreter, actual S8 source map, descriptors/owned erasure, full movement bill and failure controls" + } + ] +} diff --git a/research/bit-full-fiber-low-commit/controller.py b/research/bit-full-fiber-low-commit/controller.py new file mode 100644 index 0000000000..6d390fcaf0 --- /dev/null +++ b/research/bit-full-fiber-low-commit/controller.py @@ -0,0 +1,122 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Literal complete-fiber permutation, installation and old-cache retirement.""" + +def compile_commit(m, c, permutation, dimensions, cache_bits): + if type(dimensions) is not int or dimensions < 1: + raise ValueError('positive fixed high-coordinate count') + permutation = tuple(permutation) + if not permutation or any(type(v) is not int for v in permutation) or sorted(permutation) != list(range(len(permutation))): + raise ValueError('complete finite low-type permutation') + cache_bits = tuple(cache_bits) + if any(type(v) is not int or v not in (0,1) for v in cache_bits): + raise ValueError('canonical finite old-type cache') + # 0 source, 1 output, 2 Q, 3 spectator extent, 4 owned old cache, + # 5 binary work, 6 fiber length, then D Q counters and one spectator counter. + count = dimensions+1 + tapes = 7+count + a = m.Assembler(tapes) + fail = a.fresh('invalid_commit_boundary') + counters = tuple(range(7,tapes)) + private = (1,5,6)+counters + + def checked(symbols, tape, prefix): + good = a.fresh(prefix) + a.branch(tape,{s:good for s in symbols},fail) + a.label(good) + + def erase(tape, prefix): + # Start anywhere in a contiguous marked region; find its right marker. + loop, body, end = (a.fresh(prefix+s) for s in ('_seek','_body','_end')) + a.label(loop) + a.branch(tape,{m.RIGHT:end,m.ZERO:body,m.ONE:body,m.UNIT:body},fail) + a.label(body);a.move(tape,1);a.goto(loop) + a.label(end);a.write(tape,m.BLANK);a.move(tape,-1) + back, more, done = (a.fresh(prefix+s) for s in ('_back','_more','_done')) + a.label(back) + a.branch(tape,{m.LEFT:done,m.ZERO:more,m.ONE:more,m.UNIT:more},fail) + a.label(more);a.write(tape,m.BLANK);a.move(tape,-1);a.goto(back) + a.label(done);a.write(tape,m.BLANK) + + for tape in private: + checked((m.BLANK,),tape,'blank_owned') + a.write(tape,m.LEFT);a.move(tape,1) + # Cache validation occurs before payload mutation; its exact old values + # remain present until the completed installed output no longer needs them. + for bit in cache_bits: + checked((m.ONE if bit else m.ZERO,),4,'old_cache_bit') + a.move(4,1) + checked((m.RIGHT,),4,'old_cache_end') + c.emit_rewind(a,4,'old_cache_return') + for i,tape in enumerate(counters): + c.emit_binary_to_unary(a,2 if i < dimensions else 3,5,tape,'extent_'+str(i)) + + labels=[] + for tape in counters: + loop,body,end=(a.fresh('fiber_'+s) for s in ('loop','body','end')) + labels.append((tape,loop,end)) + a.label(loop);a.branch(tape,{m.UNIT:body,m.RIGHT:end},fail) + a.label(body) + a.write(6,m.UNIT);a.move(6,1) + for tape,loop,end in reversed(labels): + a.move(tape,1);a.goto(loop) + a.label(end);c.emit_rewind(a,tape,'fiber_counter_return') + a.write(6,m.RIGHT);c.emit_rewind(a,6,'fiber_length_return') + + def segment(copy): + loop, body, end = (a.fresh('segment_'+s) for s in ('loop','body','end')) + a.label(loop);a.branch(6,{m.UNIT:body,m.RIGHT:end},fail) + a.label(body) + if copy: + zero,one,advance=(a.fresh('copy_'+s) for s in ('zero','one','advance')) + a.branch(0,{m.ZERO:zero,m.ONE:one},fail) + a.label(zero);a.write(1,m.ZERO);a.goto(advance) + a.label(one);a.write(1,m.ONE) + a.label(advance);a.move(1,1) + else: + checked((m.ZERO,m.ONE),0,'payload_bit') + a.move(0,1);a.move(6,1);a.goto(loop) + a.label(end);c.emit_rewind(a,6,'segment_counter_return') + + for _ in permutation: + segment(False) + checked((m.RIGHT,),0,'complete_source') + c.emit_rewind(a,0,'validated_source_return') + inverse=[permutation.index(i) for i in range(len(permutation))] + for source in inverse: + for _ in range(source): + segment(False) + segment(True) + c.emit_rewind(a,0,'gather_source_return') + a.write(1,m.RIGHT);c.emit_rewind(a,1,'output_return') + # Consume the owned output and install it into the original owner. + loop,zero,one,advance,end=(a.fresh('install_'+s) for s in ('loop','zero','one','advance','end')) + a.label(loop);a.branch(1,{m.ZERO:zero,m.ONE:one,m.RIGHT:end},fail) + a.label(zero);a.write(0,m.ZERO);a.goto(advance) + a.label(one);a.write(0,m.ONE) + a.label(advance);a.write(1,m.BLANK);a.move(0,1);a.move(1,1);a.goto(loop) + a.label(end);checked((m.RIGHT,),0,'installed_length') + a.write(1,m.BLANK) + c.emit_rewind(a,1,'consumed_output_return');a.move(1,-1);a.write(1,m.BLANK) + c.emit_rewind(a,0,'installed_source_return') + erase(4,'retire_old_cache') + for tape in (6,)+counters: + erase(tape,'clear_counter_'+str(tape)) + # Converter returns binary work to its marked empty state. + a.move(5,-1);checked((m.LEFT,),5,'binary_work_left');a.write(5,m.BLANK) + a.halt();a.label(fail);a.reject('complete low-type source, old cache, extents and blank owned workspace') + return a.finish() + + +def compile_cache(m,cache_bits,tapes): + """Prepare the finite old-type snapshot before its dependent carry reads.""" + cache_bits=tuple(cache_bits) + if any(type(v) is not int or v not in (0,1) for v in cache_bits): + raise ValueError('binary compiler cache') + a=m.Assembler(tapes);fail=a.fresh('owned_cache_not_blank') + for symbol in (m.LEFT,*(m.ONE if bit else m.ZERO for bit in cache_bits),m.RIGHT): + good=a.fresh('blank_cache_cell') + a.branch(4,{m.BLANK:good},fail);a.label(good) + a.write(4,symbol);a.move(4,1) + for _ in range(len(cache_bits)+1): a.move(4,-1) + a.halt();a.label(fail);a.reject('blank independently owned old-cache tape') + return a.finish() diff --git a/research/bit-full-fiber-low-commit/loader.py b/research/bit-full-fiber-low-commit/loader.py new file mode 100644 index 0000000000..6d96f4c35a --- /dev/null +++ b/research/bit-full-fiber-low-commit/loader.py @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Load only authenticated predecessor bytes; no ambient module lookup.""" +from pathlib import Path +import hashlib +import json +import sys +import types + +HERE=Path(__file__).resolve().parent +ROOT=HERE.parent.parent + + +def load(): + raw={} + for row in json.loads((HERE/'SOURCES.json').read_text())['files']: + if row['usage']=='input': + content=(ROOT/row['path']).read_bytes() + if hashlib.sha256(content).hexdigest()!=row['sha256']: + raise ValueError('source SHA256 '+row['path']) + raw[row['path']]=content + modules={} + names={'machine':'research/fixed-tape-ordered-shear/machine.py', + 'counters':'research/fixed-tape-ordered-shear/counters.py'} + if any(name in sys.modules for name in names): + raise ValueError('preloaded predecessor module') + try: + for name,path in names.items(): + module=types.ModuleType(name);module.__file__=str(ROOT/path) + sys.modules[name]=module + exec(compile(raw[path],module.__file__,'exec'),module.__dict__) + modules[name]=module + finally: + for name in names: + sys.modules.pop(name,None) + return raw,modules diff --git a/research/bit-full-fiber-low-commit/type_compiler.py b/research/bit-full-fiber-low-commit/type_compiler.py new file mode 100644 index 0000000000..00cf9fe108 --- /dev/null +++ b/research/bit-full-fiber-low-commit/type_compiler.py @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Pre-input finite type compilation; no runtime payload or width arguments.""" +from fractions import Fraction +from itertools import product +from math import isqrt + + +def inverse(a,q): + n=len(a) + rows=[list(row)+[int(i==j) for j in range(n)] for i,row in enumerate(a)] + for j in range(n): + i=next((i for i in range(j,n) if rows[i][j]%q),None) + if i is None: + raise ValueError('singular matrix') + rows[i],rows[j]=rows[j],rows[i] + c=pow(rows[j][j],-1,q) + rows[j]=[x*c%q for x in rows[j]] + for i in range(n): + if i!=j: + c=rows[i][j] + rows[i]=[(x-c*y)%q for x,y in zip(rows[i],rows[j])] + return [row[n:] for row in rows] + + +def right_action(g,a,q): + n=len(a) + return tuple(sum(g[r*n+j]*a[j][k] for j in range(n))%q + for r in range(n) for k in range(n)) + + +def compile_types(q, matrix, inverse_direction=False): + if type(q) is not int or q<3 or any(q%d==0 for d in range(2,isqrt(q)+1)): + raise ValueError('odd prime fixed radix') + n=len(matrix) + if n<1 or any(len(row)!=n for row in matrix) or type(inverse_direction) is not bool: + raise ValueError('fixed square matrix and direction') + a=[[Fraction(v).numerator*pow(Fraction(v).denominator,-1,q)%q for v in row] for row in matrix] + ai=inverse(a,q) + if inverse_direction: + a=ai + types=[] + for g in product(range(q),repeat=n*n): + try: + inverse([g[i*n:(i+1)*n] for i in range(n)],q) + except ValueError: + continue + types.append(g) + index={g:i for i,g in enumerate(types)} + permutation=[index[right_action(g,a,q)] for g in types] + bits=(q-1).bit_length() + cache=[(x>>j)&1 for g in types for x in g for j in range(bits)] + return types,permutation,cache diff --git a/research/bit-full-fiber-low-commit/verify.py b/research/bit-full-fiber-low-commit/verify.py new file mode 100644 index 0000000000..030958fbf5 --- /dev/null +++ b/research/bit-full-fiber-low-commit/verify.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Closed-source full-fiber consumer checks with independent local execution.""" +from fractions import Fraction +from pathlib import Path +import gzip +import hashlib +import json +import sys + +HERE=Path(__file__).resolve().parent +sys.path.insert(0,str(HERE)) +from loader import load +from controller import compile_commit,compile_cache +from type_compiler import compile_types,right_action,inverse + + +def need(ok,message): + if not ok: raise ValueError(message) + + +def execute(program,initial,limit): + # Independent literal machine: the program observes no address or counter. + cells=[dict(c) for c,h in initial] + heads=[h for c,h in initial] + low=list(heads);high=list(heads) + pc=program.entry;steps=0 + while True: + row=program.instructions[pc];op=row[0];steps+=1 + need(steps<=limit,'transition envelope') + if op=='halt': break + if op=='reject': raise ValueError(row[1]) + if op=='goto': pc=row[1];continue + tape=row[1] + if op=='branch': pc=dict(row[2]).get(cells[tape].get(heads[tape],0),row[3]);continue + if op=='move': heads[tape]+=row[2] + elif op=='write': + if row[2]: cells[tape][heads[tape]]=row[2] + else: cells[tape].pop(heads[tape],None) + else: raise ValueError('nonlocal instruction') + low[tape]=min(low[tape],heads[tape]);high[tape]=max(high[tape],heads[tape]);pc+=1 + return list(zip(cells,heads)),steps,sum(b-a+1 for a,b in zip(low,high)) + + +def marked(symbols,origin=0): + symbols=list(symbols) + return ({origin:1,**{origin+i+1:v for i,v in enumerate(symbols)},origin+len(symbols)+1:2},origin+1) + + +def binary(value,origin): + return marked([4 if value>>i&1 else 3 for i in range(value.bit_length())],origin) + + +def fixture(program,payload,Q,Z,cache,translated): + origins=[(i*7-41 if translated else 0) for i in range(program.tapes)] + bank=[({},o) for o in origins] + bank[0]=marked((4 if b else 3 for b in payload),origins[0]) + bank[2]=binary(Q,origins[2]);bank[3]=binary(Z,origins[3]) + bank[4]=marked((4 if b else 3 for b in cache),origins[4]) + return bank + + +def check(program,permutation,D,cache,Q,Z,payload,modules,translated=False,primary=False): + H=Q**D*Z;V=len(permutation)*H;K=len(cache) + need(len(payload)==V,'complete payload') + bank=fixture(program,payload,Q,Z,cache,translated) + empty=[(dict(cells),head) for cells,head in bank] + empty[4]=({},bank[4][1]-1) + prep=compile_cache(modules['machine'],cache,program.tapes) + prepared,prepare_steps,_=execute(prep,empty,5*len(cache)+16) + need(prepared==bank,'literal full old-cache preparation') + bound=128*(len(permutation)+D+1)*V+8*K+128*D + output,steps,space=execute(program,bank,bound) + expected=[0]*V + for src,dst in enumerate(permutation): + expected[dst*H:(dst+1)*H]=payload[src*H:(src+1)*H] + need(output[0]==marked((4 if b else 3 for b in expected),bank[0][1]-1),'literal low-type push and installation') + for i in (2,3): need(output[i]==bank[i],'descriptor or head changed') + for i in (1,4,*range(5,program.tapes)): + origin=bank[i][1]-(1 if i==4 else 0) + need(output[i]==({},origin),'owned storage or head not erased: '+str(i)) + need(space<=(D+5)*V+2*K+64*(D+1),'visited-space envelope') + if primary: + m=modules['machine'] + machine=m.Machine(program,[m.Tape(c,h) for c,h in bank]).run(bound) + need([(t.cells,t.head) for t in machine.tapes]==output and machine.steps==steps,'independent interpreter disagreement') + return dict(types=len(permutation),dimensions=D,Q=Q,Z=Z,volume=V,steps=steps,visited=space, + instructions=len(program.instructions),cache_prepare_steps=prepare_steps,endpoint_sha256=hashlib.sha256(bytes(expected)).hexdigest()) + + +def main(): + raw,modules=load();m,c=modules['machine'],modules['counters'] + records=[] + # Every low type in GL2(F3), not a chosen subset; both direction tables. + matrix=[[1,1],[0,1]] + for inverse_direction in (False,True): + types,perm,cache=compile_types(3,matrix,inverse_direction) + need(len(types)==48,'complete GL2 type count') + program=compile_commit(m,c,perm,4,cache) + for Q,Z in ((1,1),(3,1),(3,2)): + V=len(perm)*Q**4*Z + payload=[((i*i+3*i+7)^(i>>2))&1 for i in range(V)] + records.append(check(program,perm,4,cache,Q,Z,payload,modules,True,primary=Q==1)) + # Exhaustive arbitrary-bit inputs for a nontrivial three-block permutation. + perm=[2,0,1];cache=[0,1,1,0];program=compile_commit(m,c,perm,1,cache) + for value in range(8): + records.append(check(program,perm,1,cache,1,1,[(value>>i)&1 for i in range(3)],modules,primary=True)) + # Read actual S8 and bind both modular directions to the actual source ABI. + source=json.loads(gzip.decompress(raw['research/bit-row-route-generator/PROGRAM.json.gz'])) + S=[[Fraction(v) for v in row] for row in source['matcher']] + source_checks=[] + for q in (3,5,7): + mod=[[v.numerator*pow(v.denominator,-1,q)%q for v in row] for row in S] + inv=inverse(mod,q) + old=tuple(int(i==j) for i in range(8) for j in range(8)) + extra=list(old);extra[5]=q-2;extra=tuple(extra) + for g in (old,extra): + mapped=right_action(g,mod,q) + need(right_action(mapped,inv,q)==g,'actual source forward/inverse type') + for w in (2,4): + Q=q**(w-1);M=q*Q + lift=[[v.numerator*pow(v.denominator,-1,M)%M for v in row] for row in S] + for i in range(64): + r,col=divmod(i,8) + total=sum(g[r*8+j]*lift[j][col] for j in range(8)) + need(total%q==mapped[i],'old-low source map') + source_checks.append((q,w,i,total//q%Q)) + # Boundary and actual-byte mutation controls. + controls=[] + for label,per,D,bits in [('duplicate_type',[0,0],1,[]),('zero_dimension',[0],0,[]),('bad_cache',[0],1,[2])]: + try: compile_commit(m,c,per,D,bits) + except ValueError: controls.append(label) + else: raise ValueError('accepted '+label) + bank=fixture(program,[0,1,0],1,1,cache,False) + for label,tape,position,symbol in [('stale_cache',4,1,4),('short_payload',0,2,2),('zero_extent',2,1,3)]: + mutant=[(dict(cells),head) for cells,head in bank] + mutant[tape][0][position]=symbol + try: execute(program,mutant,100000) + except ValueError: controls.append(label) + else: raise ValueError('accepted '+label) + result=dict(schema_version=1,physical=records,source_cases=len(source_checks),controls=controls, + scope='complete low-type block consumer; high/carry suppliers remain explicit inherited contracts') + result['code_hashes']={name:hashlib.sha256((HERE/name).read_bytes()).hexdigest() for name in ('controller.py','type_compiler.py','loader.py','verify.py','PROOF.md')} + canonical=json.dumps(result,indent=2,sort_keys=True)+'\n' + if sys.argv[1:]==['--write-result']:(HERE/'RESULT.json').write_text(canonical) + else: + need(not sys.argv[1:],'arguments') + need((HERE/'RESULT.json').read_text()==canonical,'receipt mismatch') + print('PASS_FULL_FIBER_LOW_COMMIT complete_GL2_48 literal_payload cache_retired') + + +if __name__=='__main__':main() From e72e7d0d46e11d36eb64190808c51f0f9c3142b1 Mon Sep 17 00:00:00 2001 From: JoyboyBrian <122925040+JoyboyBrian@users.noreply.github.com> Date: Sat, 24 Oct 2026 21:01:48 -0700 Subject: [PATCH 2/2] Repair generic cache invoice with long-cache counterexample controls --- research/bit-full-fiber-low-commit/PROOF.md | 22 ++++++++++----- research/bit-full-fiber-low-commit/README.md | 8 +++--- .../bit-full-fiber-low-commit/RESULT.json | 16 +++++++++-- .../bit-full-fiber-low-commit/VERIFY.json | 10 +++++++ .../bit-full-fiber-low-commit/test_sources.py | 27 +++++++++++++++++++ research/bit-full-fiber-low-commit/verify.py | 11 ++++++-- 6 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 research/bit-full-fiber-low-commit/test_sources.py diff --git a/research/bit-full-fiber-low-commit/PROOF.md b/research/bit-full-fiber-low-commit/PROOF.md index 2006e2c0b3..7a5bc995bd 100644 --- a/research/bit-full-fiber-low-commit/PROOF.md +++ b/research/bit-full-fiber-low-commit/PROOF.md @@ -50,7 +50,7 @@ single-cache ABI unchanged. The instruction program unrolls pi^-1 as finite state control, with no runtime permutation table lookup. Its length is O(T^2+K+D). A conservative pre-input -work envelope is O(q^D N^3 (log q)^2 + T D log q + T^2 + D) exact bit operations, +work envelope is O(q^D N^3 (log q)^3 + T^2 D log q + D) exact bit operations, plus rational source reduction and inverse preparation. Schoolbook modular elimination may be bounded more loosely by an additional log q factor without changing the fixed-parameter conclusion. No GL8(Fq) enumeration is executed in @@ -124,20 +124,28 @@ A segment costs at most 16H+8 including its H-counter rewind, whether copied or skipped. Validation uses T segments. Gathering uses `sum_k (pi^-1(k)+1)=T(T+1)/2` segments, plus T source rewinds, each at most 3V+3. Output/source installation, marker removal and returns cost at most -24V+24. Cache validation and retirement cost at most 8K+8. With H>=1 and +24V+24. Cache validation and return use 5K+4 transitions; erasure from its first +bit uses 7K+5, hence 12K+9 together. We allow 16K+16 independently +of payload volume, including arbitrarily long generic caches. With H>=1 and V=TH, the following deliberately loose envelope covers all these instructions: -`transitions <= 128(T+D+1)V + 8K + 128D`. +`transitions <= 128(T+D+1)V + 16K + 16 + 128D`. -The implemented separate cache initializer adds at most 5K+16. For fixed +The implemented separate cache initializer adds at most 5K+16. It visits +K+3 cache cells because it steps one cell beyond RIGHT before returning; +the commit alone visits K+2. The combined space envelope below absorbs that +extra cell. For fixed N,q, both terms are O_(N,q)(V), since K=TDb<=Db V. This does not assert a small constant or a whole supplier recurrence. Source and output consume at most 2V+4 visited cells; the H counter consumes -H+2; D Q counters, Z counter, binary work and input descriptors consume at most -(D+3)H+O(D); old cache consumes K+2. The conservative checked envelope is +H+2; the D Q counters and one Z counter consume at most (D+1)H +plus their markers. The two input descriptor lengths and the maximum binary +work length are each at most H, adding at most 3H and their markers. Old cache +consumes K+2. Thus the payload-dependent part is at most (D+7)V; +the following envelope leaves another V plus explicit marker/head slack. The conservative checked envelope is -`visited cells <= (D+5)V + 2K + 64(D+1)`. +`visited cells <= (D+8)V + 2K + 64(D+1)`. It includes cells subsequently erased. Tape translations change no interval length. Runtime width enters through Q and payload H, not program size. diff --git a/research/bit-full-fiber-low-commit/README.md b/research/bit-full-fiber-low-commit/README.md index 2219b783cc..6d7f118254 100644 --- a/research/bit-full-fiber-low-commit/README.md +++ b/research/bit-full-fiber-low-commit/README.md @@ -8,8 +8,8 @@ All runtime instructions are local symbol operations and unit head moves. [PROOF.md](PROOF.md) specifies the actual layout and universal loop invariants. For T low types, D high coordinates, runtime Q,Z, V=T Q^D Z and K=TDb old-cache -bits, the commit costs at most `128(T+D+1)V+8K+128D` transitions and -`(D+5)V+2K+64(D+1)` visited cells. A separate literal initializer prepares the +bits, the commit costs at most `128(T+D+1)V+16K+16+128D` transitions and +`(D+8)V+2K+64(D+1)` visited cells. A separate literal initializer prepares the complete old cache in at most `5K+16` transitions. Runtime extent multiplication is performed by nested tape loops, not a host arithmetic instruction. Finite compilation and repeated source scans are explicitly charged; these large @@ -43,7 +43,9 @@ complete cases; all eight inputs of a three-block bit example are exhausted. Actual S8 source checks use q=3,5,7 and w=2,4. They bind the mathematical source map, not a materialization of the enormous full GL8 payload. Six controls reject invalid type tables, dimensions, cache bits, stale old data, short payloads and -zero extents. The written invariants establish all-width correctness; bounded +zero extents. A K=1000, T=D=V=1 regression exceeds the superseded 8K +cache formula and passes the corrected 16K+16 charge. A separate copied +Git-free test rejects source changes in normal and optimized modes. The written invariants establish all-width correctness; bounded fixtures are not presented as its proof. ## Source and scope diff --git a/research/bit-full-fiber-low-commit/RESULT.json b/research/bit-full-fiber-low-commit/RESULT.json index abe64dedd4..21648a6041 100644 --- a/research/bit-full-fiber-low-commit/RESULT.json +++ b/research/bit-full-fiber-low-commit/RESULT.json @@ -1,10 +1,10 @@ { "code_hashes": { - "PROOF.md": "505a8470fcaae2dcf000f6427ec9d8926f34115ca17391cc928260b4f927c60f", + "PROOF.md": "82cf7fb98db939fc06523282b2516357d6f8f17494bddd46de31d2fe37de8d62", "controller.py": "21112808749b1894715e27f2f5b12e04b405ebdd0fa38805ccaf530fe9864c49", "loader.py": "adee3e66f16cf3e98eb1bf0faab036042cf9b7fe4c5075b8dd028fec32143465", "type_compiler.py": "f12d827b3655981f9149d1b523bf009c30306d2bc5f89d135a386443d8ab5dfb", - "verify.py": "3becb634a2b6f34796b8340c1e4f57efc982ef0cc728185c4c9a271d90b8bda2" + "verify.py": "3d7208d4a091ed800673d9a13cc55d9922f6a1879eb849543525e9277abc4c2c" }, "controls": [ "duplicate_type", @@ -182,6 +182,18 @@ "types": 3, "visited": 34, "volume": 3 + }, + { + "Q": 1, + "Z": 1, + "cache_prepare_steps": 4008, + "dimensions": 1, + "endpoint_sha256": "4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a", + "instructions": 2281, + "steps": 12250, + "types": 1, + "visited": 1026, + "volume": 1 } ], "schema_version": 1, diff --git a/research/bit-full-fiber-low-commit/VERIFY.json b/research/bit-full-fiber-low-commit/VERIFY.json index 9474931238..354bf8aece 100644 --- a/research/bit-full-fiber-low-commit/VERIFY.json +++ b/research/bit-full-fiber-low-commit/VERIFY.json @@ -35,6 +35,16 @@ ], "timeout_seconds": 60, "checks": "Complete GL2 full-payload forward/inverse tape execution, independent interpreter, actual S8 source map, descriptors/owned erasure, full movement bill and failure controls" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_sources.py" + ], + "timeout_seconds": 30, + "checks": "Modified declared source rejection in a copied Git-free closure under normal and optimized Python" } ] } diff --git a/research/bit-full-fiber-low-commit/test_sources.py b/research/bit-full-fiber-low-commit/test_sources.py new file mode 100644 index 0000000000..e858a70974 --- /dev/null +++ b/research/bit-full-fiber-low-commit/test_sources.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +"""Fast fail-closed source tests in an independently copied Git-free closure.""" +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile + +HERE=Path(__file__).resolve().parent +ROOT=HERE.parent.parent +with tempfile.TemporaryDirectory(prefix='low-commit-source-') as temporary: + root=Path(temporary) + package=root/'research'/HERE.name + shutil.copytree(HERE,package) + inputs=json.loads((HERE/'VERIFY.json').read_text())['inputs'] + for name in inputs: + target=root/name;target.parent.mkdir(parents=True,exist_ok=True) + shutil.copyfile(ROOT/name,target) + source=root/inputs[0] + source.write_bytes(source.read_bytes()+b'\n') + for options in ([],['-O']): + run=subprocess.run([sys.executable,'-I',*options,'-B',str(package/'verify.py')], + capture_output=True,text=True,timeout=10) + if run.returncode==0 or 'source SHA256' not in run.stderr: + raise RuntimeError('modified source accepted or wrong failure: '+run.stderr) +print('PASS_LOW_COMMIT_SOURCE_CONTROLS git_free normal_optimized') diff --git a/research/bit-full-fiber-low-commit/verify.py b/research/bit-full-fiber-low-commit/verify.py index 030958fbf5..3a98cb963b 100644 --- a/research/bit-full-fiber-low-commit/verify.py +++ b/research/bit-full-fiber-low-commit/verify.py @@ -69,7 +69,7 @@ def check(program,permutation,D,cache,Q,Z,payload,modules,translated=False,prima prep=compile_cache(modules['machine'],cache,program.tapes) prepared,prepare_steps,_=execute(prep,empty,5*len(cache)+16) need(prepared==bank,'literal full old-cache preparation') - bound=128*(len(permutation)+D+1)*V+8*K+128*D + bound=128*(len(permutation)+D+1)*V+16*K+16+128*D output,steps,space=execute(program,bank,bound) expected=[0]*V for src,dst in enumerate(permutation): @@ -79,7 +79,7 @@ def check(program,permutation,D,cache,Q,Z,payload,modules,translated=False,prima for i in (1,4,*range(5,program.tapes)): origin=bank[i][1]-(1 if i==4 else 0) need(output[i]==({},origin),'owned storage or head not erased: '+str(i)) - need(space<=(D+5)*V+2*K+64*(D+1),'visited-space envelope') + need(space<=(D+8)*V+2*K+64*(D+1),'visited-space envelope') if primary: m=modules['machine'] machine=m.Machine(program,[m.Tape(c,h) for c,h in bank]).run(bound) @@ -105,6 +105,13 @@ def main(): perm=[2,0,1];cache=[0,1,1,0];program=compile_commit(m,c,perm,1,cache) for value in range(8): records.append(check(program,perm,1,cache,1,1,[(value>>i)&1 for i in range(3)],modules,primary=True)) + # The generic cache length is independent of V. This rejects the old 8K + # invoice even at the exact requested K=1000, T=D=V=1 boundary. + long_cache=[i%2 for i in range(1000)] + long_program=compile_commit(m,c,[0],1,long_cache) + long_record=check(long_program,[0],1,long_cache,1,1,[1],modules,True) + need(long_record['steps']>128*3+8*1000+128,'long-cache undercharge control') + records.append(long_record) # Read actual S8 and bind both modular directions to the actual source ABI. source=json.loads(gzip.decompress(raw['research/bit-row-route-generator/PROGRAM.json.gz'])) S=[[Fraction(v) for v in row] for row in source['matcher']]