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-k7-retimed-binary/K7-STACK-LEDGER.json b/research/p104-k7-retimed-binary/K7-STACK-LEDGER.json new file mode 100644 index 0000000000..2add885cf9 --- /dev/null +++ b/research/p104-k7-retimed-binary/K7-STACK-LEDGER.json @@ -0,0 +1,230 @@ +{ + "description": "Constructive binary graph reduction steps reaching seed_k7 from PR #8027/#8035 baseline", + "baseline_8027": { + "moves": 2803, + "dirty_clears": 3433, + "frames": 636, + "pairs": 2352, + "frame_gates": 44825, + "n_targets": 18906, + "n_paid": 104904, + "linear_paid_sum": 285600 + }, + "final_k7": { + "moves": 2796, + "dirty_clears": 3426, + "frames": 636, + "pairs": 2353, + "frame_gates": 44734, + "n_targets": 18906, + "n_paid": 104652, + "linear_paid_sum": 284592, + "gz_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "raw_sha256": "f4a43e4e36ac734dea10a73dca496bf4a4f4a9804b903ea379483d0513d7abc3" + }, + "steps": [ + { + "k": 2, + "method": "quad_toggle_plus_thirdperm", + "details": { + "toggle": { + "D4": 519, + "q": 307, + "d2_cell": 134, + "d6_H": 398, + "d7s": [ + 551, + 546 + ], + "rk0": 7, + "rk_new": 8, + "rk_v1": 504, + "rk_tot": 519 + } + }, + "seed_name": "seed_k2.json.gz", + "gz_sha256": "10eebd653d0725b8229be327ede06cf546b3018d8d3ff6c6c7ad9a2872638fdf", + "raw_sha256": "f47580954b437dfdcef93e271fbbb19a836682a436cb54deaef4d5c4849a48da", + "moves": 2801, + "adds": 30960, + "dirty_clears": 3431, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44841 + }, + "n_targets": 18906, + "n_paid": 104832, + "linear_paid_sum": 285312, + "linear_target_sum": 286818, + "raw_c0_float": 0.003893181247910902 + }, + { + "k": 3, + "method": "quad_toggle_plus_thirdperm", + "details": { + "toggle": { + "D4": 522, + "q": 323, + "d2_cell": 213, + "d6_H": 471, + "d7s": [ + 628, + 527 + ], + "rk0": 7, + "rk_new": 8, + "rk_v1": 503, + "rk_tot": 519 + } + }, + "seed_name": "seed_k3.json.gz", + "gz_sha256": "5baf5494c8d073c6ff410b108ad909c2d12ed548479a2ec6e021b8f821f90ea6", + "raw_sha256": "69e7e3e66be4baeec96a8d1090f0037f98df7841323f2389f11690cad2c26669", + "moves": 2800, + "adds": 30899, + "dirty_clears": 3430, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44822 + }, + "n_targets": 18906, + "n_paid": 104796, + "linear_paid_sum": 285168, + "linear_target_sum": 286674, + "raw_c0_float": 0.003894716044279911 + }, + { + "k": 4, + "method": "quad_toggle_plus_thirdperm", + "details": { + "toggle": { + "D4": 523, + "q": 322, + "d2_cell": 231, + "d6_H": 453, + "d7s": [ + 631, + 526 + ], + "rk0": 8, + "rk_new": 9, + "rk_v1": 502, + "rk_tot": 519 + } + }, + "seed_name": "seed_k4.json.gz", + "gz_sha256": "8876015ef6c172da589f26e64a818b752feef266244ee49e4232fa8fe7173de8", + "raw_sha256": "f1c159a5d23dc09c9118ffbff957e277a7f3d542c7c3604b4b67783cc34547ac", + "moves": 2799, + "adds": 30961, + "dirty_clears": 3429, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44780 + }, + "n_targets": 18906, + "n_paid": 104760, + "linear_paid_sum": 285024, + "linear_target_sum": 286530, + "raw_c0_float": 0.003896252053038069 + }, + { + "k": 5, + "method": "thirdperm_rcv", + "details": { + "D4": 521 + }, + "seed_name": "seed_k5.json.gz", + "gz_sha256": "8dba3630679cdd232bba66234ea843011b097a2dc0cdbf61e4a608aea4099567", + "raw_sha256": "91a70d9c7aeecf56586f6bb63ec27c036294df6824372d6ccac2a7517e31a067", + "moves": 2798, + "adds": 30834, + "dirty_clears": 3428, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44769 + }, + "n_targets": 18906, + "n_paid": 104724, + "linear_paid_sum": 284880, + "linear_target_sum": 286386, + "raw_c0_float": 0.003897789275624352 + }, + { + "k": 6, + "method": "simul_quad_toggle", + "details": { + "toggle": { + "D4": 520, + "q": 292, + "d2_cell": 172, + "d6_H": 370, + "d7s": [ + 555, + 607 + ], + "rk0": 8, + "rk_new": 9, + "rk_v1": 499, + "rk_tot": 518 + } + }, + "seed_name": "seed_k6.json.gz", + "gz_sha256": "034cded61ad647b259ecb9f44425102960ae762949512a430dae960b9926bca5", + "raw_sha256": "98710327e4ebd9d4172dcbd0188be9091b1de19096e3fd1e5fea5b18a430126a", + "moves": 2797, + "adds": 30765, + "dirty_clears": 3427, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44756 + }, + "n_targets": 18906, + "n_paid": 104688, + "linear_paid_sum": 284736, + "linear_target_sum": 286242, + "raw_c0_float": 0.0038993277134807035 + }, + { + "k": 7, + "method": "simul_quad_toggle_thirdperm", + "details": { + "toggle": { + "D4": 524, + "q": 266, + "d2_cell": 248, + "d6_H": 439, + "d7s": [ + 632, + 629 + ], + "rk0": 8, + "rk_new": 9, + "rk_v1": 498, + "rk_tot": 518 + } + }, + "seed_name": "seed_k7.json.gz", + "gz_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "raw_sha256": "f4a43e4e36ac734dea10a73dca496bf4a4f4a9804b903ea379483d0513d7abc3", + "moves": 2796, + "adds": 30588, + "dirty_clears": 3426, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44734 + }, + "n_targets": 18906, + "n_paid": 104652, + "linear_paid_sum": 284592, + "linear_target_sum": 286098, + "raw_c0_float": 0.0039008673680502896 + } + ] +} diff --git a/research/p104-k7-retimed-binary/LICENSE b/research/p104-k7-retimed-binary/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/p104-k7-retimed-binary/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-k7-retimed-binary/NOTICE.md b/research/p104-k7-retimed-binary/NOTICE.md new file mode 100644 index 0000000000..d1a9e0924d --- /dev/null +++ b/research/p104-k7-retimed-binary/NOTICE.md @@ -0,0 +1,18 @@ +# Predecessor Credits and License Notice + +This package inherits code, mathematical constructions, pinned archives, and verification structure from prior work in `CrocSwap/integer-mult-bounds` under the Apache License, Version 2.0 (`LICENSE`). + +## Pinned Predecessor Contributions + +- **Ali Romman** (`PR #8027`, `PR #8030`, `PR #8040`, `PR #8042`): + - Original 111-port strong binary catalogue and word (`#8027`, `fb9b6a7b0d27da1cf98430893a3016bf811e2aa4`), retimed machine and archive baseline (`#8030`, `6285dd829114705862e8d91facaedc1f31d3cfcb`), and unpowered retimed seven-stage native multiplier architecture (`#8042`, `dfd25d553a843a946ca0b94130a5ff8943e98fdd`, including `transport.py`, `unpowered_price.py`, `retimed_supplier.py`, `raw_binary_stage.py`, `five_exchange.py`, `fiscal_scans.py`, `activation.py`, and verifier suite). +- **Clear1nsight** (`PR #8031`–`#8050`): + - Powered 6-stage retimed margin construction (`#8035`, `ea776471bf8ed143a0625cf2d7532f65d15eb5f9`), seven-stage dyadic endpoint refit at `numerical_H = 36000` (`#8050`, `328b858e24709495843abc751fcbf5df35a89da8`, `κ ≥ 0.003890115286594461`), and `binary` vs `Gaussian` sensitivity characterization. +- **ToikY** (`PR #8026`, `PR #8029`): + - Prior outer-caller and binary optimization groundwork feeding into the `strong-bit` construction family. +- **DreamingOfClouds** (`PR #7852`) & **Jerry Chen / CubeJerry** (`PR #7257`, `PR #7914`, `PR #7981`): + - Physical bank machine, 36-call catalogue interpreter, sparse weighted oracle verification (`#7981`), counted compiler (`1ca6b8111297ac2cc2dcfe5da0027656898f7589`), and CI research-package validator harness (`#7257`, `0618e75a22cec54d1651394ef83d088551b7f026`). + +## Present Contribution (`p104-k7-retimed-binary`) + +- Constructive 6-round (`k=2..7`) binary circuit modification `strong-bit-k7.json.gz` reducing `MOVE` instructions (`2803 -> 2796`), dirty private clears (`3433 -> 3426`), and paid linear rank sum (`285,600 -> 284,592`; `104,904 -> 104,652` paid ports) while preserving exact register semantics and unchanged 2-scale Gaussian receiver coupling (`GAUSSIAN_C = 2092819/2^29`). diff --git a/research/p104-k7-retimed-binary/README.md b/research/p104-k7-retimed-binary/README.md new file mode 100644 index 0000000000..c07c038222 --- /dev/null +++ b/research/p104-k7-retimed-binary/README.md @@ -0,0 +1,65 @@ +# Conditional Retimed κ Improvement via Constructive Binary Graph Reduction (`seed_k7`) + +The selected frontier remains on canonical `main`; independent scientific acceptance is open. + +This package applies a constructive, verified binary-word improvement (`strong-bit-k7.json.gz`) onto the unpowered retimed multiplier architecture of PR `#8042` (`research/retimed-native-multiplier`, commit `dfd25d55`) and compares directly against the latest public endpoint PR `#8050` (`research/p104-retimed-dyadic-endpoint`, commit `328b858e`). Under the exact same inherited five all-size framework obligations and an **unmodified** 2-scale `(1, 8)` Gaussian receiver (`GAUSSIAN_C = 2092819/2^29`), replacing the PR `#8027` binary word lifts conditional `κ` across matched, compact, and extended operating profiles. + +## Summary Comparison (`log2_fixed_setup_and_install_le = 513`) + +| Profile / Prior Work | Model | `BINARY_C` | `GAUSSIAN_C` | Binary Stages (`rank_logs`) | `numerical_H` | Public Exponent `A` | Conditional `κ` | +| --- | --- | --- | --- | --- | --- | --- | --- | +| PR `#8035` (`ea776471`) | Powered 6-stage retimed | powered (`v=228`) | powered | 6 stages | `19,000` | `> 10^15` | `0.0038901152865907` | +| PR `#8042` (`dfd25d55`) | Unpowered 7-stage retimed | `4484997569314581/2^60` | `2092819/2^29` | 7 (`5.70e9`–`9.56e16`) | `19,000` | `101,973,332,976,357,367` | `0.003890115286594445` | +| PR `#8050` (`328b858e`) | Unpowered 7-stage dyadic endpoint | `287039844436133239/2^66` | `2092819/2^29` | 7 (`2.00e12`–`3.36e19`) | `36,000` | `~3.58e19` | `0.003890115286594461` | +| **`present` `conservative-36k`** | Unpowered 2-stage retimed (`k7`) | `4391986206293/2^50` | `2092819/2^29` | **2 (`60,000`, `960,000`)** | `36,000` | `1,056,618` | **`0.003893947`** | +| **`present` `compact-1m`** | Unpowered 2-stage retimed (`k7`) | `4391986206293/2^50` | `2092819/2^29` | **2 (`60,000`, `960,000`)** | `1,000,000` | `2,020,618` | **`0.003898026`** | +| **`present` `extended-10m`** | Unpowered 2-stage retimed (`k7`) | `4391986206293/2^50` | `2092819/2^29` | **2 (`60,000`, `960,000`)** | `10,000,000` | `11,020,639` | **`0.003898163`** | +| **`present` `extended`** | Unpowered 2-stage retimed (`k7`) | `4391986206293/2^50` | `2092819/2^29` | **2 (`60,000`, `960,000`)** | `20,000,000` | `21,020,646` | **`0.003898171`** | + +## What Changed in the Binary Word (`strong-bit-k7.json.gz`) + +- Six documented constructive graph-rewrite rounds (`k=2..7`, recorded in `K7-STACK-LEDGER.json`) eliminate 7 `MOVE` instructions across the 36 `LOCAL` calls (`2803 -> 2796`), reduce dirty private clears (`3433 -> 3426`), add one delta chart pair (`2352 -> 2353`) while reducing total frame gates (`44,825 -> 44,734`), and reduce binary paid ports from `104,904` (linear sum `285,600`) to `104,652` (linear sum `284,592`) over the exact same `18,906` targets (linear sum `286,098`). +- In unpowered moment pricing, the raw binary crossing jumps from `~0.003890115286594` to above `4391986206293 / 2^50 ≈ 0.003900867368050`. Thus binary ceases to be the ceiling: `BINARY_C` requires only a 50-bit dyadic denominator (`2^50` vs `#8050`'s `2^66`) and only 2 tiny binary stages `(60_000, 960_000)`, leaving the unmodified Gaussian complex word (`GAUSSIAN_C = 2092819/2^29 ≈ 0.003898179158568`) minus `39/(256 * numerical_H)` as the active bound. +- Negative control: `check_binary_k7.py` extracts PR `#8027`'s original `strong-bit.json.gz` from `predecessor/predecessor-8030.tar.gz` and confirms it fails unpowered certification at `k7`'s `BINARY_C = 4391986206293/2^50`. + +## Scope, Inherited Premises, and Restraint + +1. **Five Inherited All-Size Framework Obligations** (unchanged from `#8027` / `#8030` / `#8035` / `#8042` / `#8050`): + - `native_all_columns` + - `owned_erasure_and_restoration` + - `compiler_transfer` + - `precision_and_tape_services` + - `analytic_recovery` +2. **Finite Replay vs Production Size / Formal Proof**: The 8 executable modes verify finite register semantics, sparse weighted `mod 3` / `mod 9` transport, retimed moment couplings, clock/budget arithmetic, finite product (`-345550037539`), and profile consistency. They do **not** constitute production-scale payload execution or an independent theorem-prover (Lean 4) certificate for `seed_k7` or for the five inherited obligations. +3. **AI-Assistance Disclosure**: Circuit search tooling, package integration, and verification automation were built with AI assistance and validated directly through clean `TemporaryDirectory` installs and `scripts/research_package.py`. + +## Verification + +Run the official package validator from the repository root (`0618e75a22cec54d1651394ef83d088551b7f026` base): + +```bash +python3.12 -IB scripts/research_package.py --package research/p104-k7-retimed-binary +``` + +Full official validator result: + +- `PASS_PACKAGE_METADATA_AND_PINS (not a mathematical acceptance check)` +- `PASS_REGISTERED_RESEARCH_PACKAGE research/p104-k7-retimed-binary outcome=completed` in **`597.74 s`** total wall time across all 8 declared checks: + +| Mode | Command | Declared Timeout | Observed Timing & Key Output | +| --- | --- | --- | --- | +| `binary` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py binary` | `45 s` | `15.83 s` (`moves=2796`, `dirty=3426`, `paid=104652`, `cells=24`, `control_8027=rejected`) | +| `cost` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py cost` | `35 s` | `7.07 s` (all 7 profiles checked against `RESULT.json`; `24` binary / `54` numerical pairs) | +| `schedule` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py schedule` | `40 s` | `16.15 s` (`nested same-program stream restored both complete 2,048-row schedules`) | +| `install` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py install` | `240 s` | `117.249 s` instrumented install + `fiscal_scans` (`peak resident bytes 663986176`) | +| `physical` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py physical` | `280 s` | `137.93 s` (`binary=18906/104652`, `positive=105216/564144`, `extended_stop` at `H=20,000,000`) | +| `receiver` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py receiver` | `400 s` | `237.38 s` (`physical cells 1112292`, `64800` noncommuting direct checks) | +| `slabs` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py slabs` | `25 s` | `0.39 s` (`125062` charged movements, `Gaussian sibling base 128`) | +| `product` | `python3.12 -IB research/p104-k7-retimed-binary/verify.py product` | `135 s` | `57.0261 s` (`physical_product(EXTENDED)` at `numerical_H=20000000`, `product=-345550037539`) | + +(Single-mode timings for `binary`, `cost`, `schedule`, `physical`, `receiver`, `slabs` were measured directly prior to the final `VERIFY.json` timeout tune; `install` instrumented seconds and `product` seconds are directly from the final `597.74 s` full `scripts/research_package.py` run.) + +## Open next questions + +1. **Gaussian Complex Word Optimization**: Because `seed_k7` raises raw binary capacity to `~0.003900867` while the unmodified PR `#8042` 2-scale `(1, 8)` Gaussian supplier caps at `GAUSSIAN_C = 2092819/2^29 ≈ 0.003898179`, improving or splitting the complex word offers a direct path toward `0.003900+`. +2. **Lean 4 / Independent Audit**: Formalizing the 7 removed binary `MOVE` transitions and independently verifying all five inherited all-size obligations remain open. diff --git a/research/p104-k7-retimed-binary/RESULT.json b/research/p104-k7-retimed-binary/RESULT.json new file mode 100644 index 0000000000..a9cae40710 --- /dev/null +++ b/research/p104-k7-retimed-binary/RESULT.json @@ -0,0 +1,566 @@ +{ + "predecessor_comparison": { + "pr_8035": { + "head": "ea776471bf8ed143a0625cf2d7532f65d15eb5f9", + "model": "powered_6stage_retimed", + "kappa": "0.0038901152865907", + "binary_paid": 104904, + "binary_stages": 6 + }, + "pr_8042": { + "head": "dfd25d553a843a946ca0b94130a5ff8943e98fdd", + "model": "unpowered_7stage_retimed", + "kappa": "0.003890115286594445", + "binary_c": "4484997569314581/1152921504606846976", + "gaussian_c": "2092819/536870912", + "binary_paid": 104904, + "binary_stages": 7, + "numerical_H": 19000 + }, + "pr_8050": { + "head": "328b858e24709495843abc751fcbf5df35a89da8", + "model": "unpowered_7stage_dyadic_endpoint", + "kappa": "0.003890115286594461", + "binary_c": "287039844436133239/73786976294838206464", + "gaussian_c": "2092819/536870912", + "binary_paid": 104904, + "binary_stages": 7, + "numerical_H": 36000 + }, + "present_k7": { + "binary_c": "4391986206293/1125899906842624", + "binary_c_decimal": "0.003900867368050091", + "gaussian_c": "2092819/536870912", + "gaussian_c_decimal": "0.003898179158568382", + "binary_paid": 104652, + "binary_dirty_clears": 3426, + "binary_moves": 2796, + "binary_stages": 2, + "log2_fixed_setup_and_install_le": 513, + "conservative_36k_kappa": "0.003893947", + "compact_1m_kappa": "0.003898026", + "extended_10m_kappa": "0.003898163", + "extended_kappa": "0.003898171" + } + }, + "baseline": { + "compact": { + "binary_H": [ + 260000, + 1600000 + ], + "numerical_H": 610000, + "kappa": "96998200889/25000000000000", + "A": 2471428, + "log2_S_le": 1638400002, + "old_installed_visits_log_gt": 11191922, + "log2_C_le": 30535241478 + }, + "high-rate": { + "binary_H": [ + 25000000, + 160000000, + 1000000000, + 6000000000, + 36000000000, + 224000000000 + ], + "numerical_H": 1600000, + "kappa": "389011519729/100000000000000", + "A": 267186701153, + "log2_S_le": 229376000000003, + "old_installed_visits_log_gt": 1567999985622, + "log2_C_le": 4377559200001478 + }, + "price-match": { + "binary_H": [ + 175000000, + 1120000000, + 7000000000, + 42000000000, + 252000000000, + 1568000000000 + ], + "numerical_H": 1600000, + "kappa": "389011527141/100000000000000", + "A": 1870297303584, + "log2_S_le": 1605632000000003, + "old_installed_visits_log_gt": 10975999985622, + "log2_C_le": 30642913440001478 + }, + "fixed-stock-stop": { + "binary_H": [ + 106811524, + 1708984375, + 27343750000, + 437500000000, + 7000000000000, + 112000000000000 + ], + "numerical_H": 1600000, + "kappa": "9725288215981/2500000000000000", + "A": 119466661575676, + "log2_S_le": 114688000000000003, + "old_installed_visits_log_gt": 783999999983102, + "log2_C_le": 1957341750160010694 + }, + "small-gap": { + "binary_H": [ + 6835937536, + 109375000000, + 1750000000000, + 28000000000000, + 448000000000000, + 7168000000000000 + ], + "numerical_H": 1600000, + "kappa": "38901152865907/10000000000000000", + "A": 7645866239991957, + "log2_S_le": 7340032000000000003, + "old_installed_visits_log_gt": 50175999999982031, + "log2_C_le": 125269872000160591302 + } + }, + "binary": { + "productive": 18906, + "paid": 104652, + "cells": 24, + "directed_margin": "55321779883482082595639/244544123725211460862213013703178693829", + "factor_upper_times_1000000": 1101878 + }, + "positive": { + "productive": 105216, + "paid": 564144, + "cells": 54, + "directed_margin": "1162362417094264714206716158580/712832082881474022086691592938270190237", + "factor_upper_times_1000000": 1111354 + }, + "profiles": { + "selected-price": { + "A_lower_in_this_price": 5936, + "kappa": "363005817/100000000000", + "binary_H": [ + 5610 + ], + "numerical_H": 1024, + "width_logs": [ + 516120, + 94208 + ], + "stage_rates": [ + "72601163401/20000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000", + "ordinary_margin": "1/100000000000000", + "positive_margin": "78215771035407/655360000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -6909, + "last_extent_bits_minus_b": -6908, + "minimum_width": 3541248, + "log2_axis_count": 6888, + "largest_axis_width": 5592406, + "private_clock_log2_upper": 5733779202, + "actual_dense_root_entry_log2": 11184812 + }, + "binary_cuts": [ + 5697 + ], + "public_exponent_A": 6913, + "first_public_offset": 4, + "initial_s": 6914, + "stage_and_outer_fixed_log_overhead": 1960, + "retimed_first_stripe_margin": 1443, + "retimed_all_size_margin_floor": 1385, + "absolute_log2_private_control_envelope": 5744642, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 91914289, + "log2_C_le": 92141171 + }, + "small": { + "A_lower_in_this_price": 16889, + "kappa": "19/5000", + "binary_H": [ + 18400 + ], + "numerical_H": 1600, + "width_logs": [ + 1692800, + 147200 + ], + "stage_rates": [ + "76000000001/20000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000", + "ordinary_margin": "1/100000000000000", + "positive_margin": "1942693326607/655360000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -20341, + "last_extent_bits_minus_b": -20340, + "minimum_width": 10418432, + "log2_axis_count": 20319, + "largest_axis_width": 11184811, + "private_clock_log2_upper": 11474169722, + "actual_dense_root_entry_log2": 22369622 + }, + "binary_cuts": [ + 18539 + ], + "public_exponent_A": 20345, + "first_public_offset": 4, + "initial_s": 20346, + "stage_and_outer_fixed_log_overhead": 1960, + "retimed_first_stripe_margin": 8151, + "retimed_all_size_margin_floor": 7892, + "absolute_log2_private_control_envelope": 18841602, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 301465649, + "log2_C_le": 301819251 + }, + "compact": { + "A_lower_in_this_price": 82403, + "kappa": "96998200889/25000000000000", + "binary_H": [ + 9100, + 144000 + ], + "numerical_H": 8500, + "width_logs": [ + 837200, + 13248000, + 782000 + ], + "stage_rates": [ + "1867384696541679599/500000000000000000000", + "387992803561/100000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000", + "ordinary_margin": "1/100000000000000", + "positive_margin": "18289755070459/55705600000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 2, + "first_extent_bits_minus_b": -161988, + "last_extent_bits_minus_b": -161987, + "minimum_width": 82941696, + "log2_axis_count": 161963, + "largest_axis_width": 89478486, + "private_clock_log2_upper": 91792081097, + "actual_dense_root_entry_log2": 178956972 + }, + "binary_cuts": [ + 9201, + 153265 + ], + "public_exponent_A": 161992, + "first_public_offset": 2, + "initial_s": 161993, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 78958, + "retimed_all_size_margin_floor": 76498, + "absolute_log2_private_control_envelope": 147456002, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 2508390457, + "log2_C_le": 2510262059 + }, + "conservative-36k": { + "A_lower_in_this_price": 261055, + "kappa": "3893947/1000000000", + "binary_H": [ + 60000, + 960000 + ], + "numerical_H": 36000, + "width_logs": [ + 5520000, + 88320000, + 3312000 + ], + "stage_rates": [ + "3862438898577864693/1000000000000000000000", + "77878940001/20000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000", + "ordinary_margin": "1/100000000000000", + "positive_margin": "762219821/1966080000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 2, + "first_extent_bits_minus_b": -1056614, + "last_extent_bits_minus_b": -1056613, + "minimum_width": 540990208, + "log2_axis_count": 1056586, + "largest_axis_width": 715827883, + "private_clock_log2_upper": 734090855275, + "actual_dense_root_entry_log2": 1431655766 + }, + "binary_cuts": [ + 60306, + 1020370 + ], + "public_exponent_A": 1056618, + "first_public_offset": 2, + "initial_s": 1056619, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 526259, + "retimed_all_size_margin_floor": 509832, + "absolute_log2_private_control_envelope": 983040002, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 16711680057, + "log2_C_le": 16719601659 + }, + "compact-1m": { + "A_lower_in_this_price": 1542854, + "kappa": "1949013/500000000", + "binary_H": [ + 60000, + 960000 + ], + "numerical_H": 1000000, + "width_logs": [ + 5520000, + 88320000, + 92000000 + ], + "stage_rates": [ + "3862438898577864693/1000000000000000000000", + "77960520000001/20000000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000000", + "ordinary_margin": "1/100000000000000000", + "positive_margin": "66749917779/81920000000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 2, + "first_extent_bits_minus_b": -2020614, + "last_extent_bits_minus_b": -2020613, + "minimum_width": 1034558208, + "log2_axis_count": 2020585, + "largest_axis_width": 1431655766, + "private_clock_log2_upper": 1468086707467, + "actual_dense_root_entry_log2": 2863311532 + }, + "binary_cuts": [ + 60306, + 1020370 + ], + "public_exponent_A": 2020618, + "first_public_offset": 2, + "initial_s": 2020619, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 1008259, + "retimed_all_size_margin_floor": 976770, + "absolute_log2_private_control_envelope": 1024000002, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 16711680057, + "log2_C_le": 16931681659 + }, + "extended-10m": { + "A_lower_in_this_price": 10003994, + "kappa": "3898163/1000000000", + "binary_H": [ + 60000, + 960000 + ], + "numerical_H": 10000000, + "width_logs": [ + 5520000, + 88320000, + 920000000 + ], + "stage_rates": [ + "3862438898577864693/1000000000000000000000", + "779632600000001/200000000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/10000000000000000000", + "ordinary_margin": "1/1000000000000000000", + "positive_margin": "378549607327/409600000000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -11020635, + "last_extent_bits_minus_b": -11020634, + "minimum_width": 5642568960, + "log2_axis_count": 11020604, + "largest_axis_width": 5726623062, + "private_clock_log2_upper": 5875358240096, + "actual_dense_root_entry_log2": 11453246124 + }, + "binary_cuts": [ + 60306, + 1020370 + ], + "public_exponent_A": 11020639, + "first_public_offset": 4, + "initial_s": 11020640, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 5508258, + "retimed_all_size_margin_floor": 5336155, + "absolute_log2_private_control_envelope": 10240000002, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 16711680057, + "log2_C_le": 18911681659 + }, + "extended": { + "A_lower_in_this_price": 19250509, + "kappa": "3898171/1000000000", + "binary_H": [ + 60000, + 960000 + ], + "numerical_H": 20000000, + "width_logs": [ + 5520000, + 88320000, + 1840000000 + ], + "stage_rates": [ + "3862438898577864693/1000000000000000000000", + "779634200000001/200000000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/10000000000000000000", + "ordinary_margin": "1/1000000000000000000", + "positive_margin": "221749607327/409600000000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 2, + "first_extent_bits_minus_b": -21020642, + "last_extent_bits_minus_b": -21020641, + "minimum_width": 10762572544, + "log2_axis_count": 21020610, + "largest_axis_width": 11453246123, + "private_clock_log2_upper": 11749670261735, + "actual_dense_root_entry_log2": 22906492246 + }, + "binary_cuts": [ + 60306, + 1020370 + ], + "public_exponent_A": 21020646, + "first_public_offset": 2, + "initial_s": 21020647, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 10508257, + "retimed_all_size_margin_floor": 10179908, + "absolute_log2_private_control_envelope": 20480000002, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 16711680057, + "log2_C_le": 21111681659 + } + }, + "prefix": { + "small_stop_tail_factor_log2": 1591, + "private_prefix_log2": 126082079, + "controls_prefix_log2": 5081414, + "private_prefix_after_input_log2": 84484466, + "early_log2_C_bound": 84500000, + "tail_log2_fixed_factor_including_b_to_n": 1434, + "tail_unit": "(1 + B + Z) * n * (1 + log2(n))^(1-kappa)" + }, + "first_controller_shape": { + "first_b": 18508, + "first_L": 18496, + "first_P": 606385061, + "first_side_bit_length": 18496, + "host_list": "OverflowError" + }, + "first_numerical_placement": { + "root_tag": [ + "root", + "rotated", + 0, + 4080, + 1 + ], + "per_target_probability": "1/624", + "placements": { + "1024": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + }, + "1600": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + }, + "8500": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + }, + "36000": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + }, + "1000000": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + }, + "10000000": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + }, + "20000000": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + } + } + } +} diff --git a/research/p104-k7-retimed-binary/SOURCES.json b/research/p104-k7-retimed-binary/SOURCES.json new file mode 100644 index 0000000000..9e8205cc9e --- /dev/null +++ b/research/p104-k7-retimed-binary/SOURCES.json @@ -0,0 +1,59 @@ +{ + "schema_version": 1, + "base_commit": "0618e75a22cec54d1651394ef83d088551b7f026", + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "physical_head": "6285dd829114705862e8d91facaedc1f31d3cfcb", + "physical_tree": "3a1c001cbf175ae48ee1d56e56e4723eda1c8218", + "signed_head": "ea776471bf8ed143a0625cf2d7532f65d15eb5f9", + "retimed_native_head": "dfd25d553a843a946ca0b94130a5ff8943e98fdd", + "retimed_endpoint_head": "328b858e24709495843abc751fcbf5df35a89da8", + "physical_catalogue": "fb9b6a7b0d27da1cf98430893a3016bf811e2aa4", + "counted_compiler": "1ca6b8111297ac2cc2dcfe5da0027656898f7589", + "inherited_ci": "0618e75a22cec54d1651394ef83d088551b7f026", + "frozen_inputs": { + "predecessor-8030.tar.gz": "769d5a05cc1373fa22ed5956af636992fcd19d7e5c1753a32033a73c358cd31c", + "SOURCES.json": "3634f7a15b8ca6f1832e48bdd4e83bd764509f804196d956149a9a82e7512a64", + "OVERLAY.json": "73aaf56a8a199cf3b7fc6c87316ca50298f47561e4b7c227edec6230f12a8403", + "strong-bit-k7.json.gz": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "K7-STACK-LEDGER.json": "a0c0d5b241e6861a5c49a287617e48fba56b09824f5ef4fcb7f03152edf37e8e" + }, + "mathematical_dependencies": "Unpowered retimed 2-scale complex receiver (#8042) with five inherited all-size framework premises from #8027/#8030/#8035/#8042, plus constructive k7 binary graph overlay (2796 moves, 104652 paid ports, 3426 dirty clears).", + "files": [ + { + "path": "AGENTS.md", + "git_blob": "ff81117fca368042f6092964d1f54eb4e6e08fb9", + "sha256": "fece32cdec9c1572ddce354a0b623459cb2c4ca162125d36d36262a92e3caa83", + "usage": "provenance" + }, + { + "path": "CONTRIBUTING.md", + "git_blob": "5185786f2ec00f215019fb5777d70979429690a9", + "sha256": "fcd1a8d0e52342a23b8ffa9e905e85ccc539fb084145ef016dfc93cedfb3d924", + "usage": "provenance" + }, + { + "path": "certificates/selected-result.json", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1", + "usage": "provenance" + }, + { + "path": "docs/research/agent-task-catalog.json", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81", + "usage": "provenance" + }, + { + "path": "docs/research/research-package-guide.md", + "git_blob": "24cf53c403ff4e72a1717d082296c3918c42fe92", + "sha256": "5e3aa8b2ce657f943ef5fd187473a01a92a7073ef7e05b30affa08979daa2c6e", + "usage": "provenance" + }, + { + "path": "scripts/research_package.py", + "git_blob": "091b4c8f58bac9a9580d76025b887dc5c873d05f", + "sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70", + "usage": "provenance" + } + ] +} diff --git a/research/p104-k7-retimed-binary/TASK.json b/research/p104-k7-retimed-binary/TASK.json new file mode 100644 index 0000000000..c0874122fe --- /dev/null +++ b/research/p104-k7-retimed-binary/TASK.json @@ -0,0 +1,120 @@ +{ + "schema_version": 1, + "task_id": "scalar-to-moment", + "priority_revision": 8, + "base_commit": "0618e75a22cec54d1651394ef83d088551b7f026", + "original_card": { + "id": "scalar-to-moment", + "question": "Can a scalar/frame rewrite improve the complete signed moment through paid jobs, productive targets, or both?", + "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", + "docs/research/recursive-invoice-preflight.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "Require a legal chronological rewrite and favorable complete signed target-minus-paid moment with all extra charges. Unchanged ADD counts or unchanged paid-call counts alone decide neither success nor failure. Compiler, native and outer admission remain separate obligations.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Construct one legal source-bound rewrite and compare complete before/after P and T. Charge restoration, source windows and owned helpers. A paid call need not disappear: a legal target split or rank redistribution may win. Stop if the signed moment is unchanged or the consumer repays the gain. Do not extend a scalar-only census on ADD counts.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "signed moment", + "target split", + "rank exchange", + "scalar rewrite" + ], + "existing_checks": [ + { + "scope": "PR #3998: consecutive A2 scalar contraction", + "evidence": "research/staged544-a2-graph-rewrite/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "389268a6b5e0373a3125d5c6fcd6995f4ea324f5", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4019: separated A2 sites with unchanged recursive histogram", + "evidence": "research/staged544-separated-a2/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "f408e09df300b575235f7f77f81948071397e16d", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4112: composition audit", + "evidence": "research/staged544-a2-composition-audit/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "205b7380656ba4b6316a8a493b1a3c679b8f7a0e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4152: A1858 contraction audit", + "evidence": "research/staged544-a1858-contraction-audit/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "caaa14cde5962adc372fdca71f63d0f29e73c8b2", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "claim": "Constructive 6-round (k=2..7) rewrite of the 36-call 111-port strong binary word removes 7 MOVE instructions (2803 -> 2796), reduces dirty clears (3433 -> 3426), and lowers paid linear capacity from 104,904 ports (sum 285,600) to 104,652 ports (sum 284,592) while preserving exact register semantics across all 630 registers. Rebased into the unpowered retimed multiplier architecture of PR #8042 / PR #8050, this raises BINARY_C from 287039844436133239/2^66 (0.003890115286594461...) to 4391986206293/2^50 (0.003900867368050091...), eliminates the binary bottleneck, preserves GAUSSIAN_C = 2092819/2^29 unmodified and log2_fixed_setup_and_install_le = 513, shrinks the binary hierarchy from 7 stages to 2 stages (60000, 960000), and lifts conditional kappa to 0.003893947 (H=36000), 0.003898026 (H=1000000), 0.003898163 (H=10000000), and 0.003898171 (H=20000000), conditional on five inherited all-size framework obligations.", + "related": [ + "https://github.com/CrocSwap/integer-mult-bounds/pull/8027", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8030", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8035", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8042", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8050" + ], + "scope_status": "refined", + "actual_scope": "Complete finite-machine constructive verification and retimed unpowered cost accounting for the modified 111-port binary word (seed_k7) paired with the unmodified 2-scale (1,8) retimed complex receiver of PR #8042; full production-payload execution and independent all-size proof of the five inherited framework obligations remain open.", + "scope_change_reason": "Because PR #8042 and PR #8050 freeze the underlying 2-scale Gaussian supplier (GAUSSIAN_C = 2092819/2^29), improving only the binary word moves the overall unpowered bottleneck cleanly from binary to Gaussian while reducing binary depth to 2 stages and shrinking required numerical_H/public_exponent_A dramatically; full Lean 4 proof diffs and Gaussian supplier optimization are separated as explicit follow-up work.", + "bottleneck_link": "Replaces the binary coupling bottleneck (~0.003890115) with seed_k7 BINARY_C = 4391986206293/2^50 (~0.003900867), leaving the unmodified PR #8042 GAUSSIAN_C = 2092819/2^29 (~0.003898179) minus 39/(256*numerical_H) as the active ceiling.", + "stop_rule": "Stopped after constructive binary optimization reached kappa=0.003898171 within GAUSSIAN_C=2092819/2^29 and passed all eight independent verify.py gates.", + "evidence": "research/p104-k7-retimed-binary/RESULT.json, research/p104-k7-retimed-binary/K7-STACK-LEDGER.json, research/p104-k7-retimed-binary/VERIFY.json, and all eight verify.py executable checks.", + "author": "SYLforge", + "ai_assistance": "Constructive binary optimization, PR #8042/#8050 architectural rebase, verification scripts, and documentation were developed with AI coding assistance and checked end-to-end by executable Python verification.", + "outcome": "completed", + "open_questions": [ + { + "question": "Can tightening or locally rewriting the 2-scale (1, 8) Gaussian supplier raise GAUSSIAN_C above 2092819/2^29 toward seed_k7's binary ceiling ~0.003900867?", + "first_step": "Compute tighter dyadic trials on the retimed 2-scale complex receiver (already 17555843548241/2^52 ~ 0.0038981803 without graph changes) and search legal rank-preserving rewrites of strong_complex.", + "why_it_matters": "With seed_k7 solving the binary bottleneck up to 0.003900867, GAUSSIAN_C is now the sole rate ceiling capping complete kappa near 0.00389817.", + "blocked_by": "The unmodified 48-call 2-scale Gaussian supplier word caps GAUSSIAN_C around 0.00389818034." + }, + { + "question": "Can Lean 4 proofs cover the changed binary MOVE/frame/port counts of seed_k7 alongside an independent audit of all five inherited framework obligations?", + "first_step": "Mechanize the delta-chart transitions and dirty-clear accounting between the #8027 baseline (2803 MOVEs, 104904 paid) and strong-bit-k7 (2796 MOVEs, 104652 paid).", + "why_it_matters": "Executable Python replays check finite instances and sparse weighted transports but do not replace theorem-prover certificates for all-size compiler/erasure assumptions.", + "blocked_by": "Formal Lean 4 checking of the modified binary graph overlay and the five inherited framework assumptions has not yet been executed here." + } + ] +} diff --git a/research/p104-k7-retimed-binary/VERIFY.json b/research/p104-k7-retimed-binary/VERIFY.json new file mode 100644 index 0000000000..436a8516e8 --- /dev/null +++ b/research/p104-k7-retimed-binary/VERIFY.json @@ -0,0 +1,97 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "binary" + ], + "timeout_seconds": 45, + "checks": "Replay the constructive k7 binary graph on all 630 registers and 36 LOCAL calls, verify all 636 frames and 2353 delta charts, run mod-3 and mod-9 sparse weighted checks, certify BINARY_C, verify K7-STACK-LEDGER.json, and confirm PR #8027 fails BINARY_C." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "cost" + ], + "timeout_seconds": 35, + "checks": "Verify RESULT.json across binary/numerical tariffs, all seven installed profiles, entrance bounds, signed outer budgets, and fast placement receipts." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "schedule" + ], + "timeout_seconds": 40, + "checks": "Check chronology, precision floors, streamed cross-parent loans, and reentrant returns across all profiles." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "install" + ], + "timeout_seconds": 240, + "checks": "Generate and check all seven installations, receiver selections, binary chart/frame metadata, and fiscal scans." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "physical" + ], + "timeout_seconds": 280, + "checks": "Run the literal unpowered binary constant-address emitter, two-scale Gaussian positive word replay, and extended stop exponent bounds." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "receiver" + ], + "timeout_seconds": 400, + "checks": "Check public direct and quotient weighted five-exchange shuttles, nonzero eight-rank classes, and exact direct checks." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "slabs" + ], + "timeout_seconds": 25, + "checks": "Verify Gaussian historical stage fences, arena heads, scratch slots, and restoring ordinary shuttles." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "product" + ], + "timeout_seconds": 135, + "checks": "Run physical_product(EXTENDED) at numerical_H=20000000 and verify product -345550037539, coefficients prefix, and restored owners." + } + ] +} diff --git a/research/p104-k7-retimed-binary/activation.py b/research/p104-k7-retimed-binary/activation.py new file mode 100644 index 0000000000..20525c7fa3 --- /dev/null +++ b/research/p104-k7-retimed-binary/activation.py @@ -0,0 +1,80 @@ +"""Check the complete connected activation of a streamed raw-transport installation.""" + +from fractions import Fraction + + +def ceil_log2(n): + return (n-1).bit_length() + + +def binary_entries(rank_logs): + cuts = [] + for h in rank_logs: + minimum = (250*(h+64)+248)//249 + cuts.append(max(minimum,h+64+cuts[-1] if cuts else 0)) + return cuts + + +def full_entrance(last_cut, numerical): + target = last_cut + numerical + 102 + s = max(512,target) + while s - 7*ceil_log2(s) < target: + s = target + 7*ceil_log2(s) + log = ceil_log2(s) + after = 7*(log+1) + target + if (1<=target + assert (1<=target + return s-1 + + +def resource_receipt(profile): + ranks=tuple(profile.rank_logs) + num=profile.complex_log + m=len(ranks) + assert 1<=m<=7 + cuts=binary_entries(ranks) + A=full_entrance(cuts[-1],num) + s=A+1 + assert s>=6000 + # 8E < 33L/s and L <= p/6+3. The remaining excess is <= 34s+8. + # Then 5.5/s <= 11/12000, and p/12000 covers 34s+9 for every s>=6000. + assert (12000*(34*s+9)).bit_length() <= s-2 + for h in (num,*ranks): + assert h>=1024 + assert 68+83*h<92*h + assert 92*h<105*h and 92*h<448*h + assert (700*h).bit_length()<=h and (872*(4*h+1)).bit_length()<=h + assert (30*1024*h+120).bit_length()<=h-1 + for i,h in enumerate(ranks): + assert not i or cuts[i-1]+2=num+cuts[-1]+2 + assert profile.eta1024 and tail>1024 + delta=(-pow(2,A,6))%6 + assert delta in (2,4) + return {"binary_cuts":cuts,"public_exponent_A":A,"first_public_offset":delta, + "initial_s":s,"stage_and_outer_fixed_log_overhead":local, + "retimed_first_stripe_margin":slack,"retimed_all_size_margin_floor":tail, + "absolute_log2_private_control_envelope":job_log, + "storage_upper":"6.2 p T < 297.6 n bits"} diff --git a/research/p104-k7-retimed-binary/bootstrap.py b/research/p104-k7-retimed-binary/bootstrap.py new file mode 100644 index 0000000000..7795186285 --- /dev/null +++ b/research/p104-k7-retimed-binary/bootstrap.py @@ -0,0 +1,87 @@ +"""Restore the two pinned predecessor packages and apply the reviewed local source changes.""" + +from hashlib import sha256 +import json +from pathlib import Path +from shutil import copyfile +from subprocess import run +import tarfile + +HERE = Path(__file__).resolve().parent + + +def unpack(destination): + frozen = HERE / "predecessor" + spec = json.loads((frozen / "SOURCES.json").read_bytes())["offline_predecessor"] + archive = frozen / spec["archive"] + if sha256(archive.read_bytes()).hexdigest() != spec["archive_sha256"]: + raise ValueError("The archived predecessor differs") + found = set() + with tarfile.open(archive) as package: + for entry in package: + name = entry.name + path = Path(name) + if (name not in spec["files"] or not entry.isfile() or name in found + or path.is_absolute() or ".." in path.parts or str(path) != name): + raise ValueError("Unexpected predecessor source") + record = spec["files"][name] + data = package.extractfile(entry).read() + if len(data) != record["size"] or sha256(data).hexdigest() != record["sha256"]: + raise ValueError(f"The source differs at {name}") + found.add(name) + target = destination / path + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(data) + if found != spec["files"].keys(): + raise ValueError("A predecessor source is missing") + for name, changes in json.loads((frozen / "OVERLAY.json").read_bytes()).items(): + target = destination / name + data = target.read_bytes() + if sha256(data).hexdigest() != changes["old_sha256"]: + raise ValueError(f"The base of the signed-margin extension differs at {name}") + source = data.decode() + for old, new in changes["edits"]: + if source.count(old) != 1: + raise ValueError(f"The signed-margin change has no unique site at {name}") + source = source.replace(old, new) + data = source.encode() + if sha256(data).hexdigest() != changes["new_sha256"]: + raise ValueError(f"The signed-margin extension differs at {name}") + target.write_bytes(data) + + +def install(destination): + unpack(destination) + run(["git", "apply", "--no-index", str(HERE / "machine.patch")], + check=True, cwd=destination) + run(["git", "apply", "--no-index", str(HERE / "receiver.patch")], + check=True, cwd=destination) + for name in ("five_exchange", "installations", "raw_binary_stage", "retimed_supplier", "transport", "unpowered_price", "fiscal_scans"): + copyfile(HERE / f"{name}.py", destination / f"{name}.py") + target_k7 = destination / "strong-bit.json.gz" + k7_source = HERE / "strong-bit-k7.json.gz" + if sha256(k7_source.read_bytes()).hexdigest() != "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362": + raise ValueError("seed_k7 binary source archive digest differs") + copyfile(k7_source, target_k7) + strong_binary_file = destination / "strong_binary.py" + sb_text = strong_binary_file.read_text(encoding="utf-8") + if "74e93daf2b7acf794ffb51f92f03f51556f68126d41ee13a8969bddb4cbe6326" not in sb_text: + raise ValueError("Expected predecessor binary digest in strong_binary.py") + strong_binary_file.write_text(sb_text.replace("74e93daf2b7acf794ffb51f92f03f51556f68126d41ee13a8969bddb4cbe6326", "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", 1), encoding="utf-8") + ind_price_file = destination / "independent_binary_price.py" + ibp_text = ind_price_file.read_text(encoding="utf-8") + if "104_904" not in ibp_text: + raise ValueError("Expected predecessor paid port count in independent_binary_price.py") + ind_price_file.write_text(ibp_text.replace("104_904", "104_652", 1), encoding="utf-8") + + +if __name__ == "__main__": + from argparse import ArgumentParser + + cli = ArgumentParser(description=__doc__) + cli.add_argument("destination", type=Path) + target = cli.parse_args().destination.resolve() + target.mkdir(parents=True, exist_ok=True) + if any(target.iterdir()): + cli.error("Select an empty destination for this installation") + install(target) diff --git a/research/p104-k7-retimed-binary/check_binary_k7.py b/research/p104-k7-retimed-binary/check_binary_k7.py new file mode 100644 index 0000000000..5d5d9173f4 --- /dev/null +++ b/research/p104-k7-retimed-binary/check_binary_k7.py @@ -0,0 +1,434 @@ +"""Check the constructive k7 binary circuit: replays, charts, sparse oracle, tariff, and #8027 control.""" + +from collections import Counter +from fractions import Fraction +from functools import cache +import gzip +from hashlib import sha256 +import json +from math import lcm +from pathlib import Path +from random import Random +import tarfile + +from installations import BINARY_C +from unpowered_price import certify + +PACKAGE_DIR = Path(__file__).resolve().parent +K7_GZ_SHA256 = "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" +K7_RAW_SHA256 = "f4a43e4e36ac734dea10a73dca496bf4a4f4a9804b903ea379483d0513d7abc3" +OLD_8027_GZ_SHA256 = "74e93daf2b7acf794ffb51f92f03f51556f68126d41ee13a8969bddb4cbe6326" + + +def check_archives_and_ledger(): + gz_bytes = (PACKAGE_DIR / "strong-bit-k7.json.gz").read_bytes() + assert sha256(gz_bytes).hexdigest() == K7_GZ_SHA256 + raw_bytes = gzip.decompress(gz_bytes) + assert sha256(raw_bytes).hexdigest() == K7_RAW_SHA256 + ledger = json.loads((PACKAGE_DIR / "K7-STACK-LEDGER.json").read_text(encoding="utf-8")) + final = ledger["final_k7"] + assert final["moves"] == 2796 + assert final["dirty_clears"] == 3426 + assert (final["frames"], final["pairs"], final["frame_gates"]) == (636, 2353, 44734) + assert (final["n_targets"], final["n_paid"], final["linear_paid_sum"]) == (18906, 104652, 284592) + assert final["gz_sha256"] == K7_GZ_SHA256 and final["raw_sha256"] == K7_RAW_SHA256 + return json.loads(raw_bytes) + + +def run_registers(program, starts, ends, ports): + count = len(starts) + frames = dict(enumerate(starts)) + values = {i: 1 << i for i in range(count)} + dirty = 0 + moves = 0 + for op, dest, *args in program: + if op == "MOVE": + before, after = args + assert frames[dest] == before + frames[dest] = after + moves += 1 + elif op == "ADD": + read, site = args + assert frames[dest] == frames[read] == site + values[dest] ^= values[read] + elif op == "SWAP": + (read,) = args + frames[dest], frames[read] = frames[read], frames[dest] + values[dest], values[read] = values[read], values[dest] + elif op == "INIT": + assert dest >= count and dest not in frames + frames[dest], values[dest] = args[0], 0 + elif op == "CLEAR": + assert dest >= count and frames.pop(dest) == args[0] + dirty += int(bool(values.pop(dest))) + else: + raise ValueError("Unknown graph instruction") + assert frames == dict(enumerate(ends)) + assert len(values) == count == 630 and ports == 111 + for i in range(count): + expected = 1 << i + if ports <= i < 2 * ports: + expected ^= 1 << (i - ports) + assert values[i] == expected + return dirty, moves + + +def check_outer_word(root): + def shift(terms, mask): + return {(role, exponent ^ mask) for role, exponent in terms} + + def stage_mask(stages): + mask = 0 + for stage in stages: + mask ^= 1 << stage + return mask + + head = 1 + words = [{(i, 0)} for i in range(root["roles"])] + for op, *args in root["events"]: + if op == "LOCAL": + stage, x, y = args + body = stage_mask((stage,)) + first, second = words[x], words[y] + words[x] = shift(first, body) + words[y] = shift(first, body ^ head) ^ shift(second, body) + elif op == "IDLE_ONE": + x, stages = args + words[x] = shift(words[x], stage_mask(stages)) + elif op == "QUERY": + x, y = args + words[x] ^= shift(words[y], head) + elif op == "ADD": + x, y = args + words[x] ^= words[y] + elif op == "SWAP": + x, y = args + words[x], words[y] = words[y], words[x] + else: + raise ValueError("Unknown caller instruction") + for i, (answer, diag) in enumerate(zip(words, root["diagonal"], strict=True)): + assert diag["q"] == 1 + assert answer == {(i, head ^ stage_mask(diag["stages"]))} + + +def matrix_product(a, b): + cols = list(zip(*b, strict=True)) + return [[sum(x * y for x, y in zip(u, v, strict=True)) for v in cols] for u in a] + + +def integer_matrix(a): + den = lcm(*(v.denominator for row in a for v in row)) + assert den % 3 + return den, [[int(v * den) for v in row] for row in a] + + +def rational_word(frame): + from factored_frames import inverse_word + from ternary_frames import identity + from vendor.cover import row_program + + word = row_program(frame, 3) + back = tuple(inverse_word(word)) + for program, base, goal in [ + (word, identity(len(frame)), frame), + (back, frame, identity(len(frame))), + ]: + rows = [list(row) for row in base] + for op, i, *args in program: + if op in ("scale", "add"): + q = Fraction(args[-1]) + assert q.denominator % 3 and max(abs(q.numerator), q.denominator) <= 20 + if op == "scale": + assert q.numerator % 3 + for row in rows: + if op == "scale": + row[i] *= q + elif op == "add": + row[i] += row[args[0]] * q + elif op == "swap": + j = args[0] + row[i], row[j] = row[j], row[i] + else: + raise ValueError("Unknown frame instruction") + assert rows == goal + return len(word) + + +def check_charts(data, ports): + from ternary_frames import frame_at_three, identity, projector, transpose + + frames, starts, ends = data["frames"], data["start"], data["final"] + ops = data["program"] + projectors, splits = [], [] + ident = identity(8) + for i in range(len(frames)): + spec = frames[str(i)] + p = projector(transpose(spec["B"] + spec["A"]), spec["dim"]) + projectors.append(p) + den, m = integer_matrix(p) + assert matrix_product(m, m) == [[den * x for x in row] for row in m] + splits.append((den, m)) + pairs = {tuple(row[2:]) for row in ops if row[0] == "MOVE"} + pairs.update(zip(starts[2 * ports :], ends[2 * ports :], strict=True)) + pairs = {tuple(sorted(pair, key=lambda j: frames[str(j)]["dim"])) for pair in pairs} + steps = 0 + for i, j in sorted(pairs): + di, pi = splits[i] + dj, pj = splits[j] + lifted = [[dj * x for x in row] for row in pi] + assert matrix_product(pi, pj) == matrix_product(pj, pi) == lifted + delta = [ + [y - x for x, y in zip(a, b, strict=True)] + for a, b in zip(projectors[i], projectors[j], strict=True) + ] + basis, rank = frame_at_three(delta) + assert rank == frames[str(j)]["dim"] - frames[str(i)]["dim"] + den, m = integer_matrix(delta) + assert matrix_product(m, basis) == [ + [den * v if col < rank else 0 for col, v in enumerate(row)] for row in basis + ] + steps += rational_word(basis) + for i in range(ports): + head, body = projectors[starts[i]], projectors[ends[ports + i]] + assert len(frames[str(starts[i])]["B"]) == 1 + assert projectors[ends[i]] == ident + assert all(x == 0 for row in projectors[starts[ports + i]] for x in row) + assert [ + [x + y for x, y in zip(a, b, strict=True)] for a, b in zip(head, body, strict=True) + ] == ident + basis = transpose(frames[str(starts[i])]["B"] + frames[str(ends[ports + i])]["B"]) + steps += rational_word(basis) + return len(projectors), len(pairs), steps + + +def raw_moments(data, root): + ports = root["ports"] + dims = {int(idx): frame["dim"] for idx, frame in data["frames"].items()} + targets = Counter() + paid = Counter() + local = sum(row[0] == "LOCAL" for row in root["events"]) + for row in root["diagonal"]: + targets[1 + root["body_rank"] * len(row["stages"])] += ports + for src, dst in zip(data["start"][2 * ports :], data["final"][2 * ports :], strict=True): + targets[abs(dims[dst] - dims[src])] += local + for row in data["program"]: + if row[0] == "MOVE": + paid[abs(dims[row[3]] - dims[row[2]])] += local + for row in root["events"]: + if row[0] == "QUERY": + paid[1] += ports + elif row[0] == "IDLE_ONE": + paid[len(row[2]) * root["body_rank"]] += ports + return targets, paid + + +def check_weighted_sparse(data, root): + from check_raw_delta import Sparse, right_columns + from strong_binary import StrongBinarySource + from direct_body import direct_actions, direct_factors + from factored_frames import Frame, inverse_word + from periodic import Job + from raw_binary import Axis, job_frame + from tagged_sources import binary_ports + from ternary_frames import residue + + source = binary_ports(data, root) + seeds = {0, 111, 114, len(source.targets) - 1} + for grade in (4, 8): + seeds.add( + next( + i + for i, port in enumerate(source.targets) + if port.tag[0] == "helper" and port.rank == grade + ) + ) + for modulus, columns in ((3, 1), (9, 2)): + n = source.ambient * columns + ident = tuple(bytes(int(x == y) for x in range(n)) for y in range(n)) + rng = Random(7914) + units = [x for x in range(modulus) if x % 3] + A = [rng.choice(units) for _ in range(n)] + Ai = [pow(a, -1, modulus) for a in A] + + @cache + def scaled_word(word): + out = [] + for op, tail, i, j, coeff in direct_actions(word, 1): + a = residue(coeff, modulus) + if not tail and op == "swap": + a = A[i] * Ai[j] % modulus + elif not tail and op == "add": + a = a * A[j] * Ai[i] % modulus + out.append((op, tail, i, j, a)) + return tuple(out) + + @cache + def factors(word, axis): + u, v = direct_factors(Frame(n, word, (axis,)), modulus) + return bytes(u), bytes(v) + + class DirectSparse(Sparse): + dimension = n + + def route(self, owner, word): + if not self.values[owner]: + return + self.active_routes += 1 + out = set() + for label, h, t in self.values[owner]: + pair = list(h), list(t) + for op, tail, i, j, a in scaled_word(word): + bank = pair[tail] + if op == "swap": + bank[i], bank[j] = ( + a * bank[j] % modulus, + pow(a, -1, modulus) * bank[i] % modulus, + ) + elif op == "scale": + bank[i] = a * bank[i] % modulus + else: + bank[j] = (bank[j] + a * bank[i]) % modulus + out.add((label, bytes(pair[0]), bytes(pair[1]))) + self.values[owner] = out + + def pay(self, job): + if not self.values[job.owner]: + return + self.active_paid += 1 + frame = job_frame(job, n) + out = set() + for label, h, t in self.values[job.owner]: + d = [(y - ai * x) % modulus for x, ai, y in zip(h, Ai, t, strict=True)] + change = [0] * n + for axis in frame.mask: + u, v = factors(frame.word, axis) + coeff = sum(x * y for x, y in zip(v, d, strict=True)) % modulus + if coeff: + change = [ + (x + coeff * y) % modulus for x, y in zip(change, u, strict=True) + ] + self.moved += any(change) + out.add( + ( + label, + bytes( + (x + a * v) % modulus for x, a, v in zip(h, A, change, strict=True) + ), + bytes((y - v) % modulus for y, v in zip(t, change, strict=True)), + ) + ) + self.values[job.owner] = out + + banks = DirectSparse(None, modulus) + entries, expected = [], {} + for i, port in enumerate(source.targets): + owner = banks.zero() + if i in seeds: + g = ( + ("add", 7, 113, Fraction(4, 5)), + ("swap", 0, 126), + ("scale", 4, Fraction(-2)), + ("add", 0, 32, 2), + ("add", 7, 0, i % 4 + 1), + ) + axes = tuple(Axis(g, j) for j in range(port.rank * columns)) + h, t = (bytes(rng.randrange(modulus) for _ in range(n)) for _ in range(2)) + banks.values[i].add((i, h, t)) + data_mat = right_columns(ident, g, modulus) + inv = right_columns(ident, tuple(inverse_word(g)), modulus) + diff = [(y - ai * x) % modulus for x, ai, y in zip(h, Ai, t, strict=True)] + local = [ + sum(col[j] * x for col, x in zip(inv, diff, strict=True)) % modulus + for j in range(port.rank * columns) + ] + change = [ + sum(data_mat[j][k] * entry for j, entry in enumerate(local)) % modulus + for k in range(n) + ] + expected[i] = { + ( + i, + bytes((x + a * v) % modulus for x, a, v in zip(h, A, change, strict=True)), + bytes((y - v) % modulus for y, v in zip(t, change, strict=True)), + ) + } + else: + axes = tuple(range(port.rank * columns)) + entries.append((port.tag, Job(owner, axes))) + count = 0 + for (tag, job), paid in zip( + StrongBinarySource(banks).raw(entries, columns), source.paid, strict=True + ): + assert tag == paid.tag and len(job.axes) == paid.rank * columns + banks.pay(job) + count += 1 + assert count == 104652 and len(banks.values) == len(entries) == 18906 + wrong = [k for k, v in banks.values.items() if v != expected.get(k, set())] + assert not wrong, wrong[:3] + + +def check_predecessor_8027_fails_binary_c(root): + tar_path = PACKAGE_DIR / "predecessor" / "predecessor-8030.tar.gz" + with tarfile.open(tar_path, "r:gz") as archive: + member = archive.getmember("strong-bit.json.gz") + with archive.extractfile(member) as f: + old_gz = f.read() + assert sha256(old_gz).hexdigest() == OLD_8027_GZ_SHA256 + old_data = json.loads(gzip.decompress(old_gz)) + old_targets, old_paid = raw_moments(old_data, root) + assert (old_targets.total(), old_paid.total()) == (18906, 104904) + try: + margin, cells = certify(BINARY_C, (old_targets, old_paid)) + except (AssertionError, ValueError): + return + assert cells is None or margin <= 0, "PR #8027 binary source unexpectedly certified at k7 BINARY_C" + + +def check(): + from strong_binary import caller, graph + + k7_from_pkg = check_archives_and_ledger() + data, root = graph(), caller() + assert data == k7_from_pkg + assert sum(r[0] == "LOCAL" for r in root["events"]) == 36 + dirty, moves = run_registers(data["program"], data["start"], data["final"], root["ports"]) + assert (dirty, moves) == (3426, 2796) + check_outer_word(root) + frames, pairs, steps = check_charts(data, root["ports"]) + assert (frames, pairs, steps) == (636, 2353, 44734) + + targets, paid = raw_moments(data, root) + assert (targets.total(), paid.total()) == (18906, 104652) + linear_t = sum(r * c for r, c in targets.items()) + linear_p = sum(r * c for r, c in paid.items()) + assert (linear_t, linear_p) == (286098, 284592) + signed = {r: targets[r] - paid[r] for r in targets.keys() | paid.keys() if targets[r] != paid[r]} + expected_signed = dict(enumerate((-48720, -45144, -1980, -396, -1296, -2664, -480), 1)) + expected_signed.update({8: 14268, 64: 444, 127: 222}) + for low in range(14, 57, 7): + expected_signed[low] = -444 + expected_signed[low + 1] = 444 + assert signed == expected_signed + + margin, cells = certify(BINARY_C, (targets, paid)) + assert cells is not None and len(cells) == 24 and margin > 0 + + check_weighted_sparse(data, root) + check_predecessor_8027_fails_binary_c(root) + print( + "PASS_K7_BINARY_CIRCUIT", + f"moves={moves}", + f"dirty={dirty}", + f"targets={targets.total()}", + f"paid={paid.total()}", + f"linear_paid={linear_p}", + f"frames={frames}", + f"pairs={pairs}", + f"frame_gates={steps}", + f"cells={len(cells)}", + "control_8027=rejected", + ) + + +if __name__ == "__main__": + check() diff --git a/research/p104-k7-retimed-binary/check_binary_word.py b/research/p104-k7-retimed-binary/check_binary_word.py new file mode 100644 index 0000000000..6d8d56516c --- /dev/null +++ b/research/p104-k7-retimed-binary/check_binary_word.py @@ -0,0 +1,62 @@ +"""Run the complete binary emitter on the constant-address subspace of each owner.""" + +from collections import Counter +from periodic import Job +from raw_binary_stage import binary_word +from strong_binary import StrongBinarySource, fixed_binary_charts + + +class ConstantFields: + """Each integer is a GF(2) form on independent external data words.""" + + def __init__(self, labels): + self.dimension = 134 + self.data = {i: 1 << i for i in range(labels)} + self.next = labels + self.counts = Counter() + + def zero(self): + owner = self.next + self.next += 1 + self.data[owner] = 0 + return owner + + def clone(self, parent): + owner = self.zero() + self.data[owner] = self.data[parent] + return owner + + def route(self, owner, word): + assert owner in self.data + self.counts["routes"] += 1 + self.counts["elementary_steps"] += len(word) + + def xor(self, dest, src): + self.data[dest] ^= self.data[src] + + def swap(self, left, right): + self.data[left], self.data[right] = self.data[right], self.data[left] + + def retire(self, owner, require_zero=False): + former = self.data.pop(owner) + if require_zero: + assert not former + + +def check(): + source = binary_word() + n = len(source.targets) + bank = ConstantFields(n) + jobs = [Job(i,tuple(range(r))) for i,r in enumerate(source.targets)] + issued = 0 + for job in source.native(jobs, 1, StrongBinarySource(bank)): + assert job.owner in bank.data and len(job.axes) == source.paid[issued] + issued += 1 + assert issued == 104652 and len(bank.data) == n + assert all(bank.data[i] == (1 << i) for i in range(n)) + charts, ports = fixed_binary_charts() + print("binary constant-address physical emitter", n, issued, len(charts), len(ports), dict(bank.counts)) + + +if __name__ == "__main__": + check() diff --git a/research/p104-k7-retimed-binary/check_chronology.py b/research/p104-k7-retimed-binary/check_chronology.py new file mode 100644 index 0000000000..efcfd334e4 --- /dev/null +++ b/research/p104-k7-retimed-binary/check_chronology.py @@ -0,0 +1,92 @@ +"""Run retimed loans from distinct positive-word calls through moving parent charts.""" + +from itertools import chain +from random import Random + +from upstream import install + +install() +from check_band import Chart, ChartJob +from periodic import Rule + + +def test(ticks=45): + raw = Chart(Rule(4, (4, 4), (2, 2, 2, 2)), ((2, 2), (2, 2)), 37) + rng = Random(3009317) + parents = {} + original = {} + active = {} + complete = [] + for birth in range(ticks): + ports = [] + for port in range(2): + owner = 2 * birth + port + axes = tuple(rng.sample(range(raw.n), 32)) + row = [rng.randrange(17) for _ in range(raw.n)] + raw.data[owner] = row.copy() + raw.chart[owner] = 0 + original[owner] = [ + 4 * a % 17 if i in axes else a for i, a in enumerate(row) + ] + ports.append(ChartJob(owner, axes, 0)) + parents[birth] = raw.native(ports, 8) + + def leaf(job): + for i in range(len(job.axes)): + raw.leaf(job.select((i,))) + + def finish(iterator): + assert next(iterator, None) is None + + exemplar = ChartJob(0, tuple(range(16)), 0) + cross_returns = 0 + for tick in range(ticks + 32): + for item in active.pop(tick, []): + finish(item[0]) + for loan in item[1]: + raw.retire_zero(loan) + born = tick - 32 + if born >= 0 and born in parents: + finish(parents.pop(born)) + jobs = [] + for step in range(4): + source = tick - 8 * step + if source in parents: + request = next(parents[source]) + assert len(request.axes) == 16 + jobs.append(request) + else: + jobs.append(None) + if tick >= ticks: + for job in filter(None, jobs): + leaf(job) + else: + # Two unequal parent births issue to each one of these two real children. + for a, b in ((0, 2), (1, 3)): + ports, padded = [], [] + for job in (jobs[a], jobs[b]): + if job is None: + job = raw.zero(exemplar) + padded.append(job) + ports.append(job) + if not padded: + assert ports[0].owner // 2 != ports[1].owner // 2 + cross_returns += 1 + iterator = raw.native(ports, 4) + active.setdefault(tick + 4, []).append((iterator, padded)) + complete.append((tick, iterator)) + for start, it in complete: + if start <= tick < start + 4: + leaf(next(it)) + + assert not parents and not active + assert raw.data == original and not any(raw.chart.values()) + assert raw.serial == raw.freed and raw.noncommuting and cross_returns + return ticks, raw.raw, cross_returns, raw.leaves, raw.freed, raw.noncommuting + + +if __name__ == "__main__": + print( + "ticks, native calls, crossing returns, primitive leaves, retired zeros, noncommuting frames", + *test(), + ) diff --git a/research/p104-k7-retimed-binary/check_complete.py b/research/p104-k7-retimed-binary/check_complete.py new file mode 100644 index 0000000000..316e205296 --- /dev/null +++ b/research/p104-k7-retimed-binary/check_complete.py @@ -0,0 +1,267 @@ +"""Compute whole-machine tariffs from the raw words and the actual signed controller.""" + +from collections import Counter +from fractions import Fraction as Q +import json +from pathlib import Path + +from activation import resource_receipt +from installations import BINARY_C, GAUSSIAN_C, PROFILES +from linear_geometry import connected_exponent, entrance_geometry +from ordinary_clock import polynomial_to_fibre_bound, first_stage_bound +from outer_budget import qualify +from outer_clock import exact_shape_check, financial_checks +from raw_binary_stage import binary_word +from staged_carriers import entrance_logs +from strict_moment import power_interval, UNIT +from unpowered_price import certify, intervals, ranks +from upstream import HERE + +HERE_RESULT = Path(__file__).with_name("RESULT.json") +SETUP_LOG = 513 + + +def tariff(c, census, ambient): + targets, paid = census + t = 1 - c + margin, cells = certify(c, census) + assert cells and margin > 0 and min(cells.values()) / sum(targets.values()) > Q(1, 2**64) + assert max(max(targets), max(paid)) <= 1032 and min(paid) >= Q(1, 2) + assert all(4 * k >= 5 * r for r, k in cells) + assert max(max(v.numerator.bit_length(), v.denominator.bit_length()) for v in cells.values()) < 512 + p = Q(sum(count * intervals(r, t)[0] for r, count in paid.items()), UNIT) + total = Q(sum(count * intervals(k, t)[1] for k, count in targets.items()), UNIT) + assert p / total > Q(99, 100) and p > 10 + lower, guard, delta = 32768, 1024, Q(1, 2**128) + + def upper(x, exponent): + return Q(intervals(x, exponent)[1], UNIT) + + assert upper(max(targets), c) < Q(106, 100) and t > Q(996, 1000) + factor = ( + Q(256, 255) * Q(4097, 4096) * Q(1028, 1024) * upper(guard * ambient * lower, c) + * (1 + Q(64, lower) + delta) / ((1 - Q(10, lower)) * (1 - delta)**3) + ) + if ambient == 134: + assert (factor * Q(47, 20))**8 < 2**11 + assert Q(75, 32) / Q(47, 20) == Q(375, 376) + else: + assert ambient == 1224 and cells[448, 1032] == 1 + assert factor**256 < 2**39 + return { + "productive": sum(targets.values()), + "paid": sum(paid.values()), + "cells": len(cells), + "directed_margin": str(margin), + "factor_upper_times_1000000": -(-10**6 * factor.numerator // factor.denominator), + } + + +def first_external_swap(census): + """Read the real root and the first placement tickets at each production Gaussian rank.""" + from itertools import islice + from periodic import Job + from raw48 import ComplexRaw + from strong_complex import load_changed, word + from transport import axes + + native = word(*load_changed(HERE / "inputs")) + roots = [p for p in native.targets if p.rank == 129 and p.tag[:2] == ("root", "rotated")] + assert len(roots) == 384 + targets, _ = census + assert targets[1032] == 624 + placements = {} + for h in sorted({profile.complex_log for profile in PROFILES.values()}): + rank = 1 << h + upper = 2 * (rank // (2048 * 1224)) + band = 2 * ((3 * upper) // 8) + left_num, right_num = band * 1032, (band + 2) * 1032 + assert upper * 448 < left_num < right_num < rank * 448 and band > 32768 + # Equivalently rank**6 * ((right_num - left_num) / 448) / (624 * rank**2) > 4. + assert (rank**4) * (right_num - left_num) > 4 * 624 * 448 + size = 1032 * (band - 8) + period = 4 * ((rank + 4 * size - 1) // (4 * size)) + assert period >= 1024 and rank // period > 0 + tickets = tuple(islice(axes(rank, size, period, 0), 3)) + assert tickets[0] == 0 and tickets[1] > 1 + canonical = ComplexRaw.axis_list(3, (0,)) + swaps = [] + + class TapeProbe: + def swap(self, left, right, width, exchange): + swaps.append((left, right, width)) + + class Columns: + window = 1 + swap = None + + body = ComplexRaw(None, {}, Columns(), low=0, bundle=1, slots=rank) + route = body.align(TapeProbe(), Job(0, tickets), canonical) + assert route and swaps[0] == (1, tickets[1], 1) + placements[str(h)] = {"period": period, "first_tickets": list(tickets)} + return {"root_tag": list(roots[0].tag), "per_target_probability": "1/624", "placements": placements} + + +def ceiling_log(q): + answer = max(0, q.numerator.bit_length() - q.denominator.bit_length()) + return answer if 2**answer >= q else answer + 1 + + +def profile_row(profile): + receipt = resource_receipt(profile) + heights = profile.rank_logs + cuts = entrance_logs(heights) + assert tuple(receipt["binary_cuts"]) == tuple(cuts) + A = connected_exponent(cuts[-1], profile.complex_log) + assert receipt["public_exponent_A"] == A + geom = entrance_geometry(A) + assert geom["public_offset_above_2_to_A"] == receipt["first_public_offset"] + prev = Q() + history = [] + for i, h in enumerate(heights): + covered = BINARY_C - Q(11, 8 * h) + limit = min(profile.eta, (249 * covered + prev) / 250) + b = profile.ordinary if i + 1 == len(heights) else Q(int(limit * 10**21) - 1, 10**21) + assert prev < b < limit + overhead = polynomial_to_fibre_bound() if i else first_stage_bound(profile.eta) + assert overhead + 80 * h < 1024 * h + history.append(str(b)) + prev = b + positive = GAUSSIAN_C - Q(39, 256 * profile.complex_log) + signed = qualify(profile.kappa, Q(1, profile.positive_stop_denominator), prev, positive) + logB = 40 + ceiling_log(Q(376 * 7, 10)**len(heights)) + 16384 * sum(heights) + logC = 1 + max(84_500_000, 1600 + 220 * profile.complex_log + logB + 1) + floors = [] + for stages in range(1, max(6, len(heights)) + 1): + room = BINARY_C - profile.ordinary - BINARY_C * Q(1, 250)**stages + if room > 0: + weight = sum(Q(1, 16)**i for i in range(stages)) + floors.append(1 + int(Q(249, 250) * Q(11, 8) * weight**2 / room)) + numerical_floor = 1 + int(Q(39, 256) / (GAUSSIAN_C - profile.ordinary)) + entrance_floor = min(floors) + numerical_floor + assert entrance_floor <= A + return { + "A_lower_in_this_price": entrance_floor, + "kappa": str(profile.kappa), + "binary_H": list(heights), + "numerical_H": profile.complex_log, + "width_logs": [92 * h for h in (*heights, profile.complex_log)], + "stage_rates": history, + "signed_gate": signed, + "geometry": geom, + **receipt, + "log2_fixed_setup_and_install_le": SETUP_LOG, + "log2_ordinary_clock_le": logB, + "log2_C_le": logC, + } + + +def baseline(): + from calibration import PROFILES as old, entrance + + result = {} + for key in ("compact", "high-rate", "price-match", "fixed-stock-stop", "small-gap"): + profile = old[key] + H, M = profile.rank_logs, profile.complex_log + logB = 40 + 16384 * sum(H) + logS = 1024 * max(*H, M) + (len(H) + 1).bit_length() + result[key] = { + "binary_H": list(H), + "numerical_H": M, + "kappa": str(profile.kappa), + "A": entrance(profile), + "log2_S_le": logS, + "old_installed_visits_log_gt": 7 * (max(H) - 2 - 9 * profile.power), + "log2_C_le": 1 + max(2**27, 1436 + 100 * M + logB + 1), + } + return result + + +def predecessor_comparison(): + return { + "pr_8035": { + "head": "ea776471bf8ed143a0625cf2d7532f65d15eb5f9", + "model": "powered_6stage_retimed", + "kappa": "0.0038901152865907", + "binary_paid": 104904, + "binary_stages": 6, + }, + "pr_8042": { + "head": "dfd25d553a843a946ca0b94130a5ff8943e98fdd", + "model": "unpowered_7stage_retimed", + "kappa": "0.003890115286594445", + "binary_c": "4484997569314581/1152921504606846976", + "gaussian_c": "2092819/536870912", + "binary_paid": 104904, + "binary_stages": 7, + "numerical_H": 19000, + }, + "pr_8050": { + "head": "328b858e24709495843abc751fcbf5df35a89da8", + "model": "unpowered_7stage_dyadic_endpoint", + "kappa": "0.003890115286594461", + "binary_c": "287039844436133239/73786976294838206464", + "gaussian_c": "2092819/536870912", + "binary_paid": 104904, + "binary_stages": 7, + "numerical_H": 36000, + }, + "present_k7": { + "binary_c": str(BINARY_C), + "binary_c_decimal": "0.003900867368050091", + "gaussian_c": str(GAUSSIAN_C), + "gaussian_c_decimal": "0.003898179158568382", + "binary_paid": 104652, + "binary_dirty_clears": 3426, + "binary_moves": 2796, + "binary_stages": 2, + "log2_fixed_setup_and_install_le": SETUP_LOG, + "conservative_36k_kappa": "0.003893947", + "compact_1m_kappa": "0.003898026", + "extended_10m_kappa": "0.003898163", + "extended_kappa": "0.003898171", + }, + } + + +def all_results(): + word = binary_word() + census = Counter(word.targets), Counter(word.paid) + from independent_binary_price import raw_moments, rank_price + from strong_binary import graph, caller + + assert census == raw_moments(graph(), caller()) + for grade in set(census[0]) | set(census[1]): + a, b = rank_price(grade, 1 - BINARY_C) + lo, hi = intervals(grade, 1 - BINARY_C) + assert Q(lo, UNIT) <= b and a <= Q(hi, UNIT) + binary = tariff(BINARY_C, census, 134) + positive_census = ranks() + positive = tariff(GAUSSIAN_C, positive_census, 1224) + first_move = first_external_swap(positive_census) + assert (binary["cells"], positive["cells"]) == (24, 54) + early = financial_checks() + regime = exact_shape_check(HERE) + rows = {name: profile_row(profile) for name, profile in PROFILES.items()} + return { + "predecessor_comparison": predecessor_comparison(), + "baseline": baseline(), + "binary": binary, + "positive": positive, + "profiles": rows, + "prefix": early, + "first_controller_shape": regime, + "first_numerical_placement": first_move, + } + + +def verify(): + actual = all_results() + assert actual == json.loads(HERE_RESULT.read_bytes()) + for name, row in actual["profiles"].items(): + print(name, "A", row["public_exponent_A"], "log2 C <=", row["log2_C_le"]) + print("binary / numerical transport pairs", actual["binary"]["cells"], actual["positive"]["cells"]) + + +if __name__ == "__main__": + print(json.dumps(all_results(), indent=2)) diff --git a/research/p104-k7-retimed-binary/check_extended_stop.py b/research/p104-k7-retimed-binary/check_extended_stop.py new file mode 100644 index 0000000000..770d14f58c --- /dev/null +++ b/research/p104-k7-retimed-binary/check_extended_stop.py @@ -0,0 +1,107 @@ +"""Probe the actual seven-stage configuration, its positive receiver and its signed caller.""" + +from fractions import Fraction as F +import json + +from installations import EXTENDED + +D = EXTENDED.positive_stop_denominator +HM = EXTENDED.complex_log + + +def exact_capped_test(power_le): + for e in (2, 3, 9): + for k in (1, 2, 5, 29, 100): + for d in (-1, 0, 1): + x = e**k+d + assert power_le(e,k,x) == (e**k <= x) + e = 2 << HM + assert not power_le(e, D, e) + assert power_le(e, 1, e) + + class Two: + """Represent 2**exponent exactly. Only ceiling+1 can have plus=1.""" + counts = {"multiply": 0, "successor": 0} + def __init__(self, exponent, plus=0): + self.e, self.plus = exponent, plus + + def __mul__(self, other): + assert self.plus == other.plus == 0 + Two.counts["multiply"] += 1 + return Two(self.e + other.e) + + def __rmul__(self, one): + assert one == 1 and not self.plus + Two.counts["multiply"] += 1 + return self + + def __add__(self, one): + assert one == 1 and not self.plus + Two.counts["successor"] += 1 + return Two(self.e,1) + + def __lt__(self, other): + assert min(self.e, other.e) > 0 + return (self.e,self.plus) < (other.e,other.plus) + + def __gt__(self, other): + return other < self + + trace = [] + for off in (-1,0,1): + Two.counts = dict.fromkeys(Two.counts, 0) + assert power_le(Two(HM+1), D, Two((HM+1)*D+off)) == (off>=0) + assert Two.counts == {"multiply":D.bit_length()-1 + D.bit_count(), + "successor":D.bit_length()-1} + trace.append((off, dict(Two.counts))) + return trace + + +def install_test(): + import band_product as bp + p = EXTENDED + from compact_columns import Columns + from positive import power_le + from spool import Field + + recipes = bp.prepare_native(p) + assert len(recipes) == 3 and D == 10**18 and HM == 20000000 + for recipe, height in zip(recipes, (*p.rank_logs, HM), strict=True): + assert recipe.rank_log == height and recipe.width_log == 92*height + supplier=bp.production_supplier(HM, D) + assert supplier.carrier == 1 << HM and supplier.denominator == D + recipe = supplier.recipe + assert recipes[-1] is recipe + assert (len(recipe.targets),len(recipe.paid),len(recipe.cells))==(105216,564144,54) + assert recipe.trial == F(2092819,2**29) + e = supplier.carrier * 2 + field = Field(1,8) + payload = bytes(range(32)) + field.stream.write(payload) + field.stream.seek(0) + columns = Columns(1,0,1,0,0,0,0,None) + try: + supplier._run(field,0,e,columns,e) + except ValueError as exc: + assert str(exc) == "The positive field has no independent row reserve." + else: + raise AssertionError("The receiver accepted a short physical field") + field.stream.seek(0) + assert field.stream.read(len(payload))==payload + field.retire() + from ordinary_carrier import stage_for_width_log + from staged_carriers import admitted_stage, entrance_logs + small = (1,2,3,4,5,6,7) + for i,cut in enumerate(entrance_logs(small),1): + for digits in ((1<= 0) + return tuple(-1 if q < 0 else (q - first) % 4 for q in v), first + + +@cache +def basis(i): + return tuple(0 if j == i else -1 for j in range(512)) + + +@cache +def affine(v, t, s): + assert 0 <= t < 9 and (s is None or 0 <= s < 9) + return normalize(tuple(v[j ^ ((1 if s is None else (j >> s) & 1) << t)] for j in range(512))) + + +@cache +def diagonal(v, q): + return normalize(tuple(-1 if a < 0 else (a + b) % 4 for a, b in zip(v, q, strict=True))) + + +@cache +def kernel(v, t): + assert 0 <= t < 9 + roots = {-1: (0, 0), 0: (1, 0), 1: (0, 1), 2: (-1, 0), 3: (0, -1)} + values = tuple( + plus(times((1, 1), roots[q]), times((1, -1), roots[v[j ^ (1 << t)]])) + for j, q in enumerate(v) + ) + pivot = next(x for x in values if x != (0, 0)) + identify = {rot(pivot, e): e for e in range(4)} + # A Clifford image of a stabilizer basis state has equal nonzero magnitudes. + return tuple(-1 if x == (0, 0) else identify[x] for x in values), pivot + + +@cache +def addresses(col, count): + return tuple(sum(((j >> b) & 1) << (count * b + col) for b in range(9)) for j in range(512)) + + +class Field: + """Store an exact Gaussian scalar times normalized disjoint column rays.""" + + def __init__(self, stock): + self.stock = stock + self.data = None + self.live = True + self.writes = 0 + stock[0] += 1 + stock[1] = max(stock[1], stock[0]) + + def blank(self): + return Field(self.stock) + + def clear(self): + self.data = None + + def copy(self): + x = self.blank() + x.data = self.data + return x + + def retire(self): + assert self.live + self.live = False + self.data = None + self.stock[0] -= 1 + + def replace(self, other): + self.data = other.data + self.writes += 1 + other.retire() + + def scaled(self, real, imag): + if self.data is None: + return None + real, imag = F(real), F(imag) + z, v = self.data + for s in (real, imag): + assert all(a % s.denominator == 0 for a in z) + a, b = times(z, (real, imag)) + assert a.denominator == b.denominator == 1 + return None if not a and not b else ((int(a), int(b)), v) + + def scale(self, real, imag=0): + self.data = self.scaled(real, imag) + + def scale_add(self, other, real=1, imag=0): + d = other.scaled(real, imag) + if d is None: + return + if self.data is None: + self.data = d + return + a, v = self.data + b, w = d + assert v == w, "Two live donor states do not have the same exact ray." + s = plus(a, b) + self.data = None if s == (0, 0) else (s, v) + + def swap(self, *args): + assert self.data is None, "The nonzero witness left the external canonical placement." + + def phase(self, fn, suffix): + if self.data is None: + return + z, ray = self.data + count = len(ray) + base = fn(0) % 4 + z = rot(z, base) + after = [] + sums = base + check = 0 + for i, v in enumerate(ray): + addr = addresses(i, count) + phases = tuple((fn(x) - base) % 4 for x in addr) + j = (71 * i + 93) % 512 + check |= addr[j] + sums += phases[j] + v2, phase = diagonal(v, phases) + after.append(v2) + z = rot(z, phase) + assert fn(check) % 4 == sums % 4 + self.data = z, tuple(after) + + def paid(self, index): + z, vs = self.data + c = index % len(vs) + t = index // len(vs) + v, p = kernel(vs[c], t) + u = times(z, p) + assert u[0] % 2 == 0 and u[1] % 2 == 0 + self.data = (u[0] // 2, u[1] // 2), vs[:c] + (v,) + vs[c + 1 :] + + +class Axes: + window = 1 + offset = suffix = 0 + swap = None + + def row(self, field, targets, sources=None): + if field.data is None: + return + z, vs = field.data + n = len(vs) + after = [] + assert len(targets) == n and (sources is None or len(sources) == n) + for c, i in enumerate(targets): + assert i % n == c and (sources is None or sources[c] % n == c) + v, phase = affine(vs[c], i // n, None if sources is None else sources[c] // n) + after.append(v) + z = rot(z, phase) + field.data = z, tuple(after) + + +class WitnessRaw(ComplexRaw): + def chart(self, field, tape, axes, cols, inverse=False): + if field.data is not None and any(axis >= 9 for axis in axes): + raise ValueError("A live chart reached a coordinate outside the nine-axis witness.") + return super().chart(field, tape, axes, cols, inverse) + + +def final_ray(origin): + """Evaluate the closed eight-axis product on one basis column.""" + vals = [-1 if (j ^ origin) & 256 else (-(j ^ origin).bit_count()) % 4 for j in range(512)] + return normalize(tuple(vals)) + + +def check(): + a = artifacts(source / "research/grade14-native-realization", HERE / "inputs") + w = word(a.graph, a.layout) + from retimed_supplier import Raw, source_ranks, SCALES, SMALL_SPLITS + + assert SCALES == (1, 8) and SMALL_SPLITS == 1008 + sizes, paid = source_ranks(w) + stock = [0, 0] + fields = {i: Field(stock) for i in range(len(sizes))} + jobs = [Job(i, range(2 * k)) for i, k in enumerate(sizes)] + clock, call = next((i, row[1]) for i, row in enumerate(a.instructions()) if row[0] == "NATIVE") + key = ("helper", clock, call, 1544) + pawn = next(i for i, p in enumerate(w.targets) if p.tag == key) + assert w.targets[pawn].rank == 8 + expected = {} + for copy, cols in enumerate((2, 16)): + owner = pawn + copy * len(w.targets) + origins = tuple((37 * i + 11 + 17 * copy) % 512 for i in range(cols)) + initial = ((3 if not copy else -7) << 512, (5 if not copy else 2) << 512) + fields[owner].data = initial, tuple(basis(i) for i in origins) + exact = tuple(final_ray(i) for i in origins) + z = rot(initial, sum(p for _, p in exact)) + assert all(a % 16**cols == 0 for a in z) + expected[owner] = (z[0] // 16**cols, z[1] // 16**cols), tuple(v for v, _ in exact) + physical = WitnessRaw(a, fields, Axes(), low=0, bundle=1, slots=2 * 1224) + it = Raw(w, physical).native(jobs, 2) + cnt = 0 + nonzero = {2: 0, 16: 0} + for g in paid: + j = next(it) + f = fields[j.owner] + cnt += 1 + assert len(j.axes) == 2 * g + if f.data is not None: + nonzero[len(f.data[1])] += 1 + for axis in j.axes: + f.paid(axis) + assert next(it, None) is None + assert set(fields) == set(range(len(sizes))) and all( + f.live and f.writes >= 1 for f in fields.values() + ) + assert {k: f.data for k, f in fields.items() if f.data is not None} == expected + assert all(nonzero.values()) + for f in fields.values(): + f.retire() + assert stock[0] == 0 + print("independent columns", 2, 16, "nonzero paid cuts by copy", nonzero, "all cuts", cnt) + print( + "returned owners", + len(fields), + "active output axes", + 2 * sum(sizes), + "nonzero Hilbert dimensions", + 2**18, + 2**144, + "peak handles", + stock[1], + ) + print( + "all other outputs retained zero; both nonzero states match the independent closed H-kernel formula" + ) + + +if __name__ == "__main__": + check() diff --git a/research/p104-k7-retimed-binary/check_positive_word.py b/research/p104-k7-retimed-binary/check_positive_word.py new file mode 100644 index 0000000000..8f2831a41a --- /dev/null +++ b/research/p104-k7-retimed-binary/check_positive_word.py @@ -0,0 +1,53 @@ +"""Replay both halves of every split through the literal native call on zero rows.""" + +from upstream import HERE, install + +_, _, _, source = install() +from check_strong_raw_word import Axes, Field +from periodic import Job +from raw48 import ComplexRaw +from retimed_supplier import Raw, source_ranks +from strong_complex import artifacts, word + + +class Original(Field): + def __init__(self, stock): + super().__init__(stock) + self.writes = 0 + + def replace(self, other): + super().replace(other) + self.writes += 1 + + +def check(): + a = artifacts(source / "research/grade14-native-realization", HERE / "inputs") + w = word(a.graph, a.layout) + sizes, paid = source_ranks(w) + stock = [0, 0] + fields = {i: Original(stock) for i in range(len(sizes))} + inputs = [Job(i, range(2 * k)) for i, k in enumerate(sizes)] + machine = ComplexRaw(a, fields, Axes(), low=0, bundle=1, slots=2448) + # A zero Clifford field stays zero under every phase and permutation. The + # full raw iterator still issues the same true chart, scale and move calls. + calls = 0 + it = Raw(w, machine).native(inputs, 2) + for grade in paid: + request = next(it) + assert request.owner in fields and len(request.axes) == 2 * grade + assert len(set(request.axes)) == len(request.axes) + calls += 1 + assert next(it, None) is None and len(fields) == len(inputs) + assert stock[0] == len(inputs) + assert set(fields) == set(range(len(inputs))) + assert all(f.live and f.writes and f.data is None for f in fields.values()) + assert 2*sum(sizes) == 13440384 and sum(f.writes for f in fields.values()) == 143616 + print("original output owners, selected axes, physical writes", len(fields), 2*sum(sizes), sum(f.writes for f in fields.values())) + for owned in fields.values(): + owned.retire() + assert stock[0] == 0 + print("complete two-column raw path", len(sizes), calls, stock[1]) + + +if __name__ == "__main__": + check() diff --git a/research/p104-k7-retimed-binary/check_precision.py b/research/p104-k7-retimed-binary/check_precision.py new file mode 100644 index 0000000000..62b024a025 --- /dev/null +++ b/research/p104-k7-retimed-binary/check_precision.py @@ -0,0 +1,140 @@ +"""Audit the Gaussian transport reserve against the two literal finite programs.""" +from fractions import Fraction as Q +from functools import cache +from hashlib import sha256 +from math import gcd +import gzip +import json + + +def loadp(path): + return json.loads(gzip.decompress(path.read_bytes())) + + +def digest(x): + return sha256(json.dumps(x, sort_keys=True, separators=(",", ":")).encode()).hexdigest() + + +class Bound: + def __init__(self, height=0, mass=Q(1)): + self.height, self.mass = height, mass + + def __add__(self, other): + return Bound(max(self.height, other.height), self.mass + other.mass) + + def scaled(self, re, im=0): + re, im = Q(re), Q(im) + val2 = lambda n: (n & -n).bit_length() - 1 + return Bound(self.height + max(val2(re.denominator), val2(im.denominator)), + self.mass * (abs(re) + abs(im))) + + +def audit_mixed(events, n): + rows = [Bound() for _ in range(n)] + mixed_height = graph_height = 0 + mixed_mass = graph_mass = Q(1) + + def see(*values): + nonlocal mixed_mass, mixed_height + for value in values: + mixed_height = max(mixed_height, value.height) + mixed_mass = max(mixed_mass, value.mass) + return values[-1] + + for kind, dst, *args in events: + if kind.startswith("HOST"): + inputs = [rows[j] for j in args] + graph_mass = max(graph_mass, *(v.mass for v in inputs)) + graph_height = max(graph_height, *(v.height for v in inputs)) + if kind == "HOST_A": + x, y, u, v = args + rows[y] = see(rows[y] + rows[x]) + rows[u] = see(rows[u] + rows[v]) + else: + x, y = args + one = rows[x] + rows[y] + half = rows[x].scaled(Q(1, 2)) + rows[y].scaled(Q(1, 2)) + rows[x], rows[y] = see(one), see(half) + elif kind == "SWAP": + i, = args + rows[i], rows[dst] = rows[dst], rows[i] + elif kind in ("ADD", "SCALE"): + operand = rows[args[0]] if kind == "ADD" else rows[dst] + scaled = see(operand.scaled(*args[-1])) + rows[dst] = see(rows[dst] + scaled) if kind == "ADD" else scaled + elif kind == "QUERY": + rows[dst] = see(rows[dst] + rows[args[0]]) + elif kind == "LAMBDA": + half = see(rows[dst].scaled(Q(1, 2), Q(1, 2))) + rows[dst] = see(half + half) + else: + assert kind in ("IDLE_ONE", "IDLE_ODD") + return mixed_height, graph_height, mixed_mass, graph_mass + + +def graph_bound(graph): + mass = {~i: Q(1) for i in range(len(graph["initial"]))} + edges = dict(graph["forms"]) + peak = Q(1) + terms = literal_bits = 0 + for vertex in graph["schedule"]: + total = Q(0) + for donor, literal in edges[vertex]: + scalar = Q(literal) + literal_bits = max(literal_bits, abs(scalar.numerator).bit_length(), scalar.denominator.bit_length()) + total += mass[donor] * abs(scalar) + mass[vertex] = total + terms += len(edges[vertex]) + peak = max(peak, total) + return peak, terms, literal_bits + + +def audit(): + from upstream import HERE, install + _, _, _, src = install() + retained = src / "research/grade14-native-realization/retained" + from strong_complex import load_changed + from closed_caller import templates + from mixed_grid import exact + from check_strong_complex import literal_grid + from strong_complex import GRID, WORD, ODD, DYADIC, LAYOUT + + g, layout = load_changed(HERE / "inputs") + assert digest(g) == WORD and digest(layout) == LAYOUT + local, terms, literal = graph_bound(g) + signed = literal_grid(g, layout) + assert local == Q(signed["peak"]) and signed["literal_width_with_odd"] == 87 + print("graph", terms, "edges", literal, "direct scalar bits", signed["products"], "basis products", + signed["nontrivial"], "nontrivial separate divisions", flush=True) + + drops, masses = [], [] + for name, (events, diagonal) in templates(loadp(retained / "data/CALLER.json.gz")).items(): + receipt = exact(events, diagonal, 2025 << 9) + assert receipt == exact(events, diagonal, receipt["minimum_grid"]) + d, b, m, n = audit_mixed(events, len(diagonal)) + drop = max(d, b+DYADIC) + mass = max(2025*m, 2025*n*ODD*local) + drops.append(drop) + masses.append(mass) + print(name, "source signed grid", receipt["minimum_grid"], "height/entrance", d, b, + "Mell", drop, "ceil-log-mass", ((mass.numerator-1)//mass.denominator).bit_length()) + assert max(drops) == 148 + big = max(masses) + assert 2**435 < big < 2**436 + assert GRID == ODD << DYADIC + from installations import PROFILES + profiles = {(p.complex_log,p.positive_stop_denominator) for p in PROFILES.values()} + for h, d in profiles: + assert 872*(4*h+1) < 1 << h + assert 68+(6+77)*h < 92*h + assert 32*(h+11)+6*h+4 < 64*(h+1) + assert 150+6*(h+1).bit_length() < h + assert 96*h + 92*h + h + 100 < 191*h + assert 700*h + 200 < (1 << (h-2)) + assert 16*(h+2) + 200 < h*h//2 + print("bound per causal raw context", max(drops), 436) + print("all listed profiles satisfy the finite reserve and clock inequalities") + + +if __name__ == "__main__": + audit() diff --git a/research/p104-k7-retimed-binary/check_reentry.py b/research/p104-k7-retimed-binary/check_reentry.py new file mode 100644 index 0000000000..7726e110b5 --- /dev/null +++ b/research/p104-k7-retimed-binary/check_reentry.py @@ -0,0 +1,65 @@ +"""Suspend a streamed numerical epoch inside one of its real paid singleton calls.""" + +from fractions import Fraction as F +from random import Random +from upstream import install + +install() +from check_band import Chart, ChartJob +from periodic import Rule +from transport import Plan + + +def sample(plan, seed, reenter=None): + rule = Rule(2, (2, 2), (1, 1, 1, 1)) + + class Nested(Chart): + nested = False + + def leaf(self, job): + if not self.nested and reenter is not None: + self.nested = True + reenter() + super().leaf(job) + + chart = Nested(rule, ((1, 1), (1, 1)), plan.n) + random = Random(seed) + fields = [] + for owner in range(plan.width): + fields.append(ChartJob(owner, tuple(random.sample(range(plan.n), plan.n)), 0)) + chart.data[owner] = [random.randrange(17) for _ in range(plan.n)] + chart.chart[owner] = 0 + plan.decode(fields, 5, 0, chart, plan.events()) + assert chart.leaves == plan.leaves_per_epoch and chart.freed == chart.serial + assert not any(chart.chart.values()) and chart.nested == (reenter is not None) + return chart.data + + +if __name__ == "__main__": + plan = Plan( + 224, + (2, 2), + (1, 1, 1, 1), + {(1, 2): F(1)}, + F(1), + 12, + 34, + 1536, + 9, + 32, + width=2048, + delay_base=4, + scale_step=F(2), + padding=1, + ) + expected = sample(plan, 992) + inside = sample(plan, 1436) + + def nested(): + assert sample(plan, 1436) == inside + + assert sample(plan, 992, nested) == expected + print( + "nested same-program stream restored both complete 2,048-row schedules; leaves each", + plan.leaves_per_epoch, + ) diff --git a/research/p104-k7-retimed-binary/check_scans.py b/research/p104-k7-retimed-binary/check_scans.py new file mode 100644 index 0000000000..ee4f1a54cd --- /dev/null +++ b/research/p104-k7-retimed-binary/check_scans.py @@ -0,0 +1,120 @@ +"""Check the signed input reader and the ordinary dispatcher on fenced intervals.""" +from contextlib import closing +from dataclasses import replace +from io import BytesIO +from itertools import product +from random import Random +from fiscal_scans import LowCounter, magnitude_bits, rectangle_slab, slab_indices, transfer, zero_bytes + + +class Window(BytesIO): + def __init__(self,data,*,short=None,restore=False): + super().__init__(b'GUARD'+data+b'END') + self.origin=5 + super().seek(5) + self.limit=5+len(data) + self.short=short + self.restore=restore + self.moves=[] + + def read(self,size=-1): + assert size>=0 and self.origin<=self.tell()<=self.limit + return super().read(min(size,self.limit-self.tell(),self.short or size)) + + def seek(self,to,whence=0): + assert self.restore and (to,whence)==(self.origin,0) + self.moves.append(abs(self.tell()-to)) + return super().seek(to,whence) + + +def oracle(data, side, prefix, gap, suffix): + result=bytearray(len(data)) + for p in range(prefix): + for a in range(side): + for g in range(gap): + for b in range(side): + x=(((p*side+a)*gap+g)*side+b)*suffix + y=(((p*side+b)*gap+g)*side+a)*suffix + result[y:y+suffix]=data[x:x+suffix] + return result + + +def check_fixed_product(): + from band_product import Product + + values = (741503, 466013) + tapes = [BytesIO(b"pre" + value.to_bytes(3, "little") + b"guard") for value in values] + for source in tapes: + source.seek(3) + lengths = tuple(magnitude_bits(source, 3) for source in tapes) + output = BytesIO() + machine = Product((3, 5), 8, 136) + sign, size, coefficients = machine._multiply_tapes(*tapes, output, lengths, True, True) + assert lengths == (20, 19) + assert sign and size == 5 and int.from_bytes(output.getvalue(), "little") == 345550037539 + assert list(coefficients[:5]) == [11811, 10996, 4152, 868, 77] + assert not any(coefficients[5:]) and machine.h_calls == 157248 + for value, source in zip(values, tapes, strict=True): + assert source.tell() == 3 + assert source.getvalue() == b"pre" + value.to_bytes(3, "little") + b"guard" + print("signed scanner and fixed-geometry product -345550037539; 157248 H calls") + + +def main(): + from ordinary_carrier import ordinary_swap,stage_body + from installations import COMPACT + from band_product import multiply_tapes + packets=0 + for n in range(8): + for w in product((0,1,128,255),repeat=n): + data=bytes(w); src=Window(data,restore=True) + assert magnitude_bits(src,n)==int.from_bytes(data,'little').bit_length() + assert src.moves==[n] and src.tell()==src.origin + packets+=1 + for n in (65535,65536,65537,131073): + for data in (bytes(n), bytes(n-1)+b'\x80', b'\x81'+bytes(n-1), b'\xff'*n): + src=Window(data,restore=True) + assert magnitude_bits(src,n)==int.from_bytes(data,'little').bit_length() and src.moves==[n] + packets+=1 + data=Random(n+551).randbytes(n); src=Window(data,short=383); out=BytesIO() + transfer(src,out,n); assert out.getvalue()==data and src.tell()==src.limit and not src.moves + out=BytesIO(); zero_bytes(out,n);assert out.getvalue()==bytes(n) + src=Window(b'\xff\x00',restore=True) + try:magnitude_bits(src,3) + except EOFError:pass + else:raise AssertionError('truncated declared interval passed') + assert src.moves==[2] and src.tell()==src.origin + for raw in ((b'\x00', b''),(b'\x01\x02',b'\x03')): + a,b=(Window(v,restore=True) for v in raw); out=BytesIO() + sign,length=multiply_tapes(a,len(raw[0]),b,len(raw[1]),out,left_negative=True) + value=int.from_bytes(raw[0],'little')*int.from_bytes(raw[1],'little') + assert sign==bool(value) and int.from_bytes(out.getvalue(),'little')==value and length==len(out.getvalue()) + assert a.tell()==a.origin and b.tell()==b.origin + tests=0 + for bits in (0,1,2,4): + for p,g,s in ((1,1,1),(3,5,7),(5,3,1)): + side=1< 2 * plan.source_width + assert any( + plan.rounds % s.period for sources in plan.sources.values() for s in sources + ) + assert not hasattr(plan, "image") + chart = Chart(source, ((1, 1), (1, 1)), plan.n) + rng = Random(1389) + lanes = [] + original = {} + for i in range(plan.width): + lane = ChartJob(i, tuple(rng.sample(range(plan.n), plan.n)), 0) + original[i] = [rng.randrange(17) for _ in lane.axes] + chart.data[i] = original[i].copy() + chart.chart[i] = 0 + lanes.append(lane) + plan.run(lanes, chart) + z = -(-plan.width // plan.source_width) + assert all( + chart.data[i] == [4 * x % 17 for x in row] for i, row in original.items() + ) + assert chart.leaves == z * plan.rounds * plan.leaves_per_epoch + assert not any(chart.chart.values()) and chart.freed == chart.serial + print( + "fixed width / slots / groups / actual leaves / raw / zero returns / chart checks", + plan.width, + plan.source_width, + z, + chart.leaves, + chart.raw, + chart.freed, + chart.noncommuting, + ) + + +if __name__ == "__main__": + check() diff --git a/research/p104-k7-retimed-binary/direct_exact.py b/research/p104-k7-retimed-binary/direct_exact.py new file mode 100644 index 0000000000..8d6ef215d4 --- /dev/null +++ b/research/p104-k7-retimed-binary/direct_exact.py @@ -0,0 +1,96 @@ +"""Test noncommuting placed bases against an independent exact matrix computation.""" + +from fractions import Fraction as Q +from io import BytesIO +from pathlib import Path +from math import prod +import sys + + +def exact_projector(n, word, axis): + def eye(): + return [[Q(i == j) for j in range(n)] for i in range(n)] + def times(a,b): + return [[sum(a[i][k]*b[k][j] for k in range(n)) for j in range(n)] for i in range(n)] + basis=eye() + for gate,i,*args in word: + new=eye() + if gate=="add": + j,c=args + new[j][i]=Q(c) + elif gate=="scale": + new[i][i]=Q(args[0]) + else: + j=args[0] + new[j],new[i]=new[i],new[j] + basis=times(basis,new) + aug=[row+unit for row,unit in zip(basis,eye())] + for i in range(n): + k=next(k for k in range(i,n) if aug[k][i]) + aug[i],aug[k]=aug[k],aug[i] + q=aug[i][i] + aug[i]=[v/q for v in aug[i]] + for j in range(n): + if j!=i: + q=aug[j][i] + aug[j]=[a-q*b for a,b in zip(aug[j],aug[i])] + primal=[basis[i][axis] for i in range(n)] + dual=aug[axis][n:] + assert sum(i*j for i,j in zip(primal,dual))==1 + return primal,dual + + +def main(root): + sys.path.insert(0,str(root)) + from upstream import install + install() + from binary_receiver import Receiver + from factored_frames import Frame + from check_module_atoms import payload, expected_packet + + class Counted(Receiver): + def weighted(self,*args,**kwargs): + self.calls+=1 + return super().weighted(*args,**kwargs) + cases=[ + (2,1,(1,1,0,0),1,(("add",0,1,1),("add",1,0,1),("scale",0,-1))), + (2,1,(1,2,0,0),0,(("scale",0,Q(5,2)),("add",0,1,Q(1,2)),("add",1,0,2))), + (3,1,(1,1,0,0),2,(("add",2,0,1),("swap",1,2),("add",1,0,-1),("scale",1,-1))), + (3,1,(1,1,0,0),0,(("scale",1,-1),("add",2,1,Q(1,2)),("add",0,2,-1),("swap",0,1))), + ] + total=0 + for n,f,layout,axis,word in cases: + core=Counted(n,layout,direct=True) + core.calls=0 + atom,mod=core.atom,core.modulus + assert atom==mod + earlier,middle,repeat=2,2,2 + dims=(repeat,earlier)+(atom,)*(n*f)+(middle,)+(atom,)*(n*f) + u,v=exact_projector(n,word,axis) + def residue(k): + return k.numerator*pow(k.denominator,-1,mod)%mod + u,v=list(map(residue,u)),list(map(residue,v)) + def weight(row,i): + return (1,2,4,5,7,8)[(row+i)%6]%mod + def image(unused,old,*coordinates): + left=list(coordinates[:n*f]);right=list(coordinates[n*f+1:]);gap=coordinates[n*f] + for j in range(f): + col=range(j,n*f,f) + delta=sum(z*(right[k]-pow(weight(old,k),-1,mod)*left[k]) for z,k in zip(v,col)) + for z,k in zip(u,col): + left[k]=(left[k]+weight(old,k)*z*delta)%mod + right[k]=(right[k]-z*delta)%mod + return unused,old,*left,gap,*right + raw=payload(prod(dims));target=BytesIO() + with core.storage(): + core.serve_line(BytesIO(raw),target,Frame(n,word,(axis,)),f,repeat,earlier,middle,4,weight) + assert core.calls==1 + assert target.getvalue()==expected_packet(raw,dims,image) + total+=prod(dims) + print("noncommuting",n,mod,axis,"calls",core.calls,"records",prod(dims),flush=True) + print("complete noncommuting direct comparisons",total) + + +if __name__ == "__main__": + from upstream import HERE + main(HERE) diff --git a/research/p104-k7-retimed-binary/direct_recursive.py b/research/p104-k7-retimed-binary/direct_recursive.py new file mode 100644 index 0000000000..75b2a00879 --- /dev/null +++ b/research/p104-k7-retimed-binary/direct_recursive.py @@ -0,0 +1,127 @@ +"""Exercise the production one-child direct dispatcher with nonconstant weights and real recursion.""" +from fractions import Fraction as Q +from io import BytesIO +from math import gcd, prod +from pathlib import Path +from random import Random +import sys + + +def digits(q, radices): + out=[] + for r in reversed(radices): + q,x=divmod(q,r) + out.append(x) + assert q==0 + return list(reversed(out)) + + +def address(xs,radices): + n=0 + for x,r in zip(xs,radices,strict=True): + n=n*r+x + return n + + +def factors(n,axis,word,modulus): + # Follow the selected unit vector through the elementary factors on either side. + u=[int(i==axis) for i in range(n)] + v=u.copy() + def residue(x): + r=Q(x) + return int(r.numerator*pow(r.denominator,-1,modulus)%modulus) + for op,i,*args in reversed(word): + if op=="add": + j,k=args + u[j]=(u[j]+residue(k)*u[i])%modulus + v[i]=(v[i]-residue(k)*v[j])%modulus + elif op=="scale": + a=residue(args[0]) + u[i]=a*u[i]%modulus + v[i]=pow(a,-1,modulus)*v[i]%modulus + else: + assert op=="swap" + j=args[0] + u[i],u[j]=u[j],u[i] + v[i],v[j]=v[j],v[i] + assert sum(a*b for a,b in zip(u,v))%modulus==1 + return u,v + + +def check(root): + sys.path.insert(0,str(Path(root).resolve())) + from upstream import install + install() + from binary_receiver import Receiver + from direct_body import direct_line as bound + from factored_frames import Frame + from five_exchange import direct_line + from module_atoms import component_widths + assert bound is direct_line + + tests=[ + (2,2,(1,1,0,1),1,(("add",0,1,1),("swap",0,1),("scale",1,Q(5,2)),("add",1,0,2)),2,2,2), + (2,1,(1,2,1,1),0,(("scale",0,Q(5,2)),("add",0,1,Q(1,2)),("add",1,0,2)),2,1,1), + (3,1,(1,1,0,1),1,(("add",1,2,-1),("swap",0,2),("add",0,1,Q(1,2)),("scale",2,-1)),3,3,2), + ] + rng=Random(58119) + for n,f,layout,axis,word,unused,older,gap in tests: + core=Receiver(n,layout,direct=True) + atom,mod=core.atom,core.modulus + rings=[3**s for s in component_widths(layout)] + u,v=factors(n,axis,word,mod) + units=[a for a in range(mod) if gcd(a,mod)==1] + weights=[[rng.choice(units) for _ in range(n*f)] for _ in range(older)] + shape=[unused,older]+[atom]*(n*f)+[gap]+[atom]*(n*f) + volume=prod(shape) + inputs=bytearray(volume) + expected=bytearray(volume) + seen=set() + samples=range(volume) if volume<15000 else rng.sample(range(volume),311) + for src in samples: + a=digits(src,shape) + old=a[1] + left = [digits(t,rings) for t in a[2:2+n*f]] + right = [digits(t,rings) for t in a[3+n*f:]] + for j in range(f): + for k,m in enumerate(rings): + indices=range(j,n*f,f) + delta=sum(v[i] * (right[t][k]-pow(weights[old][t],-1,m)*left[t][k]) + for i,t in enumerate(indices)) + for i,t in enumerate(indices): + left[t][k]=(left[t][k]+weights[old][t]*u[i]*delta)%m + right[t][k]=(right[t][k]-u[i]*delta)%m + a[2:2+n*f]=[address(t,rings) for t in left] + a[3+n*f:]=[address(t,rings) for t in right] + dest=address(a,shape) + assert dest not in seen + seen.add(dest) + inputs[src]=rng.randrange(1,256) + expected[dest]=inputs[src] + calls=[] + outer=core.weighted + depth=0 + def counted(src,dst,**kw): + nonlocal depth + calls.append((depth,kw["atoms"])) + depth+=1 + try: + return outer(src,dst,**kw) + finally: + depth-=1 + core.weighted=counted + src=BytesIO(b"prefix"+inputs+b"suffix") + dst=BytesIO(b"prefix"+bytes(volume)+b"suffix") + for tape in (src,dst):tape.seek(6) + with core.storage(): + core.serve_line(src,dst,Frame(n,word,(axis,)),f,unused,older,gap,1,lambda row,j:weights[row][j]) + assert dst.getvalue()==b"prefix"+expected+b"suffix" + assert src.getvalue()==b"prefix"+inputs+b"suffix" + assert src.tell()==dst.tell()==6+volume + assert [width for dep,width in calls if dep==0]==[f] + print("direct",n,"f",f,"layout",layout,"volume",volume,"checked origins",len(seen), + "root arrows",sum(dep==0 for dep,_ in calls),"nested",sum(dep>0 for dep,_ in calls),flush=True) + +if __name__ == "__main__": + from upstream import HERE + check(HERE) diff --git a/research/p104-k7-retimed-binary/fiscal_scans.py b/research/p104-k7-retimed-binary/fiscal_scans.py new file mode 100644 index 0000000000..760c1dfbd2 --- /dev/null +++ b/research/p104-k7-retimed-binary/fiscal_scans.py @@ -0,0 +1,143 @@ +"""Scan low-first binary counters and restore signed-magnitude input heads.""" + + +from contextlib import closing + + +class LowCounter: + """Keep canonical binary digits with the low bit at the active end.""" + + def __init__(self, value=0): + if value < 0: + raise ValueError("Use a nonnegative counter") + self.digits = bytearray() + for octet in value.to_bytes((value.bit_length() + 7) // 8, "little"): + self.digits.extend((octet >> bit) & 1 for bit in range(8)) + while self.digits and not self.digits[-1]: + self.digits.pop() + + def take(self): + if not self.digits: + return False + i = 0 + while not self.digits[i]: + self.digits[i] = 1 + i += 1 + self.digits[i] = 0 + if i + 1 == len(self.digits): + self.digits.pop() + return True + + def add_one(self): + i = 0 + while i < len(self.digits) and self.digits[i]: + self.digits[i] = 0 + i += 1 + if i == len(self.digits): + self.digits.append(1) + else: + self.digits[i] = 1 + + def value(self): + data = bytearray((len(self.digits) + 7) // 8) + for bit, value in enumerate(self.digits): + data[bit // 8] |= value << (bit % 8) + result = int.from_bytes(data, "little") + data[:] = bytes(len(data)) + return result + + def clear(self): + while self.digits: + self.digits[-1] = 0 + self.digits.pop() + + +def slab_indices(count): + """Yield once per complete slab. Retire the counter on an early exit.""" + remaining = LowCounter(count) + try: + while remaining.take(): + yield None + finally: + remaining.clear() + + +def magnitude_bits(source, octets): + """Read the declared byte interval and return to its original boundary.""" + if octets < 0: + raise ValueError("The input extent must be nonnegative") + remaining = LowCounter(octets) + trailing = LowCounter() + last = 0 + origin = source.tell() + try: + while remaining.take(): + byte = source.read(1) + if not byte: + raise EOFError("The input magnitude ended before its declared extent") + if byte[0]: + last = byte[0] + trailing.clear() + else: + trailing.add_one() + return 8 * (octets - trailing.value() - 1) + last.bit_length() if last else 0 + finally: + remaining.clear() + trailing.clear() + source.seek(origin) + + +BLOCK = 1 << 16 +ZERO_BLOCK = bytes(BLOCK) + + +def _block_sizes(count): + blocks, last = divmod(count, BLOCK) + remaining = LowCounter(blocks) + try: + while remaining.take(): + yield BLOCK + if last: + yield last + finally: + remaining.clear() + + +def transfer(source, target, count): + """Copy exactly one interval, or consume it when the target is absent.""" + with closing(_block_sizes(count)) as sizes: + for size in sizes: + while size: + block = source.read(size) + if not block: + raise EOFError("The source field ended inside its declared extent") + if target is not None: + target.write(block) + size -= len(block) + + +def zero_bytes(target, count): + """Fill one declared interval with zeroes in forward order.""" + with closing(_block_sizes(count)) as sizes: + for size in sizes: + target.write(ZERO_BLOCK[:size]) + + +def rectangle_slab(source, target, small, big, gap, suffix, *, restrict=False): + """Extend or restrict two address fields in one contiguous prefix slab.""" + real = small * suffix + pad = (big - small) * suffix + with closing(slab_indices(small)) as rows: + for _ in rows: + with closing(slab_indices(gap)) as intervals: + for _ in intervals: + transfer(source, target, real) + if restrict: + transfer(source, None, pad) + else: + zero_bytes(target, pad) + tail = (big - small) * gap * big * suffix + if restrict: + transfer(source, None, tail) + else: + zero_bytes(target, tail) diff --git a/research/p104-k7-retimed-binary/five_exchange.py b/research/p104-k7-retimed-binary/five_exchange.py new file mode 100644 index 0000000000..dbbba0ba77 --- /dev/null +++ b/research/p104-k7-retimed-binary/five_exchange.py @@ -0,0 +1,160 @@ +"""Run an ordinary projective line with one direct child or at most five per low.""" + +from functools import lru_cache, partial +from math import prod + +from growing_binary import pipe +from module_atoms import lower_tape, pair_shape + + +def corner_exchanges(u, v, pivot): + """Choose the shortest corner-exposure itinerary from the common low.""" + last = len(u) - 1 + first_unit, last_unit = bool(u[0] % 3), bool(v[-1] % 3) + if first_unit and last_unit: + return () + if last_unit: + for i in range(last): + if u[i] % 3: + return ((0, i),) + if first_unit: + for i in range(1, last + 1): + if v[i] % 3: + return ((i, last),) + if u[last] % 3 and v[0] % 3: + return ((0, last),) + if pivot == 0: + return ((0, last), (0, 0)) + if pivot == last: + return ((0, last), (last, last)) + return ((0, pivot), (pivot, last)) + + +def direct_line(core, source, target, frame, f, unused, older, gap, suffix, weight): + """Move the supplied native basis to coordinates and restore it after one call.""" + from direct_body import direct_route + from factored_frames import inverse_word + + (axis,) = frame.mask + head = core.atom ** (axis * f) + middle = core.atom ** ((core.n - 1) * f) * gap + tail = core.atom ** ((core.n - axis - 1) * f) * suffix + volume = unused * older * core.atom ** (2 * core.n * f) * gap * suffix + + def coordinate_weight(row, j): + return weight(row // head, axis * f + j) + + def move(word): + return partial(direct_route, core, word=word, f=f, unused=unused, older=older, + gap=gap, suffix=suffix, weight=weight) + + def schedule(): + if frame.word: + yield move(frame.word) + yield partial(core.weighted, atoms=f, available=unused, older=older * head, + gap=middle, suffix=tail, weight=coordinate_weight) + if frame.word: + yield move(inverse_word(frame.word)) + + with core.storage() as arena: + pipe(arena, "direct-coordinate", source, target, volume, schedule()) + + +def same_order_line(core, source, target, *, pivot, factors, f, unused, + heights, older, gap, suffix, weight): + """Execute and restore one full low packet, including all its high lifts.""" + n, atom, modulus = core.n, core.atom, core.modulus + rows = heights * older + dims = [unused, rows] + [atom] * (n * f) + [gap] + [atom] * (n * f) + last = 2 * n - 1 + + @lru_cache(maxsize=1) + def line(high): + return factors(high) + + pairs = corner_exchanges(*line(0), pivot) + origins = {} + for left, right in pairs: + right += n + origins[left], origins[right] = origins.get(right, right), origins.get(left, left) + + def value(position, dual, j, old, high): + """Read D times the permuted primal, or D inverse times the permuted dual.""" + origin = origins.get(position, position) + primal, covector = line(high) + vector = covector if dual else primal + entry = vector[origin] if origin < n else -vector[origin - n] + if position < n: + factor = weight(old, position * f + j) + entry *= pow(factor, -1, modulus) if dual else factor + return entry % modulus + + def coefficient(src, dest, j, old, high): + if src == 0: + first_inverse = pow(value(0, False, j, old, high), -1, modulus) + if dest == last: + end_inverse = pow(value(last, True, j, old, high), -1, modulus) + return (end_inverse - value(last, False, j, old, high)) * first_inverse % modulus + return -value(dest, False, j, old, high) * first_inverse % modulus + end_inverse = pow(value(last, True, j, old, high), -1, modulus) + return value(src, True, j, old, high) * end_inverse % modulus + + def child(left, right, central): + start = left * f + end = (n + right) * f + front = atom**start + + def child_weight(row, j): + high, old = divmod(row // front, older) + if central: + return -value(0, False, j, old, high) * value(last, True, j, old, high) % modulus + return weight(old, left * f + j) + + return partial( + core.weighted, atoms=f, available=unused, older=rows * front, + gap=gap * atom ** (end - start - f), suffix=suffix * atom ** (2 * n * f - end - f), + weight=child_weight, + ) + + def shear(src, dest, j, undo): + x = (2 if src < n else 3) + src * f + j + y = (2 if dest < n else 3) + dest * f + j + visible = prod(dims[2:x]) + + def coefficients(): + for _ in range(unused): + for high in range(heights): + for old in range(older): + scalar = coefficient(src, dest, j, old, high) + yield visible, -scalar if undo else scalar + + prefix, middle, tail = pair_shape(dims, x, y, suffix) + return partial(lower_tape, layout=core.layout, prefix=prefix, gap=middle, + suffix_bytes=tail, runs=coefficients) + + def sweeps(undo): + middle = range(last - 1, 0, -1) if undo else range(1, last) + columns = range(f - 1, -1, -1) if undo else range(f) + if undo: + for j in columns: + yield shear(0, last, j, True) + for tail in ((True, False) if undo else (False, True)): + for i in middle: + src, dest = (i, last) if tail else (0, i) + for j in columns: + yield shear(src, dest, j, undo) + if not undo: + for j in columns: + yield shear(0, last, j, False) + + def schedule(): + for left, right in pairs: + yield child(left, right, False) + yield from sweeps(False) + yield child(0, n - 1, True) + yield from sweeps(True) + for left, right in reversed(pairs): + yield child(left, right, False) + + with core.storage() as arena: + pipe(arena, "exposed-leaf", source, target, prod(dims) * suffix, schedule()) diff --git a/research/p104-k7-retimed-binary/installations.py b/research/p104-k7-retimed-binary/installations.py new file mode 100644 index 0000000000..43dd409281 --- /dev/null +++ b/research/p104-k7-retimed-binary/installations.py @@ -0,0 +1,39 @@ +"""Fixed, complete installations of the retimed binary and numerical suppliers.""" + +from dataclasses import dataclass +from fractions import Fraction as Q + +BINARY_C = Q(4391986206293, 2**50) +GAUSSIAN_C = Q(2092819, 2**29) + + +@dataclass(frozen=True) +class Profile: + rank_logs: tuple + complex_log: int + eta: Q + kappa: Q + positive_stop_denominator: int + + @property + def ordinary(self): + return self.kappa + Q(5, self.positive_stop_denominator) + + +SELECTED_PRICE = Profile((5610,), 1024, Q(97, 25000), Q(".00363005817"), 10**14) +SMALL = Profile((18400,), 1600, Q(97, 25000), Q(".0038"), 10**14) +COMPACT = Profile((9100, 144000), 8500, Q(97, 25000), Q(".00387992803556"), 10**14) +CONSERVATIVE_36K = Profile((60_000, 960_000), 36_000, Q(39, 10000), Q(".003893947"), 10**14) +COMPACT_1M = Profile((60_000, 960_000), 1_000_000, Q(39, 10000), Q(".003898026"), 10**17) +EXTENDED_10M = Profile((60_000, 960_000), 10_000_000, Q(39, 10000), Q(".003898163"), 10**18) +EXTENDED = Profile((60_000, 960_000), 20_000_000, Q(39, 10000), Q(".003898171"), 10**18) + +PROFILES = { + "selected-price": SELECTED_PRICE, + "small": SMALL, + "compact": COMPACT, + "conservative-36k": CONSERVATIVE_36K, + "compact-1m": COMPACT_1M, + "extended-10m": EXTENDED_10M, + "extended": EXTENDED, +} diff --git a/research/p104-k7-retimed-binary/low_inventory_scan.py b/research/p104-k7-retimed-binary/low_inventory_scan.py new file mode 100644 index 0000000000..69c1791179 --- /dev/null +++ b/research/p104-k7-retimed-binary/low_inventory_scan.py @@ -0,0 +1,79 @@ +"""Count corner schedules on every actual low quotient for ranks two and three.""" +from collections import Counter +from fractions import Fraction +from itertools import product +from math import prod +from pathlib import Path +import sys + + +def inverse(matrix, n): + a = [list(matrix[i*n:(i+1)*n]) + [int(i==j) for j in range(n)] for i in range(n)] + for j in range(n): + k = next(k for k in range(j,n) if a[k][j]) + a[j],a[k] = a[k],a[j] + q = pow(a[j][j],-1,3) + a[j] = [q*x%3 for x in a[j]] + for k in range(n): + if k==j: continue + q=a[k][j] + a[k]=[(x-q*y)%3 for x,y in zip(a[k],a[j])] + return tuple(x for row in a for x in row[n:]) + + +def apply(matrix, vec): + n = len(vec) + return tuple(sum(a*v for a,v in zip(matrix[k*n:(k+1)*n],vec))%3 for k in range(n)) + + +def run(runtime): + sys.path.insert(0,str(Path(runtime).resolve())) + from upstream import install + install() + from quotient_route import canonical_lows + from five_exchange import corner_exchanges + for n in (2,3,4): + vectors=tuple(product(range(3),repeat=n)) + pairs=[(u,v) for u in vectors for v in vectors if sum(x*y for x,y in zip(u,v))%3==1] + if n==4: pairs=[pairs[k] for k in (0,1,53,len(pairs)-1)] + lows=[] + for matrix in canonical_lows(n): + inv=inverse(matrix,n) + inv_t=tuple(inv[j*n+i] for i in range(n) for j in range(n)) + lows.append((matrix,inv_t)) + assert len(lows)==prod(3**j-1 for j in range(1,n+1)) + worst=0 + best=5 + for u,v in pairs: + stats=Counter() + for g,gt in lows: + x,y=apply(g,u),apply(gt,v) + piv=next(i for i in range(n) if x[i] and y[i]) + swaps=corner_exchanges(x,y,piv) + z=list(x)+[(-a)%3 for a in x] + w=list(y)+[(-a)%3 for a in y] + for i,j in swaps: + j+=n + z[i],z[j]=z[j],z[i] + w[i],w[j]=w[j],w[i] + assert z[0] and w[-1] + stats["child"] += 1 + 2*len(swaps) + stats["A"]+=bool(x[0]) + stats["B"]+=bool(y[-1]) + stats["both"]+=bool(x[0] and y[-1]) + stats["last_basis"]+=sum(c!=0 for c in x)==1 and bool(x[-1]) + stats["first_dual_basis"]+=sum(c!=0 for c in y)==1 and bool(y[0]) + Q=len(lows) + a=Fraction(2*3**(n-1),3**n-1) + assert stats["A"]==stats["B"]==a*Q and stats["both"]==Fraction(2,3)*a*Q + assert stats["last_basis"]==stats["first_dual_basis"]==Fraction(2*Q,3**n-1) + mean=Fraction(stats["child"],Q) + assert mean<=Fraction(7,3)+Fraction(16,3*(3**n-1)) + worst=max(worst,mean) + best=min(best,mean) + print("rank",n,"low rows",len(lows),"native (u,v) pairs",len(pairs),"mean range",best,worst,flush=True) + + +if __name__ == "__main__": + from upstream import HERE + run(HERE) diff --git a/research/p104-k7-retimed-binary/machine.patch b/research/p104-k7-retimed-binary/machine.patch new file mode 100644 index 0000000000..16b6205d1f --- /dev/null +++ b/research/p104-k7-retimed-binary/machine.patch @@ -0,0 +1,320 @@ +--- a/binary_receiver.py ++++ b/binary_receiver.py +@@ -1,34 +1,14 @@ + """Run the funded binary graph in the public bank and return every physical loan.""" + +-from functools import cache +- +-from calibration import COMPACT +-from compiler_cut import SourceRule +-from epoch_tape import Compiler, run ++from installations import COMPACT ++from raw_binary_stage import binary_recipe, binary_word, run + from module_atoms import chart_width, total_width + from periodic import Job + from quotient_route import free_count, low_count + from raw_binary import job_frame + from receiver import OwnerBanks, Receiver as PhysicalReceiver + from streaming_routes import cold_swap_tape, erase, type_route +-from strong_binary import StrongBinarySource, native_word +- +- +-class NativeRule(SourceRule): +- def __init__(self, power): +- word = native_word(power) +- self.word = word +- self.ambient = word.ambient**word.power +- +- +-@cache +-def source_rule(power): +- return NativeRule(power) +- +- +-@cache +-def source_planner(power, floor): +- return Compiler(source_rule(power), floor) ++from strong_binary import StrongBinarySource + + + class Receiver(PhysicalReceiver): +@@ -44,9 +24,11 @@ + self.atom = 3 ** total_width(layout) + self.low = 1 if direct else low_count(dimension) + self.high = 1 if direct else 3 ** ((self.digits - 1) * free_count(dimension)) +- self.rule = source_rule(profile.power) +- self.planner = source_planner(profile.power, profile.floor) +- self.owners = self.planner(dimension).width ++ height = dimension.bit_length() - 1 ++ self.recipe = binary_recipe(height) if height >= 3000 else None ++ if self.recipe is not None and dimension != 1 << height: ++ raise ValueError("The retimed carrier needs a dyadic rank") ++ self.owners = self.recipe.width if self.recipe is not None else 1 + self.stock = self.owners * self.low * self.high + self.arena = self.last_storage = None + self.small = None +@@ -97,7 +79,7 @@ + banks.install(job.owner, out) + + def native(self, ports, columns): +- return core.rule.word.native(ports, columns, raw) ++ return binary_word().native(ports, columns, raw) + + def zero(self, exemplar): + return Job(banks.zero(), exemplar.axes) +@@ -105,7 +87,7 @@ + def retire_zero(self, job): + banks.retire(job.owner, require_zero=True) + +- run(self.rule, self.n, jobs, Machine(), planner=self.planner) ++ run(self.recipe, jobs, Machine()) + for job in jobs: + banks.read(job.owner, result) + banks.retire(job.owner) +--- a/ordinary_carrier.py ++++ b/ordinary_carrier.py +@@ -1,25 +1,29 @@ + """Route both signed-product shuttles through the two installed binary carriers.""" + ++from contextlib import closing + from functools import partial + + from upstream import install + + install() + from binary_receiver import Receiver +-from calibration import COMPACT ++from installations import COMPACT + from module_atoms import ceil_root +-from ordinary import least_power, rectangle ++from ordinary import least_power + from staged_carriers import admitted_stage, entrance_logs +-from streaming_routes import cold_swap_tape, copy_bytes, work_tapes, erase ++from fiscal_scans import rectangle_slab, slab_indices, transfer ++from streaming_routes import cold_swap_tape, work_tapes, erase + from triangular_ordinary import root_body + + + def ternary(source, target, digits, prefix, gap, suffix, *, maximum, profile): + stage = admitted_stage(digits, maximum, profile.rank_logs) +- if not stage: +- cold_swap_tape(source, target, digits, prefix, gap, suffix) ++ if stage: ++ stage_body(source, target, digits, prefix, gap, suffix, stage, profile) + return +- stage_body(source, target, digits, prefix, gap, suffix, stage, profile) ++ with closing(slab_indices(prefix)) as slabs: ++ for _ in slabs: ++ cold_swap_tape(source, target, digits, 1, gap, suffix) + + + def stage_body(source, target, digits, prefix, gap, suffix, stage, profile): +@@ -36,7 +40,9 @@ + previous = partial(ternary, maximum=stage - 1, profile=profile) + direct = (digits + width - 1) // width <= rank**8 + backend = Receiver(rank, layout, previous, direct=direct, profile=profile) +- root_body(source, target, digits, prefix, gap, suffix, backend) ++ with closing(slab_indices(prefix)) as slabs: ++ for _ in slabs: ++ root_body(source, target, digits, 1, gap, suffix, backend) + + + def ordinary_swap(source, target, bits, prefix, gap, suffix, *, profile=COMPACT): +@@ -44,7 +50,7 @@ + if bits < 0 or min(prefix, gap, suffix) < 1: + raise ValueError("Use a nonnegative width and positive field dimensions") + if not bits: +- copy_bytes(source, target, prefix * gap * suffix) ++ transfer(source, target, prefix * gap * suffix) + return + extent = 1 << bits + digits = least_power(3, extent) +@@ -52,13 +58,17 @@ + if not admitted_stage(digits, stages, rank_logs): + from compact_crt import binary_swap + +- binary_swap(source, target, bits, prefix, gap, suffix) ++ with closing(slab_indices(prefix)) as slabs: ++ for _ in slabs: ++ binary_swap(source, target, bits, 1, gap, suffix) + return + padded = 3**digits +- with work_tapes(2) as (opened, completed): +- rectangle(source, opened, extent, padded, prefix, gap, suffix) +- opened.seek(0) +- ternary(opened, completed, digits, prefix, gap, suffix, maximum=stages, profile=profile) +- erase(opened) +- completed.seek(0) +- rectangle(completed, target, extent, padded, prefix, gap, suffix, restrict=True) ++ with work_tapes(2) as (opened, completed), closing(slab_indices(prefix)) as slabs: ++ for _ in slabs: ++ rectangle_slab(source, opened, extent, padded, gap, suffix) ++ opened.seek(0) ++ ternary(opened, completed, digits, 1, gap, suffix, maximum=stages, profile=profile) ++ erase(opened) ++ completed.seek(0) ++ rectangle_slab(completed, target, extent, padded, gap, suffix, restrict=True) ++ erase(completed) +--- a/band_product.py ++++ b/band_product.py +@@ -7,43 +7,29 @@ + from upstream import HERE, install + + install() +-from band_positive import Positive +-from binary_io import magnitude_bits, magnitude_limbs +-from calibration import COMPACT, PROFILES ++from retimed_supplier import Positive ++from binary_io import magnitude_limbs ++from fiscal_scans import magnitude_bits ++from installations import COMPACT, PROFILES + from inputs.triangular.multiplier import Product as PackProduct, precision + from linear_geometry import parameters, square_sides + from ordinary_carrier import ordinary_swap + from positive_dispatch import h_pack + from product_path import scalar_product +-from raw48 import ComplexRaw + + + @cache + def production_supplier(rank_log, stop_denominator): +- from strong_complex import artifacts, word +- +- _, _, _, source = install() +- data = HERE / "inputs" +- atlas = artifacts(source / "research/grade14-native-realization", data) +- native = word(atlas.graph, atlas.layout) +- +- def physical(fields, columns, **kw): +- return ComplexRaw(atlas, fields, columns, **kw) +- +- return Positive(native, physical, 1 << rank_log, denominator=stop_denominator) ++ return Positive(rank_log, stop_denominator) + + + def prepare_native(profile=COMPACT): +- """Generate the fixed native programs. The tape caller can also install each at first use.""" +- from binary_receiver import source_planner ++ """Generate the raw labels, both signed circuits, the atlas and the two grade couplings.""" ++ from raw_binary_stage import binary_recipe + +- binary = source_planner(profile.power, profile.floor) +- streams = [binary.image(1 << log_rank) for log_rank in profile.rank_logs] ++ binary = tuple(binary_recipe(height) for height in profile.rank_logs) + positive = production_supplier(profile.complex_log, profile.positive_stop_denominator) +- if positive.owners <= 1: +- raise ArithmeticError("The numerical carrier needs independent rows") +- streams.append(positive.planner.image(positive.carrier)) +- return tuple(streams) ++ return (*binary, positive.recipe) + + + class Product(PackProduct): +--- a/strong_binary.py ++++ b/strong_binary.py +@@ -52,19 +52,46 @@ + if self.ambient * columns > dimension or columns < 1: + raise ValueError("The complete source ambient and its columns must fit the frame") + +- for name in ( +- "raw_projector", +- "difference", +- "joint", +- "target", +- "head", +- "idle", +- "port_stage", +- ): +- setattr(self, name, cache(getattr(self, name))) ++ ++ def difference(self, first, last): ++ frames = self.graph["frames"] ++ if frames[str(first)]["dim"] > frames[str(last)]["dim"]: ++ first, last = last, first ++ word, rank = fixed_binary_charts()[0][first, last] ++ return self.extend(word, range(rank)) ++ ++ def joint(self, port): ++ return fixed_binary_charts()[1][port] + + + @cache ++def fixed_binary_charts(): ++ """Compile the eight-coordinate forms once. Lift them only on a real field.""" ++ from ternary_frames import frame_at_three, projector, transpose ++ from vendor.cover import row_program ++ ++ data, root = graph(), caller() ++ frames, starts, ends = data["frames"], data["start"], data["final"] ++ projectors = {int(i): projector(transpose(f["B"] + f["A"]), f["dim"]) ++ for i, f in frames.items()} ++ ports = root["ports"] ++ pairs = {tuple(row[2:]) for row in data["program"] if row[0] == "MOVE"} ++ pairs.update(zip(starts[2*ports:], ends[2*ports:], strict=True)) ++ differences = {} ++ for i, j in sorted(pairs): ++ if frames[str(i)]["dim"] > frames[str(j)]["dim"]: ++ i, j = j, i ++ if (i, j) in differences: ++ continue ++ delta = [[y-x for x,y in zip(left,right,strict=True)] ++ for left,right in zip(projectors[i],projectors[j],strict=True)] ++ basis, rank = frame_at_three(delta) ++ differences[i,j] = tuple(row_program(basis,3)),rank ++ joint = tuple(tuple(row_program(transpose(frames[str(starts[i])]["B"] ++ + frames[str(ends[ports+i])]["B"]),3)) for i in range(ports)) ++ return differences, joint ++ ++ + def active_catalogue(dimension, columns): + return ActiveCatalogue(dimension, columns) + +--- a/ordinary_carrier.py ++++ b/ordinary_carrier.py +@@ -10,14 +10,24 @@ + from installations import COMPACT + from module_atoms import ceil_root + from ordinary import least_power +-from staged_carriers import admitted_stage, entrance_logs ++from staged_carriers import entrance_logs + from fiscal_scans import rectangle_slab, slab_indices, transfer + from streaming_routes import cold_swap_tape, work_tapes, erase + from triangular_ordinary import root_body + + ++def stage_for_width_log(available, maximum, rank_logs): ++ """Choose a receiver from the exact scanned width logarithm.""" ++ if available < 0 or not 0 <= maximum <= len(rank_logs): ++ raise ValueError("Use a positive trit width and a supported stage") ++ cuts = entrance_logs(rank_logs) ++ return next((i for i in range(maximum, 0, -1) if available >= cuts[i-1]), 0) ++ ++ + def ternary(source, target, digits, prefix, gap, suffix, *, maximum, profile): +- stage = admitted_stage(digits, maximum, profile.rank_logs) ++ if digits < 1: ++ raise ValueError("Use a positive trit width and a supported stage") ++ stage = stage_for_width_log(digits.bit_length()-1, maximum, profile.rank_logs) + if stage: + stage_body(source, target, digits, prefix, gap, suffix, stage, profile) + return +@@ -55,7 +65,7 @@ + extent = 1 << bits + digits = least_power(3, extent) + stages = len(rank_logs) +- if not admitted_stage(digits, stages, rank_logs): ++ if not stage_for_width_log(digits.bit_length()-1, stages, rank_logs): + from compact_crt import binary_swap + + with closing(slab_indices(prefix)) as slabs: +--- a/check_product.py ++++ b/check_product.py +@@ -97,7 +97,7 @@ + restored.seek(0) + rectangle(restored, dst, 2, 9, prefix, gap, suffix, restrict=True) + +- machine = Product((3, 5), 8, 136, exchange) ++ machine = Product((3, 5), 8, 136, exchange, profile=profile) + row = one(machine, -741503, 466013) + assert calls["shuttles"] == 138 and row["H_calls"] == 157248 + return {**row, **calls, "rank": core.n, "stage_body_records": 81**2} diff --git a/research/p104-k7-retimed-binary/normal_five.py b/research/p104-k7-retimed-binary/normal_five.py new file mode 100644 index 0000000000..f1f494cfa1 --- /dev/null +++ b/research/p104-k7-retimed-binary/normal_five.py @@ -0,0 +1,61 @@ +"""Use both public covered-line paths and independently decode every arbitrary record.""" + +from fractions import Fraction +from io import BytesIO +from itertools import product +from math import prod +from pathlib import Path +import sys + + +def main(package): + sys.path.insert(0,str(package)) + from upstream import install + install() + from binary_receiver import Receiver + from direct_body import same_order_line as direct_impl + from factored_frames import Frame + from five_exchange import same_order_line as five, direct_line as direct_five + from direct_body import direct_line as direct_bound + from quotient_route import canonical_lows + from receiver import same_order_line as covered_impl + from check_module_atoms import payload,expected_packet + from ternary_frames import identity + assert direct_impl is covered_impl + assert direct_impl is five + assert direct_bound is direct_five + class Counted(Receiver): + def weighted(self,*args,**kw): + self.paid+=1 + return super().weighted(*args,**kw) + n=2;f=1;unused=1;older=2;gap=2;suffix=4 + frame=Frame(n,(("add",0,1,Fraction(1)),("scale",1,Fraction(-1))), (1,)) + def weight(old,j): + return (1,2)[(old+j)%2] + for direct in (True,False): + core=Counted(n,(1,1,0,0),direct=direct) + core.paid=0 + lows=(tuple(x for row in identity(n) for x in row),) if direct else tuple(canonical_lows(n)) + maps=[] + for flat in lows: + low=tuple(flat[i:i+n] for i in range(0,n*n,n)) + u,v=frame.covered_line(low,1) + maps.append((u,v)) + dims=(len(lows),older,3,3,gap,3,3) + raw=payload(prod(dims)); source=BytesIO(raw); target=BytesIO() + with core.storage(): + core.serve_line(source,target,frame,f,unused,older,gap,suffix,weight) + def oracle(index,old,h0,h1,g,t0,t1): + u,v=maps[index];a,b=weight(old,0),weight(old,1) + d=(v[0]*(t0-a*h0)+v[1]*(t1-b*h1))%3 + return (index,old,(h0+a*u[0]*d)%3,(h1+b*u[1]*d)%3,g, + (t0-u[0]*d)%3,(t1-u[1]*d)%3) + assert target.getvalue()==expected_packet(raw,dims,oracle) + assert core.paid == (1 if direct else 32) + print("direct" if direct else "quotient","lows",len(lows),"true children",core.paid, + "records",prod(dims),"physical statistics",core.last_storage) + + +if __name__ == "__main__": + from upstream import HERE + main(HERE) diff --git a/research/p104-k7-retimed-binary/ordinary_clock.py b/research/p104-k7-retimed-binary/ordinary_clock.py new file mode 100644 index 0000000000..87c72664af --- /dev/null +++ b/research/p104-k7-retimed-binary/ordinary_clock.py @@ -0,0 +1,49 @@ +"""Check integer envelopes in the ordinary fixed-tape clock proof.""" + +from fractions import Fraction + +RANKS = { + '8030-compact': (260_000, 1_600_000), + '8030-high': (25_000_000, 160_000_000, 1_000_000_000, 6_000_000_000, 36_000_000_000, 224_000_000_000), + '8030-match': tuple(7*x for x in (25_000_000, 160_000_000, 1_000_000_000, 6_000_000_000, 36_000_000_000, 224_000_000_000)), + '8035-near': (6_835_937_536, 109_375_000_000, 1_750_000_000_000, 28_000_000_000_000, 448_000_000_000_000, 7_168_000_000_000_000), + '8035-fixed': (106_811_524, 1_708_984_375, 27_343_750_000, 437_500_000_000, 7_000_000_000_000, 112_000_000_000_000), +} + + +def polynomial_to_fibre_bound(): + # X=2^16 N^4 (D+1)(w+1)^252, D+1<=256(w+1). + # w+1<=2^259*u^258; u^a/3^(u-1)<=3*a^a. + degree = 20 * 253 + a = 258 * degree + return 20 * (16 + 8) + 259 * degree + 2 + a * (a - 1).bit_length() + + +def first_stage_bound(eta): + assert eta >= Fraction(97,25000) and 2*eta > Fraction(1,250) + # u >= ceil(e^eta)/2, hence w+1 <= 9u^2. Bound u^a/3^(u-1) by 3a^a. + degree = 20*253 + a = 2*degree + return 20*(16+8)+4*degree+2+a*(a-1).bit_length() + + +def full_log2_B(ranks): + # B0=2^100, B_i<=J_i^14(1+Bprev); root binary rectangle and digit rounding. + return 40 + 16 * 1024 * sum(ranks) + + +def main(): + extra = polynomial_to_fibre_bound() + assert Fraction(9*16, 15*32) == Fraction(3, 10) + assert Fraction(1,1) / (1-Fraction(3,10)) == Fraction(10,7) + assert all((1+y)**5 <= 2**14 * max(1, 2**(y-1)) for y in range(1, 11)) + assert all((z+1)**5 <= 2**10*3**z for z in range(1, 8)) + assert all((e+1)**5 <= 32*4**e for e in range(1, 8)) + assert all(extra + 80*min(H) < 1024*min(H) for H in RANKS.values()) + print('log2 fixed variable-amortization factor <=', extra, 'plus 80 H') + for name, H in RANKS.items(): + print(name, 'sum H', sum(H), 'log2 B <=', full_log2_B(H)) + + +if __name__ == '__main__': + main() diff --git a/research/p104-k7-retimed-binary/outer_budget.py b/research/p104-k7-retimed-binary/outer_budget.py new file mode 100644 index 0000000000..35dd5cf836 --- /dev/null +++ b/research/p104-k7-retimed-binary/outer_budget.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Directed rational outer inequalities for the inherited parameterized signed caller. + +The 54 strict and four functional expressions follow the P104 dual-supplier +gate at 4f7c67ae387cc91580f469aeda4d508b372b9ec1. The positive and ordinary +caps come independently from the actual single-band profiles. +""" +from fractions import Fraction as Q + + +def margins(k,g,ordinary,positive): + a,b,q=k+4*g,k+5*g,k+3*g + ep,be=1-g,1-3*g + r0=g/10 + sigma,tau=1-b,1-a + internal=tau+(1-g)*max(sigma-tau,0) + leaf=sigma+g*(1-sigma) + lam=1-(q+a)/2 + xi=ep*(1+q)-Q(3,32)+g + key=be+1-ep + powers=[ep*q,a,1-ep+q*be,1-ep+a*be,1-ep+be,Q(3,32)+xi-ep, + xi+Q(1,2)-ep,ep,1-(ep+be+48-128+2)] + strict=[ordinary-a,b-a,q,b-q,a-q,g,1-g,(1-g)*b-a,1-internal-q,1-leaf-q, + lam-tau,lam-sigma,lam-internal,1-q-lam,1-q-leaf,ep,1-ep,xi-Q(1,2),ep-xi, + be,ep-be,1-be,1-(2*xi-2)-r0-be,1-(2*xi-2)-be,1-ep-r0,1-ep,r0,1-key, + 1-be-2*(1-ep),128-48-be,g,ep-a,Q(1,32)-b,Q(2**45-7**16),Q(2),2-xi, + Q(5),1-be,1-be,1-ep,powers[2]-powers[0],g,k-Q('.001730970419199163702738'), + 1-ep,Q(11,2)]+[x-k for x in powers] + functional=[1-be,be*(1-Q(3,1000)),128-48-ep-be-1,be*(1-Q(1,250))] + assert len(strict)==54 and len(functional)==4 + return strict,functional,positive-b + + +def qualify(k,g,ordinary,positive): + strict,functional,paid=margins(k,g,ordinary,positive) + if min(*strict,*functional,paid)<=0: + raise ArithmeticError('signed outer budget has an unfunded inequality') + return {'strict':len(strict),'functional':len(functional), + 'smallest_margin':str(min(*strict,*functional,paid)), + 'ordinary_margin':str(ordinary-k-4*g),'positive_margin':str(paid)} diff --git a/research/p104-k7-retimed-binary/outer_clock.py b/research/p104-k7-retimed-binary/outer_clock.py new file mode 100644 index 0000000000..3c4fa183a0 --- /dev/null +++ b/research/p104-k7-retimed-binary/outer_clock.py @@ -0,0 +1,114 @@ +"""Check the finite endpoints and the dyadic induction comparisons for the outer clock.""" + +from fractions import Fraction +from itertools import chain + + +def width_cap(s): + if s < 512: + return 128 * s * s + return 1024 * s + 2560 + + +def private_log(s): + # X=2^64(t+2)(P+2), P<2^20 p, d<=p<2^s. + return s + 1024 * (width_cap(s) + s + 88) + + +def controls_log(s): + # Dense Beneš, inverse modulo the true side, restored left child, and all copies. + return 60 + 16 * (s + 1) + 10 * (width_cap(s) + 1) + + +def exact_shape_check(package): + from pathlib import Path + import sys + + sys.path.insert(0, str(Path(package).resolve())) + import band_product + from linear_geometry import parameters, square_sides + + first = (18508 << 18493) + 1 + assert parameters(first - 1) is None + shape = parameters(first) + assert shape.count == 1 + side, = square_sides(shape) + bits = next(shape.axes()) + assert side.bit_length() == bits + actual_precision = band_product.precision(shape.public, shape.extent_bits, shape.count) + # The production fourier_axis function calls [Fraction(1)] * r. This reproduces + # its host list limit before any large allocation. It is not a Turing lower bound. + try: + [None] * side + except OverflowError as exc: + host = type(exc).__name__ + else: + raise AssertionError("The first side unexpectedly fit a host list") + + # The two-endpoint assertions bind all advertised finite constants to the producer. + return {"first_b": shape.public // 6, "first_L": bits, "first_P": actual_precision, + "first_side_bit_length": side.bit_length(), "host_list": host} + + +def financial_checks(): + # At s>=32 the private setup fits in n. Compare one term with an exponential + # and use (s+2)^2<2(s+1)^2 on the tail. The linear cap only decreases at s=512. + # p=6b, s=ceil(log2(6b+2)), and n>2^(b-1) when n>1. + def prefix_log(s): + lower = max(0, ((1 << (s-1))-2)//6-1) + return private_log(s)-lower + prefix = max(prefix_log(s) for s in range(1,32)) + assert prefix < 84_500_000-1000 and prefix == prefix_log(27) + assert 32 + 1024 * (128 * 32**2 + 32 + 88) < 1 << (32 - 4) + assert max(controls_log(s) for s in range(1, 64)) < 1 << 23 + assert 128 * 63**2 == 508_032 + for s in chain(range(32, 1025), (4096, 8192)): + assert private_log(s) < 1 << (s - 4) + if s >= 64: + # Use p>=2^(s-1)-1 and L>=p/12. The polynomial has its + # maximum relative to the exponential at the first endpoint. + p_min = (1 << (s - 1)) - 1 + L_min = p_min // 12 + G_max = 64 * (width_cap(s) + s) + assert L_min >= 10100 * G_max + assert L_min // (2 * width_cap(s)) >= 51_200 + H_min = L_min // 101 + assert controls_log(s) + 16 < H_min + assert private_log(s) + 16 < H_min + # Scalar fallback is impossible at b >= 2^15. On 2^j<=b<2^(j+1), + # ceil(log2(p+2))<=j+4; L >= 2^j-j-1. Growth closes all later j. + for j in range(15, 128): + assert (1 << j) - j - 1 >= 64 * (j + 4)**2 + assert 2 * (j + 4)**2 >= (j + 5)**2 + for s in (512, 1023, 1024, 4096): + ell = width_cap(s) + h_mixing_class = 80_000 * (ell + 2)**6 + 2048 * s + 2 + pack_pass = 40_000 * (ell + 2)**6 + 4 + assert 3 * h_mixing_class * pack_pass < (1 << 168) * (s + 1)**12 + # Each switch has at most 20 whole swaps, and each tail has two. + K = 64 * 64 * (ell + s) + crt_dispatch = 3 * s * 2 * ell * (1 << 18) * (10 + 32 * K + 4 * K*K) + assert crt_dispatch < (1 << 90) * (s + 1)**4 + g = Fraction(1, 10**17) + assert (Fraction(128, 1) / g)**16 < 1 << 1024 + assert 17**16 * 10**(21*16) < 1 << 1182 + assert 400 + 1182 + 9 + 2 < 1600 + return {"small_stop_tail_factor_log2":1591, "private_prefix_log2": max(private_log(s) for s in range(1, 32)), + "controls_prefix_log2": max(controls_log(s) for s in range(1, 64)), + "private_prefix_after_input_log2": prefix, + "early_log2_C_bound": 84_500_000, + "tail_log2_fixed_factor_including_b_to_n": 1434, + "tail_unit": "(1 + B + Z) * n * (1 + log2(n))^(1-kappa)"} + + +if __name__ == "__main__": + from argparse import ArgumentParser + import json + + command = ArgumentParser(description=__doc__) + command.add_argument("package", nargs="?") + args = command.parse_args() + report = financial_checks() + if args.package: + report.update(exact_shape_check(args.package)) + print(json.dumps(report, sort_keys=True)) diff --git a/research/p104-k7-retimed-binary/predecessor/LAST-TICK-RECEIPT.json b/research/p104-k7-retimed-binary/predecessor/LAST-TICK-RECEIPT.json new file mode 100644 index 0000000000..68e300af92 --- /dev/null +++ b/research/p104-k7-retimed-binary/predecessor/LAST-TICK-RECEIPT.json @@ -0,0 +1,154 @@ +{ + "G_plus_1_upper": 7739534883720930232561, + "band_floor": 1180591620717411303424, + "bit_debit": 31, + "complete_requirements": { + "all_size_margin_lower_at_entrance": 528024503534136304443898, + "binary_entrance_logs": [ + 1004016064257028112515, + 5004016064257028112579, + 21004016064257028112643, + 85004016064257028112707, + 341004016064257028112771, + 1365004016064257028112835 + ], + "binary_rank_logs": [ + 1000000000000000000000, + 4000000000000000000000, + 16000000000000000000000, + 64000000000000000000000, + 256000000000000000000000, + 1024000000000000000000000 + ], + "complex_rank_log": 1600000, + "component_exponent": "39/10000", + "full_binary_debit": 31, + "full_positive_debit": 10, + "initial_s": 1365004016064257029713504, + "kappa": "778023057318889/200000000000000000", + "linear_geometry": { + "actual_dense_root_entry_log2": 1650586719047173699865498966, + "first_extent_bits_minus_b": -1365004016064257029713499, + "largest_axis_width": 825293359523586849932749483, + "last_extent_bits_minus_b": -1365004016064257029713498, + "log2_axis_count": 1365004016064257029713411, + "minimum_width": 698882056224899599213315328, + "private_clock_log2_upper": 846499529268618797786591880800, + "public_offset_above_2_to_A": 4 + }, + "log2_all_fixed_setup_upper": 1048576000000000000000000003, + "log2_dominant_J": 1048576000000000000000000000, + "log2_rank_part_of_recurring_envelope": 104857600000000000000000000000, + "log2_sufficient_public_precision": 1365004016064257029713503, + "native_depth_bound_at_entrance": 853127510040162488, + "native_volume_log2_upper": 65536, + "ordinary_rate": "778023057318889001/200000000000000000000", + "positive_context_cost_bitlength_upper": 58, + "prior_geometry_at_same_n": { + "actual_dense_root_entry_log2": 249429612771140764706762211450245635354612487334572, + "first_extent_bits_minus_b": -1365004016064257029713499, + "largest_axis_width": 124714806385570382353381105725122817677306243667286, + "last_extent_bits_minus_b": -1365004016064257029713498, + "log2_axis_count": 1365004016064257029713334, + "minimum_width": 119247101687779229647005282862830728700692477313024, + "private_clock_log2_upper": 1953744514052574898536537417045520956220903926031974400, + "public_offset_above_2_to_A": 4 + }, + "rate_ticks_e18": [ + 3874554825448082, + 3890053044749874, + 3890115037627081, + 3890115285598590, + 3890115286590476, + 3890115286594445 + ], + "raw_structural_nodes_log2_upper": 12973, + "stripe_excess_log_at_entrance": 111821128995984177955026, + "stripe_margin_at_entrance": 570680879036144336901724, + "uniform_payload_slope": "128000000000000273/1562500000000000000" + }, + "gap": "1/1000000000000000000000", + "host_py_ssize_max": 9223372036854775807, + "kappa": "778023057318889/200000000000000000", + "kappa_decimal": "0.003890115286594445", + "local_exponent": 53044, + "minimum_last_height_with_profile_debit": 166468119783642494505, + "native_q": 65536, + "native_slot_log_upper": 26038, + "numeric_debit": 10, + "ordinary": "778023057318889001/200000000000000000000", + "physical_execution_limit": "Production ranks exceed CPython shift size and available host storage; feasible controls only.", + "positive_paid_cap": "1274827/327680000", + "power": 430, + "power_430_toy_owner_control": { + "raw_calls": 430, + "returned_original_owner": true + }, + "raw_interval": [ + "1945057643297230564998471/500000000000000000000000000", + "3890115286594461129996943/1000000000000000000000000000" + ], + "signed": { + "functional": 4, + "ordinary_margin": "1/1000000000000000000000", + "positive_margin": "69594048298499/200000000000000000000", + "smallest_margin": "1/10000000000000000000000", + "strict": 54 + }, + "six_stage_upper_decimal": "0.003890115286594445189476955228", + "six_stage_upper_fraction": "972528821648611297369238807/250000000000000000000000000000", + "stages": [ + { + "height": 1000000000000000000000, + "limit": "139595549344916359020188522147497820907/36028797018963968000000000000000000000000", + "margin_floor_e24": 1245636, + "rate": "1937277412724041/500000000000000000", + "strict_margin": "44878791509438121820907/36028797018963968000000000000000000000000" + }, + { + "height": 4000000000000000000000, + "limit": "140153931542296025111072962766483931883/36028797018963968000000000000000000000000", + "margin_floor_e24": 1596793, + "rate": "1945026522374937/500000000000000000", + "strict_margin": "57530555784226451931883/36028797018963968000000000000000000000000" + }, + { + "height": 16000000000000000000000, + "limit": "140156165071085543933409156571843707627/36028797018963968000000000000000000000000", + "margin_floor_e24": 1770582, + "rate": "3890115037627081/1000000000000000000", + "strict_margin": "63791973396554435707627/36028797018963968000000000000000000000000" + }, + { + "height": 64000000000000000000000, + "limit": "140156174005200702035797759183262499563/36028797018963968000000000000000000000000", + "margin_floor_e24": 1600030, + "rate": "389011528559859/100000000000000000", + "strict_margin": "57647165237578142499563/36028797018963968000000000000000000000000" + }, + { + "height": 256000000000000000000000, + "limit": "140156174040937162705822778300990669547/36028797018963968000000000000000000000000", + "margin_floor_e24": 1636392, + "rate": "972528821647619/250000000000000000", + "strict_margin": "58957238162332222669547/36028797018963968000000000000000000000000" + }, + { + "height": 1024000000000000000000000, + "limit": "140156174041080108546521644696289592043/36028797018963968000000000000000000000000", + "margin_floor_e24": 175482, + "rate": "778023057318889001/200000000000000000000", + "strict_margin": "6322424775643709752043/36028797018963968000000000000000000000000" + } + ], + "surplus_floor_e21": 3906, + "trial": "1175715202810401744919/302231454903657293676544", + "upper_grid_rates": [ + "1937277412724041/500000000000000000", + "1945026522374937/500000000000000000", + "3890115037627081/1000000000000000000", + "389011528559859/100000000000000000", + "972528821647619/250000000000000000" + ], + "upper_scope": "given bit_c < RAW_RIGHT, 5 stages on 1e-18 grid and this price recurrence" +} diff --git a/research/p104-k7-retimed-binary/predecessor/OVERLAY.json b/research/p104-k7-retimed-binary/predecessor/OVERLAY.json new file mode 100644 index 0000000000..93fcd0e584 --- /dev/null +++ b/research/p104-k7-retimed-binary/predecessor/OVERLAY.json @@ -0,0 +1,96 @@ +{ + "band_product.py": { + "old_sha256": "7feb08718d511b45d0e9f927540115c9c1526f9b65ff3dadaef55b1ac8a2b19d", + "new_sha256": "b58c52fdb95499722618614b49a628fd8565d7a64173415961416039ed86aec6", + "edits": [ + [ + "\n@cache\ndef production_supplier(rank_log):\n from strong_complex import artifacts, word\n\n", + "\n@cache\ndef production_supplier(rank_log, stop_denominator):\n from strong_complex import artifacts, word\n\n" + ], + [ + " return ComplexRaw(atlas, fields, columns, **kw)\n\n return Positive(native, physical, 1 << rank_log)\n\n\n", + " return ComplexRaw(atlas, fields, columns, **kw)\n\n return Positive(native, physical, 1 << rank_log, denominator=stop_denominator)\n\n\n" + ], + [ + " binary = source_planner(profile.power, profile.floor)\n streams = [binary.image(1 << log_rank) for log_rank in profile.rank_logs]\n positive = production_supplier(profile.complex_log)\n if positive.owners <= 1:\n raise ArithmeticError(\"The numerical carrier needs independent rows\")\n", + " binary = source_planner(profile.power, profile.floor)\n streams = [binary.image(1 << log_rank) for log_rank in profile.rank_logs]\n positive = production_supplier(profile.complex_log, profile.positive_stop_denominator)\n if positive.owners <= 1:\n raise ArithmeticError(\"The numerical carrier needs independent rows\")\n" + ], + [ + " bit,\n self.profile.complex_log,\n partial(production_supplier, self.profile.complex_log),\n )\n\n", + " bit,\n self.profile.complex_log,\n partial(production_supplier, self.profile.complex_log, self.profile.positive_stop_denominator),\n )\n\n" + ] + ] + }, + "calibration.py": { + "old_sha256": "c36a253ab22f77381fe3e36889c9175680eadfd4a1203f2047141dc7a772f679", + "new_sha256": "444f185c619ef01bdea6328af3dc7ba30014b5cfebe7d1de875966e656fd57ff", + "edits": [ + [ + " ordinary: Fraction\n kappa: Fraction\n\n\n", + " ordinary: Fraction\n kappa: Fraction\n positive_stop_denominator: int = 10**14\n\n\n" + ], + [ + " kappa=Fraction(\"0.00389011527141\"),\n)\nPROFILES = {\"compact\": COMPACT, \"high-rate\": HIGH_RATE, \"price-match\": PRICE_MATCH}\n\n\n", + " kappa=Fraction(\"0.00389011527141\"),\n)\nSPLIT_TARIFF = replace(\n HIGH_RATE,\n rank_logs=(106_811_524, 1_708_984_375, 27_343_750_000,\n 437_500_000_000, 7_000_000_000_000, 112_000_000_000_000),\n power=268,\n floor=1 << 50,\n bit_c=Fraction(280312348082011, 2**56),\n ordinary=Fraction(\"0.0038901152863925\"),\n kappa=Fraction(\"0.003890115286352\"),\n)\nSPLIT_TILT = Fraction(593, 2048)\nPRODUCTIVE_TILT = Fraction(491, 1024)\nSPLIT_WEIGHT = Fraction(1, 64)\nFIXED_STOCK = replace(SPLIT_TARIFF, kappa=Fraction(\"0.0038901152863924\"),\n positive_stop_denominator=10**17)\nSMALL_GAP = replace(FIXED_STOCK,\n rank_logs=tuple(64*height for height in FIXED_STOCK.rank_logs),\n power=285,\n floor=1 << 47,\n bit_c=Fraction(280312348082137, 2**56),\n ordinary=Fraction(\"0.00389011528659083\"),\n kappa=Fraction(\"0.0038901152865907\"),\n)\nPROFILES = {\"compact\": COMPACT, \"high-rate\": HIGH_RATE, \"price-match\": PRICE_MATCH,\n \"split-tariff\": SPLIT_TARIFF, \"fixed-stock-stop\": FIXED_STOCK, \"small-gap\": SMALL_GAP}\n\n\n" + ], + [ + "\n\ndef prices(profile):\n bit_loss = debit(134, 127, profile.power, profile.bit_c, profile.floor, 5)\n numeric_loss = debit(153, 129, COMPLEX_POWER, COMPLEX_C, COMPLEX_FLOOR, 1)\n result = []\n", + "\n\ndef split_tariff_debit(profile):\n floor = profile.floor\n scale = 4 * (134 * 127) ** profile.power * floor\n assert Fraction(1024 * floor, 15 * (floor - 2)) < 69\n assert 69**100 < 2**611\n bound = Fraction(611, 100) + profile.bit_c * (scale - 1).bit_length()\n return -(-bound.numerator // bound.denominator)\n\n\ndef prices(profile):\n bit_loss = (split_tariff_debit(profile) if profile.power in (SPLIT_TARIFF.power, SMALL_GAP.power)\n else debit(134, 127, profile.power, profile.bit_c, profile.floor, 5))\n numeric_loss = debit(153, 129, COMPLEX_POWER, COMPLEX_C, COMPLEX_FLOOR, 1)\n result = []\n" + ], + [ + " result.append((height, covered, rate))\n previous = rate\n if not (\n profile.kappa + 4 * GAP < profile.ordinary\n and profile.kappa + 5 * GAP < COMPLEX_C - Fraction(numeric_loss, profile.complex_log)\n ):\n raise ArithmeticError(\"The numerical consumer cannot receive these prices\")\n", + " result.append((height, covered, rate))\n previous = rate\n gap = Fraction(1, profile.positive_stop_denominator)\n if not (\n 0 < gap <= GAP\n and profile.kappa + 4 * gap < profile.ordinary\n and profile.kappa + 5 * gap < COMPLEX_C - Fraction(numeric_loss, profile.complex_log)\n ):\n raise ArithmeticError(\"The numerical consumer cannot receive these prices\")\n" + ] + ] + }, + "check_product.py": { + "old_sha256": "5ace944e196d730ba966c042ddff6eccd2022e04f721619dfe47f45eefd64177", + "new_sha256": "3caf1264c85faa30dd2c599c3d3521059f25a366d64df995bd145161fb608092", + "edits": [ + [ + "\n\ndef stock_and_public():\n from dataclasses import replace\n from calibration import COMPACT\n\n assert multiply(-741503, 466013) == -345550037539\n for x in (0, -1, 1, 37, -69, 2**16383 + 5):\n assert multiply(x, -997) == x * -997\n # Exercise the production stage body with a feasible rank and all 81 by 81 addresses.\n profile = replace(COMPACT, rank_logs=(1,))\n side = 3**4\n records = bytes((i * 97 + (i >> 4)) % 256 for i in range(side * side))\n", + "\n\ndef stock_and_public(profile):\n from dataclasses import replace\n assert multiply(-741503, 466013, profile=profile) == -345550037539\n for x in (0, -1, 1, 37, -69, 2**16383 + 5):\n assert multiply(x, -997, profile=profile) == x * -997\n # Exercise the production stage body with a feasible rank and all 81 by 81 addresses.\n profile = replace(profile, rank_logs=(1,))\n side = 3**4\n records = bytes((i * 97 + (i >> 4)) % 256 for i in range(side * side))\n" + ], + [ + "\n\ndef physical_product():\n from binary_receiver import Receiver\n from module_atoms import balanced_widths\n", + "\n\ndef physical_product(profile=None):\n from binary_receiver import Receiver\n from module_atoms import balanced_widths\n" + ], + [ + " from triangular_ordinary import root_body\n\n stock_and_public()\n core = Receiver(2, balanced_widths(1), direct=True)\n calls = Counter()\n\n", + " from triangular_ordinary import root_body\n\n if profile is None:\n from calibration import COMPACT\n\n profile = COMPACT\n stock_and_public(profile)\n core = Receiver(2, balanced_widths(1), direct=True, profile=profile)\n calls = Counter()\n\n" + ] + ] + }, + "strict_moment.py": { + "old_sha256": "899ce86a0e5ae0455ea6cf97934658b2fd31b81d7111cb2bd636ce10e3e7264d", + "new_sha256": "f13c79ed45ce41c67a3f47c1767601be032ae65a908b9ee3a80643b0ac08689a", + "edits": [ + [ + "from math import isqrt\n\nfrom calibration import COMPLEX_C, COMPLEX_POWER\n\nUNIT = 1 << 112\n", + "from math import isqrt\n\nfrom calibration import COMPLEX_C, COMPLEX_POWER, PRODUCTIVE_TILT, SMALL_GAP, SPLIT_TARIFF, SPLIT_TILT, SPLIT_WEIGHT\n\nUNIT = 1 << 112\n" + ], + [ + "\n\ndef certify(word, c, tilt, drop, power, slack_bits, cutoff):\n if (word.power, word.floor, word.low_cut, word.high_cut) != (power, cutoff, 12, 12):\n raise ValueError(\"The evaluated strictifier differs from the installed one\")\n", + "\n\ndef certify(word, c, tilt, drop, power, slack_bits, cutoff, *, split_weight=2):\n if (word.power, word.floor, word.low_cut, word.high_cut) != (power, cutoff, 12, 12):\n raise ValueError(\"The evaluated strictifier differs from the installed one\")\n" + ], + [ + " gamma = Fraction(moment(paid, t + tilt, True) * UNIT, lower * power_interval(12, tilt)[0])\n loss = Fraction(moment(targets, t - drop, True) * power_interval(cutoff, drop)[1], lower * UNIT)\n deficit = 1 - alpha**power - 2 * gamma**power - loss**power\n if not (tilt >= c and deficit > Fraction(1, 1 << slack_bits)):\n raise ArithmeticError(\"The strict local surplus cannot pay all physical fringe axes\")\n", + " gamma = Fraction(moment(paid, t + tilt, True) * UNIT, lower * power_interval(12, tilt)[0])\n loss = Fraction(moment(targets, t - drop, True) * power_interval(cutoff, drop)[1], lower * UNIT)\n if split_weight != 2:\n # For x >= 1, (2x)^c - 1 <= (101/100)c x^tilt / tilt.\n assert 0 < c < Fraction(1, 250) and c <= tilt <= 1\n assert Fraction(101, 100)**250 > 2\n assert Fraction(101, 100) * c / tilt < split_weight\n deficit = 1 - alpha**power - split_weight * gamma**power - loss**power\n if not (tilt >= c and deficit > Fraction(1, 1 << slack_bits)):\n raise ArithmeticError(\"The strict local surplus cannot pay all physical fringe axes\")\n" + ], + [ + "\ndef both(binary, positive, profile):\n return (\n certify(\n", + "\ndef both(binary, positive, profile):\n if profile.power in (SPLIT_TARIFF.power, SMALL_GAP.power):\n return (\n certify(binary, profile.bit_c, SPLIT_TILT, PRODUCTIVE_TILT,\n profile.power, profile.floor.bit_length() - 2, 15, split_weight=SPLIT_WEIGHT),\n certify(positive, COMPLEX_C, Fraction(19, 64), Fraction(23, 64), COMPLEX_POWER, 14, 16),\n )\n return (\n certify(\n" + ] + ] + }, + "strong_binary.py": { + "old_sha256": "03ffb2075620fe793156e9bd22890185bef21e097abadba3a7d6cb5406051855", + "new_sha256": "74ba0d1aa9ca1dc2f4ade19ca1989f8dbf5329ddf3736bf3056280283f4fd660", + "edits": [ + [ + "@cache\ndef native_word(power=128):\n if power not in (128, 228):\n raise ValueError(\"Select a certified binary power\")\n raw = binary_ports(graph(), caller())\n", + "@cache\ndef native_word(power=128):\n if power not in (128, 228, 268, 285):\n raise ValueError(\"Select a certified binary power\")\n raw = binary_ports(graph(), caller())\n" + ] + ] + } +} diff --git a/research/p104-k7-retimed-binary/predecessor/SOURCES.json b/research/p104-k7-retimed-binary/predecessor/SOURCES.json new file mode 100644 index 0000000000..4afaeff69d --- /dev/null +++ b/research/p104-k7-retimed-binary/predecessor/SOURCES.json @@ -0,0 +1,633 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "AGENTS.md", + "git_blob": "ff81117fca368042f6092964d1f54eb4e6e08fb9", + "sha256": "fece32cdec9c1572ddce354a0b623459cb2c4ca162125d36d36262a92e3caa83", + "usage": "provenance" + }, + { + "path": "autoresearch.md", + "git_blob": "2fe84a7b30b1e26e60ce0ec4775894eb1831c5d6", + "sha256": "d16f0d3bb4d4b213d06c128db6d6460b0fe9ec1ac5a6c1ea1febf1db40e7b60d", + "usage": "provenance" + }, + { + "path": "CONTRIBUTING.md", + "git_blob": "5185786f2ec00f215019fb5777d70979429690a9", + "sha256": "fcd1a8d0e52342a23b8ffa9e905e85ccc539fb084145ef016dfc93cedfb3d924", + "usage": "provenance" + }, + { + "path": "certificates/selected-result.json", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1", + "usage": "provenance" + }, + { + "path": "docs/research/agent-task-catalog.json", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81", + "usage": "provenance" + }, + { + "path": "research/unconditional-batched-crt/CRT.md", + "git_blob": "d98dd8e368431cac33d5fc1c8c336696663641d6", + "sha256": "02c3a1e38cbee25aefe2640cc72676da62ba10eb7519fbcb9adb9d48b74eff2b", + "usage": "provenance" + }, + { + "path": "research/delayed-cover-physical-batch-routing/PROOF.md", + "git_blob": "af919b5ba2257c07ea17180f9b8c9fd457556079", + "sha256": "1c3dcd294d327a16fa081b7ea27497941ac6480d352f53e55e8b9e87f45d1454", + "usage": "provenance" + }, + { + "path": "notes/compact-control-movement.tex", + "git_blob": "06b6a9ef24245ac7b724c53a204635415b402357", + "sha256": "b963c3d2f4e1b7059aa289bb4b4ac89b688920bcf42f5b20d7698cdef0132cc6", + "usage": "provenance" + } + ], + "offline_predecessor": { + "head": "6285dd829114705862e8d91facaedc1f31d3cfcb", + "pr": 8030, + "tree": "3a1c001cbf175ae48ee1d56e56e4723eda1c8218", + "archive": "predecessor-8030.tar.gz", + "archive_sha256": "769d5a05cc1373fa22ed5956af636992fcd19d7e5c1753a32033a73c358cd31c", + "files": { + "ACTIVATION-SPACE.md": { + "size": 15082, + "mode": "100644", + "git_blob": "52f71ba75c3383401da5eda2c435a998629bc984", + "sha256": "e805961b0b3f5263cfb0b5c559dd99243330b8821d0a2c932c2bfabde79181c4" + }, + "ACTUAL-SETUP.md": { + "size": 6161, + "mode": "100644", + "git_blob": "61deda9516719a7039b60a0bc0f53673ad7a252d", + "sha256": "071abc2a2f9ad6d53923ccbc3f0ef09ae31430dd1ba03f54bca2bb661cda954b" + }, + "APPLICATION.md": { + "size": 11870, + "mode": "100644", + "git_blob": "07f01dadb8160dc44875a55d0884780a9ffb3649", + "sha256": "e84215c5ca9faeeb5aa9567fe6db0f1dc817bbc909c8c4e6caf3aa6d65ca938a" + }, + "BAND.md": { + "size": 16863, + "mode": "100644", + "git_blob": "bf1d63a1b7219b46dc935e734adcb22d84cac1f1", + "sha256": "4c0adb553b4357ead618e26af4fe8c600fdafc816449c54b48a9b2dfa0cff494" + }, + "LICENSE": { + "size": 11357, + "mode": "100644", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + "LINEAR-GEOMETRY.md": { + "size": 21359, + "mode": "100644", + "git_blob": "b07c2127327faceb59c4e6833e592cb96c98600a", + "sha256": "8f6a9045ebcb4b8ddeb6339e7414bc897a6583e02ae689b15d4dac0394659550" + }, + "NOTICE.md": { + "size": 4296, + "mode": "100644", + "git_blob": "10167a0c8a4f2ec6af86f16acc6cad577e5aa713", + "sha256": "c00f5acddbb6516a69f1fd9a3ef01e737f4c10fabb36a19eef5623b1fbc1edbe" + }, + "README.md": { + "size": 7097, + "mode": "100644", + "git_blob": "5349b7f95653fbc85557b44540bcdf587d3b03aa", + "sha256": "0814b1c07155a037347127fc941c47ec3d5c23b8e8c06d23f46993085f0f6798" + }, + "REQUIREMENTS.json": { + "size": 6970, + "mode": "100644", + "git_blob": "64a217df2fc0012b7aab402ceeb3d5fae1f2ce9a", + "sha256": "6de3056c25423a952d35c89f661ba511594981544c4dd270f6a5b58920edb1aa" + }, + "SOURCES.json": { + "size": 3201, + "mode": "100644", + "git_blob": "94e74a7e0202e088a4fc78e7fd4aedbfda4c7043", + "sha256": "0d22a7cfdde48de7a106fca872601d5ed345a4ae3631b0acff2e05407eae2e65" + }, + "STRONG-BINARY.md": { + "size": 13442, + "mode": "100644", + "git_blob": "530be21be91f5988cb22feea134613122f9cf040", + "sha256": "548e4d8e2290c4e58845ddd20f9099d9fc866cd3b19997ad0791b056e66ccd92" + }, + "STRONG-COMPLEX.md": { + "size": 13932, + "mode": "100644", + "git_blob": "e9c08411e4cbdddb3a2c8bb1e19bc59e8c9ba6be", + "sha256": "724e816015c2329414d503a7b29683bf563be4b7469a8149cfe2cfc888696b44" + }, + "TASK.json": { + "size": 5897, + "mode": "100644", + "git_blob": "baff001ee17330bb0a4745161fc4bec7f1b369f5", + "sha256": "9372161b8b3de4bb6ec5efa1f3519a0bbe45a87c2cc8d1c5a6f76bd6f2c0da56" + }, + "VERIFICATION.md": { + "size": 6883, + "mode": "100644", + "git_blob": "00890cd08a955dcecd1b8da12478853096cd78de", + "sha256": "1906c8a2564b83df5ed386ffea3ba8c675c225051ff9800d0147223cea0fe1bd" + }, + "VERIFY.json": { + "size": 2415, + "mode": "100644", + "git_blob": "549567731dde171633082c211dd860ed8f457c19", + "sha256": "9b935893bb78c26ff753e21f290d3007762cc8f3c1781e06c13bd628632f82de" + }, + "band_compiler.py": { + "size": 3702, + "mode": "100644", + "git_blob": "49d3675027743cb7f1ed91765da5b92ba0819a90", + "sha256": "64d96e1b732117983bf5f5cba3c59ba91b672ae0f03fc23477c8727c4109a701" + }, + "band_positive.py": { + "size": 3683, + "mode": "100644", + "git_blob": "d2e6cf98c50e5a9a11ef41d5793921890bc6527d", + "sha256": "a279e7f4261f947f32f6b0e641bacf95b69755e7ac9263e3df60698bb425b5e8" + }, + "band_product.py": { + "size": 4311, + "mode": "100644", + "git_blob": "4fba42dc54ac9ccfcebe35ecbf5b4a16f130455f", + "sha256": "7feb08718d511b45d0e9f927540115c9c1526f9b65ff3dadaef55b1ac8a2b19d" + }, + "binary_receiver.py": { + "size": 4436, + "mode": "100644", + "git_blob": "d6652929234d9232d824603e15ebc2990047d216", + "sha256": "2be42f476aa71cc2d2ad44392113151e101e56f7a09b7264fc98a74393756372" + }, + "build_charts.py": { + "size": 1333, + "mode": "100644", + "git_blob": "65492d9f8d403e1f467957501ad6dd1bfd9a23ac", + "sha256": "5ae0a7e6509ed81b03e42534ea2a82a01b8edf5dec3ef9d9b9dca49bd424725c" + }, + "calibration.py": { + "size": 2963, + "mode": "100644", + "git_blob": "9992aee320983f7e0fcbd650643d2dcc4674e3c8", + "sha256": "c36a253ab22f77381fe3e36889c9175680eadfd4a1203f2047141dc7a772f679" + }, + "check_activation_space.py": { + "size": 2953, + "mode": "100644", + "git_blob": "5dfbd8e718da6bf451e440ffb0ac0bcb51a25b28", + "sha256": "51df69d2e2c396a8bf4d6f51572e3d04250237ee23b6d3bce25bf02625f07eee" + }, + "check_band.py": { + "size": 9019, + "mode": "100644", + "git_blob": "2a453d888f53d668ed573c2db80805f984f5f27a", + "sha256": "21343d0f71d82986a5cfeb2fd7f2da4836bee5ac54eeca3608d012f994c237f6" + }, + "check_dense_band.py": { + "size": 1335, + "mode": "100644", + "git_blob": "eabff4f9911ab4423ba38ea1c9a7ca737cb8e0e1", + "sha256": "7b06a2d8c0e23897b93dbd9075123553495d51258a63ee9b8c940d76cb1db44b" + }, + "check_epoch_reentry.py": { + "size": 2630, + "mode": "100644", + "git_blob": "fa1f66b44153505051ccd0c6461b7dce73394735", + "sha256": "5764c34527e1c7b06456864f8628fdd12cc8ec2f0c47f07d4a75151663abf129" + }, + "check_linear_geometry.py": { + "size": 8659, + "mode": "100644", + "git_blob": "e8c636fc61fb8e56bc840083768bfdd83c3e77af", + "sha256": "57ed4d3111de70a9ed1ac42717f7c2c9d02073878ca2b3e211cb22e2989c5616" + }, + "check_product.py": { + "size": 4876, + "mode": "100644", + "git_blob": "c1af1bd9cc64615041a0ea908ebf4d66076936de", + "sha256": "5ace944e196d730ba966c042ddff6eccd2022e04f721619dfe47f45eefd64177" + }, + "check_strong_binary.py": { + "size": 9959, + "mode": "100644", + "git_blob": "05f8801667ef417fe63a710c01ef8d94a3df0f76", + "sha256": "dd5acaa148e4bf04fd395515010660678600e7fc1e8ef806c6446a448568aa8b" + }, + "check_strong_complex.py": { + "size": 9287, + "mode": "100644", + "git_blob": "cc1232dabcf0523dd22ac3a23c2bf78b49620e90", + "sha256": "ab3ae76bfbd2238d7c41b130a4de8f73f65f7bec3bba92973d914abaaa72cd0a" + }, + "check_strong_physical.py": { + "size": 3512, + "mode": "100644", + "git_blob": "754f4430b05a2d90c0228a468f26fe8f35409b96", + "sha256": "c1497710e88267cff463ca0ad47acca4d8e88d48c8c4cf563e6ad35c2836d978" + }, + "check_strong_raw_word.py": { + "size": 6304, + "mode": "100644", + "git_blob": "32d3cc9d3ba4c2c87dec73c0254b3bf7d69adf5a", + "sha256": "946fbb355f21536287a9af5812bc833c14a50a0aa0a455c5fdaff2b28ff15465" + }, + "check_weighted_binary.py": { + "size": 6921, + "mode": "100644", + "git_blob": "5e500f36231e9575041fec8c01726605ae629013", + "sha256": "fe70753a3c62f8e3b9b39e526311ae1e5bf4743bfba9d66f0320adcbaa52fade" + }, + "epoch_tape.py": { + "size": 6294, + "mode": "100644", + "git_blob": "2a54438538061dc06f3286ef9624f43c187abb0d", + "sha256": "c66b8c040571471170581b0c577a36f5d2c1283aac517bdc6f407122b945df04" + }, + "independent_binary_price.py": { + "size": 4835, + "mode": "100644", + "git_blob": "9cc55c5655f35f99aa017cad2e59ea4d0dcaac81", + "sha256": "1936595a79fbfa14ec74af3b4e521216740d00bd45f379b5e97a1440e5a2aaf9" + }, + "inputs/complex-source.json": { + "size": 1309, + "mode": "100644", + "git_blob": "6e1030bb2e40ec36e264a27a030dcbf8e2ee5554", + "sha256": "b33575085bcaf8e646ad7656d1f8d2c7ad402712e6b49efd307fc926f2fb39b0" + }, + "inputs/complex-source/BANK-FACTORS.json.gz": { + "size": 4098, + "mode": "100644", + "git_blob": "de611b5588be4ed1a22225b030c7994d0ef3e3f1", + "sha256": "b009cd6bb13036879214cb6d43beb923578ef7fb4c83f36a1cc971ab4ea23543" + }, + "inputs/complex-source/BIDIRECTIONAL-QUOTIENT-RECEIPT.json": { + "size": 1075, + "mode": "100644", + "git_blob": "7606122e82f72718048e6c53e9cd37ba684d11fc", + "sha256": "459f519593242a3e8ecf42817f178fb214a6833e0df0e1ce727c5809035d02de" + }, + "inputs/complex-source/BIDIRECTIONAL-QUOTIENT.json.gz": { + "size": 42126, + "mode": "100644", + "git_blob": "93b35fe94405b77409182cf0d3de06c2227ea096", + "sha256": "ed725d5c69a507352efc6a18f3e4f7e5c20592a655a7b80193034232feb43d6f" + }, + "inputs/complex-source/BIDIRECTIONAL.json.gz": { + "size": 115971, + "mode": "100644", + "git_blob": "3c91100fb02b95bf163fcccd1637dcc0bfc1b48a", + "sha256": "baf07c7085f588ce06201e2a6bf4f5f58632801202783ca195d3b8369ff74836" + }, + "inputs/complex-source/HELPER-SPLITS-RECEIPT.json": { + "size": 995, + "mode": "100644", + "git_blob": "f35d9f85be917ddc6f6743b4b45fd4a8274fc69c", + "sha256": "712b783baf1463b738bd5c5ad3023bf42681d7d0105dd550ba3549c02674f711" + }, + "inputs/complex-source/HELPER-SPLITS.json": { + "size": 3361, + "mode": "100644", + "git_blob": "a6225bf11bc9b0710f9f123da2143c1039e91dc0", + "sha256": "f70ba89a9ed5839476bbe298d4cb8f4d9eeb703621d5f478c884861cdd91fb20" + }, + "inputs/complex-source/LAYOUT.json.gz": { + "size": 7865, + "mode": "100644", + "git_blob": "3ee3637e63e4a2c135b29ae44b39937d6f33ab4b", + "sha256": "84cd1d11ff454eecf3504e4b3f26adc371539b17553bfce1bcfda7a331811998" + }, + "inputs/complex-source/LICENSE": { + "size": 11357, + "mode": "100644", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + "inputs/complex-source/PARENT-NOTICE": { + "size": 1694, + "mode": "100644", + "git_blob": "fe51894a1a630c6feee4b13da2a0499e41ee6edf", + "sha256": "b213998c8dae6d88e4a1f0fd17c81dd78c31ef35bc9460fa16ca692326f1a02b" + }, + "inputs/complex-source/WORD.json.gz": { + "size": 617321, + "mode": "100644", + "git_blob": "31786df96c1da3fe7adc42e30839265b29a90964", + "sha256": "731246c085638706bdb97e7e88618f8923e27ee4ce8eb4869f0847f8f4699f7c" + }, + "inputs/complex-source/replay.py": { + "size": 10929, + "mode": "100644", + "git_blob": "129817a60c7949749d22b9a0523aa27cea4780c9", + "sha256": "9c847a1242e730acf1dfd3a83f4801470e3e2da6c3079f53ccb7ada620b37a7b" + }, + "inputs/complex-source/verify_bidirectional.py": { + "size": 6798, + "mode": "100644", + "git_blob": "dad44147182f126ff75757bd14977d04272aed3c", + "sha256": "ef85db5c6f348b55e0db4d61517dde6a58b027737037e14b9fdea04f8b96e716" + }, + "inputs/complex-source/verify_component.py": { + "size": 7051, + "mode": "100644", + "git_blob": "6f2aff9a042ced040502e3e9fef0b47adc428f59", + "sha256": "163b1ca3a35531da94ef454229f040592c754675f59dfb805d0a9aadb33b8d65" + }, + "inputs/complex-source/verify_split_helpers.py": { + "size": 3731, + "mode": "100644", + "git_blob": "d596f75f1ff185c642f66209f04315d4770a1186", + "sha256": "6a0b59657bd1902d19b9c0f8badef2caa13c8ba84e0311550d6391360bdf186b" + }, + "inputs/new-charts.json.gz": { + "size": 1464, + "mode": "100644", + "git_blob": "04d818a87cac2b384cba4358b26d6e40d592552f", + "sha256": "b626b1ebc3359a36c4437b6916a340597bc74403b65f5a05f057602f5b6d35b0" + }, + "inputs/review.json": { + "size": 1445, + "mode": "100644", + "git_blob": "be3441d8ebb63d2235593a74c2a186dcea711dff", + "sha256": "614a5d273fc8a676b12d512ae9282f88990e696f978a2800f6cd7f986d295874" + }, + "inputs/review/check_complex.py": { + "size": 6659, + "mode": "100644", + "git_blob": "e1c0793e65ee4968f69f02ff947719ada284cc42", + "sha256": "ce8dc94ccc9fc780b991aad35aceba03b95335f9fd5b77235deb9e1a7f52e9f8" + }, + "inputs/review/check_periodic.py": { + "size": 7672, + "mode": "100644", + "git_blob": "f18ce6df234bcddb21fd46871773f25a66cf9fa5", + "sha256": "c1a5c81b5a4121498886758dd021ffdaa237c9fdc6e71e0d315a80947edc70d5" + }, + "inputs/review/check_powered.py": { + "size": 5924, + "mode": "100644", + "git_blob": "2f1c1192cdc2fe298622a837f830182e5c231c0b", + "sha256": "fc81d8d652b4290f473874114f72d4c7c8213ee4f26f5be8968894e01f786c35" + }, + "inputs/review/clifford_exact.py": { + "size": 6824, + "mode": "100644", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + "inputs/review/graph_identity.py": { + "size": 3801, + "mode": "100644", + "git_blob": "b372fd19ed4d24a630d04d3e51f9c7e55bf8e902", + "sha256": "90440581667a00a8e0a8e02a8a5a196a88dc0edb48eb8e89c22603e615524681" + }, + "inputs/review/native_verify.py": { + "size": 12323, + "mode": "100644", + "git_blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + "inputs/triangular.json": { + "size": 1314, + "mode": "100644", + "git_blob": "349cba11da90a2ff5539dec904389cb904899b52", + "sha256": "8474fd210582be93568bef852910cc9a11fbfc5da710e29dd4ce50fbf47be54d" + }, + "inputs/triangular/LICENSE": { + "size": 11357, + "mode": "100644", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + "inputs/triangular/NOTICE.md": { + "size": 3860, + "mode": "100644", + "git_blob": "9323d93ce13ff8f924006a4218f94efb9edebc52", + "sha256": "7ec57034ab47631a47e35ab9cd86a563a6a4bb2ce7397d545861f898281c696c" + }, + "inputs/triangular/direct_body.py": { + "size": 6255, + "mode": "100644", + "git_blob": "e8d742d9efab1be4283c7b13d0a17c6faad0d989", + "sha256": "f4ca3082b95f958b50f84a3c138667add0051d6a796e7f63afe95d41cf24e7af" + }, + "inputs/triangular/inputs/retained.json": { + "size": 6679, + "mode": "100644", + "git_blob": "43a35ae8c03f612b57705b3b80caa38f5d91ae22", + "sha256": "4d0dd81eb156c97403d752a3dc654d85a93b0284aed8cfa5eed840259f6abd88" + }, + "inputs/triangular/inputs/retained.tar.gz": { + "size": 1083295, + "mode": "100644", + "git_blob": "c1a75d8f555f109cb522d3050ce00d75b20efdb8", + "sha256": "77742c09b088f27e8742c3fad7b7148d3397e4d51b95312106f39a8970165903" + }, + "inputs/triangular/limb_scale.py": { + "size": 3839, + "mode": "100644", + "git_blob": "2c7243ddb889b5fd858d0b6714a43b5af02bfb78", + "sha256": "ed7c27348c2bc8259683b617c45bb0ee6aacb781c0ad04168c59035b7b5cf8ff" + }, + "inputs/triangular/multiplier.py": { + "size": 4185, + "mode": "100644", + "git_blob": "512cc8cba444b4579b414bef843d7d376ecf4067", + "sha256": "e805fb05caaa76d4c65dc3a55b99c6332a1c3772516547cf24e8027ade718cf4" + }, + "inputs/triangular/quotient_route.py": { + "size": 11607, + "mode": "100644", + "git_blob": "fc8502647a9626ffd4047cb7046b80ecc83afb5c", + "sha256": "3243f45d6097a80bc8b077d8682426e4555f6c4a3097bd0a12ffd4f1f5c45ba8" + }, + "inputs/triangular/receiver.py": { + "size": 10352, + "mode": "100644", + "git_blob": "37646beb735d42e86f3f9d54b6d0997a7eee30da", + "sha256": "09d2e9508e3e34934a6f2132c6e864f6b4ba68fa96aaadbec0a1902aa7762642" + }, + "inputs/triangular/retained.py": { + "size": 1830, + "mode": "100644", + "git_blob": "47d494454262cf9a12ec9ca57b9da5bb38dd5bc6", + "sha256": "970e71bb0fcab41a03ccc5068ddc5e0df5c00953098f542fdc1a3e0e2048ffda" + }, + "inputs/triangular/same_order_body.py": { + "size": 6478, + "mode": "100644", + "git_blob": "0b7afa194a7152cf221964a14ebfffc642209fcf", + "sha256": "56a15ce431daf25794741cb5157e136ce509ed646b32aaea34348088396e459d" + }, + "inputs/triangular/staged_carriers.py": { + "size": 5578, + "mode": "100644", + "git_blob": "4dd73b0d36850c80e2f446096d971fd0b1b409aa", + "sha256": "6c925ae4b39dc9999ac5891d1a27dcbb38e129a36e1473b2b418f27a806b6fc4" + }, + "inputs/triangular/triangular_ordinary.py": { + "size": 3674, + "mode": "100644", + "git_blob": "f9f44f18527ae0c7f705558962aea519ca7bc107", + "sha256": "1f69f21881229566e0b251a2edd8a3c9ac6409eeebdb68ee046f27e74dd8af71" + }, + "lean/.gitignore": { + "size": 7, + "mode": "100644", + "git_blob": "01f8cdb637da2370fa79960e25efa59dd8cffd6d", + "sha256": "fde850d24186b6e99c8c0debd641fb3ab85198b109eb66f71a1fea02bd6ea1b3" + }, + "lean/BandFlow.lean": { + "size": 15134, + "mode": "100644", + "git_blob": "71e109b0abba123f91302a913cf51d5e3b2ac631", + "sha256": "c47338afcf5a35e992df47ea4d11e89709a848041ef680a77c39acd57384342a" + }, + "lean/Profiles.lean": { + "size": 2148, + "mode": "100644", + "git_blob": "2423069aa74f1c739858c5a8fb272c0665cd9879", + "sha256": "53bcad234dac897478d35260598d602cc79b545e979df18efb6f82ba6667617a" + }, + "lean/SquareSieve.lean": { + "size": 6694, + "mode": "100644", + "git_blob": "183d1e6705049461e4375fe2b4d21cacc324d10d", + "sha256": "4aa9e9693a8006981aac783f7a7302b4102505c544203f69062d3073c4e83618" + }, + "lean/lake-manifest.json": { + "size": 3551, + "mode": "100644", + "git_blob": "f27574d9f7d30f24567df0789cd81751f0819998", + "sha256": "3b30b2d7e59f23142ff2028b8beec632936359b7fe3e904e8984d842a44b1488" + }, + "lean/lakefile.toml": { + "size": 304, + "mode": "100644", + "git_blob": "cac451e8fbd658c5c88eb6b8511b943bfce75d07", + "sha256": "34e23113b620bf67211a36526ebb9a768d4cddb5ba2e990b8d3222540875e19d" + }, + "lean/lean-toolchain": { + "size": 25, + "mode": "100644", + "git_blob": "ba8ebf2dbaf6a668cd2a0e086186d6d569b69ff5", + "sha256": "d5edba4e4b8faad9c1baeadb265716d20d03be4d1a2647dc5e35b0c0325bea7b" + }, + "linear_geometry.py": { + "size": 3145, + "mode": "100644", + "git_blob": "f042bfa42f75bfb3d2b59501b13f54aad197a9bf", + "sha256": "6628fcddf1eed2ffa39c2d3256d79577b950e04c4a688161a66ba92baa3fb7c2" + }, + "ordinary_carrier.py": { + "size": 2681, + "mode": "100644", + "git_blob": "15382c98cb39d8f0ef999f8cfd46aaa5e23e8a96", + "sha256": "c8e87147661a394bc7e1b879744546b7697fcde7f3636556b39ca1623a9d7b31" + }, + "positive_dispatch.py": { + "size": 2393, + "mode": "100644", + "git_blob": "6846c690e0292e9c9f1d19fb6cac3713ea0c1e73", + "sha256": "8bd147f6fd1a22b8b4519d165a290b46ab50870246345cbb0740a405f49a9a73" + }, + "prior_setup.py": { + "size": 2905, + "mode": "100644", + "git_blob": "282d755de195893b85f33ceed9d5d017e3e97a25", + "sha256": "28fa12b5290033e50e145e374d2c42b564b30ecdb2f4309213834b5a10981d5a" + }, + "resources.py": { + "size": 2918, + "mode": "100644", + "git_blob": "36cf93f347623bfe15a8fdf9a0178db68dd155a8", + "sha256": "13027d55cb74e2f53f2c182c6dce3a99c0886d2f6bc51da62df5746e3054f94e" + }, + "strict_moment.py": { + "size": 2618, + "mode": "100644", + "git_blob": "f95dff0192befe7631d1df9fc8261de98e051765", + "sha256": "899ce86a0e5ae0455ea6cf97934658b2fd31b81d7111cb2bd636ce10e3e7264d" + }, + "strong-bit.json.gz": { + "size": 135471, + "mode": "100644", + "git_blob": "16f8cafb1c4d139a99a62e46eb40c118e6176c34", + "sha256": "74e93daf2b7acf794ffb51f92f03f51556f68126d41ee13a8969bddb4cbe6326" + }, + "strong_binary.py": { + "size": 4722, + "mode": "100644", + "git_blob": "913e4faaa31709796e0bc70d9ae120555acadad0", + "sha256": "03ffb2075620fe793156e9bd22890185bef21e097abadba3a7d6cb5406051855" + }, + "strong_complex.py": { + "size": 4381, + "mode": "100644", + "git_blob": "3d5fa9f9b2bdecd9aa179af7d1fc55d3e998bb4e", + "sha256": "0c9a103a322df6c18b9b3754e5756f07ce02130a131d20a1bb254d47175cfa5e" + }, + "upstream.py": { + "size": 1128, + "mode": "100644", + "git_blob": "f68872df228508a3227cbb406caab27ddd0e5655", + "sha256": "d9b079965d8abc04be3eda662fc84ba9a08c4f03e8ccc7bd3e775876164e6c10" + }, + "verify.py": { + "size": 3506, + "mode": "100644", + "git_blob": "c0b5cbeba13d70d534e697c4288b62fb86259430", + "sha256": "20ab1e4bc2d2944ddb59f774c09977439a70e10389b7f28454f0b00fd81d5cc9" + }, + "verify_formal.py": { + "size": 1959, + "mode": "100644", + "git_blob": "0f35787441541c83b82422a81e1a28a7fc3f6550", + "sha256": "b9e908e09467794a52fd10d32ed6a1eb6f63e1d37726520af493825285f1db85" + }, + "verify_sources.py": { + "size": 2347, + "mode": "100644", + "git_blob": "a3ef7f778829e73ee80fcda0fb0df3f864359b84", + "sha256": "6ef97baeafb01cb0fc9afb6ff7beb779cea93755620f836f9e4db5307e3cd365" + } + } + }, + "paired_native_source": { + "pr": 8027, + "head": "fb9b6a7b0d27da1cf98430893a3016bf811e2aa4" + }, + "comparative_profile": { + "pr": 8032, + "head": "9c5881ab4015854c68d5f5a3fc7d97f68505cc4c", + "kappa": "0.00389011528633", + "largest_BIT_rank_exponent": 114688000000000, + "sufficient_public_exponent": 136798773006437 + }, + "split_tariff_comparator": { + "pr": 8033, + "head": "a1313ff9f84fd00d50b282fe432e522191277821", + "kappa": "0.003890115286352", + "largest_BIT_rank_exponent": 112000000000000, + "sufficient_public_exponent": 119466661575676 + }, + "signed_inequality_source": { + "commit": "4f7c67ae387cc91580f469aeda4d508b372b9ec1", + "path": "research/p104-dual-supplier-lift/complex/supplier_gate.py", + "sha256": "3796b2e5a27f3caa142d16364154788e60d0099f1e24a8dcd028e4fbd35a84ca", + "kind": "external exact provenance of the self-contained expression transcription" + } +} diff --git a/research/p104-k7-retimed-binary/predecessor/predecessor-8030.tar.gz b/research/p104-k7-retimed-binary/predecessor/predecessor-8030.tar.gz new file mode 100644 index 0000000000..e00a6bfe83 Binary files /dev/null and b/research/p104-k7-retimed-binary/predecessor/predecessor-8030.tar.gz differ diff --git a/research/p104-k7-retimed-binary/raw_binary_stage.py b/research/p104-k7-retimed-binary/raw_binary_stage.py new file mode 100644 index 0000000000..444da9677a --- /dev/null +++ b/research/p104-k7-retimed-binary/raw_binary_stage.py @@ -0,0 +1,57 @@ +"""Bind the unpowered 36-call binary word to its actual physical owners.""" + +from collections import Counter +from functools import cache + +from installations import BINARY_C +from strong_binary import caller, fixed_binary_charts, graph +from tagged_sources import binary_ports +from transport import Recipe +from unpowered_price import certify + + +class BinaryWord: + def __init__(self): + # This entry constructs the labelled raw port lists. No tensor tuples are requested. + self.tagged = binary_ports(graph(), caller()) + fixed_binary_charts() + self.targets = tuple(p.rank for p in self.tagged.targets) + self.paid = tuple(p.rank for p in self.tagged.paid) + margin, self.cells = certify(BINARY_C, (Counter(self.targets), Counter(self.paid))) + if self.cells is None or margin <= 0: + raise ArithmeticError("The binary raw word has insufficient paid capacity") + + def native(self, jobs, columns, physical): + entries = [] + for port, job in zip(self.tagged.targets, jobs, strict=True): + if len(job.axes) != port.rank * columns: + raise ArithmeticError("The external binary job has the wrong extent") + entries.append((port.tag, job)) + actual = iter(physical.raw(entries, columns)) + for port in self.tagged.paid: + tag, job = next(actual) + if tag != port.tag or len(job.axes) != port.rank * columns: + raise ArithmeticError("The binary native cut differs from its physical label") + yield job + if next(actual, None) is not None: + raise ArithmeticError("The binary native word has an extra paid cut") + + +@cache +def binary_word(): + return BinaryWord() + + +@cache +def binary_recipe(height): + word = binary_word() + return Recipe(height, word.tagged.ambient, word.targets, word.paid, word.cells, BINARY_C) + + +def run(recipe, fields, machine): + if recipe is not None: + recipe.open().run(fields, machine) + return + for field in fields: + for axis in range(len(field.axes)): + machine.leaf(field.select((axis,))) diff --git a/research/p104-k7-retimed-binary/receiver.patch b/research/p104-k7-retimed-binary/receiver.patch new file mode 100644 index 0000000000..4b7db79b29 --- /dev/null +++ b/research/p104-k7-retimed-binary/receiver.patch @@ -0,0 +1,71 @@ +--- a/inputs/triangular/direct_body.py ++++ b/inputs/triangular/direct_body.py +@@ -7,7 +7,7 @@ + from factored_frames import apply_row, inverse_word + from growing_binary import pipe + from module_atoms import component_widths, lower_tape, pair_shape, total_width, weighted_pair +-from same_order_body import same_order_line ++from five_exchange import direct_line, same_order_line + from streaming_routes import copy_bytes, erase, integer_scale, negate_field, work_tapes + from ternary_frames import residue + from ternary_leaf import select_pivot +@@ -147,21 +147,3 @@ + inverse_word(frame.word), unit, modulus + ) + +- +-def direct_line(core, source, target, frame, f, unused, older, gap, suffix, weight): +- """Act on one compiled line in its actual basis, with the chart fixed to identity.""" +- u, v = direct_factors(frame, core.modulus) +- same_order_line( +- core, +- source, +- target, +- pivot=select_pivot(u, v), +- factors=lambda high: (u, v), +- f=f, +- unused=unused, +- heights=1, +- older=older, +- gap=gap, +- suffix=suffix, +- weight=weight, +- ) +--- a/inputs/triangular/receiver.py ++++ b/inputs/triangular/receiver.py +@@ -21,7 +21,8 @@ + quotient_right_route, + representative, + ) +-from same_order_body import SameOrderBody, same_order_line ++from same_order_body import SameOrderBody ++from five_exchange import same_order_line + + + class OwnerBanks(Banks): +--- a/inputs/triangular.json ++++ b/inputs/triangular.json +@@ -4,16 +4,20 @@ + "sha256": { + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.md": "7ec57034ab47631a47e35ab9cd86a563a6a4bb2ce7397d545861f898281c696c", +- "direct_body.py": "f4ca3082b95f958b50f84a3c138667add0051d6a796e7f63afe95d41cf24e7af", ++ "direct_body.py": "cdaa0d01caa678fca495713ae9ae4efcc33c1af063d7c7de76a76d6da077b1fc", + "inputs/retained.json": "4d0dd81eb156c97403d752a3dc654d85a93b0284aed8cfa5eed840259f6abd88", + "inputs/retained.tar.gz": "77742c09b088f27e8742c3fad7b7148d3397e4d51b95312106f39a8970165903", + "limb_scale.py": "ed7c27348c2bc8259683b617c45bb0ee6aacb781c0ad04168c59035b7b5cf8ff", + "multiplier.py": "e805fb05caaa76d4c65dc3a55b99c6332a1c3772516547cf24e8027ade718cf4", + "quotient_route.py": "3243f45d6097a80bc8b077d8682426e4555f6c4a3097bd0a12ffd4f1f5c45ba8", +- "receiver.py": "09d2e9508e3e34934a6f2132c6e864f6b4ba68fa96aaadbec0a1902aa7762642", ++ "receiver.py": "5d9faeabe8ccc4a4ccf670f91322016cf33b2c2a497fd78b41f3750fbadae560", + "retained.py": "970e71bb0fcab41a03ccc5068ddc5e0df5c00953098f542fdc1a3e0e2048ffda", + "same_order_body.py": "56a15ce431daf25794741cb5157e136ce509ed646b32aaea34348088396e459d", + "staged_carriers.py": "6c925ae4b39dc9999ac5891d1a27dcbb38e129a36e1473b2b418f27a806b6fc4", + "triangular_ordinary.py": "1f69f21881229566e0b251a2edd8a3c9ac6409eeebdb68ee046f27e74dd8af71" +- } ++ }, ++ "local_derivatives": [ ++ "direct_body.py", ++ "receiver.py" ++ ] + } diff --git a/research/p104-k7-retimed-binary/retimed_supplier.py b/research/p104-k7-retimed-binary/retimed_supplier.py new file mode 100644 index 0000000000..388b2cf659 --- /dev/null +++ b/research/p104-k7-retimed-binary/retimed_supplier.py @@ -0,0 +1,162 @@ +"""Run two column scales of the tagged 48-call word in the signed positive receiver.""" + +from fractions import Fraction as F +from collections import Counter + +from upstream import HERE, install + +_, _, _, source = install() +from positive import Positive as RetainedPositive, one_axis, power_le +from periodic import Job +from raw48 import ComplexRaw +from spool import scratch, snapshot, transfer +from strong_complex import artifacts, word +from transport import Recipe +from installations import GAUSSIAN_C +from unpowered_price import certify + + +SCALES = (1, 8) +SMALL_SPLITS = 1008 + + +class Raw: + def __init__(self, tagged, physical): + self.tagged = tagged + self.physical = physical + + def native(self, ports, columns): + if columns <= 0 or columns % 2: + raise ValueError("Each split needs a positive even column count") + if len(ports) != len(SCALES) * len(self.tagged.targets): + raise ValueError("Each true target needs one complete owner") + if len({job.owner for job in ports}) != len(ports): + raise ValueError("Every productive port needs its own live owner") + source = iter(ports) + for scale in SCALES: + width = columns * scale + inputs = [] + for label in self.tagged.targets: + job = next(source) + if len(job.axes) != label.rank * width: + raise ValueError("A target has the wrong number of physical axes") + inputs.append((label.tag, job)) + actual = self.physical.raw(inputs, width) + splits = 0 + for label in self.tagged.paid: + tag, job = next(actual) + if tag != label.tag or len(job.axes) != label.rank * width: + raise ArithmeticError("The physical cut differs from the installed word") + if scale == 1 and label.rank == 1 and splits < SMALL_SPLITS: + yield job.select(range(width // 2)) + yield job.select(range(width // 2, width)) + splits += 1 + else: + yield job + if next(actual, None) is not None or (scale == 1 and splits != SMALL_SPLITS): + raise ArithmeticError("The numerical word did not close at its final loan") + + +def source_ranks(tagged): + targets = tuple(scale*p.rank for scale in SCALES for p in tagged.targets) + slots = [] + for scale in SCALES: + splits = 0 + for port in tagged.paid: + if scale == 1 and port.rank == 1 and splits < SMALL_SPLITS: + slots.extend((F(1, 2), F(1, 2))) + splits += 1 + else: + slots.append(scale * port.rank) + if scale == 1 and splits != SMALL_SPLITS: + raise ArithmeticError("The base copy has too few rank-one requests") + return targets, tuple(slots) + + +class Positive(RetainedPositive): + def __init__(self, rank_log, denominator=10**14): + atlas = artifacts( + source / "research/grade14-native-realization", HERE / "inputs" + ) + native = word(atlas.graph, atlas.layout) + super().__init__(native, atlas, 1 << rank_log, denominator) + + targets, paid = source_ranks(native) + margin, cells = certify(GAUSSIAN_C, (Counter(targets), Counter(paid))) + if cells is None or margin <= 0: + raise ArithmeticError("The Gaussian word has insufficient column capacity") + self.recipe = Recipe(rank_log, max(SCALES)*native.ambient, targets, paid, cells, GAUSSIAN_C) + + @property + def owners(self): + return self.recipe.width + + def _run(self, field, low, selected, columns, root_width): + window = columns.window + n = self.carrier + if selected <= n or power_le(selected, self.denominator, root_width): + for i in range(selected): + one_axis(field, low + i * window + columns.offset) + return + bundle, extra = divmod(selected, n) + for i in range(selected - extra, selected): + one_axis(field, low + i * window + columns.offset) + rows = self.owners + remain = field.ambient_bits - (rows.bit_length() - 1) + if remain < max( + low + (selected - extra) * window, + columns.u + (bundle - 1) * columns.digit, + columns.t + (bundle - 1) * columns.digit, + ): + raise ValueError("The positive field has no independent row reserve.") + total = field.count * field.record + part = total // rows + with field.arena.child(remain) as frame: + fields = {} + with snapshot(field.stream, total) as incoming: + for i in range(rows): + fields[i] = frame.field() + transfer(incoming, fields[i].stream, part) + physical = ComplexRaw( + self.physical, fields, columns, low=low, bundle=bundle, slots=n + ) + adapter = Raw(self.word, physical) + outer = self + + class Machine: + native = staticmethod(adapter.native) + + @staticmethod + def zero(exemplar): + return physical.fresh( + exemplar, len(exemplar.axes), ("transport-zero",) + ) + + retire_zero = staticmethod(physical.retire) + + @staticmethod + def leaf(job): + (axis,) = job.axes + outer._run( + fields[job.owner], + low + axis * bundle * window, + bundle, + columns, + root_width, + ) + + lanes = [Job(i, tuple(range(n))) for i in range(rows)] + self.recipe.open().run(lanes, Machine()) + if len(fields) != rows: + raise ArithmeticError( + "A native owner is still active at the positive return." + ) + with scratch() as outgoing: + for i in range(rows): + owned = fields.pop(i) + owned.stream.seek(0) + transfer(owned.stream, outgoing, part) + owned.retire() + outgoing.seek(0) + field.stream.seek(0) + transfer(outgoing, field.stream, total) diff --git a/research/p104-k7-retimed-binary/strong-bit-k7.json.gz b/research/p104-k7-retimed-binary/strong-bit-k7.json.gz new file mode 100644 index 0000000000..f334b505e6 Binary files /dev/null and b/research/p104-k7-retimed-binary/strong-bit-k7.json.gz differ diff --git a/research/p104-k7-retimed-binary/transport.py b/research/p104-k7-retimed-binary/transport.py new file mode 100644 index 0000000000..7006360e5b --- /dev/null +++ b/research/p104-k7-retimed-binary/transport.py @@ -0,0 +1,357 @@ +"""Compile a finite time schedule for an unpowered native word with descending loans.""" + +from collections import defaultdict +from dataclasses import dataclass +from fractions import Fraction as F +from math import isqrt + + +def ceil(q): + return -(-q.numerator // q.denominator) + + +class Measure: + """Enclose integrals of V*x**(-1-t) at rational interval endpoints.""" + + def __init__(self, t, volume, precision): + if t <= 0 or t > 1 or t.denominator.bit_count() != 1: + raise ValueError( + "The density needs a dyadic exponent between zero and one." + ) + self.t, self.volume, self.grid = t, volume, 1 << precision + + def inverse_power(self, x): + t, g = self.t, self.grid + q = g / F(x) + a, b = q.numerator // q.denominator, ceil(q) + lo = hi = g + for j in range(t.denominator.bit_length()): + if (t.numerator >> (t.denominator.bit_length() - 1 - j)) & 1: + lo, hi = lo * a // g, -(-hi * b // g) + if j + 1 != t.denominator.bit_length(): + a = isqrt(a * g) + b = isqrt(b * g - 1) + 1 + return lo, hi + + def mass(self, left, right): + if right <= left: + return F(0), F(0) + a, b = self.inverse_power(left) + c, d = self.inverse_power(right) + scale = F(self.volume, self.grid) / self.t + return max(0, a - d) * scale, (b - c) * scale + + +@dataclass(frozen=True) +class Link: + start: int + count: int + band: int + port: int + other: int + + +@dataclass(frozen=True) +class Source: + start: int + count: int + base: int + period: int + + +def axes(length, size, period, row): + five = (period * size - length) // 4 + for ticket in range(row, period * size, period): + yield ticket // 5 if ticket < 5 * five else ticket - 4 * five + + +class Plan: + def __init__( + self, + n, + targets, + paid, + cells, + t, + lower, + upper, + volume, + ticks, + rounds, + *, + delay_base, + scale_step=F(6, 5), + padding=4096, + width=None, + ): + if not 0 < lower < upper or lower % 2 or upper % 2 or lower <= 8: + raise ValueError( + "The scale endpoints must be even and the column count positive." + ) + if n % 4 or n < 4 * max(targets) * (upper - 8) or delay_base < len(paid): + raise ValueError("The word or periodic source does not fit the carrier.") + self.n, self.targets, self.paid = n, tuple(targets), tuple(paid) + self.ticks, self.rounds = ticks, rounds + self.bands = range(lower, upper, 2) + self.delay, self.count = {}, {} + self.send, self.receive, self.sources = ( + defaultdict(list), + defaultdict(list), + defaultdict(list), + ) + self.source_width = 0 + t = F(t) + measure = Measure(t, volume, max(256, 64 * n.bit_length())) + ids = defaultdict(list) + for i, k in enumerate(targets): + ids[k].append(i) + by_paid = defaultdict(list) + for (r, k), share in cells.items(): + if r <= 0 or not ids[k] or share <= 0 or 5 * r > 4 * k: + raise ValueError( + "Every positive transport cell needs a funded descending edge." + ) + for i in ids[k]: + by_paid[r].append((i, k, F(share) / len(ids[k]))) + for r in set(paid): + if sum(q for i, k, q in by_paid[r]) != 1: + raise ValueError("Every paid label needs a complete probability row.") + headroom = defaultdict(int) + level, limit = 0, F(lower) + for e in self.bands: + while limit * scale_step <= e: + level += 1 + limit *= scale_step + self.delay[e] = delay_base**level + self.count[e] = ceil(measure.mass(e, e + 2)[1]) + for e in self.bands: + for j, r in enumerate(paid): + used = 0 + for i, k, share in by_paid[r]: + left, right = F(e * r, k), F((e + 2) * r, k) + low = max(lower, 2 * (left // 2)) + high = min(upper, 2 * ceil(right / 2)) + for d in range(low, high, 2): + if self.delay[d] >= self.delay[e]: + raise ValueError( + "An allocated loan would miss its return time." + ) + a, b = max(e, F(d * k, r)), min(e + 2, F((d + 2) * k, r)) + q = measure.mass(a, b)[0] * share + number = q.numerator // q.denominator + if number: + offset = headroom[d, i] + self.send[e, j].append(Link(used, number, d, i, offset)) + self.receive[d, i].append(Link(offset, number, e, j, used)) + headroom[d, i] += number + used += number + if used > self.count[e]: + raise ArithmeticError( + "Outgoing allocations exceed the available copies." + ) + for e in self.bands: + for j, r in enumerate(paid): + for i, k, share in by_paid[r]: + a, b = max(upper, F(e * k, r)), F((e + 2) * k, r) + q = measure.mass(a, b)[0] * share + number = q.numerator // q.denominator + if not number: + continue + size = (e - 8) * k + period = 4 * ceil(F(n, 4 * size)) + base = self.source_width + self.source_width += number * ticks * (rounds // period) + self.sources[e, i].append( + Source(headroom[e, i], number, base, period) + ) + headroom[e, i] += number + for (e, i), num in headroom.items(): + if num > self.count[e]: + raise ArithmeticError( + "More fields reached an input than there are native copies." + ) + if self.source_width <= 0: + raise ValueError("The epoch has no complete productive period.") + minimum = 1 << (padding * self.source_width - 1).bit_length() + self.width = minimum if width is None else width + if self.width < minimum or self.width.bit_count() != 1: + raise ValueError("The productive width must cover all complete source periods") + + def _external(self, band, port, replica, birth): + size = (band - 8) * self.targets[port] + for src in self.sources.get((band, port), ()): + offset = replica - src.start + if 0 <= offset < src.count: + cycles = self.rounds // src.period + base = src.base + (birth * src.count + offset) * cycles + return (2, base, size, src.period) + return (0, size) + + def events(self): + serial = 0 + q = len(self.paid) + maximum = max(self.count.values()) + span = (self.bands.stop - self.bands.start) // 2 + + def frame(e, tick, rep): + return (tick * span + (e - self.bands.start) // 2) * maximum + rep + + for tick in range(self.ticks + q * max(self.delay.values())): + pending = {} + for e in self.bands: + birth = tick - q * self.delay[e] + if 0 <= birth < self.ticks: + for rep in range(self.count[e]): + yield (2, frame(e, birth, rep)) + for e in reversed(self.bands): + step = self.delay[e] + for j in range(q): + birth = tick - j * step + if not 0 <= birth < self.ticks: + continue + for rep in range(self.count[e]): + ident = frame(e, birth, rep) + if not j: + row = [0, ident, e - 8] + for i in range(len(self.targets)): + loan = pending.pop((e, rep, i), None) + if loan is not None: + row.extend((1, loan)) + continue + for link in self.receive.get((e, i), ()): + if 0 <= rep - link.start < link.count: + if tick >= link.port * self.delay[link.band]: + raise ArithmeticError( + "A scheduled parent loan did not arrive." + ) + break + row.extend(self._external(e, i, rep, birth)) + yield tuple(row) + selected = 0 + if tick < self.ticks: + for link in self.send.get((e, j), ()): + d = rep - link.start + if 0 <= d < link.count: + selected = self.targets[link.port] * (link.band - 8) + key = link.band, link.other + d, link.port + if key in pending: + raise ArithmeticError( + "Two parents supplied the same input." + ) + pending[key] = serial + break + size = self.paid[j] * (e - 8) + if size != int(size) or not 0 <= selected <= size: + raise ArithmeticError( + "The parent cannot cover the selected interval." + ) + yield (1, ident, serial, int(size), selected) + serial += 1 + if pending: + raise ArithmeticError("A pending loan was not collected.") + + @property + def leaves_per_epoch(self): + count = 0 + q = len(self.paid) + for e in self.bands: + for j in range(q): + full = self.ticks * self.count[e] * self.paid[j] * (e - 8) + routed = max(0, self.ticks - j * self.delay[e]) * sum( + link.count * self.targets[link.port] * (link.band - 8) + for link in self.send.get((e, j), ()) + ) + count += full - routed + if count != int(count): + raise ArithmeticError("The paid interval has a fractional axis.") + return int(count) + + def decode(self, rows, round_no, group, machine, records): + live, pending = {}, {} + for row in records: + op, ident, *args = row + if op == 0: + columns, *bindings = args + ports, zeros = [], [] + cursor = iter(bindings) + for kind in cursor: + if kind == 1: + ports.append(pending.pop(next(cursor))) + continue + base = next(cursor) if kind == 2 else None + size = next(cursor) + if base is not None: + period = next(cursor) + cycle, step = divmod(round_no, period) + index = group * self.source_width + base + cycle + if cycle < self.rounds // period and index < self.width: + ports.append( + rows[index].select(axes(self.n, size, period, step)) + ) + continue + job = machine.zero(rows[0].select(range(size))) + ports.append(job) + zeros.append(job) + live[ident] = iter(machine.native(ports, columns)), zeros + elif op == 1: + serial, size, selected = args + job = next(live[ident][0]) + if len(job.axes) != size: + raise ArithmeticError( + "The physical native word issued the wrong rank." + ) + for k in range(selected, size): + machine.leaf(job.select((k,))) + if selected: + pending[serial] = job.select(range(selected)) + else: + iterator, zeros = live.pop(ident) + if next(iterator, None) is not None: + raise ArithmeticError("The word emitted an extra loan.") + for job in zeros: + machine.retire_zero(job) + if live or pending: + raise ArithmeticError("The last native owner did not return.") + + def run(self, rows, machine): + if len(rows) != self.width: + raise ValueError("The caller has the wrong productive width.") + for group in range(ceil(F(self.width, self.source_width))): + for round_no in range(self.rounds): + self.decode(rows, round_no, group, machine, self.events()) + + +class Recipe: + def __init__( + self, rank_log, ambient, targets, paid, cells, trial, level_floor=2**15 + ): + if rank_log < 1024: + raise ValueError( + "The production width proof requires rank_log at least 1024." + ) + self.rank_log, self.ambient = rank_log, ambient + self.targets, self.paid, self.cells = targets, paid, cells + self.trial, self.level_floor = trial, level_floor + self.width_log = 92 * rank_log + + @property + def width(self): + return 1 << self.width_log + + def open(self): + n = 1 << self.rank_log + upper = 2 * (n // (2048 * self.ambient)) + return Plan( + n, + self.targets, + self.paid, + self.cells, + 1 - self.trial, + self.level_floor, + upper, + n**6, + n**82, + n**2, + width=self.width, + delay_base=1 << max(19, (len(self.paid) - 1).bit_length()), + ) diff --git a/research/p104-k7-retimed-binary/true_high.py b/research/p104-k7-retimed-binary/true_high.py new file mode 100644 index 0000000000..33573b2847 --- /dev/null +++ b/research/p104-k7-retimed-binary/true_high.py @@ -0,0 +1,70 @@ +"""Execute all 16 canonical low classes and their 27 genuine lifts at modulus nine.""" + +from collections import Counter +from fractions import Fraction +from io import BytesIO +from math import prod +from pathlib import Path +import sys + +from direct_exact import exact_projector + + +def main(package): + sys.path.insert(0,str(package)) + from upstream import install + install() + from binary_receiver import Receiver + from check_module_atoms import expected_packet,payload + from factored_frames import Frame + from quotient_route import canonical_lows,representative + from five_exchange import corner_exchanges + class Measured(Receiver): + def weighted(self,*args,**kwargs): + self.calls+=1 + return super().weighted(*args,**kwargs) + n=2;mod=9 + machine=Measured(n,(1,2,0,0),direct=False) + machine.calls=0 + word=(("add",0,1,1),("add",1,0,Fraction(1,2)),("scale",0,-1)) + frame=Frame(2,word,(1,)) + uu,vv=exact_projector(n,word,1) + def residue(x): + return x.numerator*pow(x.denominator,-1,mod)%mod + ru,rv=list(map(residue,uu)),list(map(residue,vv)) + heights=machine.high + assert heights==27 and machine.low==16 + maps={};cases=Counter();nontrivial=set() + for low_no,low in enumerate(canonical_lows(n)): + indexes=set() + for high in range(heights): + # Chart lifts and an independent two-by-two inverse give true factors. + (a,b),(c,d)=representative(low,high,n,2) + invdet=pow((a*d-b*c)%mod,-1,mod) + u=((a*ru[0]+b*ru[1])%mod,(c*ru[0]+d*ru[1])%mod) + v=(invdet*(d*rv[0]-c*rv[1])%mod,invdet*(-b*rv[0]+a*rv[1])%mod) + assert sum(i*j for i,j in zip(u,v))%mod==1 + pivot=next(i for i in range(n) if u[i]*v[i]%3) + size=2*len(corner_exchanges(u,v,pivot))+1 + indexes.add(size);maps[low_no,high]=(u,v) + nontrivial.add((u,v)) + assert len(indexes)==1 + cases[next(iter(indexes))]+=1 + dims=(16,27,9,9,9,9) + def img(low,high,h0,h1,t0,t1): + u,v=maps[low,high] + a,b=2,5 + delta=v[0]*(t0-5*h0)+v[1]*(t1-2*h1) + return low,high,(h0+a*u[0]*delta)%9,(h1+b*u[1]*delta)%9,(t0-u[0]*delta)%9,(t1-u[1]*delta)%9 + raw=payload(prod(dims));target=BytesIO() + with machine.storage(): + machine.serve_line(BytesIO(raw),target,frame,1,1,1,1,4,lambda old,i:(2,5)[i]) + assert machine.calls==sum(k*v for k,v in cases.items()) + assert target.getvalue()==expected_packet(raw,dims,img) + print("genuine lows",16,"high representatives",16*27,"distinct paired factors",len(nontrivial)) + print("records",prod(dims),"children",machine.calls,"class count",dict(cases),"arena",machine.last_storage) + + +if __name__ == "__main__": + from upstream import HERE + main(HERE) diff --git a/research/p104-k7-retimed-binary/unpowered_price.py b/research/p104-k7-retimed-binary/unpowered_price.py new file mode 100644 index 0000000000..8952084bc1 --- /dev/null +++ b/research/p104-k7-retimed-binary/unpowered_price.py @@ -0,0 +1,59 @@ +"""Check the literal raw ranks and a transport with a strict descent on every loan.""" + +from collections import Counter +from fractions import Fraction as F + +from upstream import HERE, install + +_, _, _, src = install() +from strong_complex import load_changed, word +from strict_moment import power_interval, UNIT + + +def ranks(): + graph, layout = load_changed(HERE / "inputs") + raw = word(graph, layout) + target = Counter(scale*p.rank for scale in (1, 8) for p in raw.targets) + paid = Counter(scale*p.rank for scale in (1, 8) for p in raw.paid) + paid[1] -= 1008 + paid[F(1, 2)] = 2016 + return target, paid + + +def intervals(r, t): + if r == F(1, 2): + low, high = power_interval(2, t) + return (UNIT * UNIT // high, -(-UNIT * UNIT // low)) + return power_interval(int(r), t) + + +def certify(C, census=None): + t = 1 - C + targets, paid = ranks() if census is None else census + target_mass = {k: n * intervals(k, t)[0] for k, n in targets.items()} + paid_mass = {r: n * intervals(r, t)[1] for r, n in paid.items()} + target_total, paid_total = sum(target_mass.values()), sum(paid_mass.values()) + if target_total <= paid_total: + return 1 - F(paid_total, target_total), None + margin = 1 - F(paid_total, target_total) + capacity = {k: F(x * paid_total, target_total) for k, x in target_mass.items()} + cells = {} + for r in sorted(paid, reverse=True): + remain = paid_mass[r] + for k in sorted(targets, reverse=True): + if 4 * k < 5 * r or not remain: + break + part = min(remain, capacity[k]) + if not part: + continue + cells[r, k] = F(part, paid_mass[r]) + capacity[k] -= part + remain -= part + if remain: + raise AssertionError((r, remain)) + assert all(not x for x in capacity.values()) + assert all(sum(q for (p, k), q in cells.items() if p == r) == 1 for r in paid) + for k in targets: + incoming = sum(paid_mass[r] * q for (r, z), q in cells.items() if z == k) + assert incoming == F(target_mass[k] * paid_total, target_total) + return margin, cells diff --git a/research/p104-k7-retimed-binary/verify.py b/research/p104-k7-retimed-binary/verify.py new file mode 100644 index 0000000000..51fa5a1b0b --- /dev/null +++ b/research/p104-k7-retimed-binary/verify.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +"""Restore the exact predecessor, install this construction and check its paths.""" + +from argparse import ArgumentParser +from pathlib import Path +import runpy +import sys +from tempfile import TemporaryDirectory + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +from bootstrap import install + + +def check(mode, tree): + install(tree) + sys.path.insert(0, str(tree)) + from upstream import install as dependencies + + dependencies() + if mode == "cost": + from check_complete import verify + + verify() + elif mode == "product": + from installations import EXTENDED + from check_product import physical_product + import band_product + + observed = [] + + def first_dispatch(frame, event, arg): + if event == "call" and frame.f_code is band_product.h_pack.__code__: + call = frame.f_locals + assert call["machine"].profile is EXTENDED + assert call["make_supplier"].func is band_product.production_supplier + observed.append((call["rank_log"], call["make_supplier"].args, call["machine"].total)) + sys.setprofile(None) + + sys.setprofile(first_dispatch) + try: + info = physical_product(EXTENDED) + finally: + sys.setprofile(None) + assert observed == [(EXTENDED.complex_log, (EXTENDED.complex_log, EXTENDED.positive_stop_denominator), 32)] + assert info["product"] == "-345550037539" and info["shuttles"] == 138 + assert info["coefficients_prefix"] == [11811, 10996, 4152, 868, 77] + print(info) + else: + files = { + "binary": ["check_binary_k7", "check_binary_word"], + "schedule": ["check_chronology", "check_precision", "check_streamed", "check_reentry"], + "install": ["check_installation", "check_scans"], + "physical": ["check_binary_word", "check_positive_word", "check_extended_stop"], + "receiver": ["check_five", "check_nonzero_eight", "direct_exact"], + "slabs": ["check_stage_fences", "check_stage_inventory"], + } + for name in files[mode]: + runpy.run_path(str(HERE / (name + ".py")), run_name="__main__") + print("PASS_K7_RETIMED_BINARY", mode) + + +def main(): + parser = ArgumentParser(description="Restore the exact predecessor, install the k7 retimed construction and verify it.") + parser.add_argument( + "mode", + choices=("binary", "cost", "schedule", "install", "physical", "receiver", "slabs", "product"), + ) + args = parser.parse_args() + with TemporaryDirectory() as root: + check(args.mode, Path(root) / "tree") + + +if __name__ == "__main__": + main()