diff --git a/docs/ci-verification.md b/docs/ci-verification.md index 63ba3e9aa8..52b62d0481 100644 --- a/docs/ci-verification.md +++ b/docs/ci-verification.md @@ -1,8 +1,25 @@ # CI verification -## Current selected-family replay: #6030 +## Current selected-family replay: #7000 with #7001 The [selected record](../certificates/selected-result.json) binds conditional +κ = 0.00363005817 to the [application review](research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md), +[validation receipts](research/pr-intake-evidence/pr7000-application/VALIDATION.json), +and [explicit source closure](../certificates/frontier7000-source.json). +`make frontier7000-verify` follows that exact-source selected replay. The review +reuses eleven authenticated preceding executions and records seven fresh serial +application, scalar and complete native-catalogue executions. The earlier +monolithic timeout is retained separately and is not completed coverage. +Consult the receipts for exact commands, source heads and limits. + +The five inherited framework assumptions remain. No complete uniform word, +literal multiplier execution, independent human proof or formal-kernel proof +is asserted. Routine research submissions do not need to rerun this +selected-family replay. The sections below preserve historical checkpoints. + +## Historical selected-family replay: #6030 + +The [historical checkpoint](../certificates/checkpoints/frontier6030.json) binds conditional κ = 0.003125804 to the [proof review](research/pr-intake-evidence/pr6030-audit/PROOF-REVIEW.md), [validation receipts](research/pr-intake-evidence/pr6030-audit/VALIDATION.json), and [explicit source closure](../certificates/frontier6030-source.json). diff --git a/research/historical-selected-replay-gap/README.md b/research/historical-selected-replay-gap/README.md index 55d8cc3b49..36d9a873ca 100644 --- a/research/historical-selected-replay-gap/README.md +++ b/research/historical-selected-replay-gap/README.md @@ -69,7 +69,11 @@ python3 -B scripts/research_package.py --package research/historical-selected-re The direct command prints `PASS_HISTORICAL_SELECTED_REPLAY_GAP`. A registered replay prints `PASS_REGISTERED_RESEARCH_PACKAGE`. Both require Git history -containing the two inspected commits. +containing the two inspected commits and the source and manifest objects at +`2485805a6d47f36ea83ddde6327d453ac82d44dc`. The verifier uses a temporary +sparse checkout of that commit, checks the declared source digests there, and +uses its planner and manifest inventory. The recorded rejections and selection +therefore remain reproducible after later changes to the live Makefile or CI guide. ## Open next questions diff --git a/research/historical-selected-replay-gap/SOURCES.json b/research/historical-selected-replay-gap/SOURCES.json index c1010eec95..62bb8b3950 100644 --- a/research/historical-selected-replay-gap/SOURCES.json +++ b/research/historical-selected-replay-gap/SOURCES.json @@ -4,13 +4,13 @@ "files": [ { "path": "Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "0d683a06b9e7ee162496108ce9a7c5d2ee94fccf", "sha256": "4f2d4f2dcd15139ec82658a975f85ed300897385f85799218539f4c8d60567da" }, { "path": "certificates/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "eccafa830c16170c36faf93045ddf1f638f7bcd4", "sha256": "4c0b9d37e1034b2076e30a70f8e514416298c462d9ee98bc87fe6556b14df786" }, @@ -22,7 +22,7 @@ }, { "path": "docs/ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "63ba3e9aa8bdc5e942b56e34244b92b16f854085", "sha256": "c7d3027e9ad8bcbff68f07aa9576b30fb2f3c76c44d876d40c7fdbf4a3e2228a" }, @@ -34,163 +34,163 @@ }, { "path": "research/clifford-state-performance/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "6f98a0061a5104dfab82c9e806f819b41811f684", "sha256": "396d0f08df24952248140d5c65c51b8c902ef1c580892ff7ea182890530f67ee" }, { "path": "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "5e0f92af463ec12c5e1dcc3effd44081a88af647", "sha256": "07a9daeaf2bda308a92e9a4684f13d5fc766c7772d74801fceb7f4599fdab226" }, { "path": "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "9e13266bf85e627f1b7dc225e9530ea69fd2c7f0", "sha256": "421e1211fb1897c45621dc6801c276e53f2e6f335583c9c9049e535f87c0a3b1" }, { "path": "research/community-batch932-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "cc4d03eb59b9ab3f952735f7e88ff18c2d15d7af", "sha256": "184629cac91a5cfaca50330a88596008b824221433867dcf8117539c913c284a" }, { "path": "research/community-batch970-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8b9f4111badf7de5d97684799560b55110e9da79", "sha256": "23188ed920e38a54006cb883e181585620821c63bf7e8b5e05d32719417cc37e" }, { "path": "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "a5300d4e7a5381a3f443fc54c768ca6f0f236d68", "sha256": "3c820fb30e1b4d9bcfc6a7ab524375e5b2abd66b940af2c509146104f0bcd79c" }, { "path": "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "d7ff6d777b01d69b6ce84caf25d3b7e4a4d2f211", "sha256": "6b185a9902652f893f3ebd8ada92d2f11b6de6533a9a4d11718a8a4496101128" }, { "path": "research/community-hyperplane599-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "546f37d326d10a99910ae8f908e71ef768524d98", "sha256": "65099d764bfcc39bda5e4d9966783611b094c3522dbdd1435cd498d657a8ef8e" }, { "path": "research/community-k492-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "e538481e4cb16ed936d3195f2dfb5b5a9ca0a76b", "sha256": "2c0f4fa5bc150d05658af2e7c54c4d2c337dd52b7efd3d69530ae73bcbdf452a" }, { "path": "research/community-reconciliation92-audit/MANIFEST.json", - "usage": "input", + "usage": "provenance", "git_blob": "2a2e93685173d5f13cbb5abe740f5d90352e0228", "sha256": "5f501f3c118131e7d069f30ad77186eb2ad6961f9680a0ef105f4514ed41808a" }, { "path": "research/partial-swap-digest/baseline.py", - "usage": "input", + "usage": "provenance", "git_blob": "a2f0190704db83bd8ef48e46e723c49b925804fe", "sha256": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" }, { "path": "research/r420-two-sided-basis/SOURCES.json", - "usage": "input", + "usage": "provenance", "git_blob": "5d718e11e62f4bcadecf1e02d6b61f87dbe190b0", "sha256": "d9810b0d139c5a1211fd2c1f0d142187cc1fca30026e1e7bc4f9ecfacf1596d1" }, { "path": "research/skip-clones/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8d1bb3b9c8189e35e5d8bfdfa632d7473e8be0d5", "sha256": "0b68e63e35a97ce6b0cdb6e291b88ebaa8f2dd4afb70b2498f10ee89428258dc" }, { "path": "research/split-skip/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "2ab610b6ea2edd2865fda793ef2168b0c76afb4f", "sha256": "7c2b4646a3ecfef6f881da5c43e4bd0fa9a4d1b00548b8ab458d897e16735134" }, { "path": "scripts/historical-ci-inputs/Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "aff68409021c9d401a6f8013b9dfd7dbcc30f2a8", "sha256": "ea8830dd79da493e2d75baf753d733ff7efbcf2b4794afe41fae0ac8f3055646" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "65db599ab0b1dea0312c4ca048e0bd0f44c3736f", "sha256": "96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "34820a8f24678f918f4d0e7a35380d8013fc3495", "sha256": "628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac" }, { "path": "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "c755b76e0d44ba4917aa94440ebe54daefce5b2a", "sha256": "d7fd929726b326aeeaf0a3996475adec88eee9aac09ae0bebeeaa0bc1fc8f199" }, { "path": "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "7f3c012504187917a728b9fe87043f0fc8cd006a", "sha256": "a854022e0e1d5d4db4d60e586be3ea56005013ef14a1fc06d02bc06e8529c4b0" }, { "path": "scripts/historical-ci-inputs/partial-swap-context.json", - "usage": "input", + "usage": "provenance", "git_blob": "ad65114886bf34a4fd27e79f3be502389e689faa", "sha256": "833a9642f33aeab2ffea17ec9c6b82e0a953f90192b2c82e10bef21538dccba9" }, { "path": "scripts/historical-ci-inputs/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "52075f2463f60af5e16571347f24274fce73a1ea", "sha256": "f3c4be597b2f2136da4ae2cc80c7454f63c90aa01f84e5b8131cee4dd55de815" }, { "path": "scripts/partial_swap/shared.py", - "usage": "input", + "usage": "provenance", "git_blob": "44a0e454c70f9c4b98e258b8443612e6a119904b", "sha256": "5a0646a50b9f3e8ea55168620a78e8853b0ab810517cefc8cfb8696aedee278a" }, { "path": "scripts/replay_historical_check.py", - "usage": "input", + "usage": "provenance", "git_blob": "1e92fff2782970ef71378f594f2350d245a4db26", "sha256": "5467619c78183d3adc82b0cb55af28e5c1a01fca2b0588677816244b53e2bafd" }, { "path": "scripts/research_package.py", - "usage": "input", + "usage": "provenance", "git_blob": "091b4c8f58bac9a9580d76025b887dc5c873d05f", "sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70" }, { "path": "scripts/run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "a96ab35b315ce492e7fbbfd6c5ae211aa066b541", "sha256": "49eb56dd0fc0d8d8ffdb209970a7adf2176223580646f575d5c22e59543b381c" }, { "path": "scripts/verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "6882a4700e410dec569b51ae2eaf1a19cc019195", "sha256": "d6b305eac5b9bdb8172c469ad30a1655a60fa0aceac8b1bf610e1b73f51babd8" }, { "path": "tests/test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "343b24abf6719b81805eba5a84c74e57634c8288", "sha256": "3a5470d0b139828b90e19bf9583ddeafcd69f8e34f2824664eb3a2958a52e34d" } diff --git a/research/historical-selected-replay-gap/VERIFY.json b/research/historical-selected-replay-gap/VERIFY.json index 98553e72ed..ab7efa3471 100644 --- a/research/historical-selected-replay-gap/VERIFY.json +++ b/research/historical-selected-replay-gap/VERIFY.json @@ -4,36 +4,7 @@ "python": "3.12", "requirements": [], "inputs": [ - "Makefile", - "certificates/partial-swap-network.json", - "docs/ci-verification.md", - "research/clifford-state-performance/SOURCE.json", - "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "research/community-batch932-audit/CONTENT-COVERAGE.json", - "research/community-batch970-audit/CONTENT-COVERAGE.json", - "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "research/community-hyperplane599-audit/SOURCE.json", - "research/community-k492-audit/SOURCE.json", - "research/community-reconciliation92-audit/MANIFEST.json", - "research/partial-swap-digest/baseline.py", - "research/r420-two-sided-basis/SOURCES.json", - "research/skip-clones/SOURCE.json", - "research/split-skip/SOURCE.json", - "scripts/historical-ci-inputs/Makefile", - "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "scripts/historical-ci-inputs/partial-swap-context.json", - "scripts/historical-ci-inputs/partial-swap-network.json", - "scripts/partial_swap/shared.py", - "scripts/replay_historical_check.py", - "scripts/research_package.py", - "scripts/run_isolated_tests.py", - "scripts/verify_selected_result.py", - "tests/test_isolated_test_runner.py" + "scripts/research_package.py" ], "commands": [ { diff --git a/research/historical-selected-replay-gap/verify.py b/research/historical-selected-replay-gap/verify.py index 83b995941a..9d266c5a4e 100644 --- a/research/historical-selected-replay-gap/verify.py +++ b/research/historical-selected-replay-gap/verify.py @@ -6,8 +6,10 @@ """ import hashlib import importlib.util +import json import subprocess import sys +import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parents[2] @@ -61,31 +63,47 @@ def require(ok, message): raise SystemExit(message) -def load_checker(): - path = ROOT / "scripts/replay_historical_check.py" - spec = importlib.util.spec_from_file_location("historical_selected_replay_gap_checker", path) +def load_module(path): + spec = importlib.util.spec_from_file_location(path.stem, path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module +def checkout_snapshot(snapshot, sources, runner, env): + paths = [runner.canonical_relative_path(row["path"]) for row in sources["files"]] + git = ["git", "-c", "maintenance.auto=false", "-c", "gc.auto=0", + "-c", "core.autocrlf=false"] + subprocess.run([*git, "clone", "--quiet", "--shared", "--no-tags", "--no-checkout", + "--", str(ROOT), str(snapshot)], cwd=ROOT, env=env, check=True) + subprocess.run([*git, "update-ref", "--no-deref", "HEAD", INSPECTED], + cwd=snapshot, env=env, check=True) + # The pinned planner reads omitted manifests from the sparse HEAD/index. + patterns = "".join(f"/{path.as_posix()}\n" for path in paths) + subprocess.run([*git, "sparse-checkout", "set", "--no-cone", "--stdin"], + cwd=snapshot, env=env, input=patterns.encode("utf-8"), check=True) + subprocess.run([*git, "read-tree", "-mu", "HEAD"], cwd=snapshot, env=env, check=True) + for path, row in zip(paths, sources["files"], strict=True): + require(hashlib.sha256((snapshot / path).read_bytes()).hexdigest() == row["sha256"], + "historical checkout source digest changed: " + path.as_posix()) + + def entries(checker): for name, config in checker.CONFIG.items(): for entry in [config, *config.get("additional_inputs", [])]: yield name, entry -def reject(checker, entry): +def reject(root, checker, entry): try: - checker.authenticated_input(ROOT, entry) + checker.authenticated_input(root, entry) except ValueError as exc: return str(exc) raise SystemExit("historical input was admitted: " + entry["path"]) -def main(): - require(not sys.flags.optimize, "assertions must stay enabled") - checker = load_checker() +def check_snapshot(root, env): + checker = load_module(root / "scripts/replay_historical_check.py") selected = [entry for name, entry in entries(checker) if name == "tooling-ledger" and entry["path"] == SELECTED_PATH] require(len(selected) == 1, "selected-result checker overlay is not unique") @@ -94,7 +112,7 @@ def main(): require(entry["accepted_live_sha256"] == [SELECTED_ACCEPTED], "accepted selected-checker successors changed") frozen = (checker.INPUTS / entry["input"]).read_bytes() - live = (ROOT / SELECTED_PATH).read_bytes() + live = (root / SELECTED_PATH).read_bytes() require(hashlib.sha256(frozen).hexdigest() == SELECTED_PIN, "frozen selected checker bytes changed") require(hashlib.sha256(live).hexdigest() == SELECTED_LIVE, "live selected checker digest changed") require(SELECTED_LIVE not in (SELECTED_PIN, SELECTED_ACCEPTED), "live checker was already admitted") @@ -102,7 +120,7 @@ def main(): # live successor, not a broken comparison. require(SELECTED_PIN in (SELECTED_PIN, *entry["accepted_live_sha256"]), "pin membership control failed") - require(reject(checker, entry) == REJECTIONS[SELECTED_PATH][1], + require(reject(root, checker, entry) == REJECTIONS[SELECTED_PATH][1], "selected checker rejection text changed") counts = {path: 0 for path in REJECTIONS} @@ -110,7 +128,7 @@ def main(): for _name, item in entries(checker): if item["path"] not in REJECTIONS: continue - message = reject(checker, item) + message = reject(root, checker, item) counts[item["path"]] += 1 messages.setdefault(item["path"], message) for path, (count, message) in REJECTIONS.items(): @@ -118,20 +136,31 @@ def main(): require(messages[path] == message, "rejection text changed for " + path) require(sum(counts.values()) == 19, "rejection total changed") ci = [item for _name, item in entries(checker) if item["path"] == CI_PATH] - require(len(ci) == 1 and hashlib.sha256((ROOT / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, + require(len(ci) == 1 and hashlib.sha256((root / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, "selected CI note digest changed") diff = subprocess.check_output( - ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=ROOT, text=True) + ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=root, env=env, text=True) changed = sorted(name for name in diff.splitlines() if name) require(changed == CHANGED, "inspected commit diff changed") - sys.path.insert(0, str(ROOT / "scripts")) - from research_package import plan_details - details = plan_details(ROOT, set(changed)) + planner = load_module(root / "scripts/research_package.py") + details = planner.plan_details(root, set(changed)) require([row["package"] for row in details] == PLAN_PACKAGES, "helper plan selection changed") matched = {name for row in details for names in row["causes"].values() for name in names} require(sorted(set(changed) - matched) == UNMATCHED, "unmatched plan paths changed") - require(plan_details(ROOT, set()) == [], "empty change set selected a package") + require(planner.plan_details(root, set()) == [], "empty change set selected a package") + + +def main(): + require(not sys.flags.optimize, "assertions must stay enabled") + sources = json.loads(Path(__file__).with_name("SOURCES.json").read_bytes()) + require(sources["base_commit"] == INSPECTED, "historical checkout base changed") + runner = load_module(ROOT / "scripts/research_package.py") + env = runner.git_source_env() + with tempfile.TemporaryDirectory(prefix="historical-selected-replay-") as temporary: + snapshot = Path(temporary) / "snapshot" + checkout_snapshot(snapshot, sources, runner, env) + check_snapshot(snapshot, env) print("PASS_HISTORICAL_SELECTED_REPLAY_GAP") print("selected_checker_live=" + SELECTED_LIVE) print("rejections=19 distinct_paths=7 plan_packages=9") diff --git a/research/p104-methods/NOTICE b/research/p104-methods/NOTICE new file mode 100644 index 0000000000..0874b92228 --- /dev/null +++ b/research/p104-methods/NOTICE @@ -0,0 +1,24 @@ +Apache-2.0. DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. + +data/base-7334-word.json.gz is the unmodified WORD.json.gz of +research/p104-helper-319-fused-return at #7334 head +aaeec8c0acf01e99a5f331ef363a698d9c084ace (Clear1nsight, with substantial +OpenAI Codex assistance; Apache-2.0), the same bytes vendored by #7542. Credit +Clear1nsight for #7334 and #7314. + +The #7113 caller data used by callers.py (and the B-side events of the joint +MONOHUB caller) are Rohan Arun's signed #7113 caller; credit Rohan Arun. + +The E8/P104 Gram matrix is computed from the repository file +research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt (PR968 +decoder, pinned in SOURCES.json) as D T^T / 2; credit the PR968 authors. The +F2^9 port vectors and the signed Gram in data/ were read from the charts of the +#7334 word family and reconstructed by reflection closure in our own lanes. + +Credit ToikY for the price engines and replay lineage and the other +contributors of the P104 price and replay lineage for the conventions used here. +Lemma E, the sigma-rank o and the hub bound are from #7555; the charge law, the +corrected anchored law and the sigma-anchor schedule are from #7557. + +All checkers in this package are our own code; no code is imported from the +repository or any other package. diff --git a/research/p104-methods/PROOF.md b/research/p104-methods/PROOF.md new file mode 100644 index 0000000000..d853a465e5 --- /dev/null +++ b/research/p104-methods/PROOF.md @@ -0,0 +1,110 @@ +# Proofs and premises + +Conventions follow [#7555](https://github.com/CrocSwap/integer-mult-bounds/pull/7555) and +[#7557](https://github.com/CrocSwap/integer-mult-bounds/pull/7557). A word is a sequence of +equal-chart ADD/COPY/SCALE events and MOVEs; public MOVEs strictly ascend, owned MOVEs are nested. +{0} is the zero chart and V the full chart. G is the Gram matrix of the port roots, Z = G/2 − I on partner +cells (G_pt odd), and X_p's target is x_p + Σ_t Z_pt y_t (relay family) or the t = −1 contract of #7557. +Only the statements below are claimed as proved. Everything else in README.md is either an exact run +(tag [C], reproduced by a checker in this package) or a quoted lane number (tag [Q], not reproduced here). + +## 1. {0}/V re-basis + +**Lemma 1.1 ({0} freedom).** Order the registers that leave {0} by departure time d_r. The departure +tuples realisable by changing only the {0}-phase events are exactly the images of the given tuple under +lower-unitriangular maps in that order (and diagonal scalings, if SCALE is allowed). +*Proof.* At {0} every ADD is between registers that both still sit at {0}, so register r can receive only +contents of registers that have not left. Composing the {0}-phase ADDs gives a matrix that is +unitriangular in departure order. Conversely, an ADD r += c·s placed just before d_r, with s still at +{0}, realises each elementary unitriangular factor. Contents of registers still at {0} at d_r equal their +own departure contents up to the same triangular mixing, so the family is linear in the coefficients +with no cross terms. ∎ + +**Lemma 1.2 (V freedom).** Nothing leaves V. After the last event every V-ending register sits at V, +so any invertible recombination of the V-ending registers can be appended (LU into elementary ADDs, +plus SCALEs if the determinant is not 1). Hence a modified word is correct on the V-ending registers iff +span(new V-arrival contents) = W_V := span(their final rows), i.e. every new V-arrival row lies in W_V. +All other rows (non-V publics, owned) must be exact. ∎ + +**The exact test.** Let E = (base finals) − (new finals) after a candidate edit (deleting a rung's +ADDs). Choose one basis of content space adapted to the {0} flag S_{r₁} ⊇ S_{r₂} ⊇ … of Lemma 1.1 and to +W_V (a flag and one subspace always admit a common adapted basis). By Lemmas 1.1 and 1.2 the edit is +repairable by {0} and V freedom iff for every basis vector b, +E_b[rows(b)] ∈ col{G_r(d_r)[rows(b)] : d_r < level(b)}, with rows(b) the non-V rows if b ∈ W_V and all +rows otherwise; a vector beyond the flag (an input never at {0}) gets no {0} freedom. This is a +direct reformulation of the two lemmas (sketch; the general test is not re-run in this package). The +package checks the instance used by #7542, helper 761 at chart 1053, with `rebasis.py` [C]. + +## 2. Absorption + +**Identity.** Let X_r(τ) = X_r^f + Σ_t ψ_rt Y_t^f. A helper H born at {0} lumps −λ·y there, is read +at its low stops, does H += Σ_r d_r X_r(τ_K) at a chart K where the X_r sit, and H −= Σ_r d_r X_r^f at V. +Then H = h + Σ_t (Σ_r d_r ψ_rt − λ_t) Y_t^f, so **H ends clean iff λ = Σ_r d_r ψ_r(τ_K)**. Readers at +earlier stops received a_p·(−λ). ∎ (Two lines of linear algebra; `absorption.py` checks it exactly.) + +**Legality (premises).** All ADDs are equal-chart (H with the X_r at K; at V). H's chain +{0} ⊂ … ⊂ K ⊂ V strictly ascends. Between its read stops and K, H holds y-charge only on supp λ ⊆ U(K), +so it stays inside each t^⊥ that its charts must respect; after K it holds no y-charge. The X_r are +referenced, not consumed. This was replayed with an LC1 check after every operation on a real E8-port +instance in the lane (ABSORBAUDIT) [Q]; this package checks the algebra, not frames. + +**Deficiency.** With every cell settled the relay-family deficiency is n − r (#7557 law 1); absorbed +cells count as settled because every later cleaning of the referenced junk reads Y after it is final. +Under the σ-anchor schedule of #7557 (one early cell per column on a perfect partner matching), the +frame-free toy algebra gives D = 0 with absorbers filling the settled set, provided each absorber reads +X_r(K) only when (r, t) is X_r's last outstanding cell [C on A3/A4, frame-free; no general proof]. + +## 3. Range-G y pre-loads + +**Lemma 3.1 (span law).** For any up-closed set W of charts and any time τ, +span(contents of registers in W at τ) ⊆ span(final rows in W) + span(rows CLEARed in, or owned-moved +out of, W after τ). +*Proof.* An ADD acts between registers at the same chart, so both or neither are in W, and inside W it +is invertible on the span. Public MOVEs ascend, so public registers only enter W. Only CLEARs and owned +MOVEs out of W remove rows. At the end the contents in W are the finals. ∎ + +Owned U rows U_j = B_j·y (range G·y) are CLEARed at V ∈ W for every W, so the per-coordinate rule +"y_u only inside q_u^⊥" is stronger than the span law by exactly span(U rows): a range-G y vector is not +excluded at any chart by Lemma 3.1. + +**Identity (E8, λ = 26).** With G² = λG and complete junk carried at c = −G_t/2, the residual is +Zc = −((λ−2)/4)·G_t − e_t, so an owned gauge G·(x/2 + μ*·y) with μ* = (λ−2)/4 − 1/2 = 11/2 gives +Y_t = x_t with every y cancelled and no zero-Y park. `preload.py` checks it on all 104 columns [C]. + +## 4. Signed-row helpers: Rado test and LU + +**Need rows.** In a deposit word whose product of deposit-side ADDs is the identity, register r carries a +need row ρ_r(τ) (the U-content it must still receive). ADD r += c·s acts as ρ_r += c·ρ_s, an injection +from U_k subtracts a multiple of e_k, a helper's load at {0} sets its row freely, and all rows end at 0. + +**Support lemma.** Let A(S) = {k : S ⊂ b_k}. A register at S has row supported on A(S). *Proof.* Fix k; +on registers at k-forbidden charts the k-column changes only by invertible ADDs among co-located +registers (charts only ascend, no e_k injection there), and must end at 0, so it is 0 on entry. ∎ + +**Group rule.** At chart S, members with incoming rows R span Ω; member p leaves for a chart with allowed +set A′_p, so its outgoing row lies in Ω_p = Ω ∩ R^{A′_p}. Without new helpers the group is feasible iff +one vector from each Ω_p can be chosen spanning Ω (Rado's transversal condition for the subspaces Ω_p); +then N = T·R with T invertible, realised by LU into elementary ADDs. A helper is an extra member with a +free signed row. Example [C]: two proportional members (1,1,1,1), (2,2,2,2) leaving on coordinate +blocks {0,1} and {2,3} are infeasible (deficit 2); one helper with the signed row (1,1,0,0) makes the group +feasible and leaves with row 0, while a helper restricted to a single e_k does not (with single-coordinate +exits a pure helper already suffices, so the free row matters for block exits). `rado_lu.py` checks these exactly. + +## 5. O+(8,2) quotient + +Every port vector q ∈ F₂⁹ has odd weight, q·c = 1 (c the all-ones vector, itself of odd weight 9). +Each class of V/⟨c⟩ contains exactly one even vector, so V/⟨c⟩ ≅ W := c^⊥, and p̄ := q_p + c. On W the dot +product is alternating (even weights) and nondegenerate (c^⊥ ∩ ⟨c⟩ = 0), so ω = dot is symplectic on the +8-dimensional W. Since ω(p̄, t̄) = q_p·q_t + 1 for odd-weight q_p, q_t, partners (q_p·q_t = 0, i.e. G_pt +odd) are exactly the pairs with ω(p̄, t̄) = 1. ∎ The counts (104 of the 120 nonsingular points of +the E8 quadratic form, the two-graph sign law, the 282 twelve-port 4-spaces, one 8-block packing) are +exact enumerations [C, `quotient.py`], not proofs of uniqueness or optimality. + +## 6. The 20-odd-op floor for one q-free plane + +Per A port the target needs R := σ(M)M⁻¹ = −I₃₆ (σ: q ↦ −q). R is a product of conjugates of the factors' +sign factors; ops have σ-rank o ∈ {0, 1}, a q-free plane contributes 0 and a q-odd transvection plane +contributes a rank-1 transvection, which is not an involution. By subadditivity Σ o ≥ 36, and by Lemma E +of #7555 (equality only if every factor is an involution) Σ o ≥ 37. With 17 J calls supplying 17, the odd +ops number ≥ 37 − 17 = 20. ∎ (Premises: the #7113 masks and idle sets, σ-fixed stage data D, odd ops of +σ-rank 1 each.) `callers.py` replays four callers that meet the floor exactly [C]. diff --git a/research/p104-methods/README.md b/research/p104-methods/README.md new file mode 100644 index 0000000000..1556a8554c --- /dev/null +++ b/research/p104-methods/README.md @@ -0,0 +1,246 @@ +# P104 methods (no κ claim) + +This package writes down the construction methods behind our P104 work so that +anyone can reuse them. Each method comes with a precise statement, its scope and +a small exact standard-library demonstration. It makes no κ claim and ships no +new word. It builds on, and does not repeat: + +- [#7542](https://github.com/CrocSwap/integer-mult-bounds/pull/7542): two helper + rung merges on #7334 (conditional κ 0.0036475398277); +- [#7555](https://github.com/CrocSwap/integer-mult-bounds/pull/7555): P104 + structure laws (σ-rank o, Lemma E, hub bound); +- [#7557](https://github.com/CrocSwap/integer-mult-bounds/pull/7557): t = −1 + laws (charge law, corrected anchored law, σ-anchor schedule, odd unit). + +Tags used throughout: +- **[P]** proved in [PROOF.md](PROOF.md); +- **[C]** exact run in this package (checker named); +- **[Q]** quoted from our lane runs or a cited PR, **not** reproduced here; +- **open** not known. + +Toy results are labelled **frame-free** when the checker does exact algebra +without chart legality. + +| # | method | checker | what the checker reproduces | +|---|---|---|---| +| 1 | {0}/V re-basis | `rebasis.py` | the helper-761 rung merge of #7542, rebuilt from #7334's word | +| 2 | absorption | `absorption.py` | clean-iff identity; σ-anchor D = 0 and the last-cell rule (frame-free A3/A4) | +| 3 | range-G pre-loads | `preload.py` | Y_t = x_t with J_t = (11/2)G_t on all 104 columns | +| 4 | signed-row helpers, Rado/LU | `rado_lu.py` | exact group rule, one helper fixing a deficit of 2, LU into ADDs | +| 5 | O+(8,2) quotient | `quotient.py` | port/quadric counts, sign law, 12-port blocks, c-sum triples | +| 6 | t = −1 callers | `callers.py` | MONOHUB joint caller, four 20-odd-op floor callers, form orbit, even fusion | + +## 1. {0}/V re-basis (`rebasis.py`) + +**What it is.** An exact test for deleting a paid helper rung while keeping every +row of the word. When a helper's stop at chart F only delivers content, deleting +the stop's ADDs leaves an error E on some final rows. Two freedoms are always +available and are exactly linear: + +- **{0} freedom [P, Lemma 1.1].** A register leaving {0} may take any combination + of the departure contents of registers that leave later. Up to SCALE these + unitriangular images are the whole {0} freedom. +- **V freedom [P, Lemma 1.2].** Nothing leaves V, so the V phase can end with any + invertible recombination of the V-ending registers. A V-ending register only + needs its V-arrival row to lie in W_V = span of the V-ending finals. + +Together with optional local insertions at intermediate charts (j += β·s, solved +exactly mod p, then replayed over Q), this gives a per-basis-vector column test +(PROOF.md §1). A stop is repairable iff the test passes. + +**What it achieved.** +- [Q] Across #7334's 201 source-only zero-need stops it found exactly one + feasible stop: helper 761 at chart 1053. The near misses (1277@115, + 1322@1049) each fail on one direction that needs a Z-modified carrier, which + the test does not cover. +- That stop is the 761 half of #7542. +- [C] `rebasis.py` rebuilds the 761 merge from the vendored #7334 word, which has + the same bytes and SHA256 as in #7542. The edit is: + - delete the two ADDs at 1053; + - re-basis 1266 += ½·761 to {0}; + - add 1438 += 591 and 1438 += −2·760 at 1053; + - add four ADDs at V: 1438 += 311, −591, +2·760, +1439. + + The replay over Q from arbitrary inputs, with full legality, gives: + - all 1,569 rows and end charts equal to #7334's; + - owned data unchanged; + - helper 761's dims 0→5→7→8→9 become 0→7→8→9; + - paid MOVE ranks per native word {2: −1, 5: −1, 7: +1}. + + The checker also verifies the two re-basis facts on their own: + - nothing writes 761 between {0} and 1053; + - 1438's V-arrival row is #7334's final − (e₃₁₁ − e₅₉₁ + 2e₇₆₀ + e₁₄₃₉), which + lies in W_V. + + Seven corrupted variants are rejected. + +**Not in this package.** The chart checks of the new {0}→rank-7 pair, the price +and the κ are #7542's (`chart.py`, `price.py` there). + +**Scope.** Zero-need stops whose helper only delivers at the stop, on #7334-family +words. The test is exact for {0} freedom, V freedom and the local slots it is +given. The bilinear family (Z-modified carriers × local slots) is **open**. + +## 2. Absorption (`absorption.py`) + +Checker: `absorption.py` (stdlib, exact Fractions, 0.3 s). Tags: [P] proved, [C] exact run in the named checker, [Q] lane number quoted, not reproduced here. + +**Mechanism.** Helper H is born at {0} with row h and lumps an arbitrary signed row -lambda.y from the Ys there. Readers take it at their low stops, as in a relay. At a higher stop K, H does H += sum_r d_r X_r(tau_K), where each X_r still holds outstanding junk psi_r. At V, H does H -= sum_r d_r X_r^final. No Y is at K, and the X_r are only referenced, never consumed. + +**Identity and clean-iff condition.** Write X_r(tau) = X_r^f + sum_t psi_rt y_t. Then H = h + sum_t (sum_r d_r psi_rt - lambda_t) y_t, so H ends clean iff lambda = sum_r d_r psi_r (the lump must match ALL of the absorber's outstanding t; no subset can be chosen). [P: three ADDs, two lines of algebra, UBUS section 2]. [C part 1: identity exact on 40 random instances; clean when lambda = sum d psi; controls coefficient x2, dropped lump, dropped absorb ADD leave H dirty on 40/40.] + +**Legality argument** [P, UBUS section 2 / ABSORBAUDIT section 1]. Every ADD is between registers at equal frames (H and X_r at K; at V). H's chain {0} < < ... < K < V strictly ascends. Between its read stops and K, H carries charge only on supp(lambda) inside U(K), so it stays in each t-perp; after K its charge is 0. Absorption is public, ascending and equal-frame, so the known frame laws apply to it unchanged. [Q: ABSORBAUDIT replay on real E8 ports (cells (0,2),(0,3)): 0 violations, targets exact, controls fail; the abstract XY instance only, not the MONOHUB endpoint contract.] Not checked in this package. + +**Last-outstanding-cell rule** [C part 3, LTOKEN]. An absorber may absorb X_r(K) only when (r,t) is X_r's last outstanding cell (all of X_r's other reads done). Frame-free algebra on A3, seeds 0-4: random absorb time D = 3 = n - r on 5/5; with the rule D = 0 on 5/5. The earlier fixed-order schedules satisfied the rule implicitly. + +**Anchors and the GLIFT bill (frame-free algebra on toys; no frame legality checked; E8 not simulated).** Absorbed cells count as settled columns (charge lemma, [Q] ABSORBLIFT section 0), so without anchors the lift bill is n - r owned units [C: all settled gives D = 3 on A3, 6 on A4]. [Q: 96 units on E8, about 25k D0/call, against a 6.8-10k budget.] With the sigma-anchor design (one early pure-anchor relay per column re-added from the parked pure copy, one late direct reference cell per column, every other cell absorbed) [C part 2]: D = 0 and Y exact on A3 (9/9 runs over 3 seeds x 3 absorb timings; also mid-read and d = 3/7) and A4 (6/6; 40 of 60 cells absorbed). Controls D = n - r (3 on A3, 6 on A4): no sigma, absorb ADD dropped, coefficient x2. + +**Value caveat** [Q, ABSORBAUDIT section 2]. The in-model STLP-type LP value (U floor 4,176 -> 609 D0/call at fixed tops; 1.3389x as an UNLIFTED ceiling) holds 0 owned units and ignores values: for dim-2 stops K = , 768 of 4,992 pairs are fully rank-1, while 4,224 show a 23:1 split, so one cell per stop comes out wrong and must be re-cleaned. That is a realisation risk, not a refutation. + +**Scope.** Mechanism and algebra only. Absorbers cannot be anchors (they are settled); the sigma early cells stay relays with chain {0} -> -> V [Q ABSORBLIFT section 3]. The L side is untouched; its Y-prefix network remains the gate. No kappa word. + +**Achievements.** The absorption identity with controls [C]; sigma-anchor absorption reaches D = 0 where all-settled costs n - r on A3/A4 [C, frame-free]; the last-outstanding-cell rule reproduced [C]. + +## 3. Range-G pre-loads (`preload.py`) + +**Method.** In the relay model each column Y_t is assembled from the y_t anchor, an owned rank-8 L row, and the complete-junk +carrier contents K_s = x_s + sum_u Z_su y_u (Z = G/2 - I) of the 48 partners s, with weights c_s = -G_ts/2. Giving the owned L +row a y part, L'_t = sum_u G_tu (x_u/2 + mu y_u), the junk of the carriers cancels exactly. **Scope:** the junk (window/LC1-per- +coordinate) algebra of the L side on the E8/P104 Gram only; it says nothing about the charge (nu-ledger / token) side. + +**Claims.** +- [P] With G^2 = lam G, sum_{s partner of t} G_ts G_su = (lam-2) G_tu; hence the y-residual of Y_t is (mu - mu*) G_t with + mu* = (lam-2)/4 - 1/2, and the x part is exactly x_t. For lam = 26, mu* = 11/2. +- [C] On all 104 columns (Fractions, PR968 Gram): Y_t = x_t with every y cancelled, 0/104 misses, no zero-Y park; the owned + rows G(x/2 + mu* y) have rank 8. +- [C] Controls: mu = 0 gives 104/104 misses with residual exactly -11/2 G_t on every coordinate, hence on every window N_p + (all 104 x 48 pairs (t,p), nonzero); zero-Y park + mu*: 104/104 misses; one partial-junk carrier (20 of 48 cells): 28 missed + coordinates in every column; wrong mu = mu* + 1/4: 104/104 misses; closed form residual = (mu - mu*) G_t at several mu. +- [P] Legality core: G = D^T T / 2 (PR968 factors), so G_t.y = (1/2) sum_k D_kt (T_k.y) lies in the span of the eight owned U rows; + with the up-set legality lemma (owned U rows are cleared at V in every frame set) any range-G y vector is legal. + [C] checks the identity for all t on a fixed integer y; the up-set lemma itself is quoted from the lane proof, not re-derived. +- [Q] LBREAK: windowed solve 0/40 (J = 0) vs 40/40 (J in range G) on sampled (t,p); lane run, not reproduced here. +- Open: the charge half. Carrier tokens need the reader to cancel H_s's token pre-anchor, which re-settles the column + (D = n - r in the A3/A4 toys); no design found that makes the carrier token-free and charge-free. Not claimed here. + +**Data / sources.** No vendored data. Reads `research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt` +(PR968 decoder), sha256 8e0178db02c14e1b29058cdbdbd50aac22f2b55a1ba21dc82f417610c9932526, hash checked in the script. + +## 4. Signed-row helpers: Rado transversal test and LU into ADDs (`rado_lu.py`) + +Checker: `rado_lu.py` (stdlib, exact Fractions, <1 s). Tags: [P] proved, [C] exact run in the named checker, [Q] lane number quoted, not reproduced here. Abstract demo of the algebra; no FANOUT56 geometry. + +**Model** [P, FANOUTOPT section 1]. A need row rho_r in Q^d is the content a register must still receive. ADD r += c s acts as rho_r += c rho_s; a load at {0} sets a helper's initial row freely; all rows end at 0. Lemma 1 (support): a register's row is supported on A(S) at frame S, because frames only ascend, co-located registers share A, and no injection happens at forbidden frames. + +**Group rule.** At a frame S, members with incoming rows R span Omega. Member p leaves for a frame with allowed set A'_p, so its outgoing row lies in Omega_p = Omega meet R^{A'_p}. Feasible without new helpers iff one vector per Omega_p can be chosen spanning Omega (Rado transversal). Then N = T R with T in SL, realised by LU into transvections (ADD r += c s). A helper is a member with a free signed row that leaves with row 0. + +**Test implemented** [C]. Exact deficiency form of Rado: max independent partial transversal = min over member subsets S of (dim sum_{p in S} Omega_p + m - |S|); feasible iff it equals rank Omega. A transversal is built from random integer combinations and verified exactly (each v_p in Omega_p, all v_p spanning Omega). T is found by solving T R = N, adding left-null-space elements until invertible, rescaling one row to det 1; the ADD list comes from Gauss-Jordan with ADDs only (no swaps). Replay of the ADDs must give N exactly. + +**Demos** [C]. (i) A feasible 3-member group in Q^3: certificate verified, 7 ADDs replay to N. (ii) Two proportional members, rows (1,1,1,1) and (2,2,2,2), leaving on blocks {0,1} and {2,3}: both Omega_p = {0}, max transversal 0 against rank 1 (deficit 2), infeasible by the Rado test and by brute force over the box [-3,3]. One helper with the free signed row (1,1,0,0) makes both sections 1-dimensional, leaves with row 0, 8 ADDs replay exactly (20 of 624 signed rows in [-2,2]^4 work). (iii) Control: the old pure-helper rule, modelled as helper row restricted to one coordinate e_k, fails for k = 0..3 on the same group. Scope note [C]: with single-coordinate exits ((1,1,0,0),(2,2,0,0) leaving on {0},{1}) a pure e_0 helper suffices, so the free row matters when members leave on coordinate blocks. + +**Cross-checks** [C]. Seeded sweep of 118 random small instances (d = 3, 2-4 members, entries in {-1,0,1}): Rado verdict equals the independent brute-force verdict on every instance (61 feasible, each with exact transversal and exact ADD replay; 57 infeasible). Controls: a non-spanning transversal is rejected; a corrupted ADD list fails replay. + +**Gather side** [Q]. It is the time-reversed transpose: a dual row is a give vector, the dual op g_x += c g_y is the forward restore ADD, with identical helper prices. Not run here. + +**Quoted lane result** [Q, lane exact run, not reproduced in this package]. FANOUTOPT's full build: F = 408.68 D0/call with 50 helpers, against FANOUT56's 1,692.1 (4.14x fewer), with proved floor 315.05 D0/call (the FANOUT56/H2 U-level oracle scope; the build sits 1.30x above it). + +**Scope.** Group-level algebra only: no frames, flags, pricing or FANOUT56 census. + +**Achievements.** An exact, certificate-carrying Rado feasibility test with LU factorisation into elementary ADDs; the "one helper fixes a deficit of 2" statement shown on a concrete group with a control that pure rows fail. + +## 5. O+(8,2) quotient structure and the c-trick (`quotient.py`) + +**Method.** Write c for the all-ones vector of F2^9. Every port has q.c = 1, so ports live in W = V/ ~ c^perp (representative +q+c, even weight) with symplectic omega = dot; partners are the pairs with omega = 1. The 104 ports are 104 of the 120 +nonsingular points of an O+(8,2) quadratic form (16 missing). Two consequences are used by the U-junk layer: a sign law +(two-graph) and c-sum triples. **Scope:** structural facts about this port set and Gram; no D0 pricing. + +**Claims.** +- [C] Gram of data/ports104.json: rank 8, G^2 = 26G, 48 partners per port, partner <=> G odd <=> dot(q_p,q_t) = 0; equal entry by + entry to the PR968 Gram under the vendored permutation with diagonal +-1 switching (data/iso968.json); swapped control fails. +- [C] A unique quadratic form (polar = omega) equals 1 on all ports: 120 nonsingular / 135 singular nonzero points, 16 missing. +- [C] Sign law: over the 19,712 mutually-partner triples, G_py G_yt G_pt = -1 exactly for the 704 triples with q_p+q_y+q_t = c + (the 704 c-sum triples, all pairs partners); the other 19,008 are +1. No proof is included beyond the exhaustive check. +- [C] Pair law: partner pairs split 2,112 (24 common partners, exactly 1 sign-wrong cell = the port t* with q_t* = q_p+q_y+c) and 384 + (22 common partners, 0 wrong; p-bar+y-bar is a missing point). This is the 3-stop-absorber fact: a partner reference y of reader p + has exactly one wrong cell t* = p-bar+y-bar (when that point is a port). +- [C] All 200,787 4-dim subspaces of W enumerated: exactly 282 hold 12 ports; each has its 3 non-ports on a line and 16 c-sum triples + (histogram printed). [C] One packing (data/packing8.json): 8 blocks, each one of the 282, disjoint, covering 96 ports; the 8 leftover + ports (6, 13, 17, 36, 43, 46, 58, 73) contain no c-sum triple. Not claimed for every packing. Controls: perturbed packing, random + 12-subset. +- [P] c-trick: for ports t.c = 1, so t.a = 1 <=> t perp a+c; hence {partners of p not perp } = U. [C] for all ports p and + all a in F2^9. [C] on the 33 disjoint c-sum triples (data/triples33.json; q_p+q_q+q_x = c, A2(p) = ): bottom(p) = U, 24 cells, + and the (reader p, host x) pair has exactly one sign-wrong column, the third triple member (198/198; 4,224/4,224 for all c-sum triples). +- Not re-checked: the order-384 stabiliser (orbits 32/48/24); 33 is the lane's CP-SAT packing (bound 34) — the checker does not prove maximality. +- [Q] Lane runs, not reproduced here: the 11,376.3 D0/call U-junk build (1,439 helpers + 104 anchors), the 8-block CP-SAT proxy 1,135.3 + per block, the J-flag incompatibility (0 of 1,408 oriented triples), the 17,270.2 D0 ABSORBNET build. + +**Data.** data/ports104.json sha256 0299f8f7165835231b057e1c6151ad0a8333efcb61a06a0a2aea045aa391c381 (lines104.json + G104.npy of +REBASET1, derived from the #7334 word's charts + reflection closure, gram104.py); data/packing8.json a4bd773ede969488aacdf8feb38487b97ce3daf48d836bbb1bd48f6fd356e12e +(QUOTIENT/bpack2.pkl via blocks.pkl, port index = ports104 order); data/triples33.json f9007e39cf6ce94915848e9c810f28572dc423c929e3c3f4d874301b8359d12e +(ABSORBNET/tripack.pkl); data/iso968.json fd3fb6b90918d6802c7b22b7fe2efdf3a3979e4bc50bb610437957a84b702e1f (permutation/signs found by a +backtracking search over an 8-line basis, verified exactly in the checker). Also reads the PR968 file +`research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt` (sha256 8e0178db...2526). + +## 6. t = −1 callers: MONOHUB joint caller, the 20-odd-op floor, form orbit, even fusion (`callers.py`) + +Tags: [P] proved (where), [C] exact run by `callers.py` (F_p, p = 2147483629, q in {1, i, -1, -i}, generic stage scalars D), [Q] quoted from a cited PR, "open" = not shown. Everything is scoped to the **joint_mono A target** (the scalar -I_36 on the 36 A roles, every exponent odd), PR #7113's B half, masks and idle sets, and one J = one native stage (17 per word). + +**The MONOHUB t = -1 caller.** The joint caller `joint_mono` uses PR #7113's JSON format (Rohan Arun's caller; credit to PR #7113). Its A half is a single-hub hosted caller; its B half and B pair (-1, 1/2) are #7113 verbatim. +- Each of the 17 J calls applies on A the pair HOST(alpha, beta) = (-1, 1), i.e. (s, t) -> D_k (s - q t, q^-1 s), matrix H = [[1, -q], [q^-1, 0]], trace 1, t = -1. [C] +- A events: ADD 428, SWAP 101, SCALE 69, LAMBDA 76, IDLE_ONE 47, QUERY 3, plus 17 HOST (741 in all). [C] +- With an idealised native HOST(-1, 1) on the A ports the whole 72-role map equals the target at the four q (bad 0 of 5,184 cells per q). [C] +- The replay is sharp: A pair (-1, 1/2), (0, 1), (1, -1), B pair (-1, 1), each of the 3 thin QUERY dropped, one idle dropped, one LAMBDA flipped (silent at q = 1, -1 as in #7113, caught at q = +-i), an altered idle set all give bad > 0. The #7113 caller with its own native is bad 0, and alpha2 = +1 or one QUERY dropped gives bad > 0. [C] +- This shows the caller is exact for an *idealised* native. No native realising HOST(-1, 1) with the existing helper layer is claimed. [open] + +**The 20-odd-op floor.** Let sigma: q -> -q and R = sigma(M) M^-1 for the word M. The target needs R = -I_36. +- R is a product of conjugates of the factors' sigma-factors, so sum of ranks >= 36 + 1 = 37, with equality only if every factor is an involution (Lemma E, #7555; equality clause proved in our GAUGECYCLE lane (not public)). [P] +- J factors are not involutions: a q-odd transvection plane has sigma-rank 1, H has sigma-rank 2, QUERY has 1, QSELF is a reflection (det -1). The ledger is run per op. [C] (ADD/SCALE/SWAP/LAMBDA/IDLE_ONE 0, QUERY 1, J(H) 2, J(SW) 1, QSELF 1, all other det +1.) +- With one q-free plane (sigma-rank 1 per J) the word needs >= 37 - 17 = **20** odd ops per A port per word. [P, scope: one q-free transvection plane per J; a fully q-free HOST(-1, 1) plane has sigma-rank 0 and floor 36.] +- **Four callers sit exactly at the floor** (live-free / hosted-free x odd / even): each replays at bad 0 at the four q. The odd variants hold 2 QUERY + 18 IDLE_ODD = 20 odd ops; the even variants hold 2 QUERY and give up the 18 phase fields as even (priced the same). [C] +- Controls all rejected: free plane given back its q, alpha2 = +1, each QUERY dropped, a phase/idle op dropped, the cancel ADD dropped, an IDLE_ODD made even, a LAMBDA flipped. [C] +- Whether a native with the needed q-free plane can be built at break-even is not shown here. [open] + +**Form-orbit growth law.** On joint_mono A, native H, all 17 J on roles (X, Y) = (1, 0), at all four q and two D seeds: [C] +- each J brings exactly 3 new lines (x_k, y_k, x_k - q y_k); 51 distinct lines among 68 forms; +- the 17 input planes span 34 dimensions (pairwise independent); rank of output plane J_k plus input plane J_k+1 is 4 for all 16 consecutive pairs. +- So M is applied once to each plane and its finite order (H^3 = -I) is not exercised on repeated content. [C for this caller only; a different caller is not covered.] Controls: the non-exact native SW fails replay; a repeated-plane list would read as 2 lines / span 2. + +**Even-fusion check.** Replacing two consecutive H calls by SW, SW plus a free q^2 on roles (0, 1): +- the o of every consecutive H-pair segment is 4 (7 at the QUERY pair), against 2 (5) for SW + q^2; [C] +- all 8 fused pair replays (pairs (1,2), (3,4), ..., (15,16)) fail at q = i, -1, -i (silent at q = 1); the control (H kept + q^2) also fails; H kept alone and SW with the per-J phases X*q, Y*q^-1 are bad 0, and dropping one J's phases gives bad > 0. [C] +- So a fused pair would need odd part of rank 4, not 2. Fusions other than these 8 pairs of SW + q^2 are not tested. [open] +- Lemma E, the identity o = rank of the q-odd part, and the gauge-shifted bound (m - 16) + (36 - m) = 20 are [P] in #7555 and our GAUGECYCLE lane (not public); only the ledger values are re-run here. + +`data/` (gzip, mtime 0, SHA256 checked by `callers.py` before use); provenance is the lane card folder (our own builds) unless stated. +| file | sha256 | provenance | +|---|---|---| +| joint_mono.json.gz | 4ffb61264d446d107de23fd9af05090db77aa16e64840165c6a0329ad0f3f3c4 | MONOCALLER joint_mono.json (A = MONOHUB hosted caller, B = PR #7113 verbatim) | +| caller-7113.json.gz | 7e8038559cd158f6e32ef6d1a3bf15ab6a8ecc2239af32ab1699511ac28e26d9 | PR #7113 (Rohan Arun) caller JSON, byte-identical copy in MONOCALLER and LIVECALLER | +| livecaller-livefree-odd.json.gz | 7b8e8c9dd04ce965f9162950da4270c7bbea1ee1fe97d11b99566abd014ce8b9 | LIVECALLER CALLER_livefree_odd.json | +| livecaller-livefree-even.json.gz | ddfc96cda2c8e4001c6b81c5c5a088d60fdb5423516384cbd8a338d19531a5cd | LIVECALLER CALLER_livefree_even.json | +| livecaller-hostedfree-odd.json.gz | a1fc419bb3c3eb7f756840c60cd3010f15c40bb09088983e56ccc8b24ff439ea | LIVECALLER CALLER_hostedfree_odd.json | +| livecaller-hostedfree-even.json.gz | 688f2464a8239562069be17b5b7e92593eaa7873975ebf86c1f6c6bd5cb49e83 | LIVECALLER CALLER_hostedfree_even.json | + +## Checks + +```sh +python3.12 -B scripts/research_package.py --package research/p104-methods +``` + +Six standard-library checkers, listed in VERIFY.json. Each prints its numbers, runs controls that must +be rejected, and ends with a PASS token. Vendored data in `data/` is authenticated by SHA256 inside the +checkers. The repository input (the PR968 decoder file) is pinned in SOURCES.json. + +## Open next questions + +The two questions recorded in TASK.json, plus the parts of our lane work not reproduced here: + +- The general {0}/V re-basis scan, and the bilinear (Z-modified carrier × local slot) extension for + 1277@115 and 1322@1049. +- A frame-legal E8 absorption layer under the σ-anchor schedule. Absorption's D = 0 is frame-free toy + algebra only. +- FANOUTOPT's full exact fan-out build (408.68 D0/call) and its 315.05 floor. +- QUOTIENT's 11,376.3 D0/call U-junk build, and the order-384 stabiliser. +- A native that realises HOST(−1, 1), or a q-free plane at break-even. +- Lemma A (#7557) stays open. diff --git a/research/p104-methods/SOURCES.json b/research/p104-methods/SOURCES.json new file mode 100644 index 0000000000..7762b75060 --- /dev/null +++ b/research/p104-methods/SOURCES.json @@ -0,0 +1,24 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/complex-frame-pair-decoders/PROOF.md", + "usage": "provenance", + "git_blob": "889f3a653ed1bdbb7df61ebe3af4f2103602a1f4", + "sha256": "ba53c1d8a9bc2d935d546bde46ca7341bd65f8515013e07b073296b4db2a9a74" + }, + { + "path": "research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt", + "usage": "input", + "git_blob": "458ddb13dcf73ed031ffb96d9df149c994c7e4ee", + "sha256": "8e0178db02c14e1b29058cdbdbd50aac22f2b55a1ba21dc82f417610c9932526" + } + ] +} diff --git a/research/p104-methods/TASK.json b/research/p104-methods/TASK.json new file mode 100644 index 0000000000..1e205068b9 --- /dev/null +++ b/research/p104-methods/TASK.json @@ -0,0 +1,123 @@ +{ + "schema_version": 1, + "task_id": "p104-side-correction", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "p104-side-correction", + "question": "Can joint helper bases and a legal causal split improve the complete P104 productive/paid invoice?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "research/p104-helper-subspace-splits/README.md", + "research/dyadic-helper-channel-capacity/README.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "An exact arbitrary-input identity, source/target frame availability and restoration at the chosen cut, plus the complete channel+correction+idle/hosting bill or an explicit favorable bound. The native channel alone is not a supplier. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Start with the selected #5599 emitted word and review pending #5718 distinct input/output bases plus #5717/#5719 coverage before claiming work. Pick one uncovered source word, helper group and cut region. Prove the arbitrary-input relation and legal entry/exit corrections, then compare full target and paid profiles. Reject if completion, owned lifetimes or consumer costs repay the gain. A static pairing rank alone is not a physical split.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "P104", + "helper basis", + "helper split", + "5718", + "dyadic capacity" + ], + "existing_checks": [ + { + "scope": "PR #4133: literal-slot defect", + "evidence": "research/p104-literal-slot-defect/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "88666f1dee93fbd85b31fd5d6f91a219e111b5f4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4136: uniform commutation gap", + "evidence": "research/p104-uniform-commutation-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "281ce601a8be9db470de630759179c23e1dfaa88", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4140: uniform encoding gap", + "evidence": "research/p104-uniform-encoding-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "de25c6525aa866962309df5d107b32d55e6e5628", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4153: source-chart shortcut exhausts its optimistic allowance", + "evidence": "research/p104-source-chart-shortcut/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "9123241fea53df77e51ffe30d9aca1625d4bf3a8", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4154: fiber-tag seam mismatch", + "evidence": "research/p104-fiber-tag-seam/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "4ffcdaee5d6255a9cea1fe53a5424435068089d0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Six P104 construction methods, each stated with its scope and a small exact standard-library demonstration: (1) the exact {0}/V re-basis test of helper mixing, demonstrated by rebuilding the helper-761 rung merge of #7542 from #7334's word; (2) absorption (a helper settled against a register's outstanding junk), its clean-iff condition and the last-outstanding-cell rule, with the sigma-anchor deficiency result as frame-free algebra on A3/A4 toys; (3) range-G y pre-loads, Y_t = x_t with J_t = (11/2)G_t on all 104 columns; (4) signed-row helpers with a Rado transversal test and LU realisation into elementary ADDs; (5) the O+(8,2) quotient structure of the 104 ports (sign law, 12-port blocks, c-sum triples); (6) the t = -1 MONOHUB joint caller and the four 20-odd-op floor callers, with the form-orbit and even-fusion checks.", + "scope_change_reason": "The card asks for a constructive helper-basis or causal-split improvement. This package documents the methods behind our P104 work (#7542, #7555, #7557) so others can reuse them; it makes no kappa claim and ships no new word.", + "bottleneck_link": "Each method is a tool for the complete P104 bill: re-basis removes paid helper rungs (the #7542 gain), absorption and pre-loads re-price the U- and L-side junk layers, the Rado/LU rule prices helper fan-out exactly, the quotient model organises the port geometry, and the callers fix the t = -1 caller side of the invoice.", + "budget_minutes": 75, + "stop_rule": "Every stated number reproduced by a standard-library checker from repository data or vendored, hash-authenticated data, with biting controls; validator PASS.", + "outcome": "completed", + "evidence": "README.md, PROOF.md, rebasis.py, absorption.py, preload.py, rado_lu.py, quotient.py, callers.py, VERIFY.json.", + "author": "DreamingOfClouds", + "ai_assistance": "Claude Opus 5.5 (Anthropic), via Claude Code.", + "open_questions": [ + { + "question": "Does the full {0}/V re-basis family, extended by bilinear (Z-modified carrier x local slot) insertions, make the near-miss stops 1277@115 and 1322@1049 feasible on the #7542 word?", + "why_it_matters": "Each feasible zero-need stop removes a paid helper rung at fixed rows, as 761@1053 did for #7542.", + "first_step": "Add the bilinear family to the exact test for those two stops only and solve it exactly mod p, then replay over Q.", + "blocked_by": "Nothing." + }, + { + "question": "Is there an absorption-native E8 U-side layer that keeps the sigma-anchor schedule (D = 0) with frame legality, at a D0 cost below the 6,797 D0/call relay-design budget?", + "why_it_matters": "Absorption removes the low-dimension Y-budget that dominates relay floors; the frame-free algebra shows the anchor bill can be zero, but no frame-legal E8 layer under the anchor schedule has been built.", + "first_step": "Build one 12-port quotient block with sigma-anchors and absorbers and run the lifted deficiency check on it.", + "blocked_by": "Nothing." + } + ] +} diff --git a/research/p104-methods/VERIFY.json b/research/p104-methods/VERIFY.json new file mode 100644 index 0000000000..0df85a3a1e --- /dev/null +++ b/research/p104-methods/VERIFY.json @@ -0,0 +1,71 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/rebasis.py" + ], + "timeout_seconds": 300, + "checks": "Vendored #7334 word (SHA256 4b9fd118...); the helper-761 half of #7542's edit applied (6 deletions, 5 insertions, 5 appended); exact arbitrary-input replay with full legality of both words; all 1,569 rows and end charts equal, owned data unchanged, only helper 761 changes (0->5->7->8->9 to 0->7->8->9); paid ranks per native word {2:-1,5:-1,7:+1}; {0} side: no write to 761 between {0} and chart 1053; V side: 1438's V-arrival = final - (e311 - e591 + 2e760 + e1439) with the four correctors V-ending unit rows; seven controls rejected. Prints PASS_METHODS_REBASIS." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/absorption.py" + ], + "timeout_seconds": 120, + "checks": "Part 1 (exact absorption identity on random instances): H = h + sum_t(sum_r d_r psi_rt - lambda_t) y_t on 40 random-lambda instances; H ends clean when lambda = sum_r d_r psi_r on 40/40; controls coefficient x2, dropped lump and dropped absorb ADD leave H dirty on 40/40 each. Part 2 (FRAME-FREE ALGEBRA on toys A3 n=6 r=3 and A4 n=10 r=4; no frame legality checked, E8 not simulated): sigma-anchor schedule gives D = 0 and Y exact on A3 in 9/9 runs (3 seeds x absorb pre-anchor/post-anchor/late; 12 absorbed, 6 early, 6 direct of 24 cells), A3 mid direct read D = 0, A3 d = 3/7 D = 0, A4 6/6 runs (2 seeds x 3 timings; 40 absorbed, 10 early, 10 direct of 60 cells); controls no sigma (all settled) D = 3 on A3 and 6 on A4, absorb ADD dropped D = 3 / 6, absorb coefficient x2 D = 3 / 6. Part 3: last-outstanding-cell rule on A3 seeds 0-4: random absorb time D = 3 on 5/5, with the rule D = 0 on 5/5. Quoted, not reproduced: UBUS 4,176 -> 609 D0/call LP, ABSORBAUDIT E8 legality replay, E8 GLIFT bill 96 units, 23:1 splits on 4,224 of 4,992 dim-2 stops. Prints PASS_METHODS_ABSORPTION." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/rado_lu.py" + ], + "timeout_seconds": 120, + "checks": "Exact Fractions, abstract group algebra (no FANOUT56 geometry). Case (i): feasible 3-member group in Q^3, rank Omega 2 = max transversal 2, certificate verified, 7 ADDs replay exactly to N, brute force agrees. Case (ii): proportional members (1,1,1,1),(2,2,2,2) leaving on blocks {0,1},{2,3}: Omega_p dimensions [0,0], rank 1 vs max transversal 0 (deficit 2), infeasible without helper (Rado test and brute force box [-3,3]); one helper with free signed row (1,1,0,0): sections [1,1,0], helper exits with row 0, certificate verified, 8 ADDs replay exactly, brute force feasible; 20 of 624 signed rows in [-2,2]^4 fix it. Control (iii): helper rows restricted to e_k (old pure rule) fail for k=0..3; scope note: with single-coordinate exits a pure e_0 helper suffices. Controls: non-spanning transversal rejected, corrupted ADD list fails replay. Seeded sweep of 118 random instances (d=3): Rado verdict equals brute force on all (61 feasible each with exact transversal and ADD replay, 57 infeasible). Quoted, not reproduced (lane exact run): FANOUTOPT F = 408.68 D0/call with 50 helpers vs FANOUT56 1,692.1 (4.14x), proved floor 315.05. Prints PASS_METHODS_RADO_LU." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/preload.py" + ], + "timeout_seconds": 120, + "checks": "Pins the PR968 file hash; 104 ports, G symmetric with diagonal 2, rank 8, G^2 = 26 G, 48 partners per port, mu* = (26-2)/4 - 1/2 = 11/2. Gauge column Y_t = [y_t] + G_t.(x/2 + mu* y) + sum over partners of -G_ts/2 (x_s + Z_s.y) with Z = G/2 - I gives Y_t = x_t with every y cancelled: 0/104 misses, no zero-Y park; owned rank of rows G(x/2 + mu* y) is 8. Controls: mu = 0 misses 104/104 with residual exactly -11/2 G_t on all coordinates and on every window N_p (4,992 (t,p) pairs); zero-Y park with mu* misses 104/104; one partial-junk carrier (20 of 48 cells) misses 28 coordinates in every column; mu = mu* + 1/4 misses 104/104; residual = (mu - mu*) G_t for several mu. Legality core: G_t.y = 1/2 sum_k D_kt (T_k.y) for all t on a fixed integer y, and the 8 U rows have rank 8 containing G's row space. Prints PASS_METHODS_PRELOAD." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/quotient.py" + ], + "timeout_seconds": 120, + "checks": "Verifies SHA256 of data/ports104.json, packing8.json, triples33.json, iso968.json and the PR968 file. Gram: symmetric, diagonal 2, rank 8, G^2 = 26G, 48 partners per port, partner <=> G odd <=> dot(q_p,q_t)=0; PR968 Gram equals eps_u eps_v G104[perm u][perm v] on all 104^2 entries (control: swapped permutation fails). Every port has q.c = 1; omega nondegenerate on the 255 even-weight vectors; exactly one quadratic form with polar omega equals 1 on all ports, with 120 nonsingular / 135 singular nonzero points, ports inside nonsingular, 16 missing; partner <=> omega(p-bar,t-bar)=1. Two-graph sign law over all mutually-partner triples: 704 with product -1, all exactly the c-sum triples (704, all pairs partners), 19,008 with +1 (control: no non-c-sum triple has -1). Pair law: partner pairs split 2,112 (24 common partners, exactly 1 sign-wrong cell = port with q = q_p+q_y+c) and 384 (22 common partners, 0 wrong, p-bar+y-bar a missing point). All 200,787 4-dim subspaces enumerated: 282 with 12 ports, each with 3 non-ports on a line and 16 c-sum triples. The vendored packing: 8 blocks each one of the 282, disjoint, covering 96 ports, 8 leftover ports with no c-sum triple (controls: perturbed packing fails disjointness and block test, random 12-subset is not a block and spans more than 4 dims). c-trick: bottom(p,a) = U for all ports p and all a in F2^9; 33 vendored triples disjoint (99 ports), c-sum, pairs partners, bottom(p) = U of size 24 on all 198 ordered pairs, sign-wrong column is the third member (198/198, and 4,224/4,224 over all c-sum triples); controls: a non-c-sum partner triple has product +1, a perturbed triple is not c-sum. The order-384 stabiliser is not re-checked. Prints PASS_METHODS_QUOTIENT." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/callers.py" + ], + "timeout_seconds": 120, + "checks": "MONOHUB joint caller (joint_mono, #7113 B half verbatim) with idealised A native HOST(-1,1): A event census ADD 428, SWAP 101, SCALE 69, LAMBDA 76, IDLE_ONE 47, QUERY 3, HOST 17 (741), pairs (-1,1)/(-1,1/2) on all 17 J, bad 0 at q=1,i,-1,-i; #7113 control with its own native bad 0; controls rejected: #7113 alpha2=+1 and one QUERY dropped, A pairs (-1,1/2), (0,1), (1,-1), B pair (-1,1), each of 3 thin QUERY dropped, one idle dropped, one LAMBDA flipped, idle set altered. Four floor callers (livefree/hostedfree x odd/even): bad 0 at the four q, odd ops 20 (2 QUERY + 18 IDLE_ODD) for the odd variants and 2 QUERY with 0 IDLE_ODD for the even ones; controls rejected: free plane given back its q, alpha2=+1, each QUERY dropped, last idle/phase op dropped, cancel ADD dropped, one IDLE_ODD made even, one LAMBDA flipped. Form orbit on joint_mono A (native H, 4 q x 2 seeds): bad 0, 3 new lines per J, 51 distinct lines of 68 forms, input planes span 34, all 16 consecutive output/input plane ranks 4; controls: non-exact native SW rejected, repeated-plane counter reads 2 lines/span 2. Sigma ledger (o at (i,-i) and (1,-1)): ADD/SCALE/SWAP/LAMBDA/IDLE_ONE 0, QUERY 1, J(H) 2, J(SW) 1, QSELF 1, det +1 except QSELF -1; target o 36 scalar -I; supply 17*2+3=37 (H), 17+3=20 (SW); 16 consecutive H-pair segments o = 4 (7 at the QUERY pair), SW+q^2 segments 2 (5); the 8 fused SW+q^2 pair replays all fail (silent only at q=1), controls H kept + q^2 fails, H alone bad 0, SW with per-J phases bad 0, phases on 16 of 17 J rejected. 54 negative controls in all, all SHA256-authenticated inputs. Prints PASS_METHODS_CALLERS." + } + ] +} diff --git a/research/p104-methods/absorption.py b/research/p104-methods/absorption.py new file mode 100644 index 0000000000..a2cdfe92ee --- /dev/null +++ b/research/p104-methods/absorption.py @@ -0,0 +1,377 @@ +"""P104 methods: ABSORPTION (a helper settles a relay's residue against another register's outstanding junk, not against Y). + +Standard library only, exact Fractions. Sources (own lane code, ported): UBUS (section 0.1 mechanism, section 2 algebra and +legality), ABSORBAUDIT (section 1), ABSORBLIFT (section 3, alg_absorb.py: sigma-anchor schedule), LTOKEN (section 0.4, +t2.py/eng.py: last-outstanding-cell rule). + +Contract per port (toy): X = x - y, Y = x. Geometry A_m: ports q_ij = e_i + e_j + e_{m+1}, roots e_i - e_j, G = Gram (rank m), +partner cells (p,t) = {p != t, G_pt odd}, Z = G/2 - I on partner cells, n = #roots, r = m, n - r = GLIFT charge deficiency. + +SCOPE. Part 1 is the exact absorption identity on random instances. Parts 2 and 3 are the FRAME-FREE ALGEBRA on the toys +A3 (n=6, r=3) and A4 (n=10, r=4): NO frame legality is checked here and E8 is NOT simulated. The lane's frame-legality replay on +real E8 ports (ABSORBAUDIT replay.py) and the E8 statements are quoted, not reproduced. + +Checked: + 1. identity: H = h + sum_t (sum_r d_r psi_rt - lambda_t) y_t exactly on 40 random instances; H clean iff lambda = sum d psi; + controls: coefficient x2 and dropped lump leave H dirty; dropped absorb ADD leaves H dirty; + 2. sigma-anchor algebra (one early pure-anchor relay per column from the parked pure copy, one late direct reference cell per + column, every other cell absorbed): D = 0 and Y exact on A3 (3 seeds x 3 absorb timings + mid-read + d = 3/7) and A4 + (2 seeds x 3 timings); controls: no sigma (all settled) D = n - r (3 / 6), absorb ADD dropped D = n - r, coefficient x2 + D = n - r; + 3. last-outstanding-cell rule: random absorb time D = n - r on 5/5 A3 seeds (the lane's seeds), with the rule D = 0 on 5/5. +Prints PASS_METHODS_ABSORPTION.""" +import itertools, random, sys +from fractions import Fraction as Fr + + +def say(s): + print(s, flush=True) + + +def expect(name, got, want): + if got != want: + raise SystemExit('FAIL %s: got %r want %r' % (name, got, want)) + say('ok %s: %r' % (name, got)) + + +def rank(rows): + """Exact rank of a list of sparse rows {key: Fraction}.""" + piv = {} + r = 0 + for row in rows: + v = {k: Fr(x) for k, x in row.items() if x} + while v: + k = min(v) + if k in piv: + c = v[k] + for kk, xx in piv[k].items(): + nv = v.get(kk, 0) - c * xx + if nv: + v[kk] = nv + else: + v.pop(kk, None) + else: + c = v[k] + piv[k] = {kk: xx / c for kk, xx in v.items()} + r += 1 + break + return r + + +def geometry(m): + pairs = list(itertools.combinations(range(m + 1), 2)) + roots = [[(1 if k == i else -1 if k == j else 0) for k in range(m + 1)] for i, j in pairs] + ports = [(1 << i) | (1 << j) | (1 << (m + 1)) for i, j in pairs] + n = len(roots) + G = [[sum(a * b for a, b in zip(roots[s], roots[t])) for t in range(n)] for s in range(n)] + B = [[Fr(r[k]) for k in range(m)] for r in roots] + IJ = [[Fr(1 + (a == b)) for b in range(m)] for a in range(m)] + C = [[sum(B[t][a] * IJ[a][j] for a in range(m)) / 2 for j in range(m)] for t in range(n)] + for s in range(n): + for t in range(n): + assert sum(C[s][j] * B[t][j] for j in range(m)) == Fr(G[s][t], 2) + even_label = bin(ports[s] & ports[t]).count('1') % 2 == 0 + assert (G[s][t] % 2 == 1) == (s != t and even_label) + Z = {(s, t): Fr(G[s][t], 2) for s in range(n) for t in range(n) if s != t and G[s][t] % 2} + return n, G, B, C, Z + + +# ------------------------------------------------------------------------------------------------ part 1: the identity +def vadd(d, c, s): + for k, v in s.items(): + nv = d.get(k, 0) + c * v + if nv: + d[k] = nv + else: + d.pop(k, None) + + +def absorption_instance(rng, nr, nt, lam_mode='match', mult=1, drop_lump=False, drop_absorb=False): + """Helper H = h. Lump -lambda.y at {0}; at K: H += sum d_r X_r(tau_K) ; at V: H -= sum d_r X_r^final. + X_r(tau) = xf_r + sum_t psi_rt y_t (junk in the y coordinates it will later be cleaned against). + Returns (H as dict, expected dirt dict, lam, d, psi).""" + psi = [[Fr(rng.randint(-5, 5), rng.randint(1, 4)) for _ in range(nt)] for _ in range(nr)] + d = [Fr(rng.randint(1, 6), rng.randint(1, 3)) for _ in range(nr)] + lam = [sum(d[r] * psi[r][t] for r in range(nr)) for t in range(nt)] + if lam_mode == 'random': + lam = [Fr(rng.randint(-5, 5)) for _ in range(nt)] + H = {'h': Fr(1)} + if not drop_lump: + for t in range(nt): + vadd(H, -lam[t], {'y%d' % t: Fr(1)}) + X_K = [dict({'xf%d' % r: Fr(1)}, **{'y%d' % t: psi[r][t] for t in range(nt) if psi[r][t]}) for r in range(nr)] + X_f = [{'xf%d' % r: Fr(1)} for r in range(nr)] + if not drop_absorb: + for r in range(nr): + vadd(H, mult * d[r], X_K[r]) + for r in range(nr): + vadd(H, -d[r], X_f[r]) + pred = {'h': Fr(1)} + for t in range(nt): + c = sum(d[r] * psi[r][t] for r in range(nr)) - lam[t] + if c: + pred['y%d' % t] = c + return H, pred, lam, d, psi + + +def part1(): + rng = random.Random(11) + ok_clean = ok_ident = 0 + for i in range(40): + nr, nt = rng.randint(1, 4), rng.randint(1, 5) + H, pred, lam, d, psi = absorption_instance(rng, nr, nt) + assert H == {'h': Fr(1)} + ok_clean += 1 + # identity for an arbitrary lambda: H = h + sum_t (sum d psi - lambda_t) y_t + rng2 = random.Random(1000 + i) + H2, pred2, lam2, d2, psi2 = absorption_instance(rng2, nr, nt, lam_mode='random') + assert H2 == pred2 + ok_ident += 1 + expect('identity H = h + sum_t(sum_r d_r psi_rt - lambda_t) y_t on random lambda', ok_ident, 40) + expect('H ends clean when lambda = sum_r d_r psi_r', ok_clean, 40) + dirty = {'x2': 0, 'nolump': 0, 'noabs': 0} + for i in range(40): + nr, nt = rng.randint(1, 4), rng.randint(1, 5) + if absorption_instance(random.Random(i), nr, nt, mult=2)[0] != {'h': Fr(1)}: + dirty['x2'] += 1 + if absorption_instance(random.Random(i), nr, nt, drop_lump=True)[0] != {'h': Fr(1)}: + dirty['nolump'] += 1 + if absorption_instance(random.Random(i), nr, nt, drop_absorb=True)[0] != {'h': Fr(1)}: + dirty['noabs'] += 1 + # an instance can have psi all zero (then even a dropped item is harmless); require dirt on most, none clean-by-error + expect('control coefficient x2: H dirty on all 40', dirty['x2'], 40) + expect('control dropped lump: H dirty on all 40', dirty['nolump'], 40) + expect('control dropped absorb ADD: H dirty on all 40', dirty['noabs'], 40) + + +# ------------------------------------------------------------------------------------------------ parts 2-3: sigma-anchor algebra +def pick_maps(m, seed): + n, G, B, C, Z = geometry(m) + part = {t: [p for p in range(n) if (p, t) in Z] for t in range(n)} + rng = random.Random(seed) + for _ in range(20000): + cols = list(range(n)) + rng.shuffle(cols) + u1, u2, sig, ref, ok = set(), set(), {}, {}, True + for t in cols: + c = [p for p in part[t] if p not in u1] + if not c: + ok = False + break + sig[t] = rng.choice(c) + u1.add(sig[t]) + c = [p for p in part[t] if p not in u2 and p != sig[t]] + if not c: + ok = False + break + ref[t] = rng.choice(c) + u2.add(ref[t]) + if ok: + return sig, ref + raise SystemExit('no sigma/ref maps') + + +def run(m, seed, abs_when='pre_anchor', read_when='late', mode='sigma', dco=Fr(1), mult=1, noabs=False, order=None): + """Frame-free algebra of ABSORBLIFT alg_absorb.py (exact Fractions). order in (None, 'random', 'rule'): if given, the + X reads / absorbs / E re-adds / L second reads / direct reads form a random linear extension of the stated constraints.""" + n, G, B, C, Z = geometry(m) + r = m + sig, rf = pick_maps(m, seed) + part = {t: [p for p in range(n) if (p, t) in Z] for t in range(n)} + E = {(sig[t], t) for t in range(n)} if mode == 'sigma' else set() + direct = {(rf[t], t) for t in range(n)} + absd = {(p, t): rf[t] for (p, t) in Z if (p, t) not in direct and (p, t) not in {(sig[t], t) for t in range(n)}} + rel = {k: 'R%d_%d' % k for k in Z if k not in direct and k not in absd} + ab = {k: 'A%d_%d' % k for k in absd} + hel = {(t, p): 'H%d_%d' % (t, p) for (t, p) in Z} + X = ['X%d' % p for p in range(n)] + Y = ['Y%d' % t for t in range(n)] + pub, own = {}, {} + for p in range(n): + pub[X[p]] = {'x%d' % p: Fr(1)} + for t in range(n): + pub[Y[t]] = {'y%d' % t: Fr(1)} + for v in list(rel.values()) + list(ab.values()) + list(hel.values()): + pub[v] = {v: Fr(1)} + reg = lambda nm: pub[nm] if nm in pub else own[nm] + + def add(d, c, s): + vadd(reg(d), c, dict(reg(s))) + U = ['U%d' % j for j in range(r)] + L = ['L%d' % j for j in range(r)] + for j in range(r): + own[U[j]] = {} + for t in range(n): + add(U[j], B[t][j], Y[t]) + for (p, t), R in rel.items(): + add(R, -1, Y[t]) + for (p, t), A in ab.items(): + add(A, dco * Z[(absd[(p, t)], t)], Y[t]) # absorber lump (pure y_t) + for (t, p), H in hel.items(): + add(H, -1, Y[p]) + for t in range(n): + own['O%d' % t] = {} + add('O%d' % t, 1, Y[t]) # parked pure anchor copy + for j in range(r): + own[L[j]] = {} + for s in range(n): + add(L[j], B[s][j], X[s]) + for t in range(n): + add(Y[t], -1, 'O%d' % t) # zero-Y (park) + for (t, p), H in hel.items(): + add(Y[t], Z[(t, p)], H) + for j in range(r): + for t in range(n): + add(Y[t], C[t][j], L[j]) + for (t, p), H in hel.items(): + add(H, 1, X[p]) # L helper picks up pure x_p + # ---- the late phase as events + ev = [] + for (p, t) in rel: + ev.append(('read', (p, t))) + for (p, t) in ab: + ev.append(('read', (p, t))) + for (p, t) in ab: + ev.append(('abs', (p, t))) + for (p, t) in rel: + if (p, t) in E: + ev.append(('readd', (p, t))) + for k in hel: + ev.append(('l2', k)) + for k in direct: + ev.append(('dread', k)) + + def do(e): + k, c = e + if k == 'read': + p, t = c + if c in rel: + add(X[p], -Z[c], rel[c]) + else: + add(X[p], Z[c] / (dco * Z[(absd[c], t)]), ab[c]) + elif k == 'abs': + if not noabs: + add(ab[c], dco * mult, X[absd[c]]) + elif k == 'readd': + add(rel[c], 1, 'O%d' % c[1]) + elif k == 'l2': + t, p = c + add(Y[t], -Z[(t, p)], hel[c]) + elif k == 'dread': + q, t = c + add(X[q], Z[(q, t)], Y[t]) + if order is None: + # ABSORBLIFT fixed schedules + reads = [e for e in ev if e[0] == 'read'] + absl = [e for e in ev if e[0] == 'abs'] + readd = [e for e in ev if e[0] == 'readd'] + l2 = [e for e in ev if e[0] == 'l2'] + dr = [e for e in ev if e[0] == 'dread'] + seq = reads + if abs_when == 'pre_anchor': + seq = seq + absl + readd + else: + seq = seq + readd + (absl if abs_when == 'post_anchor' else []) + if read_when == 'mid': + seq = seq + dr + seq = seq + l2 + if abs_when == 'late': + seq = seq + absl + if read_when == 'late': + seq = seq + dr + for e in seq: + do(e) + else: + rng = random.Random(10 * seed + 7) + done = set() + + def ready(e): + k, c = e + if k == 'abs': + if ('read', c) not in done: + return False + if order == 'rule': + rr, t = absd[c], c[1] + others = [('read', (rr, u)) for u in part[rr] if u != t and (rr, u) in rel or + u != t and (rr, u) in ab] + return all(o in done for o in others) + return True + if k == 'readd': + return ('read', c) in done + if k == 'dread': + q, t = c + return all(('abs', a) in done for a, rr in absd.items() if rr == q and a[1] == t) + return True + while len(done) < len(ev): + av = [e for e in ev if e not in done and ready(e)] + e = rng.choice(av) + do(e) + done.add(e) + # settled re-adds (mode != sigma only) + for (p, t), R in rel.items(): + if (p, t) not in E: + add(R, 1, Y[t]) + T = {} + for p in range(n): + T[X[p]] = {'x%d' % p: Fr(1), 'y%d' % p: Fr(-1)} + for t in range(n): + T[Y[t]] = {'x%d' % t: Fr(1)} + Vregs = X + list(rel.values()) + list(ab.values()) + list(hel.values()) + for v in Vregs[n:]: + T[v] = {v: Fr(1)} + arr = [pub[v] for v in Vregs] + [own[u] for u in U] + D = rank(arr + [T[v] for v in Vregs]) - rank(arr) + Yok = all(pub[Y[t]] == T[Y[t]] for t in range(n)) + return dict(D=D, Y=Yok, absorbed=len(ab), early=len(E), direct=len(direct), relays=len(rel), n=n, r=r) + + +def part2(): + for m, seeds in ((3, range(3)), (4, range(2))): + nm = 'A%d' % m + n_r = None + for seed in seeds: + for aw in ('pre_anchor', 'post_anchor', 'late'): + o = run(m, seed, aw, 'late') + n_r = o['n'] - o['r'] + if o['D'] != 0 or not o['Y']: + raise SystemExit('FAIL %s seed %d %s: %r' % (nm, seed, aw, o)) + o = run(m, 0, 'pre_anchor', 'late') + say('ok %s sigma-anchor schedule: D = 0, Y exact in %d/%d runs (%d absorbed / %d early / %d direct of %d cells)' % ( + nm, 3 * len(seeds), 3 * len(seeds), o['absorbed'], o['early'], o['direct'], o['absorbed'] + o['early'] + o['direct'])) + if m == 3: + o = run(m, 0, 'pre_anchor', 'mid') + expect('A3 direct read in the middle: D', (o['D'], o['Y']), (0, True)) + o = run(m, 0, 'pre_anchor', 'late', dco=Fr(3, 7)) + expect('A3 absorber scale d = 3/7: D', (o['D'], o['Y']), (0, True)) + o = run(m, 0, 'pre_anchor', 'late', mode='settled') + expect('%s control no sigma (all settled): D = n - r' % nm, o['D'], n_r) + o = run(m, 0, 'pre_anchor', 'late', noabs=True) + expect('%s control absorb ADD dropped: D = n - r' % nm, o['D'], n_r) + o = run(m, 0, 'pre_anchor', 'late', mult=2) + expect('%s control absorb coefficient x2: D = n - r' % nm, o['D'], n_r) + + +def part3(): + dr, dl = [], [] + for seed in range(5): + dr.append(run(3, seed, order='random')['D']) + dl.append(run(3, seed, order='rule')['D']) + say('random absorb time (A3 seeds 0-4): D = %r ; with last-outstanding-cell rule: D = %r' % (dr, dl)) + expect('last-outstanding-cell rule: D = 0 on 5/5 seeds', dl, [0] * 5) + expect('random absorb time: D = n - r = 3 on 5/5 seeds', dr, [3] * 5) + + +def main(): + say('Part 1: absorption identity (exact, random instances)') + part1() + say('Part 2: FRAME-FREE ALGEBRA on toys A3/A4 (no frame legality is checked; E8 is not simulated)') + part2() + say('Part 3: last-outstanding-cell rule (frame-free algebra, A3)') + part3() + say('Quoted, NOT reproduced here: UBUS in-model U floor 4,176 -> 609 D0/call [lane LP]; ABSORBAUDIT E8 legality replay;' + ' GLIFT n - r bill without anchors on E8 = 96 units (~25k D0/call); 23:1 splits on 4,224 of 4,992 dim-2 stops.') + say('PASS_METHODS_ABSORPTION') + + +if __name__ == '__main__': + main() diff --git a/research/p104-methods/callers.py b/research/p104-methods/callers.py new file mode 100644 index 0000000000..be5756f4ac --- /dev/null +++ b/research/p104-methods/callers.py @@ -0,0 +1,542 @@ +"""P104 t = -1 callers: the MONOHUB joint caller, the four 20-odd-op floor callers, the form orbit, the sigma-ledger. +Standard library only; exact arithmetic in F_p, p = 2147483629 (p = 1 mod 4), i = sqrt(-1), q in {1, i, -1, -i}. + +Inputs (data/, gzip with mtime 0, SHA256 hard-coded below and checked before use): + joint_mono.json.gz the exact t = -1 MONOHUB joint caller in PR #7113's JSON format (72 roles: A 0..35, B 36..71); + A events = MONOHUB hosted caller, B events and B pair (-1,1/2) = PR #7113 (Rohan Arun) verbatim. + caller-7113.json.gz the #7113 caller itself (control). + livecaller-{live,hosted}free-{odd,even}.json.gz four callers with one q-free plane at the odd-op floor. + +Checks: + 1. MONOHUB joint caller replays with an idealised native HOST(-1,1) on A ports (B = #7113 verbatim): bad 0 at the four q; + event census; 11 broken variants rejected; #7113 control with its own native bad 0, 2 controls rejected. + 2. Four floor callers: bad 0 at the four q, odd-op census (20 odd ops, or 2 QUERY + fields given up), controls rejected. + 3. Form orbit on joint_mono A: 3 new lines per J, 51 distinct lines of 68 forms, 17 input planes span 34, the 16 + consecutive output/input plane ranks all 4; controls. + 4. sigma-ledger o of every op and of J with H / SW, H-pair segment o = 4, the 8 fused SW + q^2 pairs fail, control. +Prints PASS_METHODS_CALLERS.""" +import copy +import gzip +import hashlib +import json +import random +from collections import Counter +from fractions import Fraction as Fr +from functools import lru_cache +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = Path(__file__).resolve().parents[2] +DATA = HERE / 'data' +P = 2147483629 +IM = next(pow(g, (P - 1) // 4, P) for g in range(2, 99) if pow(g, (P - 1) // 2, P) == P - 1) +assert IM * IM % P == P - 1 +HALF = (P + 1) // 2 +QS = (1, IM, P - 1, P - IM) +QN = ('1', 'i', '-1', '-i') + +SHA = { + 'joint_mono.json.gz': '4ffb61264d446d107de23fd9af05090db77aa16e64840165c6a0329ad0f3f3c4', + 'caller-7113.json.gz': '7e8038559cd158f6e32ef6d1a3bf15ab6a8ecc2239af32ab1699511ac28e26d9', + 'livecaller-livefree-odd.json.gz': '7b8e8c9dd04ce965f9162950da4270c7bbea1ee1fe97d11b99566abd014ce8b9', + 'livecaller-livefree-even.json.gz': 'ddfc96cda2c8e4001c6b81c5c5a088d60fdb5423516384cbd8a338d19531a5cd', + 'livecaller-hostedfree-odd.json.gz': 'a1fc419bb3c3eb7f756840c60cd3010f15c40bb09088983e56ccc8b24ff439ea', + 'livecaller-hostedfree-even.json.gz': '688f2464a8239562069be17b5b7e92593eaa7873975ebf86c1f6c6bd5cb49e83', +} + + +def say(s): + print(s, flush=True) + + +def expect(name, got, want): + if got != want: + raise SystemExit('FAIL %s: got %r want %r' % (name, got, want)) + say('ok %s: %r' % (name, got)) + + +def rejected(name, got): + """negative control: bad counts (list) must contain a nonzero entry""" + if not any(got): + raise SystemExit('FAIL control %s NOT rejected: %r' % (name, got)) + say('ok control rejected: %-60s bad %s' % (name, got)) + + +def load(name): + raw = (DATA / name).read_bytes() + h = hashlib.sha256(raw).hexdigest() + if h != SHA[name]: + raise SystemExit('FAIL sha256 mismatch for %s: %s' % (name, h)) + return json.loads(gzip.decompress(raw).decode()) + + +def inv(a): + return pow(a % P, P - 2, P) + + +@lru_cache(maxsize=None) +def fm(x): + f = Fr(x) + return f.numerator % P * inv(f.denominator) % P + + +def qp(q, e): + return pow(q, e % 4, P) + + +# --------------------------------------------------------------------------------------------------------------- +# generic replay of a #7113-format caller (rows of R = current linear map; one J = A hosted pair + B hosted pair) +def replay(C, qv, Dv, A_pair=None, B_pair=None, a2=None, drop=(), A_form=None, live=None, hosted_q=None): + n = C['roles'] + R = [[int(i == j) for j in range(n)] for i in range(n)] + qi = inv(qv) + form = A_form or C['types']['A']['form'] + a2 = fm(C['types']['A'].get('alpha2', '-1')) if a2 is None else fm(a2) + TA = C['types']['A'] + if live is None: + live = (fm(TA.get('live_coef', '1')), TA.get('live_qexp', -1)) + hq = TA.get('hosted_qexp', 1) if hosted_q is None else hosted_q + + def hostpair(src, dst, al, be): + tt = al * be % P + ns = [(x + al * qv % P * y) % P * d % P for x, y in zip(R[src], R[dst])] + nd = [(be * qi % P * x + (1 + tt) * y) % P * d % P for x, y in zip(R[src], R[dst])] + R[src], R[dst] = ns, nd + + for k, e in enumerate(C['events']): + if k in drop: + continue + if e[0] == 'J': + d = Dv[e[1]] + if form in ('two-chain-HOST2', 'qfree-live-HOST2'): + src, dst, x2, y2 = e[2] + cl = live[0] * qp(qv, live[1]) % P + R[dst] = [(a + cl * b) % P for a, b in zip(R[dst], R[src])] + R[x2] = [(a + a2 * qp(qv, hq) % P * b) % P for a, b in zip(R[x2], R[y2])] + for r in (src, dst, x2, y2): + R[r] = [a * d % P for a in R[r]] + else: + src, dst, al, be = e[2] + al, be = (fm(al), fm(be)) if A_pair is None else (fm(A_pair[0]), fm(A_pair[1])) + hostpair(src, dst, al, be) + # the native's D multiplies src,dst (inside hostpair via d) + src, dst, al, be = e[3] + al, be = (fm(al), fm(be)) if B_pair is None else (fm(B_pair[0]), fm(B_pair[1])) + hostpair(src, dst, al, be) + continue + op = e[1] + if op == 'ADD': + R[e[2]] = [(a + fm(e[4]) * b) % P for a, b in zip(R[e[2]], R[e[3]])] + elif op == 'SCALE': + c = fm(e[3]) + R[e[2]] = [a * c % P for a in R[e[2]]] + elif op == 'SWAP': + R[e[2]], R[e[3]] = R[e[3]], R[e[2]] + elif op == 'QUERY': + c = qp(qv, e[4]) + R[e[2]] = [(a + c * b) % P for a, b in zip(R[e[2]], R[e[3]])] + elif op == 'LAMBDA': + c = ((1 + e[3] * IM) * HALF + (1 - e[3] * IM) * HALF * qv * qv) % P + R[e[2]] = [a * c % P for a in R[e[2]]] + elif op in ('IDLE_ONE', 'IDLE_ODD'): + c = qp(qv, e[4]) if op == 'IDLE_ODD' else 1 + for s in e[3]: + c = c * Dv[s] % P + R[e[2]] = [a * c % P for a in R[e[2]]] + else: + raise SystemExit('op ' + op) + return R + + +def nbad(C, R, qv, Dv): + b = 0 + for t in ('A', 'B'): + T = C['types'][t] + off = T['offset'] + for i, dg in enumerate(T['diagonal']): + c = qp(qv, dg[0]) + for k, bit in enumerate(dg[2:]): + if bit: + c = c * Dv[k + 1] % P + r = off + i + b += sum(R[r][j] != (c if j == r else 0) for j in range(C['roles'])) + return b + + +def run(C, **kw): + rnd = random.Random(5) + out = [] + for qv in QS: + Dv = {s: rnd.randrange(2, P) for s in range(1, 18)} + out.append(nbad(C, replay(C, qv, Dv, **kw), qv, Dv)) + return out + + +def a_events(C, op=None): + return [k for k, e in enumerate(C['events']) if e[0] == 'A' and (op is None or e[1] == op)] + + +def check1(): + say('== 1. MONOHUB joint caller (joint_mono.json.gz, B = PR #7113 verbatim), idealised native, 72 roles') + M = load('joint_mono.json.gz') + C7 = load('caller-7113.json.gz') + expect('roles / A form', (M['roles'], M['types']['A']['form']), (72, 'mono-HOST')) + cen = Counter(e[1] for e in M['events'] if e[0] == 'A') + cen['HOST'] = sum(1 for e in M['events'] if e[0] == 'J') + expect('A event census', dict(sorted(cen.items())), + {'ADD': 428, 'HOST': 17, 'IDLE_ONE': 47, 'LAMBDA': 76, 'QUERY': 3, 'SCALE': 69, 'SWAP': 101}) + expect('sum of A events', sum(cen.values()), 741) + pairs = {(tuple(e[2][2:]), tuple(e[3][2:])) for e in M['events'] if e[0] == 'J'} + expect('A pair (alpha,beta) and B pair on all 17 J', pairs, {(('-1', '1'), ('-1', '1/2'))}) + say('-- control: PR #7113 caller (Rohan Arun) with its own idealised native (live t=0 plane + hosted alpha2=-1 + B t=-1/2)') + expect('#7113 bad at q=1,i,-1,-i', run(C7), [0, 0, 0, 0]) + rejected('#7113 with hosted alpha2=+1', run(C7, a2='1')) + rejected('#7113 minus one A QUERY', run(C7, drop=(a_events(C7, 'QUERY')[0],))) + say('-- MONOHUB joint caller with idealised A native HOST(alpha,beta)=(-1,1) (t=-1), B (-1,1/2)') + expect('MONOHUB bad at q=1,i,-1,-i', run(M), [0, 0, 0, 0]) + rejected('A pair (-1,1/2)', run(M, A_pair=('-1', '1/2'))) + rejected('A pair (0,1) (transvection, t=0)', run(M, A_pair=('0', '1'))) + rejected('A pair (1,-1)', run(M, A_pair=('1', '-1'))) + rejected('B pair (-1,1) instead of (-1,1/2)', run(M, B_pair=('-1', '1'))) + qk = a_events(M, 'QUERY') + expect('thin QUERY count', len(qk), 3) + for j, k in enumerate(qk): + rejected('drop thin QUERY #%d' % j, run(M, drop=(k,))) + ids = a_events(M, 'IDLE_ONE') + rejected('drop one A IDLE_ONE', run(M, drop=(ids[3],))) + lam = a_events(M, 'LAMBDA') + M2 = copy.deepcopy(M) + M2['events'][lam[10]][3] *= -1 + rejected('flip one A LAMBDA (silent at q=1,-1 as in #7113)', run(M2)) + M3 = copy.deepcopy(M) + M3['events'][ids[0]][3] = sorted(set(M3['events'][ids[0]][3]) ^ {17}) + rejected('idle stage set altered', run(M3)) + + +# --------------------------------------------------------------------------------------------------------------- +def check2(): + say('== 2. four callers at the odd-op floor (one q-free plane), replay of all 72 roles') + expect('floor arithmetic: 2 x 17 + 3 = 37 supply with H; target o = 36 needs >= 37; floor = 37 - 17', 37 - 17, 20) + for fr, fl in (('live', 'odd'), ('live', 'even'), ('hosted', 'odd'), ('hosted', 'even')): + nm = '%sfree-%s' % (fr, fl) + C = load('livecaller-%s.json.gz' % nm) + A = C['types']['A'] + say('-- caller %s: form %s, live q^%s, hosted q^%s' % (nm, A['form'], A['live_qexp'], A['hosted_qexp'])) + cen = Counter(e[1] for e in C['events'] if e[0] == 'A') + odd = Counter(e[1] for e in C['events'] if e[0] == 'A' and e[1] in ('QUERY', 'IDLE_ODD') and e[4] % 2) + say(' A census %s ; odd ops %s' % (dict(sorted(cen.items())), dict(odd))) + if fl == 'odd': + expect('%s odd ops per A port per word (2 QUERY + 18 IDLE_ODD)' % nm, sum(odd.values()), 20) + expect('%s composition' % nm, dict(odd), {'QUERY': 2, 'IDLE_ODD': 18}) + else: + expect('%s odd ops (2 QUERY; the 18 phase fields given up as even)' % nm, dict(odd), {'QUERY': 2}) + expect('%s IDLE_ODD ops' % nm, cen.get('IDLE_ODD', 0), 0) + expect('%s bad at q=1,i,-1,-i' % nm, run(C), [0, 0, 0, 0]) + if fr == 'live': + rejected('free plane given back its q (live q^-1)', run(C, live=(fm('1'), -1))) + else: + rejected('free plane given back its q (hosted q^1)', run(C, hosted_q=1)) + rejected('hosted alpha2=+1', run(C, a2='1')) + for k in a_events(C, 'QUERY'): + rejected('drop A QUERY at event %d' % k, run(C, drop=(k,))) + io = [k for k in a_events(C) if C['events'][k][1] in ('IDLE_ODD', 'IDLE_ONE')] + rejected('drop last free-chain idle/phase op', run(C, drop=(io[-1],))) + x = next(k for k in range(1, len(C['events'])) if C['events'][k - 1][0] == 'J') + rejected('drop the cancel ADD after J1', run(C, drop=(x,))) + if fl == 'odd': + D2 = copy.deepcopy(C) + x = next(k for k in a_events(D2, 'IDLE_ODD')) + D2['events'][x][4] = 0 + rejected('one IDLE_ODD made even', run(D2)) + lam = a_events(C, 'LAMBDA') + D3 = copy.deepcopy(C) + D3['events'][lam[len(lam) // 2]][3] *= -1 + rejected('flip one A LAMBDA', run(D3)) + + +# --------------------------------------------------------------------------------------------------------------- +# A-only 36x36 tools on joint_mono (native H = [[1,-q],[1/q,0]] on (src,dst) = (role 1, role 0), SW = q^-1 H) +NA = 36 + + +def mkD(seed): + r = random.Random(seed) + return {s: r.randrange(2, P - 1) for s in range(1, 18)} + + +def eye(n=NA): + return [[int(i == j) for j in range(n)] for i in range(n)] + + +def Hn(q): + return ((1, (-q) % P), (inv(q), 0)) + + +def SWn(q): + return ((inv(q), P - 1), (1, 0)) + + +def lam(q, s): + return ((1 + s * IM) * HALF + (1 - s * IM) * HALF * q * q) % P + + +def step(R, e, q, D, nat): + if e[0] == 'J': + d = D[e[1]] + s, t = e[2][0], e[2][1] + (a, b), (c, dd) = nat(q) + x, y = R[s], R[t] + R[s] = [(a * u + b * v) * d % P for u, v in zip(x, y)] + R[t] = [(c * u + dd * v) * d % P for u, v in zip(x, y)] + return + op = e[1] + if op == 'ADD': + c = fm(e[4]) + R[e[2]] = [(u + c * v) % P for u, v in zip(R[e[2]], R[e[3]])] + elif op == 'SCALE': + c = fm(e[3]) + R[e[2]] = [c * u % P for u in R[e[2]]] + elif op == 'SWAP': + R[e[2]], R[e[3]] = R[e[3]], R[e[2]] + elif op == 'QUERY': + c = qp(q, e[4]) + R[e[2]] = [(u + c * v) % P for u, v in zip(R[e[2]], R[e[3]])] + elif op == 'LAMBDA': + c = lam(q, e[3]) + R[e[2]] = [c * u % P for u in R[e[2]]] + elif op in ('IDLE_ONE', 'IDLE_ODD'): + c = qp(q, e[4]) if op == 'IDLE_ODD' else 1 + for s_ in e[3]: + c = c * D[s_] % P + R[e[2]] = [c * u % P for u in R[e[2]]] + else: + raise SystemExit(op) + + +def rank(A): + M = [r[:] for r in A] + n = len(M) + m = len(M[0]) if M else 0 + rk = 0 + for c in range(m): + p = next((r for r in range(rk, n) if M[r][c]), None) + if p is None: + continue + M[rk], M[p] = M[p], M[rk] + iv = inv(M[rk][c]) + for r in range(n): + if r != rk and M[r][c]: + f = M[r][c] * iv % P + M[r] = [(a - f * b) % P for a, b in zip(M[r], M[rk])] + rk += 1 + return rk + + +def proj(v): + k = next((i for i, x in enumerate(v) if x), None) + if k is None: + return None + iv = inv(v[k]) + return tuple(x * iv % P for x in v) + + +class AWord: + def __init__(self): + self.C = load('joint_mono.json.gz') + self.EV = [e for e in self.C['events'] if e[0] in ('J', 'A')] + self.DIAG = self.C['types']['A']['diagonal'] + self.JIDX = [k for k, e in enumerate(self.EV) if e[0] == 'J'] + expect('A events + J in joint_mono', (len(self.EV), len(self.JIDX)), (741, 17)) + + def target(self, q, D): + T = [[0] * NA for _ in range(NA)] + for i, dg in enumerate(self.DIAG): + c = qp(q, dg[0]) + for k, bit in enumerate(dg[2:]): + if bit: + c = c * D[k + 1] % P + T[i][i] = c + return T + + def word(self, q, D, natfor, lo=0, hi=None, extra=None): + R = eye() + hi = len(self.EV) if hi is None else hi + for k in range(lo, hi): + e = self.EV[k] + jn = self.JIDX.index(k) if e[0] == 'J' else None + step(R, e, q, D, natfor(jn) if jn is not None else None) + if jn is not None and extra and jn in extra: + for role, mult in extra[jn]: + R[role] = [v * mult(q) % P for v in R[role]] + return R + + def bad(self, natfor, extra=None, seed=11): + out = [] + for qi, q in enumerate(QS): + D = mkD(seed + qi) + R = self.word(q, D, natfor, extra=extra) + T = self.target(q, D) + out.append(sum(1 for i in range(NA) for j in range(NA) if R[i][j] != T[i][j])) + return out + + +def check3(W): + say('== 3. form orbit on joint_mono A (all 17 J on roles (X,Y) = (1,0), native H, 36 roles)') + allnew, allcont = [], [] + for qi, q in enumerate(QS): + for seed in (11, 29): + D = mkD(seed + qi) + R = eye() + inp, outp = [], [] + for e in W.EV: + if e[0] == 'J': + s, t = e[2][0], e[2][1] + inp.append((R[s][:], R[t][:])) + step(R, e, q, D, Hn) + outp.append((R[s][:], R[t][:])) + else: + step(R, e, q, D, Hn) + T = W.target(q, D) + b = sum(1 for i in range(NA) for j in range(NA) if R[i][j] != T[i][j]) + allf = [v for pr in inp + outp for v in pr] + lines = len(set(proj(v) for v in allf)) + span = rank([list(v) for v in allf]) + seen, new = set(), [] + for k in range(17): + cur = set(proj(v) for v in inp[k]) | set(proj(v) for v in outp[k]) + new.append(len(cur - seen)) + seen |= cur + insp = rank([list(v) for pr in inp for v in pr]) + cont = [rank([list(v) for v in outp[k]] + [list(v) for v in inp[k + 1]]) for k in range(16)] + expect('q=%s seed %d: bad / distinct lines of 68 / span of 34 forms' % (QN[qi], seed), (b, lines, len(allf), span), + (0, 51, 68, 34)) + expect(' new lines per J', new, [3] * 17) + expect(' input planes (17 x 2 forms) span', insp, 34) + expect(' consecutive output/input plane rank (16 pairs)', cont, [4] * 16) + allnew.append(new) + allcont.append(cont) + say('-- controls') + rejected('replay with the t=0 native SW (not exact, so no orbit claim)', W.bad(lambda j: SWn)) + # the counting tool does detect repetition: 17 copies of one plane give 2 lines, span 2, plane rank 2 + v1, v2 = [1] + [0] * 35, [0, 1] + [0] * 34 + rep = [(v1, v2)] * 17 + got = (len(set(proj(v) for pr in rep for v in pr)), rank([list(v) for pr in rep for v in pr])) + expect('control: 17 repeated planes would show 2 lines, span 2 (tool detects repetition; the data show 51, 34)', got, (2, 2)) + + +# --------------------------------------------------------------------------------------------------------------- +def mul(A, B): + Bt = list(zip(*B)) + return [[sum(a * b for a, b in zip(r, c)) % P for c in Bt] for r in A] + + +def minv(A): + n = len(A) + M = [row[:] + [int(i == j) for j in range(n)] for i, row in enumerate(A)] + for c in range(n): + p = next(r for r in range(c, n) if M[r][c]) + M[c], M[p] = M[p], M[c] + iv = inv(M[c][c]) + M[c] = [v * iv % P for v in M[c]] + for r in range(n): + if r != c and M[r][c]: + f = M[r][c] + M[r] = [(a - f * b) % P for a, b in zip(M[r], M[c])] + return [row[n:] for row in M] + + +def det(A): + M = [r[:] for r in A] + n = len(M) + d = 1 + for c in range(n): + p = next((r for r in range(c, n) if M[r][c]), None) + if p is None: + return 0 + if p != c: + M[c], M[p] = M[p], M[c] + d = -d + d = d * M[c][c] % P + iv = inv(M[c][c]) + for r in range(c + 1, n): + if M[r][c]: + f = M[r][c] * iv % P + M[r] = [(a - f * b) % P for a, b in zip(M[r], M[c])] + return d % P + + +def o_of(Mf, q): + """o(M) = rank(sigma(M) M^-1 - I), sigma: q -> -q; also det of the sigma-factor and whether it is -I""" + S = mul(Mf((-q) % P), minv(Mf(q))) + n = len(S) + Sm = [[(S[i][j] - (i == j)) % P for j in range(n)] for i in range(n)] + return rank(Sm), det(S), all(S[i][j] == ((P - 1) if i == j else 0) for i in range(n) for j in range(n)) + + +def check4(W): + say('== 4. sigma-sector (sigma: q -> -q) on joint_mono A: ledger, H-pair segments, fused SW + q^2 pairs') + D = mkD(5) + EV = W.EV + first = {} + for e in EV: + key = e[1] if e[0] == 'A' else 'J' + first.setdefault(key, e) + ledger = {} + for key in ('ADD', 'SCALE', 'SWAP', 'LAMBDA', 'IDLE_ONE', 'QUERY'): + e = first[key] + ledger[key] = [o_of(lambda q, e=e: (lambda R: (step(R, e, q, D, None), R)[1])(eye()), q)[:2] for q in (IM, 1)] + for nm, nat in (('J(H)', Hn), ('J(SW)', SWn)): + e = first['J'] + ledger[nm] = [o_of(lambda q, e=e, nat=nat: (lambda R: (step(R, e, q, D, nat), R)[1])(eye()), q)[:2] for q in (IM, 1)] + qself = ('A', 'IDLE_ODD', 1, [], 1) + ledger['QSELF'] = [o_of(lambda q: (lambda R: (step(R, qself, q, D, None), R)[1])(eye()), q)[:2] for q in (IM, 1)] + want = {'ADD': 0, 'SCALE': 0, 'SWAP': 0, 'LAMBDA': 0, 'IDLE_ONE': 0, 'QUERY': 1, 'J(H)': 2, 'J(SW)': 1, 'QSELF': 1} + for k, o in want.items(): + say(' ledger %-9s (o, det sigma-factor) at (i,-i): %s ; at (1,-1): %s' % (k, ledger[k][0], ledger[k][1])) + expect('sigma-rank o of %s at both sigma pairs' % k, (ledger[k][0][0], ledger[k][1][0]), (o, o)) + expect('det of the sigma-factor of %s (+1; reflection QSELF -1)' % k, + (ledger[k][0][1], ledger[k][1][1]), ((P - 1, P - 1) if k == 'QSELF' else (1, 1))) + odd = [e for e in EV if e[0] == 'A' and e[1] == 'QUERY' and e[4] % 2] + expect('odd ops in the joint_mono A caller', len(odd), 3) + for q, qn in ((IM, 'i'), (1, '1')): + expect('target o, det, scalar -I at q=%s' % qn, o_of(lambda x: W.target(x, D), q), (36, 1, True)) + expect('supply: H 17*2 + 3 (tight against the floor 36 + 1)', 17 * 2 + 3, 37) + expect('supply: SW 17*1 + 3', 17 * 1 + 3, 20) + say('-- controls: unit dropped / phases returned / H-pair segments / fused pairs') + rejected('SW (= q^-1 H) with the unit dropped', W.bad(lambda j: SWn)) + ph = {j: [(1, lambda q: q), (0, lambda q: inv(q))] for j in range(17)} + expect('SW + caller phases X*q (role 1), Y*q^-1 (role 0) on every J (= H) bad', W.bad(lambda j: SWn, extra=ph), [0, 0, 0, 0]) + ph1 = {j: ph[j] for j in range(16)} + rejected('same phases on 16 of 17 J (one unit dropped)', W.bad(lambda j: SWn, extra=ph1)) + JI = W.JIDX + po, ps = [], [] + for j in range(16): + lo, hi = JI[j], JI[j + 1] + 1 + po.append(o_of(lambda x: W.word(x, D, lambda jj: Hn, lo, hi), IM)[0]) + ps.append(o_of(lambda x: W.word(x, D, lambda jj: SWn, lo, hi, + extra={j + 1: [(0, lambda q: q * q % P), (1, lambda q: q * q % P)]}), IM)[0]) + expect('o of the 16 consecutive H-pair segments J_j..J_j+1 (q = i; 7 at the QUERY pair)', po, [4] * 7 + [7] + [4] * 8) + expect('o of the same segments with SW + q^2 (fused class-0 pair)', ps, [2] * 7 + [5] + [2] * 8) + cexp = {1: [(0, lambda q: q * q % P), (1, lambda q: q * q % P)]} + expect('control: H kept at all 17 J (bad 0, no fusion)', W.bad(lambda jj: Hn), [0, 0, 0, 0]) + rejected('control: H kept + a stray q^2 fix on roles 0,1', W.bad(lambda jj: Hn, extra=cexp)) + for j in range(0, 16, 2): + nf = lambda jj, j=j: SWn if jj in (j, j + 1) else Hn + ex = {j + 1: [(0, lambda q: q * q % P), (1, lambda q: q * q % P)]} + b = W.bad(nf, extra=ex) + rejected('fused pair (%d,%d): SW + q^2 on roles 0,1, other J = H' % (j + 1, j + 2), b) + expect(' silent at q=1 only', b[0], 0) + + +def main(): + say('root %s ; data %s' % (ROOT.name, DATA.relative_to(ROOT))) + check1() + check2() + W = AWord() + check3(W) + check4(W) + say('PASS_METHODS_CALLERS') + + +if __name__ == '__main__': + main() diff --git a/research/p104-methods/data/base-7334-word.json.gz b/research/p104-methods/data/base-7334-word.json.gz new file mode 100644 index 0000000000..73f4300719 Binary files /dev/null and b/research/p104-methods/data/base-7334-word.json.gz differ diff --git a/research/p104-methods/data/caller-7113.json.gz b/research/p104-methods/data/caller-7113.json.gz new file mode 100644 index 0000000000..2479c3a615 Binary files /dev/null and b/research/p104-methods/data/caller-7113.json.gz differ diff --git a/research/p104-methods/data/iso968.json b/research/p104-methods/data/iso968.json new file mode 100644 index 0000000000..4d1ce7948a --- /dev/null +++ b/research/p104-methods/data/iso968.json @@ -0,0 +1 @@ +{"eps":[1,1,-1,-1,1,1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,1,1,1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,1,-1,-1,1,-1,-1,1,1,1,1],"perm":[2,8,58,64,102,68,69,47,7,65,52,74,78,20,24,59,60,99,79,73,53,21,42,43,103,91,70,37,28,101,85,86,15,35,26,82,19,98,31,89,13,32,41,90,57,76,22,72,0,56,75,51,3,46,71,67,1,50,4,81,55,23,5,61,80,54,9,49,77,45,6,66,10,48,93,39,87,97,11,44,92,38,16,100,83,34,14,63,36,30,95,40,88,33,12,29,94,17,25,84,62,96,27,18]} diff --git a/research/p104-methods/data/joint_mono.json.gz b/research/p104-methods/data/joint_mono.json.gz new file mode 100644 index 0000000000..9b87a71c2c Binary files /dev/null and b/research/p104-methods/data/joint_mono.json.gz differ diff --git a/research/p104-methods/data/livecaller-hostedfree-even.json.gz b/research/p104-methods/data/livecaller-hostedfree-even.json.gz new file mode 100644 index 0000000000..2ce1cecefa Binary files /dev/null and b/research/p104-methods/data/livecaller-hostedfree-even.json.gz differ diff --git a/research/p104-methods/data/livecaller-hostedfree-odd.json.gz b/research/p104-methods/data/livecaller-hostedfree-odd.json.gz new file mode 100644 index 0000000000..9da1d79d82 Binary files /dev/null and b/research/p104-methods/data/livecaller-hostedfree-odd.json.gz differ diff --git a/research/p104-methods/data/livecaller-livefree-even.json.gz b/research/p104-methods/data/livecaller-livefree-even.json.gz new file mode 100644 index 0000000000..0a5b0338ff Binary files /dev/null and b/research/p104-methods/data/livecaller-livefree-even.json.gz differ diff --git a/research/p104-methods/data/livecaller-livefree-odd.json.gz b/research/p104-methods/data/livecaller-livefree-odd.json.gz new file mode 100644 index 0000000000..4d78cfa48e Binary files /dev/null and b/research/p104-methods/data/livecaller-livefree-odd.json.gz differ diff --git a/research/p104-methods/data/packing8.json b/research/p104-methods/data/packing8.json new file mode 100644 index 0000000000..6202a1324d --- /dev/null +++ b/research/p104-methods/data/packing8.json @@ -0,0 +1 @@ +{"blocks":[[0,1,2,39,41,50,56,59,82,83,87,100],[3,7,27,31,35,40,57,64,67,84,101,102],[4,8,11,30,33,37,42,45,48,65,68,89],[5,10,12,18,20,26,32,54,62,79,86,99],[9,16,19,44,61,63,66,69,78,81,93,98],[14,15,22,23,24,49,51,52,91,92,94,96],[21,25,29,34,38,47,70,71,75,77,80,85],[28,53,55,60,72,74,76,88,90,95,97,103]],"leftover":[6,13,17,36,43,46,58,73]} diff --git a/research/p104-methods/data/ports104.json b/research/p104-methods/data/ports104.json new file mode 100644 index 0000000000..c76576f0e4 --- /dev/null +++ b/research/p104-methods/data/ports104.json @@ -0,0 +1 @@ +{"gram":[[2,-1,-1,1,1,-1,0,0,0,0,0,1,-1,-1,0,0,0,0,0,0,-1,0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0,0,-1,-1,-1,1,1,1,-1,1,0,0,0,0,0,0,0,0,-1,1,1,1,1,1,1,1,-1,0,1,0,1,1,1,-1,1,1,0,-1,-1,-1,-1,1,1,0,0,0,0,1,1,-1,1,-1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],[-1,2,1,-1,-1,0,1,0,0,0,0,0,0,0,-1,1,0,0,0,0,0,-1,0,0,0,1,0,0,-1,1,-1,0,0,0,0,1,-1,0,0,0,-1,-1,-1,1,-1,0,0,0,-1,-1,1,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0,1,1,1,0,-1,0,1,1,0,0,-1,0,-1,-1,1,0,0,0,0,-1,-1,0,0,0,-1,0,1,1,0,0,0,-1,1,0,0,0,1,0,1,-1,1,0,-1,-1,-1,0,0,0,1,0,-1,0,1,1,0,1,-1,2,0],[0,0,1,0,-1,-1,-1,0,-1,1,0,0,-1,0,0,-1,0,-1,0,0,0,0,-1,0,0,0,0,0,-1,0,-1,0,1,1,1,0,-1,1,1,0,0,1,-1,0,0,0,1,1,0,1,1,0,0,0,0,1,-1,0,0,0,1,-1,-1,0,0,0,1,0,0,1,-1,1,1,0,1,1,0,0,1,0,0,-1,0,1,0,0,-1,-1,0,0,-1,1,-1,0,0,1,-1,1,0,-1,0,0,0,2]],"lines":[11,19,35,131,259,13,21,37,69,133,261,41,73,265,49,145,161,193,321,385,14,22,38,70,134,26,74,138,50,146,274,194,322,386,28,44,140,84,148,276,100,292,196,324,388,56,88,152,168,296,200,328,392,112,176,304,208,336,400,224,352,416,508,506,502,494,478,446,382,254,505,501,493,477,445,381,253,499,475,443,379,251,487,471,439,375,247,463,431,367,239,415,351,223,319,191,81,98,164,262,268,273,280,290]} diff --git a/research/p104-methods/data/triples33.json b/research/p104-methods/data/triples33.json new file mode 100644 index 0000000000..9d377b10be --- /dev/null +++ b/research/p104-methods/data/triples33.json @@ -0,0 +1 @@ +{"triples":[[0,40,58],[1,14,73],[2,67,97],[4,35,56],[5,8,84],[6,27,60],[7,29,51],[9,36,64],[10,39,65],[11,12,91],[13,52,68],[15,94,96],[16,63,98],[17,28,100],[18,32,62],[19,89,101],[20,34,72],[21,38,75],[23,26,77],[24,31,79],[30,71,102],[33,92,103],[37,53,78],[41,61,80],[43,74,99],[45,54,85],[46,57,86],[47,48,87],[49,55,82],[50,59,83],[66,69,93],[70,76,81],[88,90,95]]} diff --git a/research/p104-methods/preload.py b/research/p104-methods/preload.py new file mode 100644 index 0000000000..97d817d838 --- /dev/null +++ b/research/p104-methods/preload.py @@ -0,0 +1,161 @@ +"""P104 method: range-G pre-loads (the owned gauge L' = G (x/2 + mu* y)). Standard library only, exact Fractions. + +Geometry: the 104 live lines of E8/P104 with Gram G = D T^T / 2 from the PR968 decoder file +research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt (SHA256 pinned below); rank G = 8, G^2 = lam G with +lam = 26, partners p != t <=> G_pt odd (48 per port), Z = G/2 - I (Z_su = G_su/2 - delta_su). + +Model (per column t, contract X = x - y, Y = x as in the T = -1 package): the carrier column is + Y_t = [y_t anchor] + L'_t + sum_{s partner of t} c_s K_s, K_s = x_s + sum_u Z_su y_u (COMPLETE junk), + c_s = -G_ts/2, L'_t = sum_u G_tu (x_u/2 + mu y_u) (rank-8 owned rows). +Proof [P]: x-part G_tu/2 + c_u [u partner] = delta_ut. y-part for u != t: mu G_tu - (lam-2)/4 G_tu + G_tu/2, using +sum_{s partner of t} G_ts G_su = (lam - 2) G_tu (the s = t term of G^2 is 2 G_tu); for u = t: 1 + 2 mu - (lam-2)/2. +Both vanish iff mu = mu* = (lam-2)/4 - 1/2 = 11/2. Legality core [P]: G = (D^T T)/2 so G_t.y = 1/2 sum_k D_kt (T_k.y) is a +combination of the eight owned U rows T_k.y; checked below as an exact identity. +Checked (all 104 columns, Fractions): + (a) PR968 hash, 104 ports, rank 8, G^2 = 26 G, 48 partners per port, mu* = 11/2; + (b) gauge mu*: Y_t = x_t with every y cancelled, 0/104 misses, no zero-Y park; owned rank of rows G(x/2 + mu* y) is 8; + (c) controls: mu = 0 -> 104/104 misses, residual exactly -11/2 G_t on all coordinates (so on every window N_p, all + 104 x 48 (t,p) pairs); zero-Y park with mu* -> 104/104 misses; one partial-junk carrier (20 of its 48 cells) -> 28 missed + coordinates in every column; wrong mu (mu* + 1/4) -> 104/104 misses; + (d) closed form: residual y of the mu-family equals (mu - mu*) G_t for the [y_t-anchored] column; + (e) legality identity G_t.y = 1/2 sum_k D_kt T_k.y on a fixed integer y, all t; and G_t.y with y in span of the 8 U rows. +Prints PASS_METHODS_PRELOAD.""" +import hashlib, os, sys, random +from pathlib import Path +from fractions import Fraction as Fr + +ROOT = Path(__file__).resolve().parents[2] +PR968 = 'research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt' +PR968_SHA256 = '8e0178db02c14e1b29058cdbdbd50aac22f2b55a1ba21dc82f417610c9932526' + + +def say(s): + print(s, flush=True) + + +def expect(name, got, want): + if got != want: + raise SystemExit('FAIL %s: got %r want %r' % (name, got, want)) + say('ok %s: %r' % (name, got)) + + +def load_e8(): + raw = (ROOT / PR968).read_bytes() + expect('SHA256 of %s' % PR968, hashlib.sha256(raw).hexdigest(), PR968_SHA256) + L = raw.decode().split('\n') + Dr = [[int(x) for x in l[3:].split()] for l in L if l.startswith(' d:')] + Tr = [[int(x) for x in l[3:].split()] for l in L if l.startswith(' t:')] + n = len(Dr[0]) + g = [[sum(Dr[k][i] * Tr[k][j] for k in range(8)) // 2 for j in range(n)] for i in range(n)] + return n, g, Dr, Tr + + +def rank(M): + A = [[Fr(x) for x in r] for r in M] + r = 0 + for c in range(len(A[0])): + p = next((i for i in range(r, len(A)) if A[i][c] != 0), None) + if p is None: + continue + A[r], A[p] = A[p], A[r] + piv = A[r][c] + A[r] = [x / piv for x in A[r]] + for i in range(len(A)): + if i != r and A[i][c] != 0: + f = A[i][c] + A[i] = [x - f * y for x, y in zip(A[i], A[r])] + r += 1 + return r + + +def main(): + n, G, Dr, Tr = load_e8() + expect('ports', n, 104) + expect('G symmetric, diag 2', all(G[i][j] == G[j][i] for i in range(n) for j in range(n)) and all(G[i][i] == 2 for i in range(n)), True) + expect('rank G', rank(G), 8) + G2 = [[sum(G[i][k] * G[k][j] for k in range(n)) for j in range(n)] for i in range(n)] + lam = 26 + expect('G^2 = 26 G', all(G2[i][j] == lam * G[i][j] for i in range(n) for j in range(n)), True) + P = [[s for s in range(n) if s != t and G[t][s] % 2] for t in range(n)] + expect('partners per port', sorted({len(v) for v in P}), [48]) + mu_star = Fr(lam - 2, 4) - Fr(1, 2) + expect('mu*', mu_star, Fr(11, 2)) + Z = lambda s, u: Fr(G[s][u], 2) - (1 if s == u else 0) + + def column(t, mu, park=False, partial=None): + """returns (x, y) final content of Y_t.""" + x = [Fr(0)] * n + y = [Fr(0)] * n + if not park: + y[t] += 1 + for u in range(n): + x[u] += Fr(G[t][u], 2) + y[u] += mu * G[t][u] + for s in P[t]: + c = Fr(-G[t][s], 2) + x[s] += c + for u in range(n): + if partial and s == partial[0] and u not in partial[1]: + continue + y[u] += c * Z(s, u) + return x, y + + def misses(t, mu, **kw): + x, y = column(t, mu, **kw) + return sum(1 for u in range(n) if x[u] != (1 if u == t else 0)) + sum(1 for u in range(n) if y[u] != 0), x, y + + say('== (b) gauge mu*') + expect('gauge mu*: columns with Y_t != x_t', sum(1 for t in range(n) if misses(t, mu_star)[0]), 0) + M = [[Fr(G[t][u], 2) for u in range(n)] + [mu_star * G[t][u] for u in range(n)] for t in range(n)] + expect('owned L rank, rows G(x/2 + mu* y)', rank(M), 8) + + say('== (c) controls') + bad0 = 0 + resid_ok = True + for t in range(n): + m, x, y = misses(t, Fr(0)) + bad0 += 1 if m else 0 + resid_ok &= all(y[u] == -mu_star * G[t][u] for u in range(n)) + expect('control mu = 0: columns missing', bad0, 104) + expect('control mu = 0: residual = -11/2 G_t on all coords', resid_ok, True) + wincount = 0 + wok = True + for t in range(n): + _, _, y = misses(t, Fr(0)) + for p in P[t]: + Np = [u for u in range(n) if G[p][u] % 2 == 0] + wincount += 1 + wok &= all(y[u] == -mu_star * G[t][u] for u in Np) and any(y[u] != 0 for u in Np) + expect('window N_p residual -11/2 G_t, nonzero, (t,p) pairs', (wok, wincount), (True, 104 * 48)) + expect('control zero-Y park + mu*: columns missing', sum(1 for t in range(n) if misses(t, mu_star, park=True)[0]), 104) + rng = random.Random(0) + allmiss = set() + for t in range(n): + s = P[t][1] + cells = set(rng.sample(P[s], 20)) + allmiss.add(misses(t, mu_star, partial=(s, cells))[0]) + expect('control one partial-junk carrier (20/48 cells): miss coords per column', sorted(allmiss), [28]) + expect('control wrong mu = mu* + 1/4: columns missing', sum(1 for t in range(n) if misses(t, mu_star + Fr(1, 4))[0]), 104) + + say('== (d) closed form') + cf = True + for mu in (Fr(0), Fr(3), Fr(-7, 3), mu_star): + for t in (0, 17, 103): + _, _, y = misses(t, mu) + cf &= all(y[u] == (mu - mu_star) * G[t][u] for u in range(n)) + expect('residual y = (mu - mu*) G_t', cf, True) + + say('== (e) legality core') + rg = random.Random(5) + yv = [rg.randint(-9, 9) for _ in range(n)] + Urows = [sum(Tr[k][u] * yv[u] for u in range(n)) for k in range(8)] + ok = all(sum(G[t][u] * yv[u] for u in range(n)) == Fr(1, 2) * sum(Dr[k][t] * Urows[k] for k in range(8)) for t in range(n)) + expect('G_t.y = 1/2 sum_k D_kt (T_k.y), all t', ok, True) + rows_y = [[Fr(Tr[k][u]) for u in range(n)] for k in range(8)] + expect('rank of the 8 owned U rows', rank(rows_y), 8) + expect('G rows lie in span of the U-row coefficient vectors (rank [T;G])', rank(rows_y + [[Fr(x) for x in r] for r in G]), 8) + say('PASS_METHODS_PRELOAD') + + +if __name__ == '__main__': + main() diff --git a/research/p104-methods/quotient.py b/research/p104-methods/quotient.py new file mode 100644 index 0000000000..21045c274e --- /dev/null +++ b/research/p104-methods/quotient.py @@ -0,0 +1,306 @@ +"""P104 method: the O+(8,2) quotient structure of the 104 ports and the c-trick. Standard library only, exact. + +Data (data/, SHA256 pinned below): ports104.json = {"lines": 104 F2^9 port vectors, "gram": signed 104x104 Gram} (our derived +data: charts of the #7334 word + reflection closure, REBASET1/gram104.py), packing8.json (8 port-disjoint 12-port blocks), +triples33.json (33 disjoint c-sum triples), iso968.json (port permutation + diagonal signs mapping the PR968 Gram onto the +vendored Gram). c = all-ones in F2^9. +Checked (names as in the printed lines): + (a) data hashes; Gram: symmetric, diagonal 2, rank 8, G^2 = 26 G, 48 partners per port, partners <=> G odd <=> dot(q_p,q_t)=0; + the vendored Gram equals the PR968 Gram under the vendored permutation with diagonal +-1 switching (every entry); + (b) every port has q.c = 1; W = c^perp/ (even-weight representatives q+c), omega = dot is symplectic (8 dim); + a quadratic form with polar omega taking value 1 on all 104 ports exists; it has 120 nonsingular and 135 singular + nonzero points, the ports are 104 of the nonsingular points, 16 missing; + (c) two-graph sign law: over all mutually-partner triples, G_py G_yt G_pt = -1 iff q_p+q_y+q_t = c (704 triples, all other + products +1; control: no non-c-sum triple has product -1); c-sum triples number 704 and all their pairs are partners; + (d) pair law (3-stop absorber fact): partner pairs split 2,112 with 24 common partners and exactly one sign-wrong cell, which + is the port t* with q_t* = q_p + q_y + c, and 384 with 22 common partners and no wrong cell (p-bar + y-bar is one of the + 16 missing points); + (e) 4-dim quotient spaces (all 200,787 enumerated): exactly 282 contain 12 ports; in each the 3 non-ports are a line and the + 12 ports carry 16 c-sum triples; + (f) the vendored packing: 8 blocks, each one of the 282, pairwise disjoint, covering 96 ports, with the 8 leftover ports + containing no c-sum triple (this packing only; controls: a perturbed packing fails disjointness, a random 12-subset is + not a block); + (g) c-trick: for every port p and every vector a, {partners of p not perp } = U (ports perp to p and a+c); on the + 33 vendored triples (disjoint, c-sum, pairs partners) with A2(p) = , bottom(p) = U of size 24, and the + (reader, host) pair has exactly one sign-wrong column, namely the third triple member (4,224 ordered pairs). +Not re-checked: the order-384 stabiliser (lane qgrp.py), orbit sizes 32/48/24. Prints PASS_METHODS_QUOTIENT.""" +import hashlib, itertools, json, random, collections +from pathlib import Path +from fractions import Fraction as Fr + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PR968 = 'research/complex-frame-pair-decoders/inputs/pr717/P104_HIT_flip_3a.txt' +PR968_SHA256 = '8e0178db02c14e1b29058cdbdbd50aac22f2b55a1ba21dc82f417610c9932526' +SHA = { + 'ports104.json': '0299f8f7165835231b057e1c6151ad0a8333efcb61a06a0a2aea045aa391c381', + 'packing8.json': 'a4bd773ede969488aacdf8feb38487b97ce3daf48d836bbb1bd48f6fd356e12e', + 'triples33.json': 'f9007e39cf6ce94915848e9c810f28572dc423c929e3c3f4d874301b8359d12e', + 'iso968.json': 'fd3fb6b90918d6802c7b22b7fe2efdf3a3979e4bc50bb610437957a84b702e1f', +} +C = 511 + + +def say(s): + print(s, flush=True) + + +def expect(name, got, want): + if got != want: + raise SystemExit('FAIL %s: got %r want %r' % (name, got, want)) + say('ok %s: %r' % (name, got)) + + +def dot(a, b): + return bin(a & b).count('1') & 1 + + +def rank(M): + A = [[Fr(x) for x in r] for r in M] + r = 0 + for c in range(len(A[0])): + p = next((i for i in range(r, len(A)) if A[i][c] != 0), None) + if p is None: + continue + A[r], A[p] = A[p], A[r] + piv = A[r][c] + A[r] = [x / piv for x in A[r]] + for i in range(len(A)): + if i != r and A[i][c] != 0: + f = A[i][c] + A[i] = [x - f * y for x, y in zip(A[i], A[r])] + r += 1 + return r + + +def wrong_cells(com, G, p, y): + """cells t in com where sign(G_pt G_yt) is the minority class (rows p, y proportional up to these cells).""" + pos = [t for t in com if G[p][t] * G[y][t] > 0] + neg = [t for t in com if G[p][t] * G[y][t] < 0] + if len(pos) == len(neg) and pos: + raise SystemExit('FAIL tie in sign classes') + return sorted(min(pos, neg, key=len)) + + +def span(vs): + s = {0} + for v in vs: + if v not in s: + s |= {x ^ v for x in s} + return s + + +def main(): + raws = {} + for f in SHA: + raws[f] = (HERE / 'data' / f).read_bytes() + expect('SHA256 data/' + f, hashlib.sha256(raws[f]).hexdigest(), SHA[f]) + d = json.loads(raws['ports104.json']) + L, G = d['lines'], d['gram'] + n = len(L) + expect('ports (distinct)', (n, len(set(L))), (104, 104)) + expect('port range', all(0 <= v < 512 for v in L), True) + + say('== (a) Gram') + expect('G symmetric, diag 2', all(G[i][j] == G[j][i] for i in range(n) for j in range(n)) and all(G[i][i] == 2 for i in range(n)), True) + expect('rank G', rank(G), 8) + G2 = [[sum(G[i][k] * G[k][j] for k in range(n)) for j in range(n)] for i in range(n)] + expect('G^2 = 26 G', all(G2[i][j] == 26 * G[i][j] for i in range(n) for j in range(n)), True) + partner = [[t for t in range(n) if t != p and G[p][t] % 2] for p in range(n)] + expect('partners per port', sorted({len(v) for v in partner}), [48]) + expect('partner <=> dot(q_p,q_t) = 0', all((G[p][t] % 2 == 1) == (dot(L[p], L[t]) == 0) for p in range(n) for t in range(n) if p != t), True) + # PR968 cross-check + raw = (ROOT / PR968).read_bytes() + expect('SHA256 of %s' % PR968, hashlib.sha256(raw).hexdigest(), PR968_SHA256) + ls = raw.decode().split('\n') + Dr = [[int(x) for x in l[3:].split()] for l in ls if l.startswith(' d:')] + Tr = [[int(x) for x in l[3:].split()] for l in ls if l.startswith(' t:')] + GP = [[sum(Dr[k][i] * Tr[k][j] for k in range(8)) // 2 for j in range(n)] for i in range(n)] + iso = json.loads(raws['iso968.json']) + perm, eps = iso['perm'], iso['eps'] + expect('iso968: perm is a permutation, eps = +-1', (sorted(perm) == list(range(n)), set(eps) <= {1, -1}), (True, True)) + expect('PR968 Gram = eps eps G104(perm) on all 104^2 entries', + all(GP[u][v] == eps[u] * eps[v] * G[perm[u]][perm[v]] for u in range(n) for v in range(n)), True) + wrong_perm = perm[:] + wrong_perm[0], wrong_perm[1] = wrong_perm[1], wrong_perm[0] + expect('control: swapped permutation fails', all(GP[u][v] == eps[u] * eps[v] * G[wrong_perm[u]][wrong_perm[v]] for u in range(n) for v in range(n)), False) + + say('== (b) quotient form') + expect('every port has q.c = 1', all(dot(v, C) == 1 for v in L), True) + Q = [v ^ C for v in L] + expect('quotient reps even weight', all(bin(v).count('1') % 2 == 0 for v in Q), True) + EV = [v for v in range(1, 512) if bin(v).count('1') % 2 == 0] + expect('even-weight nonzero vectors (c^perp minus 0, 8-dim)', len(EV), 255) + # omega nondegenerate on even space: radical of dot on even vectors is {0, c}; c is odd weight (9) so not in it + radical = [v for v in EV if all(dot(v, w) == 0 for w in EV)] + expect('omega nondegenerate on even space', radical, []) + # quadratic forms with polar omega: q_a(v) = wt(v)/2 + a.v (v even) + sols = [a for a in range(256) if all((bin(v).count('1') // 2 + dot(a, v)) % 2 == 1 for v in Q)] + expect('forms q_a (a in F2^8 mod c) equal to 1 on all 104 ports', len(sols), 1) + a0 = sols[0] + qf = lambda v: (bin(v).count('1') // 2 + dot(a0, v)) % 2 + nonsing = [v for v in EV if qf(v) == 1] + expect('nonsingular / singular nonzero points', (len(nonsing), 255 - len(nonsing)), (120, 135)) + Qs = set(Q) + expect('ports inside nonsingular points', Qs <= set(nonsing), True) + missing = [v for v in nonsing if v not in Qs] + expect('missing nonsingular points', len(missing), 16) + expect('partner <=> omega(p-bar, t-bar) = 1', all((G[p][t] % 2 == 1) == (dot(Q[p], Q[t]) == 1) for p in range(n) for t in range(n) if p != t), True) + + say('== (c) two-graph sign law') + part = [set(x) for x in partner] + neg = pos = negok = posok = 0 + cs = [] + for p in range(n): + for y in partner[p]: + if y < p: + continue + for t in part[p] & part[y]: + if t < y: + continue + prod = G[p][y] * G[y][t] * G[p][t] + csum = (L[p] ^ L[y] ^ L[t]) == C + if prod == -1: + neg += 1 + negok += csum + else: + pos += 1 + posok += (not csum) + if csum: + cs.append((p, y, t)) + say(' mutually-partner triples: %d with sign -1, %d with sign +1' % (neg, pos)) + expect('product -1 iff c-sum (704 triples)', (neg, negok, pos == posok), (704, 704, True)) + expect('control: non-c-sum triples with product -1', neg - negok, 0) + # c-sum triples among ports, regardless of partnerness + QI = {v: i for i, v in enumerate(Q)} + TRI = [(p, q, QI[Q[p] ^ Q[q]]) for p, q in itertools.combinations(range(n), 2) if (Q[p] ^ Q[q]) in QI and QI[Q[p] ^ Q[q]] > q] + expect('c-sum triples (q_p+q_q+q_x = c)', len(TRI), 704) + expect('their pairs are all partners', all(b in part[a] for t in TRI for a, b in itertools.combinations(t, 2)), True) + expect('they are exactly the sign -1 triples', sorted(map(tuple, map(sorted, TRI))) == sorted(cs), True) + + say('== (d) pair law / 3-stop absorber') + st = collections.Counter() + tstar_ok = True + miss_ok = True + missing_s = set(missing) + for p in range(n): + for y in partner[p]: + if y < p: + continue + com = sorted(part[p] & part[y]) + wr = wrong_cells(com, G, p, y) + st[(len(com), len(wr))] += 1 + x = Q[p] ^ Q[y] + if len(wr) == 1: + tstar_ok &= (wr[0] == QI.get(x, -1)) + else: + miss_ok &= (x in missing_s) + expect('partner pairs by (common partners, sign-wrong cells)', dict(st), {(24, 1): 2112, (22, 0): 384}) + expect('wrong cell is the port with q = q_p+q_y+c; else p-bar+y-bar is missing', (tstar_ok, miss_ok), (True, True)) + + say('== (e) 12-port 4-dim quotient spaces') + Q8 = {v & 255: i for i, v in enumerate(Q)} # linear iso of even-weight space with F2^8: drop bit 8 + expect('8-bit coordinates injective on ports', len(Q8), 104) + blocks = {} + hist = collections.Counter() + nsub = 0 + for piv in itertools.combinations(range(8), 4): + free = [[c for c in range(piv[i] + 1, 8) if c not in piv] for i in range(4)] + nf = sum(len(f) for f in free) + for m in range(1 << nf): + rows = [] + k = 0 + for i in range(4): + r = 1 << piv[i] + for c in free[i]: + if (m >> k) & 1: + r |= 1 << c + k += 1 + rows.append(r) + nsub += 1 + els = span(rows) + ports = frozenset(Q8[v] for v in els if v in Q8) + hist[len(ports)] += 1 + if len(ports) == 12: + blocks[ports] = els + expect('4-dim subspaces of F2^8 enumerated', nsub, 200787) + say(' ports-per-4-space histogram: %s' % sorted(hist.items())) + expect('4-spaces containing exactly 12 ports', len(blocks), 282) + line_ok = tri_ok = True + for ports, els in blocks.items(): + non = [v for v in els if v and v not in Q8] + line_ok &= (len(non) == 3 and non[0] ^ non[1] == non[2]) + pv = sorted(v for v in els if v in Q8) + tri_ok &= sum(1 for a, b in itertools.combinations(pv, 2) if (a ^ b) in Q8 and (a ^ b) > b) == 16 + expect('the 3 non-ports of each form a line', line_ok, True) + expect('each carries 16 c-sum triples', tri_ok, True) + + say('== (f) packing of 8 blocks') + pk = json.loads(raws['packing8.json']) + blk = [frozenset(b) for b in pk['blocks']] + left = sorted(pk['leftover']) + expect('packing: 8 blocks of 12 ports', (len(blk), sorted({len(b) for b in blk})), (8, [12])) + expect('each is one of the 282 blocks', all(frozenset(Q8[Q[p] & 255] for p in b) in blocks for b in blk), True) + cover = set().union(*blk) + expect('pairwise disjoint, covering 96 ports', (sum(len(b) for b in blk), len(cover)), (96, 96)) + expect('leftover = the other 8 ports', left, sorted(set(range(n)) - cover)) + TS = set(map(frozenset, TRI)) + expect('triples inside the leftover', sum(1 for t in itertools.combinations(left, 3) if frozenset(t) in TS), 0) + # controls + bad = [set(b) for b in blk] + swap_out = sorted(bad[0])[0] + swap_in = sorted(bad[1])[0] + bad[0].remove(swap_out) + bad[0].add(swap_in) + expect('control: perturbed packing fails disjointness', sum(len(b) for b in bad) == len(set().union(*bad)), False) + expect('control: perturbed block is not a 12-port 4-space', frozenset(Q8[Q[p] & 255] for p in bad[0]) in blocks, False) + rg = random.Random(1) + rnd = frozenset(rg.sample(range(n), 12)) + expect('control: random 12-subset is not a block', frozenset(Q8[Q[p] & 255] for p in rnd) in blocks, False) + expect('control: a random 12-subset spans more than 4 dims', len(span([Q[p] for p in rnd])) > 16, True) + t0 = TRI[0] + expect('control: an 8-set containing a c-sum triple is detected by the leftover test', + sum(1 for t in itertools.combinations(sorted(list(t0) + left[:5]), 3) if frozenset(t) in TS) >= 1, True) + + say('== (g) c-trick') + bottomok = True + for p in range(n): + for a in range(512): + bottom = {t for t in partner[p] if dot(L[t], a)} + U = {t for t in range(n) if dot(L[t], L[p]) == 0 and dot(L[t], a ^ C) == 0} + bottomok &= (bottom == U) + expect('bottom(p,a) = U for all ports p, all a in F2^9', bottomok, True) + tr = [tuple(t) for t in json.loads(raws['triples33.json'])['triples']] + expect('33 triples, 99 distinct ports', (len(tr), len({v for t in tr for v in t})), (33, 99)) + expect('all c-sum', all((L[a] ^ L[b] ^ L[c_]) == C for a, b, c_ in tr), True) + expect('all pairs partners', all(b in part[a] for t in tr for a, b in itertools.combinations(t, 2)), True) + ok24 = True + one_wrong = 0 + ordered = 0 + for t in tr: + for p, q in itertools.permutations(t, 2): + x = [v for v in t if v not in (p, q)][0] + bottom = {u for u in partner[p] if dot(L[u], L[q])} # A2(p) = + U_px = {u for u in range(n) if dot(L[u], L[p]) == 0 and dot(L[u], L[x]) == 0} + ok24 &= (bottom == U_px and len(bottom) == 24) + # (reader p, host x): common partners, sign-wrong cells + com = sorted(part[p] & part[x]) + wr = wrong_cells(com, G, p, x) + ordered += 1 + one_wrong += (wr == [q]) + expect('bottom(p) = U, size 24, all ordered (p,q) in the 33 triples', ok24, True) + expect('sign-wrong column of (reader p, host x) is the third member q (ordered pairs)', (one_wrong, ordered), (198, 198)) + allord = sum(1 for t in TRI for p, x in itertools.permutations(t, 2) + if wrong_cells(sorted(part[p] & part[x]), G, p, x) == [[v for v in t if v not in (p, x)][0]]) + expect('same for all 704 c-sum triples, ordered (reader, host) pairs', allord, 4224) + # control: a non-c-sum mutually partner triple does not have this property + nonc = next((p, y, t) for p in range(n) for y in partner[p] for t in part[p] & part[y] if (L[p] ^ L[y] ^ L[t]) != C) + p, y, t = nonc + expect('control: non-c-sum partner triple product', G[p][y] * G[y][t] * G[p][t] > 0, True) + badtri = (tr[0][0], tr[0][1], left[0]) + expect('control: perturbed triple is not c-sum', (L[badtri[0]] ^ L[badtri[1]] ^ L[badtri[2]]) == C, False) + say('PASS_METHODS_QUOTIENT') + + +if __name__ == '__main__': + main() diff --git a/research/p104-methods/rado_lu.py b/research/p104-methods/rado_lu.py new file mode 100644 index 0000000000..dc93c32a77 --- /dev/null +++ b/research/p104-methods/rado_lu.py @@ -0,0 +1,433 @@ +"""P104 methods: signed-row group rule, Rado transversal test, and LU into elementary ADDs (FANOUTOPT's exact group algebra). + +Standard library only, exact Fractions. Source lane: FANOUTOPT (RESULT.md section 1 "Group rule", Lemma 1, "One helper can +fix a deficit of 2"; build2.ops_from_T). This file is a small ABSTRACT demo of the algebra, not the FANOUT56 geometry. + +Model [P, FANOUTOPT section 1]. A group of m co-located members holds incoming need rows R (m x d, rows in Q^d), row space +Omega, rank r. Member p leaves for a frame whose allowed coordinate set is A'_p, so its outgoing row must lie in +Omega_p = Omega intersect R^{A'_p}. Every ADD (row_x += c * row_y) is a transvection, so the group's total effect is +N = T R with T in SL(m). The group is feasible (without new helpers) iff one vector v_p in Omega_p can be chosen per member +with the v_p spanning Omega (Rado); then N = (v_p) is reached from R by some T in SL, realised by LU as transvections. +A helper is a member with a free signed incoming row h that leaves with row 0 (A' = empty set). + +Rado test used here (exact): max independent partial transversal size = min over member subsets S of +(dim sum_{p in S} Omega_p + m - |S|) [matroid Rado/Hall deficiency form, linear matroid]. Feasible iff that is >= r. +A transversal is then constructed (random integer combinations) and verified in Fractions, so every "feasible" verdict +carries an exact certificate, and every "infeasible" verdict is cross-checked by brute force (small-integer box). + +Checked (all exact): + (a) case (i): a feasible group: certificate, T in SL by LU, replay of the ADDs gives every member its chosen row; + (b) case (ii): two proportional members leaving on different coordinate sets: Omega_1 = Omega_2 = {0}, infeasible + without a helper; infeasible by brute force too; ONE helper with a free signed row fixes it (deficit 2 -> 0), the + helper leaves with row 0, ADD replay exact; + (c) control (iii): helpers whose row is restricted to a single coordinate e_k (the old pure-helper rule, modelled as a + restriction of the helper row) fail on the same group for every k, while a free signed row succeeds; + (d) seeded random sweep: Rado verdict == brute-force verdict (box [-3,3]) on every instance; every feasible verdict has + an exact replayed certificate; + (e) group rule controls: a transversal that does not span is rejected by the verifier; a corrupted ADD list fails replay. +The lane's full build is QUOTED, not reproduced here: F = 408.68 D0/call with 50 helpers vs FANOUT56's 1,692.1 (4.14x), +proved floor 315.05 [lane exact run, not reproduced in this package]. +Prints PASS_METHODS_RADO_LU.""" +import itertools, random, sys +from fractions import Fraction as Fr + + +def say(s): + print(s, flush=True) + + +def expect(name, got, want): + if got != want: + raise SystemExit('FAIL %s: got %r want %r' % (name, got, want)) + say('ok %s: %r' % (name, got)) + + +# ------------------------------------------------------------------------------------------------ linear algebra +def rref(rows): + """Reduced row echelon basis (list of rows) of the row space; exact.""" + A = [[Fr(x) for x in r] for r in rows] + out = [] + ncol = len(A[0]) if A else 0 + piv = [] + for c in range(ncol): + p = next((i for i in range(len(out), len(A)) if A[i][c] != 0), None) + if p is None: + continue + k = len(out) + A[k], A[p] = A[p], A[k] + A[k] = [x / A[k][c] for x in A[k]] + for i in range(len(A)): + if i != k and A[i][c] != 0: + f = A[i][c] + A[i] = [x - f * y for x, y in zip(A[i], A[k])] + out.append(A[k]) + piv.append(c) + return out[:len(piv)] + + +def rank(rows): + return len(rref(rows)) if rows else 0 + + +def left_null(M, ncols=None): + """Basis of {w : w M = 0} for M given as list of rows (m x k); returns list of m-vectors.""" + m = len(M) + k = ncols if ncols is not None else (len(M[0]) if M else 0) + if k == 0: + return [[Fr(int(i == j)) for j in range(m)] for i in range(m)] + # nullspace of M^T (k x m) + A = [[Fr(M[i][j]) for i in range(m)] for j in range(k)] + pivc, r = [], 0 + for c in range(m): + p = next((i for i in range(r, k) if A[i][c] != 0), None) + if p is None: + continue + A[r], A[p] = A[p], A[r] + A[r] = [x / A[r][c] for x in A[r]] + for i in range(k): + if i != r and A[i][c] != 0: + f = A[i][c] + A[i] = [x - f * y for x, y in zip(A[i], A[r])] + pivc.append(c) + r += 1 + out = [] + for f in range(m): + if f in pivc: + continue + v = [Fr(0)] * m + v[f] = Fr(1) + for i, c in enumerate(pivc): + v[c] = -A[i][f] + out.append(v) + return out + + +def omega_section(B, A, d): + """Basis of Omega_p = rowspace(B) intersect R^{A}: vectors x B with zero entries outside A.""" + if not B: + return [] + outside = [j for j in range(d) if j not in A] + sub = [[b[j] for j in outside] for b in B] + W = left_null(sub, len(outside)) + vecs = [[sum(w[i] * B[i][j] for i in range(len(B))) for j in range(d)] for w in W] + return rref(vecs) if vecs else [] + + +# ------------------------------------------------------------------------------------------------ Rado test +def rado_max_transversal(R, exits, d): + """(rank r of Omega, max independent partial transversal size, Omega_p bases) by the exact deficiency formula.""" + B = rref(R) + r = len(B) + secs = [omega_section(B, set(A), d) for A in exits] + m = len(exits) + best = m + 0 + for k in range(m + 1): + for S in itertools.combinations(range(m), k): + rows = [v for p in S for v in secs[p]] + val = (rank(rows) if rows else 0) + m - k + best = min(best, val) + return r, min(best, r), secs + + +def find_transversal(R, exits, d, rng, tries=40): + """Exact certificate: one vector per member (0 allowed if Omega_p = 0) spanning Omega; None if the test says infeasible.""" + r, mx, secs = rado_max_transversal(R, exits, d) + if mx < r: + return None + for _ in range(tries): + N = [] + for S in secs: + v = [Fr(0)] * d + for b in S: + c = rng.randint(1, 10 ** 6) + v = [x + c * y for x, y in zip(v, b)] + N.append(v) + if rank(N) == r: + return N + raise SystemExit('FAIL: Rado says feasible but no random transversal found') + + +def verify_transversal(R, exits, N, d): + """Independent exact check: v_p in Omega_p (zero outside A'_p and in rowspace R) and the v_p span rowspace R.""" + B = rref(R) + for v, A in zip(N, exits): + if any(v[j] != 0 for j in range(d) if j not in set(A)): + return False + if rank(B + [v]) != len(B): + return False + return rank(N) == len(B) + + +# ------------------------------------------------------------------------------------------------ LU into transvections +def det_and_ops(T): + """Reduce T (invertible, det d0) to the identity by ADDs only after pre-scaling is excluded: requires det T = 1. + Returns the ADD list (x, y, c) meaning row_x += c * row_y that carries I -> T when applied to rows of I + (equivalently R -> T R).""" + m = len(T) + M = [[Fr(x) for x in row] for row in T] + log = [] + + def add(x, y, c): + M[x] = [a + c * b for a, b in zip(M[x], M[y])] + log.append((x, y, c)) + for k in range(m): + if M[k][k] == 0: + j = next((j for j in range(k + 1, m) if M[j][k] != 0), None) + if j is None: + raise ValueError('singular') + add(k, j, Fr(1)) + if k < m - 1: + if all(M[j][k] == 0 for j in range(k + 1, m)): + add(k + 1, k, Fr(1)) + j = next(j for j in range(k + 1, m) if M[j][k] != 0) + if M[k][k] != 1: + add(k, j, (1 - M[k][k]) / M[j][k]) + else: + if M[k][k] != 1: + raise ValueError('det != 1') + for i in range(m): + if i != k and M[i][k] != 0: + add(i, k, -M[i][k]) + assert all(M[i][j] == (1 if i == j else 0) for i in range(m) for j in range(m)) + # E_N ... E_1 T = I => T = E_1^-1 ... E_N^-1 ; applying T to R applies E_N^-1 first + return [(x, y, -c) for (x, y, c) in reversed(log)] + + +def determinant(T): + m = len(T) + M = [[Fr(x) for x in row] for row in T] + det = Fr(1) + for c in range(m): + p = next((i for i in range(c, m) if M[i][c] != 0), None) + if p is None: + return Fr(0) + if p != c: + M[c], M[p] = M[p], M[c] + det = -det + det *= M[c][c] + for i in range(c + 1, m): + if M[i][c] != 0: + f = M[i][c] / M[c][c] + M[i] = [a - f * b for a, b in zip(M[i], M[c])] + return det + + +def solve_T(R, N, rng): + """T in SL(m) with T R = N' where N' equals N except one row is rescaled to fix det; None if rowspaces differ.""" + R = [[Fr(x) for x in row] for row in R] + N = [[Fr(x) for x in row] for row in N] + m = len(R) + d = len(R[0]) + r = rank(R) + if rank(N) != r or rank(R + N) != r: + return None + # express each N row in an independent row subset I of R + I = [] + for i in range(m): + if rank([R[j] for j in I] + [R[i]]) == len(I) + 1: + I.append(i) + RI = [[Fr(x) for x in R[i]] for i in I] + T0 = [] + for v in N: + # solve c RI = v by elimination on the augmented transpose + k = len(I) + A = [[RI[i][j] for i in range(k)] + [v[j]] for j in range(d)] + pivc, rr = [], 0 + for c in range(k): + p = next((i for i in range(rr, d) if A[i][c] != 0), None) + if p is None: + continue + A[rr], A[p] = A[p], A[rr] + A[rr] = [x / A[rr][c] for x in A[rr]] + for i in range(d): + if i != rr and A[i][c] != 0: + f = A[i][c] + A[i] = [x - f * y for x, y in zip(A[i], A[rr])] + pivc.append(c) + rr += 1 + c_ = [Fr(0)] * k + for i, c in enumerate(pivc): + c_[c] = A[i][k] + row = [Fr(0)] * m + for a, i in enumerate(I): + row[i] = c_[a] + T0.append(row) + W = left_null(R, d) # rows w with w R = 0 + for _ in range(60): + T = [row[:] for row in T0] + for i in range(m): + for w in W: + c = Fr(rng.randint(-5, 5)) + T[i] = [a + c * b for a, b in zip(T[i], w)] + dt = determinant(T) + if dt == 0: + continue + T[0] = [x / dt for x in T[0]] # rescale row 0 of T (and so of N) to make det 1 + N2 = [[sum(T[i][k] * R[k][j] for k in range(m)) for j in range(d)] for i in range(m)] + return T, N2 + return None + + +def apply_ops(R, ops): + R = [[Fr(x) for x in r] for r in R] + for x, y, c in ops: + R[x] = [a + c * b for a, b in zip(R[x], R[y])] + return R + + +def realise(R, exits, d, rng): + """Feasible group -> (N, ops) with ops an exact ADD list taking R to N, N verified as a transversal. None if infeasible.""" + N = find_transversal(R, exits, d, rng) + if N is None: + return None + assert verify_transversal(R, exits, N, d) + for _ in range(30): + st = solve_T(R, N, rng) + if st is None: + raise SystemExit('FAIL: no T although transversal spans') + T, N2 = st + try: + ops = det_and_ops(T) + except ValueError: + continue + got = apply_ops(R, ops) + if got != N2: + raise SystemExit('FAIL: LU replay mismatch') + assert verify_transversal(R, exits, N2, d) + return N2, ops + raise SystemExit('FAIL: LU failed') + + +def group_with_helper(R, exits, h, d): + """Add one helper: free incoming row h, exits with row 0 (allowed set empty).""" + return R + [h], list(exits) + [()] + + +# ------------------------------------------------------------------------------------------------ brute force +def projective_box(d, bound): + out = [] + for v in itertools.product(range(-bound, bound + 1), repeat=d): + if any(v): + f = next(x for x in v if x) + if f > 0: + out.append(v) + return out + + +def brute_feasible(R, exits, d, bound=3): + """Independent check: DFS over small-integer vectors in each Omega_p (zero allowed), looking for a spanning choice.""" + B = rref(R) + r = len(B) + pts = projective_box(d, bound) + cand = [] + for A in exits: + As = set(A) + c = [v for v in pts if all(v[j] == 0 for j in range(d) if j not in As) and rank(B + [list(map(Fr, v))]) == r] + cand.append(c) + m = len(exits) + + def dfs(i, chosen): + if rank(chosen) == r: + return True + if i == m: + return False + # prune: remaining members cannot reach rank r + if rank(chosen) + (m - i) < r: + return False + for v in cand[i]: + if rank(chosen + [list(map(Fr, v))]) > rank(chosen) and dfs(i + 1, chosen + [list(map(Fr, v))]): + return True + return dfs(i + 1, chosen) + return dfs(0, []) + + +# ------------------------------------------------------------------------------------------------ demo +def main(): + rng = random.Random(20261113) + d = 3 + say('ABSTRACT group algebra demo (FANOUTOPT section 1); not the FANOUT56 geometry') + + # (i) feasible group: three members, rows span a plane, each may exit on a pair of coordinates + R1 = [[1, 1, 0], [0, 1, 1], [1, 2, 1]] + X1 = [(0, 1), (1, 2), (0, 2)] + rk1, mx1, _ = rado_max_transversal(R1, X1, d) + expect('case (i) rank Omega / max transversal', (rk1, mx1), (2, 2)) + N, ops = realise(R1, X1, d, rng) + expect('case (i) certificate verifies', verify_transversal(R1, X1, N, d), True) + expect('case (i) replay of %d ADDs reaches N' % len(ops), apply_ops(R1, ops) == N, True) + expect('case (i) brute force agrees', brute_feasible(R1, X1, d), True) + + # (ii) two proportional members on different coordinate blocks: Omega = span(1,1,1,1), exits {0,1} and {2,3} + d = 4 + R2 = [[1, 1, 1, 1], [2, 2, 2, 2]] + X2 = [(0, 1), (2, 3)] + rk2, mx2, secs2 = rado_max_transversal(R2, X2, d) + expect('case (ii) Omega_p dimensions (no helper)', [len(s) for s in secs2], [0, 0]) + expect('case (ii) Rado: rank, max transversal (deficit 2: both sections 0)', (rk2, mx2), (1, 0)) + expect('case (ii) infeasible without helper (brute force box [-3,3] agrees)', brute_feasible(R2, X2, d), False) + h = [1, 1, 0, 0] # one helper, FREE signed incoming row, leaves with row 0 + Rh, Xh = group_with_helper(R2, X2, h, d) + expect('case (ii) with helper %r: sections now' % (h,), [len(s) for s in rado_max_transversal(Rh, Xh, d)[2]], [1, 1, 0]) + Nh, opsh = realise(Rh, Xh, d, rng) + expect('case (ii) helper exits with row 0', Nh[2], [0, 0, 0, 0]) + expect('case (ii) members leave inside their sections', verify_transversal(Rh, Xh, Nh, d), True) + expect('case (ii) ADD replay (%d ADDs) exact' % len(opsh), apply_ops(Rh, opsh) == Nh, True) + expect('case (ii) brute force agrees (feasible with helper)', brute_feasible(Rh, Xh, d), True) + def fixes(hh): + Rq, Xq = group_with_helper(R2, X2, list(hh), d) + return rado_max_transversal(Rq, Xq, d)[1] == rank(Rq) + nfree = sum(1 for hh in itertools.product(range(-2, 3), repeat=d) if any(hh) and fixes(hh)) + say(' (signed helper rows in [-2,2]^4 that fix it: %d of 624)' % nfree) + + # (iii) control: old pure-helper rule = helper row restricted to a single coordinate e_k + pure = [] + for k in range(d): + Rp, Xp = group_with_helper(R2, X2, [int(j == k) for j in range(d)], d) + pure.append(rado_max_transversal(Rp, Xp, d)[1] == rank(Rp)) + expect('control (iii) pure helper e_k fixes it for k=0..3', pure, [False] * 4) + # scope note: with single-coordinate exits a pure row can suffice (so the free row matters for blocks) + R3 = [[1, 1, 0, 0], [2, 2, 0, 0]] + X3 = [(0,), (1,)] + Rp, Xp = group_with_helper(R3, X3, [1, 0, 0, 0], d) + expect('scope: single-coordinate exits, pure e_0 helper suffices', rado_max_transversal(Rp, Xp, d)[1] == rank(Rp), True) + + # (e) group-rule controls + bad = [[Fr(1), Fr(1), Fr(0), Fr(0)], [Fr(2), Fr(2), Fr(0), Fr(0)], [Fr(0)] * 4] # transversal that does not span + expect('control: non-spanning transversal rejected', verify_transversal(Rh, Xh, bad, d), False) + corrupted = list(opsh) + x, y, c = corrupted[0] + corrupted[0] = (x, y, c + 1) + expect('control: corrupted ADD list fails replay', apply_ops(Rh, corrupted) == Nh, False) + + # (d) seeded sweep: Rado verdict vs brute force + srng = random.Random(77) + dd, tot, nfeas, ninf = 3, 0, 0, 0 + for _ in range(120): + m = srng.randint(2, 4) + R = [[srng.choice((-1, 0, 0, 1)) for _ in range(dd)] for _ in range(m)] + if rank(R) == 0: + continue + X = [tuple(j for j in range(dd) if srng.random() < 0.45) for _ in range(m)] + r_, mx, _ = rado_max_transversal(R, X, dd) + bf = brute_feasible(R, X, dd) + if (mx == r_) != bf: + raise SystemExit('FAIL sweep mismatch R=%r X=%r rado=%r brute=%r' % (R, X, (r_, mx), bf)) + tot += 1 + if bf: + nfeas += 1 + N, ops = realise(R, X, dd, srng) + if apply_ops(R, ops) != N or not verify_transversal(R, X, N, dd): + raise SystemExit('FAIL sweep replay') + else: + ninf += 1 + say('sweep: %d instances, %d feasible (all with exact transversal + ADD replay), %d infeasible; Rado == brute force on all' + % (tot, nfeas, ninf)) + expect('sweep covers both verdicts', nfeas > 5 and ninf > 5, True) + + say('Quoted, NOT reproduced here [lane exact run]: FANOUTOPT full build F = 408.68 D0/call with 50 helpers vs FANOUT56 1,692.1 ' + '(4.14x); proved floor 315.05 D0/call.') + say('PASS_METHODS_RADO_LU') + + +if __name__ == '__main__': + main() diff --git a/research/p104-methods/rebasis.py b/research/p104-methods/rebasis.py new file mode 100644 index 0000000000..04a3a781f2 --- /dev/null +++ b/research/p104-methods/rebasis.py @@ -0,0 +1,241 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""{0}/V re-basis: the helper-761 rung merge of #7542, rebuilt from #7334's word. + +Standard library only. Written for this package; it imports no other package. + +The vendored word is Clear1nsight's #7334 WORD.json.gz (SHA256 pinned below, +identical bytes to the copy vendored by #7542). The checker + +1. applies the six deletions, five insertions and five appended events of the + 761 merge (the helper-761 half of #7542's edit list) and replays both words + over the rationals from arbitrary inputs with the full legality rules of + #7542's check.py (operands at the event chart, public MOVEs strictly + ascend, owned MOVEs nested, owned fields cleared, public fields end at + their final charts); +2. requires all 1,569 rows and end charts to equal #7334's, and only helper + 761's MOVE chain to change (dims 0->5->7->8->9 become 0->7->8->9); +3. checks the two re-basis facts the edit rests on, separately from the + replay: ({0}) 761 and 1266 both sit at {0} at the new ADD and no event + writes 761 between it and the deleted ADD at chart 1053, so 1266 receives + the same content; (V) the four appended ADDs act at V on V-ending helpers + whose final rows are their own unit rows, and the row 1438 carries into V + in the new word differs from #7334's final row by exactly + -(e_311 - e_591 + 2 e_760 + e_1439), i.e. it lies in W_V and the V-phase + recombination restores it; +4. runs rejecting controls. +""" +import collections +import copy +import gzip +import hashlib +import json +import sys +from fractions import Fraction as Q +from pathlib import Path + +HERE = Path(__file__).resolve().parent +BASE = HERE / 'data' / 'base-7334-word.json.gz' +BASE_SHA256 = '4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a' +ZERO, V = 3, 127 # frame indices of {0} and V in #7334's word + +# The helper-761 half of #7542's data/edits.json (indices into #7334's program). +EDIT = { + 'delete': [ + [36446, ['MOVE', 1266, 3, 1053, False]], + [36447, ['MOVE', 761, 3, 1053, False]], + [36448, ['ADD', 1266, 761, '1/2', 1053]], + [36449, ['ADD', 1438, 761, '-1/2', 1053]], + [38225, ['MOVE', 591, 3, 1053, False]], + [42299, ['MOVE', 761, 1053, 1083, False]], + ], + 'insert_before': [ + [36442, [['ADD', 1266, 761, '1/2', 3]]], + [36446, [['MOVE', 591, 3, 1053, False], ['ADD', 1438, 591, '1', 1053], ['ADD', 1438, 760, '-2', 1053]]], + [42299, [['MOVE', 761, 3, 1083, False]]], + ], + 'append': [ + ['ADD', 1438, 311, '1', 127], ['ADD', 1438, 591, '-1', 127], ['ADD', 1438, 760, '2', 127], + ['ADD', 1438, 1439, '1', 127], ['MOVE', 1266, 3, 1053, False], + ], +} + + +def require(cond, label): + if not cond: + raise AssertionError(label) + + +def span(vectors): + s = {0} + for v in vectors: + require(type(v) is int and 0 < v < 512 and v not in s, 'frame vectors independent in F2^9') + s |= {x ^ v for x in s} + return frozenset(s) + + +def apply_edit(program, E): + dele = {} + for i, ev in E['delete']: + require(program[i] == ev, 'deleted event %d matches #7334' % i) + dele[i] = ev + ins = collections.defaultdict(list) + for i, evs in E['insert_before']: + ins[i].extend(evs) + out = [] + for i, ev in enumerate(program): + out.extend(ins.get(i, [])) + if i not in dele: + out.append(ev) + return out + E['append'] + + +def replay(W, stop=None): + """Exact replay from arbitrary inputs; raises on any illegality. stop: replay only a prefix (no end checks).""" + n, N = W['public'], W['public'] + W['owned_fields'] + sp = [span(f) for f in W['frames']] + rows = [{r: Q(1)} if r < n else {} for r in range(N)] + cur = list(W['initial']) + [None] * W['owned_fields'] + alive, chains = set(), collections.defaultdict(list) + owned_moves, lifetimes, init_chart, peak = collections.Counter(), collections.Counter(), {}, 0 + prog = W['program'] if stop is None else W['program'][:stop] + for i, e in enumerate(prog): + op, r = e[0], e[1] + require(type(r) is int and 0 <= r < N, '%d register index' % i) + if op == 'MOVE': + a, b, flag = e[2], e[3], e[4] + require(type(flag) is bool and flag == (r >= n), '%d MOVE ownership flag' % i) + require(cur[r] == a, '%d MOVE from the current chart' % i) + if r >= n: + require(r in alive, '%d owned MOVE on a live field' % i) + require(sp[a] < sp[b] or sp[b] < sp[a], '%d owned MOVE nested' % i) + owned_moves[(a, b)] += 1 + else: + require(sp[a] < sp[b], '%d public MOVE strictly ascends' % i) + cur[r] = b + chains[r].append((a, b)) + elif op == 'INIT': + require(r >= n and r not in alive and len(e) == 3, '%d INIT of a dead owned field' % i) + alive.add(r); rows[r] = {}; cur[r] = e[2]; init_chart[r] = e[2] + peak = max(peak, len(alive)) + elif op == 'CLEAR': + require(r >= n and r in alive and cur[r] == e[2], '%d CLEAR at the current chart' % i) + lifetimes[(r, init_chart.pop(r), e[2])] += 1 + alive.discard(r); rows[r] = {}; cur[r] = None + elif op == 'SCALE': + q = Q(e[2]) + require(q != 0 and cur[r] == e[3] and (r < n or r in alive), '%d SCALE' % i) + rows[r] = {k: v * q for k, v in rows[r].items()} + elif op in ('ADD', 'COPY'): + s, q, f = e[2], Q(e[3]), e[4] + require(type(s) is int and 0 <= s < N and s != r and q != 0, '%d operand' % i) + require(cur[r] == f and cur[s] == f, '%d ADD/COPY operands at chart %d' % (i, f)) + require(all(x < n or x in alive for x in (r, s)), '%d owned field live' % i) + if op == 'COPY': + require(not rows[r], '%d COPY into a zero field' % i) + R = rows[r] + for k, v in rows[s].items(): + nv = R.get(k, 0) + q * v + if nv: + R[k] = nv + else: + R.pop(k, None) + else: + raise AssertionError('%d unknown op %r' % (i, op)) + if stop is None: + require(not alive, 'every owned field cleared') + require(cur[:n] == list(W['final']), 'public fields end at final charts') + return dict(rows=rows, cur=cur, chains=chains, owned_moves=owned_moves, lifetimes=lifetimes, peak=peak) + + +def compare(B, RB, W): + R = replay(W) + bad = [r for r in range(len(R['rows'])) if R['rows'][r] != RB['rows'][r]] + require(not bad, 'all rows equal #7334 (first differing %s)' % bad[:3]) + require(R['cur'] == RB['cur'], 'all end charts equal #7334') + require(R['owned_moves'] == RB['owned_moves'] and R['lifetimes'] == RB['lifetimes'] and R['peak'] == RB['peak'], + 'owned MOVEs, lifetimes and peak unchanged') + changed = sorted(r for r in set(R['chains']) | set(RB['chains']) if R['chains'][r] != RB['chains'][r]) + require(changed == [761], 'only helper 761 changes its MOVE chain (got %s)' % changed[:5]) + return R + + +def main(): + raw = BASE.read_bytes() + require(hashlib.sha256(raw).hexdigest() == BASE_SHA256, 'vendored #7334 word bytes') + B = json.loads(gzip.decompress(raw)) + P0 = B['program'] + dim = [len(f) for f in B['frames']] + require(dim[ZERO] == 0 and dim[V] == 9, 'frame 3 is {0}, frame 127 is V') + W = dict(B); W['program'] = apply_edit(P0, EDIT) + print('PASS #7334 word authenticated (%d events); 761 merge: %d deletions, %d insertions, %d appended -> %d events' + % (len(P0), len(EDIT['delete']), sum(len(x[1]) for x in EDIT['insert_before']), len(EDIT['append']), + len(W['program']))) + + RB = replay(B) + R = compare(B, RB, W) + f = lambda ch: '->'.join([str(dim[ch[0][0]])] + [str(dim[b]) for a, b in ch]) + old, new = f(RB['chains'][761]), f(R['chains'][761]) + require((old, new) == ('0->5->7->8->9', '0->7->8->9'), 'helper 761 chain') + print('PASS exact replay: legal; all %d rows and end charts equal #7334; owned data unchanged; helper 761 %s became %s' + % (len(R['rows']), old, new)) + paid = lambda P: collections.Counter(abs(dim[e[3]] - dim[e[2]]) for e in P if e[0] == 'MOVE') + d = paid(W['program']); d.subtract(paid(P0)) + d = {k: v for k, v in sorted(d.items()) if v} + require(d == {2: -1, 5: -1, 7: 1}, 'paid MOVE delta per native word') + print('PASS paid MOVE ranks per native word: %s (one rank-5 and one rank-2 rung become one rank-7 MOVE)' % d) + + # ({0}) side: the new ADD reads 761 at {0}; nothing writes 761 between it and the deleted ADD at 1053. + i0, i1 = 36442, 36448 + pre = replay(B, stop=i0) + require(pre['cur'][761] == ZERO and pre['cur'][1266] == ZERO, '761 and 1266 sit at {0} at the new ADD') + writes = [i for i in range(i0, i1) if P0[i][0] in ('ADD', 'COPY', 'SCALE') and P0[i][1] == 761] + require(not writes, 'no write to 761 between {0} and chart 1053') + mid = replay(B, stop=i1) + require(pre['rows'][761] == mid['rows'][761], '761 content identical at {0} and at chart 1053') + print('PASS {0} re-basis: 761 and 1266 at {0} at event %d; no event writes 761 before event %d, so 1266 += 1/2*761 ' + 'reads the same content at {0} as at chart 1053 (761 row = %s)' % (i0, i1, mid['rows'][761])) + + # (V) side: the four appended ADDs act at V on V-ending helpers with final rows = unit rows. + corr = {311: Q(1), 591: Q(-1), 760: Q(2), 1439: Q(1)} + for r in corr: + require(B['final'][r] == V and RB['rows'][r] == {r: Q(1)}, 'helper %d ends at V with final row e_%d' % (r, r)) + require(B['final'][1438] == V, '1438 ends at V') + k = len(W['program']) - len(EDIT['append']) + pre_v = replay(W, stop=k)['rows'][1438] + target = dict(RB['rows'][1438]) + for r, c in corr.items(): + target[r] = target.get(r, 0) - c + if not target[r]: + del target[r] + require(pre_v == target, '1438 V-arrival = final - (e311 - e591 + 2 e760 + e1439)') + print('PASS V re-basis: 311, 591, 760, 1439 end at V with unit final rows; 1438 enters the V phase with ' + '#7334 final - (e_311 - e_591 + 2 e_760 + e_1439), inside W_V; the four V ADDs restore it exactly') + + # Controls. + def rejected(label, mutate): + W2 = dict(B); W2['program'] = copy.deepcopy(W['program']) + mutate(W2['program']) + try: + compare(B, RB, W2) + except AssertionError as exc: + print('PASS control rejected: %s (%s)' % (label, exc)) + return + raise AssertionError('control not rejected: ' + label) + idx = lambda P, ev: P.index(ev) + rejected('{0} ADD 1266 += 1/2*761 deleted', lambda P: P.remove(['ADD', 1266, 761, '1/2', 3])) + rejected('{0} ADD with coefficient 1 instead of 1/2', + lambda P: P.__setitem__(idx(P, ['ADD', 1266, 761, '1/2', 3]), ['ADD', 1266, 761, '1', 3])) + rejected('local 1438 += -2*760 at 1053 deleted', lambda P: P.remove(['ADD', 1438, 760, '-2', 1053])) + rejected('V correction 1438 += 1439 deleted', lambda P: P.remove(['ADD', 1438, 1439, '1', 127])) + rejected('V correction 1438 += 2*760 with coefficient 1', + lambda P: P.__setitem__(idx(P, ['ADD', 1438, 760, '2', 127]), ['ADD', 1438, 760, '1', 127])) + rejected('V correction against 1266, which ends at chart 1053, not V', + lambda P: P.insert(len(P) - 1, ['ADD', 1438, 1266, '1', 127])) + rejected('merged MOVE kept but old 1053 ADDs restored without 761 at 1053', + lambda P: P.__setitem__(idx(P, ['ADD', 1266, 761, '1/2', 3]), ['ADD', 1266, 761, '1/2', 1053])) + print('PASS_METHODS_REBASIS') + + +if __name__ == '__main__': + sys.exit(main())