diff --git a/research/bit-row-route-generator/PROGRAM.json.gz b/research/bit-row-route-generator/PROGRAM.json.gz new file mode 100644 index 0000000000..2df37028f4 Binary files /dev/null and b/research/bit-row-route-generator/PROGRAM.json.gz differ diff --git a/research/bit-row-route-generator/PROOF.md b/research/bit-row-route-generator/PROOF.md new file mode 100644 index 0000000000..358ba70e94 --- /dev/null +++ b/research/bit-row-route-generator/PROOF.md @@ -0,0 +1,67 @@ +# Addressed matcher and ROW schedule + +This closes one scheduling obligation under named P1/P2 primitives, not their +fixed-tape implementation or P3. The fixed source is original helper462, from +frame0 to rank-four frame506. With source rows B and A, S8=[B^T|A^T], and +P8=B^T(BB^T)^-1B=S8 diag(I4,0) S8^-1. For f>0 put N=8f and S=S8 tensor I_f. +This explicit tensor family is not the enormous complete #4814 uniform word. + +Rational elimination emits factors E1,...,Et with S8=E1...Et. Each is a swap, +a unit scaling or an elementary add; the actual source has 5/5/14. Each right +factor acts on columns, so E[i,j]=a updates column j from column i. Lift each +factor separately to each lane, on each of the N high-matrix rows. Inverse +routing reverses this chronological list and inverts every factor. + +Both executable entry points require odd prime q by exact trial division. +The finite matrix solver therefore works over the local ring Z/q^w, not a +general composite-modulus ring; an invertible residual column always has a +unit pivot. Global compiler prime thresholds and witness avoidance are still +separate inherited hypotheses. The verifier independently multiplies both +actual emitted factor lists over the rationals and checks the source projector. + +For G=G0+qG1 and local ring modulo M=q^w, let L=S mod M and R=q^(w-1). +After the complete high linear factor word, G1'=G1 L mod R. The generator +retains an explicitly owned copy of the old low row while applying it. Then +C=(G0 L-(G0 L mod q))/q mod R is added, one addressed cell at a time, and the +low type changes to G0 L mod q. Thus the rebuilt row is G S mod M. S is a unit +matrix at admitted q, so this is a permutation of the entire GL cover and +carries arbitrary array values without productive copying. Inverse routing +restores the complete original row. The finite low-type permutation and the +carry-control preparation remain charged P2 implementations, not address oracles. + +Each high swap acts on two explicitly addressed complete radix-q chunks of +width e=w-1. If 2k>=e, it calls the named older completed supplier directly. +Otherwise its high prefix H_hi of k digits is borrowed as ROW, with D_hi and +all other exposed fields retained as spectators. Pad only this ROW range to +ceil(q^k/reserve)*reserve. The body emits the literal five-step source wrapper +D-=H; F; D+=H; F; D=H-D. Given P1's restored raw endpoint F=(CD,CH), its result +is exactly (D,H) on the body. ROW is checked returned before unpadding and +before the older width-k high-part interchange. Consequently the entire two +chunks swap and every unrelated current field is unchanged. The borrow is +from the CURRENT argument, with no new external ROW or zero original owner. + +The outer exposed ROW and arbitrary complete spectators are disjoint from +the high-matrix fields. Induction on steps preserves their bytes and physical +owner identifiers. No two original owners may occupy the same physical slot; +no owned low cache is a productive source owner. Every allocation is paired +with complete initialization, clearing and release. Successive inner borrows +reuse the restored range and never multiply a reserve per sequential call. + +At the native cut the cover row is h=gS. The inherited completed canonical +rank-4f contract has projector h Q h^-1=g P g^-1; it leaves the whole ROW and +spectators fixed. Undoing the route restores g, while the head/tail result is +the requested source projector with its complete tail reversal. The generator +therefore schedules this one complete source invocation correctly under the +named primitive contracts, at every f and every admitted odd prime/width. +Finite independent execution corroborates the induction; it is not a proof of +P1's native/tape primitives, P2's movement bounds, P3 or API admission. + +The ledger records each completed primitive, exact addressed counts, argument +widths, low-cache allocation, ROW padding range and exact arithmetic workspace. +In particular it never maps unresolved physical cost to zero. Low-cache size +is N^2 ceil(log2 q) bits, independent of w for fixed N,q. A route accumulator +bounded by N(M-1)^2 needs bit_length(N(M-1)^2)+1 bits; fixed rational inverses +must be prepared at the current modulus and their work remains charged. +These are exact integer precision requirements, not a bound on the native +arithmetic provider's precision. P3 needs those provider, tape and recurrence +constants separately; no scalar stock constant is derived here. diff --git a/research/bit-row-route-generator/README.md b/research/bit-row-route-generator/README.md new file mode 100644 index 0000000000..a9ba8ecf58 --- /dev/null +++ b/research/bit-row-route-generator/README.md @@ -0,0 +1,195 @@ +# Source-bound matcher routes and restored ROW ownership + +This package supplies an executable **addressed contract-machine schedule** for +one actual helper462/frame506 invocation, including the explicit tensor family +`S8 ⊗ I_f`, `N=8f`. It lowers the dense matcher route to elementary high-coordinate +operations, carries and a paid low-type permutation, with complete original +owner/spectator checks and two nested ROW scopes. The emitted program is +`PROGRAM.json.gz`; it contains actual operation names and coordinate addresses, +not asserted contract flags. + +This is a bounded P1/P2 **scheduling** obligation from +[#4957](https://github.com/CrocSwap/integer-mult-bounds/pull/4957) at +`3ab584de66a9220007963c7bd476241137a263c9`. Its native, completed atom and routing +leaves remain named inherited contracts. The interpreter gives those leaves +literal finite address semantics; it does **not** implement their finite- +alphabet fixed-tape movement, cost bounds or native compiler. P3, complete +primitive API admission and the enormous full #4814 uniform word remain open. +There is no scalar stock-constant recalculation, price tuning or new kappa. + +## Concrete inputs and source binding + +`generate(frame, f, q, w, borrowed_digits=k, reserve=S, owners=(462,461))` +requires the exact source frame506, positive `f`, `w>=2`, odd prime `q` with unit +matcher denominators, distinct physical original owners, and `1<=S<=q^k`. +Both generator and interpreter exactly reject composite radices by trial +division; this offline primality cost is not a scalable compilation bound. +The source's large-prime threshold and full-program witness avoidance remain +inherited and are not certified by this local prime check. +The frame is hash-checked, and the verifier separately authenticates the whole +source frame bank and native WORD, including original owner462's transition +`frame0 -> frame506` and owner461's arbitrary original status. Nothing is read +from an unmerged predecessor at replay time. + +Each active owner state has `N^2` low and `N^2` high cover coordinates, +`N` head and `N` tail coordinates, an arbitrary exposed outer ROW, arbitrary +intervening `Z`, and its inherited tape-head marker. The low matrix is invertible +modulo the admitted prime; highs range independently over `Z/q^(w-1)`. A distinct +original owner461 is a complete spectator. Separate physical slot identifiers +and separate owner objects are required. No new productive owner is allocated. + +The generator's linear addresses are flattened matrix coordinates `row*N+col`. +A swap's current high argument is split into radix-q digits: the top `k` digits +of its first argument are the **inner** borrowed ROW; its second high prefix +and all remaining fields are spectators. That inner ROW is restored before +unpadding and before the older high-prefix interchange. The separate exposed +outer ROW never aliases these fields. The full current values are checked, +including dirty values; neither ROW is assumed zero. + +The new low cache is an owned copy of the old low type, not a source job. Its +allocation, initialization, all `N^2` copies, all clears and release are emitted. +ROW padding adds owned zero extent only after borrowing the genuine complete +range. The interpreter checks the padding lifetime and genuine-row endpoint; +it does not materialize a full exponentially large array of padded payload +cells. Their complete fibre volume, initialization/removal and physical movement +remain explicitly charged inherited implementation obligations. + +## Program and uniform statement + +The source's `S8=[B^T|A^T]` has 5 swap, 5 scaling and 14 additive right factors. +For every lane and every high-matrix row, the program emits the addressed +factor operation in chronological order. Right `E[i,j]` adds source column `i` +to target `j`. The inverse route reverses this order and inverts coefficients. +A complete original low snapshot supplies the actual affine carry + +`(G0 * (S mod q^w) - (G0 * S mod q)) / q mod q^(w-1)`. + +There is one carry shift per matrix cell, including zero-valued shifts, and one +paid complete low-type permutation per route. At the intervening native cut, +the row is `h=gS`; the inherited canonical rank-`4f` action is therefore the +actual source action with projector `g P g^-1`. The inverse route restores +**every** low/high ROW coordinate. Tail reversal is over all `N` coordinates. + +For a high-chunk width `e=w-1`, the program uses the older completed supplier +when `2k>=e`. Otherwise it emits the actual source ordinary wrapper +`D-=H; F; D+=H; F; D=H-D` on the body, verifies ROW return, removes padding, +and invokes the older supplier on the high prefixes. `F` is the named P1 +completed raw reverse/swap contract. The small-width fallback is executed, +not merely listed in metadata. + +[PROOF.md](PROOF.md) proves the all-`f` schedule and restoration by source factor +multiplication and induction on addressed steps. It assumes the exact P1/P2 +leaves just named. This is an explicit tensor lift of the actual eight-dimensional +source helper; it is **not** a materialization or admission of every matcher in +#4814's dimension `2^262208150916063859466241` uniform compiler. + +## Complete conditional ledger + +Put `T=10*N*f` for the number of ordinary swaps across both routes. The exact +emitted two-route bill contains: + +| Item | Count or extent | +|---|---:| +| Completed ordinary high-coordinate swaps | `T` | +| Fixed unit scalings | `10*N*f` | +| Linear ordered shifts | `28*N*f` | +| Low-type controlled carry shifts | `2*N^2` | +| Paid finite low-type permutations | 2 | +| Completed canonical native invocation | 1 | +| Low-cache copy / clear operations | `2*N^2` each | +| Peak owned low cache | `N^2 * ceil(log2(q))` bits | +| Low-type table size bound | `product(i=0..N-1, q^N-q^i)` | + +In the borrowed branch, each of the `T` swaps expands into two raw-body calls, +three body additive maps, one older width-`k` interchange, and one complete +borrow/pad/return/unpad lifetime. Its additive maps account for `3*T*(e-k)` +scalar atom additions. In the fallback branch there are `T` older width-`e` +interchanges and no inner borrow. Padding's added row count is +`ceil(q^k/S)*S-q^k`, multiplied by the **complete** body/spectator fibre volume; +its ratio is below two and the single live extent is reused sequentially. + +Thus there are `13+6*N^2+48*N*f` addressed steps in the fallback branch, and +`13+6*N^2+138*N*f` in the borrowed branch. These are scheduling counts, not +Turing-machine operation prices. Every primitive's contract and width appears +in the ledger. The physical cost is the sum of these positive-count primitive +calls at their stated widths, plus cache/padding preparation and cleanup; +unknown primitive tariffs are **not zero**. The low-type permutation and +coefficient preparation are explicitly included, not free gathers. + +Logical route cells use `bit_length(q^w-1)` bits. The stated exact route +accumulator bound is `bit_length(N*(q^w-1)^2)+1` bits. Rational modular inverses +must be prepared at the current modulus. These exact integer bounds do not +certify the native provider's precision or its physical work tape inventory. +Local storage consists of the two original owners, one low cache and a scoped +ROW padding extent, plus all inherited primitive tapes. P3 still needs the +actual fixed-program reserve, recurrence, tape/precision and threshold proof. + +## Independent checks and reproduction + +The independent interpreter imports no generator code. It consumes the +serialized operation/address lists and checks all non-target high/low/payload +fields, the full exposed outer ROW, the other physical owner and the inherited +head markers after every step. It rejects unreturned leases, uninitialized or +uncleared caches, argument/owner aliasing and out-of-range addresses. The +independent endpoint oracle rebuilds `P=B^T(BB^T)^-1B` from source, uses rational +inversion rather than the interpreter's modular solver, and compares the full +forward row, inverse row and returned paired projector action. An additional +exact rational check verifies `P^2=P`, `S8*Q*S8^-1=P`, and independently +multiplies the 48 actual emitted forward/inverse elementary factors into +`S8` and `S8^-1`; it does not call the generator's factorizer. + +The three examples are `(f,q,w)=(1,5,2),(1,5,4),(2,7,4)`: 781, 1,501 and 5,965 +actual steps. They cover 64 head/tail basis columns, 64 high-matrix basis +columns plus the zero matrix, and six additional dirty cases. The latter two +examples execute 80 and 320 inner ROW borrow/return lifetimes per invocation; +the first executes the older fallback. The finite radices are discriminating +contract-machine instances, not the source's large-prime compiler admission. + +Fifteen rejecting controls cover composite radices at both public interfaces, +wrong source frame, unavailable reserve, +duplicate source owners, physical/object aliasing, invalid addresses, omitted +nonzero carry, omitted factor, premature unpadding, incomplete cache cleanup, +inner/outer ROW corruption and a wrong high-part interchange. The omitted +carry control derives a nonzero source carry at cell5; the mutant operation +ledger is recomputed so rejection comes from wrong action, not a stale count. +The same is done for the omitted factor and wrong high-part operation. + +```sh +python3.12 -B scripts/research_package.py --package research/bit-row-route-generator +``` + +The registered normal and `-O` commands use explicit guards, Python 3.12 and +only the standard library. Direct `verify.py` is read-only. Explicit +`verify.py --write` regenerates RESULT.json and the compressed literal example +program. No Lean, Docker, historical suite or astronomical expansion is run. + +## Coordination, limits and credit + +Task `supplier-boundary-audit`, revision7, changed from the historical four- +provider card to the exact #4957 P1/P2 scheduling handoff. Canonical claim: +https://github.com/CrocSwap/integer-mult-bounds/discussions/4945#discussioncomment-19138351 +Base: `b91956876e5b4122fd89179f1b57557ff8378f15`. Entry overlap covered 317 open +PRs, 4,064 Discussion records and all 6,636 local notes. Specific route/ROW +terms found #4957, #4945 and unrelated row generators. The live canonical +comment list was empty before claiming. Closed histories, arbitrary diffs and +unpublished work are not exhaustively covered; this is not novelty proof. + +Credit ai-nanachi #4760/#4814/#4326; Chris R / Clear1nsight #4957; rohanarun +#185/#199 and Maxime Fleury #204; Cinna Davis, zxv, Jacob Alan Sussman, +Mark/Matarener and the retained native/E8/ordinary/ROW/routing/precision/tape +lineage. New generator, interpreter, proof and checks prepared by JoyboyBrian +with substantial OpenAI Codex assistance. Apache-2.0; frozen sources unchanged. +No independent human or proof-kernel acceptance is claimed. + +## Open next questions + +- Lower one named `ordered_shift` or `unit_scale` leaf to the actual fixed-tape + implementation, preserving all spectators and supplied widths. Start with + the emitted address pair and bind its physical head/movement/precision bill; + the current interpreter supplies semantics and scheduling only. +- Replace the conditional `native_canonical`/`raw_reverse_swap` leaves by their + complete source runtime with the same owner/ROW contract. The exact native + implementation and all-width tape proof remain prerequisites. +- Bind a whole uniform compiled matcher list and its actual P3 constants. + Start from its source matchers and owner allocation, not the already-covered + scalar stock constants. This tensor-helper schedule is not that full list. diff --git a/research/bit-row-route-generator/RESULT.json b/research/bit-row-route-generator/RESULT.json new file mode 100644 index 0000000000..78afc86e20 --- /dev/null +++ b/research/bit-row-route-generator/RESULT.json @@ -0,0 +1,231 @@ +{ + "P3_closed": false, + "body_basis_columns": 64, + "controls": [ + "composite generator radix", + "composite serialized-program radix", + "wrong source frame", + "duplicate source owner", + "insufficient current argument reserve", + "physical owner alias", + "owner object alias", + "out of owner address", + "omitted nonzero carry cell 5", + "omitted elementary route", + "premature ROW unpad", + "uncleared owned cache", + "current inner ROW corruption", + "outer ROW corruption", + "wrong post-return high interchange" + ], + "dirty_cases": 6, + "example_program_sha256": "228f7147ab8a6bde0b5b32e78630a7e2e68a1d7a098cb4ea7178f0d1df264892", + "examples": [ + { + "borrowed_rows_returned": 0, + "f": 1, + "ledger": { + "P3_closed": false, + "active_original_owner": 462, + "address_row_words": 128, + "body_scalar_adds": 0, + "borrowed_row_range": 5, + "coefficient_preparation": "exact modular inverses; physical preparation time and tape realization remain charged P2 obligations", + "dimension": 8, + "inherited_contracts": { + "carry_shift": "P2 low-type-controlled ordered shift over Z/q^(w-1)", + "low_type_commit": "P2 finite GL_N(F_q) permutation; NOT free address lookup", + "native_canonical": "P1 completed canonical rank-4f whole-job; entire ROW restored", + "older_full_swap": "P2 older completed ordinary interchange at e=w-1 radix-q digits", + "older_high_swap": "P2 older completed ordinary interchange at borrowed_digits radix-q digits", + "ordered_shift": "P2 fixed rational ordered affine shift over Z/q^(w-1)", + "raw_reverse_swap": "P1 completed F_body; all exposed ROW and other fields restored", + "unit_scale": "P2 fixed unit scaling over Z/q^(w-1)" + }, + "integer_route_accumulator_bits": 14, + "logical_cell_bits": 5, + "low_type_table_entries_bound": 412177498341354683437500000000000000000000000, + "max_live_padding_rows": 0, + "owned_cache_bits": 192, + "padded_row_range": 6, + "padding_volume_charge": "added ROW ranges times the complete body/spectator fibre; initialization and removal remain charged", + "physical_tape_cost_closed": false, + "primitive_API_admitted": false, + "primitive_calls": { + "cache_allocate": 2, + "cache_clear": 128, + "cache_copy": 128, + "cache_release": 2, + "carry_shift": 128, + "low_type_commit": 2, + "native_canonical": 1, + "older_full_swap": 80, + "ordered_shift": 224, + "outer_enter": 1, + "outer_return": 1, + "route_enter": 2, + "route_return": 2, + "unit_scale": 80 + }, + "source_frame_sha256": "7462680ac7a7cbe7d098900c9b9d45e097db37c529c442ba2f88350e51ea8f67", + "spectator_original_owner": 461, + "tape_inventory": "active owner + distinct spectator owner + one owned low cache + scoped ROW padding extent; plus inherited primitive tape inventories", + "width_contracts": { + "ordinary_full_digits": 1, + "ordinary_high_digits": 1, + "raw_body_digits": 0 + } + }, + "q": 5, + "steps": 781, + "w": 2 + }, + { + "borrowed_rows_returned": 80, + "f": 1, + "ledger": { + "P3_closed": false, + "active_original_owner": 462, + "address_row_words": 128, + "body_scalar_adds": 480, + "borrowed_row_range": 5, + "coefficient_preparation": "exact modular inverses; physical preparation time and tape realization remain charged P2 obligations", + "dimension": 8, + "inherited_contracts": { + "carry_shift": "P2 low-type-controlled ordered shift over Z/q^(w-1)", + "low_type_commit": "P2 finite GL_N(F_q) permutation; NOT free address lookup", + "native_canonical": "P1 completed canonical rank-4f whole-job; entire ROW restored", + "older_full_swap": "P2 older completed ordinary interchange at e=w-1 radix-q digits", + "older_high_swap": "P2 older completed ordinary interchange at borrowed_digits radix-q digits", + "ordered_shift": "P2 fixed rational ordered affine shift over Z/q^(w-1)", + "raw_reverse_swap": "P1 completed F_body; all exposed ROW and other fields restored", + "unit_scale": "P2 fixed unit scaling over Z/q^(w-1)" + }, + "integer_route_accumulator_bits": 23, + "logical_cell_bits": 10, + "low_type_table_entries_bound": 412177498341354683437500000000000000000000000, + "max_live_padding_rows": 1, + "owned_cache_bits": 192, + "padded_row_range": 6, + "padding_volume_charge": "added ROW ranges times the complete body/spectator fibre; initialization and removal remain charged", + "physical_tape_cost_closed": false, + "primitive_API_admitted": false, + "primitive_calls": { + "body_add": 80, + "body_rsub": 80, + "body_sub": 80, + "cache_allocate": 2, + "cache_clear": 128, + "cache_copy": 128, + "cache_release": 2, + "carry_shift": 128, + "inner_borrow": 80, + "inner_return": 80, + "low_type_commit": 2, + "native_canonical": 1, + "older_high_swap": 80, + "ordered_shift": 224, + "outer_enter": 1, + "outer_return": 1, + "raw_reverse_swap": 160, + "route_enter": 2, + "route_return": 2, + "row_pad": 80, + "row_unpad": 80, + "unit_scale": 80 + }, + "source_frame_sha256": "7462680ac7a7cbe7d098900c9b9d45e097db37c529c442ba2f88350e51ea8f67", + "spectator_original_owner": 461, + "tape_inventory": "active owner + distinct spectator owner + one owned low cache + scoped ROW padding extent; plus inherited primitive tape inventories", + "width_contracts": { + "ordinary_full_digits": 3, + "ordinary_high_digits": 1, + "raw_body_digits": 2 + } + }, + "q": 5, + "steps": 1501, + "w": 4 + }, + { + "borrowed_rows_returned": 320, + "f": 2, + "ledger": { + "P3_closed": false, + "active_original_owner": 462, + "address_row_words": 512, + "body_scalar_adds": 1920, + "borrowed_row_range": 7, + "coefficient_preparation": "exact modular inverses; physical preparation time and tape realization remain charged P2 obligations", + "dimension": 16, + "inherited_contracts": { + "carry_shift": "P2 low-type-controlled ordered shift over Z/q^(w-1)", + "low_type_commit": "P2 finite GL_N(F_q) permutation; NOT free address lookup", + "native_canonical": "P1 completed canonical rank-4f whole-job; entire ROW restored", + "older_full_swap": "P2 older completed ordinary interchange at e=w-1 radix-q digits", + "older_high_swap": "P2 older completed ordinary interchange at borrowed_digits radix-q digits", + "ordered_shift": "P2 fixed rational ordered affine shift over Z/q^(w-1)", + "raw_reverse_swap": "P1 completed F_body; all exposed ROW and other fields restored", + "unit_scale": "P2 fixed unit scaling over Z/q^(w-1)" + }, + "integer_route_accumulator_bits": 28, + "logical_cell_bits": 12, + "low_type_table_entries_bound": 1852326463911963796329607595554455606078158823239719184797797095959154002268616874098937348989699070092144896274540336770605868709219637542847877704906009052158502455234632477636177326111996968873785886664294400000000, + "max_live_padding_rows": 2, + "owned_cache_bits": 768, + "padded_row_range": 9, + "padding_volume_charge": "added ROW ranges times the complete body/spectator fibre; initialization and removal remain charged", + "physical_tape_cost_closed": false, + "primitive_API_admitted": false, + "primitive_calls": { + "body_add": 320, + "body_rsub": 320, + "body_sub": 320, + "cache_allocate": 2, + "cache_clear": 512, + "cache_copy": 512, + "cache_release": 2, + "carry_shift": 512, + "inner_borrow": 320, + "inner_return": 320, + "low_type_commit": 2, + "native_canonical": 1, + "older_high_swap": 320, + "ordered_shift": 896, + "outer_enter": 1, + "outer_return": 1, + "raw_reverse_swap": 640, + "route_enter": 2, + "route_return": 2, + "row_pad": 320, + "row_unpad": 320, + "unit_scale": 320 + }, + "source_frame_sha256": "7462680ac7a7cbe7d098900c9b9d45e097db37c529c442ba2f88350e51ea8f67", + "spectator_original_owner": 461, + "tape_inventory": "active owner + distinct spectator owner + one owned low cache + scoped ROW padding extent; plus inherited primitive tape inventories", + "width_contracts": { + "ordinary_full_digits": 3, + "ordinary_high_digits": 1, + "raw_body_digits": 2 + } + }, + "q": 7, + "steps": 5965, + "w": 4 + } + ], + "full_primitive_API_admitted": false, + "high_matrix_basis_columns": 64, + "high_matrix_zero_cases": 1, + "new_kappa": false, + "rational_checks": { + "emitted_forward_and_inverse_factors": 48, + "projector_idempotence": true, + "source_conjugation": true + }, + "source_frame": 506, + "source_helper": 462, + "status": "SCOPED_SOURCE_ROUTE_OWNER_SCHEDULE", + "uniform_compiler_materialized": false +} diff --git a/research/bit-row-route-generator/SOURCES.json b/research/bit-row-route-generator/SOURCES.json new file mode 100644 index 0000000000..875572af3b --- /dev/null +++ b/research/bit-row-route-generator/SOURCES.json @@ -0,0 +1,48 @@ +{ + "schema_version": 1, + "base_commit": "b91956876e5b4122fd89179f1b57557ff8378f15", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "c35482cd9035843b15a634cc8276a7e1e40e8395", + "sha256": "6fe0a099b89aa2aed796a13c3a21dafc63f3388ebf397464e44e0451893b9375" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "notes/three-stage-cover-rows.tex", + "usage": "input", + "git_blob": "590da4b892a08b9d5182fb3d8a983c6239dd27db", + "sha256": "6ad97a5cd7d6aecf978a81226e1c2763d37840caca130c61f3bf5c4ac111c5c8" + }, + { + "path": "research/bit-compact-carrier-retirement/provider/inputs/WORD.json.gz", + "usage": "input", + "git_blob": "776ddd13d67b2259e90d39de5b42e4df4b1447f1", + "sha256": "69fc50430f0062c040e0686f59ad32ee5af2387ae9a97d7d11b4af1aa994ed5b" + }, + { + "path": "research/bit-finite-ordinary-bootstrap/PROOF.md", + "usage": "input", + "git_blob": "7db6805f8a9ae77b28c5772ee6de3e47777912b1", + "sha256": "5cabee7e5264ab0d674d5d591b4a3880ad460a546bcf5d53067eeeb9aff68df2" + }, + { + "path": "research/kappa-rebuild/bit/DELAYED-COVER-BRIDGE.md", + "usage": "input", + "git_blob": "a58774e237c9362869a60a22bda35be09fb85872", + "sha256": "9731b93026717f5fa15851e3633cbb4bdc76eba2bffb9d6b4a3b69f7dd502443" + }, + { + "path": "research/kappa-rebuild/bit/sources/pr589-regenerated/records/frames.json", + "usage": "input", + "git_blob": "a9a932b9268da28af9ba4bccdab205c5bcd50ad3", + "sha256": "d006b3bfe0c04afecfea7aecfa59dfe4298b99501c70da3938e40289bc2f5010" + } + ] +} diff --git a/research/bit-row-route-generator/TASK.json b/research/bit-row-route-generator/TASK.json new file mode 100644 index 0000000000..1b37340d7f --- /dev/null +++ b/research/bit-row-route-generator/TASK.json @@ -0,0 +1,102 @@ +{ + "schema_version": 1, + "task_id": "supplier-boundary-audit", + "priority_revision": 7, + "base_commit": "b91956876e5b4122fd89179f1b57557ff8378f15", + "original_card": { + "id": "supplier-boundary-audit", + "question": "Can the #4088 four-provider dispatch satisfy the complete ordinary/outer admission contract?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/staged544-mixed-fourth-entry/README.md", + "research/scatter-boundary-decision/README.md" + ], + "methods": [ + "Trace one hypothesis through the source, checker and complete caller.", + "Construct one semantically invalid but superficially well-formed fixture and test rejection." + ], + "acceptance_gate": "Pin the current sources and one obligation; the historical owner audit is an example, not evidence of a current bug.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #4088 Scope and Open next questions: local words, native receipts and literal fill do not include a rerun of the mixed four-provider ordinary/outer engine. #3801 is the newer scatter-boundary decision; do not restart #2977 as if untouched.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Pin the provider registry, four native source closures and dispatch. Make a bounded acceptance coverage map or one registry adapter preserving every inherited admission predicate and rejection control (including an omitted fourth provider). Record remaining ordinary/outer obligations and a resource estimate before heavy execution. Stop at unresolved source/caller dependencies; no selected-result promotion from a local pass.", + "bottleneck_link": "Closing a current acceptance gap or proof obligation strengthens reliability even without changing kappa.", + "allowed_variations": [ + "One provider-registry, dispatch, native-closure or admission-predicate obligation; separate branches must name distinct coverage." + ], + "scope_change_triggers": [ + "Reporting the historical timing-only diagnostic as a new current acceptance bug.", + "Calling a malformed mutant a failure of the selected construction, or importing an opt-in repair without testing the exporter boundary.", + "Running another root enclosure instead of validating dispatch or weakening an inherited predicate to make mixed admission pass." + ], + "overlap_terms": [ + "owner boundary", + "bridge omission", + "hosting", + "2977", + "scatter export", + "duplicate index", + "parity semantics", + "4088", + "3801", + "staged544-mixed-fourth-entry", + "scatter-boundary-decision" + ], + "existing_checks": [ + { + "scope": "PR #4088: author-checked local words, native receipts, owner/phase fill and exact moment.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Rebind and validate ordinary/outer admission with all four providers; full mixed release not established.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #3801: successor scatter-boundary decision package.", + "evidence": "research/scatter-boundary-decision/README.md", + "remaining": "Consult its exact acceptance scope before any new exporter audit; not proof of a selected failure.", + "status": "author-checked", + "source_commit": "911f8800ba7a4b03603ef62c5ffc6240e53cb5fd", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Actual helper462/frame506 all-N=8f addressed matcher-route and nested ROW owner schedule under explicit inherited P1/P2 primitive contracts.", + "scope_change_reason": "Fresh PR4957 handoff names the missing owner/route generator; this isolates executable scheduling from the historical four-provider admission card and from already-covered scalar stock arithmetic.", + "bottleneck_link": "Turns one conditional dense matcher/ROW scheduling obligation into an addressed program and independent interpreter while leaving primitive fixed-tape implementations and P3 explicit.", + "budget_minutes": 60, + "stop_rule": "Stop at an exact missing primitive/lifecycle or unpriced bill; do not promote primitive API admission or materialize the enormous uniform compiler.", + "outcome": "partial", + "evidence": "generator.py, interpreter.py, PROOF.md, PROGRAM.json.gz, RESULT.json and verify.py; canonical discussioncomment-19138351.", + "author": "JoyboyBrian", + "ai_assistance": "Prepared by JoyboyBrian with substantial OpenAI Codex assistance; independent operational interpreter and source oracle, no human or proof-kernel acceptance claimed.", + "open_questions": [ + { + "question": "Can one emitted ordered_shift or unit_scale be lowered to the actual fixed-tape primitive?", + "why_it_matters": "The program schedules a named P2 contract but does not prove its physical cost.", + "first_step": "Bind the emitted addresses, complete spectators, widths and head/movement/precision bill.", + "blocked_by": "Actual primitive fixed-tape implementation and provider tariff." + }, + { + "question": "Can the completed native and raw-body leaves be linked to the literal source runtime?", + "why_it_matters": "Their restored all-width ROW behavior remains P1.", + "first_step": "Substitute the source runtime behind one recorded invocation and retain the same dirty-state checks.", + "blocked_by": "Complete native runtime/ownership and tape proof." + }, + { + "question": "Can the full uniform matcher list and actual P3 constants be generated?", + "why_it_matters": "One source tensor-helper family does not close the enormous full compiler.", + "first_step": "Read the actual matchers and owner allocation before deriving any constants.", + "blocked_by": "Uniform compiler realization and whole-program physical accounting." + } + ] +} diff --git a/research/bit-row-route-generator/VERIFY.json b/research/bit-row-route-generator/VERIFY.json new file mode 100644 index 0000000000..3a269359ce --- /dev/null +++ b/research/bit-row-route-generator/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "notes/three-stage-cover-rows.tex", + "research/bit-compact-carrier-retirement/provider/inputs/WORD.json.gz", + "research/bit-finite-ordinary-bootstrap/PROOF.md", + "research/kappa-rebuild/bit/DELAYED-COVER-BRIDGE.md", + "research/kappa-rebuild/bit/sources/pr589-regenerated/records/frames.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Source-bound addressed program, independent complete-coordinate action and ownership controls" + }, + { + "argv": [ + "{python}", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Same explicit checks with assertions disabled" + } + ] +} diff --git a/research/bit-row-route-generator/generator.py b/research/bit-row-route-generator/generator.py new file mode 100644 index 0000000000..30015c270b --- /dev/null +++ b/research/bit-row-route-generator/generator.py @@ -0,0 +1,141 @@ +"""Actual frame506 matcher -> executable, owned, completed-primitive schedule. + +This emits addressed operations; the named primitive implementations remain +P1/P2 contracts. It is not a lowering of those contracts to physical bit tapes. +""" +from dataclasses import dataclass, asdict +from fractions import Fraction as F +from collections import Counter +from hashlib import sha256 +from math import gcd, prod, isqrt +import json + + +def need(ok, message): + if not ok: raise ValueError(message) + + +def inverse(a): + n=len(a);x=[[F(v) for v in row]+[F(i==j) for j in range(n)] for i,row in enumerate(a)] + for j in range(n): + k=next((i for i in range(j,n) if x[i][j]),None) + need(k is not None,'singular matcher') + x[j],x[k]=x[k],x[j];v=x[j][j];x[j]=[z/v for z in x[j]] + for i in range(n): + if i!=j: + v=x[i][j];x[i]=[u-v*z for u,z in zip(x[i],x[j])] + return [row[n:] for row in x] + + +def factors(s): + """Elimination inverses in chronological RIGHT-product order.""" + x=[[F(z) for z in row] for row in s];result=[];n=len(s) + for j in range(n): + k=next((i for i in range(j,n) if x[i][j]),None) + need(k is not None,'singular matcher') + if k!=j:x[j],x[k]=x[k],x[j];result.append(('swap',j,k,F(1))) + z=x[j][j] + if z!=1:x[j]=[v/z for v in x[j]];result.append(('scale',j,j,z)) + for i in range(n): + if i!=j and x[i][j]: + z=x[i][j];x[i]=[a-z*b for a,b in zip(x[i],x[j])] + result.append(('add',i,j,z)) + return tuple(result) + + +@dataclass(frozen=True) +class Step: + op: str + addresses: tuple=() + coefficient: tuple=(0,1) + direction: int=0 + + +@dataclass(frozen=True) +class Program: + f: int + q: int + w: int + borrowed_digits: int + reserve: int + owners: tuple + matcher: tuple + steps: tuple + ledger: dict + + def export(self): + result=asdict(self);result['matcher']=[[str(v) for v in row] for row in self.matcher] + return result + + +def generate(frame, f, q, w, borrowed_digits=1, reserve=3, owners=(462,461)): + need(type(f) is int and f>0 and type(w) is int and w>=2,'positive tensor width and w>=2') + need(type(q) is int and q>=3 and q%2==1,'odd prime radix') + need(all(q%d for d in range(3,isqrt(q)+1,2)),'prime radix required') + need(type(borrowed_digits) is int and borrowed_digits>0,'positive borrowed width') + need(type(reserve) is int and 1<=reserve<=q**borrowed_digits,'available borrowed reserve') + need(len(owners)==2 and len(set(owners))==2 and owners[0]==462,'distinct physical source owners') + need(sha256(json.dumps(frame,sort_keys=True,separators=(',',':')).encode()).hexdigest()=='7462680ac7a7cbe7d098900c9b9d45e097db37c529c442ba2f88350e51ea8f67','exact source frame506') + need(frame['dim']==4 and len(frame['A'])==len(frame['B'])==4,'actual rank-four frame') + s=tuple(tuple(F(v) for v in row) for row in zip(*(frame['B']+frame['A']))) + si=inverse(s);fs=factors(s) + need(Counter(op[0] for op in fs)==Counter(swap=5,scale=5,add=14),'actual frame506 factor census') + for row in (*s,*si): + for value in row:need(gcd(value.denominator,q)==1,'nonunit matcher denominator') + n=8*f;e=w-1;steps=[] + def emit(op,*addresses,coefficient=F(0),direction=0): + steps.append(Step(op,tuple(addresses),(coefficient.numerator,coefficient.denominator),direction)) + # Addresses are flattened high-matrix cell indices, with physical owner + # resolved once at invocation. Low cache has exactly N*N distinct cells. + emit('outer_enter') + for direction in (1,-1): + emit('route_enter',direction=direction) + emit('cache_allocate') + for k in range(n*n):emit('cache_copy',k) + seq=fs if direction==1 else tuple((kind,i,j,(1/z if kind=='scale' else -z if kind=='add' else z)) for kind,i,j,z in reversed(fs)) + for kind,i,j,z in seq: + for row in range(n): + for lane in range(f): + a=row*n+i*f+lane;b=row*n+j*f+lane + if kind=='swap': + if 2*borrowed_digits=3 and q%2==1,'odd prime radix') + divisor=3 + while divisor*divisor<=q: + require(q%divisor!=0,'prime radix required');divisor+=2 + p=deepcopy(state);n=8*program['f'];w=program['w'];e=w-1;k=program['borrowed_digits'];M=q**w;R=q**e + owner,other=map(str,program['owners']);slots=p['slots'] + require(owner!=other and slots[owner]!=slots[other],'distinct physical owners') + require(state['owners'][owner] is not state['owners'][other],'aliased owner objects') + data=p['owners'][owner];spectator=deepcopy(p['owners'][other]);outer=(tuple(data['outer']),tuple(data['z']),data['tape_head']) + require(all(len(data[x])==n*n for x in ('low','high')) and all(len(data[x])==n for x in ('h','d')),'complete owner layout') + require(all(type(x) is int and 0<=x=stock and size<=total<2*size,'finite ROW padding bound') + padding={'size':size,'total':total,'zeros':[0]*(total-size),'returned':False} + elif op in ('body_sub','body_add','body_rsub','raw_reverse_swap'): + require(inner is not None and padding is not None and tuple(addresses)==inner['addresses'],'inner primitive ownership') + a,b=addresses;ha,db=digits(data['high'][a]),digits(data['high'][b]);x,y=ha[:-k],db[:-k];allowed_high={a,b} + if op=='body_sub':y=[(v-u)%q for u,v in zip(x,y)] + elif op=='body_add':y=[(v+u)%q for u,v in zip(x,y)] + elif op=='body_rsub':y=[(u-v)%q for u,v in zip(x,y)] + else:x,y=list(reversed(y)),list(reversed(x)) + data['high'][a]=value(x+ha[-k:]);data['high'][b]=value(y+db[-k:]) + elif op=='inner_return': + require(inner is not None and padding is not None and tuple(addresses)==inner['addresses'],'active inner return') + a,b=addresses + if fault=='borrowed_row_write' and not mutated:data['high'][a]=(data['high'][a]+q**(e-k))%R;mutated=True + require(tuple(digits(data['high'][a])[-k:])==inner['row'] and tuple(digits(data['high'][b])[-k:])==inner['other_hi'],'restored borrowed ROW') + restorations.append(inner['row']);padding['returned']=True;inner=None + elif op=='row_unpad': + require(inner is None and padding is not None and padding['returned'],'unpad only after ROW return') + require(all(x==0 for x in padding['zeros']),'owned padding erasure');padding=None + elif op=='older_high_swap': + require(inner is None and padding is None,'high interchange after ROW restoration') + a,b=addresses;ha,db=digits(data['high'][a]),digits(data['high'][b]);allowed_high={a,b} + data['high'][a]=value(ha[:-k]+db[-k:]);data['high'][b]=value(db[:-k]+ha[-k:]) + elif op=='carry_shift': + require(cache is not None and len(copied)==n*n and not cleared,'complete low cache for carry') + a,=addresses;row,col=divmod(a,n);matrix=S if step['direction']==1 else Sinv + total=sum(cache[row*n+j]*matrix[j][col] for j in range(n));carry=(total-total%q)//q%R + data['high'][a]=(data['high'][a]+carry)%R;allowed_high={a} + elif op=='low_type_commit': + require(cache is not None and len(copied)==n*n and not cleared,'complete low cache for low permutation') + matrix=S if step['direction']==1 else Sinv + data['low']=[sum(cache[row*n+j]*matrix[j][col] for j in range(n))%q for row in range(n) for col in range(n)];allow_low=True + elif op=='cache_clear': + a,=addresses;require(cache is not None and a in copied and a not in cleared,'owned cache clear');cache[a]=0;cleared.add(a) + elif op=='cache_release': + require(cache is not None and len(cleared)==n*n and all(x==0 for x in cache),'complete owned cache erasure');cache=copied=cleared=None + elif op=='route_return': + require(inner is padding is cache is None and direction==step['direction'],'complete route return') + route_returns.append([data['low'][i]+q*data['high'][i] for i in range(n*n)]);direction=None + elif op=='native_canonical': + require(outer_active and direction is None and inner is padding is cache is None and addresses==[4*program['f']],'completed canonical invocation') + g=[[data['low'][i*n+j]+q*data['high'][i*n+j] for j in range(n)] for i in range(n)];gi=invert(g,M) + projection=matmul([[g[i][j] if j<4*program['f'] else 0 for j in range(n)] for i in range(n)],gi,M) + ph=[sum(x*y for x,y in zip(row,data['h']))%M for row in projection];pd=[sum(x*y for x,y in zip(row,reversed(data['d'])))%M for row in projection] + data['h']=[(x-a+b)%M for x,a,b in zip(data['h'],ph,pd)] + data['d']=[(x+a-b)%M for x,a,b in zip(data['d'],reversed(ph),reversed(pd))];allow_body=True + elif op=='outer_return': + require(outer_active and direction is None and inner is padding is cache is None,'all leases returned');outer_active=False + else:raise ValueError('unsupported primitive: '+op) + if fault=='outer_row_write' and op=='raw_reverse_swap' and not mutated:data['outer'][0]+=1;mutated=True + require_row() + require(allow_low or tuple(data['low'])==before_low,'complete low spectators') + require(allow_body or (tuple(data['h'])==before_h and tuple(data['d'])==before_d),'complete payload spectators') + require(all(x==before_high[i] for i,x in enumerate(data['high']) if i not in allowed_high),'complete high spectators') + require(not outer_active and direction is inner is padding is cache is None,'no outstanding ownership') + return p,dict(calls=calls,route_returns=route_returns,borrowed_rows_returned=len(restorations),peak_owned_low_cells=peak_cache) diff --git a/research/bit-row-route-generator/verify.py b/research/bit-row-route-generator/verify.py new file mode 100644 index 0000000000..14d670c1b9 --- /dev/null +++ b/research/bit-row-route-generator/verify.py @@ -0,0 +1,169 @@ +"""Source authentication, independent endpoint oracle and destructive checks.""" +from pathlib import Path +from fractions import Fraction as F +from hashlib import sha256 +from copy import deepcopy +import argparse,gzip,json,sys,time +from collections import Counter +HERE=Path(__file__).resolve().parent;ROOT=HERE.parents[1] +sys.path.insert(0,str(HERE)) +from generator import generate +from interpreter import run + + +def need(ok,msg): + if not ok:raise ValueError(msg) + + +def authenticate(): + pins=json.loads((HERE/'SOURCES.json').read_text())['files'] + for row in pins: + if row['usage']=='input':need(sha256((ROOT/row['path']).read_bytes()).hexdigest()==row['sha256'],'source hash mismatch: '+row['path']) + frames=json.loads((ROOT/'research/kappa-rebuild/bit/sources/pr589-regenerated/records/frames.json').read_text()) + word=json.loads(gzip.decompress((ROOT/'research/bit-compact-carrier-retirement/provider/inputs/WORD.json.gz').read_bytes())) + need(word['start'][462]==0 and word['final'][462]==506 and word['start'][461]==0,'actual original owner/frame binding') + frame=frames['frames']['506'];need(frame['dim']==4,'source rank four') + return frame + + +def mm(a,b):return [[sum(x*y for x,y in zip(row,col)) for col in zip(*b)] for row in a] +def tr(a):return [list(x) for x in zip(*a)] +def inv(a): + # Independent augmented rational solve, never uses generator elimination. + n=len(a);work=[[F(x) for x in row]+[F(i==j) for j in range(n)] for i,row in enumerate(a)] + for col in range(n): + p=next(i for i in range(col,n) if work[i][col]);work[col],work[p]=work[p],work[col] + d=work[col][col];work[col]=[x/d for x in work[col]] + for i in range(n): + if i!=col: + d=work[i][col];work[i]=[x-d*y for x,y in zip(work[i],work[col])] + return [r[n:] for r in work] +def mod(a,m):return [[int(F(x).numerator*pow(F(x).denominator,-1,m))%m for x in row] for row in a] +def lift(a,f):return [[a[i//f][j//f]*int(i%f==j%f) for j in range(len(a)*f)] for i in range(len(a)*f)] + + +def source_matrices(frame,f): + b=[[F(v) for v in row] for row in frame['B']] + p=mm(mm(tr(b),inv(mm(b,tr(b)))),b) + s=tr([[F(v) for v in row] for row in frame['B']+frame['A']]) + return lift(p,f),lift(s,f) + + +def check_rational_routes(frame): + # Reconstruct the emitted row-zero word, not generator.factors(). + p,s=source_matrices(frame,1);identity=[[F(i==j) for j in range(8)] for i in range(8)] + canonical=[[F(i==j and i<4) for j in range(8)] for i in range(8)] + need(mm(p,p)==p,'exact source projector idempotence') + need(mm(mm(s,canonical),inv(s))==p,'exact source projector conjugation') + program=encoded(frame,1,5,2);products={1:deepcopy(identity),-1:deepcopy(identity)};counts={1:0,-1:0};direction=None + for step in program['steps']: + if step['op']=='route_enter':direction=step['direction'] + op=step['op'];addresses=step['addresses'] + if op not in ('older_full_swap','unit_scale','ordered_shift') or any(a>=8 for a in addresses):continue + elementary=deepcopy(identity);a=addresses[0];z=F(*step['coefficient']) + if op=='older_full_swap': + b=addresses[1];elementary[a][a]=elementary[b][b]=F(0);elementary[a][b]=elementary[b][a]=F(1) + elif op=='unit_scale':elementary[a][a]=z + else:elementary[addresses[1]][a]=z + products[direction]=mm(products[direction],elementary);counts[direction]+=1 + need(products[1]==s and products[-1]==inv(s),'exact actual emitted right-factor products') + need(counts=={1:24,-1:24},'complete actual factor words') + return dict(projector_idempotence=True,source_conjugation=True,emitted_forward_and_inverse_factors=48) + + +def state_for(program,seed=1,body_column=None,high_column=None): + n=program['f']*8;q=program['q'];w=program['w'];r=q**(w-1);m=q**w + low=[int(i==j) for i in range(n) for j in range(n)] + # Nontrivial invertible low row, so a dropped carry is observable. + low[1]=1;low[n+2]=q-1 + high=[((i+1)*seed+3*i*i)%r for i in range(n*n)] + if high_column is not None:high=[int(i==high_column) for i in range(n*n)] + h=[(3*i+seed)%m for i in range(n)];d=[(7*i+5*seed)%m for i in range(n)] + if body_column is not None: + h=[int(i==body_column) for i in range(n)];d=[int(i+n==body_column) for i in range(n)] + return dict(slots={'462':7,'461':11},owners={'462':dict(low=low,high=high,h=h,d=d,outer=[91+seed,13,5],z=[-17,3,seed],tape_head=9),'461':dict(arbitrary=[seed,-12,999,0],tape_head=4)}) + + +def check_action(program,state,frame,return_output=False): + out,trace=run(program,state);n=8*program['f'];q=program['q'];m=q**program['w'];p,s=source_matrices(frame,program['f']) + old=state['owners']['462'];new=out['owners']['462'];g=[[old['low'][i*n+j]+q*old['high'][i*n+j] for j in range(n)] for i in range(n)] + # Rational inversion followed by valid local-ring reduction is independent + # of the interpreter's modular row solver and generated elementary word. + request=mod(mm(mm(g,p),inv(g)),m);forward=mod(mm(g,s),m) + ph=[sum(x*y for x,y in zip(row,old['h']))%m for row in request] + pd=[sum(x*y for x,y in zip(row,reversed(old['d'])))%m for row in request] + expected_h=[(v-a+b)%m for v,a,b in zip(old['h'],ph,pd)] + expected_d=[(v+a-b)%m for v,a,b in zip(old['d'],reversed(ph),reversed(pd))] + need(new['h']==expected_h and new['d']==expected_d,'independent source projector endpoint') + need(trace['route_returns'][0]==sum(forward,[]) and trace['route_returns'][1]==sum(g,[]),'independent full cover route and inverse') + need(new['low']==old['low'] and new['high']==old['high'],'all fresh ROW coordinates restored') + need(new['outer']==old['outer'] and new['z']==old['z'] and new['tape_head']==old['tape_head'] and out['owners']['461']==state['owners']['461'],'all original spectator owners preserved') + need(trace['calls']==program['ledger']['primitive_calls'],'exact generated primitive ledger') + need(trace['peak_owned_low_cells']==n*n,'owned cache extent') + return (out,trace) if return_output else trace + + +def reject(action,label): + try:action() + except (ValueError,IndexError,KeyError,ZeroDivisionError):return label + raise ValueError('control accepted: '+label) + + +def recount(program): + program['ledger']['primitive_calls']=dict(Counter(s['op'] for s in program['steps'])) + return program + +def controls(frame,program): + rows=[];state=state_for(program) + rows.append(reject(lambda:generate(frame,1,15,4),'composite generator radix')) + bad=deepcopy(program);bad['q']=15;rows.append(reject(lambda:run(bad,state),'composite serialized-program radix')) + wrong_frame=deepcopy(frame);wrong_frame['B'][0][0]=1 + rows.append(reject(lambda:generate(wrong_frame,1,5,4),'wrong source frame')) + rows.append(reject(lambda:generate(frame,1,5,4,owners=(462,462)),'duplicate source owner')) + rows.append(reject(lambda:generate(frame,1,5,4,reserve=6),'insufficient current argument reserve')) + bad=deepcopy(state);bad['slots']['461']=bad['slots']['462'];rows.append(reject(lambda:run(program,bad),'physical owner alias')) + bad=deepcopy(state);bad['owners']['461']=bad['owners']['462'];rows.append(reject(lambda:run(program,bad),'owner object alias')) + bad=deepcopy(program);next(s for s in bad['steps'] if s['op']=='ordered_shift')['addresses'][0]=8*program['f']*8*program['f'];rows.append(reject(lambda:run(bad,state),'out of owner address')) + n=8*program['f'];q=program['q'];m=q**program['w'];r=m//q + sm=mod(source_matrices(frame,program['f'])[1],m);low=state['owners']['462']['low'] + carries=[sum(low[row*n+j]*sm[j][col] for j in range(n))//q%r for row in range(n) for col in range(n)] + cell=next(i for i,c in enumerate(carries) if c) + bad=deepcopy(program);bad['steps'].remove(next(s for s in bad['steps'] if s['op']=='carry_shift' and s['addresses']==[cell]));rows.append(reject(lambda:check_action(recount(bad),state,frame),'omitted nonzero carry cell '+str(cell))) + bad=deepcopy(program);bad['steps'].remove(next(s for s in bad['steps'] if s['op']=='ordered_shift'));rows.append(reject(lambda:check_action(recount(bad),state,frame),'omitted elementary route')) + bad=deepcopy(program);bad['steps'].remove(next(s for s in bad['steps'] if s['op']=='inner_return'));rows.append(reject(lambda:run(bad,state),'premature ROW unpad')) + bad=deepcopy(program);bad['steps'].remove(next(s for s in bad['steps'] if s['op']=='cache_clear'));rows.append(reject(lambda:run(bad,state),'uncleared owned cache')) + rows.append(reject(lambda:run(program,state,'borrowed_row_write'),'current inner ROW corruption')) + rows.append(reject(lambda:run(program,state,'outer_row_write'),'outer ROW corruption')) + bad=deepcopy(program);s=next(s for s in bad['steps'] if s['op']=='older_high_swap');s['op']='older_full_swap';rows.append(reject(lambda:check_action(recount(bad),state,frame),'wrong post-return high interchange')) + return rows + + +def encoded(frame,f,q,w):return json.loads(json.dumps(generate(frame,f,q,w).export())) + + +def main(): + ap=argparse.ArgumentParser();ap.add_argument('--write',action='store_true');ap.add_argument('--probe',action='store_true');args=ap.parse_args();frame=authenticate();start=time.monotonic() + example=encoded(frame,1,5,4);check_action(example,state_for(example),frame) + if args.probe:print('PASS_PROBE',round(time.monotonic()-start,3));return + rational_checks=check_rational_routes(frame);traces=[];basis=high_basis=dirty=0 + for f,q,w in ((1,5,2),(1,5,4),(2,7,4)): + program=encoded(frame,f,q,w);n=8*f + for column in range(2*n): + trace=check_action(program,state_for(program,body_column=column),frame);basis+=1 + if f==1 and w==2: + check_action(program,state_for(program,high_column=-1),frame) + for column in range(n*n):check_action(program,state_for(program,high_column=column),frame);high_basis+=1 + for seed in (2,7):check_action(program,state_for(program,seed),frame);dirty+=1 + traces.append(dict(f=f,q=q,w=w,steps=len(program['steps']),ledger=program['ledger'],borrowed_rows_returned=trace['borrowed_rows_returned'])) + result=dict(status='SCOPED_SOURCE_ROUTE_OWNER_SCHEDULE',source_helper=462,source_frame=506,body_basis_columns=basis,high_matrix_basis_columns=high_basis,high_matrix_zero_cases=1,dirty_cases=dirty, + rational_checks=rational_checks,controls=controls(frame,example),examples=traces,example_program_sha256=sha256(json.dumps(example,sort_keys=True,separators=(',',':')).encode()).hexdigest(), + full_primitive_API_admitted=False,P3_closed=False,uniform_compiler_materialized=False,new_kappa=False) + artifact=HERE/'PROGRAM.json.gz';canonical=json.dumps(example,sort_keys=True,separators=(',',':')).encode() + if args.write: + artifact.write_bytes(gzip.compress(canonical,mtime=0));(HERE/'RESULT.json').write_text(json.dumps(result,sort_keys=True,indent=2)+'\n') + else: + need(gzip.decompress(artifact.read_bytes())==canonical,'literal emitted program receipt') + need(result==json.loads((HERE/'RESULT.json').read_text()),'deterministic result receipt') + authenticate();print(json.dumps(result,sort_keys=True,indent=2));print('elapsed_seconds',round(time.monotonic()-start,3),file=sys.stderr) + +if __name__=='__main__':main()