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-banked-hub-reroutes/.gitattributes b/research/p104-banked-hub-reroutes/.gitattributes new file mode 100644 index 0000000000..d2f03c8025 --- /dev/null +++ b/research/p104-banked-hub-reroutes/.gitattributes @@ -0,0 +1 @@ +credits/PR7669-PROVENANCE.md -text !eol whitespace=cr-at-eol diff --git a/research/p104-banked-hub-reroutes/ASSETS.json b/research/p104-banked-hub-reroutes/ASSETS.json new file mode 100644 index 0000000000..9cc4ea99c1 --- /dev/null +++ b/research/p104-banked-hub-reroutes/ASSETS.json @@ -0,0 +1,113 @@ +{ + "schema_version": 1, + "files": [ + { + "path": ".gitattributes", + "sha256": "df132c7b9b59c1039cd707e90c4a4b5228823cd6399be6e890a4b0072448d927" + }, + { + "path": "LICENSE", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "path": "NOTICE", + "sha256": "43510816b93ea09e0d716ccc6261c84ce081821c0d5dea7d6e748863d55f8f40" + }, + { + "path": "PHYSICAL.md", + "sha256": "b2250222061418e0431bd621bcf140b17238f7a9ffdb428c345952c49b7a5aad" + }, + { + "path": "PROOF.md", + "sha256": "db33de68af39e4e90afdd160f4e6708aeda0d15e754617627dc9b75d39426b29" + }, + { + "path": "README.md", + "sha256": "41f5f771295da5bded1f4860b9d9fbfa2150bd4246c3072106bc7efee6d00530" + }, + { + "path": "SOURCES.json", + "sha256": "5ae4cfc96aa890b1b06aa0de688e03d9713b2772fb0f9c6ae7e23ad7d49c479d" + }, + { + "path": "TASK.json", + "sha256": "d8f14e2453b351b5355bdeb848c059523fa053242eff149e74e49a86881c4ee4" + }, + { + "path": "VERIFY.json", + "sha256": "d30d39d36dc1c16d457c0be8b4c7d0848fcc458bacbda19cf7ba88b3e13e1321" + }, + { + "path": "credits/OUTER-GATE-NOTICE", + "sha256": "cadbc642ca84311d2c7a6cf704c7828cb4cf77e3c784b66e4c6e8a5c28002fb8" + }, + { + "path": "credits/PR7663-NOTICE", + "sha256": "5fd4367578d2339fbdcd7dc116b6c12cb4fa72e92d2e3d67be537a36c8bd9d40" + }, + { + "path": "credits/PR7669-PROVENANCE.md", + "sha256": "706c6c852e87e371ddf1828244b2f0c2b00279728818023aa911c8947d69ab83" + }, + { + "path": "credits/PR7674-NOTICE", + "sha256": "382537634a3d9fa0a8089d6121a506a399382f9310088b1f29586dcc93eec92d" + }, + { + "path": "credits/PR7682-NOTICE", + "sha256": "7590f71de481c424d2315e9ea4884bea1557481676fa5f930f7a0bed637a56a1" + }, + { + "path": "credits/PR7697-NOTICE", + "sha256": "5b6226956ac93b15d88b95aaabb40d80f912f97a52ffea2a7068fd3c7074b179" + }, + { + "path": "data/CIRCUIT.json.gz", + "sha256": "7d983a01c8660a7583d6e3530b44a3912ede973c8f679360c33b370de78970cf" + }, + { + "path": "data/MOVES.json", + "sha256": "fde4079ccea9adfaafae9b6d7a8d7fae930a34267c7a76202840b377f3107805" + }, + { + "path": "source/7669-EDIT.json", + "sha256": "05b84f9578fddc7adc7805f20afdfe5ea679d298b2232d7f718193185f471656" + }, + { + "path": "source/CALLER.json.gz", + "sha256": "d889996a337f648087208ab51c98eaf052705d4fca88b5d01b6e9257a829897a" + }, + { + "path": "source/K372-2-WORD.json.gz", + "sha256": "631babeca90e78c5caac713484fe618328b9beee8294baef6ac45ffc9a75dd3b" + }, + { + "path": "tools/bank.py", + "sha256": "e9a6da475fdcfc2cdc3dbe49f34541ab4c321857581eac313adffcde804a8dce" + }, + { + "path": "tools/exval.py", + "sha256": "56f8a4a67a995b4f4114e1a89a3cd5aeb62ae644682f07b6a854b2a057aeddc5" + }, + { + "path": "tools/gauss.py", + "sha256": "f3fe30406700b0746bbbd999079336c97d7b9325f8b1fc8c8ac20377e228ae64" + }, + { + "path": "tools/nest.py", + "sha256": "f819c75f331222bdace538867d0459fb4d9b187ce80ed6b5b7dee120d0511156" + }, + { + "path": "tools/phys.py", + "sha256": "fc15a3610a58adff27183946080ea940949dc8a40c14ab23759e464a5b3447ab" + }, + { + "path": "tools/pricekit.py", + "sha256": "7e08e9129dfc46d7dd351d0ec972d1223b2488503fe49e556df0c6dcad1f3743" + }, + { + "path": "verify.py", + "sha256": "f548d25788d2af0ae88d6d9a36d19de487af8a288de07f4ca66bc40eeec8fdc3" + } + ] +} \ No newline at end of file diff --git a/research/p104-banked-hub-reroutes/LICENSE b/research/p104-banked-hub-reroutes/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/p104-banked-hub-reroutes/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/p104-banked-hub-reroutes/NOTICE b/research/p104-banked-hub-reroutes/NOTICE new file mode 100644 index 0000000000..2a92a9df69 --- /dev/null +++ b/research/p104-banked-hub-reroutes/NOTICE @@ -0,0 +1,7 @@ +Apache License 2.0. Research prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. + +The contribution is the hub-reroute construction: its search, the exact builder, the 21 reroutes and the checks in this package. All code here is newly written, and predecessor packages were read as data only. + +Clear1nsight supplied the chart-595 helper split (PR #7697) and the role-230 rechart (PR #7682), which is the first hub reroute. Ali Romman supplied the banked-transfer circuit and its fifteen pivots (PR #7674). SYLforge supplied the #7669 word and the signed sixteen-call caller. DreamingOfClouds, Rohan Arun, Jerry Chen (CubeJerry), Douglas Colkitt and the authors credited in the inherited notices supplied predecessor constructions, the selected framework and the repository infrastructure. + +The exact predecessor notices are in `credits/`. `source/` holds the K372-2 word, the twelve #7669 edits and the 16-call caller as published with #7669. `ASSETS.json` binds every package file. diff --git a/research/p104-banked-hub-reroutes/PHYSICAL.md b/research/p104-banked-hub-reroutes/PHYSICAL.md new file mode 100644 index 0000000000..b4aca44e4a --- /dev/null +++ b/research/p104-banked-hub-reroutes/PHYSICAL.md @@ -0,0 +1,7 @@ +# Physical accounting + +All coefficients fit in 13 bits. The recursive row-denominator bound is `2,083,725 × 2¹⁸`, the same grid as #7697. The largest absolute row mass is unchanged from #7697. The paid rows (6,142) and the public width (1,502) are unchanged, so the private-home allocation of the parent applies unchanged. + +The number of nonzero local terms rises from 170,652 to 170,719 per native invocation. The term-dependent services rise accordingly. With the #7682 formulas, the reset services go from 1,462,960 to 1,463,496 and the selected transfer legs from 399,452 to 399,586 per native. Scalar services rise by 67 × 32 per native, or 34,304 per raw caller. All these charges are finite constants inside the funded compiler margin. + +The same counting method reproduces the published #7682 figures exactly: 169,349 terms, 1,452,520 reset services and 396,840 selected transfer legs per native. diff --git a/research/p104-banked-hub-reroutes/PROOF.md b/research/p104-banked-hub-reroutes/PROOF.md new file mode 100644 index 0000000000..56c3599f7b --- /dev/null +++ b/research/p104-banked-hub-reroutes/PROOF.md @@ -0,0 +1,44 @@ +# Hub reroutes on a banked circuit + +## The circuit + +Use the banked-transfer reading of #7674 and its successors. Each paid edge `k : A → B` carries a rational linear form. The form is built over the values that are available at chart `A`: independent public inputs whose entrance chart is `A`, and the returned snapshots of earlier paid edges into `A`. Charts act through their canonical Cliffords `T_A`. A paid edge applies `T_B T_A⁻¹` and leaves the normalized signal unchanged. Its job rank is `|dim B − dim A|` for nested charts. A circuit is valid when three conditions hold: + +- every scalar read is cocharted; +- the dependency graph is acyclic; +- every public output equals the required normalized value. + +For the 400 mains this is the #7669 word's output. For each helper it is its own input. + +## One hub reroute + +Take a chart `Q` with incoming paid edges `E_in` from one chart `P`, an outgoing paid edge `e₂ : Q → T`, and a chart `R` that `Q` already feeds. Pick `e₁ ∈ E_in`. The reroute does four things: + +1. **Re-route `e₁` to `P → R`.** It now carries a value `w₁` available at `P`. +2. **Re-value the other `P → Q` edges.** They carry vectors `U` from the span at `P`. `U` is chosen so that every remaining consumer at `Q` can be recomputed from the retained `Q` values and `U`, up to what its receiver already holds. Each receiver `X` adds back its own local donors: the value it receives may differ from the old one by an element of `V_X`, and `X` restores the old value with a local scalar combination. +3. **Re-value the `Q → R` edges.** They carry vectors `G` in `span(retained Q values, U)`. `R` must be able to recover each old `Q → R` value from `(w₁, G, V_R)`, and so must the old value `v₂` of `e₂`. +4. **Re-source `e₂` as `R → T`.** It sends `v₂` exactly, so `T` is unchanged. + +The ranks of `e₁` and `e₂` change from `(a, b)` to `(a', b')`; every other edge keeps its charts. In all 21 reroutes `a + b = a' + b'`, so the rank mass is unchanged and strict concavity of `r ↦ r^{1−κ}` gives the gain. #7682's role-230 change is the case `(P,Q,T,R) = (261, 730, 127, 912)`, with ranks `(3,3) → (4,2)`. + +The required vectors were found by a mod-p screen (p = 33554393) over every `(P, Q)` group, in both the forward circuit and its transpose. The transpose reverses the edges and exchanges inputs with outputs; it is the adjoint view used by #7674. Every new form was then solved in exact rationals, and each reroute was accepted only after the whole circuit passed three tests: a cochart and acyclic schedule, GF(2)-nested positive-rank edges, and exact equality of all 1,502 public outputs. In the forward search, new edges are nested pairs. Non-nested candidates such as `912 ↔ 913` have physical rank 2, not 0, and were rejected. + +## Physical checks + +There are 25 chart pairs that are not MOVEs of the #7669 word. These include the 22 introduced here; the other three already occur in the parent circuits. For each, an exact Gaussian-dyadic state simulation of the canonical-frame circuit of `T_b T_a⁻¹` is run on all 512 basis columns. Every column spreads over exactly `2^r` basis states of equal modulus, with `r = |dim b − dim a|`. Separately, the symplectic rank of every one of the 2,976 transfer pairs equals the dimension difference. The absolute phase of a rank-`r` Clifford job is carried by its monomial adapters, as in the selected framework. + +## Exact arithmetic and storage + +Coefficient size, the common-root grid, private homes and the term-dependent service changes are in [PHYSICAL.md](PHYSICAL.md). + +## Premises + +The result is conditional on the five selected-framework assumptions used by #7674, #7682 and #7697: + +- uniform native realization at all column multiplicities; +- owned allocation and erasure; +- uniform compiler closure; +- fixed-tape precision and movement; +- analytic recovery. + +It also relies on the parent's common-root and banked-storage realization. No new assumption is added. diff --git a/research/p104-banked-hub-reroutes/README.md b/research/p104-banked-hub-reroutes/README.md new file mode 100644 index 0000000000..6a6ffea07f --- /dev/null +++ b/research/p104-banked-hub-reroutes/README.md @@ -0,0 +1,40 @@ +# Hub reroutes on the chart-595 banked circuit + +**Conditional κ ≥ 0.0037291618601.** This is 0.0000025329831 (0.0680%) above the #7697 upper endpoint 0.0037266288770. The parent is the #7697 circuit (Clear1nsight), which builds on #7682 (Clear1nsight), #7674 (aliromman) and the #7669 word (SYLforge). Twenty-one exact **hub reroutes** change the route of 42 paid edges. The edge count, the paid job count, the public boundary, all targets and the rank mass are unchanged. [Construction](PROOF.md) · [Physical accounting](PHYSICAL.md) · [Check](verify.py) + +| Per native invocation | #7697 | This circuit | +| --- | ---: | ---: | +| Paid edges | 6,142 | 6,142 | +| Paid histogram change | | `{1:+8, 2:+6, 3:−26, 4:+5, 5:+6, 6:−1, 7:+2}` | +| Weighted change at exponent one | | 0 | +| Public roles (mains / helpers) | 1,502 (400 / 1,102) | 1,502 (400 / 1,102) | +| Nonzero local terms | 170,652 | 170,719 | +| Coefficient bits / native grid | 13 / 2,083,725 × 2¹⁸ | 13 / 2,083,725 × 2¹⁸ | + +The complete 16-call invoice keeps 101,824 paid jobs, 21,168 targets and rank-mass surplus 1,328. The crossing is certified in (0.00372916186012, 0.00372916186013). It is computed with an error-bounded Decimal bisection, and uniqueness is proved by interval bounds. The result rests on the same five selected-framework assumptions as #7674, #7682 and #7697. + +## Reproduce + +```sh +python3.12 -I -B verify.py +``` + +From the repository root, run `python3.12 -B scripts/research_package.py --package research/p104-banked-hub-reroutes`. The check uses only the standard library and takes about 100–130 s on one core. It first authenticates every file listed in [ASSETS.json](ASSETS.json), then does the following: + +- Rebuilds the #7669 word from K372-2 and its twelve published edits, with both SHA-256 pins checked. +- Loads the circuit and checks locality and an acyclic schedule. +- Checks that every paid edge is GF(2)-nested with positive rank. The symplectic rank of each transfer `T_b T_a⁻¹` must equal the dimension difference. +- Simulates exact Gaussian-dyadic states for the 25 chart pairs that are not MOVEs of the #7669 word. All 512 columns must spread over exactly `2^r` equal-modulus basis states. A non-nested control pair is rejected. +- Proves exact rational outputs: all 400 main outputs equal those of the #7669 word, and every helper, including fresh role 1501, returns its own input. +- Prices the literal 16-call caller. + +`data/CIRCUIT.json.gz` (decompressed SHA-256 `f4954e25…51a2`) holds the full circuit. `data/MOVES.json` lists the 21 reroutes. + +## Open next questions + +- Can two hubs per cut, or hubs outside the charts that Q already feeds, give further rank-mass-preserving gains? Start by extending the screen to pairs of hubs and to all nested charts R, then rebuild each candidate exactly against all 1,502 outputs. +- Do the snapshot-sharing questions of #7674 and #7697 change for the rerouted edges? Begin from the last uses on the rerouted rows. + +## Credit + +The parent constructions are Clear1nsight's chart-595 split (#7697) and role-230 reroute (#7682). The latter is the first hub reroute, and this package generalises it. They build on aliromman's banked-transfer circuit and fifteen pivots (#7674) and on SYLforge's #7669 word and 16-call caller, whose provenance credits DreamingOfClouds, Clear1nsight, Rohan Arun, CubeJerry, Douglas Colkitt and others. The reroute search, exact builder and checks are by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. Predecessor notices are in [credits/](credits/) and [NOTICE](NOTICE). diff --git a/research/p104-banked-hub-reroutes/SOURCES.json b/research/p104-banked-hub-reroutes/SOURCES.json new file mode 100644 index 0000000000..e8c2f265cd --- /dev/null +++ b/research/p104-banked-hub-reroutes/SOURCES.json @@ -0,0 +1,18 @@ +{ + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "path": "certificates/selected-result.json", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1", + "usage": "provenance" + }, + { + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "path": "docs/research/agent-task-catalog.json", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81", + "usage": "provenance" + } + ], + "schema_version": 1 +} diff --git a/research/p104-banked-hub-reroutes/TASK.json b/research/p104-banked-hub-reroutes/TASK.json new file mode 100644 index 0000000000..488dece7ba --- /dev/null +++ b/research/p104-banked-hub-reroutes/TASK.json @@ -0,0 +1,115 @@ +{ + "actual_scope": "Verify twenty-one exact hub reroutes of paid edges on the #7697 chart-595 banked circuit for the signed sixteen-call caller.", + "ai_assistance": "Substantial Claude Opus 5.5 (Anthropic) assistance, via Claude Code, in search, construction, verification and writing. All engines in this package are newly written; predecessor files are read as data only.", + "author": "DreamingOfClouds", + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bottleneck_link": "docs/research/bottleneck-brief.md", + "evidence": "The exact circuit is data/CIRCUIT.json.gz and the reroutes are listed in data/MOVES.json. The registered command rebuilds the pinned #7669 word, checks locality, acyclicity, nesting, symplectic and exact Gaussian column ranks of every new chart pair, exact rational equality of all 1,502 public outputs, and prices the literal 16-call invoice: certified crossing (0.00372916186012, 0.00372916186013), directed lower 0.0037291618601 above the #7697 upper 0.0037266288770.", + "open_questions": [ + { + "blocked_by": "Each candidate needs a separate exact construction of its replacement carriers and receiver corrections, so the screen must stay selective.", + "first_step": "Extend the mod-p screen to pairs of hubs per cut and to all nested charts R, then rebuild every screened candidate exactly against all 1,502 outputs.", + "question": "Do hub reroutes with two hubs, or hubs chosen outside the charts that Q already feeds, admit further rank-mass-preserving concavity gains on this circuit?", + "why_it_matters": "The present search fixes one hub per cut and draws R from the destinations of the edges leaving Q; the exact builder accepts any reroute that passes the complete output check." + } + ], + "original_card": { + "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.", + "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." + ], + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "existing_checks": [ + { + "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.", + "scope": "PR #4133: literal-slot defect", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "88666f1dee93fbd85b31fd5d6f91a219e111b5f4", + "status": "author-checked" + }, + { + "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.", + "scope": "PR #4136: uniform commutation gap", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "281ce601a8be9db470de630759179c23e1dfaa88", + "status": "author-checked" + }, + { + "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.", + "scope": "PR #4140: uniform encoding gap", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "de25c6525aa866962309df5d107b32d55e6e5628", + "status": "author-checked" + }, + { + "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.", + "scope": "PR #4153: source-chart shortcut exhausts its optimistic allowance", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "9123241fea53df77e51ffe30d9aca1625d4bf3a8", + "status": "author-checked" + }, + { + "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.", + "scope": "PR #4154: fiber-tag seam mismatch", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "4ffcdaee5d6255a9cea1fe53a5424435068089d0", + "status": "author-checked" + }, + { + "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.", + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "status": "reviewed" + } + ], + "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.", + "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." + }, + "id": "p104-side-correction", + "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." + ], + "overlap_terms": [ + "P104", + "helper basis", + "helper split", + "5718", + "dyadic capacity" + ], + "question": "Can joint helper bases and a legal causal split improve the complete P104 productive/paid invoice?", + "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." + ], + "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" + ] + }, + "outcome": "completed", + "schema_version": 1, + "scope_change_reason": "The pinned P104 recipient already carries the fifteen banked pivots, the role-230 rechart and the chart-595 helper split. This follow-up keeps every productive output and the paid edge count fixed and reroutes 42 paid edges through 21 exact hub reroutes that preserve rank mass, generalising the #7682 rechart.", + "scope_status": "refined", + "stop_rule": "Require the exact changed circuit, exact rational equality of all public outputs against the pinned #7669 word and helper identities, nested positive-rank charts with exact symplectic and Gaussian column ranks for every new pair, the complete signed 16-call invoice and a certified crossing above the matched #7697 upper.", + "task_id": "p104-side-correction" +} diff --git a/research/p104-banked-hub-reroutes/VERIFY.json b/research/p104-banked-hub-reroutes/VERIFY.json new file mode 100644 index 0000000000..99a917c092 --- /dev/null +++ b/research/p104-banked-hub-reroutes/VERIFY.json @@ -0,0 +1,14 @@ +{ + "commands": [ + { + "argv": ["{python}", "-I", "-B", "{package}/verify.py"], + "checks": "Authenticate all package assets, rebuild the pinned #7669 word, then check locality and an acyclic schedule, GF(2) nesting and symplectic rank of every paid chart pair, exact Gaussian column ranks of the 25 pairs absent from the #7669 word with a non-nested control, exact rational equality of all 1,502 public outputs (400 mains against the word, every helper its own input), and the certified crossing of the complete 16-call invoice above 0.0037291618601.", + "timeout_seconds": 600 + } + ], + "inputs": [], + "python": "3.12", + "requirements": [], + "schema_version": 1, + "status": "ready" +} diff --git a/research/p104-banked-hub-reroutes/credits/OUTER-GATE-NOTICE b/research/p104-banked-hub-reroutes/credits/OUTER-GATE-NOTICE new file mode 100644 index 0000000000..1bc9b4da2b --- /dev/null +++ b/research/p104-banked-hub-reroutes/credits/OUTER-GATE-NOTICE @@ -0,0 +1,13 @@ +# Attribution and source reuse + +New independent operator/invoice verification and fixed-grid interval implementation: OpenAI Codex-assisted research session, 2026-11-10. Apache-2.0. + +DreamingOfClouds supplied the #6936 native predecessor and #6937 shared-wire backup/E-free root. CubeJerry supplied #6912 caller blocks, #6980's QUERY-only caller and #6970/#6985 precision methods. Preserve Ali Romman's #5599 helper-split attribution, icekylinx's #104 odd-grid attribution and unpaidmoon's #6930 width-phase attribution in the parent construction. + +Three unchanged source files are authenticated by exact SHA256 and source commit/path in `INDEPENDENT-SOURCES.json`: + +- #6970 `independent_bounds.py`: fixed integer-grid and positive caller-transfer engine. +- #6985 `envelopes.py`: positive forward envelopes and backward covector witnesses. +- #6985 `source_binding.py`: retained helper functions for the envelope engine. + +The adapter applies only two literal helper-census substitutions in memory and records them. It does not call that adaptation an independent mathematical implementation. The new reverse native operator, formal caller ring and elementary interval engine do not import the source authors' operator or invoice checkers. diff --git a/research/p104-banked-hub-reroutes/credits/PR7663-NOTICE b/research/p104-banked-hub-reroutes/credits/PR7663-NOTICE new file mode 100644 index 0000000000..6ce1bc49a3 --- /dev/null +++ b/research/p104-banked-hub-reroutes/credits/PR7663-NOTICE @@ -0,0 +1,7 @@ +Apache-2.0. Ali Romman with substantial OpenAI Codex assistance. + +The new material is the joint chart assignment, its source-bound operator and caller checks, and the fresh-cost complete-root scalar and private-bank specialization. The parent data are from Clear1nsight's PR #7660 on DreamingOfClouds' PRs #7658 and #7641 and SYLforge's PR #7637. The contributors credited in those sources retain their credit. Original notices are in source/parent-NOTICE, source/physical-NOTICE and source/word-NOTICE. + +Rohan Arun supplied the 17-stage signed caller in PR #7113. The unmodified interval gate and the exact caller data come from its pinned source. See source/caller-NOTICE and source/independent-NOTICE, and the source file inventory for all consumed bytes. The two operator engines and integer power evaluator come from the declared current-main inputs. + +Jerry Chen (CubeJerry) supplied selected PRs #7000 and #7001. The selected application and its phase, common-root, finite-cost and compiler arguments, the odd-native common-grid package, the prior typed six-Gamma reset of PR #7586 and the contributors credited in those records provided the foundations used here. PR #7661 independently derives the fixed caller residuals. PR #7662 supplies a rounded parent-clock alternative. This package uses neither implementation. diff --git a/research/p104-banked-hub-reroutes/credits/PR7669-PROVENANCE.md b/research/p104-banked-hub-reroutes/credits/PR7669-PROVENANCE.md new file mode 100644 index 0000000000..bbee2437f0 --- /dev/null +++ b/research/p104-banked-hub-reroutes/credits/PR7669-PROVENANCE.md @@ -0,0 +1,43 @@ +# Provenance, credit and scope + +This is a cumulative contribution. Thank you to everyone who has made their constructions, exact inputs, failure cases and careful reviews available. Those contributions made this composition possible; the small increment here should not obscure the much larger body of work it rests on. We aim to leave equally inspectable material for the next researcher. + +## Direct lineage and reused methods + +- **SYLforge, #7637:** the H5B frame-restored233-CLEAR construction is the published ancestor of this research. The present K372-2 source retains its descendants rather than starting a new independent construction. [PR7637](https://github.com/CrocSwap/integer-mult-bounds/pull/7637). +- **DreamingOfClouds, #7641 and #7658:** #7641 combines20 edits over #7637. #7658 supplies the large-neighbourhood construction and its exact joint hub reconstruction: helper360/537 SWAP-NULL relabel, main176 bypass, helper236 contact re-chart, helper370 last-stay removal and helper461 first-stay removal. The source explicitly credits its #7630/#7636 relabel lineage and #7634 swap law. Our source descends from this word; those gains are not claimed as new work here. [PR7641](https://github.com/CrocSwap/integer-mult-bounds/pull/7641), [PR7658](https://github.com/CrocSwap/integer-mult-bounds/pull/7658). +- **Clear1nsight:** the contact re-chart type from #7612 and the24-bit coefficient-splitting report are part of the construction's lineage. #7626 contributed source isolation/portable materialization, and #7631/#7633 are credited by the parent lineage. #7660 separately published the role379 shortcut already present in our source; we do not count its rediscovery as another improvement. [PR7612](https://github.com/CrocSwap/integer-mult-bounds/pull/7612), [coefficient report](https://github.com/CrocSwap/integer-mult-bounds/discussions/7111#discussioncomment-19691406), [PR7660](https://github.com/CrocSwap/integer-mult-bounds/pull/7660). +- **ToikY, #7643:** the contact re-chart work is explicitly credited by #7658 alongside Clear1nsight's #7612. Its74-erasure contract and κ are not added to this candidate. No shared CI repair is copied by this PR. [PR7643](https://github.com/CrocSwap/integer-mult-bounds/pull/7643). +- **Rohan Arun, #7113:** the signed caller/accounting lineage underlies the actual16-call composition. Its original source commit is07a76c5e2738882c0cb322278e56f6cae3c9885d. We recount the literal16-call input here; we do not substitute historical17-call constants. [PR7113](https://github.com/CrocSwap/integer-mult-bounds/pull/7113). +- **Ali Romman and upstream contributors:** #7605 supplies an earlier exact protected/application checkpoint cited by the #7637 lineage. The two unmodified directed invoice comparison files are copied from canonical upstream base e54523517d0f03e58352e647c403a5af3e525a57, retaining their attribution and Apache-2.0 headers. Their arithmetic is not a full scientific acceptance gate. [PR7605](https://github.com/CrocSwap/integer-mult-bounds/pull/7605). +- **CubeJerry, Douglas Colkitt and the earlier source contributors:** the retained framework, primitive/service work and repository infrastructure form part of the inherited basis. This package does not claim that their open supplier obligations are resolved by a successful finite replay. + +## What this contribution adds + +The predecessor K372-2 supplies five EARLY edits (1188,1013,940,1141,1195, with940/1141 sharing one ADD). This construction recomputes the1517/770 bypass on that actual source and combined it with a three-field triangle repair. The new contribution is their compatible composition, exact12-block edit, final235 CLEAR witnesses and a small reproducible publication package. Substantial OpenAI Codex assistance was used for research and packaging. New work is Apache-2.0. + +Exact source canonical:3dd1199d95291ee96e6c0aeb6f55f86244a569b1d4975840bf0207e2dcf9c025. Exact candidate canonical:ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d. Byte hashes are in MANIFEST.json. The12 edit blocks specify every changed event and leave all other fields unchanged. The parent research generators are not silently imported; this publication uses the transparent exact edit as its deterministic reconstruction recipe. + +## Related work, not automatically incorporated + +Ali Romman's #7662 studies one half-ADD rounding-error propagation with CubeJerry's service contract. Nick Petalas's #7654 provides a scoped minimal-rank interpolation result used as background when assessing structural repairs. Neither is a substitute for this candidate's entire rounded caller or physical supply proof. Their actual domains and assumptions must be checked before application. [PR7662](https://github.com/CrocSwap/integer-mult-bounds/pull/7662), [PR7654](https://github.com/CrocSwap/integer-mult-bounds/pull/7654). + +At the publication checkpoint, upstream main remained e54523517d0f03e58352e647c403a5af3e525a57. Ali Romman's #7663 uses a separate17-call full-private-bank model and changed helper endpoints; Clear1nsight's #7664 concerns180erasures/17calls; #7666 charges bank selection and return without claiming a new κ. K372-4 is later, separate research with changed helper-boundary conditions. None is silently folded into ee251f60 or used to assert identical physical assumptions. This is not a claim to the greatest bound across all models. + +## Fresh versus reused evidence + +Publication replay freshly reconstructs the whole word, runs exact rows/CLEAR, recounts native/caller histograms and checks the four directed price points. Normal, optimized Python and a Git-free committed-byte export were tested. The recorded ordinary/precision/native-phase/owner evidence retains its narrower scope and original source identifiers; it is not advertised as freshly rerun. No selected record, frozen predecessor package or common verifier is changed. + +## Editorial normalization of publication labels + +The follow-up editorial commit replaces workstation labels with construction terminology. It changes no candidate, edit, certificate, invoice, numeric result, executable code or contributor attribution. The original recorded bytes remain retrievable at commit `95d476623f1468822057554475dc8badb19bfa44`. Evidence JSON field labels and descriptive scopes are normalized, not recomputed scientific results. In NATIVE-EVIDENCE-REUSE.json, `predecessor-receipt:K372-2/NATIVE-NEW.json` is a historical receipt identifier, not a packaged file path. In PRICE-SUMMARY.json, recorded command invoice arguments now use the equivalent packaged `data/INVOICE.json` path; this is a portability transcription, not the verbatim original command. The fresh replay constructs and runs its own package-relative command. MANIFEST.json authenticates the edited publication bytes. + +Evidence byte-custody mapping (original -> editorially normalized SHA-256): + +- `evidence/BUILD.json`: `4744201691120223ded62a3e0d55ea1029203f3ea996305163e7db8d9e3679a4` -> `a0bafbb3f44920ed6ac1ed3d83385f025f5bbbcf5e9c8013ab1ca55ccf23c32d`. + +- `evidence/NATIVE-EVIDENCE-REUSE.json`: `6615b8a051ac9e4d8c73b5decf8a70d2a33d14da0c4c369574dec946984aa351` -> `84bab14d5c584aa8853b8e1025b562541ac6657e458d120ec803f2bc149c3eb8`. + +- `evidence/ROLE770-BUILD.json`: `c4ee72317678791d4b801479df0af052f3a50662c11ce3f3393b2151368fc92d` -> `1c400f16efbc427c40c811a57dc656fe97c2c84f94c71529e2c5c0598b146369`. + +- `evidence/PRICE-SUMMARY.json`: `c2777382c677634f7017b68c55dbd831a40945b77057f26b738f857c17ee8759` -> `d13741fe3217a01edd0b79b40dad037e644e441fbbc300838df99c0b050a5f42`. diff --git a/research/p104-banked-hub-reroutes/credits/PR7674-NOTICE b/research/p104-banked-hub-reroutes/credits/PR7674-NOTICE new file mode 100644 index 0000000000..951f081717 --- /dev/null +++ b/research/p104-banked-hub-reroutes/credits/PR7674-NOTICE @@ -0,0 +1,7 @@ +Apache License 2.0. Research prepared for Ali Romman with substantial OpenAI Codex assistance. + +New work includes the fifteen certified sender/receiver pivots, the forward and transposed communication construction, the complete native row checker, and the finite stock and precision application for this 16-call program. + +SYLforge supplied the composition, native word reconstruction, published invoice and exact 16-stage caller bytes from PR #7669. Their original PROVENANCE.md is preserved in source/7669-CREDITS.md. It credits the H5B work of SYLforge, DreamingOfClouds' joint native reconstructions, Clear1nsight's coefficient splitting, role-379 and helper work, Rohan Arun's signed caller lineage, and prior contributions from CubeJerry, Douglas Colkitt and others. The source/ directory holds the exact file bytes identified in SOURCE-PINS.json. + +The group-ring caller checker, independent operator checks, bit service, finite-cost method and field guide adapt the corresponding code and arguments of Ali Romman's PR #7663. That package in turn builds on the contributors named in its preserved source/7663-NOTICE. The unchanged directed log/exp gate retains its listed sources in source/gate-NOTICE. Earlier paid-transfer and bank-support constructions include PRs #7434 and #7576. Jerry Chen (CubeJerry) supplied the selected PRs #7000 and #7001 and the typed initializer in PR #7586. The per-call odd-grid induction and the selected application review provide the complete-root realization and finite-cost substitution. Douglas Colkitt and the credited repository authors supplied the pinned operator engines, price evaluator and research workflow. The license accompanies this package. diff --git a/research/p104-banked-hub-reroutes/credits/PR7682-NOTICE b/research/p104-banked-hub-reroutes/credits/PR7682-NOTICE new file mode 100644 index 0000000000..4654631de0 --- /dev/null +++ b/research/p104-banked-hub-reroutes/credits/PR7682-NOTICE @@ -0,0 +1,9 @@ +Apache License 2.0. Research prepared for Clear1nsight with substantial OpenAI Codex assistance. + +Ali Romman supplied the fifteen exact banked pivots and the frozen #7674 baseline, along with the complete signed 16-call graph and application method. The original notices remain at peer/NOTICE, peer/source/7663-NOTICE and peer/source/gate-NOTICE. Read peer/SOURCE-PINS.json for each ancestry binding and ASSETS.json for the exact vendored bytes at scientific commit 26b6c469aa6c4aa04322ce25a22150f90e5fb14e and refreshed head 28b2af322a1fab01b3734365988930920f9dda48. + +SYLforge supplied the #7669 composition, native source pins and literal caller. Its preserved parent provenance is peer/source/7669-CREDITS.md. Retain DreamingOfClouds' #7641/#7658 lineage, Clear1nsight's integer scalar/contact work including #7612, ToikY's #7643 contact-rechart precedent, Rohan Arun's #7113 signed-caller lineage, 5080's helper work, and all other contributors named in the original records. Ali Romman's #7663 exact-grid and extent proof and #7666/#7670 selection and guide work supply relevant implementation precedents. Jerry Chen (CubeJerry) supplied the selected #7000/#7001 applications and #7586 typed initialization. Douglas Colkitt and the authors in the original notices supplied the frozen native compiler, independent checker, price evaluator and package infrastructure. + +The release base reuses ToikY's exact shared CI and historical replay sync 0eabc624a9bc9ed2847719efd63390db4d297df4 above canonical e54523517d0f03e58352e647c403a5af3e525a57. This workflow provenance is separate from the banked construction and its mathematical comparison. + +This package credits the original role-230 splice and its same-contract transfer to the unchanged fifteen-pivot graph, the independent exact wire and price replays, matched complete resource accounting and source-bound native and caller verification. The original works retain their authorships and licenses. diff --git a/research/p104-banked-hub-reroutes/credits/PR7697-NOTICE b/research/p104-banked-hub-reroutes/credits/PR7697-NOTICE new file mode 100644 index 0000000000..9405484426 --- /dev/null +++ b/research/p104-banked-hub-reroutes/credits/PR7697-NOTICE @@ -0,0 +1,7 @@ +Apache License 2.0. Research prepared for Clear1nsight with substantial OpenAI Codex and ChatGPT Pro assistance. + +The chart-595 cut, arbitrary-helper encoder and decoder, exact changed graph and matched application are the contribution. Ali Romman supplied the joint helper-basis mechanism and the fifteen banked transfer pivots of PR #7674. Clear1nsight supplied the role-230 rechart and its paired chart graph in PR #7682. SYLforge supplied the signed sixteen-call caller and the preceding exact native source in PR #7669. DreamingOfClouds and Rohan Arun supplied retained native and signed-caller lineage. Jerry Chen (CubeJerry) supplied the selected #7000 and #7001 framework applications. Douglas Colkitt and the credited authors supplied the inherited operator engines, power evaluator, compiler and package infrastructure. + +The exact predecessor notices and inherited source attributions are in `credits/`. `ASSETS.json` binds the borrowed bytes and the reconstructed inputs. Direct reuse is identified against its exact published path when the bytes are present at that head. The physical guide and exact-grid approach also draw on Ali Romman's #7663, #7666, #7670 and #7674. The selected applications and earlier #5599 helper split remain separately credited in the proof. + +The branch carries ToikY's existing workflow bridge at `0eabc624a9bc9ed2847719efd63390db4d297df4` above canonical `e54523517d0f03e58352e647c403a5af3e525a57`. Its five changed blobs are Clear1nsight's #7257 guide and historical source repair and preserve the earlier published credit. The workflow commit is separate from the scientific package. diff --git a/research/p104-banked-hub-reroutes/data/CIRCUIT.json.gz b/research/p104-banked-hub-reroutes/data/CIRCUIT.json.gz new file mode 100644 index 0000000000..876564afe0 Binary files /dev/null and b/research/p104-banked-hub-reroutes/data/CIRCUIT.json.gz differ diff --git a/research/p104-banked-hub-reroutes/data/MOVES.json b/research/p104-banked-hub-reroutes/data/MOVES.json new file mode 100644 index 0000000000..274b2da99e --- /dev/null +++ b/research/p104-banked-hub-reroutes/data/MOVES.json @@ -0,0 +1,317 @@ +[ +{ +"dir": "transpose", +"e1": 96408, +"e2": 96406, +"P": 660, +"Q": 661, +"T": 3, +"R": 9, +"ranks": [ +4, +3, +6, +1 +] +}, +{ +"dir": "forward", +"e1": 93859, +"e2": 96337, +"P": 595, +"Q": 737, +"T": 529, +"R": 520, +"ranks": [ +3, +3, +5, +1 +] +}, +{ +"dir": "transpose", +"e1": 94893, +"e2": 94473, +"P": 127, +"Q": 551, +"T": 3, +"R": 278, +"ranks": [ +6, +3, +7, +2 +] +}, +{ +"dir": "transpose", +"e1": 96887, +"e2": 95272, +"P": 127, +"Q": 545, +"T": 3, +"R": 488, +"ranks": [ +6, +3, +7, +2 +] +}, +{ +"dir": "transpose", +"e1": 97269, +"e2": 96435, +"P": 674, +"Q": 687, +"T": 602, +"R": 684, +"ranks": [ +3, +2, +4, +1 +] +}, +{ +"dir": "transpose", +"e1": 96799, +"e2": 96446, +"P": 631, +"Q": 641, +"T": 602, +"R": 637, +"ranks": [ +3, +2, +4, +1 +] +}, +{ +"dir": "transpose", +"e1": 97225, +"e2": 96856, +"P": 696, +"Q": 688, +"T": 602, +"R": 686, +"ranks": [ +3, +2, +4, +1 +] +}, +{ +"dir": "transpose", +"e1": 97244, +"e2": 96858, +"P": 682, +"Q": 689, +"T": 602, +"R": 685, +"ranks": [ +3, +2, +4, +1 +] +}, +{ +"dir": "transpose", +"e1": 96641, +"e2": 96639, +"P": 649, +"Q": 640, +"T": 602, +"R": 638, +"ranks": [ +3, +2, +4, +1 +] +}, +{ +"dir": "forward", +"e1": 94247, +"e2": 102588, +"P": 507, +"Q": 707, +"T": 127, +"R": 696, +"ranks": [ +4, +3, +5, +2 +] +}, +{ +"dir": "forward", +"e1": 96636, +"e2": 102584, +"P": 478, +"Q": 646, +"T": 127, +"R": 649, +"ranks": [ +4, +3, +5, +2 +] +}, +{ +"dir": "transpose", +"e1": 99330, +"e2": 94868, +"P": 649, +"Q": 562, +"T": 3, +"R": 467, +"ranks": [ +4, +3, +5, +2 +] +}, +{ +"dir": "transpose", +"e1": 96371, +"e2": 96369, +"P": 635, +"Q": 546, +"T": 3, +"R": 506, +"ranks": [ +4, +3, +5, +2 +] +}, +{ +"dir": "transpose", +"e1": 99314, +"e2": 99312, +"P": 660, +"Q": 561, +"T": 3, +"R": 278, +"ranks": [ +4, +3, +5, +2 +] +}, +{ +"dir": "forward", +"e1": 100911, +"e2": 102780, +"P": 117, +"Q": 542, +"T": 127, +"R": 222, +"ranks": [ +2, +2, +3, +1 +] +}, +{ +"dir": "forward", +"e1": 98908, +"e2": 103356, +"P": 363, +"Q": 895, +"T": 127, +"R": 1013, +"ranks": [ +3, +3, +4, +2 +] +}, +{ +"dir": "forward", +"e1": 99901, +"e2": 103355, +"P": 364, +"Q": 896, +"T": 127, +"R": 1014, +"ranks": [ +3, +3, +4, +2 +] +}, +{ +"dir": "forward", +"e1": 96681, +"e2": 102813, +"P": 324, +"Q": 854, +"T": 127, +"R": 982, +"ranks": [ +3, +3, +4, +2 +] +}, +{ +"dir": "transpose", +"e1": 97826, +"e2": 97780, +"P": 1072, +"Q": 748, +"T": 3, +"R": 430, +"ranks": [ +3, +3, +4, +2 +] +}, +{ +"dir": "transpose", +"e1": 94362, +"e2": 94022, +"P": 776, +"Q": 577, +"T": 3, +"R": 442, +"ranks": [ +3, +3, +4, +2 +] +}, +{ +"dir": "transpose", +"e1": 97828, +"e2": 94336, +"P": 1072, +"Q": 755, +"T": 3, +"R": 450, +"ranks": [ +3, +3, +4, +2 +] +} +] \ No newline at end of file diff --git a/research/p104-banked-hub-reroutes/source/7669-EDIT.json b/research/p104-banked-hub-reroutes/source/7669-EDIT.json new file mode 100644 index 0000000000..23368c8750 --- /dev/null +++ b/research/p104-banked-hub-reroutes/source/7669-EDIT.json @@ -0,0 +1,979 @@ +{ + "schema": "source-bound-exact-event-edit/v1", + "source": "3dd1199d95291ee96e6c0aeb6f55f86244a569b1d4975840bf0207e2dcf9c025", + "candidate": "ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d", + "unchanged_headers": true, + "edits": [ + { + "start": 0, + "stop": 0, + "before": [], + "after": [ + [ + "ADD", + 112, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 113, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 114, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 116, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 117, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 118, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 119, + 607, + "1/2", + 3 + ], + [ + "ADD", + 120, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 122, + 607, + "1/2", + 3 + ], + [ + "ADD", + 123, + 607, + "1/2", + 3 + ], + [ + "ADD", + 137, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 138, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 139, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 140, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 141, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 142, + 607, + "-1", + 3 + ], + [ + "ADD", + 169, + 607, + "1/2", + 3 + ], + [ + "ADD", + 170, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 171, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 172, + 607, + "-1", + 3 + ], + [ + "ADD", + 173, + 607, + "1/4", + 3 + ], + [ + "ADD", + 174, + 607, + "1/2", + 3 + ], + [ + "ADD", + 175, + 607, + "1/2", + 3 + ], + [ + "ADD", + 176, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 177, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 178, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 179, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 180, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 181, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 182, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 183, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 184, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 185, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 186, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 187, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 191, + 607, + "1/2", + 3 + ], + [ + "ADD", + 192, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 193, + 607, + "1/2", + 3 + ], + [ + "ADD", + 194, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 195, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 196, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 198, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 199, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 200, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 201, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 202, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 203, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 204, + 607, + "1/2", + 3 + ], + [ + "ADD", + 206, + 607, + "1/2", + 3 + ], + [ + "ADD", + 207, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 208, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 209, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 228, + 607, + "1/4", + 3 + ], + [ + "ADD", + 236, + 607, + "1/4", + 3 + ], + [ + "ADD", + 255, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 272, + 607, + "1/4", + 3 + ], + [ + "ADD", + 279, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 306, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 311, + 607, + "-1", + 3 + ], + [ + "ADD", + 313, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 316, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 336, + 607, + "1/4", + 3 + ], + [ + "ADD", + 347, + 607, + "1/4", + 3 + ], + [ + "ADD", + 351, + 607, + "1/4", + 3 + ], + [ + "ADD", + 436, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 437, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 438, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 439, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 522, + 607, + "1", + 3 + ], + [ + "ADD", + 530, + 607, + "1", + 3 + ], + [ + "ADD", + 536, + 607, + "1/4", + 3 + ], + [ + "ADD", + 599, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 600, + 607, + "1/4", + 3 + ], + [ + "ADD", + 609, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 611, + 607, + "1/4", + 3 + ], + [ + "ADD", + 617, + 607, + "1/4", + 3 + ], + [ + "ADD", + 625, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 627, + 607, + "1/4", + 3 + ], + [ + "ADD", + 635, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 640, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 655, + 607, + "1/4", + 3 + ], + [ + "ADD", + 697, + 607, + "-1/4", + 3 + ], + [ + "ADD", + 752, + 607, + "17/8", + 3 + ], + [ + "ADD", + 812, + 607, + "1/2", + 3 + ], + [ + "ADD", + 1079, + 607, + "1/2", + 3 + ], + [ + "ADD", + 1122, + 607, + "-1", + 3 + ], + [ + "ADD", + 1176, + 607, + "-1/4", + 3 + ], + [ + "ADD", + 1228, + 607, + "1/8", + 3 + ], + [ + "ADD", + 1233, + 607, + "1/8", + 3 + ], + [ + "ADD", + 1234, + 607, + "1/4", + 3 + ], + [ + "ADD", + 1255, + 607, + "1/4", + 3 + ], + [ + "ADD", + 1265, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 1279, + 607, + "1/8", + 3 + ], + [ + "ADD", + 1331, + 607, + "-1/2", + 3 + ] + ] + }, + { + "start": 87321, + "stop": 87321, + "before": [], + "after": [ + [ + "INIT", + 1551, + 115 + ], + [ + "ADD", + 1551, + 770, + "1", + 115 + ] + ] + }, + { + "start": 96905, + "stop": 96905, + "before": [], + "after": [ + [ + "ADD", + 1279, + 1551, + "-1", + 115 + ] + ] + }, + { + "start": 96959, + "stop": 96961, + "before": [ + [ + "MOVE", + 1517, + 549, + 115, + true + ], + [ + "ADD", + 1517, + 1518, + "1/4", + 115 + ] + ], + "after": [ + [ + "MOVE", + 1517, + 549, + 593, + true + ] + ] + }, + { + "start": 96963, + "stop": 96964, + "before": [ + [ + "MOVE", + 1517, + 115, + 593, + true + ] + ], + "after": [] + }, + { + "start": 97747, + "stop": 97749, + "before": [ + [ + "MOVE", + 236, + 265, + 751, + false + ], + [ + "ADD", + 544, + 236, + "-2", + 751 + ] + ], + "after": [ + [ + "ADD", + 236, + 1000, + "1/4", + 265 + ], + [ + "ADD", + 1000, + 236, + "-2", + 265 + ], + [ + "MOVE", + 236, + 265, + 927, + false + ] + ] + }, + { + "start": 97750, + "stop": 97750, + "before": [], + "after": [ + [ + "ADD", + 544, + 1000, + "1/2", + 751 + ] + ] + }, + { + "start": 97751, + "stop": 97752, + "before": [ + [ + "ADD", + 236, + 1000, + "1/4", + 751 + ] + ], + "after": [] + }, + { + "start": 97753, + "stop": 97753, + "before": [], + "after": [ + [ + "ADD", + 544, + 236, + "-1", + 927 + ], + [ + "ADD", + 236, + 544, + "1/2", + 927 + ] + ] + }, + { + "start": 99687, + "stop": 99687, + "before": [], + "after": [ + [ + "ADD", + 614, + 1551, + "1", + 115 + ] + ] + }, + { + "start": 100116, + "stop": 100117, + "before": [ + [ + "MOVE", + 236, + 751, + 127, + false + ] + ], + "after": [ + [ + "MOVE", + 236, + 927, + 127, + false + ] + ] + }, + { + "start": 150409, + "stop": 150409, + "before": [], + "after": [ + [ + "ADD", + 278, + 770, + "1/2", + 127 + ], + [ + "ADD", + 566, + 770, + "1", + 127 + ], + [ + "ADD", + 567, + 770, + "1/2", + 127 + ], + [ + "ADD", + 612, + 770, + "1", + 127 + ], + [ + "ADD", + 613, + 770, + "1", + 127 + ], + [ + "ADD", + 614, + 770, + "1", + 127 + ], + [ + "ADD", + 1078, + 770, + "1/2", + 127 + ], + [ + "ADD", + 1204, + 770, + "-1/4", + 127 + ], + [ + "ADD", + 1259, + 770, + "-1/4", + 127 + ], + [ + "ADD", + 1280, + 770, + "1", + 127 + ], + [ + "ADD", + 1368, + 770, + "1", + 127 + ], + [ + "ADD", + 1374, + 770, + "2", + 127 + ], + [ + "SCALE", + 770, + "-1", + 127 + ], + [ + "CLEAR", + 1551, + 115 + ] + ] + } + ] +} diff --git a/research/p104-banked-hub-reroutes/source/CALLER.json.gz b/research/p104-banked-hub-reroutes/source/CALLER.json.gz new file mode 100644 index 0000000000..26a75a1ae3 Binary files /dev/null and b/research/p104-banked-hub-reroutes/source/CALLER.json.gz differ diff --git a/research/p104-banked-hub-reroutes/source/K372-2-WORD.json.gz b/research/p104-banked-hub-reroutes/source/K372-2-WORD.json.gz new file mode 100644 index 0000000000..1273c83178 Binary files /dev/null and b/research/p104-banked-hub-reroutes/source/K372-2-WORD.json.gz differ diff --git a/research/p104-banked-hub-reroutes/tools/bank.py b/research/p104-banked-hub-reroutes/tools/bank.py new file mode 100644 index 0000000000..eaa47875c2 --- /dev/null +++ b/research/p104-banked-hub-reroutes/tools/bank.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python3 +"""BANK: own fold + pivot + histogram tool for banked-transfer circuits (lane BANK, Nov 18). +Network: tokens >=0 are MOVE event indices (paid slots, value = sent form), tokens <0 are inputs ~r. +forms[node] = {token: Fraction}; node = move index (form sent) or FIRST+r (terminal r). +moves[k] = (src_chart, dst_chart). Paid hist = Counter |dim dst - dim src| over moves (pricekit rule).""" +import gzip, json, sys, os +from collections import Counter, defaultdict +from fractions import Fraction as Q +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import pricekit as pk + +def load(p): + return json.load(gzip.open(p, 'rt') if p.endswith('.gz') else open(p)) + +class Net: + def __init__(s, first, init, final, moves, forms): + s.first, s.init, s.final, s.moves, s.forms = first, init, final, moves, forms + def chart_of_node(s, k): # chart where node's form is evaluated + return s.moves[k][0] if k < s.first else s.final[k - s.first] + def chart_of_tok(s, t): # chart where token's value is available + return s.init[~t] if t < 0 else s.moves[t][1] + def copy(s): + return Net(s.first, s.init, s.final, dict(s.moves), dict(s.forms)) + +def axpy(row, src, a): + for k, v in src.items(): + w = row.get(k, 0) + a * v + if w: row[k] = w + else: row.pop(k, None) + +def fold(W): + n = W['public']; N = n + W['owned_fields'] + rows = [{~r: Q(1)} for r in range(n)] + [None] * W['owned_fields'] + ch = list(W['initial']) + [None] * W['owned_fields'] + moves, forms = {}, {} + for i, e in enumerate(W['program']): + op, r = e[0], e[1] + if op == 'INIT': rows[r], ch[r] = {}, e[2]; continue + if op == 'MOVE': + assert ch[r] == e[2] + moves[i] = (e[2], e[3]); forms[i] = rows[r]; rows[r] = {i: Q(1)}; ch[r] = e[3] + elif op == 'CLEAR': assert ch[r] == e[-1]; rows[r] = ch[r] = None + elif op == 'SCALE': + assert ch[r] == e[-1]; c = Q(e[2]); rows[r] = {k: v * c for k, v in rows[r].items()} + elif op == 'ADD': + assert ch[r] == e[-1] == ch[e[2]] and e[2] != r + rows[r] = dict(rows[r]); axpy(rows[r], rows[e[2]], Q(e[3])) + else: raise ValueError(op) + assert ch[:n] == W['final'] + first = len(W['program']) + for r in range(n): forms[first + r] = rows[r] + return Net(first, list(W['initial']), list(W['final']), moves, forms) + +def transpose(net): + f = net.first + def rv(x): + if x < 0: return f + ~x + if x >= f: return ~(x - f) + return x + forms = {k: {} for k in net.moves}; forms.update({f + r: {} for r in range(len(net.init))}) + for node, row in net.forms.items(): + for d, c in row.items(): forms[rv(d)][rv(node)] = c + return Net(f, net.final, net.init, {k: (b, a) for k, (a, b) in net.moves.items()}, forms) + +def schedule(net): + """locality + acyclicity; returns a topological order of nodes.""" + indeg = {k: 0 for k in net.forms}; out = defaultdict(list) + for k, row in net.forms.items(): + c = net.chart_of_node(k) + for d in row: + assert net.chart_of_tok(d) == c, ('nonlocal', k, d) + if d >= 0: indeg[k] += 1; out[d].append(k) + order = [k for k, v in indeg.items() if v == 0]; i = 0 + while i < len(order): + for m in out[order[i]]: + indeg[m] -= 1 + if indeg[m] == 0: order.append(m) + i += 1 + assert len(order) == len(net.forms), 'cycle' + return order + +def pivot(net, drop, lead, F, gamma, sender, receiver): + """PROOF s1 algebra (own implementation). gamma/sender/receiver: {token: Fraction}.""" + B = net.moves[drop][1] + uses = {m: row[drop] for m, row in net.forms.items() if drop in row} + C = net.moves[lead][1] + assert lead in gamma and set(gamma) <= set(uses) + assert all(m < net.first and net.moves[m] == (B, C) for m in uses), 'readers not all B->C' + Y = {} + for m, g in gamma.items(): axpy(Y, net.forms[m], g) + s = Y.get(drop, 0); assert s + forms = dict(net.forms); del forms[drop]; forms[lead] = dict(sender) + for m, a in uses.items(): + if m != lead: + r = dict(net.forms[m]); axpy(r, Y, -a / s); assert drop not in r; forms[m] = r + YC = {lead: Q(1)}; axpy(YC, receiver, Q(-1)) # Y recovered at C = W - D + rec = {} + for m, a in uses.items(): + r = {k: -v / gamma[lead] for k, v in gamma.items() if k != lead} if m == lead else {m: Q(1)} + axpy(r, YC, a / s); rec[m] = r + for k, row in list(forms.items()): + hit = row.keys() & rec.keys() + if hit: + new = {i: v for i, v in row.items() if i not in hit} + for i in hit: axpy(new, rec[i], row[i]) + forms[k] = new + moves = dict(net.moves); del moves[drop]; moves[lead] = (F, C) + return Net(net.first, net.init, net.final, moves, forms) + +def apply(net, direction, *a): + if direction == 'transpose': return transpose(pivot(transpose(net), *a)) + return pivot(net, *a) + +def hist(net, dim): + return +Counter(r for r in (abs(dim[b] - dim[a]) for a, b in net.moves.values()) if r) + +# ---------------- values mod p (numpy) for endpoint checks and search +P1 = 2147483629 +def inv(x, p): return pow(x, -1, p) +def fmod(q, p): return q.numerator % p * inv(q.denominator % p, p) % p + +def values(net, p=P1, order=None): + import numpy as np + n = len(net.init); order = order or schedule(net); V = {} + for k in order: + v = np.zeros(n, dtype=np.int64) + for d, c in net.forms[k].items(): + cm = fmod(c, p) + if d < 0: v[~d] = (v[~d] + cm) % p + else: v = (v + cm * V[d]) % p + V[k] = v + return V + +def terminals_equal(n1, n2, p=P1): + import numpy as np + V1, V2 = values(n1, p), values(n2, p) + return all(np.array_equal(V1[n1.first + r], V2[n2.first + r]) for r in range(len(n1.init))) + +# ---------------- pricing +CALLER = os.environ.get('BANK_CALLER', os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'source', 'CALLER.json.gz')) +def price(W, paid, digits=16): + base = pk.native_from_word(W) + nat = pk.native_from_hist(dict(paid), dict(base['T']), base['Dports']) + C = pk.load(CALLER); inv_ = pk.invoice(pk.caller_invoice(C), nat) + return pk.price(inv_, digits), inv_ + +def edits_from_pivots(path): + out = [] + for e in load(path): + cv = lambda L: {int(k): Q(v) for k, v in L} + out.append((e['direction'], e['remove'], e['pivot'], e['source_chart'], + cv(e['combination']), cv(e['sender']), cv(e['receiver']))) + return out + +if __name__ == '__main__': # control: reproduce #7674 from t7669 + their 15 pivots (DATA file) + W = load(sys.argv[1]); dim = [len(f) for f in W['frames']] + net0 = fold(W); schedule(net0); h0 = hist(net0, dim) + pr0, _ = price(W, h0); print('parent paid', sum(h0.values()), pk.kstr(pr0['kappa'], 16), 'S', pr0['S']) + net = net0 + for ed in edits_from_pivots(sys.argv[2]): + d, drop, lead, F = ed[:4] + rb = (abs(dim[net.moves[drop][1]] - dim[net.moves[drop][0]]), abs(dim[net.moves[lead][1]] - dim[net.moves[lead][0]])) + net = apply(net, d, drop, lead, F, *ed[4:]); schedule(net) + print(d, drop, lead, 'ranks drop,lead_old', rb, '-> lead_new', abs(dim[net.moves[lead][1]] - dim[net.moves[lead][0]])) + h = hist(net, dim); dh = {r: h[r] - h0[r] for r in set(h) | set(h0) if h[r] != h0[r]} + print('paid', sum(h.values()), 'delta per native', dict(sorted(dh.items()))) + print('terminals equal mod p:', terminals_equal(net0, net), terminals_equal(net0, net, 2147483587)) + pr, inv_ = price(W, h, 20); print('kappa', pk.kstr(pr['kappa'], 18), 'S', pr['S'], pk.cite('t7669+15piv', pr)) + import pickle; pickle.dump(net, open(os.path.join(os.path.dirname(__file__), 'net7674.pkl'), 'wb')) + +def price_net(W, net, dim, digits=20): + """PRICEKIT price with helper targets taken from the circuit's own boundary (width may differ from W).""" + h = W['hosted']; mains = set(W['live']) | {r + 112 for r in W['live']} | set(h.get('X2', [])) | set(h.get('Y2', [])) + from collections import Counter + T = +Counter(dim[net.final[r]] - dim[net.init[r]] for r in range(len(net.init)) if r not in mains) + nat = pk.native_from_hist(dict(hist(net, dim)), dict(T), h.get('Dports', [])) + C = pk.load(CALLER); inv_ = pk.invoice(pk.caller_invoice(C), nat) + return pk.price(inv_, digits), inv_ + +def load_graph(path): + """their p104-banked graph JSON (DATA) -> Net""" + g = json.load(gzip.open(path, 'rt') if path.endswith('.gz') else open(path)) + moves = {k: (a, b) for k, a, b in g['moves']} + forms = {k: {int(t): Q(c) for t, c in row} for k, row in g['forms']} + return Net(g['first_output'], g['initial'], g['final'], moves, forms) diff --git a/research/p104-banked-hub-reroutes/tools/exval.py b/research/p104-banked-hub-reroutes/tools/exval.py new file mode 100644 index 0000000000..036af47258 --- /dev/null +++ b/research/p104-banked-hub-reroutes/tools/exval.py @@ -0,0 +1,17 @@ +import sys,os,time,pickle +sys.path.insert(0,os.path.dirname(os.path.abspath(__file__))) +from bank import * +def exact_values(net, order=None): + order = order or schedule(net); V = {} + for k in order: + v = {} + for d,c in net.forms[k].items(): + if d < 0: axpy(v, {~d: Q(1)}, c) + else: axpy(v, V[d], c) + V[k] = v + return V +if __name__=='__main__': + t=time.time(); W=load(sys.argv[1]); net=fold(W); V=exact_values(net) + print('t',time.time()-t,'avg support',sum(len(v) for v in V.values())/len(V)) + n7674=pickle.load(open('net7674.pkl','rb')); V2=exact_values(n7674) + print('terminals exact equal:', all(V[net.first+r]==V2[net.first+r] for r in range(len(net.init))), time.time()-t) diff --git a/research/p104-banked-hub-reroutes/tools/gauss.py b/research/p104-banked-hub-reroutes/tools/gauss.py new file mode 100644 index 0000000000..66081a9a4e --- /dev/null +++ b/research/p104-banked-hub-reroutes/tools/gauss.py @@ -0,0 +1,61 @@ +"""Own exact Gaussian-dyadic state simulation of chart transfers T_b T_a^-1 (canonical chart Cliffords on 9 axes). +Checks, for every column |x>, that the transfer spreads it over exactly 2^r basis states with equal modulus, r = |dim b - dim a| +(the physical rank of the job), using exact integer Gaussian numerators over a power-of-two denominator.""" +import sys, os +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from phys import gf2_inv, gf2_rank, tr, extend, par, N +def mv(rows, x): return sum(par(r & x) << i for i, r in enumerate(rows)) +def qval(Q, al, x): + return (sum(al[i] for i in range(N) if x >> i & 1) + 2 * sum(par((Q[i] >> (i + 1)) & (x >> (i + 1))) for i in range(N) if x >> i & 1)) % 4 +def mul_i(a, k): + x, y = a + return [(x, y), (-y, x), (-x, -y), (y, -x)][k % 4] +def chart_circuit(U): + r = len(U) + if r == 0: return [] + if r == N: return [('C', 1 << i, 1) for i in range(N)] + G = tr(extend(U), N); gi = gf2_inv(G, N); git = tr(gi, N) + Q = [(1 << i) ^ sum(par(git[i] & gj) << j for j, gj in enumerate(git)) for i in range(N)] + al = [(Q[i] >> i) & 1 for i in range(N)] + K = [('P', G), ('D', Q, al)] + Kd = [('D', Q, [(-a) % 4 for a in al]), ('P', gi)] + return Kd + [('C', 1 << i, 1) for i in range(r)] + K +def adjoint(circ): + out = [] + for e in reversed(circ): + if e[0] == 'P': out.append(('P', gf2_inv(e[1], N))) + elif e[0] == 'D': out.append(('D', e[1], [(-a) % 4 for a in e[2]])) + elif e[0] == 'C': out.append(('C', e[1], -e[2])) + return out +def run(circ, x): + M = 1 << N; v = [(0, 0)] * M; v[x] = (1, 0); den = 0 + for e in circ: + if e[0] == 'P': + w = [(0, 0)] * M + for y, a in enumerate(v): w[mv(e[1], y)] = a + v = w + elif e[0] == 'D': v = [mul_i(a, qval(e[1], e[2], y)) for y, a in enumerate(v)] + elif e[0] == 'C': + q, s = e[1], e[2]; w = [] + for y, (a, b) in enumerate(v): + c, d = v[y ^ q]; w.append((a - s * b + c + s * d, b + s * a + d - s * c)) + v = w; den += 1 + while den and all((a & 1) == 0 and (b & 1) == 0 for a, b in v): v = [(a // 2, b // 2) for a, b in v]; den -= 1 + return v, den +def column_rank(Ua, Ub, cols=range(1 << N)): + circ = adjoint(chart_circuit(Ua)) + chart_circuit(Ub); out = set() + for x in cols: + v, den = run(circ, x) + nz = [a * a + b * b for a, b in v if a or b] + if len(set(nz)) != 1: return None + k = len(nz).bit_length() - 1 + if len(nz) != 1 << k: return None + out.add(k) + return out.pop() if len(out) == 1 else None +if __name__ == '__main__': + import json, gzip + from bank import load + W = load(sys.argv[1]); fr = W['frames'] + pairs = json.loads(sys.argv[2]) + for a, b in pairs: + r = column_rank(fr[a], fr[b]); print(a, b, 'column rank', r, 'dim diff', abs(len(fr[a]) - len(fr[b])), 'OK' if r == abs(len(fr[a]) - len(fr[b])) else 'FAIL', flush=True) diff --git a/research/p104-banked-hub-reroutes/tools/nest.py b/research/p104-banked-hub-reroutes/tools/nest.py new file mode 100644 index 0000000000..67202fc1ab --- /dev/null +++ b/research/p104-banked-hub-reroutes/tools/nest.py @@ -0,0 +1,30 @@ +"""GF(2) chart nesting: rank of transfer a->b = |dim b - dim a| only when spans are nested (else None).""" +def _basis(vs): + B = [] + for v in vs: + for b in B: v = min(v, v ^ b) + if v: B.append(v) + return B +def _in(v, B): + for b in sorted(B, reverse=True): v = min(v, v ^ b) + return v == 0 +_cache = {} +def span(fr, c): + if c not in _cache: + B = [] + for v in fr[c]: + for b in B: + if v ^ b < v: v ^= b + if v: B.append(v); B.sort(reverse=True) + _cache[c] = B + return _cache[c] +def red(v, B): + for b in B: + if v ^ b < v: v ^= b + return v +def nested(fr, a, b): + A, Bb = span(fr, a), span(fr, b) + small, big = (A, Bb) if len(A) <= len(Bb) else (Bb, A) + return all(red(v, big) == 0 for v in small) +def trank(fr, a, b): + return abs(len(fr[b]) - len(fr[a])) if nested(fr, a, b) else None diff --git a/research/p104-banked-hub-reroutes/tools/phys.py b/research/p104-banked-hub-reroutes/tools/phys.py new file mode 100644 index 0000000000..627aa652af --- /dev/null +++ b/research/p104-banked-hub-reroutes/tools/phys.py @@ -0,0 +1,95 @@ +"""Own physical checks for a banked circuit (no upstream code): + (a) symplectic rank of every transfer T_b T_a^-1 (canonical chart Cliffords, GF(2) tableau) equals |dim b - dim a| > 0; + (b) bank-cost stock: local terms, homes, reset/transfer service bounds (#7682 formulas), coefficient bits, row-denominator lcm.""" +import sys, os, gzip, json +from math import lcm +from fractions import Fraction as Q +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from bank import load, Net, schedule +N = 9 +def par(x): return bin(x).count('1') & 1 +def gf2_rank(rows): + piv = {} + for x in rows: + while x: + b = x.bit_length() - 1 + if b not in piv: piv[b] = x; break + x ^= piv[b] + return len(piv) +def gf2_inv(rows, n): + a = [r | (1 << (n + i)) for i, r in enumerate(rows)] + for j in range(n): + k = next(i for i in range(j, n) if a[i] >> j & 1); a[j], a[k] = a[k], a[j] + for i in range(n): + if i != j and a[i] >> j & 1: a[i] ^= a[j] + return [r >> n for r in a] +def tr(rows, n): return [sum(((rows[j] >> i) & 1) << j for j in range(n)) for i in range(n)] +# Clifford as tableau: images of X_0..X_{n-1}, Z_0..Z_{n-1} as (x, z) bitmasks (phases dropped: rank is phase-free) +def img(T, x, z): + u = v = 0 + for i in range(N): + if x >> i & 1: u ^= T[i][0]; v ^= T[i][1] + if z >> i & 1: u ^= T[N + i][0]; v ^= T[N + i][1] + return (u, v) +def then(A, B): return [img(B, *p) for p in A] # first A, then B +def ident(): return [(1 << i, 0) for i in range(N)] + [(0, 1 << i) for i in range(N)] +def inverse(T): + cols = [x | (z << N) for x, z in T]; M = tr(cols, 2 * N); Mi = gf2_inv(M, 2 * N); ci = tr(Mi, 2 * N) + return [(w & ((1 << N) - 1), w >> N) for w in ci] +def perm(G): + cols = tr(G, N); gi = gf2_inv(G, N) + return [(c, 0) for c in cols] + [(0, g) for g in gi] +def diag(Qr): return [(1 << i, Qr[i]) for i in range(N)] + [(0, 1 << i) for i in range(N)] +def fourier(axes): + T = ident() + for i in axes: T[N + i] = (1 << i, 1 << i) + return T +def extend(U): + out = [] + for x in list(U) + [1 << i for i in range(N)]: + if gf2_rank(out + [x]) > len(out): out.append(x) + return out +def chart(U): + r = len(U) + if r == 0: return ident() + if r == N: return fourier(range(N)) + G = tr(extend(U), N); gi = gf2_inv(G, N); git = tr(gi, N) + Qr = [(1 << i) ^ sum(par(git[i] & gj) << j for j, gj in enumerate(git)) for i in range(N)] + K = then(perm(G), diag(Qr)) + return then(then(inverse(K), fourier(range(r))), K) +def trank(U, V): + op = then(inverse(chart(U)), chart(V)) + return gf2_rank([x for x, z in op[N:]]) +if __name__ == '__main__': + W = load(sys.argv[1]); fr = W['frames']; dim = [len(f) for f in fr] + C = json.load(gzip.open(sys.argv[2], 'rt')) + moves = {int(k): tuple(v) for k, v in C['moves'].items()} + forms = {int(k): {int(t): Q(c) for t, c in row.items()} for k, row in C['forms'].items()} + pairs = sorted(set(moves.values())) + bad = [(a, b) for a, b in pairs if trank(fr[a], fr[b]) != abs(dim[a] - dim[b]) or a == b] + # control: a deliberately non-nested pair must not pass + print('distinct transfer pairs', len(pairs), 'symplectic rank == |dim diff| > 0 failures:', len(bad), bad[:5]) + print('control 912->913 (non-nested): rank', trank(fr[912], fr[913]), 'dim diff', abs(dim[912] - dim[913])) + if len(sys.argv) > 3: + old = {tuple(v) for v in json.load(gzip.open(sys.argv[3], 'rt'))['moves'].values()} + print('new pairs vs reference circuit:', sorted(set(pairs) - old)) + n = len(C.get('initial', W['initial'])); k = len(moves); t = sum(len(r) for r in forms.values()) + bits = max(max(abs(c.numerator).bit_length(), c.denominator.bit_length()) for r in forms.values() for c in r.values()) + net = Net(C['first'], C.get('initial', W['initial']), C.get('final', W['final']), moves, forms); order = schedule(net); den = {} + for x in order: + d = 1 + for y, c in forms[x].items(): + d = lcm(d, c.denominator * (den[y] if y >= 0 else 1)) + den[x] = d + L = 1 + for d in den.values(): L = lcm(L, d) + odd = L + while odd % 2 == 0: odd //= 2 + b = 2 * n + 2 * k + 4 + print('terms', t, 'paid rows', k, 'homes/native', b, 'reset R', 2 * b + 8 * (t + k + n) + 4 * n, + 'transfer legs X', 2 * t + 2 * (k + n) + 6 * k + 4 * n, 'coef bits', bits, + 'row-denominator lcm', L, '= odd', odd, 'x 2^%d' % (L // odd).bit_length() if L != odd else '') + mass = {} + for x in order: + mass[x] = sum(abs(c) * (mass[y] if y >= 0 else 1) for y, c in forms[x].items()) + print('max row absolute mass', max(mass.values()), '; x grid 2025', max(mass.values()) * 2025) diff --git a/research/p104-banked-hub-reroutes/tools/pricekit.py b/research/p104-banked-hub-reroutes/tools/pricekit.py new file mode 100644 index 0000000000..260a190a1c --- /dev/null +++ b/research/p104-banked-hub-reroutes/tools/pricekit.py @@ -0,0 +1,489 @@ +#!/usr/bin/env python3 +"""PRICEKIT: the one canonical exact pricer for P104 caller+native invoices. Standard library only. + +Accounting contract (README.md has the one-page version). Units: + rank r job a paid job of rank r (P[r] += 1) or a productive target of rank r (T[r] += 1). + S rank-mass surplus sum_r r (T_r - P_r) (= F(0)). + F(t) the bill sum_r (T_r - P_r) r^(1-t). + kappa the unique root of F on (0, hi]; certified by an interval enclosure (Decimal, error-bounded signs). + D0 sum (T-P) r ln r (= -F'(0); the HOSTCRIB/MAINRETIME/CALLERMAP "D", e.g. #6934 422589.15263423) + Dk sum (T-P) r^(1-kappa) ln r (= -F'(kappa); the DSPLIT/ARCHEQ dk.py/TRADELAW "D(kappa)") + +Charging rules (caller events, '#7113 format' = schema mixed-root-caller/1): + port count every caller event of type A/B is charged once per port of that type (len(types[t]['ports'])). + QUERY P[1] per port (thin unit / sign query). + IDLE_ONE s P[8|s|] per port (one idle over the stage set s). + IDLE_ODD s P[8|s|+1] per port. + LAMBDA ordinary work, 1000 units per port-use (#6913). lambda_mode='paid_rank1' charges P[1] per port + instead (counterfactual only). + ADD/SWAP/SCALE not invoiced (ordinary only). + diagonal row T[(q mod 2) + 8*sum(stage bits)] per port: a field of degree d is a target of rank 8d+1 (odd phase) + or 8d (even phase). Hubs are fields with d = #stages (r137 at 17 stages). + J (one stage) ONE native word per J event: stage = call = J event = one copy of the native word. The native word + serves all 104 ports internally, so it is NOT multiplied by ports. +Native word (schema p104-accumulated-block-composition/2): + paid P[|dim b - dim a|] per MOVE. + helpers T[dim final - dim initial] per public register that is not a main. + mains live X (r), live Y (r+112), hosted X2, Y2. A port with a hosted plane (r in hosted.Dports) has 4 + mains, otherwise 2. Mains are never in T: their climbs are paid (MOVEs) and their credit is the + caller diagonal. Ledger law: native mains per port per stage == caller slots covered per stage + (= mask rank - idle incidences); check_slots() tests it. +Parametric native (native_param): start from a word or a histogram native and + drop_mains_A/B k mains per A/B port per call removed, priced by main_unit: + 'rank1x8' (8 rank-1 jobs, the ARMS/MONOCALLER/SLOT3 unit), 'rank8' (one rank-8 job), or exact via + drop_registers() on a real word (preferred; this is not parametric). + c_A/c_B extra owned rank-1 paid jobs per A/B port per call (may be a Fraction). + dT/dP helper/paid histogram deltas per call. +Every switch is an explicit argument; nothing reads the environment. +""" +import gzip, json, math +from collections import Counter +from decimal import Decimal, localcontext +from fractions import Fraction as Q + +VERSION = 'pricekit/1 (2026-11-11)' +NPORTS = 104 + +# ------------------------------------------------------------------------------------------- io +def load(path): + op = gzip.open if str(path).endswith('.gz') else open + with op(path, 'rt') as f: + return json.load(f) + +def hist(d): + """dict with str/int keys -> Counter{int: int|Fraction}; zero entries dropped.""" + return Counter({int(k): (Q(v) if isinstance(v, str) else v) for k, v in d.items() if v}) + +def _add(dst, src, mult=1): + for r, v in src.items(): + dst[r] += mult * v + return dst + +# ------------------------------------------------------------------------------------------- native +def native_from_word(W, verify=False): + """Exact native invoice of one word (one call). verify=True also replays the word exactly (slow).""" + n = len(W['initial']); live = set(W['live']); H = W.get('hosted') or {} + X2, Y2 = list(H.get('X2', [])), list(H.get('Y2', [])) + main = live | {r + 112 for r in live} | set(X2) | set(Y2) + dim = [len(b) for b in W['frames']] + paid = Counter(); main_paid = Counter(); cls = {} + for r in live: cls[r] = 'X'; cls[r + 112] = 'Y' + for r in X2: cls[r] = 'X2' + for r in Y2: cls[r] = 'Y2' + by_class = {k: Counter() for k in ('X', 'Y', 'X2', 'Y2')} + for e in W['program']: + if e[0] == 'MOVE': + rk = abs(dim[e[3]] - dim[e[2]]); paid[rk] += 1 + if e[1] in cls: by_class[cls[e[1]]][rk] += 1 + helpers = Counter(dim[W['final'][r]] - dim[W['initial'][r]] for r in range(n) if r not in main) + dports = set(H.get('Dports', [])) + mains_per_port = {p: 2 + 2 * (p in dports and bool(X2)) for p in range(NPORTS)} + out = dict(T=+helpers, P=+paid, public=n, events=len(W['program']), mains=len(main), main_moves=by_class, + mains_per_port=mains_per_port, Dports=sorted(dports), source='word') + if verify: + out['replay'] = replay(W)['ok'] + return out + +def native_from_hist(paid, helpers, Dports=None, mains_A=4, mains_B=2): + dp = set(Dports) if Dports is not None else None + mpp = None if dp is None else {p: (mains_A if p in dp else mains_B) for p in range(NPORTS)} + return dict(T=hist(helpers), P=hist(paid), mains_per_port=mpp, Dports=sorted(dp) if dp else None, source='hist') + +def native_param(base, nA, nB, drop_mains_A=0, drop_mains_B=0, main_unit='rank1x8', c_A=0, c_B=0, dT=None, dP=None, + allow_negative=False): + """Parametric native per call. base = native dict. Returns a new native dict (source='param').""" + T = Counter(base['T']); P = Counter(base['P']) + unit = {'rank1x8': {1: 8}, 'rank8': {8: 1}}[main_unit] + for ports, k in ((nA, drop_mains_A), (nB, drop_mains_B)): + for r, v in unit.items(): + P[r] -= ports * k * v + P[1] += nA * Q(c_A) + nB * Q(c_B) + _add(T, dT or {}); _add(P, dP or {}) + mpp = base.get('mains_per_port') + if mpp is not None: + dp = set(base['Dports'] or []) + mpp = {p: m - (drop_mains_A if p in dp else drop_mains_B) for p, m in mpp.items()} + for r in list(P): # a negative native count is legal only if the caller absorbs it (invoice() re-checks) + if P[r] < 0 and not allow_negative: raise ValueError('native_param: negative paid count at rank %d' % r) + return dict(T=T, P=P, mains_per_port=mpp, Dports=base.get('Dports'), source='param', + param=dict(drop_mains_A=drop_mains_A, drop_mains_B=drop_mains_B, main_unit=main_unit, c_A=str(c_A), c_B=str(c_B))) + +# ------------------------------------------------------------------------------------------- exact word replay / pruning +def _span(b): + return frozenset(b) + +def replay(W): + """Exact replay (Fractions, sparse rows). Returns dict(ok, rows, frames, problems).""" + n = W['public']; N = n + W['owned_fields']; frames = W['frames'] + fs = [set(f) for f in frames] + rows = [{r: Q(1)} if r < n else {} for r in range(N)] + cur = list(W['initial']) + [None] * W['owned_fields']; owned = set(); bad = [] + for i, e in enumerate(W['program']): + op, r = e[0], e[1] + if op == 'MOVE': + a, b, priv = e[2:] + if cur[r] != a: bad.append(('move-from', i)); + cur[r] = b + elif op == 'INIT': + owned.add(r); rows[r] = {}; cur[r] = e[2] + elif op == 'CLEAR': + owned.discard(r); rows[r] = {}; cur[r] = None + elif op == 'SCALE': + q = Q(e[2]) + if cur[r] != e[3]: bad.append(('scale-frame', i)) + rows[r] = {k: v * q for k, v in rows[r].items()} + elif op in ('ADD', 'COPY'): + s = e[2]; q = Q(e[3]); f = e[4] + if cur[r] != f or cur[s] != f: bad.append(('add-frame', i)) + if op == 'COPY' and rows[r]: bad.append(('copy-nonzero', 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: + bad.append(('op', i, op)) + if owned: bad.append(('owned-alive', len(owned))) + if cur[:n] != list(W['final']): bad.append(('exit-frames',)) + return dict(ok=not bad, rows=rows, cur=cur, problems=bad[:20], nproblems=len(bad)) + +def drop_registers(W, drop): + """Exact dead-code deletion of the public registers in `drop` (e.g. hosted X2/Y2). + Keeps every event that some kept public output depends on; removes whole owned lifetimes with no live use. + Refuses (ValueError) if a dropped register feeds a kept output. Returns (W2, report).""" + drop = set(drop); n = W['public']; N = n + W['owned_fields']; PR = W['program'] + need_mask = 0 + dem = [0] * N + for r in range(n): + if r not in drop: dem[r] = 1 << r + keep = [False] * len(PR); feeds_dropped = 0 + for i in range(len(PR) - 1, -1, -1): + e = PR[i]; op, t = e[0], e[1] + if op in ('INIT', 'CLEAR'): + dem[t] = 0; continue + if op == 'MOVE': + continue + if dem[t]: + keep[i] = True + if op in ('ADD', 'COPY'): + s = e[2] + if s in drop: feeds_dropped += 1 + dem[s] |= dem[t] + if op == 'COPY': dem[t] = 0 + if feeds_dropped: + raise ValueError('drop_registers: %d kept events read a dropped register' % feeds_dropped) + # lifetime decisions for owned registers + life_keep = {}; open_life = {} + for i, e in enumerate(PR): + op, t = e[0], e[1] + if t >= n: + if op == 'INIT': open_life[t] = i; life_keep[i] = False + elif op in ('ADD', 'COPY', 'SCALE') and keep[i]: life_keep[open_life[t]] = True + if op in ('ADD', 'COPY') and keep[i] and e[2] >= n: life_keep[open_life[e[2]]] = True + life_of = {}; open_life = {} + for i, e in enumerate(PR): + op, t = e[0], e[1] + if t >= n: + if op == 'INIT': open_life[t] = i + life_of[i] = open_life[t] + out = []; dropped_moves = Counter(); dropped_lifetimes = 0; dim = [len(b) for b in W['frames']] + for i, e in enumerate(PR): + op, t = e[0], e[1] + if t in drop: + if op == 'MOVE': dropped_moves[abs(dim[e[3]] - dim[e[2]])] += 1 + continue + if t >= n: + if not life_keep[life_of[i]]: + if op == 'MOVE': dropped_moves[abs(dim[e[3]] - dim[e[2]])] += 1 + if op == 'INIT': dropped_lifetimes += 1 + continue + if op in ('INIT', 'CLEAR', 'MOVE') or keep[i]: out.append(e) + continue + if op == 'MOVE' or keep[i]: out.append(e) + W2 = dict(W); W2['program'] = out + H = dict(W.get('hosted') or {}) + if drop >= set(H.get('X2', [])) | set(H.get('Y2', [])) and H.get('X2'): + H['X2'] = []; H['Y2'] = []; H['dropped_hosted_plane'] = True + W2['hosted'] = H + rep = dict(events_before=len(PR), events_after=len(out), dropped_moves=dict(dropped_moves), + dropped_owned_lifetimes=dropped_lifetimes) + return W2, rep + +def zero_registers(W, drop): + """Hard deletion: registers in `drop` cease to exist (rows = 0). Every event that targets OR reads them is + removed, then dead code is pruned with drop_registers(). Only valid if verify_drop() shows every kept public row + unchanged; otherwise the word genuinely uses the dropped registers and a rebuild is needed.""" + drop = set(drop) + W1 = dict(W); W1['program'] = [e for e in W['program'] if not (e[1] in drop and e[0] != 'MOVE') + and not (e[0] in ('ADD', 'COPY') and e[2] in drop)] + removed_reads = sum(1 for e in W['program'] if e[0] in ('ADD', 'COPY') and e[2] in drop and e[1] not in drop) + W2, rep = drop_registers(W1, drop); rep['removed_reads'] = removed_reads + return W2, rep + +def verify_drop(W, W2, drop): + """Replay both words exactly; every kept public row and exit frame must be unchanged.""" + a = replay(W); b = replay(W2); n = W['public'] + same = all(a['rows'][r] == b['rows'][r] for r in range(n) if r not in set(drop)) + frames = all(b['cur'][r] == W['final'][r] for r in range(n)) + return dict(original_ok=a['ok'], pruned_ok=b['ok'], pruned_problems=b['problems'], kept_rows_equal=same, exit_frames=frames) + +# ------------------------------------------------------------------------------------------- caller +def caller_ports(C): + return {t: len(v['ports']) for t, v in C['types'].items()} + +def caller_invoice(C, lambda_mode='ordinary', only=None): + """Caller part of the invoice (no native). only='A'/'B' restricts to one port type. + Returns dict(T, P, nJ, ports, lambda_uses, ops).""" + assert lambda_mode in ('ordinary', 'paid_rank1') + ports = caller_ports(C); T = Counter(); P = Counter(); nJ = 0; lam = 0; ops = Counter() + for e in C['events']: + if e[0] == 'J': + nJ += 1; continue + ty, op = e[0], e[1] + if only and ty != only: continue + k = ports[ty]; ops[(ty, op)] += 1 + if op == 'QUERY': P[1] += k + elif op == 'IDLE_ONE': P[8 * len(e[3])] += k + elif op == 'IDLE_ODD': P[8 * len(e[3]) + 1] += k + elif op == 'LAMBDA': + lam += k + if lambda_mode == 'paid_rank1': P[1] += k + elif op in ('ADD', 'SWAP', 'SCALE', 'HOST'): pass + else: raise ValueError('caller op not in the alphabet: %r' % (op,)) + for ty, t in C['types'].items(): + if only and ty != only: continue + for dg in t['diagonal']: + T[int(dg[0]) % 2 + 8 * sum(dg[2:])] += ports[ty] + T[0] = 0; T = +T + return dict(T=T, P=+P, nJ=nJ, ports=ports, lambda_uses=lam, ops=ops) + +def check_slots(C, native=None): + """Per type and stage: mask rank, idle incidences, covered = mask - idles. With a native, compare covered with + the native's mains per port (the ledger law d = m).""" + nst = C['stages']; res = {} + for ty, t in C['types'].items(): + mask = [0] * (nst + 1); idle = [0] * (nst + 1) + for dg in t['diagonal']: + for k, b in enumerate(dg[2:], 1): + if b: mask[k] += 1 + for e in C['events']: + if e[0] == ty and e[1] in ('IDLE_ONE', 'IDLE_ODD'): + for k in e[3]: idle[k] += 1 + cov = [mask[k] - idle[k] for k in range(1, nst + 1)] + res[ty] = dict(mask=mask[1:], idle=idle[1:], covered=cov, header=sum(mask), idle_incidences=sum(idle)) + if native is not None and native.get('mains_per_port'): + mpp = native['mains_per_port'] + for ty, t in C['types'].items(): + ms = {mpp[p] for p in t['ports']} + res[ty]['native_mains'] = sorted(ms) + res[ty]['law_d_eq_m'] = (len(ms) == 1 and all(c == next(iter(ms)) for c in res[ty]['covered'])) + return res + +def caller_from_roots(fields, hosts_per_stage_cap, thin, ports, nst): + """Parametric caller (rule of our #6934 package, check.py outer()). fields = list of (mask stages, host stages); + a field of degree d is a target 8d+1; its unhosted mask stages are idled in maximal consecutive runs (P[8*run]); + a stage hosting more than hosts_per_stage_cap[k] fields pays one rank-8 idle per excess; thin rank-1 queries.""" + T = Counter(); P = Counter(); hc = Counter() + for ms, host in fields: + T[8 * len(ms) + 1] += ports + hs = set(host) + for k in hs: hc[k] += 1 + run = 0; prev = None + for k in sorted(ms): + if k in hs: + if run: P[8 * run] += ports + run = 0; prev = None; continue + if prev is not None and k == prev + 1: run += 1 + else: + if run: P[8 * run] += ports + run = 1 + prev = k + if run: P[8 * run] += ports + for k in range(nst): + if hc[k] > hosts_per_stage_cap[k]: P[8] += ports * (hc[k] - hosts_per_stage_cap[k]) + P[1] += ports * thin + return dict(T=+T, P=+P) + +# ------------------------------------------------------------------------------------------- invoice and price +def invoice(caller, native, calls=None): + """caller: dict from caller_invoice/caller_from_roots; native: native dict. calls defaults to caller nJ.""" + L = caller.get('nJ') if calls is None else calls + if not L: raise ValueError('invoice: number of native calls unknown (no J events and calls=None)') + T = Counter(caller['T']); P = Counter(caller['P']) + _add(T, native['T'], L); _add(P, native['P'], L) + for C_ in (T, P): + for r in list(C_): + if C_[r] == 0: del C_[r] + elif C_[r] < 0: raise ValueError('invoice: negative count at rank %d' % r) + return dict(T=T, P=P, calls=L) + +def S_of(T, P): + return sum(r * (T.get(r, 0) - P.get(r, 0)) for r in set(T) | set(P)) + +def _dec(x): + x = Q(x); return Decimal(x.numerator) / Decimal(x.denominator) + +def _coef(T, P): + return sorted((r, Q(T.get(r, 0)) - Q(P.get(r, 0))) for r in set(T) | set(P) if Q(T.get(r, 0)) != Q(P.get(r, 0))) + +def _F(cs, t, prec): + """F(t) and a rigorous bound on its evaluation error at this precision.""" + with localcontext() as c: + c.prec = prec; t = Decimal(t) + val = Decimal(0); mag = Decimal(0) + for r, k in cs: + p = (Decimal(r).ln() * (1 - t)).exp(); kd = _dec(k) + val += kd * p; mag += abs(kd) * p + err = mag * Decimal(10) ** (-(prec - 6)) + return val, err + +def _sign(cs, t, prec=60): + while prec <= 1200: + v, e = _F(cs, t, prec) + if abs(v) > e: return 1 if v > 0 else -1 + prec *= 2 + raise ArithmeticError('sign of F undetermined at t=%s' % t) + +def _unique(cs, hi, depth=14): + """Certify at most one root of F on [0, hi] by interval bounds (F excluded from 0, or F' < 0 on the piece).""" + with localcontext() as c: + c.prec = 40 + def pw(r, t): return (Decimal(r).ln() * (1 - Decimal(t))).exp() + def piece(a, b): + Fl = sum(_dec(k) * (pw(r, b) if k > 0 else pw(r, a)) for r, k in cs) + Fh = sum(_dec(k) * (pw(r, a) if k > 0 else pw(r, b)) for r, k in cs) + if Fl > 0 or Fh < 0: return 'noroot' + Dl = sum(_dec(k) * Decimal(r).ln() * (pw(r, b) if k > 0 else pw(r, a)) for r, k in cs if r > 1) + return 'mono' if Dl > 0 else 'unknown' + stack = [(Decimal(0), Decimal(hi), 0)]; mono = [] + while stack: + a, b, d = stack.pop(); s = piece(a, b) + if s == 'noroot': continue + if s == 'mono': mono.append((a, b)); continue + if d >= depth: return False + m = (a + b) / 2; stack += [(a, m, d + 1), (m, b, d + 1)] + mono.sort() + return all(mono[i][1] == mono[i + 1][0] for i in range(len(mono) - 1)) # one contiguous decreasing block + +def kappa(T, P, digits=50): + """Certified enclosure of the crossing. Returns dict(lo, hi, S, status). status NO_CROSSING if S <= 0.""" + cs = _coef(T, P); S = S_of(T, P) + if S <= 0: return dict(status='NO_CROSSING', S=S, lo=None, hi=None) + hi = Decimal('0.001') + while _sign(cs, hi) > 0: + hi *= 2 + if hi > 64: return dict(status='NO_SIGN_CHANGE', S=S, lo=None, hi=None) + lo = Decimal(0); uniq = _unique(cs, hi) + width = Decimal(10) ** (-digits - 2) + with localcontext() as c: + c.prec = digits + 30 + while hi - lo > width: + m = (lo + hi) / 2 + if _sign(cs, m, digits + 30) > 0: lo = m + else: hi = m + return dict(status='OK' if uniq else 'OK_UNIQUENESS_UNPROVED', S=S, lo=lo, hi=hi, unique=uniq) + +def Dsum(T, P, t=0, prec=60): + with localcontext() as c: + c.prec = prec; t = Decimal(t) + return sum(_dec(k) * Decimal(r).ln() * (Decimal(r).ln() * (1 - t)).exp() for r, k in _coef(T, P) if r > 1) + +def F_at(T, P, t, prec=60): + return _F(_coef(T, P), t, prec)[0] + +def price(inv, digits=50): + T, P = inv['T'], inv['P']; k = kappa(T, P, digits) + out = dict(S=S_of(T, P), paid_jobs=sum(P.values()), paid_positions=sum(r * v for r, v in P.items()), + targets=sum(T.values()), target_positions=sum(r * v for r, v in T.items()), kappa=k, + D0=Dsum(T, P, 0)) + if k.get('lo') is not None: out['Dk'] = Dsum(T, P, k['lo']) + return out + +def kstr(k, n=30): + if k.get('lo') is None: return k['status'] + return str(k['lo'])[:n + 2] + +def break_even_c(T, P, kappa_ref, ports_calls): + """Linear break-even: extra rank-1 paid per (port x call) at which kappa == kappa_ref. F(kref; c) = F0 - c*ports_calls.""" + return F_at(T, P, kappa_ref) / ports_calls + +# ------------------------------------------------------------------------------------------- ordinary units (#6934 package reading) +def word_ordinary(W): + """Per-call ordinary terms of a native word (allowance, reviewed upper, routes): our #6934 jclib.word_terms.""" + H = W['hosted']; nD = len(H['Dports']); n = len(W['initial']); live = set(W['live']) + main = live | {r + 112 for r in live} | set(H.get('X2', [])) | set(H.get('Y2', [])) + dim = [len(b) for b in W['frames']] + paid = Counter(abs(dim[e[3]] - dim[e[2]]) for e in W['program'] if e[0] == 'MOVE') + hel = Counter(dim[W['final'][r]] - dim[W['initial'][r]] for r in range(n) if r not in main) + life = sum(e[0] == 'INIT' for e in W['program']); allow = upper = 0 + for e in W['program']: + if e[0] in ('INIT', 'CLEAR'): allow += 2 + elif e[0] == 'SCALE': + q = Q(e[2]); a, d = abs(q.numerator), q.denominator + allow += 2 * (abs(a.bit_length() - d.bit_length()) + int(q < 0)); upper += 4 * (a.bit_length() + d.bit_length() + 1) + elif e[0] in ('ADD', 'COPY'): + q = Q(e[3]); a, d = abs(q.numerator), q.denominator + allow += 2 * (3 + a.bit_length() - 1 + bin(a).count('1') + d.bit_length() - 1); upper += 4 * (a.bit_length() + bin(a).count('1') + d.bit_length() + 1) + routes = (sum(paid.values()) + 2 * sum(hel.values()) + 208 + 2 * nD + 4 * 104 + 4 * nD + 4 * life) * 1000 + return dict(allow=allow, upper=upper, routes=routes, n=n, nD=nD) + +def _swaps(sel): + wanted = set(range(len(sel))); return len(list(zip(sorted(set(sel) - wanted), sorted(wanted - set(sel))))) + +def _shim(C, ty): + t = C['types'][ty]; off = t['offset']; ev = [] + for e in C['events']: + if e[0] == 'J': ev.append(['HOST', e[1]]) + elif e[0] == ty: + e = list(e[1:]) + if e[0] in ('ADD', 'SWAP', 'QUERY'): e[1] -= off; e[2] -= off + else: e[1] -= off + ev.append(e) + return dict(events=ev, roles=t['roles'], diagonal=t['diagonal']) + +def _rest(C, ports): + ev = C['events']; roles = C['roles']; mx = mn = mp = 0 + for role, (qp, zero, *sel) in enumerate(C['diagonal']): + axes = ([0] if qp else []) + [a for st, y in enumerate(sel, 1) if y for a in range(9 + 8 * (st - 1), 9 + 8 * st)] + k = _swaps(axes); mx += 2 * k * ports; mn += 2 * bool(qp) * ports; mp += int(qp == -1) * ports + ie = qn = qph = 0 + for e in ev: + if e[0] in ('IDLE_ONE',): + ie += 2 * _swaps([a for st in e[2] for a in range(9 + 8 * (st - 1), 9 + 8 * st)]) * ports + elif e[0] == 'QUERY': + qn += 2 * ports; qph += int(e[3] == -1) * ports + return (32 * roles * ports * len(ev) + sum(e[0] == 'QUERY' for e in ev) * 16 * ports + roles * ports * 26 + + (mx + mn + mp) * 1000 + ie * 1000 + (qn + qph) * 1000) + +def ordinary(C, W, odd_scale=1125): + """Raw ordinary readings of the #6934 package (literal/actual/upper/recharge/per_input). IDLE_ODD is not in that + formula (#7113-era callers): such callers get a flag, not a number for the IDLE_ODD routes.""" + t = word_ordinary(W); ports = caller_ports(C); L = sum(1 for e in C['events'] if e[0] == 'J') + rest = _rest(_shim(C, 'A'), ports['A']) + _rest(_shim(C, 'B'), ports['B']) + lam = sum(ports[e[0]] for e in C['events'] if e[0] != 'J' and e[1] == 'LAMBDA'); debit = 1000 * lam + sc = 4 * (odd_scale.bit_length() + 2) + 4 * (odd_scale.bit_length() + 2) + per_in = L * t['n'] * sc + lit = L * 10 ** 7 + rest; act = L * (t['allow'] + t['routes']) + rest; up = L * (t['upper'] + t['routes']) + rest + return dict(literal=lit, actual=act, upper=up, recharge=up + debit, per_input=up + per_in, per_input_recharge=up + per_in + debit, + lambda_uses=lam, lambda_debit=debit, idle_odd_present=any(e[0] != 'J' and e[1] == 'IDLE_ODD' for e in C['events'])) + +# ------------------------------------------------------------------------------------------- one-call convenience +def run(caller_path, native, lambda_mode='ordinary', digits=50): + C = load(caller_path); ci = caller_invoice(C, lambda_mode) + inv = invoice(ci, native); pr = price(inv, digits) + return dict(caller=ci, invoice=inv, price=pr, slots=check_slots(C, native)) + +def cite(label, pr): + """One-line citation string for RESULT.md files.""" + k = pr['kappa'] + return '[PRICEKIT %s] %s: S=%s kappa=%s D0=%.4f Dk=%s paid=%d' % ( + VERSION, label, pr['S'], kstr(k, 26), float(pr['D0']), ('%.8f' % float(pr['Dk'])) if 'Dk' in pr else '-', pr['paid_jobs']) + +if __name__ == '__main__': + import sys + if len(sys.argv) < 3: + print('usage: pricekit.py CALLER.json WORD.json[.gz] | NATIVE-RESULT.json'); sys.exit(1) + X = load(sys.argv[2]) + nat = native_from_word(X) if 'program' in X else native_from_hist(X['native']['paid'], X['native']['helpers']) + R = run(sys.argv[1], nat) + print(cite(sys.argv[2], R['price'])) diff --git a/research/p104-banked-hub-reroutes/verify.py b/research/p104-banked-hub-reroutes/verify.py new file mode 100644 index 0000000000..936d24b873 --- /dev/null +++ b/research/p104-banked-hub-reroutes/verify.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""Exact check of the hub-rerouted banked circuit (standard library only). + +1. Rebuild the #7669 source word from K372-2 and the twelve published edits; check both SHA-256 pins. +2. Load data/CIRCUIT.json.gz (paid edges with rational source forms, public boundary). +3. Locality (every donor is cocharted with its reader) and an acyclic schedule. +4. Every paid edge joins GF(2)-nested charts with positive rank; the symplectic rank of T_b T_a^-1 equals |dim b - dim a|. +5. For every chart pair that is not a MOVE of the #7669 word, an exact Gaussian state simulation of T_b T_a^-1 spreads + every one of the 512 columns over exactly 2^r basis states of equal modulus, r = |dim b - dim a|. +6. Exact rational outputs: every main output equals the #7669 word's; every helper (including fresh role 1501) + returns its own normalized input. +7. Invoice on the literal 16-call #7669 caller and a certified enclosure of the crossing (PRICEKIT). +usage: python3.12 -I -B verify.py [--skip-columns]""" +import sys, os, gzip, json, hashlib +from fractions import Fraction as Q +HERE = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.join(HERE, 'tools')) +from bank import fold, Net, schedule, price_net, hist, pk +from exval import exact_values +import nest, phys, gauss + +def enc(v): return json.dumps(v, sort_keys=True, separators=(',', ':')).encode() +assets = json.load(open(os.path.join(HERE, 'ASSETS.json'))) +for row in assets['files']: + with open(os.path.join(HERE, row['path']), 'rb') as fh: + if hashlib.sha256(fh.read()).hexdigest() != row['sha256']: raise SystemExit('FAIL: asset hash ' + row['path']) +print('1. %d package assets authenticated' % len(assets['files'])) +def need(c, m): + if not c: raise SystemExit('FAIL: ' + m) + +base = json.load(gzip.open(os.path.join(HERE, 'source', 'K372-2-WORD.json.gz'), 'rt')) +ed = json.load(open(os.path.join(HERE, 'source', '7669-EDIT.json'))) +need(hashlib.sha256(enc(base)).hexdigest() == ed['source'], 'K372-2 source pin') +prog, cur = [], 0 +for e in ed['edits']: + need(base['program'][e['start']:e['stop']] == e['before'], 'edit preimage') + prog += base['program'][cur:e['start']] + e['after']; cur = e['stop'] +W = dict(base, program=prog + base['program'][cur:]) +need(hashlib.sha256(enc(W)).hexdigest() == ed['candidate'] == 'ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d', '#7669 word pin') +print('#7669 word rebuilt: %d events, SHA-256 %s' % (len(W['program']), ed['candidate'][:16])) +fr = W['frames']; dim = [len(f) for f in fr] + +C = json.load(gzip.open(os.path.join(HERE, 'data', 'CIRCUIT.json.gz'), 'rt')) +net = Net(C['first'], C['initial'], C['final'], {int(k): tuple(v) for k, v in C['moves'].items()}, + {int(k): {int(t): Q(c) for t, c in row.items()} for k, row in C['forms'].items()}) +schedule(net); print('3. locality + acyclic schedule: PASS (%d paid edges, %d public roles)' % (len(net.moves), len(net.init))) +pairs = sorted(set(net.moves.values())) +for a, b in pairs: + r = nest.trank(fr, a, b) + need(r is not None and r > 0, 'nested positive pair %s' % ((a, b),)) + need(phys.trank(fr[a], fr[b]) == r, 'symplectic rank %s' % ((a, b),)) +print('4. %d distinct chart pairs nested, positive rank, symplectic rank = |dim diff|: PASS' % len(pairs)) +wordpairs = {(e[2], e[3]) for e in W['program'] if e[0] == 'MOVE'} +newp = [p for p in pairs if p not in wordpairs] +if '--skip-columns' not in sys.argv: + for a, b in newp: + need(gauss.column_rank(fr[a], fr[b]) == abs(dim[a] - dim[b]), 'Gaussian column rank %s' % ((a, b),)) + need(gauss.column_rank(fr[912], fr[913]) != 0, 'control: non-nested 912->913 must not be rank 0') + print('5. %d pairs outside the #7669 word: exact Gaussian column rank = |dim diff| on all 512 columns: PASS (control rejects 912->913)' % len(newp)) +h = W['hosted']; mains = set(W['live']) | {r + 112 for r in W['live']} | set(h['X2']) | set(h['Y2']) +ref = fold(W); EVr = exact_values(ref); EVc = exact_values(net) +need(all(EVc[net.first + r] == EVr[ref.first + r] and net.final[r] == W['final'][r] for r in mains), 'main outputs') +need(all(EVc[net.first + r] == {r: Q(1)} for r in range(len(net.init)) if r not in mains), 'helper identity') +print('6. EXACT: %d main outputs equal the #7669 word; %d helpers return their own input: PASS' % (len(mains), len(net.init) - len(mains))) +pr, inv = price_net(W, net, dim, 30) +k = pr['kappa']; need(k['status'] == 'OK', 'certified unique crossing') +print('7. paid/native %d, paid %d, targets %d, S %d; crossing in (%s, %s)' % ( + sum(hist(net, dim).values()), pr['paid_jobs'], pr['targets'], pr['S'], str(k['lo'])[:20], str(k['hi'])[:20])) +claim = Q('0.0037291618601') +need(Q(str(k['lo'])) > claim, 'claim below certified lower end') +print('PASS: kappa >= 0.0037291618601 on the stated invoice')