From 84bd28ef6da3a3473d14a48088f30ba82d414450 Mon Sep 17 00:00:00 2001 From: ToikY <27568617+ToikY@users.noreply.github.com> Date: Mon, 19 Oct 2026 02:50:29 -0700 Subject: [PATCH] Share encoded radix traversal in directory production --- .../directory-producer-invoice/.gitattributes | 1 + research/directory-producer-invoice/PROOF.md | 250 ++ research/directory-producer-invoice/README.md | 117 + .../directory-producer-invoice/RESULT.json | 2409 +++++++++++++++++ .../directory-producer-invoice/SOURCES.json | 121 + research/directory-producer-invoice/TASK.json | 122 + .../directory-producer-invoice/VERIFY.json | 36 + .../directory-producer-invoice/independent.py | 404 +++ .../source/CALLER.py | 453 ++++ .../source/NOTICE.md | 49 + .../source/cardinality.py | 136 + .../source/counts.py | 57 + .../source/directory.py | 126 + .../source/records.py | 271 ++ .../source/stream.py | 163 ++ .../source/words.py | 415 +++ .../directory-producer-invoice/test_verify.py | 315 +++ research/directory-producer-invoice/verify.py | 285 ++ 18 files changed, 5730 insertions(+) create mode 100644 research/directory-producer-invoice/.gitattributes create mode 100644 research/directory-producer-invoice/PROOF.md create mode 100644 research/directory-producer-invoice/README.md create mode 100644 research/directory-producer-invoice/RESULT.json create mode 100644 research/directory-producer-invoice/SOURCES.json create mode 100644 research/directory-producer-invoice/TASK.json create mode 100644 research/directory-producer-invoice/VERIFY.json create mode 100644 research/directory-producer-invoice/independent.py create mode 100644 research/directory-producer-invoice/source/CALLER.py create mode 100644 research/directory-producer-invoice/source/NOTICE.md create mode 100644 research/directory-producer-invoice/source/cardinality.py create mode 100644 research/directory-producer-invoice/source/counts.py create mode 100644 research/directory-producer-invoice/source/directory.py create mode 100644 research/directory-producer-invoice/source/records.py create mode 100644 research/directory-producer-invoice/source/stream.py create mode 100644 research/directory-producer-invoice/source/words.py create mode 100644 research/directory-producer-invoice/test_verify.py create mode 100644 research/directory-producer-invoice/verify.py diff --git a/research/directory-producer-invoice/.gitattributes b/research/directory-producer-invoice/.gitattributes new file mode 100644 index 0000000000..e022399ddb --- /dev/null +++ b/research/directory-producer-invoice/.gitattributes @@ -0,0 +1 @@ +source/** -text whitespace=blank-at-eol,blank-at-eof,space-before-tab,cr-at-eol diff --git a/research/directory-producer-invoice/PROOF.md b/research/directory-producer-invoice/PROOF.md new file mode 100644 index 0000000000..177069e9c2 --- /dev/null +++ b/research/directory-producer-invoice/PROOF.md @@ -0,0 +1,250 @@ +# One shared radix traversal in the source-pinned directory producer + +ToikY, with substantial OpenAI Codex assistance. Apache-2.0. + +## Result and predecessor boundary + +PR2590 (ywz65), `research/source-directory-setup-cost`, already proves the +unchanged producer's cubic radix reconstruction and complete volume-linear +asymptotic. Its explicit next question asks whether one encoded exponent +traversal can be shared across the fixed matrix coordinates. This package +answers that question for the producer component: replace its repeated +`high_power` traversal by one shared traversal, preserve its exact result and +complete record-tape behavior, and save a specified number of Word reads, +writes and unit moves. No new asymptotic order is claimed. + +The source closure is six byte-authenticated files retained at canonical main +`20ecf2891d80b5acf18d980b2164fb44ea7faa90`, under +`research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/`. +The `directory.py` SHA256 is +`4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7`; +the six original executable files remain unchanged. The experiment rebinds only the +producer module's `high_power` callback after constructing an already valid +Context. Context construction, including its separate `high_count`, and +Context close are outside the measured component and remain unchanged. + +The new claim is the shared traversal, its exact complete producer-action +delta and a separately derived complete read/write/move invoice. The earlier +division write law, output-volume theorem and directory/reserve lifetime +results retain their original credit. This is no full selected caller, +source-stock construction, physical tape compiler, recursive tariff or kappa +result. + +## Valid input contract and replacement + +Write `d` for the fixed vocabulary dimension, `M=d^2`, `modulus=q^w`, +`c=q^(w-1)`, `H=c^M`, with `q>=2`, `w>=1`. A valid source Ring uses +`L=bit_length(modulus)+1` numerical bits. `B>=1` is the number of physical old +prefix positions; `h>=0` is the number of fields in each prefix. The supplied +old-field count is an `I`-bit Word, while the old-prefix count is a canonical +variable-length Count. The supplied old-directory/count/field and used Context +heads enter at 1; unrelated protected spectators retain their own heads. + +Every old field has one valid finite `Q`-bit source code, followed by `M` +valid `L`-bit words with values strictly below `c`, then its record delimiter. +There are no extra or missing input symbols. One serialized field therefore +has + +``` +F = Q + 2 + M(L+1) +``` + +symbols. Equal old prefixes remain distinct physical positions. Successful +production emits, in source order, every old prefix followed by every +lexicographically ordered high field. Its output extent and count are + +``` +U = B H (h+1) F, returned_count = B H. +``` + +The source `counts.high_power` performs `M` complete `radix_power` traversals. +Each traversal yields `w` times; `digit_suffix` skips the first yield and +multiplies its Count by `q` on every other yield. The replacement is: + +``` +first = True +for _ in radix_power(ring,q): + if first: + first = False + else: + for _ in range(d*d): + value.multiply_small(q) +``` + +Both programs apply the same ordered sequence of exactly `M(w-1)` +multiplications by the same fixed `q`. Thus they have exactly the same Count +intermediate values, bit widths, symbol operations and final value `BH`. +The replacement decodes no runtime exponent: the existing encoded traversal +controls the outer loop and the inner `d*d` bound is fixed finite vocabulary +data. At `w=1` it still performs one full validating traversal; skipping every +traversal would omit source validation. + +The radix generator and Count multiplication operate on disjoint Word and +record-Tape objects. Retaining its divisor/power across multiple Count +multiplications requires no additional Word. On success it frees those Word +roles and restores the same protected heads. Consequently every later +instruction of `produce`, its supplied arguments and its old-prefix/output +state is identical. No change to `old_prefix`, Odometer, cleanup, count +comparison, code validation or source serialization is needed. + +This theorem concerns successful valid inputs. It does not add a new +exception-path rollback contract to the inherited source, or establish that +every arbitrary malformed numerical record is leak-free on rejection. + +## Exact radix invoice + +All vectors below have order `(reads,writes,unit_moves)` and use the source's +fixed-alphabet Word/Tape meters. They include zero initialization and erasure +where stated. Python allocation, instrumentation, audit-only integer decoding +and a physical fixed-tape implementation are outside this meter. + +For a full-width division with quotient popcount `s`, the exact Word invoice is + +``` +D_L(s) = (15L^2+44L+33 + (12L+15)s, + 3L^2+ 8L+ 4 + ( 3L+ 2)s, + 14L^2+50L+44 + (12L+20)s). +``` + +PR2590 owns the middle, write-count identity. The other lanes are derived from +the same frozen methods. Each of the `L` division iterations performs a shift, +erases its former remainder, compares full words, writes one quotient bit and +moves both scan heads. A subtraction occurs exactly for the `s` one bits of +the quotient. Every `shift_add_bit` includes its `L+1` loop-condition reads; +finite literal loading also includes its extent-check reads. Counting these +reads is necessary for the complete invoice. + +Useful exact vectors, for words starting at head 1, are + +| Operation | `(reads,writes,unit_moves)` | +|---|---| +| Arena zero | `(4L+5,L+1,4L+6)` | +| Arena free | `(2L+3,L+1,2L+4)` | +| Arena copy | `(8L+9,2L+1,8L+12)` | +| Nonaliased comparison | `(5L+6,0,4L+8)` | +| Word zero test | `(2L+3,0,2L+4)` | +| Literal `q`, `b=bit_length(q)` | zero-vector plus `(2b+1,b,2b+2)` | + +Let `A_L`, `E_L`, `C_L`, `P_L`, `Z_L` respectively denote the last table's +literal, free, copy, comparison and zero-test vectors. One full radix +traversal has exact cost + +``` +R(q,w,L) = A_L + C_L + (w+2)P_L + + sum_(j=0..w-1) D_L(popcount(q^j)) + + 2w Z_L + (2w+2)E_L. +``` + +The two extra comparisons validate the final one; the final two erasures +dispose of divisor and power. The unchanged source performs `M` such +traversals, and the replacement performs one. All other Word operations and +every record/index operation agree. The exact complete producer saving is +therefore + +``` +Delta_record = Delta_index = (0,0,0), +Delta_residue = (M-1) R(q,w,L). +``` + +It is zero for `d=1` and strictly positive in all three lanes for `d>1`. +This saving is independent of `B`, `h`, old field values and the Count size; +those affect identical retained work. The asymptotic cubic dependence on +`w` remains when `d` is fixed, as already proved in PR2590. + +## Complete retained work, rather than only output writes + +`independent.py` derives the entire original and replacement invoices, not +only their delta. It imports no primary or predecessor executable and binds +the six source byte strings before comparing the measured receipt. Its +separate lanes include all supplied Tape and Word meter changes as well as +source-created scratch objects. + +The exact Odometer counts per old prefix are + +``` +I_c = sum_(j=1..M) c^j, A_c = sum_(j=0..M-1) c^j, +T_c = A_c (c-popcount(c)). +``` + +Here `I_c` counts digit increments, `A_c` counts carry/reset paths and `T_c` +counts one-bit ripple visits. At `c=1`, both sums equal `M`, rather than using +a singular geometric-quotient expression. Each reset scans the entire `L` +bits. The last advance, which marks the Odometer finished, is included. + +For `K>=1`, put `t=K-popcount(K)` and `e=bit_length(K)-1`. All emission Count +increments from 0 to K cost + +``` +(2t+5K, t+K+e, 2t+4K+2e). +``` + +The complete Counter countdown from K to 0 costs + +``` +(2t+5K+1, t+K+2e+3, 2t+4K+2e+4). +``` + +The different final-zero and growing-right-delimiter paths explain the +different constants. Constructors, old padded-field-count input scans, +normalization, Count equality and final erasure are additional explicit +terms; they are not folded into a zero-cost loop bound. Count multiplication +from bit width `k` to `k'` costs `(2k+k'+2,k'+1,2k'+2)`. + +For completeness, a saved old prefix has `n=hF` symbols. Its construction, +return rewind, all H copies and final clear cost + +``` +(4n+4+H(3n+3), 2n, 4n+6+H(2n+4)) +``` + +on its own record Tape. The output Tape, including its final rewind, costs +`(2U+1,U,2U+2)`. Its borrowed old-input Tape costs +`(2BhF+BhML+3,0,2BhF+4)`. This includes all validation reads, initial and +final rewinds. One old numerical word's allocation, decoding, range check, +saved serialization and erasure costs `(16L+19,3L+2,14L+24)`. +These terms, all Odometer Word operations, all count operations and the +unchanged `high_power` or replacement term are summed in the checker. + +The source creates exactly `5+2B` record Tape objects during production. +No physical Tape-object reuse is inferred merely because a logical role is +dead. The already known additional numerical live-word peak is +`max(M,6)`: Odometer owns M, exponent reconstruction needs at most six and +old-prefix decoding owns one at a time. Those phases are disjoint. The shared +version does not change this peak. This is reuse/confirmation of the existing +directory lifetime analysis, not a new reserve theorem or proof that the +physical caller can host all objects simultaneously. + +## Finite evidence and limits + +The measured component starts with a valid Context. Both variants run against +the same source fixtures, with runtime `Word.inspect` forbidden. The primary +observer includes all preexisting borrowed record tapes, all new record tapes, +residue-arena/template actions and the index-word arena. The independent +checker reproduces every action lane from formulas and independently creates +the complete expected output bytes by base-c address expansion. + +Seven paired fixtures include three distinct empty-prefix positions, +nonempty histories of lengths one and two, radices 2/3/5, a binary long-carry +case, a nine-digit binary Odometer, a nontrivial `d=2,c=3` high cube and the +actual `d=64,c=1` boundary. The latter runs the unchanged dimension-64 producer code, but is +not a full nontrivial high-cube or selected source-stock execution. Bounded +small Odometers independently corroborate unique ordered enumeration, full +carry/reset counts and ripple sums. These checks do not replace the symbolic +loop argument above. + +At `d=64,q=3,w=1,L=3`, one radix traversal costs `(523,95,556)`. +The replacement saves exactly `(2141685,389025,2276820)` residue Word actions. +In the recorded `B=1,h=1,Q=6507,I=4` fixture, its residue Word invoice changes +from `(2793472,483328,2916352)` to `(651787,94303,639532)`. +Record Tape `(310027,91612,274870)` and index Word `(15,0,12)` costs agree. +The complete output bytes/count, protected words, heads and scratch erasure +also agree. No elapsed-time or bit-machine saving is inferred from these +source-meter numbers. + +Credit Jose Manuel/PR2569 for the producer, ywz65/PR2590 and PR2566 for setup +and primitive cost analysis, and the retained stream/cardinality/selected +caller and storage-reserve lineage. Original source notices and all frozen +bytes remain intact. Adoption into a shared producer, a complete caller +invoice, physical Tape layout/allocation, full Pi/source-stock admission, +recursive/supplier/outer obligations and frontier changes are outside this +package. No independent human or formal-kernel acceptance is claimed. diff --git a/research/directory-producer-invoice/README.md b/research/directory-producer-invoice/README.md new file mode 100644 index 0000000000..48605632ee --- /dev/null +++ b/research/directory-producer-invoice/README.md @@ -0,0 +1,117 @@ +# Share one encoded radix traversal in directory setup + +The retained `directory.produce` computes its returned count by reconstructing +the same modulus radix once per matrix coordinate. This package supplies one +local replacement, `high_power_shared`, that traverses the encoded radix once +and repeats the identical count multiplication at each yield. The unchanged +producer is executed with either binding; frozen/shared runtime bytes are not +edited or installed. + +Let d be dimension, M=d², modulus=q^w, c=q^(w−1), H=c^M, and B>0 the physical +old-prefix count. Both versions perform exactly M(w−1) ordered multiplications +by q on the returned Count and produce B H. The candidate removes exactly +M−1 complete radix traversals. For a one-traversal source Word invoice +rho=(reads,writes,unit moves), its exact saving is `(M−1)rho`. +Record/Count/Counter Tape actions, old-field index Word actions, output bytes, +lexicographic order and multiplicity are unchanged. + +The actual dimension64/cap1 fixture uses the retained Q=6507 code width and +executes the complete producer. Source residue Word actions fall from +`(2793472,483328,2916352)` to `(651787,94303,639532)`: +exact saving `(2141685,389025,2276820) = 4095*(523,95,556)`. +Record Tape actions remain `(310027,91612,274870)` and index Word actions +remain `(15,0,12)`. This is an action count, not a wall-clock speed claim. +The fixture uses a projected valid finite vocabulary; it does not reconstruct +the full selected source catalogue or admit its low-code/GL specifications. + +## Contract and prior work + +The interval starts with an already-live valid Context and canonical valid +input tapes/Words, positive B, enough arena capacity and no concurrent mutation. +Context preparation/teardown, input/vocabulary compilation and disposal of the +returned directory/Count remain explicit caller charges outside the interval. +No numerical decoding of runtime Words is used. The independent integer model +is external mathematical verification, not runtime control. + +`source/CALLER.py:207` retains the actual `Machine.residual_begin` call to this +producer. The candidate is opt-in research code; the shared caller remains +unchanged. Python controller/object/allocation costs, literal physical tape +lowering, backing/slot metadata, source admission and full caller composition +remain separate. Successful valid-input restoration is the contract; inherited +malformed-input paths do not provide general exception rollback. + +[PR2590](https://github.com/CrocSwap/integer-mult-bounds/pull/2590), by ywz65, +already proves repeated radix reconstruction is cubic in w and the complete +producer is Theta_q(D), including counters and physical duplicate prefixes. +Its explicit shared-traversal question motivates this replacement. Its output +formula `D=B H(h+1)[Q+2+M(L+1)]`, the separate directory-storage allowance, +and Ross Richardson's exact successful numerical peak `max(M,6)` are credited +prior results. The peak remains unchanged here; at d=64 it is 4096 above +all entry residents. This is not a new asymptotic theorem or peak discovery. + +The source Word radix term falls from M traversals to one. With fixed dimension +it retains the cubic width order; no claim removes that order. All M(w−1) +Count multiplications remain charged. `PROOF.md` and `independent.py` give the +complete exact invoice and phase boundaries, rather than treating output size +or a numerical peak as a whole physical caller bill. + +## Evidence and reproduction + +```sh +python3.12 -B scripts/research_package.py --package research/directory-producer-invoice +python3.12 -I -B research/directory-producer-invoice/verify.py +python3.12 -I -B research/directory-producer-invoice/independent.py +python3.12 -I -B research/directory-producer-invoice/test_verify.py +``` + +Six runtime modules and the caller/notice exports are authenticated by exact +SHA256 and Git blobs before execution. The primary meters every created and +borrowed Tape plus residue/index arena traffic, compares actual original and +candidate runs, and checks output/order, count, heads, protected state and +successful cleanup. The separate formula checker imports neither primary nor +retained executable modules. Controls target wrong yield/multiplication, +undercounted radix work, multiplicity, source authentication and typed receipts. +Normal and optimized replay must pass; default replay is read-only. + +Bounded complete high cubes use small dimensions/caps. The dimension64 fixture +has cap1; no multi-lift dimension64 directory, huge-prime payload, complete GL64 +source, full selected cold replay, human review or formal-kernel acceptance is +claimed. The written source argument covers valid arbitrary parameters under +its contract; finite tests corroborate it. + +## Scope and coordination + +Canonical base `20ecf2891d80b5acf18d980b2164fb44ea7faa90`, priority6. The changed +`selected-stock-envelope` card is retained exactly in `TASK.json`. The named +baseline was attempted but a sparse omitted selected-package ASSEMBLY blocks +its inventory check; this package supplies its own complete local runtime slice. +It does not derive the selected complex m73 reserve coefficient. + +The canonical investigation is the claim/update on +[PR4011](https://github.com/CrocSwap/integer-mult-bounds/pull/4011#issuecomment-6264214824). +`TASK.json` records the full724-open-PR-body entry scan, latest100-body delta, +retained predecessor reassessment, live handoff checks and coverage limits. +No novelty guarantee follows from the bounded text search. + +## Open next questions + +See structured questions in `TASK.json`. First review this exact success +contract and bind the candidate to the complete caller with a physical control +and allocator tariff. Context, child_extents/read_prefix, geometry, coefficients, +dispatch and the other Pi phases remain charged obligations. Then join all +simultaneously live parent/child, dirty, Count, template and backing categories +at original widths before claiming reserve or recursive supplier admission. +There is no selected-frontier or kappa change. + +## Credit + +Jose Manuel/jmbarrancoml supplies the physical caller, encoded runtime and +canonical directory lineage; David Arias/PR2753 and Nick Petalas supply retained +caller/controller/record components. Their complete original notice is retained +unchanged in `source/NOTICE.md`. ywz65/PR2566 and PR2590 supply primitive/setup +analysis, the cubic correction and explicit optimization question; ywz65's +directory-storage package and Ross Richardson's numerical-phase audit supply +the credited storage/peak facts. Chris R/Clear1nsight PR3983/4011 supplies the +adjacent preparation/admission bill and named directory/context obligations. +New adapter, exact invoice, proof and packaging by ToikY with substantial +OpenAI Codex assistance and separate AI math/test contexts. Apache-2.0. diff --git a/research/directory-producer-invoice/RESULT.json b/research/directory-producer-invoice/RESULT.json new file mode 100644 index 0000000000..8fff36f159 --- /dev/null +++ b/research/directory-producer-invoice/RESULT.json @@ -0,0 +1,2409 @@ +{ + "cases": [ + { + "config": { + "B": 3, + "I": 3, + "Q": 4, + "d": 1, + "h": 0, + "name": "small_h0", + "q": 3, + "w": 2 + }, + "original": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 4, + "reads": 3, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": false, + "config": { + "B": 3, + "I": 3, + "Q": 4, + "d": 1, + "h": 0, + "name": "small_h0", + "q": 3, + "w": 2 + }, + "created_record_tapes": 11, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 12, + "H": 3, + "L": 5, + "M": 1, + "cap": 3, + "modulus": 9, + "old_body": 0, + "output_body": 108 + }, + "index_words": { + "moves": 30, + "reads": 36, + "writes": 0 + }, + "input_sha256": "dbc1b4c900ffe48d575b5da5c638040125f65db0fe3e24494b76ea986457d986", + "new_residue_slots": 1, + "odometer_advances": 9, + "odometer_increment_visits": 9, + "ordered_expected_q_multipliers": 1, + "output_head": 1, + "output_sha256": "2fc4b52c190e9dac49cb226f3af178d1b41223a517453206abee2db19e544fe3", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 36, + "reads": 39, + "writes": 8 + }, + "head": 1, + "role": "expected", + "visited_cells": 6 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 98, + "reads": 100, + "writes": 30 + }, + "head": 1, + "role": "emitted", + "visited_cells": 7 + }, + { + "actions": { + "moves": 36, + "reads": 32, + "writes": 14 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 218, + "reads": 217, + "writes": 108 + }, + "head": 1, + "role": "output", + "visited_cells": 110 + }, + { + "actions": { + "moves": 18, + "reads": 13, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 18, + "reads": 13, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 18, + "reads": 13, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 566, + "reads": 520, + "writes": 206 + }, + "residue_allocations": 24, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 2524, + "reads": 2540, + "writes": 407 + }, + "returned_prefix_count": 9, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1864, + "reads": 1814, + "writes": 344 + } + }, + "saved_residue_actions": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "shared_radix": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 4, + "reads": 3, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": true, + "config": { + "B": 3, + "I": 3, + "Q": 4, + "d": 1, + "h": 0, + "name": "small_h0", + "q": 3, + "w": 2 + }, + "created_record_tapes": 11, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 12, + "H": 3, + "L": 5, + "M": 1, + "cap": 3, + "modulus": 9, + "old_body": 0, + "output_body": 108 + }, + "index_words": { + "moves": 30, + "reads": 36, + "writes": 0 + }, + "input_sha256": "dbc1b4c900ffe48d575b5da5c638040125f65db0fe3e24494b76ea986457d986", + "new_residue_slots": 1, + "odometer_advances": 9, + "odometer_increment_visits": 9, + "ordered_expected_q_multipliers": 1, + "output_head": 1, + "output_sha256": "2fc4b52c190e9dac49cb226f3af178d1b41223a517453206abee2db19e544fe3", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 36, + "reads": 39, + "writes": 8 + }, + "head": 1, + "role": "expected", + "visited_cells": 6 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 98, + "reads": 100, + "writes": 30 + }, + "head": 1, + "role": "emitted", + "visited_cells": 7 + }, + { + "actions": { + "moves": 36, + "reads": 32, + "writes": 14 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 218, + "reads": 217, + "writes": 108 + }, + "head": 1, + "role": "output", + "visited_cells": 110 + }, + { + "actions": { + "moves": 18, + "reads": 13, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 18, + "reads": 13, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 18, + "reads": 13, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 566, + "reads": 520, + "writes": 206 + }, + "residue_allocations": 24, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 2524, + "reads": 2540, + "writes": 407 + }, + "returned_prefix_count": 9, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1864, + "reads": 1814, + "writes": 344 + } + } + }, + { + "config": { + "B": 2, + "I": 3, + "Q": 4, + "d": 2, + "h": 1, + "name": "small_h1", + "q": 3, + "w": 2 + }, + "original": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 124, + "reads": 163, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": false, + "config": { + "B": 2, + "I": 3, + "Q": 4, + "d": 2, + "h": 1, + "name": "small_h1", + "q": 3, + "w": 2 + }, + "created_record_tapes": 9, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 30, + "H": 81, + "L": 5, + "M": 4, + "cap": 3, + "modulus": 9, + "old_body": 60, + "output_body": 9720 + }, + "index_words": { + "moves": 20, + "reads": 24, + "writes": 0 + }, + "input_sha256": "a27def7da638fed61060b96a4e2d5abe7accf09e70034ccb043555387a9bdcb6", + "new_residue_slots": 1, + "odometer_advances": 162, + "odometer_increment_visits": 240, + "ordered_expected_q_multipliers": 4, + "output_head": 1, + "output_sha256": "ee3f760e7029b24f825f3a1de03c483ce5c55d4490f1fb7d3f7cbf58b9339009", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 4, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 86, + "reads": 103, + "writes": 29 + }, + "head": 1, + "role": "expected", + "visited_cells": 10 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 1038, + "reads": 1189, + "writes": 343 + }, + "head": 1, + "role": "emitted", + "visited_cells": 11 + }, + { + "actions": { + "moves": 32, + "reads": 27, + "writes": 13 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 19442, + "reads": 19441, + "writes": 9720 + }, + "head": 1, + "role": "output", + "visited_cells": 9722 + }, + { + "actions": { + "moves": 5310, + "reads": 7657, + "writes": 60 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 32 + }, + { + "actions": { + "moves": 30, + "reads": 22, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 5310, + "reads": 7657, + "writes": 60 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 32 + }, + { + "actions": { + "moves": 30, + "reads": 22, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 31438, + "reads": 36317, + "writes": 10257 + }, + "residue_allocations": 100, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 28640, + "reads": 32016, + "writes": 2328 + }, + "returned_prefix_count": 162, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1864, + "reads": 1814, + "writes": 344 + } + }, + "saved_residue_actions": { + "moves": 5592, + "reads": 5442, + "writes": 1032 + }, + "shared_radix": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 124, + "reads": 163, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": true, + "config": { + "B": 2, + "I": 3, + "Q": 4, + "d": 2, + "h": 1, + "name": "small_h1", + "q": 3, + "w": 2 + }, + "created_record_tapes": 9, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 30, + "H": 81, + "L": 5, + "M": 4, + "cap": 3, + "modulus": 9, + "old_body": 60, + "output_body": 9720 + }, + "index_words": { + "moves": 20, + "reads": 24, + "writes": 0 + }, + "input_sha256": "a27def7da638fed61060b96a4e2d5abe7accf09e70034ccb043555387a9bdcb6", + "new_residue_slots": 1, + "odometer_advances": 162, + "odometer_increment_visits": 240, + "ordered_expected_q_multipliers": 4, + "output_head": 1, + "output_sha256": "ee3f760e7029b24f825f3a1de03c483ce5c55d4490f1fb7d3f7cbf58b9339009", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 86, + "reads": 103, + "writes": 29 + }, + "head": 1, + "role": "expected", + "visited_cells": 10 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 1038, + "reads": 1189, + "writes": 343 + }, + "head": 1, + "role": "emitted", + "visited_cells": 11 + }, + { + "actions": { + "moves": 32, + "reads": 27, + "writes": 13 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 19442, + "reads": 19441, + "writes": 9720 + }, + "head": 1, + "role": "output", + "visited_cells": 9722 + }, + { + "actions": { + "moves": 5310, + "reads": 7657, + "writes": 60 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 32 + }, + { + "actions": { + "moves": 30, + "reads": 22, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 5310, + "reads": 7657, + "writes": 60 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 32 + }, + { + "actions": { + "moves": 30, + "reads": 22, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 31438, + "reads": 36317, + "writes": 10257 + }, + "residue_allocations": 37, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 23048, + "reads": 26574, + "writes": 1296 + }, + "returned_prefix_count": 162, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1864, + "reads": 1814, + "writes": 344 + } + } + }, + { + "config": { + "B": 1, + "I": 4, + "Q": 5, + "d": 2, + "h": 2, + "name": "small_h2", + "q": 3, + "w": 2 + }, + "original": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 128, + "reads": 167, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 12, + "reads": 12, + "writes": 0 + }, + "candidate_shared_radix": false, + "config": { + "B": 1, + "I": 4, + "Q": 5, + "d": 2, + "h": 2, + "name": "small_h2", + "q": 3, + "w": 2 + }, + "created_record_tapes": 7, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 31, + "H": 81, + "L": 5, + "M": 4, + "cap": 3, + "modulus": 9, + "old_body": 62, + "output_body": 7533 + }, + "index_words": { + "moves": 12, + "reads": 15, + "writes": 0 + }, + "input_sha256": "bf7f9d4ca7aac108a03e78c1f6e27ef92fb1c528c54f884028014c5abe12be44", + "new_residue_slots": 1, + "odometer_advances": 81, + "odometer_increment_visits": 120, + "ordered_expected_q_multipliers": 4, + "output_head": 1, + "output_sha256": "7aad7e0e229057f4a991be2339b48581998067864b79fcdfa8e251ceae3b3310", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 4, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 72, + "reads": 84, + "writes": 24 + }, + "head": 1, + "role": "expected", + "visited_cells": 9 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 546, + "reads": 617, + "writes": 179 + }, + "head": 1, + "role": "emitted", + "visited_cells": 10 + }, + { + "actions": { + "moves": 22, + "reads": 18, + "writes": 8 + }, + "head": 1, + "role": "outer", + "visited_cells": 4 + }, + { + "actions": { + "moves": 15068, + "reads": 15067, + "writes": 7533 + }, + "head": 1, + "role": "output", + "visited_cells": 7535 + }, + { + "actions": { + "moves": 10622, + "reads": 15561, + "writes": 124 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 64 + }, + { + "actions": { + "moves": 40, + "reads": 31, + "writes": 19 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + } + ], + "record_tapes": { + "moves": 26530, + "reads": 31575, + "writes": 7891 + }, + "residue_allocations": 96, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 18424, + "reads": 20032, + "writes": 1920 + }, + "returned_prefix_count": 81, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1864, + "reads": 1814, + "writes": 344 + } + }, + "saved_residue_actions": { + "moves": 5592, + "reads": 5442, + "writes": 1032 + }, + "shared_radix": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 128, + "reads": 167, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 12, + "reads": 12, + "writes": 0 + }, + "candidate_shared_radix": true, + "config": { + "B": 1, + "I": 4, + "Q": 5, + "d": 2, + "h": 2, + "name": "small_h2", + "q": 3, + "w": 2 + }, + "created_record_tapes": 7, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 31, + "H": 81, + "L": 5, + "M": 4, + "cap": 3, + "modulus": 9, + "old_body": 62, + "output_body": 7533 + }, + "index_words": { + "moves": 12, + "reads": 15, + "writes": 0 + }, + "input_sha256": "bf7f9d4ca7aac108a03e78c1f6e27ef92fb1c528c54f884028014c5abe12be44", + "new_residue_slots": 1, + "odometer_advances": 81, + "odometer_increment_visits": 120, + "ordered_expected_q_multipliers": 4, + "output_head": 1, + "output_sha256": "7aad7e0e229057f4a991be2339b48581998067864b79fcdfa8e251ceae3b3310", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 72, + "reads": 84, + "writes": 24 + }, + "head": 1, + "role": "expected", + "visited_cells": 9 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 546, + "reads": 617, + "writes": 179 + }, + "head": 1, + "role": "emitted", + "visited_cells": 10 + }, + { + "actions": { + "moves": 22, + "reads": 18, + "writes": 8 + }, + "head": 1, + "role": "outer", + "visited_cells": 4 + }, + { + "actions": { + "moves": 15068, + "reads": 15067, + "writes": 7533 + }, + "head": 1, + "role": "output", + "visited_cells": 7535 + }, + { + "actions": { + "moves": 10622, + "reads": 15561, + "writes": 124 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 64 + }, + { + "actions": { + "moves": 40, + "reads": 31, + "writes": 19 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + } + ], + "record_tapes": { + "moves": 26530, + "reads": 31575, + "writes": 7891 + }, + "residue_allocations": 33, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 12832, + "reads": 14590, + "writes": 888 + }, + "returned_prefix_count": 81, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1864, + "reads": 1814, + "writes": 344 + } + } + }, + { + "config": { + "B": 3, + "I": 3, + "Q": 3, + "d": 1, + "h": 0, + "name": "binary_long_carry", + "q": 2, + "w": 4 + }, + "original": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 4, + "reads": 3, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": false, + "config": { + "B": 3, + "I": 3, + "Q": 3, + "d": 1, + "h": 0, + "name": "binary_long_carry", + "q": 2, + "w": 4 + }, + "created_record_tapes": 11, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 12, + "H": 8, + "L": 6, + "M": 1, + "cap": 8, + "modulus": 16, + "old_body": 0, + "output_body": 288 + }, + "index_words": { + "moves": 30, + "reads": 36, + "writes": 0 + }, + "input_sha256": "dbc1b4c900ffe48d575b5da5c638040125f65db0fe3e24494b76ea986457d986", + "new_residue_slots": 1, + "odometer_advances": 24, + "odometer_increment_visits": 24, + "ordered_expected_q_multipliers": 3, + "output_head": 1, + "output_sha256": "04f1b3cd7f86cb6e7229f00f983926332fd569afddd2a8f9b8896ed1e2338f50", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 4, + "record_roles": [ + { + "actions": { + "moves": 58, + "reads": 68, + "writes": 18 + }, + "head": 1, + "role": "expected", + "visited_cells": 7 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 194, + "reads": 210, + "writes": 62 + }, + "head": 1, + "role": "emitted", + "visited_cells": 8 + }, + { + "actions": { + "moves": 36, + "reads": 32, + "writes": 14 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 578, + "reads": 577, + "writes": 288 + }, + "head": 1, + "role": "output", + "visited_cells": 290 + }, + { + "actions": { + "moves": 38, + "reads": 28, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 38, + "reads": 28, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 38, + "reads": 28, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 1104, + "reads": 1064, + "writes": 428 + }, + "residue_allocations": 45, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 5902, + "reads": 6061, + "writes": 917 + }, + "returned_prefix_count": 24, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 4336, + "reads": 4273, + "writes": 812 + } + }, + "saved_residue_actions": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "shared_radix": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 4, + "reads": 3, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": true, + "config": { + "B": 3, + "I": 3, + "Q": 3, + "d": 1, + "h": 0, + "name": "binary_long_carry", + "q": 2, + "w": 4 + }, + "created_record_tapes": 11, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 12, + "H": 8, + "L": 6, + "M": 1, + "cap": 8, + "modulus": 16, + "old_body": 0, + "output_body": 288 + }, + "index_words": { + "moves": 30, + "reads": 36, + "writes": 0 + }, + "input_sha256": "dbc1b4c900ffe48d575b5da5c638040125f65db0fe3e24494b76ea986457d986", + "new_residue_slots": 1, + "odometer_advances": 24, + "odometer_increment_visits": 24, + "ordered_expected_q_multipliers": 3, + "output_head": 1, + "output_sha256": "04f1b3cd7f86cb6e7229f00f983926332fd569afddd2a8f9b8896ed1e2338f50", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 4, + "record_roles": [ + { + "actions": { + "moves": 58, + "reads": 68, + "writes": 18 + }, + "head": 1, + "role": "expected", + "visited_cells": 7 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 194, + "reads": 210, + "writes": 62 + }, + "head": 1, + "role": "emitted", + "visited_cells": 8 + }, + { + "actions": { + "moves": 36, + "reads": 32, + "writes": 14 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 578, + "reads": 577, + "writes": 288 + }, + "head": 1, + "role": "output", + "visited_cells": 290 + }, + { + "actions": { + "moves": 38, + "reads": 28, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 38, + "reads": 28, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + }, + { + "actions": { + "moves": 38, + "reads": 28, + "writes": 0 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 2 + }, + { + "actions": { + "moves": 28, + "reads": 18, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 1104, + "reads": 1064, + "writes": 428 + }, + "residue_allocations": 45, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 5902, + "reads": 6061, + "writes": 917 + }, + "returned_prefix_count": 24, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 4336, + "reads": 4273, + "writes": 812 + } + } + }, + { + "config": { + "B": 1, + "I": 3, + "Q": 3, + "d": 3, + "h": 1, + "name": "binary_nine_digits", + "q": 2, + "w": 2 + }, + "original": { + "additional_residue_peak": 9, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 104, + "reads": 139, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 12, + "reads": 12, + "writes": 0 + }, + "candidate_shared_radix": false, + "config": { + "B": 1, + "I": 3, + "Q": 3, + "d": 3, + "h": 1, + "name": "binary_nine_digits", + "q": 2, + "w": 2 + }, + "created_record_tapes": 7, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 50, + "H": 512, + "L": 4, + "M": 9, + "cap": 2, + "modulus": 4, + "old_body": 50, + "output_body": 51200 + }, + "index_words": { + "moves": 10, + "reads": 12, + "writes": 0 + }, + "input_sha256": "cdad5e6f979720bed4f592e119a4707ec1a84c906c4b9d0828babd398c624178", + "new_residue_slots": 4, + "odometer_advances": 512, + "odometer_increment_visits": 1022, + "ordered_expected_q_multipliers": 9, + "output_head": 1, + "output_sha256": "668c9eab71a86eabc09b205a377138fc3512bf3f833f6a62ddb11c55d1a9296c", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 9, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 160, + "reads": 205, + "writes": 65 + }, + "head": 1, + "role": "expected", + "visited_cells": 12 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 3154, + "reads": 3653, + "writes": 1049 + }, + "head": 1, + "role": "emitted", + "visited_cells": 13 + }, + { + "actions": { + "moves": 22, + "reads": 18, + "writes": 8 + }, + "head": 1, + "role": "outer", + "visited_cells": 4 + }, + { + "actions": { + "moves": 102402, + "reads": 102401, + "writes": 51200 + }, + "head": 1, + "role": "output", + "visited_cells": 51202 + }, + { + "actions": { + "moves": 53454, + "reads": 78540, + "writes": 100 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 52 + }, + { + "actions": { + "moves": 30, + "reads": 22, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 159358, + "reads": 185008, + "writes": 52440 + }, + "residue_allocations": 180, + "residue_slots_at_exit": 13, + "residue_words": { + "moves": 115574, + "reads": 131978, + "writes": 5971 + }, + "returned_prefix_count": 512, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1360, + "reads": 1305, + "writes": 242 + } + }, + "saved_residue_actions": { + "moves": 10880, + "reads": 10440, + "writes": 1936 + }, + "shared_radix": { + "additional_residue_peak": 9, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 104, + "reads": 139, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 12, + "reads": 12, + "writes": 0 + }, + "candidate_shared_radix": true, + "config": { + "B": 1, + "I": 3, + "Q": 3, + "d": 3, + "h": 1, + "name": "binary_nine_digits", + "q": 2, + "w": 2 + }, + "created_record_tapes": 7, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 50, + "H": 512, + "L": 4, + "M": 9, + "cap": 2, + "modulus": 4, + "old_body": 50, + "output_body": 51200 + }, + "index_words": { + "moves": 10, + "reads": 12, + "writes": 0 + }, + "input_sha256": "cdad5e6f979720bed4f592e119a4707ec1a84c906c4b9d0828babd398c624178", + "new_residue_slots": 4, + "odometer_advances": 512, + "odometer_increment_visits": 1022, + "ordered_expected_q_multipliers": 9, + "output_head": 1, + "output_sha256": "668c9eab71a86eabc09b205a377138fc3512bf3f833f6a62ddb11c55d1a9296c", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 160, + "reads": 205, + "writes": 65 + }, + "head": 1, + "role": "expected", + "visited_cells": 12 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 3154, + "reads": 3653, + "writes": 1049 + }, + "head": 1, + "role": "emitted", + "visited_cells": 13 + }, + { + "actions": { + "moves": 22, + "reads": 18, + "writes": 8 + }, + "head": 1, + "role": "outer", + "visited_cells": 4 + }, + { + "actions": { + "moves": 102402, + "reads": 102401, + "writes": 51200 + }, + "head": 1, + "role": "output", + "visited_cells": 51202 + }, + { + "actions": { + "moves": 53454, + "reads": 78540, + "writes": 100 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 52 + }, + { + "actions": { + "moves": 30, + "reads": 22, + "writes": 14 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 6 + } + ], + "record_tapes": { + "moves": 159358, + "reads": 185008, + "writes": 52440 + }, + "residue_allocations": 36, + "residue_slots_at_exit": 13, + "residue_words": { + "moves": 104694, + "reads": 121538, + "writes": 4035 + }, + "returned_prefix_count": 512, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 1360, + "reads": 1305, + "writes": 242 + } + } + }, + { + "config": { + "B": 2, + "I": 4, + "Q": 4, + "d": 1, + "h": 2, + "name": "radix5_history2", + "q": 5, + "w": 2 + }, + "original": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 108, + "reads": 131, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": false, + "config": { + "B": 2, + "I": 4, + "Q": 4, + "d": 1, + "h": 2, + "name": "radix5_history2", + "q": 5, + "w": 2 + }, + "created_record_tapes": 9, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 13, + "H": 5, + "L": 6, + "M": 1, + "cap": 5, + "modulus": 25, + "old_body": 52, + "output_body": 390 + }, + "index_words": { + "moves": 24, + "reads": 30, + "writes": 0 + }, + "input_sha256": "2a9d092c2f94c31c0edc3ad95aa56eb27edce4b37470d5c54f2caeda9053cd0e", + "new_residue_slots": 1, + "odometer_advances": 10, + "odometer_increment_visits": 10, + "ordered_expected_q_multipliers": 1, + "output_head": 1, + "output_sha256": "bb40ed50fcf2af2eb097090dd3df3f63df60ea1d8e2c8d0a3448b99bf69bf5d0", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 36, + "reads": 39, + "writes": 8 + }, + "head": 1, + "role": "expected", + "visited_cells": 6 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 104, + "reads": 107, + "writes": 32 + }, + "head": 1, + "role": "emitted", + "visited_cells": 7 + }, + { + "actions": { + "moves": 32, + "reads": 27, + "writes": 13 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 782, + "reads": 781, + "writes": 390 + }, + "head": 1, + "role": "output", + "visited_cells": 392 + }, + { + "actions": { + "moves": 390, + "reads": 513, + "writes": 52 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 28 + }, + { + "actions": { + "moves": 40, + "reads": 31, + "writes": 19 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + }, + { + "actions": { + "moves": 390, + "reads": 513, + "writes": 52 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 28 + }, + { + "actions": { + "moves": 40, + "reads": 31, + "writes": 19 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + } + ], + "record_tapes": { + "moves": 1958, + "reads": 2209, + "writes": 589 + }, + "residue_allocations": 29, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 3506, + "reads": 3592, + "writes": 581 + }, + "returned_prefix_count": 10, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 2358, + "reads": 2322, + "writes": 445 + } + }, + "saved_residue_actions": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "shared_radix": { + "additional_residue_peak": 6, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 108, + "reads": 131, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 16, + "reads": 18, + "writes": 0 + }, + "candidate_shared_radix": true, + "config": { + "B": 2, + "I": 4, + "Q": 4, + "d": 1, + "h": 2, + "name": "radix5_history2", + "q": 5, + "w": 2 + }, + "created_record_tapes": 9, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 13, + "H": 5, + "L": 6, + "M": 1, + "cap": 5, + "modulus": 25, + "old_body": 52, + "output_body": 390 + }, + "index_words": { + "moves": 24, + "reads": 30, + "writes": 0 + }, + "input_sha256": "2a9d092c2f94c31c0edc3ad95aa56eb27edce4b37470d5c54f2caeda9053cd0e", + "new_residue_slots": 1, + "odometer_advances": 10, + "odometer_increment_visits": 10, + "ordered_expected_q_multipliers": 1, + "output_head": 1, + "output_sha256": "bb40ed50fcf2af2eb097090dd3df3f63df60ea1d8e2c8d0a3448b99bf69bf5d0", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 2, + "record_roles": [ + { + "actions": { + "moves": 36, + "reads": 39, + "writes": 8 + }, + "head": 1, + "role": "expected", + "visited_cells": 6 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 104, + "reads": 107, + "writes": 32 + }, + "head": 1, + "role": "emitted", + "visited_cells": 7 + }, + { + "actions": { + "moves": 32, + "reads": 27, + "writes": 13 + }, + "head": 1, + "role": "outer", + "visited_cells": 5 + }, + { + "actions": { + "moves": 782, + "reads": 781, + "writes": 390 + }, + "head": 1, + "role": "output", + "visited_cells": 392 + }, + { + "actions": { + "moves": 390, + "reads": 513, + "writes": 52 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 28 + }, + { + "actions": { + "moves": 40, + "reads": 31, + "writes": 19 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + }, + { + "actions": { + "moves": 390, + "reads": 513, + "writes": 52 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 28 + }, + { + "actions": { + "moves": 40, + "reads": 31, + "writes": 19 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + } + ], + "record_tapes": { + "moves": 1958, + "reads": 2209, + "writes": 589 + }, + "residue_allocations": 29, + "residue_slots_at_exit": 10, + "residue_words": { + "moves": 3506, + "reads": 3592, + "writes": 581 + }, + "returned_prefix_count": 10, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 2358, + "reads": 2322, + "writes": 445 + } + } + }, + { + "config": { + "B": 1, + "I": 4, + "Q": 6507, + "d": 64, + "h": 1, + "name": "dimension64_cap1", + "q": 3, + "w": 1 + }, + "original": { + "additional_residue_peak": 4096, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 45790, + "reads": 58077, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 12, + "reads": 12, + "writes": 0 + }, + "candidate_shared_radix": false, + "config": { + "B": 1, + "I": 4, + "Q": 6507, + "d": 64, + "h": 1, + "name": "dimension64_cap1", + "q": 3, + "w": 1 + }, + "created_record_tapes": 7, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 22893, + "H": 1, + "L": 3, + "M": 4096, + "cap": 1, + "modulus": 3, + "old_body": 22893, + "output_body": 45786 + }, + "index_words": { + "moves": 12, + "reads": 15, + "writes": 0 + }, + "input_sha256": "e8dcc334cf877fcc2c93a726fef6487f8c61f54ffd6f4599b5dc774e98c46bb3", + "new_residue_slots": 4091, + "odometer_advances": 1, + "odometer_increment_visits": 4096, + "ordered_expected_q_multipliers": 0, + "output_head": 1, + "output_sha256": "f5dddd5430496c234f2377992c876eaca628706e4cbc9b14baa3403288997177", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 4096, + "radix_yields_each": 1, + "record_roles": [ + { + "actions": { + "moves": 16, + "reads": 16, + "writes": 2 + }, + "head": 1, + "role": "expected", + "visited_cells": 4 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 34, + "reads": 31, + "writes": 9 + }, + "head": 1, + "role": "emitted", + "visited_cells": 4 + }, + { + "actions": { + "moves": 22, + "reads": 18, + "writes": 8 + }, + "head": 1, + "role": "outer", + "visited_cells": 4 + }, + { + "actions": { + "moves": 91574, + "reads": 91573, + "writes": 45786 + }, + "head": 1, + "role": "output", + "visited_cells": 45788 + }, + { + "actions": { + "moves": 137368, + "reads": 160258, + "writes": 45786 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 22895 + }, + { + "actions": { + "moves": 34, + "reads": 24, + "writes": 17 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + } + ], + "record_tapes": { + "moves": 274870, + "reads": 310027, + "writes": 91612 + }, + "residue_allocations": 45056, + "residue_slots_at_exit": 4100, + "residue_words": { + "moves": 2916352, + "reads": 2793472, + "writes": 483328 + }, + "returned_prefix_count": 1, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 556, + "reads": 523, + "writes": 95 + } + }, + "saved_residue_actions": { + "moves": 2276820, + "reads": 2141685, + "writes": 389025 + }, + "shared_radix": { + "additional_residue_peak": 4096, + "all_borrowed_bytes_heads_preserved": true, + "all_scratch_cleared": true, + "borrowed_old_actions": { + "moves": 45790, + "reads": 58077, + "writes": 0 + }, + "borrowed_old_count_actions": { + "moves": 12, + "reads": 12, + "writes": 0 + }, + "candidate_shared_radix": true, + "config": { + "B": 1, + "I": 4, + "Q": 6507, + "d": 64, + "h": 1, + "name": "dimension64_cap1", + "q": 3, + "w": 1 + }, + "created_record_tapes": 7, + "expected_head": 1, + "full_source_stock_admitted": false, + "geometry": { + "F": 22893, + "H": 1, + "L": 3, + "M": 4096, + "cap": 1, + "modulus": 3, + "old_body": 22893, + "output_body": 45786 + }, + "index_words": { + "moves": 12, + "reads": 15, + "writes": 0 + }, + "input_sha256": "e8dcc334cf877fcc2c93a726fef6487f8c61f54ffd6f4599b5dc774e98c46bb3", + "new_residue_slots": 4091, + "odometer_advances": 1, + "odometer_increment_visits": 4096, + "ordered_expected_q_multipliers": 0, + "output_head": 1, + "output_sha256": "f5dddd5430496c234f2377992c876eaca628706e4cbc9b14baa3403288997177", + "protected_residue_words": 4, + "radix_complete_each": true, + "radix_traversals": 1, + "radix_yields_each": 1, + "record_roles": [ + { + "actions": { + "moves": 16, + "reads": 16, + "writes": 2 + }, + "head": 1, + "role": "expected", + "visited_cells": 4 + }, + { + "actions": { + "moves": 20, + "reads": 18, + "writes": 4 + }, + "head": 1, + "role": "emitted_literal_temporary", + "visited_cells": 4 + }, + { + "actions": { + "moves": 34, + "reads": 31, + "writes": 9 + }, + "head": 1, + "role": "emitted", + "visited_cells": 4 + }, + { + "actions": { + "moves": 22, + "reads": 18, + "writes": 8 + }, + "head": 1, + "role": "outer", + "visited_cells": 4 + }, + { + "actions": { + "moves": 91574, + "reads": 91573, + "writes": 45786 + }, + "head": 1, + "role": "output", + "visited_cells": 45788 + }, + { + "actions": { + "moves": 137368, + "reads": 160258, + "writes": 45786 + }, + "head": 1, + "role": "saved_prefix", + "visited_cells": 22895 + }, + { + "actions": { + "moves": 34, + "reads": 24, + "writes": 17 + }, + "head": 1, + "role": "history_counter", + "visited_cells": 7 + } + ], + "record_tapes": { + "moves": 274870, + "reads": 310027, + "writes": 91612 + }, + "residue_allocations": 8201, + "residue_slots_at_exit": 4100, + "residue_words": { + "moves": 639532, + "reads": 651787, + "writes": 94303 + }, + "returned_prefix_count": 1, + "runtime_word_decoding_used": false, + "single_radix_residue_actions": { + "moves": 556, + "reads": 523, + "writes": 95 + } + } + } + ], + "schema_version": 1, + "scope": "produce with an already valid protected Context; no shared-source adoption or full Pi/stock admission" +} diff --git a/research/directory-producer-invoice/SOURCES.json b/research/directory-producer-invoice/SOURCES.json new file mode 100644 index 0000000000..7e090c39ce --- /dev/null +++ b/research/directory-producer-invoice/SOURCES.json @@ -0,0 +1,121 @@ +{ + "schema_version": 1, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + } + ], + "source_exports": [ + { + "path": "research/directory-producer-invoice/source/cardinality.py", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/cardinality.py", + "git_blob": "b8ba857e32c5903408e1e61ff916300848b4a208", + "sha256": "505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22", + "bytes": 3936, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + }, + { + "path": "research/directory-producer-invoice/source/counts.py", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/counts.py", + "git_blob": "81b48940ce222290a40d4fb349ce827f4788469d", + "sha256": "00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069", + "bytes": 1695, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + }, + { + "path": "research/directory-producer-invoice/source/directory.py", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py", + "git_blob": "c74cacf5ce809c0561d374f137a52df0992b4226", + "sha256": "4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7", + "bytes": 4633, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + }, + { + "path": "research/directory-producer-invoice/source/records.py", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py", + "git_blob": "4f00467a0ff580954ad2fd0c7380240c753ddef3", + "sha256": "0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372", + "bytes": 9888, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + }, + { + "path": "research/directory-producer-invoice/source/stream.py", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream.py", + "git_blob": "5e5a4bb0f98971447043e25d4dd6991bfc070389", + "sha256": "c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5", + "bytes": 5523, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + }, + { + "path": "research/directory-producer-invoice/source/words.py", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/words.py", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9", + "bytes": 13794, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + }, + { + "path": "research/directory-producer-invoice/source/CALLER.py", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/macro_machine.py", + "git_blob": "5a032e8923f7f8b22bb98f3e39b804beb9906c16", + "sha256": "7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a", + "bytes": 21501, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + }, + { + "path": "research/directory-producer-invoice/source/NOTICE.md", + "origin_repository": "CrocSwap/integer-mult-bounds", + "origin_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "origin_path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/NOTICE.md", + "git_blob": "ef9f81510db86eaf2f0a7191d85e92a6db30ddc0", + "sha256": "c446b32b8a621844fb2fbe654810c8122035bdd43fed2132f1137d98cb6f9943", + "bytes": 2849, + "usage": "Byte-exact retained canonical source. Six runtime modules are executed; CALLER.py and NOTICE.md bind actual caller/credit without importing the full caller." + } + ], + "source_export_contract": "All scientific runtime bytes are package-local; the primary authenticates SHA256 and Git blobs before execution. The independent mathematical model imports neither predecessor runtime nor primary checker. Canonical provenance does not establish complete selected theorem acceptance.", + "predecessor_results": [ + { + "package": "research/source-directory-setup-cost", + "pr": 2590, + "credit": "ywz65: repeated exponent reconstruction, cubic setup correction, complete Theta_q(D), output extent and explicit shared-traversal open question." + }, + { + "package": "research/selected-directory-storage-reserve", + "credit": "ywz65: serialized numerical directory-only reserve under its explicit premises." + }, + { + "package": "research/selected-stream-directory-numerical-audit", + "credit": "Ross Richardson: exact max(d\u00b2,6) successful directory numerical peak and failure boundary." + }, + { + "pr": 4011, + "head": "fc1426353de3389409a27e5b9bc146a95edf811c", + "credit": "Chris R/Clear1nsight: linear child-program admission cursor bill; adjacent producer/context gaps." + } + ] +} diff --git a/research/directory-producer-invoice/TASK.json b/research/directory-producer-invoice/TASK.json new file mode 100644 index 0000000000..657254be26 --- /dev/null +++ b/research/directory-producer-invoice/TASK.json @@ -0,0 +1,122 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 6, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "original_card": { + "id": "selected-stock-envelope", + "question": "What explicit uniform stock envelope does the actual selected stopped producer supply at one bootstrap stage?", + "starting_points": [ + "research/selected-bootstrap-stock-audit/README.md", + "research/bootstrap-cutoff-time-space-split/README.md", + "certificates/selected-result.json", + "docs/research/community-efficient1000-review.md", + "research/stock-margin-chain/README.md" + ], + "methods": [ + "Derive a source-bound reserve recurrence at the actual selected atom widths, separating parent stock from completed inner borrowing.", + "Find an exact missing implication or counterexample to a proposed selected-stage stock envelope." + ], + "acceptance_gate": "Bind every coefficient and depth factor to the selected producer and state the width domain. Compare a proved envelope with the sufficient cutoff guard; a large numerical headroom or a historical m=120 coefficient is not a selected m=73 proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #2972 stock-margin chain and the selected stock audit. The new source archive reports the remaining cutoff comparisons, but leaves every actual stock coefficient unresolved; it is not an independently validated reserve envelope.", + "scope": "Source-bound orientation only. Read the named package and review before relying on its local evidence; this command is not its replay or supplier admission." + }, + "first_experiment": "Choose one actual selected producer/stage and derive its parent reserve and depth coefficient from source. Check whether newer handoffs already cover that exact obligation. Stop with the missing implementation lemma if it cannot be bounded; do not rerun #2972 cutoff/headroom arithmetic as a new contribution.", + "bottleneck_link": "This reduces a concrete inherited implementation obligation without confusing unchanged kappa arithmetic with a completed theorem.", + "allowed_variations": [ + "One stage or one explicit reserve/depth implication.", + "An independently checked same-domain proof repair, retaining all remaining assumptions." + ], + "scope_change_triggers": [ + "Importing the historical 57604 or 252 allowance without a selected-producer binding.", + "Calling a conditional fit lemma a full outer-proof adoption.", + "Replacing an actual selected stock coefficient with cutoff comparisons or a conditional fit inequality." + ], + "overlap_terms": [ + "selected stock", + "stock envelope", + "bootstrap cutoff", + "1956", + "1965", + "1990", + "2972", + "stock-margin-chain", + "actual_stock_coefficient" + ], + "existing_checks": [ + { + "scope": "Retained stock audit identifies missing actual selected-stage coefficients; later cutoff-chain arithmetic does not supply them.", + "evidence": "docs/research/research-family-status.md#revision-6-handoffs-source-archives-awaiting-independent-validation", + "remaining": "Derive one actual reserve/depth coefficient from the selected producer.", + "status": "reviewed", + "source_commit": "836b19bfa309ceafbc8ee32a15e8c4b10dde7e11", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Share one encoded radix traversal in directory.high_power, preserving the successful complete produce contract and deriving exact source Tape/Word action savings.", + "scope_change_reason": "Handoff-first inspection of PR4011 names directory generation. Retained PR2590 already proves its asymptotic bill and explicitly asks for shared exponent traversal; retained numerical/storage audits already cover peak and directory size. Narrow to this concrete package-local optimization rather than repeat those results. The named card baseline command was attempted but sparse omission of selected-package ASSEMBLY blocks its inventory check; no full historical replay is claimed.", + "bottleneck_link": "Removes repeated actual producer setup work with an exact complete component bill. This does not produce the selected complex m73 stock coefficient or complete physical Pi; those remain open.", + "budget_minutes": 60, + "stop_rule": "Freeze one shared-traversal adapter and exact unchanged-producer comparison. Stop on changed output/head/ownership, counter invoice disagreement or covered scope. No unrelated source/compiler expansion. Science cutoff2026-10-19T10:14:56Z; final15minutes reserved for verification/handoff.", + "outcome": "partial", + "evidence": "Written arbitrary-valid-input proof, exact independent action formulas, authenticated actual original/candidate producer fixtures, semantic/integrity controls and bounded replay.", + "author": "ToikY", + "ai_assistance": "Substantial OpenAI Codex assistance in implementation, proof, testing and separate AI review contexts; no independent human or formal-kernel acceptance.", + "open_questions": [ + { + "question": "Can the shared traversal be admitted into the complete selected caller with its physical controller tariff?", + "why_it_matters": "This removes measured source Word actions but leaves controller/allocator and other Pi phases unpriced.", + "first_step": "Review this exact success contract, then bind the replacement to the actual caller and charge its fixed control, context, geometry, child_extents/read_prefix and coefficient phases.", + "blocked_by": "No complete physical finite-state lowering or full selected caller ledger is supplied." + }, + { + "question": "What reserve covers all simultaneously live caller categories?", + "why_it_matters": "The credited max(d\u00b2,6) occupied numerical peak is not a backing/slot/role or root-payload reserve.", + "first_step": "Join existing component ledgers under one entry baseline and original word widths, retaining parent/child directories, Count tapes, erased backing, templates and dirty restoration.", + "blocked_by": "Complete lifetimes, source/low-code admission, recursive hosting and selected m73 stock coefficients remain outside scope." + } + ], + "selection": { + "method": "handoff-first, named selected-stock-envelope card retained as changed provenance; no reroll", + "canonical_main": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "priority_revision": 6, + "entry_open_pr_bodies_including_drafts": 724, + "entry_checked_at_utc": "2026-10-19T09:31:03Z", + "pagination": "seven100-record pages plus24-recordpage8 and empty9;724unique", + "claim": "https://github.com/CrocSwap/integer-mult-bounds/pull/4011#issuecomment-6264214824", + "scope_update": "https://github.com/CrocSwap/integer-mult-bounds/pull/4011#issuecomment-6264315659", + "pre_pivot": { + "canonical_main": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "checked_at_utc": "2026-10-19T09:42:00Z", + "latest100_open_pr_bodies_through": 4022, + "retained_evidence": [ + "research/source-directory-setup-cost/README.md", + "research/source-directory-setup-cost/PROOF.md", + "research/selected-directory-storage-reserve/README.md", + "research/selected-stream-directory-numerical-audit/README.md" + ], + "decision": "Close PR2590 explicit shared-traversal question; do not rebrand prior asymptotic, serialization, multiplicity or max(d\u00b2,6) results as new." + }, + "coverage_limit": "All open PR bodies including drafts at entry, latest100-body delta, repository helper, targeted retained packages and bounded live1166/start-here/active-board/source thread. Broader Discussions, arbitrary code and closed work coverage partial; absence of a match is not a novelty certificate.", + "pre_submission": { + "checked_at_utc": "2026-10-19T09:50:03.250917+00:00", + "canonical_main": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "source4011_head": "fc1426353de3389409a27e5b9bc146a95edf811c", + "latest100_open_pr_bodies_through": 4023, + "hashes": { + "docs/research/agent-task-catalog.json": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0", + "certificates/selected-result.json": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + "decision": "Main/priority/selected and source4011 unchanged. No matching shared-radix result in latest100delta; frozen inputs preserved. Broader coverage remains partial." + } + } +} diff --git a/research/directory-producer-invoice/VERIFY.json b/research/directory-producer-invoice/VERIFY.json new file mode 100644 index 0000000000..0b2ef325a4 --- /dev/null +++ b/research/directory-producer-invoice/VERIFY.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Authenticate all retained sources; compare original/candidate complete producer bytes, order, heads, ownership and exact measured lane invoices; typed receipt." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 120, + "checks": "No-import exact cost model and shared-traversal identity, independent odometer/count ripple controls." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 120, + "checks": "Meaningful production API and source/receipt/candidate semantic controls, effective under optimized Python." + } + ] +} diff --git a/research/directory-producer-invoice/independent.py b/research/directory-producer-invoice/independent.py new file mode 100644 index 0000000000..ddea4629cf --- /dev/null +++ b/research/directory-producer-invoice/independent.py @@ -0,0 +1,404 @@ +#!/usr/bin/env python3 +"""Closed action-count certificate; no predecessor/primary executable imports. + +Costs are (reads,writes,unit_moves), derived from the exact methods in the +frozen source. This is an external mathematical oracle, not runtime control. +Apache-2.0. ToikY with substantial OpenAI Codex assistance. +""" +import argparse +import hashlib +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +PINS = { + 'cardinality.py': '505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22', + 'counts.py': '00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069', + 'directory.py': '4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7', + 'records.py': '0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372', + 'stream.py': 'c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5', + 'words.py': '5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9', +} + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def add(*values): + return tuple(sum(x[i] for x in values) for i in range(3)) + + +def mul(n, value): + return tuple(n * x for x in value) + + +def pop(n): + return bin(n).count('1') + + +def record(cost): + return dict(zip(('reads', 'writes', 'moves'), cost)) + + +def unique(pairs): + value = {} + for key, item in pairs: + need(key not in value, 'duplicate JSON key') + value[key] = item + return value + + +def rewind(head): + return head, 0, head + 1 + + +def clear(symbols): + """A valid Tape at head1; backing capacity is not silently shrunk.""" + return 2 * symbols + 3, symbols, 2 * symbols + 4 + + +def word_zero(L): + return 4 * L + 5, L + 1, 4 * L + 6 + + +def word_free(L): + return 2 * L + 3, L + 1, 2 * L + 4 + + +def word_literal(L, n): + k = n.bit_length() + need(k <= L, 'literal extent') + return add(word_zero(L), (2 * k + 1, k, 2 * k + 2)) + + +def word_copy(L): + return add(word_zero(L), (4 * L + 4, L, 4 * L + 6)) + + +def word_zero_test(L): + return 2 * L + 3, 0, 2 * L + 4 + + +def word_msb(L): + return L + 2, 0, L + 3 + + +def compare(L): + return 5 * L + 6, 0, 4 * L + 8 + + +def shift(L): + return add(word_zero(L), (4 * L + 4, L, 4 * L + 6)) + + +def subtract(L): + return add(word_zero(L), (6 * L + 7, L, 6 * L + 10)) + + +def divide(L, numerator, denominator): + """Exact Unsigned.divmod cost; quotient 1-bits select subtraction paths.""" + need(0 < denominator < 1 << (L - 1), 'divisor high-bit margin') + quotient = numerator // denominator + return add( + word_zero_test(L), word_msb(L), (1, 0, 0), rewind(L), + word_copy(L), mul(2, word_zero(L)), mul(2, word_msb(L)), + (2 * L + 1, 0, 0), + mul(L, add(shift(L), word_free(L), compare(L), (0, 1, 2))), + mul(pop(quotient), add(subtract(L), word_free(L))), + (0, 0, 2), word_free(L)) + + +def radix_word_cost(q, modulus, L): + """One full radix_power traversal, including validation and final frees.""" + need(q >= 2 and modulus > 1, 'radix domain') + value, exponent = modulus, 0 + cost = add(word_literal(L, q), word_copy(L)) + while value > 1: + quotient, remainder = divmod(value, q) + need(remainder == 0 and quotient > 0, 'source prime-power validation') + cost = add(cost, compare(L), divide(L, value, q), + mul(2, word_zero_test(L)), mul(2, word_free(L))) + value, exponent = quotient, exponent + 1 + cost = add(cost, mul(2, compare(L)), mul(2, word_free(L))) + return cost, exponent + + +def countdown(n): + """All Counter.decrement calls from n through0; construction/close separate.""" + if n == 0: + return 0, 0, 0 + trailing_sum, extensions = n - pop(n), n.bit_length() - 1 + return (2 * trailing_sum + 5 * n + 1, + trailing_sum + n + 2 * extensions + 3, + 2 * trailing_sum + 4 * n + 2 * extensions + 4) + + +def counter_constructor(width, value): + """Return own Tape cost and separate source Tape/Word cost.""" + need(0 <= value < 1 << width, 'counter input extent') + k = value.bit_length() + if value: + own = (2 * width + 3, width + 1 + 2 * (width - k), + 4 * width - 2 * k + 4) + else: + own = 2 * width + 5, 3 * width + 3, 4 * width + 8 + source = 3 * width + 3, 0, 2 * width + 4 + return own, source + + +def count_increments(n): + """All Count.increment calls from0 ton, including new RIGHT delimiters.""" + if n == 0: + return 0, 0, 0 + trailing_sum, extensions = n - pop(n), n.bit_length() - 1 + return (2 * trailing_sum + 5 * n, + trailing_sum + n + extensions, + 2 * trailing_sum + 4 * n + 2 * extensions) + + +def count_multiply_chain(value, q, repetitions): + cost = (0, 0, 0) + for _ in range(repetitions): + old_width = value.bit_length() + value *= q + new_width = value.bit_length() + cost = add(cost, (2 * old_width + new_width + 2, + new_width + 1, 2 * new_width + 2)) + return value, cost + + +def invoice(*, d, q, modulus, L, I, Q, h, B, shared=False): + """Exact successful-produce counts from a valid already-live Context. + + L: residue Word width; I: old_fields Word width; Q: finite code bit width; + h: fields/old prefix; B: physical old-prefix count. All entry heads are1. + """ + need(all(type(x) is int for x in (d, q, modulus, L, I, Q, h, B)), 'typed parameters') + need(type(shared) is bool, 'typed shared-traversal flag') + need(d > 0 and L >= 2 and I >= 2 and Q > 0 and B > 0 and h >= 0, 'parameter domain') + need(h < 1 << I and modulus < 1 << (L - 1), 'declared word margins') + need(L == modulus.bit_length() + 1, 'canonical source Ring word width') + radix_cost, w = radix_word_cost(q, modulus, L) + M, c = d * d, modulus // q + H, F = c ** M, Q + 2 + d * d * (L + 1) + new_count = B * H + n, old_symbols, output_symbols = h * F, B * h * F, B * H * (h + 1) * F + increments = M if c == 1 else c * (H - 1) // (c - 1) + carries = M if c == 1 else (H - 1) // (c - 1) + trailing_sum = carries * (c - pop(c)) + + # Numerical words: high_power; one-at-a-time decoded old words; odometer. + decoded_word = (16 * L + 19, 3 * L + 2, 14 * L + 24) + digit_increment = (4 * increments + 2 * trailing_sum, + increments + trailing_sum, + 4 * increments + 2 * trailing_sum) + odometer = add(digit_increment, mul(increments + carries, compare(L)), + mul(carries, (2 * L + 2, L, 2 * L + 2))) + residue_parts = { + 'high_power_validation': mul(1 if shared else M, radix_cost), + 'old_decode_validate_save': mul(B * h * M, decoded_word), + 'odometer_allocate_erase': mul(B * M, add(word_zero(L), word_free(L))), + 'new_digit_serialization': mul(B * H * M, (3 * L + 3, 0, 2 * L + 4)), + 'odometer_advance': mul(B, odometer), + } + + # Record Tape traffic: input, one saved prefix at a time, append-only output. + tape_parts = { + 'old_input': (2 * old_symbols + B * h * M * L + 3, 0, 2 * old_symbols + 4), + 'saved_prefixes': mul(B, (4 * n + 4 + H * (3 * n + 3), 2 * n, + 4 * n + 6 + H * (2 * n + 4))), + 'output': (2 * output_symbols + 1, output_symbols, 2 * output_symbols + 2), + } + kB = B.bit_length() + outer_own, outer_source = counter_constructor(kB, B) + field_own, field_source = counter_constructor(I, h) + # Count(old_count): source read and new positive Count normalization. + expected_init = add((4 * kB + 6, kB + 1, 4 * kB + 6), outer_source) + multiplied, multiply_cost = count_multiply_chain(B, q, M * (w - 1)) + need(multiplied == new_count, 'source high_power value') + emitted_literal_zero = (30, 10, 36) + kN = new_count.bit_length() + equal = 6 * kN + 7, 0, 4 * kN + 8 + tape_parts['expected_count'] = add(expected_init, multiply_cost, equal) + tape_parts['emitted_count'] = add(emitted_literal_zero, count_increments(new_count), clear(kN + 1)) + tape_parts['outer_counter'] = add(outer_own, outer_source, countdown(B), clear(2)) + tape_parts['field_counters'] = mul(B, add(field_own, countdown(h), clear(2))) + return { + 'parameters': {'d': d, 'q': q, 'modulus': modulus, 'L': L, 'I': I, 'Q': Q, 'h': h, 'B': B}, + 'geometry': {'M': M, 'c': c, 'H': H, 'F': F, 'new_count': new_count, + 'old_symbols': old_symbols, 'output_symbols': output_symbols, + 'digit_increments_per_prefix': increments, 'digit_carries_per_prefix': carries, + 'digit_trailing_ones_sum_per_prefix': trailing_sum}, + 'record_tapes': record(add(*tape_parts.values())), + 'residue_words': record(add(*residue_parts.values())), + 'index_words': record(mul(B, field_source)), + 'record_parts': {k: record(v) for k, v in tape_parts.items()}, + 'residue_parts': {k: record(v) for k, v in residue_parts.items()}, + 'additional_residue_peak': max(M, 6), + 'shared_radix': shared, + 'radix_word_cost': record(radix_cost), + 'saved_residue_actions': record(mul(M - 1, radix_cost)), + 'heads': {'old': 1, 'output': 1, 'expected_count': 1, 'old_count': 1, 'old_fields': 1}, + } + + +def small_odometer(M, c): + """Independent integer-state enumeration for bounded corroboration only.""" + need(M <= 9 and c ** M <= 10000, 'bounded odometer control') + state, visited = [0] * M, [] + increments = carries = trailing = 0 + while True: + visited.append(tuple(state)) + for j in range(M - 1, -1, -1): + old = state[j] + while old & 1: + trailing += 1 + old >>= 1 + state[j] += 1 + increments += 1 + if state[j] < c: + break + need(state[j] == c, 'integer carry') + state[j] = 0 + carries += 1 + else: + break + return visited, increments, carries, trailing + + +def controls(): + for M in (1, 4, 9): + for c in (1, 2, 3): + if c ** M > 10000: + continue + visited, increments, carries, trailing = small_odometer(M, c) + H = c ** M + expected_carries = M if c == 1 else (H - 1) // (c - 1) + need(len(visited) == len(set(visited)) == H, 'all high fields exactly once') + need(increments == c * expected_carries and carries == expected_carries, 'carry sums') + need(trailing == expected_carries * (c - pop(c)), 'ripple sum') + need(visited[0] == (0,) * M and visited[-1] == (c - 1,) * M, 'lexical endpoints') + need(countdown(1) == (6, 4, 8), 'final Counter zero representation') + need(count_increments(1) == (5, 1, 4), 'first emitted increment') + need(count_increments(2) == (12, 4, 12), 'emitted delimiter extension') + # PR2590 owns the earlier exact write law; all three new closed lanes agree. + for L in range(3, 8): + for numerator in (1, (1 << (L - 1)) - 1): + for denominator in (1, 2, 3): + if denominator >= 1 << (L - 1): + continue + s = pop(numerator // denominator) + closed = (15 * L * L + 44 * L + 33 + (12 * L + 15) * s, + 3 * L * L + 8 * L + 4 + (3 * L + 2) * s, + 14 * L * L + 50 * L + 44 + (12 * L + 20) * s) + need(divide(L, numerator, denominator) == closed, 'complete closed division invoice') + return 'PASS_BOUNDED_ODOMETER_AND_COUNT_CONTROLS' + + +def fixture_bytes(parameters): + """Independent direct base-c oracle for the bounded fixtures, not runtime.""" + d, L, Q, c, B, h = (parameters[k] for k in ('d', 'L', 'Q', 'c', 'B', 'h')) + M, H = d * d, c ** (d * d) + need(H <= 10000, 'bounded byte oracle; no nontrivial dimension64 high cube') + def field(code, digits): + value = bytearray((code >> i) & 1 for i in range(Q)) + value.append(5) + for digit in digits: + value.extend((digit >> i) & 1 for i in range(L)) + value.append(5) + value.append(6) + return value + old, output = bytearray([2]), bytearray([2]) + for outer in range(B): + prefix = bytearray() + for level in range(h): + prefix.extend(field((outer + level) % (1 << Q), + ((outer + level + j) % c for j in range(M)))) + old.extend(prefix) + for rank in range(H): + number, digits = rank, [0] * M + for j in range(M - 1, -1, -1): + number, digits[j] = divmod(number, c) + need(number == 0, 'complete base-c address') + output.extend(prefix) + output.extend(field(min(3, (1 << Q) - 1), digits)) + return hashlib.sha256(old).hexdigest(), hashlib.sha256(output).hexdigest() + + +def measured_audit(root): + for name, digest in PINS.items(): + path = root / 'source' / name + need(not path.is_symlink() and hashlib.sha256(path.read_bytes()).hexdigest() == digest, + 'frozen source bytes: ' + name) + data = json.loads((root / 'RESULT.json').read_bytes(), object_pairs_hook=unique) + need(isinstance(data, dict) and set(data) == {'schema_version', 'cases', 'scope'}, 'receipt root') + need(type(data['schema_version']) is int and data['schema_version'] == 1, 'typed schema version') + need(isinstance(data['cases'], list) and data['cases'], 'nonempty measured cases') + for case in data['cases']: + need(set(case) == {'config', 'original', 'shared_radix', 'saved_residue_actions'}, 'paired case schema') + config = case['config'] + need(set(config) == {'name', 'd', 'q', 'w', 'B', 'h', 'Q', 'I'}, 'parameter schema') + need(all(type(config[k]) is int for k in config if k != 'name'), 'typed fixture parameters') + need(config['w'] >= 1 and isinstance(config['name'], str), 'fixture exponent and name') + parameters = {k: config[k] for k in ('d', 'q', 'B', 'h', 'Q', 'I')} + parameters['modulus'] = config['q'] ** config['w'] + parameters['L'] = parameters['modulus'].bit_length() + 1 + formula = invoice(**parameters) + geometry = formula['geometry'] + expected_geometry = {'M': geometry['M'], 'modulus': parameters['modulus'], + 'cap': geometry['c'], 'H': geometry['H'], 'L': parameters['L'], + 'F': geometry['F'], 'old_body': geometry['old_symbols'], + 'output_body': geometry['output_symbols']} + input_hash, output_hash = fixture_bytes(dict(parameters, c=geometry['c'])) + for label, shared in (('original', False), ('shared_radix', True)): + measured = case[label] + model = invoice(**parameters, shared=shared) + need(measured['config'] == config and measured['candidate_shared_radix'] is shared, + 'exact paired mode and parameters') + for lane in ('record_tapes', 'residue_words', 'index_words'): + actual = measured[lane] + need(isinstance(actual, dict) and set(actual) == {'reads', 'writes', 'moves'} + and all(type(value) is int for value in actual.values()), 'typed action lane') + need(model[lane] == actual, 'complete measured action lane: ' + label + ':' + lane) + need(all(type(value) is int for value in measured['geometry'].values()) and + expected_geometry == measured['geometry'], 'complete geometry') + need(model['additional_residue_peak'] == measured['additional_residue_peak'], 'numeric peak') + need(measured['created_record_tapes'] == 5 + 2 * parameters['B'], 'all created record tapes') + need(measured['odometer_advances'] == geometry['new_count'] and + measured['odometer_increment_visits'] == parameters['B'] * geometry['digit_increments_per_prefix'], + 'complete odometer visits') + need(measured['input_sha256'] == input_hash and measured['output_sha256'] == output_hash, + 'complete independently serialized bytes') + need(measured['returned_prefix_count'] == geometry['new_count'] and + measured['output_head'] == measured['expected_head'] == 1, 'returned count and heads') + need(measured['all_borrowed_bytes_heads_preserved'] is True and + measured['all_scratch_cleared'] is True and + measured['runtime_word_decoding_used'] is False and + measured['full_source_stock_admitted'] is False, 'preservation/scope flags') + need(case['saved_residue_actions'] == formula['saved_residue_actions'], 'exact saved actions') + return len(data['cases']) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--root', type=Path, default=HERE) + parser.add_argument('--parameters', type=str, help='explicit JSON parameters for formula inspection') + args = parser.parse_args() + controls() + if args.parameters: + print(json.dumps(invoice(**json.loads(args.parameters)), sort_keys=True)) + else: + count = measured_audit(args.root) + print('PASS_INDEPENDENT_DIRECTORY_PRODUCER fixtures=' + str(count) + + ' paired_exact_actions_and_bytes no_full_stock_admission') + + +if __name__ == '__main__': + try: + main() + except Exception as error: + import sys + print('FAIL_INDEPENDENT_DIRECTORY_PRODUCER ' + str(error), file=sys.stderr) + raise SystemExit(1) diff --git a/research/directory-producer-invoice/source/CALLER.py b/research/directory-producer-invoice/source/CALLER.py new file mode 100644 index 0000000000..5a032e8923 --- /dev/null +++ b/research/directory-producer-invoice/source/CALLER.py @@ -0,0 +1,453 @@ +"""One active frame, fixed stream roles and an encoded parent continuation.""" +from contextlib import contextmanager + +import loader +codec = loader.activate() +from cardinal_counts import Count, positive +from cardinality import multiply_atom_power +from directory import Context, append_tape, produce +from driver import xor_family +from episode import xor_packet +import fresh_rows +from layout import Layout +from macro_binding import view +from numeric import Geometry +from packet import read_prefix +import packet_engine +import peel +from plan import Request +from records import Program, Tape +from recursive_call import copy_word +from residual_blocks import events as block_events +from role_parking import FiniteFields, RoleParking, transfer +from routes import copy_rows, route_packet +from scratch_pool import Lease, ScratchPool +from selection import gather, scatter +from stream import Counter +from trace import child +from words import BLANK, LEFT, Ring, Unsigned, need + + +NAMES = ("source", "peeled", "old_directory", "program", "old_count", "rows", + "before", "gap", "suffix", "unused", "leading", "fibre", "highs", + "family_rows", "directory", "prefixes", "current", "copy_source", "idle", "swap", "header") +CAPSULE = ("source", "old_directory", "program", "old_count", "rows", "before", "gap", "suffix") + + +class Machine: + def __init__(self, binding, topology, programs, arena, indices, observe=None): + self.binding, self.topology, self.programs = binding, topology, tuple(programs) + self.arena, self.indices = arena, indices + staged = max(program.staged_roles for program in programs) + labels = (*NAMES, *(("family", i) for i in range(topology.families)), + *(("stage", i) for i in range(staged))) + self.roles = {label: Tape() for label in labels} + self.handoff = {label: Tape() for label in CAPSULE} + self.output = Tape() + self.pool = ScratchPool(binding.codes.q ** 2 + 128) + self.numerical = codec.BankParking(arena, indices) + self.streams = RoleParking(self.numerical, self.roles.values()) + self.header = FiniteFields((2, len(programs), max(len(p.operations) for p in programs), + arena.capacity, arena.capacity, arena.capacity, + indices.capacity, indices.capacity)) + self.context = self.program = self.size = self.depth = None + self.geometry_state = None + self.pc = self.mode = 0 + self.root = True + self.closed = False + self.observe = observe # Checker-only; the controller never reads its result. + self.counts = dict(macros=0, residuals=0, calls=0, returns=0) # Observers only. + + def tape(self, label): + return self.roles[label] + + def count(self, label): + result = object.__new__(Count) + result.tape = self.tape(label) + return result + + def commit(self, result, label): + target = self.tape(label) + if result is target: + return + target.clear() + append_tape(result, target) + target.rewind() + if isinstance(result, Lease): + result.clear() + + def save_count(self, value, label): + self.commit(value.tape, label) + value.close() + + def new_context(self, modulus, size, depth): + ring = Ring(modulus) + context = Context(ring, self.binding.codes) + self.save_count(context.highs, "highs") + context.highs = self.count("highs") + self.context, self.size, self.depth = context, size, depth + self.program = view(Program, self, self.tape("program")) + + def restore_context(self, labels): + modulus, one, cap, size, depth = labels + ring = object.__new__(Ring) + ring.arena, ring.raw = self.arena, Unsigned(self.arena) + ring.modulus, ring.one = self.arena.words[modulus], self.arena.words[one] + context = object.__new__(Context) + context.ring, context.arena, context.raw = ring, self.arena, ring.raw + context.codes = self.binding.codes + context.q, context.dimension = context.codes.q, context.codes.dimension + context.cap, context.highs = self.arena.words[cap], self.count("highs") + self.context = context + self.size, self.depth = self.indices.words[size], self.indices.words[depth] + self.program = view(Program, self, self.tape("program")) + + def boundary(self): + self.pool.empty() + for tape in self.roles.values(): + tape.step(-1) + need(tape.read() == LEFT, "completed canonical head stands after LEFT") + tape.step(1) + ring = self.context.ring + expected_indices = {self.size.slot, self.depth.slot} + if self.geometry_state is not None: + _definition, page, layout, fields, columns = self.geometry_state + expected_indices.update(word.slot for word in + (columns, page.one, page.two, page.leaf_cutoff, fields, + layout.core, layout.extra, layout.total)) + need(self.arena.live == {ring.modulus.slot, ring.one.slot, self.context.cap.slot} and + self.indices.live == expected_indices, + "only declared persistent and active geometry words at a completed macro") + + @contextmanager + def geometry(self, definition): + if self.geometry_state is not None: + owner, page, layout, fields, _columns = self.geometry_state + need(owner is definition, "one active residual geometry") + yield page, layout, fields + return + divisor = self.indices.literal(self.context.dimension) + columns, remainder = Unsigned(self.indices).divmod(self.size, divisor) + self.indices.free_many(divisor, remainder) + page = Geometry(definition.plan, self.indices, columns, self.depth, definition.code, self.program) + if self.binding.cutoff != 64: + self.indices.free(page.leaf_cutoff) + page.leaf_cutoff = self.indices.literal(self.binding.cutoff) + layout = Layout(page, self.size, self.context.ring, self.context.q, + self.count("leading"), self.count("gap"), self.count("suffix")) + fields = page.plus(self.depth, page.one) + self.geometry_state = definition, page, layout, fields, columns + yield page, layout, fields + + def close_geometry(self): + if self.geometry_state is None: + return + _definition, page, layout, fields, columns = self.geometry_state + self.geometry_state = None + self.indices.free(fields) + layout.close() + page.close() + self.indices.free(columns) + + def node(self): + divisor = self.indices.literal(self.context.dimension) + columns, remainder = Unsigned(self.indices).divmod(self.size, divisor) + valid = not columns.zero() + self.indices.free_many(divisor, columns, remainder) + need(valid, "complete internal node width") + for label in ("old_count", "rows", "before", "gap", "suffix"): + self.count(label).normalize() + positive(self.count(label)) + # Preserve source ingress validation before the first payload operation. + first = read_prefix(self.tape("old_directory"), self.depth) + self.tape("old_directory").rewind() + zero = self.indices.zero() + incoming = self.binding.incoming(self) + try: + value = incoming.coefficient(first, Request("incoming", zero)) + self.arena.free(value) + finally: + first.clear() + self.indices.free(zero) + unused = fresh_rows.quotient(self.count("rows"), self.context, self.topology.families) + self.save_count(unused, "unused") + stock = Count(self.count("unused")) + try: + need(stock.divide_small(self.binding.stock_multiple) == 0, "compatible fresh stock factor") + finally: + stock.close() + self.save_count(Count.product(self.count("unused"), self.count("before")), "leading") + fibre = Count.product(self.count("leading"), self.count("gap")) + total = Unsigned(self.indices).times_small(self.size, 2) + multiply_atom_power(fibre, total, self.context.ring, self.context.q) + self.indices.free(total) + complete = Count.product(fibre, self.count("suffix")) + fibre.close() + self.save_count(complete, "fibre") + peeled = peel.run(self.tape("source"), self.context, self.indices, self.size, self.depth, + self.program, self.tape("old_directory"), self.count("old_count"), + self.count("rows"), self.count("before"), self.count("gap"), + self.count("suffix"), incoming) + self.commit(peeled, "peeled") + self.save_count(fresh_rows.family_rows(self.context), "family_rows") + source = self.tape("peeled") + outer = Counter(self.count("old_count")) + try: + while not outer.finished: + for family in range(self.topology.families): + copy_rows(source, self.tape(("family", family)), self.count("family_rows"), self.count("fibre")) + outer.decrement() + need(source.read() == BLANK, "complete canonical fresh-row split") + finally: + outer.close() + source.rewind() + for family in range(self.topology.families): + self.tape(("family", family)).rewind() + + def residual_begin(self, role, definition): + self.binding.check_stock(self) + directory, prefixes = produce(self.tape("old_directory"), self.depth, self.count("old_count"), + definition.code, self.context) + self.commit(directory, "directory") + self.save_count(prefixes, "prefixes") + with self.geometry(definition) as (_page, _layout, fields): + first = read_prefix(self.tape("directory"), fields) + self.tape("directory").rewind() + try: + self.binding.validate_residual(self, definition, first) + finally: + first.clear() + self.commit(self.tape(role), "current") + self.counts["residuals"] += 1 + if self.observe is not None: + self.observe(self, "residual_begin", definition, role) + + def prepare_child(self, definition, event, layout, fields): + need(event.parent_identity is self.program and + event.source_code == definition.code == layout.geometry.source_code, + "recursive gate belongs to the current program and source") + raw = Unsigned(self.indices) + need(raw.compare(event.width, self.size) < 0, "strict child contraction") + extents = layout.child_extents(event.first, event.second, event.width, before=self.count("before")) + first = read_prefix(self.tape("directory"), fields) + self.tape("directory").rewind() + program = None + try: + program = self.binding.child_program(self, definition, event, first) + inputs = (self.tape("current"), self.tape("directory"), program, + self.tape("prefixes"), self.tape("unused"), *(extent.tape for extent in extents)) + for label, source in zip(CAPSULE, inputs): + target = self.handoff[label] + need(target.read() == BLANK, "empty fixed child handoff port") + append_tape(source, target) + target.rewind() + return (self.arena.copy(self.context.ring.modulus), + self.indices.copy(event.width), self.indices.copy(event.depth)) + finally: + if program is not None: + program.clear() + first.clear() + for extent in extents: + extent.close() + + def block(self, definition, block): + grants = None + with self.geometry(definition) as (page, layout, fields): + if block[0] == "axis": + axis = block[1] + trace = child(page, page.raw.times_small(page.columns, axis), + page.raw.times_small(page.columns, 3 - axis), + self.indices.copy(page.columns), "good") + else: + trace = block_events(page, block) + try: + first = next(trace, None) + if first is not None and first.kind == "enter" and page.raw.compare(first.width, page.leaf_cutoff) >= 0: + grants = self.prepare_child(definition, first, layout, fields) + else: + def complete_events(): + if first is not None: + yield first + yield from trace + result = packet_engine.run(self.tape("current"), complete_events(), layout, + self.tape("directory"), self.count("prefixes"), fields, + lambda prefix, request: self.binding.coefficient(self, definition, prefix, request)) + self.commit(result, "current") + finally: + trace.close() + if grants is not None: + self.close_geometry() + self.call(grants) + return True + return False + + def call(self, grants): + self.pool.empty() + need(self.geometry_state is None, "close derived geometry before the recursive cut") + ring = self.context.ring + self.header.write(self.tape("header"), (int(self.root), self.mode, self.pc + 1, + ring.modulus.slot, ring.one.slot, self.context.cap.slot, + self.size.slot, self.depth.slot)) + self.streams.park() + modulus, size, depth = grants + self.numerical.park(({modulus.slot}, {size.slot, depth.slot})) + for label in CAPSULE: + transfer(self.handoff[label], self.tape(label)) + self.new_context(modulus, size, depth) + self.root, self.mode, self.pc = False, self.binding.child_mode, 0 + self.counts["calls"] += 1 + + def close_frame(self): + self.close_geometry() + ring = self.context.ring + self.context.close() + ring.close() + self.arena.free(ring.modulus) + self.indices.free_many(self.size, self.depth) + for tape in self.roles.values(): + tape.clear() + self.pool.empty() + need(not self.arena.live and not self.indices.live, "child numerical cleanup before restoration") + + def returned(self): + families = {i: self.tape(("family", i)) for i in range(self.topology.families)} + result = fresh_rows.merge(families, self.context, self.topology.families, + self.count("old_count"), self.count("fibre")) + need(self.output.read() == BLANK, "empty protected return port") + append_tape(result, self.output) + self.output.rewind() + result.clear() + return self.complete_return() + + def complete_return(self): + """Return the already completed protected output through one frame.""" + self.close_frame() + if self.root: + return True + self.numerical.restore() + self.streams.restore() + root, self.mode, self.pc, *labels = self.header.read(self.tape("header")) + self.root = bool(root) + self.tape("header").clear() + self.restore_context(labels) + transfer(self.output, self.tape("current")) + self.counts["returns"] += 1 + return False + + def dispatch(self, operation): + kind, *args = operation + context, old_count, fibre = self.context, self.count("old_count"), self.count("fibre") + if kind == "node": + self.node() + elif kind == "residual_begin": + self.residual_begin(*args) + elif kind == "block": + if self.block(*args): + return "jump" + elif kind == "residual_end": + self.close_geometry() + transfer(self.tape("current"), self.tape(args[0])) + self.tape("directory").clear() + self.tape("prefixes").clear() + if self.observe is not None: + self.observe(self, "residual_end", args[1], args[0]) + elif kind == "gather_route": + role, family, low, route = args + selected = gather(self.tape(("family", family)), context, old_count, low, fibre) + try: + self.commit(route_packet(selected, route, context, old_count, fibre), role) + finally: + selected.clear() + elif kind == "route_scatter": + role, family, low, route = args + result = route_packet(self.tape(role), route, context, old_count, fibre) + try: + changed = scatter(self.tape(("family", family)), result, context, old_count, low, fibre) + self.commit(changed, ("family", family)) + finally: + result.clear() + elif kind == "gather": + role, family, low = args + self.commit(gather(self.tape(("family", family)), context, old_count, low, fibre), role) + elif kind == "scatter": + role, family, low = args + self.commit(scatter(self.tape(("family", family)), self.tape(role), context, old_count, low, fibre), ("family", family)) + elif kind == "xor": + target, source = args + self.commit(xor_packet(self.tape(source), self.tape(target), context, old_count, fibre), target) + elif kind == "family_xor": + target, source = args + self.commit(xor_family(self.tape(("family", source)), self.tape(("family", target)), + old_count, self.count("family_rows"), fibre), ("family", target)) + elif kind == "exchange": + first, second = (("family", index) for index in args) + transfer(self.tape(first), self.tape("swap")) + transfer(self.tape(second), self.tape(first)) + transfer(self.tape("swap"), self.tape(second)) + elif kind == "copy": + self.commit(self.tape(args[0]), args[1]) + if self.observe is not None: + self.observe(self, "copy_source", *args) + elif kind == "move": + transfer(self.tape(args[0]), self.tape(args[1])) + elif kind == "clear": + self.tape(args[0]).clear() + elif kind == "checkpoint": + if self.observe is not None: + self.observe(self, *args) + else: + need(kind == "return", "closed finite macro alphabet") + return "done" if self.returned() else "jump" + return "next" + + def load_root(self, source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode=0): + need(not self.arena.live and not self.indices.live, "empty supplied working banks") + inputs = (source, directory, program, old_count.tape, rows.tape, before.tape, gap.tape, suffix.tape) + owned = (*self.roles.values(), *self.handoff.values(), self.output, *self.pool.tapes) + need(all(input_tape is not work_tape for input_tape in inputs for work_tape in owned), + "borrowed root input ports are outside the reusable working bank") + for label, tape in zip(CAPSULE, inputs): + self.commit(tape, label) + self.new_context(copy_word(modulus, self.arena), copy_word(size, self.indices), copy_word(depth, self.indices)) + self.mode, self.pc, self.root = mode, 0, True + + def run(self, source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode=0): + need(not self.closed, "one owned root invocation per machine initialization") + with self.pool.install(): + self.load_root(source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode) + while True: + self.boundary() + operation = self.programs[self.mode].operations[self.pc] + action = self.dispatch(operation) + self.counts["macros"] += 1 + if action == "done": + break + if action == "next": + self.pc += 1 + self.pool.empty() + need(self.numerical.machine.tapes == [{}, {0: "^"}], "complete physical stack return") + self.erase_work() + return self.output + + def erase_work(self): + """Erase permanent owned markers/templates at the final root return.""" + need(not self.arena.live and not self.indices.live and not self.pool.live, + "root cleanup follows complete frame and scratch cleanup") + def marker(tape): + tape.step(-1) + need(tape.read() == LEFT, "owned work marker at the known origin") + tape.write(BLANK) + tape.step(1) + for tape in (*self.roles.values(), *self.handoff.values(), *self.pool.tapes): + need(tape.read() == BLANK, "empty body before owned marker erasure") + marker(tape) + for arena in (self.arena, self.indices): + for word in arena.words: + marker(word) + arena.template.erase() + marker(arena.template) + self.numerical._empty_port() + self.numerical._move(1, -1) + self.numerical._write(1, "_") + self.numerical._move(1, 1) + self.closed = True diff --git a/research/directory-producer-invoice/source/NOTICE.md b/research/directory-producer-invoice/source/NOTICE.md new file mode 100644 index 0000000000..ef9f81510d --- /dev/null +++ b/research/directory-producer-invoice/source/NOTICE.md @@ -0,0 +1,49 @@ +# Attribution + +Jose Manuel (`jmbarrancoml`) prepared the full first-range caller, gap/peel +integration, source catalogue binding and checks with substantial OpenAI Codex +assistance. New work uses Apache-2.0. We claim no independent human review +or new formal-kernel verification of this package. + +We credit OpenAI's retained framework and Douglas Colkitt for the stream, +interchange and tape contracts. The selected word/hosting lineage includes +DreamingOfClouds' PR589 tuning on eumemic's PR555 word, Dugongue's PR541/548, +rohanarun's PR542, eumemic's PR490 whole-owner argument and alephnan's PR1627 +literal reader and chronological hosting proof. + +The source527 contributors supplied the normal forms and weighted leaf +factorization. commdata2338 supplied PR2160's selected good form, PR2188's +mixed descriptor grammar, PR1379's parking boundary and PR2332's selected +table/global-slot binding. Ross Richardson supplied PR2159's full-ring fallback +topology and covariance. Jose Manuel's PR2157/2171/2195/2207/2234 and +PR2310/2364/2405/2449/2501/2569 supply the selected chart, controlled stream, +generated grammar, canonical-prefix, completed residual and source-route +predecessors. PR2195 supplies the ring/GL hosting lift and terminal gauge +calculation recalled in our proof. We do not claim new versions of those +algebraic identities. + +We retain 25 files from PR2569 at +`0b116cb34f27a4b064f0d8dd65549ea5705cf9c0`, including its 16 unchanged PR2501 +runtime/compiler dependencies. SOURCES.json lists their original paths, +Git blobs and SHA256 hashes. We retain their bytes and source comments. +We adapt PR2234's provider enumeration in catalogue.py and preserve its +ordered request digest. Our test-only model and observers adapt predecessor +finite expectation and origin-column patterns. The oracle module serves +fixed-q source compilation and finite expectations; we do not use it to +decode runtime high fields or execute payload permutations. + +We credit ywz65's PR2475 for conditional whole-call staging and PR2545 for its +separate buffer-residency completion. Ross Richardson's PR2519 gives a +separate one-buffer R439 adapter and relative-chart packet identity. We do +not adopt those numerical workspace constants. commdata2338's PR2386/2399 +sharpen request counts and completed leaf/header substitution. + +We credit ywz65's completed PR2566 audit of AtomSwap/Sign cost and ownership, +and PR2590 for the cubic radix-reconstruction term in directory setup. We +use PR2569's corrected proof at +`898ff36fe2cd05f733de6b26c88a4c4741b06237`; its runtime bytes match our earlier +pin. We preserve the canonical-input hypothesis and charge returned directory +and Count disposal outside the audited producer interval. + +We leave larger recursive return, numerical reserve admission and full +multiplication transfer open. We retain the selected frontier. diff --git a/research/directory-producer-invoice/source/cardinality.py b/research/directory-producer-invoice/source/cardinality.py new file mode 100644 index 0000000000..b8ba857e32 --- /dev/null +++ b/research/directory-producer-invoice/source/cardinality.py @@ -0,0 +1,136 @@ +"""Canonical unbounded binary cardinalities on one sequential tape each.""" +from records import Tape +from stream import Counter +from words import BLANK, LEFT, ONE, RIGHT, ZERO, need + + +class Natural: + def __init__(self, source=None): + self.tape = Tape() + if source is None: + self.tape.append(ONE) + else: + source.rewind() + while source.read() != RIGHT: + bit = source.read() + need(bit in (ZERO, ONE), "binary cardinality input") + self.tape.append(bit) + source.step(1) + source.rewind() + self.tape.append(RIGHT) + self.normalize() + + def read(self): + return self.tape.read() + + def step(self, direction): + self.tape.step(direction) + + def rewind(self): + self.tape.rewind() + + def msb(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + + def normalize(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + while self.read() == ZERO: + self.tape.write(RIGHT) + self.step(1) + self.tape.write(BLANK) + self.step(-1) + self.step(-1) + if self.read() == LEFT: + self.step(1) + self.tape.write(ZERO) + self.step(1) + self.tape.write(RIGHT) + self.rewind() + + def multiply_small(self, constant): + """The multiplier and bounded carry belong to fixed finite control.""" + need(constant >= 2, "fixed cardinality multiplier") + carry = 0 + while self.read() != RIGHT: + total = constant*self.read()+carry + self.tape.write(total & 1) + carry = total >> 1 + self.step(1) + while carry: + self.tape.write(carry & 1) + carry >>= 1 + self.step(1) + self.tape.write(RIGHT) + self.rewind() + + def divide_small(self, constant): + self.msb() + remainder = 0 + while self.read() != LEFT: + remainder = 2*remainder+self.read() + if remainder >= constant: + self.tape.write(ONE) + remainder -= constant + else: + self.tape.write(ZERO) + self.step(-1) + self.step(1) + self.normalize() + return remainder + + def marginal(self): + """Copy with one high zero bit for the retained ADD input contract.""" + result = Natural(self) + result.msb() + result.step(1) + result.tape.write(ZERO) + result.step(1) + result.tape.write(RIGHT) + result.rewind() + return result + + def close(self): + self.tape.clear() + + +def radix_power(ring, q): + """Yield once per radix-q digit of M=q^w, without decoding w.""" + arena = ring.arena + divisor, power = arena.literal(q), arena.copy(ring.modulus) + try: + while ring.raw.compare(power, ring.one) > 0: + quotient, remainder = ring.raw.divmod(power, divisor) + need(remainder.zero() and not quotient.zero(), "cardinality prime-power context") + arena.free_many(power, remainder) + power = quotient + yield + need(ring.raw.compare(power, ring.one) == 0, "complete radix exponent") + finally: + arena.free_many(divisor, power) + + +def multiply_atom_power(value, exponent, ring, q): + count = Counter(exponent) + try: + while not count.finished: + for _ in radix_power(ring, q): + value.multiply_small(q) + count.decrement() + finally: + count.close() + + +def digit_suffix(value, ring, q): + """Multiply by q^(w-1), preserving an arbitrary spectator factor.""" + first = True + for _ in radix_power(ring, q): + if first: + first = False + else: + value.multiply_small(q) diff --git a/research/directory-producer-invoice/source/counts.py b/research/directory-producer-invoice/source/counts.py new file mode 100644 index 0000000000..81b48940ce --- /dev/null +++ b/research/directory-producer-invoice/source/counts.py @@ -0,0 +1,57 @@ +"""Unbounded cardinalities; only compiled finite constants enter host control.""" +from cardinality import Natural, digit_suffix +from records import Tape +from words import ONE, RIGHT, ZERO, need + + +class Count(Natural): + @classmethod + def literal(cls, value): + """Compile a fixed cardinality, never decode a runtime operand.""" + need(isinstance(value, int) and value >= 0, "compiled cardinality") + tape = Tape() + for bit in range(max(1, value.bit_length())): + tape.append((value >> bit) & 1) + tape.append(RIGHT) + tape.rewind() + result = cls(tape) + tape.clear() + return result + + def increment(self): + self.rewind() + while self.read() == ONE: + self.tape.write(ZERO) + self.step(1) + if self.read() == RIGHT: + self.tape.write(ONE) + self.step(1) + self.tape.write(RIGHT) + else: + need(self.read() == ZERO, "canonical count digit") + self.tape.write(ONE) + self.rewind() + + def equals(self, other): + self.rewind() + other.rewind() + same = True + while self.read() != RIGHT and other.read() != RIGHT: + same = same and self.read() == other.read() + self.step(1) + other.step(1) + same = same and self.read() == other.read() == RIGHT + self.rewind() + other.rewind() + return same + + +def high_power(value, ring, q, dimension): + for _ in range(dimension*dimension): + digit_suffix(value, ring, q) + + +def high_count(ring, q, dimension): + result = Count.literal(1) + high_power(result, ring, q, dimension) + return result diff --git a/research/directory-producer-invoice/source/directory.py b/research/directory-producer-invoice/source/directory.py new file mode 100644 index 0000000000..c74cacf5ce --- /dev/null +++ b/research/directory-producer-invoice/source/directory.py @@ -0,0 +1,126 @@ +"""Produce all high fields while preserving physical old-prefix multiplicity.""" +from cardinality import radix_power +from counts import Count, high_count, high_power +from records import RECORD_END, Tape, append_finite, append_word, read_finite, read_word +from stream import Counter +from words import BLANK, RIGHT, ZERO, need + + +class Context: + def __init__(self, ring, vocabulary): + self.ring, self.arena, self.raw = ring, ring.arena, ring.raw + self.codes = vocabulary + self.q, self.dimension = vocabulary.q, vocabulary.dimension + for _ in radix_power(ring, self.q): + pass + divisor = self.arena.literal(self.q) + self.cap, remainder = self.raw.divmod(ring.modulus, divisor) + need(remainder.zero() and not self.cap.zero(), "positive high-field radix") + self.arena.free_many(divisor, remainder) + self.highs = high_count(ring, self.q, self.dimension) + + def close(self): + self.arena.free(self.cap) + self.highs.close() + + +class Odometer: + def __init__(self, context): + self.context = context + self.digits = [[context.arena.zero() for _ in range(context.dimension)] + for _ in range(context.dimension)] + self.finished = False + + def advance(self): + need(not self.finished, "live high odometer") + context = self.context + for row in reversed(self.digits): + for digit in reversed(row): + context.raw.increment_in_place(digit) + if context.raw.compare(digit, context.cap) < 0: + return + need(context.raw.compare(digit, context.cap) == 0, "high digit carry") + while digit.read() != RIGHT: + digit.write(ZERO) + digit.step(1) + digit.rewind() + self.finished = True + + def close(self): + for row in self.digits: + self.context.arena.free_many(*row) + + +def append_tape(source, destination): + source.rewind() + while source.read() != BLANK: + destination.append(source.read()) + source.step(1) + source.rewind() + + +def old_prefix(source, field_count, context): + """Retain one serialized prefix; decode at most one old numerical word.""" + output, remaining = Tape(), Counter(field_count) + try: + while not remaining.finished: + code = read_finite(source, context.codes.bits) + need(code < context.codes.limit, "old compiled source code") + append_finite(output, code, context.codes.bits) + for _ in range(context.dimension*context.dimension): + word = read_word(source, context.arena) + try: + need(context.raw.compare(word, context.cap) < 0, "old high digit range") + append_word(output, word) + finally: + context.arena.free(word) + need(source.read() == RECORD_END, "old field boundary") + source.step(1) + output.append(RECORD_END) + remaining.decrement() + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + remaining.close() + + +def produce(old, old_fields, old_count, code, context): + need(0 <= code < context.codes.limit, "new compiled source code") + expected, emitted = Count(old_count), Count.literal(0) + high_power(expected, context.ring, context.q, context.dimension) + outer, output = Counter(old_count), Tape() + old.rewind() + try: + need(not outer.finished, "nonempty old physical prefix domain") + while not outer.finished: + saved = old_prefix(old, old_fields, context) + high = Odometer(context) + try: + while not high.finished: + append_tape(saved, output) + append_finite(output, code, context.codes.bits) + for row in high.digits: + for digit in row: + append_word(output, digit) + output.append(RECORD_END) + emitted.increment() + high.advance() + finally: + saved.clear() + high.close() + outer.decrement() + need(old.read() == BLANK and emitted.equals(expected), "complete canonical raw directory") + old.rewind() + output.rewind() + return output, expected + except ValueError: + output.clear() + expected.close() + old.rewind() + raise + finally: + emitted.close() + outer.close() diff --git a/research/directory-producer-invoice/source/records.py b/research/directory-producer-invoice/source/records.py new file mode 100644 index 0000000000..4f00467a0f --- /dev/null +++ b/research/directory-producer-invoice/source/records.py @@ -0,0 +1,271 @@ +"""Sequential binary program/field records and typed continuation stacks. + +Runtime numerical words copy between tapes. Only tags, source codes, ranks +and row labels enter fixed finite control. Fixture encoding is separate. +""" +from words import BLANK, LEFT, ONE, RIGHT, ZERO, Meter, Unsigned, need + +WORD_END, RECORD_END = 5, 6 +ROOT, STEP, VALUE, CONSTANT, MULTIPLY, PAIR, RETURN = range(7, 14) +FINITE_BITS = 16 # Fixed vocabulary width for this compiled source instance. + + +class Tape: + def __init__(self): + self.cells = bytearray([LEFT]) + self.head = 1 + self.meter = Meter() + + def read(self): + self.meter.reads += 1 + return self.cells[self.head] if self.head < len(self.cells) else BLANK + + def write(self, symbol): + need(ZERO <= symbol <= RETURN, "fixed record alphabet") + self.meter.writes += 1 + if self.head >= len(self.cells): + self.cells.extend([BLANK]*(self.head+1-len(self.cells))) + self.cells[self.head] = symbol + + def step(self, direction): + need(direction in (-1, 1), "unit record-head move") + self.head += direction + need(self.head >= 0, "local record boundary") + self.meter.moves += 1 + + def append(self, symbol): + need(self.read() == BLANK, "append at record blank") + self.write(symbol) + self.step(1) + + def rewind(self): + self.step(-1) + while self.read() != LEFT: + self.step(-1) + self.step(1) + + def clear(self): + self.rewind() + while self.read() != BLANK: + self.write(BLANK) + self.step(1) + self.rewind() + + +def append_word(tape, word): + word.rewind() + while word.read() != RIGHT: + tape.append(word.read()) + word.step(1) + tape.append(WORD_END) + word.rewind() + + +def read_word(tape, arena): + out = arena.zero() + while tape.read() != WORD_END: + bit = tape.read() + need(bit in (ZERO, ONE) and out.read() != RIGHT, "encoded word extent") + out.write(bit) + out.step(1) + tape.step(1) + need(out.read() == RIGHT, "complete encoded word") + tape.step(1) + out.rewind() + return out + + +def append_finite(tape, value, bits=FINITE_BITS): + """Compile-time finite source/operation tag encoding.""" + need(0 <= value < 1 << bits, "compiled finite vocabulary") + for bit in range(bits): + tape.append((value >> bit) & 1) + tape.append(WORD_END) + + +def read_finite(tape, bits=FINITE_BITS): + # The accumulator ranges over a fixed finite set, independent of e/w/h. + state = 0 + for bit in range(bits): + value = tape.read() + need(value in (ZERO, ONE), "finite label bit") + state |= value << bit + tape.step(1) + need(tape.read() == WORD_END, "finite label delimiter") + tape.step(1) + return state + + +def seek_record(tape, index): + machine, arena = Unsigned(index.arena), index.arena + remaining, one = arena.copy(index), arena.literal(1) + tape.rewind() + while not remaining.zero(): + while tape.read() != RECORD_END: + need(tape.read() != BLANK, "record exists at global slot") + tape.step(1) + tape.step(1) + after = machine.subtract_exact(remaining, one) + arena.free(remaining) + remaining = after + arena.free_many(remaining, one) + + +class Stack: + def __init__(self, index_arena, residue_arena): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.tape, self.reverse = Tape(), Tape() + + def empty(self): + self.tape.step(-1) + result = self.tape.read() == LEFT + self.tape.step(1) + return result + + def push(self, tag, *words): + need(tag in (VALUE, CONSTANT, MULTIPLY, PAIR, RETURN), "continuation kind") + need(len(words) == (2 if tag == VALUE else 1), "continuation arity") + self.tape.append(tag) + for word in words: + append_word(self.tape, word) + self.tape.append(RECORD_END) + + def pop(self): + need(not self.empty(), "nonempty continuation stack") + tape, reverse = self.tape, self.reverse + tape.step(-1) + need(tape.read() == RECORD_END, "continuation top delimiter") + tape.write(BLANK) + tape.step(-1) + while tape.read() not in (LEFT, RECORD_END): + reverse.append(tape.read()) + tape.write(BLANK) + tape.step(-1) + tape.step(1) + reverse.step(-1) + tag = reverse.read() + need(tag in (VALUE, CONSTANT, MULTIPLY, PAIR, RETURN), "encoded continuation kind") + reverse.write(BLANK) + reverse.step(-1) + arenas = (self.index_arena, self.index_arena) if tag == VALUE else (self.residue_arena,) + words = [] + for arena in arenas: + out = arena.zero() + while reverse.read() != WORD_END: + bit = reverse.read() + need(bit in (ZERO, ONE) and out.read() != RIGHT, "continuation binary word") + out.write(bit) + out.step(1) + reverse.write(BLANK) + reverse.step(-1) + need(out.read() == RIGHT, "complete continuation operand") + reverse.write(BLANK) + reverse.step(-1) + out.rewind() + words.append(out) + need(reverse.read() == LEFT, "complete continuation record") + reverse.step(1) + return tag, tuple(words) + + +class Program: + """Encoded root and admitted chronological steps; numerical fields are words.""" + def __init__(self, index_arena, residue_arena, code_bits=FINITE_BITS): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.code_bits = code_bits + self.tape = Tape() + + def root(self): + self.tape.rewind() + need(self.tape.read() == ROOT, "root record") + self.tape.step(1) + size = read_word(self.tape, self.index_arena) + unit = read_word(self.tape, self.residue_arena) + depth = read_word(self.tape, self.index_arena) + need(self.tape.read() == RECORD_END, "root record end") + self.tape.rewind() + return size, unit, depth + + def step(self, level): + need(not level.zero(), "positive step level") + seek_record(self.tape, level) + need(self.tape.read() == STEP, "step record") + self.tape.step(1) + metadata = tuple(read_finite(self.tape, self.code_bits if field == 1 else FINITE_BITS) + for field in range(6)) + parent = read_word(self.tape, self.index_arena) + child = read_word(self.tape, self.index_arena) + need(self.tape.read() == RECORD_END, "step record end") + self.tape.rewind() + return metadata, parent, child + + @classmethod + def fixture(cls, index_arena, residue_arena, root_size, root_unit, events, code_bits=FINITE_BITS): + """Fixture-only serialization; runtime computes and validates extents.""" + out = cls(index_arena, residue_arena, code_bits) + out.tape.append(ROOT) + for arena, value in ((index_arena, root_size), (residue_arena, root_unit), (index_arena, len(events))): + word = arena.input(value) + append_word(out.tape, word) + arena.free(word) + out.tape.append(RECORD_END) + size = root_size + for kind, code, rank, field, reverse, half in events: + f = size//64 + child = rank*f if kind == 0 else f//2 if half else f + out.tape.append(STEP) + for field_index, label in enumerate((kind, code, rank, field, int(reverse), int(half))): + append_finite(out.tape, label, code_bits if field_index == 1 else FINITE_BITS) + for value in (size, child): + word = index_arena.input(value) + append_word(out.tape, word) + index_arena.free(word) + out.tape.append(RECORD_END) + size = child + out.tape.rewind() + return out + + +class Fields: + def __init__(self, index_arena, residue_arena, code_bits=FINITE_BITS): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.code_bits = code_bits + self.tape = Tape() + + def check_code(self, slot, code): + seek_record(self.tape, slot) + observed = read_finite(self.tape, self.code_bits) + self.tape.rewind() + need(observed == code, "original global raw-field code") + + def end(self, after): + seek_record(self.tape, after) + complete = self.tape.read() == BLANK + self.tape.rewind() + need(complete, "exact frozen/current field prefix") + + def read(self, slot, code, depth): + need(Unsigned(self.index_arena).compare(slot, depth) < 0, "frozen field excludes current/future slot") + seek_record(self.tape, slot) + observed = read_finite(self.tape, self.code_bits) + need(observed == code, "exact encoded raw-field specification") + out = [[read_word(self.tape, self.residue_arena) for _ in range(64)] for _ in range(64)] + need(self.tape.read() == RECORD_END, "complete 64-dimensional raw high field") + self.tape.rewind() + return out + + @classmethod + def fixture(cls, index_arena, residue_arena, fields, code_bits=FINITE_BITS): + """Load canonical raw-field fixture data before measured execution.""" + out = cls(index_arena, residue_arena, code_bits) + for code, high in fields: + append_finite(out.tape, code, code_bits) + need(len(high) == 64 and all(len(row) == 64 for row in high), "field fixture shape") + for row in high: + for value in row: + word = residue_arena.input(value) + append_word(out.tape, word) + residue_arena.free(word) + out.tape.append(RECORD_END) + out.tape.rewind() + return out diff --git a/research/directory-producer-invoice/source/stream.py b/research/directory-producer-invoice/source/stream.py new file mode 100644 index 0000000000..5e5a4bb0f9 --- /dev/null +++ b/research/directory-producer-invoice/source/stream.py @@ -0,0 +1,163 @@ +"""Binary-counted complete-fibre ADD using an encoded coefficient callback. + +Each arbitrary spectator extent has its own canonical word length. None +enters the coefficient context. Payload bits remain opaque to the arithmetic. +""" +from records import Tape +from words import BLANK, LEFT, ONE, RIGHT, ZERO, need + + +class Counter: + """Canonical variable-length countdown with amortized ripple movement.""" + def __init__(self, word): + self.tape = Tape() + word.rewind() + while word.read() != RIGHT: + self.tape.append(word.read()) + word.step(1) + word.rewind() + self.tape.append(RIGHT) + self.tape.step(-1) + self.tape.step(-1) + while self.tape.read() == ZERO: + self.tape.write(RIGHT) + self.tape.step(1) + self.tape.write(BLANK) + self.tape.step(-1) + self.tape.step(-1) + self.finished = self.tape.read() == LEFT + if self.finished: + self.tape.step(1) + self.tape.write(ZERO) + self.tape.step(1) + self.tape.write(RIGHT) + self.tape.rewind() + + def decrement(self): + need(not self.finished, "positive countdown") + tape = self.tape + while tape.read() == ZERO: + tape.write(ONE) + tape.step(1) + need(tape.read() == ONE, "canonical positive counter") + tape.write(ZERO) + tape.step(1) + if tape.read() == RIGHT: + tape.write(BLANK) + tape.step(-1) + tape.step(-1) + if tape.read() == LEFT: + tape.step(1) + tape.write(ZERO) + tape.step(1) + tape.write(RIGHT) + self.finished = True + else: + tape.step(1) + tape.write(RIGHT) + tape.rewind() + + def close(self): + self.tape.clear() + + +def positive_extent(word): + """Reject padding inherited from a different, larger spectator extent.""" + word.msb() + margin = word.read() + word.step(-1) + significant = word.read() + word.rewind() + need(margin == ZERO and significant == ONE, "separately canonical positive spectator extent") + + +def one_bit_suffix(word): + """Recognize the fixed encodings of one, without decoding a cardinality.""" + word.rewind() + if word.read() != ONE: + return False + word.step(1) + if word.read() == ZERO: + word.step(1) + result = word.read() == RIGHT + word.rewind() + return result + + +def copy_blocks(source, target, count, suffix, observe): + blocks = Counter(count) + single = one_bit_suffix(suffix) + while not blocks.finished: + if single: + bit = source.read() + need(bit in (ZERO, ONE), "opaque payload bit") + target.append(bit) + source.step(1) + else: + bits = Counter(suffix) + while not bits.finished: + bit = source.read() + need(bit in (ZERO, ONE), "opaque payload bit") + target.append(bit) + source.step(1) + bits.decrement() + bits.close() + observe(bits) + blocks.decrement() + blocks.close() + observe(blocks) + + +def add_pass(source, ring, before, middle, suffix, prepare_coefficient, payload_factory=Tape): + for extent in (before, middle, suffix): + positive_extent(extent) + left, right, out = payload_factory(), payload_factory(), payload_factory() + totals = {"reads": 0, "writes": 0, "moves": 0} + def observe(counter): + # External meter only; no count controls execution. + for key in totals: + totals[key] += getattr(counter.tape.meter, key) + def traverse(merge): + coefficient = prepare_coefficient() + need(ring.raw.compare(coefficient, ring.modulus) < 0, "canonical encoded coefficient") + outer = Counter(before) + while not outer.finished: + x = ring.arena.zero() + sources = Counter(ring.modulus) + while not sources.finished: + offset = ring.multiply(coefficient, x) + leading = ring.raw.subtract_exact(ring.modulus, offset) + mid = Counter(middle) + while not mid.finished: + if merge: + copy_blocks(right, out, offset, suffix, observe) + copy_blocks(left, out, leading, suffix, observe) + else: + copy_blocks(source, left, leading, suffix, observe) + copy_blocks(source, right, offset, suffix, observe) + mid.decrement() + mid.close() + observe(mid) + ring.arena.free_many(offset, leading) + sources.decrement() + if not sources.finished: + ring.raw.increment_in_place(x) + sources.close() + observe(sources) + ring.arena.free(x) + outer.decrement() + outer.close() + observe(outer) + ring.arena.free(coefficient) + traverse(False) + need(source.read() == BLANK, "complete input extent") + source.rewind() + left.rewind() + right.rewind() + traverse(True) + need(left.read() == right.read() == BLANK, "complete split consumption") + left.clear() + right.clear() + out.rewind() + return out, {"counters": totals, "left": left.meter.record(), "right": right.meter.record(), + "output": out.meter.record()} diff --git a/research/directory-producer-invoice/source/words.py b/research/directory-producer-invoice/source/words.py new file mode 100644 index 0000000000..8d4ba37e27 --- /dev/null +++ b/research/directory-producer-invoice/source/words.py @@ -0,0 +1,415 @@ +"""Binary word tapes; unbounded numerical values stay in tape cells. + +Only zero/one carry states and fixed register/operation tags enter Python +control. Fixture loading/inspection methods are outside measured execution. +The arena bounds the tape inventory by a compile-time register capacity. +""" +ZERO, ONE, LEFT, RIGHT, BLANK = range(5) + + +def need(test, message): + if not test: + raise ValueError(message) + + +class Meter: + __slots__ = ("reads", "writes", "moves", "peak_live", "allocations") + + def __init__(self): + self.reads = self.writes = self.moves = self.peak_live = self.allocations = 0 + + def record(self): + return {name: getattr(self, name) for name in self.__slots__} + + +class Word: + __slots__ = ("arena", "slot", "cells", "head") + + def __init__(self, arena, slot): + self.arena, self.slot = arena, slot + self.cells = bytearray([LEFT] + [BLANK]*(arena.bits+1)) + self.head = 1 + + def read(self): + self.arena.meter.reads += 1 + return self.cells[self.head] + + def write(self, symbol): + need(symbol in (ZERO, ONE, RIGHT, BLANK), "word tape alphabet") + self.arena.meter.writes += 1 + self.cells[self.head] = symbol + + def step(self, direction): + need(direction in (-1, 1), "unit word-head movement") + self.head += direction + need(0 <= self.head < len(self.cells), "local word boundary") + self.arena.meter.moves += 1 + + def rewind(self): + self.step(-1) + while self.read() != LEFT: + self.step(-1) + self.step(1) + + def msb(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + + def zero(self): + self.rewind() + nonzero = False + while True: + bit = self.read() + if bit == RIGHT: + break + need(bit in (ZERO, ONE), "complete binary word") + nonzero = nonzero or bit == ONE + self.step(1) + self.rewind() + return not nonzero + + def erase(self): + self.rewind() + while self.read() != RIGHT: + self.write(BLANK) + self.step(1) + self.write(BLANK) + self.rewind() + + def inspect(self): + """Checker-only decoding; arithmetic code must not call this.""" + need(self.head == 1 and self.cells[-1] == RIGHT, "inspect a restored word") + return sum(bit << i for i, bit in enumerate(self.cells[1:-1])) + + +class Arena: + def __init__(self, bits, capacity=65536): + need(bits >= 2 and capacity > 0, "fixed word context") + self.bits, self.capacity = bits, capacity + self.meter = Meter() + self.words, self.available, self.live = [], [], set() + self.template = Word(self, -1) + self.template.cells[1:-1] = bytes([ZERO])*bits + self.template.cells[-1] = RIGHT + + def zero(self): + if self.available: + slot = self.available.pop() + out = self.words[slot] + else: + slot = len(self.words) + need(slot < self.capacity, "fixed register inventory") + out = Word(self, slot) + self.words.append(out) + need(slot not in self.live, "fresh numerical register") + self.live.add(slot) + self.meter.allocations += 1 + self.meter.peak_live = max(self.meter.peak_live, len(self.live)) + source = self.template + source.rewind() + while source.read() != RIGHT: + need(out.read() == BLANK, "erased register before reuse") + out.write(ZERO) + out.step(1) + source.step(1) + need(out.read() == BLANK, "erased right delimiter cell") + out.write(RIGHT) + out.rewind() + source.rewind() + return out + + def literal(self, value): + """Compile-time literal only; never decode a runtime word here.""" + need(isinstance(value, int) and value >= 0, "unsigned literal") + out = self.zero() + for bit in tuple((value >> i) & 1 for i in range(value.bit_length())): + need(out.read() != RIGHT, "literal fits the fixed word") + out.write(bit) + out.step(1) + out.rewind() + return out + + def input(self, value): + """Fixture-only loading of an encoded input word.""" + return self.literal(value) + + def copy(self, source): + need(source.arena is self, "one word extent") + out = self.zero() + source.rewind() + while source.read() != RIGHT: + out.write(source.read()) + source.step(1) + out.step(1) + out.rewind() + source.rewind() + return out + + def free(self, word): + need(word.arena is self and word.slot in self.live, "owned numerical register") + word.erase() + self.live.remove(word.slot) + self.available.append(word.slot) + + def free_many(self, *words): + for word in words: + self.free(word) + + def rollback(self, protected): + """Erase owned temporary roles on a rejecting path; capacity is fixed.""" + for slot in tuple(self.live): + if slot not in protected: + self.free(self.words[slot]) + for slot in protected: + self.words[slot].rewind() + + +class Unsigned: + def __init__(self, arena): + self.arena = arena + + def compare(self, a, b): + need(a.arena is b.arena is self.arena, "comparison word context") + if a is b: + return 0 + a.rewind() + b.rewind() + state = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + need(x in (ZERO, ONE) and y in (ZERO, ONE), "comparison binary digits") + if x != y: + state = 1 if x == ONE else -1 + a.step(1) + b.step(1) + need(b.read() == RIGHT, "equal comparison extents") + a.rewind() + b.rewind() + return state + + def add(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + carry = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + total = x+y+carry # Four finite carry states, not word arithmetic. + out.write(total & 1) + carry = total >> 1 + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal addition extents") + a.rewind() + b.rewind() + out.rewind() + return out, carry + + def subtract(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + borrow = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + digit = x-y-borrow # One finite borrow bit. + out.write(digit & 1) + borrow = int(digit < 0) + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal subtraction extents") + a.rewind() + b.rewind() + out.rewind() + return out, borrow + + def subtract_exact(self, a, b): + out, borrow = self.subtract(a, b) + need(not borrow, "unsigned subtraction precondition") + return out + + def shift_add_bit(self, a, bit): + need(bit in (ZERO, ONE), "one incoming bit") + out = self.arena.zero() + a.rewind() + carry = bit + while a.read() != RIGHT: + previous = a.read() + out.write(carry) + carry = previous + a.step(1) + out.step(1) + a.rewind() + out.rewind() + need(not carry, "reserved high-bit margin") + return out + + def divmod(self, numerator, denominator): + need(not denominator.zero(), "nonzero binary divisor") + # A zero high bit leaves room for 2*remainder+bit. + denominator.msb() + margin = denominator.read() + denominator.rewind() + need(margin == ZERO, "binary divisor has the high-bit margin") + scan = self.arena.copy(numerator) + quotient, remainder = self.arena.zero(), self.arena.zero() + scan.msb() + quotient.msb() + while scan.read() != LEFT: + shifted = self.shift_add_bit(remainder, scan.read()) + self.arena.free(remainder) + if self.compare(shifted, denominator) >= 0: + remainder = self.subtract_exact(shifted, denominator) + self.arena.free(shifted) + quotient.write(ONE) + else: + remainder = shifted + quotient.write(ZERO) + scan.step(-1) + quotient.step(-1) + scan.step(1) + quotient.step(1) + self.arena.free(scan) + return quotient, remainder + + def times_small(self, a, constant): + """Multiply by a fixed finite matrix/rank label; preserve the word margin.""" + need(0 <= constant <= 128, "finite index multiplier") + result = self.arena.zero() + for bit in tuple((constant >> i) & 1 for i in range(constant.bit_length()-1, -1, -1)): + doubled, carry = self.add(result, result) + need(not carry, "index multiplication margin") + self.arena.free(result) + if bit: + result, carry = self.add(doubled, a) + need(not carry, "index multiplication extent") + self.arena.free(doubled) + else: + result = doubled + return result + + def increment_in_place(self, word): + """Ripple increment for a bounded address counter; restore its head.""" + word.rewind() + while word.read() == ONE: + word.write(ZERO) + word.step(1) + need(word.read() == ZERO, "ripple increment has space") + word.write(ONE) + word.rewind() + + +class Ring: + """Canonical residues modulo an encoded M>1 with one leading zero bit.""" + def __init__(self, modulus): + self.modulus, self.arena = modulus, modulus.arena + self.raw = Unsigned(self.arena) + self.one = self.arena.literal(1) + try: + need(self.raw.compare(modulus, self.one) > 0, "modulus exceeds one") + modulus.msb() + margin = modulus.read() + modulus.step(-1) + significant = modulus.read() + modulus.rewind() + need(margin == ZERO and significant == ONE, "canonical modulus word with one high-bit margin") + except ValueError: + self.arena.free(self.one) + raise + + def close(self): + self.arena.free(self.one) + + def add(self, a, b): + total, carry = self.raw.add(a, b) + need(not carry, "canonical modular addition margin") + if self.raw.compare(total, self.modulus) >= 0: + out = self.raw.subtract_exact(total, self.modulus) + self.arena.free(total) + return out + return total + + def subtract(self, a, b): + if self.raw.compare(a, b) >= 0: + return self.raw.subtract_exact(a, b) + larger, carry = self.raw.add(a, self.modulus) + need(not carry, "canonical modular subtraction margin") + out = self.raw.subtract_exact(larger, b) + self.arena.free(larger) + return out + + def negate(self, a): + zero = self.arena.zero() + out = self.subtract(zero, a) + self.arena.free(zero) + return out + + def multiply(self, a, b): + if a.zero() or b.zero(): + return self.arena.zero() + if self.raw.compare(a, self.one) == 0: + return self.arena.copy(b) + if self.raw.compare(b, self.one) == 0: + return self.arena.copy(a) + scan = self.arena.copy(b) + result = self.arena.zero() + scan.msb() + while scan.read() != LEFT: + doubled = self.add(result, result) + self.arena.free(result) + if scan.read() == ONE: + result = self.add(doubled, a) + self.arena.free(doubled) + else: + result = doubled + scan.step(-1) + scan.step(1) + self.arena.free(scan) + return result + + def inverse(self, a): + """Euclid, with Bezout coefficients reduced modulo M; None for nonunits.""" + r0, r1 = self.arena.copy(self.modulus), self.arena.copy(a) + t0, t1 = self.arena.zero(), self.arena.copy(self.one) + while not r1.zero(): + quotient, r2 = self.raw.divmod(r0, r1) + if self.raw.compare(quotient, self.modulus) >= 0: + reduced = self.raw.subtract_exact(quotient, self.modulus) + self.arena.free(quotient) + quotient = reduced + product = self.multiply(quotient, t1) + t2 = self.subtract(t0, product) + self.arena.free_many(quotient, product, r0, t0) + r0, r1, t0, t1 = r1, r2, t1, t2 + unit = self.raw.compare(r0, self.one) == 0 + self.arena.free_many(r0, r1, t1) + if unit: + return t0 + self.arena.free(t0) + return None + + def literal(self, constant): + """Compile a fixed signed integer through binary modular operations.""" + negative = constant < 0 + magnitude = abs(constant) + result = self.arena.zero() + instructions = tuple((magnitude >> i) & 1 for i in range(magnitude.bit_length()-1, -1, -1)) + for bit in instructions: + doubled = self.add(result, result) + self.arena.free(result) + if bit: + result = self.add(doubled, self.one) + self.arena.free(doubled) + else: + result = doubled + if negative: + out = self.negate(result) + self.arena.free(result) + result = out + return result diff --git a/research/directory-producer-invoice/test_verify.py b/research/directory-producer-invoice/test_verify.py new file mode 100644 index 0000000000..1efdefcbe1 --- /dev/null +++ b/research/directory-producer-invoice/test_verify.py @@ -0,0 +1,315 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Bounded behavioral and mutation controls for the directory component. + +These tests exercise the submitted replay and package-local candidate. They do +not establish source-stock admission or recovery from malformed producer input. +""" +from contextlib import contextmanager +from copy import deepcopy +import hashlib +import importlib.util +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile + + +class TestFailure(Exception): + pass + + +def need(ok, message): + if not ok: + raise TestFailure(message) + + +def tree_bytes(root): + return {str(p.relative_to(root)): hashlib.sha256(p.read_bytes()).hexdigest() + for p in root.rglob('*') if p.is_file()} + + +def load_subject(root): + spec = importlib.util.spec_from_file_location('directory_invoice_subject', root / 'verify.py') + subject = importlib.util.module_from_spec(spec) + spec.loader.exec_module(subject) + return subject + + +@contextmanager +def candidate(subject, replacement): + original = subject.high_power_shared + subject.high_power_shared = replacement + try: + yield + finally: + subject.high_power_shared = original + + +def run_cli(root): + command = [sys.executable, '-I', '-B'] + if not __debug__: + command.append('-O') + return subprocess.run(command + [str(root / 'verify.py')], cwd=root, + capture_output=True, text=True) + + +class Controls: + def __init__(self): + self.rejected = [] + + def rejects(self, name, action): + try: + action() + except ValueError: + self.rejected.append(name) + return + except Exception as error: + raise TestFailure(name + ' crashed with ' + type(error).__name__ + ': ' + str(error)) from error + raise TestFailure(name + ' was accepted') + + def cli_rejects(self, name, root): + result = run_cli(root) + need(result.returncode != 0, name + ' CLI accepted the altered fixture') + need('FAIL_DIRECTORY_PRODUCER_COMPONENT' in result.stderr, + name + ' CLI did not report an explicit validation failure: ' + result.stderr[-500:]) + self.rejected.append(name) + + +def writable_copy(source, destination): + shutil.copytree(source, destination, copy_function=shutil.copyfile) + for path in destination.rglob('*'): + path.chmod(0o755 if path.is_dir() else 0o644) + destination.chmod(0o755) + + +def main(): + import argparse + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--package', type=Path, default=Path(__file__).resolve().parent) + args = parser.parse_args() + root = args.package.resolve() + before = tree_bytes(root) + subject = load_subject(root) + controls = Controls() + positives = [] + config = dict(name='test_d2', d=2, q=3, w=2, B=1, h=0, Q=4, I=3) + + # The first yield corresponds to the omitted leading radix digit. Every + # later yield must contribute exactly d² ordered q multiplications, and the + # iterator must be exhausted so its final validation runs. + class Value: + def __init__(self): + self.factors = [] + + def multiply_small(self, q): + self.factors.append(q) + + calls = [] + completed = [] + + def radix(_ring, q): + calls.append(q) + for _ in range(3): + yield + completed.append(True) + + value = Value() + subject.high_power_shared(value, object(), 3, 2, radix) + need(calls == [3] and completed == [True] and value.factors == [3] * 8, + 'shared candidate did not preserve one full traversal and ordered M(w-1) q multipliers') + positives.append('one complete radix traversal and ordered M(w-1) multipliers') + + def late_failure(_ring, _q): + yield + yield + raise ValueError('final radix validation sentinel') + + controls.rejects('omitted final radix validation', + lambda: subject.high_power_shared(Value(), object(), 3, 2, late_failure)) + + def no_first_skip(value, ring, q, dimension, radix_power): + for _ in radix_power(ring, q): + for _ in range(dimension * dimension): + value.multiply_small(q) + + def missed_M(value, ring, q, dimension, radix_power): + first = True + for _ in radix_power(ring, q): + if first: + first = False + else: + value.multiply_small(q) + + def wrong_multiplier(value, ring, q, dimension, radix_power): + first = True + for _ in radix_power(ring, q): + if first: + first = False + else: + for _ in range(dimension * dimension): + value.multiply_small(q + 1) + + def missing_one_coordinate(value, ring, q, dimension, radix_power): + first = True + for _ in radix_power(ring, q): + if first: + first = False + else: + for _ in range(dimension * dimension - 1): + value.multiply_small(q) + + for name, mutant in ( + ('missing first-yield skip', no_first_skip), + ('missed d-squared multiplier count', missed_M), + ('wrong q multiplier', wrong_multiplier), + ('omitted one coordinate multiplier', missing_one_coordinate), + ): + with candidate(subject, mutant): + controls.rejects(name, lambda: subject.run_case(config, candidate=True)) + + cap_one = dict(name='test_complete_radix_cap1', d=2, q=3, w=1, B=1, h=0, Q=4, I=3) + + def no_radix(value, ring, q, dimension, radix_power): + return + + def incomplete_radix(value, ring, q, dimension, radix_power): + iterator = radix_power(ring, q) + next(iterator) + iterator.close() + + for name, mutant in ( + ('all radix validation skipped despite cap1 output match', no_radix), + ('final radix validation skipped despite cap1 output match', incomplete_radix), + ): + with candidate(subject, mutant): + controls.rejects(name, lambda: subject.run_case(cap_one, candidate=True)) + + # Successful valid inputs contain physically repeated empty prefixes. B is + # still a multiplicity even though the borrowed old tape has no body bytes. + repeated = dict(name='duplicate_empty_prefix', d=1, q=3, w=2, B=3, h=0, Q=4, I=3) + original = subject.run_case(repeated) + shared = subject.run_case(repeated, candidate=True) + need(original['geometry']['old_body'] == 0 and original['returned_prefix_count'] == 9, + 'empty-prefix physical multiplicity was collapsed') + need(original['output_sha256'] == shared['output_sha256'] and shared['returned_prefix_count'] == 9, + 'candidate changed duplicate-empty-prefix enumeration') + positives.append('B=3 empty-prefix physical multiplicity on original and shared producer') + + original_shared = subject.high_power_shared + + def corrupt_one(value, ring, q, dimension, radix_power): + original_shared(value, ring, q, dimension, radix_power) + ring.one.cells[1] ^= 1 + + def move_one_head(value, ring, q, dimension, radix_power): + original_shared(value, ring, q, dimension, radix_power) + ring.one.head = 2 + + def corrupt_modulus(value, ring, q, dimension, radix_power): + original_shared(value, ring, q, dimension, radix_power) + ring.modulus.cells[1] ^= 1 + + for name, mutant in ( + ('borrowed ring-one bytes changed', corrupt_one), + ('borrowed ring-one head changed', move_one_head), + ('borrowed modulus bytes changed', corrupt_modulus), + ): + with candidate(subject, mutant): + controls.rejects(name, lambda: subject.run_case(config, candidate=True)) + + def corrupt_returned_borrowed(selector, change): + def install(_old, sources): + producer = sources.directory.produce + + def altered(old, fields, old_count, code, context): + result = producer(old, fields, old_count, code, context) + change(selector(fields, context)) + return result + + sources.directory.produce = altered + return install + + def spectator(arena): + words = [arena.words[slot] for slot in arena.live if arena.words[slot].head == 2] + need(len(words) == 1, 'expected one protected unrelated spectator at head2') + return words[0] + + for name, selector, change in ( + ('borrowed field-count bytes changed', lambda fields, context: fields, + lambda word: word.cells.__setitem__(1, word.cells[1] ^ 1)), + ('borrowed Context-highs bytes changed', lambda fields, context: context.highs.tape, + lambda tape: tape.cells.__setitem__(1, tape.cells[1] ^ 1)), + ('borrowed cap head changed', lambda fields, context: context.cap, + lambda word: setattr(word, 'head', 2)), + ('unrelated residue spectator bytes changed', lambda fields, context: spectator(context.arena), + lambda word: word.cells.__setitem__(1, word.cells[1] ^ 1)), + ('unrelated index spectator bytes changed', lambda fields, context: spectator(fields.arena), + lambda word: word.cells.__setitem__(1, word.cells[1] ^ 1)), + ('borrowed Context-highs head changed', lambda fields, context: context.highs.tape, + lambda tape: setattr(tape, 'head', 2)), + ('protected residue template head changed', lambda fields, context: context.arena.template, + lambda word: setattr(word, 'head', 2)), + ): + controls.rejects(name, lambda selector=selector, change=change: + subject.run_case(config, candidate=True, + alter_old=corrupt_returned_borrowed(selector, change))) + + controls.rejects('boolean candidate flag', lambda: subject.run_case(config, candidate=1)) + bad_config = deepcopy(config) + bad_config['d'] = True + controls.rejects('boolean dimension', lambda: subject.run_case(bad_config)) + + # Receipt and byte-authentication checks use a fresh writable copy, so this + # suite also runs against a read-only exported package. + with tempfile.TemporaryDirectory(prefix='directory-invoice-negative-') as directory: + fixture = Path(directory) / 'package' + writable_copy(root, fixture) + baseline = run_cli(fixture) + need(baseline.returncode == 0 and 'PASS_DIRECTORY_PRODUCER_COMPONENT' in baseline.stdout, + 'unaltered copied CLI fixture failed: ' + baseline.stderr[-500:]) + positives.append('unaltered complete typed receipt accepted by copied CLI') + marker = Path(directory) / 'source-was-executed' + source = fixture / 'source/words.py' + raw = source.read_bytes() + source.write_bytes(raw + ('\nopen(' + repr(str(marker)) + ', "w").write("executed")\n').encode()) + controls.cli_rejects('source bytes authenticated before execution', fixture) + need(not marker.exists(), 'tampered source was executed before authentication') + source.write_bytes(raw) + sibling = Path(directory) / 'same-words.py' + sibling.write_bytes(raw) + source.unlink() + source.symlink_to(sibling) + controls.cli_rejects('symlink source substitution', fixture) + source.unlink() + source.write_bytes(raw) + + receipt = fixture / 'RESULT.json' + receipt_bytes = receipt.read_bytes() + data = json.loads(receipt_bytes) + forged = deepcopy(data) + forged['schema_version'] = True + receipt.write_text(json.dumps(forged) + '\n') + controls.cli_rejects('boolean receipt schema', fixture) + receipt.write_text('{"schema_version":1,"schema_version":1,"cases":' + json.dumps(data['cases']) + + ',"scope":' + json.dumps(data['scope']) + '}\n') + controls.cli_rejects('duplicate receipt JSON key', fixture) + forged = deepcopy(data) + forged['cases'][1]['saved_residue_actions']['reads'] -= 1 + receipt.write_text(json.dumps(forged) + '\n') + controls.cli_rejects('undercounted complete d-squared-minus-one saving', fixture) + + need(tree_bytes(root) == before, 'the package under test changed') + print('PASS_DIRECTORY_INVOICE_TESTS ' + json.dumps( + {'positive_controls': len(positives), 'expected_rejections': len(controls.rejected), + 'positive_names': positives, 'rejection_names': controls.rejected, + 'package_bytes_unchanged': True, 'optimized': not __debug__}, sort_keys=True)) + + +if __name__ == '__main__': + try: + main() + except TestFailure as error: + raise SystemExit('FAIL_DIRECTORY_INVOICE_TESTS ' + str(error)) diff --git a/research/directory-producer-invoice/verify.py b/research/directory-producer-invoice/verify.py new file mode 100644 index 0000000000..614e57282c --- /dev/null +++ b/research/directory-producer-invoice/verify.py @@ -0,0 +1,285 @@ +#!/usr/bin/env python3 +"""Meter the frozen directory producer, including all Count/Counter tape work. + +Apache-2.0. ToikY with substantial OpenAI Codex assistance. The six canonical +source files implement the object under review; no source bytes are changed. +Setup supplies an already valid Context. No full source/specification/stock +admission or physical finite-state tariff is inferred from this component. +""" +from __future__ import annotations +from contextlib import contextmanager +import hashlib +import itertools +import json +from pathlib import Path +import sys +import types + +HERE=Path(__file__).resolve().parent +PINS={ + 'CALLER.py':('7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a','5a032e8923f7f8b22bb98f3e39b804beb9906c16'), + 'NOTICE.md':('c446b32b8a621844fb2fbe654810c8122035bdd43fed2132f1137d98cb6f9943','ef9f81510db86eaf2f0a7191d85e92a6db30ddc0'), + 'cardinality.py':('505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22','b8ba857e32c5903408e1e61ff916300848b4a208'), + 'counts.py':('00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069','81b48940ce222290a40d4fb349ce827f4788469d'), + 'directory.py':('4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7','c74cacf5ce809c0561d374f137a52df0992b4226'), + 'records.py':('0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372','4f00467a0ff580954ad2fd0c7380240c753ddef3'), + 'stream.py':('c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5','5e5a4bb0f98971447043e25d4dd6991bfc070389'), + 'words.py':('5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9','8d4ba37e2778acb35b34e0719df2caf138fbeb50'), +} +CASES=( + {'name':'small_h0','d':1,'q':3,'w':2,'B':3,'h':0,'Q':4,'I':3}, + {'name':'small_h1','d':2,'q':3,'w':2,'B':2,'h':1,'Q':4,'I':3}, + {'name':'small_h2','d':2,'q':3,'w':2,'B':1,'h':2,'Q':5,'I':4}, + {'name':'binary_long_carry','d':1,'q':2,'w':4,'B':3,'h':0,'Q':3,'I':3}, + {'name':'binary_nine_digits','d':3,'q':2,'w':2,'B':1,'h':1,'Q':3,'I':3}, + {'name':'radix5_history2','d':1,'q':5,'w':2,'B':2,'h':2,'Q':4,'I':4}, + {'name':'dimension64_cap1','d':64,'q':3,'w':1,'B':1,'h':1,'Q':6507,'I':4}, +) + + +def need(condition,message): + if not condition:raise ValueError(message) + + +def canonical(value):return json.dumps(value,sort_keys=True,separators=(',',':')) + +def digest(raw):return hashlib.sha256(raw).hexdigest() + +def no_duplicate_keys(pairs): + result={} + for key,value in pairs: + need(key not in result,'duplicate receipt key: '+key) + result[key]=value + return result + +def load_receipt(path=None): + return json.loads((HERE/'RESULT.json' if path is None else Path(path)).read_text(),object_pairs_hook=no_duplicate_keys) + + +def authenticate(): + for name,(sha,blob) in PINS.items(): + path=HERE/'source'/name + need(not path.is_symlink(),'source symlink: '+name) + raw=path.read_bytes() + need(digest(raw)==sha,'source bytes: '+name) + need(hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()==blob, + 'source Git blob: '+name) + + +@contextmanager +def sources(): + authenticate() + names=('words','records','stream','cardinality','counts','directory') + saved={name:sys.modules.get(name) for name in names} + modules={} + try: + for name in names: + module=types.ModuleType(name);module.__file__=str(HERE/'source'/(name+'.py')) + sys.modules[name]=module + exec(compile((HERE/'source'/(name+'.py')).read_bytes(),module.__file__,'exec'),module.__dict__) + modules[name]=module + yield types.SimpleNamespace(**modules) + finally: + for name,value in saved.items(): + if value is None:sys.modules.pop(name,None) + else:sys.modules[name]=value + + +def actions(meter):return {key:getattr(meter,key) for key in ('reads','writes','moves')} + +def difference(after,before):return {key:after[key]-before[key] for key in after} + +def sum_actions(rows):return {key:sum(row[key] for row in rows) for key in ('reads','writes','moves')} + + +def field_bytes(code,digits,Q,L): + return bytes([(code>>i)&1 for i in range(Q)]+[5]+ + [bit for value in digits for bit in [(value>>i)&1 for i in range(L)]+[5]]+[6]) + + +def decode_count(value): + raw=bytes(value.tape.cells) + end=raw.index(3,1) + return sum(bit<<(i-1) for i,bit in enumerate(raw[1:end],1)) + + +def high_power_shared(value,ring,q,dimension,radix_power): + first=True + for _ in radix_power(ring,q): + if first: + first=False + else: + for _ in range(dimension*dimension): + value.multiply_small(q) + + +def run_case(config,candidate=False,alter_old=None,alter_code=None): + need(isinstance(config,dict),'case schema') + need(type(candidate) is bool,'candidate mode') + d,q,w,B,h,Q,I=(config[k] for k in ('d','q','w','B','h','Q','I')) + need(all(type(x) is int for x in (d,q,w,B,h,Q,I)) and + d>0 and q>=2 and w>=1 and B>=1 and h>=0 and Q>=2 and I>=max(2,h.bit_length()+1),'case domain') + M=d*d;modulus=q**w;c=q**(w-1);H=c**M;L=modulus.bit_length()+1 + need(H<=10000,'bounded fixture output enumeration; no full nontrivial GL64 lift') + F=Q+2+M*(L+1) + with sources() as S: + registry=[] + original_init=S.records.Tape.__init__;original_step=S.records.Tape.step + def tape_init(tape): + original_init(tape);tape.audit_max_head=1;registry.append(tape) + def tape_step(tape,direction): + original_step(tape,direction);tape.audit_max_head=max(tape.audit_max_head,tape.head) + S.records.Tape.__init__=tape_init;S.records.Tape.step=tape_step + arena=S.words.Arena(L,capacity=M+64);indices=S.words.Arena(I,capacity=16) + ring=S.words.Ring(arena.literal(modulus)) + vocabulary=types.SimpleNamespace(q=q,dimension=d,bits=Q,limit=1<