diff --git a/research/cheaper-readout-7q-obstruction/CERTIFICATE.json b/research/cheaper-readout-7q-obstruction/CERTIFICATE.json new file mode 100644 index 0000000000..74ed4f1ce2 --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/CERTIFICATE.json @@ -0,0 +1,279 @@ +{ + "schema_version": 1, + "status": "PASS_CHEAPER_READOUT_7Q_OBSTRUCTION", + "scope": "Five-source common-B mutable-source Q/R/X alphabet (PR1898). Priced odd-cardinality (all-subset) connector-state readout at Q=7 versus dirty-parity repair back to even live-connector schedules. Answers #2686 OQ1 for this alphabet.", + "claim": { + "Q": 7, + "all_subset_min_R": 66, + "even_subset_min_R": 82, + "parity_repair_min_R": 82, + "one_repeat_all_subset_min_R": 80, + "one_repeat_parity_repair_min_R": 96, + "undercuts_436_if_all_subset_free": true, + "undercuts_436_after_parity_repair": false, + "hypothetical_all_subset_tariff_at_X6": 410, + "parity_repair_tariff_at_X6": 442, + "endpoint_Q6_tariff": 436, + "answers_7qr_oq1": true, + "oq1_answer": "Free all-subset (odd-cardinality) readout reaches R=66 and would tariff 410<436 at X=6, but odd live-connector R_m parity leaves arbitrary connector dirt on those outputs. Minimal zero-slot parity repair collapses every covering schedule to even-subset cost R>=82 (tariff 442), so this cheaper alphabet does not undercut the six-query endpoint under the PR1898 dirty-connector contract.", + "no_new_kappa": true + }, + "champion": { + "slots": [ + 0, + 1, + 2, + 6, + 12, + 24, + 16 + ], + "path_X": 6, + "all_subset_R": 66, + "even_subset_R": 82, + "parity_repair_R": 82, + "all_subset_odd_dirt_masks": [ + 1, + 2, + 5, + 6, + 9, + 11, + 12, + 15, + 16, + 19, + 21, + 23, + 24, + 27, + 29, + 31 + ], + "all_subset_odd_dirt_count": 16, + "hypothetical_tariff_all_X6": 410, + "tariff_repair_X6": 442, + "endpoint_Q6": 436 + }, + "dirt_obstruction_examples": [ + { + "note": "champion_all_subset", + "slots": [ + 0, + 1, + 2, + 6, + 12, + 24, + 16 + ], + "odd_dirt_masks": [ + 1, + 2, + 5, + 6, + 9, + 11, + 12, + 15, + 16, + 19, + 21, + 23, + 24, + 27, + 29, + 31 + ], + "odd_dirt_count": 16, + "legal_under_dirty_cancellation": false, + "all_R": 66, + "repair_R": 82 + }, + { + "note": "first_all_subset_66_witness", + "slots": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ], + "odd_dirt_masks": [ + 1, + 2, + 4, + 8, + 15, + 16, + 19, + 21, + 22, + 23, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "odd_dirt_count": 16, + "legal_under_dirty_cancellation": false, + "all_R": 66, + "repair_R": 82 + } + ], + "distinct6": { + "covering_sets": 583296, + "all_subset": { + "attainable_R": [ + 66, + 72 + ], + "histogram": { + "66": 97216, + "72": 486080 + }, + "min_R": 66, + "first_witnesses": { + "72": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16 + ], + "66": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + } + }, + "even_subset": { + "attainable_R": [ + 82, + 88 + ], + "histogram": { + "82": 97216, + "88": 486080 + }, + "min_R": 82, + "first_witnesses": { + "88": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16 + ], + "82": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + } + }, + "parity_repair": { + "attainable_R": [ + 82, + 88 + ], + "histogram": { + "82": 97216, + "88": 486080 + }, + "min_R": 82, + "first_witnesses": { + "88": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16 + ], + "82": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + }, + "matches_even_on_covering": 583296 + } + }, + "one_repeat_all_subset": { + "kind": "one_repeat_on_standard_basis", + "covering_walks": 1680, + "attainable_R": [ + 80 + ], + "histogram": { + "80": 1680 + }, + "min_R": 80, + "first_witness": [ + 0, + 1, + 0, + 2, + 4, + 8, + 16 + ] + }, + "one_repeat_parity_repair": { + "kind": "one_repeat_on_standard_basis", + "covering_walks": 1680, + "attainable_R": [ + 96 + ], + "histogram": { + "96": 1680 + }, + "min_R": 96, + "first_witness": [ + 0, + 1, + 0, + 2, + 4, + 8, + 16 + ] + }, + "leave_alone": { + "through": 2686, + "includes": [ + 2593, + 2643, + 2677, + 2686 + ], + "pending_skeptical_not_edited": "cursor/odd-kernel-query-pair-60b9@c319093b", + "deferred": [ + "mutable-source-7q-shared-xor soft-overlap #2643", + "host screens" + ] + } +} diff --git a/research/cheaper-readout-7q-obstruction/NOTICE.md b/research/cheaper-readout-7q-obstruction/NOTICE.md new file mode 100644 index 0000000000..43c8d6cecb --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/NOTICE.md @@ -0,0 +1,23 @@ +# 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 spectrum 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` and OQ1 + answered here; not edited. +- Live pin: `research/mutable-source-shear-cost/CERTIFICATE.json`. + +Prepared by Wentao Li (VictorLiwentao, @Is__Victor) with substantial AI +assistance. diff --git a/research/cheaper-readout-7q-obstruction/PROOF.md b/research/cheaper-readout-7q-obstruction/PROOF.md new file mode 100644 index 0000000000..67c7f7535b --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/PROOF.md @@ -0,0 +1,102 @@ +# Odd-cardinality cheaper readout does not undercut tariff 436 after dirty-parity repair + +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 1 of +[#2686](https://github.com/CrocSwap/integer-mult-bounds/pull/2686) +(`research/seven-query-r-floor`): whether a readout alphabet strictly cheaper +than even-subset connector-state combinations can reach `R ≤ 78` at `Q = 7` +with `X = 6`. + +No new kappa is claimed. Leave-alone packages through #2686 are not edited. + +## 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-7 walk are slots +`(s_0,…,s_6)` with `s_0 = 0`. The **even-subset** score is + +```text +R_even = Σ_{m=1}^{31} min{|T| : T ⊂ {0,…,6}, |T| even, ⊕_{i∈T} s_i = m}. +``` + +[#2686](https://github.com/CrocSwap/integer-mult-bounds/pull/2686) proves +`R_even ≥ 82` on every covering Q=7 walk (sharp), so at `X = 6` the abstract +tariff `(b,a,x)=(38,2,2)` is at least `442 > 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,…,6}, |T|≥1, ⊕_{i∈T} s_i = m}. +``` + +**Census (distinct nonzero 6-sets).** Covering sets: `583296`. Attainable +totals `R_all ∈ {66, 72}` with histogram `97216 / 486080`. Minimum `66`. + +**One-repeat spanning layer (GL basis).** All `1680` covering one-repeat walks +have `R_all = 80` only. + +The credited champion `(0,1,2,6,12,24,16)` attains `R_all = 66` with path-local +`X = 6`. The hypothetical tariff `38·7 + 2·66 + 2·6 = 410` is **strictly below** +the six-query endpoint `436`. + +## 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: the minimum all-subset schedules on the champion and on the first +`R_all = 66` witness each leave a nonempty set of masks with odd live-connector +parity. + +## Priced repair: zero-slot parity completion + +Every Q=7 restored walk 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 `583296` covering distinct-6 sets, `R_repair` matches +`R_even` exactly (spectrum `{82,88}`). On the one-repeat basis layer, +`R_repair = 96` only (`1680` walks), matching the even-subset repeat floor. + +## Tariff consequence + +After dirty-parity repair, every covering Q=7 schedule still has `R ≥ 82`. At +the [#2643](https://github.com/CrocSwap/integer-mult-bounds/pull/2643) XOR floor +`X = 6`, tariff `≥ 442 > 436`. The free all-subset undercut is not realizable +under the PR1898 dirty-connector contract; the minimal priced repair returns to +the even-subset floor already proved in #2686. + +## Scope limits + +- This prices one natural odd-cardinality alphabet (all-subset) plus zero-slot + parity repair. Multi-connector alphabets, output-mixing readouts, and host + screens are outside. +- Shared non-path XOR schedules remain deferred (soft-overlap with #2643). +- Leave-alone through #2686 (including #2593, #2643, #2677) and pending + `odd-kernel-query-pair` are not edited. +- 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∈{82,88}` | — | +| #2686 | Even-subset `R≥82` at `Q=7` (OQ1: cheaper alphabets?) | — | +| **This** | — | **All-subset would hit R=66/tariff 410, but dirty-parity repair collapses to R≥82/tariff 442** | diff --git a/research/cheaper-readout-7q-obstruction/README.md b/research/cheaper-readout-7q-obstruction/README.md new file mode 100644 index 0000000000..fc7650c97e --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/README.md @@ -0,0 +1,79 @@ +# Odd-cardinality cheaper readout cannot undercut 436 after dirty-parity repair + +**Scoped obstruction / priced alphabet; no new kappa.** Answers open question 1 +of [#2686](https://github.com/CrocSwap/integer-mult-bounds/pull/2686) +(`research/seven-query-r-floor`) in the five-source common-B mutable-source +alphabet of +[PR1898](https://github.com/CrocSwap/integer-mult-bounds/pull/1898). + +Define the natural **all-subset** (odd-cardinality allowed) connector-state +readout score on Q=7 walks. Free of dirty-cancellation, it reaches **R=66** +(spectrum `{66,72}` on distinct-6 covers; one-repeat layer `R=80`) and would +tariff **410 < 436** at `X=6`. But odd live-connector `R_m` counts leave +arbitrary connector dirt on those outputs. The minimal **zero-slot parity +repair** restores even live-connector parity and collapses every covering +schedule to even-subset cost **R≥82** (tariff **442**), matching #2686. + +| Readout model | Distinct-6 min R | One-repeat R | Tariff at X=6 | Undercuts 436? | +|---|---:|---:|---:|---| +| All-subset (free, illegal dirt) | **66** | 80 | **410** | yes (not legal) | +| Even-subset (#2686) | 82 | 96 | 442 | no | +| Parity-repaired odd sets | **82** | 96 | **442** | **no** | + +## Reproduce + +Python **3.12**, standard library only, from the repository root: + +```sh +python3.12 -I -B research/cheaper-readout-7q-obstruction/verify.py +python3.12 -I -O -B research/cheaper-readout-7q-obstruction/verify.py +python3.12 -I -B research/cheaper-readout-7q-obstruction/independent.py +python3.12 -I -B research/cheaper-readout-7q-obstruction/test_package.py +python3.12 -B scripts/research_package.py --package research/cheaper-readout-7q-obstruction +``` + +Expected: + +```text +PASS_CHEAPER_READOUT_7Q_OBSTRUCTION all_subset_min_R=66 parity_repair_min_R=82 hypothetical_tariff=410 repair_tariff=442 no_undercut_after_dirty_parity_repair answers_7qr_oq1 no_new_kappa +PASS_INDEPENDENT_CHEAPER_READOUT_7Q covering=583296 all_min=66 repair_min=82 tariff_free=410 tariff_repair=442 answers_7qr_oq1 no_new_kappa +PASS_CHEAPER_READOUT_7Q_PACKAGE_TESTS groups=6 +PASS_REGISTERED_RESEARCH_PACKAGE research/cheaper-readout-7q-obstruction outcome=completed +``` + +Default verify is read-only and compares a fresh rebuild to +[CERTIFICATE.json](CERTIFICATE.json). Use `--write` only to regenerate that +receipt. Admission uses `need()` (not `assert`); `-O` also passes. + +## Scope and overlap + +Base commit `0b1cccf86e2f5132ed286a26ef0a681a495740ea`. Direct predecessors: +PR1898, #2643 (XOR floor), #2677 / path-lowered 789q invoice, #2686 (even-subset +R floor; OQ1). Leave-alone through #2686 including #2593, #2643, #2677 is +respected; pending `cursor/odd-kernel-query-pair-60b9@c319093b` is not edited. +Deferred shared-XOR soft-overlap with #2643 and host screens are not opened. + +## Open next questions + +1. Can a **multi-connector** readout alphabet (two live connectors, or a priced + shadow snapshot) reach `R≤78` at `Q=7` with `X=6` after a complete dirty bill? + Why it matters: the remaining cheaper-alphabet direction after odd-cardinality + collapse. First step: fix one dual-connector interface, charge both walks and + dirt cancellation, and census length-7 covers. Blocked by: no dual-connector + fixture is priced here. +2. Does the same dirty-parity collapse apply at eight queries for all-subset + versus even-subset floors? + Why it matters: extends the unequal-price handoff beyond Q=7. First step: + reuse the repair lemma on length-8 slot lists and compare to #2677's R≥74 + distinct-slot floor. Blocked by: larger search. + +## Credit + +Credit **Arham Tahir / PR1898** (alphabet, endpoint tariff), **ywz65 / PR2455**, +**PR1370**, the fork **789q invoice** / **#2677**, open **#2643** and **#2686** +(even-subset R floor; OQ1 answered here; not edited), **TennisBowling / PR1524**, +**Ross Richardson / PR943**, and the retained mutable-source lineage. Live input +pin: `research/mutable-source-shear-cost/CERTIFICATE.json`. Prepared by Wentao Li +([VictorLiwentao](https://github.com/VictorLiwentao), +[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance. +Apache-2.0. No independent human review or multiplication theorem is claimed. diff --git a/research/cheaper-readout-7q-obstruction/SOURCES.json b/research/cheaper-readout-7q-obstruction/SOURCES.json new file mode 100644 index 0000000000..719b378cbd --- /dev/null +++ b/research/cheaper-readout-7q-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/cheaper-readout-7q-obstruction/TASK.json b/research/cheaper-readout-7q-obstruction/TASK.json new file mode 100644 index 0000000000..24743ca6d4 --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/TASK.json @@ -0,0 +1,96 @@ +{ + "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": "Price the natural all-subset (odd-cardinality) connector-state readout at Q=7 in the PR1898 alphabet: show free R=66 would tariff 410<436 at X=6, prove dirty-parity obstruction, and show zero-slot parity repair collapses to even-subset R>=82 (tariff 442), answering #2686 OQ1 for this alphabet.", + "scope_change_reason": "The drawn connector-alphabet card is redirected to the explicit cheaper-than-even-subset readout open question left by #2686 on the #1898 lineage, which is the nearest priced obstruction outside leave-alone tooling hosts and the hard leave-alones through #2686.", + "bottleneck_link": "A priced odd-cardinality readout alphabet decides whether seven queries can undercut the six-query endpoint by cheaper readouts at the #2643 XOR floor.", + "budget_minutes": 60, + "stop_rule": "Stop after all-subset census, dirty-parity obstruction, parity-repair collapse to even-subset, tariff consequence, package tests; no multi-connector search and no shared-XOR reopening.", + "outcome": "completed", + "evidence": "CERTIFICATE.json distinct-6 histograms all{66:97216,72:486080} even/repair{82:97216,88:486080} with repair matching even on all covering sets; one-repeat all R=80 and repair R=96; champion odd-dirt masks; 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 readout alphabet reach R<=78 at Q=7 with X=6 after a complete dirty bill?", + "why_it_matters": "Remaining cheaper-alphabet direction after odd-cardinality collapse.", + "first_step": "Fix one dual-connector interface, charge both walks and dirt cancellation, census length-7 covers.", + "blocked_by": "No dual-connector fixture is priced here." + }, + { + "question": "Does the same dirty-parity collapse apply at eight queries for all-subset versus even-subset floors?", + "why_it_matters": "Extends the unequal-price handoff beyond Q=7.", + "first_step": "Reuse the repair lemma on length-8 slot lists and compare to the distinct-slot R>=74 floor.", + "blocked_by": "Larger search." + } + ], + "predecessors": [ + { + "pr": 1898, + "credit": "Arham Tahir; minimum-query endpoint and abstract tariff fixture" + }, + { + "pr": 2686, + "credit": "Wentao Li; even-subset R floor and OQ1 answered here" + }, + { + "pr": 2643, + "credit": "Wentao Li; seven-query XOR floor X>=6" + }, + { + "pr": 2677, + "credit": "Wentao Li; path-lowered 7-9Q invoices" + }, + { + "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/cheaper-readout-7q-obstruction/VERIFY.json b/research/cheaper-readout-7q-obstruction/VERIFY.json new file mode 100644 index 0000000000..acfe41c949 --- /dev/null +++ b/research/cheaper-readout-7q-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": 240, + "checks": "All-subset/even/repair distinct-6 census, one-repeat layers, dirty obstruction, champion, certificate match, source pins" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 240, + "checks": "Same admission under PYTHONOPTIMIZE via need()" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 240, + "checks": "Separate triple census, repeat layers, champion odd-dirt, tariff arithmetic" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 480, + "checks": "Corruption rejection, duplicate JSON keys, -O controls, independent replay" + } + ] +} diff --git a/research/cheaper-readout-7q-obstruction/independent.py b/research/cheaper-readout-7q-obstruction/independent.py new file mode 100644 index 0000000000..8852c267e6 --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/independent.py @@ -0,0 +1,184 @@ +#!/usr/bin/env python3 +"""Independent all-subset / parity-repair census at Q=7. + +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 +from collections import Counter +from itertools import combinations, permutations +from pathlib import Path + +HERE = Path(__file__).resolve().parent +CERT_PATH = HERE / "CERTIFICATE.json" +CHAMPION = (0, 1, 2, 6, 12, 24, 16) +BASIS = (1, 2, 4, 8, 16) + + +def fail(message): + raise SystemExit(f"FAIL_INDEPENDENT: {message}") + + +def scores(slots): + 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_even[m] >= 99 for m in range(1, 32)): + return None + return sum(best_all[1:]), sum(best_even[1:]), sum(best_repair[1:]) + + +def all_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 + if found is None: + fail(f"uncovered {mask}") + reads[mask] = found + return reads + + +def tariff(q, r, x): + return (28 * q + r) + (9 * q) + x + (q + r + x) + + +def distinct6(): + ha, he, hr = Counter(), Counter(), Counter() + covering = 0 + match = 0 + for nonzero in combinations(range(1, 32), 6): + got = scores((0,) + nonzero) + 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 + if covering != 583296: + fail(f"covering {covering}") + if dict(ha) != {66: 97216, 72: 486080}: + fail(f"all hist {dict(ha)}") + if dict(he) != {82: 97216, 88: 486080}: + fail(f"even hist {dict(he)}") + if dict(hr) != {82: 97216, 88: 486080}: + fail(f"repair hist {dict(hr)}") + if match != covering: + fail(f"repair/even mismatch count {match}") + return covering + + +def one_repeat(kind): + hist = Counter() + covering = 0 + + def take(slots): + nonlocal covering + if slots[-1] == 0 or any(slots[i] == slots[i + 1] for i in range(6)): + return + got = scores(tuple(slots)) + if got is None: + return + a, e, r = got + total = a if kind == "all" else r + covering += 1 + hist[total] += 1 + + for j in range(1, 6): + rest = [i for i in range(1, 7) if i != j] + for perm in permutations(BASIS): + slots = [0] * 7 + slots[j] = 0 + for pos, val in zip(rest, perm): + slots[pos] = val + take(slots) + for dbl in range(5): + others = [BASIS[i] for i in range(5) if i != dbl] + for p1, p2 in combinations(range(1, 7), 2): + rest = [i for i in range(1, 7) if i not in (p1, p2)] + for perm in permutations(others): + slots = [0] * 7 + slots[p1] = slots[p2] = BASIS[dbl] + for pos, val in zip(rest, perm): + slots[pos] = val + take(slots) + return covering, dict(hist) + + +def main(): + cert = json.loads(CERT_PATH.read_text(encoding="utf-8")) + covering = distinct6() + cov_all, hist_all = one_repeat("all") + cov_rep, hist_rep = one_repeat("repair") + if cov_all != 1680 or hist_all != {80: 1680}: + fail(f"repeat all {cov_all} {hist_all}") + if cov_rep != 1680 or hist_rep != {96: 1680}: + fail(f"repeat repair {cov_rep} {hist_rep}") + + got = scores(CHAMPION) + if got != (66, 82, 82): + fail(f"champion scores {got}") + odds = [m for m, subset in all_reads(CHAMPION).items() if len(subset) % 2] + if not odds: + fail("champion all-subset schedule has no odd dirt") + if tariff(7, 66, 6) != 410 or tariff(7, 82, 6) != 442: + fail("tariff") + if not ( + cert["claim"]["all_subset_min_R"] == 66 + and cert["claim"]["parity_repair_min_R"] == 82 + and cert["claim"]["undercuts_436_after_parity_repair"] is False + ): + fail("certificate claim drift") + + print( + "PASS_INDEPENDENT_CHEAPER_READOUT_7Q", + f"covering={covering}", + "all_min=66", + "repair_min=82", + "tariff_free=410", + "tariff_repair=442", + "answers_7qr_oq1", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/cheaper-readout-7q-obstruction/model.py b/research/cheaper-readout-7q-obstruction/model.py new file mode 100644 index 0000000000..32e4f208c4 --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/model.py @@ -0,0 +1,319 @@ +"""Odd-cardinality / all-subset readout vs dirty-parity repair at seven queries. + +Answers open question 1 of the seven-query R-floor package (#2686): whether a +readout alphabet strictly cheaper than even-subset connector-state combinations +can reach R<=78 at Q=7 with X=6. Self-contained relative to PR1898 / #2643 / +#2686. Prepared by Wentao Li with substantial AI assistance. Apache-2.0. +""" +from __future__ import annotations + +from collections import Counter +from itertools import combinations, permutations + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +# Expected spectra (single-pass distinct-6 census; one-repeat GL basis). +EXPECTED = { + "distinct6_covering": 583296, + "all_subset_attainable_R": [66, 72], + "all_subset_histogram": {"66": 97216, "72": 486080}, + "all_subset_min_R": 66, + "even_subset_attainable_R": [82, 88], + "even_subset_histogram": {"82": 97216, "88": 486080}, + "even_subset_min_R": 82, + "parity_repair_attainable_R": [82, 88], + "parity_repair_histogram": {"82": 97216, "88": 486080}, + "parity_repair_min_R": 82, + "one_repeat_all_subset_R": 80, + "one_repeat_all_subset_covering": 1680, + "one_repeat_parity_repair_R": 96, + "one_repeat_parity_repair_covering": 1680, + "champion_slots": (0, 1, 2, 6, 12, 24, 16), + "champion_all_R": 66, + "champion_even_R": 82, + "champion_repair_R": 82, + "endpoint_tariff_Q6": 436, + "hypothetical_all_subset_tariff_X6": 410, + "parity_repair_tariff_X6": 442, +} + + +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 mask_best_sizes(slots): + """Per-mask min sizes: all-subset, even-subset, and zero-slot parity repair.""" + need(type(slots) is tuple and slots and slots[0] == 0, "slots must start at 0") + 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: + # Odd live-connector parity: repair at a 0-valued slot (adjoin or drop). + 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 + return { + "all": best_all, + "even": best_even, + "repair": best_repair, + "zero_idxs": zero_idxs, + } + + +def total_from_best(best): + if any(best[mask] >= 99 for mask in range(1, 32)): + return None + return sum(best[1:]) + + +def min_all_subset_R(slots): + return total_from_best(mask_best_sizes(slots)["all"]) + + +def min_even_subset_R(slots): + return total_from_best(mask_best_sizes(slots)["even"]) + + +def min_parity_repair_R(slots): + """Minimum dirty-canceling cost with odd sets repaired at a 0-valued slot. + + An odd realizing set S either contains a 0-valued slot index (drop one: + cost |S|-1, same XOR) or adjoins one 0-valued slot readout (cost |S|+1). + Both repairs restore even live-connector parity for arbitrary connector dirt. + """ + return total_from_best(mask_best_sizes(slots)["repair"]) + + +def all_subset_reads(slots): + """Minimum-cardinality (any parity) realizing subsets for each nonzero mask.""" + 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"mask {mask} uncovered under all-subset") + reads[mask] = found + return reads + + +def dirt_parity_by_mask(reads): + """Live-connector dirt parity contributed to each output by a readout schedule.""" + return {mask: len(subset) % 2 for mask, subset in reads.items()} + + +def odd_dirt_masks(reads): + return sorted(mask for mask, parity in dirt_parity_by_mask(reads).items() if parity) + + +def valid_walk_slots(slots): + if type(slots) is not tuple or len(slots) != 7 or slots[0] != 0: + return False + if slots[-1] == 0: + return False + if any(slots[i] == slots[i + 1] for i in range(6)): + return False + return True + + +def path_X(closed): + total = 0 + for a, b in zip(closed, closed[1:]): + delta = a ^ b + need(delta != 0, "zero query edge") + total += 2 * (delta.bit_count() - 1) + return total + + +def enumerate_distinct6_triple_spectrum(): + """One pass: all-subset, even-subset, and parity-repair R on distinct-6 covers.""" + hist_all = Counter() + hist_even = Counter() + hist_repair = Counter() + covering = 0 + witnesses = {"all": {}, "even": {}, "repair": {}} + repair_matches_even = 0 + for nonzero in combinations(range(1, 32), 6): + slots = (0,) + nonzero + info = mask_best_sizes(slots) + if any(info["even"][m] >= 99 for m in range(1, 32)): + continue + all_r = sum(info["all"][1:]) + even_r = sum(info["even"][1:]) + repair_r = sum(info["repair"][1:]) + covering += 1 + hist_all[all_r] += 1 + hist_even[even_r] += 1 + hist_repair[repair_r] += 1 + if repair_r == even_r: + repair_matches_even += 1 + witnesses["all"].setdefault(all_r, slots) + witnesses["even"].setdefault(even_r, slots) + witnesses["repair"].setdefault(repair_r, slots) + return { + "covering_sets": covering, + "all_subset": { + "attainable_R": sorted(hist_all), + "histogram": {str(r): hist_all[r] for r in sorted(hist_all)}, + "min_R": min(hist_all) if hist_all else None, + "first_witnesses": {str(r): list(slots) for r, slots in witnesses["all"].items()}, + }, + "even_subset": { + "attainable_R": sorted(hist_even), + "histogram": {str(r): hist_even[r] for r in sorted(hist_even)}, + "min_R": min(hist_even) if hist_even else None, + "first_witnesses": {str(r): list(slots) for r, slots in witnesses["even"].items()}, + }, + "parity_repair": { + "attainable_R": sorted(hist_repair), + "histogram": {str(r): hist_repair[r] for r in sorted(hist_repair)}, + "min_R": min(hist_repair) if hist_repair else None, + "first_witnesses": { + str(r): list(slots) for r, slots in witnesses["repair"].items() + }, + "matches_even_on_covering": repair_matches_even, + }, + } + + +def one_repeat_basis_census(score): + """Valid Q=7 one-repeat walks on the standard basis, scored by ``score``.""" + labels = (1, 2, 4, 8, 16) + hist = Counter() + covering = 0 + best = None + witness = None + + for j in range(1, 6): + rest = [i for i in range(1, 7) if i != j] + for perm in permutations(labels): + slots = [0] * 7 + slots[j] = 0 + for pos, val in zip(rest, perm): + slots[pos] = val + slots_t = tuple(slots) + if not valid_walk_slots(slots_t): + continue + total = score(slots_t) + if total is None: + continue + covering += 1 + hist[total] += 1 + if best is None or total < best: + best = total + witness = slots_t + + for dbl_idx in range(5): + others = [labels[i] for i in range(5) if i != dbl_idx] + for p1, p2 in combinations(range(1, 7), 2): + rest_pos = [i for i in range(1, 7) if i not in (p1, p2)] + for perm in permutations(others): + slots = [0] * 7 + slots[p1] = slots[p2] = labels[dbl_idx] + for pos, val in zip(rest_pos, perm): + slots[pos] = val + slots_t = tuple(slots) + if not valid_walk_slots(slots_t): + continue + total = score(slots_t) + if total is None: + continue + covering += 1 + hist[total] += 1 + if best is None or total < best: + best = total + witness = slots_t + + attainable = sorted(hist) + return { + "kind": "one_repeat_on_standard_basis", + "covering_walks": covering, + "attainable_R": attainable, + "histogram": {str(r): hist[r] for r in attainable}, + "min_R": best, + "first_witness": list(witness) if witness is not None else None, + } + + +def champion_analysis(): + slots = EXPECTED["champion_slots"] + closed = slots + (0,) + reads = all_subset_reads(slots) + odd_masks = odd_dirt_masks(reads) + return { + "slots": list(slots), + "path_X": path_X(closed), + "all_subset_R": min_all_subset_R(slots), + "even_subset_R": min_even_subset_R(slots), + "parity_repair_R": min_parity_repair_R(slots), + "all_subset_odd_dirt_masks": odd_masks, + "all_subset_odd_dirt_count": len(odd_masks), + "hypothetical_tariff_all_X6": tariff_qrx(7, min_all_subset_R(slots), 6), + "tariff_repair_X6": tariff_qrx(7, min_parity_repair_R(slots), 6), + "endpoint_Q6": EXPECTED["endpoint_tariff_Q6"], + } + + +def dirt_obstruction_examples(): + """Finite checks: odd live-connector R_m parity leaves connector dirt on y_m.""" + examples = [] + # Abstract F2 dirt: each live R_m flips output dirt; legal iff even. + for slots, note in ( + (EXPECTED["champion_slots"], "champion_all_subset"), + ((0, 1, 2, 4, 8, 15, 16), "first_all_subset_66_witness"), + ): + reads = all_subset_reads(slots) + odds = odd_dirt_masks(reads) + examples.append( + { + "note": note, + "slots": list(slots), + "odd_dirt_masks": odds, + "odd_dirt_count": len(odds), + "legal_under_dirty_cancellation": len(odds) == 0, + "all_R": min_all_subset_R(slots), + "repair_R": min_parity_repair_R(slots), + } + ) + need(all(ex["odd_dirt_count"] > 0 for ex in examples), "expected odd dirt") + need(all(not ex["legal_under_dirty_cancellation"] for ex in examples), "illegal") + return examples + + +# Credited path-lowered champion from the 789q / #2643 / #2686 lineage. +CHAMPION_7 = (0, 1, 2, 6, 12, 24, 16, 0) diff --git a/research/cheaper-readout-7q-obstruction/test_package.py b/research/cheaper-readout-7q-obstruction/test_package.py new file mode 100644 index 0000000000..f1be07ba0b --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/test_package.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Package fault controls for cheaper-readout 7q 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 = "cheaper-readout-7q-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_CHEAPER_READOUT_7Q_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_CHEAPER_READOUT_7Q_OBSTRUCTION" in proc.stdout, proc.stdout) + + # 3) Certificate claim corruption fails before/without accepting. + 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"] = 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 (fails at pin check). + 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_CHEAPER_READOUT_7Q" 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_CHEAPER_READOUT_7Q_PACKAGE_TESTS groups=6") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/cheaper-readout-7q-obstruction/verify.py b/research/cheaper-readout-7q-obstruction/verify.py new file mode 100644 index 0000000000..b4fcef9a99 --- /dev/null +++ b/research/cheaper-readout-7q-obstruction/verify.py @@ -0,0 +1,253 @@ +#!/usr/bin/env python3 +"""Odd-cardinality cheaper readout obstruction at Q=7; 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_7, + EXPECTED, + champion_analysis, + dirt_obstruction_examples, + enumerate_distinct6_triple_spectrum, + min_all_subset_R, + min_even_subset_R, + min_parity_repair_R, + one_repeat_basis_census, + path_X, + 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"] == EXPECTED["all_subset_min_R"], "claim all min") + need(claim["parity_repair_min_R"] == EXPECTED["parity_repair_min_R"], "claim repair min") + need(claim["even_subset_min_R"] == EXPECTED["even_subset_min_R"], "claim even min") + 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["no_new_kappa"] is True, "kappa") + need(claim["answers_7qr_oq1"] is True, "oq1 flag") + + +def build_certificate(): + 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["path_X"] == 6, "champion path X") + need(champ["all_subset_odd_dirt_count"] > 0, "champion must show odd dirt") + need( + champ["hypothetical_tariff_all_X6"] == EXPECTED["hypothetical_all_subset_tariff_X6"], + "hypothetical tariff", + ) + need(champ["tariff_repair_X6"] == EXPECTED["parity_repair_tariff_X6"], "repair tariff") + need( + champ["hypothetical_tariff_all_X6"] < EXPECTED["endpoint_tariff_Q6"], + "free all-subset would undercut", + ) + need( + champ["tariff_repair_X6"] > EXPECTED["endpoint_tariff_Q6"], + "repair must not undercut", + ) + + dirt = dirt_obstruction_examples() + need(len(dirt) >= 2, "dirt examples") + + # Closed champion identity for path_X only (readout alphabet change is the claim). + need(path_X(CHAMPION_7) == 6, "closed champion X") + need(min_all_subset_R(CHAMPION_7[:-1]) == 66, "closed all") + need(min_even_subset_R(CHAMPION_7[:-1]) == 82, "closed even") + need(min_parity_repair_R(CHAMPION_7[:-1]) == 82, "closed repair") + need( + tariff_qrx(7, 66, 6) == 410 and tariff_qrx(7, 82, 6) == 442, + "tariff arithmetic", + ) + + distinct = enumerate_distinct6_triple_spectrum() + need(distinct["covering_sets"] == EXPECTED["distinct6_covering"], "covering count") + need( + distinct["all_subset"]["attainable_R"] == EXPECTED["all_subset_attainable_R"], + "all spectrum", + ) + need( + distinct["all_subset"]["histogram"] == EXPECTED["all_subset_histogram"], + "all histogram", + ) + 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 histogram", + ) + 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 histogram", + ) + need(distinct["parity_repair"]["min_R"] == EXPECTED["parity_repair_min_R"], "repair min") + need( + distinct["parity_repair"]["matches_even_on_covering"] == distinct["covering_sets"], + "repair must match even on every covering distinct-6 set", + ) + + repeats_all = one_repeat_basis_census(min_all_subset_R) + need(repeats_all["min_R"] == EXPECTED["one_repeat_all_subset_R"], "repeat all min") + need( + repeats_all["covering_walks"] == EXPECTED["one_repeat_all_subset_covering"], + "repeat all covering", + ) + need(repeats_all["attainable_R"] == [80], "repeat all spectrum") + + repeats_repair = one_repeat_basis_census(min_parity_repair_R) + need( + repeats_repair["min_R"] == EXPECTED["one_repeat_parity_repair_R"], + "repeat repair min", + ) + need( + repeats_repair["covering_walks"] == EXPECTED["one_repeat_parity_repair_covering"], + "repeat repair covering", + ) + need(repeats_repair["attainable_R"] == [96], "repeat repair spectrum") + + return { + "schema_version": 1, + "status": "PASS_CHEAPER_READOUT_7Q_OBSTRUCTION", + "scope": ( + "Five-source common-B mutable-source Q/R/X alphabet (PR1898). " + "Priced odd-cardinality (all-subset) connector-state readout at Q=7 " + "versus dirty-parity repair back to even live-connector schedules. " + "Answers #2686 OQ1 for this alphabet." + ), + "claim": { + "Q": 7, + "all_subset_min_R": 66, + "even_subset_min_R": 82, + "parity_repair_min_R": 82, + "one_repeat_all_subset_min_R": 80, + "one_repeat_parity_repair_min_R": 96, + "undercuts_436_if_all_subset_free": True, + "undercuts_436_after_parity_repair": False, + "hypothetical_all_subset_tariff_at_X6": 410, + "parity_repair_tariff_at_X6": 442, + "endpoint_Q6_tariff": 436, + "answers_7qr_oq1": True, + "oq1_answer": ( + "Free all-subset (odd-cardinality) readout reaches R=66 and would " + "tariff 410<436 at X=6, but odd live-connector R_m parity leaves " + "arbitrary connector dirt on those outputs. Minimal zero-slot " + "parity repair collapses every covering schedule to even-subset " + "cost R>=82 (tariff 442), so this cheaper alphabet does not undercut " + "the six-query endpoint under the PR1898 dirty-connector contract." + ), + "no_new_kappa": True, + }, + "champion": champ, + "dirt_obstruction_examples": dirt, + "distinct6": distinct, + "one_repeat_all_subset": repeats_all, + "one_repeat_parity_repair": repeats_repair, + "leave_alone": { + "through": 2686, + "includes": [2593, 2643, 2677, 2686], + "pending_skeptical_not_edited": "cursor/odd-kernel-query-pair-60b9@c319093b", + "deferred": [ + "mutable-source-7q-shared-xor soft-overlap #2643", + "host screens", + ], + }, + } + + +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() + cert_existing = None + if CERT_PATH.is_file(): + cert_existing = load_json_reject_duplicates(CERT_PATH) + if not args.write: + check_claim_constants(cert_existing) + + built = build_certificate() + if args.write: + CERT_PATH.write_text(json.dumps(built, indent=2) + "\n", encoding="utf-8") + print("WROTE_CERTIFICATE", CERT_PATH) + else: + need(cert_existing is not None, "missing CERTIFICATE.json") + need(built == cert_existing, "fresh rebuild differs from CERTIFICATE.json") + + print( + "PASS_CHEAPER_READOUT_7Q_OBSTRUCTION", + "all_subset_min_R=66", + "parity_repair_min_R=82", + "hypothetical_tariff=410", + "repair_tariff=442", + "no_undercut_after_dirty_parity_repair", + "answers_7qr_oq1", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())