From 13d780ea51248ddd51901cd546b9f59adc76eb43 Mon Sep 17 00:00:00 2001 From: Hanson Sun Date: Tue, 13 Oct 2026 21:36:54 -0400 Subject: [PATCH] Research faithful S3 output transport with exact boundary certificate --- .../CERTIFICATE.json | 316 ++++++++++++++++ .../s3-standard-output-transport/CLAIM.txt | 11 + .../s3-standard-output-transport/OVERLAP.json | 100 ++++++ .../PREDECESSORS.json | 28 ++ .../s3-standard-output-transport/README.md | 303 ++++++++++++++++ .../s3-standard-output-transport/SOURCES.json | 18 + .../s3-standard-output-transport/TASK.json | 84 +++++ .../VALIDATION.json | 85 +++++ .../s3-standard-output-transport/VERIFY.json | 31 ++ .../s3-standard-output-transport/model.py | 209 +++++++++++ .../s3-standard-output-transport/oracle.py | 219 +++++++++++ .../references/PR1287-README.md | 274 ++++++++++++++ .../test_package.py | 87 +++++ .../s3-standard-output-transport/verify.py | 339 ++++++++++++++++++ 14 files changed, 2104 insertions(+) create mode 100644 research/s3-standard-output-transport/CERTIFICATE.json create mode 100644 research/s3-standard-output-transport/CLAIM.txt create mode 100644 research/s3-standard-output-transport/OVERLAP.json create mode 100644 research/s3-standard-output-transport/PREDECESSORS.json create mode 100644 research/s3-standard-output-transport/README.md create mode 100644 research/s3-standard-output-transport/SOURCES.json create mode 100644 research/s3-standard-output-transport/TASK.json create mode 100644 research/s3-standard-output-transport/VALIDATION.json create mode 100644 research/s3-standard-output-transport/VERIFY.json create mode 100644 research/s3-standard-output-transport/model.py create mode 100644 research/s3-standard-output-transport/oracle.py create mode 100644 research/s3-standard-output-transport/references/PR1287-README.md create mode 100644 research/s3-standard-output-transport/test_package.py create mode 100644 research/s3-standard-output-transport/verify.py diff --git a/research/s3-standard-output-transport/CERTIFICATE.json b/research/s3-standard-output-transport/CERTIFICATE.json new file mode 100644 index 0000000000..846289c083 --- /dev/null +++ b/research/s3-standard-output-transport/CERTIFICATE.json @@ -0,0 +1,316 @@ +{ + "schema_version": 1, + "status": "SCOPED_EXACT_INTERFACE_NO_NEW_KAPPA", + "assignment_seed": 58, + "group": [ + [ + -1, + 0, + -1, + 1 + ], + [ + -1, + 1, + -1, + 0 + ], + [ + 0, + -1, + 1, + -1 + ], + [ + 0, + 1, + 1, + 0 + ], + [ + 1, + -1, + 0, + -1 + ], + [ + 1, + 0, + 0, + 1 + ] + ], + "source_bindings": [ + { + "path": "references/PR1287-README.md", + "sha256": "fc56e55e76a4d41d9da442ee1af63b4032eb41267a80500814f81027cc0fd087" + } + ], + "group_and_admission": { + "group_products": 36, + "frame_words": 12, + "admission_identities": 150, + "admission_mutations": 300, + "output_bfs_layers": [ + 1, + 6, + 21, + 58, + 122 + ], + "output_costs": [ + 2, + 4, + 4, + 4, + 2, + 0 + ], + "workspace_macro_costs": [ + 12, + 12, + 12, + 12, + 12, + 0 + ] + }, + "schedule_coverage": { + "unrestricted_words": 378504, + "admitted_words": 1884, + "price_comparisons": 84, + "cut_words": 186624, + "cut_price_comparisons": 24, + "records_sha256": "81c422087406d11266bc41b2a91ce7ad5d93ed221280eeb22ba4ec82cc57338f" + }, + "recursive_coverage": { + "cases": 24, + "forward_and_inverse_columns": 816, + "primitive_occurrences": 36352, + "invoice_sha256": "535e62bd8d009735d2716120043bfc0ec946c56985112f66128d6b27c2561311" + }, + "array_lifts": [ + { + "width": 2, + "basis_columns": 28, + "instructions": 808, + "word_sha256": "a424d24c5a31672860441c2cdf210cdb153829871df315a5ea67f90bc2c2e895" + }, + { + "width": 3, + "basis_columns": 42, + "instructions": 1212, + "word_sha256": "64f50c9db4f634fb7858aa7b5c942acd43500cd4cf405c90e5df4cc1e9f58907" + } + ], + "seed_fixture": { + "children": [ + { + "drift": 4, + "v": [ + 0, + 1 + ] + }, + { + "drift": 1, + "v": [ + 0, + 1 + ] + }, + { + "drift": 1, + "v": [ + 0, + 1 + ] + }, + { + "drift": 1, + "v": [ + 0, + 1 + ] + }, + { + "drift": 0, + "v": [ + 1, + 1 + ] + }, + { + "drift": 1, + "v": [ + 0, + 1 + ] + }, + { + "drift": 3, + "v": [ + 0, + 1 + ] + }, + { + "drift": 3, + "v": [ + 1, + 1 + ] + } + ], + "reader_sum_vector": [ + 2, + 8 + ], + "boundary_cost": 36, + "eager_boundary_cost": 96, + "boundary_primal_dual": { + "lower_bound": 36, + "primal_cost": 36, + "checked_inequalities": 294, + "potentials": [ + [ + 14, + 16, + 16, + 16, + 14, + 0 + ], + [ + 14, + 16, + 16, + 16, + 2, + 12 + ], + [ + 6, + 16, + 18, + 18, + 14, + 16 + ], + [ + 18, + 20, + 20, + 10, + 22, + 20 + ], + [ + 26, + 24, + 24, + 22, + 14, + 24 + ], + [ + 26, + 16, + 24, + 26, + 26, + 28 + ], + [ + 30, + 28, + 20, + 30, + 30, + 28 + ], + [ + 32, + 34, + 32, + 32, + 24, + 34 + ], + [ + 38, + 36, + 28, + 38, + 36, + 36 + ] + ] + }, + "midpoint_boundary_cost": 46, + "path": [ + 5, + 4, + 0, + 0, + 3, + 2, + 5, + 3, + 5 + ], + "eager": { + "ADD": 476, + "NEG": 48, + "instructions": 524, + "data_reads": 1000, + "data_writes": 524, + "descriptor_fields": 2096, + "address_travel": 3796, + "prefix_l1_peak": 65, + "registers": 14, + "inverse_prefix_l1_peak": 33 + }, + "transport": { + "ADD": 372, + "NEG": 32, + "instructions": 404, + "data_reads": 776, + "data_writes": 404, + "descriptor_fields": 1616, + "address_travel": 3558, + "prefix_l1_peak": 114, + "registers": 14, + "inverse_prefix_l1_peak": 62 + }, + "saved_instructions": 120, + "eager_word_sha256": "0db652455d2f1f102d18acd901abc115b7b5f10955cfba95d38755ae3bbbc8c2", + "transport_word_sha256": "95545e0c07676110c7c63d33acc4c71ed664031d2533dced1441ebc20e32b8a4", + "midpoint_canonical": { + "ADD": 380, + "NEG": 44, + "instructions": 424, + "data_reads": 804, + "data_writes": 424, + "descriptor_fields": 1696, + "address_travel": 3614, + "prefix_l1_peak": 114, + "registers": 14, + "inverse_prefix_l1_peak": 59 + }, + "midpoint_word_sha256": "e3d782cecab405f2548bd83425056cb546c623de445a82e6637b5023d001bd28" + }, + "negative_controls": [ + "missing_positive_source_copy", + "forward_child_batch_used_as_inverse", + "missing_negative_source_copy", + "reversed_noncommuting_gap_order", + "workspace_restored_without_output_transport", + "premature_canonical_output_observation", + "canonical_frame_is_not_public_dirty_echo_output", + "replace_faithful_output_by_sign_character", + "nonlinear_readout_breaks_dirty_echo", + "aliased_two_address_add", + "overstated_boundary_lower_bound" + ] +} diff --git a/research/s3-standard-output-transport/CLAIM.txt b/research/s3-standard-output-transport/CLAIM.txt new file mode 100644 index 0000000000..f8a378e29a --- /dev/null +++ b/research/s3-standard-output-transport/CLAIM.txt @@ -0,0 +1,11 @@ +CLAIM — Recursive interfaces; OS-random assignment seed 58. + +Base: 410026dc5513b87db92ae98571d1d5984c69a983. Exact question: can a faithful two-dimensional, nonmonomial S3 output representation carry noncommuting six-row regular workspace drift through fixed child calls, with every correction and both directions of a source-only dirty echo charged? + +Domain/method: the standard integer representation generated by s=[[0,1],[1,0]] and t=[[-1,0],[-1,1]], all intertwiners from the regular six-row action, a six-state boundary recurrence, and literal signed ADD/NEG words. Seed 58 fixes one eight-child fixture. Exhaust small schedules, independently replay every dirty basis column, and test chronological order, admission, restoration and inverse failures. Stop after this bounded interface and its evidence; no supplier search or new kappa claim. Expected package: research/s3-standard-output-transport/. + +Three candidates considered: more cyclic persistence (close PR1391/1410 overlap); another connector operation (active two-root/DUO work); faithful vector-valued noncommuting transport (chosen). Distinct from Discussion1381's active one-row sign-character S3 construction: the output representation here is faithful and noncommuting, with nonmonomial elementary output operations and no character kernel. PR1287 supplies the cyclic output-frame predecessor; PR1227 supplies the sign-frame mechanism. General output transport is predecessor credit, not a priority claim. No predecessor implementation is imported. + +The completed overlap snapshot covered 823 open PRs and 159 Discussion records with complete pagination (01:03–01:04 UTC), plus local notes and the review ledger. Exact predecessor heads and limits will be retained. Selected PR1094 remains context only. + +Expected finish: 2026-10-14T02:00:56Z (October 13, 10:00 p.m. EDT); claim expires then. Final 15 minutes reserved for verification and handoff. Prepared by Hanson Sun (@bbMisk) with substantial OpenAI Codex assistance; no independent human review is implied. diff --git a/research/s3-standard-output-transport/OVERLAP.json b/research/s3-standard-output-transport/OVERLAP.json new file mode 100644 index 0000000000..e83e43ac8e --- /dev/null +++ b/research/s3-standard-output-transport/OVERLAP.json @@ -0,0 +1,100 @@ +{ + "initial": { + "searched_at": "2026-10-14T01:04:38.883950+00:00", + "coverage": { + "open_prs": { + "fetched_at": "2026-10-14T01:03:58.384345+00:00", + "complete_pagination": true, + "records": 823 + }, + "discussions": { + "fetched_at": "2026-10-14T01:04:38.832167+00:00", + "complete_pagination": true, + "records": 159 + } + }, + "limits": "Remote PR scope is open PRs including drafts. Closed work is searched through local READMEs, TASK metadata and ledger only. No code diffs or arbitrary package files are searched. Recheck relevant heads before submission.", + "warnings": [] + }, + "submission": { + "searched_at": "2026-10-14T01:33:54.473586+00:00", + "coverage": { + "open_prs": { + "fetched_at": "2026-10-14T01:33:47.100557+00:00", + "complete_pagination": true, + "records": 744 + }, + "discussions": { + "fetched_at": "2026-10-14T01:24:56.947040+00:00", + "complete_pagination": true, + "records": 171 + } + }, + "limits": "Remote PR scope is open PRs including drafts. Closed work is searched through local READMEs, TASK metadata and ledger only. No code diffs or arbitrary package files are searched. Recheck relevant heads before submission.", + "warnings": [ + "discussions: refresh failed; using old data if available: gh: HTTP 500\n" + ], + "terms": [ + "faithful", + "S3", + "vector output", + "output transport" + ] + }, + "nearest": [ + { + "object": "PR1287", + "head": "8606df05eca3c65032361c74ee3dbc2630b0cdc4", + "distinction": "Predecessor cyclic output transport; the new output representation is faithful and noncommuting." + }, + { + "object": "PR1227", + "head": "fea44a4d0d78570021d854881d15d9efe62e1713", + "distinction": "Predecessor scalar sign frames; general mechanism credited." + }, + { + "object": "PR1246", + "head": "5ed1ce17a9df4c853a93f9758ba903d2620c3443", + "distinction": "Additive defect repair at canonical cuts, rather than multiplicative output transport." + }, + { + "object": "Discussion1381", + "updated_at": "2026-10-13T23:50:29Z", + "distinction": "Active one-dimensional sign-character S3 quotient. No new comment at final refresh; results not imported." + } + ], + "conclusion": "No matching faithful two-dimensional S3 transport package found in the declared search coverage. This is not a novelty proof.", + "refreshed_main": "e6f9716621f4e01fc190617934cdfaf072bd976f", + "prior_complete": { + "searched_at": "2026-10-14T01:24:56.993894+00:00", + "coverage": { + "open_prs": { + "fetched_at": "2026-10-14T01:24:39.499233+00:00", + "complete_pagination": true, + "records": 764 + }, + "discussions": { + "fetched_at": "2026-10-14T01:24:56.947040+00:00", + "complete_pagination": true, + "records": 171 + } + }, + "limits": "Remote PR scope is open PRs including drafts. Closed work is searched through local READMEs, TASK metadata and ledger only. No code diffs or arbitrary package files are searched. Recheck relevant heads before submission.", + "warnings": [], + "terms": [ + "faithful", + "S3", + "vector output", + "output transport" + ] + }, + "supplemental_discussions": { + "checked_at_utc": "2026-10-14T01:36:54.271474+00:00", + "coverage": "20 most recently updated discussion bodies, last five comments and replies, plus Discussion1381 directly; bounded query, not complete historical pagination.", + "oldest_listed_updated_at": "2026-10-14T00:30:47Z", + "newest_listed_updated_at": "2026-10-14T01:34:57Z", + "nearest_claim_updated_at": "2026-10-13T23:50:29Z", + "nearest_claim_comments": 0, + "finding": "No newly listed faithful two-dimensional S3 output-transport claim. Other S3/group results concern binary paid-call register bounds." + } +} diff --git a/research/s3-standard-output-transport/PREDECESSORS.json b/research/s3-standard-output-transport/PREDECESSORS.json new file mode 100644 index 0000000000..45e1b0b33b --- /dev/null +++ b/research/s3-standard-output-transport/PREDECESSORS.json @@ -0,0 +1,28 @@ +{ + "schema_version": 1, + "references": [ + { + "path": "references/PR1287-README.md", + "pr": 1287, + "head": "8606df05eca3c65032361c74ee3dbc2630b0cdc4", + "sha256": "fc56e55e76a4d41d9da442ee1af63b4032eb41267a80500814f81027cc0fd087", + "role": "Cyclic output-frame predecessor; prose only, no imported implementation." + }, + { + "pr": 1227, + "head": "fea44a4d0d78570021d854881d15d9efe62e1713", + "role": "Paid sign-frame predecessor; metadata and PR description inspected." + }, + { + "pr": 1246, + "head": "5ed1ce17a9df4c853a93f9758ba903d2620c3443", + "role": "Independent additive-defect repair at canonical cuts; distinct method." + }, + { + "discussion": 1381, + "url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1381", + "observed_updated_at": "2026-10-13T23:50:29Z", + "role": "Concurrent noncommuting regular S3 workspace with one-row sign-character output. This package instead transports a faithful noncommuting two-vector." + } + ] +} diff --git a/research/s3-standard-output-transport/README.md b/research/s3-standard-output-transport/README.md new file mode 100644 index 0000000000..4508b469df --- /dev/null +++ b/research/s3-standard-output-transport/README.md @@ -0,0 +1,303 @@ +# Faithful S3 output transport across recursive child boundaries + +This scoped recursive-interface construction carries noncommuting workspace +changes through a smaller, faithful two-dimensional output. For the seed-58 +eight-child example, the complete dirty echo uses **404 scalar ADD/NEG +instructions instead of 524**, saving **120**. The boundary alone costs **36 +instead of 96**. Both copies, both directions of every child, physical output +frame operations, and final restoration are included. + +No selected supplier or new kappa is claimed. The fixed-child interface is +essential: opening these small matrix leaves permits cheaper direct evaluation. +No actual multiplication supplier with this indivisible boundary has been +identified. The forward prefix row-L1 bound grows from **65 to 114**. This is +instruction-count evidence, not a runtime, precision, or complete-theorem result. + +## What this adds + +Ross Richardson's [PR1287](https://github.com/CrocSwap/integer-mult-bounds/pull/1287) +already gives cyclic output frames and the admission gate `R P = Q R`, following +Sagar Thakrar's paid sign frames in +[PR1227](https://github.com/CrocSwap/integer-mult-bounds/pull/1227). General output +transport and dirty-echo cancellation remain predecessor credit. + +The added case has **noncommuting output transformations**, including a genuine +two-register shear/negation. Its faithful output retains the whole six-element +group action. The active +[Discussion1381](https://github.com/CrocSwap/integer-mult-bounds/discussions/1381) +instead investigates a one-row sign-character output with a nontrivial kernel. +That concurrent scope was inspected before claiming this work; its results are +provisional and are not a dependency here. A scalar representation cannot be +faithful for a nonabelian group, since nonzero scalars commute. Two dimensions +are therefore necessary for this faithful-transport requirement and suffice +below. This is not an output-width lower bound for other tasks or interfaces. + +The new evidence is the exact integer representation, its admitted reader +class, a chronological six-state recurrence, complete primitive words, +independent unaligned-schedule enumeration, and recursive dirty-state replay. +The implementation imports no predecessor verifier. Exact references and +notices are retained in [PREDECESSORS.json](PREDECESSORS.json). + +## Fixed child and frame contracts + +Work over characteristic zero. The six group elements, in the certificate's +order, are the integer matrices generated by + +``` +Q_s = [[0, 1], [1, 0]], Q_t = [[-1, 0], [-1, 1]]. +``` + +They obey `s^2=t^2=(st)^3=e`, and `st != ts`. They can also be derived by +permuting three coordinates and acting on `(z1-z0,z2-z0)`; `oracle.py` uses that +independent description. This is an algebraic derivation, not a runtime +conversion or a hidden third output register. + +Index the six arbitrary dirty workspace coordinates by `h in S3`. Let +`P_g e_h = e_(gh)` be the left regular permutation. The two-output reader + +``` +R(v) e_h = Q_h v, v in K^2 +``` + +satisfies `R(v) P_g = Q_g R(v)` for every `g`. Conversely, any intertwiner has +this form: its column at `e` determines every column by the same equality. +Thus admission is a reader-class characterization, not just a test of the +example. Checking generators `s,t` suffices by closure. `R((1,0))` has rank two. + +Each fixed, indivisible child has a known drift `g_i` and the contract + +``` +C_i(D,W) = (D + R(v_i) W, P_(g_i) W). +``` + +It preserves private dirty scratch and exposes its literal inverse with a +complete price. The parent uses the same frame schedule for every independently variable +tuple of admitted readers `v_i`. It may insert only complete `P_a` operations on the +six workspace rows and complete `Q_b` operations on the two output rows in +gaps around the ordered children. Source and output rows are disjoint; none +is descendant scratch. No copy, temporary, frame annotation, role change, +or primitive is free. The emitted integer examples require no clean cell. + +Nonidentity `P_g` costs 12 instructions in the declared cycle backend: an +order-two element has three swaps, each `3 ADD + 1 NEG`; an order-three +element has two three-cycles, each six signed ADDs. The latter is the existing +cycle word retained by PR1287 and credited there to PR1145. No new unrestricted +permutation-circuit optimum is claimed. + +In certificate order, `Q_g` costs `[2,4,4,4,2,0]`. Literal words are in +`model.Q_WORDS`. A separate exhaustive breadth-first enumeration of all +two-register signed ADD/NEG endpoints through radius four checks these local +minimum costs: its layer sizes are `1,6,21,58,122`. This excludes temporary +registers and other primitive alphabets. For example `Q_t` is just +`D1 -= D0; NEG D0`. Every group frame is physically emitted. + +## Exact chronological boundary recurrence + +Before a child, write the workspace frame as `p` and output frame as `q`. +Its normalized response is `Q_q^-1 R(v_i) P_p W = Q_q^-1 Q_p R(v_i) W`. +Uniform correctness for independently variable readers forces `p=q`: set all +other readers to zero and use the rank-two reader `R((1,0))`; faithfulness then +forces equality of group elements. Conversely, aligned phases are sufficient. +This necessity concerns uniform schedules. It does not exclude accidental +cheaper words for one fixed tuple of readers. + +At aligned phase `t`, child `g` leaves workspace phase `gt` and output phase +`t`. To reach aligned phase `u`, the unique gap is + +``` +a = u t^-1 g^-1 on workspace, +b = u t^-1 on output, +c_g(t,u) = cP(a) + cQ(b). +``` + +Order matters. Moving `g^-1` to the left is generally wrong; a mixed-frame +positive/negative pair in the verifier isolates this error. In the optimal +seed word every gap happens to be pure workspace or pure output, so that word +alone would not detect the bug. + +With arbitrary entrance frames charged, the exact boundary recurrence is + +``` +F_0(t) = cP(t) + cQ(t), +F_(j+1)(u) = min_t [F_j(t) + c_(g_(j+1))(t,u)], +B(g_1,...,g_k) = F_k(e). +``` + +Both endpoints are canonical. A required canonical cut after child `j` restricts +that layer to `u=e`. At a normalized aligned boundary, canonical output also forces phase `e` +because this representation is faithful. A sign-character output can instead +have an invisible nonidentity aligned phase. Observing partway through a +mixed, unaligned gap is a different interface and is not optimized here. + +Every uniform legal word reduces to such a path. Workspace and output frames +act on disjoint registers and commute with each other. Within either register +their products are group elements. Replacing multiple workspace macros by the +single reduced macro never increases cost (`cP=12` off the identity), and the +output's minimum primitive costs obey the triangle inequality. Conversely, +every path emits a legal word. Induction proves the recurrence for every finite +child list. The finite census checks its implementation; it is not the proof +of the all-length statement. + +The seed chooses group indices `[4,1,1,1,0,1,3,3]` using `random.Random(58)` after +the OS assignment draw. The optimum path is `[5,4,0,0,3,2,5,3,5]`, where `5=e`. +It costs 36, versus 96 for eager workspace restoration. The certificate also +contains forward distance potentials. An independent checker verifies all 288 +transition inequalities plus six entrance inequalities by enumerating actual +permutation-frame pairs, without the planner's gap formula. These prove a lower +bound of 36; the emitted path attains 36. An overstated bound is rejected. +Requiring a canonical frame after child four costs 46 and yields a complete +echo of 424 instructions. + +**A frame checkpoint inside the batch is not a public source-only checkpoint +inside its dirty echo.** It still contains the current workspace's contribution. +Public observation waits for the whole echo; splitting the echo for earlier +observations requires another priced contract. The verifier rejects conflating +these two interfaces. + +## Complete echo and recursive invoice + +Let the completed batch be `H(D,W)=(D+R_total W,W)`, where +`R_total=R(sum_i v_i)`. Execute + +``` +W += X; H(D,W); W -= X; H^-1(D,W). +``` + +The result is `(D+R_total X,X,W_initial)` for every initial dirty `D,W`. +The inverse is the literal reversed instruction word, not another forward +call. Nonlinear readouts do not inherit the cancellation. + +A leaf emits its integer reader ADDs and complete `P_g` drift. An internal +child emits this echo, then `P_(g_v)` on its own source. Reader sums remain +intertwiners, so this closes the recursive contract. Siblings reuse a workspace +only after a complete return. A leaf uses eight scalar registers; a child of +depth `h` uses `2+6(h+1)`; an echo over children of maximum depth `h` uses +`2+6(h+2)`. + +With `J_v` counting all emitted ADD/NEG instructions, including descendants, + +``` +leaf: J_v = sum_abs_entries(R(v)) + cP(g_v), +internal: J_v = 2 sum_i J_i + 12 + 2 B(g_1,...,g_k) + cP(g_v), +root echo: J = 2 sum_i J_i + 12 + 2 B(g_1,...,g_k). +``` + +The 12 is both six-coordinate source-copy passes. Eager restoration substitutes +`sum_i cP(g_i)` for `B`. This is a complete depth/instruction recurrence. It is +not a contracting input-size recurrence or a new supplier moment. For length-L +arrays with componentwise exact operations, every scalar instruction expands +to L instructions; the identity holds over any vector space. The receipt +includes literal L=2,3 tensor lifts, with every component charged. + +| Complete scalar echo | Eager | Transport | +| --- | ---: | ---: | +| ADD | 476 | 372 | +| NEG | 48 | 32 | +| All instructions / writes | 524 | 404 | +| Data reads | 1,000 | 776 | +| Four-field instruction records | 2,096 | 1,616 | +| Declared data-address travel | 3,796 | 3,558 | +| Registers, all possibly dirty | 14 | 14 | +| Forward prefix row-L1 peak | 65 | 114 | + +An ADD reads two cells and writes one; a NEG reads and writes one. Each literal +instruction has four fields. The travel score follows source then destination +for ADD, destination for NEG, starting and returning to address zero. It is a +specified access-trace score, not a physical tape-machine construction. + +Coefficient access is included in the emitted integer word: signs and operand +addresses are instruction fields, with larger integer coefficients expanded +into repeated signed ADDs. There is no runtime coefficient oracle. Parsing the +tree, validating admission, planning, materializing and reading this word are +additional preparation/program costs. The tuple-path planner takes O(k^2) +time and O(k) live state for a k-child node (six states, path copies); sum this +over internal nodes. A conservative emission/preparation bound for tree +description size M, output length J and height h is +`O((h+1)(M+J) + sum_v k_v^2)` time, with materialized word storage O(J) in +addition to the tree, plans and call stack. No preparation speedup is claimed. + +Exact arithmetic is assumed. The recorded row-L1 peaks bound intermediate +magnitudes for bounded inputs, including every emitted prefix; standalone +inverse peaks are recorded separately. Larger coefficients may cost more bits. +Rounding, fixed precision, physical source layouts, tape access, hosting, +common-label realization and outer analytic transfer remain unproved or +inherited from any future supplier using this interface. + +## Reproduce and completed coverage + +Python 3.12, standard library only, from the repository root: + +```sh +python3.12 scripts/research_package.py --package research/s3-standard-output-transport +``` + +Expected main marker: + +``` +PASS_S3_STANDARD_OUTPUT boundary=36_vs_96 echo=404_vs_524 saved=120 controls=11 no_new_kappa +``` + +The registered replay also runs five package tests and ends with +`PASS_REGISTERED_RESEARCH_PACKAGE research/s3-standard-output-transport outcome=completed`. +Direct replay is `python3 -I -O -B research/s3-standard-output-transport/verify.py`. +It recomputes every certificate field and fails on disagreement. `--emit PATH` +writes a fresh certificate and refuses to overwrite one. + +Completed bounded domains, with no heuristic pruning: + +- All 36 group products, 12 literal frame words, 150 exact intertwiner identities + for `v in {-2,-1,0,1,2}^2`, and 300 single-entry admission mutations. +- All 378,504 unaligned schedules for every `s/t` word of length 1..3, after + forcing only terminal frames. The independent oracle carries each child's + separate response through actual permutation/difference actions; it does not + use the planner's alignment condition or gap formula. Its 1,884 admitted + schedules give the same 84 minima at workspace price multipliers 1..3 and + output multipliers 1..2. Another 186,624 enumerated schedules check four + canonical-cut policies and 24 price comparisons. +- 24 eager/transport recursive-child cases at depths 0..3, 816 forward/inverse + basis columns, and 36,352 primitive occurrences. The seed root, constrained + midpoint, and L=2,3 array lifts add separate exact full-state checks. +- Eleven semantic controls, including chronological multiplication, source copies, + inverse direction, output transport, premature observations, replacing the + faithful output by a scalar sign, nonlinear readers, aliased instructions, + and an overstated lower-bound certificate. + Five package tests cover read-only relocation, immutable source/certificate + mutations, a wrong output macro, and refusal to overwrite a certificate. + +The independent implementation was written in the same AI-assisted session; +it is not independent human review or proof-assistant formalization. No full +selected-supplier cold replay was needed or run for this isolated package. + +## Provenance, scope and credit + +Base commit: `410026dc5513b87db92ae98571d1d5984c69a983`. The OS-random assignment +seed was 58, track recursive interfaces. The candidates, domain and stopping +rule are in [TASK.json](TASK.json); the sprint claim is +[Discussion1467](https://github.com/CrocSwap/integer-mult-bounds/discussions/1467). +[SOURCES.json](SOURCES.json) pins source catalogue and selected-record context. +The selected conditional kappa is still `836330098538459/500000000000000000`; +no selected file or upstream input changes. +[CERTIFICATE.json](CERTIFICATE.json) is the exact deterministic receipt. + +Prepared by **Hanson Sun (@bbMisk)** with substantial **OpenAI Codex assistance** +in derivation, implementation, checking and prose. New material is Apache-2.0. +Credit Ross Richardson's PR1287; Sagar Thakrar's PR1227 and related PR1199 +reader-defect work; mightyOil/Philipp's PR1203 noncommuting-reader work; +Aaron Wang/Navinor's PR1155 restoration-coalescing work; and the retained +PR889 dirty-echo lineage. The active Discussion1381 sign-character approach +and Hanson Sun's earlier PR1246 additive-defect repair are distinct related +work. Their outcomes are not silently incorporated or represented as reviewed. + +## Open next questions + +The structured questions are in TASK.json. The material blocker is an actual +supplier with the admitted fixed-child boundary: a first step is to extract +its literal entry/exit maps and test the two generator equalities before +pricing a replacement. A favorable toy instruction count does not resolve +that admission or justify a new kappa. + +For this interface, a second question is whether different equal-cost phase +paths lower the prefix magnitude bound. The first step would compare exact +prefix row-L1 envelopes on the finite set of tied minimum paths while +preserving the complete word and invoice. This session did not perform that +secondary optimization or make a precision claim. diff --git a/research/s3-standard-output-transport/SOURCES.json b/research/s3-standard-output-transport/SOURCES.json new file mode 100644 index 0000000000..178b3ca979 --- /dev/null +++ b/research/s3-standard-output-transport/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "410026dc5513b87db92ae98571d1d5984c69a983", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "c05fafaa25ba95b2d5af86b1800427198e3d20eb", + "sha256": "89b5928bc92c81e2647b6d702a7ad85a6795b8f44e2eb267b2ff3145d8f2b2ce" + } + ] +} diff --git a/research/s3-standard-output-transport/TASK.json b/research/s3-standard-output-transport/TASK.json new file mode 100644 index 0000000000..3674851463 --- /dev/null +++ b/research/s3-standard-output-transport/TASK.json @@ -0,0 +1,84 @@ +{ + "schema_version": 1, + "task_id": "persistent-boundary", + "priority_revision": 2, + "base_commit": "410026dc5513b87db92ae98571d1d5984c69a983", + "original_card": { + "id": "persistent-boundary", + "question": "Can a specified pair of consecutive calls eliminate a restoration that the next call reconstructs?", + "starting_points": [ + "research/heterogeneous-owner-assembly/README.md", + "certificates/selected-result.json" + ], + "methods": [ + "Write typed entry/exit contracts and a contracting multitype recurrence.", + "Derive a lower bound for the compulsory transitions of one proposed typed interface." + ], + "acceptance_gate": "Show actual eliminated work and legal composition; changing a scalar recurrence into a matrix is insufficient.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Find a concrete consecutive-call boundary in the selected review and list its entry/exit obligations.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Specify two call types and one operation actually removed by composition; derive the normalized recurrence.", + "bottleneck_link": "Eliminating compulsory boundary work can lower recursive cost beyond packing gains.", + "allowed_variations": [ + "A two-type pilot or one explicit deferred restoration." + ], + "scope_change_triggers": [ + "Rewriting the old scalar recurrence as a matrix without eliminating work." + ], + "overlap_terms": [ + "persistent boundary", + "deferred restoration", + "multitype" + ] + }, + "scope_status": "refined", + "actual_scope": "Faithful two-dimensional noncommuting S3 output transport for fixed children with a regular six-row workspace; exact uniform boundary recurrence and fully charged recursive dirty echo.", + "scope_change_reason": "The persistent-boundary card is narrowed to one specified group representation and emitted child interface. This is a synthetic interface result; no selected-supplier instance is identified.", + "bottleneck_link": "Eliminate literal workspace restoration instructions by physically transporting a smaller output. This can affect a future recursive supplier only if its actual fixed-child maps satisfy this admission contract; no paid supplier profile changes here.", + "budget_minutes": 60, + "stop_rule": "One-hour session; stop after the named S3 family, all s/t drift words of lengths 1..3, all 36^k unaligned gap choices, price multipliers 1..3 and 1..2, four cut policies, depths 0..3, and seed fixture/lifts. No supplier search or tied-path precision optimization. Reserve at least the final quarter for verification and handoff.", + "outcome": "completed", + "evidence": "CERTIFICATE.json: boundary 96 to 36 and full arbitrary-dirty echo 524 to 404 scalar instructions. Independent permutation/difference-coordinate oracle, complete finite schedules, recursive inverses, eleven semantic controls, and package corruption/relocation tests.", + "author": "Hanson Sun (@bbMisk)", + "ai_assistance": "Substantial OpenAI Codex assistance in derivation, both implementations, verification and prose. Independent implementations were authored in the same AI session; no independent human or proof-assistant review.", + "open_questions": [ + { + "question": "Does an actual supplier expose an indivisible child with R P_g = Q_g R for this output representation?", + "why_it_matters": "Without physical admission, the toy instruction savings do not change the selected recursive invoice or kappa.", + "first_step": "Extract literal supplier child maps and test both generator equalities, with arbitrary dirty inputs and complete source-access costs.", + "blocked_by": "No matching supplier has been identified; realization, hosting, precision/tape and analytic transfer remain open." + }, + { + "question": "Can tied minimum-cost paths reduce the exact prefix magnitude bound?", + "why_it_matters": "The chosen minimum-instruction word raises the forward row-L1 peak from 65 to 114.", + "first_step": "Enumerate tied optimal paths for the fixed seed fixture and compare their literal prefix envelopes.", + "blocked_by": "This is a separate finite optimization, not performed in the bounded session; fixed-precision admission would still be required." + } + ], + "assignment_seed": 58, + "random_source": "Python secrets.randbelow(100), operating-system randomness; drawn once at 2026-10-14T01:00:56.403423+00:00", + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1467", + "candidate_tasks": [ + { + "question": "Extend cyclic-frame persistence across adjacent echoes", + "decision": "Not selected: close PR1391/1410 overlap." + }, + { + "question": "Add a paid connector operation or second root", + "decision": "Not selected: active Discussion1403 DUO and Discussion1412 second-root work." + }, + { + "question": "Faithful vector-valued transport for noncommuting S3 children", + "decision": "Selected: noncommuting, nonmonomial two-output action, distinct from Discussion1381 sign-character quotient." + } + ], + "seed_use": "random.Random(58) selects eight nonidentity group drifts, then leaf vectors from (1,0),(0,1),(1,1). The checker exhausts a fixed domain; this is not a seeded heuristic search." +} diff --git a/research/s3-standard-output-transport/VALIDATION.json b/research/s3-standard-output-transport/VALIDATION.json new file mode 100644 index 0000000000..c7ec8acaf5 --- /dev/null +++ b/research/s3-standard-output-transport/VALIDATION.json @@ -0,0 +1,85 @@ +{ + "schema_version": 1, + "base_commit": "410026dc5513b87db92ae98571d1d5984c69a983", + "refreshed_main": "e6f9716621f4e01fc190617934cdfaf072bd976f", + "environment": { + "platform": "macOS-27.0.1-arm64-arm-64bit-Mach-O", + "optimized_replay_python": "3.14.6", + "registered_replay_python": "Python 3.12.13", + "dependencies": "Python standard library only" + }, + "completed": [ + { + "command": "python3.12 scripts/research_package.py --package research/s3-standard-output-transport", + "result": "PASS_REGISTERED_RESEARCH_PACKAGE; exact certificate replay and five passing package tests." + }, + { + "command": "python3 -I -O -B research/s3-standard-output-transport/verify.py", + "result": "PASS_S3_STANDARD_OUTPUT boundary=36_vs_96 echo=404_vs_524 saved=120 controls=11 no_new_kappa" + }, + { + "command": "python3 -B scripts/research_baseline.py", + "result": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY; complex remains binding, selected kappa unchanged." + }, + { + "command": "git diff --check", + "result": "No whitespace errors." + } + ], + "not_performed": [ + "Full selected supplier cold replay (no selected supplier source changes)", + "Hosted CI and independent human review", + "Proof-assistant formalization", + "Physical tape/compiler implementation, fixed-precision admission, actual supplier hosting or a new kappa" + ], + "receipt_sha256": "674f5ce5e242d4a4488a19ae3ad6fa7084dde79f4ee14e38f1ff770ee9c92192", + "preserved": [ + "upstream/", + "certificates/selected-result.json", + "frozen sources and predecessor reference bytes" + ], + "checked_at_utc": "2026-10-14T01:31:20.605868+00:00", + "final_exit_codes": [ + { + "argv": [ + "python3.12", + "scripts/research_package.py", + "--package", + "research/s3-standard-output-transport" + ], + "exit_code": 0 + }, + { + "argv": [ + "python3", + "-I", + "-O", + "-B", + "research/s3-standard-output-transport/verify.py" + ], + "exit_code": 0 + }, + { + "argv": [ + "python3.12", + "-B", + "scripts/verify_selected_result.py" + ], + "exit_code": 0 + }, + { + "argv": [ + "git", + "diff", + "--check" + ], + "exit_code": 0 + } + ], + "exact_boundary_certificate": "294 independently checked entrance/transition inequalities, lower bound 36, attained by the emitted seed path.", + "patch_application": { + "target": "e6f9716621f4e01fc190617934cdfaf072bd976f", + "method": "git read-tree into a temporary index, then git apply --cached --check of the isolated package diff", + "result": "PASS; catalogue and selected-record bytes also unchanged on this target" + } +} diff --git a/research/s3-standard-output-transport/VERIFY.json b/research/s3-standard-output-transport/VERIFY.json new file mode 100644 index 0000000000..9cf2a0ae20 --- /dev/null +++ b/research/s3-standard-output-transport/VERIFY.json @@ -0,0 +1,31 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Recompute exact certificate, independently enumerate unaligned schedules, replay full dirty maps/inverses and eleven semantic controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 120, + "checks": "Five package tests: read-only relocation, certificate/source/macro corruption, and overwrite refusal." + } + ] +} diff --git a/research/s3-standard-output-transport/model.py b/research/s3-standard-output-transport/model.py new file mode 100644 index 0000000000..ef9da39b10 --- /dev/null +++ b/research/s3-standard-output-transport/model.py @@ -0,0 +1,209 @@ +"""Faithful S3 output transport: construction and six-state planner. + +Hanson Sun (@bbMisk), with substantial OpenAI Codex assistance. Apache-2.0. +All costs count emitted scalar ADD/NEG instructions, not multiplication time. +""" +from dataclasses import dataclass + + +G = ((-1, 0, -1, 1), (-1, 1, -1, 0), (0, -1, 1, -1), + (0, 1, 1, 0), (1, -1, 0, -1), (1, 0, 0, 1)) +E, S, T = 5, 3, 0 + + +def mm(a, b): + return tuple(sum(a[2*i+k] * b[2*k+j] for k in range(2)) + for i in range(2) for j in range(2)) + + +PRODUCT = tuple(tuple(G.index(mm(a, b)) for b in G) for a in G) +INVERSE = tuple(next(b for b in range(6) if PRODUCT[a][b] == E) + for a in range(6)) + + +def mul(a, b): + return PRODUCT[a][b] + + +def add(dst, src, sign=1): + return ("ADD", dst, src, sign) + + +def neg(dst): + return ("NEG", dst, -1, -1) + + +# These literal two-register words are checked independently through radius four. +Q_WORDS = ( + (add(1, 0, -1), neg(0)), + (add(0, 1), add(1, 0, -1), add(0, 1), add(0, 1)), + (add(0, 1, -1), add(0, 1, -1), add(1, 0), add(0, 1, -1)), + (add(0, 1), add(1, 0, -1), add(0, 1), neg(1)), + (add(0, 1, -1), neg(1)), + (), +) +Q_COST = tuple(map(len, Q_WORDS)) + + +def q_word(g, rows): + return [(kind, rows[d], rows[s] if kind == "ADD" else -1, sign) + for kind, d, s, sign in Q_WORDS[g]] + + +def p_word(g, rows): + """Left regular action P_g e_h=e_(gh), with charged cycle rotations.""" + pull = [mul(INVERSE[g], h) for h in range(6)] + seen, word = set(), [] + for start in range(6): + if start in seen: + continue + cycle, h = [], start + while h not in seen: + cycle.append(rows[h]) + seen.add(h) + h = pull[h] + for a, b in zip(cycle, cycle[1:]): + # (a,b) <- (b,-a). Consecutive signs cancel on odd cycles. + word.extend((add(a, b), add(b, a, -1), add(a, b))) + if len(cycle) % 2 == 0: + word.append(neg(cycle[-1])) + return word + + +P_COST = tuple(len(p_word(g, list(range(6)))) for g in range(6)) + + +def reader(v): + """The intertwiner R(v) has column h equal to Q_h v.""" + return tuple(tuple(G[h][2*i] * v[0] + G[h][2*i+1] * v[1] + for h in range(6)) for i in range(2)) + + +def admitted(r): + if len(r) != 2 or any(len(row) != 6 for row in r): + return False + for g in (S, T): + for i in range(2): + for h in range(6): + if r[i][mul(g, h)] != sum(G[g][2*i+j] * r[j][h] + for j in range(2)): + return False + return True + + +def gap(before, after, drift): + delta = mul(after, INVERSE[before]) + return mul(delta, INVERSE[drift]), delta + + +def plan(drifts, cuts=(), pscale=1, qscale=1): + """Exact minimum in the declared complete P/Q macro alphabet.""" + if any(type(g) is not int or not 0 <= g < 6 for g in drifts): + raise ValueError("unknown group element") + if pscale <= 0 or qscale <= 0: + raise ValueError("frame prices must be positive") + if any(type(c) is not int or not 0 <= c <= len(drifts) for c in cuts): + raise ValueError("checkpoint outside the batch") + cuts = set(cuts) | {len(drifts)} + costs = {g: (pscale * P_COST[g] + qscale * Q_COST[g], (g,)) + for g in range(6) if 0 not in cuts or g == E} + for j, drift in enumerate(drifts, 1): + following = {} + for after in range(6): + if j in cuts and after != E: + continue + choices = [] + for before, (price, path) in costs.items(): + a, b = gap(before, after, drift) + choices.append((price + pscale * P_COST[a] + qscale * Q_COST[b], + path + (after,))) + following[after] = min(choices) + costs = following + return costs[E] + + +def distance_certificate(drifts): + """Forward shortest distances, to be checked as dual feasible potentials.""" + rows = [[P_COST[g]+Q_COST[g] for g in range(6)]] + for drift in drifts: + following = [] + for after in range(6): + choices = [] + for before in range(6): + a, b = gap(before, after, drift) + choices.append(rows[-1][before]+P_COST[a]+Q_COST[b]) + following.append(min(choices)) + rows.append(following) + return rows + + +@dataclass(frozen=True) +class Node: + drift: int + v: tuple = (0, 0) + children: tuple = () + + +def vector(node): + if not node.children: + return node.v + return tuple(sum(vector(c)[i] for c in node.children) for i in range(2)) + + +def depth(node): + return 0 if not node.children else 1 + max(map(depth, node.children)) + + +def inverse_word(word): + return [(kind, d, s, -sign if kind == "ADD" else sign) + for kind, d, s, sign in reversed(word)] + + +def leaf_word(node, output, source): + word = [] + for i, row in enumerate(reader(node.v)): + for j, coefficient in enumerate(row): + word.extend([add(output[i], source[j], 1 if coefficient > 0 else -1)] + * abs(coefficient)) + return word + p_word(node.drift, source) + + +def batch_word(children, output, work, scratch, optimized=True, cuts=()): + drifts = tuple(c.drift for c in children) + path = plan(drifts, cuts)[1] if optimized else (E,) * (len(children)+1) + word = p_word(path[0], work) + q_word(path[0], output) + boundaries = [len(word)] + for i, child in enumerate(children): + word.extend(node_word(child, output, work, scratch, optimized)) + a, b = gap(path[i], path[i+1], child.drift) + word.extend(p_word(a, work)) + word.extend(q_word(b, output)) + boundaries.append(len(word)) + return word, path, boundaries + + +def echo_word(children, output, source, scratch, optimized=True, cuts=()): + work = list(range(scratch, scratch+6)) + h, _, _ = batch_word(children, output, work, scratch+6, optimized, cuts) + return ([add(w, x) for w, x in zip(work, source)] + h + + [add(w, x, -1) for w, x in zip(work, source)] + inverse_word(h)) + + +def node_word(node, output=(0, 1), source=tuple(range(2, 8)), scratch=8, + optimized=True): + if not node.children: + return leaf_word(node, output, source) + return (echo_word(node.children, output, source, scratch, optimized) + + p_word(node.drift, source)) + + +def cost_node(node, optimized=True): + if not node.children: + return sum(abs(x) for row in reader(node.v) for x in row) + P_COST[node.drift] + return cost_echo(node.children, optimized) + P_COST[node.drift] + + +def cost_echo(children, optimized=True, cuts=()): + drifts = tuple(c.drift for c in children) + boundary = plan(drifts, cuts)[0] if optimized else sum(P_COST[g] for g in drifts) + return 2 * sum(cost_node(c, optimized) for c in children) + 12 + 2 * boundary diff --git a/research/s3-standard-output-transport/oracle.py b/research/s3-standard-output-transport/oracle.py new file mode 100644 index 0000000000..033db7ecbe --- /dev/null +++ b/research/s3-standard-output-transport/oracle.py @@ -0,0 +1,219 @@ +"""Independent permutation/difference-coordinate oracle and literal row replay. + +No imports from the construction. S3 is derived by permuting three coordinates; +the two outputs are coordinate differences (z1-z0, z2-z0). +Hanson Sun (@bbMisk), with substantial OpenAI Codex assistance. Apache-2.0. +""" +from itertools import permutations, product +from functools import lru_cache + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +PERMS = tuple(permutations(range(3))) + + +def difference_matrix(p): + z = ((0, 0), (1, 0), (0, 1)) + return tuple(z[p[i]][j] - z[p[0]][j] for i in (1, 2) for j in (0, 1)) + + +MATS = tuple(sorted(map(difference_matrix, PERMS))) +PERM_FOR = tuple(next(p for p in PERMS if difference_matrix(p) == a) for a in MATS) +ONE = MATS.index((1, 0, 0, 1)) + + +@lru_cache(maxsize=None) +def compose(a, b): + # Pull permutations: applying a after b reads b[a[i]]. + pa, pb = PERM_FOR[a], PERM_FOR[b] + return PERM_FOR.index(tuple(pb[pa[i]] for i in range(3))) + + +INV = tuple(next(b for b in range(6) if compose(a, b) == ONE) for a in range(6)) + + +def identity(n): + return [[int(i == j) for j in range(n)] for i in range(n)] + + +def row_add(a, b, sign): + return [x + sign*y for x, y in zip(a, b)] + + +def run(word, n): + """Exact all-input linear map, all prefixes, and literal access invoice.""" + rows = identity(n) + adds = negs = travel = cursor = 0 + peak = 1 + for op in word: + require(len(op) == 4, "invalid instruction shape") + kind, d, s, sign = op + require(type(d) is int and 0 <= d < n, "invalid destination") + if kind == "ADD": + require(type(s) is int and 0 <= s < n and s != d and sign in (-1, 1), + "invalid or aliased ADD") + rows[d] = row_add(rows[d], rows[s], sign) + adds += 1 + travel += abs(cursor-s) + abs(s-d) + else: + require(kind == "NEG" and s == -1 and sign == -1, "invalid NEG") + rows[d] = [-x for x in rows[d]] + negs += 1 + travel += abs(cursor-d) + cursor = d + peak = max(peak, sum(map(abs, rows[d]))) + return rows, {"ADD": adds, "NEG": negs, "instructions": adds+negs, + "data_reads": 2*adds+negs, "data_writes": adds+negs, + "descriptor_fields": 4*(adds+negs), + "address_travel": travel+abs(cursor), "prefix_l1_peak": peak, + "registers": n} + + +def regular(g): + p = [[0]*6 for _ in range(6)] + for col in range(6): + p[compose(g, col)][col] = 1 + return p + + +def intertwiner(v): + z = (0, v[0], v[1]) + return [[z[p[i]] - z[p[0]] for p in PERM_FOR] for i in (1, 2)] + + +def linear_product(a, b): + return [[sum(x*y for x, y in zip(row, col)) for col in zip(*b)] for row in a] + + +def expected(n, v, drift=None, inverse=False): + out = identity(n) + r = intertwiner(v) + if drift is not None: + p = regular(INV[drift] if inverse else drift) + for i in range(6): + out[2+i][2:8] = p[i] + if inverse: + r = linear_product(r, p) + for i in range(2): + out[i][2:8] = [-x for x in r[i]] if inverse else r[i] + return out + + +def primitive_frame_minima(): + """Exhaust all distinct GL2(Z) endpoints through radius four, no cutoff.""" + initial = ((1, 0), (0, 1)) + dist, layer = {initial: 0}, {initial} + layers = [1] + for d in range(1, 5): + following = set() + for state in layer: + for target in (0, 1): + for sign in (-1, 1): + row = tuple(x+sign*y for x, y in zip(state[target], state[1-target])) + rows = list(state) + rows[target] = row + following.add(tuple(rows)) + rows = list(state) + rows[target] = tuple(-x for x in rows[target]) + following.add(tuple(rows)) + layer = following - dist.keys() + for state in layer: + dist[state] = d + layers.append(len(layer)) + costs = [] + for q in MATS: + state = (q[:2], q[2:]) + require(state in dist, "frame not reached at radius four") + costs.append(dist[state]) + return costs, layers + + +def raw_schedule_minima(drifts, pcost, qcost, cuts=()): + """Enumerate unaligned entrance and interior frame pairs, force only exits. + +Each child's independent response is carried through chronological output +operations. No planner alignment test or transition formula is used. There are +36**k words for k children after the two terminal frame choices are forced. +""" + k = len(drifts) + minima = {(a, b): None for a in range(1, 4) for b in range(1, 3)} + accepted = 0 + # Tags (left output action, right workspace action) denote Q_l R P_p. + # An explicit 2x6 equality decides whether each tag is the desired R. + r = intertwiner((1, 0)) + admissible_tag = {} + for left in range(6): + qm = [list(MATS[left][:2]), list(MATS[left][2:])] + for right in range(6): + actual = linear_product(linear_product(qm, r), regular(right)) + admissible_tag[left, right] = actual == r + for choices in product(range(36), repeat=k): + work = output = ONE + tags = [] + wp = qp = 0 + for j, choice in enumerate(choices): + a, b = divmod(choice, 6) + work = compose(a, work) + output = compose(b, output) + tags = [(compose(b, left), right) for left, right in tags] + wp += pcost[a] + qp += qcost[b] + if j in cuts and (work != ONE or output != ONE): + break + tags.append((ONE, work)) + work = compose(drifts[j], work) + if len(tags) != k: + continue + a, b = INV[work], INV[output] + wp += pcost[a] + qp += qcost[b] + tags = [(compose(b, left), right) for left, right in tags] + if not all(admissible_tag[tag] for tag in tags): + continue + accepted += 1 + for scales in minima: + bill = scales[0]*wp + scales[1]*qp + if minima[scales] is None or bill < minima[scales]: + minima[scales] = bill + return minima, 36**k, accepted + + +def certify_boundary(drifts, pcost, qcost, rows, path, claimed): + """Check a lower-bound potential and a matching path, without optimization. + +Transitions are constructed by enumerating actual frame pairs and multiplying +permutations chronologically. No construction gap formula is imported. +""" + require(len(rows) == len(drifts)+1 and len(path) == len(rows), "dual shape") + require(all(len(row) == 6 and all(type(v) is int for v in row) for row in rows), + "dual potentials must be integer six-vectors") + require(all(type(t) is int and 0 <= t < 6 for t in path), "primal phase") + require(path[-1] == ONE, "primal endpoint") + checks = 0 + for t in range(6): + require(rows[0][t] <= pcost[t]+qcost[t], "dual entrance exceeds legal price") + checks += 1 + primal = pcost[path[0]]+qcost[path[0]] + for j, drift in enumerate(drifts): + path_edges = [] + for before, a, b in product(range(6), repeat=3): + workspace_after = compose(a, compose(drift, before)) + output_after = compose(b, before) + if workspace_after != output_after: + continue + after = workspace_after + price = pcost[a]+qcost[b] + require(rows[j+1][after] <= rows[j][before]+price, + "invalid dual transition inequality") + checks += 1 + if before == path[j] and after == path[j+1]: + path_edges.append(price) + require(len(path_edges) == 1, "primal gap is not uniquely realized") + primal += path_edges[0] + require(rows[-1][ONE] == claimed == primal, "primal/dual gap") + return {"lower_bound": rows[-1][ONE], "primal_cost": primal, + "checked_inequalities": checks, "potentials": rows} diff --git a/research/s3-standard-output-transport/references/PR1287-README.md b/research/s3-standard-output-transport/references/PR1287-README.md new file mode 100644 index 0000000000..2cb99db015 --- /dev/null +++ b/research/s3-standard-output-transport/references/PR1287-README.md @@ -0,0 +1,274 @@ +# Three-cycle output frames replace workspace restorations + +This **recursive-interface research construction** extends the paid output-frame +idea of Sagar Thakrar's [PR1227](https://github.com/CrocSwap/integer-mult-bounds/pull/1227) +from scalar sign drift to a non-scalar three-cycle. The extension needs a real +admission condition: `R P = Q R`. Arbitrary readers do not satisfy it. + +For the frozen five-child example (`N=9` workspace coordinates, `d=3` output +coordinates), the complete source-only dirty echo costs **504 signed ADD +instructions instead of 588**. Both words restore every arbitrary scratch input. +A shortest boundary planner, full emitted recursive words and exact failure +controls make the result checkable. No selected supplier or new κ is claimed. + +## Fixed child contract and changed restriction + +Let `P` cyclically permute each of `m` workspace triples and `Q` each of `n` +output triples, sending `(a,b,c)` to `(c,a,b)`. Put `N=3m`, `d=3n`. The fixed, +indivisible child contract is + +``` +C_i(D,W) = (D + R_i W, P W), R_i P = Q R_i. +``` + +Children preserve their arbitrary private scratch and expose their literal +inverse at the same signed ADD count. Unlike sign-drifting children, these calls +are **not involutions**. Source/coefficient access and the internal source +permutation are part of the child bill. All maps here are exact and linear. + +For this particular `P,Q`, admission is equivalent to every 3×3 block of `R_i` +being circulant. Thus readers may inspect changing workspace coordinates; +they need not be invariant readers. The compiler checks the equality before +emitting a word. A separate dense multiplication check agrees on all 19,683 +3×3 matrices with entries in `{-1,0,1}`: exactly 27 are admitted. This is a +finite admission census, not a claim that only those integer readers exist. + +The parent may apply only complete-register `P^u` and `Q^v`, `u,v∈{0,1,2}`, +in gaps around the fixed ordered children. Each nontrivial power uses one +six-ADD rotation per triple. The existing six-primitive upper bound is credited +to [PR1145](https://github.com/CrocSwap/integer-mult-bounds/pull/1145); no new +rotation-circuit or minimality claim is made here. For power two, emit + +``` +a += b; b -= a; a += b; b += c; c -= b; b += c. +``` + +This sends `(a,b,c)` to `(b,c,a)`. Power one is its literal inverse. Neither +power uses a NEG, extra register, free frame annotation or unpriced temporary. +The executable checks these exact words; PR1145's lower-bound census is not +replayed or needed. Both eager and optimized batches use this same cheaper +rotation backend. + +The restriction to indivisible children is essential. The demonstration leaves +expose their terminal permutations, so a compiler allowed to remove those +permutations and sum their matrices directly beats both wrappers. This result +is an exact interface construction, not an optimal matrix algorithm. No actual +supplier with this indivisible boundary has been identified. + +## A sharp uniform boundary recurrence + +Write `A=m`, `B=n` for workspace/output costs in triple rotations; each costs six ADDs. +Let `p,q∈Z/3Z` be their respective current phases. A uniform correct word must +have `p=q` immediately before each child: after normalization of the output, +that child's contribution is `Q^(p-q) R_i W`. Independently varying `R_i` +among admitted readers includes an identity block in any block position, so a +nonzero phase cannot give the intended contribution for all readers. Arbitrary +incoming output also forces total output phase zero. This argument concerns a +word uniform over that reader class, not an accidentally cancelling fixed tuple. + +Calling a child takes aligned phase `t` to `(p,q)=(t+1,t)`. A gap returning to +aligned phase `s` therefore has the unique powers + +``` +u = s-t-1 mod 3, v = s-t mod 3, +c(t,s) = A [u != 0] + B [v != 0]. +``` + +Entrance phases cost `F_0(t)=(A+B)[t!=0]`. For each of `k` children, use + +``` +F_(j+1)(s) = min_t (F_j(t) + c(t,s)); b(k,A,B) = F_k(0). +``` + +This is an exact three-state shortest-path recurrence, with predecessor paths +retained by `model.plan`. It includes entrance and exit corrections. All gap +operations commute between the two disjoint registers; within one register +they reduce modulo three. Repeated powers cannot be cheaper than their reduced +representative at these positive symmetric prices. Thus every admissible +uniform word has such a path, and every path is realized. Induction proves the +recurrence for **all positive k,m,n**; the finite census below is a separate +implementation check, not its proof. Checkpoints requiring canonical registers +would additionally force phase zero at those cuts and are not optimized here. + +For the seed fixture, `b(5,3,1)=8`, versus the eager `5*3=15`. Its word calls +child one directly, rotates output by `Q` before each remaining child, then +applies `P` to workspace and `Q²` to output at exit. Four output rotations cost +4 triple rotations; final workspace/output corrections cost 3+1. Both +registers return to the canonical frame, with `D` increased by `(sum_i R_i)W`. + +This is distinct from PR1227's parity formula: a two-child boundary already +admits a three-operation alternative (`A+2B`), and child inversion cannot be +replaced by a forward call. The non-scalar admission and order-three boundary +planner are the added evidence. The output-frame idea and dirty-echo method +remain predecessor credit. + +## Complete echo and recursive implementation + +Let the completed batch be `H(D,W)=(D+L W,W)`, where `L=sum_i R_i`. Execute + +``` +W += X; H(D,W); W -= X; H^-1(D,W). +``` + +It returns `(D+L X, X, W_initial)` for every initial dirty `W,D`. Both copies +and both sets of complete child calls are paid. `H^-1` is the actual reverse +instruction word, with every ADD sign reversed; no involution shortcut is used. +All active ancestors' outputs and sources remain outside descendant scratch. +Siblings reuse a block only after the complete child returns. + +A leaf emits its signed matrix ADDs and `P` on its source. An internal reader +emits the above echo using its children and then applies `P` to its own source. +Sums of admitted readers remain admitted, so this recursively satisfies the +same child contract. One width-N dirty block per active internal level suffices; +no initialization or hidden clean accumulator is used. + +Let `a_v,c_v` count direct ADDs and triple rotations, respectively, **including all +descendants**. With fixed common dimensions, the complete recurrence is + +``` +leaf: a_v = sum of absolute matrix entries; c_v = m +internal: a_v = 2 sum_i a_i + 2N + c_v = 2 sum_i c_i + 2 b(k_v,m,n) + m +``` + +For a root echo omit the final `+m`. Eager restoration replaces `b` by `m k_v`. +After expansion, `ADD=a_v+6c_v`, `NEG=0`. At maximum depth `h` (leaf depth 0), +data storage is `d+(h+1)N`, counting output, source and all dirty work blocks. +This is a complete depth recurrence, not an asymptotic input-size recurrence. +With inclusive addressed-machine ADD price `alpha`, the reader bill is + +`T_v = 2 sum_i T_i + [2N + 6(2b+m)] alpha`. + +Preparation, descriptor access and routing are separate resources, not free +recursive work. The supplied compiler materializes `P_len=ADD` primitives +from description size `M`. Its planner stores complete path tuples, giving +`O(k²)` preparation time and `O(k)` live path space per distinct child count +(cached afterward). A conservative uncached whole-tree bound is +`O((h+1)(M+P_len) + sum_v k_v²)` preparation time and +`O(M+P_len+sum_v k_v+h)` compiler/program storage. This cost is additional to +the execution recurrence; no total preparation-plus-execution improvement is +claimed. The finite word must then be read. The source matrix entries and +signed operands appear in that word; no runtime multiplication or coefficient oracle is assumed for ±1 leaves. + +| Complete seed echo | Eager | Output frames | +| --- | ---: | ---: | +| Direct ADDs | 228 | 228 | +| Triple rotations, including child source drift | 60 | 46 | +| Expanded signed ADDs | 588 | 504 | +| NEGs | 0 | 0 | +| Dispatches / writes | 588 | 504 | +| Data reads | 1176 | 1008 | +| Instruction fields | 2352 | 2016 | +| Declared data-address travel | 7286 | 7234 | +| Data registers | 21 | 21 | +| Exact forward prefix row-L1 peak | 31 | 42 | +| Exact inverse prefix row-L1 peak, arbitrary inverse input | 28 | 40 | + +ADD reads two cells and writes one; records contain four fields, including +the sign and addresses. Thus reads=`2ADD`, writes=dispatches=`ADD`, +fields=`4ADD`. `oracle.invoice` independently reconstructs the access +records. The travel column visits each ADD's source then destination and +returns a cursor to zero. It is an exact score for this specified layout/access +trace, **not a constructed tape-machine implementation**. + +Arithmetic savings need not improve every resource. The depth-three witness +saves 1,548 primitives (9,408→7,860), but its travel score rises +137,726→141,338 and its prefix bound rises 65→106. Even the small fixture's +prefix bound rises 31→42. These costs must not be hidden in supplier adoption. +For this finite exact word, input magnitude ≤M gives coordinate magnitude +≤`prefix_l1_peak*M`; finite bit-width or rational representation costs are not +incorporated into a multiplication bound. No fixed-precision/rounded-leaf +contract, physical routing, hosting, common-label, all-size or analytic result +is established. + +## Reproduction and completed coverage + +Standard library only; from the repository root: + +```sh +python3.12 scripts/research_package.py --package research/cyclic-output-restoration +``` + +Expected final marker: `PASS_REGISTERED_RESEARCH_PACKAGE` with outcome completed. +The direct checker is `python3 -I -O -B research/cyclic-output-restoration/verify.py`; +its marker reports `saved_rotations=14 saved_primitives=84 no_new_kappa`. +`--emit` regenerates the complete certificate, which ordinary replay compares +field for field. Required checks use explicit exceptions and still run with `-O`. + +Completed domains, with stopping rule **exhaust exactly these finite sets**: + +- All 66,420 normalized boundary schedules through four children, including + all entrance and exit choices. The code-disjoint oracle propagates a distinct + symbolic response for each child through literal output rotations, without + using the planner's alignment predicate. The 120 admitted schedules give the + same minima at all 100 `1<=m,n<=5` price comparisons. Another 150 checks test + price scaling and the eager upper bound through 30 children; these are not + exhaustive schedule censuses at those lengths. +- All 19,683 ternary 3×3 readers, using indexed admission and independent dense + matrix products; 27 admitted, 19,656 rejected. +- `1<=m<=3`, `1<=n<=2`, `1<=k<=4`, depths 1 and 2, echo/reader contracts and + eager/optimized words: 192 cases, 3,744 basis columns and 157,704 forward + primitive occurrences. Every case checks all arbitrary dirty-state columns, + literal inverse (also from arbitrary inverse input against a separate block + inverse formula), macro expansion, recurrence, access invoice and a rational + dirty probe. A frozen five-child fixture and a separate depth-three witness + are also fully checked. Leaf entries come from `random.Random(56)` over + `{-1,0,1}`; the depth-three example uses seed 57. +- Ten mathematical controls reject missing copies/restoration/output frames, + incorrect rotation expansion, a forward-for-inverse substitution, non-equivariant + readers, premature canonical observations and nonlinear dirty substitution. + `test_package.py` adds API input, plan-path, relocation and corruption checks. + +No finite replay is a formal proof of the complete multiplication theorem. +Neither human peer review nor hosted CI success is inferred from local passes. +The selected supplier is unchanged, so its expensive cold replay was not run. + +## Provenance and credit + +Exact base: `dadfea6e8a78ff6ba901705f87532a71c6f5bbb8`; OS assignment seed **56**, +recursive interfaces. The selected construction is Rohan Arun's PR1094 on +Jeremy Kothe's retained word/packing and the PR589/555 bit lineage, with +κ=`836330098538459/500000000000000000`. The actual selected construction, review, +source manifest and certificate were inspected and pinned as historical context +in `SOURCES.json`. `upstream/`, the selected record and frozen packages are unchanged. + +Sagar Thakrar's PR1227 (`fea44a4d0d78570021d854881d15d9efe62e1713`) supplies the +paid output-sign mechanism and complete echo comparison. MightyOil/Philipp's +PR1203 (`38459854fd5bb93099871a84324413bd0e338d8e`) supplies noncommuting invariant +readers and source-only restoration accounting. Ross Richardson's PR1145 +(`fd4d5ffc448361297e717aa30eafed578caf8e61`) supplies the existing six-ADD three-cycle upper bound, found in the final overlap check and +used for both words. Its CK/JP8 lower bounds and PR1216's restored-donor extension +concern different boundary alphabets; neither is re-established here. These +three README files, original notices, Git blob IDs and SHA256 hashes are retained in `sources/` and +`PREDECESSORS.json`; no executable predecessor code is imported. Also credit +Aaron Wang/Navinor PR1155, Sagar Thakrar PR1199, Adam Gall PR1205, and Ross +Richardson/CubeJerry PR889 for the existing restoration and dirty-echo lineages. +Hanson Sun's concurrent [PR1246](https://github.com/CrocSwap/integer-mult-bounds/pull/1246) +adds paid additive defect repair at canonical partition cuts; its head +`5ed1ce17a9df4c853a93f9758ba903d2620c3443` was inspected at submission. It is +distinct from keeping output in a moving cyclic frame between fixed calls. +No code, certificate or mathematical dependency is imported from it. + +This package does not claim priority for their compatible-reader corrections, +observation distinctions or output-frame/echo principles. + +Prepared by **Ross Richardson** with substantial **OpenAI Codex assistance** in +algebra, implementation, verification and prose, including both code paths. +No independent human audit is claimed. New material is Apache-2.0 under the +repository license; retained sources keep their original credit and notices. +The scoped claim, three considered candidates and overlap coverage are in +`CLAIM.md`; structured outcome and next questions are in `TASK.json`. + +## Open next questions + +Does a supported supplier expose an indivisible cyclic-equivariant reader with +a cheaper output action than workspace restoration? Test one candidate's exact +source-return map for `R P=Q R`, then price its routing, precision and retained +child boundary. Those missing supplier facts currently block an asymptotic +application. If its source drift can simply be deleted inside the child, reject +it as evidence for this wrapper's algorithmic benefit. + +Can canonical intermediate checkpoints retain enough of this saving? A first +step is to constrain phase zero at a specified cut in the same three-state +recurrence, then emit and price that word. This would address observation +requirements; no adaptive observer implementation is supplied here. diff --git a/research/s3-standard-output-transport/test_package.py b/research/s3-standard-output-transport/test_package.py new file mode 100644 index 0000000000..ba8cb78d19 --- /dev/null +++ b/research/s3-standard-output-transport/test_package.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +"""Bounded package failures and read-only relocation, with optimized Python. + +Hanson Sun (@bbMisk), with substantial OpenAI Codex assistance. Apache-2.0. +""" +import hashlib +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent + + +def replay(package): + return subprocess.run([sys.executable, "-I", "-O", "-B", str(package/"verify.py")], + cwd=package.parent, capture_output=True, text=True, timeout=60) + + +def hashes(package): + return {p.relative_to(package).as_posix(): hashlib.sha256(p.read_bytes()).hexdigest() + for p in package.rglob("*") if p.is_file()} + + +class PackageTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory(prefix="s3-output-test-") + self.copy = Path(self.tmp.name)/"relocated" + shutil.copytree(HERE, self.copy, ignore=shutil.ignore_patterns("__pycache__")) + + def tearDown(self): + for p in self.copy.rglob("*"): + p.chmod(0o755 if p.is_dir() else 0o644) + self.copy.chmod(0o755) + self.tmp.cleanup() + + def test_read_only_relocation(self): + before = hashes(self.copy) + for p in self.copy.rglob("*"): + p.chmod(0o555 if p.is_dir() else 0o444) + self.copy.chmod(0o555) + result = replay(self.copy) + self.assertEqual(result.returncode, 0, result.stdout+result.stderr) + self.assertIn("PASS_S3_STANDARD_OUTPUT", result.stdout) + self.assertEqual(hashes(self.copy), before) + + def test_changed_certificate_rejected(self): + p = self.copy/"CERTIFICATE.json" + data = json.loads(p.read_text()) + data["seed_fixture"]["saved_instructions"] += 1 + p.write_text(json.dumps(data)) + result = replay(self.copy) + self.assertNotEqual(result.returncode, 0) + self.assertIn("certificate differs", result.stderr) + + def test_changed_reference_rejected(self): + p = self.copy/"references/PR1287-README.md" + p.write_bytes(p.read_bytes()+b"\nchanged predecessor\n") + result = replay(self.copy) + self.assertNotEqual(result.returncode, 0) + self.assertIn("predecessor source drift", result.stderr) + + def test_wrong_output_macro_rejected(self): + p = self.copy/"model.py" + source = p.read_text() + old, new = "(add(1, 0, -1), neg(0)),", "(add(1, 0, 1), neg(0))," + self.assertEqual(source.count(old), 1) + p.write_text(source.replace(old, new)) + result = replay(self.copy) + self.assertNotEqual(result.returncode, 0) + self.assertIn("wrong output word", result.stderr) + + def test_emission_refuses_existing_certificate(self): + target = self.copy/"CERTIFICATE.json" + before = target.read_bytes() + result = subprocess.run([sys.executable, "-I", "-O", "-B", str(self.copy/"verify.py"), + "--emit", str(target)], capture_output=True, text=True, timeout=60) + self.assertNotEqual(result.returncode, 0) + self.assertIn("refusing to overwrite", result.stderr) + self.assertEqual(target.read_bytes(), before) + + +if __name__ == "__main__": + unittest.main() diff --git a/research/s3-standard-output-transport/verify.py b/research/s3-standard-output-transport/verify.py new file mode 100644 index 0000000000..62161a3edc --- /dev/null +++ b/research/s3-standard-output-transport/verify.py @@ -0,0 +1,339 @@ +#!/usr/bin/env python3 +"""Recompute the exact, scoped S3 transport certificate; never trust exit alone. + +Hanson Sun (@bbMisk), with substantial OpenAI Codex assistance. Apache-2.0. +""" +import argparse +from hashlib import sha256 +import importlib.util +from itertools import product +import json +from pathlib import Path +import random +import sys + +HERE = Path(__file__).resolve().parent + + +def load(name): + spec = importlib.util.spec_from_file_location("s3_transport_"+name, HERE/(name+".py")) + module = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = module + spec.loader.exec_module(module) + return module + + +m, o = load("model"), load("oracle") +require = o.require + + +def digest(value): + return sha256(json.dumps(value, separators=(",", ":"), sort_keys=True).encode()).hexdigest() + + +def sum_vectors(children): + leaves = [] + def visit(c): + if c.children: + for sub in c.children: + visit(sub) + else: + leaves.append(c.v) + for child in children: + visit(child) + return tuple(sum(v[i] for v in leaves) for i in range(2)) + + +def source_bindings(): + refs = json.loads((HERE/"PREDECESSORS.json").read_text()) + pins = [] + for row in refs["references"]: + if "path" in row: + data = (HERE/row["path"]).read_bytes() + require(sha256(data).hexdigest() == row["sha256"], "predecessor source drift") + pins.append({"path": row["path"], "sha256": row["sha256"]}) + return pins + + +def check_group_and_admission(): + require(m.G == o.MATS, "matrix/permutation group disagreement") + for a, b in product(range(6), repeat=2): + require(m.mul(a, b) == o.compose(a, b), "chronological product mismatch") + costs, layers = o.primitive_frame_minima() + require(costs == list(m.Q_COST), "output primitive minimum differs") + for g in range(6): + actual, _ = o.run(m.p_word(g, list(range(6))), 6) + require(actual == o.regular(g), "wrong regular permutation word") + actual, _ = o.run(m.q_word(g, (0, 1)), 2) + require(sum(actual, []) == list(o.MATS[g]), "wrong output word") + require(m.P_COST[g] == (0 if g == m.E else 12), "workspace macro bill") + require(m.mul(m.S, m.T) != m.mul(m.T, m.S), "commuting fixture") + mutations = checks = 0 + for v in product(range(-2, 3), repeat=2): + r = m.reader(v) + require([list(row) for row in r] == o.intertwiner(v), "reader mismatch") + require(m.admitted(r), "valid intertwiner rejected") + for g in range(6): + q = [list(o.MATS[g][:2]), list(o.MATS[g][2:])] + require(o.linear_product(r, o.regular(g)) == o.linear_product(q, r), + "dense intertwiner equality failed") + checks += 1 + for i, j in product(range(2), range(6)): + bad = [list(row) for row in r] + bad[i][j] += 1 + require(not m.admitted(bad), "one-entry nonintertwiner admitted") + mutations += 1 + # Complete enumeration of group matrices proves this finite representation + # is faithful; the written characterization extends to all allowed readers. + require(len(set(o.MATS)) == 6, "nonfaithful output action") + return {"group_products": 36, "frame_words": 12, "admission_identities": checks, + "admission_mutations": mutations, "output_bfs_layers": layers, + "output_costs": costs, "workspace_macro_costs": list(m.P_COST)} + + +def check_schedules(): + words = accepted = comparisons = 0 + records = [] + for k in range(1, 4): + for drifts in product((m.S, m.T), repeat=k): + minima, count, valid = o.raw_schedule_minima(drifts, m.P_COST, m.Q_COST) + words += count + accepted += valid + for (a, b), value in minima.items(): + result = m.plan(drifts, pscale=a, qscale=b)[0] + require(result == value, "six-state planner/raw schedule disagreement") + comparisons += 1 + records.append([list(drifts), valid, sorted((list(key), value) + for key, value in minima.items())]) + cut_comparisons = 0 + for cuts in ((1,), (2,), (1, 2), (0, 1, 2)): + drifts = (m.S, m.T, m.S) + minima, _, _ = o.raw_schedule_minima(drifts, m.P_COST, m.Q_COST, cuts) + for (a, b), value in minima.items(): + require(m.plan(drifts, cuts, a, b)[0] == value, "canonical cut mismatch") + cut_comparisons += 1 + return {"unrestricted_words": words, "admitted_words": accepted, + "price_comparisons": comparisons, "cut_words": 4*36**3, + "cut_price_comparisons": cut_comparisons, "records_sha256": digest(records)} + + +def seed_fixture(): + rng = random.Random(58) + nontrivial = [g for g in range(6) if g != m.E] + drifts = [rng.choice(nontrivial) for _ in range(8)] + vectors = [rng.choice(((1, 0), (0, 1), (1, 1))) for _ in drifts] + return tuple(m.Node(g, v) for g, v in zip(drifts, vectors)) + + +def check_echo(children, optimized, cuts=()): + n = 2+6*(max(map(m.depth, children))+2) + word = m.echo_word(children, (0, 1), tuple(range(2, 8)), 8, optimized, cuts) + actual, invoice = o.run(word, n) + v = sum_vectors(children) + require(actual == o.expected(n, v), "dirty echo map mismatch") + inverse, inverse_invoice = o.run(m.inverse_word(word), n) + require(inverse == o.expected(n, v, inverse=True), "dirty echo inverse mismatch") + require(len(word) == m.cost_echo(children, optimized, cuts), "echo recurrence mismatch") + invoice["inverse_prefix_l1_peak"] = inverse_invoice["prefix_l1_peak"] + return word, invoice + + +def check_recursive_cases(): + rng = random.Random(58) + cases = columns = occurrences = 0 + invoices = [] + def tree(d): + g = rng.randrange(6) + if not d: + return m.Node(g, (rng.randrange(-1, 2), rng.randrange(-1, 2))) + return m.Node(g, children=tuple(tree(d-1) for _ in range(2))) + for d in range(4): + for _ in range(3): + node = tree(d) + n = 2+6*(d+1) + for optimized in (False, True): + word = m.node_word(node, optimized=optimized) + actual, invoice = o.run(word, n) + v = sum_vectors((node,)) + require(actual == o.expected(n, v, node.drift), "recursive child contract") + inverse, inverse_invoice = o.run(m.inverse_word(word), n) + require(inverse == o.expected(n, v, node.drift, True), + "recursive child inverse contract") + require(len(word) == m.cost_node(node, optimized), "node recurrence") + cases += 1 + columns += 2*n + occurrences += 2*len(word) + invoices.append([d, optimized, invoice, inverse_invoice["prefix_l1_peak"]]) + return {"cases": cases, "forward_and_inverse_columns": columns, + "primitive_occurrences": occurrences, "invoice_sha256": digest(invoices)} + + +def check_array_lifts(word, base_map, base_invoice): + records = [] + for width in (2, 3): + lifted = [(kind, d*width+j, s*width+j if kind == "ADD" else -1, sign) + for kind, d, s, sign in word for j in range(width)] + actual, invoice = o.run(lifted, len(base_map)*width) + expected = [[base_map[i//width][j//width] if i % width == j % width else 0 + for j in range(len(actual))] for i in range(len(actual))] + require(actual == expected, "array lift differs from the exact tensor product") + for field in ("ADD", "NEG", "instructions", "data_reads", "data_writes", + "descriptor_fields", "registers"): + require(invoice[field] == width*base_invoice[field], "array cost not charged") + require(invoice["prefix_l1_peak"] == base_invoice["prefix_l1_peak"], + "array lift prefix bound") + records.append({"width": width, "basis_columns": len(actual), + "instructions": len(lifted), "word_sha256": digest(lifted)}) + return records + + +def controls(children, optimized_word): + names = [] + n = 14 + target = o.expected(n, sum_vectors(children)) + def rejected(name, word): + require(o.run(word, n)[0] != target, "negative control survived: "+name) + names.append(name) + rejected("missing_positive_source_copy", optimized_word[1:]) + # The reverse H call is essential; these children are not involutions. + h, path, _ = m.batch_word(children, (0, 1), list(range(8, 14)), 14) + plus = [m.add(8+j, 2+j) for j in range(6)] + minus = [m.add(8+j, 2+j, -1) for j in range(6)] + rejected("forward_child_batch_used_as_inverse", plus+h+minus+h) + rejected("missing_negative_source_copy", plus+h+minus[1:]+m.inverse_word(h)) + # The optimal seed uses pure P or Q gaps, where an order bug is invisible. + # Use a legal mixed-frame witness instead: drift S, requested next phase T. + # Correct formula is delta*g^-1, not g^-1*delta. + pair = (m.Node(m.S, (1, 0)), m.Node(m.T, (0, 1))) + phases = (m.E, m.T, m.E) + right, wrong = [], [] + for j, child in enumerate(pair): + child_word = m.node_word(child, (0, 1), tuple(range(8, 14)), 14) + delta = m.mul(phases[j+1], m.INVERSE[phases[j]]) + for word, a in ((right, m.mul(delta, m.INVERSE[child.drift])), + (wrong, m.mul(m.INVERSE[child.drift], delta))): + word.extend(child_word) + word.extend(m.p_word(a, list(range(8, 14)))) + word.extend(m.q_word(delta, (0, 1))) + pair_target = o.expected(n, sum_vectors(pair)) + require(o.run(plus+right+minus+m.inverse_word(right), n)[0] == pair_target, + "mixed-gap positive control") + require(o.run(plus+wrong+minus+m.inverse_word(wrong), n)[0] != pair_target, + "mixed-gap noncommuting order control survived") + names.append("reversed_noncommuting_gap_order") + # Ignoring Q entirely leaves dirt-independent but incorrect source responses. + untransported = [] + for child in children: + untransported.extend(m.node_word(child, (0, 1), tuple(range(8, 14)), 14)) + product_g = m.E + for child in children: + product_g = m.mul(child.drift, product_g) + untransported.extend(m.p_word(m.INVERSE[product_g], list(range(8, 14)))) + rejected("workspace_restored_without_output_transport", + plus+untransported+minus+m.inverse_word(untransported)) + batch, phases, cuts = m.batch_word(children, (0, 1), tuple(range(2, 8)), 8) + observed = False + for j in range(1, len(children)): + if phases[j] != m.E: + physical, _ = o.run(batch[:cuts[j]], 8) + canonical = o.expected(8, sum_vectors(children[:j])) + if physical[:2] != canonical[:2]: + observed = True + break + require(observed, "premature canonical observation control did not fire") + names.append("premature_canonical_output_observation") + # A canonical frame inside H still contains workspace dirt. It is not a + # public partial source-only answer until the enclosing echo finishes. + canonical_h, _, boundaries = m.batch_word(children, (0, 1), tuple(range(8, 14)), + 14, cuts=(4,)) + mid, _ = o.run(plus+canonical_h[:boundaries[4]], n) + require(mid[:2] != o.expected(n, sum_vectors(children[:4]))[:2], + "dirty midpoint was incorrectly exposed as source-only") + names.append("canonical_frame_is_not_public_dirty_echo_output") + r = o.intertwiner((1, 0)) + lhs = o.linear_product(r, o.regular(m.T)) + require(lhs != [[-x for x in row] for row in r], "scalar sign unexpectedly sufficient") + names.append("replace_faithful_output_by_sign_character") + # With nonlinear readout f(w)=w^2 the echo difference contains 2wx. + require((2+3)**2-2**2 != 3**2, "nonlinear dirty echo control") + names.append("nonlinear_readout_breaks_dirty_echo") + try: + o.run([m.add(0, 0)], 2) + except ValueError: + names.append("aliased_two_address_add") + else: + raise ValueError("aliasing accepted") + return names + + +def evidence(): + refs = source_bindings() + group = check_group_and_admission() + schedules = check_schedules() + children = seed_fixture() + optimized, opt = check_echo(children, True) + eager, old = check_echo(children, False) + require(opt["instructions"] < old["instructions"], "no complete improvement") + price, path = m.plan(tuple(c.drift for c in children)) + drifts = tuple(c.drift for c in children) + dual = o.certify_boundary(drifts, m.P_COST, m.Q_COST, + m.distance_certificate(drifts), path, price) + with_cut, cut_invoice = check_echo(children, True, (4,)) + # Explicitly verify the canonical midpoint, including workspace restoration. + batch, _, boundaries = m.batch_word(children, (0, 1), tuple(range(2, 8)), 8, + cuts=(4,)) + mid, _ = o.run(batch[:boundaries[4]], 8) + require(mid == o.expected(8, sum_vectors(children[:4])), "canonical midpoint broken") + recursive = check_recursive_cases() + failures = controls(children, optimized) + lifts = check_array_lifts(optimized, o.expected(14, sum_vectors(children)), opt) + bad_dual = [row[:] for row in dual["potentials"]] + bad_dual[-1][m.E] += 1 + try: + o.certify_boundary(drifts, m.P_COST, m.Q_COST, bad_dual, path, price+1) + except ValueError: + failures.append("overstated_boundary_lower_bound") + else: + raise ValueError("overstated lower-bound certificate accepted") + return {"schema_version": 1, "status": "SCOPED_EXACT_INTERFACE_NO_NEW_KAPPA", + "assignment_seed": 58, "group": [list(g) for g in m.G], + "source_bindings": refs, "group_and_admission": group, + "schedule_coverage": schedules, "recursive_coverage": recursive, + "array_lifts": lifts, + "seed_fixture": { + "children": [{"drift": c.drift, "v": list(c.v)} for c in children], + "reader_sum_vector": list(sum_vectors(children)), + "boundary_cost": price, "eager_boundary_cost": sum(m.P_COST[c.drift] for c in children), + "boundary_primal_dual": dual, + "midpoint_boundary_cost": m.plan(tuple(c.drift for c in children), (4,))[0], + "path": list(path), "eager": old, "transport": opt, + "saved_instructions": old["instructions"]-opt["instructions"], + "eager_word_sha256": digest(eager), "transport_word_sha256": digest(optimized), + "midpoint_canonical": cut_invoice, "midpoint_word_sha256": digest(with_cut)}, + "negative_controls": failures} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--emit", type=Path, help="write a fresh certificate; ordinary replay is read-only") + args = parser.parse_args() + try: + actual = evidence() + if args.emit: + require(not args.emit.exists(), "refusing to overwrite a certificate") + args.emit.write_text(json.dumps(actual, indent=2)+"\n") + else: + expected = json.loads((HERE/"CERTIFICATE.json").read_text()) + require(actual == expected, "certificate differs from exact recomputation") + seed = actual["seed_fixture"] + print("PASS_S3_STANDARD_OUTPUT boundary=%s_vs_%s echo=%s_vs_%s saved=%s controls=%s no_new_kappa" + % (seed["boundary_cost"], seed["eager_boundary_cost"], + seed["transport"]["instructions"], seed["eager"]["instructions"], + seed["saved_instructions"], len(actual["negative_controls"]))) + except (ValueError, KeyError, OSError, TypeError) as exc: + print("FAIL_S3_STANDARD_OUTPUT: "+str(exc), file=sys.stderr) + raise SystemExit(1) + + +if __name__ == "__main__": + main()