From d4d5f0f37929df97ea1e0f8d2bf0859f92407e55 Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 20:06:18 +0000 Subject: [PATCH] Research: dirty-parity collapse extends to eight queries (no new kappa) Answers #2715 OQ2 in the PR1898 alphabet: free all-subset readout at Q=8 reaches R=61 (tariff 426<436 at X=0), but zero-slot dirty-parity repair collapses every covering distinct-7 schedule to even-subset R>=74 (tariff 452), matching #2677. Prepared by Wentao Li with substantial AI assistance. --- .../CERTIFICATE.json | 233 +++++++++++ .../dirty-parity-8q-obstruction/NOTICE.md | 25 ++ research/dirty-parity-8q-obstruction/PROOF.md | 110 +++++ .../dirty-parity-8q-obstruction/README.md | 76 ++++ .../dirty-parity-8q-obstruction/SOURCES.json | 24 ++ .../dirty-parity-8q-obstruction/TASK.json | 100 +++++ .../dirty-parity-8q-obstruction/VERIFY.json | 52 +++ .../independent.py | 291 +++++++++++++ research/dirty-parity-8q-obstruction/model.py | 396 ++++++++++++++++++ .../test_package.py | 100 +++++ .../dirty-parity-8q-obstruction/verify.py | 335 +++++++++++++++ 11 files changed, 1742 insertions(+) create mode 100644 research/dirty-parity-8q-obstruction/CERTIFICATE.json create mode 100644 research/dirty-parity-8q-obstruction/NOTICE.md create mode 100644 research/dirty-parity-8q-obstruction/PROOF.md create mode 100644 research/dirty-parity-8q-obstruction/README.md create mode 100644 research/dirty-parity-8q-obstruction/SOURCES.json create mode 100644 research/dirty-parity-8q-obstruction/TASK.json create mode 100644 research/dirty-parity-8q-obstruction/VERIFY.json create mode 100644 research/dirty-parity-8q-obstruction/independent.py create mode 100644 research/dirty-parity-8q-obstruction/model.py create mode 100644 research/dirty-parity-8q-obstruction/test_package.py create mode 100644 research/dirty-parity-8q-obstruction/verify.py diff --git a/research/dirty-parity-8q-obstruction/CERTIFICATE.json b/research/dirty-parity-8q-obstruction/CERTIFICATE.json new file mode 100644 index 0000000000..ee6c4fbd35 --- /dev/null +++ b/research/dirty-parity-8q-obstruction/CERTIFICATE.json @@ -0,0 +1,233 @@ +{ + "schema_version": 1, + "status": "PASS_DIRTY_PARITY_8Q_OBSTRUCTION", + "scope": "Five-source common-B mutable-source Q/R/X alphabet (PR1898). All-subset vs even-subset vs zero-slot dirty-parity repair on restored length-8 slot lists. Answers #2715 OQ2.", + "claim": { + "Q": 8, + "all_subset_min_R_distinct7": 61, + "even_subset_min_R_distinct7": 74, + "parity_repair_min_R_distinct7": 74, + "one_dup_all_subset_min_R": 66, + "one_dup_parity_repair_min_R": 82, + "undercuts_436_if_all_subset_free": true, + "undercuts_436_after_parity_repair": false, + "hypothetical_all_subset_tariff_at_X0": 426, + "parity_repair_tariff_at_X0": 452, + "endpoint_Q6_tariff": 436, + "matches_2677_even_floor": true, + "answers_cr7q_oq2": true, + "oq2_answer": "Free all-subset readout at Q=8 reaches R=61 on distinct-7 covers (hypothetical tariff 426<436 even at X=0), but odd live-connector parity leaves connector dirt. Zero-slot parity repair collapses every covering distinct-7 schedule to even-subset cost R>=74 (tariff >=452), matching #2677's distinct-slot floor; one-duplicate covers repair to R>=82. The dirty-parity collapse therefore extends from Q=7 to Q=8.", + "no_new_kappa": true + }, + "champion": { + "slots": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ], + "all_subset_R": 61, + "even_subset_R": 74, + "parity_repair_R": 74, + "odd_dirt_mask_count": 13, + "hypothetical_tariff_X0": 426, + "repair_tariff_X0": 452 + }, + "dirt_obstruction_examples": [ + { + "mask": 1, + "subset_idxs": [ + 1 + ], + "values": [ + 1 + ], + "size": 1, + "live_connector_parity": "odd" + }, + { + "mask": 2, + "subset_idxs": [ + 2 + ], + "values": [ + 2 + ], + "size": 1, + "live_connector_parity": "odd" + }, + { + "mask": 3, + "subset_idxs": [ + 3 + ], + "values": [ + 3 + ], + "size": 1, + "live_connector_parity": "odd" + }, + { + "mask": 4, + "subset_idxs": [ + 4 + ], + "values": [ + 4 + ], + "size": 1, + "live_connector_parity": "odd" + }, + { + "mask": 8, + "subset_idxs": [ + 5 + ], + "values": [ + 8 + ], + "size": 1, + "live_connector_parity": "odd" + } + ], + "distinct7": { + "covering_sets": 2430400, + "repair_equals_even_count": 2430400, + "all_subset": { + "attainable_R": [ + 61, + 64, + 68 + ], + "histogram": { + "61": 416640, + "64": 1180480, + "68": 833280 + }, + "min_R": 61, + "first_witness": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ] + }, + "even_subset": { + "attainable_R": [ + 74, + 80, + 84 + ], + "histogram": { + "74": 416640, + "80": 1180480, + "84": 833280 + }, + "min_R": 74, + "first_witness": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ] + }, + "parity_repair": { + "attainable_R": [ + 74, + 80, + 84 + ], + "histogram": { + "74": 416640, + "80": 1180480, + "84": 833280 + }, + "min_R": 74, + "first_witness": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ] + } + }, + "one_duplicate": { + "covering_multisets": 4083072, + "all_subset": { + "attainable_R": [ + 66, + 72 + ], + "histogram": { + "66": 680512, + "72": 3402560 + }, + "min_R": 66, + "first_witness": [ + 0, + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + }, + "parity_repair": { + "attainable_R": [ + 82, + 88 + ], + "histogram": { + "82": 680512, + "88": 3402560 + }, + "min_R": 82, + "first_witness": [ + 0, + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + } + }, + "leave_alone": { + "through_pr": 2715, + "not_edited": [ + 1898, + 2455, + 2593, + 2643, + 2677, + 2686, + 2687, + 2715 + ], + "deferred_pending": [ + "cursor/multi-connector-7q-60b9 dual-census DEFER", + "mutable-source-7q-shared-xor soft-overlap #2643", + "host screens" + ] + } +} diff --git a/research/dirty-parity-8q-obstruction/NOTICE.md b/research/dirty-parity-8q-obstruction/NOTICE.md new file mode 100644 index 0000000000..467cc19a3d --- /dev/null +++ b/research/dirty-parity-8q-obstruction/NOTICE.md @@ -0,0 +1,25 @@ +# 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. +- 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 Q=8 floor R≥74 and champion path; not edited. +- Open #2643 `research/seven-query-xor-floor` — restored `X ≥ 6` at `Q = 7`; + not edited. +- Open #2686 `research/seven-query-r-floor` — even-subset `R ≥ 82` at `Q = 7`; + not edited. +- Open #2715 `research/cheaper-readout-7q-obstruction` — Q=7 all-subset / + dirty-parity collapse; OQ2 answered here; not edited. +- Live pin: `research/mutable-source-shear-cost/CERTIFICATE.json`. + +Prepared by Wentao Li (VictorLiwentao, @Is__Victor) with substantial AI +assistance. Disclosure: Prepared by Wentao Li with substantial AI assistance. diff --git a/research/dirty-parity-8q-obstruction/PROOF.md b/research/dirty-parity-8q-obstruction/PROOF.md new file mode 100644 index 0000000000..df267cd3b2 --- /dev/null +++ b/research/dirty-parity-8q-obstruction/PROOF.md @@ -0,0 +1,110 @@ +# Dirty-parity collapse extends to eight queries + +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). It answers +open question 2 of +[#2715](https://github.com/CrocSwap/integer-mult-bounds/pull/2715) +(`research/cheaper-readout-7q-obstruction`): whether the same dirty-parity +collapse applies at eight queries for all-subset versus even-subset floors. + +No new kappa is claimed. Leave-alone packages through #2715 are not edited. +Pending `multi-connector-7q` dual-census repair, deferred shared-XOR soft-overlap +with #2643, and host screens are not opened. + +## Setup + +Retain queries `Q_j`, readouts `R_m: y_m += A_m z`, and paid source shears +`X_(s,t)`. Connector prefixes of a restored length-8 walk are slots +`(s_0,…,s_7)` with `s_0 = 0`. The **even-subset** score is + +```text +R_even = Σ_{m=1}^{31} min{|T| : T ⊂ {0,…,7}, |T| even, ⊕_{i∈T} s_i = m}. +``` + +[#2677](https://github.com/CrocSwap/integer-mult-bounds/pull/2677) / the path-lowered +789q invoice records that on distinct-slot covers the minimum is `R_even = 74` +(witness `(0,1,2,3,4,8,16,29)`), so even at `X = 0` the abstract tariff +`(b,a,x)=(38,2,2)` is at least `452 > 436`. + +## Candidate cheaper alphabet: all-subset / odd-cardinality + +Allow every nonempty realizing subset (odd cardinalities included): + +```text +R_all = Σ_{m=1}^{31} min{|T| : T ⊂ {0,…,7}, |T|≥1, ⊕_{i∈T} s_i = m}. +``` + +**Census (distinct nonzero 7-sets).** Covering sets: `2430400`. Attainable +totals `R_all ∈ {61, 64, 68}` with histogram `416640 / 1180480 / 833280`. +Minimum `61`. + +**One-duplicate layer.** Length-8 multisets with exactly seven distinct labels +including `0`: covering count `4083072`, attainable `R_all ∈ {66, 72}` +(minimum `66`). + +The distinct-7 champion `(0,1,2,3,4,8,16,29)` attains `R_all = 61`. The +hypothetical tariff `38·8 + 2·61 + 2·0 = 426` is **strictly below** the +six-query endpoint `436` even with free XOR budget. + +## Dirty-connector obstruction + +Each live readout `R_m` on connector `z` adds one copy of `A_m · z_dirt` to +output `y_m`. For arbitrary connector dirt to cancel on every output, the number +of live `R_m` events for each mask `m` must be even. Therefore every +odd-cardinality realizing set is **illegal** in the PR1898 dirty-restoration +contract unless repaired. + +Finite check: a minimum all-subset schedule on the champion leaves a nonempty +set of masks with odd live-connector parity (13 odd min-masks). + +## Priced repair: zero-slot parity completion + +Every restored walk here has a 0-valued slot (the start). For an odd realizing +set `S`: + +- if `S` already contains a 0-valued index, drop one such index (`|S|-1`, same XOR); +- otherwise adjoin one 0-valued slot readout (`|S|+1`, same XOR). + +Both moves restore even live-connector parity without changing the pure mask. +Define `R_repair` as the minimum cost over even sets and such repaired odd sets. + +**Lemma.** On any slot list containing a 0-valued index, `R_repair = R_even`. +Every repaired odd set is an even set with the same XOR, and every even set is +already admitted. + +**Census.** On all `2430400` covering distinct-7 sets, `R_repair` matches +`R_even` exactly (spectrum `{74,80,84}`; `repair_equals_even_count = 2430400`). +On the one-duplicate layer, `R_repair ∈ {82,88}` with minimum `82`. + +## Tariff consequence + +After dirty-parity repair, every covering distinct-7 Q=8 schedule still has +`R ≥ 74`, matching the #2677 even-subset distinct-slot floor. Even at `X = 0`, +tariff `≥ 452 > 436`. One-duplicate covers repair to `R ≥ 82` (tariff `≥ 468`). +The free all-subset undercut (`426 < 436`) is not realizable under the PR1898 +dirty-connector contract; the minimal priced repair returns to the even-subset +floor. + +## Scope limits + +- This prices the natural odd-cardinality alphabet (all-subset) plus zero-slot + parity repair at `Q = 8`. Multi-connector alphabets (including independent + walks), dirty-shadow fixtures, output-mixing readouts, and host screens are + outside; the pending `multi-connector-7q` dual-census repair is not edited. +- Shared non-path XOR schedules remain deferred (soft-overlap with #2643). +- Leave-alone through #2715 (including #2593, #2643, #2677, #2686, #2687, #2715) + is respected. +- Exact XOR floors at `Q = 8` and non-distinct multi-repeat layers beyond one + duplicate are not claimed. +- No new kappa, physical supplier, or multiplication theorem. + +## Relation to predecessors + +| Prior | Already proves | This package adds | +|---|---|---| +| PR1898 | Min `Q=6`, endpoint tariff 436 | — | +| #2643 | `X≥6` at `Q=7` | — | +| #2677 / 789q | Path-lowered invoices; distinct-slot `R≥74` at `Q=8` | — | +| #2686 | Even-subset `R≥82` at `Q=7` | — | +| #2715 | All-subset→repair collapse at `Q=7` (OQ2: does it extend to Q=8?) | — | +| **This** | — | **All-subset would hit R=61/tariff 426 at Q=8, but dirty-parity repair collapses to R≥74/tariff 452** | diff --git a/research/dirty-parity-8q-obstruction/README.md b/research/dirty-parity-8q-obstruction/README.md new file mode 100644 index 0000000000..fe75ecb7a4 --- /dev/null +++ b/research/dirty-parity-8q-obstruction/README.md @@ -0,0 +1,76 @@ +# Dirty-parity collapse at eight queries + +**Scoped obstruction / priced alphabet; no new kappa.** Answers open question 2 +of [#2715](https://github.com/CrocSwap/integer-mult-bounds/pull/2715) +(`research/cheaper-readout-7q-obstruction`) in the five-source common-B +mutable-source alphabet of +[#1898](https://github.com/CrocSwap/integer-mult-bounds/pull/1898): does the +same dirty-parity collapse apply at eight queries for all-subset versus +even-subset floors? + +| Readout model | Distinct-7 min R | One-dup min R | Tariff at X=0 | Undercuts 436? | +|---|---:|---:|---:|---:| +| All-subset (free, illegal dirt) | **61** | 66 | **426** | yes (not legal) | +| Even-subset (#2677) | 74 | — | 452 | no | +| Parity-repaired odd sets | **74** | **82** | **452** | **no** | + +Free all-subset reaches `R=61` (hypothetical tariff `426 < 436` even at `X=0`). +Odd live-connector `R_m` counts leave connector dirt. Minimal zero-slot parity +repair restores even live-connector parity and collapses every covering +distinct-7 schedule to even-subset cost `R≥74` (tariff `≥452`), matching +#2677's distinct-slot floor. + +## Reproduction + +```sh +python3.12 -I -B research/dirty-parity-8q-obstruction/verify.py +python3.12 -I -O -B research/dirty-parity-8q-obstruction/verify.py +python3.12 -I -B research/dirty-parity-8q-obstruction/independent.py +python3.12 -I -B research/dirty-parity-8q-obstruction/test_package.py +python3.12 -B scripts/research_package.py --package research/dirty-parity-8q-obstruction +``` + +Expected: + +```text +PASS_DIRTY_PARITY_8Q_OBSTRUCTION all_subset_min_R=61 parity_repair_min_R=74 hypothetical_tariff=426 repair_tariff=452 no_undercut_after_dirty_parity_repair answers_cr7q_oq2 matches_2677_even_floor no_new_kappa +PASS_INDEPENDENT_DIRTY_PARITY_8Q covering=2430400 all_min=61 repair_min=74 tariff_free=426 tariff_repair=452 ... answers_cr7q_oq2 no_new_kappa +PASS_DIRTY_PARITY_8Q_PACKAGE_TESTS groups=6 +PASS_REGISTERED_RESEARCH_PACKAGE research/dirty-parity-8q-obstruction outcome=completed +``` + +Default verify is read-only. Admission uses `need()`; `-O` also passes. + +## Overlap + +Base commit `0b1cccf86e2f5132ed286a26ef0a681a495740ea`. Direct predecessors: +PR1898, #2677 (distinct-slot `R≥74` at Q=8), #2715 (OQ2). Leave-alone through +#2715 including #2593, #2643, #2677, #2686, #2687, #2715 is respected; those +packages are not edited. Pending `cursor/multi-connector-7q-60b9` dual-census +DEFER, deferred shared-XOR soft-overlap with #2643, and host screens are not +opened. No competing open PR on this freestanding Q=8 dirty-parity fixture at +refresh. + +## Open next questions + +1. Can a multi-connector alphabet with **independent walks** (partitioned or + transfer-coupled queries, not the same slot list) undercut tariff 436 after + charging both walks, transfers, and dirt? + Why it matters: remaining dual-row direction after same-walk / dirty-parity + collapses. First step: fix one transfer-coupled schedule and census dirt-legal + R. Blocked by: pending `multi-connector-7q` dual-census repair; larger search. +2. Does the dirty-shadow sym-diff collapse extend verbatim to eight queries? + Why it matters: closes the priced-shadow companion of #2715 OQ2 / mc7q OQ2. + First step: reuse the snapshot lemma on length-8 slot lists. + Blocked by: pending mc7q dual-census DEFER; larger search. + +## Credit + +Credit **Arham Tahir / PR1898**, **ywz65 / PR2455**, **PR1370**, fork **789q** / +**#2677**, **#2643**, **#2686**, open **#2715** (cheaper-readout; OQ2 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/dirty-parity-8q-obstruction/SOURCES.json b/research/dirty-parity-8q-obstruction/SOURCES.json new file mode 100644 index 0000000000..719b378cbd --- /dev/null +++ b/research/dirty-parity-8q-obstruction/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/dirty-parity-8q-obstruction/TASK.json b/research/dirty-parity-8q-obstruction/TASK.json new file mode 100644 index 0000000000..3a0cf460c5 --- /dev/null +++ b/research/dirty-parity-8q-obstruction/TASK.json @@ -0,0 +1,100 @@ +{ + "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": "Extend the #2715 dirty-parity (all-subset vs zero-slot repair) obstruction from Q=7 to Q=8 in the PR1898 alphabet: show free distinct-7 R=61 would tariff 426<436 at X=0, prove dirty-parity obstruction, and show repair collapses to even-subset R>=74 (tariff 452), matching #2677 and answering #2715 OQ2.", + "scope_change_reason": "The drawn connector-alphabet card is redirected to the explicit remaining #1898-lineage OQ (#2715 OQ2) outside the blocked mc7q dual-census claim, hard leave-alones through #2715, deferred shared-XOR soft-overlap, and leave-alone-safe host screens.", + "bottleneck_link": "A priced odd-cardinality readout alphabet at Q=8 decides whether intermediate query counts can undercut the six-query endpoint by cheaper readouts after the Q=7 collapses.", + "budget_minutes": 60, + "stop_rule": "Stop after distinct-7 and one-duplicate censuses, dirty-parity obstruction, repair collapse to even-subset matching #2677, tariff consequence, package tests; no multi-connector dual census, no shared-XOR reopening, no host screens.", + "outcome": "completed", + "evidence": "CERTIFICATE.json distinct-7 histograms all{61:416640,64:1180480,68:833280} even/repair{74:416640,80:1180480,84:833280} with repair matching even on all 2430400 covering sets; one-dup all{66,72}/repair{82,88}; champion odd-dirt; independent checker; corruption controls.", + "author": "Wentao Li", + "ai_assistance": "Substantial AI assistance for derivation, implementation, checking and writing.", + "open_questions": [ + { + "question": "Can a multi-connector alphabet with independent walks undercut tariff 436 after charging both walks, transfers, and dirt?", + "why_it_matters": "Remaining dual-row direction after same-walk / dirty-parity collapses.", + "first_step": "Fix one transfer-coupled schedule and census dirt-legal R.", + "blocked_by": "Pending multi-connector-7q dual-census DEFER; larger search." + }, + { + "question": "Does the dirty-shadow sym-diff collapse extend verbatim to eight queries?", + "why_it_matters": "Closes the priced-shadow companion of #2715 OQ2 / mc7q OQ2.", + "first_step": "Reuse the snapshot lemma on length-8 slot lists.", + "blocked_by": "Pending mc7q dual-census DEFER; larger search." + } + ], + "predecessors": [ + { + "pr": 1898, + "credit": "Arham Tahir; minimum-query endpoint and abstract tariff fixture" + }, + { + "pr": 2715, + "credit": "Wentao Li; Q=7 all-subset/dirty-parity collapse; OQ2 answered here" + }, + { + "pr": 2677, + "credit": "Wentao Li; path-lowered 7-9Q invoices; distinct-slot R>=74 at Q=8" + }, + { + "pr": 2686, + "credit": "Wentao Li; even-subset R floor at Q=7" + }, + { + "pr": 2643, + "credit": "Wentao Li; seven-query XOR floor X>=6" + }, + { + "pr": 2455, + "credit": "ywz65; six-query XOR necessity" + }, + { + "pr": 1370, + "credit": "Arham Tahir; path-local shear lowering / four-X word" + }, + { + "pr": 1524, + "credit": "TennisBowling; equal-price theorem / unequal-price handoff" + } + ] +} diff --git a/research/dirty-parity-8q-obstruction/VERIFY.json b/research/dirty-parity-8q-obstruction/VERIFY.json new file mode 100644 index 0000000000..f55664868d --- /dev/null +++ b/research/dirty-parity-8q-obstruction/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": "Distinct-7 all/even/repair census, one-duplicate layer, dirty obstruction, champion, 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 DP census, one-dup layer, champion odd-dirt, 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/dirty-parity-8q-obstruction/independent.py b/research/dirty-parity-8q-obstruction/independent.py new file mode 100644 index 0000000000..087874ac8e --- /dev/null +++ b/research/dirty-parity-8q-obstruction/independent.py @@ -0,0 +1,291 @@ +#!/usr/bin/env python3 +"""Independent all-subset / parity-repair 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" +CHAMPION = (0, 1, 2, 3, 4, 8, 16, 29) +INF = 99 + + +def fail(message): + raise SystemExit(f"FAIL_INDEPENDENT: {message}") + + +def gf2_rank(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) + return len(basis) + + +def scores(slots): + """Bit-enumeration totals: all / even / zero-slot repair.""" + n = len(slots) + best_all = [99] * 32 + best_even = [99] * 32 + best_repair = [99] * 32 + zero_idxs = [i for i in range(n) if slots[i] == 0] + for bits in range(1 << n): + size = bits.bit_count() + if size == 0: + continue + value = 0 + for i in range(n): + if bits >> i & 1: + value ^= slots[i] + if size < best_all[value]: + best_all[value] = size + if size % 2 == 0: + if size < best_even[value]: + best_even[value] = size + if size < best_repair[value]: + best_repair[value] = size + elif zero_idxs: + includes_zero = any(bits >> i & 1 for i in zero_idxs) + cost = size - 1 if includes_zero else size + 1 + if cost < best_repair[value]: + best_repair[value] = cost + if any(best_all[m] >= 99 for m in range(1, 32)): + return None + return sum(best_all[1:]), sum(best_even[1:]), sum(best_repair[1:]) + + +def dp_scores(slots): + """Separate DP implementation (not the bit oracle).""" + ba = [INF] * 32 + be = [INF] * 32 + boz = [INF] * 32 + bon = [INF] * 32 + ba[0] = 0 + be[0] = 0 + for v in slots: + is_zero = v == 0 + na = ba[:] + ne = be[:] + noz = boz[:] + non = bon[:] + for m in range(32): + if ba[m] < INF: + nm = m ^ v + c = ba[m] + 1 + if c < na[nm]: + na[nm] = c + if be[m] < INF: + nm = m ^ v + c = be[m] + 1 + if is_zero: + if c < noz[nm]: + noz[nm] = c + else: + if c < non[nm]: + non[nm] = c + if boz[m] < INF: + nm = m ^ v + c = boz[m] + 1 + if c < ne[nm]: + ne[nm] = c + if bon[m] < INF: + nm = m ^ v + c = bon[m] + 1 + if c < ne[nm]: + ne[nm] = c + ba, be, boz, bon = na, ne, noz, non + br = be[:] + if any(s == 0 for s in slots): + for m in range(32): + if boz[m] < INF: + br[m] = min(br[m], boz[m] - 1) + if bon[m] < INF: + br[m] = min(br[m], bon[m] + 1) + + def tot(best): + if any(best[m] >= INF for m in range(1, 32)): + return None + return sum(best[1:]) + + return tot(ba), tot(be), tot(br) + + +def tariff(q, r, x): + return (28 * q + r) + (9 * q) + x + (q + r + x) + + +def _worker(combos): + ha, he, hr = Counter(), Counter(), Counter() + covering = match = 0 + for combo in combos: + if gf2_rank(combo) < 5: + continue + slots = (0,) + combo + got = dp_scores(slots) + if got is None: + continue + a, e, r = got + covering += 1 + ha[a] += 1 + he[e] += 1 + hr[r] += 1 + if r == e: + match += 1 + return covering, match, ha, he, hr + + +def distinct7(): + combos = list(combinations(range(1, 32), 7)) + n = os.cpu_count() or 4 + chunk = (len(combos) + n - 1) // n + chunks = [combos[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_worker, chunks) + covering = match = 0 + ha, he, hr = Counter(), Counter(), Counter() + for c, m, a, e, r in parts: + covering += c + match += m + ha.update(a) + he.update(e) + hr.update(r) + if covering != 2430400: + fail(f"covering {covering}") + if match != covering: + fail(f"repair!=even on {covering - match} sets") + if dict(ha) != {61: 416640, 64: 1180480, 68: 833280}: + fail(f"all hist {dict(ha)}") + if dict(he) != {74: 416640, 80: 1180480, 84: 833280}: + fail(f"even hist {dict(he)}") + if dict(hr) != {74: 416640, 80: 1180480, 84: 833280}: + fail(f"repair hist {dict(hr)}") + return covering, min(ha), min(hr) + + +def _dup_worker(items): + ha, hr = Counter(), Counter() + covering = 0 + for six, dup in items: + if gf2_rank(six) < 5: + continue + slots = tuple(sorted(((0,) + six) + (dup,))) + got = dp_scores(slots) + if got is None: + continue + a, _e, r = got + covering += 1 + ha[a] += 1 + hr[r] += 1 + return covering, ha, hr + + +def one_dup(): + items = [] + for six in combinations(range(1, 32), 6): + labels = (0,) + six + for dup in labels: + items.append((six, dup)) + n = os.cpu_count() or 4 + chunk = (len(items) + n - 1) // n + chunks = [items[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_dup_worker, chunks) + covering = 0 + ha, hr = Counter(), Counter() + for c, a, r in parts: + covering += c + ha.update(a) + hr.update(r) + if covering != 4083072: + fail(f"one-dup covering {covering}") + if dict(ha) != {66: 680512, 72: 3402560}: + fail(f"one-dup all {dict(ha)}") + if dict(hr) != {82: 680512, 88: 3402560}: + fail(f"one-dup repair {dict(hr)}") + return min(ha), min(hr) + + +def champion_checks(): + bit = scores(CHAMPION) + dp = dp_scores(CHAMPION) + if bit != dp: + fail(f"champion DP/bit {bit} vs {dp}") + if bit != (61, 74, 74): + fail(f"champion totals {bit}") + # Odd-dirt on a min all-subset schedule. + reads = {} + n = len(CHAMPION) + for mask in range(1, 32): + found = None + for size in range(1, n + 1): + for subset in combinations(range(n), size): + value = 0 + for i in subset: + value ^= CHAMPION[i] + if value == mask: + found = subset + break + if found is not None: + break + if found is None: + fail(f"uncovered {mask}") + reads[mask] = found + odds = [m for m, s in reads.items() if len(s) % 2 == 1] + if not odds: + fail("no odd dirt on champion") + hyp = tariff(8, 61, 0) + rep = tariff(8, 74, 0) + if hyp != 426 or rep != 452: + fail(f"tariff {hyp} {rep}") + if not (hyp < 436 < rep or hyp < 436 <= rep): + fail("tariff ordering") + if not (hyp < 436 and rep > 436): + fail("undercut flags") + return len(odds) + + +def main(): + cert = json.loads(CERT_PATH.read_text(encoding="utf-8")) + claim = cert["claim"] + odd_count = champion_checks() + covering, all_min, repair_min = distinct7() + dup_all, dup_repair = one_dup() + if claim["all_subset_min_R_distinct7"] != all_min: + fail("claim all min") + if claim["parity_repair_min_R_distinct7"] != repair_min: + fail("claim repair min") + if claim["one_dup_all_subset_min_R"] != dup_all: + fail("claim one-dup all") + if claim["one_dup_parity_repair_min_R"] != dup_repair: + fail("claim one-dup repair") + if claim["undercuts_436_if_all_subset_free"] is not True: + fail("free undercut flag") + if claim["undercuts_436_after_parity_repair"] is not False: + fail("repair undercut flag") + if claim["answers_cr7q_oq2"] is not True: + fail("oq2 flag") + print( + "PASS_INDEPENDENT_DIRTY_PARITY_8Q " + f"covering={covering} all_min={all_min} repair_min={repair_min} " + f"tariff_free={tariff(8, all_min, 0)} tariff_repair={tariff(8, repair_min, 0)} " + f"one_dup_all={dup_all} one_dup_repair={dup_repair} " + f"champion_odd_dirt={odd_count} answers_cr7q_oq2 no_new_kappa" + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/dirty-parity-8q-obstruction/model.py b/research/dirty-parity-8q-obstruction/model.py new file mode 100644 index 0000000000..2142d7e8f8 --- /dev/null +++ b/research/dirty-parity-8q-obstruction/model.py @@ -0,0 +1,396 @@ +"""All-subset / dirty-parity repair at eight queries (PR1898 alphabet). + +Answers open question 2 of #2715 (`research/cheaper-readout-7q-obstruction`): +does the dirty-parity collapse apply at Q=8 for all-subset versus even-subset +floors? Self-contained relative to PR1898 / #2677 / #2715. 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 + +# Distinct-7 covering census (length-8 slots = {0}+7 distinct nonzero). +EXPECTED = { + "distinct7_covering": 2430400, + "all_subset_attainable_R": [61, 64, 68], + "all_subset_histogram": {"61": 416640, "64": 1180480, "68": 833280}, + "all_subset_min_R": 61, + "even_subset_attainable_R": [74, 80, 84], + "even_subset_histogram": {"74": 416640, "80": 1180480, "84": 833280}, + "even_subset_min_R": 74, + "parity_repair_attainable_R": [74, 80, 84], + "parity_repair_histogram": {"74": 416640, "80": 1180480, "84": 833280}, + "parity_repair_min_R": 74, + "repair_equals_even_count": 2430400, + "one_dup_covering": 4083072, + "one_dup_all_subset_attainable_R": [66, 72], + "one_dup_all_subset_histogram": {"66": 680512, "72": 3402560}, + "one_dup_all_subset_min_R": 66, + "one_dup_parity_repair_attainable_R": [82, 88], + "one_dup_parity_repair_histogram": {"82": 680512, "88": 3402560}, + "one_dup_parity_repair_min_R": 82, + "champion_slots": (0, 1, 2, 3, 4, 8, 16, 29), + "champion_all_R": 61, + "champion_even_R": 74, + "champion_repair_R": 74, + "endpoint_tariff_Q6": 436, + "hypothetical_all_subset_tariff_X0": 426, + "parity_repair_tariff_X0": 452, + "pr2677_even_distinct_floor": 74, +} + + +def tariff_qrx(q, r, x): + """Abstract complete-call tariff at (b,a,x)=(38,2,2).""" + leaves = 28 * q + r + nodes = 9 * q + dispatch = q + r + x + return leaves + nodes + x + dispatch + + +def gf2_rank(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) + return len(basis) + + +def spectrum_totals(slots): + """DP: (all_total, even_total, repair_total) or Nones if not all-covering. + + Repair tracks whether an odd realizing set already used a 0-valued slot + (drop) or must adjoin one (add), matching the bit-enumeration model of #2715. + """ + ba = [INF] * 32 + be = [INF] * 32 + boz = [INF] * 32 + bon = [INF] * 32 + ba[0] = 0 + be[0] = 0 + for v in slots: + is_zero = v == 0 + na = ba[:] + ne = be[:] + noz = boz[:] + non = bon[:] + for m in range(32): + a = ba[m] + if a < INF: + nm = m ^ v + c = a + 1 + if c < na[nm]: + na[nm] = c + e = be[m] + if e < INF: + nm = m ^ v + c = e + 1 + if is_zero: + if c < noz[nm]: + noz[nm] = c + else: + if c < non[nm]: + non[nm] = c + if boz[m] < INF: + nm = m ^ v + c = boz[m] + 1 + if c < ne[nm]: + ne[nm] = c + if bon[m] < INF: + nm = m ^ v + c = bon[m] + 1 + if c < ne[nm]: + ne[nm] = c + ba, be, boz, bon = na, ne, noz, non + has_zero = any(s == 0 for s in slots) + br = be[:] + if has_zero: + for m in range(32): + if boz[m] < INF: + br[m] = min(br[m], boz[m] - 1) + if bon[m] < INF: + br[m] = min(br[m], bon[m] + 1) + + def tot(best): + if any(best[m] >= INF for m in range(1, 32)): + return None + return sum(best[1:]) + + return tot(ba), tot(be), tot(br) + + +def bit_enum_totals(slots): + """Independent bit-enumeration oracle (used on small witnesses).""" + n = len(slots) + ba = [99] * 32 + be = [99] * 32 + br = [99] * 32 + zero_idxs = [i for i in range(n) if slots[i] == 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] + if size < ba[value]: + ba[value] = size + if size % 2 == 0: + if size < be[value]: + be[value] = size + if size < br[value]: + br[value] = size + elif zero_idxs: + includes_zero = any(bits >> i & 1 for i in zero_idxs) + cost = size - 1 if includes_zero else size + 1 + if cost < br[value]: + br[value] = cost + if any(ba[m] >= 99 for m in range(1, 32)): + return None + return sum(ba[1:]), sum(be[1:]), sum(br[1:]) + + +def min_all_subset_R(slots): + got = spectrum_totals(slots) + return None if got[0] is None else got[0] + + +def min_even_subset_R(slots): + got = spectrum_totals(slots) + return None if got[1] is None else got[1] + + +def min_parity_repair_R(slots): + got = spectrum_totals(slots) + return None if got[2] is None else got[2] + + +def all_subset_reads(slots): + n = len(slots) + reads = {} + for mask in range(1, 32): + found = None + for size in range(1, n + 1): + for subset in combinations(range(n), size): + value = 0 + for i in subset: + value ^= slots[i] + if value == mask: + found = subset + break + if found is not None: + break + need(found is not None, f"uncovered mask {mask}") + reads[mask] = found + return reads + + +def odd_dirt_masks(reads): + return [m for m, subset in reads.items() if len(subset) % 2 == 1] + + +def _distinct7_worker(combos): + ha, he, hr = Counter(), Counter(), Counter() + covering = 0 + match = 0 + mins = [999, 999, 999] + wits = [None, None, None] + for combo in combos: + if gf2_rank(combo) < 5: + continue + slots = (0,) + combo + ta, te, tr = spectrum_totals(slots) + if ta is None: + continue + covering += 1 + ha[ta] += 1 + he[te] += 1 + hr[tr] += 1 + if tr == te: + match += 1 + if ta < mins[0]: + mins[0] = ta + wits[0] = slots + if te < mins[1]: + mins[1] = te + wits[1] = slots + if tr < mins[2]: + mins[2] = tr + wits[2] = slots + return covering, match, ha, he, hr, mins, wits + + +def enumerate_distinct7_triple_spectrum(): + combos = list(combinations(range(1, 32), 7)) + n = os.cpu_count() or 4 + chunk = (len(combos) + n - 1) // n + chunks = [combos[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_distinct7_worker, chunks) + covering = match = 0 + ha, he, hr = Counter(), Counter(), Counter() + mins = [999, 999, 999] + wits = [None, None, None] + for c, m, a, e, r, mn, w in parts: + covering += c + match += m + ha.update(a) + he.update(e) + hr.update(r) + for i in range(3): + if mn[i] < mins[i]: + mins[i] = mn[i] + wits[i] = w[i] + return { + "covering_sets": covering, + "repair_equals_even_count": match, + "all_subset": { + "attainable_R": sorted(ha), + "histogram": {str(k): ha[k] for k in sorted(ha)}, + "min_R": mins[0], + "first_witness": list(wits[0]) if wits[0] is not None else None, + }, + "even_subset": { + "attainable_R": sorted(he), + "histogram": {str(k): he[k] for k in sorted(he)}, + "min_R": mins[1], + "first_witness": list(wits[1]) if wits[1] is not None else None, + }, + "parity_repair": { + "attainable_R": sorted(hr), + "histogram": {str(k): hr[k] for k in sorted(hr)}, + "min_R": mins[2], + "first_witness": list(wits[2]) if wits[2] is not None else None, + }, + } + + +def _one_dup_worker(items): + ha, hr = Counter(), Counter() + covering = 0 + min_a = min_r = 999 + wit_a = wit_r = None + for six, dup in items: + if gf2_rank(six) < 5: + continue + labels = (0,) + six + slots = tuple(sorted(labels + (dup,))) + ta, _te, tr = spectrum_totals(slots) + if ta is None: + continue + covering += 1 + ha[ta] += 1 + hr[tr] += 1 + if ta < min_a: + min_a = ta + wit_a = slots + if tr < min_r: + min_r = tr + wit_r = slots + return covering, ha, hr, min_a, min_r, wit_a, wit_r + + +def enumerate_one_duplicate_spectrum(): + """Length-8 multisets with exactly seven distinct labels including 0.""" + items = [] + for six in combinations(range(1, 32), 6): + labels = (0,) + six + for dup in labels: + items.append((six, dup)) + n = os.cpu_count() or 4 + chunk = (len(items) + n - 1) // n + chunks = [items[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_one_dup_worker, chunks) + covering = 0 + ha, hr = Counter(), Counter() + min_a = min_r = 999 + wit_a = wit_r = None + for c, a, r, ma, mr, wa, wr in parts: + covering += c + ha.update(a) + hr.update(r) + if ma < min_a: + min_a = ma + wit_a = wa + if mr < min_r: + min_r = mr + wit_r = wr + return { + "covering_multisets": covering, + "all_subset": { + "attainable_R": sorted(ha), + "histogram": {str(k): ha[k] for k in sorted(ha)}, + "min_R": min_a, + "first_witness": list(wit_a) if wit_a is not None else None, + }, + "parity_repair": { + "attainable_R": sorted(hr), + "histogram": {str(k): hr[k] for k in sorted(hr)}, + "min_R": min_r, + "first_witness": list(wit_r) if wit_r is not None else None, + }, + } + + +def champion_analysis(): + slots = EXPECTED["champion_slots"] + ca, ce, cr = bit_enum_totals(slots) + need(ca == EXPECTED["champion_all_R"], "champion all") + need(ce == EXPECTED["champion_even_R"], "champion even") + need(cr == EXPECTED["champion_repair_R"], "champion repair") + reads = all_subset_reads(slots) + odds = odd_dirt_masks(reads) + need(len(odds) > 0, "champion must show odd dirt") + hyp = tariff_qrx(8, ca, 0) + rep = tariff_qrx(8, cr, 0) + need(hyp == EXPECTED["hypothetical_all_subset_tariff_X0"], "hyp tariff") + need(rep == EXPECTED["parity_repair_tariff_X0"], "repair tariff") + return { + "slots": list(slots), + "all_subset_R": ca, + "even_subset_R": ce, + "parity_repair_R": cr, + "odd_dirt_mask_count": len(odds), + "odd_dirt_masks": odds, + "hypothetical_tariff_X0": hyp, + "repair_tariff_X0": rep, + } + + +def dirt_obstruction_examples(): + slots = EXPECTED["champion_slots"] + reads = all_subset_reads(slots) + examples = [] + for mask, subset in reads.items(): + if len(subset) % 2 == 1: + examples.append( + { + "mask": mask, + "subset_idxs": list(subset), + "values": [slots[i] for i in subset], + "size": len(subset), + "live_connector_parity": "odd", + } + ) + if len(examples) >= 5: + break + need(len(examples) >= 2, "need dirt examples") + return examples + + +CHAMPION_8 = EXPECTED["champion_slots"] diff --git a/research/dirty-parity-8q-obstruction/test_package.py b/research/dirty-parity-8q-obstruction/test_package.py new file mode 100644 index 0000000000..ce7c08d563 --- /dev/null +++ b/research/dirty-parity-8q-obstruction/test_package.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Package fault controls for dirty-parity 8q obstruction. 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 = "dirty-parity-8q-obstruction" + + +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_DIRTY_PARITY_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_DIRTY_PARITY_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"]["parity_repair_min_R_distinct7"] = 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_DIRTY_PARITY_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" + text = cert.read_text(encoding="utf-8") + # Inject a duplicate top-level key after schema_version. + text = text.replace( + '"schema_version": 1,', + '"schema_version": 1,\n "schema_version": 2,', + 1, + ) + cert.write_text(text, 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_DIRTY_PARITY_8Q_PACKAGE_TESTS groups=6") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/dirty-parity-8q-obstruction/verify.py b/research/dirty-parity-8q-obstruction/verify.py new file mode 100644 index 0000000000..ed1a039de0 --- /dev/null +++ b/research/dirty-parity-8q-obstruction/verify.py @@ -0,0 +1,335 @@ +#!/usr/bin/env python3 +"""Dirty-parity collapse 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 + CHAMPION_8, + EXPECTED, + bit_enum_totals, + champion_analysis, + dirt_obstruction_examples, + enumerate_distinct7_triple_spectrum, + enumerate_one_duplicate_spectrum, + min_all_subset_R, + min_even_subset_R, + min_parity_repair_R, + spectrum_totals, + tariff_qrx, +) + +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 check_claim_constants(cert): + claim = cert["claim"] + need(claim["all_subset_min_R_distinct7"] == EXPECTED["all_subset_min_R"], "claim all") + need(claim["parity_repair_min_R_distinct7"] == EXPECTED["parity_repair_min_R"], "claim repair") + need(claim["even_subset_min_R_distinct7"] == EXPECTED["even_subset_min_R"], "claim even") + need(claim["undercuts_436_if_all_subset_free"] is True, "claim undercut flag") + need(claim["undercuts_436_after_parity_repair"] is False, "claim repair undercut") + need(claim["matches_2677_even_floor"] is True, "2677 floor flag") + need(claim["answers_cr7q_oq2"] is True, "oq2 flag") + need(claim["no_new_kappa"] is True, "kappa") + + +def build_certificate(): + # DP vs bit-enum agreement on champion and nearby witnesses. + for slots in ( + CHAMPION_8, + (0, 1, 2, 3, 4, 8, 16, 30), + (0, 1, 2, 4, 8, 15, 16, 3), + ): + need(spectrum_totals(slots) == bit_enum_totals(slots), f"DP/bit mismatch {slots}") + + champ = champion_analysis() + need(champ["all_subset_R"] == EXPECTED["champion_all_R"], "champion all R") + need(champ["even_subset_R"] == EXPECTED["champion_even_R"], "champion even R") + need(champ["parity_repair_R"] == EXPECTED["champion_repair_R"], "champion repair R") + need(champ["odd_dirt_mask_count"] > 0, "champion odd dirt") + need( + champ["hypothetical_tariff_X0"] == EXPECTED["hypothetical_all_subset_tariff_X0"], + "hyp tariff", + ) + need(champ["repair_tariff_X0"] == EXPECTED["parity_repair_tariff_X0"], "repair tariff") + need( + champ["hypothetical_tariff_X0"] < EXPECTED["endpoint_tariff_Q6"], + "free all-subset would undercut", + ) + need( + champ["repair_tariff_X0"] > EXPECTED["endpoint_tariff_Q6"], + "repair must not undercut", + ) + + dirt = dirt_obstruction_examples() + need(len(dirt) >= 2, "dirt examples") + + need(min_all_subset_R(CHAMPION_8) == 61, "closed all") + need(min_even_subset_R(CHAMPION_8) == 74, "closed even") + need(min_parity_repair_R(CHAMPION_8) == 74, "closed repair") + need( + tariff_qrx(8, 61, 0) == 426 and tariff_qrx(8, 74, 0) == 452, + "tariff arithmetic", + ) + need( + EXPECTED["parity_repair_min_R"] == EXPECTED["pr2677_even_distinct_floor"], + "match #2677 floor", + ) + + distinct = enumerate_distinct7_triple_spectrum() + need(distinct["covering_sets"] == EXPECTED["distinct7_covering"], "covering count") + need( + distinct["repair_equals_even_count"] == EXPECTED["repair_equals_even_count"], + "repair==even count", + ) + need( + distinct["all_subset"]["attainable_R"] == EXPECTED["all_subset_attainable_R"], + "all spectrum", + ) + need( + distinct["all_subset"]["histogram"] == EXPECTED["all_subset_histogram"], + "all hist", + ) + need(distinct["all_subset"]["min_R"] == EXPECTED["all_subset_min_R"], "all min") + need( + distinct["even_subset"]["attainable_R"] == EXPECTED["even_subset_attainable_R"], + "even spectrum", + ) + need( + distinct["even_subset"]["histogram"] == EXPECTED["even_subset_histogram"], + "even hist", + ) + need(distinct["even_subset"]["min_R"] == EXPECTED["even_subset_min_R"], "even min") + need( + distinct["parity_repair"]["attainable_R"] + == EXPECTED["parity_repair_attainable_R"], + "repair spectrum", + ) + need( + distinct["parity_repair"]["histogram"] == EXPECTED["parity_repair_histogram"], + "repair hist", + ) + need( + distinct["parity_repair"]["min_R"] == EXPECTED["parity_repair_min_R"], + "repair min", + ) + + one_dup = enumerate_one_duplicate_spectrum() + need(one_dup["covering_multisets"] == EXPECTED["one_dup_covering"], "one-dup covering") + need( + one_dup["all_subset"]["histogram"] == EXPECTED["one_dup_all_subset_histogram"], + "one-dup all hist", + ) + need( + one_dup["all_subset"]["min_R"] == EXPECTED["one_dup_all_subset_min_R"], + "one-dup all min", + ) + need( + one_dup["parity_repair"]["histogram"] + == EXPECTED["one_dup_parity_repair_histogram"], + "one-dup repair hist", + ) + need( + one_dup["parity_repair"]["min_R"] == EXPECTED["one_dup_parity_repair_min_R"], + "one-dup repair min", + ) + need( + one_dup["all_subset"]["min_R"] > EXPECTED["all_subset_min_R"], + "one-dup cannot beat distinct-7 free floor", + ) + need( + one_dup["parity_repair"]["min_R"] >= EXPECTED["parity_repair_min_R"], + "one-dup repair at least distinct-7 repair", + ) + + return { + "schema_version": 1, + "status": "PASS_DIRTY_PARITY_8Q_OBSTRUCTION", + "scope": ( + "Five-source common-B mutable-source Q/R/X alphabet (PR1898). " + "All-subset vs even-subset vs zero-slot dirty-parity repair on " + "restored length-8 slot lists. Answers #2715 OQ2." + ), + "claim": { + "Q": 8, + "all_subset_min_R_distinct7": EXPECTED["all_subset_min_R"], + "even_subset_min_R_distinct7": EXPECTED["even_subset_min_R"], + "parity_repair_min_R_distinct7": EXPECTED["parity_repair_min_R"], + "one_dup_all_subset_min_R": EXPECTED["one_dup_all_subset_min_R"], + "one_dup_parity_repair_min_R": EXPECTED["one_dup_parity_repair_min_R"], + "undercuts_436_if_all_subset_free": True, + "undercuts_436_after_parity_repair": False, + "hypothetical_all_subset_tariff_at_X0": EXPECTED[ + "hypothetical_all_subset_tariff_X0" + ], + "parity_repair_tariff_at_X0": EXPECTED["parity_repair_tariff_X0"], + "endpoint_Q6_tariff": EXPECTED["endpoint_tariff_Q6"], + "matches_2677_even_floor": True, + "answers_cr7q_oq2": True, + "oq2_answer": ( + "Free all-subset readout at Q=8 reaches R=61 on distinct-7 covers " + "(hypothetical tariff 426<436 even at X=0), but odd live-connector " + "parity leaves connector dirt. Zero-slot parity repair collapses " + "every covering distinct-7 schedule to even-subset cost R>=74 " + "(tariff >=452), matching #2677's distinct-slot floor; " + "one-duplicate covers repair to R>=82. The dirty-parity collapse " + "therefore extends from Q=7 to Q=8." + ), + "no_new_kappa": True, + }, + "champion": { + "slots": champ["slots"], + "all_subset_R": champ["all_subset_R"], + "even_subset_R": champ["even_subset_R"], + "parity_repair_R": champ["parity_repair_R"], + "odd_dirt_mask_count": champ["odd_dirt_mask_count"], + "hypothetical_tariff_X0": champ["hypothetical_tariff_X0"], + "repair_tariff_X0": champ["repair_tariff_X0"], + }, + "dirt_obstruction_examples": dirt, + "distinct7": distinct, + "one_duplicate": one_dup, + "leave_alone": { + "through_pr": 2715, + "not_edited": [1898, 2455, 2593, 2643, 2677, 2686, 2687, 2715], + "deferred_pending": [ + "cursor/multi-connector-7q-60b9 dual-census DEFER", + "mutable-source-7q-shared-xor soft-overlap #2643", + "host screens", + ], + }, + } + + +def compare_certificate(fresh, stored): + need(fresh["status"] == stored["status"], "status") + need(fresh["claim"] == stored["claim"], "claim drift") + need(fresh["champion"]["slots"] == stored["champion"]["slots"], "champion slots") + need( + fresh["champion"]["all_subset_R"] == stored["champion"]["all_subset_R"], + "champion all", + ) + need( + fresh["champion"]["parity_repair_R"] == stored["champion"]["parity_repair_R"], + "champion repair", + ) + need( + fresh["distinct7"]["covering_sets"] == stored["distinct7"]["covering_sets"], + "distinct7 covering", + ) + need( + fresh["distinct7"]["all_subset"]["histogram"] + == stored["distinct7"]["all_subset"]["histogram"], + "distinct7 all hist", + ) + need( + fresh["distinct7"]["parity_repair"]["histogram"] + == stored["distinct7"]["parity_repair"]["histogram"], + "distinct7 repair hist", + ) + need( + fresh["distinct7"]["repair_equals_even_count"] + == stored["distinct7"]["repair_equals_even_count"], + "repair equals even", + ) + need( + fresh["one_duplicate"]["covering_multisets"] + == stored["one_duplicate"]["covering_multisets"], + "one-dup covering", + ) + need( + fresh["one_duplicate"]["all_subset"]["histogram"] + == stored["one_duplicate"]["all_subset"]["histogram"], + "one-dup all hist", + ) + need( + fresh["one_duplicate"]["parity_repair"]["histogram"] + == stored["one_duplicate"]["parity_repair"]["histogram"], + "one-dup repair hist", + ) + + +def main(argv=None): + parser = argparse.ArgumentParser() + parser.add_argument( + "--write", + action="store_true", + help="Regenerate CERTIFICATE.json (default is read-only compare).", + ) + args = parser.parse_args(argv) + + check_source_pins() + fresh = build_certificate() + if args.write: + CERT_PATH.write_text(json.dumps(fresh, indent=2) + "\n", encoding="utf-8") + print( + "WROTE_DIRTY_PARITY_8Q_OBSTRUCTION " + f"all_min={EXPECTED['all_subset_min_R']} " + f"repair_min={EXPECTED['parity_repair_min_R']} " + f"hyp_tariff={EXPECTED['hypothetical_all_subset_tariff_X0']} " + f"repair_tariff={EXPECTED['parity_repair_tariff_X0']}" + ) + return 0 + + stored = load_json_reject_duplicates(CERT_PATH) + check_claim_constants(stored) + compare_certificate(fresh, stored) + print( + "PASS_DIRTY_PARITY_8Q_OBSTRUCTION " + f"all_subset_min_R={EXPECTED['all_subset_min_R']} " + f"parity_repair_min_R={EXPECTED['parity_repair_min_R']} " + f"hypothetical_tariff={EXPECTED['hypothetical_all_subset_tariff_X0']} " + f"repair_tariff={EXPECTED['parity_repair_tariff_X0']} " + "no_undercut_after_dirty_parity_repair " + "answers_cr7q_oq2 matches_2677_even_floor no_new_kappa" + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())