From fc3a2cb3362934b1e34df974e64f9d0acfe07b77 Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 16:33:37 +0000 Subject: [PATCH] Research: shared-dirt partitioned 8q priced obstruction (no new kappa) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Freestanding #840-style alphabet under PR1898 (b,a,x)=(38,2,2): shared-dirt (joint even live-read parity) dual on distinct partitioned walks at Q=8. Exact min R=82 (tariff floor 468>436); undercuts independent floors 92/98/100; soft-overlap-safe vs deferred shared-XOR. Answers next18 / tworepeat OQ1–OQ2. Prepared by Wentao Li with substantial AI assistance. --- .../shared-dirt-walks-8q/CERTIFICATE.json | 333 ++++++++++++ .../shared-dirt-walks-8q/MASTER-HANDOFF.md | 60 +++ research/shared-dirt-walks-8q/NOTICE.md | 36 ++ research/shared-dirt-walks-8q/PROOF.md | 130 +++++ research/shared-dirt-walks-8q/README.md | 87 +++ research/shared-dirt-walks-8q/SOURCES.json | 24 + research/shared-dirt-walks-8q/TASK.json | 108 ++++ research/shared-dirt-walks-8q/VERIFY.json | 52 ++ research/shared-dirt-walks-8q/independent.py | 302 +++++++++++ research/shared-dirt-walks-8q/model.py | 504 ++++++++++++++++++ research/shared-dirt-walks-8q/test_package.py | 100 ++++ research/shared-dirt-walks-8q/verify.py | 257 +++++++++ 12 files changed, 1993 insertions(+) create mode 100644 research/shared-dirt-walks-8q/CERTIFICATE.json create mode 100644 research/shared-dirt-walks-8q/MASTER-HANDOFF.md create mode 100644 research/shared-dirt-walks-8q/NOTICE.md create mode 100644 research/shared-dirt-walks-8q/PROOF.md create mode 100644 research/shared-dirt-walks-8q/README.md create mode 100644 research/shared-dirt-walks-8q/SOURCES.json create mode 100644 research/shared-dirt-walks-8q/TASK.json create mode 100644 research/shared-dirt-walks-8q/VERIFY.json create mode 100755 research/shared-dirt-walks-8q/independent.py create mode 100755 research/shared-dirt-walks-8q/model.py create mode 100755 research/shared-dirt-walks-8q/test_package.py create mode 100755 research/shared-dirt-walks-8q/verify.py diff --git a/research/shared-dirt-walks-8q/CERTIFICATE.json b/research/shared-dirt-walks-8q/CERTIFICATE.json new file mode 100644 index 0000000000..bc4b499016 --- /dev/null +++ b/research/shared-dirt-walks-8q/CERTIFICATE.json @@ -0,0 +1,333 @@ +{ + "schema_version": 1, + "status": "PASS_SHARED_DIRT_WALKS_8Q_OBSTRUCTION", + "scope": "Five-source common-B mutable-source Q/R/X alphabet (PR1898) at (b,a,x)=(38,2,2). Freestanding shared-dirt (single coefficient / joint even live-read parity) dual on distinct partitioned restored walks at total Q=8 on shapes (2,6), (3,5), and (4,4). Exact covering min R=82 (tariff floor 468>436). Undercuts independent-dirt floors 92/98/100 but does not undercut tariff 436. Soft-overlap-safe vs deferred shared-XOR: R-side dirt coupling only. Answers preferred next18 / tworepeat OQ1\u2013OQ2 without editing leave-alones through #2858 / #2851 or pending onerepeat/tworepeat tips.", + "claim": { + "Q": 8, + "partitions": [ + [ + 2, + 6 + ], + [ + 3, + 5 + ], + [ + 4, + 4 + ] + ], + "alphabet": "shared_dirt_partitioned_dual", + "shared_dirt_26_covering": 3916416, + "shared_dirt_26_min_R": 82, + "shared_dirt_26_histogram": { + "82": 583296, + "88": 2916480, + "96": 416640 + }, + "shared_dirt_35_covering": 10416000, + "shared_dirt_35_min_R": 82, + "shared_dirt_35_histogram": { + "82": 1458240, + "88": 7291200, + "96": 1666560 + }, + "shared_dirt_44_covering": 14165760, + "shared_dirt_44_min_R": 82, + "shared_dirt_44_histogram": { + "82": 1944320, + "88": 9721600, + "96": 2499840 + }, + "partition_min_R": 82, + "tariff_floor_at_X0": 468, + "endpoint_Q6_tariff": 436, + "undercuts_436_after_complete_bill": false, + "beats_independent_dirt_floors": true, + "independent_floors": { + "26": 92, + "35": 98, + "44": 100 + }, + "answers_fourth_priced_alphabet_q8": true, + "answers_tworepeat_oq2_shared_dirt": true, + "soft_overlap_shared_xor": "safe_R_side_dirt_coupling_only", + "oq_answer": "The named fourth priced readout alphabet under PR1898 (b,a,x)=(38,2,2) beyond same-walk / dirty-shadow / partitioned dual / one-repeat / two-repeat is the shared-dirt (joint even live-read parity) dual on distinct partitioned walks at Q=8. Exact census: (2,6)/(3,5)/(4,4) covering mins all R=82 (histograms {82,88,96}); tariff floor 38\u00b78+2\u00b782=468>436. Shared dirt undercuts independent-dirt floors 92/98/100 on every covering shape's champion layer, but still cannot undercut the six-query endpoint after a complete dirty bill. Soft-overlap vs deferred shared-XOR is safe: only the R-side dirt coefficient is coupled; path-X / non-path XOR schedules are not shared. Leave-alones through #2858/#2851 and pending onerepeat/tworepeat tips are not reopened.", + "no_new_kappa": true + }, + "shared_dirt_2_plus_6": { + "kind": "shared_dirt_partition_2_plus_6", + "Q": 8, + "covering_pairs": 3916416, + "attainable_R": [ + 82, + 88, + 96 + ], + "histogram": { + "82": 583296, + "88": 2916480, + "96": 416640 + }, + "min_R": 82, + "first_witnesses": { + "82": [ + [ + 0, + 16 + ], + [ + 0, + 1, + 2, + 4, + 8, + 15 + ] + ], + "88": [ + [ + 0, + 16 + ], + [ + 0, + 1, + 2, + 3, + 4, + 8 + ] + ], + "96": [ + [ + 0, + 1 + ], + [ + 0, + 1, + 2, + 4, + 8, + 16 + ] + ] + }, + "champion_short_long_identity": true + }, + "shared_dirt_3_plus_5": { + "kind": "shared_dirt_partition_3_plus_5", + "Q": 8, + "covering_pairs": 10416000, + "attainable_R": [ + 82, + 88, + 96 + ], + "histogram": { + "82": 1458240, + "88": 7291200, + "96": 1666560 + }, + "min_R": 82, + "first_witnesses": { + "82": [ + [ + 0, + 1, + 2 + ], + [ + 0, + 4, + 8, + 15, + 16 + ] + ], + "88": [ + [ + 0, + 1, + 2 + ], + [ + 0, + 3, + 4, + 8, + 16 + ] + ], + "96": [ + [ + 0, + 1, + 2 + ], + [ + 0, + 1, + 4, + 8, + 16 + ] + ] + } + }, + "shared_dirt_4_plus_4": { + "kind": "shared_dirt_partition_4_plus_4", + "Q": 8, + "covering_pairs": 14165760, + "attainable_R": [ + 82, + 88, + 96 + ], + "histogram": { + "82": 1944320, + "88": 9721600, + "96": 2499840 + }, + "min_R": 82, + "first_witnesses": { + "82": [ + [ + 0, + 1, + 2, + 4 + ], + [ + 0, + 8, + 15, + 16 + ] + ], + "88": [ + [ + 0, + 1, + 2, + 3 + ], + [ + 0, + 4, + 8, + 16 + ] + ], + "96": [ + [ + 0, + 1, + 2, + 4 + ], + [ + 0, + 1, + 8, + 16 + ] + ] + }, + "symmetry_checked": true + }, + "length1_invalid": [ + { + "slots": [ + 0 + ], + "valid_restored_walk": false, + "path_X": null, + "note": "closed_(0,0)_zero_edge" + } + ], + "champion": { + "champion_26": { + "walks": [ + [ + 0, + 16 + ], + [ + 0, + 1, + 2, + 4, + 8, + 15 + ] + ], + "R_shared": 82, + "R_independent": 92, + "path_X": 16, + "tariff": 500 + }, + "champion_35": { + "walks": [ + [ + 0, + 1, + 2 + ], + [ + 0, + 4, + 8, + 15, + 16 + ] + ], + "R_shared": 82, + "R_independent": 98, + "path_X": 16, + "tariff": 500 + }, + "champion_44": { + "walks": [ + [ + 0, + 1, + 2, + 4 + ], + [ + 0, + 8, + 15, + 16 + ] + ], + "R_shared": 82, + "R_independent": 100, + "path_X": 16, + "tariff": 500 + }, + "tariff_floor_at_X0": 468, + "endpoint_Q6": 436, + "single_walk_even_min_R_Q8": 74, + "partition_min_R": 82, + "beats_independent_floors": true, + "undercuts_436_after_complete_bill": false, + "soft_overlap_shared_xor": "safe_R_side_dirt_coupling_only" + }, + "unit_tariff": { + "b": 38, + "a": 2, + "x": 2 + }, + "tariff_check": { + "formula": "38*Q + 2*R + 2*X", + "shared_dirt_floor_at_R82_X0": 468, + "independent_26_at_R92_X0": 488, + "one_repeat_at_R112_X0": 528, + "single_walk_at_R74_X0": 452, + "endpoint_Q6": 436 + } +} diff --git a/research/shared-dirt-walks-8q/MASTER-HANDOFF.md b/research/shared-dirt-walks-8q/MASTER-HANDOFF.md new file mode 100644 index 0000000000..de3a361e68 --- /dev/null +++ b/research/shared-dirt-walks-8q/MASTER-HANDOFF.md @@ -0,0 +1,60 @@ +# Master handoff — shared-dirt-walks-8q + +## Deliverable + +| Field | Value | +|---|---| +| Branch | `cursor/shared-dirt-walks-8q-60b9` | +| Tip SHA | branch HEAD (`git rev-parse cursor/shared-dirt-walks-8q-60b9`) | +| Package | `research/shared-dirt-walks-8q/` | +| Claim | Freestanding `#840`-style priced alphabet: **shared-dirt** (joint even live-read parity) partitioned dual at Q=8 under PR1898 `(b,a,x)=(38,2,2)` | +| Result | Exact covering min **R=82** on `(2,6)` / `(3,5)` / `(4,4)`; tariff floor **468>436**; beats independent floors 92/98/100; soft-overlap-safe vs shared-XOR | +| Kappa | none | + +## Answers + +- Preferred next18 / tworepeat OQ1: named fourth alphabet beyond same-walk / + dirty-shadow / partitioned dual / one-repeat / two-repeat. +- tworepeat OQ2: shared-dirt undercuts independent-dirt floors (82 < 92/98/100) + but still cannot undercut tariff 436; soft-overlap vs shared-XOR is safe + (R-side dirt coupling only). + +## Exact census + +| Shape | Covering | Min R | Histogram | +|---|---:|---:|---| +| `(2,6)` | 3916416 | 82 | 82:583296 / 88:2916480 / 96:416640 | +| `(3,5)` | 10416000 | 82 | 82:1458240 / 88:7291200 / 96:1666560 | +| `(4,4)` | 14165760 | 82 | 82:1944320 / 88:9721600 / 96:2499840 | + +Champions: `((0,16),(0,1,2,4,8,15))`, `((0,1,2),(0,4,8,15,16))`, +`((0,1,2,4),(0,8,15,16))` — each shared `R=82`. + +## Leave-alone respected + +Through #2858 / #2851; pending `cursor/independent-walks-onerepeat-8q-60b9@b07bc1e1` +and `cursor/independent-walks-tworepeat-8q-60b9@c4581aaf`; +#2846/#2840/#2836/#2817/#2779/#2764/#2761; deferred soft-overlaps untouched +(shared-XOR not opened). + +## Verify gate + +```sh +python3.12 -I -B research/shared-dirt-walks-8q/verify.py +python3.12 -I -O -B research/shared-dirt-walks-8q/verify.py +python3.12 -I -B research/shared-dirt-walks-8q/independent.py +python3.12 -I -B research/shared-dirt-walks-8q/test_package.py +python3.12 -B scripts/research_package.py --package research/shared-dirt-walks-8q +``` + +## Attribution + +Author: Wentao Li \ +Disclosure: Prepared by Wentao Li with substantial AI assistance. +`TASK.json` `ai_assistance` without product/model names. +Never `Co-authored-by: Victor Li`. + +## Next open + +1. Fifth priced alphabet under PR1898 at Q=8 beyond shared-dirt? +2. Three-walk shared-dirt (e.g. `(2,2,4)`) vs two-walk floor R=82? diff --git a/research/shared-dirt-walks-8q/NOTICE.md b/research/shared-dirt-walks-8q/NOTICE.md new file mode 100644 index 0000000000..5d6530f786 --- /dev/null +++ b/research/shared-dirt-walks-8q/NOTICE.md @@ -0,0 +1,36 @@ +# 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 #2851 `research/independent-walks-8q-obstruction` — distinct partitioned + dual at Q=8; leave-alone; not edited. +- Open #2858 `research/independent-walks-onerepeat-35-44` — one-repeat + (3,5)/(4,4) at Q=8; leave-alone; not edited. +- Open #2846 `research/transfer-coupled-onerepeat-7q` — transfer-coupled + one-repeat at Q=7; leave-alone; not edited. +- Open #2840 / #2836 / #2817 / #2764 / #2761 / #2715 / #2686 / #2643 — + leave-alone through #2858/#2851; not edited. #2643 marks deferred shared-XOR; + this package does not open that soft-overlap (R-side dirt only). +- Pending `cursor/independent-walks-onerepeat-8q-60b9@b07bc1e1` + `research/independent-walks-onerepeat-8q` — one-repeat (2,6) at Q=8; + leave-alone; not edited or competed. +- Pending `cursor/independent-walks-tworepeat-8q-60b9@c4581aaf` + `research/independent-walks-tworepeat-8q` — two-repeat at Q=8; OQ1–OQ2 + 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/shared-dirt-walks-8q/PROOF.md b/research/shared-dirt-walks-8q/PROOF.md new file mode 100644 index 0000000000..6df09217d6 --- /dev/null +++ b/research/shared-dirt-walks-8q/PROOF.md @@ -0,0 +1,130 @@ +# Shared-dirt partitioned duals undercut independent floors but not tariff 436 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 names one freestanding `#840`-style priced +readout alphabet at eight queries beyond same-walk / dirty-shadow / partitioned +dual / one-repeat / two-repeat: the **shared-dirt** (single coefficient / joint +even live-read parity) dual on distinct partitioned restored walks. It answers +preferred next18 and open questions 1–2 of pending +`cursor/independent-walks-tworepeat-8q-60b9`. + +No new kappa is claimed. Leave-alone packages through #2858 / #2851 are not +edited. Pending onerepeat / tworepeat tips are not edited or competed. + +## Soft-overlap vs deferred shared-XOR + +Deferred soft-overlap notes (e.g. #2851 / #2840) reserve **shared non-path XOR +schedules** (X-side) against [#2643](https://github.com/CrocSwap/integer-mult-bounds/pull/2643). +This package couples only the **R-side dirt coefficient**: both walks share one +dirt register so live-read parity is joint. Path-`X` on each restored walk and +all non-path XOR schedules remain the independent / unpaid-as-before baseline. +The shared-XOR soft-overlap is therefore **not opened**. + +## 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 **shared-dirt partitioned dual** of total query count `Q = 8` is a pair of +valid restored walks of lengths `(n_0,n_1)` with `n_0+n_1=8` and `n_0,n_1≥2`, +distinct nonzero labels within each walk, and **one shared dirt coefficient**. +Legal dirty cancellation requires even **total** live-read parity across both +walks. With even/odd subset tables `(e_i,o_i)` on walk `i`, the dual cost is + +```text +R = Σ_{m=1}^{31} min( + min_α (e0[α] + e1[α ⊕ m]), + min_α (o0[α] + o1[α ⊕ m]) + ). +``` + +Independent dirt ([#2851](https://github.com/CrocSwap/integer-mult-bounds/pull/2851)) +admits only the even+even branch, so shared-dirt `R` is always ≤ independent `R` +whenever both cover. + +Up to swap the only partitions are `(2,6)`, `(3,5)`, and `(4,4)`. Length-1 +components are not restored. The abstract complete-call tariff at +`(b,a,x)=(38,2,2)` is `38·Q + 2·R + 2·X`. + +## Fixture A: partition `(2,6)` + +Short walk `(0,σ)` has `e[0]=0`, `e[σ]=2`, `o[0]=1`, `o[σ]=1`. Shared cost +collapses to + +```text +R = Σ_m min( e1[m], 2 + e1[m ⊕ σ], 1 + o1[m], 1 + o1[m ⊕ σ] ). +``` + +**Census.** Distinct-label pairs: covering count `3916416` (same as independent +covering); attainable `R ∈ {82,88,96}` with histogram +`583296 / 2916480 / 416640`. Minimum `R = 82`. + +Champion `((0,16),(0,1,2,4,8,15))` has shared `R = 82` and independent `R = 92`. +Path `X = 16`, tariff `500`. The `X = 0` figure `468` is the abstract lower +bound from `R = 82`. + +## Fixture B: partition `(3,5)` + +**Census.** Covering count `10416000`; attainable `R ∈ {82,88,96}` with +histogram `1458240 / 7291200 / 1666560`. Minimum `R = 82`. + +Champion `((0,1,2),(0,4,8,15,16))` has shared `R = 82`. + +## Fixture C: partition `(4,4)` + +**Lemma (swap symmetry).** `dual_shared(e0,o0,e1,o1) = dual_shared(e1,o1,e0,o0)` +by reindexing `α ↦ α ⊕ m` on each mask. Ordered census uses the upper triangle +and doubles off-diagonal contributions. + +**Census.** Covering count `14165760`; attainable `R ∈ {82,88,96}` with +histogram `1944320 / 9721600 / 2499840`. Minimum `R = 82`. + +Champion `((0,1,2,4),(0,8,15,16))` has shared `R = 82`. + +## Tariff consequence + +Every covering shared-dirt partitioned dual at `Q = 8` has `R ≥ 82`, attained +on all three shapes. Even at `X = 0`, + +```text +38·8 + 2·82 + 2·0 = 468 > 436. +``` + +Positive path-`X` only increases the bill. Shared dirt **undercuts** the +independent-dirt floors (`92` / `98` / `100` on `(2,6)` / `(3,5)` / `(4,4)`) but +still cannot undercut the six-query endpoint under the PR1898 abstract tariff. +By comparison, same-walk even-subset reaches `R ≥ 74` (tariff floor `452` at +`X = 0`); shared-dirt on partitioned walks lands strictly between same-walk and +independent dual. + +| Alphabet | Covering min R | Tariff floor (X=0) | Undercuts 436? | +|---|---:|---:|---| +| Same-walk even-subset (#2677) | ≥74 | ≥452 | no | +| Dirty-shadow (#2840) | ≥74 | ≥452 | no | +| Distinct partitioned (#2851) | 92 | 488 | no | +| One-repeat partitioned (pending) | 112 | 528 | no | +| Two-repeat partitioned (pending) | — (covering 0) | — | no | +| **Shared-dirt partitioned (this)** | **82** | **468** | **no** | + +## Scope limits + +- Fixes the **shared-dirt** partitioned dual interface at total `Q = 8` with + distinct nonzero labels within each walk. Same-walk, dirty-shadow, distinct + partitioned, one-repeat, and two-repeat leave-alones / pending tips are + outside and not edited. +- Transfer-coupled dual/shapes and host screens remain deferred soft-overlaps + and are not opened. +- Shared non-path XOR schedules remain deferred (soft-overlap with #2643); this + package does not share X. +- No new kappa and no multiplication theorem are claimed. + +## Relation to predecessors + +| Prior | Already proves | This package adds | +|---|---|---| +| PR1898 | Min `Q=6`, endpoint tariff 436, `(b,a,x)=(38,2,2)` | — | +| #2851 | Partitioned independent dual at `Q=8` has `R≥92` | — | +| pending tworepeat | Two-repeat covering 0; OQ1–OQ2 | — | +| **This** | — | **Shared-dirt dual at `Q=8` has `R≥82` (all shapes); tariff floor `468>436`; beats independent floors; soft-overlap-safe vs shared-XOR** | diff --git a/research/shared-dirt-walks-8q/README.md b/research/shared-dirt-walks-8q/README.md new file mode 100644 index 0000000000..801e554d9c --- /dev/null +++ b/research/shared-dirt-walks-8q/README.md @@ -0,0 +1,87 @@ +# Shared-dirt partitioned-walk obstruction 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 one new dirt-legal readout alphabet at `Q=8` beyond +same-walk / dirty-shadow / partitioned dual / one-repeat / two-repeat: +**shared-dirt** (single coefficient / joint even live-read parity) duals on +distinct partitioned walks. Answers preferred next18 and open questions 1–2 of +pending `cursor/independent-walks-tworepeat-8q-60b9`. Soft-overlap-safe vs +deferred shared-XOR (R-side dirt coupling only). + +| Dual schedule | Covering pairs | Exact min R | Tariff floor (X≥0) | Undercuts 436? | Beats independent? | +|---|---:|---:|---:|---|---| +| Distinct partitioned (#2851) | — | 92 | ≥488 | no | — | +| One-repeat (pending) | — | 112 | ≥528 | no | — | +| Two-repeat (pending) | 0 | — | — | no | — | +| Shared-dirt `(2,6)` (this) | **3916416** | **82** | **≥468** | **no** | **yes (vs 92)** | +| Shared-dirt `(3,5)` (this) | **10416000** | **82** | **≥468** | **no** | **yes (vs 98)** | +| Shared-dirt `(4,4)` (this) | **14165760** | **82** | **≥468** | **no** | **yes (vs 100)** | + +Global covering minimum is `R=82` on every shape (spectrum `{82,88,96}`). +Abstract tariff `38·8 + 2·82 + 2·0 = 468 > 436`. Shared dirt undercuts +independent-dirt floors but cannot undercut the six-query endpoint. + +## Reproduction + +```sh +python3.12 -I -B research/shared-dirt-walks-8q/verify.py +python3.12 -I -O -B research/shared-dirt-walks-8q/verify.py +python3.12 -I -B research/shared-dirt-walks-8q/independent.py +python3.12 -I -B research/shared-dirt-walks-8q/test_package.py +python3.12 -B scripts/research_package.py --package research/shared-dirt-walks-8q +``` + +Expected: + +```text +PASS_SHARED_DIRT_WALKS_8Q_OBSTRUCTION partition_min_R=82 ... tariff_floor=468 ... answers_fourth_priced_alphabet_q8 soft_overlap_shared_xor_safe no_new_kappa +PASS_SHARED_DIRT_WALKS_8Q covering_26=3916416 covering_35=10416000 covering_44=14165760 partition_min_R=82 tariff_floor=468 ... no_new_kappa +PASS_SHARED_DIRT_WALKS_8Q_PACKAGE_TESTS groups=6 +PASS_REGISTERED_RESEARCH_PACKAGE research/shared-dirt-walks-8q outcome=completed +``` + +Default verify is read-only. Admission uses `need()`; `-O` also passes. + +## Overlap + +Base commit `0b1cccf86e2f5132ed286a26ef0a681a495740ea`. Direct predecessors: +PR1898, #2851 (distinct partitioned dual), pending tworepeat (OQ answered here), +#2858 / onerepeat tips, #2846/#2840/#2779/#2677. Leave-alone through #2858 +including #2851, #2846, #2840, #2836, #2817, #2779, #2764, #2761 is respected; +those packages are not edited. Pending +`cursor/independent-walks-onerepeat-8q-60b9@b07bc1e1` and +`cursor/independent-walks-tworepeat-8q-60b9@c4581aaf` are not edited or +competed. Deferred soft-overlaps (transfer-coupled-dual/shapes; shared-XOR as +X-sharing; host screens) are not opened — shared-dirt is R-side only. + +## Open next questions + +1. Does any fifth priced readout alphabet under PR1898 `(b,a,x)=(38,2,2)` + (beyond same-walk / dirty-shadow / partitioned dual / one-repeat / + two-repeat / shared-dirt) undercut `436` at `Q=8`? + Why it matters: remaining unequal-price handoff after shared-dirt is closed. + First step: name one new alphabet outside leave-alones and census dirt-legal R. + Blocked by: leave-alones through #2858/#2851; pending onerepeat/tworepeat; + deferred transfer-coupled-dual/shapes and host screens. +2. Does a three-walk partitioned shared-dirt schedule (e.g. `(2,2,4)`) undercut + the two-walk shared-dirt floor `R=82`? + Why it matters: extends shared-dirt to three restored components. + First step: fix triple shared-dirt cost and census distinct-label `(2,2,4)`. + Blocked by: larger search; expected not to undercut 436 even if R improves + toward 74. + +## Credit + +Credit **Arham Tahir / PR1898**, **ywz65 / PR2455**, **PR1370**, fork **789q** / +**#2677**, **#2779**, open **#2851** / **#2858** (leave-alone; not edited), +pending tworepeat tip (OQ answered here; not edited), pending onerepeat tip +(leave-alone), open **#2846** / **#2840** / **#2836** / **#2817** / **#2764** / +**#2761** (leave-alone), **#2643** (shared-XOR soft-overlap not opened), +**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/shared-dirt-walks-8q/SOURCES.json b/research/shared-dirt-walks-8q/SOURCES.json new file mode 100644 index 0000000000..719b378cbd --- /dev/null +++ b/research/shared-dirt-walks-8q/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/shared-dirt-walks-8q/TASK.json b/research/shared-dirt-walks-8q/TASK.json new file mode 100644 index 0000000000..e421150955 --- /dev/null +++ b/research/shared-dirt-walks-8q/TASK.json @@ -0,0 +1,108 @@ +{ + "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): name the shared-dirt (joint even live-read parity / single coefficient) dual on distinct partitioned walks at total Q=8 on shapes (2,6)/(3,5)/(4,4), show exact covering min R=82 and tariff floor 468>436 (undercuts independent-dirt floors 92/98/100 but not 436), soft-overlap-safe vs deferred shared-XOR, answering preferred next18 / tworepeat OQ1–OQ2 without editing leave-alones through #2858/#2851 or pending onerepeat/tworepeat tips.", + "scope_change_reason": "The drawn connector-alphabet card is redirected to the explicit remaining freestanding Q=8 fourth-alphabet / shared-dirt companion handoff left by pending independent-walks-tworepeat-8q OQ1–OQ2 on the #1898 lineage, using a new package name outside hard leave-alones through #2858/#2851, pending onerepeat/tworepeat tips, and confirming soft-overlap safety vs deferred shared-XOR (R-side dirt coupling only).", + "bottleneck_link": "A priced shared-dirt companion of the partitioned dual at Q=8 decides whether coupling the dirt coefficient undercuts independent-dirt floors enough to reopen an undercut of the six-query endpoint after the distinct / one-repeat / two-repeat / dirty-shadow collapses.", + "budget_minutes": 60, + "stop_rule": "Stop after (2,6)/(3,5)/(4,4) shared-dirt covering censuses, champion comparisons to independent floors, tariff consequence, soft-overlap note vs shared-XOR, package tests; no leave-alone reopen, no pending onerepeat/tworepeat edit/compete, no shared-XOR reopening, no host screens.", + "outcome": "completed", + "evidence": "CERTIFICATE.json partition_min_R=82 (26/35/44 histograms {82,88,96}); tariff_floor=468>436; beats independent floors 92/98/100; soft_overlap_shared_xor=safe_R_side_dirt_coupling_only; independent checker; corruption controls.", + "author": "Wentao Li", + "ai_assistance": "Substantial AI assistance for derivation, implementation, checking and writing.", + "open_questions": [ + { + "question": "Does any fifth priced readout alphabet under PR1898 (b,a,x)=(38,2,2) (beyond same-walk / dirty-shadow / partitioned dual / one-repeat / two-repeat / shared-dirt) undercut 436 at Q=8?", + "why_it_matters": "Remaining unequal-price handoff after shared-dirt is closed.", + "first_step": "Name one new alphabet outside leave-alones and census dirt-legal R.", + "blocked_by": "Leave-alones through #2858/#2851; pending onerepeat/tworepeat; deferred transfer-coupled-dual/shapes and host screens." + }, + { + "question": "Does a three-walk partitioned shared-dirt schedule (e.g. (2,2,4)) undercut the two-walk shared-dirt floor R=82?", + "why_it_matters": "Extends the shared-dirt alphabet to three independent restored components with one dirt coefficient.", + "first_step": "Fix triple shared-dirt cost and census distinct-label (2,2,4).", + "blocked_by": "Larger search; expected not to undercut 436 even if R improves toward 74." + } + ], + "predecessors": [ + { + "pr": 1898, + "credit": "Arham Tahir; minimum-query endpoint and abstract tariff fixture" + }, + { + "pr": 2858, + "credit": "Wentao Li; one-repeat (3,5)/(4,4) at Q=8; leave-alone; not edited" + }, + { + "pr": 2851, + "credit": "Wentao Li; distinct partitioned dual at Q=8; leave-alone; not edited" + }, + { + "ref": "cursor/independent-walks-onerepeat-8q-60b9@b07bc1e1", + "credit": "Wentao Li; one-repeat (2,6) at Q=8; leave-alone; not edited" + }, + { + "ref": "cursor/independent-walks-tworepeat-8q-60b9@c4581aaf", + "credit": "Wentao Li; two-repeat at Q=8; OQ1–OQ2 answered here; not edited" + }, + { + "pr": 2846, + "credit": "Wentao Li; transfer-coupled onerepeat at Q=7; leave-alone" + }, + { + "pr": 2840, + "credit": "Wentao Li; dirty-shadow at Q=8; leave-alone" + }, + { + "pr": 2779, + "credit": "Wentao Li; partitioned independent walks at Q=7" + }, + { + "pr": 2677, + "credit": "Wentao Li; Q=7–9 invoice / distinct-slot Q=8 baseline" + }, + { + "pr": 2643, + "credit": "Wentao Li; XOR floor; deferred shared-XOR soft-overlap not opened" + } + ] +} diff --git a/research/shared-dirt-walks-8q/VERIFY.json b/research/shared-dirt-walks-8q/VERIFY.json new file mode 100644 index 0000000000..69fc7fd804 --- /dev/null +++ b/research/shared-dirt-walks-8q/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": "Shared-dirt (2,6)/(3,5)/(4,4) dual censuses; short-long identity; champions vs independent floors; tariff floor 468; 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 shared-dirt 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/shared-dirt-walks-8q/independent.py b/research/shared-dirt-walks-8q/independent.py new file mode 100755 index 0000000000..1945ace61b --- /dev/null +++ b/research/shared-dirt-walks-8q/independent.py @@ -0,0 +1,302 @@ +#!/usr/bin/env python3 +"""Independent shared-dirt partitioned 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 + +EXPECTED_26_COVERING = 3916416 +EXPECTED_26_MIN = 82 +EXPECTED_26_HIST = {82: 583296, 88: 2916480, 96: 416640} +EXPECTED_35_COVERING = 10416000 +EXPECTED_35_MIN = 82 +EXPECTED_35_HIST = {82: 1458240, 88: 7291200, 96: 1666560} +EXPECTED_44_COVERING = 14165760 +EXPECTED_44_MIN = 82 +EXPECTED_44_HIST = {82: 1944320, 88: 9721600, 96: 2499840} +ENDPOINT = 436 +FLOOR = 468 + + +def fail(message): + raise SystemExit(f"FAIL_INDEPENDENT: {message}") + + +def even_odd(slots): + n = len(slots) + even = [INF] * 32 + odd = [INF] * 32 + even[0] = 0 + for bits in range(1, 1 << n): + size = bits.bit_count() + value = 0 + for i in range(n): + if bits >> i & 1: + value ^= slots[i] + table = even if size % 2 == 0 else odd + if size < table[value]: + table[value] = size + return even, odd + + +def shared_R(e0, o0, e1, o1): + re = [(a, e0[a]) for a in range(32) if e0[a] < INF] + ro = [(a, o0[a]) for a in range(32) if o0[a] < INF] + total = 0 + for m in range(1, 32): + best = INF + for a, c0 in re: + c1 = e1[a ^ m] + if c1 < INF: + best = min(best, c0 + c1) + for a, c0 in ro: + c1 = o1[a ^ m] + if c1 < INF: + best = min(best, c0 + c1) + if best >= INF: + return None + total += best + return total + + +def shared_short(e1, o1, sigma): + total = 0 + for m in range(1, 32): + best = e1[m] + t = e1[m ^ sigma] + if t < INF: + best = min(best, 2 + t) + t = o1[m] + if t < INF: + best = min(best, 1 + t) + t = o1[m ^ sigma] + if t < INF: + best = min(best, 1 + t) + if best >= INF: + return None + total += best + return total + + +def independent_R(e0, e1): + re = [(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 re: + 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 + + +def _chunk26(chunk): + hist = Counter() + covering = 0 + for e1, o1 in chunk: + for sigma in range(1, 32): + r = shared_short(e1, o1, sigma) + if r is None: + continue + covering += 1 + hist[r] += 1 + return covering, hist + + +_T = None + + +def _init(tables): + global _T + _T = tables + + +def _work35(i): + e0, o0 = _T[0][i] + hist = Counter() + covering = 0 + for e1, o1 in _T[1]: + r = shared_R(e0, o0, e1, o1) + if r is None: + continue + covering += 1 + hist[r] += 1 + return covering, hist + + +def _work44(i): + tables = _T[0] + e0, o0 = tables[i] + hist = Counter() + covering = 0 + r = shared_R(e0, o0, e0, o0) + if r is not None: + covering += 1 + hist[r] += 1 + for j in range(i + 1, len(tables)): + e1, o1 = tables[j] + r = shared_R(e0, o0, e1, o1) + if r is None: + continue + covering += 2 + hist[r] += 2 + return covering, hist + + +def census_26(): + tables = [even_odd((0,) + nz) for nz in combinations(range(1, 32), 5)] + n = max(1, os.cpu_count() or 2) + chunk = max(1, (len(tables) + n * 4 - 1) // (n * 4)) + chunks = [tables[i : i + chunk] for i in range(0, len(tables), chunk)] + with Pool(n) as pool: + results = pool.map(_chunk26, chunks) + hist = Counter() + covering = 0 + for c, h in results: + covering += c + hist.update(h) + if covering != EXPECTED_26_COVERING: + fail(f"26 covering {covering}") + if min(hist) != EXPECTED_26_MIN: + fail(f"26 min {min(hist)}") + if dict(hist) != EXPECTED_26_HIST: + fail(f"26 hist {dict(hist)}") + return covering, min(hist) + + +def census_35(): + t3 = [even_odd((0,) + nz) for nz in combinations(range(1, 32), 2)] + t5 = [even_odd((0,) + nz) for nz in combinations(range(1, 32), 4)] + n = max(1, os.cpu_count() or 2) + with Pool(n, initializer=_init, initargs=((t3, t5),)) as pool: + results = pool.map(_work35, range(len(t3))) + hist = Counter() + covering = 0 + for c, h in results: + covering += c + hist.update(h) + if covering != EXPECTED_35_COVERING: + fail(f"35 covering {covering}") + if min(hist) != EXPECTED_35_MIN: + fail(f"35 min {min(hist)}") + if dict(hist) != EXPECTED_35_HIST: + fail(f"35 hist {dict(hist)}") + return covering, min(hist) + + +def census_44(): + t4 = [even_odd((0,) + nz) for nz in combinations(range(1, 32), 3)] + n = max(1, os.cpu_count() or 2) + with Pool(n, initializer=_init, initargs=((t4,),)) as pool: + results = pool.map(_work44, range(len(t4))) + hist = Counter() + covering = 0 + for c, h in results: + covering += c + hist.update(h) + if covering != EXPECTED_44_COVERING: + fail(f"44 covering {covering}") + if min(hist) != EXPECTED_44_MIN: + fail(f"44 min {min(hist)}") + if dict(hist) != EXPECTED_44_HIST: + fail(f"44 hist {dict(hist)}") + return covering, min(hist) + + +def champions(): + checks = [ + ((0, 16), (0, 1, 2, 4, 8, 15), 82, 92), + ((0, 1, 2), (0, 4, 8, 15, 16), 82, None), + ((0, 1, 2, 4), (0, 8, 15, 16), 82, None), + ] + for w0, w1, expect_s, expect_i in checks: + e0, o0 = even_odd(w0) + e1, o1 = even_odd(w1) + rs = shared_R(e0, o0, e1, o1) + ri = independent_R(e0, e1) + if rs != expect_s: + fail(f"champ shared {w0} {w1} -> {rs}") + if ri is None or rs >= ri: + fail(f"shared should beat independent on {w0}") + if expect_i is not None and ri != expect_i: + fail(f"ind champ {ri}") + if path_X(w0) is None or path_X(w1) is None: + fail("path") + # Short-long identity. + e1, o1 = even_odd((0, 1, 2, 4, 8, 15)) + if shared_short(e1, o1, 16) != 82: + fail("short-long") + floor = tariff(8, 82, 0) + if floor != FLOOR or floor <= ENDPOINT: + fail(f"tariff floor {floor}") + + +def main(): + pinned = json.loads(CERT_PATH.read_text(encoding="utf-8")) + champions() + c26, m26 = census_26() + c35, m35 = census_35() + c44, m44 = census_44() + claim = pinned["claim"] + if claim["shared_dirt_26_covering"] != c26 or claim["shared_dirt_26_min_R"] != m26: + fail("26 claim drift") + if claim["shared_dirt_35_covering"] != c35 or claim["shared_dirt_35_min_R"] != m35: + fail("35 claim drift") + if claim["shared_dirt_44_covering"] != c44 or claim["shared_dirt_44_min_R"] != m44: + fail("44 claim drift") + if claim["partition_min_R"] != min(m26, m35, m44): + fail("partition min") + if claim["tariff_floor_at_X0"] != FLOOR: + fail("floor claim") + if claim["undercuts_436_after_complete_bill"] is not False: + fail("undercut claim") + if claim["beats_independent_dirt_floors"] is not True: + fail("beats claim") + if claim["endpoint_Q6_tariff"] != ENDPOINT: + fail("endpoint") + print( + "PASS_SHARED_DIRT_WALKS_8Q", + f"covering_26={c26}", + f"covering_35={c35}", + f"covering_44={c44}", + f"partition_min_R={min(m26, m35, m44)}", + f"tariff_floor={FLOOR}", + "beats_independent_dirt_floors", + "no_undercut_436", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/shared-dirt-walks-8q/model.py b/research/shared-dirt-walks-8q/model.py new file mode 100755 index 0000000000..5873008982 --- /dev/null +++ b/research/shared-dirt-walks-8q/model.py @@ -0,0 +1,504 @@ +"""Shared-dirt partitioned dual readout at eight queries. + +Freestanding priced alphabet under PR1898 (b,a,x)=(38,2,2): two restored walks +with distinct slot lists and a **shared dirt coefficient** (joint even live-read +parity across both walks), total Q = n0 + n1 = 8. Names one new dirt-legal +readout alphabet beyond same-walk / dirty-shadow / partitioned dual / +one-repeat / two-repeat. + +Answers preferred next18 / tworepeat OQ1–OQ2. Soft-overlap-safe vs deferred +shared-XOR (#2643): this couples the R-side dirt coefficient only; path-X and +non-path XOR schedules are unchanged and not shared. + +Self-contained relative to PR1898 / #2851 / iw lineage / tworepeat. +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 = { + "partition_26_covering": 3916416, + "partition_26_min_R": 82, + "partition_26_histogram": {"82": 583296, "88": 2916480, "96": 416640}, + "partition_35_covering": 10416000, + "partition_35_min_R": 82, + "partition_35_histogram": {"82": 1458240, "88": 7291200, "96": 1666560}, + "partition_44_covering": 14165760, + "partition_44_min_R": 82, + "partition_44_histogram": {"82": 1944320, "88": 9721600, "96": 2499840}, + "partition_min_R": 82, + "independent_26_min_R": 92, + "independent_35_min_R": 98, + "independent_44_min_R": 100, + "champion_26_walks": ((0, 16), (0, 1, 2, 4, 8, 15)), + "champion_35_walks": ((0, 1, 2), (0, 4, 8, 15, 16)), + "champion_44_walks": ((0, 1, 2, 4), (0, 8, 15, 16)), + "champion_26_path_X": 16, + "champion_35_path_X": 16, + "champion_44_path_X": 16, + "tariff_floor_at_X0": 468, + "endpoint_tariff_Q6": 436, + "single_walk_even_min_R_Q8": 74, + "length1_invalid": True, +} + + +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_odd_tables(slots): + """Even- and odd-subset per-mask minima on a slot list (INF if unreachable).""" + need(type(slots) is tuple and slots and slots[0] == 0, "slots must start at 0") + n = len(slots) + even = [INF] * 32 + odd = [INF] * 32 + even[0] = 0 + for bits in range(1, 1 << n): + size = bits.bit_count() + value = 0 + for i in range(n): + if bits >> i & 1: + value ^= slots[i] + table = even if size % 2 == 0 else odd + if size < table[value]: + table[value] = size + return even, odd + + +def even_table(slots): + even, _odd = even_odd_tables(slots) + 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 dual_shared_dirt_R(e0, o0, e1, o1): + """Shared dirt: joint even total live-read parity (even+even or odd+odd). + + Cost for mask m is + min( min_α (e0[α]+e1[α⊕m]), min_α (o0[α]+o1[α⊕m]) ). + Independent dirt admits only the even+even branch. + """ + reach_e0 = [(a, e0[a]) for a in range(32) if e0[a] < INF] + reach_o0 = [(a, o0[a]) for a in range(32) if o0[a] < INF] + total = 0 + for m in range(1, 32): + best = INF + for a, c0 in reach_e0: + c1 = e1[a ^ m] + if c1 < INF: + cost = c0 + c1 + if cost < best: + best = cost + for a, c0 in reach_o0: + c1 = o1[a ^ m] + if c1 < INF: + cost = c0 + c1 + if cost < best: + best = cost + if best >= INF: + return None + total += best + return total + + +def dual_shared_short_long(e_long, o_long, sigma): + """Shared-dirt dual when the short walk is (0, sigma). + + Short tables: e[0]=0, e[sigma]=2, o[0]=1, o[sigma]=1. + Per mask: min(e_long[m], 2+e_long[m⊕σ], 1+o_long[m], 1+o_long[m⊕σ]). + """ + total = 0 + for m in range(1, 32): + best = e_long[m] + flipped = e_long[m ^ sigma] + if flipped < INF: + best = min(best, 2 + flipped) + odd_m = o_long[m] + if odd_m < INF: + best = min(best, 1 + odd_m) + odd_flip = o_long[m ^ sigma] + if odd_flip < INF: + best = min(best, 1 + odd_flip) + if best >= INF: + return None + total += best + return total + + +def path_X(slots): + """Path XOR cost on the restored closed walk slots + (0,).""" + 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): + """A restored walk needs length ≥ 2 (closed return must be a nonzero edge).""" + 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 short_walk_tables(sigma): + """Sanity tables for (0, sigma).""" + e, o = even_odd_tables((0, sigma)) + need(e[0] == 0 and e[sigma] == 2, "short even") + need(o[0] == 1 and o[sigma] == 1, "short odd") + return e, o + + +# --- multiprocessing workers --- + +_WORKER_TABLES = None + + +def _init_worker_tables(tables): + global _WORKER_TABLES + _WORKER_TABLES = tables + + +def _work_short_chunk(chunk): + hist = Counter() + covering = 0 + witnesses = {} + for e_long, o_long in chunk: + for sigma in range(1, 32): + r = dual_shared_short_long(e_long, o_long, sigma) + if r is None: + continue + covering += 1 + hist[r] += 1 + witnesses.setdefault(r, sigma) + return covering, hist, witnesses + + +def _work_pair_index(i): + e0, o0 = _WORKER_TABLES[0][i] + hist = Counter() + covering = 0 + witnesses = {} + for j, (e1, o1) in enumerate(_WORKER_TABLES[1]): + r = dual_shared_dirt_R(e0, o0, e1, o1) + if r is None: + continue + covering += 1 + hist[r] += 1 + witnesses.setdefault(r, (i, j)) + return covering, hist, witnesses + + +def _work_pair_sym(i): + """Ordered (4,4) via upper triangle: dual_shared is symmetric in the two walks.""" + tables = _WORKER_TABLES[0] + e0, o0 = tables[i] + hist = Counter() + covering = 0 + witnesses = {} + r = dual_shared_dirt_R(e0, o0, e0, o0) + if r is not None: + covering += 1 + hist[r] += 1 + witnesses.setdefault(r, (i, i)) + for j in range(i + 1, len(tables)): + e1, o1 = tables[j] + r = dual_shared_dirt_R(e0, o0, e1, o1) + if r is None: + continue + covering += 2 + hist[r] += 2 + 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 enumerate_partition_26(): + """All distinct-label (2,6) shared-dirt pairs; covering spectrum {82,88,96}.""" + tables = [even_odd_tables((0,) + nz) for nz in combinations(range(1, 32), 5)] + n = _pool_count() + chunk = max(1, (len(tables) + n * 4 - 1) // (n * 4)) + chunks = [tables[i : i + chunk] for i in range(0, len(tables), chunk)] + with Pool(n) as pool: + covering, hist, _ = _merge_results(pool.map(_work_short_chunk, chunks)) + need(covering == EXPECTED["partition_26_covering"], "26 covering count") + need(min(hist) == EXPECTED["partition_26_min_R"], "26 min R") + need( + {str(r): hist[r] for r in sorted(hist)} == EXPECTED["partition_26_histogram"], + "26 histogram", + ) + witnesses = {} + long_nz = list(combinations(range(1, 32), 5)) + for nz, (e_long, o_long) in zip(long_nz, tables): + slots = (0,) + nz + for sigma in range(1, 32): + r = dual_shared_short_long(e_long, o_long, sigma) + if r is None: + continue + witnesses.setdefault(r, ((0, sigma), slots)) + if len(witnesses) == len(hist): + break + if len(witnesses) == len(hist): + break + # Short-long identity on the R=82 champion. + w0, w1 = EXPECTED["champion_26_walks"] + e1, o1 = even_odd_tables(w1) + r_fast = dual_shared_short_long(e1, o1, w0[1]) + e0, o0 = even_odd_tables(w0) + r_full = dual_shared_dirt_R(e0, o0, e1, o1) + need(r_fast == r_full == 82, "champion 26 short-long identity") + return { + "kind": "shared_dirt_partition_2_plus_6", + "Q": 8, + "covering_pairs": covering, + "attainable_R": sorted(hist), + "histogram": {str(r): hist[r] for r in sorted(hist)}, + "min_R": min(hist), + "first_witnesses": { + str(r): [list(a), list(b)] for r, (a, b) in sorted(witnesses.items()) + }, + "champion_short_long_identity": True, + } + + +def enumerate_partition_35(): + """All distinct-label (3,5) shared-dirt pairs; covering spectrum {82,88,96}.""" + tables3 = [even_odd_tables((0,) + nz) for nz in combinations(range(1, 32), 2)] + tables5 = [even_odd_tables((0,) + nz) for nz in combinations(range(1, 32), 4)] + 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 count") + 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", + ) + nz3 = list(combinations(range(1, 32), 2)) + nz5 = list(combinations(range(1, 32), 4)) + witnesses = {} + for r, (i, j) in wit_idx.items(): + witnesses[r] = ((0,) + nz3[i], (0,) + nz5[j]) + return { + "kind": "shared_dirt_partition_3_plus_5", + "Q": 8, + "covering_pairs": covering, + "attainable_R": sorted(hist), + "histogram": {str(r): hist[r] for r in sorted(hist)}, + "min_R": min(hist), + "first_witnesses": { + str(r): [list(a), list(b)] for r, (a, b) in sorted(witnesses.items()) + }, + } + + +def enumerate_partition_44(): + """All ordered distinct-label (4,4) shared-dirt pairs; spectrum {82,88,96}.""" + tables4 = [even_odd_tables((0,) + nz) for nz in combinations(range(1, 32), 3)] + n = _pool_count() + with Pool(n, initializer=_init_worker_tables, initargs=((tables4,),)) as pool: + covering, hist, wit_idx = _merge_results( + pool.map(_work_pair_sym, range(len(tables4))) + ) + need(covering == EXPECTED["partition_44_covering"], "44 covering count") + 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", + ) + # Symmetry sanity: swap of champion walks yields the same R. + w0, w1 = EXPECTED["champion_44_walks"] + e0, o0 = even_odd_tables(w0) + e1, o1 = even_odd_tables(w1) + need( + dual_shared_dirt_R(e0, o0, e1, o1) == dual_shared_dirt_R(e1, o1, e0, o0) == 82, + "44 symmetry", + ) + nz4 = list(combinations(range(1, 32), 3)) + witnesses = {} + for r, (i, j) in wit_idx.items(): + witnesses[r] = ((0,) + nz4[i], (0,) + nz4[j]) + return { + "kind": "shared_dirt_partition_4_plus_4", + "Q": 8, + "covering_pairs": covering, + "attainable_R": sorted(hist), + "histogram": {str(r): hist[r] for r in sorted(hist)}, + "min_R": min(hist), + "first_witnesses": { + str(r): [list(a), list(b)] for r, (a, b) in sorted(witnesses.items()) + }, + "symmetry_checked": True, + } + + +def length1_invalid_examples(): + """Length-1 'walks' are not restored: closed return is a zero edge.""" + examples = [] + for slots in ((0,),): + examples.append( + { + "slots": list(slots), + "valid_restored_walk": valid_restored_walk(slots), + "path_X": path_X(slots), + "note": "closed_(0,0)_zero_edge", + } + ) + need(all(not ex["valid_restored_walk"] for ex in examples), "length-1 must be invalid") + need(all(ex["path_X"] is None for ex in examples), "zero return edge") + return examples + + +def beats_independent_on_champions(): + """Shared dirt strictly undercuts independent-dirt floors on each shape's champ.""" + rows = [] + for name, walks, ind_floor in ( + ("26", EXPECTED["champion_26_walks"], EXPECTED["independent_26_min_R"]), + ("35", EXPECTED["champion_35_walks"], EXPECTED["independent_35_min_R"]), + ("44", EXPECTED["champion_44_walks"], EXPECTED["independent_44_min_R"]), + ): + w0, w1 = walks + e0, o0 = even_odd_tables(w0) + e1, o1 = even_odd_tables(w1) + r_shared = dual_shared_dirt_R(e0, o0, e1, o1) + r_ind = dual_independent_R(e0, e1) + need(r_shared is not None and r_ind is not None, f"{name} covering") + need(r_shared < r_ind, f"{name} shared should beat independent on champ") + need(r_shared < ind_floor or r_shared == 82, f"{name} vs independent floor") + rows.append( + { + "partition": name, + "walks": [list(w0), list(w1)], + "R_shared": r_shared, + "R_independent": r_ind, + "independent_floor": ind_floor, + "beats_independent_floor": r_shared < ind_floor, + } + ) + return rows + + +def champion_analysis(): + w26_a, w26_b = EXPECTED["champion_26_walks"] + w35_a, w35_b = EXPECTED["champion_35_walks"] + w44_a, w44_b = EXPECTED["champion_44_walks"] + for w in (w26_a, w26_b, w35_a, w35_b, w44_a, w44_b): + need(valid_restored_walk(w), f"invalid champion walk {w}") + e26a, o26a = even_odd_tables(w26_a) + e26b, o26b = even_odd_tables(w26_b) + e35a, o35a = even_odd_tables(w35_a) + e35b, o35b = even_odd_tables(w35_b) + e44a, o44a = even_odd_tables(w44_a) + e44b, o44b = even_odd_tables(w44_b) + r26 = dual_shared_dirt_R(e26a, o26a, e26b, o26b) + r35 = dual_shared_dirt_R(e35a, o35a, e35b, o35b) + r44 = dual_shared_dirt_R(e44a, o44a, e44b, o44b) + x26 = path_X(w26_a) + path_X(w26_b) + x35 = path_X(w35_a) + path_X(w35_b) + x44 = path_X(w44_a) + path_X(w44_b) + need(r26 == 82, "champ 26 R") + need(r35 == 82, "champ 35 R") + need(r44 == 82, "champ 44 R") + need(x26 == EXPECTED["champion_26_path_X"], "champ 26 X") + need(x35 == EXPECTED["champion_35_path_X"], "champ 35 X") + need(x44 == EXPECTED["champion_44_path_X"], "champ 44 X") + # Shared ≤ independent on every champion. + need(dual_independent_R(e26a, e26b) == 92, "26 ind on shared champ") + need(r26 < 92, "26 shared beats ind") + need(r35 < dual_independent_R(e35a, e35b), "35 shared beats ind") + need(r44 < dual_independent_R(e44a, e44b), "44 shared beats ind") + tariff26 = tariff_qrx(8, r26, x26) + tariff35 = tariff_qrx(8, r35, x35) + tariff44 = tariff_qrx(8, r44, x44) + tariff_floor = tariff_qrx(8, 82, 0) + need(tariff_floor == EXPECTED["tariff_floor_at_X0"], "floor") + need(tariff_floor > EXPECTED["endpoint_tariff_Q6"], "no undercut at X0") + need(tariff26 >= tariff_floor, "champ 26 tariff") + need(tariff35 >= tariff_floor, "champ 35 tariff") + need(tariff44 >= tariff_floor, "champ 44 tariff") + return { + "champion_26": { + "walks": [list(w26_a), list(w26_b)], + "R_shared": r26, + "R_independent": 92, + "path_X": x26, + "tariff": tariff26, + }, + "champion_35": { + "walks": [list(w35_a), list(w35_b)], + "R_shared": r35, + "R_independent": dual_independent_R(e35a, e35b), + "path_X": x35, + "tariff": tariff35, + }, + "champion_44": { + "walks": [list(w44_a), list(w44_b)], + "R_shared": r44, + "R_independent": dual_independent_R(e44a, e44b), + "path_X": x44, + "tariff": tariff44, + }, + "tariff_floor_at_X0": tariff_floor, + "endpoint_Q6": EXPECTED["endpoint_tariff_Q6"], + "single_walk_even_min_R_Q8": EXPECTED["single_walk_even_min_R_Q8"], + "partition_min_R": EXPECTED["partition_min_R"], + "beats_independent_floors": True, + "undercuts_436_after_complete_bill": False, + "soft_overlap_shared_xor": "safe_R_side_dirt_coupling_only", + } diff --git a/research/shared-dirt-walks-8q/test_package.py b/research/shared-dirt-walks-8q/test_package.py new file mode 100755 index 0000000000..ec643d5858 --- /dev/null +++ b/research/shared-dirt-walks-8q/test_package.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Package fault controls for shared-dirt walks 8q. 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 = "shared-dirt-walks-8q" + + +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_SHARED_DIRT_WALKS_8Q_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_SHARED_DIRT_WALKS_8Q_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"]["partition_min_R"] = 70 + 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_SHARED_DIRT_WALKS_8Q" 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_SHARED_DIRT_WALKS_8Q_PACKAGE_TESTS groups=6") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/shared-dirt-walks-8q/verify.py b/research/shared-dirt-walks-8q/verify.py new file mode 100755 index 0000000000..24d79fb660 --- /dev/null +++ b/research/shared-dirt-walks-8q/verify.py @@ -0,0 +1,257 @@ +#!/usr/bin/env python3 +"""Shared-dirt partitioned dual 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, + champion_analysis, + enumerate_partition_26, + enumerate_partition_35, + enumerate_partition_44, + length1_invalid_examples, + 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") + length1 = length1_invalid_examples() + + census26 = enumerate_partition_26() + need(census26["covering_pairs"] == EXPECTED["partition_26_covering"], "26 covering") + need(census26["min_R"] == EXPECTED["partition_26_min_R"], "26 min") + + census35 = enumerate_partition_35() + need(census35["covering_pairs"] == EXPECTED["partition_35_covering"], "35 covering") + need(census35["min_R"] == EXPECTED["partition_35_min_R"], "35 min") + + census44 = enumerate_partition_44() + need(census44["covering_pairs"] == EXPECTED["partition_44_covering"], "44 covering") + need(census44["min_R"] == EXPECTED["partition_44_min_R"], "44 min") + + champ = champion_analysis() + need(champ["partition_min_R"] == 82, "global min") + need(champ["tariff_floor_at_X0"] == EXPECTED["tariff_floor_at_X0"], "floor") + need(champ["undercuts_436_after_complete_bill"] is False, "no undercut") + need(champ["beats_independent_floors"] is True, "beats independent") + + partition_min = min(census26["min_R"], census35["min_R"], census44["min_R"]) + need(partition_min == EXPECTED["partition_min_R"], "partition min") + + cert = { + "schema_version": 1, + "status": "PASS_SHARED_DIRT_WALKS_8Q_OBSTRUCTION", + "scope": ( + "Five-source common-B mutable-source Q/R/X alphabet (PR1898) at " + "(b,a,x)=(38,2,2). Freestanding shared-dirt (single coefficient / " + "joint even live-read parity) dual on distinct partitioned restored " + "walks at total Q=8 on shapes (2,6), (3,5), and (4,4). Exact covering " + "min R=82 (tariff floor 468>436). Undercuts independent-dirt floors " + "92/98/100 but does not undercut tariff 436. Soft-overlap-safe vs " + "deferred shared-XOR: R-side dirt coupling only. Answers preferred " + "next18 / tworepeat OQ1–OQ2 without editing leave-alones through " + "#2858 / #2851 or pending onerepeat/tworepeat tips." + ), + "claim": { + "Q": 8, + "partitions": [[2, 6], [3, 5], [4, 4]], + "alphabet": "shared_dirt_partitioned_dual", + "shared_dirt_26_covering": EXPECTED["partition_26_covering"], + "shared_dirt_26_min_R": 82, + "shared_dirt_26_histogram": EXPECTED["partition_26_histogram"], + "shared_dirt_35_covering": EXPECTED["partition_35_covering"], + "shared_dirt_35_min_R": 82, + "shared_dirt_35_histogram": EXPECTED["partition_35_histogram"], + "shared_dirt_44_covering": EXPECTED["partition_44_covering"], + "shared_dirt_44_min_R": 82, + "shared_dirt_44_histogram": EXPECTED["partition_44_histogram"], + "partition_min_R": 82, + "tariff_floor_at_X0": EXPECTED["tariff_floor_at_X0"], + "endpoint_Q6_tariff": EXPECTED["endpoint_tariff_Q6"], + "undercuts_436_after_complete_bill": False, + "beats_independent_dirt_floors": True, + "independent_floors": {"26": 92, "35": 98, "44": 100}, + "answers_fourth_priced_alphabet_q8": True, + "answers_tworepeat_oq2_shared_dirt": True, + "soft_overlap_shared_xor": "safe_R_side_dirt_coupling_only", + "oq_answer": ( + "The named fourth priced readout alphabet under PR1898 " + "(b,a,x)=(38,2,2) beyond same-walk / dirty-shadow / partitioned " + "dual / one-repeat / two-repeat is the shared-dirt (joint even " + "live-read parity) dual on distinct partitioned walks at Q=8. " + "Exact census: (2,6)/(3,5)/(4,4) covering mins all R=82 " + "(histograms {82,88,96}); tariff floor 38·8+2·82=468>436. " + "Shared dirt undercuts independent-dirt floors 92/98/100 on " + "every covering shape's champion layer, but still cannot " + "undercut the six-query endpoint after a complete dirty bill. " + "Soft-overlap vs deferred shared-XOR is safe: only the R-side " + "dirt coefficient is coupled; path-X / non-path XOR schedules " + "are not shared. Leave-alones through #2858/#2851 and pending " + "onerepeat/tworepeat tips are not reopened." + ), + "no_new_kappa": True, + }, + "shared_dirt_2_plus_6": census26, + "shared_dirt_3_plus_5": census35, + "shared_dirt_4_plus_4": census44, + "length1_invalid": length1, + "champion": champ, + "unit_tariff": {"b": 38, "a": 2, "x": 2}, + "tariff_check": { + "formula": "38*Q + 2*R + 2*X", + "shared_dirt_floor_at_R82_X0": tariff_qrx(8, 82, 0), + "independent_26_at_R92_X0": tariff_qrx(8, 92, 0), + "one_repeat_at_R112_X0": tariff_qrx(8, 112, 0), + "single_walk_at_R74_X0": tariff_qrx(8, 74, 0), + "endpoint_Q6": EXPECTED["endpoint_tariff_Q6"], + }, + } + return cert + + +def compare_certificate(live, pinned): + need(live["status"] == pinned["status"], "status") + need(live["claim"] == pinned["claim"], "claim drift") + need( + live["shared_dirt_2_plus_6"]["covering_pairs"] + == pinned["shared_dirt_2_plus_6"]["covering_pairs"], + "26 covering drift", + ) + need( + live["shared_dirt_2_plus_6"]["min_R"] == pinned["shared_dirt_2_plus_6"]["min_R"], + "26 min drift", + ) + need( + live["shared_dirt_2_plus_6"]["histogram"] + == pinned["shared_dirt_2_plus_6"]["histogram"], + "26 hist drift", + ) + need( + live["shared_dirt_3_plus_5"]["covering_pairs"] + == pinned["shared_dirt_3_plus_5"]["covering_pairs"], + "35 covering drift", + ) + need( + live["shared_dirt_3_plus_5"]["min_R"] == pinned["shared_dirt_3_plus_5"]["min_R"], + "35 min drift", + ) + need( + live["shared_dirt_3_plus_5"]["histogram"] + == pinned["shared_dirt_3_plus_5"]["histogram"], + "35 hist drift", + ) + need( + live["shared_dirt_4_plus_4"]["covering_pairs"] + == pinned["shared_dirt_4_plus_4"]["covering_pairs"], + "44 covering drift", + ) + need( + live["shared_dirt_4_plus_4"]["min_R"] == pinned["shared_dirt_4_plus_4"]["min_R"], + "44 min drift", + ) + need( + live["shared_dirt_4_plus_4"]["histogram"] + == pinned["shared_dirt_4_plus_4"]["histogram"], + "44 hist drift", + ) + need(live["tariff_check"] == pinned["tariff_check"], "tariff drift") + need( + live["champion"]["undercuts_436_after_complete_bill"] + == pinned["champion"]["undercuts_436_after_complete_bill"], + "undercut drift", + ) + need( + live["champion"]["beats_independent_floors"] + == pinned["champion"]["beats_independent_floors"], + "beats-independent drift", + ) + + +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_SHARED_DIRT_WALKS_8Q_OBSTRUCTION", + f"partition_min_R={claim['partition_min_R']}", + f"covering_26={claim['shared_dirt_26_covering']}", + f"covering_35={claim['shared_dirt_35_covering']}", + f"covering_44={claim['shared_dirt_44_covering']}", + f"tariff_floor={claim['tariff_floor_at_X0']}", + f"endpoint={claim['endpoint_Q6_tariff']}", + "beats_independent_dirt_floors", + "no_undercut_436", + "answers_fourth_priced_alphabet_q8", + "soft_overlap_shared_xor_safe", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())