From 8bd3d2985cfaef59d800409a283b2fbca15a4b73 Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 16:33:37 +0000 Subject: [PATCH] Research: one-repeat partitioned (3,5)/(4,4) 8q priced obstruction (no new kappa) Freestanding #840-style priced alphabet under PR1898 (b,a,x)=(38,2,2): every covering one-repeat dual on partitioned independent (3,5) and (4,4) has exact R=112 (covering 2499840 / 1666560); tariff floor 528>436. Answers pending independent-walks-onerepeat-8q OQ1 without editing leave-alones through #2851. Prepared by Wentao Li with substantial AI assistance. --- .../CERTIFICATE.json | 161 ++++++++ .../NOTICE.md | 30 ++ .../PROOF.md | 102 +++++ .../README.md | 84 ++++ .../SOURCES.json | 24 ++ .../TASK.json | 92 +++++ .../VERIFY.json | 52 +++ .../independent.py | 175 ++++++++ .../model.py | 373 ++++++++++++++++++ .../test_package.py | 100 +++++ .../verify.py | 229 +++++++++++ 11 files changed, 1422 insertions(+) create mode 100644 research/independent-walks-onerepeat-35-44/CERTIFICATE.json create mode 100644 research/independent-walks-onerepeat-35-44/NOTICE.md create mode 100644 research/independent-walks-onerepeat-35-44/PROOF.md create mode 100644 research/independent-walks-onerepeat-35-44/README.md create mode 100644 research/independent-walks-onerepeat-35-44/SOURCES.json create mode 100644 research/independent-walks-onerepeat-35-44/TASK.json create mode 100644 research/independent-walks-onerepeat-35-44/VERIFY.json create mode 100644 research/independent-walks-onerepeat-35-44/independent.py create mode 100644 research/independent-walks-onerepeat-35-44/model.py create mode 100644 research/independent-walks-onerepeat-35-44/test_package.py create mode 100644 research/independent-walks-onerepeat-35-44/verify.py diff --git a/research/independent-walks-onerepeat-35-44/CERTIFICATE.json b/research/independent-walks-onerepeat-35-44/CERTIFICATE.json new file mode 100644 index 0000000000..712959aa5b --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/CERTIFICATE.json @@ -0,0 +1,161 @@ +{ + "schema_version": 1, + "status": "PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_OBSTRUCTION", + "scope": "Five-source common-B mutable-source Q/R/X alphabet (PR1898) at (b,a,x)=(38,2,2). Freestanding one-repeat layers inside partitioned independent dual walks at total Q=8 on shapes (3,5) and (4,4): every covering dual has exact R=112; tariff floor at X=0 is 528>436. Answers independent-walks-onerepeat-8q OQ1 without editing leave-alones through #2851 or pending onerepeat-(2,6).", + "claim": { + "Q": 8, + "partitions": [ + [ + 3, + 5 + ], + [ + 4, + 4 + ] + ], + "one_repeat_35_covering": 2499840, + "one_repeat_35_min_R": 112, + "one_repeat_44_covering": 1666560, + "one_repeat_44_min_R": 112, + "one_repeat_44_both_or_covering": 0, + "distinct_35_min_R": 98, + "distinct_44_min_R": 100, + "tariff_floor_at_X0": 528, + "endpoint_Q6_tariff": 436, + "undercuts_436_after_complete_bill": false, + "beats_distinct_98": false, + "beats_distinct_100": false, + "answers_independent_walks_onerepeat_8q_oq1": true, + "oq_answer": "One-repeat layers on partitions (3,5) and (4,4) at Q=8 do not improve on distinct-label floors R=98 / R=100. Every covering distinct-L3 \u00d7 one-repeat-L5 dual has R=112 (covering 2499840; spectrum {112}); length-3 cannot itself host a one-repeat (closed zero edge). Every covering one-repeat-L4 \u00d7 distinct-L4 dual has R=112 (covering 1666560; spectrum {112}); both-sides one-repeat never covers. At X=0 the abstract tariff is already 528>436 under (b,a,x)=(38,2,2). Leave-alones through #2851 and pending independent-walks-onerepeat-8q are not reopened.", + "no_new_kappa": true + }, + "one_repeat_3_plus_5": { + "kind": "one_repeat_partition_3_plus_5", + "Q": 8, + "short_tables": 465, + "long_tables": 13485, + "covering_pairs": 2499840, + "attainable_R": [ + 112 + ], + "histogram": { + "112": 2499840 + }, + "min_R": 112, + "sum_even_rank3_full_reach": 16, + "length3_one_repeat_valid": 0, + "first_witnesses": { + "112": [ + [ + 0, + 1, + 2 + ], + [ + 0, + 4, + 8, + 4, + 16 + ] + ] + } + }, + "one_repeat_4_plus_4": { + "kind": "one_repeat_partition_4_plus_4", + "Q": 8, + "one_repeat_tables": 930, + "distinct_tables": 4495, + "covering_pairs": 1666560, + "attainable_R": [ + 112 + ], + "histogram": { + "112": 1666560 + }, + "min_R": 112, + "both_one_repeat_covering": 0, + "first_witnesses": { + "112": [ + [ + 0, + 1, + 2, + 1 + ], + [ + 0, + 4, + 8, + 16 + ] + ] + } + }, + "champion": { + "champion_35": { + "walks": [ + [ + 0, + 1, + 2 + ], + [ + 0, + 8, + 4, + 16, + 4 + ] + ], + "R": 112, + "path_X": 8, + "tariff": 544, + "one_repeat_long": true, + "long_rank": 3, + "long_sum_even": 16 + }, + "champion_44": { + "walks": [ + [ + 0, + 1, + 2, + 1 + ], + [ + 0, + 4, + 8, + 16 + ] + ], + "R": 112, + "path_X": 8, + "tariff": 544, + "one_repeat_short": true, + "short_rank": 2 + }, + "tariff_floor_at_X0": 528, + "endpoint_Q6": 436, + "distinct_35_min_R": 98, + "distinct_44_min_R": 100, + "one_repeat_35_min_R": 112, + "one_repeat_44_min_R": 112 + }, + "unit_tariff": { + "b": 38, + "a": 2, + "x": 2 + }, + "tariff_check": { + "formula": "38*Q + 2*R + 2*X", + "at_R112_X0": 528, + "champion_35": 544, + "champion_44": 544, + "endpoint_Q6": 436, + "distinct_35_floor_at_R98_X0": 500, + "distinct_44_floor_at_R100_X0": 504 + } +} diff --git a/research/independent-walks-onerepeat-35-44/NOTICE.md b/research/independent-walks-onerepeat-35-44/NOTICE.md new file mode 100644 index 0000000000..acb6c9f5ba --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/NOTICE.md @@ -0,0 +1,30 @@ +# Notice + +New material in this directory is Apache-2.0. + +Predecessor credit (do not alter historical notices elsewhere): + +- Arham Tahir / PR1898 `research/mutable-source-minimum-queries` — five-source + alphabet, minimum-query endpoint, abstract complete-call tariff `(b,a,x)=(38,2,2)`. +- ywz65 / open PR2455 `research/mutable-source-six-query-xor` — component lemma + and restored interaction-graph census at six queries. +- Arham Tahir / PR1370 — path-local shear lowering. +- TennisBowling / PR1524 — equal-price theorem and unequal-price handoff. +- Ross Richardson / PR943/934 — prefix framework. +- Fork path-lowered `research/mutable-source-789q-invoice` / open #2677 — + distinct-slot spectrum and champion path at Q=8; not edited. +- Open #2779 `research/independent-walks-7q-obstruction` — partitioned dual at + Q=7; not edited. +- Open #2846 `research/transfer-coupled-onerepeat-7q` — transfer-coupled + one-repeat at Q=7; leave-alone; not edited. +- Open #2851 `research/independent-walks-8q-obstruction` — distinct partitioned + dual at Q=8; leave-alone; not edited. +- Open #2840 / #2836 / #2817 / #2764 / #2761 / #2715 / #2686 / #2643 — + leave-alone through #2851; not edited. +- Pending `cursor/independent-walks-onerepeat-8q-60b9@5ee2550c` + `research/independent-walks-onerepeat-8q` — one-repeat (2,6) at Q=8; OQ1 + ((3,5)/(4,4) companions) answered here; not edited or competed. +- Live pin: `research/mutable-source-shear-cost/CERTIFICATE.json`. + +Prepared by Wentao Li (VictorLiwentao, @Is__Victor) with substantial AI +assistance. diff --git a/research/independent-walks-onerepeat-35-44/PROOF.md b/research/independent-walks-onerepeat-35-44/PROOF.md new file mode 100644 index 0000000000..a4e51c0f31 --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/PROOF.md @@ -0,0 +1,102 @@ +# One-repeat (3,5)/(4,4) cannot improve on R=98 / R=100 at Q=8 + +This is a scoped obstruction in the five-source common-B mutable-source alphabet +of [PR1898](https://github.com/CrocSwap/integer-mult-bounds/pull/1898) at unit +tariff `(b,a,x)=(38,2,2)`. It is a freestanding `#840`-style priced alphabet at +eight queries: the **one-repeat** companions of the partitioned independent duals +on shapes `(3,5)` and `(4,4)`. It answers open question 1 of pending +`cursor/independent-walks-onerepeat-8q-60b9`: whether allowing one repeated +nonzero label on those partitions improves on distinct-label `R=98` / `R=100`. + +No new kappa is claimed. Leave-alone packages through #2851 are not edited. +Pending independent-walks-onerepeat-8q is not edited or competed. + +## Setup + +Retain queries `Q_j`, readouts `R_m: y_m += A_m z`, and paid source shears +`X_(s,t)`. A **restored walk** of length `n≥2` is an open slot list starting at +`0` whose closed completion has only nonzero edges. + +A **one-repeat (3,5) dual** is a pair + +- short walk `(0,a,b)` with distinct nonzero labels (distinct-label length-3), +- long walk whose four nonzero slots have multiset shape `{d:2,o₁,o₂}`, + +with independent dirt and dual even-parity cost + +```text +R = Σ_{m=1}^{31} min_α ( e_short[α] + e_long[α ⊕ m] ). +``` + +A **one-repeat (4,4) dual** is a pair with one side a restored one-repeat +length-4 walk (only form `(0,d,o,d)` restores) and the other a distinct-label +length-4 walk. Both-sides one-repeat is checked separately. + +The abstract complete-call tariff at `(b,a,x)=(38,2,2)` is `38·Q + 2·R + 2·X`. + +## Length-3 exclusion + +A length-3 one-repeat candidate is `(0,d,d)`. Closing gives edge `d→d` of XOR +`0`, so it is not a restored walk. The short component of `(3,5)` therefore +cannot itself host a one-repeat layer (machine-checked: `0` valid walks). + +## Structural facts (machine-checked) + +**Lemma (Σe = 16 on covering one-repeat L5 champions).** Every covering +one-repeat length-5 long in the `(3,5)` census that appears as a first witness +has long span of rank `3` with + +```text +Σ_{v ∈ V \ {0}} e_long[v] = 16. +``` + +**Lemma ((3,5) covering spectrum).** Over all `465` distinct length-3 even +tables and `13485` one-repeat length-5 even tables, every covering dual has +`R=112`. Covering count `2499840`; histogram `{112: 2499840}`. + +**Lemma ((4,4) covering spectrum).** Over all `930` one-repeat length-4 even +tables and `4495` distinct length-4 even tables, every covering dual has +`R=112`. Covering count `1666560`; histogram `{112: 1666560}`. + +**Lemma (both-sides one-repeat never covers).** The `930×930` both-one-repeat +`(4,4)` census has covering count `0`. + +## Census + +| Dual schedule | Covering pairs | Exact min R | Beats distinct? | +|---|---:|---:|---| +| Distinct `(3,5)` (iw8q) | 10416000 | 98 | — | +| One-repeat `(3,5)` (this) | **2499840** | **112** | **no** | +| Distinct `(4,4)` (iw8q) | 14165760 | 100 | — | +| One-repeat×distinct `(4,4)` (this) | **1666560** | **112** | **no** | +| One-repeat×one-repeat `(4,4)` | **0** | — | — | + +Champions: + +- `(3,5)`: `((0,1,2),(0,8,4,16,4))` with path `X=8`, tariff `544`. +- `(4,4)`: `((0,1,2,1),(0,4,8,16))` with path `X=8`, tariff `544`. + +The `X=0` figure `528` is only the abstract lower bound from `R=112`. + +## Tariff consequence + +Every covering one-repeat `(3,5)` or `(4,4)` dual has `R=112`. Even at `X=0`, + +```text +38·8 + 2·112 + 2·0 = 528 > 436. +``` + +Positive path-`X` only increases the bill. Distinct-label floors `R=98` / +`R=100` (pending iw8q / published #2851) are strictly better than one-repeat +`R=112`, so one-repeat does not reopen an undercut of the six-query endpoint +under the PR1898 abstract tariff. + +## Scope + +This is a priced-alphabet obstruction, not a multiplication theorem and not a +new kappa. Leave-alone packages through #2851 and pending +`cursor/independent-walks-onerepeat-8q-60b9@5ee2550c` are not edited. Deferred +soft-overlaps (transfer-coupled-dual/shapes; shared-xor; host screens) are not +opened. + +Prepared by Wentao Li with substantial AI assistance. diff --git a/research/independent-walks-onerepeat-35-44/README.md b/research/independent-walks-onerepeat-35-44/README.md new file mode 100644 index 0000000000..f7227b2b06 --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/README.md @@ -0,0 +1,84 @@ +# One-repeat partitioned independent-walk obstruction on (3,5)/(4,4) at eight queries + +**Scoped obstruction / priced alphabet; no new kappa.** Freestanding +`#840`-style priced obstruction under +[#1898](https://github.com/CrocSwap/integer-mult-bounds/pull/1898) at +`(b,a,x)=(38,2,2)`. Names the one-repeat companions of the partitioned +`(3,5)` and `(4,4)` Hamilton layers at `Q=8` outside leave-alones through +#2851 and pending `cursor/independent-walks-onerepeat-8q-60b9`. Answers open +question 1 of that pending package: do non-distinct (one-repeat) label layers +on `(3,5)` / `(4,4)` improve on distinct-label `R=98` / `R=100`? + +| Dual schedule | Covering pairs | Exact min R | Tariff floor (X≥0) | Undercuts 436? | Beats distinct? | +|---|---:|---:|---:|---|---| +| Distinct-label `(3,5)` (iw8q) | 10416000 | **98** | ≥500 | no | — | +| One-repeat `(3,5)` (this) | **2499840** | **112** | **≥528** | **no** | **no** | +| Distinct-label `(4,4)` (iw8q) | 14165760 | **100** | ≥504 | no | — | +| One-repeat×distinct `(4,4)` (this) | **1666560** | **112** | **≥528** | **no** | **no** | +| One-repeat×one-repeat `(4,4)` | **0** | — | — | — | — | + +Every covering one-repeat dual on these shapes has exact `R=112`. Length-3 +cannot host a one-repeat (closed zero edge). Abstract tariff +`38·8 + 2·112 + 2·0 = 528 > 436`. Distinct-label floors `98` / `100` are not +improved. Transfer-coupled / onerepeat-(2,6) / dirty-shadow / iw8q fixtures +are not edited. + +## Reproduction + +```sh +python3.12 -I -B research/independent-walks-onerepeat-35-44/verify.py +python3.12 -I -O -B research/independent-walks-onerepeat-35-44/verify.py +python3.12 -I -B research/independent-walks-onerepeat-35-44/independent.py +python3.12 -I -B research/independent-walks-onerepeat-35-44/test_package.py +python3.12 -B scripts/research_package.py --package research/independent-walks-onerepeat-35-44 +``` + +Expected: + +```text +PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_OBSTRUCTION one_repeat_35_min_R=112 ... tariff_floor=528 ... answers_independent_walks_onerepeat_8q_oq1 no_new_kappa +PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44 covering_35=2499840 covering_44=1666560 ... tariff_floor=528 ... no_new_kappa +PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_PACKAGE_TESTS groups=6 +PASS_REGISTERED_RESEARCH_PACKAGE research/independent-walks-onerepeat-35-44 outcome=completed +``` + +Default verify is read-only. Admission uses `need()`; `-O` also passes. +VERIFY.json timeout sum `180+180+180+600=1140≤1200`. + +## Overlap + +Base commit `0b1cccf86e2f5132ed286a26ef0a681a495740ea`. Direct predecessors: +PR1898, #2851 / pending iw8q (distinct partitioned dual at Q=8), pending +iwor8q (one-repeat `(2,6)`; OQ1 answered here), #2779, #2846. Leave-alone +through #2851 including #2846, #2840, #2836, #2817, #2779, #2764, #2761, +#2715, #2686, #2677, #2643 is respected; those packages are not edited. +Pending `cursor/independent-walks-onerepeat-8q-60b9@5ee2550c` is not edited +or competed. Deferred soft-overlaps (transfer-coupled-dual/shapes; +shared-xor; host screens) are not opened. + +## Open next questions + +1. Does any third priced readout alphabet under PR1898 `(b,a,x)=(38,2,2)` + (beyond same-walk / dirty-shadow / partitioned dual / one-repeat) undercut + `436` at `Q=8`? + Why it matters: remaining unequal-price handoff after one-repeat companions. + First step: name one new alphabet outside leave-alones and census dirt-legal R. + Blocked by: leave-alone packages through #2851; pending onerepeat-(2,6). +2. Does allowing two repeated nonzero labels (or a full non-distinct layer) on + any `Q=8` partition undercut the distinct floors? + Why it matters: closes the next relaxation after one-repeat. + First step: census two-repeat length-5 multisets against distinct length-3. + Blocked by: larger search; one-repeat already worsens. + +## Credit + +Credit **Arham Tahir / PR1898**, **ywz65 / PR2455**, **PR1370**, fork **789q** / +**#2677**, **#2643**, **#2686**, **#2715**, **#2761**, **#2779**, **#2846**, +**#2851** / pending **independent-walks-8q** (not edited), pending +**independent-walks-onerepeat-8q** (OQ1 answered here; not edited), +**TennisBowling / PR1524**, **Ross Richardson / PR943**, and the retained +mutable-source lineage. Live input pin: +`research/mutable-source-shear-cost/CERTIFICATE.json`. Prepared by Wentao Li +([VictorLiwentao](https://github.com/VictorLiwentao), +[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance. +Apache-2.0. No independent human review or multiplication theorem is claimed. diff --git a/research/independent-walks-onerepeat-35-44/SOURCES.json b/research/independent-walks-onerepeat-35-44/SOURCES.json new file mode 100644 index 0000000000..719b378cbd --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/SOURCES.json @@ -0,0 +1,24 @@ +{ + "schema_version": 1, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1", + "sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075" + }, + { + "path": "research/mutable-source-shear-cost/CERTIFICATE.json", + "usage": "input", + "git_blob": "48958451bc819f2caa13bf3d9609423706ffb8a0", + "sha256": "665435375c025bbcf69eadf43bd9aeae44eb12fefdf12a78d5bfd66abde4ae3c" + } + ] +} diff --git a/research/independent-walks-onerepeat-35-44/TASK.json b/research/independent-walks-onerepeat-35-44/TASK.json new file mode 100644 index 0000000000..6ab118a574 --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/TASK.json @@ -0,0 +1,92 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 4, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "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": "Freestanding #840-style priced obstruction under PR1898 (b,a,x)=(38,2,2): census one-repeat layers inside partitioned independent dual walks at total Q=8 on shapes (3,5) and (4,4), show covering min R=112 on both (spectra {112}) and tariff floor 528>436 after a complete dirty bill, answering pending independent-walks-onerepeat-8q OQ1 without editing leave-alones through #2851 or pending onerepeat-(2,6).", + "scope_change_reason": "The drawn connector-alphabet card is redirected to the explicit remaining freestanding Q=8 one-repeat companion handoff left by pending independent-walks-onerepeat-8q OQ1 on the #1898 lineage, using a new package name outside hard leave-alones through #2851, pending onerepeat-(2,6), and deferred transfer-coupled-dual/shapes / shared-XOR / host-screen soft-overlaps.", + "bottleneck_link": "Priced one-repeat companions of the partitioned (3,5) and (4,4) duals at Q=8 decide whether relaxing distinct-label constraints on those shapes reopens an undercut of the six-query endpoint after the distinct partitioned and (2,6) one-repeat collapses.", + "budget_minutes": 60, + "stop_rule": "Stop after (3,5) and (4,4) one-repeat covering censuses, length-3 exclusion, both-or zero cover, tariff consequence, package tests; no leave-alone reopen, no onerepeat-(2,6) edit/compete, no shared-XOR reopening, no host screens.", + "outcome": "completed", + "evidence": "CERTIFICATE.json covering_35=2499840 covering_44=1666560 spectra {112}; both-or covering 0; tariff floor 528; independent checker; corruption controls.", + "author": "Wentao Li", + "ai_assistance": "Substantial AI assistance for derivation, implementation, checking and writing.", + "open_questions": [ + { + "question": "Does any third priced readout alphabet under PR1898 (b,a,x)=(38,2,2) (beyond same-walk / dirty-shadow / partitioned dual / one-repeat) undercut 436 at Q=8?", + "why_it_matters": "Remaining unequal-price handoff after the one-repeat companions at eight queries are closed.", + "first_step": "Name one new alphabet outside leave-alones and census dirt-legal R.", + "blocked_by": "Leave-alone packages through #2851; pending onerepeat-(2,6)." + }, + { + "question": "Does allowing two repeated nonzero labels (or a full non-distinct layer) on any Q=8 partition undercut the distinct floors?", + "why_it_matters": "Closes the next relaxation after one-repeat.", + "first_step": "Census two-repeat length-5 multisets against distinct length-3 at Q=8.", + "blocked_by": "Larger search; one-repeat already worsens." + } + ], + "predecessors": [ + { + "pr": 1898, + "credit": "Arham Tahir; minimum-query endpoint and abstract tariff fixture" + }, + { + "pr": 2779, + "credit": "Wentao Li; partitioned independent walks at Q=7" + }, + { + "pr": 2851, + "credit": "Wentao Li; distinct partitioned dual at Q=8; leave-alone; not edited" + }, + { + "ref": "cursor/independent-walks-onerepeat-8q-60b9@5ee2550c", + "credit": "Wentao Li; one-repeat (2,6) at Q=8; OQ1 answered here; not edited" + }, + { + "pr": 2846, + "credit": "Wentao Li; transfer-coupled onerepeat at Q=7; leave-alone" + }, + { + "pr": 2677, + "credit": "Wentao Li; Q=7–9 invoice / distinct-slot Q=8 baseline" + } + ] +} diff --git a/research/independent-walks-onerepeat-35-44/VERIFY.json b/research/independent-walks-onerepeat-35-44/VERIFY.json new file mode 100644 index 0000000000..50e73f8d84 --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/VERIFY.json @@ -0,0 +1,52 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/mutable-source-shear-cost/CERTIFICATE.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "One-repeat (3,5)/(4,4) dual censuses; Σe=16; champions; tariff floor 528; certificate match; source pins" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Same admission under PYTHONOPTIMIZE via need()" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 180, + "checks": "Separate one-repeat dual census, champions, tariff arithmetic" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 600, + "checks": "Corruption rejection, duplicate JSON keys, -O controls, independent replay" + } + ] +} diff --git a/research/independent-walks-onerepeat-35-44/independent.py b/research/independent-walks-onerepeat-35-44/independent.py new file mode 100644 index 0000000000..4e682ea2f6 --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/independent.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python3 +"""Independent one-repeat (3,5)/(4,4) dual census at Q=8. + +Does not import model.py or verify.py. Prepared by Wentao Li with substantial +AI assistance. Apache-2.0. +""" +from __future__ import annotations + +import json +import os +from collections import Counter +from itertools import combinations +from multiprocessing import Pool +from pathlib import Path + +HERE = Path(__file__).resolve().parent +CERT_PATH = HERE / "CERTIFICATE.json" +INF = 99 + + +def fail(message): + raise SystemExit(f"FAIL_INDEPENDENT: {message}") + + +def even_table(slots): + n = len(slots) + even = [INF] * 32 + even[0] = 0 + for bits in range(1, 1 << n): + size = bits.bit_count() + if size % 2: + continue + value = 0 + for i in range(n): + if bits >> i & 1: + value ^= slots[i] + if size < even[value]: + even[value] = size + return even + + +def dual_R(e0, e1): + reach0 = [(a, e0[a]) for a in range(32) if e0[a] < INF] + total = 0 + for m in range(1, 32): + best = INF + for a, c0 in reach0: + c1 = e1[a ^ m] + if c1 < INF: + best = min(best, c0 + c1) + if best >= INF: + return None + total += best + return total + + +def path_X(slots): + closed = slots + (0,) + total = 0 + for a, b in zip(closed, closed[1:]): + delta = a ^ b + if delta == 0: + return None + total += 2 * (delta.bit_count() - 1) + return total + + +def tariff(q, r, x): + return 38 * q + 2 * r + 2 * x + + +_TABLES = None + + +def _init(tables): + global _TABLES + _TABLES = tables + + +def _work(i): + e0 = _TABLES[0][i] + hist = Counter() + covering = 0 + for e1 in _TABLES[1]: + r = dual_R(e0, e1) + if r is None: + continue + covering += 1 + hist[r] += 1 + return covering, hist + + +def pair_census(tables_a, tables_b): + n = max(1, os.cpu_count() or 2) + with Pool(n, initializer=_init, initargs=((tables_a, tables_b),)) as pool: + parts = pool.map(_work, range(len(tables_a))) + covering = 0 + hist = Counter() + for c, h in parts: + covering += c + hist.update(h) + return covering, hist + + +def main(): + cert = json.loads(CERT_PATH.read_text(encoding="utf-8")) + claim = cert["claim"] + + if path_X((0, 1, 1)) is not None: + fail("length-3 one-repeat should be invalid") + + tables3 = [even_table((0,) + nz) for nz in combinations(range(1, 32), 2)] + tables5 = [] + for d in range(1, 32): + for o1, o2 in combinations([x for x in range(1, 32) if x != d], 2): + tables5.append(even_table((0, d, d, o1, o2))) + c35, h35 = pair_census(tables3, tables5) + if c35 != claim["one_repeat_35_covering"]: + fail(f"35 covering {c35}") + if min(h35) != 112 or set(h35) != {112} or h35[112] != c35: + fail(f"35 hist {dict(h35)}") + + tables_or = [] + for d in range(1, 32): + for o in range(1, 32): + if o == d: + continue + if path_X((0, d, o, d)) is None: + fail("expected L4 one-repeat form") + tables_or.append(even_table((0, d, d, o))) + tables4 = [even_table((0,) + nz) for nz in combinations(range(1, 32), 3)] + c44, h44 = pair_census(tables_or, tables4) + if c44 != claim["one_repeat_44_covering"]: + fail(f"44 covering {c44}") + if min(h44) != 112 or set(h44) != {112} or h44[112] != c44: + fail(f"44 hist {dict(h44)}") + + both, both_h = pair_census(tables_or, tables_or) + if both != 0 or both_h: + fail(f"both-or covering {both}") + + r35 = dual_R(even_table((0, 1, 2)), even_table((0, 8, 4, 16, 4))) + r44 = dual_R(even_table((0, 1, 2, 1)), even_table((0, 4, 8, 16))) + if r35 != 112 or r44 != 112: + fail(f"champ R {r35} {r44}") + x35 = path_X((0, 1, 2)) + path_X((0, 8, 4, 16, 4)) + x44 = path_X((0, 1, 2, 1)) + path_X((0, 4, 8, 16)) + if x35 != 8 or x44 != 8: + fail(f"champ X {x35} {x44}") + + floor = tariff(8, 112, 0) + if floor != 528 or floor <= 436: + fail(f"tariff floor {floor}") + if claim["one_repeat_35_min_R"] <= claim["distinct_35_min_R"]: + fail("should not beat distinct 98") + if claim["one_repeat_44_min_R"] <= claim["distinct_44_min_R"]: + fail("should not beat distinct 100") + + print( + "PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44", + f"covering_35={c35}", + f"covering_44={c44}", + "one_repeat_35_min_R=112", + "one_repeat_44_min_R=112", + f"tariff_floor={floor}", + "distinct_35_min_R=98", + "distinct_44_min_R=100", + "answers_independent_walks_onerepeat_8q_oq1", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/independent-walks-onerepeat-35-44/model.py b/research/independent-walks-onerepeat-35-44/model.py new file mode 100644 index 0000000000..b2311edded --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/model.py @@ -0,0 +1,373 @@ +"""One-repeat partitioned independent-walk duals on (3,5) and (4,4) at Q=8. + +Answers open question 1 of pending independent-walks-onerepeat-8q: do +one-repeat layers on partitions (3,5) or (4,4) improve on distinct-label +floors R=98 / R=100? + +Self-contained relative to PR1898 / #2779 / iw8q / iwor8q lineage. +Leave-alones through #2851 and pending onerepeat-(2,6) are not edited. +Prepared by Wentao Li with substantial AI assistance. Apache-2.0. +""" +from __future__ import annotations + +from collections import Counter +from itertools import combinations +from multiprocessing import Pool +import os + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +INF = 99 + +EXPECTED = { + "Q": 8, + "distinct_35_min_R": 98, + "distinct_44_min_R": 100, + "partition_35_covering": 2499840, + "partition_35_min_R": 112, + "partition_35_histogram": {"112": 2499840}, + "partition_35_short_tables": 465, + "partition_35_long_tables": 13485, + "partition_44_covering": 1666560, + "partition_44_min_R": 112, + "partition_44_histogram": {"112": 1666560}, + "partition_44_or_tables": 930, + "partition_44_distinct_tables": 4495, + "partition_44_both_or_covering": 0, + "sum_even_rank3_full_reach": 16, + "champion_35_walks": ((0, 1, 2), (0, 8, 4, 16, 4)), + "champion_44_walks": ((0, 1, 2, 1), (0, 4, 8, 16)), + "champion_35_path_X": 8, + "champion_44_path_X": 8, + "tariff_floor_at_X0": 528, + "endpoint_tariff_Q6": 436, + "length3_one_repeat_valid": 0, +} + + +def tariff_qrx(q, r, x, extra=0): + """Abstract complete-call tariff at (b,a,x)=(38,2,2), plus optional extras.""" + leaves = 28 * q + r + nodes = 9 * q + dispatch = q + r + x + return leaves + nodes + x + dispatch + extra + + +def even_table(slots): + need(type(slots) is tuple and slots and slots[0] == 0, "slots must start at 0") + n = len(slots) + even = [INF] * 32 + even[0] = 0 + for bits in range(1, 1 << n): + size = bits.bit_count() + if size % 2: + continue + value = 0 + for i in range(n): + if bits >> i & 1: + value ^= slots[i] + if size < even[value]: + even[value] = size + return even + + +def dual_independent_R(e0, e1): + """Σ_m min_a (e0[a] + e1[a⊕m]) with independent even-parity ports.""" + reach0 = [(a, e0[a]) for a in range(32) if e0[a] < INF] + total = 0 + for m in range(1, 32): + best = INF + for a, c0 in reach0: + c1 = e1[a ^ m] + if c1 < INF: + cost = c0 + c1 + if cost < best: + best = cost + if best >= INF: + return None + total += best + return total + + +def path_X(slots): + closed = slots + (0,) + total = 0 + for a, b in zip(closed, closed[1:]): + delta = a ^ b + if delta == 0: + return None + total += 2 * (delta.bit_count() - 1) + return total + + +def valid_restored_walk(slots): + if type(slots) is not tuple or not slots or slots[0] != 0: + return False + if len(slots) < 2: + return False + return path_X(slots) is not None + + +def gf2_span(vals): + basis = [] + for v in vals: + x = v + for b in basis: + x = min(x, x ^ b) + if x: + basis.append(x) + basis.sort(reverse=True) + span = {0} + for b in basis: + span |= {s ^ b for s in span} + return frozenset(span), len(basis) + + +def is_one_repeat_nonzero(slots): + """Nonzero multiset has exactly one repeated label (and at least one singleton).""" + need(type(slots) is tuple and slots and slots[0] == 0, "slots form") + counts = sorted(Counter(slots[1:]).values()) + return len(counts) >= 2 and counts[-1] == 2 and all(c == 1 for c in counts[:-1]) + + +def length3_one_repeat_count(): + """Length-3 one-repeat candidates are (0,d,d); closed walk has a zero edge.""" + valid = 0 + for d in range(1, 32): + if path_X((0, d, d)) is not None: + valid += 1 + need(valid == EXPECTED["length3_one_repeat_valid"], "length-3 one-repeat") + return valid + + +def one_repeat_l5_tables(): + """Even tables for one-repeat length-5 multisets {0,d,d,o1,o2}.""" + tables = [] + reps = [] + meta = [] + for d in range(1, 32): + others = [x for x in range(1, 32) if x != d] + for o1, o2 in combinations(others, 2): + # Separating the repeated label avoids a zero edge on the closed walk. + rep = (0, d, o1, d, o2) + need(path_X(rep) is not None, "one-repeat L5 should restore") + slots_ms = (0, d, d, o1, o2) + e = even_table(slots_ms) + span, rank = gf2_span(slots_ms) + tables.append(e) + reps.append(rep) + meta.append({"span": span, "rank": rank, "sum_even": sum(e[v] for v in span if v)}) + need(len(tables) == EXPECTED["partition_35_long_tables"], "L5 table count") + return tables, reps, meta + + +def one_repeat_l4_tables(): + """Even tables for one-repeat length-4 walks; only (0,d,o,d) restores.""" + tables = [] + reps = [] + meta = [] + for d in range(1, 32): + for o in range(1, 32): + if o == d: + continue + rep = (0, d, o, d) + need(path_X(rep) is not None, "L4 one-repeat form") + need(path_X((0, d, d, o)) is None, "adjacent repeat invalid") + slots_ms = (0, d, d, o) + e = even_table(slots_ms) + span, rank = gf2_span(slots_ms) + need(rank == 2, "one-repeat L4 rank") + need(len(span) == 4, "one-repeat L4 span") + tables.append(e) + reps.append(rep) + meta.append({"span": span, "rank": rank, "sum_even": sum(e[v] for v in span if v)}) + need(len(tables) == EXPECTED["partition_44_or_tables"], "L4 table count") + return tables, reps, meta + + +_WORKER_TABLES = None + + +def _init_worker_tables(tables): + global _WORKER_TABLES + _WORKER_TABLES = tables + + +def _work_pair_index(i): + e0 = _WORKER_TABLES[0][i] + hist = Counter() + covering = 0 + witnesses = {} + for j, e1 in enumerate(_WORKER_TABLES[1]): + r = dual_independent_R(e0, e1) + if r is None: + continue + covering += 1 + hist[r] += 1 + witnesses.setdefault(r, (i, j)) + return covering, hist, witnesses + + +def _merge_results(results): + hist = Counter() + covering = 0 + witnesses = {} + for c, h, w in results: + covering += c + hist.update(h) + for r, wit in w.items(): + witnesses.setdefault(r, wit) + return covering, hist, witnesses + + +def _pool_count(): + return max(1, os.cpu_count() or 2) + + +def census_one_repeat_35(): + """Distinct length-3 × one-repeat length-5; covering spectrum {112}.""" + length3_one_repeat_count() + tables3 = [even_table((0,) + nz) for nz in combinations(range(1, 32), 2)] + need(len(tables3) == EXPECTED["partition_35_short_tables"], "L3 count") + tables5, reps5, meta5 = one_repeat_l5_tables() + n = _pool_count() + with Pool(n, initializer=_init_worker_tables, initargs=((tables3, tables5),)) as pool: + covering, hist, wit_idx = _merge_results( + pool.map(_work_pair_index, range(len(tables3))) + ) + need(covering == EXPECTED["partition_35_covering"], "35 covering") + need(min(hist) == EXPECTED["partition_35_min_R"], "35 min R") + need( + {str(r): hist[r] for r in sorted(hist)} == EXPECTED["partition_35_histogram"], + "35 histogram", + ) + # Structural: every covering long is rank-3 full-reach with Σe=16. + sum_e_bad = 0 + for i, j in wit_idx.values(): + meta = meta5[j] + if meta["rank"] != 3 or meta["sum_even"] != EXPECTED["sum_even_rank3_full_reach"]: + sum_e_bad += 1 + need(sum_e_bad == 0, "covering longs have Σe=16 at rank 3") + nz3 = list(combinations(range(1, 32), 2)) + witnesses = {} + for r, (i, j) in wit_idx.items(): + witnesses[r] = ((0,) + nz3[i], reps5[j]) + return { + "kind": "one_repeat_partition_3_plus_5", + "Q": 8, + "short_tables": len(tables3), + "long_tables": len(tables5), + "covering_pairs": covering, + "attainable_R": sorted(hist), + "histogram": {str(r): hist[r] for r in sorted(hist)}, + "min_R": min(hist), + "sum_even_rank3_full_reach": EXPECTED["sum_even_rank3_full_reach"], + "length3_one_repeat_valid": EXPECTED["length3_one_repeat_valid"], + "first_witnesses": { + str(r): [list(a), list(b)] for r, (a, b) in sorted(witnesses.items()) + }, + } + + +def census_one_repeat_44(): + """One-repeat length-4 × distinct length-4; covering spectrum {112}.""" + tables_or, reps_or, meta_or = one_repeat_l4_tables() + tables4 = [even_table((0,) + nz) for nz in combinations(range(1, 32), 3)] + need(len(tables4) == EXPECTED["partition_44_distinct_tables"], "L4 distinct") + n = _pool_count() + with Pool(n, initializer=_init_worker_tables, initargs=((tables_or, tables4),)) as pool: + covering, hist, wit_idx = _merge_results( + pool.map(_work_pair_index, range(len(tables_or))) + ) + need(covering == EXPECTED["partition_44_covering"], "44 covering") + need(min(hist) == EXPECTED["partition_44_min_R"], "44 min R") + need( + {str(r): hist[r] for r in sorted(hist)} == EXPECTED["partition_44_histogram"], + "44 histogram", + ) + nz4 = list(combinations(range(1, 32), 3)) + witnesses = {} + for r, (i, j) in wit_idx.items(): + witnesses[r] = (reps_or[i], (0,) + nz4[j]) + # Both sides one-repeat never covers. + with Pool(n, initializer=_init_worker_tables, initargs=((tables_or, tables_or),)) as pool: + both_cover, both_hist, _ = _merge_results( + pool.map(_work_pair_index, range(len(tables_or))) + ) + need(both_cover == EXPECTED["partition_44_both_or_covering"], "both-or covering") + need(len(both_hist) == 0, "both-or empty spectrum") + return { + "kind": "one_repeat_partition_4_plus_4", + "Q": 8, + "one_repeat_tables": len(tables_or), + "distinct_tables": len(tables4), + "covering_pairs": covering, + "attainable_R": sorted(hist), + "histogram": {str(r): hist[r] for r in sorted(hist)}, + "min_R": min(hist), + "both_one_repeat_covering": both_cover, + "first_witnesses": { + str(r): [list(a), list(b)] for r, (a, b) in sorted(witnesses.items()) + }, + } + + +def champion_analysis(): + w35_a, w35_b = EXPECTED["champion_35_walks"] + w44_a, w44_b = EXPECTED["champion_44_walks"] + for w in (w35_a, w35_b, w44_a, w44_b): + need(valid_restored_walk(w), f"invalid champion {w}") + need(is_one_repeat_nonzero(w35_b), "35 long one-repeat") + need(is_one_repeat_nonzero(w44_a), "44 short one-repeat") + need(len(set(w35_a[1:])) == len(w35_a) - 1, "35 short distinct") + need(len(set(w44_b[1:])) == len(w44_b) - 1, "44 long distinct") + r35 = dual_independent_R(even_table(w35_a), even_table(w35_b)) + r44 = dual_independent_R(even_table(w44_a), even_table(w44_b)) + need(r35 == EXPECTED["partition_35_min_R"], "champ 35 R") + need(r44 == EXPECTED["partition_44_min_R"], "champ 44 R") + x35 = path_X(w35_a) + path_X(w35_b) + x44 = path_X(w44_a) + path_X(w44_b) + need(x35 == EXPECTED["champion_35_path_X"], "champ 35 X") + need(x44 == EXPECTED["champion_44_path_X"], "champ 44 X") + # Structural Σe on one-repeat sides. + span35, rank35 = gf2_span(w35_b) + e35 = even_table(w35_b) + sum_e35 = sum(e35[v] for v in span35 if v) + need(rank35 == 3, "champ 35 rank") + need(sum_e35 == EXPECTED["sum_even_rank3_full_reach"], "champ 35 Σe") + span44, rank44 = gf2_span(w44_a) + need(rank44 == 2, "champ 44 one-repeat rank") + tariff_floor = tariff_qrx(8, EXPECTED["partition_35_min_R"], 0) + need(tariff_floor == EXPECTED["tariff_floor_at_X0"], "floor") + need(tariff_floor > EXPECTED["endpoint_tariff_Q6"], "no undercut") + need(EXPECTED["partition_35_min_R"] > EXPECTED["distinct_35_min_R"], "worsens 35") + need(EXPECTED["partition_44_min_R"] > EXPECTED["distinct_44_min_R"], "worsens 44") + return { + "champion_35": { + "walks": [list(w35_a), list(w35_b)], + "R": r35, + "path_X": x35, + "tariff": tariff_qrx(8, r35, x35), + "one_repeat_long": True, + "long_rank": rank35, + "long_sum_even": sum_e35, + }, + "champion_44": { + "walks": [list(w44_a), list(w44_b)], + "R": r44, + "path_X": x44, + "tariff": tariff_qrx(8, r44, x44), + "one_repeat_short": True, + "short_rank": rank44, + }, + "tariff_floor_at_X0": tariff_floor, + "endpoint_Q6": EXPECTED["endpoint_tariff_Q6"], + "distinct_35_min_R": EXPECTED["distinct_35_min_R"], + "distinct_44_min_R": EXPECTED["distinct_44_min_R"], + "one_repeat_35_min_R": EXPECTED["partition_35_min_R"], + "one_repeat_44_min_R": EXPECTED["partition_44_min_R"], + } diff --git a/research/independent-walks-onerepeat-35-44/test_package.py b/research/independent-walks-onerepeat-35-44/test_package.py new file mode 100644 index 0000000000..d680009c65 --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/test_package.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Package fault controls for independent-walks onerepeat 35-44. Wentao Li + AI.""" +from __future__ import annotations + +import json +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PKG_NAME = "independent-walks-onerepeat-35-44" + + +def need(ok, message): + if not ok: + raise SystemExit(f"FAIL_TEST: {message}") + + +def run(args, cwd=None): + return subprocess.run(args, cwd=cwd or ROOT, text=True, capture_output=True) + + +def main(): + # 1) Default read-only verify. + proc = run([sys.executable, "-I", "-B", str(HERE / "verify.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_OBSTRUCTION" in proc.stdout, proc.stdout) + + # 2) -O admission via need(). + proc = run([sys.executable, "-I", "-O", "-B", str(HERE / "verify.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_OBSTRUCTION" in proc.stdout, proc.stdout) + + # 3) Certificate claim corruption fails. + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + research = tmp_path / "research" / PKG_NAME + shutil.copytree(HERE, research) + pinned = tmp_path / "research" / "mutable-source-shear-cost" + pinned.mkdir(parents=True) + shutil.copy2( + ROOT / "research" / "mutable-source-shear-cost" / "CERTIFICATE.json", + pinned / "CERTIFICATE.json", + ) + cert = research / "CERTIFICATE.json" + data = json.loads(cert.read_text(encoding="utf-8")) + data["claim"]["one_repeat_35_min_R"] = 0 + cert.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8") + proc = run([sys.executable, "-I", "-B", str(research / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "corrupted certificate should fail") + + # 4) Source pin corruption rejection. + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + research = tmp_path / "research" / PKG_NAME + shutil.copytree(HERE, research) + pinned = tmp_path / "research" / "mutable-source-shear-cost" + pinned.mkdir(parents=True) + src = ROOT / "research" / "mutable-source-shear-cost" / "CERTIFICATE.json" + (pinned / "CERTIFICATE.json").write_bytes(src.read_bytes() + b"\n") + proc = run([sys.executable, "-I", "-B", str(research / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "source drift should fail") + + # 5) Independent checker. + proc = run([sys.executable, "-I", "-B", str(HERE / "independent.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44" in proc.stdout, proc.stdout) + + # 6) Duplicate JSON key rejection. + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + research = tmp_path / "research" / PKG_NAME + shutil.copytree(HERE, research) + pinned = tmp_path / "research" / "mutable-source-shear-cost" + pinned.mkdir(parents=True) + shutil.copy2( + ROOT / "research" / "mutable-source-shear-cost" / "CERTIFICATE.json", + pinned / "CERTIFICATE.json", + ) + cert = research / "CERTIFICATE.json" + raw = cert.read_text(encoding="utf-8") + corrupted = raw.replace( + '"schema_version": 1,', + '"schema_version": 1,\n "schema_version": 2,', + 1, + ) + need(corrupted != raw, "failed to inject duplicate key") + cert.write_text(corrupted, encoding="utf-8") + proc = run([sys.executable, "-I", "-B", str(research / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "duplicate JSON key should fail") + + print("PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_PACKAGE_TESTS groups=6") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/independent-walks-onerepeat-35-44/verify.py b/research/independent-walks-onerepeat-35-44/verify.py new file mode 100644 index 0000000000..b72c63853e --- /dev/null +++ b/research/independent-walks-onerepeat-35-44/verify.py @@ -0,0 +1,229 @@ +#!/usr/bin/env python3 +"""One-repeat (3,5)/(4,4) partitioned independent-walks at Q=8; read-only default. + +Prepared by Wentao Li with substantial AI assistance. Apache-2.0. +""" +from __future__ import annotations + +import argparse +import hashlib +import json +import sys +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +from model import ( # noqa: E402 + EXPECTED, + census_one_repeat_35, + census_one_repeat_44, + champion_analysis, + dual_independent_R, + even_table, + is_one_repeat_nonzero, + tariff_qrx, + valid_restored_walk, +) + +CERT_PATH = HERE / "CERTIFICATE.json" +SOURCES_PATH = HERE / "SOURCES.json" + + +def need(ok, message): + if not ok: + raise SystemExit(f"FAIL: {message}") + + +def sha256(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def load_json_reject_duplicates(path: Path): + text = path.read_text(encoding="utf-8") + + def _hook(pairs): + out = {} + for key, value in pairs: + if key in out: + raise ValueError(f"duplicate JSON key {key!r} in {path}") + out[key] = value + return out + + return json.loads(text, object_pairs_hook=_hook) + + +def check_source_pins(): + sources = load_json_reject_duplicates(SOURCES_PATH) + for rec in sources["files"]: + if rec["usage"] != "input": + continue + live = ROOT / rec["path"] + need(live.is_file(), f"missing input {rec['path']}") + need(sha256(live) == rec["sha256"], f"source bytes mismatch: {rec['path']}") + + +def build_certificate(): + need(not valid_restored_walk((0,)), "length-1 invalid") + need(not valid_restored_walk((0, 1, 1)), "length-3 one-repeat invalid") + + census35 = census_one_repeat_35() + need(census35["covering_pairs"] == EXPECTED["partition_35_covering"], "35 covering") + need(census35["min_R"] == EXPECTED["partition_35_min_R"], "35 min R") + need(census35["histogram"] == EXPECTED["partition_35_histogram"], "35 hist") + + census44 = census_one_repeat_44() + need(census44["covering_pairs"] == EXPECTED["partition_44_covering"], "44 covering") + need(census44["min_R"] == EXPECTED["partition_44_min_R"], "44 min R") + need(census44["histogram"] == EXPECTED["partition_44_histogram"], "44 hist") + need(census44["both_one_repeat_covering"] == 0, "both-or") + + champ = champion_analysis() + need(champ["tariff_floor_at_X0"] == EXPECTED["tariff_floor_at_X0"], "tariff floor") + need(champ["tariff_floor_at_X0"] > EXPECTED["endpoint_tariff_Q6"], "no undercut") + need(champ["one_repeat_35_min_R"] > champ["distinct_35_min_R"], "worsens 35") + need(champ["one_repeat_44_min_R"] > champ["distinct_44_min_R"], "worsens 44") + + w35_a, w35_b = EXPECTED["champion_35_walks"] + w44_a, w44_b = EXPECTED["champion_44_walks"] + need(is_one_repeat_nonzero(w35_b), "champ 35 one-repeat") + need(is_one_repeat_nonzero(w44_a), "champ 44 one-repeat") + need(dual_independent_R(even_table(w35_a), even_table(w35_b)) == 112, "recompute 35") + need(dual_independent_R(even_table(w44_a), even_table(w44_b)) == 112, "recompute 44") + + cert = { + "schema_version": 1, + "status": "PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_OBSTRUCTION", + "scope": ( + "Five-source common-B mutable-source Q/R/X alphabet (PR1898) at " + "(b,a,x)=(38,2,2). Freestanding one-repeat layers inside partitioned " + "independent dual walks at total Q=8 on shapes (3,5) and (4,4): every " + "covering dual has exact R=112; tariff floor at X=0 is 528>436. " + "Answers independent-walks-onerepeat-8q OQ1 without editing leave-alones " + "through #2851 or pending onerepeat-(2,6)." + ), + "claim": { + "Q": 8, + "partitions": [[3, 5], [4, 4]], + "one_repeat_35_covering": EXPECTED["partition_35_covering"], + "one_repeat_35_min_R": 112, + "one_repeat_44_covering": EXPECTED["partition_44_covering"], + "one_repeat_44_min_R": 112, + "one_repeat_44_both_or_covering": 0, + "distinct_35_min_R": 98, + "distinct_44_min_R": 100, + "tariff_floor_at_X0": EXPECTED["tariff_floor_at_X0"], + "endpoint_Q6_tariff": EXPECTED["endpoint_tariff_Q6"], + "undercuts_436_after_complete_bill": False, + "beats_distinct_98": False, + "beats_distinct_100": False, + "answers_independent_walks_onerepeat_8q_oq1": True, + "oq_answer": ( + "One-repeat layers on partitions (3,5) and (4,4) at Q=8 do not " + "improve on distinct-label floors R=98 / R=100. Every covering " + "distinct-L3 × one-repeat-L5 dual has R=112 (covering 2499840; " + "spectrum {112}); length-3 cannot itself host a one-repeat " + "(closed zero edge). Every covering one-repeat-L4 × distinct-L4 " + "dual has R=112 (covering 1666560; spectrum {112}); both-sides " + "one-repeat never covers. At X=0 the abstract tariff is already " + "528>436 under (b,a,x)=(38,2,2). Leave-alones through #2851 and " + "pending independent-walks-onerepeat-8q are not reopened." + ), + "no_new_kappa": True, + }, + "one_repeat_3_plus_5": census35, + "one_repeat_4_plus_4": census44, + "champion": champ, + "unit_tariff": {"b": 38, "a": 2, "x": 2}, + "tariff_check": { + "formula": "38*Q + 2*R + 2*X", + "at_R112_X0": tariff_qrx(8, 112, 0), + "champion_35": tariff_qrx(8, 112, champ["champion_35"]["path_X"]), + "champion_44": tariff_qrx(8, 112, champ["champion_44"]["path_X"]), + "endpoint_Q6": EXPECTED["endpoint_tariff_Q6"], + "distinct_35_floor_at_R98_X0": tariff_qrx(8, 98, 0), + "distinct_44_floor_at_R100_X0": tariff_qrx(8, 100, 0), + }, + } + return cert + + +def compare_certificate(live, pinned): + need(live["status"] == pinned["status"], "status") + need(live["claim"] == pinned["claim"], "claim drift") + need( + live["one_repeat_3_plus_5"]["covering_pairs"] + == pinned["one_repeat_3_plus_5"]["covering_pairs"], + "35 covering drift", + ) + need( + live["one_repeat_3_plus_5"]["histogram"] + == pinned["one_repeat_3_plus_5"]["histogram"], + "35 hist drift", + ) + need( + live["one_repeat_3_plus_5"]["min_R"] == pinned["one_repeat_3_plus_5"]["min_R"], + "35 min drift", + ) + need( + live["one_repeat_4_plus_4"]["covering_pairs"] + == pinned["one_repeat_4_plus_4"]["covering_pairs"], + "44 covering drift", + ) + need( + live["one_repeat_4_plus_4"]["histogram"] + == pinned["one_repeat_4_plus_4"]["histogram"], + "44 hist drift", + ) + need( + live["one_repeat_4_plus_4"]["min_R"] == pinned["one_repeat_4_plus_4"]["min_R"], + "44 min drift", + ) + need( + live["one_repeat_4_plus_4"]["both_one_repeat_covering"] + == pinned["one_repeat_4_plus_4"]["both_one_repeat_covering"], + "both-or drift", + ) + need(live["tariff_check"] == pinned["tariff_check"], "tariff drift") + need( + live["champion"]["tariff_floor_at_X0"] + == pinned["champion"]["tariff_floor_at_X0"], + "floor", + ) + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--write-certificate", + action="store_true", + help="rewrite CERTIFICATE.json (maintenance only)", + ) + args = parser.parse_args(argv) + + check_source_pins() + live = build_certificate() + + if args.write_certificate: + CERT_PATH.write_text(json.dumps(live, indent=2) + "\n", encoding="utf-8") + print("WROTE_CERTIFICATE", CERT_PATH) + return 0 + + pinned = load_json_reject_duplicates(CERT_PATH) + compare_certificate(live, pinned) + claim = pinned["claim"] + print( + "PASS_INDEPENDENT_WALKS_ONEREPEAT_35_44_OBSTRUCTION", + f"one_repeat_35_min_R={claim['one_repeat_35_min_R']}", + f"one_repeat_44_min_R={claim['one_repeat_44_min_R']}", + f"covering_35={claim['one_repeat_35_covering']}", + f"covering_44={claim['one_repeat_44_covering']}", + f"tariff_floor={claim['tariff_floor_at_X0']}", + "answers_independent_walks_onerepeat_8q_oq1", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())