diff --git a/research/dirty-shadow-8q-obstruction/CERTIFICATE.json b/research/dirty-shadow-8q-obstruction/CERTIFICATE.json new file mode 100644 index 0000000000..16fe4e8c47 --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/CERTIFICATE.json @@ -0,0 +1,340 @@ +{ + "schema_version": 1, + "status": "PASS_DIRTY_SHADOW_8Q_OBSTRUCTION", + "scope": "Five-source common-B mutable-source Q/R/X alphabet (PR1898). Priced dirty-shadow snapshot readout at Q=8: sym-diff collapse to even-subset, plus illegal clean-shadow counterfactual. Answers #2761 OQ2 / #2764 OQ2 (dirty-shadow at eight queries).", + "claim": { + "Q": 8, + "dirty_shadow_min_R": 74, + "even_subset_min_R": 74, + "clean_shadow_counterfactual_min_R": 67, + "one_dup_dirty_min_R": 82, + "one_dup_clean_counterfactual_min_R": 71, + "undercuts_436_if_clean_shadow_free": false, + "undercuts_436_after_complete_dirty_bill": false, + "legal_tariff_at_X0": 452, + "hypothetical_clean_tariff_at_X0": 438, + "endpoint_Q6_tariff": 436, + "matches_2677_even_floor": true, + "answers_mc7q_oq2": true, + "oq2_answer": "The dirty-shadow sym-diff collapse extends verbatim to eight queries: on all 2430400 covering distinct-7 length-8 slot lists, priced dirty-shadow totals match even-subset exactly (spectrum {74,80,84}; matches_even=2430400), so legal R>=74 and tariff >=452>436 at X=0, matching #2677. One-duplicate multisets likewise collapse (spectrum {82,88} on 4083072 covering lists). A dirt-free shadow would reach R=67 (tariff 438) on distinct-7 and R=71 (tariff 446) on one-dup, but both still fail to undercut 436 at X=0 and remain illegal under PR1898 inherited dirt; shadow-only reads leave odd dirt. After a complete dirty bill, legal dirty-shadow alphabets stay at tariff >=452 and do not undercut the six-query endpoint 436.", + "no_new_kappa": true + }, + "champion": { + "slots": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ], + "even_R": 74, + "dirty_shadow_R_by_k": [ + 74, + 74, + 74, + 74, + 74, + 74, + 74, + 74 + ], + "dirty_shadow_min_R": 74, + "clean_shadow_R_by_k": [ + 74, + 73, + 67, + 67, + 67, + 67, + 67, + 67 + ], + "clean_shadow_min_R": 67, + "clean_best_k": 2, + "legal_tariff_X0": 452, + "hypothetical_clean_tariff_X0": 438, + "endpoint_Q6": 436, + "symdiff_checked_at_k2": 128 + }, + "clean_shadow_dirt_examples": [ + { + "note": "champion_shadow_only_sigma", + "slots": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ], + "snapshot_index": 2, + "sigma": 2, + "mask": 2, + "primary_reads": 0, + "shadow_reads": 1, + "inherited_dirt_parity": 1, + "legal_under_correlated_dirt": false, + "clean_R": 67, + "dirty_R": 74 + }, + { + "note": "first_clean_70_witness_shadow_dirt", + "slots": [ + 0, + 1, + 2, + 3, + 4, + 8, + 12, + 16 + ], + "snapshot_index": 7, + "sigma": 16, + "mask": 16, + "primary_reads": 0, + "shadow_reads": 1, + "inherited_dirt_parity": 1, + "legal_under_correlated_dirt": false, + "clean_R": 70, + "dirty_R": 80 + } + ], + "distinct7": { + "covering_sets": 2430400, + "dirty_matches_even_on_covering": 2430400, + "even_subset": { + "attainable_R": [ + 74, + 80, + 84 + ], + "histogram": { + "74": 416640, + "80": 1180480, + "84": 833280 + }, + "min_R": 74, + "first_witnesses": { + "74": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ], + "80": [ + 0, + 1, + 2, + 3, + 4, + 8, + 12, + 16 + ], + "84": [ + 0, + 1, + 2, + 3, + 4, + 5, + 8, + 16 + ] + } + }, + "dirty_shadow": { + "attainable_R": [ + 74, + 80, + 84 + ], + "histogram": { + "74": 416640, + "80": 1180480, + "84": 833280 + }, + "min_R": 74, + "matches_even_on_covering": 2430400, + "first_witnesses": { + "74": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ], + "80": [ + 0, + 1, + 2, + 3, + 4, + 8, + 12, + 16 + ], + "84": [ + 0, + 1, + 2, + 3, + 4, + 5, + 8, + 16 + ] + } + }, + "clean_shadow_counterfactual": { + "attainable_R": [ + 67, + 70, + 76 + ], + "histogram": { + "67": 416640, + "70": 1180480, + "76": 833280 + }, + "min_R": 67, + "first_witnesses": { + "67": [ + 0, + 1, + 2, + 3, + 4, + 8, + 16, + 29 + ], + "70": [ + 0, + 1, + 2, + 3, + 4, + 8, + 12, + 16 + ], + "76": [ + 0, + 1, + 2, + 3, + 4, + 5, + 8, + 16 + ] + }, + "legal_under_dirty_contract": false + } + }, + "one_duplicate": { + "covering_multisets": 4083072, + "dirty_matches_even_on_covering": 4083072, + "even_subset": { + "attainable_R": [ + 82, + 88 + ], + "histogram": { + "82": 680512, + "88": 3402560 + }, + "min_R": 82, + "first_witness": [ + 0, + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + }, + "dirty_shadow": { + "attainable_R": [ + 82, + 88 + ], + "histogram": { + "82": 680512, + "88": 3402560 + }, + "min_R": 82, + "matches_even_on_covering": 4083072, + "first_witness": [ + 0, + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ] + }, + "clean_shadow_counterfactual": { + "attainable_R": [ + 71, + 80 + ], + "histogram": { + "71": 680512, + "80": 3402560 + }, + "min_R": 71, + "first_witness": [ + 0, + 0, + 1, + 2, + 4, + 8, + 15, + 16 + ], + "legal_under_dirty_contract": false + } + }, + "leave_alone": { + "through": 2817, + "includes": [ + 2487, + 2593, + 2643, + 2677, + 2686, + 2687, + 2715, + 2761, + 2764, + 2779, + 2817 + ], + "deferred": [ + "transfer-coupled-dual-7q soft-overlap", + "shared-xor soft-overlap #2643", + "host screens" + ], + "do_not_touch_package": "research/transfer-coupled-7q-obstruction/" + } +} diff --git a/research/dirty-shadow-8q-obstruction/NOTICE.md b/research/dirty-shadow-8q-obstruction/NOTICE.md new file mode 100644 index 0000000000..0ecbb31b74 --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/NOTICE.md @@ -0,0 +1,30 @@ +# Notice + +New material in this directory is Apache-2.0. + +Predecessor credit (do not alter historical notices elsewhere): + +- Arham Tahir / PR1898 `research/mutable-source-minimum-queries` — five-source + alphabet, minimum-query endpoint, abstract complete-call tariff. +- 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; not edited. +- Open #2761 `research/multi-connector-7q-obstruction` — dirty-shadow at Q=7; + OQ2 answered here; not edited. +- Open #2764 `research/dirty-parity-8q-obstruction` — dirty-parity at Q=8; + matching OQ2 handoff; not edited. +- Open #2817 `research/transfer-coupled-7q-obstruction/` — leave-alone; not + touched. +- Live pin: `research/mutable-source-shear-cost/CERTIFICATE.json`. + +Prepared by Wentao Li (VictorLiwentao, @Is__Victor) with substantial AI +assistance. diff --git a/research/dirty-shadow-8q-obstruction/PROOF.md b/research/dirty-shadow-8q-obstruction/PROOF.md new file mode 100644 index 0000000000..929ac2f9de --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/PROOF.md @@ -0,0 +1,101 @@ +# Dirty-shadow sym-diff collapse extends to eight queries + +This is a scoped obstruction in the five-source common-B mutable-source alphabet +of [PR1898](https://github.com/CrocSwap/integer-mult-bounds/pull/1898). It answers +open question 2 of +[#2761](https://github.com/CrocSwap/integer-mult-bounds/pull/2761) +(`research/multi-connector-7q-obstruction`) and the matching handoff in +[#2764](https://github.com/CrocSwap/integer-mult-bounds/pull/2764): whether the +**dirty-shadow sym-diff collapse** that forced priced shadow snapshots back to +even-subset cost at `Q=7` extends verbatim to eight queries. + +No new kappa is claimed. Leave-alone packages through #2817 are not edited. +In particular, `research/transfer-coupled-7q-obstruction/` is not touched. + +## Setup + +Retain queries `Q_j`, readouts `R_m: y_m += A_m z`, and paid source shears +`X_(s,t)`. Connector prefixes of a restored length-8 walk are slots +`(s_0,…,s_7)` with `s_0 = 0`. The even-subset score + +```text +R_even = Σ_{m=1}^{31} min{|T| : T ⊂ {0,…,7}, |T| even, ⊕_{i∈T} s_i = m} +``` + +satisfies `R_even ≥ 74` on every covering distinct-7 list +([#2677](https://github.com/CrocSwap/integer-mult-bounds/pull/2677)), so at +`X = 0` the abstract tariff `(b,a,x)=(38,2,2)` is at least `452 > 436`. + +## Fixture: 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. +``` + +The identity is machine-checked on the champion for all eight snapshot indices +(`128` odd primary subsets each) and enforced on the census by requiring +`dirty_r == even_r` for every covering list and every `k`. + +**Census.** On all `2430400` covering distinct-7 sets, the min-over-`k` dirty +shadow total matches even-subset exactly (spectrum `{74,80,84}`). On all +`4083072` covering one-duplicate length-8 multisets, dirty-shadow likewise +matches even-subset (spectrum `{82,88}`). + +## 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 `{67, 70, 76}` on distinct-7 (histogram +`416640 / 1180480 / 833280`) and `{71, 80}` on one-dup. The champion +`(0,1,2,3,4,8,16,29)` reaches `R_clean = 67` at `k=2`, hypothetical tariff +`38·8 + 2·67 + 2·0 = 438 > 436`. + +Unlike the Q=7 companion (#2761), where a free clean shadow would undercut +(`420 < 436`), at Q=8 the illegal clean-shadow floor still fails to undercut +the six-query endpoint at `X=0`. The counterfactual remains **illegal** under +the PR1898 arbitrary-dirt contract: a copy of a dirty connector inherits dirt. +Finite check: shadow-only readout of mask `σ` has odd inherited-dirt parity. + +## Tariff consequence + +After a complete dirty bill, every legal dirty-shadow schedule on covering Q=8 +walks still has `R ≥ 74`. At `X = 0`, tariff `≥ 452 > 436`. Charging the +snapshot copy `C` only increases the bill. Even the free clean-shadow floor +stays at `438 > 436`. + +## Scope limits + +- Fixes the priced dirty-shadow snapshot at Q=8 and the illegal clean-shadow + counterfactual. Dual-independent same-walk and transfer-coupled shapes are + outside (open #2817 leave-alone for `(5,1,1)`). +- Shared non-path XOR schedules remain deferred (soft-overlap with #2643). +- Host screens are deferred. +- Leave-alone through #2817 (including #2764, #2761, #2779, #2715, #2687, + #2686, #2677, #2643, #2593, #2487) 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 | — | +| #2677 | Distinct-slot even-subset `R≥74` at Q=8 | — | +| #2761 | Dirty-shadow collapse at Q=7; OQ2 asks Q=8 | — | +| #2764 | Dirty-parity collapse at Q=8; OQ2 asks dirty-shadow | — | +| **This** | — | **Dirty-shadow collapse at Q=8: legal R≥74 (tariff 452); clean counterfactual R=67 (tariff 438) still fails undercut** | diff --git a/research/dirty-shadow-8q-obstruction/README.md b/research/dirty-shadow-8q-obstruction/README.md new file mode 100644 index 0000000000..569e878f1b --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/README.md @@ -0,0 +1,81 @@ +# Dirty-shadow sym-diff collapse at eight queries + +**Scoped obstruction / priced alphabet; no new kappa.** Answers open question 2 +of [#2761](https://github.com/CrocSwap/integer-mult-bounds/pull/2761) +(`research/multi-connector-7q-obstruction`) and the matching handoff in +[#2764](https://github.com/CrocSwap/integer-mult-bounds/pull/2764) +(`research/dirty-parity-8q-obstruction`) in the five-source common-B +mutable-source alphabet of +[#1898](https://github.com/CrocSwap/integer-mult-bounds/pull/1898): does the +dirty-shadow sym-diff collapse extend verbatim to eight queries? + +| Alphabet | Distinct-7 min R | One-dup min R | Tariff at X=0 | Undercuts 436? | +|---|---:|---:|---:|---| +| Even-subset (#2677) | 74 | 82 | 452 | no | +| Dirty shadow (legal) | **74** | **82** | **452** | **no** | +| Clean shadow (illegal) | **67** | **71** | **438** | **no** (still ≥436) | + +Dirty shadow collapses to even-subset by sym-diff with the snapshot index on +every covering distinct-7 list (`matches_even=2430400`) and every covering +one-duplicate multiset (`matches_even=4083072`). A dirt-free shadow would reach +`R=67` (tariff `438`) but still fails to undercut `436` at `X=0` and remains +illegal under PR1898 inherited dirt. + +## Reproduction + +```sh +python3.12 -I -B research/dirty-shadow-8q-obstruction/verify.py +python3.12 -I -O -B research/dirty-shadow-8q-obstruction/verify.py +python3.12 -I -B research/dirty-shadow-8q-obstruction/independent.py +python3.12 -I -B research/dirty-shadow-8q-obstruction/test_package.py +python3.12 -B scripts/research_package.py --package research/dirty-shadow-8q-obstruction +``` + +Expected: + +```text +PASS_DIRTY_SHADOW_8Q_OBSTRUCTION dirty_shadow_min_R=74 ... answers_mc7q_oq2 matches_2677_even_floor no_new_kappa +PASS_INDEPENDENT_DIRTY_SHADOW_8Q covering=2430400 one_dup=4083072 dirty_min=74 ... answers_mc7q_oq2 no_new_kappa +PASS_DIRTY_SHADOW_8Q_PACKAGE_TESTS groups=6 +PASS_REGISTERED_RESEARCH_PACKAGE research/dirty-shadow-8q-obstruction outcome=completed +``` + +Default verify is read-only. Admission uses `need()`; `-O` also passes. + +## Overlap + +Base commit `0b1cccf86e2f5132ed286a26ef0a681a495740ea`. Direct predecessors: +PR1898, #2677 (distinct-slot `R≥74` at Q=8), #2761 (dirty-shadow at Q=7; OQ2), +#2764 (dirty-parity at Q=8; OQ2). Freestanding package name +`dirty-shadow-8q-obstruction` — does **not** touch +`research/transfer-coupled-7q-obstruction/` (#2817) or other leave-alones through +#2817. Deferred transfer-coupled-dual soft-overlap, shared-XOR, and host screens +are not opened. No competing open PR on this Q=8 dirty-shadow fixture at refresh. + +## Open next questions + +1. Can a multi-connector alphabet with **independent walks** (partitioned or + transfer-coupled shapes other than the open #2817 `(5,1,1)` package) undercut + tariff 436 after charging both walks, transfers, and dirt? + Why it matters: remaining dual-row direction after same-walk / dirty-shadow / + dirty-parity collapses. + First step: fix one new transfer-coupled shape with a new checkable fact + beyond #2817's `(5,1,1)`. + Blocked by: open #2817 package leave-alone; larger search. +2. Does any other priced readout alphabet under PR1898 `(b,a,x)=(38,2,2)` undercut + 436 at Q=8 after a complete dirty bill? + Why it matters: closes remaining unequal-price handoffs at eight queries. + First step: name one new alphabet and census dirt-legal R against tariff 436. + Blocked by: leave-alone packages through #2817; larger search. + +## Credit + +Credit **Arham Tahir / PR1898**, **ywz65 / PR2455**, **PR1370**, fork **789q** / +**#2677**, **#2643**, **#2686**, open **#2715**, open **#2761** (mc7q; OQ2 +answered here; not edited), open **#2764** (dirty-parity-8q; not edited), +**TennisBowling / PR1524**, **Ross Richardson / PR943**, and the retained +mutable-source lineage. Live input pin: +`research/mutable-source-shear-cost/CERTIFICATE.json`. Prepared by Wentao Li +([VictorLiwentao](https://github.com/VictorLiwentao), +[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance. +Apache-2.0. No independent human review or multiplication theorem is claimed. diff --git a/research/dirty-shadow-8q-obstruction/SOURCES.json b/research/dirty-shadow-8q-obstruction/SOURCES.json new file mode 100644 index 0000000000..719b378cbd --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/SOURCES.json @@ -0,0 +1,24 @@ +{ + "schema_version": 1, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1", + "sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075" + }, + { + "path": "research/mutable-source-shear-cost/CERTIFICATE.json", + "usage": "input", + "git_blob": "48958451bc819f2caa13bf3d9609423706ffb8a0", + "sha256": "665435375c025bbcf69eadf43bd9aeae44eb12fefdf12a78d5bfd66abde4ae3c" + } + ] +} diff --git a/research/dirty-shadow-8q-obstruction/TASK.json b/research/dirty-shadow-8q-obstruction/TASK.json new file mode 100644 index 0000000000..c029ce1335 --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/TASK.json @@ -0,0 +1,108 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 4, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "original_card": { + "id": "connector-alphabet-change", + "question": "Does one explicit extension of the connector alphabet offer a favorable completed budget?", + "starting_points": [ + "research/universal-connector-boundary/README.md", + "certificates/selected-result.json" + ], + "methods": [ + "Construct and charge a legal extra operation on a minimal instance.", + "Prove a target-specific bound after adding one specified operation family." + ], + "acceptance_gate": "State which fixed-alphabet premise changes and charge its implementation; do not declare it free.", + "first_step": { + "command": [ + "python3", + "-B", + "research/universal-connector-boundary/verify.py" + ], + "expected": "PASS_UNIVERSAL_CONNECTOR_BOUNDARY", + "inspect": "Reproduce the 945-pairing control, then read Exact interface to list the allowed calls.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Add exactly one legally priced operation and test a tiny dirty-input instance before enumerating larger cases.", + "bottleneck_link": "A new legal connector operation could change recursive interface cost; a larger census in the same alphabet is a separate side result.", + "allowed_variations": [ + "Choose one additional operation and a small source count for its first counterexample." + ], + "scope_change_triggers": [ + "Keeping the alphabet and only increasing the source count; record this as a changed assignment." + ], + "overlap_terms": [ + "universal connector", + "source-toggle", + "connector alphabet" + ] + }, + "scope_status": "changed", + "actual_scope": "Extend the #2761 dirty-shadow sym-diff collapse from Q=7 to Q=8 in the PR1898 alphabet: show legal dirty-shadow matches even-subset R>=74 (tariff 452) on all covering distinct-7 and one-dup lists, show illegal clean-shadow reaches R=67 (tariff 438) but still fails to undercut 436 at X=0, answering #2761/#2764 OQ2.", + "scope_change_reason": "The drawn connector-alphabet card is redirected to the explicit remaining dirty-shadow Q=8 handoff left by #2761 OQ2 / #2764 OQ2 on the #1898 lineage, using a freestanding package name outside hard leave-alones through #2817 (including transfer-coupled-7q-obstruction), deferred shared-XOR soft-overlap, and host screens.", + "bottleneck_link": "A priced dirty-shadow readout alphabet at Q=8 decides whether intermediate query counts can undercut the six-query endpoint by snapshot dual-row cheaper readouts after the Q=7 collapses.", + "budget_minutes": 60, + "stop_rule": "Stop after distinct-7 and one-duplicate dirty/clean censuses, sym-diff collapse, tariff consequence, package tests; no transfer-coupled reopen of #2817, no shared-XOR reopening, no host screens.", + "outcome": "completed", + "evidence": "CERTIFICATE.json distinct-7 dirty matches even {74:416640,80:1180480,84:833280}; clean counterfactual {67:416640,70:1180480,76:833280}; one-dup dirty=even {82,88}/clean {71,80}; champion dirty=74 clean=67; 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 (transfer-coupled shapes other than open #2817 (5,1,1)) undercut tariff 436 after charging both walks, transfers, and dirt?", + "why_it_matters": "Remaining dual-row direction after same-walk / dirty-shadow / dirty-parity collapses.", + "first_step": "Fix one new transfer-coupled shape with a new checkable fact beyond #2817's (5,1,1).", + "blocked_by": "Open #2817 package leave-alone; larger search." + }, + { + "question": "Does any other priced readout alphabet under PR1898 (b,a,x)=(38,2,2) undercut 436 at Q=8 after a complete dirty bill?", + "why_it_matters": "Closes remaining unequal-price handoffs at eight queries.", + "first_step": "Name one new alphabet and census dirt-legal R against tariff 436.", + "blocked_by": "Leave-alone packages through #2817; larger search." + } + ], + "predecessors": [ + { + "pr": 1898, + "credit": "Arham Tahir; minimum-query endpoint and abstract tariff fixture" + }, + { + "pr": 2761, + "credit": "Wentao Li; dirty-shadow / multi-connector at Q=7; OQ2 answered here" + }, + { + "pr": 2764, + "credit": "Wentao Li; dirty-parity collapse at Q=8; matching OQ2 handoff" + }, + { + "pr": 2677, + "credit": "Wentao Li; path-lowered 7-9Q invoices; distinct-slot R>=74 at Q=8" + }, + { + "pr": 2715, + "credit": "Wentao Li; cheaper-readout obstruction lineage" + }, + { + "pr": 2686, + "credit": "Wentao Li; even-subset R floor at Q=7" + }, + { + "pr": 2643, + "credit": "Wentao Li; seven-query XOR floor X>=6" + }, + { + "pr": 2455, + "credit": "ywz65; six-query XOR necessity" + }, + { + "pr": 1370, + "credit": "Arham Tahir; path-local shear lowering / four-X word" + }, + { + "pr": 1524, + "credit": "TennisBowling; equal-price theorem / unequal-price handoff" + } + ] +} diff --git a/research/dirty-shadow-8q-obstruction/VERIFY.json b/research/dirty-shadow-8q-obstruction/VERIFY.json new file mode 100644 index 0000000000..a4f6b19f29 --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/VERIFY.json @@ -0,0 +1,52 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/mutable-source-shear-cost/CERTIFICATE.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Distinct-7 dirty/even/clean census; one-duplicate layer; sym-diff identities; dirt obstruction; champion; certificate match; source pins" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Same admission under PYTHONOPTIMIZE via need()" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 180, + "checks": "Separate dirty-shadow census, one-dup layer, champion bit/DP agreement, tariff arithmetic" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 600, + "checks": "Corruption rejection, duplicate JSON keys, -O controls, independent replay" + } + ] +} diff --git a/research/dirty-shadow-8q-obstruction/independent.py b/research/dirty-shadow-8q-obstruction/independent.py new file mode 100644 index 0000000000..dffb181b6b --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/independent.py @@ -0,0 +1,290 @@ +#!/usr/bin/env python3 +"""Independent dirty-shadow / clean-shadow census at Q=8. + +Does not import model.py or verify.py. Prepared by Wentao Li with substantial +AI assistance. Apache-2.0. +""" +from __future__ import annotations + +import json +import os +from collections import Counter +from itertools import combinations +from multiprocessing import Pool +from pathlib import Path + +HERE = Path(__file__).resolve().parent +CERT_PATH = HERE / "CERTIFICATE.json" +CHAMPION = (0, 1, 2, 3, 4, 8, 16, 29) +INF = 99 + + +def fail(message): + raise SystemExit(f"FAIL_INDEPENDENT: {message}") + + +def gf2_rank(vals): + basis = [] + for v in vals: + x = v + for b in basis: + x = min(x, x ^ b) + if x: + basis.append(x) + basis.sort(reverse=True) + return len(basis) + + +def bit_bundle(slots): + """Bit-enumeration even / dirty-by-k / clean-by-k totals.""" + 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)] + return even_r, dirty_rs, clean_rs + + +def dp_bundle(slots): + """Separate even/odd DP; dirty equals even under collapse; clean min-over-k.""" + be = [INF] * 32 + bo = [INF] * 32 + be[0] = 0 + for v in slots: + ne = be[:] + no = bo[:] + for m in range(32): + e = be[m] + if e < INF: + nm = m ^ v + c = e + 1 + if c < no[nm]: + no[nm] = c + o = bo[m] + if o < INF: + nm = m ^ v + c = o + 1 + if c < ne[nm]: + ne[nm] = c + be, bo = ne, no + if any(be[m] >= INF for m in range(1, 32)): + return None + even_r = sum(be[1:]) + dirty_rs = [] + clean_rs = [] + for sigma in slots: + dirty_ok = True + cr = 0 + for m in range(1, 32): + e = be[m] + alt = bo[m ^ sigma] + if alt < INF and alt + 1 < e: + dirty_ok = False + c = e + e2 = be[m ^ sigma] + if e2 < INF and e2 + 1 < c: + c = e2 + 1 + if sigma == m and c > 1: + c = 1 + cr += c + dirty_rs.append(even_r if dirty_ok else -1) + clean_rs.append(cr) + if any(v < 0 for v in dirty_rs): + # Collapse failed: fall back to explicit dirty totals. + dirty_rs = [] + for sigma in slots: + dr = 0 + for m in range(1, 32): + d = be[m] + if bo[m ^ sigma] < INF: + d = min(d, bo[m ^ sigma] + 1) + dr += d + dirty_rs.append(dr) + return even_r, dirty_rs, clean_rs + + +def tariff(q, r, x): + return (28 * q + r) + (9 * q) + x + (q + r + x) + + +def _d7_worker(combos): + he, hd, hc = Counter(), Counter(), Counter() + covering = 0 + dirty_eq = 0 + for combo in combos: + if gf2_rank(combo) < 5: + continue + got = dp_bundle((0,) + combo) + if got is None: + continue + e, ds, cs = got + covering += 1 + dmin = min(ds) + cmin = min(cs) + he[e] += 1 + hd[dmin] += 1 + hc[cmin] += 1 + if dmin == e and all(v == e for v in ds): + dirty_eq += 1 + return covering, dirty_eq, he, hd, hc + + +def distinct7(): + combos = list(combinations(range(1, 32), 7)) + n = os.cpu_count() or 4 + chunk = (len(combos) + n - 1) // n + chunks = [combos[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_d7_worker, chunks) + covering = dirty_eq = 0 + he, hd, hc = Counter(), Counter(), Counter() + for c, de, a, d, cl in parts: + covering += c + dirty_eq += de + he.update(a) + hd.update(d) + hc.update(cl) + if covering != 2430400: + fail(f"covering {covering}") + if dict(he) != {74: 416640, 80: 1180480, 84: 833280}: + fail(f"even hist {dict(he)}") + if dict(hd) != {74: 416640, 80: 1180480, 84: 833280}: + fail(f"dirty hist {dict(hd)}") + if dict(hc) != {67: 416640, 70: 1180480, 76: 833280}: + fail(f"clean hist {dict(hc)}") + if dirty_eq != covering: + fail(f"match dirty={dirty_eq}") + return covering + + +def _dup_worker(items): + he, hd, hc = Counter(), Counter(), Counter() + covering = 0 + dirty_eq = 0 + for six, dup in items: + if gf2_rank(six) < 5: + continue + labels = (0,) + six + slots = tuple(sorted(labels + (dup,))) + got = dp_bundle(slots) + if got is None: + continue + e, ds, cs = got + covering += 1 + dmin = min(ds) + cmin = min(cs) + he[e] += 1 + hd[dmin] += 1 + hc[cmin] += 1 + if dmin == e and all(v == e for v in ds): + dirty_eq += 1 + return covering, dirty_eq, he, hd, hc + + +def one_dup(): + items = [] + for six in combinations(range(1, 32), 6): + labels = (0,) + six + for dup in labels: + items.append((six, dup)) + n = os.cpu_count() or 4 + chunk = (len(items) + n - 1) // n + chunks = [items[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_dup_worker, chunks) + covering = dirty_eq = 0 + he, hd, hc = Counter(), Counter(), Counter() + for c, de, a, d, cl in parts: + covering += c + dirty_eq += de + he.update(a) + hd.update(d) + hc.update(cl) + if covering != 4083072: + fail(f"one-dup covering {covering}") + if dict(he) != {82: 680512, 88: 3402560}: + fail(f"one-dup even {dict(he)}") + if dict(hd) != {82: 680512, 88: 3402560}: + fail(f"one-dup dirty {dict(hd)}") + if dict(hc) != {71: 680512, 80: 3402560}: + fail(f"one-dup clean {dict(hc)}") + if dirty_eq != covering: + fail(f"one-dup match {dirty_eq}") + return covering + + +def main(): + cert = json.loads(CERT_PATH.read_text(encoding="utf-8")) + covering = distinct7() + one_dup_covering = one_dup() + + bit = bit_bundle(CHAMPION) + dp = dp_bundle(CHAMPION) + if bit is None or dp is None or bit != dp: + fail(f"champion bit/dp {bit} {dp}") + e, ds, cs = bit + if e != 74 or min(ds) != 74 or min(cs) != 67 or any(v != 74 for v in ds): + fail(f"champion scores {bit}") + if tariff(8, 74, 0) != 452 or tariff(8, 67, 0) != 438: + fail("tariff") + if not ( + cert["claim"]["dirty_shadow_min_R"] == 74 + and cert["claim"]["clean_shadow_counterfactual_min_R"] == 67 + and cert["claim"]["undercuts_436_after_complete_dirty_bill"] is False + and cert["claim"]["undercuts_436_if_clean_shadow_free"] is False + and cert["claim"]["answers_mc7q_oq2"] is True + ): + fail("certificate claim drift") + + print( + "PASS_INDEPENDENT_DIRTY_SHADOW_8Q", + f"covering={covering}", + f"one_dup={one_dup_covering}", + "dirty_min=74", + "clean_counterfactual_min=67", + "tariff_legal=452", + "tariff_clean=438", + "answers_mc7q_oq2", + "matches_2677_even_floor", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/dirty-shadow-8q-obstruction/model.py b/research/dirty-shadow-8q-obstruction/model.py new file mode 100644 index 0000000000..7f2becb4e5 --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/model.py @@ -0,0 +1,520 @@ +"""Dirty-shadow sym-diff collapse at eight queries (PR1898 alphabet). + +Companion of #2761 (dirty-shadow at Q=7) and #2764 (dirty-parity at Q=8): +does the priced dirty-shadow snapshot collapse to even-subset via sym-diff +extend verbatim to length-8 slot lists? Self-contained relative to PR1898 / +#2677 / #2761 / #2764. Prepared by Wentao Li with substantial AI assistance. +Apache-2.0. +""" +from __future__ import annotations + +from collections import Counter +from itertools import combinations +from multiprocessing import Pool +import os + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +INF = 99 + +EXPECTED = { + "distinct7_covering": 2430400, + "even_subset_attainable_R": [74, 80, 84], + "even_subset_histogram": {"74": 416640, "80": 1180480, "84": 833280}, + "even_subset_min_R": 74, + "dirty_shadow_attainable_R": [74, 80, 84], + "dirty_shadow_histogram": {"74": 416640, "80": 1180480, "84": 833280}, + "dirty_shadow_min_R": 74, + "dirty_shadow_matches_even_covering": 2430400, + "clean_shadow_attainable_R": [67, 70, 76], + "clean_shadow_histogram": {"67": 416640, "70": 1180480, "76": 833280}, + "clean_shadow_min_R": 67, + "one_dup_covering": 4083072, + "one_dup_even_attainable_R": [82, 88], + "one_dup_even_histogram": {"82": 680512, "88": 3402560}, + "one_dup_even_min_R": 82, + "one_dup_dirty_attainable_R": [82, 88], + "one_dup_dirty_histogram": {"82": 680512, "88": 3402560}, + "one_dup_dirty_min_R": 82, + "one_dup_dirty_matches_even": 4083072, + "one_dup_clean_attainable_R": [71, 80], + "one_dup_clean_histogram": {"71": 680512, "80": 3402560}, + "one_dup_clean_min_R": 71, + "champion_slots": (0, 1, 2, 3, 4, 8, 16, 29), + "champion_even_R": 74, + "champion_dirty_shadow_min_R": 74, + "champion_clean_shadow_min_R": 67, + "champion_clean_best_k": 2, + "endpoint_tariff_Q6": 436, + "legal_tariff_at_X0": 452, + "hypothetical_clean_tariff_at_X0": 438, + "pr2677_even_distinct_floor": 74, +} + + +def tariff_qrx(q, r, x): + """Abstract complete-call tariff at (b,a,x)=(38,2,2).""" + leaves = 28 * q + r + nodes = 9 * q + dispatch = q + r + x + return leaves + nodes + x + dispatch + + +def gf2_rank(vals): + basis = [] + for v in vals: + x = v + for b in basis: + x = min(x, x ^ b) + if x: + basis.append(x) + basis.sort(reverse=True) + return len(basis) + + +def even_odd_tables(slots): + """DP min costs for even- and odd-cardinality realizing sets.""" + be = [INF] * 32 + bo = [INF] * 32 + be[0] = 0 + for v in slots: + ne = be[:] + no = bo[:] + for m in range(32): + e = be[m] + if e < INF: + nm = m ^ v + c = e + 1 + if c < no[nm]: + no[nm] = c + o = bo[m] + if o < INF: + nm = m ^ v + c = o + 1 + if c < ne[nm]: + ne[nm] = c + be, bo = ne, no + return be, bo + + +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. + + Clean shadow at index k: hypothetical dirt-free snapshot (illegal under + PR1898 arbitrary dirt — retained only as a counterfactual). + """ + need(type(slots) is tuple and slots and slots[0] == 0, "slots must start at 0") + be, bo = even_odd_tables(slots) + n = len(slots) + if any(be[m] >= INF for m in range(1, 32)): + return None + dirty = [[INF] * 32 for _ in range(n)] + clean = [[INF] * 32 for _ in range(n)] + for k, sigma in enumerate(slots): + dirty[k][0] = 0 + clean[k][0] = 0 + for m in range(32): + if be[m] < INF: + dirty[k][m] = min(dirty[k][m], be[m]) + clean[k][m] = min(clean[k][m], be[m]) + if bo[m ^ sigma] < INF: + dirty[k][m] = min(dirty[k][m], bo[m ^ sigma] + 1) + if be[m ^ sigma] < INF: + clean[k][m] = min(clean[k][m], be[m ^ sigma] + 1) + if sigma != 0 and 1 < clean[k][sigma]: + clean[k][sigma] = 1 + return {"even": be, "odd": bo, "dirty": dirty, "clean": clean} + + +def bit_enum_bundle(slots): + """Independent bit-enumeration oracle (used on small witnesses).""" + 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 + return {"even": even, "dirty": dirty, "clean": clean} + + +def total_or_none(best): + if any(best[mask] >= INF for mask in range(1, 32)): + return None + return sum(best[1:]) + + +def min_even_subset_R(slots): + info = mask_best_bundle(slots) + return None if info is None else total_or_none(info["even"]) + + +def dirty_shadow_R_by_k(slots): + info = mask_best_bundle(slots) + if info is None: + return None + return [total_or_none(info["dirty"][k]) for k in range(len(slots))] + + +def min_dirty_shadow_R(slots): + vals = dirty_shadow_R_by_k(slots) + if vals is None: + return None + ok = [v for v in vals if v is not None] + return min(ok) if ok else None + + +def clean_shadow_R_by_k(slots): + info = mask_best_bundle(slots) + if info is None: + return None + return [total_or_none(info["clean"][k]) for k in range(len(slots))] + + +def min_clean_shadow_R(slots): + vals = clean_shadow_R_by_k(slots) + if vals is None: + return None + ok = [v for v in vals if v is not None] + return min(ok) if ok else None + + +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 _census_scores(slots): + """Fast covering score: (even_r, dirty_matches_all_k, clean_min_r) or None. + + Dirty totals equal even when the per-mask collapse inequality holds for + every snapshot index; the census records that match rather than rebuilding + full dirty tables. + """ + be, bo = even_odd_tables(slots) + if any(be[m] >= INF for m in range(1, 32)): + return None + even_r = sum(be[1:]) + dirty_matches_all_k = True + clean_min = 10**9 + for sigma in slots: + clean_r = 0 + for m in range(1, 32): + e = be[m] + alt = bo[m ^ sigma] + if alt < INF and alt + 1 < e: + dirty_matches_all_k = False + c = e + e2 = be[m ^ sigma] + if e2 < INF and e2 + 1 < c: + c = e2 + 1 + if sigma == m and c > 1: + c = 1 + clean_r += c + if clean_r < clean_min: + clean_min = clean_r + return even_r, dirty_matches_all_k, clean_min + + +def _spectrum_worker(combos): + he, hd, hc = Counter(), Counter(), Counter() + covering = 0 + dirty_matches = 0 + first = {"even": {}, "dirty": {}, "clean": {}} + for combo in combos: + if gf2_rank(combo) < 5: + continue + slots = (0,) + combo + got = _census_scores(slots) + if got is None: + continue + even_r, dirty_ok, clean_r = got + if dirty_ok: + dirty_r = even_r + dirty_matches += 1 + else: + # Retain an explicit dirty total via the slow path if collapse fails. + info = mask_best_bundle(slots) + need(info is not None, "dirty fail uncovered") + dirty_r = min(total_or_none(info["dirty"][k]) for k in range(8)) + covering += 1 + he[even_r] += 1 + hd[dirty_r] += 1 + hc[clean_r] += 1 + first["even"].setdefault(even_r, slots) + first["dirty"].setdefault(dirty_r, slots) + first["clean"].setdefault(clean_r, slots) + return covering, dirty_matches, he, hd, hc, first + + +def _merge_first(dst, src): + for key, slots in src.items(): + prev = dst.get(key) + if prev is None or slots < prev: + dst[key] = slots + + +def enumerate_distinct7_shadow_spectrum(): + combos = list(combinations(range(1, 32), 7)) + n = os.cpu_count() or 4 + chunk = (len(combos) + n - 1) // n + chunks = [combos[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_spectrum_worker, chunks) + covering = dirty_matches = 0 + he, hd, hc = Counter(), Counter(), Counter() + first = {"even": {}, "dirty": {}, "clean": {}} + for c, dm, a, d, cl, fr in parts: + covering += c + dirty_matches += dm + he.update(a) + hd.update(d) + hc.update(cl) + for kind in ("even", "dirty", "clean"): + _merge_first(first[kind], fr[kind]) + return { + "covering_sets": covering, + "dirty_matches_even_on_covering": dirty_matches, + "even_subset": { + "attainable_R": sorted(he), + "histogram": {str(k): he[k] for k in sorted(he)}, + "min_R": min(he) if he else None, + "first_witnesses": { + str(r): list(slots) for r, slots in sorted(first["even"].items()) + }, + }, + "dirty_shadow": { + "attainable_R": sorted(hd), + "histogram": {str(k): hd[k] for k in sorted(hd)}, + "min_R": min(hd) if hd else None, + "matches_even_on_covering": dirty_matches, + "first_witnesses": { + str(r): list(slots) for r, slots in sorted(first["dirty"].items()) + }, + }, + "clean_shadow_counterfactual": { + "attainable_R": sorted(hc), + "histogram": {str(k): hc[k] for k in sorted(hc)}, + "min_R": min(hc) if hc else None, + "first_witnesses": { + str(r): list(slots) for r, slots in sorted(first["clean"].items()) + }, + "legal_under_dirty_contract": False, + }, + } + + +def _one_dup_worker(items): + he, hd, hc = Counter(), Counter(), Counter() + covering = 0 + dirty_matches = 0 + mins = [999, 999, 999] + wits = [None, None, None] + for six, dup in items: + if gf2_rank(six) < 5: + continue + labels = (0,) + six + slots = tuple(sorted(labels + (dup,))) + got = _census_scores(slots) + if got is None: + continue + even_r, dirty_ok, clean_r = got + dirty_r = even_r + if dirty_ok: + dirty_matches += 1 + else: + info = mask_best_bundle(slots) + need(info is not None, "dirty fail uncovered") + dirty_r = min(total_or_none(info["dirty"][k]) for k in range(8)) + covering += 1 + he[even_r] += 1 + hd[dirty_r] += 1 + hc[clean_r] += 1 + if even_r < mins[0]: + mins[0] = even_r + wits[0] = slots + if dirty_r < mins[1]: + mins[1] = dirty_r + wits[1] = slots + if clean_r < mins[2]: + mins[2] = clean_r + wits[2] = slots + return covering, dirty_matches, he, hd, hc, mins, wits + + +def enumerate_one_duplicate_shadow_spectrum(): + """Length-8 multisets with exactly seven distinct labels including 0.""" + items = [] + for six in combinations(range(1, 32), 6): + labels = (0,) + six + for dup in labels: + items.append((six, dup)) + n = os.cpu_count() or 4 + chunk = (len(items) + n - 1) // n + chunks = [items[i * chunk : (i + 1) * chunk] for i in range(n)] + with Pool(n) as pool: + parts = pool.map(_one_dup_worker, chunks) + covering = dirty_matches = 0 + he, hd, hc = Counter(), Counter(), Counter() + mins = [999, 999, 999] + wits = [None, None, None] + for c, dm, a, d, cl, mn, w in parts: + covering += c + dirty_matches += dm + he.update(a) + hd.update(d) + hc.update(cl) + for i in range(3): + if mn[i] < mins[i]: + mins[i] = mn[i] + wits[i] = w[i] + return { + "covering_multisets": covering, + "dirty_matches_even_on_covering": dirty_matches, + "even_subset": { + "attainable_R": sorted(he), + "histogram": {str(k): he[k] for k in sorted(he)}, + "min_R": mins[0], + "first_witness": list(wits[0]) if wits[0] is not None else None, + }, + "dirty_shadow": { + "attainable_R": sorted(hd), + "histogram": {str(k): hd[k] for k in sorted(hd)}, + "min_R": mins[1], + "matches_even_on_covering": dirty_matches, + "first_witness": list(wits[1]) if wits[1] is not None else None, + }, + "clean_shadow_counterfactual": { + "attainable_R": sorted(hc), + "histogram": {str(k): hc[k] for k in sorted(hc)}, + "min_R": mins[2], + "first_witness": list(wits[2]) if wits[2] is not None else None, + "legal_under_dirty_contract": False, + }, + } + + +def clean_shadow_dirt_examples(): + """Finite checks: dirt-free shadow schedules fail inherited-dirt cancellation.""" + examples = [] + slots = EXPECTED["champion_slots"] + k = EXPECTED["champion_clean_best_k"] + sigma = slots[k] + 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), + } + ) + witness = (0, 1, 2, 3, 4, 8, 12, 16) + k2 = min(range(8), key=lambda i: clean_shadow_R_by_k(witness)[i]) + examples.append( + { + "note": "first_clean_70_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"] + dirty_by_k = dirty_shadow_R_by_k(slots) + clean_by_k = clean_shadow_R_by_k(slots) + need(dirty_by_k is not None and clean_by_k is not None, "champion uncovered") + return { + "slots": list(slots), + "even_R": min_even_subset_R(slots), + "dirty_shadow_R_by_k": dirty_by_k, + "dirty_shadow_min_R": min(dirty_by_k), + "clean_shadow_R_by_k": clean_by_k, + "clean_shadow_min_R": min(clean_by_k), + "clean_best_k": min(range(8), key=lambda i: clean_by_k[i]), + "legal_tariff_X0": tariff_qrx(8, min(dirty_by_k), 0), + "hypothetical_clean_tariff_X0": tariff_qrx(8, min(clean_by_k), 0), + "endpoint_Q6": EXPECTED["endpoint_tariff_Q6"], + "symdiff_checked_at_k2": dirty_shadow_symdiff_identities(slots, 2), + } + + +CHAMPION_8 = EXPECTED["champion_slots"] diff --git a/research/dirty-shadow-8q-obstruction/test_package.py b/research/dirty-shadow-8q-obstruction/test_package.py new file mode 100644 index 0000000000..8d5773b788 --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/test_package.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Package fault controls for dirty-shadow 8q obstruction. Wentao Li + AI.""" +from __future__ import annotations + +import json +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PKG_NAME = "dirty-shadow-8q-obstruction" + + +def need(ok, message): + if not ok: + raise SystemExit(f"FAIL_TEST: {message}") + + +def run(args, cwd=None): + return subprocess.run(args, cwd=cwd or ROOT, text=True, capture_output=True) + + +def main(): + # 1) Default read-only verify. + proc = run([sys.executable, "-I", "-B", str(HERE / "verify.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_DIRTY_SHADOW_8Q_OBSTRUCTION" in proc.stdout, proc.stdout) + + # 2) -O admission via need(). + proc = run([sys.executable, "-I", "-O", "-B", str(HERE / "verify.py")]) + need(proc.returncode == 0, proc.stderr + proc.stdout) + need("PASS_DIRTY_SHADOW_8Q_OBSTRUCTION" in proc.stdout, proc.stdout) + + # 3) Certificate claim corruption fails. + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + research = tmp_path / "research" / PKG_NAME + shutil.copytree(HERE, research) + pinned = tmp_path / "research" / "mutable-source-shear-cost" + pinned.mkdir(parents=True) + shutil.copy2( + ROOT / "research" / "mutable-source-shear-cost" / "CERTIFICATE.json", + pinned / "CERTIFICATE.json", + ) + cert = research / "CERTIFICATE.json" + data = json.loads(cert.read_text(encoding="utf-8")) + data["claim"]["dirty_shadow_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_DIRTY_SHADOW_8Q" in proc.stdout, proc.stdout) + + # 6) Duplicate JSON key rejection. + with tempfile.TemporaryDirectory() as tmp: + tmp_path = Path(tmp) + research = tmp_path / "research" / PKG_NAME + shutil.copytree(HERE, research) + pinned = tmp_path / "research" / "mutable-source-shear-cost" + pinned.mkdir(parents=True) + shutil.copy2( + ROOT / "research" / "mutable-source-shear-cost" / "CERTIFICATE.json", + pinned / "CERTIFICATE.json", + ) + cert = research / "CERTIFICATE.json" + raw = cert.read_text(encoding="utf-8") + corrupted = raw.replace( + '"schema_version": 1,', + '"schema_version": 1,\n "schema_version": 2,', + 1, + ) + need(corrupted != raw, "failed to inject duplicate key") + cert.write_text(corrupted, encoding="utf-8") + proc = run([sys.executable, "-I", "-B", str(research / "verify.py")], cwd=tmp_path) + need(proc.returncode != 0, "duplicate JSON key should fail") + + print("PASS_DIRTY_SHADOW_8Q_PACKAGE_TESTS groups=6") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/dirty-shadow-8q-obstruction/verify.py b/research/dirty-shadow-8q-obstruction/verify.py new file mode 100644 index 0000000000..2a6cca9939 --- /dev/null +++ b/research/dirty-shadow-8q-obstruction/verify.py @@ -0,0 +1,345 @@ +#!/usr/bin/env python3 +"""Dirty-shadow sym-diff collapse at Q=8; read-only default. + +Prepared by Wentao Li with substantial AI assistance. Apache-2.0. +""" +from __future__ import annotations + +import argparse +import hashlib +import json +import sys +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +from model import ( # noqa: E402 + CHAMPION_8, + EXPECTED, + bit_enum_bundle, + champion_analysis, + clean_shadow_dirt_examples, + dirty_shadow_symdiff_identities, + enumerate_distinct7_shadow_spectrum, + enumerate_one_duplicate_shadow_spectrum, + mask_best_bundle, + min_clean_shadow_R, + min_dirty_shadow_R, + min_even_subset_R, + tariff_qrx, + total_or_none, +) + +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["dirty_shadow_min_R"] == EXPECTED["dirty_shadow_min_R"], "dirty min") + need(claim["even_subset_min_R"] == EXPECTED["even_subset_min_R"], "even min") + need( + claim["clean_shadow_counterfactual_min_R"] == EXPECTED["clean_shadow_min_R"], + "clean min", + ) + need(claim["undercuts_436_if_clean_shadow_free"] is False, "clean undercut flag") + need(claim["undercuts_436_after_complete_dirty_bill"] is False, "legal undercut") + need(claim["matches_2677_even_floor"] is True, "2677 floor") + need(claim["answers_mc7q_oq2"] is True, "oq2 flag") + need(claim["no_new_kappa"] is True, "kappa") + + +def totals_from_bundle(info): + even_r = total_or_none(info["even"]) + dirty_r = min(total_or_none(info["dirty"][k]) for k in range(len(info["dirty"]))) + clean_r = min(total_or_none(info["clean"][k]) for k in range(len(info["clean"]))) + return even_r, dirty_r, clean_r + + +def build_certificate(): + # DP vs bit-enum agreement on champion and nearby witnesses. + for slots in ( + CHAMPION_8, + (0, 1, 2, 3, 4, 8, 12, 16), + (0, 1, 2, 3, 4, 5, 8, 16), + (0, 0, 1, 2, 4, 8, 15, 16), + ): + dp = mask_best_bundle(slots) + bit = bit_enum_bundle(slots) + need(dp is not None and bit is not None, f"uncovered {slots}") + need(totals_from_bundle(dp) == totals_from_bundle(bit), f"DP/bit mismatch {slots}") + need( + all( + total_or_none(dp["dirty"][k]) == total_or_none(bit["dirty"][k]) + for k in range(len(slots)) + ), + f"dirty-by-k mismatch {slots}", + ) + need( + all( + total_or_none(dp["clean"][k]) == total_or_none(bit["clean"][k]) + for k in range(len(slots)) + ), + f"clean-by-k mismatch {slots}", + ) + + 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["legal_tariff_X0"] == EXPECTED["legal_tariff_at_X0"], "legal tariff") + need( + champ["hypothetical_clean_tariff_X0"] == EXPECTED["hypothetical_clean_tariff_at_X0"], + "clean tariff", + ) + need(champ["legal_tariff_X0"] > EXPECTED["endpoint_tariff_Q6"], "legal must not undercut") + need( + champ["hypothetical_clean_tariff_X0"] > EXPECTED["endpoint_tariff_Q6"], + "clean also fails undercut at X=0", + ) + need(all(v == champ["even_R"] for v in champ["dirty_shadow_R_by_k"]), "dirty==even all k") + + dirt = clean_shadow_dirt_examples() + need(len(dirt) >= 2, "dirt examples") + + need(min_even_subset_R(CHAMPION_8) == 74, "closed even") + need(min_dirty_shadow_R(CHAMPION_8) == 74, "closed dirty") + need(min_clean_shadow_R(CHAMPION_8) == 67, "closed clean") + need( + tariff_qrx(8, 74, 0) == 452 and tariff_qrx(8, 67, 0) == 438, + "tariff arithmetic", + ) + + # Sym-diff identities on champion for every snapshot index (2^{7}=128 odds). + for k in range(8): + need(dirty_shadow_symdiff_identities(CHAMPION_8, k) == 128, f"symdiff k={k}") + + distinct = enumerate_distinct7_shadow_spectrum() + need(distinct["covering_sets"] == EXPECTED["distinct7_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["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", + ) + + one_dup = enumerate_one_duplicate_shadow_spectrum() + need(one_dup["covering_multisets"] == EXPECTED["one_dup_covering"], "one-dup covering") + need( + one_dup["even_subset"]["attainable_R"] == EXPECTED["one_dup_even_attainable_R"], + "one-dup even spectrum", + ) + need( + one_dup["even_subset"]["histogram"] == EXPECTED["one_dup_even_histogram"], + "one-dup even hist", + ) + need(one_dup["even_subset"]["min_R"] == EXPECTED["one_dup_even_min_R"], "one-dup even min") + need( + one_dup["dirty_shadow"]["attainable_R"] == EXPECTED["one_dup_dirty_attainable_R"], + "one-dup dirty spectrum", + ) + need( + one_dup["dirty_shadow"]["histogram"] == EXPECTED["one_dup_dirty_histogram"], + "one-dup dirty hist", + ) + need(one_dup["dirty_shadow"]["min_R"] == EXPECTED["one_dup_dirty_min_R"], "one-dup dirty min") + need( + one_dup["dirty_shadow"]["matches_even_on_covering"] + == EXPECTED["one_dup_dirty_matches_even"], + "one-dup dirty matches", + ) + need( + one_dup["clean_shadow_counterfactual"]["attainable_R"] + == EXPECTED["one_dup_clean_attainable_R"], + "one-dup clean spectrum", + ) + need( + one_dup["clean_shadow_counterfactual"]["histogram"] + == EXPECTED["one_dup_clean_histogram"], + "one-dup clean hist", + ) + need( + one_dup["clean_shadow_counterfactual"]["min_R"] == EXPECTED["one_dup_clean_min_R"], + "one-dup clean min", + ) + + return { + "schema_version": 1, + "status": "PASS_DIRTY_SHADOW_8Q_OBSTRUCTION", + "scope": ( + "Five-source common-B mutable-source Q/R/X alphabet (PR1898). " + "Priced dirty-shadow snapshot readout at Q=8: sym-diff collapse to " + "even-subset, plus illegal clean-shadow counterfactual. Answers " + "#2761 OQ2 / #2764 OQ2 (dirty-shadow at eight queries)." + ), + "claim": { + "Q": 8, + "dirty_shadow_min_R": 74, + "even_subset_min_R": 74, + "clean_shadow_counterfactual_min_R": 67, + "one_dup_dirty_min_R": 82, + "one_dup_clean_counterfactual_min_R": 71, + "undercuts_436_if_clean_shadow_free": False, + "undercuts_436_after_complete_dirty_bill": False, + "legal_tariff_at_X0": 452, + "hypothetical_clean_tariff_at_X0": 438, + "endpoint_Q6_tariff": 436, + "matches_2677_even_floor": True, + "answers_mc7q_oq2": True, + "oq2_answer": ( + "The dirty-shadow sym-diff collapse extends verbatim to eight " + "queries: on all 2430400 covering distinct-7 length-8 slot lists, " + "priced dirty-shadow totals match even-subset exactly (spectrum " + "{74,80,84}; matches_even=2430400), so legal R>=74 and tariff " + ">=452>436 at X=0, matching #2677. One-duplicate multisets likewise " + "collapse (spectrum {82,88} on 4083072 covering lists). A dirt-free " + "shadow would reach R=67 (tariff 438) on distinct-7 and R=71 " + "(tariff 446) on one-dup, but both still fail to undercut 436 at " + "X=0 and remain illegal under PR1898 inherited dirt; shadow-only " + "reads leave odd dirt. After a complete dirty bill, legal " + "dirty-shadow alphabets stay at tariff >=452 and do not undercut " + "the six-query endpoint 436." + ), + "no_new_kappa": True, + }, + "champion": champ, + "clean_shadow_dirt_examples": dirt, + "distinct7": distinct, + "one_duplicate": one_dup, + "leave_alone": { + "through": 2817, + "includes": [ + 2487, + 2593, + 2643, + 2677, + 2686, + 2687, + 2715, + 2761, + 2764, + 2779, + 2817, + ], + "deferred": [ + "transfer-coupled-dual-7q soft-overlap", + "shared-xor soft-overlap #2643", + "host screens", + ], + "do_not_touch_package": "research/transfer-coupled-7q-obstruction/", + }, + } + + +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_DIRTY_SHADOW_8Q_OBSTRUCTION", + "dirty_shadow_min_R=74", + "even_subset_min_R=74", + "clean_counterfactual_min_R=67", + "legal_tariff=452", + "hypothetical_clean_tariff=438", + "no_undercut_even_if_clean_free_at_X0", + "no_undercut_after_complete_dirty_bill", + "answers_mc7q_oq2", + "matches_2677_even_floor", + "no_new_kappa", + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())