diff --git a/research/multi-connector-7q-obstruction/CERTIFICATE.json b/research/multi-connector-7q-obstruction/CERTIFICATE.json new file mode 100644 index 0000000000..38659768a7 --- /dev/null +++ b/research/multi-connector-7q-obstruction/CERTIFICATE.json @@ -0,0 +1,312 @@ +{ + "schema_version": 1, + "status": "PASS_MULTI_CONNECTOR_7Q_OBSTRUCTION", + "scope": "Five-source common-B mutable-source Q/R/X alphabet (PR1898). Priced multi-connector readout at Q=7: correlated dirty shadow snapshot, independent dual same-walk, and illegal clean-shadow counterfactual. Answers #2715 OQ1 (cr7q multi-connector).", + "claim": { + "Q": 7, + "legal_multi_connector_min_R": 82, + "dirty_shadow_min_R": 82, + "dual_independent_min_R": 82, + "even_subset_min_R": 82, + "clean_shadow_counterfactual_min_R": 71, + "one_repeat_legal_min_R": 96, + "one_repeat_clean_counterfactual_min_R": 88, + "undercuts_436_if_clean_shadow_free": true, + "undercuts_436_after_complete_dirty_bill": false, + "legal_tariff_at_X6": 442, + "hypothetical_clean_tariff_at_X6": 420, + "endpoint_Q6_tariff": 436, + "answers_cr7q_oq1": true, + "oq1_answer": "A priced shadow snapshot with inherited correlated dirt collapses to even-subset cost R>=82 via sym-diff with the snapshot index (spectrum {82,88} on all 583296 covering distinct-6 sets). Two independently dirty connectors on the same walk likewise cannot beat R=82: dual R is computed as \u03a3_m min_a (e[a]+e[a\u2295m]) and the even-subset triangle inequality is verified on every covering set (matches_even=triangle_holds=583296). A dirt-free shadow would reach R=71 and tariff 420<436, but cannot scrub inherited connector dirt under the PR1898 contract; shadow-only reads leave odd dirt. After a complete dirty bill, legal multi-connector alphabets stay at tariff >=442 and do not undercut the six-query endpoint 436.", + "no_new_kappa": true + }, + "champion": { + "slots": [ + 0, + 1, + 2, + 6, + 12, + 24, + 16 + ], + "path_X": 6, + "even_R": 82, + "dirty_shadow_R_by_k": [ + 82, + 82, + 82, + 82, + 82, + 82, + 82 + ], + "dirty_shadow_min_R": 82, + "dual_independent_R": 82, + "clean_shadow_R_by_k": [ + 82, + 71, + 77, + 77, + 77, + 77, + 77 + ], + "clean_shadow_min_R": 71, + "clean_best_k": 1, + "legal_tariff_X6": 442, + "hypothetical_clean_tariff_X6": 420, + "endpoint_Q6": 436, + "symdiff_checked_at_k1": 64 + }, + "clean_shadow_dirt_examples": [ + { + "note": "champion_shadow_only_sigma", + "slots": [ + 0, + 1, + 2, + 6, + 12, + 24, + 16 + ], + "snapshot_index": 1, + "sigma": 1, + "mask": 1, + "primary_reads": 0, + "shadow_reads": 1, + "inherited_dirt_parity": 1, + "legal_under_correlated_dirt": false, + "clean_R": 71, + "dirty_R": 82 + }, + { + "note": "first_clean_71_witness_shadow_dirt", + "slots": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ], + "snapshot_index": 6, + "sigma": 16, + "mask": 16, + "primary_reads": 0, + "shadow_reads": 1, + "inherited_dirt_parity": 1, + "legal_under_correlated_dirt": false, + "clean_R": 71, + "dirty_R": 82 + } + ], + "distinct6": { + "covering_sets": 583296, + "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 + ] + } + }, + "dirty_shadow": { + "attainable_R": [ + 82, + 88 + ], + "histogram": { + "82": 97216, + "88": 486080 + }, + "min_R": 82, + "matches_even_on_covering": 583296, + "first_witnesses": { + "88": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16 + ], + "82": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + } + }, + "dual_independent": { + "attainable_R": [ + 82, + 88 + ], + "histogram": { + "82": 97216, + "88": 486080 + }, + "min_R": 82, + "matches_even_on_covering": 583296, + "triangle_holds_on_covering": 583296, + "first_witnesses": { + "88": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16 + ], + "82": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + } + }, + "clean_shadow_counterfactual": { + "attainable_R": [ + 71, + 80 + ], + "histogram": { + "71": 97216, + "80": 486080 + }, + "min_R": 71, + "first_witnesses": { + "80": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16 + ], + "71": [ + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + }, + "legal_under_dirty_contract": false + } + }, + "one_repeat_even": { + "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 + ] + }, + "one_repeat_dirty_shadow": { + "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 + ] + }, + "one_repeat_clean_shadow_counterfactual": { + "kind": "one_repeat_on_standard_basis", + "covering_walks": 1680, + "attainable_R": [ + 88 + ], + "histogram": { + "88": 1680 + }, + "min_R": 88, + "first_witness": [ + 0, + 1, + 0, + 2, + 4, + 8, + 16 + ] + }, + "leave_alone": { + "through": 2715, + "includes": [ + 2593, + 2643, + 2677, + 2686, + 2687, + 2715 + ], + "deferred": [ + "mutable-source-7q-shared-xor soft-overlap #2643", + "host screens" + ] + } +} diff --git a/research/multi-connector-7q-obstruction/NOTICE.md b/research/multi-connector-7q-obstruction/NOTICE.md new file mode 100644 index 0000000000..5385f6cfa2 --- /dev/null +++ b/research/multi-connector-7q-obstruction/NOTICE.md @@ -0,0 +1,24 @@ +# 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`; not edited. +- Open #2715 `research/cheaper-readout-7q-obstruction` — all-subset / + dirty-parity repair 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/multi-connector-7q-obstruction/PROOF.md b/research/multi-connector-7q-obstruction/PROOF.md new file mode 100644 index 0000000000..240d0ccd03 --- /dev/null +++ b/research/multi-connector-7q-obstruction/PROOF.md @@ -0,0 +1,115 @@ +# Multi-connector / priced-shadow readout cannot undercut tariff 436 at Q=7 + +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 +[#2715](https://github.com/CrocSwap/integer-mult-bounds/pull/2715) +(`research/cheaper-readout-7q-obstruction`): whether a **multi-connector** readout +alphabet (two live connectors, or a priced shadow snapshot) can reach `R ≤ 78` +at `Q = 7` with `X = 6` after a complete dirty bill. + +No new kappa is claimed. Leave-alone packages through #2715 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 + +```text +R_even = Σ_{m=1}^{31} min{|T| : T ⊂ {0,…,6}, |T| even, ⊕_{i∈T} s_i = m} +``` + +satisfies `R_even ≥ 82` on every covering Q=7 walk +([#2686](https://github.com/CrocSwap/integer-mult-bounds/pull/2686)), so at +`X = 6` the abstract tariff `(b,a,x)=(38,2,2)` is at least `442 > 436`. + +## Fixture A: priced shadow snapshot with inherited dirt + +At one index `k`, pay a full-row copy producing a second live connector holding +value `σ = s_k` and **the same dirt coefficient** as the primary (inherited +dirt). Readouts may use primary slots and/or one shadow read. Legal dirty +cancellation requires even total live-read parity across primary and shadow. + +**Lemma (sym-diff collapse).** Every legal dirty-shadow schedule has the same +cost as an even-subset schedule: an odd primary set `S` plus one shadow read +realizing `XOR(S) ⊕ σ` is equivalent, via `S Δ {k}`, to an even primary set of +cost `|S| ± 1` realizing the same mask. Even primary schedules are already +even-subset. Hence for every covering slot list and every `k`, + +```text +R_dirty-shadow(k) = R_even. +``` + +**Census.** On all `583296` covering distinct-6 sets, the min-over-`k` dirty +shadow total matches even-subset exactly (spectrum `{82,88}`). One-repeat basis +layer: `R = 96` only (`1680` walks). + +## Fixture B: two independently dirty connectors, same walk + +Admit a second connector with independent dirt on the same slot list. Each port +needs even live-read parity separately. Cost for mask `m` is + +```text +min_a (e[a] + e[a ⊕ m]), +``` + +where `e` is the even-subset per-mask table (with `e[0] = 0`). + +**Lemma (triangle).** Concatenating two even realizing sets (or taking their +symmetric difference on one connector) yields `e[m] ≤ e[a] + e[a ⊕ m]`. The +bound is achieved at `a = m`. Therefore the dual-independent total equals +`R_even` on every covering list: **no improvement**. + +**Census (machine-checked).** On all `583296` covering distinct-6 sets, +`dual_independent_from_even` computes `Σ_m min_a (e[a]+e[a⊕m])` directly +(not by copying `Σ e[m]`), the triangle inequality is verified on each even +table, and both match even-subset (spectrum `{82,88}`; +`matches_even_on_covering = triangle_holds_on_covering = 583296`). + +## Counterfactual: dirt-free shadow + +If the snapshot were somehow dirt-free while retaining `σ`, primary would still +need even parity while shadow reads would be free of dirt. Then + +```text +R_clean = min( e[m], 1 + e[m ⊕ σ], 1_{m=σ} ). +``` + +**Census.** Min-over-`k` totals attain `{71, 80}` (histogram `97216 / 486080`). +The champion `(0,1,2,6,12,24,16)` reaches `R_clean = 71` at `k=1`, hypothetical +tariff `38·7 + 2·71 + 2·6 = 420 < 436`. + +This counterfactual is **illegal** under the PR1898 arbitrary-dirt contract: a +copy of a dirty connector inherits dirt, and there is no dirt-only register with +which to scrub the shadow while keeping `σ`. Finite check: shadow-only readout +of mask `σ` has odd inherited-dirt parity on that output. + +## Tariff consequence + +After a complete dirty bill, every legal multi-connector / priced-shadow +schedule on covering Q=7 walks still has `R ≥ 82`. At the +[#2643](https://github.com/CrocSwap/integer-mult-bounds/pull/2643) XOR floor +`X = 6`, tariff `≥ 442 > 436`. Charging the snapshot copy `C` only increases +the bill. The free clean-shadow undercut is not realizable. + +## Scope limits + +- Fixes one dual-connector interface (correlated dirty shadow; independent dual + same-walk) and the illegal clean-shadow counterfactual. Other multi-row + alphabets with new query schedules or transfers are outside. +- Shared non-path XOR schedules remain deferred (soft-overlap with #2643). +- Host screens are deferred. +- Leave-alone through #2715 (including #2593, #2643, #2677, #2686, #2687) is + 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` | — | +| #2686 | Even-subset `R≥82` | — | +| #2715 | All-subset collapses under dirty-parity repair; OQ1 asks multi-connector | — | +| **This** | — | **Legal dirty shadow / dual same-walk stay at R≥82; clean shadow would hit 71 but fails dirty bill** | diff --git a/research/multi-connector-7q-obstruction/README.md b/research/multi-connector-7q-obstruction/README.md new file mode 100644 index 0000000000..dfebcc3746 --- /dev/null +++ b/research/multi-connector-7q-obstruction/README.md @@ -0,0 +1,76 @@ +# Multi-connector / priced-shadow readout obstruction at seven queries + +**Scoped obstruction / priced alphabet; no new kappa.** Answers open question 1 +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): can a +multi-connector readout alphabet reach `R≤78` at `Q=7` with `X=6` after a +complete dirty bill? + +| Alphabet | Distinct-6 min R | One-repeat R | Tariff at X=6 | Undercuts 436? | +|---|---:|---:|---:|---| +| Even-subset (#2686) | 82 | 96 | 442 | no | +| Dirty shadow (legal) | **82** | 96 | **442** | **no** | +| Dual indep. same-walk | **82** | 96 | **442** | **no** | +| Clean shadow (illegal) | **71** | 88 | **420** | yes (not legal) | + +Dirty shadow collapses to even-subset by sym-diff with the snapshot index. +Independent dual same-walk equals even-subset: each covering set computes +`Σ min_a (e[a]+e[a⊕m])` and checks the even-subset triangle inequality +(machine-checked on all `583296` covering lists). A dirt-free shadow would +undercut, but inherits dirt under PR1898 and fails the dirty bill. + +## Reproduction + +```sh +python3.12 -I -B research/multi-connector-7q-obstruction/verify.py +python3.12 -I -O -B research/multi-connector-7q-obstruction/verify.py +python3.12 -I -B research/multi-connector-7q-obstruction/independent.py +python3.12 -I -B research/multi-connector-7q-obstruction/test_package.py +python3.12 -B scripts/research_package.py --package research/multi-connector-7q-obstruction +``` + +Expected: + +```text +PASS_MULTI_CONNECTOR_7Q_OBSTRUCTION legal_min_R=82 ... answers_cr7q_oq1 no_new_kappa +PASS_INDEPENDENT_MULTI_CONNECTOR_7Q covering=583296 legal_min=82 ... answers_cr7q_oq1 no_new_kappa +PASS_MULTI_CONNECTOR_7Q_PACKAGE_TESTS groups=6 +PASS_REGISTERED_RESEARCH_PACKAGE research/multi-connector-7q-obstruction outcome=completed +``` + +Default verify is read-only. Admission uses `need()`; `-O` also passes. + +## Overlap + +Base commit `0b1cccf86e2f5132ed286a26ef0a681a495740ea`. Direct predecessors: +PR1898, #2643, #2677, #2686, #2715 (OQ1). Leave-alone through #2715 including +#2593, #2643, #2677, #2686, #2687, #2715 is respected; those packages are not +edited. Deferred shared-XOR soft-overlap with #2643 and host screens are not +opened. No competing open PR on this freestanding multi-connector 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 collapse. + First step: fix one transfer-coupled Q=7+C schedule and census dirt-legal R. + Blocked by: larger search; leave-alone host screens deferred. +2. Does the dirty-shadow sym-diff collapse extend verbatim to eight queries? + Why it matters: extends the unequal-price handoff beyond Q=7. + First step: reuse the snapshot lemma on length-8 slot lists. + Blocked by: larger search. + +## Credit + +Credit **Arham Tahir / PR1898**, **ywz65 / PR2455**, **PR1370**, fork **789q** / +**#2677**, **#2643**, **#2686**, open **#2715** (cheaper-readout; 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/multi-connector-7q-obstruction/SOURCES.json b/research/multi-connector-7q-obstruction/SOURCES.json new file mode 100644 index 0000000000..719b378cbd --- /dev/null +++ b/research/multi-connector-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/multi-connector-7q-obstruction/TASK.json b/research/multi-connector-7q-obstruction/TASK.json new file mode 100644 index 0000000000..638617f48b --- /dev/null +++ b/research/multi-connector-7q-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": "Price one multi-connector / shadow-snapshot readout alphabet at Q=7 in the PR1898 alphabet: prove legal dirty-shadow and dual same-walk collapse to even-subset R>=82 (tariff 442), show illegal clean-shadow would reach R=71 (tariff 420), answering #2715 OQ1 (cr7q multi-connector).", + "scope_change_reason": "The drawn connector-alphabet card is redirected to the explicit multi-connector open question left by #2715 on the #1898 lineage, which is the nearest priced obstruction outside leave-alone tooling hosts and the hard leave-alones through #2715.", + "bottleneck_link": "A priced multi-connector readout alphabet decides whether seven queries can undercut the six-query endpoint by dual-row cheaper readouts at the #2643 XOR floor.", + "budget_minutes": 60, + "stop_rule": "Stop after dirty-shadow collapse, dual triangle identity, clean-shadow counterfactual census, tariff consequence, package tests; no shared-XOR reopening and no host screens.", + "outcome": "completed", + "evidence": "CERTIFICATE.json distinct-6 dirty-shadow matches even {82:97216,88:486080}; clean counterfactual {71:97216,80:486080}; dual min_a cost + triangle verified on all 583296 covering sets; champion dirty=82 clean=71; 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 (partitioned or transfer-coupled queries) undercut tariff 436 after charging both walks, transfers, and dirt?", + "why_it_matters": "Remaining dual-row direction after same-walk collapse.", + "first_step": "Fix one transfer-coupled Q=7+C schedule and census dirt-legal R.", + "blocked_by": "Larger search; host screens deferred." + }, + { + "question": "Does the dirty-shadow sym-diff collapse extend verbatim to eight queries?", + "why_it_matters": "Extends the unequal-price handoff beyond Q=7.", + "first_step": "Reuse the snapshot lemma on length-8 slot lists.", + "blocked_by": "Larger search." + } + ], + "predecessors": [ + { + "pr": 1898, + "credit": "Arham Tahir; minimum-query endpoint and abstract tariff fixture" + }, + { + "pr": 2715, + "credit": "Wentao Li; cheaper-readout obstruction and OQ1 answered here" + }, + { + "pr": 2686, + "credit": "Wentao Li; even-subset R floor" + }, + { + "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/multi-connector-7q-obstruction/VERIFY.json b/research/multi-connector-7q-obstruction/VERIFY.json new file mode 100644 index 0000000000..b205ab7832 --- /dev/null +++ b/research/multi-connector-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": "Dirty-shadow/even/clean distinct-6 census; dual min_a cost + triangle on every covering set; one-repeat layers; dirt 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 multi-connector census with real dual min_a + triangle, repeat layers, champion, 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/multi-connector-7q-obstruction/independent.py b/research/multi-connector-7q-obstruction/independent.py new file mode 100644 index 0000000000..9f0d665fc2 --- /dev/null +++ b/research/multi-connector-7q-obstruction/independent.py @@ -0,0 +1,221 @@ +#!/usr/bin/env python3 +"""Independent multi-connector / shadow 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 dual_and_triangle(even): + """One pass: (Σ_m min_a (e[a]+e[a⊕m]), triangle_holds). Not a Σ e copy.""" + total = 0 + triangle = True + for m in range(1, 32): + best = 99 + em = even[m] + for a in range(32): + c0 = even[a] + c1 = even[a ^ m] + if c0 < 99 and c1 < 99: + cost = c0 + c1 + if cost < best: + best = cost + if em > cost: + triangle = False + if best >= 99: + return None, False + total += best + return total, triangle + + +def bundle(slots): + n = len(slots) + even = [99] * 32 + even[0] = 0 + dirty = [[99] * 32 for _ in range(n)] + clean = [[99] * 32 for _ in range(n)] + 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 % 2 == 0: + if size < even[value]: + even[value] = size + for k in range(n): + if size < dirty[k][value]: + dirty[k][value] = size + if size < clean[k][value]: + clean[k][value] = size + cost = size + 1 + v = value ^ slots[k] + if cost < clean[k][v]: + clean[k][v] = cost + else: + for k in range(n): + cost = size + 1 + v = value ^ slots[k] + if cost < dirty[k][v]: + dirty[k][v] = cost + for k in range(n): + sigma = slots[k] + if sigma != 0 and 1 < clean[k][sigma]: + clean[k][sigma] = 1 + if any(even[m] >= 99 for m in range(1, 32)): + return None + even_r = sum(even[1:]) + dirty_rs = [sum(dirty[k][1:]) for k in range(n)] + clean_rs = [sum(clean[k][1:]) for k in range(n)] + dual, tri = dual_and_triangle(even) + if dual is None: + return None + return even_r, dirty_rs, clean_rs, dual, tri + + +def tariff(q, r, x): + return (28 * q + r) + (9 * q) + x + (q + r + x) + + +def distinct6(): + he, hd, hdu, hc = Counter(), Counter(), Counter(), Counter() + covering = 0 + dirty_eq = 0 + dual_eq = 0 + triangle_ok = 0 + for nonzero in combinations(range(1, 32), 6): + got = bundle((0,) + nonzero) + if got is None: + continue + e, ds, cs, du, tri = got + covering += 1 + he[e] += 1 + dmin = min(ds) + cmin = min(cs) + hd[dmin] += 1 + hc[cmin] += 1 + hdu[du] += 1 + if dmin == e and all(v == e for v in ds): + dirty_eq += 1 + if du == e: + dual_eq += 1 + if tri: + triangle_ok += 1 + if covering != 583296: + fail(f"covering {covering}") + if dict(he) != {82: 97216, 88: 486080}: + fail(f"even hist {dict(he)}") + if dict(hd) != {82: 97216, 88: 486080}: + fail(f"dirty hist {dict(hd)}") + if dict(hdu) != {82: 97216, 88: 486080}: + fail(f"dual hist {dict(hdu)}") + if dict(hc) != {71: 97216, 80: 486080}: + fail(f"clean hist {dict(hc)}") + if dirty_eq != covering: + fail(f"match dirty={dirty_eq}") + if dual_eq != covering: + fail(f"match dual={dual_eq}") + if triangle_ok != covering: + fail(f"triangle={triangle_ok}") + 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 = bundle(tuple(slots)) + if got is None: + return + e, ds, cs, du, _tri = got + if kind == "even": + total = e + elif kind == "dirty": + total = min(ds) + elif kind == "clean": + total = min(cs) + else: + fail("kind") + 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() + for kind, expect in (("even", {96: 1680}), ("dirty", {96: 1680}), ("clean", {88: 1680})): + cov, hist = one_repeat(kind) + if cov != 1680 or hist != expect: + fail(f"repeat {kind} {cov} {hist}") + + got = bundle(CHAMPION) + if got is None: + fail("champion uncovered") + e, ds, cs, du, tri = got + if e != 82 or min(ds) != 82 or du != 82 or min(cs) != 71 or not tri: + fail(f"champion scores {got}") + if tariff(7, 82, 6) != 442 or tariff(7, 71, 6) != 420: + fail("tariff") + if not ( + cert["claim"]["legal_multi_connector_min_R"] == 82 + and cert["claim"]["clean_shadow_counterfactual_min_R"] == 71 + and cert["claim"]["undercuts_436_after_complete_dirty_bill"] is False + ): + fail("certificate claim drift") + + print( + "PASS_INDEPENDENT_MULTI_CONNECTOR_7Q", + f"covering={covering}", + "legal_min=82", + "clean_counterfactual_min=71", + "tariff_legal=442", + "tariff_clean=420", + "answers_cr7q_oq1", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/multi-connector-7q-obstruction/model.py b/research/multi-connector-7q-obstruction/model.py new file mode 100644 index 0000000000..5a839af1a7 --- /dev/null +++ b/research/multi-connector-7q-obstruction/model.py @@ -0,0 +1,455 @@ +"""Multi-connector / priced-shadow readout at seven queries. + +Answers open question 1 of the cheaper-readout package (#2715): whether a +multi-connector readout alphabet (two live connectors, or a priced shadow +snapshot) can reach R<=78 at Q=7 with X=6 after a complete dirty bill. +Self-contained relative to PR1898 / #2643 / #2686 / #2715. 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 = { + "distinct6_covering": 583296, + "even_subset_attainable_R": [82, 88], + "even_subset_histogram": {"82": 97216, "88": 486080}, + "even_subset_min_R": 82, + "dirty_shadow_attainable_R": [82, 88], + "dirty_shadow_histogram": {"82": 97216, "88": 486080}, + "dirty_shadow_min_R": 82, + "dirty_shadow_matches_even_covering": 583296, + "dual_indep_attainable_R": [82, 88], + "dual_indep_histogram": {"82": 97216, "88": 486080}, + "dual_indep_min_R": 82, + "dual_indep_matches_even_covering": 583296, + "clean_shadow_attainable_R": [71, 80], + "clean_shadow_histogram": {"71": 97216, "80": 486080}, + "clean_shadow_min_R": 71, + "one_repeat_even_R": 96, + "one_repeat_dirty_shadow_R": 96, + "one_repeat_clean_shadow_R": 88, + "one_repeat_covering": 1680, + "champion_slots": (0, 1, 2, 6, 12, 24, 16), + "champion_even_R": 82, + "champion_dirty_shadow_min_R": 82, + "champion_clean_shadow_min_R": 71, + "champion_clean_best_k": 1, + "endpoint_tariff_Q6": 436, + "legal_tariff_at_X6": 442, + "hypothetical_clean_tariff_at_X6": 420, +} + + +def tariff_qrx(q, r, x, extra=0): + """Abstract complete-call tariff at (b,a,x)=(38,2,2), plus optional extras.""" + leaves = 28 * q + r + nodes = 9 * q + dispatch = q + r + x + return leaves + nodes + x + dispatch + extra + + +def mask_best_bundle(slots): + """Even, dirty-shadow (per k), and clean-shadow (per k) per-mask minima. + + Dirty shadow at index k: second live connector inherits correlated dirt from + a priced copy of the primary at slot k. Legal schedules need even total + live-read parity across primary+shadow (same dirt coefficient). + + Clean shadow at index k: hypothetical dirt-free snapshot of value slots[k] + (illegal under PR1898 arbitrary dirt — retained only as a counterfactual). + Primary still needs even live-connector parity; shadow reads are free of dirt. + """ + need(type(slots) is tuple and slots and slots[0] == 0, "slots must start at 0") + n = len(slots) + even = [99] * 32 + even[0] = 0 + dirty = [[99] * 32 for _ in range(n)] + clean = [[99] * 32 for _ in range(n)] + 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 % 2 == 0: + if size < even[value]: + even[value] = size + for k in range(n): + if size < dirty[k][value]: + dirty[k][value] = size + if size < clean[k][value]: + clean[k][value] = size + sigma = slots[k] + cost = size + 1 + v = value ^ sigma + if cost < clean[k][v]: + clean[k][v] = cost + else: + for k in range(n): + sigma = slots[k] + cost = size + 1 + v = value ^ sigma + if cost < dirty[k][v]: + dirty[k][v] = cost + for k in range(n): + sigma = slots[k] + if sigma != 0 and 1 < clean[k][sigma]: + clean[k][sigma] = 1 + return {"even": even, "dirty": dirty, "clean": clean} + + +def total_or_none(best): + if any(best[mask] >= 99 for mask in range(1, 32)): + return None + return sum(best[1:]) + + +def min_even_subset_R(slots): + return total_or_none(mask_best_bundle(slots)["even"]) + + +def dirty_shadow_R_by_k(slots): + info = mask_best_bundle(slots) + return [total_or_none(info["dirty"][k]) for k in range(len(slots))] + + +def min_dirty_shadow_R(slots): + vals = [v for v in dirty_shadow_R_by_k(slots) if v is not None] + return min(vals) if vals else None + + +def clean_shadow_R_by_k(slots): + info = mask_best_bundle(slots) + return [total_or_none(info["clean"][k]) for k in range(len(slots))] + + +def min_clean_shadow_R(slots): + vals = [v for v in clean_shadow_R_by_k(slots) if v is not None] + return min(vals) if vals else None + + +def even_triangle_holds(even): + """Even-subset costs obey e[m] <= e[a] + e[a⊕m] (concatenate two even sets).""" + if any(even[m] >= 99 for m in range(1, 32)): + return False + for m in range(1, 32): + for a in range(32): + c0 = even[a] + c1 = even[a ^ m] + if c0 < 99 and c1 < 99 and even[m] > c0 + c1: + return False + return True + + +def dual_and_triangle_from_even(even): + """One 31×32 pass: (Σ_m min_a (e[a]+e[a⊕m]), triangle_holds). + + Dual cost is computed directly (not copied from Σ e[m]). Triangle is + e[m] <= e[a]+e[a⊕m] for every covered a,m. With e[0]=0 the choice a=m + always achieves e[m], so triangle forces dual == Σ e[m] on covering lists. + """ + if any(even[m] >= 99 for m in range(1, 32)): + return None, False + total = 0 + triangle = True + for m in range(1, 32): + best = 99 + em = even[m] + for a in range(32): + c0 = even[a] + c1 = even[a ^ m] + if c0 < 99 and c1 < 99: + cost = c0 + c1 + if cost < best: + best = cost + if em > cost: + triangle = False + if best >= 99: + return None, False + total += best + return total, triangle + + +def dual_independent_from_even(even): + """Dual-indep R = Σ_{m=1}^{31} min_a (e[a] + e[a⊕m]) from even table.""" + dual_r, _triangle = dual_and_triangle_from_even(even) + return dual_r + + +def dual_independent_same_walk_R(slots): + """Two independently dirty connectors on the same slot list. + + Each port needs even live-read parity separately. Cost is |T0|+|T1| for + even realizing sets with XOR(T0)⊕XOR(T1)=m. Empty second port recovers + ordinary even-subset; triangle inequality prevents any improvement. + """ + return dual_independent_from_even(mask_best_bundle(slots)["even"]) + + +def dirty_shadow_symdiff_identities(slots, k): + """Check the sym-diff collapse: odd primary + shadow ≡ even set via Δ{k}.""" + n = len(slots) + sigma = slots[k] + checked = 0 + for bits in range(1 << n): + size = bits.bit_count() + if size % 2 == 0: + continue + value = 0 + for i in range(n): + if bits >> i & 1: + value ^= slots[i] + new_bits = bits ^ (1 << k) + new_size = new_bits.bit_count() + need(new_size % 2 == 0, "sym-diff must be even") + includes = (bits >> k) & 1 + need(new_size == (size - 1 if includes else size + 1), "sym-diff cost") + new_value = 0 + for i in range(n): + if new_bits >> i & 1: + new_value ^= slots[i] + need(new_value == (value ^ sigma), "sym-diff XOR") + checked += 1 + return checked + + +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_multi_connector(): + """One pass: even, dirty-shadow, clean-shadow, and dual-indep (real min_a).""" + hist_even = Counter() + hist_dirty = Counter() + hist_dual = Counter() + hist_clean = Counter() + covering = 0 + dirty_matches = 0 + dual_matches = 0 + triangle_ok = 0 + witnesses = {"even": {}, "dirty": {}, "dual": {}, "clean": {}} + for nonzero in combinations(range(1, 32), 6): + slots = (0,) + nonzero + info = mask_best_bundle(slots) + even = info["even"] + even_r = total_or_none(even) + if even_r is None: + continue + dirty_vals = [total_or_none(info["dirty"][k]) for k in range(7)] + clean_vals = [total_or_none(info["clean"][k]) for k in range(7)] + need(all(v is not None for v in dirty_vals), "dirty uncovered") + need(all(v is not None for v in clean_vals), "clean uncovered") + dual_r, tri_ok = dual_and_triangle_from_even(even) + need(dual_r is not None, "dual uncovered") + dirty_r = min(dirty_vals) + clean_r = min(clean_vals) + covering += 1 + hist_even[even_r] += 1 + hist_dirty[dirty_r] += 1 + hist_dual[dual_r] += 1 + hist_clean[clean_r] += 1 + if dirty_r == even_r and all(v == even_r for v in dirty_vals): + dirty_matches += 1 + if dual_r == even_r: + dual_matches += 1 + if tri_ok: + triangle_ok += 1 + witnesses["even"].setdefault(even_r, slots) + witnesses["dirty"].setdefault(dirty_r, slots) + witnesses["dual"].setdefault(dual_r, slots) + witnesses["clean"].setdefault(clean_r, slots) + return { + "covering_sets": covering, + "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() + }, + }, + "dirty_shadow": { + "attainable_R": sorted(hist_dirty), + "histogram": {str(r): hist_dirty[r] for r in sorted(hist_dirty)}, + "min_R": min(hist_dirty) if hist_dirty else None, + "matches_even_on_covering": dirty_matches, + "first_witnesses": { + str(r): list(slots) for r, slots in witnesses["dirty"].items() + }, + }, + "dual_independent": { + "attainable_R": sorted(hist_dual), + "histogram": {str(r): hist_dual[r] for r in sorted(hist_dual)}, + "min_R": min(hist_dual) if hist_dual else None, + "matches_even_on_covering": dual_matches, + "triangle_holds_on_covering": triangle_ok, + "first_witnesses": { + str(r): list(slots) for r, slots in witnesses["dual"].items() + }, + }, + "clean_shadow_counterfactual": { + "attainable_R": sorted(hist_clean), + "histogram": {str(r): hist_clean[r] for r in sorted(hist_clean)}, + "min_R": min(hist_clean) if hist_clean else None, + "first_witnesses": { + str(r): list(slots) for r, slots in witnesses["clean"].items() + }, + "legal_under_dirty_contract": False, + }, + } + + +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 clean_shadow_dirt_examples(): + """Finite checks: dirt-free shadow schedules fail inherited-dirt cancellation.""" + examples = [] + slots = EXPECTED["champion_slots"] + # Best clean k for champion is 1 (sigma=1), R=71. + k = EXPECTED["champion_clean_best_k"] + sigma = slots[k] + # Shadow-only readout of mask sigma has odd live dirt on the shadow port. + examples.append( + { + "note": "champion_shadow_only_sigma", + "slots": list(slots), + "snapshot_index": k, + "sigma": sigma, + "mask": sigma, + "primary_reads": 0, + "shadow_reads": 1, + "inherited_dirt_parity": 1, + "legal_under_correlated_dirt": False, + "clean_R": min_clean_shadow_R(slots), + "dirty_R": min_dirty_shadow_R(slots), + } + ) + # First clean-71 witness: odd shadow use similarly illegal. + witness = (0, 1, 2, 4, 8, 15, 16) + k2 = min(range(7), key=lambda i: clean_shadow_R_by_k(witness)[i]) + examples.append( + { + "note": "first_clean_71_witness_shadow_dirt", + "slots": list(witness), + "snapshot_index": k2, + "sigma": witness[k2], + "mask": witness[k2], + "primary_reads": 0, + "shadow_reads": 1, + "inherited_dirt_parity": 1, + "legal_under_correlated_dirt": False, + "clean_R": min_clean_shadow_R(witness), + "dirty_R": min_dirty_shadow_R(witness), + } + ) + need(all(ex["inherited_dirt_parity"] == 1 for ex in examples), "odd dirt") + need(all(not ex["legal_under_correlated_dirt"] for ex in examples), "illegal") + return examples + + +def champion_analysis(): + slots = EXPECTED["champion_slots"] + closed = slots + (0,) + dirty_by_k = dirty_shadow_R_by_k(slots) + clean_by_k = clean_shadow_R_by_k(slots) + return { + "slots": list(slots), + "path_X": path_X(closed), + "even_R": min_even_subset_R(slots), + "dirty_shadow_R_by_k": dirty_by_k, + "dirty_shadow_min_R": min(dirty_by_k), + "dual_independent_R": dual_independent_same_walk_R(slots), + "clean_shadow_R_by_k": clean_by_k, + "clean_shadow_min_R": min(clean_by_k), + "clean_best_k": min(range(7), key=lambda i: clean_by_k[i]), + "legal_tariff_X6": tariff_qrx(7, min(dirty_by_k), 6), + "hypothetical_clean_tariff_X6": tariff_qrx(7, min(clean_by_k), 6), + "endpoint_Q6": EXPECTED["endpoint_tariff_Q6"], + "symdiff_checked_at_k1": dirty_shadow_symdiff_identities(slots, 1), + } + + +# Credited path-lowered champion from the 789q / #2643 / #2686 / #2715 lineage. +CHAMPION_7 = (0, 1, 2, 6, 12, 24, 16, 0) diff --git a/research/multi-connector-7q-obstruction/test_package.py b/research/multi-connector-7q-obstruction/test_package.py new file mode 100644 index 0000000000..88b361d1fb --- /dev/null +++ b/research/multi-connector-7q-obstruction/test_package.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Package fault controls for multi-connector 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 = "multi-connector-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_MULTI_CONNECTOR_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_MULTI_CONNECTOR_7Q_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"]["legal_multi_connector_min_R"] = 0 + cert.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8") + proc = run([sys.executable, "-I", "-B", str(research / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "corrupted certificate should fail") + + # 4) Source pin corruption rejection. + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + research = tmp_path / "research" / PKG_NAME + shutil.copytree(HERE, research) + pinned = tmp_path / "research" / "mutable-source-shear-cost" + pinned.mkdir(parents=True) + src = ROOT / "research" / "mutable-source-shear-cost" / "CERTIFICATE.json" + (pinned / "CERTIFICATE.json").write_bytes(src.read_bytes() + b"\n") + proc = run([sys.executable, "-I", "-B", str(research / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "source drift should fail") + + # 5) Independent checker. + proc = run([sys.executable, "-I", "-B", str(HERE / "independent.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_INDEPENDENT_MULTI_CONNECTOR_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_MULTI_CONNECTOR_7Q_PACKAGE_TESTS groups=6") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/multi-connector-7q-obstruction/verify.py b/research/multi-connector-7q-obstruction/verify.py new file mode 100644 index 0000000000..aefb8c4333 --- /dev/null +++ b/research/multi-connector-7q-obstruction/verify.py @@ -0,0 +1,299 @@ +#!/usr/bin/env python3 +"""Multi-connector / priced-shadow 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, + clean_shadow_dirt_examples, + dirty_shadow_symdiff_identities, + dual_independent_same_walk_R, + enumerate_distinct6_multi_connector, + even_triangle_holds, + mask_best_bundle, + min_clean_shadow_R, + min_dirty_shadow_R, + min_even_subset_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["legal_multi_connector_min_R"] == EXPECTED["dirty_shadow_min_R"], "legal min") + need(claim["clean_shadow_counterfactual_min_R"] == EXPECTED["clean_shadow_min_R"], "clean min") + need(claim["undercuts_436_if_clean_shadow_free"] is True, "clean undercut flag") + need(claim["undercuts_436_after_complete_dirty_bill"] is False, "legal undercut") + need(claim["no_new_kappa"] is True, "kappa") + need(claim["answers_cr7q_oq1"] is True, "oq1 flag") + + +def build_certificate(): + champ = champion_analysis() + need(champ["even_R"] == EXPECTED["champion_even_R"], "champion even") + need(champ["dirty_shadow_min_R"] == EXPECTED["champion_dirty_shadow_min_R"], "champion dirty") + need(champ["clean_shadow_min_R"] == EXPECTED["champion_clean_shadow_min_R"], "champion clean") + need(champ["clean_best_k"] == EXPECTED["champion_clean_best_k"], "champion clean k") + need(champ["dual_independent_R"] == EXPECTED["champion_even_R"], "champion dual") + need(champ["path_X"] == 6, "champion path X") + need(champ["legal_tariff_X6"] == EXPECTED["legal_tariff_at_X6"], "legal tariff") + need( + champ["hypothetical_clean_tariff_X6"] == EXPECTED["hypothetical_clean_tariff_at_X6"], + "clean tariff", + ) + need(champ["legal_tariff_X6"] > EXPECTED["endpoint_tariff_Q6"], "legal must not undercut") + need( + champ["hypothetical_clean_tariff_X6"] < EXPECTED["endpoint_tariff_Q6"], + "free clean would undercut", + ) + need(all(v == champ["even_R"] for v in champ["dirty_shadow_R_by_k"]), "dirty==even all k") + + # Dual triangle identity on champion and clean-71 witness. + for slots in (CHAMPION_7[:-1], (0, 1, 2, 4, 8, 15, 16)): + even = mask_best_bundle(slots)["even"] + need(even_triangle_holds(even), f"triangle on {slots}") + need(sum(even[1:]) == dual_independent_same_walk_R(slots), "dual==even") + + dirt = clean_shadow_dirt_examples() + need(len(dirt) >= 2, "dirt examples") + + need(path_X(CHAMPION_7) == 6, "closed champion X") + need(min_even_subset_R(CHAMPION_7[:-1]) == 82, "closed even") + need(min_dirty_shadow_R(CHAMPION_7[:-1]) == 82, "closed dirty") + need(min_clean_shadow_R(CHAMPION_7[:-1]) == 71, "closed clean") + need( + tariff_qrx(7, 82, 6) == 442 and tariff_qrx(7, 71, 6) == 420, + "tariff arithmetic", + ) + + # Sym-diff identities on champion for every snapshot index. + for k in range(7): + need(dirty_shadow_symdiff_identities(CHAMPION_7[:-1], k) == 64, f"symdiff k={k}") + + distinct = enumerate_distinct6_multi_connector() + need(distinct["covering_sets"] == EXPECTED["distinct6_covering"], "covering count") + 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["dirty_shadow"]["attainable_R"] == EXPECTED["dirty_shadow_attainable_R"], + "dirty spectrum", + ) + need( + distinct["dirty_shadow"]["histogram"] == EXPECTED["dirty_shadow_histogram"], + "dirty histogram", + ) + need(distinct["dirty_shadow"]["min_R"] == EXPECTED["dirty_shadow_min_R"], "dirty min") + need( + distinct["dirty_shadow"]["matches_even_on_covering"] + == EXPECTED["dirty_shadow_matches_even_covering"], + "dirty matches even", + ) + need( + distinct["dual_independent"]["attainable_R"] == EXPECTED["dual_indep_attainable_R"], + "dual spectrum", + ) + need( + distinct["dual_independent"]["histogram"] == EXPECTED["dual_indep_histogram"], + "dual histogram", + ) + need(distinct["dual_independent"]["min_R"] == EXPECTED["dual_indep_min_R"], "dual min") + need( + distinct["dual_independent"]["matches_even_on_covering"] + == EXPECTED["dual_indep_matches_even_covering"], + "dual matches even", + ) + need( + distinct["dual_independent"]["triangle_holds_on_covering"] + == EXPECTED["distinct6_covering"], + "dual triangle covering", + ) + need( + distinct["clean_shadow_counterfactual"]["attainable_R"] + == EXPECTED["clean_shadow_attainable_R"], + "clean spectrum", + ) + need( + distinct["clean_shadow_counterfactual"]["histogram"] + == EXPECTED["clean_shadow_histogram"], + "clean histogram", + ) + need( + distinct["clean_shadow_counterfactual"]["min_R"] == EXPECTED["clean_shadow_min_R"], + "clean min", + ) + need( + distinct["clean_shadow_counterfactual"]["legal_under_dirty_contract"] is False, + "clean illegal flag", + ) + + repeats_even = one_repeat_basis_census(min_even_subset_R) + need(repeats_even["min_R"] == EXPECTED["one_repeat_even_R"], "repeat even") + need(repeats_even["covering_walks"] == EXPECTED["one_repeat_covering"], "repeat covering") + need(repeats_even["attainable_R"] == [96], "repeat even spectrum") + + repeats_dirty = one_repeat_basis_census(min_dirty_shadow_R) + need(repeats_dirty["min_R"] == EXPECTED["one_repeat_dirty_shadow_R"], "repeat dirty") + need(repeats_dirty["covering_walks"] == EXPECTED["one_repeat_covering"], "repeat dirty cov") + need(repeats_dirty["attainable_R"] == [96], "repeat dirty spectrum") + + repeats_clean = one_repeat_basis_census(min_clean_shadow_R) + need(repeats_clean["min_R"] == EXPECTED["one_repeat_clean_shadow_R"], "repeat clean") + need(repeats_clean["covering_walks"] == EXPECTED["one_repeat_covering"], "repeat clean cov") + need(repeats_clean["attainable_R"] == [88], "repeat clean spectrum") + + return { + "schema_version": 1, + "status": "PASS_MULTI_CONNECTOR_7Q_OBSTRUCTION", + "scope": ( + "Five-source common-B mutable-source Q/R/X alphabet (PR1898). " + "Priced multi-connector readout at Q=7: correlated dirty shadow " + "snapshot, independent dual same-walk, and illegal clean-shadow " + "counterfactual. Answers #2715 OQ1 (cr7q multi-connector)." + ), + "claim": { + "Q": 7, + "legal_multi_connector_min_R": 82, + "dirty_shadow_min_R": 82, + "dual_independent_min_R": 82, + "even_subset_min_R": 82, + "clean_shadow_counterfactual_min_R": 71, + "one_repeat_legal_min_R": 96, + "one_repeat_clean_counterfactual_min_R": 88, + "undercuts_436_if_clean_shadow_free": True, + "undercuts_436_after_complete_dirty_bill": False, + "legal_tariff_at_X6": 442, + "hypothetical_clean_tariff_at_X6": 420, + "endpoint_Q6_tariff": 436, + "answers_cr7q_oq1": True, + "oq1_answer": ( + "A priced shadow snapshot with inherited correlated dirt collapses " + "to even-subset cost R>=82 via sym-diff with the snapshot index " + "(spectrum {82,88} on all 583296 covering distinct-6 sets). " + "Two independently dirty connectors on the same walk likewise " + "cannot beat R=82: dual R is computed as Σ_m min_a (e[a]+e[a⊕m]) " + "and the even-subset triangle inequality is verified on every " + "covering set (matches_even=triangle_holds=583296). A dirt-free " + "shadow would reach R=71 and tariff 420<436, but cannot scrub " + "inherited connector dirt under the PR1898 contract; shadow-only " + "reads leave odd dirt. After a complete dirty bill, legal " + "multi-connector alphabets stay at tariff >=442 and do not " + "undercut the six-query endpoint 436." + ), + "no_new_kappa": True, + }, + "champion": champ, + "clean_shadow_dirt_examples": dirt, + "distinct6": distinct, + "one_repeat_even": repeats_even, + "one_repeat_dirty_shadow": repeats_dirty, + "one_repeat_clean_shadow_counterfactual": repeats_clean, + "leave_alone": { + "through": 2715, + "includes": [2593, 2643, 2677, 2686, 2687, 2715], + "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_MULTI_CONNECTOR_7Q_OBSTRUCTION", + "legal_min_R=82", + "dirty_shadow_min_R=82", + "dual_indep_min_R=82", + "clean_counterfactual_min_R=71", + "legal_tariff=442", + "hypothetical_clean_tariff=420", + "no_undercut_after_complete_dirty_bill", + "answers_cr7q_oq1", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())