From 5a306ee4115848883ff297adbec59e81ab85f14b Mon Sep 17 00:00:00 2001 From: commdata2338 <199849969+commdata2338@users.noreply.github.com> Date: Thu, 15 Oct 2026 02:25:46 -0500 Subject: [PATCH] Research: an optimal 144-call seven-source sparse-mask connector Takes PR #2236's 18-event construction handoff in discussion #2221. A closed single-source path of 18 toggles, with multiplicities (4,4,2,2,2,2,2), supports every one of the 63 seven-source masks of Hamming weight 1, 2 and 3 as a difference of two prefix states. With 126 paired output calls this gives 144 complete calls, attaining PR #2236's lower boundary in its event model. The witness is replayed by independent interval-XOR and prefix-difference methods, with explicit readout pairs, symbolic arbitrary linear maps and dirty connector and target restoration. Minimality rests on the predecessor's lower bound; no supplier or kappa change. Adds research/seven-source-18event-connector/ only. Submitted by @commdata2338 with substantial AI assistance (OpenAI Codex research and implementation; packaged with Claude Code). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01X86sCSXdoDd61SDFfC1PKG --- .../CERTIFICATE.json | 941 ++++++++++++++++++ .../seven-source-18event-connector/README.md | 231 +++++ .../RESULT.json | 82 ++ .../SOURCES.json | 68 ++ .../seven-source-18event-connector/TASK.json | 120 +++ .../VERIFY.json | 34 + .../test_verify.py | 99 ++ .../seven-source-18event-connector/verify.py | 348 +++++++ 8 files changed, 1923 insertions(+) create mode 100644 research/seven-source-18event-connector/CERTIFICATE.json create mode 100644 research/seven-source-18event-connector/README.md create mode 100644 research/seven-source-18event-connector/RESULT.json create mode 100644 research/seven-source-18event-connector/SOURCES.json create mode 100644 research/seven-source-18event-connector/TASK.json create mode 100644 research/seven-source-18event-connector/VERIFY.json create mode 100644 research/seven-source-18event-connector/test_verify.py create mode 100644 research/seven-source-18event-connector/verify.py diff --git a/research/seven-source-18event-connector/CERTIFICATE.json b/research/seven-source-18event-connector/CERTIFICATE.json new file mode 100644 index 0000000000..903998bcd1 --- /dev/null +++ b/research/seven-source-18event-connector/CERTIFICATE.json @@ -0,0 +1,941 @@ +{ + "schema": "seven-source-18event-connector/1", + "source_word": [ + 0, + 1, + 2, + 3, + 1, + 0, + 4, + 2, + 0, + 5, + 1, + 4, + 1, + 6, + 5, + 0, + 3, + 6 + ], + "prefix_states": [ + 0, + 1, + 3, + 7, + 15, + 13, + 12, + 28, + 24, + 25, + 57, + 59, + 43, + 41, + 105, + 73, + 72, + 64, + 0 + ], + "target_masks": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 24, + 25, + 26, + 28, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 40, + 41, + 42, + 44, + 48, + 49, + 50, + 52, + 56, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 72, + 73, + 74, + 76, + 80, + 81, + 82, + 84, + 88, + 96, + 97, + 98, + 100, + 104, + 112 + ], + "readout_pairs": { + "1": [ + 0, + 1 + ], + "2": [ + 1, + 2 + ], + "3": [ + 0, + 2 + ], + "4": [ + 2, + 3 + ], + "5": [ + 7, + 9 + ], + "6": [ + 1, + 3 + ], + "7": [ + 0, + 3 + ], + "8": [ + 3, + 4 + ], + "9": [ + 15, + 17 + ], + "10": [ + 3, + 5 + ], + "11": [ + 3, + 6 + ], + "12": [ + 0, + 6 + ], + "13": [ + 0, + 5 + ], + "14": [ + 1, + 4 + ], + "16": [ + 6, + 7 + ], + "17": [ + 5, + 7 + ], + "18": [ + 10, + 12 + ], + "19": [ + 4, + 7 + ], + "20": [ + 5, + 9 + ], + "21": [ + 5, + 8 + ], + "22": [ + 4, + 9 + ], + "24": [ + 0, + 8 + ], + "25": [ + 0, + 9 + ], + "26": [ + 2, + 9 + ], + "28": [ + 0, + 7 + ], + "32": [ + 9, + 10 + ], + "33": [ + 8, + 10 + ], + "34": [ + 9, + 11 + ], + "35": [ + 8, + 11 + ], + "36": [ + 4, + 12 + ], + "37": [ + 6, + 13 + ], + "38": [ + 4, + 13 + ], + "40": [ + 1, + 13 + ], + "41": [ + 0, + 13 + ], + "42": [ + 1, + 12 + ], + "44": [ + 3, + 12 + ], + "48": [ + 9, + 13 + ], + "49": [ + 8, + 13 + ], + "50": [ + 9, + 12 + ], + "52": [ + 4, + 11 + ], + "56": [ + 1, + 10 + ], + "64": [ + 0, + 17 + ], + "65": [ + 1, + 17 + ], + "66": [ + 12, + 14 + ], + "67": [ + 2, + 17 + ], + "68": [ + 5, + 15 + ], + "69": [ + 5, + 16 + ], + "70": [ + 4, + 15 + ], + "72": [ + 0, + 16 + ], + "73": [ + 0, + 15 + ], + "74": [ + 2, + 15 + ], + "76": [ + 6, + 17 + ], + "80": [ + 8, + 16 + ], + "81": [ + 8, + 15 + ], + "82": [ + 11, + 14 + ], + "84": [ + 7, + 16 + ], + "88": [ + 8, + 17 + ], + "96": [ + 13, + 15 + ], + "97": [ + 13, + 16 + ], + "98": [ + 12, + 15 + ], + "100": [ + 5, + 14 + ], + "104": [ + 1, + 14 + ], + "112": [ + 9, + 14 + ] + }, + "events": [ + [ + "A", + 0 + ], + [ + "A", + 2 + ], + [ + "A", + 6 + ], + [ + "A", + 11 + ], + [ + "A", + 12 + ], + [ + "A", + 21 + ], + [ + "A", + 22 + ], + [ + "A", + 24 + ], + [ + "A", + 33 + ], + [ + "A", + 41 + ], + [ + "A", + 48 + ], + [ + "A", + 49 + ], + [ + "B", + 0 + ], + [ + "A", + 0 + ], + [ + "A", + 1 + ], + [ + "A", + 5 + ], + [ + "A", + 13 + ], + [ + "A", + 32 + ], + [ + "A", + 34 + ], + [ + "A", + 40 + ], + [ + "A", + 42 + ], + [ + "A", + 61 + ], + [ + "B", + 1 + ], + [ + "A", + 1 + ], + [ + "A", + 2 + ], + [ + "A", + 3 + ], + [ + "A", + 23 + ], + [ + "A", + 44 + ], + [ + "A", + 50 + ], + [ + "B", + 2 + ], + [ + "A", + 3 + ], + [ + "A", + 5 + ], + [ + "A", + 6 + ], + [ + "A", + 7 + ], + [ + "A", + 9 + ], + [ + "A", + 10 + ], + [ + "A", + 35 + ], + [ + "B", + 3 + ], + [ + "A", + 7 + ], + [ + "A", + 13 + ], + [ + "A", + 17 + ], + [ + "A", + 20 + ], + [ + "A", + 29 + ], + [ + "A", + 31 + ], + [ + "A", + 39 + ], + [ + "A", + 47 + ], + [ + "B", + 1 + ], + [ + "A", + 9 + ], + [ + "A", + 12 + ], + [ + "A", + 15 + ], + [ + "A", + 18 + ], + [ + "A", + 19 + ], + [ + "A", + 45 + ], + [ + "A", + 46 + ], + [ + "A", + 60 + ], + [ + "B", + 0 + ], + [ + "A", + 10 + ], + [ + "A", + 11 + ], + [ + "A", + 14 + ], + [ + "A", + 30 + ], + [ + "A", + 51 + ], + [ + "B", + 4 + ], + [ + "A", + 4 + ], + [ + "A", + 14 + ], + [ + "A", + 15 + ], + [ + "A", + 17 + ], + [ + "A", + 24 + ], + [ + "A", + 55 + ], + [ + "B", + 2 + ], + [ + "A", + 19 + ], + [ + "A", + 21 + ], + [ + "A", + 26 + ], + [ + "A", + 28 + ], + [ + "A", + 37 + ], + [ + "A", + 52 + ], + [ + "A", + 53 + ], + [ + "A", + 56 + ], + [ + "B", + 0 + ], + [ + "A", + 4 + ], + [ + "A", + 18 + ], + [ + "A", + 20 + ], + [ + "A", + 22 + ], + [ + "A", + 23 + ], + [ + "A", + 25 + ], + [ + "A", + 27 + ], + [ + "A", + 36 + ], + [ + "A", + 38 + ], + [ + "A", + 62 + ], + [ + "B", + 5 + ], + [ + "A", + 16 + ], + [ + "A", + 25 + ], + [ + "A", + 26 + ], + [ + "A", + 40 + ], + [ + "B", + 1 + ], + [ + "A", + 27 + ], + [ + "A", + 28 + ], + [ + "A", + 39 + ], + [ + "A", + 54 + ], + [ + "B", + 4 + ], + [ + "A", + 16 + ], + [ + "A", + 29 + ], + [ + "A", + 34 + ], + [ + "A", + 35 + ], + [ + "A", + 38 + ], + [ + "A", + 43 + ], + [ + "A", + 59 + ], + [ + "B", + 1 + ], + [ + "A", + 30 + ], + [ + "A", + 31 + ], + [ + "A", + 32 + ], + [ + "A", + 33 + ], + [ + "A", + 36 + ], + [ + "A", + 37 + ], + [ + "A", + 57 + ], + [ + "A", + 58 + ], + [ + "B", + 6 + ], + [ + "A", + 43 + ], + [ + "A", + 54 + ], + [ + "A", + 60 + ], + [ + "A", + 61 + ], + [ + "A", + 62 + ], + [ + "B", + 5 + ], + [ + "A", + 8 + ], + [ + "A", + 45 + ], + [ + "A", + 47 + ], + [ + "A", + 49 + ], + [ + "A", + 50 + ], + [ + "A", + 53 + ], + [ + "A", + 57 + ], + [ + "A", + 59 + ], + [ + "B", + 0 + ], + [ + "A", + 46 + ], + [ + "A", + 48 + ], + [ + "A", + 52 + ], + [ + "A", + 55 + ], + [ + "A", + 58 + ], + [ + "B", + 3 + ], + [ + "A", + 8 + ], + [ + "A", + 41 + ], + [ + "A", + 42 + ], + [ + "A", + 44 + ], + [ + "A", + 51 + ], + [ + "A", + 56 + ], + [ + "B", + 6 + ] + ] +} diff --git a/research/seven-source-18event-connector/README.md b/research/seven-source-18event-connector/README.md new file mode 100644 index 0000000000..6b2c03959d --- /dev/null +++ b/research/seven-source-18event-connector/README.md @@ -0,0 +1,231 @@ +# A 144-call connector for every seven-source mask of weight at most three + +**Finite construction with an all-dimension linear identity; no new κ.** +The following closed source word supports all 63 nonzero seven-bit masks of +Hamming weight one, two or three: + +```text +0 1 2 3 1 0 4 2 0 5 1 4 1 6 5 0 3 6 +``` + +Its 18 source calls and 126 output calls give **144 complete calls**. This +attains the lower boundary left open by Cinna Davis's +[PR #2236](https://github.com/CrocSwap/integer-mult-bounds/pull/2236), following +[PR #2229](https://github.com/CrocSwap/integer-mult-bounds/pull/2229). +Their smaller-path exclusions are credited, not claimed as new. The full +predecessor checker was rerun successfully at its pinned head during this +contribution; the short new replay checks the attaining construction. + +The independent per-output stars use 434 complete calls for this same full +batch. The new schedule saves 290 source calls, while keeping every output +call paid. No selected-supplier caller, physical runtime gain or multiplication +exponent change is established. + +## Exact interface and literal certificate + +Use the [fixed connector contract](../universal-connector-boundary/README.md): +seven distinct immutable source rows `x_j`, 63 distinct target rows `y_m`, and +one connector `z`, all arbitrarily dirty over F2. For each nonzero mask `m` +of weight at most three, the required update is + +```text +y_m += A_m(sum_{j: m_j=1} B_j x_j), with every x_j and z preserved. +``` + +The maps `B_j` and `A_m` are arbitrary fixed compatible F2-linear maps. They +need not commute or be invertible. The only root operations are complete +additive calls `B_j: z += B_j x_j` and `A_m: y_m += A_m z`. Each call preserves +all other data rows, restores its private scratch, returns its heads, and is +independent of old target contents. Data rows and `z` cannot be child scratch. +Targets are observed only after the batch. There are no combined queries, +extra root connectors, free frame changes, copies or overwrites. + +[CERTIFICATE.json](CERTIFICATE.json) contains the word, all 63 boundary pairs, +and the full 144-event chronological stream. Source bit `j` has value `2^j`. +Target identifiers `0..62` refer to masks in increasing numerical order. +A boundary counts completed source calls; boundary zero precedes the word. +The prefix parities are + +```text +0 1 3 7 15 13 12 28 24 25 57 59 43 41 105 73 72 64 0 +``` + +Every required mask is the XOR of two listed prefixes. For example, mask 44 +has a pair in the certificate even though it is missing from #2236's best +16-event word. The exact pairs are verified both by prefix XOR and by direct +XOR of the intervening singleton source events. + +## Why the construction works for arbitrary maps and dirty inputs + +Let `q_t` be the parity after the first `t` source calls. Induction gives + +```text +z_t = z_initial + sum_j q_t[j] B_j x_j. +``` + +For the pair `(s,t)` assigned to mask `m`, linearity and characteristic two +give + +```text +A_m z_s + A_m z_t = A_m(sum_j (q_s[j]+q_t[j]) B_j x_j) + = A_m(sum_{j: m_j=1} B_j x_j). +``` + +Thus connector dirt cancels from the increment; the target's original dirty +value is retained. Calls for different targets commute because they change +distinct targets and leave `z` unchanged. Every source count is even: +`(4,4,2,2,2,2,2)`. Therefore the connector is restored. This proves the +identity at every compatible vector dimension. Finite matrix checks below +are controls, not a replacement for this argument. + +The statement does not extend to nonlinear readouts or ordinary positive +addition in odd characteristic. The test file supplies counterexamples to +both extensions. Specialized maps or inputs may permit cheaper schedules; +the optimality statement concerns one schedule valid for arbitrary maps. + +## Why this reaches the unit-call minimum + +The parity argument from #943 forces every active source map and every +required target map to occur a positive even number of times. Hence the first +possible total is `14+126=140`. Cinna Davis's #2229 census proves that a +14-source-call path supports at most 56 of the 63 masks by paired readouts. +The #2236 census proves that a 16-source-call path supports at most 60. + +At 142 calls there are only two splits: `16+126`, excluded by the 60-mask +bound, and `14+128`. In the second split, only one target can receive four +readouts; at least six of the seven masks missing a pair remain unsupported. +The same argument excludes 140, and odd totals cannot restore arbitrary dirt. +Our 144-call upper witness therefore meets their lower bound in this exact +alphabet. It is not a minimum over other alphabets, extra connectors or +arbitrary weighted prices. + +The unmodified #2236 checker at head +`be03870d764e7875ea9a9f6cc69933c9b1a2456a` was run with Python 3.12.3 and `-I -O -B`. +It completed 135,135 old paths (maximum 56), 18,918,900 new paths (maximum 60, +eight maximizers), and its four controls. The exact predecessor hashes are in +[SOURCES.json](SOURCES.json). This is a replay of their implementation, not a +new independent implementation of the lower census. Its existing command is +`python3 -I -O -B research/seven-source-16event-connector-seeda7de5e/verify.py` +on that pinned PR head. It is not imported by the new package. + +## Complete invoice in the declared interface + +Each source belongs to `1+6+15=22` requested masks. Separate closed stars +therefore use 44 calls to every `B_j` and two to every `A_m`. + +| Charge | Shared word | Separate stars | +|---|---:|---:| +| Complete source calls | 18 | 308 | +| Complete output calls | 126 | 126 | +| Total complete calls / root dispatches | 144 | 434 | +| Root descriptor bits | 954 | 2114 | + +A descriptor uses one opcode bit plus a three-bit source or six-bit target +identifier. Event order supplies chronology, so no runtime boundary-search +oracle is used. The mask family and target numbering are fixed, and common +operator metadata is admitted in both programs. The certificate's JSON byte +size is not this binary instruction-storage bill. + +Let `c(B_j)` and `c(A_m)` be complete fixed-port call prices, `lambda>=0` the +cost per stored descriptor bit, `delta>=0` the root-dispatch price, `I` common +admission and `P` common one-time coefficient preparation. Then + +```text +C_shared = I+P + 4(c(B0)+c(B1)) + 2 sum_{j=2..6} c(Bj) + + 2 sum_m c(Am) + 954 lambda + 144 delta. +C_stars = I+P + 44 sum_j c(Bj) + 2 sum_m c(Am) + + 2114 lambda + 434 delta. +C_shared-C_stars = -40(c(B0)+c(B1)) -42 sum_{j=2..6} c(Bj) + -1160 lambda -290 delta. +``` + +Each complete price includes source/coefficient access, arithmetic, target +updates, private-scratch restoration, hosting, required frames and head return. +No root copy or frame operation is added. A physical caller requiring other +conversions must pay those separately before using this comparison. The new +schedule is componentwise cheaper than these stars under the stated common +admission/complete-call premises. This is not a global weighted optimum. + +For a concrete composed-map fixture, source factor lengths are `(1,2,3,4,1,2,3)` +and target factor length is its mask weight. A balanced dirty echo compiles +each product into primitive additive calls, with +`ell(1)=1`, `ell(d)=2ell(floor(d/2))+2ell(ceil(d/2))`. +The shared and star programs use **984 and 2906 primitive leaf calls**, +respectively. Two private dirty rows suffice in this fixture, in addition to +the root connector; all 70 source/target rows stay reserved. The verifier checks +every one of the 144 child return boundaries, not just final scratch cleanup. +This fixture does not provide an implementation of a selected supplier. + +## Replay and evidence + +Python 3.12 standard library; default replay is read-only and requires no Git +or network. The metadata wrapper additionally checks historical Git provenance. + +```sh +python3 -I -O -B research/seven-source-18event-connector/verify.py +python3 -I -O -B research/seven-source-18event-connector/test_verify.py +python3 scripts/research_package.py --package research/seven-source-18event-connector +``` + +Expected primary marker: + +```text +PASS_SEVEN_SOURCE_18EVENT masks=63 source_calls=18 target_calls=126 total=144 controls=10 +``` + +The checker compares the entire [RESULT.json](RESULT.json). It verifies the +literal root stream over free noncommuting operator words, the fully expanded +leaf stream, their inverses, the independent-star baseline, and all 73 arbitrary +input rows. A separate dense GF2 interpreter checks 438 forward and 438 inverse +basis cases in dimensions 1, 2, 3, including dirty private rows. + +Ten in-package controls reject omitted source restoration, omitted readout, +wrong source/target maps, reversed noncommuting factors, omitted primitive +cleanup, invalid boundary, missing mask, wrong chronology and scratch alias. +The six tests also check all 36 cyclic/reversal variants, nonuniform invoices, +the two scope counterexamples, strict JSON types, Git-free relocation, and +four on-disk failure cases (receipt, certificate, source, occupied output). +`--out NEW.json` regenerates a receipt only at an unoccupied path. + +Discovery used a bounded heuristic search with random seed 2236. It found a +full cover after 89,042 candidate swaps; cyclic rotation, reversal and source +renaming give the displayed word. Heuristic completeness is neither needed +nor claimed: the explicit witness and exact replay establish the upper bound. +The other 18-event multiplicity profile remains unresolved here. + +## Open next questions + +1. **Does `(6,2,2,2,2,2,2)` also attain all 63 masks?** A witness could improve + weighted cost when one source is particularly cheap. Start with a bounded + search on that exact profile, then an exact certificate or a complete census + if practical. The blocker is full coverage; the present two-four-use witness + does not answer it. No weighted optimality follows from the unit-call result. +2. **Which concrete caller has this 63-mask demand and complete-call contract?** + Pin one caller's source/target ports, inspect observation cuts and scratch + exclusions, then compare fully charged physical words. The blocker is an + actual interface binding; no selected supplier is known to instantiate it. + +## Scope, source pins and credit + +The claim is in [Discussion #2221](https://github.com/CrocSwap/integer-mult-bounds/discussions/2221#discussioncomment-18942820), taking its released handoff. +Task `connector-alphabet-change` has explicitly **changed** scope: the original +alphabet is retained, and the contribution is attainment of its first open +seven-source sparse-batch call boundary. This is a side result for the recursive +interface, not completion of the catalogue's changed-operation construction +gate. Base main is `0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2`, priority revision 4. +No selected word, frontier, predecessor package or shared tool is changed. + +Credit Cinna Davis (#2229/#2236) for the seven-source weight123 question, both +smaller-path exclusions, complete-call pricing and the explicit 144-call handoff; +Ross Richardson (#934/#943) and the retained dirty-commutator lineage for the +connector contract, prefix criterion and recursive echo. PR2282's 127-mask, +multiple-root minimum and PR2146's six-source TRIO question are distinct. +The new work supplies the 18-event attaining word, its readout assignment, +expanded executable check and complete invoice. + +Prepared for commdata2338 (@commdata2338), with substantial OpenAI Codex assistance. +Codex performed discovery, proof, implementation, checking and writing. Evidence +is author-checked; no independent human review or proof-assistant verification +is claimed. New work is Apache-2.0. The retained lineage includes @shhxera/@CubeJerry (#889) and Chafik Boukhalfa (#628); their attribution is preserved. +Native supplier integration, global moment/owner pricing, precision/tape/all-size +admission, selected cold replay and a full multiplication theorem are not checked. diff --git a/research/seven-source-18event-connector/RESULT.json b/research/seven-source-18event-connector/RESULT.json new file mode 100644 index 0000000000..8dcf92e4d9 --- /dev/null +++ b/research/seven-source-18event-connector/RESULT.json @@ -0,0 +1,82 @@ +{ + "certificate_sha256": "51e067cc3466021a2d83c431485fcfd36427f79090050b5e589c6d0d87733649", + "completed_child_boundaries_checked": 144, + "dense_forward_basis_cases": 438, + "dense_inverse_basis_cases": 438, + "expanded_program_sha256": "dd15e87d46fb583a2b2044a947854ab606e37e513c9a9fa8be234a2410f48448", + "failure_controls": [ + "omitted_source_restoration", + "omitted_readout_dirty_root", + "wrong_target_and_operator", + "wrong_source_map", + "reversed_noncommuting_factors", + "omitted_primitive_cleanup", + "invalid_boundary_pair", + "missing_target_mask", + "wrong_chronological_event", + "scratch_alias" + ], + "fixture_private_dirty_rows": 2, + "formal_rows_checked": 73, + "independent_interval_checks": 63, + "independent_stars_invoice": { + "complete_calls": 434, + "primitive_leaf_calls_fixture": 2906, + "root_descriptor_bits": 2114, + "source_calls": 308, + "source_calls_by_map": [ + 44, + 44, + 44, + 44, + 44, + 44, + 44 + ], + "target_calls": 126 + }, + "interface_source_pins": 2, + "prefix_pair_checks": 63, + "program_sha256": "9364fce82fa288d111ffc89e882ce88a05d10c03656ad1e1e9dc9dda93ff4d5a", + "root_descriptor_bit_savings": 1160, + "root_dispatch_savings": 290, + "schema": "seven-source-18event-result/1", + "scope": "Constructive upper bound in fixed linear F2 model; lower144 credited to PR2236, not re-enumerated; no supplier or kappa.", + "shared_invoice": { + "complete_calls": 144, + "primitive_leaf_calls_fixture": 984, + "root_descriptor_bits": 954, + "source_calls": 18, + "source_calls_by_map": [ + 4, + 4, + 2, + 2, + 2, + 2, + 2 + ], + "target_calls": 126 + }, + "source_call_savings_by_map": [ + 40, + 40, + 42, + 42, + 42, + 42, + 42 + ], + "source_events": 18, + "source_multiplicities": [ + 4, + 4, + 2, + 2, + 2, + 2, + 2 + ], + "status": "PASS_SEVEN_SOURCE_18EVENT", + "target_masks": 63 +} diff --git a/research/seven-source-18event-connector/SOURCES.json b/research/seven-source-18event-connector/SOURCES.json new file mode 100644 index 0000000000..0abdef64f9 --- /dev/null +++ b/research/seven-source-18event-connector/SOURCES.json @@ -0,0 +1,68 @@ +{ + "schema_version": 1, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "e8870e5917057d59b730eb14721a778639eca050", + "sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7" + }, + { + "path": "research/universal-connector-boundary/CERTIFICATE.json", + "usage": "input", + "git_blob": "079e3e1441dc07c2f0536e9527acf290e51ea9c0", + "sha256": "e733746ba3e5151c829b4e8728bfff5ae3ed24d8d203eb77c735d20758e8266a" + }, + { + "path": "research/universal-connector-boundary/README.md", + "usage": "input", + "git_blob": "d277f7c5830b1f2bc42e1ff41ab86e7d7564929f", + "sha256": "23415f7829ab8d80a783142f10f7d31abbce84579362769984680af3df954476" + } + ], + "predecessor_replay": { + "pr": 2236, + "head": "be03870d764e7875ea9a9f6cc69933c9b1a2456a", + "package": "research/seven-source-16event-connector-seeda7de5e", + "command": "python3 -I -O -B research/seven-source-16event-connector-seeda7de5e/verify.py", + "python": "3.12.3", + "status": "PASS_SEVEN_SOURCE_16EVENT_BOUND", + "old_domain": 135135, + "old_max": 56, + "new_domain": 18918900, + "new_max": 60, + "full_hits": 0, + "max_words": 8, + "controls": 4, + "note": "Unmodified predecessor implementation rerun separately; not imported or required by the new upper-witness replay. Credit Cinna Davis.", + "files": [ + { + "path": "research/seven-source-16event-connector-seeda7de5e/verify.py", + "git_blob": "608452342912b0235c43ba0ee54918e07a251335", + "sha256": "deff2dfea1896b2bd2ca2bd9de8a215b0eb582b08cc90e0525180c4e922c15ea" + }, + { + "path": "research/seven-source-16event-connector-seeda7de5e/RESULT.json", + "git_blob": "e813d7d478b6257a41f32ef664556d7b6f1017c3", + "sha256": "119b20ce4f2fb8945aa45829313ed40d10e33d7c42f342ccf67a4ea4d7b50833" + }, + { + "path": "research/seven-source-16event-connector-seeda7de5e/PREDECESSOR.json", + "git_blob": "3109a7cd7d7ec7bfe32f9a7f365f7544eac48e90", + "sha256": "f624f914169ee2b04439882cec692b59389bc544d163fc379d4913a434e59eac" + }, + { + "path": "research/seven-source-16event-connector-seeda7de5e/TASK.json", + "git_blob": "b82a6ffaca0324bdf46d0886c99f70bf88570441", + "sha256": "ad904f83c4bcd199115e6537b0dc80e8bdad56d30ce8e020d2d4bbf2d054f714" + } + ] + } +} diff --git a/research/seven-source-18event-connector/TASK.json b/research/seven-source-18event-connector/TASK.json new file mode 100644 index 0000000000..2863bf6283 --- /dev/null +++ b/research/seven-source-18event-connector/TASK.json @@ -0,0 +1,120 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 4, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "original_card": { + "id": "connector-alphabet-change", + "question": "Does one explicit extension of the connector alphabet offer a favorable completed budget?", + "starting_points": [ + "research/universal-connector-boundary/README.md", + "certificates/selected-result.json" + ], + "methods": [ + "Construct and charge a legal extra operation on a minimal instance.", + "Prove a target-specific bound after adding one specified operation family." + ], + "acceptance_gate": "State which fixed-alphabet premise changes and charge its implementation; do not declare it free.", + "first_step": { + "command": [ + "python3", + "-B", + "research/universal-connector-boundary/verify.py" + ], + "expected": "PASS_UNIVERSAL_CONNECTOR_BOUNDARY", + "inspect": "Reproduce the 945-pairing control, then read Exact interface to list the allowed calls.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Add exactly one legally priced operation and test a tiny dirty-input instance before enumerating larger cases.", + "bottleneck_link": "A new legal connector operation could change recursive interface cost; a larger census in the same alphabet is a separate side result.", + "allowed_variations": [ + "Choose one additional operation and a small source count for its first counterexample." + ], + "scope_change_triggers": [ + "Keeping the alphabet and only increasing the source count; record this as a changed assignment." + ], + "overlap_terms": [ + "universal connector", + "source-toggle", + "connector alphabet" + ] + }, + "scope_status": "changed", + "actual_scope": "Attain the first open 144-complete-call boundary for the 63 seven-source masks of weights 1, 2 and 3, in the unchanged one-root F2 connector alphabet.", + "scope_change_reason": "Take Cinna Davis PR2236 released explicit 18-event handoff in Discussion2221. This keeps the operation alphabet and is a declared side result, not the original changed-alphabet acceptance gate.", + "bottleneck_link": "A concrete sparse multi-output caller may reuse these fully charged complete maps; no selected supplier binding is established.", + "budget_minutes": 60, + "stop_rule": "Stop after one full 18-event witness and exact boundary/cost validation; a 25-minute search miss would be only a bounded handoff.", + "outcome": "completed", + "evidence": "CERTIFICATE.json supplies all 63 readout pairs and 144 events. RESULT.json records free noncommutative root/leaf replay, 144 completed child boundaries, 438 forward and 438 inverse dense basis cases, ten rejecting controls and exact invoices. The pinned PR2236 lower checker was separately rerun completely.", + "author": "commdata2338", + "ai_assistance": "Substantial OpenAI Codex assistance in discovery, derivation, implementation, checking and writing. No subagents or independent human review.", + "open_questions": [ + { + "question": "Does the 18-event profile (6,2,2,2,2,2,2) cover all 63 masks?", + "why_it_matters": "It may reduce weighted source-call cost when one source is much cheaper.", + "first_step": "Search that exact even-count profile and certify a witness or a complete finite census.", + "blocked_by": "The present (4,4,2,2,2,2,2) witness supplies no conclusion for that profile." + }, + { + "question": "Which concrete caller realizes this 63-mask contract?", + "why_it_matters": "Only a source-bound caller with fully paid complete maps can turn the call saving into a supplier improvement.", + "first_step": "Pin source/target ports, observation cuts and scratch exclusions, then price the entire inserted word.", + "blocked_by": "No selected supplier instance or physical embedding is supplied." + } + ], + "scope_key": "9ba764a68e96fac776b5", + "selection": { + "mode": "live unclaimed handoff override", + "discussion": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2221", + "priority_revision": 4 + }, + "predecessors": [ + { + "pr": 2236, + "head": "be03870d764e7875ea9a9f6cc69933c9b1a2456a", + "author": "Cinna Davis", + "role": "16-event exclusion, 144-call lower bound and attaining-path handoff" + }, + { + "pr": 2229, + "head": "b4eab83755969d406edba9f25b7890e4db4c4931", + "author": "Cinna Davis", + "role": "14-event exclusion for the seven-source sparse masks" + } + ], + "method": "Bounded heuristic discovery followed by exact prefix and interval parity certificates, formal noncommuting word replay and separate concrete matrix execution; no heuristic exclusion claim.", + "optimistic_full_budget": "18 B calls + 126 A calls + 954 root descriptor bits + 144 dispatches; common admission/preparation and complete-call obligations explicit. Baseline: 308 B + 126 A + 2114 bits + 434 dispatches.", + "unrun_obligations": [ + "No feasibility/exclusion of the (6,2,2,2,2,2,2) profile", + "No global weighted optimum", + "No selected caller or physical supplier", + "No native/hosting/precision/tape/all-size/outer admission", + "No selected cold replay, hosted CI, independent human or proof-assistant review" + ], + "freshness": { + "checked_at_utc": "2026-10-15T07:03:12Z", + "canonical_main": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "priority_revision": 4, + "changes_since_base": "none", + "decision": "Continue: guidance, selected record and relevant inputs unchanged." + }, + "overlap": { + "mode": "offline shared snapshot; complete pagination; no novelty guarantee", + "open_prs_fetched_at": "2026-10-15T06:55:23.240869+00:00", + "open_prs_records": 583, + "discussions_fetched_at": "2026-10-15T06:57:32.010338+00:00", + "discussion_records": 1111, + "queries": [ + "--task connector-alphabet-change", + "--all-terms seven-source 144" + ], + "canonical_claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2221#discussioncomment-18942820", + "nearest": [ + "PR2229 and PR2236: smaller-path exclusions and this explicit attainment handoff", + "PR2282: all127 masks with multiple roots, different contract", + "PR2146: six-source TRIO alphabet, different object" + ], + "result": "Matching new claim is this investigation; no matching competing 18-event full-mask construction in searched snapshot." + } +} diff --git a/research/seven-source-18event-connector/VERIFY.json b/research/seven-source-18event-connector/VERIFY.json new file mode 100644 index 0000000000..6612567c64 --- /dev/null +++ b/research/seven-source-18event-connector/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/universal-connector-boundary/CERTIFICATE.json", + "research/universal-connector-boundary/README.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Exact source pins, full 63-mask certificate, noncommutative root/leaf boundary and inverses, 144 child returns, dense basis cases, invoices, ten controls and full receipt." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 60, + "checks": "Six mathematical/integrity tests: dihedral starts, weighted invoice, scope counterexamples, strict types, Git-free relocation and four on-disk failures." + } + ] +} diff --git a/research/seven-source-18event-connector/test_verify.py b/research/seven-source-18event-connector/test_verify.py new file mode 100644 index 0000000000..200bd3e225 --- /dev/null +++ b/research/seven-source-18event-connector/test_verify.py @@ -0,0 +1,99 @@ +"""Mathematical scope and independent on-disk failure controls. Apache-2.0.""" +import importlib.util +from itertools import combinations +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest + +HERE = Path(__file__).resolve().parent +spec = importlib.util.spec_from_file_location("connector18", HERE / "verify.py") +v = importlib.util.module_from_spec(spec) +spec.loader.exec_module(v) + + +class ConnectorTests(unittest.TestCase): + def test_all_cyclic_starts_and_reversal(self): + word = v.read(HERE / "CERTIFICATE.json")["source_word"] + for direction in (word, word[::-1]): + for shift in range(18): + path = direction[shift:] + direction[:shift] + points = [0] + for j in path: + points.append(points[-1] ^ (1 << j)) + differences = {a ^ b for a, b in combinations(points, 2)} + self.assertTrue(set(v.MASKS) <= differences) + self.assertEqual(points[-1], 0) + + def test_weighted_complete_invoice(self): + certificate = v.read(HERE / "CERTIFICATE.json") + _, events = v.validate(certificate) + shared, stars = v.invoice(events), v.invoice(v.baseline()) + prices = [2, 3, 5, 7, 11, 13, 17] + actual = sum((x-y)*p for x, y, p in zip(shared["source_calls_by_map"], stars["source_calls_by_map"], prices)) + actual += 3*(shared["root_descriptor_bits"]-stars["root_descriptor_bits"]) + actual += 5*(shared["complete_calls"]-stars["complete_calls"]) + self.assertEqual(actual, -40*sum(prices[:2])-42*sum(prices[2:])-1160*3-290*5) + self.assertTrue(all(sum(m >> j & 1 for m in v.MASKS) == 22 for j in range(7))) + + def test_nonlinear_readout_is_outside_scope(self): + # f(a,b)=ab is not linear: a pair no longer evaluates the XOR difference. + f = lambda x: ((x >> 1) & 1) & (x & 1) + self.assertNotEqual(f(1) ^ f(2), f(1 ^ 2)) + + def test_odd_characteristic_is_outside_scope(self): + # In characteristic3, two equal positive readouts do not cancel dirt. + dirt, increment = 1, 1 + self.assertNotEqual((dirt + dirt + increment) % 3, increment) + + def test_strict_certificate_types(self): + c = v.read(HERE / "CERTIFICATE.json") + c["events"][0][1] = bool(c["events"][0][1]) + with self.assertRaises(ValueError): + v.validate(c) + with self.assertRaises(ValueError): + json.loads('{"x":1,"x":1}', object_pairs_hook=v.unique_object) + + def test_git_free_relocation_and_corruptions(self): + with tempfile.TemporaryDirectory(prefix="replay-control-", dir=HERE) as folder: + root = Path(folder) + package = root / "research" / HERE.name + package.mkdir(parents=True) + for name in ["verify.py", "CERTIFICATE.json", "RESULT.json", "SOURCES.json"]: + shutil.copy2(HERE / name, package / name) + for item in v.read(HERE / "SOURCES.json")["files"]: + if item["usage"] == "input": + target = root / item["path"] + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copy2(v.ROOT / item["path"], target) + + def command(*extra): + return subprocess.run([sys.executable, "-I", "-O", "-B", str(package / "verify.py"), *extra], + capture_output=True, text=True, timeout=30) + + self.assertEqual(command().returncode, 0) + receipt = package / "RESULT.json" + original = receipt.read_bytes() + bad = json.loads(original) + bad["shared_invoice"]["complete_calls"] = 142 + receipt.write_text(json.dumps(bad)) + self.assertNotEqual(command().returncode, 0) + receipt.write_bytes(original) + certificate = package / "CERTIFICATE.json" + original = certificate.read_bytes() + bad = json.loads(original) + bad["readout_pairs"]["1"] = [0, 0] + certificate.write_text(json.dumps(bad)) + self.assertNotEqual(command().returncode, 0) + certificate.write_bytes(original) + self.assertNotEqual(command("--out", str(receipt)).returncode, 0) + source = root / "research/universal-connector-boundary/README.md" + source.write_bytes(source.read_bytes() + b"\nchanged source\n") + self.assertNotEqual(command().returncode, 0) + + +if __name__ == "__main__": + unittest.main() diff --git a/research/seven-source-18event-connector/verify.py b/research/seven-source-18event-connector/verify.py new file mode 100644 index 0000000000..baaf2699c3 --- /dev/null +++ b/research/seven-source-18event-connector/verify.py @@ -0,0 +1,348 @@ +#!/usr/bin/env python3 +"""Exact 144-call connector certificate. Python standard library only. + +Prepared for commdata2338 with substantial OpenAI Codex assistance. +Apache-2.0. Interface: Ross Richardson's PR943. Seven-source question and +smaller-path lower bounds: Cinna Davis's PR2229/2236. No checker imports. +""" +import argparse +from collections import Counter +from functools import lru_cache +import hashlib +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +MASKS = tuple(m for m in range(1, 128) if 1 <= m.bit_count() <= 3) +SOURCE_LENGTHS = (1, 2, 3, 4, 1, 2, 3) +TARGET_LENGTHS = tuple(m.bit_count() for m in MASKS) + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def unique_object(pairs): + result = {} + for key, value in pairs: + require(key not in result, "duplicate JSON key") + result[key] = value + return result + + +def read(path): + return json.loads(Path(path).read_bytes(), object_pairs_hook=unique_object) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def check_sources(): + count = 0 + for item in read(HERE / "SOURCES.json")["files"]: + if item["usage"] == "input": + payload = (ROOT / item["path"]).read_bytes() + require(hashlib.sha256(payload).hexdigest() == item["sha256"], + "source hash mismatch: " + item["path"]) + count += 1 + require(count == 2, "two interface source pins required") + return count + + +def validate(certificate): + require(set(certificate) == {"schema", "source_word", "prefix_states", + "target_masks", "readout_pairs", "events"}, "certificate fields") + require(certificate["schema"] == "seven-source-18event-connector/1", "schema") + word = certificate["source_word"] + require(len(word) == 18 and all(type(j) is int and 0 <= j < 7 for j in word), + "18 singleton source calls") + counts = [word.count(j) for j in range(7)] + require(counts == [4, 4, 2, 2, 2, 2, 2], "source multiplicities") + prefix = [0] + for j in word: + prefix.append(prefix[-1] ^ (1 << j)) + require(prefix[-1] == 0, "connector restoration") + require(certificate["prefix_states"] == prefix and + all(type(x) is int for x in certificate["prefix_states"]), "prefix states") + require(certificate["target_masks"] == list(MASKS) and + all(type(m) is int for m in certificate["target_masks"]), "complete target family") + pairs = certificate["readout_pairs"] + require(set(pairs) == {str(m) for m in MASKS}, "readout coverage") + for m in MASKS: + pair = pairs[str(m)] + require(isinstance(pair, list) and len(pair) == 2 and + all(type(x) is int for x in pair), "readout pair type") + s, t = pair + require(0 <= s < t <= len(word), "readout boundary range") + require(prefix[s] ^ prefix[t] == m, "prefix-difference identity") + interval_mask = 0 + for j in word[s:t]: + interval_mask ^= 1 << j + require(interval_mask == m, "independent interval-XOR identity") + events = [] + for boundary in range(19): + for index, m in enumerate(MASKS): + if boundary in pairs[str(m)]: + events.append(["A", index]) + if boundary < 18: + events.append(["B", word[boundary]]) + require(all(isinstance(e, list) and len(e) == 2 and type(e[0]) is str and + type(e[1]) is int for e in certificate["events"]), "event types") + require(certificate["events"] == events, "literal chronological program") + require(len(events) == 144, "144 complete calls") + return counts, events + + +def initial_rows(): + names = ["X" + str(j) for j in range(7)] + ["Y" + str(i) for i in range(63)] + names += ["Z", "W0", "W1"] + # (input_name, word) means word applied to the arbitrary initial row. + # Words are outermost-first and noncommuting. Set XOR is addition in F2. + return {name: {(name, ())} for name in names} + + +def apply_word(expression, word): + return {(source, tuple(word) + old) for source, old in expression} + + +def map_word(kind, index, expanded): + if not expanded: + return (kind + str(index),) + length = SOURCE_LENGTHS[index] if kind == "B" else TARGET_LENGTHS[index] + return tuple(kind + str(index) + "." + str(k) for k in reversed(range(length))) + + +def expected_rows(expanded=False): + result = initial_rows() + for i, mask in enumerate(MASKS): + for j in range(7): + if mask >> j & 1: + term = ("X" + str(j), map_word("A", i, expanded) + map_word("B", j, expanded)) + result["Y" + str(i)].symmetric_difference_update({term}) + return result + + +def replay_root(events, state=None): + state = initial_rows() if state is None else {k: set(v) for k, v in state.items()} + for kind, index in events: + require(kind in ("A", "B") and type(index) is int and + 0 <= index < (7 if kind == "B" else 63), "root call type") + source, target = ("X" + str(index), "Z") if kind == "B" else ("Z", "Y" + str(index)) + state[target].symmetric_difference_update(apply_word(state[source], map_word(kind, index, False))) + return state + + +def compile_product(factors, source, target, level=0): + """Application-order factors; every product uses a dirty four-call echo.""" + require(source != target, "source/target alias") + if len(factors) == 1: + return [(factors[0], source, target)] + require(level < 2, "scratch depth") + work = "W" + str(level) + require(work not in (source, target), "scratch aliases active row") + middle = len(factors) // 2 + first = compile_product(factors[:middle], source, work, level + 1) + second = compile_product(factors[middle:], work, target, level + 1) + return first + second + first[::-1] + second[::-1] + + +def expand(events, reverse_factors=False): + program = [] + for kind, index in events: + factors = list(reversed(map_word(kind, index, True))) + if reverse_factors: + factors.reverse() + source, target = ("X" + str(index), "Z") if kind == "B" else ("Z", "Y" + str(index)) + program.extend(compile_product(factors, source, target)) + return program + + +def replay_leaves(program, state=None): + state = initial_rows() if state is None else {k: set(v) for k, v in state.items()} + for operator, source, target in program: + require(source != target, "aliased leaf call") + state[target].symmetric_difference_update(apply_word(state[source], (operator,))) + return state + + +def check_completed_boundaries(events): + """Check every returned child, so dirty scratch cannot leak between calls.""" + literal = initial_rows() + specified = initial_rows() + for event in events: + kind, index = event + literal = replay_leaves(expand([event]), literal) + source, target = ("X" + str(index), "Z") if kind == "B" else ("Z", "Y" + str(index)) + specified[target].symmetric_difference_update(apply_word(specified[source], map_word(kind, index, True))) + require(literal == specified, "completed child boundary or private dirt") + return len(events) + + +def baseline(): + result = [] + for i, m in enumerate(MASKS): + sources = [["B", j] for j in range(7) if m >> j & 1] + result.extend(sources + [["A", i]] + sources[::-1] + [["A", i]]) + return result + + +@lru_cache(maxsize=None) +def leaf_cost(n): + return 1 if n == 1 else 2 * (leaf_cost(n // 2) + leaf_cost(n - n // 2)) + + +def invoice(events): + counts = Counter(tuple(e) for e in events) + b = [counts["B", j] for j in range(7)] + a = [counts["A", i] for i in range(63)] + return {"source_calls_by_map": b, "source_calls": sum(b), + "target_calls": sum(a), "complete_calls": sum(a) + sum(b), + "root_descriptor_bits": 4 * sum(b) + 7 * sum(a), + "primitive_leaf_calls_fixture": sum(b[j] * leaf_cost(n) for j, n in enumerate(SOURCE_LENGTHS)) + + sum(a[i] * leaf_cost(n) for i, n in enumerate(TARGET_LENGTHS))} + + +def concrete_checks(program): + """Separate dense interpretation on all basis inputs, dimensions1..3.""" + labels = sorted({op for op, _, _ in program}) + names = list(initial_rows()) + forward_cases = inverse_cases = 0 + for dimension in (1, 2, 3): + mask = (1 << dimension) - 1 + matrices = {} + for label in labels: + digest = hashlib.sha256(label.encode()).digest() + matrices[label] = [digest[k] & mask for k in range(dimension)] + + def matvec(label, value): + return sum(((row & value).bit_count() % 2) << k for k, row in enumerate(matrices[label])) + + def evaluate_word(word, value): + for label in reversed(word): + value = matvec(label, value) + return value + + for name in names: + for bit in range(dimension): + state = {row: 0 for row in names} + state[name] = 1 << bit + original = dict(state) + for op, source, target in program: + state[target] ^= matvec(op, state[source]) + expected = dict(original) + for i, m in enumerate(MASKS): + value = 0 + for j in range(7): + if m >> j & 1: + value ^= evaluate_word(map_word("B", j, True), original["X" + str(j)]) + expected["Y" + str(i)] ^= evaluate_word(map_word("A", i, True), value) + require(state == expected, "dense matrix forward boundary") + forward_cases += 1 + for op, source, target in reversed(program): + state[target] ^= matvec(op, state[source]) + require(state == original, "dense matrix inverse boundary") + inverse_cases += 1 + return forward_cases, inverse_cases + + +def failure_controls(certificate, events, leaves): + controls = [] + + def wrong_program(name, mutant, expanded=False): + actual = replay_leaves(mutant) if expanded else replay_root(mutant) + require(actual != expected_rows(expanded), "mutation escaped: " + name) + controls.append(name) + + last_b = max(i for i, e in enumerate(events) if e[0] == "B") + wrong_program("omitted_source_restoration", events[:last_b] + events[last_b + 1:]) + first_a = next(i for i, e in enumerate(events) if e[0] == "A") + wrong_program("omitted_readout_dirty_root", events[:first_a] + events[first_a + 1:]) + changed = [e[:] for e in events] + changed[first_a] = ["A", (changed[first_a][1] + 1) % 63] + wrong_program("wrong_target_and_operator", changed) + changed = [e[:] for e in events] + changed[last_b] = ["B", (changed[last_b][1] + 1) % 7] + wrong_program("wrong_source_map", changed) + wrong_program("reversed_noncommuting_factors", expand(events, reverse_factors=True), True) + wrong_program("omitted_primitive_cleanup", leaves[:-1], True) + for name, change in [ + ("invalid_boundary_pair", lambda c: c["readout_pairs"]["1"].__setitem__(1, 0)), + ("missing_target_mask", lambda c: c["target_masks"].pop()), + ("wrong_chronological_event", lambda c: c["events"].reverse()), + ]: + altered = json.loads(json.dumps(certificate)) + change(altered) + try: + validate(altered) + except ValueError: + controls.append(name) + else: + raise ValueError("mutation escaped: " + name) + try: + compile_product(["f", "g"], "W0", "Z") + except ValueError: + controls.append("scratch_alias") + else: + raise ValueError("scratch alias escaped") + return controls + + +def run(certificate=None): + pins = check_sources() + certificate = read(HERE / "CERTIFICATE.json") if certificate is None else certificate + counts, events = validate(certificate) + original = initial_rows() + result = replay_root(events) + require(result == expected_rows(), "free noncommutative root boundary") + require(replay_root(events[::-1], result) == original, "root inverse") + stars = baseline() + require(replay_root(stars) == result, "independent-star boundary") + leaves = expand(events) + expanded = replay_leaves(leaves) + require(expanded == expected_rows(True), "expanded arbitrary-dirty boundary") + require(replay_leaves(leaves[::-1], expanded) == original, "expanded inverse") + require(replay_leaves(expand(stars)) == expanded, "expanded independent-star boundary") + child_boundaries = check_completed_boundaries(events) + actual, reference = invoice(events), invoice(stars) + require(len(leaves) == actual["primitive_leaf_calls_fixture"], "literal leaf invoice") + require(actual["complete_calls"] == 144 and reference["complete_calls"] == 434, + "complete call invoice") + forward, inverse = concrete_checks(leaves) + controls = failure_controls(certificate, events, leaves) + return {"schema": "seven-source-18event-result/1", "status": "PASS_SEVEN_SOURCE_18EVENT", + "target_masks": len(MASKS), "source_events": len(certificate["source_word"]), + "source_multiplicities": counts, + "prefix_pair_checks": len(MASKS), "independent_interval_checks": len(MASKS), + "formal_rows_checked": len(original), "fixture_private_dirty_rows": 2, + "completed_child_boundaries_checked": child_boundaries, + "dense_forward_basis_cases": forward, "dense_inverse_basis_cases": inverse, + "shared_invoice": actual, "independent_stars_invoice": reference, + "source_call_savings_by_map": [44 - x for x in counts], + "root_dispatch_savings": 290, "root_descriptor_bit_savings": 1160, + "failure_controls": controls, "interface_source_pins": pins, + "certificate_sha256": hashlib.sha256((HERE / "CERTIFICATE.json").read_bytes()).hexdigest(), + "program_sha256": hashlib.sha256(canonical(events)).hexdigest(), + "expanded_program_sha256": hashlib.sha256(canonical(leaves)).hexdigest(), + "scope": "Constructive upper bound in fixed linear F2 model; lower144 credited to PR2236, not re-enumerated; no supplier or kappa."} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--out", type=Path, help="write receipt exclusively to a new path") + args = parser.parse_args() + require(args.out is None or not args.out.exists(), "output exists") + result = run() + if args.out is None: + require(canonical(result) == canonical(read(HERE / "RESULT.json")), "receipt mismatch") + else: + with args.out.open("x", encoding="utf-8") as stream: + json.dump(result, stream, indent=2, sort_keys=True) + stream.write("\n") + print(result["status"], "masks=63 source_calls=18 target_calls=126 total=144 controls=10") + + +if __name__ == "__main__": + main()