From 13193a22b1070a74a8580c5d3ea27470443f815a Mon Sep 17 00:00:00 2001 From: CubeJerry <80299683+CubeJerry@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:46:25 +0800 Subject: [PATCH] research: execute current scalar services as literal finite tables --- .../current-scalar-flat-tables/.gitignore | 2 + .../DEPENDENCIES.json | 32 + .../PR-DESCRIPTION.md | 89 +++ research/current-scalar-flat-tables/PROOF.md | 307 ++++++++ research/current-scalar-flat-tables/README.md | 108 +++ .../current-scalar-flat-tables/RESULT.json | 699 ++++++++++++++++++ .../current-scalar-flat-tables/SOURCES.json | 30 + research/current-scalar-flat-tables/TASK.json | 93 +++ .../VERIFICATION.md | 105 +++ .../current-scalar-flat-tables/VERIFY.json | 108 +++ .../check_controls.py | 128 ++++ .../evidence/TIMINGS.json | 8 + .../evidence/normal-arithmetic.log | 2 + .../evidence/normal-binding.log | 2 + .../evidence/normal-controller.log | 2 + .../evidence/normal-controls.log | 2 + .../evidence/registered-replay.log | 25 + .../current-scalar-flat-tables/physical.py | 136 ++++ .../source_binding.py | 35 + research/current-scalar-flat-tables/tables.py | 295 ++++++++ .../vendor/lifecycle/machine.py | 406 ++++++++++ .../vendor/lifecycle/source_ir.py | 522 +++++++++++++ .../vendor/stack.py | 170 +++++ research/current-scalar-flat-tables/verify.py | 194 +++++ 24 files changed, 3500 insertions(+) create mode 100644 research/current-scalar-flat-tables/.gitignore create mode 100644 research/current-scalar-flat-tables/DEPENDENCIES.json create mode 100644 research/current-scalar-flat-tables/PR-DESCRIPTION.md create mode 100644 research/current-scalar-flat-tables/PROOF.md create mode 100644 research/current-scalar-flat-tables/README.md create mode 100644 research/current-scalar-flat-tables/RESULT.json create mode 100644 research/current-scalar-flat-tables/SOURCES.json create mode 100644 research/current-scalar-flat-tables/TASK.json create mode 100644 research/current-scalar-flat-tables/VERIFICATION.md create mode 100644 research/current-scalar-flat-tables/VERIFY.json create mode 100644 research/current-scalar-flat-tables/check_controls.py create mode 100644 research/current-scalar-flat-tables/evidence/TIMINGS.json create mode 100644 research/current-scalar-flat-tables/evidence/normal-arithmetic.log create mode 100644 research/current-scalar-flat-tables/evidence/normal-binding.log create mode 100644 research/current-scalar-flat-tables/evidence/normal-controller.log create mode 100644 research/current-scalar-flat-tables/evidence/normal-controls.log create mode 100644 research/current-scalar-flat-tables/evidence/registered-replay.log create mode 100644 research/current-scalar-flat-tables/physical.py create mode 100644 research/current-scalar-flat-tables/source_binding.py create mode 100644 research/current-scalar-flat-tables/tables.py create mode 100644 research/current-scalar-flat-tables/vendor/lifecycle/machine.py create mode 100644 research/current-scalar-flat-tables/vendor/lifecycle/source_ir.py create mode 100644 research/current-scalar-flat-tables/vendor/stack.py create mode 100644 research/current-scalar-flat-tables/verify.py diff --git a/research/current-scalar-flat-tables/.gitignore b/research/current-scalar-flat-tables/.gitignore new file mode 100644 index 0000000000..7a60b85e14 --- /dev/null +++ b/research/current-scalar-flat-tables/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/research/current-scalar-flat-tables/DEPENDENCIES.json b/research/current-scalar-flat-tables/DEPENDENCIES.json new file mode 100644 index 0000000000..e01676c6b2 --- /dev/null +++ b/research/current-scalar-flat-tables/DEPENDENCIES.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "files": [ + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "ab239cb6ee884e7a900dd9101c34448077fad0b0", + "original_path": "research/compiled-owned-bank-lifecycle/machine.py", + "local_path": "vendor/lifecycle/machine.py", + "git_blob": "acf475e4fccaff2fb64bd5b0b3f3fc0d246dc592", + "bytes": 14932, + "sha256": "ec597bce13275003ff30e4be481c936401826c1d4af642b55eec0c410774d1df" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "ab239cb6ee884e7a900dd9101c34448077fad0b0", + "original_path": "research/compiled-owned-bank-lifecycle/source_ir.py", + "local_path": "vendor/lifecycle/source_ir.py", + "git_blob": "79c95fa79439f3c893de52991173bd3a5eae2729", + "bytes": 27393, + "sha256": "54dd93bc50bd10e974c70794df1c13da27f0e3d8cdb6cfe6791a63280096f1b1" + }, + { + "repository": "CrocSwap/integer-mult-bounds", + "commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "original_path": "research/delimited-continuation-stack/stack.py", + "local_path": "vendor/stack.py", + "git_blob": "a5d6753b901901a5b2d1a4dd72134e53af70c666", + "bytes": 5657, + "sha256": "21a2213aa850c55e5eace4cd10b72b958d7ee84d83a014567902ce8ee9b3f4f2" + } + ] +} diff --git a/research/current-scalar-flat-tables/PR-DESCRIPTION.md b/research/current-scalar-flat-tables/PR-DESCRIPTION.md new file mode 100644 index 0000000000..5528ef88ec --- /dev/null +++ b/research/current-scalar-flat-tables/PR-DESCRIPTION.md @@ -0,0 +1,89 @@ +## Result + +**No new κ.** This package gives actual fixed finite ADD/SCALE transition +tables for the current three-bit coded lifecycle ABI. They execute through +the unchanged published `execute_table` and `Controller.primitive`, with no +runtime numerical callback or decoded length. The all-width theorem accepts +exactly the common-grid outputs that fit the original signed word, stages the +entire field before target writes, preserves borrowed sources, returns heads +and physically erases its two work tapes on success. + +This supplies one concrete missing scalar-provider implication in the current +compiler/owned-lifecycle composition. It covers 366,842 original ADD/SCALE +occurrences in the exact 642,410-event selected caller, using 42 tables with +58,544 rows. It does not discharge the five assumptions as a whole or improve +the selected conditional κ = 0.003125804. + +## Why this is new + +CrocSwap/integer-mult-bounds#3098 already executes inherited scalar recipes on +aligned sequential packets and leaves their actual caller/owner binding open. +This package binds the current exact source tokens and ordered owners to +tables accepted by the newer coded lifecycle, with complete copying, head +return, backing and erasure costs. It also removes recipe-specific temporary +headroom requirements: four-bit SCALE(-1/2) accepts -8 → +4, and ADD(2) accepts +(-7,+7) → +7, without storing either overflowing intermediate word. + +The 31-coefficient/denominator-16 census is credited to +CrocSwap/integer-mult-bounds#6928 and is not claimed anew. The general fixed +rational theorem does not prove the unfinished-context grid condition of +CrocSwap/integer-mult-bounds#6932 or CrocSwap/integer-mult-bounds#6934. + +## Exact sources + +- Canonical base: `7c49fe32c55de02c2c873655c804b16e4c3fef0a`. +- Selected local word from CrocSwap/integer-mult-bounds#6030 and the original + productive controller, pinned by Git blob and SHA256 in `SOURCES.json`. +- Unchanged [published lifecycle machine and source compiler](https://github.com/CubeJerry/integer-mult-bounds/tree/ab239cb6ee884e7a900dd9101c34448077fad0b0/research/compiled-owned-bank-lifecycle), + pinned in `DEPENDENCIES.json` at + `ab239cb6ee884e7a900dd9101c34448077fad0b0`. +- Unchanged CrocSwap/integer-mult-bounds#5356 physical continuation source. + +## Verification + +```sh +python3 -B scripts/research_package.py --package research/current-scalar-flat-tables +``` + +The manifest registers eight bounded normal/optimized checks, with exact +committed receipts. The physical oracle covers all 10,870 width-1-through-4 +signed cases for the actual table catalogue, wider complete fields through +width 129, and 400 additional rational cases. A real unchanged-controller +fixture executes the complete initial scalar block at source events 1..9895 +on 799 coded fields, totaling 41,088,794 physical cell actions, and compares +every endpoint to a separate exact Fraction interpretation. + +Twenty-five controls detect arithmetic, shape, source, alias and erasure +failures, including mutants of the final-carry sign and sign extension. An +independent lead AI mathematical audit derived the terminal equation and +checked a separate 14,260-case integer-digit/Fraction domain. It is described +separately from physical executor tests in `VERIFICATION.md`. The all-size +proof is in `PROOF.md`; finite tests do not establish it alone. + +## Limits and next obligations + +Successful execution requires aligned complete operands on the same grid and +the stated final signed range. Source owner maps and original lifecycle +contracts remain premises. Arithmetic rejection preserves public contents but +can leave heads advanced and work occupied; no physical rollback is claimed. + +The positive complete scalar bill is `O_q(V+D+Q)`, with two used work tapes and +current backing at most `2V+3+O(1)`; retained erased history remains counted. +This does not certify the complete old numerical allowance. Native maps, +row/recursive services, whole-caller precision/error returns, global ownership +and analytic recovery remain open composition obligations. + +## Credit and assistance + +Prepared for **@CubeJerry**, with substantial OpenAI assistance in mathematics, +implementation, source analysis and checking. Prior credit is preserved for +Jose Manuel/jmbarrancoml (CrocSwap/integer-mult-bounds#3098), Nick Petalas +(CrocSwap/integer-mult-bounds#3078 and CrocSwap/integer-mult-bounds#3090), +Sagar Thakrar (CrocSwap/integer-mult-bounds#696), James Chang +(CrocSwap/integer-mult-bounds#1869), the encoded arithmetic of +CrocSwap/integer-mult-bounds#3091, Ali Romman's productive caller/continuation +work, DreamingOfClouds' selected word, Mark/Matarener's occurrence sources, +and the retained native/compiler/lifecycle lineage. The geometry and precision +work in CrocSwap/integer-mult-bounds#6878, CrocSwap/integer-mult-bounds#6900 and +CrocSwap/integer-mult-bounds#6901 retains its scope and credit. Separate AI +review is not independent human or proof-kernel admission. diff --git a/research/current-scalar-flat-tables/PROOF.md b/research/current-scalar-flat-tables/PROOF.md new file mode 100644 index 0000000000..2469f719ad --- /dev/null +++ b/research/current-scalar-flat-tables/PROOF.md @@ -0,0 +1,307 @@ +# Current scalar SERVICE tables on complete coded fields + +Prepared for **@CubeJerry**, with substantial OpenAI assistance. Apache-2.0. +This is a source-bound physical implementation lemma. **No new κ.** + +## 1. Exact claim and boundary + +For each fixed nonzero rational coefficient q, `tables.compile_scalar` emits a +finite table in the **unchanged** `machine.execute_table` grammar of the +published `compiled-owned-bank-lifecycle` source. The only runtime instructions +are branch on one local symbol, write one local symbol, unit move, goto, halt +and reject. The generator runs before numerical input size varies. No runtime +integer, coordinate, component width, record count or payload callback is +supplied to the resulting table. + +For SCALE the ordered public ports are `(target)`. For ADD they are +`(target,source)`, on **distinct physical tapes**. There are two work ports: +protected candidate output and unary rewind guide. Any additional supplied +work and binary-context ports are untouched by the table. The unchanged +`Controller.primitive` supplies entry retirement, `execute_table`, and success +retirement on its complete fixed work inventory. + +Each input is a nonempty complete complex field on one common numerical grid. +One complex record has two signed little-endian two's-complement components, +each of width w>=1 followed by virtual delimiter 2. The source and target have +the same complete ordered shape. A virtual symbol occupies the lifecycle's +three nonblank physical bits. The physical blank frontier immediately follows +the last complete component: no coded logical blank or private tail belongs to +the public field. All supplied public, work and context heads begin at their +current origins. Each initially dirty work body is one contiguous raw binary +prefix ending at a physical blank, as required by the inherited `retire`; +there are no hidden live bytes beyond an interior blank. Work and context +segments are distinct from every public field and ancestor segment. + +**Theorem (exact success domain).** For every width and record count, the table +succeeds exactly when every component of the requested scalar output is an +integer on that same grid and lies in the original signed width. On success, + +* SCALE returns q*x and ADD returns x+q*y, component by component; +* every public field has precisely its original physical extent and delimiter + positions; the ADD source is unchanged; +* the table performs no target write until the complete field has passed all + arithmetic/shape checks; +* the original table executor restores all supplied heads, and the original + primitive wrapper physically erases all work bodies before return; +* fixed-tape time is O_q(V+D+Q), with two used work tapes, where V is one + complete coded field's physical length, D is the total initially occupied + current work prefix, and Q is the fixed caller work/context inventory. + +The result does not require the product q*y or an implementation-specific +numerator to fit a temporary signed word. It never materializes such a word. +The finite carry belongs to the precompiled control, whose size depends on q +and not on w or the number of records. + +The exact current sources instantiate this theorem at all 366,842 original +ADD/SCALE service occurrences of the selected complete caller. Their 42 +operation/coefficient pairs use only 31 distinct coefficients. COPY remains +the lifecycle's original addition; two-output SWAP/SIGNED_SWAP and native +phase, movement, Gaussian and recursive services remain separate. + +## 2. Integer relation and the finite carry + +Write q=a/b in lowest terms, b=2^d*b0, b0 positive odd. The required relation is + + 2^d*b0*z = p*x + r*y, + +where `(p,r)=(a,0)` for SCALE and `(p,r)=(b,a)` for ADD. In the one-input case +y is the finite constant zero, not an allocated numerical word. + +Read the w bits of each input least-significant first and remember their last +bits sx,sy in finite control. Continue with **exactly d sign-extension bits** +sx,sy, even when w=d, emit + + z_(i-d) = u mod 2, + c_(i+1) = (u-b0*z_(i-d))/2. + +The division is integral because b0 is odd. Negative carries use the same +integer equalities and nonnegative parity bit; there is no unsigned +reinterpretation of a negative component. Exactly w output bits are emitted: +there are w+d input positions and precisely d discarded positions. For w=0 and L>=1. Extra untouched fixed ports cost O(Q); a dirty initial raw work +prefix of D cells costs O(D) to erase. These positive terms are retained. + +The candidate output occupies at most V cells and the guide at most V+3. +Two used work tapes therefore suffice with current-call backing at most +`2V+3+O(1)`, plus the public inputs and any separate caller inventory. For +reuse histories each tape retains its maximum reached coordinate. A smaller +later call begins at a blank current origin and scans its own new body, not +an old erased high-water interval. This gives the coordinatewise maximum bound +`max(previous backing, current extent)`; no deletion of visited cells is assumed. +When these ports are parked by the existing lifecycle, its original ancestor +and allocation theorem remains the explicit composition premise. + +For a fixed compiled template with arithmetic services E, the complete added +bill is the positive sum of these per-service bounds, using each actual +field length V_e and initial dirt D_e. Finite source compilation, tables and +coefficient constants are independent of input size. Thus these services cost +linear current volume per ordinary node and do not alter paid recursive +histograms or productive targets. This does not certify the historical raw +`10^9` numerical allowance: exact machine constants, other providers and the +outer admission must still be joined and priced. + +## 5. Binding to actual current source events + +`SOURCES.json` pins canonical main +`7c49fe32c55de02c2c873655c804b16e4c3fef0a`, its selected #6030 word and the +complete P104 controller. `DEPENDENCIES.json` pins byte-identical published +lifecycle machine and `source_ir` exports at +`ab239cb6ee884e7a900dd9101c34448077fad0b0`. Those source bytes are unchanged. + +The original lowerer supplies the exact local operands and caller field maps. +It preserves local instruction tokens under chronological products, caller +occurrences and the finite compiler's `unit-fragment` remapping. The new +`source_literal` follows the exact source remapping wrapper grammar to the +active original token, authenticating its exact source instruction, operation, +coefficient and arity. In `product-right`, the separate issuing PAID token is +provenance; only the last member is the active instruction. Searching all +nested tuples would confuse these two roles. It uses the emitted +ordered fields as the actual ports, rather than replacing them by the old +local role numbers. Duplicate binary ports are rejected. + +Boundary ADD/SCALE instructions are authenticated against their actual source +program; physical outer ADDs against their exact site; query additions against +the actual forward QUERY_SHEAR record. No whole-job normalizer, two-output +swap or native/paid event is reinterpreted as a scalar. The complete source +partition is: + +| Covered original scalar service | Occurrences | +| --- | ---: | +| 18 copies of the local ADD/SCALE word | 346,770 | +| Outer scalar ADDs | 9,360 | +| Left boundary ADD/SCALE | 6,240 | +| Right boundary ADD/SCALE | 2,912 | +| Forward query accumulation ADD | 1,560 | +| Total | 366,842 | + +The 18,404 local ADDs, 861 SCALEs and 23 separate COPYs agree with the source; +the 31-coefficient/denominator-16 census is already reported by #6928 and is +credited rather than claimed anew. The contribution is the actual executable +table binding, its exact success domain and complete tape accounting. + +Assume the source occurrence/geometry theorem gives each scalar its actual +aligned complete operands, and the current ideal precision theorem supplies +exact integer-grid outputs and the common signed range at these cuts. The +theorem above then discharges the physical scalar-table premise for every +covered service, including arbitrarily correlated values and all spectators. +Induction through its actual chronological service sites preserves their +endpoints without a scalar numerical callback. This substitution does not +prove those geometry or precision premises, native returns, row dispatch, +recursive termination, global ownership, or analytic recovery. + +## 6. Novelty, evidence and open obligations + +PR #3098 (`physical-scalar-stream`, Jose Manuel/jmbarrancoml) already proves +linear sequential execution of inherited scalar recipes on aligned packets, +with finite local word roles and explicit lifecycle. It leaves actual caller +alignment and owner binding open. It credits Nick Petalas's #3078/#3090, +Sagar Thakrar's #696, James Chang's #1869 and #3091. Their arithmetic and +ownership contributions are retained. This package supplies the current +coded ABI and actual finite-table/source join. The endpoint-complete fused +transducer also avoids recipe-specific temporary-word rejection conditions. +It does not rerun or replace their whole-provider theorem. + +The exact Fraction oracle checks small full signed domains and complete wider +fields through the original physical table executor. The actual Controller +fixture executes the uninterrupted current scalar block at source events +1..9895 on 799 borrowed fields after the source's INIT(778) boundary; it starts +that owned operand at zero and compares every returned component. This is a +source prefix, not a complete native caller. The complete 642,410-event source +scan binds the covered services and leaves every other opcode untouched. +Finite evidence is not the quantified proof in Sections 1–5. + +Open next questions are the current Gaussian/phase and recursive numerical +providers, complete compiler/row/lifecycle composition, and the successful +whole-caller precision/cost join. The optional odd-denominator primitive does +not discharge the new rational-grid obligation in #6932/#6934. All five +selected assumptions remain in force; the selected κ stays 0.003125804. diff --git a/research/current-scalar-flat-tables/README.md b/research/current-scalar-flat-tables/README.md new file mode 100644 index 0000000000..4c12f9d1c6 --- /dev/null +++ b/research/current-scalar-flat-tables/README.md @@ -0,0 +1,108 @@ +# Current ADD/SCALE services as executable finite tables + +Prepared for **@CubeJerry**, with substantial OpenAI assistance. **No new κ.** + +This package supplies actual finite tables for the original ADD/SCALE services +of the current selected caller. They execute through the unchanged published +owned-lifecycle `execute_table` and `Controller.primitive`, on the current +three-bit coded signed-component format. There is no runtime numerical callback, +decoded field length or host integer arithmetic in the generated table. + +For each fixed rational coefficient, the table accepts exactly those complete +fields whose requested outputs are integral on the common grid and fit the +original signed width. It stages the whole field before writing its target, +preserves the ADD source and component delimiters, and returns with physically +blank work under the original success wrapper. It uses two work ports and +linear complete-field time, including source access, staging, guided rewinds, +output installation, head return and erasure. + +This removes recipe-specific temporary-word headroom conditions. For example, +four-bit SCALE(-1/2) accepts -8 and returns +4 without an overflowing temporary ++8; four-bit ADD(2) accepts target -7 and source +7 and returns +7. The written +finite-carry proof supplies the all-width statement. These finite examples +are discriminating checks, not its justification. + +## Current source coverage + +Canonical base: `7c49fe32c55de02c2c873655c804b16e4c3fef0a`. +The selected certificate stays **κ = 0.003125804**, with all five assumptions. + +The actual 642,410-event lowerer output contains **366,842 covered scalar +services**: 346,770 local, 9,360 outer, 6,240 left boundary, 2,912 right +boundary and 1,560 forward-query additions. There are **42 operation/coefficient +pairs**, represented by 58,544 finite table rows. The 31 distinct coefficient +values and denominator-16 census already appear in +[#6928](https://github.com/CrocSwap/integer-mult-bounds/pull/6928). +COPY, two-output swaps, native maps and paid jobs retain their separate sources +and charges. Actual field mappings come from the authenticated lowerer; the +scalar binder does not replace them by old local role numbers. + +The concrete controller replay executes source events **1..9895**, the entire +first uninterrupted scalar block after INIT(778), on **799 complete coded +fields**. It uses 11-bit signed components, executes **41,088,794 physical cell +actions**, preserves its borrowed context and compares every endpoint with a +separate exact Fraction interpretation. This is a source prefix, not a full +native caller or production-size execution. + +## Verification and limits + +The bounded physical oracle checks all 10,870 width-1-through-4 signed cases +for the current catalogue, with 2,887 accepted and 7,983 correctly rejected. +Additional complete fields reach width 129. Four hundred extra rational cases +check the generic odd-denominator primitive independently of the concrete +dyadic-source application. Negative controls cover signed overflow, inexact +division, short widths, malformed codewords and component shapes, owner aliases, +source-token corruption, the final-carry sign, missing sign extension, omitted +raw retirement and retained backing after a shrinking call. + +The common input format, actual geometric alignment and successful precision +cuts remain explicit premises. The whole-field staging preserves public +contents on arithmetic rejection, but the inherited exception path can leave +heads advanced and work occupied. Rejection rollback is not claimed. + +The complete successful bill is `O_q(V+D+Q)`: V is one field's physical size, +D is initially occupied current work, and Q is the fixed supplied inventory. +Current work backing is at most `2V+3+O(1)` plus explicit caller storage; erased +historical backing remains counted. This is a positive scalar-service bill, +not validation of the old raw numerical allowance or an improved full exponent. + +## Reproduce + +Python 3.12, standard library only, from the repository root: + +```sh +python3 -B scripts/research_package.py --package research/current-scalar-flat-tables +``` + +`VERIFY.json` registers normal and optimized arithmetic, complete source binding, +actual controller-prefix and failure-control suites. Expected final marker: +`PASS_REGISTERED_RESEARCH_PACKAGE`. Exact receipts and execution/review scope +are in [RESULT.json](RESULT.json) and [VERIFICATION.md](VERIFICATION.md). +[PROOF.md](PROOF.md) contains the quantified theorem, carry equations, complete +cost and source composition argument. + +## Predecessors and attribution + +[#3098](https://github.com/CrocSwap/integer-mult-bounds/pull/3098), Jose Manuel +(`jmbarrancoml`), already executes inherited recipes on aligned sequential +packets and leaves the actual caller/owner join open. It credits Nick Petalas +(#3078/#3090), Sagar Thakrar (#696), James Chang (#1869) and the encoded +arithmetic of #3091. Generic scalar arithmetic and their earlier lifecycle +contributions are not claimed anew. + +The current caller/lifecycle interface is retained from the published +[owned-bank implementation](https://github.com/CubeJerry/integer-mult-bounds/tree/ab239cb6ee884e7a900dd9101c34448077fad0b0/research/compiled-owned-bank-lifecycle). +Ali Romman's #5356 continuation source is unchanged. DreamingOfClouds' #6030, +Ali Romman's productive caller, Mark/Matarener's occurrence sources, the +#6878/#6900/#6901 geometry/precision work and the retained native/compiler +lineage keep their credit. Exact Git blob and SHA256 pins are in SOURCES.json +and DEPENDENCIES.json. No independent human or proof-kernel admission is claimed. + +## Open next questions + +The structured questions in [TASK.json](TASK.json) concern (1) actual phase, +Gaussian and recursive providers on the same ABI, (2) the successful whole-caller +grid/headroom/full-cost join, and (3) a stable common grid for odd-denominator +successor words. The generic rational table does not discharge the new +unfinished-context grid obligation in #6932/#6934. Native, compiler, ownership, +precision/tape and analytic admission beyond this scalar interface remain open. diff --git a/research/current-scalar-flat-tables/RESULT.json b/research/current-scalar-flat-tables/RESULT.json new file mode 100644 index 0000000000..59f843dbe6 --- /dev/null +++ b/research/current-scalar-flat-tables/RESULT.json @@ -0,0 +1,699 @@ +{ + "arithmetic": { + "check": "arithmetic", + "counts": { + "accepted": 2887, + "cases": 10870, + "extra_rational_cases": 400, + "physical_actions": 15799406, + "rejected": 7983, + "wide_accepted": 2, + "wide_fields": 168, + "wide_zero_fields": 168 + }, + "variants": [ + { + "carry_bound": 18, + "carry_states": 17, + "coefficient": "-16", + "denominator_twos": 0, + "numerator_source": -16, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2633, + "states": 862, + "work_ports": 2 + }, + { + "carry_bound": 10, + "carry_states": 9, + "coefficient": "-8", + "denominator_twos": 0, + "numerator_source": -8, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1481, + "states": 478, + "work_ports": 2 + }, + { + "carry_bound": 6, + "carry_states": 5, + "coefficient": "-4", + "denominator_twos": 0, + "numerator_source": -4, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 905, + "states": 286, + "work_ports": 2 + }, + { + "carry_bound": 5, + "carry_states": 4, + "coefficient": "-3", + "denominator_twos": 0, + "numerator_source": -3, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 761, + "states": 238, + "work_ports": 2 + }, + { + "carry_bound": 14, + "carry_states": 13, + "coefficient": "-9/4", + "denominator_twos": 2, + "numerator_source": -9, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2794, + "states": 871, + "work_ports": 2 + }, + { + "carry_bound": 4, + "carry_states": 3, + "coefficient": "-2", + "denominator_twos": 0, + "numerator_source": -2, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 617, + "states": 190, + "work_ports": 2 + }, + { + "carry_bound": 6, + "carry_states": 5, + "coefficient": "-3/2", + "denominator_twos": 1, + "numerator_source": -3, + "numerator_target": 2, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1118, + "states": 347, + "work_ports": 2 + }, + { + "carry_bound": 10, + "carry_states": 9, + "coefficient": "-5/4", + "denominator_twos": 2, + "numerator_source": -5, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2098, + "states": 655, + "work_ports": 2 + }, + { + "carry_bound": 3, + "carry_states": 2, + "coefficient": "-1", + "denominator_twos": 0, + "numerator_source": -1, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 473, + "states": 142, + "work_ports": 2 + }, + { + "carry_bound": 8, + "carry_states": 7, + "coefficient": "-3/4", + "denominator_twos": 2, + "numerator_source": -3, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1746, + "states": 543, + "work_ports": 2 + }, + { + "carry_bound": 4, + "carry_states": 3, + "coefficient": "-1/2", + "denominator_twos": 1, + "numerator_source": -1, + "numerator_target": 2, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 790, + "states": 243, + "work_ports": 2 + }, + { + "carry_bound": 12, + "carry_states": 11, + "coefficient": "-3/8", + "denominator_twos": 3, + "numerator_source": -3, + "numerator_target": 8, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2950, + "states": 931, + "work_ports": 2 + }, + { + "carry_bound": 6, + "carry_states": 5, + "coefficient": "-1/4", + "denominator_twos": 2, + "numerator_source": -1, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1402, + "states": 439, + "work_ports": 2 + }, + { + "carry_bound": 10, + "carry_states": 9, + "coefficient": "-1/8", + "denominator_twos": 3, + "numerator_source": -1, + "numerator_target": 8, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2606, + "states": 827, + "work_ports": 2 + }, + { + "carry_bound": 18, + "carry_states": 17, + "coefficient": "-1/16", + "denominator_twos": 4, + "numerator_source": -1, + "numerator_target": 16, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 4994, + "states": 1599, + "work_ports": 2 + }, + { + "carry_bound": 18, + "carry_states": 17, + "coefficient": "1/16", + "denominator_twos": 4, + "numerator_source": 1, + "numerator_target": 16, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 4994, + "states": 1599, + "work_ports": 2 + }, + { + "carry_bound": 10, + "carry_states": 9, + "coefficient": "1/8", + "denominator_twos": 3, + "numerator_source": 1, + "numerator_target": 8, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2606, + "states": 827, + "work_ports": 2 + }, + { + "carry_bound": 6, + "carry_states": 5, + "coefficient": "1/4", + "denominator_twos": 2, + "numerator_source": 1, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1402, + "states": 439, + "work_ports": 2 + }, + { + "carry_bound": 12, + "carry_states": 11, + "coefficient": "3/8", + "denominator_twos": 3, + "numerator_source": 3, + "numerator_target": 8, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2950, + "states": 931, + "work_ports": 2 + }, + { + "carry_bound": 4, + "carry_states": 3, + "coefficient": "1/2", + "denominator_twos": 1, + "numerator_source": 1, + "numerator_target": 2, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 790, + "states": 243, + "work_ports": 2 + }, + { + "carry_bound": 8, + "carry_states": 7, + "coefficient": "3/4", + "denominator_twos": 2, + "numerator_source": 3, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1746, + "states": 543, + "work_ports": 2 + }, + { + "carry_bound": 3, + "carry_states": 2, + "coefficient": "1", + "denominator_twos": 0, + "numerator_source": 1, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 473, + "states": 142, + "work_ports": 2 + }, + { + "carry_bound": 10, + "carry_states": 9, + "coefficient": "5/4", + "denominator_twos": 2, + "numerator_source": 5, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2098, + "states": 655, + "work_ports": 2 + }, + { + "carry_bound": 6, + "carry_states": 5, + "coefficient": "3/2", + "denominator_twos": 1, + "numerator_source": 3, + "numerator_target": 2, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1118, + "states": 347, + "work_ports": 2 + }, + { + "carry_bound": 12, + "carry_states": 11, + "coefficient": "7/4", + "denominator_twos": 2, + "numerator_source": 7, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 2442, + "states": 759, + "work_ports": 2 + }, + { + "carry_bound": 4, + "carry_states": 3, + "coefficient": "2", + "denominator_twos": 0, + "numerator_source": 2, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 617, + "states": 190, + "work_ports": 2 + }, + { + "carry_bound": 8, + "carry_states": 7, + "coefficient": "5/2", + "denominator_twos": 1, + "numerator_source": 5, + "numerator_target": 2, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1446, + "states": 451, + "work_ports": 2 + }, + { + "carry_bound": 5, + "carry_states": 4, + "coefficient": "3", + "denominator_twos": 0, + "numerator_source": 3, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 761, + "states": 238, + "work_ports": 2 + }, + { + "carry_bound": 6, + "carry_states": 5, + "coefficient": "4", + "denominator_twos": 0, + "numerator_source": 4, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 905, + "states": 286, + "work_ports": 2 + }, + { + "carry_bound": 10, + "carry_states": 9, + "coefficient": "8", + "denominator_twos": 0, + "numerator_source": 8, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1481, + "states": 478, + "work_ports": 2 + }, + { + "carry_bound": 12, + "carry_states": 11, + "coefficient": "10", + "denominator_twos": 0, + "numerator_source": 10, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "ADD", + "public_ports": 2, + "rows": 1769, + "states": 574, + "work_ports": 2 + }, + { + "carry_bound": 9, + "carry_states": 9, + "coefficient": "-8", + "denominator_twos": 0, + "numerator_source": 0, + "numerator_target": -8, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 692, + "states": 284, + "work_ports": 2 + }, + { + "carry_bound": 5, + "carry_states": 5, + "coefficient": "-4", + "denominator_twos": 0, + "numerator_source": 0, + "numerator_target": -4, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 420, + "states": 172, + "work_ports": 2 + }, + { + "carry_bound": 3, + "carry_states": 3, + "coefficient": "-2", + "denominator_twos": 0, + "numerator_source": 0, + "numerator_target": -2, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 284, + "states": 116, + "work_ports": 2 + }, + { + "carry_bound": 2, + "carry_states": 2, + "coefficient": "-1", + "denominator_twos": 0, + "numerator_source": 0, + "numerator_target": -1, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 216, + "states": 88, + "work_ports": 2 + }, + { + "carry_bound": 2, + "carry_states": 2, + "coefficient": "-1/2", + "denominator_twos": 1, + "numerator_source": 0, + "numerator_target": -1, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 262, + "states": 108, + "work_ports": 2 + }, + { + "carry_bound": 2, + "carry_states": 2, + "coefficient": "-1/4", + "denominator_twos": 2, + "numerator_source": 0, + "numerator_target": -1, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 306, + "states": 130, + "work_ports": 2 + }, + { + "carry_bound": 2, + "carry_states": 2, + "coefficient": "-1/8", + "denominator_twos": 3, + "numerator_source": 0, + "numerator_target": -1, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 352, + "states": 154, + "work_ports": 2 + }, + { + "carry_bound": 2, + "carry_states": 1, + "coefficient": "1/4", + "denominator_twos": 2, + "numerator_source": 0, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 240, + "states": 106, + "work_ports": 2 + }, + { + "carry_bound": 2, + "carry_states": 1, + "coefficient": "1/2", + "denominator_twos": 1, + "numerator_source": 0, + "numerator_target": 1, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 202, + "states": 86, + "work_ports": 2 + }, + { + "carry_bound": 3, + "carry_states": 2, + "coefficient": "2", + "denominator_twos": 0, + "numerator_source": 0, + "numerator_target": 2, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 234, + "states": 96, + "work_ports": 2 + }, + { + "carry_bound": 5, + "carry_states": 4, + "coefficient": "4", + "denominator_twos": 0, + "numerator_source": 0, + "numerator_target": 4, + "odd_denominator": 1, + "operation": "SCALE", + "public_ports": 1, + "rows": 370, + "states": 152, + "work_ports": 2 + } + ] + }, + "binding": { + "caller_events": 642410, + "check": "binding", + "excluded_services": { + "boundary-left": 3120, + "boundary-right": 2808, + "caller-local": 124308, + "central-square": 3328, + "idle-in": 3120, + "idle-out": 3120, + "local-entry": 13860, + "local-return": 13860, + "outer": 4992, + "query-in": 1560, + "query-out": 1560, + "raw-whole-job-enter": 13444, + "raw-whole-job-return": 13444 + }, + "raw_paid": { + "1": 41502, + "16": 416, + "2": 8226, + "24": 416, + "3": 8928, + "32": 416, + "4": 1800, + "40": 416, + "48": 416, + "5": 2934, + "56": 416, + "6": 198, + "64": 416, + "7": 108, + "72": 208, + "8": 18 + }, + "scopes": { + "boundary-left": 6240, + "boundary-right": 2912, + "local": 346770, + "outer": 9360, + "query-add": 1560 + }, + "services": 366842, + "source_receipt_sha256": "cda8b8c71c3ad6f059a6f54f50e88e868487c0a9a79c72d90b12c0c2c219644b", + "table_rows": 58544, + "variants": 42 + }, + "controller": { + "actual_scalar_services": 9895, + "check": "controller_prefix", + "component_width": 11, + "field_count": 799, + "output_sha256": "4d74b866aadf4bf1f674d8a33f04e055aa45dc2c2ab7f3d44771e35f15a44910", + "physical_actions": 41088794, + "source_first": 1, + "source_last": 9895 + }, + "controls": { + "check": "controls", + "controls": [ + "inexact_negative_half", + "short_width_below_denominator", + "late_signed_overflow", + "odd_denominator_inexact", + "edge_SCALE_-1/2_4", + "edge_ADD_2_4", + "edge_ADD_-1_4", + "edge_SCALE_1/16_1", + "empty_component", + "missing_delimiter", + "odd_component_count", + "partial_physical_code", + "mismatched_component_width", + "mismatched_record_count", + "physical_alias", + "altered_coefficient", + "wrong_source_site", + "malformed_wrapper", + "unsupported_swap_service", + "corrupt_sources", + "corrupt_dependencies", + "reversed_final_carry", + "missing_sign_extension", + "omitted_physical_retirement", + "shrinking_call_reuse" + ], + "count": 25, + "retained_highwater": [ + 12713, + 12728 + ], + "small_fresh_actions": 1304 + } +} diff --git a/research/current-scalar-flat-tables/SOURCES.json b/research/current-scalar-flat-tables/SOURCES.json new file mode 100644 index 0000000000..ac3fb54c14 --- /dev/null +++ b/research/current-scalar-flat-tables/SOURCES.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "research/p104-helper470-twin-rung-removal/WORD.json.gz", + "usage": "input", + "git_blob": "22f9ab02d1b73ea0aa4b07ce445a14cc2602c760", + "sha256": "7834725d9e34ee846a9ccc615221ea81e0201613938afa185d2eda0c9a6c232f" + }, + { + "path": "research/p104-productive-controller/CONTROLLER.json", + "usage": "input", + "git_blob": "cc539db709cf7a6c42872c4380902736ad453af3", + "sha256": "a84f6bbd547379597464e56c420cc665f96bc43a9a1351eed4b7cd0fce3cc4b9" + } + ] +} diff --git a/research/current-scalar-flat-tables/TASK.json b/research/current-scalar-flat-tables/TASK.json new file mode 100644 index 0000000000..ec04660a46 --- /dev/null +++ b/research/current-scalar-flat-tables/TASK.json @@ -0,0 +1,93 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Can one of the selected record's five inherited assumptions be proved at its actual caller?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Choose one assumption ID (native_all_columns, owned_erasure, compiler, precision_tape, analytic_recovery), one quantified implication and exact dependency closure. Check current handoffs, including #5625 row reentry and #5707 root-prefix lowering, without treating their partial scope as the whole theorem. Prove or falsify that implication with a caller-bound argument; stop at the chosen obligation. Finite tests or root digits do not discharge an all-size statement.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "refined", + "scope_change_reason": "Explicit wave-1 compiler/owned research assignment narrowed to actual finite scalar tables for the current coded lifecycle, excluding concurrent Compact, monomial, row and Core implementations.", + "actual_scope": "Prove and execute source-bound ADD/SCALE tables for complete current coded fields, with exact representability/range success domain, whole-field staging, two work tapes, source owner-token binding and explicit complete costs.", + "bottleneck_link": "Discharges the numerical scalar-table premise at the 366842 current original ADD/SCALE service occurrences while retaining caller geometry, native and recursive precision, ownership and analytic premises.", + "stop_rule": "Finish this scalar-only source/physical refinement and independent verification; do not claim a complete dispatcher, selected tariff, unconditional multiplication theorem or new kappa.", + "evidence": "PROOF.md, RESULT.json and registered exact physical Fraction-oracle, complete source-binding, actual Controller-prefix and negative-control checks.", + "author": "@CubeJerry", + "ai_assistance": "Substantial OpenAI assistance in source analysis, mathematics, implementation and verification. Separate AI review is not independent human or proof-kernel acceptance.", + "outcome": "completed", + "open_questions": [ + { + "question": "Join the current phase, Gaussian and recursive numerical providers to the same coded lifecycle.", + "why_it_matters": "The scalar services are only one class of the current fixed-template numerical boundary.", + "first_step": "Bind one exact provider token and its complete physical and precision contract, preserving protected outputs and ordinary prices.", + "blocked_by": "Other actual numerical providers and selected-rate admission remain separate." + }, + { + "question": "Close the all-success whole-caller grid, headroom and full-machine cost join.", + "why_it_matters": "Primitive representability is not a proof that every actual recursive entrance satisfies it.", + "first_step": "Use the exact current source event sequence and all native endpoint/error guarantees to verify the global precision predicates and accumulated positive costs.", + "blocked_by": "Native/recursive return, row geometry, lifecycle and analytic framework premises." + }, + { + "question": "Establish a stable common grid for odd-denominator successor words.", + "why_it_matters": "The generic table executes exact rational scalars but rejects values absent from its input grid.", + "first_step": "Prove exact numerator divisibility at every unfinished recursive context of a pinned 1/3 or 1/5 successor.", + "blocked_by": "This package does not prove the new rational-grid hypothesis of CrocSwap/integer-mult-bounds#6932 and CrocSwap/integer-mult-bounds#6934." + } + ] +} diff --git a/research/current-scalar-flat-tables/VERIFICATION.md b/research/current-scalar-flat-tables/VERIFICATION.md new file mode 100644 index 0000000000..0bfc90a8cf --- /dev/null +++ b/research/current-scalar-flat-tables/VERIFICATION.md @@ -0,0 +1,105 @@ +# Verification record + +Prepared for **@CubeJerry**, with substantial OpenAI assistance. No new κ. + +## What is proved and what is tested + +`PROOF.md` gives the all-width, all-record-count finite-carry theorem, complete +field staging, exact source-token substitution and complete linear tape bill. +The finite checks below challenge its implementation; their bounded coverage +is not a substitute for the quantified proof or the inherited caller premises. + +The three vendored dependencies are byte-identical to the published commits +in `DEPENDENCIES.json`. Every test checks their Git blob and SHA256 before +import. Both runtime input files are checked against `SOURCES.json` before +decoding. These pins have no authority over the truth of the mathematics. + +## Exact replay coverage + +The four suites have deterministic receipts in `RESULT.json`. Each replay +compares its entire JSON result with that committed receipt using an explicit +exception, including under Python optimization. No proof obligation or test +guard depends on an `assert` statement. + +| Suite | Coverage | Result | +| --- | --- | --- | +| `arithmetic` | All 42 current operation/coefficient pairs, widths 1–4, every signed target and every signed ADD source | 10,870 cases: 2,887 accepts and 7,983 rejects | +| `arithmetic` | 168 complete wider fields and 168 wide zero controls, widths 5, 16, 65, 129 | Exact endpoint/representation equivalence; bounded current work and physical actions | +| `arithmetic` | Extra SCALE(1/3), SCALE(-7/6), ADD(1/5), full small signed domains | 400 cases; a generic rational primitive check, without successor caller admission | +| `binding` | Original complete 642,410-event caller | 366,842 scalar service instances, 42 tables, 58,544 table rows; exact source/owner receipts | +| `controller` | Actual source scalar events 1..9895 after INIT(778), with 799 borrowed fields of two 11-bit components | All endpoints match a separate Fraction interpreter; 41,088,794 physical cell actions | +| `controls` | 25 targeted failures and boundary cases | Every named failure detected; valid endpoint-only headroom cases accepted | + +The arithmetic suite uses the unchanged published `execute_table` on metered +physical tapes. Fixture construction and the independent post-execution +Fraction oracle inspect numerical values and tape storage; the runtime table +does neither. The controller suite additionally uses the original +`Controller.run`/`Controller.primitive` and the original #5356 physical +continuation constructor. Its owner initialization is explicitly supplied at +the prefix entry; it does not exercise the complete caller or recursive row +providers. All extra descriptor/context ports remain protected. + +The controls include late-component failure before any target write, negative +inexact division, odd-denominator inexact division, most-negative negation, +width smaller than the denominator's power of two, malformed shape/codeword, +physical operand alias, altered coefficient, wrong source site, malformed +wrapper grammar, unsupported operation, source/dependency byte corruption, +wrong final-carry sign, missing sign extension, omitted raw scratch retirement +and shrinking reuse of erased warm backing. The binding suite separately +tests chronological product wrappers that retain an issuing PAID token: it +follows the active scalar token rather than mistaking that provenance for a +second scalar origin. + +## Independent mathematical review + +A separate lead AI reviewer read proof Sections 1–5 and the table's core state +machine, independently derived the telescoping identity and final sign guard, +and reported an independent digit/Fraction exhaustive check of 14,260 cases, +with 3,037 accepts. Its domain was SCALE and ADD, widths 1–5, every signed +operand, and coefficients `{1/2,-1/2,3/8,-5/16,1/3,-2/3,6/5,-7/10,9,-9}`. +The reviewer found no mismatch in rejection equivalence or carry bounds and +confirmed the geometry/staging argument under distinct-tape and well-formed +input premises. This is a separate mathematical audit reported during the +research session, not another physical-executor run, an independent human +review or formal proof-kernel acceptance. The registered package's own +reproduction commands do not purport to replay that external review. + +## Corrections found before freeze + +The first development draft reversed the sign of the telescoping terminal +carry condition. Its first most-negative negative-half fixture exposed the +error; the proof and generator were corrected before the recorded exhaustive +runs. A retained wrong-sign mutation control now detects this exact defect. +One initial width-1 negative fixture was itself out of range and was replaced +by a valid signed value before the reported controls passed. + +During source-composition review, an initial recursive search over all token +members was found too broad for `product-right`, which retains both issuing +PAID provenance and the active token. It was replaced by the exact original +wrapper grammar, and a nested chronological-product positive control was +added. All direct caller receipts remain unchanged. + +## Reproduction and publication boundary + +From a checkout with the two declared source inputs: + +```sh +python3 -B scripts/research_package.py --package research/current-scalar-flat-tables +``` + +`VERIFY.json` registers eight commands: normal and optimized execution of the +four suites. All eight passed in the final registered replay, with unchanged +exact receipts. Each command has a 120-second limit and requires only Python 3.12 +and its standard library. `TASK.json` records the exact canonical task card, +base, narrowed claim and remaining obligations. Publication must include the +committed-byte preflight; [the final execution log](evidence/registered-replay.log) +records the eight registered checks and their +`PASS_REGISTERED_RESEARCH_PACKAGE` marker. + +The all-success caller substitution still assumes common grid, signed range, +aligned actual owners, all supplied heads at current origins, contiguous +binary dirty work prefixes and the original lifecycle contracts. Immediate reject +leaves public contents intact but can leave work occupied and heads advanced; +no physical rollback theorem is claimed. Native maps, row/recursive services, +their error returns, the complete machine constant and analytic recovery +remain separate. All five selected assumptions remain in force. diff --git a/research/current-scalar-flat-tables/VERIFY.json b/research/current-scalar-flat-tables/VERIFY.json new file mode 100644 index 0000000000..ebe105e8ef --- /dev/null +++ b/research/current-scalar-flat-tables/VERIFY.json @@ -0,0 +1,108 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/p104-helper470-twin-rung-removal/WORD.json.gz", + "research/p104-productive-controller/CONTROLLER.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "research/current-scalar-flat-tables/verify.py", + "--suite", + "arithmetic" + ], + "timeout_seconds": 120, + "checks": "Normal arithmetic source/physical/cost validation with exact receipts and declared scope." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "research/current-scalar-flat-tables/verify.py", + "--suite", + "binding" + ], + "timeout_seconds": 120, + "checks": "Normal binding source/physical/cost validation with exact receipts and declared scope." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "research/current-scalar-flat-tables/verify.py", + "--suite", + "controller" + ], + "timeout_seconds": 120, + "checks": "Normal controller source/physical/cost validation with exact receipts and declared scope." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "research/current-scalar-flat-tables/check_controls.py" + ], + "timeout_seconds": 120, + "checks": "Normal controls source/physical/cost validation with exact receipts and declared scope." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "research/current-scalar-flat-tables/verify.py", + "--suite", + "arithmetic" + ], + "timeout_seconds": 120, + "checks": "Optimized arithmetic source/physical/cost validation with exact receipts and declared scope." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "research/current-scalar-flat-tables/verify.py", + "--suite", + "binding" + ], + "timeout_seconds": 120, + "checks": "Optimized binding source/physical/cost validation with exact receipts and declared scope." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "research/current-scalar-flat-tables/verify.py", + "--suite", + "controller" + ], + "timeout_seconds": 120, + "checks": "Optimized controller source/physical/cost validation with exact receipts and declared scope." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "research/current-scalar-flat-tables/check_controls.py" + ], + "timeout_seconds": 120, + "checks": "Optimized controls source/physical/cost validation with exact receipts and declared scope." + } + ] +} diff --git a/research/current-scalar-flat-tables/check_controls.py b/research/current-scalar-flat-tables/check_controls.py new file mode 100644 index 0000000000..c4c4fdfac6 --- /dev/null +++ b/research/current-scalar-flat-tables/check_controls.py @@ -0,0 +1,128 @@ +"""Failure-detection controls for scalar source, arithmetic and physical ABI. + +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from pathlib import Path +from fractions import Fraction +import gzip +import json +import sys +import types + +sys.path.insert(0,str(Path(__file__).resolve().parent)) +from tables import compile_scalar,source_literal,need +from physical import A,IR,ROOT,Tape,execute,encode_symbols,symbols_for +from source_binding import check_inputs,check_dependencies,hashes,check_payload + + +def reject(call, fragment): + try:call() + except ValueError as exc: + need(fragment in str(exc),'named failure: '+str(exc)) + return + raise ValueError('negative control accepted: '+fragment) + + +def raw_failure(table, fields, fragment): + before=[t.body() for t in fields] + work=[Tape(origin=101),Tape(origin=111)] + reject(lambda:A.execute_table(table,tuple(fields+work)),fragment) + need(all(t.body()==old for t,old in zip(fields,before)),'malformed field changed before validation') + + +def main(): + check_inputs() + done=[] + def record(name):done.append(name) + t,_=compile_scalar('SCALE','-1/2') + for value,width,fragment,name in [(-7,4,'inexact','inexact_negative_half'), + (-1,1,'inexact','short_width_below_denominator')]: + result=execute(t,'SCALE',(0,value),(0,0),width) + need(result['error'] and fragment in result['error'],'late arithmetic rejects') + need(result['public'][0].body()==result['before'][0] and result['public'][0].writes==0, + 'whole-field staged failure') + record(name) + tneg,_=compile_scalar('SCALE','-1') + result=execute(tneg,'SCALE',(0,-8),(0,0),4) + need(result['error'] and 'overflow' in result['error'],'most-negative negation rejects') + need(result['public'][0].writes==0,'late overflow keeps target');record('late_signed_overflow') + todd,_=compile_scalar('SCALE','1/3') + result=execute(todd,'SCALE',(0,2),(0,0),4) + need(result['error'] and 'quotient' in result['error'],'odd divisibility rejects');record('odd_denominator_inexact') + for op,q,x,y,w,want in [('SCALE','-1/2',-8,0,4,4),('ADD','2',-7,7,4,7), + ('ADD','-1',-8,-8,4,0),('SCALE','1/16',0,0,1,0)]: + table,_=compile_scalar(op,q);result=execute(table,op,(x,x),(y,y),w) + need(not result['error'] and result['output']==(want,want),'endpoint-admitted edge control') + record('edge_'+op+'_'+q+'_'+str(w)) + identity,_=compile_scalar('SCALE','1') + raw_failure(identity,[Tape(encode_symbols((2,)))],'positive component width');record('empty_component') + raw_failure(identity,[Tape(encode_symbols((0,)))],'unterminated');record('missing_delimiter') + raw_failure(identity,[Tape(encode_symbols((0,2)))],'complex field');record('odd_component_count') + raw_failure(identity,[Tape((0,1))],'codeword');record('partial_physical_code') + add,_=compile_scalar('ADD','1') + raw_failure(add,[Tape(encode_symbols(symbols_for((0,0),2))), + Tape(encode_symbols(symbols_for((0,0),1)),origin=29)],'component shape') + record('mismatched_component_width') + raw_failure(add,[Tape(encode_symbols(symbols_for((0,0),2))), + Tape(encode_symbols(symbols_for((0,0,0,0),2)),origin=29)],'field frontier') + record('mismatched_record_count') + # This is the actual source-token validator, including independent local + # roles with equal numerical values versus an illegal physical alias. + word=json.loads(gzip.decompress((ROOT.parents[1]/'research/p104-helper470-twin-rung-removal/WORD.json.gz').read_bytes())) + event=IR.Event('SERVICE',(778,572),('local',1,tuple(word['program'][1]))) + need(source_literal(event,word)[:2]==('ADD',Fraction(1,2)),'actual source literal') + alias=IR.Event('SERVICE',(778,778),event.token) + reject(lambda:source_literal(alias,word),'distinct actual');record('physical_alias') + changed=list(word['program'][1]);changed[-2]='1/4' + bad=IR.Event('SERVICE',event.fields,('local',1,tuple(changed))) + reject(lambda:source_literal(bad,word),'exact current');record('altered_coefficient') + bad=IR.Event('SERVICE',event.fields,('local',2,event.token[2])) + reject(lambda:source_literal(bad,word),'exact current');record('wrong_source_site') + bad=IR.Event('SERVICE',event.fields,('unit-fragment',event.token,event.token)) + reject(lambda:source_literal(bad,word),'wrapper grammar');record('malformed_wrapper') + reject(lambda:compile_scalar('SWAP',1),'scalar operation');record('unsupported_swap_service') + for manifest,key,base in [('SOURCES.json','path',ROOT.parents[1]), + ('DEPENDENCIES.json','local_path',ROOT)]: + rows=json.loads((ROOT/manifest).read_text())['files'] + row=next(r for r in rows if manifest=='DEPENDENCIES.json' or r['usage']=='input') + data=(base/row[key]).read_bytes() + reject(lambda:check_payload(data+b'\n',row,row[key]),'source byte pin') + record('corrupt_'+manifest.split('.')[0].lower()) + # Source-code mutants preserve the same retained physical executor. + source=(ROOT/'tables.py').read_text() + mutants=[('reversed_final_carry', + 'carry != p*sx+r*sy-odd*sq','carry != odd*sq-p*sx-r*sy', + 'SCALE','-1/2',(-8,-8),(0,0),4,(4,4)), + ('missing_sign_extension', + 'digit(k,carry,sq,sx,sy)','digit(k,carry,sq,0,0)', + 'SCALE','1/2',(-8,-8),(0,0),4,(-4,-4))] + for name,old,new,op,q,xs,ys,w,expected in mutants: + need(source.count(old)==1,'unique controlled mutation') + module=types.ModuleType('scalar_mutant_'+name) + exec(compile(source.replace(old,new),name,'exec'),module.__dict__) + table,_=module.compile_scalar(op,q) + result=execute(table,op,xs,ys,w) + need(result['error'] is not None or result['output']!=expected,'mutation must be detected') + record(name) + # Omitting the actual lifecycle retirement leaves both coded work bodies. + public=Tape(encode_symbols(symbols_for((2,-2),4))) + work=[Tape(origin=101),Tape(origin=111)] + A.execute_table(identity,tuple([public]+work)) + need(not all(t.blank() for t in work),'missing raw retirement detected');record('omitted_physical_retirement') + # A small call on erased warm backing must do its own current-volume work. + warm=execute(identity,'SCALE',(1,-1)*64,(0,0)*64,32)['work'] + old_backing=[t.highwater for t in warm] + small=execute(identity,'SCALE',(1,-1),(0,0),3,work=warm) + fresh=execute(identity,'SCALE',(1,-1),(0,0),3) + need(small['actions']==fresh['actions'] and [t.highwater for t in warm]==old_backing, + 'warm backing retained without rescanning erased history') + record('shrinking_call_reuse') + result=dict(check='controls',count=len(done),controls=done, + small_fresh_actions=fresh['actions'],retained_highwater=old_backing) + expected=json.loads((ROOT/'RESULT.json').read_text())['controls'] + need(result==expected,'committed exact control receipt') + print(json.dumps(result,sort_keys=True)) + print('PASS_CURRENT_SCALAR_FLAT_TABLES_CONTROLS') + + +if __name__=='__main__':main() diff --git a/research/current-scalar-flat-tables/evidence/TIMINGS.json b/research/current-scalar-flat-tables/evidence/TIMINGS.json new file mode 100644 index 0000000000..4dce367542 --- /dev/null +++ b/research/current-scalar-flat-tables/evidence/TIMINGS.json @@ -0,0 +1,8 @@ +{ + "normal": { + "arithmetic": 8.629, + "binding": 6.525, + "controller": 22.278, + "controls": 0.398 + } +} diff --git a/research/current-scalar-flat-tables/evidence/normal-arithmetic.log b/research/current-scalar-flat-tables/evidence/normal-arithmetic.log new file mode 100644 index 0000000000..b5853171d5 --- /dev/null +++ b/research/current-scalar-flat-tables/evidence/normal-arithmetic.log @@ -0,0 +1,2 @@ +{"check": "arithmetic", "counts": {"accepted": 2887, "cases": 10870, "extra_rational_cases": 400, "physical_actions": 15799406, "rejected": 7983, "wide_accepted": 2, "wide_fields": 168, "wide_zero_fields": 168}, "variants": [{"carry_bound": 18, "carry_states": 17, "coefficient": "-16", "denominator_twos": 0, "numerator_source": -16, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2633, "states": 862, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-8", "denominator_twos": 0, "numerator_source": -8, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1481, "states": 478, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-4", "denominator_twos": 0, "numerator_source": -4, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 905, "states": 286, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "-3", "denominator_twos": 0, "numerator_source": -3, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 761, "states": 238, "work_ports": 2}, {"carry_bound": 14, "carry_states": 13, "coefficient": "-9/4", "denominator_twos": 2, "numerator_source": -9, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2794, "states": 871, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "-2", "denominator_twos": 0, "numerator_source": -2, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 617, "states": 190, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-3/2", "denominator_twos": 1, "numerator_source": -3, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1118, "states": 347, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-5/4", "denominator_twos": 2, "numerator_source": -5, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2098, "states": 655, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "-1", "denominator_twos": 0, "numerator_source": -1, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 473, "states": 142, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "-3/4", "denominator_twos": 2, "numerator_source": -3, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1746, "states": 543, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "-1/2", "denominator_twos": 1, "numerator_source": -1, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 790, "states": 243, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "-3/8", "denominator_twos": 3, "numerator_source": -3, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2950, "states": 931, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-1/4", "denominator_twos": 2, "numerator_source": -1, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1402, "states": 439, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-1/8", "denominator_twos": 3, "numerator_source": -1, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2606, "states": 827, "work_ports": 2}, {"carry_bound": 18, "carry_states": 17, "coefficient": "-1/16", "denominator_twos": 4, "numerator_source": -1, "numerator_target": 16, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 4994, "states": 1599, "work_ports": 2}, {"carry_bound": 18, "carry_states": 17, "coefficient": "1/16", "denominator_twos": 4, "numerator_source": 1, "numerator_target": 16, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 4994, "states": 1599, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "1/8", "denominator_twos": 3, "numerator_source": 1, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2606, "states": 827, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "1/4", "denominator_twos": 2, "numerator_source": 1, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1402, "states": 439, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "3/8", "denominator_twos": 3, "numerator_source": 3, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2950, "states": 931, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "1/2", "denominator_twos": 1, "numerator_source": 1, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 790, "states": 243, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "3/4", "denominator_twos": 2, "numerator_source": 3, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1746, "states": 543, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "1", "denominator_twos": 0, "numerator_source": 1, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 473, "states": 142, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "5/4", "denominator_twos": 2, "numerator_source": 5, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2098, "states": 655, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "3/2", "denominator_twos": 1, "numerator_source": 3, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1118, "states": 347, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "7/4", "denominator_twos": 2, "numerator_source": 7, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2442, "states": 759, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "2", "denominator_twos": 0, "numerator_source": 2, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 617, "states": 190, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "5/2", "denominator_twos": 1, "numerator_source": 5, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1446, "states": 451, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "3", "denominator_twos": 0, "numerator_source": 3, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 761, "states": 238, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "4", "denominator_twos": 0, "numerator_source": 4, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 905, "states": 286, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "8", "denominator_twos": 0, "numerator_source": 8, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1481, "states": 478, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "10", "denominator_twos": 0, "numerator_source": 10, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1769, "states": 574, "work_ports": 2}, {"carry_bound": 9, "carry_states": 9, "coefficient": "-8", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -8, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 692, "states": 284, "work_ports": 2}, {"carry_bound": 5, "carry_states": 5, "coefficient": "-4", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -4, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 420, "states": 172, "work_ports": 2}, {"carry_bound": 3, "carry_states": 3, "coefficient": "-2", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -2, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 284, "states": 116, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 216, "states": 88, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/2", "denominator_twos": 1, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 262, "states": 108, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/4", "denominator_twos": 2, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 306, "states": 130, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/8", "denominator_twos": 3, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 352, "states": 154, "work_ports": 2}, {"carry_bound": 2, "carry_states": 1, "coefficient": "1/4", "denominator_twos": 2, "numerator_source": 0, "numerator_target": 1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 240, "states": 106, "work_ports": 2}, {"carry_bound": 2, "carry_states": 1, "coefficient": "1/2", "denominator_twos": 1, "numerator_source": 0, "numerator_target": 1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 202, "states": 86, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "2", "denominator_twos": 0, "numerator_source": 0, "numerator_target": 2, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 234, "states": 96, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "4", "denominator_twos": 0, "numerator_source": 0, "numerator_target": 4, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 370, "states": 152, "work_ports": 2}]} +PASS_CURRENT_SCALAR_FLAT_TABLES_ARITHMETIC diff --git a/research/current-scalar-flat-tables/evidence/normal-binding.log b/research/current-scalar-flat-tables/evidence/normal-binding.log new file mode 100644 index 0000000000..bfea1e4011 --- /dev/null +++ b/research/current-scalar-flat-tables/evidence/normal-binding.log @@ -0,0 +1,2 @@ +{"caller_events": 642410, "check": "binding", "excluded_services": {"boundary-left": 3120, "boundary-right": 2808, "caller-local": 124308, "central-square": 3328, "idle-in": 3120, "idle-out": 3120, "local-entry": 13860, "local-return": 13860, "outer": 4992, "query-in": 1560, "query-out": 1560, "raw-whole-job-enter": 13444, "raw-whole-job-return": 13444}, "raw_paid": {"1": 41502, "2": 8226, "3": 8928, "4": 1800, "5": 2934, "6": 198, "7": 108, "8": 18, "16": 416, "24": 416, "32": 416, "40": 416, "48": 416, "56": 416, "64": 416, "72": 208}, "scopes": {"boundary-left": 6240, "boundary-right": 2912, "local": 346770, "outer": 9360, "query-add": 1560}, "services": 366842, "source_receipt_sha256": "cda8b8c71c3ad6f059a6f54f50e88e868487c0a9a79c72d90b12c0c2c219644b", "table_rows": 58544, "variants": 42} +PASS_CURRENT_SCALAR_FLAT_TABLES_BINDING diff --git a/research/current-scalar-flat-tables/evidence/normal-controller.log b/research/current-scalar-flat-tables/evidence/normal-controller.log new file mode 100644 index 0000000000..d45acc1f0b --- /dev/null +++ b/research/current-scalar-flat-tables/evidence/normal-controller.log @@ -0,0 +1,2 @@ +{"actual_scalar_services": 9895, "check": "controller_prefix", "component_width": 11, "field_count": 799, "output_sha256": "4d74b866aadf4bf1f674d8a33f04e055aa45dc2c2ab7f3d44771e35f15a44910", "physical_actions": 41088794, "source_first": 1, "source_last": 9895} +PASS_CURRENT_SCALAR_FLAT_TABLES_CONTROLLER diff --git a/research/current-scalar-flat-tables/evidence/normal-controls.log b/research/current-scalar-flat-tables/evidence/normal-controls.log new file mode 100644 index 0000000000..fa67581bcf --- /dev/null +++ b/research/current-scalar-flat-tables/evidence/normal-controls.log @@ -0,0 +1,2 @@ +{"check": "controls", "controls": ["inexact_negative_half", "short_width_below_denominator", "late_signed_overflow", "odd_denominator_inexact", "edge_SCALE_-1/2_4", "edge_ADD_2_4", "edge_ADD_-1_4", "edge_SCALE_1/16_1", "empty_component", "missing_delimiter", "odd_component_count", "partial_physical_code", "mismatched_component_width", "mismatched_record_count", "physical_alias", "altered_coefficient", "wrong_source_site", "malformed_wrapper", "unsupported_swap_service", "corrupt_sources", "corrupt_dependencies", "reversed_final_carry", "missing_sign_extension", "omitted_physical_retirement", "shrinking_call_reuse"], "count": 25, "retained_highwater": [12713, 12728], "small_fresh_actions": 1304} +PASS_CURRENT_SCALAR_FLAT_TABLES_CONTROLS diff --git a/research/current-scalar-flat-tables/evidence/registered-replay.log b/research/current-scalar-flat-tables/evidence/registered-replay.log new file mode 100644 index 0000000000..fcfdeb78e6 --- /dev/null +++ b/research/current-scalar-flat-tables/evidence/registered-replay.log @@ -0,0 +1,25 @@ +CHECK Normal arithmetic source/physical/cost validation with exact receipts and declared scope. +{"check": "arithmetic", "counts": {"accepted": 2887, "cases": 10870, "extra_rational_cases": 400, "physical_actions": 15799406, "rejected": 7983, "wide_accepted": 2, "wide_fields": 168, "wide_zero_fields": 168}, "variants": [{"carry_bound": 18, "carry_states": 17, "coefficient": "-16", "denominator_twos": 0, "numerator_source": -16, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2633, "states": 862, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-8", "denominator_twos": 0, "numerator_source": -8, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1481, "states": 478, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-4", "denominator_twos": 0, "numerator_source": -4, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 905, "states": 286, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "-3", "denominator_twos": 0, "numerator_source": -3, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 761, "states": 238, "work_ports": 2}, {"carry_bound": 14, "carry_states": 13, "coefficient": "-9/4", "denominator_twos": 2, "numerator_source": -9, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2794, "states": 871, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "-2", "denominator_twos": 0, "numerator_source": -2, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 617, "states": 190, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-3/2", "denominator_twos": 1, "numerator_source": -3, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1118, "states": 347, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-5/4", "denominator_twos": 2, "numerator_source": -5, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2098, "states": 655, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "-1", "denominator_twos": 0, "numerator_source": -1, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 473, "states": 142, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "-3/4", "denominator_twos": 2, "numerator_source": -3, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1746, "states": 543, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "-1/2", "denominator_twos": 1, "numerator_source": -1, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 790, "states": 243, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "-3/8", "denominator_twos": 3, "numerator_source": -3, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2950, "states": 931, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-1/4", "denominator_twos": 2, "numerator_source": -1, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1402, "states": 439, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-1/8", "denominator_twos": 3, "numerator_source": -1, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2606, "states": 827, "work_ports": 2}, {"carry_bound": 18, "carry_states": 17, "coefficient": "-1/16", "denominator_twos": 4, "numerator_source": -1, "numerator_target": 16, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 4994, "states": 1599, "work_ports": 2}, {"carry_bound": 18, "carry_states": 17, "coefficient": "1/16", "denominator_twos": 4, "numerator_source": 1, "numerator_target": 16, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 4994, "states": 1599, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "1/8", "denominator_twos": 3, "numerator_source": 1, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2606, "states": 827, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "1/4", "denominator_twos": 2, "numerator_source": 1, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1402, "states": 439, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "3/8", "denominator_twos": 3, "numerator_source": 3, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2950, "states": 931, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "1/2", "denominator_twos": 1, "numerator_source": 1, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 790, "states": 243, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "3/4", "denominator_twos": 2, "numerator_source": 3, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1746, "states": 543, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "1", "denominator_twos": 0, "numerator_source": 1, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 473, "states": 142, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "5/4", "denominator_twos": 2, "numerator_source": 5, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2098, "states": 655, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "3/2", "denominator_twos": 1, "numerator_source": 3, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1118, "states": 347, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "7/4", "denominator_twos": 2, "numerator_source": 7, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2442, "states": 759, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "2", "denominator_twos": 0, "numerator_source": 2, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 617, "states": 190, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "5/2", "denominator_twos": 1, "numerator_source": 5, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1446, "states": 451, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "3", "denominator_twos": 0, "numerator_source": 3, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 761, "states": 238, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "4", "denominator_twos": 0, "numerator_source": 4, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 905, "states": 286, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "8", "denominator_twos": 0, "numerator_source": 8, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1481, "states": 478, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "10", "denominator_twos": 0, "numerator_source": 10, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1769, "states": 574, "work_ports": 2}, {"carry_bound": 9, "carry_states": 9, "coefficient": "-8", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -8, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 692, "states": 284, "work_ports": 2}, {"carry_bound": 5, "carry_states": 5, "coefficient": "-4", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -4, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 420, "states": 172, "work_ports": 2}, {"carry_bound": 3, "carry_states": 3, "coefficient": "-2", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -2, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 284, "states": 116, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 216, "states": 88, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/2", "denominator_twos": 1, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 262, "states": 108, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/4", "denominator_twos": 2, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 306, "states": 130, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/8", "denominator_twos": 3, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 352, "states": 154, "work_ports": 2}, {"carry_bound": 2, "carry_states": 1, "coefficient": "1/4", "denominator_twos": 2, "numerator_source": 0, "numerator_target": 1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 240, "states": 106, "work_ports": 2}, {"carry_bound": 2, "carry_states": 1, "coefficient": "1/2", "denominator_twos": 1, "numerator_source": 0, "numerator_target": 1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 202, "states": 86, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "2", "denominator_twos": 0, "numerator_source": 0, "numerator_target": 2, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 234, "states": 96, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "4", "denominator_twos": 0, "numerator_source": 0, "numerator_target": 4, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 370, "states": 152, "work_ports": 2}]} +PASS_CURRENT_SCALAR_FLAT_TABLES_ARITHMETIC +CHECK Normal binding source/physical/cost validation with exact receipts and declared scope. +{"caller_events": 642410, "check": "binding", "excluded_services": {"boundary-left": 3120, "boundary-right": 2808, "caller-local": 124308, "central-square": 3328, "idle-in": 3120, "idle-out": 3120, "local-entry": 13860, "local-return": 13860, "outer": 4992, "query-in": 1560, "query-out": 1560, "raw-whole-job-enter": 13444, "raw-whole-job-return": 13444}, "raw_paid": {"1": 41502, "2": 8226, "3": 8928, "4": 1800, "5": 2934, "6": 198, "7": 108, "8": 18, "16": 416, "24": 416, "32": 416, "40": 416, "48": 416, "56": 416, "64": 416, "72": 208}, "scopes": {"boundary-left": 6240, "boundary-right": 2912, "local": 346770, "outer": 9360, "query-add": 1560}, "services": 366842, "source_receipt_sha256": "cda8b8c71c3ad6f059a6f54f50e88e868487c0a9a79c72d90b12c0c2c219644b", "table_rows": 58544, "variants": 42} +PASS_CURRENT_SCALAR_FLAT_TABLES_BINDING +CHECK Normal controller source/physical/cost validation with exact receipts and declared scope. +{"actual_scalar_services": 9895, "check": "controller_prefix", "component_width": 11, "field_count": 799, "output_sha256": "4d74b866aadf4bf1f674d8a33f04e055aa45dc2c2ab7f3d44771e35f15a44910", "physical_actions": 41088794, "source_first": 1, "source_last": 9895} +PASS_CURRENT_SCALAR_FLAT_TABLES_CONTROLLER +CHECK Normal controls source/physical/cost validation with exact receipts and declared scope. +{"check": "controls", "controls": ["inexact_negative_half", "short_width_below_denominator", "late_signed_overflow", "odd_denominator_inexact", "edge_SCALE_-1/2_4", "edge_ADD_2_4", "edge_ADD_-1_4", "edge_SCALE_1/16_1", "empty_component", "missing_delimiter", "odd_component_count", "partial_physical_code", "mismatched_component_width", "mismatched_record_count", "physical_alias", "altered_coefficient", "wrong_source_site", "malformed_wrapper", "unsupported_swap_service", "corrupt_sources", "corrupt_dependencies", "reversed_final_carry", "missing_sign_extension", "omitted_physical_retirement", "shrinking_call_reuse"], "count": 25, "retained_highwater": [12713, 12728], "small_fresh_actions": 1304} +PASS_CURRENT_SCALAR_FLAT_TABLES_CONTROLS +CHECK Optimized arithmetic source/physical/cost validation with exact receipts and declared scope. +{"check": "arithmetic", "counts": {"accepted": 2887, "cases": 10870, "extra_rational_cases": 400, "physical_actions": 15799406, "rejected": 7983, "wide_accepted": 2, "wide_fields": 168, "wide_zero_fields": 168}, "variants": [{"carry_bound": 18, "carry_states": 17, "coefficient": "-16", "denominator_twos": 0, "numerator_source": -16, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2633, "states": 862, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-8", "denominator_twos": 0, "numerator_source": -8, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1481, "states": 478, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-4", "denominator_twos": 0, "numerator_source": -4, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 905, "states": 286, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "-3", "denominator_twos": 0, "numerator_source": -3, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 761, "states": 238, "work_ports": 2}, {"carry_bound": 14, "carry_states": 13, "coefficient": "-9/4", "denominator_twos": 2, "numerator_source": -9, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2794, "states": 871, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "-2", "denominator_twos": 0, "numerator_source": -2, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 617, "states": 190, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-3/2", "denominator_twos": 1, "numerator_source": -3, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1118, "states": 347, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-5/4", "denominator_twos": 2, "numerator_source": -5, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2098, "states": 655, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "-1", "denominator_twos": 0, "numerator_source": -1, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 473, "states": 142, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "-3/4", "denominator_twos": 2, "numerator_source": -3, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1746, "states": 543, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "-1/2", "denominator_twos": 1, "numerator_source": -1, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 790, "states": 243, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "-3/8", "denominator_twos": 3, "numerator_source": -3, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2950, "states": 931, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "-1/4", "denominator_twos": 2, "numerator_source": -1, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1402, "states": 439, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "-1/8", "denominator_twos": 3, "numerator_source": -1, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2606, "states": 827, "work_ports": 2}, {"carry_bound": 18, "carry_states": 17, "coefficient": "-1/16", "denominator_twos": 4, "numerator_source": -1, "numerator_target": 16, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 4994, "states": 1599, "work_ports": 2}, {"carry_bound": 18, "carry_states": 17, "coefficient": "1/16", "denominator_twos": 4, "numerator_source": 1, "numerator_target": 16, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 4994, "states": 1599, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "1/8", "denominator_twos": 3, "numerator_source": 1, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2606, "states": 827, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "1/4", "denominator_twos": 2, "numerator_source": 1, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1402, "states": 439, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "3/8", "denominator_twos": 3, "numerator_source": 3, "numerator_target": 8, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2950, "states": 931, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "1/2", "denominator_twos": 1, "numerator_source": 1, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 790, "states": 243, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "3/4", "denominator_twos": 2, "numerator_source": 3, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1746, "states": 543, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "1", "denominator_twos": 0, "numerator_source": 1, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 473, "states": 142, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "5/4", "denominator_twos": 2, "numerator_source": 5, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2098, "states": 655, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "3/2", "denominator_twos": 1, "numerator_source": 3, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1118, "states": 347, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "7/4", "denominator_twos": 2, "numerator_source": 7, "numerator_target": 4, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 2442, "states": 759, "work_ports": 2}, {"carry_bound": 4, "carry_states": 3, "coefficient": "2", "denominator_twos": 0, "numerator_source": 2, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 617, "states": 190, "work_ports": 2}, {"carry_bound": 8, "carry_states": 7, "coefficient": "5/2", "denominator_twos": 1, "numerator_source": 5, "numerator_target": 2, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1446, "states": 451, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "3", "denominator_twos": 0, "numerator_source": 3, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 761, "states": 238, "work_ports": 2}, {"carry_bound": 6, "carry_states": 5, "coefficient": "4", "denominator_twos": 0, "numerator_source": 4, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 905, "states": 286, "work_ports": 2}, {"carry_bound": 10, "carry_states": 9, "coefficient": "8", "denominator_twos": 0, "numerator_source": 8, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1481, "states": 478, "work_ports": 2}, {"carry_bound": 12, "carry_states": 11, "coefficient": "10", "denominator_twos": 0, "numerator_source": 10, "numerator_target": 1, "odd_denominator": 1, "operation": "ADD", "public_ports": 2, "rows": 1769, "states": 574, "work_ports": 2}, {"carry_bound": 9, "carry_states": 9, "coefficient": "-8", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -8, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 692, "states": 284, "work_ports": 2}, {"carry_bound": 5, "carry_states": 5, "coefficient": "-4", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -4, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 420, "states": 172, "work_ports": 2}, {"carry_bound": 3, "carry_states": 3, "coefficient": "-2", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -2, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 284, "states": 116, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1", "denominator_twos": 0, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 216, "states": 88, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/2", "denominator_twos": 1, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 262, "states": 108, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/4", "denominator_twos": 2, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 306, "states": 130, "work_ports": 2}, {"carry_bound": 2, "carry_states": 2, "coefficient": "-1/8", "denominator_twos": 3, "numerator_source": 0, "numerator_target": -1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 352, "states": 154, "work_ports": 2}, {"carry_bound": 2, "carry_states": 1, "coefficient": "1/4", "denominator_twos": 2, "numerator_source": 0, "numerator_target": 1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 240, "states": 106, "work_ports": 2}, {"carry_bound": 2, "carry_states": 1, "coefficient": "1/2", "denominator_twos": 1, "numerator_source": 0, "numerator_target": 1, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 202, "states": 86, "work_ports": 2}, {"carry_bound": 3, "carry_states": 2, "coefficient": "2", "denominator_twos": 0, "numerator_source": 0, "numerator_target": 2, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 234, "states": 96, "work_ports": 2}, {"carry_bound": 5, "carry_states": 4, "coefficient": "4", "denominator_twos": 0, "numerator_source": 0, "numerator_target": 4, "odd_denominator": 1, "operation": "SCALE", "public_ports": 1, "rows": 370, "states": 152, "work_ports": 2}]} +PASS_CURRENT_SCALAR_FLAT_TABLES_ARITHMETIC +CHECK Optimized binding source/physical/cost validation with exact receipts and declared scope. +{"caller_events": 642410, "check": "binding", "excluded_services": {"boundary-left": 3120, "boundary-right": 2808, "caller-local": 124308, "central-square": 3328, "idle-in": 3120, "idle-out": 3120, "local-entry": 13860, "local-return": 13860, "outer": 4992, "query-in": 1560, "query-out": 1560, "raw-whole-job-enter": 13444, "raw-whole-job-return": 13444}, "raw_paid": {"1": 41502, "2": 8226, "3": 8928, "4": 1800, "5": 2934, "6": 198, "7": 108, "8": 18, "16": 416, "24": 416, "32": 416, "40": 416, "48": 416, "56": 416, "64": 416, "72": 208}, "scopes": {"boundary-left": 6240, "boundary-right": 2912, "local": 346770, "outer": 9360, "query-add": 1560}, "services": 366842, "source_receipt_sha256": "cda8b8c71c3ad6f059a6f54f50e88e868487c0a9a79c72d90b12c0c2c219644b", "table_rows": 58544, "variants": 42} +PASS_CURRENT_SCALAR_FLAT_TABLES_BINDING +CHECK Optimized controller source/physical/cost validation with exact receipts and declared scope. +{"actual_scalar_services": 9895, "check": "controller_prefix", "component_width": 11, "field_count": 799, "output_sha256": "4d74b866aadf4bf1f674d8a33f04e055aa45dc2c2ab7f3d44771e35f15a44910", "physical_actions": 41088794, "source_first": 1, "source_last": 9895} +PASS_CURRENT_SCALAR_FLAT_TABLES_CONTROLLER +CHECK Optimized controls source/physical/cost validation with exact receipts and declared scope. +{"check": "controls", "controls": ["inexact_negative_half", "short_width_below_denominator", "late_signed_overflow", "odd_denominator_inexact", "edge_SCALE_-1/2_4", "edge_ADD_2_4", "edge_ADD_-1_4", "edge_SCALE_1/16_1", "empty_component", "missing_delimiter", "odd_component_count", "partial_physical_code", "mismatched_component_width", "mismatched_record_count", "physical_alias", "altered_coefficient", "wrong_source_site", "malformed_wrapper", "unsupported_swap_service", "corrupt_sources", "corrupt_dependencies", "reversed_final_carry", "missing_sign_extension", "omitted_physical_retirement", "shrinking_call_reuse"], "count": 25, "retained_highwater": [12713, 12728], "small_fresh_actions": 1304} +PASS_CURRENT_SCALAR_FLAT_TABLES_CONTROLS +PASS_REGISTERED_RESEARCH_PACKAGE research/current-scalar-flat-tables outcome=completed diff --git a/research/current-scalar-flat-tables/physical.py b/research/current-scalar-flat-tables/physical.py new file mode 100644 index 0000000000..781a0fef17 --- /dev/null +++ b/research/current-scalar-flat-tables/physical.py @@ -0,0 +1,136 @@ +"""Metered physical tape fixtures, separate from the compiled runtime. + +Only fixture construction and post-execution oracles decode integers or inspect +storage. The runtime is the unchanged source execute_table on local tape ports. +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from pathlib import Path +import importlib.util +import sys +from source_binding import check_dependencies + + +def load_module(name, path): + spec = importlib.util.spec_from_file_location(name,path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +ROOT = Path(__file__).resolve().parent +check_dependencies() +A = load_module('scalar_retained_lifecycle',ROOT/'vendor/lifecycle/machine.py') +IR = load_module('scalar_retained_source_ir',ROOT/'vendor/lifecycle/source_ir.py') + + +class Tape: + """A physical one-sided current segment; addresses are observer data only.""" + def __init__(self, symbols=(), origin=17, readonly=False, marker=A.LEFT): + self.origin = origin + self.pos = origin + self.marker = marker + self.cells = {origin-1:marker, origin-2:91} + self.cells.update({origin+i:s for i,s in enumerate(symbols)}) + self.readonly = readonly + self.actions = self.reads = self.writes = self.moves = 0 + self.highwater = origin+len(symbols) + self.floor = origin + + def tick(self): + if self.pos < self.origin-1: + raise ValueError('accessed ancestor beyond local marker') + self.highwater = max(self.highwater,self.pos) + self.floor = min(self.floor,self.pos) + self.actions += 1 + + def read(self): + self.tick(); self.reads += 1 + return self.cells.get(self.pos,A.BLANK) + + def write(self, value): + self.tick(); self.writes += 1 + if self.readonly: + raise ValueError('write to borrowed read-only source') + if self.pos < self.origin: + raise ValueError('overwrite protected origin') + if value not in range(7): + raise ValueError('physical alphabet') + self.cells[self.pos] = value + + def move(self, delta): + if delta not in (-1,1): + raise ValueError('nonunit physical move') + self.tick(); self.moves += 1 + self.pos += delta + if self.pos < self.origin-1: + raise ValueError('crossed ancestor boundary') + self.highwater = max(self.highwater,self.pos) + + def body(self): + end = self.origin + while self.cells.get(end,A.BLANK) != A.BLANK: + end += 1 + return tuple(self.cells.get(i,A.BLANK) for i in range(self.origin,end)) + + def blank(self): + return all(s == A.BLANK for i,s in self.cells.items() if i >= self.origin) + + def sentinel_ok(self): + return self.cells[self.origin-1] == self.marker and self.cells[self.origin-2] == 91 + + +def encode_symbols(symbols): + return tuple((s>>k)&1 for s in symbols for k in (2,1,0)) + + +def symbols_for(values, width): + if width < 1: + raise ValueError('positive fixture width') + out = [] + for value in values: + if not -(1<<(width-1)) <= value < (1<<(width-1)): + raise ValueError('fixture value outside signed width') + out.extend((value>>j)&1 for j in range(width)) + out.append(2) + return tuple(out) + + +def decode_body(body, width): + if len(body)%3: + raise ValueError('partial physical codeword') + syms = [4*body[i]+2*body[i+1]+body[i+2] for i in range(0,len(body),3)] + block = width+1 + if len(syms)%block: + raise ValueError('partial fixture component') + values = [] + for i in range(0,len(syms),block): + bits = syms[i:i+width] + if any(x not in (0,1) for x in bits) or syms[i+width] != 2: + raise ValueError('corrupt numeric component') + value = sum(x<> shift) & 1) + for _ in range(3): + self.tape.move(-1) + + def move(self, direction): + need(direction in (-1, 1), "virtual unit move") + t = self.tape + if direction == 1: + if t.read() == BLANK: + self.write(4) + for _ in range(3): + t.move(1) + else: + t.move(-1) + if t.read() == LEFT: + t.move(1) + raise ValueError("native routine crossed its local origin") + t.move(-1) + t.move(-1) + + +class BinaryContextPort: + """Read-only raw binary descriptor, with its own physical alphabet. + + Unlike CodedPort, read returns physical BLANK=6 at the frontier. A table + may inspect that frontier but cannot pass it or the current LEFT marker. + This supplies runtime e/f/K/rho data through counted local operations. + """ + __slots__ = ("tape",) + + def __init__(self, tape): + self.tape = tape + + def read(self): + symbol = self.tape.read() + need(symbol in (ZERO, ONE, BLANK), "binary context alphabet") + return symbol + + def write(self, value): + raise ValueError("native context is read-only") + + def move(self, direction): + need(direction in (-1, 1), "binary context unit move") + t = self.tape + if direction == 1: + need(t.read() in (ZERO, ONE), "context frontier cannot be crossed") + t.move(1) + else: + t.move(-1) + if t.read() == LEFT: + t.move(1) + raise ValueError("native context crossed its local origin") + + +def read_code(tape): + """Consume a numeric-format code; physical frontier returns None.""" + if tape.read() == BLANK: + return None + value = 0 + for _ in range(3): + bit = tape.read() + need(bit in (ZERO, ONE), "numeric codeword") + value = 2 * value + bit + tape.move(1) + need(value < 7, "unused numeric codeword") + return value + + +def write_code(tape, value): + for shift in (2, 1, 0): + emit(tape, (value >> shift) & 1) + + +def initialize(target, shape): + """Dispose of arbitrary old bytes, then zero the complete common format.""" + need(target is not shape, "private initialization cannot destroy its guide") + retire(target) + origin(shape) + in_component = False + while (symbol := read_code(shape)) is not None: + need(symbol in (ZERO, ONE, COMPONENT), "canonical signed components") + if symbol == COMPONENT: + need(in_component, "positive component width") + write_code(target, COMPONENT) + in_component = False + else: + write_code(target, ZERO) + in_component = True + need(not in_component, "component terminator") + origin(shape) + origin(target) + + +def copy_as_add(target, source): + """Signed addition into the actual destination, including any residue. + + Components are little-endian two's complement followed by COMPONENT. + Carries reset at delimiters; equal-sign signed overflow rejects. + No ideal-zero test or exact-value overwrite substitutes for addition. + """ + need(target is not source, "distinct COPY/ADD ports") + origin(source) + origin(target) + carry = 0 + last_a = last_b = last_out = 0 + in_component = False + while True: + a = read_code(source) + b = read_code(target) + need((a is None) == (b is None), "same complete numerical extent") + if a is None: + need(not in_component, "complete signed component") + break + need(a in (ZERO, ONE, COMPONENT) and b in (ZERO, ONE, COMPONENT), + "canonical signed addition operands") + need((a == COMPONENT) == (b == COMPONENT), "same component boundaries") + if a == COMPONENT: + need(in_component, "positive signed component width") + need(last_a != last_b or last_out == last_a, "signed addition overflow") + carry = 0 + in_component = False + continue + value = a + b + carry + last_a, last_b, last_out = a, b, value & 1 + carry = value >> 1 + for _ in range(3): + target.move(-1) + write_code(target, last_out) + in_component = True + origin(source) + origin(target) + + +def execute_table(table, ports, readonly_context=()): + """Run a supplied finite native table with every port confined. + + These tables retain explicit semantics/time/space premises. Fixture + tables are not advertised as Gaussian implementations. + """ + views = (tuple(CodedPort(t) for t in ports) + + tuple(BinaryContextPort(t) for t in readonly_context)) + pc = 0 + while True: + row = table[pc] + op = row[0] + if op == "halt": + break + if op == "reject": + raise ValueError(row[1]) + if op == "goto": + pc = row[1] + continue + view = views[row[1]] + if op == "branch": + pc = dict(row[2]).get(view.read(), row[3]) + continue + if op == "write": + view.write(row[2]) + elif op == "move": + view.move(row[2]) + else: + raise ValueError("native table opcode") + pc += 1 + for tape in tuple(ports)+tuple(readonly_context): + origin(tape) + + +@dataclass(frozen=True) +class Instruction: + op: str + ports: tuple = () + token: tuple = () + + +class Controller: + """Fixed finite controller of a fixed flat compiled template. + + rows implements the separately priced row/shape interface; all its + dynamic state belongs on the supplied tapes. services contains fixed + finite transition tables. Payload ports include metadata and all scratch. + The only runtime continuation is the physical Stack. + """ + def __init__(self, program, public_count, payloads, control, descriptor, + bridge, child_header, rows, services, stack_class, protected_ports=(), + primitive_work=(), primitive_context=()): + self.program = tuple(program) + self.public_count = public_count + self.payloads = tuple(payloads) + self.control = control + self.descriptor = descriptor + self.bridge = bridge + self.child_header = child_header + self.rows = rows + self.services = services + need(len({id(t) for t in self.payloads+(control,descriptor,bridge,child_header)}) + == len(self.payloads)+4, "all physical ports distinct") + self.stack = stack_class(self.payloads, control, descriptor) + self.protected_ports = tuple(protected_ports) + owned = {e.ports[0] for e in self.program if e.op == "INIT"} + need(all(public_count <= i < len(self.payloads) for i in owned), "INIT only private physical slots") + need(owned.isdisjoint(self.protected_ports), "owned fields cannot be borrowed descriptors") + self.root_cleanup = tuple(i for i in range(public_count,len(self.payloads)) + if i not in self.protected_ports) + self.primitive_work = tuple(primitive_work) + self.primitive_context = tuple(primitive_context) + data_ports = {i for e in self.program for i in e.ports} + need(all(0 <= i < len(self.payloads) for i in data_ports), "compiled port range") + need(all(i >= public_count and i < len(self.payloads) and i not in data_ports + and i not in self.protected_ports for i in self.primitive_work), "separate primitive scratch") + need(len(set(self.primitive_work)) == len(self.primitive_work), "distinct primitive work ports") + need(len(set(self.primitive_context)) == len(self.primitive_context) + and all(i in self.protected_ports and 0 <= i < len(self.payloads) + and i not in data_ports for i in self.primitive_context), "borrowed binary context ports") + self.pc_bits = max(1, (len(self.program) - 1).bit_length()) + self.pc_words = tuple(tuple((pc >> j) & 1 for j in range(self.pc_bits)) + for pc in range(len(self.program))) + need(self.program and self.program[-1].op == "RET", "finite completed program") + + def save_pc(self, pc): + need(self.descriptor.read() == BLANK, "empty active PC descriptor") + for bit in self.pc_words[pc]: + emit(self.descriptor, bit) + origin(self.descriptor, BASE) + + def consume_pc(self): + pc = 0 + for shift in range(self.pc_bits): + bit = self.descriptor.read() + need(bit in (ZERO, ONE), "binary return PC") + pc |= bit << shift + emit(self.descriptor, BLANK) + need(self.descriptor.read() == BLANK, "exact fixed return PC width") + origin(self.descriptor, BASE) + need(pc < len(self.program) and pc > 0 and self.program[pc-1].op == "PAID", + "return PC designates a paid continuation") + return pc + + def has_parent(self): + self.control.move(-1) + symbol = self.control.read() + self.control.move(1) + need(symbol in (BASE, END), "complete continuation top") + return symbol == END + + def descend(self, pc): + event = self.program[pc] + source = self.payloads[event.ports[0]] + transfer(source, self.bridge, target_marker=BASE) + self.rows.prepare(event.token, self.child_header) + self.save_pc(pc + 1) + self.stack.push((True,) * len(self.payloads)) + self.rows.install(self.bridge, self.child_header, + self.payloads[:self.public_count]) + retire(self.bridge, BASE) + retire(self.child_header, BASE) + + def primitive(self, token, fields): + for i in self.primitive_work: + retire(self.payloads[i]) + execute_table(self.services[token], + tuple(self.payloads[i] for i in fields+self.primitive_work), + tuple(self.payloads[i] for i in self.primitive_context)) + for i in self.primitive_work: + retire(self.payloads[i]) + + def ascend(self): + self.rows.collect(self.payloads[:self.public_count], self.bridge) + for tape in self.payloads: + retire(tape) + self.stack.pop() # ignore observer sizes and heads + pc = self.consume_pc() + target = self.payloads[self.program[pc-1].ports[0]] + retire(target) + transfer(self.bridge, target, source_marker=BASE) + retire(self.bridge, BASE) + return pc + + def run(self, observe=None): + pc = 0 + while True: + event = self.program[pc] + if observe is not None: + observe("before", pc, event) # checker only; ignores return value + if event.op == "INIT": + initialize(self.payloads[event.ports[0]], self.payloads[0]) + pc += 1 + elif event.op == "CLEAR": + retire(self.payloads[event.ports[0]]) + pc += 1 + elif event.op == "COPY": + copy_as_add(self.payloads[event.ports[0]], self.payloads[event.ports[1]]) + pc += 1 + elif event.op == "SERVICE": + self.primitive(event.token,event.ports) + pc += 1 + elif event.op == "PAID": + if self.rows.is_leaf(event.token): + self.primitive(("leaf",)+event.token,event.ports) + pc += 1 + else: + self.descend(pc) + pc = 0 + elif event.op == "RET": + if not self.has_parent(): + for i in self.root_cleanup: + retire(self.payloads[i]) + break + pc = self.ascend() + else: + raise ValueError("compiled opcode") + if observe is not None: + observe("after", pc, event) + + +def boundary_actions(q, b, parent_total, child_total, input_length, + output_length, staged_header_length): + """Exact descend+ascend actions, excluding the three row-service calls. + + Also excludes caller leaf/top tests. All heads are at local origins. + Includes PC, all retirement, occupied-target replacement and both relays. + """ + return (4 * parent_total + 5 * child_total + 18 * input_length + + 13 * output_length + 5 * staged_header_length + + 38 * q + 27 * b + 103) diff --git a/research/current-scalar-flat-tables/vendor/lifecycle/source_ir.py b/research/current-scalar-flat-tables/vendor/lifecycle/source_ir.py new file mode 100644 index 0000000000..79c95fa794 --- /dev/null +++ b/research/current-scalar-flat-tables/vendor/lifecycle/source_ir.py @@ -0,0 +1,522 @@ +"""Source-driven lifecycle IR and finite compiler lowering. + +All recursion/dictionaries here belong to template construction, before runtime +input size varies. machine.py executes the resulting fixed finite program. +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from collections import Counter +from dataclasses import dataclass +from fractions import Fraction + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +@dataclass(frozen=True) +class Event: + op: str + fields: tuple + token: tuple = () + rank: int = 0 + + +@dataclass(frozen=True) +class Unit: + name: str + roles: tuple + owned: tuple + events: tuple + + def check(self): + public = {name for name, rank in self.roles} + private = set(self.owned) + need(len(public) == len(self.roles) and len(private) == len(self.owned), "unique unit names") + need(public.isdisjoint(private), "public/private name separation") + need(all(type(r) is int and r >= 1 for _, r in self.roles), "positive target ranks") + live = set() + for e in self.events: + need(e.op in ("INIT", "CLEAR", "COPY", "SERVICE", "PAID"), "unit opcode") + if e.op == "INIT": + need(len(e.fields) == 1 and e.fields[0] in private and e.fields[0] not in live, "fresh private INIT") + live.add(e.fields[0]) + elif e.op == "CLEAR": + need(len(e.fields) == 1 and e.fields[0] in live, "CLEAR only own live bank") + live.remove(e.fields[0]) + else: + need(e.fields and all(f in public or f in live for f in e.fields), "use outside private lifetime") + if e.op == "COPY": + need(len(e.fields) == 2 and e.fields[0] in live + and e.fields[0] != e.fields[1], "private COPY ports") + if e.op == "PAID": + need(len(e.fields) == 1 and type(e.rank) is int and e.rank > 0, "positive whole paid job") + need(not live, "all private lifetimes end") + return self + + def pieces(self): + fragments, rounds = [[]], [] + for e in self.events: + if e.op == "PAID": + rounds.append(e) + fragments.append([]) + else: + fragments[-1].append(e) + return tuple(tuple(f) for f in fragments), tuple(rounds) + + +def remap(event, names, context=(), rank_factor=1): + return Event(event.op, tuple(names[f] for f in event.fields), + context + (event.token,), event.rank * rank_factor) + + +def product(left, right): + """p7-TENSOR chronological substitution; never tensor an operator sum.""" + left.check(); right.check() + lf, lr = left.pieces() + roles = tuple(((i,j),k*h) for i,k in left.roles for j,h in right.roles) + owned, maps, events = [], {}, [] + for j,h in right.roles: + maps[j] = {i:(i,j) for i,_ in left.roles} + for o in left.owned: + fresh = ("left",j,o) + owned.append(fresh); maps[j][o] = fresh + for j,h in right.roles: + for i,_ in left.roles: + events.append(Event("SERVICE",((i,j),),("product-left-enter",j,h,i))) + for ell in range(len(lr)+1): + for j,h in right.roles: + events += [remap(e,maps[j],("product-left",j,h)) for e in lf[ell]] + if ell == len(lr): + break + issuing = lr[ell] + names = {j:maps[j][issuing.fields[0]] for j,_ in right.roles} + need(len(set(names.values())) == len(names), "distinct product request owners") + for o in right.owned: + fresh = ("right",ell,o) + owned.append(fresh); names[o] = fresh + events += [Event("SERVICE",(names[j],),("product-enter",ell,j,issuing.token)) for j,_ in right.roles] + events += [remap(e,names,("product-right",ell,issuing.rank,issuing.token),issuing.rank) for e in right.events] + events += [Event("SERVICE",(names[j],),("product-return",ell,j,issuing.token)) for j,_ in right.roles] + for j,h in right.roles: + for i,_ in left.roles: + events.append(Event("SERVICE",((i,j),),("product-left-return",j,h,i))) + return Unit(left.name+"*"+right.name,roles,tuple(owned),tuple(events)).check() + + +def completion_split(unit, cutoff, floor): + unit.check() + need(0 < cutoff < floor <= max(k for _,k in unit.roles), "completion/splitting domain") + completed = [(name,k) for name,k in unit.roles if k < floor] + events = [Event("SERVICE",(name,),("whole-job-in",k,floor)) for name,k in completed] + extended = list(unit.events) + for name,k in completed: + extended.append(Event("PAID",(name,),("completion",k,floor),floor-k)) + for e in extended: + if e.op != "PAID": + events.append(e); continue + start = 0 + while start < e.rank: + size = min(cutoff,e.rank-start) + token = ("piece",start,size,e.rank,e.token) + events += [Event("SERVICE",e.fields,("piece-enter",)+token), + Event("PAID",e.fields,token,size), + Event("SERVICE",e.fields,("piece-return",)+token)] + start += size + events += [Event("SERVICE",(name,),("whole-job-out",k,floor)) for name,k in completed] + return Unit(unit.name+"/pass",tuple((name,max(k,floor)) for name,k in unit.roles), + unit.owned,tuple(events)).check() + + +def current_local(word): + """Retain every current #6030 operand, chart, lifetime and paid position. + + No all-column algebra is redone. MOVE ranks are the dimension differences + in the authenticated source rule, with their native meaning retained. + """ + p,o = word["public"],word["owned_fields"] + frames = word["frames"] + current = list(word["initial"])+[None]*o + live,untouched,starts,episodes = set(),set(),{},[] + events,moves,peak = [],Counter(),0 + for pc,raw in enumerate(word["program"]): + op,r = raw[:2] + need(type(r) is int and 0 <= r < p+o,"current local role") + token = ("local",pc,tuple(raw)) + if op == "INIT": + need(p <= r and r not in live,"current fresh private INIT") + live.add(r); untouched.add(r); starts[r] = pc + current[r] = raw[2]; peak = max(peak,len(live)) + events.append(Event("INIT",(r,),token)) + elif op == "CLEAR": + need(r in live and current[r] == raw[2],"current owned CLEAR chart") + live.remove(r); untouched.discard(r) + episodes.append((r,starts.pop(r),pc)); current[r] = None + events.append(Event("CLEAR",(r,),token)) + elif op == "MOVE": + need(len(raw) == 5 and type(raw[4]) is bool,"typed private MOVE flag") + need(current[r] == raw[2] and (r in live) == raw[4],"current MOVE owner and chart") + need(r < p or r in live,"live MOVE source") + rank = abs(len(frames[raw[3]])-len(frames[raw[2]])) + need(rank > 0,"current positive MOVE rank") + current[r] = raw[3]; moves[rank] += 1 + untouched.discard(r) + events += [Event("SERVICE",(r,),("move-in",)+token), + Event("PAID",(r,),token,rank), + Event("SERVICE",(r,),("move-out",)+token)] + else: + need(op in ("COPY","ADD","SCALE") and current[r] == raw[-1],"current scalar destination chart") + need(r < p or r in live,"live scalar destination") + coefficient = Fraction(raw[-2]) + need(coefficient != 0,"nonzero source coefficient") + if op == "SCALE": + fields = (r,) + else: + src = raw[2] + need(type(src) is int and 0 <= src < p+o and src != r,"current distinct scalar source") + need((src < p or src in live) and current[src] == raw[-1],"current common scalar chart") + fields = (r,src) + if op == "COPY": + need(r in untouched and coefficient == 1,"current COPY follows untouched INIT with coefficient one") + events.append(Event("COPY",fields,token)) + else: + events.append(Event("SERVICE",fields,token)) + untouched.discard(r) + need(not live and current[:p] == word["final"],"current complete local exit") + return tuple(events),dict(events=len(word["program"]),owned_labels=o, + owned_lifetimes=len(episodes),peak_live=peak, + episodes=episodes,paid=dict(sorted(moves.items()))) + + +def current_caller(word,caller): + """Exact outer/local field maps and explicit copied-query lifetimes. + + Named contact/normalizer/query services retain source endpoint meanings. + Every original scalar/MOVE token and its chronology are preserved. + """ + local_events,report = current_local(word) + ports = tuple(word["live"]) + need(len(ports) == len(set(ports)) == 104,"current 104 ports") + need((caller["kind"],caller["pairs"],caller["prefix_pairs"],caller["ambient_rank"]) + == ("complex",16,7,145),"current physical caller family") + main_local = set(ports)|{x+112 for x in ports} + helpers = sorted(set(range(word["public"]))-main_local) + locals_ = [e for e in caller["physical_events"] if e[0] == "LOCAL"] + need(len(locals_) == 18 and all(not e[3] for e in locals_),"current forward local sites") + public = 32*104+18*len(helpers) + own_first,query_first = public,public+18*word["owned_fields"] + owned = tuple(range(public,query_first+104)) + roles = [] + for i,term in enumerate(caller["diagonal"]): + stages = term[1:] + rank = (9 if stages[0] else 1)+8*sum(stages[1:]) + roles += [(i*104+j,rank) for j in range(104)] + events,local_sites,query_sites = [],[],[] + def scalar(raw,context): + for j in range(104): + fields = (raw[1]*104+j,) if raw[0] == "SCALE" else (raw[1]*104+j,raw[2]*104+j) + events.append(Event("SERVICE",fields,context+(j,tuple(raw)))) + for raw in caller["boundaries"]["right_program"]: + scalar(raw,("boundary-right",)) + local_number = 0 + for site,raw in enumerate(caller["physical_events"]): + op = raw[0] + if op == "LOCAL": + _,stage,pair,reverse = raw + need(not reverse,"all-forward local occurrence") + names = {} + for j,r in enumerate(ports): + names[r] = 2*pair*104+j; names[r+112] = (2*pair+1)*104+j + for j,r in enumerate(helpers): + field = 32*104+local_number*len(helpers)+j + names[r] = field + rank = len(word["frames"][word["final"][r]])-len(word["frames"][word["initial"][r]]) + roles.append((field,rank)) + for j in range(word["owned_fields"]): + names[word["public"]+j] = own_first+local_number*word["owned_fields"]+j + need(len(names) == len(set(names.values())) == word["public"]+word["owned_fields"], + "injective complete current local grant") + for r in range(word["public"]): + events.append(Event("SERVICE",(names[r],),("local-entry",site,stage,r))) + events += [remap(e,names,("caller-local",site,stage)) for e in local_events] + for r in range(word["public"]): + events.append(Event("SERVICE",(names[r],),("local-return",site,stage,r))) + local_sites.append((site,stage,tuple(sorted(names.items())))); local_number += 1 + elif op == "QUERY_SHEAR": + _,stage,pair,reverse = raw + need(not reverse,"current forward query") + for j in range(104): + x,y,z = 2*pair*104+j,(2*pair+1)*104+j,query_first+j + token = ("query",site,stage,j) + events += [Event("INIT",(z,),token),Event("COPY",(z,x),token), + Event("SERVICE",(z,),("query-in",)+token),Event("PAID",(z,),token,1), + Event("SERVICE",(z,),("query-out",)+token), + Event("SERVICE",(y,z),("query-add",)+token),Event("CLEAR",(z,),token)] + query_sites.append((site,j,x,y,z)) + elif op == "IDLE": + for side in (0,1): + for j in range(104): + field = (2*raw[1]+side)*104+j + token = ("idle",site,tuple(raw[2]),side,j) + events += [Event("SERVICE",(field,),("idle-in",)+token), + Event("PAID",(field,),token,8*len(raw[2])), + Event("SERVICE",(field,),("idle-out",)+token)] + elif op == "Q_POWER": + for j in range(104): + events.append(Event("SERVICE",(raw[1]*104+j,),("central-square",site,j,raw[2]))) + else: + need(op in ("ADD","SWAP","SIGNED_SWAP"),"current outer scalar opcode") + scalar(raw,("outer",site)) + for raw in caller["boundaries"]["left_program"]: + scalar(raw,("boundary-left",)) + roles = tuple(sorted(roles)) + need([r for r,_ in roles] == list(range(public)),"every productive field supplied once") + # The pinned occurrence theorem supplies the complete 145-coordinate + # whole-job canonicalizers. Each is a charged service, never a free name. + events = ([Event("SERVICE",(r,),("raw-whole-job-enter",r,k)) for r,k in roles] + +events+[Event("SERVICE",(r,),("raw-whole-job-return",r,k)) for r,k in roles]) + unit = Unit("selected6030",roles,owned,tuple(events)).check() + report.update(public_count=public,raw_owned=len(owned),local_sites=len(local_sites), + query_lifetimes=len(query_sites),total_lifetimes=18*report["owned_lifetimes"]+len(query_sites), + raw_paid=dict(sorted(Counter(e.rank for e in events if e.op=="PAID").items())), + raw_targets=dict(sorted(Counter(k for _,k in roles).items())),raw_events=len(events)) + return unit,report + + +def lower(unit,rank,source): + """Refine #5443's unchanged matching, with no partial/interface fallback. + + Insert all inter-round fragments before a class is suspended. Flatten + finite compiler substitutions; only rank-one leaves make runtime children. + """ + unit.check() + fragments,rounds = unit.pieces() + need(rounds,"nonempty paid word") + need(max(e.rank for e in rounds)= self.floor, 'ancestor prefix accessed') + return self.cells[self.head] if self.head < len(self.cells) else BLANK + + def write(self, value): + need(value in range(7), 'finite tape alphabet') + need(self.head >= self.floor, 'ancestor prefix overwritten') + self.counts.writes += 1 + while len(self.cells) <= self.head: + self.cells.append(BLANK) + self.cells[self.head] = value + + def move(self, direction): + need(direction in (-1, 1), 'unit move') + self.counts.moves += 1 + self.head += direction + need(self.head >= self.floor, 'ancestor prefix crossed') + + +def emit(tape, symbol): + tape.write(symbol) + tape.move(1) + + +def rewind(tape, marker): + tape.move(-1) + while tape.read() != marker: + tape.move(-1) + tape.move(1) + + +def clear_descriptor(tape): + """Entry and exit are at the descriptor origin.""" + while (symbol := tape.read()) != BLANK: + need(symbol in (ZERO, ONE), 'binary descriptor') + emit(tape, BLANK) + rewind(tape, BASE) + + +class Stack: + """No saved frame, parent pointer, frame size or origin is stored here.""" + def __init__(self, payloads, control, descriptor): + self.payloads = tuple(payloads) + self.control = control + self.descriptor = descriptor + + def push(self, present): + need(len(present) == len(self.payloads), 'fixed role bitmap') + c = self.control + need(c.read() == BLANK, 'control at free top') + emit(c, LEFT) + for tape, occupied in zip(self.payloads, present): + need(type(occupied) is bool, 'role presence bit') + emit(c, int(occupied)) + tape.move(-1) + while (symbol := tape.read()) != LEFT: + need(symbol in (ZERO, ONE), 'binary prefix before current head') + emit(c, ONE) + tape.move(-1) + emit(c, ZERO) + tape.move(1) + if not occupied: + need(tape.read() == BLANK, 'absent role is empty') + while (symbol := tape.read()) != BLANK: + need(symbol in (ZERO, ONE), 'binary parent payload') + tape.move(1) + emit(tape, LEFT) + emit(c, SEP) + d = self.descriptor + while (symbol := d.read()) != BLANK: + need(symbol in (ZERO, ONE), 'binary descriptor') + emit(c, symbol) + emit(d, BLANK) + rewind(d, BASE) + emit(c, END) + + def pop(self): + """Child payloads are empty at their origins; clear its descriptor. + + Returned sizes/heads are observer counts for the source API adapter. + No branch or tape move uses those counts. + """ + clear_descriptor(self.descriptor) + c = self.control + c.move(-1) + need(c.read() == END, 'complete control frame') + c.move(-1) + while (symbol := c.read()) != LEFT: + need(symbol in (ZERO, ONE, SEP), 'frame start before ancestor boundary') + c.move(-1) + emit(c, BLANK) + state = [] + for tape in self.payloads: + present = c.read() + need(present in (ZERO, ONE), 'role presence bit') + emit(c, BLANK) + need(tape.read() == BLANK, 'child payload is retired') + tape.move(-1) + need(tape.read() == LEFT, 'child delimiter') + tape.write(BLANK) + tape.move(-1) + size = 0 + while (symbol := tape.read()) != LEFT: + need(symbol in (ZERO, ONE), 'parked parent payload') + size += 1 + tape.move(-1) + tape.move(1) + if not present: + need(tape.read() == BLANK, 'absent parent role is empty') + head = 0 + while (symbol := c.read()) == ONE: + need(tape.read() in (ZERO, ONE), 'saved head is within payload') + tape.move(1) + head += 1 + emit(c, BLANK) + need(symbol == ZERO, 'terminated unary head') + emit(c, BLANK) + state.append((bool(present), size, head)) + need(c.read() == SEP, 'complete fixed-role header') + emit(c, BLANK) + d = self.descriptor + while (symbol := c.read()) != END: + need(symbol in (ZERO, ONE), 'binary saved descriptor') + emit(d, symbol) + emit(c, BLANK) + c.write(BLANK) + c.move(-1) + while c.read() == BLANK: + c.move(-1) + need(c.read() in (BASE, END), 'previous control top') + c.move(1) + rewind(d, BASE) + return state diff --git a/research/current-scalar-flat-tables/verify.py b/research/current-scalar-flat-tables/verify.py new file mode 100644 index 0000000000..6d3a2b7269 --- /dev/null +++ b/research/current-scalar-flat-tables/verify.py @@ -0,0 +1,194 @@ +"""Bounded physical, exact-oracle and source-binding verification. + +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from pathlib import Path +from collections import Counter +from fractions import Fraction +import argparse +import gzip +import hashlib +import json +import random +import sys + +sys.path.insert(0,str(Path(__file__).resolve().parent)) +from tables import compile_scalar, bind_services, source_literal, need +from physical import A, IR, ROOT, Tape, execute, encode_symbols, symbols_for, decode_body, load_module +from source_binding import check_inputs + + +def repository(): + return ROOT.parents[1] + + +def inputs(): + check_inputs() + word = json.loads(gzip.decompress((repository()/'research/p104-helper470-twin-rung-removal/WORD.json.gz').read_bytes())) + caller = json.loads((repository()/'research/p104-productive-controller/CONTROLLER.json').read_text()) + return word,caller + + +def check_case(table,op,q,xs,ys,width): + expected = [Fraction(x)+(q*y) if op=='ADD' else q*x for x,y in zip(xs,ys)] + allowed = all(z.denominator==1 and -(1<<(width-1)) <= z < 1<<(width-1) for z in expected) + result = execute(table,op,xs,ys,width) + need((result['error'] is None)==allowed,'exact representability/range iff') + public,work = result['public'],result['work'] + need(all(t.sentinel_ok() for t in public+work),'protected ancestor sentinels') + if allowed: + need(result['output']==tuple(int(z) for z in expected),'independent Fraction endpoint') + need(len(public[0].body())==len(result['before'][0]),'exact complete target extent') + need(all(t.blank() for t in work),'physical scratch erased on success') + need(all(t.pos==t.origin for t in public+work),'complete origin return') + d=0;b=q.denominator + while b%2==0:d+=1;b//=2 + length=len(xs)*(width+1) + need(result['actions'] <= 1024*(d+2)*(length+1),'proven complete linear cell-action ceiling') + need(work[0].highwater-work[0].origin <= 3*length,'output high-water bound') + need(work[1].highwater-work[1].origin <= 3*(length+1),'guide high-water bound') + else: + need(public[0].body()==result['before'][0] and public[0].writes==0, + 'whole-field arithmetic rejection precedes every target write') + if op=='ADD': + need(public[1].body()==result['before'][1] and public[1].writes==0,'borrowed source preserved') + return int(allowed),result['actions'] + + +def arithmetic(): + word,_=inputs() + variants=sorted({(e[0],Fraction(e[-2])) for e in word['program'] if e[0] in ('ADD','SCALE')}) + counters=Counter();records=[] + for op,q in variants: + table,receipt=compile_scalar(op,q);records.append(receipt) + for width in range(1,5): + values=range(-(1<<(width-1)),1<<(width-1)) + for x in values: + for y in values if op=='ADD' else (0,): + passed,actions=check_case(table,op,q,(x,x),(y,y),width) + counters['cases']+=1;counters['accepted']+=passed + counters['rejected']+=1-passed;counters['physical_actions']+=actions + # Deterministic wide complete fields: zero, extrema, equal/correlated + # operands, multiple records, and both integer and inexact divisions. + rng=random.Random(6030) + for width in (5,16,65,129): + edge=1<<(width-1) + xs=(-edge,edge-1,0,0,rng.randrange(-edge,edge),rng.randrange(-edge,edge)) + ys=(-edge,edge-1,0,1,rng.randrange(-edge,edge),rng.randrange(-edge,edge)) + passed,actions=check_case(table,op,q,xs,ys,width) + counters['wide_fields']+=1;counters['wide_accepted']+=passed + counters['physical_actions']+=actions + # Universally admitted multi-record positive control for each q. + xs=(0,0,0,0,0,0);ys=(0,0,0,0,0,0) + passed,actions=check_case(table,op,q,xs,ys,width) + need(passed,'wide zero control');counters['wide_zero_fields']+=1 + counters['physical_actions']+=actions + # General rational theorem checks beyond the concrete dyadic catalogue. + for op,q in [('SCALE',Fraction(1,3)),('SCALE',Fraction(-7,6)),('ADD',Fraction(1,5))]: + table,_=compile_scalar(op,q) + for width in range(1,5): + values=range(-(1<<(width-1)),1<<(width-1)) + for x in values: + for y in values if op=='ADD' else (0,): + passed,actions=check_case(table,op,q,(x,x),(y,y),width) + counters['extra_rational_cases']+=1 + counters['physical_actions']+=actions + return dict(check='arithmetic',counts=dict(counters),variants=records) + + +def binding(): + word,caller=inputs() + unit,summary=IR.current_caller(word,caller) + supported=[];scopes=Counter();variants=Counter();excluded=Counter() + for event in unit.events: + if event.op!='SERVICE':continue + try:op,q,origin=source_literal(event,word,caller) + except ValueError:excluded[event.token[0]]+=1 + else: + supported.append(event);scopes[origin[0]]+=1;variants[(op,str(q))]+=1 + need(len(supported)==366842,'complete selected arithmetic service coverage') + need(dict(scopes)=={'boundary-right':2912,'local':346770,'query-add':1560, + 'outer':9360,'boundary-left':6240},'exact caller scope partition') + services,receipts,origins=bind_services(supported,word,caller) + need(len(receipts)==42 and len(origins)==366842,'full source catalogue') + # Preserve exact semantics through the actual source remap API. Neither + # raw role numbers nor equal-rank substitutes are used as physical ports. + original=next(e for e in supported if e.token[0]=='caller-local') + names={f:('actual-bank',j) for j,f in enumerate(original.fields)} + remapped=IR.remap(original,names,('unit-fragment',7,11,3,0)) + op,q,origin=source_literal(remapped,word,caller) + need(remapped.fields==tuple(names[f] for f in original.fields),'actual mapped owners') + need((op,q,origin)==source_literal(original,word,caller),'nested scalar semantics') + # A chronological product carries an issuing MOVE token separately from + # the active scalar. Follow the original wrapper's last member only. + issuing=next(e for e in IR.current_local(word)[0] if e.op=='PAID') + right=IR.remap(original,{f:f for f in original.fields}, + ('product-right',3,issuing.rank,issuing.token)) + left=IR.remap(right,{f:f for f in right.fields},('product-left',2,7)) + nested=IR.remap(left,{f:f for f in left.fields},('unit-fragment',7,11,3,0)) + need(source_literal(nested,word,caller)==(op,q,origin), + 'active scalar separated from issuing paid provenance') + rows=sum(x['rows'] for x in receipts) + return dict(check='binding',caller_events=len(unit.events),services=len(origins), + variants=len(receipts),table_rows=rows,scopes=dict(scopes), + excluded_services=dict(excluded),raw_paid=summary['raw_paid'], + source_receipt_sha256=hashlib.sha256(json.dumps(origins,separators=(',',':')).encode()).hexdigest()) + + +def controller_prefix(): + word,caller=inputs() + raw,summary=IR.current_local(word) + # The actual first scalar block, after source INIT(778) and before its + # first native MOVE. All its owners are borrowed complete fields here. + events=[] + for event in raw[1:]: + if event.op!='SERVICE' or event.token[0]!='local':break + events.append(event) + need(len(events)==9895 and events[0].token[1]==1 and events[-1].token[1]==9895, + 'actual uninterrupted selected source block') + services,_,_=bind_services(events,word) + n=word['public']+word['owned_fields'];width=11 + values=[(16*(i%7-3),16*(i%5-2)) for i in range(word['public'])] + values += [(0,0) for _ in range(word['owned_fields'])] + expected=[list(v) for v in values] + for event in events: + op,q,_=source_literal(event,word) + target=event.fields[0] + if op=='SCALE':expected[target]=[q*x for x in expected[target]] + else:expected[target]=[x+q*y for x,y in zip(expected[target],expected[event.fields[1]])] + need(all(Fraction(x).denominator==1 and -1024<=x<1024 for x in expected[target]), + 'source-prefix exact oracle admission') + public=[Tape(encode_symbols(symbols_for(v,width)),origin=17+5*i) for i,v in enumerate(values)] + context=Tape((1,0,1,0,0,1),origin=5000,readonly=True) + work=[Tape(origin=5100),Tape(origin=5200)] + payloads=tuple(public+[context]+work) + stack=load_module('scalar_retained_stack',ROOT/'vendor/stack.py') + program=tuple(A.Instruction('SERVICE',e.fields,e.token) for e in events)+(A.Instruction('RET'),) + admin=[Tape(origin=6000+100*i,marker=A.BASE) for i in range(4)] + controller=A.Controller(program,n,payloads,*admin,rows=None,services=services, + stack_class=stack.Stack,protected_ports=(n,), + primitive_work=(n+1,n+2),primitive_context=(n,)) + controller.run() + observed=[decode_body(t.body(),width) for t in public] + need(observed==[tuple(int(x) for x in v) for v in expected],'actual Controller exact source-prefix endpoint') + need(context.body()==(1,0,1,0,0,1),'borrowed context preserved') + need(all(t.blank() for t in work),'actual Controller work retirement') + need(all(t.pos==t.origin and t.sentinel_ok() for t in payloads+tuple(admin)), + 'actual Controller complete heads and ancestor ownership') + return dict(check='controller_prefix',source_first=1,source_last=9895, + actual_scalar_services=len(events),field_count=n,component_width=width, + physical_actions=sum(t.actions for t in payloads+tuple(admin)), + output_sha256=hashlib.sha256(json.dumps(observed,separators=(',',':')).encode()).hexdigest()) + + +def main(): + parser=argparse.ArgumentParser();parser.add_argument('--suite',choices=['arithmetic','binding','controller'],required=True) + args=parser.parse_args() + result={'arithmetic':arithmetic,'binding':binding,'controller':controller_prefix}[args.suite]() + expected=json.loads((ROOT/'RESULT.json').read_text())[args.suite] + need(json.loads(json.dumps(result))==expected,'committed exact suite receipt') + print(json.dumps(result,sort_keys=True)) + print('PASS_CURRENT_SCALAR_FLAT_TABLES_'+args.suite.upper()) + + +if __name__=='__main__':main()