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/retimed-native-multiplier/ACTIVATION.md b/research/retimed-native-multiplier/ACTIVATION.md new file mode 100644 index 0000000000..c84980c3b7 --- /dev/null +++ b/research/retimed-native-multiplier/ACTIVATION.md @@ -0,0 +1,53 @@ +# Complete activation at the seven revised rank lists + +Write n for the larger significant bit length, p=6 ceil(log₂ n), s=ceil(log₂(p+2)), T for the true outer padded extent, and k=floor(s/2)−2. The first sufficient significant length is 2^(ceil(2^A/6)−1)+1. At this length a genuine positive source touches the top ordinary stage through the actual full-slot operation. It is an applicability bound. The table counts the first full historical storage as well as true geometric entry. A performance crossover has not been measured. + +| Rate profile | Positive log rank | Largest binary log rank | Last ordinary cut | A | First stripe surplus | Proved surplus for every later s | +|---|---:|---:|---:|---:|---:|---:| +| Selected-rate | 1,024 | 5,610 | 5,697 | 6,913 | 1,443 | 1,385 | +| Small | 1,600 | 18,400 | 18,539 | 20,345 | 8,151 | 7,892 | +| Compact | 8,500 | 144,000 | 153,265 | 161,992 | 78,958 | 76,498 | +| Balanced | 19,000 | 12,800,000 | 13,655,297 | 13,674,566 | 6,835,217 | 6,621,647 | +| Near | 19,000 | 222,000,000,000 | 237,047,764,578 | 237,047,783,945 | 118,523,889,843 | 114,820,018,369 | +| Matched | 19,000 | 396,000,000,000,000 | 422,797,742,610,827 | 422,797,742,630,271 | 211,398,871,312,958 | 204,792,656,584,555 | +| Resolution | 19,000 | 95,600,000,000,000,000 | 101,973,332,976,337,867 | 101,973,332,976,357,367 | 50,986,666,488,176,470 | 49,393,333,160,421,113 | + +The first selected geometry contains 2^6888 actual square axes. Its largest axis has 5,592,406 address bits. Output precision and the astronomical full tensor still dominate feasibility. + +## Entry and precision + +At stage i, a_i=max(ceil(250(H_i+64)/249),H_i+64+a_(i−1)); omit the second term for the first stage. Each subsequent H_i exceeds a_(i−1)+2. The rank's true owner product is N_i^92 below its N_i^105 reserve bound. A positive source uses M^92 below its M^448 bound, retains all tail and high coordinates, and passes 872(4H_M+1)1. Its integral over the width-two target bin, including the dilation and 1/624 share, exceeds two replicas since V=M^6 and x≤M. The first assigned replica of group zero and round zero is a real row (h0=4096h for H>=1024. For a tighter upper bound on the actual executed copy count, the true external sizes per time sum to at least eta(1−2^-128) V U^c Ψ > V, since U>1, eta>0.99 and Ψ>0.19P>1.9. The physical periods satisfy qs'/N<=1+4/1024. Thus h >= K(R/N)(1-1/N)sum(s')/(1+4/1024)>KVN/2, where the integer source loss has already been counted in the lower bound on sum(s'). With K=N^82,V=N^6 this gives + + 1 <= z=ceil(B/h) < 3N^3, + z*h/B <= 1+1/4096, + B=N^92 < N^448. + +Every one of these z copied programs really runs. A whole last group can have arbitrary fields and zeros at different sources. In an incomplete period releases occur at each native return. The shared decoder checks its real row ordinal against B, and fills every other required port with a distinct complete zero in the current cohort. These copies are included in both native price bounds. It makes B an explicit architectural parameter whose bit size is paid. At compact H=8500 it is 2^782000 fields. At the matched positive H=19000 it is 2^1748000 fields. The earlier 2^91H *upper limit* on the number of slots does not make the extra rows or their copies free. + +## Complete per-use control and per-field cost + +There are <2K time instants and =1024. This includes both copies when a rank-one native request supplies two half-column loans. Iterator resume is sequential. For a sequential tape simulation allow even a scan of all fixed-rank control stores on every access. The current physical owners and descriptors, including the B real rows, have at most N^96 fixed-rank control bits: B rows can each record N ordered axes with O(H) bits per axis; uncompleted raw units number at most 2VN^77 and have fewer than 2^64 associated base field descriptors. On updates a second tape permits a complete sequential rewrite, with all seeks and erasure. Even charging the square of N^96 moves per logical visit and allowing two further powers of the store for encoding scratch and restoration uses fewer than N^700 purely structural transitions per *active numerical invocation*. Its actual field volume exceeds 2^N>N^700. This absorbs pure preparation into one field pass. It does not absorb or remove any movement of real payloads. + +## Fixed setup on a sequential machine + +Use separately delimited words on the fixed tapes of [the outer clock](OUTER-CLOCK.md). The pinned input manifest covers the archive, nested archives and source digests. Its expanded inputs total 6,788,928 bytes. Count inflate and hashing, parsing, rational row changes, generation of frames from signs and phases, slot ordering, basis compilation, grade coupling, writing the resulting tables, rewinds and disposal. The native seed contains all fixed source graphs; no input digit enters it. + +The fixed positive source gives a $2^{64}$ bound on the index operations that reconstruct the frame pairs before sequential tape lowering. The 1,103 absolute frames have at most 18 signed tableau rows. Each pair needs fewer than 32 elementary frame factors and at most 128 factors for a derived monomial. Phase matching acts on its 512-entry vector. There are three quotient journals and two helper steps, with fewer than $2^{13}$ rows and slots per loop and at most $2^{26}$ local donor pairs. The finite journal replay, sorting, ready list and incidence passes take fewer than $2^{50}$ scalar or indexed operations. Allow another $2^{64}$ such actions for all finite signed atlas, source, label and coupling scans. [Predecessor generator and scalar proof](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/STRONG-COMPLEX.md) + +For the binary word scan every fixed byte, all 39,600 graph opcodes, 36 LOCAL events, all starts and ends, and every chart pair. Projectors, subtraction, elimination and basis replay each use matrices of order eight. Each reduction uses eight pivots, with two eliminations per pivot and eight row operations of width eight. Even rescanning all $2^{16}$ graph records per pair and per pivot leaves fewer than $2^{50}$ indexed operations. The binary and positive coupling use at most 61 dyadic power steps per grade, compare fewer than $256^2$ grade pairs, and build the individual label lists by sequential scans. The complete fixed work on all claimed installations has fewer than $2^{68}$ such actions, before tape lowering. [Literal scalar and source evidence](check_installation.py) · [Exact stage preparation](machine.patch) + +The finite trace observes all returned Fraction values during both preparations. The seven-profile instrumented run returned 14,932,186 reduced rational results, with at most 262 bits per numerator or denominator and no premature calendar. The first six profiles returned 14,928,855 results. Ordinary numerator products stay below 4,096 bits before reduction. The fixed Pauli operations use at most 128 layers on nine coordinates. The implicit growing rank words are kept as their installed logarithms, except for the numerical rank below $2^{19001}$. With fixed data strings shorter than $2^{38}$ bits per item, even appending a separate item for every indexed action fits $2^{106}$ tape cells. A delimited-key read or rewrite can use a quadratic scan of this store. Schoolbook division and Euclid on one $2^{38}$-bit item cost less than $2^{135}$ transitions. Charging both even for each candidate of an indexed search fits $2^{400}$ per indexed action. Allow an additional factor $2^{32}$ for parsing and hashing the actual immutable bytes, sequential spools, stable total ordering, control counters and clearing. Thus the whole fixed generation, initialization and installed size are bounded by $2^{513}$ transitions or bits, respectively. The measured Python installation and this deliberately loose serial bound are separate numbers. + +The exponential width of an active cohort remains a real resource. The complete upper bounds on input-dependent control, recurring data movement and all-size historical storage appear in [the clock](CLOCK.md) and [the activation proof](ACTIVATION.md). The expanded installer of the physical predecessor actually visited more than $2^{7(H-2-9v)}$ binary records on the stated heights with strictifier power $v$. The counted installation of PR #8040 already removed those visits. These are two distinct comparators. [Earlier lower bound and six counted setup ceilings](https://github.com/aliromman/integer-mult-bounds/blob/1ca6b8111297ac2cc2dcfe5da0027656898f7589/research/counted-native-bands/RESULT.json) diff --git a/research/retimed-native-multiplier/LICENSE b/research/retimed-native-multiplier/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/NOTICE.md b/research/retimed-native-multiplier/NOTICE.md new file mode 100644 index 0000000000..68f00c098e --- /dev/null +++ b/research/retimed-native-multiplier/NOTICE.md @@ -0,0 +1,9 @@ +Ali Romman prepared the retimed column construction, direct/quotient reflection, two-scale Gaussian receiver, signed physical integration, and the proofs and tests, with substantial OpenAI Codex assistance. Author-side adversarial checks are included. Independent scientific review remains open. The source and predecessor packages retain their Apache 2.0 notices. + +- Ali Romman's [PR #8030](https://github.com/CrocSwap/integer-mult-bounds/pull/8030) supplies the executable single-band physical baseline, tagged word interpreters, linear square geometry, stopped positive call and signed entry. [Original complete attribution](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/NOTICE.md) +- Clear1nsight’s [PR #8033](https://github.com/CrocSwap/integer-mult-bounds/pull/8033) supplied the tilted split tariff and [PR #8035](https://github.com/CrocSwap/integer-mult-bounds/pull/8035) the modified stopping margin, signed comparison and portable archived sources. The 54 strict and four functional outer inequalities are reproduced under the original license. [Signed source evidence](https://github.com/CrocSwap/integer-mult-bounds/blob/ea776471bf8ed143a0625cf2d7532f65d15eb5f9/research/p104-single-band-signed-margin/README.md) +- The two paid words and their original helper sources come from Ali Romman’s [PR #8027](https://github.com/CrocSwap/integer-mult-bounds/pull/8027). It credits Clear1nsight's iterated-return programs and scalar audit. [PR #7981](https://github.com/CrocSwap/integer-mult-bounds/pull/7981) and [PR #7914](https://github.com/CrocSwap/integer-mult-bounds/pull/7914) supply earlier physical storage, matrix routing, precision and signed product work. The expanded histories and notices remain in the archived source. +- [PR #8040](https://github.com/CrocSwap/integer-mult-bounds/pull/8040) first removed the expanded fixed epoch by counting powered grades and regenerating the real labels. This work changes the physical use of the raw word and the required rank. [Predecessor setup receipt](https://github.com/aliromman/integer-mult-bounds/blob/1ca6b8111297ac2cc2dcfe5da0027656898f7589/research/counted-native-bands/RESULT.json) +- The unchanged canonical selection credits Jerry Chen / CubeJerry, DreamingOfClouds and the shared native work. The separate existing historical verification repair originated in [PR #7257](https://github.com/CrocSwap/integer-mult-bounds/pull/7257). [Selected application](https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/certificates/selected-result.json) + +Clear1nsight supplied the 430-factor trial, its attainment, exact six-stage upper bound and predecessor tape bridge in [PR #8044](https://github.com/CrocSwap/integer-mult-bounds/pull/8044). The archived receipt is reproduced under its Apache 2.0 license. The seventh retimed stage, full-cost comparison, sharper all-size stop accounting and lower bounds across stage counts are this package’s contributions. [Pinned predecessor](https://github.com/Clear1nsight/integer-mult-bounds/blob/c3746ea769fcf0d20818d7e18366f1b602e4aa3d/research/p104-six-stage-resolution/README.md) diff --git a/research/retimed-native-multiplier/NUMERICAL.md b/research/retimed-native-multiplier/NUMERICAL.md new file mode 100644 index 0000000000..1408078af3 --- /dev/null +++ b/research/retimed-native-multiplier/NUMERICAL.md @@ -0,0 +1,53 @@ +# The positive retimed call on the actual field + +The two source templates gave the following results in a separate replay. Each value in the height and mass columns is an upper bound. The mass bound uses absolute values at every donor sum. + +| Template | Exact required mixed grid | Caller height | At a graph entrance | Combined height | Ceiling of log2 combined mass | +| --- | ---: | ---: | ---: | ---: | ---: | +| A | 4 | 43 | 41 | 71 | 238 | +| Rotated | 8 | 121 | 118 | 148 | 436 | + +The independent unsigned program in `check_precision.py` follows every template event and all 323,573 scalar donor edges of the graph. It also calls the predecessor's signed basis and mixed-caller verifiers on the two digest-checked actual source files. These verified 25,146,238 basis products and 17,231,591 nontrivial divisions before multiplication. The full row and phase verification for the retained raw word is in [the physical source](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/STRONG-COMPLEX.md). The divisions in the mixed templates deserve a separate check. The signed Laurent evaluator checks each Cartesian product for SCALE, ADD and LAMBDA, as well as their sums. For every nonzero Cartesian rational in reduced form a/b, integrality of a·x/b implies b divides x. Thus the actual instruction can divide by all the positive short factors of b in order before multiplying by a. The output of a hosted graph is checked against the indicated HOST operator on every basis column, including independent helpers. One can replace a completed graph with that operator when continuing its template. + +## Precision along a real dependency + +Let D be the number of selected windows of one public positive call. The selected bit of each window has the same offset. A field restricted to a fixed assignment of all other coordinates has 2^D complex entries. The public shape first performs its complete placement swap. Its new slab has the highest r coordinate positions reserved for future row splits, where r=(2+ceil(log_M(D+1)))log2(Brow) and Brow=M^92. The two high controls, the complete selected windows, the low control and suffix all lie below that reserve. Each of the at most floor(log_M D) nested numerical splits removes exactly log2(Brow) leading positions. No split fixes a selected bit. Its arbitrary row label is another spectator assignment. See [the physical placement and reserve calculation](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/complex_stage.py). + +At a clean cut, express a row as a finite sum of c U x. Here x is one original spectator fibre, U is a Gaussian dyadic Clifford operator on the original D selected bits, and c is a Gaussian dyadic scalar. Different terms and different raw inputs can have different x and U. A completed alignment swaps whole windows, including both selected and spectator coordinates. Consequently it permutes the spectator assignment independently of the D-bit argument. Its selected permutation is a Clifford. The compact affine row can use dirty controls internally. This operation returns every control before it can yield to a raw child. Its transient rotate, permutation and repair passes only relocate a stored value or apply a phase. A partly written tape cell is an old or a new bounded scalar. No child reads a half-written field. A complete chart on the extant windows acts on the original D-bit factor. The return list reverses the physical alignment in order. + +Check the logical circuit first with exact rationals. At one unfinished raw call treat its productive field entrances as independent variables. The signed input grid, the completed hosted operators and the ordered donor proof above give a formal expanded row whose scalar coefficients add at most 148 to the dyadic height. At graph input the factor 2025 times the pre-HOST envelope covers every main field, while an independent helper still has relative input bound one. The graph first multiplies all its fields by its odd factor. Its absolute donor recurrence includes every partial donor sum. The log2 of the greatest resulting total mass is below 436. At graph exit the signed scaled endpoint has its odd factor on every Cartesian coefficient, so all short divisions also succeed in the inverse odd conversion. The same property holds at the final inverse 2025 conversion. These statements apply to every choice of entrances, including a different linear expansion for each one. If all incoming coefficient masses are at most A, a formal row of coefficients b_i has mass at most A times sum_i |b_i|. The source envelope bounds this whole sum. No factor proportional to the number of supplying parents occurs. + +Collapse each completed child to the separate signed Clifford promised to each of its own inputs before counting open contexts. The two chronological halves of a split commute on their disjoint selected columns. The elementary complement commutes with the selected prefix on disjoint axes. The native child restores its complement before the parent resumes. Different raw bindings can receive unrelated parents in one child. Their numerical debts combine by maximum as above. A dependency follows one entrance term at a time. The two column scales use disjoint owners in sequence. One causal term can traverse only one copy at any raw level. A continuing link from even bin e to d satisfies d<5e/6 for e>=32768 because k>=5r/4 and the width-two bins can add at most two to 4e/5. Since (6/5)^4>2 and the first bin is less than M=2^H, one level has at most 4H+1 open raw contexts along such a path. Earlier completed periods and other simultaneously open raw programs do not add debt. A new numerical level divides its parent width by M with floor. Thus K=(4H+1)floor(log_M D) bounds the full causal count. This induction is on the finite ideal schedule. It needs no previously exact finite-precision recursive call. + +The inherited Gaussian-dyadic Clifford row has denominator at most 2^ceil(D/2) and row Euclidean norm one. The root field was shifted left by D. For D>=M put ell=floor(log_M D). Then M ell<=D and 872(4H+1)=1024. Hence ceil(D/2)+148K<=D. The Cartesian magnitude exponent, apart from the original signed input and initial D-bit shift, is at most ceil((D+1)/2)+436K+1<=D+2. For D=p+8E. The arbitrary-input claim is for every integer operand, or for the advertised bounded Fourier pack. [Pack size, error and final product](https://github.com/CrocSwap/integer-mult-bounds/blob/9585c1fa2ed5f2316ac09e04b357cb720badfcb8/research/triangular-native-supplier/NUMERICAL-STORAGE.md). + +## True copying and stack high-water + +Use h0 for the actual external source width in one complete timed program, K0=M^82 birth times, V=M^6 for its density, and R=M^2 sequential rounds. The two-scale numerical word has W<2^17 independent targets and fewer than 2V live births per time. Hence h0<2K0VWR V. + +The linear-boundary calculation counts the actual occurrences in both copies. Here Ψ>0.19P, P>10, and U>1. It pays the integer allocation and the width lost at every source. For an external size s0 its period q=4ceil(M/(4s0)) satisfies q/R<=1/M and qs0/M<=1+4/1024. Then floor(R/q)>=(1-1/M)R/q, so + + h0 >= K0*(R/M)*(1-1/M)*sum(s0)/(1+4/1024) > K0*V*M/2. + +Thus z=ceil(Brow/h0)<3M^3, every one of these groups runs, and zh0/Brow<=1+1/4096. The final group can be partial. Maximum raw life is at most 1+Q max(delay)=H>=1024. This estimate only absorbs generation of descriptors; it makes no real data-head motion free. +* There are at most 87 small divisors of at most 24 bits and four 23-bit numerator limbs per fixed scalar. A high-to-low division has at most 2^9 bit steps per real input bit, and the Horner terms use fixed-width shifted additions. With the once-per-emitted-row literal and divisor selection charged to control, 2^25 bit steps per Gaussian field bit suffice for a scalar update. Preparation of fixed divisors by trial division, even if repeated per emitted literal, takes fewer than 2^60 fixed steps per selection and fits the generator bill. The two streams in scale_add are each completely staged before alternating Cartesian arithmetic on separate tapes. The component loop therefore has a bounded number of cohort traversals per field. The one-axis ADDS, shifts, two half streams, exact division, rewrite and clear require fewer than 2^40 bit steps per input-field bit and fixed number of cohort traversals. The compact chart uses at most 22 genuine grouped passes and its high single-column fix and stable sparse-repair. At an active call of width e and f=floor(e/M), every swap is at most 1+Mfk positions wide. Its fresh coefficient and inverse key take at most 2^80(p+2)^8 elementary steps per whole suffix group. The grouped suffix pays for this whenever present. The union-bound bad-group fraction is <=3p 2^(-4s'-6) and at most p radix passes operate on them, including their full data and tags. Thus a common row tariff per unit volume is <=2^50(1+Bord)M(1+k)(1+f)^(1-a), before long repositioning. [Physical row, repair and heads](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/compact_columns.py). +* Charge every one of the M^96 visits the larger parent volume v, and even allow a factor 4M^92 for full-cohort travel on all of them. Include newly allocated slots, snapshots, returns and clears. With local elementary and control terms the active cost is below M^193 v (1+Bord)(1+k)(1+f)^(1-a). Up to M-1 residual single axes on the incoming field have their inherited-frame charge 2^40(4M^92)v each, absorbed here. A stopped call of width e costs below 2^45 M^92(1+e)v. At an unplaced top stop, clear an L-bit mask and set the h selected bits by one indexed walk of at most 16(L+1) moves per bit. A parity evaluation scans the address and mask together and returns both heads in at most 32(L+1) moves per record. The public record already has at least p>=L bits and h<=L. Its two scalar conversions and complete tape scans fit the same allowance. +* The sum of physical input volumes at depth j is at most v M^((1-b)j). The bound comes from the actual F singleton calls divided by Brow, including partial groups. At an active level, f<=D/M^(j+1) and (1+f)^(1-a)<=2(D/M^(j+1))^(1-a). Since a0, e_j<=max(M,D^g). Use M^j<=D/e_j and (1-g)b>a to obtain M^((1-b)j) e_j <= M^b (1+D)^(1-a). This covers the full individual cost on the parent frame. The zero-width public case has only its prologue and clears. There are at most s+2 depths and k<=1030(s+1) on the outer packs. All displayed constants and transfers fit + + Z = M^220(1+Bord) + +in front of (s+1)^2 v (1+D)^(1-a). Charge the two public whole-support placement swaps separately to Bord. The public prologue increases component width by at most 2D+41 bits and D<=p<=P. The outer caller already pays this constant widening. The exponent 220 is a conservative number, not a measured optimum. The previous strict-band M^82 descriptor count and M^100 positive constant do not apply to this schedule. + +This is a written tape simulation and algebraic composition. The finite signed checks, additional unsigned replay and independent geometry/clock inequalities are executable. Lean coverage for the transport cost and return order is in the package's separate small theorems. This document does not claim a Lean verification of the raw source interpreter, arbitrary-input H accuracy, or the complete fixed-head clock. The original scientific assumptions on the outer multiplier and the active ordinary source have their previous scope. + +The seven-stage profile calls the same numerical word with D_stop=10^21. Its actual capped power test has a 70-bit exponent and at most 69 squares plus 29 selected multiplications. It short-circuits at e≤M. Otherwise the current e exceeds M. At the root its comparison limit h equals e. At a recursive test, the parent width is less than M(e+1); it passed the strict test parent^D_stop>h. Thus bitlength(h+2) is bounded by 3D_stop(1+log₂ e) whenever this nontrivial comparison is executed. Capped products have at most twice that width. The sequential cubic arithmetic bill per comparison is below 2^32(bitlength(h+2)+2)^3. For e>M≥2^1024 this fits one actual field scan of at least 2^e positions. The control returns and clears its temporary before the stopped or active branch. Previous frames and source fields keep their ordinary volume charges. The smaller stop margin changes the outer log absorption as proved in [the outer bill](OUTER-CLOCK.md). diff --git a/research/retimed-native-multiplier/ORDINARY-CLOCK.md b/research/retimed-native-multiplier/ORDINARY-CLOCK.md new file mode 100644 index 0000000000..7155d52a90 --- /dev/null +++ b/research/retimed-native-multiplier/ORDINARY-CLOCK.md @@ -0,0 +1,72 @@ +# An absolute ordinary interchange clock + +Fix one of the seven chronological binary and numerical profiles in `installations.py`. The retained receiver uses the arbitrary-payload physical charts of PR 7981 and the signed general caller of PRs 8030 and 8035. The unpowered source is the 36-call binary graph from PR 8027. Write `N=2^H`, `J=N^1024` separately at each stage. Count one read, write, or one-cell move on one fixed-alphabet work tape as one transition. Counting the operations of simultaneous heads separately can only raise this bill. Use the installed raw labels, the per-use chronological schedule from `transport.py`, and the serial physical work tapes. This is a bound on that specified sequential implementation. Python `TemporaryFile` seeks are an executable description of its routing and do not define a unit-cost random-access primitive. + +For two binary index fields of width `a>=0`, a positive prefix `P`, gap `G` and byte suffix `S`, let `V=P G S 2^(2a)`. With final ordinary saving `b`, the service takes at most + + 2^40 ((7·376/10))^m product_i J_i^16 · V (1+a)^(1-b) + +transitions, including admission, any cold range, the padded ternary rectangle and all returns. Here `m` in the final product of constants counts the selected ordinary stages. This is an upper bound on a recurring constant, without a matching lower bound or timing claim. The chosen fixed-tape implementation below makes the low-level normalization explicit. The computation in `check_complete.py` checks the numerical absorption, independently reads the raw moments, and evaluates every stage of the seven actual installations. The proof of the chronological bill and the finite-width storage conditions are separate. + +## Tapes and spectator dimensions + +A physical byte and frame delimiters use distinct symbols on a fixed alphabet. Store variable counters least significant bit first with a delimiting high bit. In a sequence of `q` decrements from `q`, the carry lengths sum to at most `2q+ceil(log2(q+1))`. Moving the counter head back doubles that bound. Copying the initial counter costs at most `q+1`. Thus an opaque `repeat(q)` loop uses fewer than `16(q+1)` control transitions aside from its body. Copy an opaque `size`-byte run with such a counter. Rewind to the physical segment delimiter and erase through the old end. The forward travel, return and erase cost fewer than `64(size+1)` transitions together. Split the public input into its `P` consecutive slabs, with `P=1` in the outer stage of each invocation. `root_body` always has its required owner stock in one slab. Write the completed slabs consecutively. This costs one public pass and avoids an operation on a numerical external prefix for each coefficient. There is no byte change to the returned string. + +`G` and `S` are opaque positive lengths. Store their factors as repeat counters or binary lengths. The returned weight at an internal row uses `older`, `atom^start`, its chart ordinal and the earlier weight. At entry `older=1`. A descendant increases `older` only by old head atoms and the true high chart. The external middle interval stays in the gap, and the exterior suffix stays in the suffix. Thus no algebraic coefficient uses the ordinal of a record in `P,G,S`. Addressed lower passes may have `G` inside a repeated prefix when both chosen fields are on the right. Restart the prefix counter once before processing the corresponding full interval. Applying an actual `G` or `S` as a length, including indexing its endpoint, is paid either once per whole slab or per complete contiguous interval containing that factor. Binary multiplication of lengths can use the bounded private factor as multiplier. If both opaque factors occur, pay the length arithmetic over their whole combined interval. For positive `Q`, `(1+ceil(log2(Q+1)))^5 <= 2^14 Q`; for `y=ceil(log2(Q+1))>=1` this follows by checking `y<=8` and using `(1+1/9)^5<2` thereafter. This bounds long descriptor arithmetic at interval creation even on one tape. A byte copy, nested loop, or a one-cell coefficient-charged operation never recomputes all public absolute addresses. + +At each type cut keep its parent banks parked. Reverse the one split stream onto the pending stack; pop each packet, append its answer, then transfer the one answer interval. Put markers on the stacks. Child accesses are relative to their exposed tops. At the first child of a paid site or the return to its parent the shared compiler backing head can cross the suspended bank. Across all the low packets at this site the parent bank stays parked; intervening seeks are within the previously used child frame and the next one. Charge at most two additional complete parent-bank traversals per site. On separate tapes hold active program/row descriptors and compact saved coefficient chains. For normal sequential transfers keep the head at the next cell. To locate an owner, scan the installed owner descriptions or the full fixed number of bank extents, as permitted in [the local installation proof](INSTALLATION.md) and the retained `STREAMED-MACHINE.md`. A rewind or release uses its local delimiter; no per-byte subtraction of absolute positions on the entire ancestor tape occurs. `Banks.xor` copies both the donor and former destination to distinct sequential spools before writing the destination. This avoids a seek across both live owners on every opaque byte. A stage can reuse one set of spools per named role as in `Arena`. The other temporary spools have bounded call nesting per stage (`unit_scale` has a loop over its limb depth). Fixed names for all seven stage sets suffice. These choices preserve arbitrary payloads, all permitted reads, and all zeros and erasures in the program. + +## Local numerical control + +For a coarse recursion inside one growing stage let `e` be its entry width, `w` the chosen atom width, `m` its number of physical components, `u` its maximum component width, and `D=2+ceil(log_N(ceil(e/w)))` the depth bound. Define + + X = 2^16 N^4 (D+1)(w+1)^252. + +The inequality `e<=w^250` holds even on a predecessor floor. `D<=3+250 log2(w+1)`. In the original entered call, the actual stock divisor and its high range have fewer than `2e` index bits by the stage reserve proof. In an ancestor descriptor, the two head/tail coordinates use at most `4e` bits in total. Within one stage all current `older` ordinals consist of parts of those original fields and the paid stock, apart from a factor less than two for the root padding. Alternatively, summing uncompressed lifts gives at most `2D(N^2 w+105H)` additional bits. Word indices have at most `1024H` bits. The chart entries have fewer than `2w+1` bits. A temporary dot product adds at most `log2 N` bits to twice that entry width. `least_power`, repeated squaring, and the two integer roots at entry need at most `2^15` times a field bit width for their positive 250th or at most 25,000th powers. These bounds fit `X`, including a second operand and a guard bit. Scalar `3^e`, complete type counts, residue fields, compiled indices and all ordinary coefficient addresses fit. Unrestricted spectator lengths use the preceding separate interval bill. + +One sequential implementation works with the following deliberately loose finite counts. In each list, materialize the indicated compact controls on distinct cells; an indexed access may scan the whole list. All constants below include decoding and operand copying. + +* At a new paid head coefficient there are at most three linear inherited chains, each with at most `D` links. Each preliminary or central exchange inherits at most one older weight. The weighted preliminary swaps retain this property after the basis permutation. Each link scans at most `J` installed word cells to get a placed generator. Chart recovery uses at most `N^2` high-digit divisions and at most `8(N+1)^3` elementary matrix operations to solve the `N` augmented rows or form the triangular image. `row_action` may repeat a row reduction in at most `N` directions. `pair_shape`, placement, and the two operand positions require at most `4(e+1)` field lengths per link. Restarting `least_power` and schoolbook repeated-square control takes at most `2^16(X+1)^2` scalar steps. In particular, allowing `2^25 J (D+1)(N+1)^4(e+1)^2 + 2^16(X+1)^2 <= J^2 X^4` scalar operations per requested current prefix covers a coefficient, an exposed row action, a field shift parameter, or a setup of its local schedule. Raw loops counted once per paid site below are separate. +* Store up to `N^2` rows/slots at any solve, one chart and fixed-basis key per saved link, and at most `4(e+1)` coordinate lengths per active schedule. The actual native interpreter can have up to `J` live small fixed owner and continuation descriptors. Scanning even a store with `J^2 X^3` scalar words costs at most `4 J^2 X^4` transitions per access, including return to the saved mark. Replicate a read into a temporary word before moving either scalar head. At most a fixed eight lookups are needed for any scalar add, product, division, extended-Euclidean step or array update in the tests above; loops over a whole row have already been counted. +* For operands, temporaries, and result with at most `X` bits, a ripple add uses at most `16(X+1)` transitions. Repeated shift/add schoolbook multiplication or restoring long division uses at most `128(X+1)^2` transitions on a fixed set of tapes. One Euclidean modular inverse takes fewer than `2X+2` division steps because the residue decreases by at least a factor of two after every two steps. Update the modular Bézout coefficient with two products/divisions, staying on at most twice the operand length. Even treating each of these three costs at width `2X+2`, fewer than `2^14 (X+1)^4` transitions suffice for any modular arithmetic instruction. Temporary scratch is swept clean before reuse. Coordinate counters are included in the scalar operand bill. + +Thus `J^5 X^20` transitions per true coefficient/prefix or one setup is sufficient, charging scalar operations times store lookups plus the scalar bit routine. Fixed raw word constants fit in the separately installed `J`-cell stream. In `lower_tape` the coefficient is generated once for a complete target component. The smallest component has width `u-1`. In `high_packet` a prefix for `row_action` still has at least one complete free high digit, while its optional compensation block contains at least one full body atom. In a direct stopped block both addressed atoms survive. Each such coefficient or setup is therefore charged across at least `3^(u-1)` distinct current byte-cells, once per respective sweep. The inequalities `D+1<=256(w+1)`, `w<=e<=(2u)^258` and `w+1<=2^259 u^258` hold on every profile. For positive integers `a,u`, `u^a/3^(u-1)<=3 a^a`: if `u<=a` it follows directly, and after `u=a` the consecutive ratio is at most `(1+1/a)^a/3<1`. With `a=258*5060` this gives + + X^20 / 3^(u-1) <= N^80 · 2^28,726,102 < N^1024 = J, + +at every stage after the first, since their H is at least 144,000. At the first stage there is no predecessor floor, so w=ceil(e^(1/250)). The largest balanced component has u≥ceil(e^η)/2 and η≥.00388. Therefore w+1≤(2u)^2+2≤9u². Substitution gives $X^{20}/3^{u-1}≤N^{80}2^{162402}$ using the same inequality with a=2·5,060. This is below J already at H=5,610. A small earlier service below entry pays its own stopped price. + +Two short inner operations have a different fibre. In `unit_scale` at an even split `2v`, the `carry_step` forms `old_low`, an inverse or a carry from values of at most `4(v+1)` bits per low. Its target has `3^v` positions at that low. In `shift_field` updating an amount on a radix `3^v` uses at most `2(v+1)` bits and its rotation reads a full target of that size. For `z>=1`, `(z+1)^5/3^z <= 2^10`, by checking `z<=5` and the ratio thereafter. Thus `2^50` operations per visited byte, including the length factors in the full interval, covers these scalar updates and their copy/counter loops. No ancestor weight is reconstructed in these inner data loops. At each halving `unit_scale` uses at most six preceding ordinary transpositions, at widths bounded by `floor(u/2^j)` for successive `j>=1`. As `b_prev<.004`, the series of their `(1+v)^(1-bprev)` bills is at most `4u^(1-bprev)` before the multiplier six. Odd steps and ending shifts use at most ten full linear sweeps per halving plus one. `1+log2(u+1)<=4u^(1-bprev)` for `u>=1`. Together these bounds pay all inner-limb work. Full-rank earlier-stage calls and same-stage funded children are accounted separately below. + +## Sweeps and contraction + +At most `J` complete native sites/factors/elementary issues are visited at a coarse node: the per-use scheduler includes its timed raw openings, each original paid tag, every integer fringe, complete row cycles, copies and releases. [the local installation proof](INSTALLATION.md) bounds the expanded logical visits by `N^96` and their pure serial control work, including creation, scans and clearing, by `N^700=1` are covered by + + B_i <= ((7·376/10)) J_i^14 (1+B_(i-1)). + +A cold trit swap uses nine contiguous buckets, a binary one four. For each digit, there are two copies of every opaque byte into/out of a bucket, one parked rewind and a scrub of both bucket and formerly current tape. Loop counts can use the explicit `repeat` above. Compute powers of the radix by successive multiplication (or repeated squaring) once per digit, with polynomial bit work below `2^16(1+e+ceil(log2(PGS+1)))^5`. At most `2^15` primitive control/copy actions per cell, including the fixed small bucket selector, outer tape rewind and counters, suffice outside this arithmetic. Every such whole public slab has at least `PGS·4^e` cells (or `PGS·9^e` on ternary); for `e>=1`, `(1+e)^5/4^e<=32` by checking `e<=5` and successive ratios. The external-log bound above and `(x+y)^5<=16(x^5+y^5)` absorb the setup. Store the at most seven entrance *logarithms* at installation, and check one compare per stage at the door. The greatest has fewer than 64 bits in each of these profiles. An empty stage list returns cold immediately. The case `e=0` copies one full slab. An absolute cold constant `B_0=2^100` suffices. + +Finally the rectangle opens and closes two binary fields to ternary volume `<9V`, and `e=ceil(log_3(2^a))<=a` for `a>=1`. Its scan loop has the same counter/copy bound as the elementary pass. Where the root selects the pure binary cold branch, `a<2E_1` and the same finite-range conversion applies. Since `J_i>=2^(1024*5610)`, the at most seven unit additions, `B_0`, all small fixed values, number of public passes, and the factors 9 and 2 fit the two extra powers per stage in the stated `2^40 ((7·376/10))^m product J_i^16`. Bounds for physical circuits, paid moments and equality of the returned permutation belong to the underlying proofs; the conclusions here are an explicit cost normalization and written induction. The Lean scope ends at the three volume and induction lemmas. The complete serial controller and the comparison with an optimal clock are outside that formal scope. + + +The [machine receipts](RESULT.json) give the exact rational ceiling for each list of ranks. + +The ordinary entry uses `fiscal_scans.py` to visit each public prefix slab without rereading the entire public address in a byte loop. A private binary-to-ternary rectangle opens and closes each slab before the next begins. Its source and target heads visit each real byte once in forward order. A short read from a file is accepted while the declared interval is still available. The allocation of a zero run has one fixed-size 64 KiB block. A zero-width ordinary field uses a full contiguous copy. The signed source reader advances once over the indicated magnitude, discards each completed zero-run counter at a nonzero byte, computes the final significant length once, and restores the input head even on premature EOF. The cost of clearing a zero-run counter with length `r` is at most `1+ceil(log2(r+1))<=r+1`, payable by this run. The reset positions need no running ordinal. On an input tape with extra high zero bytes, the bound includes the declared byte count. In a canonical binary encoding that count is linear in the bit length. A single final retreat costs exactly the distance consumed, including on premature EOF. [the executable scan check](check_scans.py) executes both public signed multiplication calls, the true cold ordinary dispatcher, and direct growing rank-two receiver slabs on 78,732 dirty bytes. The latter is an explicitly selected finite physical receiver. The cofinal rank and its full payload are beyond these tests. + +For the binary rank transport, `BINARY_C` has denominator `2^60`. The endpoint enclosure uses 60 square roots and at most 61 products. Each `a` and `b` is in `[1/(512N),1]` before a root. This holds initially since the exact inverse endpoint is at least `1/(258N)` and the rounding unit is below the difference. Squaring-root an element of this interval and rounding it downward stays in the interval; this follows from `sqrt(z)-z >= 1/(2 sqrt(512N))` on its lower part and from monotonicity on the rest. An enclosed square root has error width at most `sqrt(512N)/2` times the input width plus two grid units by the exact difference-of-squares identity. An accumulator product of factors in `[0,1]` adds their two input widths and two units. Starting at width no more than `1/grid`, these operations give width below `(4 sqrt(512N))^61/grid`, with `grid=2^(64 bitlength(N))`. Its numerator is at most `2^397 N^30.5`. After forming a difference of endpoints and multiplying by `N^6/t` the error is less than `1/4` at all seven ordinary rank profiles. Increasing the per-intersection count from 20 to 60 is less than a factor of four in the fixed loop bounds, absorbed by `J`. diff --git a/research/retimed-native-multiplier/OUTER-CLOCK.md b/research/retimed-native-multiplier/OUTER-CLOCK.md new file mode 100644 index 0000000000..3b036d85a7 --- /dev/null +++ b/research/retimed-native-multiplier/OUTER-CLOCK.md @@ -0,0 +1,223 @@ +# The non-native clock of the single-band product + +This calculation uses the default signed tape machine at #8030, commit +6285dd829114705862e8d91facaedc1f31d3cfcb, and the same outer at #8035, +ea776471bf8ed143a0625cf2d7532f65d15eb5f9. It uses their stated private +compiler, numerical correctness and physical service theorems. It does not +discharge the five research premises of #8035. The unit is one move on a +fixed-alphabet, finite-multitape machine. All fair comparisons must fix that +unit. The Python reference uses seekable files, arbitrary integers and host +lists. Its interpreter instruction count is a different quantity. + +Let n be the greater significant input bit length, with n at least 2 in +the formulas. A separate sign and two declared unsigned little-endian +magnitude intervals specify the input. Both input heads return to their +original positions. A zero product occupies one byte. Extra declared leading +zeros cost their actual aggregate length. At canonical lengths this adds at +most linear time. Let b=ceil(log2 n), p=6b, s=ceil(log2(p+2)), L be the +address width of the tensor, T=2^L and V=Tp. Its two true-width classes have +d total axes. Let ell denote the largest actual width and P the Gaussian +working precision. No table in this note takes multiplication operands as +an argument. Both source-size factors in (4·2^b·product(sides))², the +truncations to p and the actual final carry are those of the source. + +## Fixed-tape scan conventions + +Use separate tapes for a sender, receiver and temporary. A left-to-right +copy/erase costs fewer than 16 transitions per bit including rewind, tests, +and binary-byte delimiters. Reserve 2^24 transitions to open/clear a short +64 KiB buffer if used. A fixed-width binary comparison, shift, add or move +with both heads restored costs fewer than 2^8 transitions per bit by +forward and reverse scans. In a streamed loop keep counters low-bit first. +Consume a binary count by decrement with borrow and return to its low end. +Over m successes the number of zero crossings is at most +sum(floor(m/2^i),i>=1) + bitlength(m); the final failed decrement scrubs +the temporary. All bits above the low 16 can label a loop over complete +65536-byte chunks. Retain the low 16-bit remainder for the final copy. +A skip advances a tape head over the whole +interval. Absolute addresses in a sequential scan can be maintained by the +same ripple counter, or replaced by its specified relative move. + +The installed `fiscal_scans.magnitude_bits` reads each declared byte once. It counts its trailing zero run with a low-first ripple counter, resetting that counter on each nonzero byte. Each reset pays for its own preceding zero run. It computes the endpoint once and restores the input head. The fixed sequential spools copy or skip a whole interval with a low-first block count and one bounded final piece. See [the executed scans](fiscal_scans.py) and [the fenced tape checks](check_scans.py). + +For a signed w-bit word use the production difference-form Karatsuba with +terminal width 192. The sign is stored separately. Pad the width to the +next dyadic length for the bound. Tape markers separate disjoint operands, +three child results, and the output; a depth-first child frame follows its +parent. Including head returns, fewer than 64 complete interval passes, +each over fewer than 64(w+1) symbols, suffice to split, make both +differences, append each of the three entered arguments, read each result, +align the three shifts, sum, and clear. The ancestor work area has no scan +inside a child. Allocating 2^17(w+1) transitions at each internal node +and 2^36 per schoolbook terminal gives fewer than 2^40(w+1)^(8/5) +transitions: there are 3^j nodes at level j and each width halves. The +dyadic padding costs less than a factor of two in width. Word products +here never receive whole external operands except at the scalar cutoff. + +## The finite interval + +For s<512 the square selector uses W=64s². When the shape exists, +ell<=128s². For all admitted shapes d<=p, ell<=p and +P<=2^20 p. For this last bound insert h=max(1,floor(d/(1024s))) into +the actual pack precision. Then h(ell+6)<=d(ell+6)<=L+7d<=8(p+3). +The four logarithms of the stage count and the 67 trailing bits fit the +remaining slack. With t=2^ell and X=2^64(t+2)(P+2), the private bound +D=d X^1024 therefore satisfies + + log2 D <= s + 1024(ell+s+88). + +The same proof of its private bit heights and scalar loops applies to the +old square selector. For s<=31 the right side is at most 126082079. +For 1≤s≤31 use n>2^(b−1) except at the trivial n=1 door. Because s=ceil(log2(6b+2)), subtract max(0,floor((2^(s−1)−2)/6)−1) from the private exponent before maximizing. The largest result is 84,484,466 at s=27. Other scan terms below have a separate additive bill. [Exact finite maximum](outer_clock.py) + +For s>=32 it is below 2^(s-4)=64 the very same greedy grouped CRT path has L>=10100G for +G=64(ell+s), H=G floor(L/(100G))>=L/101 and d>=51200. Indeed +L>=p/12 and d>L/(2W)-1. Bound ell<=128s² throughout and check +at 64, then use doubling versus quadratic growth. Every free root +quarter has at least L/8 bits and deleting its two forbidden high +reservoirs and low reservoir leaves at least 3H consecutive bits. +The non-root unused half has at least that much space too. Consequently +jobs() never returns the individual unbuffered case. A tail single's +actual dest is H. It evaluates a switch once per 2^(H+1) addresses. +CompactSwitch.raw calls its controls once per 2^H records or fewer; +the inverse code in repair_key evaluates at most eleven controls per 2^H-record +group. Even dX^1024 fits below 2^(H-16) on this range, as does Q. +Their binary logarithms grow quadratically and H>=p/1212 grows +exponentially. Even eleven Q evaluations and eleven fresh private compilations then cost fewer than 22·2^(H−16) steps per group of 2^H records. The complete control cost fits one traversal of the slice, counting at least one step per record. + +On the bad-set repair, each of at most d members excludes two all-one +G-bit digits or one of the two extreme strings on 63G-2 guard bits. +The union has measure at most 3d 2^-G. This does not assume independence +between different exclusions. The complete destinations are sorted on at +most L bits. Each tag is shorter than the entire grouped buffer even when +the slice payload is just one byte per address. Since 3dL 2^-G<1, all +stable radix passes input and emit at most one additional slice of payload in total. Keys have at most L bits and each exceptional group carries at least 2^H payload bytes, with H≥L/101 and 2^H≥L. Marking, copying to the two buckets, rewinding, concatenating the two streams, deleting, rescanning for the returned hole and clearing the marked file use fewer than 32 one-way transfers of a slice after doubling for key volume. Even 2^16 transitions per transferred bit, including the restoration and counters above, cost under 2^22 slice bits. Each failed group calls the ten-operation inverse key routine once. The packing here includes every hole. + +For all s<512, none of the comparator or retimed native carriers can be active: +every installed native rank logarithm is at least 1024. The ordinary leaf is the +four-bucket, at-most-p digit swap, and the positive leaf is the exact +ordered two-pair arithmetic on at most p coordinates. Its public +widen/phase/narrow and clear are counted. A crude volume multiplier +2^160(p+2)^25 suffices: one transform has at most d packs of +40000(ell+2)^6+4 stages, each with at most p single-axis passes; the +three CRTs have at most 2p³ row, target and level choices, at most +32 variable rotations per compact switch and p sparse radix passes; +each bucket swap uses at most p full four-bucket sweeps; both kinds of +stripes use at most p slices; fixed word arithmetic is less than +2^40(2^23p)^(8/5). These estimates also allow one unfused p-bit loop +counter update at every transferred byte. For s<64 multiply the scan +bound by Q. For 64<=s<512 the prior group amortization removes Q. +The result has log multiplier below 5.1 million everywhere. Add the +private compiler once. An absent shape also has a finite numeric clock: +on 2^j<=b<2^(j+1), s<=j+4 and L>=2^j-j-1. For j>=15 this exceeds +64(j+4)^2 by induction, so the scalar branch always has n<=2^32768. +Its signed word and file costs are less than 2^32820 n. Altogether +2^(84500000) n suffices for every s<512. + +## The cofinal outer call count + +For s>=512 use ell+2<=2^11(s+1), P<1.02p, V<48n, and G=64(ell+s). +The two widths, two root passes, true first-mixing tag and at most +ceil(d/h0) remainders give at most 80000(ell+2)^6+2048s+2 packs. +Each completed pack has at most 40000(ell+2)^6+4 H/diagonal stages, +using the local matching, its forward/inverse Beneš rows, sixteen-H +lowering and both root passes. Over the two forward and one opposite +transform their product is below 2^168(s+1)^12. + +At a CRT level there are fewer than 2ell rows. At each row there are +at most 2^18 batches, since floor(H/G)>=d/51200 and there are two free +halves/quarters. A batch uses six reserve placement/return swaps, at +most K=64G colors and at most K² individual tails. A compact switch +has at most 20 whole shuttles, 10 rotations and one full repair. Count +10+32K+4K² positive-volume macro operations. Across levels and three +calls this gives fewer than 2^90(s+1)^4. For a fixed BIT or CRT +operation, sum actual stripe volumes, which are disjoint portions of +the same T-record array. Separately charge the scan of the original +bank that reaches each stripe: its count is at most 2 sqrt(p+2); +both gather and scatter pay their complete head travel, including each +marker rewind and the final erasure. + +Each tensor diagonal has fewer than 3T signed complex grid products, +including partial suffixes and initialization. One has four signed +products of at most 10p+100 bits. Store coefficient tables in descending +axis-width order. Reaching table j can traverse at most (j+1)t0 records +after the fastest table of size t0, and occurs at most T/(t0·2^(j-1)) +times. The sum of (j+1)/2^(j−1) over j≥0 is eight. This pays at most 8T record traversals on returns; +count a copy of the private inventory for setup. Each record includes +precision, crossing and rounding bits. Source validity can be checked +by a scan of the full d-tuple per record as its total coordinate width +is L address bits plus at most four delimiter and loop bits per axis. Keep each coordinate in its fixed-width field, and use a sequential delimiter walk of at most L+4d bits on this pass. Pointwise multiplication, conjugation, both digit-scale +and source-size recoveries, grid conversions in both directions, CRT, +sign, carry, input heads and returned output have the same or smaller +word/scan bill. Reserve 2^58 V p^(3/5) per arithmetic stage. The +spectator collector's two file scans add at most 2^38 V sqrt(p+2). +Its layout comparisons and total extent calculation are private, +at most 2^40(p+2)^8 once per stripe, which the actual stripe absorbs. + +Let B denote a proved unit-volume fixed constant of the actual ordinary +swap on arbitrary exterior/gap/suffix, for a=κ+4g. Let Z denote +the corresponding positive constant at price at least κ+g: its clock +on a pack with h selected axes is at most +Z·(s+1)^2·volume·(1+h)^(1-a). The separate note gives an upper bound +for Z from B. Separately charge the two support exposures at the top +using B and width h·ell<=L. A full source record has fewer than 5p +bits; the paid services get their actual stripe extent, including all +allocated slots. One non-native macro costs at most a sum of the +above scalar, gather, grouped-control, or paid-service bills. The +extra factors from the bounded reshaping, outer byte grain, three +transforms and restoration fit in 2^400 for the whole bound. In +particular 2^168 times 2^58 leaves 174 further binary factors of two. +Replacing all the powers by the largest one yields + + time <= 2^400 (s+1)^16 (1+B+Z) V p^(1-kappa-g). + +For g=10^-17 or the larger g=10^-14, +(s+1)^16/p^g <= (128/g)^16 < 2^1024. Use s+1<=4 log2 p and maximize +y^16 2^(-gy). Replacing V,p by 48n and 6 ceil(log2 n) then gives a +cofinal factor below 2^1434(1+B+Z). Add 2^(84500000) for the finite +prefix. This is an explicit reduction of the outer time constant to +the actual physical native constant. It gives no timing crossover. + +## Reproducible source bindings + +* [Signed entry](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/band_product.py) +* [Linear square controller, private clock and stop](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/LINEAR-GEOMETRY.md) +* [Completed pack, precision and actual transform loop](https://github.com/CrocSwap/integer-mult-bounds/blob/9585c1fa2ed5f2316ac09e04b357cb720badfcb8/research/triangular-native-supplier/multiplier.py) +* [Original axis compilation, grid/rounding/CRT/carry](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/product_path.py) +* [Finite selector, true-axis witness, fixed private instructions](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/OUTER.md) +* [Root count and odometer](https://github.com/CrocSwap/integer-mult-bounds/blob/3615fd982f2f4dc7172bef6f0dc9a4f77d5ab6dd/research/direct-circulant-fourier/COMPOSITE-OUTER.md) +* [CRT eligibility, real controls and tail dest](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/crt_tree.py) +* [Exceptional keys, radix passes and rotation](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/compact_crt.py) +* [Finite binary input, extrema and carried output](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/binary_io.py) +* [Updated positive margin](https://github.com/CrocSwap/integer-mult-bounds/blob/ea776471bf8ed143a0625cf2d7532f65d15eb5f9/research/p104-single-band-signed-margin/PROOF.md) + +## The 70-bit stop parameter + +At g=10^−21 the previous 1024-bit inequality fails. Put y=log₂ p. For s≥512, y≥s−2, so s+1≤17y/16. For every real t≥0 one has t≤2^t, since 2^floor(t)≥floor(t)+1. Apply this with t=gy/16. It gives (s+1)^16/p^g ≤ (17/g)^16 < 2^1182. The scalar inequality is verified with integers. Since V<48n and p=6 ceil(log₂ n), conversion to the stated input unit adds at most nine bits to the factor. The cofinal exponent for (1+B+Z) is at most 400+1182+9=1591. The original 1600 allowance covers the remaining two bits for the sum of the three services. The explicit initialization and finite-prefix bounds still apply. [Actual stop, ranks and allocation](RESOLUTION.md) diff --git a/research/retimed-native-multiplier/PREDECESSOR-POSITIVE-CLOCK.md b/research/retimed-native-multiplier/PREDECESSOR-POSITIVE-CLOCK.md new file mode 100644 index 0000000000..0858ba3b3a --- /dev/null +++ b/research/retimed-native-multiplier/PREDECESSOR-POSITIVE-CLOCK.md @@ -0,0 +1,250 @@ +# Numerical native clock, with all input-dependent control work + +Use the raw 128-factor positive word and physical service of #8030, with +either published numerical carrier M=2^610000 or M=2^1600000. #8035 +uses the latter M with D=10^17 in the test e^D<=h. The 430-factor variant uses the same M with D=10^21. +Let B be a numerical upper bound on the ordinary bit service in the same +fixed-tape units, at ordinary rate a=κ+4g and g=1/D. This service must +include real payload, arbitrary exterior, its own installed data, +restoration and the full stop below its last rank. There is no observation +or arithmetic oracle in the calculation below. It uses the published +all-column, stable arithmetic and paid-port theorems. A numerical B still +needs a separate binary proof. + +Use volume for a *physical* binary field in bits. Rewinding or traversing +M complete field intervals costs M times the actual field volume. Nothing +below charges a large real move to its smaller encoded offset. + +## The field sizes available to control calculations + +The public shape has s=ceil(log2(p+2)), and each active window has k=ell_i. +Set s'=(P+1).bit_length(), g0=4s'+6 and z=(s')². At an active parent of +selected width e>M, f=floor(e/M). The actual back position from entrance() +is start+z. That low suffix survives every native raw rotation, chart +and subsequent paid subcall. An active parent and each raw field created +by the row split preserve the complete first M f windows. The code checks +remain >= low+(e-e%M)k. Thus a raw field has at least 2^(z+M k) +records, including all exterior and holes. At stopped raw descendants the +suffix remains present. At an unnested stopped root, where the public +dispatcher instead sets the suffix to zero, the phase is addressed below. + +Use J=M^1024. The source enumerates fewer than M^82 structural records +over all rounds, including omissions, the terminal/surplus slots and the +powered word. Even if the whole structural program is scanned on each +binding, the purely controlling part of *one active parent* costs less +than 2^120 J^30(p+2)^16: + +* A fixed raw quartet of word/graph/port/chart identifiers and its + positions may be reconstituted rather than indexed. Allow M^4 further + structural reads per expanded record to select an entire M-entry + coordinate tuple, find every port, construct its selected job and + reverse all saved swaps. Each installed cursor read, including a + seek back into the common image after a child, costs at most two full + image sweeps. A map of loans, owners, slots and active cursors has at + most M^82 entries. Even storing up to J scalar coordinates per entry, + all such fixed tables take less than J^2(p+2)^4 cells. A reference to + an actual data head has O(p+log J) bits; the original binary address + has at most p bits and the field slot/cursor uses fewer than 1024 log2 M + more. At an active parent s>=log2 M, so this is below 2048(p+2). +* Allocate two sequential rewrite tapes. For each indexed op mark a + key, find all matching records and return the head. Even three complete + nested searches per entry, with comparisons, arithmetic and copying + charged as 2^20(p+2)^3 per scalar word (or as three corresponding + scans of a full fixed key), fit the stated J^30 envelope. Offset + normalization, decoding base-128 operands, capped binary powering for + the D test, and cleanup use the same tapes. Computing all dynamic raw + index lists takes at most (p+2)^4 visits per row. The cutoff D has + at most 70 bits over these variants. Capped repeated squaring needs at most 69 squares and 29 further products for D=10^21; this fits in 2^7 elementary multiplications per test. These are once + per active execution or once per physical row. Per-address functions + are counted separately below, with their *entire* iteration. +* This absolute work is smaller than one actual row field. With + H=log2 M, 30720H+120=512. Thus a new full control build at every + active parent, including per-parent generation dependent on p, costs + less than one scan of its data. A program tape may be distinct from + the data frame. No observation about the *number of bits in its head + address* would suffice to pay a data-frame seek. + +## One chart row on arbitrary data + +The installed forms have fixed reduced scalar magnitudes at most 87 bits. +Each numerator uses at most four 23-bit limbs and denominators split +into at most 87 divisors below 2^24. For a fixed divisor, long division +scans the value in high-to-low order, maintaining its at-most-24-bit +remainder. Each input bit costs at most 2^9 moves, with sign, output +and head restoration. Schoolbook accumulation by a 23-bit constant +takes at most 23 shifts/additions. Thus even 2^25 times one field volume +suffices for a scalar update. The coefficient and its divisor list are +determined once when the row is issued and copied to fixed working tapes. +The source removes the odd factor and the residual shifts on return. + +An actual ROW/NOT of c columns distributes at most c f selected +positions, where c<=M. Each address and relative bit index has fewer +than p+2 bits. A whole coefficient evaluation for a phase, carry, +bad-set check or inverse key costs at most + + 2^80(p+2)^8 + +bit transitions. There are at most p indices (they are distinct +positions in a field of at most p bits), at most 22 forward or inverse +operator pieces, a bounded number of field-word shifts per position, +and at most p saved positions. Even a sequential re-scan of every saved +position per term followed by a full p-bit addition/shift, plus the +loop controls, is below this bound. No variable-width position is +read for free. Field.phase computes once per complete z-bit suffix; +Field.rotate computes once per 2^(lo+width) records with lo>=z. +Columns.repair also computes its decision and key once per complete +suffix, restoring every item after sorting. The bound above is less +than 2^(z-4) from s=512. Each whole group pays for its own evaluation. +The final single column selects a true bit >=z; its high/low swap uses +the physical ordinary service. + +For the exceptional subset, for n=c f-1 selected positions two all-one +g0-bit digits and two extreme subranges in a (k-1)-bit guard give +probability at most n(2·2^-g0+2^(g0+3-k)). This is at most 3p·2^-g0 +since k>=128g0 and n<=p. No independence is used. There are fewer than +p radix passes over the bad groups. Even with a complete p-bit key +and all its data, these cost fewer than a fixed number of full scans: +3p²2^-g0<1, and the suffix group holds more bits than the key. The +algorithm's two incoming streams, stable radix banks, restoration, +lifetime and clearing are those of compact_columns.py. + +One compact row has at most 22 raw shuttles/rotations, plus those of +the high single column and one radix repair. Each genuinely swapped +address width is at most 1+M f k, including raw slot alignment and +unalignment (which use f k). If the row volume is v0, the ordinary +tariff on these moves is at most + + 2^8 B v0 M (1+k)(1+f)^(1-a). + +The inequality 1+M f k <= M(1+k)(1+f) bounds its actual width. +There is an independent copy/clear/rewind charge per operator and +separate physical travel to each owner. + +## Number of physical moves and maximum travel + +Let v be the incoming parent volume after the common fixed-grid widening +and R0 the number of independent parent output rows. A raw field in the +new local frame then has volume v/R0. The source proves +R0<60M^96 and a local slot count at most F R0 with + + F=2^19 Q_128²(G+1), log2 Q_128<=3912, G+1<=H+2. + +At both ranks 60F=1. Use (1+f)^(1-a)<=2(h/M^(j+1))^(1-a). The power of M left +in a depth sum is M^((a-b+)j)<=1. The pure scan and residual costs +are at most M^99 v h^(1-b+) at each active depth. There are at most +s+2 depths. For a stopped child, + + M^((1-b+)j) e_j <= M^b+ h^(1-b++g b+). + +This follows from e_j<=max(M,h^g) and M^j<=h/e_j. Since +(1-g)b+>a, the h power is at most 1-a. The M^b+ factor is covered +even after the 2^40 M^97 charge on a worst-positioned individual +terminal axis. The actual field has the same working precision at +every such yield. In total the complete inner positive call, including +its own residuals, native construction, scalar sweeps and data motion, +has a fixed constant + + Z <= M^100(1+B) + +in front of (s+1)^2 · v · (1+h)^(1-a). Here k<=1030(s+1) and the +slack between each per-depth bound and M^100 covers all the displayed +numerical factors. The numerical publication prologue widens each +component by at most 2h+48 extra bits, with h<=p and the public grid +already P>=p. Its fixed increase in v belongs to the outer assembly. +Both actual support placement swaps at width h k are separately +charged to B at the top. No iteration requires h^g>=M. + +Combining this with OUTER-CLOCK.md gives a bound + + C <= 2^(134217728) + 2^1436 M^100 (1+B) + +for the complete signed product **conditional on a numerical B for the +actual physical six-stage ordinary service and the source correctness +premises**. This does not give a numerical whole-product C by itself. +The positive fixed factor alone has log2 no greater than 61000000 or +160000000 (plus the displayed outer absorptions). The proof gives +upper certificates, not a minimum factor or a measured crossover. + +OuterTickets.lean checks the active depth inequality, stopped depth +inequality and both integer quotient statements against Lean's real-power +and natural division definitions. It also checks the all-size polynomial +private cutoff and the two binary-exponent absorptions. The linked program +establishes the event and volume hypotheses in the written arguments. +The local Lean 4.34.1 kernel replay accepted all seven declarations with +only propext, Classical.choice and Quot.sound; the two divisor statements +use only propext. + +## Source bindings + +* [Full generated epoch and resumed positions](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/epoch_tape.py) +* [M^82 record count and paid rate](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/BAND.md) +* [Physical row split and jobs](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/band_positive.py) +* [Absolute slot and order bounds](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/ACTIVATION-SPACE.md) +* [Fixed graph, rational scalar and representable width](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/STRONG-COMPLEX.md) +* [Serving public and stopped H](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/positive_dispatch.py) +* [Actual positive placement and retained suffix](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/complex_stage.py) +* [Ordered ops, subset guard and repair](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/compact_columns.py) +* [Raw chart, align and inverse](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/raw48.py) +* [Staged owners, physical seeks, scalar division and pair phases](https://github.com/CrocSwap/integer-mult-bounds/blob/46783fbbfc219a3faffbea76f60a2810b85ab75a/research/native-stock-activation/spool.py) +* [Updated signed margins](https://github.com/CrocSwap/integer-mult-bounds/blob/ea776471bf8ed143a0625cf2d7532f65d15eb5f9/research/p104-single-band-signed-margin/PROOF.md) diff --git a/research/retimed-native-multiplier/README.md b/research/retimed-native-multiplier/README.md new file mode 100644 index 0000000000..58e9952b90 --- /dev/null +++ b/research/retimed-native-multiplier/README.md @@ -0,0 +1,61 @@ +# Retimed native suppliers for signed integer multiplication + +A fixed integer-multiplication machine can generate both native words and their grade couplings before it reads the operand bits. It calls the original binary and Gaussian circuits directly on a timed collection of independent fields, routes each paid operation to a smaller admissible column count, and restores its suspended owner before the next cut. This removes the powered-word ranks from both suppliers. The result also gives an explicit absolute time constant for the complete signed tape algorithm, subject to the predecessor's five research premises. [Transport proof](TRANSFER.md) · [True initialization](INSTALLATION.md) · [Signed clock](CLOCK.md) · [Exact receipts](RESULT.json) + +| Machine | Complete κ | Last binary H | Numerical H | log₂ S ≤ | Activation A | log₂ C ≤ | +| --- | ---: | ---: | ---: | ---: | ---: | ---: | +| Prior compact | 0.00387992803556 | 1,600,000 | 610,000 | 1,638,400,002 | 2,471,428 | 30,535,241,478 | +| Prior small-gap | 0.0038901152865907 | 7,168,000,000,000,000 | 1,600,000 | 7,340,032,000,000,000,003 | 7,645,866,239,991,957 | 125,269,872,000,160,591,302 | +| Selected-Price | 0.00363005817 | 5,610 | 1,024 | 513 | 6,913 | 92,141,171 | +| Small | 0.0038 | 18,400 | 1,600 | 513 | 20,345 | 301,819,251 | +| Compact | 0.00387992803556 | 144,000 | 8,500 | 513 | 161,992 | 2,510,262,059 | +| Balanced | 0.00389 | 12,800,000 | 19,000 | 513 | 13,674,566 | 223,726,063,267 | +| Near | 0.00389011528 | 222,000,000,000 | 19,000 | 513 | 237,047,783,945 | 3,883,790,340,181,683 | +| Matched | 0.0038901152865907 | 396,000,000,000,000 | 19,000 | 513 | 422,797,742,630,271 | 6,927,118,188,548,181,691 | +| Published 430-factor six-stage | .003890115286594445 | 1,024,000,000,000,000,000,000,000 | 1,600,000 | 1,048,576,000,000,000,000,000,000,003 | 1,365,004,016,064,257,029,713,503 | 22,364,160,000,000,000,000,160,001,642 | +| Seven-stage resolution | .003890115286594445 | 95,600,000,000,000,000 | 19,000 | 513 | 101,973,332,976,357,367 | 1,670,731,087,109,379,198,659 | + +All dimensions in the table are exponents. The ranks are $2^H$, setup is bounded by $2^{\log_2 S}$ transitions and the recurring coefficient by $2^{\log_2 C}$. The prior rows use the single-band physical compiler and our explicit repricing of its recurring tape costs. Its submitted bound used an unspecified coefficient. PR #8040 already lowered the corresponding setup exponents to 4,098 and 6,267 with its grade-counted installer. The new fixed bound is 513. The upper bounds do not measure the speed of one product. [Prior setup receipts](https://github.com/aliromman/integer-mult-bounds/blob/1ca6b8111297ac2cc2dcfe5da0027656898f7589/research/counted-native-bands/RESULT.json) + +For each A, the first sufficient significant input length in bits is $2^{\lceil 2^A/6\rceil-1}+1$. This entrance supplies the complete numerical raw word, a genuine full-slot ordinary interchange, all earlier services, the private precision and the true high-matrix stock. The public controller can select a cheaper or stopped branch before this point. Even the selected-price row needs 2^6,888 outer axes at entry. Its largest axis uses 5,592,406 address bits. Every rank-$2^H$ raw cohort actually has $2^{92H}$ independent native rows. Input-dependent preparation, incomplete groups and head movement enter the recurring bound. [Complete activation](ACTIVATION.md) · [Precision and movement](NUMERICAL.md) + +The direct ordinary receiver now moves its supplied basis into a coordinate, issues one recursive exchange and restores the basis. In wide mode it transforms each actual low/high packet by a rank-one reflection. A packet needs at most five recursive calls. The volume-weighted mean over all lows is at most $7/3+16/[3(3^N-1)]$, uniformly over the paid input frame. The two-scale Gaussian supplier repays its small-column loans with actual fields from two complete raw executions. A linear integral over both real transport boundaries prices the integer remainders. The first change lowers the ordinary debit from 3.5 to 1.375 bits per installed stage. The second lowers the matched numerical exponent from the first retimed value of 36,000 to 19,000. [Direct and quotient construction](RECEIVER.md) · [Full transport](TRANSFER.md) · [First retimed receipts](https://github.com/aliromman/integer-mult-bounds/blob/3d33cb0c8a523b66d91e8de8250b85d0a436eb35/research/retimed-native-multiplier/RESULT.json) + +The seven-stage profile matches the later 430-factor submission. At fixed κ, its terminal binary exponent is 10.71 million times smaller and its complete activation exponent is 13.39 million times smaller than the published values. Retuning the prior six-stage tariff still forces an activation exponent over 1,890 times ours. If the old tariff can use any number of stages, its lower bound is 21.37 times ours. One reduction comes from an extra physical stage, another from cheaper calls at each stage. The upper bound on setup replaces a real expanded installation. The numerical rank and all high-matrix reserves remain large. [Source, lower bounds and costs](RESOLUTION.md) + +## Equal-rate comparison + +Retune the old compact, higher-rate, 268-factor and 285-factor prices with one to six ordinary stages at the two supported stop margins. For fixed raw trial c, debit $l$ and stage widths $H_i$, iteration from the cold stage gives +$$ +c-b_m \ge c/250^m+(249l/250)\sum_{i=1}^m250^{i-m}/H_i . +$$ +Cauchy–Schwarz with $1/16<1/\sqrt{250}$ bounds the last sum below by $(\sum_{j=0}^{m-1}16^{-j})^2/(\sum_i H_i)$. The ordinary width floor implies $A>\sum_i H_i+H_M$. At the most permissive supported positive stop add the strictly necessary numerical debit. The checker also constructs actual alternative installations from those words and runs their complete resource and signed gates. The lower bound applies to these four named tariff formulas and stage rule. Other physical suppliers may do better. [Retunings](equal_rate.py) + +- At κ = .00389, a feasible old refit has A = 188,868,731. Every such retuning has A ≥ 188,252,135. The new balanced installation has A = 13,674,566. +- At κ = .00389011528, a feasible old refit has A = 3,615,709,999,957. Every such retuning has A ≥ 3,609,923,786,113. The new near installation has A = 237,047,783,945. +- At κ = .0038901152865907, a feasible old refit has A = 7,420,702,481,833,889. Every such retuning has A ≥ 7,404,411,307,975,972. The new matched installation has A = 422,797,742,630,271. + +The same lower-bound argument applies to this package's **own** two tariffs. Use the actual raw ordinary crossing and debit 11/8, positive debit 39/256, final ordinary target κ+5g, and at most six stages. At the six-stage 285-factor rate it gives A≥421,764,310,695,960. The installed A is within 0.25% of that bound. This restriction is on these prices and stage funding. An improvement of several further orders at this κ requires a new price or a different stage construction. The present 36-call word has only about $3.76·10^{-15}$ of raw rate above the target. [Rational floor calculation](check_complete.py) + +The near profile lowers κ by $6.5907·10^{-12}$ relative to the matched profile. This permits a further factor of 1,784 in the defining activation exponent. At that exact near rate the comparison against an independently retuned predecessor is about 15.2-fold. The first factor includes the price tradeoff. Neither factor measures elapsed running time. + +## Reproduction + +Use Python 3.12 with assertions enabled and Git on PATH. + +~~~sh +python3.12 -IB scripts/research_package.py --package research/retimed-native-multiplier +~~~ + +The command ends with `PASS_REGISTERED_RESEARCH_PACKAGE research/retimed-native-multiplier outcome=completed`. A clean installation is also available to callers. + +~~~sh +python3.12 -IB research/retimed-native-multiplier/bootstrap.py /tmp/retimed-machine +python3.12 -B /tmp/retimed-machine/band_product.py -741503 466013 --profile compact +~~~ + +The public signed entry prints `-345550037539`; on that input the normal selector uses the scalar stop. A separate true finite Fourier computation visits 157,248 H calls and 138 physical shuttles, verifies all five base-256 coefficients, and restores both inputs. Both original raw emitters, the new timed scheduler with noncommuting finite charts, and real setup at production rank logarithms have separate runs. No test materializes an active production-dimensional field. These results establish neither a measured crossover nor a nonconditional integer-multiplication bound. [Verification details](VERIFICATION.md) · [Credits](NOTICE.md) + +## Open next questions + +Which change to the binary word or the stage funding can sustain the strongest rate across a substantially wider raw margin? The certified tariff floor limits what later work can gain by tuning these same ranks. diff --git a/research/retimed-native-multiplier/RECEIVER.md b/research/retimed-native-multiplier/RECEIVER.md new file mode 100644 index 0000000000..90ed818f72 --- /dev/null +++ b/research/retimed-native-multiplier/RECEIVER.md @@ -0,0 +1,79 @@ +# Execute a direct line with one recursive exchange and a covered line with at most five + +An ordinary source occurrence exposes its actual singleton frame. The old leaf used up to nine recursive whole-field exchanges. In direct mode the new machine uses one. On a true low packet in quotient mode it uses one, three, or five. The number of high representatives, the dirty payload and the column multiplicity do not change the bound. At fixed rank N the quotient volume-weighted mean is at most + + 7/3 + 16/(3(3^N-1)). + +All counts include the inverse moves. The two routes feed the same arbitrary-input multiplication caller. This change affects the ordinary price. The independent numerical supplier, normalized transforms, signed recovery and the five research premises of the inherited complete claim keep their original scope. + +## Coordinates and operation order + +For one resident high representative, one aligned column and one cyclic component, let R=Z/(3^d). The column has two N-component vectors h,t. Let u,v be the actual placed factors of the issued singleton. Their pairing is vᵀu=1. Let A be the diagonal matrix of the old row's units a_i. The required map sends h to h+Au·δ and t to t−u·δ, with δ=vᵀ(t−A⁻¹h). Equivalently it is I−zwᵀ for z=(Au,−u) and w=(A⁻¹v,−v). Its pairing wᵀz is 2. Apply these ring identities to each physical component. Reduction from the largest modulus to any narrower component preserves inverses of the actual units. The oracle tests include a pair of unequal component widths. + +### Direct source and its actual cost + +If the input chart is the identity, the existing body knows its emitted basis F and its selected coordinate k. On a frame with a word, first execute direct_route(F). This sends the head to AF⁻¹A⁻¹h and the tail to F⁻¹t. Next use the same coordinate child as the public empty-word branch on the pair H_k,T_k, with coefficient a_k. Finally execute direct_route(F⁻¹). The head and tail now receive exactly the desired correlated add/subtract with projector F E_kk F⁻¹. Invert the word with its actual reverse-order inverses. The theorem directCoordinate in FiveExchange.lean proves this two-sided mechanism over any module with two linear equivalences. + +Every direct preparation is an invocation of the literal native matcher on the real entire field. Its add, scale and interchange instructions visit each genuine column, earlier prefix and full suffix. Its same-bank inverse direction uses its earlier-rank service twice where needed. The returned basis consists of the original paid frame word and selected coordinates stored by job_frame. Every new raw cut enters a real placed frame, and a selection within that job keeps the same word. The source verifies the 44,825 fixed basis factors, their inverses, the modulus prerequisites, and the magnitude limit 20 on individual numerators and denominators. Embedding changes addresses; extending by a column identity repeats actual factors. The streamed scheduler's N^96 operation estimate already counts every expanded selector, leaf and placed source word per node. Even allowing J=N^1024 issued jobs each to read J complete frame factors, these extra scans cost at most 2 J² factor passes. A factor traverses both banks, touches at most 2f positions, and uses only an earlier service. The original J^4 local structural allowance covers the scans, off-tape movement and two full snapshots. At a direct coarse node c≤N^8, the earlier-service column term is paid with c≤N^(8C)c^(1−C)0. +* Also try (H_0,T_(N−1)) if u_(N−1) and v_0 are units. +* If none of these suffice and p is interior, use (H_0,T_p) and then (H_p,T_(N−1)). If p is zero, use (H_0,T_(N−1)) and then (H_0,T_0). If p is last, use (H_0,T_(N−1)) and then (H_(N−1),T_(N−1)). + +The last two cases include all sparse edge ties at N=2. The empty case covers N=1; production uses N≥2. Each path puts a unit e of z at physical position 0 and a unit d of w at l=2N−1. In the sparse p=0 case, the first swap moves the head-0 dual to the last tail. The second puts the tail-0 primal at the first head. The p=last case is its reversal. For an interior p the two selected pairs are disjoint. A single preliminary swap that changes neither affected outside position cannot repair a missing unit, so the listed one-swap cases are exhaustive within this dictionary. + +Apply lower shears in the following order: + +1. For each middle i, add −z_i/e times position 0 to position i. This kills the middle primal. +2. For each middle i, add w_i/d times position i to l. This kills the middle dual. The primal at l stays unchanged. +3. Add (d⁻¹−z_l)/e times 0 to l. + +A shear sending x_j to x_j+c x_i sends z_j to z_j+c z_i and w_i to w_i−c w_j. It preserves the pairing on every input. The final outside primal is (e,d⁻¹), and its dual is (e⁻¹,d) since their pairing is 2. The map on this pair is a weighted interchange with weight −ed and inverse −1/(ed), leaving every middle address fixed. Execute it, undo all lower shears in reverse order and undo the preliminary pairs. FiveExchange.loweredReflection proves the exact signs, units and arbitrary middle-coordinate identity over every commutative ring. No entry divisible by three has been inverted. + +### Physical dimensions, movement and restoration + +For a child (H_i,T_j) let start=i f and end=(N+j)f, α the full atom cardinality, U=unused, G=gap and S=suffix. Its real callback arguments are + + atoms=f, available=U, + older=heights·older_origin·α^start, + gap=G·α^(end−start−f), suffix=S·α^(2Nf−end−f). + +The coefficient reader removes the entire α^start prefix, splits the next row into high and old, and uses exactly the relevant coordinate in that old row. Multiplying those dimensions by both exposed f blocks gives the original byte volume. In direct mode this is one native owner. In quotient mode it is one owner divided by the actual low count Q. Siblings and unfinished rows keep their full volumes while the parent is suspended. No high digit, arbitrary spectator or output credit disappears. + +A lower shear on block i, column j uses physical index 2+i f+j on the head, 3+i f+j on the tail. Each row's coefficient repeats for the full prod(dims[2:source]) visible prefix. lower_tape executes the required passes and repeated component conversions, and its frame is scrubbed and rewound. The number of lower shears in both directions is (8N−6)f≤8c. The old exact count was (8N−8)f, while its established complete clock charged 8c. Coordinate-origin bookkeeping changes at most four positions. It requires no extra sort or matrix relocation. The new direct basis wrapper adds two real ping-pong scratch heads on the tested nontrivial direct frame. The complete stock proof allows at least 80 local sites, 22 spools, 3 tuple positions, 256 equivalents, eight staged fields and both owner cohorts, fitting 2^25 incoming equivalents per local adapter. Complete checks for the new control and high-water thresholds are in adaptive_activation.py. + +## Prove the wide average, and pay the direct case separately + +Uniform lows mean the Q actual canonical matrices enumerated by quotient_route.low_rows. They quotient full GL_N(F_3) by left unit lower triangular row operations. Every full GL matrix has one reduction with exactly the same number of preimages. A flag has 2^N choices for its nonzero row signs at the successive one-dimensional quotients. The first row's line and the span U of the first N−1 rows therefore have the ordinary uniform flag law. This law applies to every fixed incoming rank-one frame before conditioning on the current low. Every one of those lows has exactly the same byte volume and high cardinality on that occurrence. + +Let x=3^(N−2) and D=9x−1. Both events a,b have marginal 6x/D: they assert that a uniformly drawn row evaluates nonzero on the fixed primal, and that the original dual vector lies outside a uniform hyperplane. For the mixed event a and not b, v lies in U. There are (3^(N−1)−1)/2 such hyperplanes. Because vᵀu=1, u is a nonzero functional on each. Its first row is uniform among the 3^(N−1)−1 nonzero vectors there, of which 2·3^(N−2) have nonzero evaluation. Thus this mixed event has probability 2x/D. The other mixed event has that same probability by equal marginals. Both hold with probability 4x/D. Neither holds with probability (x−1)/D. + +A mixed event that needs both preliminary swaps has either u supported solely on the last axis, which forces U=ker(u_original), or v supported solely on the first, which forces the very first row to span v_original. Each special subspace occurs with probability 2/D. All lows together thus satisfy Pr(five)≤(x−1+4)/D. The exact weighted sum is 3−2Pr(one)+2Pr(five) ≤ (21x+3)/D. This upper bound holds for every single paid frame without any distribution on the program, input values or high digits. FiveExchange.weightedChartSum checks its linear arithmetic. A direct frame separately uses exactly one same-rank child, independent of any average. + +The upper bound is sharp for an arbitrary placed frame. Take the bare vectors u=v=e_0. Canonical rows eliminate their first remaining nonzero column; column zero can be nonzero only in its one pivot row. Therefore Cu has exactly that single nonzero coordinate. When the first N−1 rows span ker(e_0), column zero is the last remaining free column, and the last row equals ±e_0. The exceptional mixed case needs two pairs. When the first row spans e_0, the original dual is supported solely on that first row, and the other mixed exception needs two pairs. Each event has probability 2/(9x−1). If both corners fail, the one support of Cu is interior (its being last would force the previous case). A single pair cannot repair both corners there. Thus the count inequality is equality for this low law on e_0. This identifies the exact worst mean for the stated selector over all rank-one source frames. It makes no claim about the frequency of this particular frame in the complete supplier word. check_flags.py verifies sharpness at N=2,3,4, including every paired frame at N=2,3. + +Every installed N exceeds eight. The complete mean is below 75/32. The actual chronological bound buys τ=47/20 within 11/8 bits of rate debit. The normalized child volume is at most (75/32)/(47/20)=375/376 at both required moments. Sum the finite tree by induction to get a factor at most 376. The earlier-rank basis motions belong to the local invoice. [Physical charge and geometric sum](ORDINARY-CLOCK.md) · [Directed inequalities](check_complete.py) + +A useful lower obstruction remains. Conditional on a and not b, the last dual coordinate is a nonunit. Select a preceding unit v_j. Adding 3t times the final row to row j permutes the actual permitted high lifts of this low, since free columns decrease by inclusion. The second trit of the last dual cycles, while the first primal stays a unit. At least two thirds of that packet at modulus at least 9 has a nonzero nonunit upper right coefficient. In contrast the outside corner of L S R for any invertible lower L,R and a single weighted interchange S is either zero or a unit. The f-column version compares its extreme square block. Thus one cannot fund every true high with just one such child and free lower passes. The direct path's extra same-bank basis moves are paid on the bounded direct column range. + +## Evidence and credit + +[The implementation](five_exchange.py) uses the original physical tape primitives. [receiver.patch](receiver.patch) connects both live entry points in the digest-checked predecessor. normal_five.py compares dirty records in the public direct receiver and quotient receiver with a dense independent projector. The same packet on the older code provides these finite physical measurements. + +| Path | Lows | Records | Children, old → new | Arena moves, old → new | Historical bytes, old → new | +|---|---:|---:|---:|---:|---:| +| Nonidentity direct | 1 | 324 | 7 → 1 | 228,096 → 116,640 | 5,184 → 7,776 | +| Full quotient | 16 | 5,184 | 112 → 32 | 4,407,696 → 2,790,288 | 90,720 → 90,720 | + +check_five.py checks 1,112,292 opaque records over nine distinct packet tests and another 2,000 independent modular vector cases at N=2,3,4,8,17 and moduli up to 81. It includes the N=2 edge ties, two nontrivial component widths together, repeated high types, earlier prefix and gap values, and two columns. direct_exact.py adds 64,800 independent records from four noncommuting rational direct frames. The reference matrix and inverse there are generated by separate exact elimination. One full public quotient call in [the complete high-class test](true_high.py) covered all 16 lows × 27 actual high lifts at modulus 9, 216 distinct pairs of placed factors and 2,834,352 opaque payload records. It used 40 children and 1,628,281,996 arena moves, with 49,601,160 bytes of historical backing, and matched an independent two-by-two matrix inverse on every returned record. The finite signed product returns −345550037539 on −741503 and 466013, with coefficients [11811,10996,4152,868,77], 157248 physical H calls and 138 binary shuttles in the rank-two checked installation. That small product is a composition control. The new direct/quotient branches are identified by the two independent packet tests. The large admitted ranks cannot be executed with this hardware. + +The Lean kernel checks the conjugated weighted swap, arbitrary basis/weight direct action, quotient outside and middle action, and arithmetic of the count. Standard Lean axioms are listed by #print axioms and replayed by leanchecker. The full invertible-group first-coordinate and exceptional-line counts also have kernel checks in [MatrixMarginals.lean](lean/MatrixMarginals.lean). The projection from the canonical quotient flags, connected tape bindings, source finite factor checks, numerical pipeline and complete time/space lowering remain written or computational checks. + +Source evidence follows. [Inherited true sheet and pivot body](https://github.com/CrocSwap/integer-mult-bounds/blob/9585c1fa2ed5f2316ac09e04b357cb720badfcb8/research/triangular-native-supplier/same_order_body.py), [physical direct matcher](https://github.com/CrocSwap/integer-mult-bounds/blob/9585c1fa2ed5f2316ac09e04b357cb720badfcb8/research/triangular-native-supplier/direct_body.py), [original quotient and representatives](https://github.com/CrocSwap/integer-mult-bounds/blob/9585c1fa2ed5f2316ac09e04b357cb720badfcb8/research/triangular-native-supplier/quotient_route.py), [physical binary catalogue and attributed predecessor chain](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/STRONG-BINARY.md), [signed high-price caller](https://github.com/CrocSwap/integer-mult-bounds/blob/ea776471bf8ed143a0625cf2d7532f65d15eb5f9/research/p104-single-band-signed-margin/README.md). diff --git a/research/retimed-native-multiplier/RESOLUTION.md b/research/retimed-native-multiplier/RESOLUTION.md new file mode 100644 index 0000000000..02a2e77e17 --- /dev/null +++ b/research/retimed-native-multiplier/RESOLUTION.md @@ -0,0 +1,42 @@ +# A seventh physical receiver at the six-stage reporting limit + +Clear1nsight’s 430-factor construction reaches κ = 0.003890115286594445. It uses six ordinary stages and a positive stop denominator of 10²¹. The new signed multiplier reaches the same κ with one more ordinary stage, lower per-stage costs and the same two unpowered circuits as the other profiles. It retains the same five research premises. [430-factor proof](https://github.com/Clear1nsight/integer-mult-bounds/blob/c3746ea769fcf0d20818d7e18366f1b602e4aa3d/research/p104-six-stage-resolution/PROOF.md) · [Published receipt](predecessor/LAST-TICK-RECEIPT.json) · [Source bindings](SOURCES.json) + +| Exact-price comparison | Last binary H | Numerical H | Complete activation A | +| --- | ---: | ---: | ---: | +| Published 430-factor six-stage machine | 1,024,000,000,000,000,000,000,000 | 1,600,000 | 1,365,004,016,064,257,029,713,503 | +| Same powered price, six-stage refit with all first-entry checks | 181,000,000,000,000,000,000 | 1,515,618 | 217,195,438,131,126,840,924 | +| Same powered price allowed seven stages, sensitivity calculation | 1,980,000,000,000,000,000 | 1,515,618 | 2,375,991,682,782,021,338 | +| New seven-stage signed machine | 95,600,000,000,000,000 | 19,000 | 101,973,332,976,357,367 | + +A native rank is $2^H$. The new last binary cohort retains $2^{8,795,200,000,000,000,000}$ real rows. The numerical cohort retains $2^{1,748,000}$ rows. The first connected geometry contains $2^{101,973,332,976,357,298}$ axes. Its largest axis needs 98,382,635,059,784,275,286 address bits. The first sufficient input length in bits is $2^{\lceil 2^A/6\rceil-1}+1$. These are model dimensions and sufficient conditions. Host memory, signed 64-bit offsets and actual multiplication speeds have different limits. [Controller and historical storage](ACTIVATION.md) + +## Attainment and the scope of the comparison + +Let $c=4484997569314581/2^{60}$ be the certified retimed trial. Even if the six stages could spend zero bits to transport their arrays and book exact real-valued rates, they could pay only $c(1-250^{-6})$. This is strictly below the requested κ, by $155262826220501/281474976710656000000000000000000$. Thus smaller heights alone cannot reach this rate with the existing retimed six-stage rule. A seventh true receiver changes the cold-start term to $c/250^7$. The installed heights are 5,698,204,041; 91,171,264,649; 1,458,740,234,375; 23,339,843,750,000; 373,437,500,000,000; 5,975,000,000,000,000 and 95,600,000,000,000,000. Each stage pays its actual 11/8-bit debit. Each intermediate rate is one tick below the rounded-down boundary on the $10^{-21}$ grid. The last stage buys exactly κ + 5·10⁻²¹. Its remaining strict margin exceeds $8.74\cdot10^{-21}$. The positive stage pays its separate 39/256-bit debit at H = 19,000. All 54 strict and four functional signed conditions hold. Their denominators divide the square of the stop denominator. The independent numerical margin needs one further factor of 19. With that common scale the signed checks use at most 186 bits. [Literal price and ceilings](RESULT.json) · [Lean induction and exact bookings](lean/SevenStage.lean) + +The source passes the number of installed ranks into the initial dispatcher. Each stage passes its own index minus one into its predecessor. On every mandatory first crossing the stopped weighted atom asks for the actual predecessor interchange at width above the previous cutoff. The seventh receiver therefore reaches all six prior receivers. The production selector checks the public width logarithm against each real cutoff. The verifier uses that same comparison at the two sides of all seven true boundaries. Actual small-width digit measurements also exercise this branch. The earlier physical tests cover arbitrary data in the shared ordinary body. No test allocates a full field at these seven heights. The new stage adds one fixed set of role tapes, one historical pad at most, and a full independent term in the ordinary transition and storage sums. [Selector and signed integration](machine.patch) · [All-size storage](ACTIVATION.md) · [Source-level role assignment](STAGE-STORE.md) + +For the prior power-430 price let $c_o$ be its actual dyadic trial and $d=31$. Write $b=\kappa+5/10^{21}$. Dropping the first debits and retaining all five directed $10^{-18}$ roundings gives a sixth-stage upper limit $u$. A terminal height must satisfy $H_6>(249/250)d/(u-b)$. The resulting minimum is exactly 175,918,902,360,455,213,871. A six-stage height list with geometric ratio three attains this terminal minimum. Its activation exponent is 263,519,287,904,617,167,988. The table uses a different refit that reduces total activation further. Both pass the predecessor's top-width, parent-recursion, quotient and simultaneous-stock conditions. [Exact minima, refits and controls](resolution.py) + +There is also a bound independent of how these paid stages are tuned. Monotonicity and the cold start give + +$$ +c_o-b_m \;>\; c_o250^{-m}+(249/250)d\sum_{i=1}^m 250^{i-m}/H_i . +$$ + +Five ideal stages cannot reach κ. On the last six terms Cauchy–Schwarz and $1/16<1/\sqrt{250}$ give $A>\sum H_i>(249/250)d(\sum_{j=0}^5 16^{-j})^2/(c_o-b-c_o250^{-m})$. Thus six stages force $A\ge192,932,563,756,139,752,661$, over 1,891 times the new A. Dropping the cold term entirely still forces $A\ge2,179,823,139,751,493,506$ at any stage count, more than 21.37 times the new A. The latter comparison grants the predecessor extra stages. Its feasible seven-stage tariff row checks prices, guards and width tables. It does not constitute a separate published powered seven-stage implementation. Different raw circuits, debits or funding rules fall outside these lower bounds. For the new tariff itself, up to seven stages force $A\ge101,752,003,703,545,537$. The chosen ranks lie within 0.22% of that activation floor. For any number of stages the six-stage obstruction first implies m≥7. Apply the same width inequality to the last seven terms with 63,245,553,203/10^12 below 1/√250, and omit the cold term. The binary sum then exceeds 101,491,622,976,982,786. Adding the mandatory numerical height gives A≥101,491,622,977,001,680. Even an unlimited stage count under these two tariffs could improve the new A by less than 0.48%. [Exact comparisons](resolution.py) · [New tariff floor](check_complete.py) + +## The complete bill + +The new upper bounds for a fixed serial multitape program are $\log_2 S\le513$ and $\log_2 C\le1,670,731,087,109,379,198,659$. The complete time is at most $2^{513}+C n(1+\log_2 n)^{1-\kappa}$ for all canonical operand lengths $n\ge1$. The earlier finite-prefix ceiling is $2^{84,500,000}n$. The stage sum is 101,973,332,953,453,065. Its multiplier 16,384 accounts for ordinary preparation, movement through genuine row fields, arithmetic, suspended calls and restoration. It supplies most of the recurring logarithm. The positive term adds $220\cdot19000$ bits. It includes the full two-copy word, public placement and inverse, high stock, and internal arithmetic. The outer clock pays the three transforms, CRT, carry and signed recovery. At the smaller stop gap the elementary bound $(128/g)^{16}<2^{1024}$ fails. The sharper uniform bound $(17/g)^{16}<2^{1182}$ pays the outer logarithms and leaves the 1,600-bit assembly allowance intact. One more stage does not duplicate the outer prologue. [Complete clock](CLOCK.md) · [Tighter stop absorption](OUTER-CLOCK.md) · [Original five research premises](NOTICE.md) + +The 430-factor predecessor publishes a fixed setup exponent of 1,048,576,000,000,000,000,000,000,003. Its actual installed instruction count also has an exponential lower bound. Put v=430, R=(5/4)^v, U=2^(H−2)/134^v and let G be the first integer with R^G>U. Choose the attained paid block of rank 12^v. At depth one choose a labelled rank-15 factor in every future target position. There are 444 raw choices per position, all retained at equality in the source. The normalized column count before flooring is x=R^(G−1), so U/R2^(H−2−9v)>2^70. Every resulting unit passes both the floor and capacity guards. Each has an external source since xR>U. The root visits its child through the prefix table even with empty incoming requests. The epoch emits and stores at least one OPEN instruction per unit. Thus this one stage installs at least 444^(v(G−1)) distinct indexed units and strictly more than 2^[8(H−2−9v)] OPEN records, including all repeats. At the published height the lower exponent is **8,191,999,999,999,999,999,969,024**. An independent finite check with repeated target ranks found 27 distinct depth-one futures, 17 copies, 1,428 OPEN instructions and 66,397 actual image bytes. The counting proof compares work that the old initializer must perform with the complete new upper bound. [Formal first-layer bound](lean/CountedEpoch.lean) · [Actual source multiplicities](https://github.com/Clear1nsight/integer-mult-bounds/blob/c3746ea769fcf0d20818d7e18366f1b602e4aa3d/research/p104-six-stage-resolution/check_bridge.py) · [Forest enumeration](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/band_compiler.py) · [Emitted and stored instructions](https://github.com/CrocSwap/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/epoch_tape.py) + + The new machine compiles the literal words, their fixed role arrays and two grade tables. All growing incidence tables and payload movement are built and charged on entry. A fresh CPython 3.12.16 process generated all eight recipes of the highest-rate retimed machine in 81.68 seconds, with a process high-water mark of 307,789,824 bytes on the author's machine. Ten subsequent lookups returned the same objects. This measures fixed recipe generation. Production payload execution remains infeasible. [Original source and tape bridge](https://github.com/Clear1nsight/integer-mult-bounds/blob/c3746ea769fcf0d20818d7e18366f1b602e4aa3d/research/p104-six-stage-resolution/BRIDGE.md) · [Fixed generation and payload costs](INSTALLATION.md) + +## A comparable clock for the published machine + +The predecessor states a finite recurring coefficient without a number. For comparison, lower its payload and control steps using the same contiguous prefix scans, binary counters, head movements, integer arithmetic and restoration as the new machine. The charged circuits still differ. The old direct native route uses the nine-call tariff and pays five outer bits. Its contraction ratio is at most 9·(16/15)/32=3/10. The 430 factors change the number of fixed labels, the total rank, and the period. Their physical charts still use the same 36-call binary source. Its 44,825 elementary factors have numerator and denominator magnitudes at most 20. The published bridge proves that the 430-factor slot indices fit the dynamic 65,536-bit logarithmic allowance at these ranks. Specifically, 19+2·12,973+bitlength(G+1)<53,044<65,536. The genuine expanded program and all its head visits retain their powers of the true J=N^1024. The predecessor's six fixed cutoff keys need at most 81 bits each. Scanning six such keys costs less than 2^20 transitions, within the 2^100 cold allowance. The positive machine uses the original 128-factor word at H_M=1,600,000 with the 70-bit cutoff. The capped tests and its parent rows use the charged bounds in the [predecessor positive clock](PREDECESSOR-POSITIVE-CLOCK.md). The common outer factor from the smaller stop is covered above. + +Substitution in the [ordinary clock](ORDINARY-CLOCK.md) gives log₂ B_old ≤ 40+16384·sum H_i. The positive multiplier is M^100(1+B_old). Including the initial range, a conservative integer value of log₂ C_old is 22,364,160,000,000,000,000,160,001,642. This is our new bound for this specified sequential lowering of the old construction. It is neither an original numerical claim of the predecessor nor an estimate of CPython time. No lower bound on either machine's least C follows. [Old 430-factor tape bridge](https://github.com/Clear1nsight/integer-mult-bounds/blob/c3746ea769fcf0d20818d7e18366f1b602e4aa3d/research/p104-six-stage-resolution/BRIDGE.md) diff --git a/research/retimed-native-multiplier/RESULT.json b/research/retimed-native-multiplier/RESULT.json new file mode 100644 index 0000000000..67f8707a1d --- /dev/null +++ b/research/retimed-native-multiplier/RESULT.json @@ -0,0 +1,661 @@ +{ + "resolution_comparison": { + "retimed_any_stage_count_A_floor": 101491622977001680, + "prior_head": "c3746ea769fcf0d20818d7e18366f1b602e4aa3d", + "old_six_A_floor": 192932563756139752661, + "old_any_stage_count_A_floor": 2179823139751493506, + "prior_binary_H": [ + 1000000000000000000000, + 4000000000000000000000, + 16000000000000000000000, + 64000000000000000000000, + 256000000000000000000000, + 1024000000000000000000000 + ], + "prior_numerical_H": 1600000, + "prior_A": 1365004016064257029713503, + "prior_log2_S_le": 1048576000000000000000000003, + "prior_installed_OPEN_log2_gt": 8191999999999999999969024, + "prior_log2_C_le": 22364160000000000000160001642, + "old_powered_last_H_strict_integer_floor": 162953853479683169949, + "old_exact_trial_last_H_floors": [ + 175918902360455213871, + 1924036490513633076 + ], + "old_minimum_sixth_height_witness": { + "heights": [ + 723946100248786889, + 2171838300746360666, + 6515514902239081996, + 19546544706717245986, + 58639634120151737957, + 175918902360455213871 + ], + "numerical_H": 1515618, + "A": 263519287904617167988, + "all_size_stripe_margin": 100735282531864885850 + }, + "old_powered_six_refit": { + "heights": [ + 23276748971193416, + 139660493827160494, + 837962962962962963, + 5027777777777777778, + 30166666666666666667, + 181000000000000000000 + ], + "numerical_H": 1515618, + "A": 217195438131126840924, + "all_size_stripe_margin": 83027105903227861351 + }, + "old_powered_seven_price_sensitivity": { + "heights": [ + 42438271604939, + 254629629629630, + 1527777777777778, + 9166666666666667, + 55000000000000000, + 330000000000000000, + 1980000000000000000 + ], + "numerical_H": 1515618, + "A": 2375991682782021338, + "all_size_stripe_margin": 908268207007002971 + }, + "retimed_zero_debit_six_stage_upper": "1094970109695938141955555685419/281474976710656000000000000000000", + "retimed_six_stage_deficit": "155262826220501/281474976710656000000000000000000", + "stop_absorption_log2_le": 1182 + }, + "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 + } + }, + "equal_rate": { + ".00389": { + "old_word_power": 228, + "feasible_H": [ + 686359, + 10981738, + 175707798 + ], + "feasible_H_M": 1489590, + "feasible_A": 188868731, + "old_A_lower_in_stated_tariffs": 188252135, + "feasible_log2_C_le": 3070115624158 + }, + ".00389011528": { + "old_word_power": 268, + "feasible_H": [ + 3232696, + 51723128, + 827570043, + 13241120677, + 211857930826, + 3389726893208 + ], + "feasible_H_M": 1515617, + "feasible_A": 3615709999957, + "old_A_lower_in_stated_tariffs": 3609923786113, + "feasible_log2_C_le": 59239767733513130 + }, + ".0038901152865907": { + "old_word_power": 285, + "feasible_H": [ + 6634625402, + 106154006424, + 1698464102779, + 27175425644461, + 434806810311369, + 6956908964981897 + ], + "feasible_H_M": 1515618, + "feasible_A": 7420702481833889, + "old_A_lower_in_stated_tariffs": 7404411307975972, + "feasible_log2_C_le": 121580789001119050766 + } + }, + "binary": { + "productive": 18906, + "paid": 104904, + "cells": 24, + "directed_margin": "82842835076019278655/81805129444042060601000009008477661941", + "factor_upper_times_1000000": 1101615 + }, + "positive": { + "productive": 105216, + "paid": 564144, + "cells": 54, + "directed_margin": "1162362417094264714206716158580/712832082881474022086691592938270190237", + "factor_upper_times_1000000": 1111354 + }, + "profiles": { + "selected-price": { + "A_lower_in_this_price": 6171, + "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": 18721, + "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": 161043, + "kappa": "96998200889/25000000000000", + "binary_H": [ + 9100, + 144000 + ], + "numerical_H": 8500, + "width_logs": [ + 837200, + 13248000, + 782000 + ], + "stage_rates": [ + "744812063990715409/200000000000000000000", + "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 + }, + "balanced": { + "A_lower_in_this_price": 13534103, + "kappa": "389/100000", + "binary_H": [ + 50900, + 804000, + 12800000 + ], + "numerical_H": 19000, + "width_logs": [ + 4682800, + 73968000, + 1177600000, + 1748000 + ], + "stage_rates": [ + "961912282000527511/250000000000000000000", + "972060515937783939/250000000000000000000", + "77800000001/20000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000", + "ordinary_margin": "1/100000000000000", + "positive_margin": "2005573205533/12451840000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 2, + "first_extent_bits_minus_b": -13674562, + "last_extent_bits_minus_b": -13674561, + "minimum_width": 7001379584, + "log2_axis_count": 13674530, + "largest_axis_width": 11453246123, + "private_clock_log2_upper": 11742140529735, + "actual_dense_root_entry_log2": 22906492246 + }, + "binary_cuts": [ + 51169, + 855233, + 13655297 + ], + "public_exponent_A": 13674566, + "first_public_offset": 2, + "initial_s": 13674567, + "stage_and_outer_fixed_log_overhead": 1968, + "retimed_first_stripe_margin": 6835217, + "retimed_all_size_margin_floor": 6621647, + "absolute_log2_private_control_envelope": 13107200003, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 223721881665, + "log2_C_le": 223726063267 + }, + "near": { + "A_lower_in_this_price": 236289566495, + "kappa": "48626441/12500000000", + "binary_H": [ + 3550000, + 56200000, + 888000000, + 14100000000, + 222000000000 + ], + "numerical_H": 19000, + "width_logs": [ + 326600000, + 5170400000, + 81696000000, + 1297200000000, + 20424000000000, + 1748000 + ], + "stage_rates": [ + "774833810160039043/200000000000000000000", + "778005426664776237/200000000000000000000", + "1945056695875824167/500000000000000000000", + "1945057590943714779/500000000000000000000", + "77802305600001/20000000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000000", + "ordinary_margin": "1/100000000000000000", + "positive_margin": "71265714037801/1556480000000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -237047783941, + "last_extent_bits_minus_b": -237047783940, + "minimum_width": 121368465381632, + "log2_axis_count": 237047783895, + "largest_axis_width": 187649984473771, + "private_clock_log2_upper": 192396558079754762, + "actual_dense_root_entry_log2": 375299968947542 + }, + "binary_cuts": [ + 3564322, + 59764386, + 947764450, + 15047764514, + 237047764578 + ], + "public_exponent_A": 237047783945, + "first_public_offset": 4, + "initial_s": 237047783946, + "stage_and_outer_fixed_log_overhead": 1976, + "retimed_first_stripe_margin": 118523889843, + "retimed_all_size_margin_floor": 114820018369, + "absolute_log2_private_control_envelope": 227328000000003, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 3883790336000081, + "log2_C_le": 3883790340181683 + }, + "matched": { + "A_lower_in_this_price": 421764310695960, + "kappa": "38901152865907/10000000000000000", + "binary_H": [ + 401000000, + 6340000000, + 101000000000, + 1590000000000, + 25100000000000, + 396000000000000 + ], + "numerical_H": 19000, + "width_logs": [ + 36892000000, + 583280000000, + 9292000000000, + 146280000000000, + 2309200000000000, + 36432000000000000, + 1748000 + ], + "stage_rates": [ + "242159463139757029/62500000000000000000", + "3890052815079563267/1000000000000000000000", + "972528755787248713/250000000000000000000", + "972528821169839441/250000000000000000000", + "3890115286532238217/1000000000000000000000", + "15560461146363/4000000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/1000000000000000000", + "ordinary_margin": "1/100000000000000000", + "positive_margin": "14251091149013/311296000000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -422797742630267, + "last_extent_bits_minus_b": -422797742630266, + "minimum_width": 216472444226700544, + "log2_axis_count": 422797742630210, + "largest_axis_width": 384307168202282326, + "private_clock_log2_upper": 393963907925333199232, + "actual_dense_root_entry_log2": 768614336404564652 + }, + "binary_cuts": [ + 402610507, + 6742610571, + 107742610635, + 1697742610699, + 26797742610763, + 422797742610827 + ], + "public_exponent_A": 422797742630271, + "first_public_offset": 4, + "initial_s": 422797742630272, + "stage_and_outer_fixed_log_overhead": 1980, + "retimed_first_stripe_margin": 211398871312958, + "retimed_all_size_margin_floor": 204792656584555, + "absolute_log2_private_control_envelope": 405504000000000003, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 6927118188544000089, + "log2_C_le": 6927118188548181691 + }, + "resolution": { + "A_lower_in_this_price": 101752003703545537, + "kappa": "778023057318889/200000000000000000", + "binary_H": [ + 5698204041, + 91171264649, + 1458740234375, + 23339843750000, + 373437500000000, + 5975000000000000, + 95600000000000000 + ], + "numerical_H": 19000, + "width_logs": [ + 524234771772, + 8387756347708, + 134204101562500, + 2147265625000000, + 34356250000000000, + 549700000000000000, + 8795200000000000000, + 1748000 + ], + "stage_rates": [ + "1937277292554599271/500000000000000000000", + "1945026514383669541/500000000000000000000", + "389011503662432813/100000000000000000000", + "1945057642767951683/500000000000000000000", + "486264410823319859/125000000000000000000", + "389011528659419957/100000000000000000000", + "778023057318889001/200000000000000000000" + ], + "signed_gate": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/10000000000000000000000", + "ordinary_margin": "1/1000000000000000000000", + "positive_margin": "44534656246164761/972800000000000000000000" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -101973332976357363, + "last_extent_bits_minus_b": -101973332976357362, + "minimum_width": 52210346483894973696, + "log2_axis_count": 101973332976357298, + "largest_axis_width": 98382635059784275286, + "private_clock_log2_upper": 100848340967519864263672, + "actual_dense_root_entry_log2": 196765270119568550572 + }, + "binary_cuts": [ + 5721088459, + 96892353172, + 1555632587611, + 24895476337675, + 398332976337739, + 6373332976337803, + 101973332976337867 + ], + "public_exponent_A": 101973332976357367, + "first_public_offset": 4, + "initial_s": 101973332976357368, + "stage_and_outer_fixed_log_overhead": 1984, + "retimed_first_stripe_margin": 50986666488176470, + "retimed_all_size_margin_floor": 49393333160421113, + "absolute_log2_private_control_envelope": 97894400000000000004, + "storage_upper": "6.2 p T < 297.6 n bits", + "log2_fixed_setup_and_install_le": 513, + "log2_ordinary_clock_le": 1670731087109375017057, + "log2_C_le": 1670731087109379198659 + } + }, + "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 + ] + }, + "19000": { + "period": 1620, + "first_tickets": [ + 0, + 324, + 648 + ] + } + } + } +} diff --git a/research/retimed-native-multiplier/SOURCES.json b/research/retimed-native-multiplier/SOURCES.json new file mode 100644 index 0000000000..29469b94f2 --- /dev/null +++ b/research/retimed-native-multiplier/SOURCES.json @@ -0,0 +1,74 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "physical_head": "6285dd829114705862e8d91facaedc1f31d3cfcb", + "physical_tree": "3a1c001cbf175ae48ee1d56e56e4723eda1c8218", + "signed_head": "ea776471bf8ed143a0625cf2d7532f65d15eb5f9", + "frozen_inputs": { + "OVERLAY.json": "73aaf56a8a199cf3b7fc6c87316ca50298f47561e4b7c227edec6230f12a8403", + "SOURCES.json": "3634f7a15b8ca6f1832e48bdd4e83bd764509f804196d956149a9a82e7512a64", + "predecessor-8030.tar.gz": "769d5a05cc1373fa22ed5956af636992fcd19d7e5c1753a32033a73c358cd31c" + }, + "physical_catalogue": "fb9b6a7b0d27da1cf98430893a3016bf811e2aa4", + "mathematical_dependencies": "Physical and signed correctness and five inherited framework obligations from the pinned sources.", + "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" + } + ], + "counted_compiler": "1ca6b8111297ac2cc2dcfe5da0027656898f7589", + "inherited_ci": "0618e75a22cec54d1651394ef83d088551b7f026", + "outer_budget_sha256": "ca4438db28a447ed5c43d87d43f0ac10a0cb2b4e183342ac93139d517b9d4d02", + "initial_retimed_comparison": "3d33cb0c8a523b66d91e8de8250b85d0a436eb35", + "six_stage_comparator": { + "head": "c3746ea769fcf0d20818d7e18366f1b602e4aa3d", + "file": "LAST-TICK-RECEIPT.json", + "sha256": "057e381fa486590b6190aceeac59aafe2102626a011a9f3fd7b871e6719512d5", + "source": "research/p104-six-stage-resolution/LAST-TICK-RECEIPT.json" + } +} diff --git a/research/retimed-native-multiplier/STAGE-STORE.md b/research/retimed-native-multiplier/STAGE-STORE.md new file mode 100644 index 0000000000..8ee02945d5 --- /dev/null +++ b/research/retimed-native-multiplier/STAGE-STORE.md @@ -0,0 +1,35 @@ +# Fixed tape roles at the seventh stage + +The 54-cell numerical supplier calls seven installed ordinary receivers. This section binds their recursive data to a fixed number of serial heads. The five physical and analytic premises remain in force. The concurrent [seven-stage price](https://github.com/CrocSwap/integer-mult-bounds/pull/8048) uses the older 31-cell numerical word and a different ordinary tariff. Its [open inventory question](https://github.com/Clear1nsight/integer-mult-bounds/blob/9b4bb847d7573c8e08827fee22e9bcad8c9bb43c/research/p104-seven-stage-retimed/PROOF.md) concerns that installation. + +## Fixed heads and the two forms of recursion + +Reserve one fixed set per ordinary stage. The page kinds and arities are `weighted` 2, `compiler` 3, `issued-leaf` 1, `chart-line` 2, `chart-packet` 2, `direct-coordinate` 2, `exposed-leaf` 2, `matcher` 2 and `triangular-body` 2. The pending and answer tapes bring the total to 20. Assign one scratch head per `work_tapes` call site and tuple position per stage. The sites together specify 91 slots, including the binary rectangle, cold routes and 22 buckets in `scale_atom`. Seven disjoint sets require at most 777 binary native heads. An eighth complete set for the public rectangle and cold terminal raises this conservative count to 888. The outer and Gaussian heads retain their own allocations. [Installed site list and binding checks](check_stage_inventory.py) · [Ordinary source delta](machine.patch) + +At the public entrance `ordinary_swap` holds its two rectangle streams. It enters `ternary` with the length of the installed rank list. Its descendants use the ternary service directly. A stage root retains five work files and passes one consecutive prefix slab at a time. The root pads its input and output by a factor less than two. The receiver binds `previous` to `ternary` with `maximum=stage-1`. The direct matcher, stopped weighted pair, quotient affine operation and limb scaler can hold scratch across this call. At most one root of each index is live. The earlier stage consumes and fills the two identified parent intervals while it uses its own fixed heads for new scratch. Terminal bit and trit primitives return directly. The iterative limb scaler holds three permanent scratch files and may open seven more in an odd step or one for a carry. + +A same-stage paid call comes from the empty direct line, the coordinate call between the two basis routes, or one of the ordered quotient children. Here the current binary arena stays live. A temporary direct receiver shares that arena with its parent when one is already open. At the paid call, the raw iterator has already returned its Job. Its clone, move and XOR work files have closed. The intermediate scratch in the basis or quotient routes ends before the same-stage call or crosses a strictly earlier stage. The five rank-root files persist once. Within the rank, recursive calls therefore retain named pages, packet markers and real owner slots. They can reuse the same scratch tapes at arbitrary depth. [Direct and quotient bodies](five_exchange.py) · [Rank-local source and decoder](raw_binary_stage.py) · [Weighted receiver changes](receiver.patch) + +On a named page tape, each child opens at the end of the current parent. A parent can be read while its child is open. Writing or truncating a page requires that it be on top. The weighted child copies its argument onto its own page before any deeper operation. Its final copy back takes place after its descendants have returned. Releasing a page erases its bytes and pops its marker. The next sibling starts at the same live parent end. The pending stack appends complete packets in reverse order and erases each popped interval. The answer tape appends replies and clears through the saved return marker. Lower markers survive. A head can cross the whole parent bank on entry or return. The receiver keeps its position across ordered child windows and pays for these scans, including the cleanup traversals. [Ordinary movement induction](ORDINARY-CLOCK.md) · [Physical receiver](RECEIVER.md) + +Let V be the entering weighted field. At c=Nf+r the two residual factors atom^r enter the actual gap and suffix. A compiler slot therefore has volume V/B, with the unused prefix, all high representatives and both coarse blocks intact. Its Q low packets each have volume V/(BQ). A direct child takes the full slot, and a covered child takes one whole low packet. The matcher can use a preceding interchange up to volume V. Every N²-byte tag in a wide sort accompanies at least 3^(2Nfw) actual payload addresses. The split, sorted copy, full answer, temporary padding and pending packet belong to the current local bound. [Extent equations and historical limits](ACTIVATION.md) + +## Gaussian storage and suspended raw operations + +The positive entrance or an external CRT or outer shuttle can call the public binary service. A Gaussian `Field.swap` snapshots its full field, obtains its full replacement, and calls the ordinary service with both. Their storage persists until return. The outer placement files, the complete current slab and widened H working field all retain separate charges. A descending ordinary path has only one public rectangle, with enlargement less than nine. [Source and lowering](machine.patch) · [Positive cost](NUMERICAL.md) + +An active positive invocation opens `Arena.child` for its B rows. Its input snapshot closes before `Plan.run`. The output scratch opens after the last raw return. A paid child receives exactly one extant row of volume V/B. Its arena starts beyond the parent's historical slot high. New allocations in the parent are suspended until the child's slots retire. The allocator truncates to the saved start. A free slot is used before the high grows. `Field.blank` retains its arena and `replace` checks that the two arenas agree. Graph-node fields, mixed-chart results, saved replacements, simultaneous raw outputs and scalar snapshots therefore occupy actual charged cohort slots or immediate scratch. `ComplexRaw.scratch` gives an existing field a new owner key. [Two-copy source and return](retimed_supplier.py) + +The seven raw or scheduler generators in the [source check](check_stage_inventory.py) yield with no open work-file, page or snapshot scope. Their suspended owners remain live. Group them by raw birth tick. At most 2N^6 births per tick, a lifetime below N^77, and fewer than 2^67 new fields per context give at most 2^68 N^83 additional physical slots. The B=N^92 external owners remain reserved. The sum is less than 2B over the installed range. A pending Job names an existing slot and stores its charged control axes. This argument covers the two distinct subjobs at a half-column cut. [Causal stock bounds](TRANSFER.md) · [Generation and controls](INSTALLATION.md) + +## Historical peak and complete cost + +Induct along an active call path. Same-stage true arguments contract. A transition to an earlier stage adds at most one factor of two. With the binary rectangle and fixed positive entrance, every true incoming argument stays within 2^(m+12) starting stripes. A suspended backing or retired sibling can enlarge one head's highest address. Its high is bounded by the greatest sum of local open extents over the trace on that head, including all earlier siblings. Fixed heads may have maxima at different times. Sum their maxima. This is the historical allocation cover that enters the complete storage proof. + +With the starting stripe factor 128, at most 32(s+128) native heights, the local bound 2^800 and outer bound 2^1024, even charging eight complete sets in the existing physical-role estimate adds only three bits. The logarithm of the complete factor is at most + + 7 + (m+12) + 800 + 1024 + 5 + 35 + 3 bitlength(s+128). + +At m=7 this equals 1890+3 bitlength(s+128), below the installed D(s)=1984+4 bitlength(s+128). The private coefficient, control, numeric table and index bounds are separate. Crossing to a preceding stage already has its own term in the ordinary clock. Fencing the role tapes changes neither the complete time receipt nor the connected threshold. [All-size space proof](ACTIVATION.md) · [Complete clock](CLOCK.md) · [Exact receipt](RESULT.json) + +`StageStore.historical` proves the single-role historical inequality for any sequence of pushes, interval replacements and pops with the stated depth and extent bounds. The written argument above binds those operations and their parameters to the installed source. The finite replay checks the actual allocator at seven stages, three nested levels per stage and a second dirty sibling. Across 42 visits it checked 10,752 historical bytes, 125,062 charged head movements, all restored data and zeroes on return. The separate Gaussian replay found that siblings reuse the actual 128-byte historical parent end. Run `python3.12 -IB research/retimed-native-multiplier/verify.py slabs` from the repository root. [Lean proof](lean/StageStore.lean) · [Physical fence replay](check_stage_fences.py) · [Verification scope](VERIFICATION.md) diff --git a/research/retimed-native-multiplier/TASK.json b/research/retimed-native-multiplier/TASK.json new file mode 100644 index 0000000000..e14eee8437 --- /dev/null +++ b/research/retimed-native-multiplier/TASK.json @@ -0,0 +1,89 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "selected-stock-envelope", + "question": "What explicit uniform stock envelope does the actual selected stopped producer supply at one bootstrap stage?", + "starting_points": [ + "research/selected-bootstrap-stock-audit/README.md", + "research/bootstrap-cutoff-time-space-split/README.md", + "certificates/selected-result.json", + "docs/research/community-efficient1000-review.md", + "research/stock-margin-chain/README.md" + ], + "methods": [ + "Derive a source-bound reserve recurrence at the actual selected atom widths, separating parent stock from completed inner borrowing.", + "Find an exact missing implication or counterexample to a proposed selected-stage stock envelope." + ], + "acceptance_gate": "Bind every coefficient and depth factor to the selected producer and state the width domain. Compare a proved envelope with the sufficient cutoff guard; a large numerical headroom or a historical m=120 coefficient is not a selected m=73 proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "first_experiment": "Choose one actual selected producer/stage and derive its parent reserve and depth coefficient from source. Check whether newer handoffs already cover that exact obligation. Stop with the missing implementation lemma if it cannot be bounded; do not rerun #2972 cutoff/headroom arithmetic as a new contribution.", + "bottleneck_link": "This reduces a concrete inherited implementation obligation without confusing unchanged kappa arithmetic with a completed theorem.", + "allowed_variations": [ + "One stage or one explicit reserve/depth implication.", + "An independently checked same-domain proof repair, retaining all remaining assumptions." + ], + "scope_change_triggers": [ + "Importing the historical 57604 or 252 allowance without a selected-producer binding.", + "Calling a conditional fit lemma a full outer-proof adoption.", + "Replacing an actual selected stock coefficient with cutoff comparisons or a conditional fit inequality." + ], + "overlap_terms": [ + "selected stock", + "stock envelope", + "bootstrap cutoff", + "1956", + "1965", + "1990", + "2972", + "stock-margin-chain", + "actual_stock_coefficient" + ], + "existing_checks": [ + { + "scope": "Retained stock audit identifies missing actual selected-stage coefficients; later cutoff-chain arithmetic does not supply them.", + "evidence": "docs/research/research-family-status.md#revision-6-handoffs-source-archives-awaiting-independent-validation", + "remaining": "Derive one actual reserve/depth coefficient from the selected producer.", + "status": "reviewed", + "source_commit": "836b19bfa309ceafbc8ee32a15e8c4b10dde7e11", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/8039", + "related": [ + "https://github.com/CrocSwap/integer-mult-bounds/pull/8030", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8033", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8035", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8040", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8044" + ], + "scope_status": "changed", + "actual_scope": "Reduce actual physical ranks, fixed installation and complete connected entrance; derive an explicit all-input recurring tape clock.", + "scope_change_reason": "The donor assigned the complete physical construction scale and its recurring clock beyond selected stock.", + "bottleneck_link": "Tensor strictification requires huge ranks. Expanded compilation, same-stage motion and the two connected raw bodies set the activation and clock.", + "stop_rule": "Publish after both true grade transports, signed application, stock, setup and all-size clock have independent checks.", + "evidence": "TRANSFER.md, INSTALLATION.md, CLOCK.md, ACTIVATION.md, RESULT.json, verify.py and lean/.", + "author": "Ali Romman", + "ai_assistance": "Substantial OpenAI Codex assistance on the construction, proofs and adversarial checks.", + "outcome": "completed", + "open_questions": [ + { + "question": "Can a different arbitrary-input binary word raise the verified raw crossing?", + "first_step": "Require its actual charts, independently productive owners, paid chronology and restoration to pass together.", + "why_it_matters": "Even seven funded stages need a last binary rank exponent above 90 quadrillion at the highest tested complete rate.", + "blocked_by": "The verified raw word crosses only about 1.6e-17 above the 430-factor six-stage target." + } + ] +} diff --git a/research/retimed-native-multiplier/TRANSFER.md b/research/retimed-native-multiplier/TRANSFER.md new file mode 100644 index 0000000000..c8a5afa257 --- /dev/null +++ b/research/retimed-native-multiplier/TRANSFER.md @@ -0,0 +1,51 @@ +# Retimed transport for two physical native words + +## The two physical words + +Use the 48-call Gaussian word of [the paired word](https://github.com/CrocSwap/integer-mult-bounds/pull/8027) with its actual charts, interleaved paid order, independent helpers and common scalar grid from [the one-band physical multiplier](https://github.com/CrocSwap/integer-mult-bounds/pull/8030). The required contract is the all-column signed physical action in that last source. This argument does not independently discharge its five inherited scientific premises. Run this word on two sets of independent owners. Use one column scale on the first copy and eight on the second. Only the first 1,008 rank-one loans of the smaller copy split into two disjoint half-columns. Check the original chronological tag before the split. Return both halves before continuing that physical generator. Keep all 105,216 productive positions and all 564,144 chronological cuts. The maximum paid and productive grades are 448 and 1,032. Their common ambient rank is 1,224. The literal two-column replay checks every returned owner and clears the private fields. In the binary 36-call word keep all 18,906 original targets and 104,904 original paid requests. Use each signed elementary basis program and each original root, helper, MOVE, IDLE and QUERY tag. The external action for an axis is an involution on the binary side and has fourth power one on the numerical side. Both admit the fourth-period cover below. + +Let $c=2092819/2^{29}$ for the numerical word and $c=4484997569314581/2^{60}$ for the binary word. Put $t=1-c$. Round each target power down and each paid power up with 112 fractional bits. For a half grade take the reciprocal of the opposite interval endpoint. The lower total exceeds the upper total for both words. Scale the target capacities to sum to the upper paid mass. In decreasing order of paid grade assign its mass to available target grades with $4k≥5r$. Divide the resulting fraction equally among the target labels of each grade. This constructs rational probabilities $π_{ji}$ for individual labels, with +$$ +\sum_i π_{ji}=1,\qquad \sum_j π_{ji} r_j^{t}\le k_i^t. +$$ +The verifier checks actual row and column sums. It finds 24 nonempty grade cells on the binary side and 54 on the numerical side. Every positive probability per target label exceeds $2^{-64}$. The relative numerical surplus exceeds $1.63\times10^{-9}$. The binary surplus exceeds $10^{-18}$. See [exact numerators and denominators](RESULT.json), [allocation](unpowered_price.py) and [independent binary grade reader and checks](check_complete.py). The resulting schedule uses each individual label. + +## Scale bands and data + +Let N=2^H, H>=1,024 (binary H>=5,610), L=32768 and A=134 or 1,224 on the binary and numerical sides respectively. Set U=2 floor(N/(2048A)), V=N^6, K=N^82 and R=N^2. The static scale coordinate x ranges from L to U. Put e=2 floor(x/2) and execute e-8 actual columns. Then x-10 < c(x) <= x-8, and A c(x) <= N/1024. The number m[e] of native copies at each time is the upward-rounded integral of V x^(-1-t) over [e,e+2), using an upper enclosure. At a paid j, for each target i, send the fraction pi[j,i] with y=x r[j]/k[i]. If L<=yU but y is in the band, issue an external occurrence at y. There are no upward interior transfers. In each child port fill every unassigned input of a native unit with its own blank zero field, then run and retire it. This is essential because the normalized transport can leave unused target capacity in the interior. It gives no credit for the dummy inputs. + +In the program, each nonempty parent-bin/target-bin intersection reserves floor of a lower enclosure of +V pi[j,i] integral x^(-1-t) dx. Source intervals use the same rule. At a paid cut assign different replicas consecutive disjoint ranges for their destinations. At the receiving label assign disjoint consecutive target ranges for its incoming records and its external occurrences. Under the change of variable x=k[i]y/r[j], the density factor is (r[j]/k[i])^t. Thus the sum entering a child bin and label does not exceed its unrounded integral or m[e]. Its outgoing ranges do not exceed m[e] by the row sum. Leftover parent replicas execute the entire paid job. The receiving criterion depends on the actual positive ranks and cells, not on an independent choice of input. + +For an interior transfer k*y=r*x and r<=4k/5. Therefore r*c(x)-k*c(y)>=8k-10r>=0 and the difference is smaller than 10k. Lend the prefix of precisely k*c(y) ordered axes and execute the whole suffix at the parent's cut. Every helper retains all its spectator coordinates. The two actions on the selected prefix and suffix commute in that chart. The recipient returns before the parent advances to another operation. No field or data comes from an observation or lookup oracle. + +The integral enclosures start with a rational reciprocal. The grid has spacing $2^{-64(H+1)}$. The binary word uses at most 60 roots and 61 products. Its unrounded reciprocal endpoints belong to $[1/(258N),1]$. Rounded bases stay above $1/(512N)$ by monotonicity. The square-root derivative there is at most $\sqrt{512N}/2$. In $[0,1]$ a rounded product adds the two term errors plus two units. The final error is bounded by $2(4\sqrt{512N})^{61}$ grid units. On the positive word use 29 roots, at most 30 products, initial lower endpoint $1/(2064N)$ and rounded lower bound $1/(4096N)$. A conservative bound is $(2048N)^{32}$ units. Subtract two endpoints and multiply by $V/t$. Both errors are below $1/4$ throughout their stated ranges. Every bin ceiling exceeds its ideal mass by less than two, and each allocation loses less than two replicas. [Signed numerical bill](NUMERICAL.md) + +## Chronological scheduling + +Let level(e)=floor(log_(6/5)(e/L)), computed by comparing powers of 5 and 6, and D[e]=D0^level(e), with D0=2^19 for binary and 2^20 for the two-scale Gaussian word. Start all m[e] true raw units of each band at each integer birth b from 0 to K-1. At t0=b+jD[e] issue paid ordinal j, starting at j=0. Close a unit at b+Q D[e], where Q is the actual paid count. For a positive edge e to d, d<=4(e+2)/5 <5e/6. Thus D[d]<=D[e]/D0. At time t0 the child at d receives real jobs from parent births t0-jD[e]. Its last paid cut and return precede the next parent cut, independent of which other j values feed the same child. Missing negative births supply private zeros. For t0>=K, any parent with a later cutoff executes its whole loan locally. Since (6/5)^77>2^20, D[e]≤(e/L)^77. The full lifetime Q D[e]+1 is less than N^77 because e≤N/(1024A) and Q≤2^20. The separate inequality (6/5)^4>2 bounds the number of dependency levels by 4H+1. + +At each integer time close all due units first. Open and issue in order of decreasing e, including the first issue of a newly opened child. Different e on one delay level cannot lend to each other. Only a live parent creates a loan. Issue the suffix on that parent before passing its prefix. Consume the prefix once, on that same tick. A fresh zero has a new owner, and external occurrences have disjoint live fields. By induction on these operations, all concurrently lent owners are disjoint until return. This also follows by giving each complete root field a unique custody token and moving that token only to the current one child at its cut. Internal aliases of the physical raw emitter, such as its idle register, stay locked in that suspended context. Other fields with different true jobs cannot use the underlying physical storage before it returns. The last close and the final empty-pending check dispose of all temporary jobs. Each active `Plan.events` emits its own open, issue and close records as the physical decoder needs them. A recursive paid call retains its parent’s iterator and live fields until it returns. + +## Price of the complete integer plan + +Write $P=\sum_j r_j^t$, $T=\sum_i k_i^t$ over individual labels. For each paid/target pair, weigh it by the certified per-occurrence probability pi. Define + + Ψ=∑ pi r ((k/r)^c−1)/c. + +The contribution to the continuous terminal count, measured in ordinary elementary axes, is pi V r ∫ from L to Lk/r of x^(−t) dx. The contribution to the continuous external input size, also in ordinary axes, is the same integral from U to Uk/r. Since U/L>max k/r, neither interval is cut by the opposite edge of the scale band. The two integrated totals are exactly V L^c Ψ and V U^c Ψ. In the external integral the virtual size k y equals r x where y=xr/k. This proves the cancellation with the actual linear sizes used by the periodic source. No change to a true target or paid leaf is involved. [LinearBoundary.lean](lean/LinearBoundary.lean) kernel-checks this change of variables for the real interval integrals and an arbitrary finite edge measure. + +For both installed suppliers, kmax≤1,032, rmin>=1/2, t>.996, P/T>.99 and kmax^c<1.06. Thus Ψ>=2^{-c}P log(5/4)>0.19P. One internal rounded matched interval costs <10k residual axes per receiver. Because sum m[e]<=V/(tL^t)+2U and sum k<=kmax^c T, its normalized fringe, divided by V L^c Ψ, is <64/L plus the integer error. For each paid/target/bin there are at most two interior intersections and one exterior interval. Their downward enclosure and rounding loses fewer than two replicas each; the upward rounding in m costs fewer than two. Every physical or virtual size here is at most N. The total integer error in the linear mass is thus <2^46 N² per time for these two words (fewer than 2^20 paid and 2^17 productive labels). The absolute delay-end loss per birth time is at most (N^77/K) 2V Q M. These errors are each <2^-132 V at H≥1,024. They use the per-time values at a genuine integral source or terminal, so no P/T factor or hidden preservation of t-mass at conversion is needed. + +Set η=1−10/L and δ=2^-128. External discretization preserves at least η times every virtual linear size. Also U≥(1−δ)N/(1024A), and each periodic occurrence has q s'/N≤1+4/1024 and q/R≤1/N. + +Write s' for the physical size of an external occurrence. Give each external slot q=4 ceil(N/(4s')) rounds. The first (qs'-N)/4 coordinates are covered five times and the rest once by the ticket bijection in `axes`. Each visit selects distinct axes because q>=1024. A full q visits acts on each axis as the required order-four operator. Set R=N^2. Give each slot floor(R/q) independent arbitrary fields for complete cycles. Fill the remaining partial cycle with independent true zeros. Then qs'/N<=1+4/1024 and q/R≤1/N≤δ. If h is the resulting total field count including all K times, set B=N^92, which exceeds 4096h by the stock proof and run z=ceil(B/h) copies. This pays for every padded owner, with zh/B<=1+1/4096. A true external work record can reuse an arbitrary row only on later sequential rounds of its own complete cycle. A padding zero returns to zero after every partial action. + +Let F be total recursive singleton calls divided by B. The generating program has an independent integer price: from the K sum of all `m[e] * r[j] * (e-8)`, subtract, for each actual link to i,d, max(0,K-jD[e]) times its count times `k[i] * (d-8)`. Multiply by zR. The result is exactly the raw count before division by B. The independent chart run checks this equality against its physically issued leaves. The outward bound for $(256/255)F/N^t$ is + + (256/255)(4097/4096)(1028/1024)(1024 A L)^c + * (1+64/L+δ) / [(1−10/L)(1−δ)^3]. + +For binary A=134 call this bound f. Integer arithmetic gives ((47/20)f)^8<2048. The [weighted matrix receiver](RECEIVER.md) uses one direct child and at most 75/32 same-rank child volumes per complete low inventory. The ratio to the bought 47/20 is at most 375/376. Hence 376 pays the sum of the recursive volumes in each of the two moments, while the covered rate is c−11/(8H). For numerical A=1224 the same formula has f^256<2^39. Its bound includes the factor 256/255. The positive geometric sum is at most 256 and the safe rate is c−39/(256H). [Numerical certification](check_complete.py) · [Physical accounting](ORDINARY-CLOCK.md) + +The mandatory whole-slot numerical-to-ordinary crossing and historical high stock are proved in [the complete entrance calculation](ACTIVATION.md). diff --git a/research/retimed-native-multiplier/VERIFICATION.md b/research/retimed-native-multiplier/VERIFICATION.md new file mode 100644 index 0000000000..ff096a83f4 --- /dev/null +++ b/research/retimed-native-multiplier/VERIFICATION.md @@ -0,0 +1,47 @@ +# Evidence and limits + +The physical mode constructs the atlas once and shares it across the zero and nonzero checks. The original separate 80-second witness entry timed out while repeating preparation on the author’s machine. The combined mode exercises both witnesses. A hosted seven-profile installation reached the old 250-second command limit. The current manifest gives installation 350 seconds within the same 1,200-second total. All registered modes use Python 3.12, ordinary assertions, and the locally restored SHA-256-verified predecessors. No network is needed after checkout. [Source pins](SOURCES.json) · [Manifest](VERIFY.json) · [Runner](verify.py) + +| Check | Evidence | +| --- | --- | +| Cost and entrance | Read the actual 36-call word in two ways. Intersect the 112-bit directed price bounds with an independent rational implementation. Check the 24 and 54 grade cells, every old and new signed tariff, all 54 strict and four functional conditions, all seven entrance/stock receipts, the actual first mandatory slot placement at each installed numerical rank, the first finite shape and the full integer ceilings for S and C. | +| Actual installation | Generate 2,352 binary differences, 111 joint charts, the 2,971 Gaussian pairs and 104 original ports. Emit both ordered raw inventories and both rational couplings. Instrumented execution generated the first six fixed machines in a shared process in 88.630 seconds with a 560,939,008-byte peak RSS on the author’s machine. The original run returned 14,928,855 rational results. The complete seven-profile replay returned 14,932,186, with at most 262 bits per reduced numerator or denominator. It took 86.553 seconds with a 625,377,280-byte process peak on the same host. It created zero input-dependent calendars. This figure includes the monitor and shared caches. It is not a time measurement of native payload execution. | +| Physical role stacks | The source check inspects 78 bodies in 25 installed modules. Seven physical arenas used 20 heads per stage. Two dirty siblings reached 21 nested levels. The test checked all restored bytes, 10,752 historical bytes and 125,062 charged movements. The Gaussian allocator reused the 128-byte historical fence. [Role assignment and induction](STAGE-STORE.md) | +| Chronology | The width-4,096 test covers arbitrary independent input rows, 1,440 genuine slots, three padded groups, 2,958,336 actual singleton leaves, 75,168 raw calls, 88,768 retired independent zeros and 51,288 noncommuting chart checks. A separate test observes 50 genuine transfers between different parent birth times and paid ordinals. A nested 2,048-row epoch resumes the original parent on its correct iterator and restores both arrays. | +| Physical words | The binary test calls the physical interpreter at every one of the 104,904 true cuts. It runs 53,796 routes with 1,298,332 elementary steps in the constant-address data subspace, using an independent formal coefficient for every external owner. The numerical test issues all 564,144 true slots on two and sixteen columns. It verifies all 105,216 returned owners, 143,616 actual terminal writes, 13,440,384 selected axes and release of every slot. The separate unsigned and signed scalar calculations visit 323,573 graph edges, 25,146,238 basis products and 17,231,591 nontrivial predivisions. | +| Direct and quotient | The public receiver matches every dirty byte on a direct frame and all 16 rank-two low packets. Nine quotient fixtures cover 1,112,292 opaque records and 2,000 independent modular cases. Four direct noncommuting comparisons cover 64,800 further records. All rank-two and rank-three low classes were enumerated for every paired frame, with four independent rank-four probes. [Receiver proof and finite movement](RECEIVER.md) | +| Nonzero numerical word | Two distinct stabilizer-product states entered the actual two-scale supplier. The 2-column and 16-column copies returned exact states in dimensions 2^18 and 2^144. All remaining owners returned zero. The checker uses an exact tensor representation for these test inputs only. The production field has its full volume. [Executable nonzero witness](check_nonzero_eight.py) | +| Signed inputs and storage | Check 21,861 data windows, truncated and bounded reads, three contiguous rank-two shuttles on 78,732 arbitrary bytes, actual public sign calls, restored heads, short I/O pieces, inverses and cleanup. | +| Complete finite product | The normal entry and finite Fourier path both return $-741503\cdot466013=-345550037539$. On the fixed sides 3 and 5 with precision 136 the Fourier path made 157,248 H calls and 138 physical exchanges. Before carry its only nonzero coefficients were 11811, 10996, 4152, 868 and 77. The supplied powers and ordinary starts for the actual cofinal construction are too large to reproduce with full fields. | + +An additional full modulus-nine quotient check executed all 432 actual low/high configurations and checked 2,834,352 dirty output records against independent matrix inversion. It issued 40 recursive children and used 49,601,160 historical backing bytes. A separate public direct check entered an actual nested weighted child, mixed component sizes and checked surrounding input/output bytes and head positions. Run both longer controls with `python3.12 -IB research/retimed-native-multiplier/verify.py deep-receiver`. + +The seven-stage test builds eight physical recipes and checks its 70-bit stop at the two sides of the exact boundary. The numerical receiver rejects a deliberately short reserve at the real production rank and preserves its input. The signed product observes the actual H dispatcher forwarding (19000, 10^21) before the local H executes on 32 sites. [Separate evidence at the highest rate](RESOLUTION.md) + +The first outer shape the controller can return has $b=18508$, largest width 18,496, and grid precision 606,385,061. At that shape a direct Python list of the retained axis size exceeds the host list index limit before allocation. Local runs use the finite controller stop or a declared physical geometry for whole products. The all-size execution, space and cofinal correctness claims are mathematical statements in the tape model under the inherited premises. No timing comparison with another practical multiplier was feasible. + +## Kernel replay + +The package pins Lean 4.34.1 and mathlib `d13f23b723b8a846827a245b89c10fc7d3f11612`. The fixed-column projection/fringe and dilated mass, offered capacity, equal boundary mass, timed return and final padding were checked in [Retimed.lean](lean/Retimed.lean). [OrdinaryClock.lean](lean/OrdinaryClock.lean) checks the disjoint-volume sum, contraction and finite stage clock. [OuterTickets.lean](lean/OuterTickets.lean) checks active/stopped inequalities, cutoff and cofinal stripe/stack rules. [RetimedGrid.lean](lean/RetimedGrid.lean) checks the heterogeneous entrance bound and final root reserve. [FiveExchange.lean](lean/FiveExchange.lean) checks the ring reflection and direct conjugation. [LinearBoundary.lean](lean/LinearBoundary.lean) checks the common linear factor for the actual real interval integrals. [QuotientAverage.lean](lean/QuotientAverage.lean) checks the weighted packet sum and finite mixed tree. [MatrixMarginals.lean](lean/MatrixMarginals.lean), [TritMarginals.lean](lean/TritMarginals.lean) and [TransitiveTrits.lean](lean/TransitiveTrits.lean) establish the uniform full-group marginal counts over ZMod 3. [BoundedDirect.lean](lean/BoundedDirect.lean) checks the all-size early exponent, finite maximum and 376-fold geometric allowance. [SevenStage.lean](lean/SevenStage.lean) proves the six-stage obstruction, all seven literal bookings, and the product bound for the serial stage clock. [OuterStop.lean](lean/OuterStop.lean) proves the real-power absorption for the 70-bit stop and its integer ceiling. It also bounds the real comparison work by the root or child payload using the true prior descent condition. [CountedEpoch.lean](lean/CountedEpoch.lean) proves the old lower and upper admission guards and the cardinality bound for the labelled futures. The source loop to physical image connection is written and has a separate finite replay. [StageStore.lean](lean/StageStore.lean) bounds the historical address on any fixed role over all finite sequences of pushes, replacements and returns. All fifteen modules were built and passed a separate `leanchecker` replay. The combined axiom list is `propext`, `Classical.choice`, and `Quot.sound`. The proofs contain no added axioms or placeholders. + +~~~sh +cd research/retimed-native-multiplier/lean +lake build +lake env leanchecker -v Retimed +lake env leanchecker -v OrdinaryClock +lake env leanchecker -v OuterTickets +lake env leanchecker -v RetimedGrid +lake env leanchecker -v FiveExchange +lake env leanchecker -v LinearBoundary +lake env leanchecker -v QuotientAverage +lake env leanchecker -v TritMarginals +lake env leanchecker -v TransitiveTrits +lake env leanchecker -v MatrixMarginals +lake env leanchecker -v BoundedDirect +lake env leanchecker -v SevenStage +lake env leanchecker -v OuterStop +lake env leanchecker -v CountedEpoch +lake env leanchecker -v StageStore +~~~ + +The raw source interpretations, exact integral enclosures in the emitted schedule, absolute tape lowering, geometry/source bindings, all-input numerical execution and complete signed theorem remain outside Lean. The transfer proofs were challenged within the authoring team. Independent scientific acceptance remains open. diff --git a/research/retimed-native-multiplier/VERIFY.json b/research/retimed-native-multiplier/VERIFY.json new file mode 100644 index 0000000000..77455dd9d5 --- /dev/null +++ b/research/retimed-native-multiplier/VERIFY.json @@ -0,0 +1,86 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "cost" + ], + "timeout_seconds": 50, + "checks": "Certify both couplings, seven connected entrances, the six-stage obstruction, fixed-stop costs, retuning floors and absolute signed clocks." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "install" + ], + "timeout_seconds": 350, + "checks": "Generate all seven profiles. Verify actual receiver selection, stop forwarding, fixed tables and rational widths." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "schedule" + ], + "timeout_seconds": 30, + "checks": "Check arbitrary independent fields, cross-parent loans, incomplete periods and reentrant returns." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "physical" + ], + "timeout_seconds": 430, + "checks": "Use one generated atlas for the zero and independent nonzero two-scale words. Check every returned field, both dense-formula witnesses and the signed source precision." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "receiver" + ], + "timeout_seconds": 165, + "checks": "Check public direct and quotient weighted shuttles, noncommuting frames, high digits, mixed widths and actual low classes." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "slabs" + ], + "timeout_seconds": 25, + "checks": "Verify signed scans, physical stage roles, nested dirty returns, Gaussian historical fences and restoring ordinary shuttles." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "product" + ], + "timeout_seconds": 150, + "checks": "Return the exact signed product on the public and finite physical paths. Check every coefficient and restored owner." + } + ] +} diff --git a/research/retimed-native-multiplier/activation.py b/research/retimed-native-multiplier/activation.py new file mode 100644 index 0000000000..20525c7fa3 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/bootstrap.py b/research/retimed-native-multiplier/bootstrap.py new file mode 100644 index 0000000000..dd5374a70b --- /dev/null +++ b/research/retimed-native-multiplier/bootstrap.py @@ -0,0 +1,72 @@ +"""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") + + +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/retimed-native-multiplier/check_binary_word.py b/research/retimed-native-multiplier/check_binary_word.py new file mode 100644 index 0000000000..d4ed11898d --- /dev/null +++ b/research/retimed-native-multiplier/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 == 104904 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/retimed-native-multiplier/check_chronology.py b/research/retimed-native-multiplier/check_chronology.py new file mode 100644 index 0000000000..efcfd334e4 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/check_complete.py b/research/retimed-native-multiplier/check_complete.py new file mode 100644 index 0000000000..3c13191ead --- /dev/null +++ b/research/retimed-native-multiplier/check_complete.py @@ -0,0 +1,189 @@ +"""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, ceil + + 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, right = Q(band*1032,448), Q((band+2)*1032,448) + assert upper < left < right < rank and band > 32768 + # Throughout this interval x^(-1-t) >= 1/rank^2. The 1/624 share remains positive after flooring. + assert rank**6 * (right-left)/(624*rank**2) > 4 + size = 1032*(band-8) + period = 4*ceil(Q(rank,4*size)) + assert period >= 1024 and rank**2//period > 0 + tickets = tuple(islice(axes(rank,size,period,0),3)) + assert tickets[0] == 0 and tickets[1] > 1 + # The true rotated root starts with coordinate zero repeated over the columns. + # Its first three canonical slots equal these three slots at every tested rank. + 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) + # Iterated stage funding and Cauchy-Schwarz apply to all admitted stage counts. + 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 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()} + from equal_rate import comparisons + from resolution import compare_resolution + return {"resolution_comparison":compare_resolution(), "baseline":baseline(),"equal_rate":comparisons(),"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/retimed-native-multiplier/check_five.py b/research/retimed-native-multiplier/check_five.py new file mode 100644 index 0000000000..65ae271b04 --- /dev/null +++ b/research/retimed-native-multiplier/check_five.py @@ -0,0 +1,140 @@ +"""Exercise all true tape records and compare them with dense weighted projectors.""" + +from contextlib import contextmanager +from collections import Counter +from io import BytesIO +from itertools import product +from math import prod +from pathlib import Path +from random import Random +import argparse +import sys + + +def main(package): + sys.path.insert(0,str(package)) + from upstream import install + install() + from five_exchange import corner_exchanges, same_order_line + from same_order_body import SameOrderBody + from growing_binary import Weighted + from module_atoms import component_widths + from streaming_routes import cold_swap_tape + from check_module_atoms import payload,expected_packet + from ternary_leaf import select_pivot + + def weight(row,idx,mod=81): + return (1,2,4,5,7,8)[(3*row+idx)%6]%mod + + # The signed rectangular test calls the source's true stopped weighted body. + class LineCore(SameOrderBody,Weighted): + def __init__(self,n,layout): + super().__init__(n,layout,cold_swap_tape) + self.stock=self.owners + self.calls=0 + def weighted(self,*args,**kw): + self.calls+=1 + # In these cases f= 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/retimed-native-multiplier/check_positive_word.py b/research/retimed-native-multiplier/check_positive_word.py new file mode 100644 index 0000000000..8f2831a41a --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/check_precision.py b/research/retimed-native-multiplier/check_precision.py new file mode 100644 index 0000000000..62b024a025 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/check_reentry.py b/research/retimed-native-multiplier/check_reentry.py new file mode 100644 index 0000000000..7726e110b5 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/check_resolution_stop.py b/research/retimed-native-multiplier/check_resolution_stop.py new file mode 100644 index 0000000000..4f85f58b6c --- /dev/null +++ b/research/retimed-native-multiplier/check_resolution_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 RESOLUTION + +D = RESOLUTION.positive_stop_denominator +HM = RESOLUTION.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 = RESOLUTION + from compact_columns import Columns + from positive import power_le + from spool import Field + + recipes = bp.prepare_native(p) + assert len(recipes) == 8 and D == 10**21 and HM == 19000 + 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 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/retimed-native-multiplier/direct_exact.py b/research/retimed-native-multiplier/direct_exact.py new file mode 100644 index 0000000000..8d6ef215d4 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/direct_recursive.py b/research/retimed-native-multiplier/direct_recursive.py new file mode 100644 index 0000000000..75b2a00879 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/equal_rate.py b/research/retimed-native-multiplier/equal_rate.py new file mode 100644 index 0000000000..9beb707f6b --- /dev/null +++ b/research/retimed-native-multiplier/equal_rate.py @@ -0,0 +1,48 @@ +"""Compare concrete retuned predecessor machines at the exact consumer rate.""" + +from dataclasses import replace +from fractions import Fraction as Q + +from calibration import COMPLEX_C, COMPACT, FIXED_STOCK, HIGH_RATE, SMALL_GAP, prices +from outer_budget import qualify +from resources import requirements + +EXAMPLES = { + ".00389": (HIGH_RATE,(686359,10981738,175707798),1489590), + ".00389011528": (FIXED_STOCK,(3232696,51723128,827570043,13241120677,211857930826,3389726893208),1515617), + ".0038901152865907": (SMALL_GAP,(6634625402,106154006424,1698464102779, + 27175425644461,434806810311369,6956908964981897),0), +} + + +def comparisons(): + g = Q(1,10**17) + output = {} + for key, (word, heights, numerical) in EXAMPLES.items(): + k = Q(key) + mlo = int(10/(COMPLEX_C-k-5*g))+1 + assert not numerical or numerical == mlo + old_debit = prices(word)[0] + last = Q() + for h in heights: + limit = min(word.eta,(249*(word.bit_c-Q(old_debit,h))+last)/250) + last = Q(int(limit*10**18)-1,10**18) + source = replace(word,rank_logs=heights,complex_log=mlo, + ordinary=last,kappa=k,positive_stop_denominator=10**17) + row = requirements(source) + qualify(k,g,last,COMPLEX_C-Q(10,mlo)) + floors = [] + for prior in (COMPACT,HIGH_RATE,FIXED_STOCK,SMALL_GAP): + loss = prices(prior)[0] + for count in range(1,7): + headroom = prior.bit_c-k-4*g-prior.bit_c*Q(1,250)**count + if headroom <= 0: + continue + geom = sum(Q(1,16)**j for j in range(count)) + floors.append(1+int(Q(249,250)*loss*geom**2/headroom)+mlo) + log_b = 40+16384*sum(heights) + output[key] = {"old_word_power":source.power,"feasible_H":list(heights), + "feasible_H_M":mlo,"feasible_A":row["log2_sufficient_public_precision"], + "old_A_lower_in_stated_tariffs":min(floors), + "feasible_log2_C_le":1+max(2**27,1436+100*mlo+log_b+1)} + return output diff --git a/research/retimed-native-multiplier/fiscal_scans.py b/research/retimed-native-multiplier/fiscal_scans.py new file mode 100644 index 0000000000..760c1dfbd2 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/five_exchange.py b/research/retimed-native-multiplier/five_exchange.py new file mode 100644 index 0000000000..dbbba0ba77 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/installations.py b/research/retimed-native-multiplier/installations.py new file mode 100644 index 0000000000..4feaf4ce77 --- /dev/null +++ b/research/retimed-native-multiplier/installations.py @@ -0,0 +1,37 @@ +"""Fixed, complete installations of the retimed binary and numerical suppliers.""" + +from dataclasses import dataclass +from fractions import Fraction as Q + +BINARY_C = Q(4484997569314581, 2**60) +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) +BALANCED = Profile((50900, 804000, 12800000), 19000, Q(39,10000), Q(".00389"), 10**14) +NEAR = Profile((3550000, 56200000, 888000000, 14100000000, 222000000000), + 19000, Q(39,10000), Q(".00389011528"), 10**17) +MATCHED = Profile((401000000, 6340000000, 101000000000, 1590000000000, + 25100000000000, 396000000000000), + 19000, Q(39,10000), Q(".0038901152865907"), 10**17) +RESOLUTION = Profile((5_698_204_041, 91_171_264_649, 1_458_740_234_375, + 23_339_843_750_000, 373_437_500_000_000, + 5_975_000_000_000_000, 95_600_000_000_000_000), + 19_000, Q(39,10000), Q(".003890115286594445"), 10**21) +PROFILES = {"selected-price": SELECTED_PRICE, "small": SMALL, "compact": COMPACT, + "balanced": BALANCED, "near": NEAR, "matched": MATCHED, "resolution": RESOLUTION} diff --git a/research/retimed-native-multiplier/lean/BoundedDirect.lean b/research/retimed-native-multiplier/lean/BoundedDirect.lean new file mode 100644 index 0000000000..2bd7cb2126 --- /dev/null +++ b/research/retimed-native-multiplier/lean/BoundedDirect.lean @@ -0,0 +1,49 @@ +import Mathlib.Tactic + +namespace BoundedDirect + +def privateLog (s : ℕ) : ℕ := s + 1024*(128*s^2+s+88) +def inputFloor (s : ℕ) : ℕ := ((2^(s-1) - 2)/6)-1 + +/-- Exhaust the actual small-precision range with kernel-reduced integer arithmetic. -/ +theorem prefixSmall (s : Fin 32) : privateLog s ≤ 84484466 + inputFloor s := by + fin_cases s <;> norm_num [privateLog, inputFloor] + +theorem attained : privateLog 27 - inputFloor 27 = 84484466 := by + norm_num [privateLog, inputFloor] + +/-- The earlier quadratic private bound fits the input from s = 32 on. -/ +theorem polynomialGrowth (s : ℕ) (hs : 32 ≤ s) : + privateLog (s+1) ≤ 2*privateLog s := by + unfold privateLog + nlinarith [Nat.mul_le_mul hs hs] + +theorem tailPays (j : ℕ) : privateLog (j+32) < 2^(j+28) := by + induction j with + | zero => norm_num [privateLog] + | succ j ih => + have h := polynomialGrowth (j+32) (by omega) + have need := Nat.mul_lt_mul_of_pos_left ih (by decide : 0 < 2) + calc + privateLog (j+1+32) = privateLog ((j+32)+1) := by congr 1 + _ ≤ 2*privateLog (j+32) := h + _ < 2*2^(j+28) := need + _ = 2^(j+28)*2 := Nat.mul_comm _ _ + _ = 2^((j+28)+1) := (pow_succ _ _).symm + _ = 2^(j+1+28) := by congr 1 + +/-- This tariff covers the exact single-child direct route and every unequal quotient count. -/ +theorem twoModes (children : ℝ) (h : children ≤ 75/32 ∨ children = 1) : + children / (47/20) ≤ 375/376 := by + rcases h with h | h + · linarith + · rw [h]; norm_num + +theorem geometric : (1:ℝ) / (1 - 375/376) = 376 := by norm_num + +#print axioms prefixSmall +#print axioms tailPays +#print axioms twoModes +#print axioms geometric + +end BoundedDirect diff --git a/research/retimed-native-multiplier/lean/CountedEpoch.lean b/research/retimed-native-multiplier/lean/CountedEpoch.lean new file mode 100644 index 0000000000..2822f9890a --- /dev/null +++ b/research/retimed-native-multiplier/lean/CountedEpoch.lean @@ -0,0 +1,57 @@ +import Mathlib.Tactic + +set_option exponentiation.threshold 4096 + +namespace CountedEpoch + +def ratio : ℚ := (5/4 : ℚ)^430 +def ceiling (h : ℕ) : ℚ := (2:ℚ)^h / (4*134^430) + +theorem depthBound (k : ℕ) : + 4*(134:ℚ)^430 * ratio^k ≤ 2^(2+8*430+430*k) := by + have a := pow_le_pow_left₀ (by norm_num : (0:ℚ) ≤ 134) + (by norm_num : (134:ℚ) ≤ 2^8) 430 + have r := pow_le_pow_left₀ (by norm_num : (0:ℚ) ≤ 5/4) + (by norm_num : (5/4:ℚ) ≤ 2) (430*k) + calc + _ = 4*(134:ℚ)^430 * (5/4 : ℚ)^(430*k) := by rw [pow_mul]; rfl + _ ≤ 4*((2:ℚ)^8)^430 * 2^(430*k) := by gcongr + _ = (2:ℚ)^(2+8*430+430*k) := by rw [pow_add, pow_add, pow_mul (2:ℚ) 8 430]; rfl + +/-- `tail+1` is the first level above the upper band. Its preceding all-minimum + suffix is active, and each of its ordered labelled words gives a separate unit. -/ +theorem firstLayer (h tail : ℕ) (hh : 512*430 ≤ h) + (prev : ratio^tail ≤ ceiling h) (cross : ceiling h < ratio^(tail+1)) : + (2:ℚ)^70 < ratio^tail ∧ ratio^tail ≤ ceiling h ∧ ceiling h < ratio^tail*ratio ∧ + (2:ℕ)^(8*h-30976) < Fintype.card (Fin tail → Fin 430 → Fin 444) := by + have pos : (0:ℚ) < 4*134^430 := by positivity + have step : 0 < ratio := by unfold ratio; positivity + have square : ceiling h < ratio^tail*ratio := by simpa [pow_succ] using cross + have launch : (2:ℚ)^70 * ratio < ceiling h := by + apply (lt_div_iff₀ pos).2 + calc + _ = (2:ℚ)^70 * (4*134^430 * ratio^1) := by rw [pow_one]; ring + _ ≤ (2:ℚ)^70 * 2^(2+8*430+430*1) := by + exact mul_le_mul_of_nonneg_left (depthBound 1) (by positivity) + _ = (2:ℚ)^(70+(2+8*430+430*1)) := (pow_add _ _ _).symm + _ < 2^h := pow_lt_pow_right₀ (by norm_num) (by omega) + have hstep : (2:ℚ)^70 < ratio^tail := by + by_contra! bad + exact (not_lt_of_ge (mul_le_mul_of_nonneg_right bad step.le)) (launch.trans square) + have exponent : h < 2+8*430+430*(tail+1) := by + apply (pow_lt_pow_iff_right₀ (a := (2:ℚ)) (by norm_num)).1 + calc + _ < ratio^(tail+1) * (4*134^430) := (div_lt_iff₀ pos).1 cross + _ = 4*134^430 * ratio^(tail+1) := mul_comm _ _ + _ ≤ _ := depthBound (tail+1) + refine ⟨hstep, prev, square, ?_⟩ + calc + _ < (2:ℕ)^(8*(430*tail)) := Nat.pow_lt_pow_right (by decide) (by omega) + _ = (256:ℕ)^(430*tail) := by rw [pow_mul]; rfl + _ ≤ 444^(430*tail) := Nat.pow_le_pow_left (by decide) _ + _ = Fintype.card (Fin tail → Fin 430 → Fin 444) := by simp [pow_mul] + +#print axioms depthBound +#print axioms firstLayer + +end CountedEpoch diff --git a/research/retimed-native-multiplier/lean/FiveExchange.lean b/research/retimed-native-multiplier/lean/FiveExchange.lean new file mode 100644 index 0000000000..c49525ab8b --- /dev/null +++ b/research/retimed-native-multiplier/lean/FiveExchange.lean @@ -0,0 +1,103 @@ +import Mathlib.Tactic + +namespace FiveExchange + +variable {R : Type*} [CommRing R] + +/-- A lower shear sends a dual backwards and preserves its pairing with every vector. -/ +theorem shearPair (wSrc wDst xSrc xDst c : R) : + (wSrc - c*wDst)*xSrc + wDst*(xDst+c*xSrc) = wSrc*xSrc+wDst*xDst := by ring + +/-- The last coordinate after the two lower sweeps and the final corner shear. + The scalar y is the middle dual applied to all the middle coordinates. -/ +def endValue (ai bi zLast mid x y t : R) := + t+bi*(y-ai*x*mid)+ai*(bi-zLast)*x + +theorem endAdd (ai bi zLast mid x y t X Y T c : R) : + endValue ai bi zLast mid (x-c*X) (y-c*Y) (t-c*T) = + endValue ai bi zLast mid x y t - c*endValue ai bi zLast mid X Y T := by + unfold endValue + ring + +/-- The spent factors are only the indicated corner units. This applies over every + commutative ring, including ternary residue rings with zero divisors. -/ +theorem endOfVector {a ai bi : R} (ha : a*ai=1) (zLast mid : R) : + endValue ai bi zLast mid a mid zLast = bi := by + unfold endValue + rw [show ai*a=1 by simpa [mul_comm] using ha, one_mul, sub_self, mul_zero, + add_zero, show ai*(bi-zLast)*a=(a*ai)*(bi-zLast) by ring, ha] + ring + +theorem factoredDual {a ai b bi zLast mid w0 : R} (ha : a*ai=1) (hb : b*bi=1) + (charge : w0*a+mid+b*zLast=2) (x y t : R) : + w0*x+y+b*t = ai*x + b*endValue ai bi zLast mid x y t := by + have inv : ai*a = 1 := by simpa [mul_comm] using ha + have w : w0*x = ai*x*(2-mid-b*zLast) := by + rw [← charge, show w0*a+mid+b*zLast-mid-b*zLast=w0*a by ring, + show ai*x*(w0*a)=(ai*a)*(w0*x) by ring, inv, one_mul] + rw [w] + unfold endValue + linear_combination (-(ai*x*mid)+y+ai*x) * (-hb) + +/-- Running the lower sweeps on the reflected input gives the weighted outside swap + of the swept original input, and preserves each swept middle coordinate. + y is the original middle dual evaluated on the middle vector, Y is any original + middle coordinate, and Z is the corresponding coordinate of the primal factor. -/ +theorem loweredReflection {a ai b bi zLast mid w0 : R} (ha : a*ai=1) (hb : b*bi=1) + (charge : w0*a+mid+b*zLast=2) (x y t Y Z : R) : + let d := w0*x+y+b*t + let out := endValue ai bi zLast mid x y t + x-d*a = (-a*b)*out ∧ + (Y-d*Z)-ai*(x-d*a)*Z = Y-ai*x*Z ∧ + endValue ai bi zLast mid (x-d*a) (y-d*mid) (t-d*zLast) = (-ai*bi)*x := by + dsimp only + have w := factoredDual ha hb charge x y t + have normal := endOfVector (bi:=bi) ha zLast mid + constructor + · rw [w] + linear_combination (-x)*ha + constructor + · linear_combination (w0*x+y+b*t)*Z*ha + · rw [endAdd,normal,w] + linear_combination (-endValue ai bi zLast mid x y t)*hb + +theorem centralUnits {a ai b bi : R} (ha : a*ai=1) (hb:b*bi=1) : + (-a*b)*(-ai*bi)=1 := by + calc + _ = (a*ai)*(b*bi) := by ring + _ = 1 := by rw [ha,hb,mul_one] + +/-- A true weighted interchange is the diagonal conjugate of the bare one. + This controls the number of inherited row weights per recursive label. -/ +theorem diagonalPair {a ai : R} (ha : ai*a=1) (x y : R) : + (a*y, ai*(a*x)) = (a*y, x) := by + rw [← mul_assoc, ha, one_mul] + +/-- The physical before and after change of the two banks realizes the + full placed projector, for any ring-linear invertible basis and bank weight. + Taking p to project onto one coordinate gives the single direct child. -/ +theorem directCoordinate {V : Type*} [AddCommGroup V] [Module R V] + (basis weight : V ≃ₗ[R] V) (p : V →ₗ[R] V) (h t : V) : + let movedH := weight (basis.symm (weight.symm h)) + let movedT := basis.symm t + let q := p (movedT - weight.symm movedH) + let wanted := basis (p (basis.symm (t - weight.symm h))) + (weight (basis (weight.symm (movedH+weight q))), basis (movedT-q)) = + (h+weight wanted, t-wanted) := by + simp + +/-- A full low has one, three, or five children. Singletons that miss one + outside coordinate add no more than the two specified exceptional sets. -/ +theorem weightedChartSum {x one three five total : ℚ} (sizes : one+three+five=total) + (both : one=4*x) (all : total=9*x-1) (exceptions : five≤x-1+4) : + one+3*three+5*five ≤ 21*x+3 := by linarith + +#print axioms diagonalPair +#print axioms directCoordinate +#print axioms weightedChartSum + +#print axioms loweredReflection +#print axioms centralUnits +#print axioms shearPair + +end FiveExchange diff --git a/research/retimed-native-multiplier/lean/LinearBoundary.lean b/research/retimed-native-multiplier/lean/LinearBoundary.lean new file mode 100644 index 0000000000..a7a7b4ba93 --- /dev/null +++ b/research/retimed-native-multiplier/lean/LinearBoundary.lean @@ -0,0 +1,67 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic +import Mathlib.Tactic.Ring + +namespace LinearBoundary + +open scoped BigOperators +open MeasureTheory Set + +noncomputable def edge (x r k c : ℝ) := r*((x*(k/r))^c-x^c)/c +noncomputable def slope (r k c : ℝ) := r*((k/r)^c-1)/c + +theorem factor_edge {x r k c : ℝ} (hx : 0 ≤ x) (hr : 0 < r) (hk : 0 ≤ k) : + edge x r k c = x^c * slope r k c := by + unfold edge slope + rw [Real.mul_rpow hx (div_nonneg hk hr.le)] + ring + +theorem same_moment {ι : Type*} (s : Finset ι) (p r k : ι → ℝ) {a b c : ℝ} + (ha : 0 ≤ a) (hb : 0 ≤ b) + (hr : ∀ i ∈ s, 0 < r i) (hk : ∀ i ∈ s, 0 ≤ k i) : + b^c*(∑ i ∈ s, p i*edge a (r i) (k i) c) = + a^c*(∑ i ∈ s, p i*edge b (r i) (k i) c) := by + rw [Finset.mul_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + rw [factor_edge ha (hr i hi) (hk i hi), factor_edge hb (hr i hi) (hk i hi)] + ring + +/-- The ordinary axis-size integral at either boundary is a dilation of one fixed integral. -/ +theorem sized_integral {x r q c : ℝ} (hx : 0 < x) (hq : 1 ≤ q) : + (∫ u in x..x*q, r * u^(c-1)) = + x^c * (∫ u in (1:ℝ)..q, r * u^(c-1)) := by + have change := intervalIntegral.smul_integral_comp_mul_left + (a := (1:ℝ)) (b := q) (fun u : ℝ => r * u^(c-1)) x + simp only [smul_eq_mul, mul_one] at change + rw [← change] + have equiv : (∫ u in (1:ℝ)..q, r * (x*u)^(c-1)) = + x^(c-1) * (∫ u in (1:ℝ)..q, r * u^(c-1)) := by + rw [← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro u hu + rw [Set.uIcc_of_le hq] at hu + change r * (x*u)^(c-1) = x^(c-1) * (r * u^(c-1)) + rw [Real.mul_rpow hx.le (le_trans zero_le_one hu.1)] + ring + rw [equiv, Real.rpow_sub_one hx.ne'] + field_simp + +/-- Both finite measures use precisely the same linear size moment. -/ +theorem actual_boundaries {ι : Type*} (s : Finset ι) (weight r ratio : ι → ℝ) + {L U c : ℝ} (hL : 0 (T : V n → V n)) (by + intro A B eq + exact LinearEquiv.ext (congrFun eq)) + +def placed {n : ℕ} (x : NZ n) (T : Aut n) : NZ n := + ⟨T x.val, fun hz => x.prop (T.injective (hz.trans T.map_zero.symm))⟩ + +def targetFibers {n : ℕ} (x y z : NZ n) (T : Aut n) (hy : T y.val = z.val) : + {A : Aut n // placed x A = y} ≃ {A : Aut n // placed x A = z} where + toFun A := ⟨A.val.trans T, by + apply Subtype.ext + change T (A.val x.val) = z.val + exact (congrArg T (congrArg Subtype.val A.prop)).trans hy⟩ + invFun A := ⟨A.val.trans T.symm, by + apply Subtype.ext + change T.symm (A.val x.val) = y.val + apply T.injective + rw [T.apply_symm_apply] + exact (congrArg Subtype.val A.prop).trans hy.symm⟩ + left_inv A := by + apply Subtype.ext + apply LinearEquiv.ext + intro v + exact T.symm_apply_apply _ + right_inv A := by + apply Subtype.ext + apply LinearEquiv.ext + intro v + exact T.apply_symm_apply _ + +/-- A fixed native nonzero factor has the exact uniform marginal over all invertible matrices. -/ +theorem marginal {n : ℕ} (x : NZ (n+1)) (p : NZ (n+1) → Prop) [DecidablePred p] : + Fintype.card {T : Aut (n+1) // p (placed x T)} * Fintype.card (NZ (n+1)) = + Fintype.card (Aut (n+1)) * Fintype.card {y : NZ (n+1) // p y} := by + classical + let k := Fintype.card {T : Aut (n+1) // placed x T = x} + have hf (y : NZ (n+1)) : Fintype.card {T : Aut (n+1) // placed x T = y} = k := by + obtain ⟨T,hT⟩ := transitiveNonzero y.val x.val y.prop x.prop + exact Fintype.card_congr (targetFibers x y x T hT) + have all := uniformCount (placed x) (fun _ => True) k hf + have size : Fintype.card (Aut (n+1)) = Fintype.card (NZ (n+1))*k := by + simpa only [Fintype.card_subtype_true] using all + rw [uniformCount (placed x) p k hf, size] + ring + +/-- Remove the extra nonzero witness when membership already implies it. -/ +def flatten {n : ℕ} (p : V n → Prop) (nz : ∀ v, p v → v ≠ 0) : + {y : NZ n // p y.val} ≃ {y : V n // p y} where + toFun y := ⟨y.val.val, y.prop⟩ + invFun y := ⟨⟨y.val, nz y.val y.prop⟩, y.prop⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem firstMarginal {n : ℕ} (x : NZ (n+1)) : + Fintype.card {T : Aut (n+1) // T x.val 0 ≠ 0} * (3^(n+1)-1) = + Fintype.card (Aut (n+1)) * (2*3^n) := by + let p (y : NZ (n+1)) := y.val 0 ≠ 0 + have h := marginal x p + have nz : ∀ v : V (n+1), v 0 ≠ 0 → v ≠ 0 := + fun _ hv hz => hv (congrFun hz 0) + have c := Fintype.card_congr (flatten (fun v : V (n+1) => v 0 ≠ 0) nz) + rw [nonzeroCount, c, firstCount] at h + exact h + +theorem lineMarginal {n : ℕ} (x : NZ (n+1)) : + Fintype.card {T : Aut (n+1) // T x.val 0 ≠ 0 ∧ Fin.tail (T x.val) = 0} * (3^(n+1)-1) = + Fintype.card (Aut (n+1)) * 2 := by + let p (y : NZ (n+1)) := y.val 0 ≠ 0 ∧ Fin.tail y.val = 0 + have h := marginal x p + have nz : ∀ v : V (n+1), (v 0 ≠ 0 ∧ Fin.tail v = 0) → v ≠ 0 := + fun _ hv hz => hv.1 (congrFun hz 0) + have c := Fintype.card_congr + (flatten (fun v : V (n+1) => v 0 ≠ 0 ∧ Fin.tail v = 0) nz) + rw [nonzeroCount, c, onlyCount] at h + exact h + +#print axioms marginal +#print axioms firstMarginal +#print axioms lineMarginal + +end TritMarginals diff --git a/research/retimed-native-multiplier/lean/OrdinaryClock.lean b/research/retimed-native-multiplier/lean/OrdinaryClock.lean new file mode 100644 index 0000000000..7a0fda9747 --- /dev/null +++ b/research/retimed-native-multiplier/lean/OrdinaryClock.lean @@ -0,0 +1,96 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring +import Mathlib.Tactic.FieldSimp + + +open scoped BigOperators + +namespace OrdinaryClock + +/-- A counted paid owner has disjoint equal low packets. Each pivot uses up to nine copies. -/ +theorem ninePhysical {P B Q : ℕ} (hB : 0 < B) (hQ : 0 < Q) (V factor : ℝ) + (hV : 0 ≤ V) (hf : 0 ≤ factor) (children : Fin P → Fin Q → ℕ) + (hnine : ∀ i j, children i j ≤ 9) : + (∑ i, ∑ j, (children i j : ℝ) * (V/((B:ℝ)*Q)) * factor) ≤ + 9*((P:ℝ)/B)*V*factor := by + have positiveB : (0:ℝ) < B := by exact_mod_cast hB + have positiveQ : (0:ℝ) < Q := by exact_mod_cast hQ + have hvol : 0 ≤ V/((B:ℝ)*Q) := by positivity + calc + _ ≤ ∑ _i : Fin P, ∑ _j : Fin Q, (9:ℝ)*(V/((B:ℝ)*Q))*factor := by + apply Finset.sum_le_sum + intro i _ + apply Finset.sum_le_sum + intro j _ + have h9 : (children i j : ℝ) ≤ 9 := by exact_mod_cast hnine i j + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right h9 hvol) hf + _ = _ := by simp; field_simp + +/-- Each physical child occurrence has its own index, area, and exponent cost. -/ +theorem paidTree {Node : Type*} (rank : Node → ℕ) (arity : Node → ℕ) + (child : Node → ℕ → Node) (cost rows power : Node → ℝ) (L σ : ℝ) (hL : 0 ≤ L) (hσ : σ < 1) + (descend : ∀ n i, i < arity n → rank (child n i) < rank n) + (localCost : ∀ n, cost n ≤ L * (rows n + power n) + + ∑ i ∈ Finset.range (arity n), cost (child n i)) + (rowMoment : ∀ n, (∑ i ∈ Finset.range (arity n), rows (child n i)) ≤ σ * rows n) + (powerMoment : ∀ n, (∑ i ∈ Finset.range (arity n), power (child n i)) ≤ σ * power n) + (root : Node) : cost root ≤ (L / (1-σ)) * (rows root + power root) := by + suffices H : ∀ k n, rank n = k → cost n ≤ (L / (1-σ)) * (rows n + power n) by + exact H _ _ rfl + intro k + induction k using Nat.strong_induction_on with + | h k ih => + intro n hn + have hp : 0 < 1-σ := sub_pos.mpr hσ + have hK : 0 ≤ L / (1-σ) := div_nonneg hL hp.le + have childBounds : (∑ i ∈ Finset.range (arity n), cost (child n i)) ≤ + ∑ i ∈ Finset.range (arity n), (L / (1-σ)) * (rows (child n i) + power (child n i)) := by + apply Finset.sum_le_sum + intro i hi + exact ih _ (hn ▸ descend n i (Finset.mem_range.mp hi)) _ rfl + rw [← Finset.mul_sum, Finset.sum_add_distrib] at childBounds + calc + cost n ≤ _ := localCost n + _ ≤ L * (rows n + power n) + (L / (1-σ)) * + (σ * rows n + σ * power n) := by + exact add_le_add_right (childBounds.trans (mul_le_mul_of_nonneg_left + (add_le_add (rowMoment n) (powerMoment n)) hK)) _ + _ = _ := by field_simp; ring + +/-- Fixed program factors multiply across the finite ordinary stages. -/ +theorem stageClock (J B : ℕ → ℝ) (A : ℝ) (hA : 1 ≤ A) (init : B 0 ≤ A) + (hJ : ∀ n, 2 ≤ J n) (step : ∀ n, B (n+1) ≤ J n ^ 14 * (1+B n)) (n : ℕ) : + B n ≤ A * ∏ i ∈ Finset.range n, J i ^ 15 := by + induction n with + | zero => simpa using init + | succ n ih => + have hJ₁ : ∀ i, 1 ≤ J i := fun i => le_trans (by norm_num) (hJ i) + have hb : ∀ k, 1 ≤ A * ∏ i ∈ Finset.range k, J i ^ 15 := by + intro k + induction k with + | zero => simpa using hA + | succ k hk => + rw [Finset.prod_range_succ, ← mul_assoc] + exact hk.trans (le_mul_of_one_le_right (le_trans zero_le_one hk) (one_le_pow₀ (hJ₁ k))) + have hs := hb n + have hK : 0 ≤ J n ^ 14 := pow_nonneg (le_trans (by norm_num) (hJ n)) _ + have hP : 0 ≤ A * ∏ i ∈ Finset.range n, J i ^ 15 := le_trans zero_le_one hs + rw [Finset.prod_range_succ] + calc + B (n+1) ≤ J n ^ 14 * (1+B n) := step n + _ ≤ J n ^ 14 * (2 * (A * ∏ i ∈ Finset.range n, J i ^ 15)) := by + apply mul_le_mul_of_nonneg_left _ hK + linarith + _ ≤ J n ^ 14 * (J n * (A * ∏ i ∈ Finset.range n, J i ^ 15)) := by + exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (hJ n) hP) hK + _ = _ := by ring + +#print axioms ninePhysical +#print axioms paidTree +#print axioms stageClock + +end OrdinaryClock diff --git a/research/retimed-native-multiplier/lean/OuterStop.lean b/research/retimed-native-multiplier/lean/OuterStop.lean new file mode 100644 index 0000000000..fc2cf156fb --- /dev/null +++ b/research/retimed-native-multiplier/lean/OuterStop.lean @@ -0,0 +1,94 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Algebra.Order.Floor.Ring +import Mathlib.Tactic + +namespace RetimedOuter + +private theorem le_two_rpow {t : ℝ} (ht : 0 ≤ t) : t ≤ (2 : ℝ) ^ t := by + have hfloor : t < (⌊t⌋₊ : ℝ) + 1 := Nat.lt_floor_add_one t + have hn : ⌊t⌋₊ + 1 ≤ 2 ^ ⌊t⌋₊ := ⌊t⌋₊.lt_two_pow_self + have hc : (⌊t⌋₊ : ℝ) + 1 ≤ (2 : ℝ) ^ ⌊t⌋₊ := by exact_mod_cast hn + have hp : (2 : ℝ) ^ (⌊t⌋₊ : ℝ) ≤ (2 : ℝ) ^ t := + Real.rpow_le_rpow_of_exponent_le (by norm_num) (Nat.floor_le ht) + rw [Real.rpow_natCast] at hp + exact le_trans hfloor.le (le_trans hc hp) + +theorem log_absorption {s y g : ℝ} (hs : 512 ≤ s) (hy : s - 2 ≤ y) (hg : 0 < g) : + (s + 1)^16 / (2 : ℝ)^(g*y) ≤ (17/g)^16 := by + have hy0 : 0 ≤ y := by linarith + have h0 : 0 ≤ g*y/16 := by positivity + have hp := le_two_rpow h0 + have hprod : (s+1) ≤ (17/g) * (2 : ℝ)^(g*y/16) := by + have hpre : s+1 ≤ (17/g) * (g*y/16) := by + rw [show 17/g*(g*y/16) = 17*y/16 by field_simp] + linarith + exact hpre.trans (mul_le_mul_of_nonneg_left hp (by positivity)) + have hp16 := pow_le_pow_left₀ (by linarith : (0 : ℝ) ≤ s+1) hprod 16 + rw [mul_pow] at hp16 + have hchain : ((2 : ℝ)^(g*y/16))^16 = (2 : ℝ)^(g*y) := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (by norm_num : (0 : ℝ) ≤ 2)] + norm_num + rw [hchain] at hp16 + exact (div_le_iff₀ (by positivity)).2 hp16 + +set_option exponentiation.threshold 2000 in +theorem stop21_headroom : (17 * 10^21 : ℕ)^16 < 2^1182 := by norm_num + +private theorem width_cube_step (k : ℕ) (hk : 4 ≤ k) : (k+1)^3 ≤ 2*k^3 := by + obtain ⟨u, rfl⟩ := Nat.exists_eq_add_of_le hk + ring_nf + omega + +set_option exponentiation.threshold 2000 in +theorem stopped_test_volume (e : ℕ) (he : 1024 ≤ e) : + 2^256 * e^3 ≤ 2^e := by + induction e, he using Nat.le_induction with + | base => norm_num + | succ k hk ih => + calc + 2^256 * (k+1)^3 ≤ 2^256 * (2*k^3) := + Nat.mul_le_mul_left _ (width_cube_step _ (by omega)) + _ = 2 * (2^256*k^3) := by ring + _ ≤ 2 * 2^k := Nat.mul_le_mul_left _ ih + _ = 2^(k+1) := by rw [pow_succ]; omega + +theorem stop21_physical_scan (e l : ℕ) (he : 1024 ≤ e) + (width : l + 2 ≤ (3 * 10^21 + 2) * e) : + 2^32 * (l+2)^3 ≤ 2^e := by + calc + 2^32 * (l+2)^3 ≤ 2^32 * ((3 * 10^21 + 2) * e)^3 := + Nat.mul_le_mul_left _ (Nat.pow_le_pow_left width 3) + _ = (2^32 * (3 * 10^21 + 2)^3) * e^3 := by ring + _ ≤ 2^256 * e^3 := Nat.mul_le_mul_right _ (by norm_num) + _ ≤ 2^e := stopped_test_volume e he + +theorem stop21_comparison_on_root (e : ℕ) (he : 1024 ≤ e) : + 2^32 * ((e+2).log2+3)^3 ≤ 2^e := by + apply stop21_physical_scan e ((e+2).log2+1) he + have h0 := Nat.log2_le_self (e+2) + omega + +theorem stop21_comparison_on_child (e M z h : ℕ) (he : 1024 ≤ e) + (hM : M ≤ e) (hz : z < M*(e+1)) (parent_ran : h < z^(10^21)) : + 2^32 * ((h+2).log2+3)^3 ≤ 2^e := by + have he' : e+1 ≤ 2^e := e.lt_two_pow_self + have hm' : M ≤ 2^e := le_trans (le_trans hM (Nat.le_succ _)) he' + have hz' : z ≤ 2^e * 2^e := hz.le.trans (Nat.mul_le_mul hm' he') + have top : h < 2^((e+e)*10^21) := by + have hh := Nat.pow_le_pow_left hz' (10^21) + rw [← pow_add, ← pow_mul] at hh + exact parent_ran.trans_le hh + have hp : 0 < (2:ℕ)^((e+e)*10^21) := by positivity + have cap : h+2 < 2^((e+e)*10^21 + 2) := by + rw [pow_add] + norm_num only [Nat.reducePow] at hp top ⊢ + omega + have hw := (Nat.log2_lt (show h+2 ≠ 0 by omega)).2 cap + apply stop21_physical_scan e ((h+2).log2+1) he + omega + +#print axioms log_absorption +#print axioms stop21_headroom +#print axioms stop21_comparison_on_root +#print axioms stop21_comparison_on_child +end RetimedOuter diff --git a/research/retimed-native-multiplier/lean/OuterTickets.lean b/research/retimed-native-multiplier/lean/OuterTickets.lean new file mode 100644 index 0000000000..c607529296 --- /dev/null +++ b/research/retimed-native-multiplier/lean/OuterTickets.lean @@ -0,0 +1,242 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic + +namespace OuterTickets + +/-- The paid volume at one active depth covers genuine ordinary shuttles. -/ +theorem active {u h f v a b : ℝ} (hu : 1 ≤ u) (hh : 0 ≤ h) (hf : 0 ≤ f) + (hshare : f ≤ h/u) (ha : a ≤ 1) (hab : a ≤ b) + (hv : v ≤ u^(1-b)) : + v * f^(1-a) ≤ h^(1-a) := by + have hp : 0 < u := by linarith + calc + v * f^(1-a) ≤ u^(1-a) * (h/u)^(1-a) := by + apply mul_le_mul + · exact hv.trans (Real.rpow_le_rpow_of_exponent_le hu (by linarith)) + · exact Real.rpow_le_rpow hf hshare (by linarith) + · exact Real.rpow_nonneg hf _ + · exact Real.rpow_nonneg hp.le _ + _ = h^(1-a) := by + rw [← Real.mul_rpow hp.le (div_nonneg hh hp.le)] + congr 1 + field_simp + +/-- The two actual stop conditions cover the unexpanded cost at every depth. -/ +theorem stop {u e h M a b g : ℝ} (hu : 0 ≤ u) (he : 0 < e) (hh : 1 ≤ h) + (hm : 0 ≤ M) (hsize : u*e ≤ h) (hcut : e ≤ M*h^g) + (hb : 0 ≤ b) (hb1 : b ≤ 1) (hab : a ≤ (1-g)*b) : + u^(1-b)*e ≤ M^b*h^(1-a) := by + have hp : 0 < h := by linarith + calc + u^(1-b)*e = (u*e)^(1-b)*e^b := by + rw [Real.mul_rpow hu he.le, mul_assoc, ← Real.rpow_add he] + ring_nf + simp + _ ≤ h^(1-b)*(M*h^g)^b := by + apply mul_le_mul + · exact Real.rpow_le_rpow (mul_nonneg hu he.le) hsize (by linarith) + · exact Real.rpow_le_rpow he.le hcut hb + · exact Real.rpow_nonneg he.le _ + · exact Real.rpow_nonneg hp.le _ + _ = M^b*h^(1-b+g*b) := by + rw [Real.mul_rpow hm (Real.rpow_nonneg hp.le _), + ← Real.rpow_mul hp.le, Real.rpow_add hp] + ring + _ ≤ M^b*h^(1-a) := by + apply mul_le_mul_of_nonneg_left _ (Real.rpow_nonneg hm _) + exact Real.rpow_le_rpow_of_exponent_le hh (by nlinarith) + +/-- These are the integer offspring and data inequalities at one real depth. -/ +theorem floorNext (h M j : ℕ) : (h/M^j)/M = h/M^(j+1) := by + rw [Nat.div_div_eq_div_mul, pow_succ] + +theorem floorArea (h M j : ℕ) : M^j * (h/M^j) ≤ h := by + exact Nat.mul_div_le h _ + +def privateCap (s : ℕ) := s + 1024*(128*s*s+s+88) + +/-- At all later sizes the entire private setup costs less than the input. -/ +theorem privateCapTail (s : ℕ) (hs : 32 ≤ s) : privateCap s < 2^(s-4) := by + obtain ⟨r, rfl⟩ := Nat.exists_eq_add_of_le hs + induction r with + | zero => decide + | succ r ih => + have step : privateCap (32+(r+1)) ≤ 2*privateCap (32+r) := by + unfold privateCap + nlinarith [Nat.zero_le (r*r)] + rw [show 32+r.succ-4 = (32+r-4)+1 by omega, pow_succ] + omega + +/-- An entire fixed native control scan, including 30 powers of J, fits the active axes. -/ +theorem fixedScan (H : ℕ) (h : 32 ≤ H) : 30720*H+120 < 2^(H-1) := by + obtain ⟨r, rfl⟩ := Nat.exists_eq_add_of_le h + induction r with + | zero => decide + | succ r ih => + rw [show 32+r.succ-1 = (32+r-1)+1 by omega, pow_succ] + omega + +theorem prefixControl (s : ℕ) (h : 64 ≤ s) : + 2*(16*(s+1)+120) < s*s := by + obtain ⟨r, rfl⟩ := Nat.exists_eq_add_of_le h + nlinarith [Nat.zero_le (r*r)] + +/-- Splitting the low quotient and moving the two residual factors preserves every cell. -/ +theorem oneOrdinaryBank (B Q K u o A N f r G F : ℕ) : + (u*B*Q*K)*o*A^(2*(N*f+r))*G*F = + B*(u*Q*K*o*A^(2*(N*f))*(G*A^r)*(F*A^r)) := by + rw [show 2*(N*f+r)=2*(N*f)+(r+r) by ring, pow_add, pow_add] + ring + +/-- A native stack records its true field sizes, including the suspended callers. -/ +inductive Spine (root : ℕ) : ℕ → ℕ → List ℕ → Prop + | initial : Spine root 0 root [] + | nested {m v z saved} : Spine root m v saved → z ≤ v → + Spine root m z (v::saved) + | entry {m v z saved} : Spine root m v saved → z ≤ 2*v → + Spine root (m+1) z (v::saved) + +private theorem afterEntry {m root v z : ℕ} (hv : v ≤ 2^m*root) (hz : z ≤ 2*v) : + z ≤ 2^(m+1)*root := by + calc + z ≤ 2*v := hz + _ ≤ 2*(2^m*root) := Nat.mul_le_mul_left _ hv + _ = 2^(m+1)*root := by rw [pow_succ]; ring + +/-- Only entries to a strictly earlier stage can increase an ancestor field. -/ +theorem spineCap {root m v saved} (p : Spine root m v saved) : + v ≤ 2^m*root ∧ ∀ x ∈ saved, x ≤ 2^m*root := by + induction p with + | initial => simp + | nested base hz ih => + refine ⟨hz.trans ih.1, ?_⟩ + intro x hx + rcases List.mem_cons.mp hx with rfl | h + · exact ih.1 + · exact ih.2 x h + | entry base hz ih => + refine ⟨afterEntry ih.1 hz, ?_⟩ + intro x hx + rcases List.mem_cons.mp hx with rfl | h + · exact afterEntry ih.1 (by omega) + · exact afterEntry (ih.2 x h) (by omega) + +private theorem boundedSum {ys : List ℕ} {c : ℕ} (h : ∀ x ∈ ys, x ≤ c) : + ys.sum ≤ ys.length*c := by + induction ys with + | nil => simp + | cons x ys ih => + have hx := h x (by simp) + have ht := ih (fun t ht => h t (by simp [ht])) + simp only [List.sum_cons, List.length_cons, Nat.succ_mul] + omega + +/-- All local high-water allowances add along a physical tape. -/ +theorem stackHigh (localFactor : ℕ) {root m v saved} (p : Spine root m v saved) : + (v::saved).sum*localFactor ≤ ((saved.length+1)*localFactor)*(2^m*root) := by + have h := spineCap p + have hs : (v::saved).sum ≤ (v::saved).length*(2^m*root) := by + apply boundedSum + intro x hx + rcases List.mem_cons.mp hx with rfl | hh + · exact h.1 + · exact h.2 x hh + calc + _ ≤ (v::saved).length*(2^m*root)*localFactor := Nat.mul_le_mul_right _ hs + _ = _ := by simp only [List.length_cons]; ring + +/-- The first port can vary; subsequent parent edges always take the zero port. -/ +def terminalKey {α : Type*} (zero : α) : ℕ → α × List α → α × List α + | 0, p => p + | j+1, (i, a) => (zero, List.replicate j zero ++ i::a) + +theorem readTerminal {α : Type*} (zero : α) (j : ℕ) : + Function.Injective (terminalKey zero j) := by + cases j with + | zero => exact fun _ _ h => h + | succ j => + rintro ⟨i,a⟩ ⟨k,b⟩ h + simpa [terminalKey] using h + +theorem recoverPort {α : Type*} (zero : α) {d j k : ℕ} {p q : α × List α} + (hj : j ≤ d) (hk : k ≤ d) (depth : d-j=d-k) + (label : terminalKey zero j p = terminalKey zero k q) : j=k ∧ p=q := by + have he : j=k := by omega + subst k + exact ⟨rfl, readTerminal zero j label⟩ + +theorem sourceCard {w u s : ℕ} (f : Fin w × Fin u → Fin s) + (hf : Function.Injective f) : w*u ≤ s := by + simpa using Fintype.card_le_of_injective f hf + +private theorem headCap (j : ℕ) (hj : 16 ≤ j) : 64*(j+1)+127 < 2^j := by + obtain ⟨t, rfl⟩ := Nat.exists_eq_add_of_le hj + induction t with + | zero => decide + | succ t ih => + rw [show 16+t.succ=(16+t)+1 by omega, pow_succ] + omega + +theorem headWidth (s : ℕ) (hs : 1024 ≤ s) : 4*((s+128).log2+1) ≤ s/16 := by + have cap := headCap (s/64) (by omega) + have loc : s+128 < 2^(s/64) := by omega + have bits := (Nat.log2_lt (show s+128≠0 by omega)).2 loc + omega + +/-- A single integer test covers the complete stripe margin at all later lengths. -/ +theorem stripeTail (s0 s localOverhead : ℕ) (h0 : 1024 ≤ s0) (hs : s0 ≤ s) + (base : 16*(localOverhead+1028) ≤ 7*s0) : + 1024+(localOverhead+4*((s+128).log2+1)) < s/2-2 := by + have width := headWidth s (by omega) + omega + +/-- For every cofinal stripe, a full earlier prefix has at most s/64 index bits + after the four address and reader copies. -/ +theorem sharpHeadWidth (s : ℕ) (hs : 4096 ≤ s) : 4*((s+128).log2+1) ≤ s/64 := by + have cap : ∀ j : ℕ, 16 ≤ j → 256*(j+1)+127 < 2^j := by + intro j h + obtain ⟨t, rfl⟩ := Nat.exists_eq_add_of_le h + induction t with + | zero => decide + | succ t ih => + rw [show 16+t.succ=(16+t)+1 by omega, pow_succ] + omega + have loc := cap (s/256) (by omega) + have bits := (Nat.log2_lt (show s+128≠0 by omega)).2 (show s+128<2^(s/256) by omega) + omega + +theorem tightStripe (s0 s localOverhead : ℕ) (h0 : 4096 ≤ s0) (hs : s0 ≤ s) + (base : 64*(localOverhead+1028) ≤ 31*s0) : + 1024+(localOverhead+4*((s+128).log2+1)) < s/2-2 := by + have width := sharpHeadWidth s (by omega) + omega + +theorem precisionTail (s : ℕ) (hs : 64 ≤ s) : 12000*(34*s+9) ≤ 2^(s-2) := by + obtain ⟨j, rfl⟩ := Nat.exists_eq_add_of_le hs + induction j with + | zero => decide + | succ j ih => + rw [show 64+j.succ-2=(64+j-2)+1 by omega, pow_succ] + omega + +#print axioms sharpHeadWidth +#print axioms tightStripe +#print axioms precisionTail + +#print axioms active +#print axioms stop +#print axioms floorNext +#print axioms floorArea +#print axioms privateCapTail +#print axioms fixedScan +#print axioms prefixControl +#print axioms oneOrdinaryBank +#print axioms spineCap +#print axioms stackHigh +#print axioms readTerminal +#print axioms recoverPort +#print axioms sourceCard +#print axioms headWidth +#print axioms stripeTail + +end OuterTickets diff --git a/research/retimed-native-multiplier/lean/QuotientAverage.lean b/research/retimed-native-multiplier/lean/QuotientAverage.lean new file mode 100644 index 0000000000..7b5cf67952 --- /dev/null +++ b/research/retimed-native-multiplier/lean/QuotientAverage.lean @@ -0,0 +1,71 @@ +import Mathlib.Tactic + +open scoped BigOperators + +namespace QuotientAverage + +/-- A card with no exceptional case spends one, three, three or five calls. -/ +theorem regularMix (p11 p10 p01 p00 : ℝ) (h : p11 + p10 + p01 + p00 = 1) : + p11 + 3*p10 + 3*p01 + 5*p00 = + 5 - 2 * (p11+p10) - 2 * (p11+p01) := by + linarith + +/-- K is the number of all vectors. Each exceptional line holds two nonzero vectors. -/ +theorem finiteBound (K : ℝ) (hK : 729 ≤ K) : + 5 - 4*(2*K / (3*(K-1))) + 8/(K-1) < 75/32 := by + have hpos : 0 < K-1 := by linarith + have eq : 5 - 4*(2*K / (3*(K-1))) + 8/(K-1) = + (7*(K-1) + 16)/(3*(K-1)) := by + field_simp + ring + rw [eq] + apply (div_lt_iff₀ (show 0 < 3*(K-1) by positivity)).mpr + linarith + +/-- Sum over the realized low classes with their actual common field volume. -/ +theorem projectedPhysical {P B Q : ℕ} (hB : 0 < B) (hQ : 0 < Q) (V factor : ℝ) + (hV : 0 ≤ V) (hf : 0 ≤ factor) (children : Fin P → Fin Q → ℕ) + (labels : ∀ i, (∑ j, (children i j : ℝ)) ≤ (75/32:ℝ)*Q) : + (∑ i, ∑ j, (children i j : ℝ) * (V/((B:ℝ)*Q)) * factor) ≤ + (75/32:ℝ) * (P/B) * V * factor := by + have positiveB : (0:ℝ) < B := by exact_mod_cast hB + have positiveQ : (0:ℝ) < Q := by exact_mod_cast hQ + have hvol : 0 ≤ V/((B:ℝ)*Q) := by positivity + calc + _ ≤ ∑ _i : Fin P, ((75/32:ℝ)*Q) * (V/((B:ℝ)*Q)) * factor := by + apply Finset.sum_le_sum + intro i _ + rw [← Finset.sum_mul, ← Finset.sum_mul] + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (labels i) hvol) hf + _ = _ := by simp; field_simp + +/-- A subtree either already has the stopped direct bill or exposes a funded quotient step. -/ +theorem mixedTree {Node : Type*} (rank arity : Node → ℕ) (child : Node → ℕ → Node) + (cost moment : Node → ℝ) (positive : ∀ n, 0 ≤ moment n) + (descend : ∀ n i, i < arity n → rank (child n i) < rank n) + (one : ∀ n, cost n ≤ 376 * moment n ∨ + (cost n ≤ moment n + ∑ i ∈ Finset.range (arity n), cost (child n i)) ∧ + (∑ i ∈ Finset.range (arity n), moment (child n i)) ≤ (375/376) * moment n) + (root : Node) : cost root ≤ 376 * moment root := by + suffices H : ∀ k n, rank n = k → cost n ≤ 376 * moment n by + exact H _ _ rfl + intro k + induction k using Nat.strong_induction_on with + | h k ih => + intro n hn + rcases one n with stop | ⟨work, mass⟩ + · exact stop + · have all : (∑ i ∈ Finset.range (arity n), cost (child n i)) ≤ + ∑ i ∈ Finset.range (arity n), 376 * moment (child n i) := by + apply Finset.sum_le_sum + intro i hi + exact ih _ (hn ▸ descend n i (Finset.mem_range.mp hi)) _ rfl + rw [← Finset.mul_sum] at all + linarith [positive n] + +#print axioms regularMix +#print axioms finiteBound +#print axioms projectedPhysical +#print axioms mixedTree + +end QuotientAverage diff --git a/research/retimed-native-multiplier/lean/Retimed.lean b/research/retimed-native-multiplier/lean/Retimed.lean new file mode 100644 index 0000000000..1b87004024 --- /dev/null +++ b/research/retimed-native-multiplier/lean/Retimed.lean @@ -0,0 +1,93 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring +import Mathlib.Tactic.FieldSimp + +namespace Retimed + +open scoped BigOperators + +noncomputable def columns (x : ℝ) : ℕ := 2 * ⌊x/2⌋₊ - 8 + +theorem column_interval {x : ℝ} (hx : 10 ≤ x) : + x - 10 < (columns x : ℝ) ∧ (columns x : ℝ) ≤ x - 8 := by + have h₁ := Nat.floor_le (show 0 ≤ x/2 by linarith) + have h₂ := Nat.lt_floor_add_one (x/2) + have hf : 4 ≤ ⌊x/2⌋₊ := Nat.le_floor (by linarith : (4 : ℝ) ≤ x/2) + have h : 8 ≤ 2 * ⌊x/2⌋₊ := by omega + simp only [columns, Nat.cast_sub h, Nat.cast_mul, Nat.cast_ofNat] + constructor <;> linarith + +theorem paid_fringe {x y r k : ℝ} (hx : 10 ≤ x) (hy : 10 ≤ y) (hr : 0 < r) + (hk : 5*r ≤ 4*k) (match_size : r*x=k*y) : + 0 ≤ r * (columns x : ℝ) - k * (columns y : ℝ) ∧ + r * (columns x : ℝ) - k * (columns y : ℝ) < 10*k := by + have hk' : 0 < k := by linarith + obtain ⟨xa, xb⟩ := column_interval hx + obtain ⟨ya, yb⟩ := column_interval hy + constructor + · nlinarith [mul_lt_mul_of_pos_left xa hr, mul_le_mul_of_nonneg_left yb hk'.le] + · nlinarith [mul_le_mul_of_nonneg_left xb hr.le, mul_lt_mul_of_pos_left ya hk'] + +noncomputable def mass (t x y : ℝ) : ℝ := (x^(-t)- y^(-t))/t + +theorem dilate_mass {t x y r k : ℝ} (hx : 0 < x) (hy : 0 < y) + (hr : 0 < r) (hk : 0 < k) : + mass t (x*(k/r)) (y*(k/r)) = (r^t/k^t) * mass t x y := by + have ha : 0 < k/r := div_pos hk hr + simp only [mass, Real.mul_rpow hx.le ha.le, Real.mul_rpow hy.le ha.le, + Real.div_rpow hk.le hr.le, Real.rpow_neg hk.le, Real.rpow_neg hr.le] + have hp := (Real.rpow_pos_of_pos hr t).ne' + have hq := (Real.rpow_pos_of_pos hk t).ne' + by_cases ht : t=0 + · simp [ht] + · field_simp + +theorem offered_capacity {ι : Type} (s : Finset ι) {t x y k : ℝ} (r p : ι → ℝ) + (hx : 0 < x) (hy : 0 < y) (hk : 0 < k) (hr : ∀ j ∈ s, 0 < r j) + (cap : ∑ j ∈ s, p j * r j ^ t ≤ k ^ t) (ht : 0 < t) (hxy : x ≤ y) : + ∑ j ∈ s, p j * mass t (x*(k/r j)) (y*(k/r j)) ≤ mass t x y := by + have h : ∑ j ∈ s, p j * mass t (x*(k/r j)) (y*(k/r j)) = + (∑ j ∈ s, p j * (r j)^t) * (mass t x y / k^t) := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro j hj + rw [dilate_mass hx hy (hr j hj) hk] + ring + rw [h] + have hp := Real.rpow_pos_of_pos hk t + have m : 0 ≤ mass t x y := div_nonneg (sub_nonneg.mpr + (Real.rpow_le_rpow_of_nonpos hx hxy (neg_nonpos.mpr ht.le))) ht.le + calc + _ ≤ k^t * (mass t x y / k^t) := mul_le_mul_of_nonneg_right cap (div_nonneg m hp.le) + _ = mass t x y := by field_simp + +theorem equal_end_mass {L U r k : ℝ} (hL : 0 < L) (hU : 0 < U) + (hr : 0 < r) (hk : 0 < k) : + Real.log (L*(k/r)) - Real.log L = Real.log (U*(k/r)) - Real.log U := by + have h := (div_pos hk hr).ne' + rw [Real.log_mul hL.ne' h, Real.log_mul hU.ne' h] + ring + +theorem timely_return (birth j child parent slots : ℕ) (h : slots * child ≤ parent) : + birth+j*parent+slots*child ≤ birth+(j+1)*parent := by + rw [Nat.add_mul] + simp + omega + +theorem complete_copy_tariff (B h : ℕ) (hB : 4096*h ≤ B) : + 4096 * (((B+h-1)/h)*h) ≤ 4097*B := by + have a := Nat.div_mul_le_self (B+h-1) h + omega + +#print axioms column_interval +#print axioms paid_fringe +#print axioms dilate_mass +#print axioms offered_capacity +#print axioms equal_end_mass +#print axioms timely_return +#print axioms complete_copy_tariff + +end Retimed diff --git a/research/retimed-native-multiplier/lean/RetimedGrid.lean b/research/retimed-native-multiplier/lean/RetimedGrid.lean new file mode 100644 index 0000000000..08592a8ba6 --- /dev/null +++ b/research/retimed-native-multiplier/lean/RetimedGrid.lean @@ -0,0 +1,63 @@ +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +namespace RetimedGrid + +open scoped BigOperators + +/-- A row has a causal budget, a total coefficient mass, and a dyadic height. -/ +inductive Row : ℕ → ℝ → ℕ → Prop + | entry {m : ℝ} (atMostOne : m ≤ 1) : Row 0 m 0 + | reserve {j m d} (prior : Row j m d) : Row (j+1) m d + | combine {j n : ℕ} {m w : Fin n → ℝ} {d : Fin n → ℕ} {out : ℕ} + (prior : ∀ i, Row j (m i) (d i)) + (sign : ∀ i, 0 ≤ w i) + (mass : ∑ i, w i ≤ (2 : ℝ)^436) + (height : out ≤ 148 + Finset.univ.sup d) : + Row (j+1) (∑ i, w i * m i) out + +/-- The number of causal parents is arbitrary. A joined row pays for one raw context. -/ +theorem joined {j : ℕ} {m : ℝ} {d : ℕ} (r : Row j m d) : + m ≤ ((2 : ℝ)^436)^j ∧ d ≤ 148*j := by + induction r with + | entry h => simpa using h + | @reserve j m d _ ih => + constructor + · calc + m ≤ ((2 : ℝ)^436)^j := ih.1 + _ = ((2 : ℝ)^436)^j * 1 := (mul_one _).symm + _ ≤ ((2 : ℝ)^436)^(j+1) := by + rw [pow_succ _ j] + exact mul_le_mul_of_nonneg_left (one_le_pow₀ (by norm_num)) (by positivity) + · omega + | @combine j n m w d out prior sign mass height ih => + constructor + · calc + ∑ i, w i * m i ≤ ∑ i, w i * ((2 : ℝ)^436)^j := by + exact Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left (ih i).1 (sign i) + _ = (∑ i, w i) * ((2 : ℝ)^436)^j := (Finset.sum_mul _ _ _).symm + _ ≤ (2 : ℝ)^436 * ((2 : ℝ)^436)^j := + mul_le_mul_of_nonneg_right mass (by positivity) + _ = ((2 : ℝ)^436)^(j+1) := by rw [pow_succ _ j, mul_comm] + · have bound : Finset.univ.sup d ≤ 148*j := Finset.sup_le fun i _ => (ih i).2 + omega + +/-- Root reserve for a descent with proved causal depth and actual remaining rank. -/ +theorem root_width {D M H ell K : ℕ} + (causal : K ≤ (4*H+1)*ell) + (rank : 872*(4*H+1) simpa [ideal] using start + | succ i ih => + rw [idealStep] + have prior := ih (by omega) + have next := step i (by omega) + linarith + +def c : ℚ := 4484997569314581 / 2^60 +def k : ℚ := 3890115286594445 / 10^18 +def g : ℚ := 1 / 10^21 + +/-- Six is impossible for the actual unpowered dyadic price even if all local + calls, physical transport, strict slack, and intermediate grid errors are free. -/ +theorem sixCannotReach (b : ℕ → ℚ) (start : b 0 ≤ 0) + (step : ∀ i<6, b (i+1) ≤ (249*c+b i)/250) : b 6 < k := by + have upper := allStageUpper c b 6 start step 6 (by omega) + exact upper.trans_lt (by norm_num [ideal,c,k]) + +theorem finalSeparation : k+5*g-ideal c 6 = + 3916755027601357/7036874417766400000000000000000000 := by + norm_num [ideal,c,k,g] + +def ranks : List ℕ := + [5698204041,91171264649,1458740234375,23339843750000,373437500000000, + 5975000000000000,95600000000000000] + +def ticks : List ℕ := + [3874554585109198542,3890053028767339082,3890115036624328130, + 3890115285535903366,3890115286586558872,3890115286594199570,3890115286594445005] + +def price (previous : ℚ) (h : ℕ) : ℚ := + min (39/10000) ((249*(c-11/(8*(h:ℚ)))+previous)/250) + +/-- Follow the written booking grid for every intermediate stage and the actual + complete caller's exact chosen ordinary rate on the final stage. -/ +def paidList : ℚ → List (ℕ × ℕ) → Bool + | _, [] => true + | previous, (h,b)::rest => + let boundary := price previous h + let rate : ℚ := (b:ℚ) / 10^21 + decide (h>0 ∧ previous simp + | succ i ih => + rw [Finset.prod_range_succ] + exact one_le_mul_of_one_le_of_one_le ih (one_le_pow₀ (le_trans (by norm_num : (1:ℚ)≤2) (hJ i))) + induction n with + | zero => simpa using initial + | succ n ih => + have hp := invariant n + have hn := hJ n + have factor : 0 ≤ K*(J n)^14 := by positivity + have move : 1+B n ≤ + J n*(A*K^n*∏ i ∈ Finset.range n, (J i)^15) := by + have double := mul_le_mul_of_nonneg_right hn (le_trans zero_le_one hp) + linarith + rw [Finset.prod_range_succ, pow_succ K] + calc + _ ≤ K*(J n)^14*(1+B n) := step n + _ ≤ K*(J n)^14*(J n*(A*K^n*∏ i ∈ Finset.range n, (J i)^15)) := + mul_le_mul_of_nonneg_left move factor + _ = _ := by ring + +#print axioms serialClock +#print axioms allStageUpper +#print axioms sixCannotReach +#print axioms finalSeparation +#print axioms actualSeven + +end SevenStage diff --git a/research/retimed-native-multiplier/lean/StageStore.lean b/research/retimed-native-multiplier/lean/StageStore.lean new file mode 100644 index 0000000000..8c425a0e75 --- /dev/null +++ b/research/retimed-native-multiplier/lean/StageStore.lean @@ -0,0 +1,68 @@ +import Mathlib.Tactic + +namespace StageStore + +/-- A fixed physical role has an ordered list of open suffix lengths and the + greatest position reached so far. Closing a sibling preserves that high. -/ +structure Tape where + slots : List ℕ + high : ℕ + +def reserved (D W : ℕ) (t : Tape) : Prop := + t.slots.length ≤ D ∧ (∀ v ∈ t.slots,v≤W) ∧ t.high ≤ D*W + +theorem intervalTotal (W : ℕ) (vs : List ℕ) (h : ∀ x ∈ vs, x≤W) : + vs.sum ≤ vs.length*W := by + induction vs with + | nil => simp + | cons x xs ih => + have head := h x (by simp) + have tail := ih (by intro y hy; exact h y (by simp [hy])) + simp only [List.sum_cons,List.length_cons,Nat.succ_mul] + omega + +/-- push allocates a delimited reusable suffix. replace accounts an opened + interval's new own extent. remove erases it and restores its parent end. -/ +inductive Step (D W : ℕ) : Tape → Tape → Prop + | push (vs : List ℕ) (h k : ℕ) (hd : vs.length < D) (hw : k≤W) : + Step D W ⟨vs,h⟩ ⟨k::vs,max h (k+vs.sum)⟩ + | replace (vs : List ℕ) (h old k : ℕ) (hw : k≤W) : + Step D W ⟨old::vs,h⟩ ⟨k::vs,max h (k+vs.sum)⟩ + | remove (vs : List ℕ) (h old : ℕ) : + Step D W ⟨old::vs,h⟩ ⟨vs,h⟩ + +theorem oneStep (D W : ℕ) {u v : Tape} (h : reserved D W u) (step : Step D W u v) : + reserved D W v := by + cases step with + | push vs hist k hd hw => + obtain ⟨_,bounds,past⟩ := h + have ht := intervalTotal W vs bounds + have hd' : (vs.length+1)*W≤D*W := Nat.mul_le_mul_right W hd + simp only [Nat.add_mul,one_mul] at hd' + refine ⟨by simpa using hd,by simpa [hw] using And.intro hw bounds,?_⟩ + change max hist (k+vs.sum) ≤ D*W + exact max_le past (by omega) + | replace vs hist old k hw => + obtain ⟨hd,bounds,past⟩ := h + have hb : ∀ x ∈ vs,x≤W := by intro x hx; exact bounds x (by simp [hx]) + have ht := intervalTotal W vs hb + change vs.length+1≤D at hd + have hd' := Nat.mul_le_mul_right W hd + simp only [Nat.add_mul,one_mul] at hd' + refine ⟨hd,by simpa using And.intro hw hb,?_⟩ + change max hist (k+vs.sum) ≤ D*W + exact max_le past (by omega) + | remove vs hist old => + obtain ⟨hd,bounds,past⟩ := h + change vs.length+1≤D at hd + exact ⟨by change vs.length≤D; omega,by intro x hx; exact bounds x (by simp [hx]),past⟩ + +theorem historical (D W : ℕ) {t : Tape} + (path : Relation.ReflTransGen (Step D W) ⟨[],0⟩ t) : t.high ≤ D*W := by + suffices reserved D W t from this.2.2 + induction path with + | refl => simp [reserved] + | tail _ step ih => exact oneStep D W ih step + +#print axioms historical +end StageStore diff --git a/research/retimed-native-multiplier/lean/TransitiveTrits.lean b/research/retimed-native-multiplier/lean/TransitiveTrits.lean new file mode 100644 index 0000000000..e8546bb6a5 --- /dev/null +++ b/research/retimed-native-multiplier/lean/TransitiveTrits.lean @@ -0,0 +1,74 @@ +import TritMarginals + +namespace TritMarginals + +def axis {n : ℕ} (i j : Fin n) : F := if j = i then 1 else 0 + +/-- Normalize a nonzero pivot and clear all other entries with one invertible linear map. -/ +def toAxis {n : ℕ} (i : Fin n) (a : V n) (h : a i ≠ 0) : V n ≃ₗ[F] V n where + toFun x j := x j + (axis i j - a j)*(x i / a i) + invFun x j := x j + (a j - axis i j)*x i + left_inv x := by + funext j + change x j + (axis i j - a j)*(x i/a i) + + (a j-axis i j)*(x i+(axis i i-a i)*(x i/a i)) = x j + rw [show axis i i = 1 by simp [axis]] + field_simp + ring + right_inv x := by + funext j + change x j + (a j - axis i j)*x i + + (axis i j-a j)*((x i + (a i-axis i i)*x i)/a i) = x j + rw [show axis i i = 1 by simp [axis]] + field_simp + ring + map_add' x y := by + funext j + change (x j + y j) + (axis i j - a j) * ((x i + y i) / a i) = + (x j + (axis i j - a j)*(x i/a i)) + (y j+(axis i j-a j)*(y i/a i)) + ring + map_smul' c x := by + funext j + change c*x j+(axis i j-a j)*((c*x i)/a i) = c*(x j+(axis i j-a j)*(x i/a i)) + ring + +theorem toAxis_self {n : ℕ} (i : Fin n) (a : V n) (h : a i ≠ 0) : + toAxis i a h a = axis i := by + funext j + change a j + (axis i j-a j)*(a i / a i) = axis i j + rw [div_self h] + ring + +/-- Reorder coordinates without changing the vector-space contract. -/ +def permute {n : ℕ} (s : Equiv.Perm (Fin n)) : V n ≃ₗ[F] V n where + toFun x j := x (s j) + invFun x j := x (s.symm j) + left_inv x := by funext j; exact congrArg x (s.apply_symm_apply j) + right_inv x := by funext j; exact congrArg x (s.symm_apply_apply j) + map_add' _ _ := rfl + map_smul' _ _ := rfl + +theorem normalize {n : ℕ} (x : V (n+1)) (hx : x ≠ 0) : + ∃ T : V (n+1) ≃ₗ[F] V (n+1), T x = axis 0 := by + have existsPivot : ∃ i, x i ≠ 0 := by + by_contra! none + exact hx (funext none) + obtain ⟨i, hi⟩ := existsPivot + let S := permute (Equiv.swap 0 i) + have hfirst : S x 0 ≠ 0 := by + change x (Equiv.swap 0 i 0) ≠ 0 + simpa using hi + exact ⟨S.trans (toAxis 0 (S x) hfirst), toAxis_self 0 (S x) hfirst⟩ + +/-- The group of invertible linear maps is transitive on the nonzero trit vectors. -/ +theorem transitiveNonzero {n : ℕ} (x y : V (n+1)) (hx : x ≠ 0) (hy : y ≠ 0) : + ∃ T : V (n+1) ≃ₗ[F] V (n+1), T x = y := by + obtain ⟨A,hA⟩ := normalize x hx + obtain ⟨B,hB⟩ := normalize y hy + refine ⟨A.trans B.symm, ?_⟩ + change B.symm (A x) = y + rw [hA, ← hB, B.symm_apply_apply] + +#print axioms transitiveNonzero + +end TritMarginals diff --git a/research/retimed-native-multiplier/lean/TritMarginals.lean b/research/retimed-native-multiplier/lean/TritMarginals.lean new file mode 100644 index 0000000000..1ab0985392 --- /dev/null +++ b/research/retimed-native-multiplier/lean/TritMarginals.lean @@ -0,0 +1,80 @@ +import Mathlib.Tactic +import Mathlib.Data.ZMod.Basic +import Mathlib.Data.Fin.Tuple.Basic + +namespace TritMarginals + +abbrev F := ZMod 3 +abbrev V (n : ℕ) := Fin n → F + +/-- The nonzero first coordinate and the free tail give the entire event. -/ +def firstEquiv (n : ℕ) : + ({a : F // a ≠ 0} × V n) ≃ {x : V (n+1) // x 0 ≠ 0} where + toFun p := ⟨Fin.cons p.1.val p.2, by simpa using p.1.prop⟩ + invFun p := (⟨p.1 0, p.2⟩, Fin.tail p.1) + left_inv p := by rcases p with ⟨⟨a, ha⟩, r⟩; simp + right_inv p := by apply Subtype.ext; exact Fin.cons_self_tail _ + +theorem nonzeroTrits : Fintype.card {a : F // a ≠ 0} = 2 := by + rw [Fintype.card_subtype_compl, Fintype.card_subtype_eq, ZMod.card] + +theorem firstCount (n : ℕ) : Fintype.card {x : V (n+1) // x 0 ≠ 0} = 2*3^n := by + rw [← Fintype.card_congr (firstEquiv n), Fintype.card_prod, nonzeroTrits] + simp [V, ZMod.card] + +theorem nonzeroCount (n : ℕ) : Fintype.card {x : V n // x ≠ 0} = 3^n-1 := by + rw [Fintype.card_subtype_compl, Fintype.card_subtype_eq] + simp [V, ZMod.card] + +/-- An exceptional line contains only its two nonzero scalar multiples. -/ +def onlyEquiv (n : ℕ) : + {a : F // a ≠ 0} ≃ {x : V (n+1) // x 0 ≠ 0 ∧ Fin.tail x = 0} where + toFun a := ⟨Fin.cons a.val (0 : V n), by simp [a.prop]⟩ + invFun p := ⟨p.1 0, p.2.1⟩ + left_inv _ := by apply Subtype.ext; simp + right_inv p := by + apply Subtype.ext + change Fin.cons (p.1 0) (0 : V n) = p.1 + calc + Fin.cons (p.1 0) (0 : V n) = Fin.cons (p.1 0) (Fin.tail p.1) := + congrArg (fun t : V n => (Fin.cons (p.1 0) t : V (n+1))) p.2.2.symm + _ = p.1 := Fin.cons_self_tail p.1 + +theorem onlyCount (n : ℕ) : + Fintype.card {x : V (n+1) // x 0 ≠ 0 ∧ Fin.tail x = 0} = 2 := by + rw [← Fintype.card_congr (onlyEquiv n), nonzeroTrits] + +/-- Left multiplication gives an explicit bijection between fibers of a transitive orbit. -/ +def actionFibers {G X : Type*} [Group G] [MulAction G X] (x y z : X) + (g : G) (hyz : g • y = z) : + {h : G // h • x = y} ≃ {h : G // h • x = z} where + toFun h := ⟨g * h.1, by rw [mul_smul, h.2, hyz]⟩ + invFun h := ⟨g⁻¹ * h.1, by rw [mul_smul, h.2, ← hyz, inv_smul_smul]⟩ + left_inv h := by apply Subtype.ext; exact inv_mul_cancel_left g _ + right_inv h := by apply Subtype.ext; exact mul_inv_cancel_left g _ + +/-- Equal subgroup or stabilizer fibers preserve exact event counts up to + their common integer cardinal. -/ +theorem uniformCount {X Y : Type*} [Fintype X] [Fintype Y] [DecidableEq Y] + (f : X → Y) (p : Y → Prop) [DecidablePred p] (k : ℕ) + (fiber : ∀ y, Fintype.card {x : X // f x = y} = k) : + Fintype.card {x : X // p (f x)} = Fintype.card {y : Y // p y} * k := by + let e : {x : X // p (f x)} ≃ ((y : {v : Y // p v}) × {x : X // f x = y.val}) := + { toFun := fun x => ⟨⟨f x.val, x.prop⟩, ⟨x.val, rfl⟩⟩ + invFun := fun ⟨y, x⟩ => ⟨x.val, Eq.mpr (congrArg p x.prop) y.prop⟩ + left_inv := fun _ => rfl + right_inv := by + rintro ⟨⟨y, py⟩, ⟨x, hx⟩⟩ + change f x = y at hx + subst y + rfl } + rw [Fintype.card_congr e, Fintype.card_sigma] + simp [fiber] + +#print axioms firstCount +#print axioms nonzeroCount +#print axioms onlyCount +#print axioms actionFibers +#print axioms uniformCount + +end TritMarginals diff --git a/research/retimed-native-multiplier/lean/lake-manifest.json b/research/retimed-native-multiplier/lean/lake-manifest.json new file mode 100644 index 0000000000..e48af08eb0 --- /dev/null +++ b/research/retimed-native-multiplier/lean/lake-manifest.json @@ -0,0 +1,117 @@ +{ + "version": "1.2.0", + "packagesDir": ".lake/packages", + "packages": [ + { + "url": "https://github.com/leanprover-community/plausible", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "118aa17ee84656b8bd727fef7c458ee8c833385c", + "name": "plausible", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/LeanSearchClient", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "ddf04cf3949fa556442341e87d47f9f6e6074707", + "name": "LeanSearchClient", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/import-graph", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "e928b72544873815af278d38681b31c0293588e3", + "name": "importGraph", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/ProofWidgets4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "106ff4fafc74ef4ac99d81dbf3ab399118f497a5", + "name": "proofwidgets", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.lean" + }, + { + "url": "https://github.com/leanprover-community/aesop", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "355695d523e41d0554926416cba2a2b3544fbbc9", + "name": "aesop", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/quote4", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "6a489d9af5d0c47e5b259e2e8bcdfc1811b5a259", + "name": "Qq", + "manifestFile": "lake-manifest.json", + "inputRev": "master", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/batteries", + "type": "git", + "subDir": null, + "scope": "leanprover-community", + "rev": "f2effa3d803fda822b1f97b806c47cf2adfbcbc2", + "name": "batteries", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover/lean4-cli", + "type": "git", + "subDir": null, + "scope": "leanprover", + "rev": "e92c9f15fdfacc8536f31cfb3b7ad26c3c8cd204", + "name": "Cli", + "manifestFile": "lake-manifest.json", + "inputRev": "v4.34.0", + "inherited": true, + "configFile": "lakefile.toml" + }, + { + "url": "https://github.com/leanprover-community/mathlib4.git", + "type": "git", + "subDir": null, + "scope": "", + "rev": "d13f23b723b8a846827a245b89c10fc7d3f11612", + "name": "mathlib", + "manifestFile": "lake-manifest.json", + "inputRev": "d13f23b723b8a846827a245b89c10fc7d3f11612", + "inherited": false, + "configFile": "lakefile.lean" + } + ], + "name": "RetimedNativeMultiplier", + "lakeDir": ".lake", + "fixedToolchain": true +} diff --git a/research/retimed-native-multiplier/lean/lakefile.toml b/research/retimed-native-multiplier/lean/lakefile.toml new file mode 100644 index 0000000000..92547f9ffa --- /dev/null +++ b/research/retimed-native-multiplier/lean/lakefile.toml @@ -0,0 +1,12 @@ +name = "RetimedNativeMultiplier" +version = "1.0.0" +defaultTargets = ["Construction"] + +[[require]] +name = "mathlib" +git = "https://github.com/leanprover-community/mathlib4.git" +rev = "d13f23b723b8a846827a245b89c10fc7d3f11612" + +[[lean_lib]] +name = "Construction" +roots = ["Retimed", "OrdinaryClock", "OuterTickets", "RetimedGrid", "FiveExchange", "QuotientAverage", "LinearBoundary", "TritMarginals", "TransitiveTrits", "MatrixMarginals", "BoundedDirect", "SevenStage", "OuterStop", "CountedEpoch", "StageStore"] diff --git a/research/retimed-native-multiplier/lean/lean-toolchain b/research/retimed-native-multiplier/lean/lean-toolchain new file mode 100644 index 0000000000..ba8ebf2dba --- /dev/null +++ b/research/retimed-native-multiplier/lean/lean-toolchain @@ -0,0 +1 @@ +leanprover/lean4:v4.34.1 diff --git a/research/retimed-native-multiplier/low_inventory_scan.py b/research/retimed-native-multiplier/low_inventory_scan.py new file mode 100644 index 0000000000..69c1791179 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/machine.patch b/research/retimed-native-multiplier/machine.patch new file mode 100644 index 0000000000..16b6205d1f --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/normal_five.py b/research/retimed-native-multiplier/normal_five.py new file mode 100644 index 0000000000..f1f494cfa1 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/ordinary_clock.py b/research/retimed-native-multiplier/ordinary_clock.py new file mode 100644 index 0000000000..87c72664af --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/outer_budget.py b/research/retimed-native-multiplier/outer_budget.py new file mode 100644 index 0000000000..35dd5cf836 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/outer_clock.py b/research/retimed-native-multiplier/outer_clock.py new file mode 100644 index 0000000000..3c4fa183a0 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/predecessor/LAST-TICK-RECEIPT.json b/research/retimed-native-multiplier/predecessor/LAST-TICK-RECEIPT.json new file mode 100644 index 0000000000..68e300af92 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/predecessor/OVERLAY.json b/research/retimed-native-multiplier/predecessor/OVERLAY.json new file mode 100644 index 0000000000..93fcd0e584 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/predecessor/SOURCES.json b/research/retimed-native-multiplier/predecessor/SOURCES.json new file mode 100644 index 0000000000..4afaeff69d --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/predecessor/predecessor-8030.tar.gz b/research/retimed-native-multiplier/predecessor/predecessor-8030.tar.gz new file mode 100644 index 0000000000..e00a6bfe83 Binary files /dev/null and b/research/retimed-native-multiplier/predecessor/predecessor-8030.tar.gz differ diff --git a/research/retimed-native-multiplier/raw_binary_stage.py b/research/retimed-native-multiplier/raw_binary_stage.py new file mode 100644 index 0000000000..444da9677a --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/receiver.patch b/research/retimed-native-multiplier/receiver.patch new file mode 100644 index 0000000000..4b7db79b29 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/resolution.py b/research/retimed-native-multiplier/resolution.py new file mode 100644 index 0000000000..a67dcbb52c --- /dev/null +++ b/research/retimed-native-multiplier/resolution.py @@ -0,0 +1,182 @@ +"""Reprice the source-bound six-stage comparator and test the seventh paid receiver.""" + +from fractions import Fraction as Q +from hashlib import sha256 +import json +from pathlib import Path + +from activation import full_entrance +from calibration import COMPLEX_C +from check_activation_space import receipt as powered_stock +from installations import BINARY_C, RESOLUTION +from outer_budget import margins, qualify +from ordinary_carrier import stage_for_width_log +from staged_carriers import entrance_logs + +HERE = Path(__file__).resolve().parent + + +def powered_refit(trial, debit, final_height, count, ratio=6): + """Use the old intermediate rounding and its actual stock and signed tests.""" + heights = tuple((final_height+ratio**j-1)//ratio**j for j in reversed(range(count))) + profile = RESOLUTION + gap = Q(1, profile.positive_stop_denominator) + ordinary = profile.ordinary + numerical = 1 + int(10 / (COMPLEX_C - ordinary)) + previous = Q() + for index, height in enumerate(heights): + limit = min(profile.eta, (249*(trial-Q(debit,height))+previous)/250) + rate = ordinary if index+1 == len(heights) else Q(int(10**18*limit)-1,10**18) + assert previous < rate < limit + previous = rate + qualify(profile.kappa, gap, ordinary, COMPLEX_C-Q(10,numerical)) + cuts = entrance_logs(heights) + assert all(cut+2 < h for cut,h in zip(cuts[:-1],heights[1:],strict=True)) + assert min(heights) >= 512*430 and numerical >= 512*128 + assert min(heights) >= 2+(134**430).bit_length()+(127**430).bit_length()+71 + stock = powered_stock(heights,numerical,cuts[-1],1024*max(heights)+(len(heights)+1).bit_length(), + 430,complex_power=128) + # The published 430-factor bridge requests direct coverage at each first entrance. + first_s = stock["initial_s"] + for i,h in enumerate(heights): + quotient_cut = (Q(2*h+64)/(1-profile.eta)).__ceil__() + assert (1-profile.eta)*quotient_cut >= 2*h+64 and quotient_cut < 3*h < 8*h + top = cuts[i+1] if i+1 < len(cuts) else first_s + floor = cuts[i-1] if i else 0 + assert top-floor <= 8*h + if i+1 < len(cuts): + parent = cuts[i+2] if i+2 < len(cuts) else first_s + assert parent+250 < 250*top and cuts[i]+1 < top + h = max(numerical,*heights) + levels = (13*h+4*430-1)//(4*430)+2 + local = 4*stock["raw_structural_nodes_log2_upper"]+8*h.bit_length()+512 + assert 19+2*stock["raw_structural_nodes_log2_upper"]+levels.bit_length()= 512*v and height-2-9*v > 70 + assert 134 < 2**8 and Q(15,12) < 2 and 444 > 2**8 + from band_compiler import make_planner + from epoch_tape import OPEN, Image, epoch + from itertools import product + + class Rule: + ambient = 8 + targets = (6,6,6) + paid = (2,3) + + plan = make_planner(Rule,2)(272) + first = plan.forest.layers[(1,)] + assert plan.forest.height == 4 and {u.future for u in first} == set(product(range(3),repeat=3)) + assert all(kind == "source" for u in first for kind,_ in u.ports) and (1,) in plan.forest.prefixes + records = tuple(epoch(Rule,plan)) + opens = sum(row[0] == OPEN for row in records) + image = Image(Rule,plan) + try: + assert tuple(image.rows()) == records and opens >= plan.copies*len(first) + assert (len(first),plan.copies,opens,image.records,image.size) == (27,17,1428,8568,66397) + finally: + image.stream.close() + return 8*(height-2-9*v) + + +def compare_resolution(): + spec = json.loads((HERE/"SOURCES.json").read_bytes())["six_stage_comparator"] + raw = (HERE/"predecessor"/spec["file"]).read_bytes() + assert sha256(raw).hexdigest() == spec["sha256"] + prior = json.loads(raw) + profile = RESOLUTION + k = profile.kappa + gap = Q(1,profile.positive_stop_denominator) + trial = Q(prior["trial"]) + assert Q(prior["kappa"]) == k and Q(prior["gap"]) == gap + assert prior["power"] == 430 and prior["bit_debit"] == 31 and prior["numeric_debit"] == 10 + from installations import GAUSSIAN_C + positive = GAUSSIAN_C-Q(39,256*profile.complex_log) + strict,functional,paid = margins(k,gap,profile.ordinary,positive) + scale = profile.positive_stop_denominator**2 + assert len(strict) == 54 and len(functional) == 4 + assert all((x*scale).denominator == 1 for x in (*strict,*functional)) + assert (paid*scale).denominator == 19 + assert max((x*19*scale).numerator.bit_length() for x in (*strict,*functional,paid)) <= 186 + # Removing all the earlier debits and keeping the original five grid roundings + # only increases the possible sixth limit. Use the outward raw endpoint. + previous = Q() + crossing_upper = Q(prior["raw_interval"][1]) + for _ in range(5): + previous = Q(int(10**18*(249*crossing_upper+previous)/250)-1,10**18) + upper = (249*crossing_upper+previous)/250 + assert upper == Q(prior["six_stage_upper_fraction"]) + # This weaker bound even allows the competitor to change its stop margin. + old_H_floor = 1 + int(Q(249*31,250)/(upper-k)) + assert 0 < old_H_floor <= prior["minimum_last_height_with_profile_debit"] + # At our own binary price, six costless, unrounded stages already miss k. + ceiling = BINARY_C*(1-Q(1,250)**6) + assert ceiling < k + cuts = entrance_logs(profile.rank_logs) + for index, cut in enumerate(cuts,1): + assert stage_for_width_log(cut-1,7,profile.rank_logs) == index-1 + assert stage_for_width_log(cut,7,profile.rank_logs) == index + assert stage_for_width_log(cut,index-1,profile.rank_logs) == index-1 + # Any funded retimed chain has at least seven stages. Apply Cauchy to its last seven + # widths and drop the cold term. This bound also grants all possible further stages. + root_lower = Q(63_245_553_203,10**12) + assert root_lower**2 < Q(1,250) + weight = sum(root_lower**j for j in range(7)) + all_counts = 1+int(Q(249,250)*Q(11,8)*weight**2/(BINARY_C-profile.ordinary)) + min_positive = 1+int(Q(39,256)/(GAUSSIAN_C-profile.ordinary)) + old = prior["complete_requirements"] + assert max(x.bit_length() for x in old["binary_entrance_logs"]) <= 81 + assert old["raw_structural_nodes_log2_upper"] == 12973 and prior["local_exponent"] == 53044 + assert 19 + 2*12973 + prior["G_plus_1_upper"].bit_length() < 53044 < prior["native_q"] + assert Q(9*16,15*32) == Q(3,10) + A = full_entrance(cuts[-1],profile.complex_log) + assert old["log2_sufficient_public_precision"] > 13_000_000*A + # Reprice common tape/access units. The larger stop uses the uniform 1,600 allowance. + old_E = 1 + max(84_500_000, 1600+100*old["complex_rank_log"]+40+16384*sum(old["binary_rank_logs"])+1) + exact_floors = [] + for count in (6,7): + limit = Q() + for _ in range(count-1): + limit = Q(int(10**18*(249*trial+limit)/250)-1,10**18) + final = (249*trial+limit)/250 + exact_floors.append(1+int(Q(249*31,250)/(final-profile.ordinary))) + # Five zero-debit stages miss the target. Cauchy--Schwarz over the last six + # positive deficits bounds the sum of widths of every funded longer chain. + assert trial*(1-Q(1,250)**5) < k + weight = sum(Q(1,16)**i for i in range(6)) + cost = Q(249*31,250)*weight**2 + six_floor = 1 + int(cost/(trial-profile.ordinary-trial/250**6)) + any_count_floor = 1 + int(cost/(trial-profile.ordinary)) + row_sum = sum(prior["complete_requirements"]["binary_rank_logs"]) + assert row_sum > six_floor >= any_count_floor > 21*A + return {"retimed_any_stage_count_A_floor":all_counts+min_positive, + "prior_head":spec["head"], "old_six_A_floor":six_floor, + "old_any_stage_count_A_floor":any_count_floor, "prior_binary_H":old["binary_rank_logs"], + "prior_numerical_H":old["complex_rank_log"], "prior_A":old["log2_sufficient_public_precision"], + "prior_log2_S_le":old["log2_all_fixed_setup_upper"], + "prior_installed_OPEN_log2_gt":expanded_open_floor(old["binary_rank_logs"][-1]), "prior_log2_C_le":old_E, + "old_powered_last_H_strict_integer_floor":old_H_floor, + "old_exact_trial_last_H_floors":exact_floors, + "old_minimum_sixth_height_witness":powered_refit(trial,31,exact_floors[0],6,ratio=3), + "old_powered_six_refit":powered_refit(trial,31,181_000_000_000_000_000_000,6), + "old_powered_seven_price_sensitivity":powered_refit(trial,31,1_980_000_000_000_000_000,7), + "retimed_zero_debit_six_stage_upper":str(ceiling), "retimed_six_stage_deficit":str(k-ceiling), + "stop_absorption_log2_le":((17*profile.positive_stop_denominator)**16-1).bit_length()} diff --git a/research/retimed-native-multiplier/retimed_supplier.py b/research/retimed-native-multiplier/retimed_supplier.py new file mode 100644 index 0000000000..388b2cf659 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/transport.py b/research/retimed-native-multiplier/transport.py new file mode 100644 index 0000000000..7006360e5b --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/true_high.py b/research/retimed-native-multiplier/true_high.py new file mode 100644 index 0000000000..33573b2847 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/unpowered_price.py b/research/retimed-native-multiplier/unpowered_price.py new file mode 100644 index 0000000000..8952084bc1 --- /dev/null +++ b/research/retimed-native-multiplier/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/retimed-native-multiplier/verify.py b/research/retimed-native-multiplier/verify.py new file mode 100644 index 0000000000..7e5b9c0f29 --- /dev/null +++ b/research/retimed-native-multiplier/verify.py @@ -0,0 +1,67 @@ +"""Restore the exact predecessor, install this construction and check its public path.""" + +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 RESOLUTION + 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 RESOLUTION + 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(RESOLUTION) + finally: + sys.setprofile(None) + assert observed == [(19000, (19000, 10**21), 32)] + assert info["product"] == "-345550037539" and info["shuttles"] == 138 + assert info["coefficients_prefix"] == [11811, 10996, 4152, 868, 77] + print(info) + else: + files = {"schedule": ["check_streamed", "check_chronology", "check_reentry"], + "physical": ["check_binary_word", "check_positive_word", "check_nonzero_eight", "check_precision"], + "install": ["check_installation", "check_resolution_stop"], + "witness": ["check_nonzero_eight"], + "deep-receiver": ["true_high", "direct_recursive"], + "receiver": ["normal_five", "direct_exact", "check_five", "low_inventory_scan"], + "slabs": ["check_scans", "check_stage_fences"]} + for name in files[mode]: + runpy.run_path(str(HERE / (name + ".py")), run_name="__main__") + print("PASS_RETIMED_MULTIPLIER", mode) + + +if __name__ == "__main__": + cli = ArgumentParser(description=__doc__) + cli.add_argument("mode", choices=("cost", "schedule", "install", "physical", "product", "slabs", "receiver", "witness", "deep-receiver")) + command = cli.parse_args().mode + if sys.version_info[:2] != (3, 12) or not __debug__: + raise RuntimeError("Use Python 3.12 with assertions enabled") + with TemporaryDirectory(prefix="retimed-multiplier-") as folder: + tree = Path(folder) / "machine" + tree.mkdir() + check(command, tree)