diff --git a/docs/ci-verification.md b/docs/ci-verification.md index 63ba3e9aa8..52b62d0481 100644 --- a/docs/ci-verification.md +++ b/docs/ci-verification.md @@ -1,8 +1,25 @@ # CI verification -## Current selected-family replay: #6030 +## Current selected-family replay: #7000 with #7001 The [selected record](../certificates/selected-result.json) binds conditional +κ = 0.00363005817 to the [application review](research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md), +[validation receipts](research/pr-intake-evidence/pr7000-application/VALIDATION.json), +and [explicit source closure](../certificates/frontier7000-source.json). +`make frontier7000-verify` follows that exact-source selected replay. The review +reuses eleven authenticated preceding executions and records seven fresh serial +application, scalar and complete native-catalogue executions. The earlier +monolithic timeout is retained separately and is not completed coverage. +Consult the receipts for exact commands, source heads and limits. + +The five inherited framework assumptions remain. No complete uniform word, +literal multiplier execution, independent human proof or formal-kernel proof +is asserted. Routine research submissions do not need to rerun this +selected-family replay. The sections below preserve historical checkpoints. + +## Historical selected-family replay: #6030 + +The [historical checkpoint](../certificates/checkpoints/frontier6030.json) binds conditional κ = 0.003125804 to the [proof review](research/pr-intake-evidence/pr6030-audit/PROOF-REVIEW.md), [validation receipts](research/pr-intake-evidence/pr6030-audit/VALIDATION.json), and [explicit source closure](../certificates/frontier6030-source.json). diff --git a/research/historical-selected-replay-gap/README.md b/research/historical-selected-replay-gap/README.md index 55d8cc3b49..36d9a873ca 100644 --- a/research/historical-selected-replay-gap/README.md +++ b/research/historical-selected-replay-gap/README.md @@ -69,7 +69,11 @@ python3 -B scripts/research_package.py --package research/historical-selected-re The direct command prints `PASS_HISTORICAL_SELECTED_REPLAY_GAP`. A registered replay prints `PASS_REGISTERED_RESEARCH_PACKAGE`. Both require Git history -containing the two inspected commits. +containing the two inspected commits and the source and manifest objects at +`2485805a6d47f36ea83ddde6327d453ac82d44dc`. The verifier uses a temporary +sparse checkout of that commit, checks the declared source digests there, and +uses its planner and manifest inventory. The recorded rejections and selection +therefore remain reproducible after later changes to the live Makefile or CI guide. ## Open next questions diff --git a/research/historical-selected-replay-gap/SOURCES.json b/research/historical-selected-replay-gap/SOURCES.json index c1010eec95..62bb8b3950 100644 --- a/research/historical-selected-replay-gap/SOURCES.json +++ b/research/historical-selected-replay-gap/SOURCES.json @@ -4,13 +4,13 @@ "files": [ { "path": "Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "0d683a06b9e7ee162496108ce9a7c5d2ee94fccf", "sha256": "4f2d4f2dcd15139ec82658a975f85ed300897385f85799218539f4c8d60567da" }, { "path": "certificates/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "eccafa830c16170c36faf93045ddf1f638f7bcd4", "sha256": "4c0b9d37e1034b2076e30a70f8e514416298c462d9ee98bc87fe6556b14df786" }, @@ -22,7 +22,7 @@ }, { "path": "docs/ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "63ba3e9aa8bdc5e942b56e34244b92b16f854085", "sha256": "c7d3027e9ad8bcbff68f07aa9576b30fb2f3c76c44d876d40c7fdbf4a3e2228a" }, @@ -34,163 +34,163 @@ }, { "path": "research/clifford-state-performance/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "6f98a0061a5104dfab82c9e806f819b41811f684", "sha256": "396d0f08df24952248140d5c65c51b8c902ef1c580892ff7ea182890530f67ee" }, { "path": "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "5e0f92af463ec12c5e1dcc3effd44081a88af647", "sha256": "07a9daeaf2bda308a92e9a4684f13d5fc766c7772d74801fceb7f4599fdab226" }, { "path": "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "9e13266bf85e627f1b7dc225e9530ea69fd2c7f0", "sha256": "421e1211fb1897c45621dc6801c276e53f2e6f335583c9c9049e535f87c0a3b1" }, { "path": "research/community-batch932-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "cc4d03eb59b9ab3f952735f7e88ff18c2d15d7af", "sha256": "184629cac91a5cfaca50330a88596008b824221433867dcf8117539c913c284a" }, { "path": "research/community-batch970-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8b9f4111badf7de5d97684799560b55110e9da79", "sha256": "23188ed920e38a54006cb883e181585620821c63bf7e8b5e05d32719417cc37e" }, { "path": "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "a5300d4e7a5381a3f443fc54c768ca6f0f236d68", "sha256": "3c820fb30e1b4d9bcfc6a7ab524375e5b2abd66b940af2c509146104f0bcd79c" }, { "path": "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "d7ff6d777b01d69b6ce84caf25d3b7e4a4d2f211", "sha256": "6b185a9902652f893f3ebd8ada92d2f11b6de6533a9a4d11718a8a4496101128" }, { "path": "research/community-hyperplane599-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "546f37d326d10a99910ae8f908e71ef768524d98", "sha256": "65099d764bfcc39bda5e4d9966783611b094c3522dbdd1435cd498d657a8ef8e" }, { "path": "research/community-k492-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "e538481e4cb16ed936d3195f2dfb5b5a9ca0a76b", "sha256": "2c0f4fa5bc150d05658af2e7c54c4d2c337dd52b7efd3d69530ae73bcbdf452a" }, { "path": "research/community-reconciliation92-audit/MANIFEST.json", - "usage": "input", + "usage": "provenance", "git_blob": "2a2e93685173d5f13cbb5abe740f5d90352e0228", "sha256": "5f501f3c118131e7d069f30ad77186eb2ad6961f9680a0ef105f4514ed41808a" }, { "path": "research/partial-swap-digest/baseline.py", - "usage": "input", + "usage": "provenance", "git_blob": "a2f0190704db83bd8ef48e46e723c49b925804fe", "sha256": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" }, { "path": "research/r420-two-sided-basis/SOURCES.json", - "usage": "input", + "usage": "provenance", "git_blob": "5d718e11e62f4bcadecf1e02d6b61f87dbe190b0", "sha256": "d9810b0d139c5a1211fd2c1f0d142187cc1fca30026e1e7bc4f9ecfacf1596d1" }, { "path": "research/skip-clones/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8d1bb3b9c8189e35e5d8bfdfa632d7473e8be0d5", "sha256": "0b68e63e35a97ce6b0cdb6e291b88ebaa8f2dd4afb70b2498f10ee89428258dc" }, { "path": "research/split-skip/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "2ab610b6ea2edd2865fda793ef2168b0c76afb4f", "sha256": "7c2b4646a3ecfef6f881da5c43e4bd0fa9a4d1b00548b8ab458d897e16735134" }, { "path": "scripts/historical-ci-inputs/Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "aff68409021c9d401a6f8013b9dfd7dbcc30f2a8", "sha256": "ea8830dd79da493e2d75baf753d733ff7efbcf2b4794afe41fae0ac8f3055646" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "65db599ab0b1dea0312c4ca048e0bd0f44c3736f", "sha256": "96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "34820a8f24678f918f4d0e7a35380d8013fc3495", "sha256": "628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac" }, { "path": "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "c755b76e0d44ba4917aa94440ebe54daefce5b2a", "sha256": "d7fd929726b326aeeaf0a3996475adec88eee9aac09ae0bebeeaa0bc1fc8f199" }, { "path": "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "7f3c012504187917a728b9fe87043f0fc8cd006a", "sha256": "a854022e0e1d5d4db4d60e586be3ea56005013ef14a1fc06d02bc06e8529c4b0" }, { "path": "scripts/historical-ci-inputs/partial-swap-context.json", - "usage": "input", + "usage": "provenance", "git_blob": "ad65114886bf34a4fd27e79f3be502389e689faa", "sha256": "833a9642f33aeab2ffea17ec9c6b82e0a953f90192b2c82e10bef21538dccba9" }, { "path": "scripts/historical-ci-inputs/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "52075f2463f60af5e16571347f24274fce73a1ea", "sha256": "f3c4be597b2f2136da4ae2cc80c7454f63c90aa01f84e5b8131cee4dd55de815" }, { "path": "scripts/partial_swap/shared.py", - "usage": "input", + "usage": "provenance", "git_blob": "44a0e454c70f9c4b98e258b8443612e6a119904b", "sha256": "5a0646a50b9f3e8ea55168620a78e8853b0ab810517cefc8cfb8696aedee278a" }, { "path": "scripts/replay_historical_check.py", - "usage": "input", + "usage": "provenance", "git_blob": "1e92fff2782970ef71378f594f2350d245a4db26", "sha256": "5467619c78183d3adc82b0cb55af28e5c1a01fca2b0588677816244b53e2bafd" }, { "path": "scripts/research_package.py", - "usage": "input", + "usage": "provenance", "git_blob": "091b4c8f58bac9a9580d76025b887dc5c873d05f", "sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70" }, { "path": "scripts/run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "a96ab35b315ce492e7fbbfd6c5ae211aa066b541", "sha256": "49eb56dd0fc0d8d8ffdb209970a7adf2176223580646f575d5c22e59543b381c" }, { "path": "scripts/verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "6882a4700e410dec569b51ae2eaf1a19cc019195", "sha256": "d6b305eac5b9bdb8172c469ad30a1655a60fa0aceac8b1bf610e1b73f51babd8" }, { "path": "tests/test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "343b24abf6719b81805eba5a84c74e57634c8288", "sha256": "3a5470d0b139828b90e19bf9583ddeafcd69f8e34f2824664eb3a2958a52e34d" } diff --git a/research/historical-selected-replay-gap/VERIFY.json b/research/historical-selected-replay-gap/VERIFY.json index 98553e72ed..ab7efa3471 100644 --- a/research/historical-selected-replay-gap/VERIFY.json +++ b/research/historical-selected-replay-gap/VERIFY.json @@ -4,36 +4,7 @@ "python": "3.12", "requirements": [], "inputs": [ - "Makefile", - "certificates/partial-swap-network.json", - "docs/ci-verification.md", - "research/clifford-state-performance/SOURCE.json", - "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "research/community-batch932-audit/CONTENT-COVERAGE.json", - "research/community-batch970-audit/CONTENT-COVERAGE.json", - "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "research/community-hyperplane599-audit/SOURCE.json", - "research/community-k492-audit/SOURCE.json", - "research/community-reconciliation92-audit/MANIFEST.json", - "research/partial-swap-digest/baseline.py", - "research/r420-two-sided-basis/SOURCES.json", - "research/skip-clones/SOURCE.json", - "research/split-skip/SOURCE.json", - "scripts/historical-ci-inputs/Makefile", - "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "scripts/historical-ci-inputs/partial-swap-context.json", - "scripts/historical-ci-inputs/partial-swap-network.json", - "scripts/partial_swap/shared.py", - "scripts/replay_historical_check.py", - "scripts/research_package.py", - "scripts/run_isolated_tests.py", - "scripts/verify_selected_result.py", - "tests/test_isolated_test_runner.py" + "scripts/research_package.py" ], "commands": [ { diff --git a/research/historical-selected-replay-gap/verify.py b/research/historical-selected-replay-gap/verify.py index 83b995941a..9d266c5a4e 100644 --- a/research/historical-selected-replay-gap/verify.py +++ b/research/historical-selected-replay-gap/verify.py @@ -6,8 +6,10 @@ """ import hashlib import importlib.util +import json import subprocess import sys +import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parents[2] @@ -61,31 +63,47 @@ def require(ok, message): raise SystemExit(message) -def load_checker(): - path = ROOT / "scripts/replay_historical_check.py" - spec = importlib.util.spec_from_file_location("historical_selected_replay_gap_checker", path) +def load_module(path): + spec = importlib.util.spec_from_file_location(path.stem, path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module +def checkout_snapshot(snapshot, sources, runner, env): + paths = [runner.canonical_relative_path(row["path"]) for row in sources["files"]] + git = ["git", "-c", "maintenance.auto=false", "-c", "gc.auto=0", + "-c", "core.autocrlf=false"] + subprocess.run([*git, "clone", "--quiet", "--shared", "--no-tags", "--no-checkout", + "--", str(ROOT), str(snapshot)], cwd=ROOT, env=env, check=True) + subprocess.run([*git, "update-ref", "--no-deref", "HEAD", INSPECTED], + cwd=snapshot, env=env, check=True) + # The pinned planner reads omitted manifests from the sparse HEAD/index. + patterns = "".join(f"/{path.as_posix()}\n" for path in paths) + subprocess.run([*git, "sparse-checkout", "set", "--no-cone", "--stdin"], + cwd=snapshot, env=env, input=patterns.encode("utf-8"), check=True) + subprocess.run([*git, "read-tree", "-mu", "HEAD"], cwd=snapshot, env=env, check=True) + for path, row in zip(paths, sources["files"], strict=True): + require(hashlib.sha256((snapshot / path).read_bytes()).hexdigest() == row["sha256"], + "historical checkout source digest changed: " + path.as_posix()) + + def entries(checker): for name, config in checker.CONFIG.items(): for entry in [config, *config.get("additional_inputs", [])]: yield name, entry -def reject(checker, entry): +def reject(root, checker, entry): try: - checker.authenticated_input(ROOT, entry) + checker.authenticated_input(root, entry) except ValueError as exc: return str(exc) raise SystemExit("historical input was admitted: " + entry["path"]) -def main(): - require(not sys.flags.optimize, "assertions must stay enabled") - checker = load_checker() +def check_snapshot(root, env): + checker = load_module(root / "scripts/replay_historical_check.py") selected = [entry for name, entry in entries(checker) if name == "tooling-ledger" and entry["path"] == SELECTED_PATH] require(len(selected) == 1, "selected-result checker overlay is not unique") @@ -94,7 +112,7 @@ def main(): require(entry["accepted_live_sha256"] == [SELECTED_ACCEPTED], "accepted selected-checker successors changed") frozen = (checker.INPUTS / entry["input"]).read_bytes() - live = (ROOT / SELECTED_PATH).read_bytes() + live = (root / SELECTED_PATH).read_bytes() require(hashlib.sha256(frozen).hexdigest() == SELECTED_PIN, "frozen selected checker bytes changed") require(hashlib.sha256(live).hexdigest() == SELECTED_LIVE, "live selected checker digest changed") require(SELECTED_LIVE not in (SELECTED_PIN, SELECTED_ACCEPTED), "live checker was already admitted") @@ -102,7 +120,7 @@ def main(): # live successor, not a broken comparison. require(SELECTED_PIN in (SELECTED_PIN, *entry["accepted_live_sha256"]), "pin membership control failed") - require(reject(checker, entry) == REJECTIONS[SELECTED_PATH][1], + require(reject(root, checker, entry) == REJECTIONS[SELECTED_PATH][1], "selected checker rejection text changed") counts = {path: 0 for path in REJECTIONS} @@ -110,7 +128,7 @@ def main(): for _name, item in entries(checker): if item["path"] not in REJECTIONS: continue - message = reject(checker, item) + message = reject(root, checker, item) counts[item["path"]] += 1 messages.setdefault(item["path"], message) for path, (count, message) in REJECTIONS.items(): @@ -118,20 +136,31 @@ def main(): require(messages[path] == message, "rejection text changed for " + path) require(sum(counts.values()) == 19, "rejection total changed") ci = [item for _name, item in entries(checker) if item["path"] == CI_PATH] - require(len(ci) == 1 and hashlib.sha256((ROOT / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, + require(len(ci) == 1 and hashlib.sha256((root / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, "selected CI note digest changed") diff = subprocess.check_output( - ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=ROOT, text=True) + ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=root, env=env, text=True) changed = sorted(name for name in diff.splitlines() if name) require(changed == CHANGED, "inspected commit diff changed") - sys.path.insert(0, str(ROOT / "scripts")) - from research_package import plan_details - details = plan_details(ROOT, set(changed)) + planner = load_module(root / "scripts/research_package.py") + details = planner.plan_details(root, set(changed)) require([row["package"] for row in details] == PLAN_PACKAGES, "helper plan selection changed") matched = {name for row in details for names in row["causes"].values() for name in names} require(sorted(set(changed) - matched) == UNMATCHED, "unmatched plan paths changed") - require(plan_details(ROOT, set()) == [], "empty change set selected a package") + require(planner.plan_details(root, set()) == [], "empty change set selected a package") + + +def main(): + require(not sys.flags.optimize, "assertions must stay enabled") + sources = json.loads(Path(__file__).with_name("SOURCES.json").read_bytes()) + require(sources["base_commit"] == INSPECTED, "historical checkout base changed") + runner = load_module(ROOT / "scripts/research_package.py") + env = runner.git_source_env() + with tempfile.TemporaryDirectory(prefix="historical-selected-replay-") as temporary: + snapshot = Path(temporary) / "snapshot" + checkout_snapshot(snapshot, sources, runner, env) + check_snapshot(snapshot, env) print("PASS_HISTORICAL_SELECTED_REPLAY_GAP") print("selected_checker_live=" + SELECTED_LIVE) print("rejections=19 distinct_paths=7 plan_packages=9") diff --git a/research/p104-two-type-threshold/CERTIFICATE.json b/research/p104-two-type-threshold/CERTIFICATE.json new file mode 100644 index 0000000000..31452df521 --- /dev/null +++ b/research/p104-two-type-threshold/CERTIFICATE.json @@ -0,0 +1,880 @@ +{ + "source_head": "75f7e1c44f48c43983016bcf8878c4d9e5e87c62", + "source_histogram_sha256": "49f22c0d2d235138173b599004d49b6593244cca8aa5e3a6e6999444308f9cba", + "exponent_power_grid_bits": { + "exponent": 128, + "values": 224 + }, + "integer_lower": { + "rate": "1949233305442878621/500000000000000000000", + "weight_0": "1", + "weight_1": "4578602863181069903047991109700900468280627955974647050278778376141001871277476058358561919482227240790288703577208320850012449802155075/50734667026723589598279941530854385606009685196953562699085775007052781454111986085985969738942598242397277577119132533292120742242984", + "split_0": "1006", + "split_1": "0", + "all_cut_margins": [ + [ + "None", + "236860262217181695388327927088227220883681708557915372618789348350801494054089652911048479497286913180396055659772120717951/5074065423709260181004006817843476545074342374353869625278365159573190039902499299511649885519147403356461230713045843686345551638429696" + ], + [ + "1/2", + "236860262217181695388327927088227220883681708557915372618789348350801494054089652911048479497286913180396055659772120717951/5074065423709260181004006817843476545074342374353869625278365159573190039902499299511649885519147403356461230713045843686345551638429696" + ], + [ + "1", + "3663985664435146932822078261419590272159171209810411157673761885890540793963183540993788151989951126148899762724514868244891520316157313/5074065423709260181004006817843476545074342374353869625278365159573190039902499299511649885519147403356461230713045843686345551638429696" + ], + [ + "2", + "78953420739060565129442642362742406961227236185971790872929782783600498018029884303682826499095637726798685219924040239317/25234477777861656639473755536074193462976358347739142921191219553717170208158468632867060882903540086177559668057254559440382722048" + ], + [ + "3", + "19633371952488788779949912737649704918041713505430199504849881450106277231354723704827840436693169418570061013566973703337753609420892501877946582739163182797748733892715990711088434124116441764671311399755/593664894625049522197842101120434039131490160725647185919273089789828376985712918939347554922810254712259789643357274176605419656204332587359918918519560198982293900196887071491853043731016697511936" + ], + [ + "4", + "78219314074398558366963799114561302018387051736802264486202296513324378262975269050129206207519373886113664959657181793665522795849733197437741785238033101738190304669975697195524750201663052739263470697155/2374659578500198088791368404481736156525960642902588743677092359159313507942851675757390219691241018849039158573429096706421678624817330349439675674078240795929175600787548285967412174924066790047744" + ], + [ + "5", + "330305267937260539866590787174641379762044192715356591311535317069751157009402817109766913117121120957770278860508601589080310653818265220311457810143424866448157654428733813274000925112538186386762242367061/7123978735500594266374105213445208469577881928707766231031277077477940523828555027272170659073723056547117475720287290119265035874451991048319027022234722387787526802362644857902236524772200370143232" + ], + [ + "6", + "330805515119265224245459865983022294594971243955453611546704878364148022880921438679316397611676062313687655986330311401758689958870975753656492309635244957833534265310743370908986114551865874056067932084849/7123978735500594266374105213445208469577881928707766231031277077477940523828555027272170659073723056547117475720287290119265035874451991048319027022234722387787526802362644857902236524772200370143232" + ], + [ + "7", + "1440158752359280104477738320698564739520391655151270759745223223637910125803062246455122044770973440922464717834355858415070575099489999876592943086009048619860994162615641771516350911060334515348377451399095/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "8", + "1433675151496353620794719697814797189542162199029958703147305720884547683679184768231075087923213034798961093276506324750852389338136822162442135095964623444638705904613433965625979253641660952243861645576239/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "10", + "1613516874671368490664002218327654224831560075162629848900341938423522062893352964331032484690686226144638177248872227412611552689086853729437614059444736838751833650987038581082178636532476581495923993581343/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "12", + "1973704877773796288221896668712684003868040414404623477018885090138524631854594879331050194981386600271025446575659114075554567518232553069815305260439395996779647176713898745107279081619841566492133032595943/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "14", + "30762161570808674115608612227508938070933710784469154501485747914720489494202799325290523673930361266996416639527087055837612001663658211853530134543288580203091656665765470303831735265602805316453944518163/445248670968787141648381575840325529348617620544235389439454817342371282739284689204510666192107691034194842232517955632454064742153249440519939188889670149236720425147665303618889782798262523133952" + ], + [ + "16", + "267232559780448016882565541010179216232801055904372198540317908011194115504510454755146921315698990372768248935698688300924762178023229774009743737844915797268800717076628255820474101238486854550312408694969/9498638314000792355165473617926944626103842571610354974708369436637254031771406703029560878764964075396156634293716386825686714499269321397758702696312963183716702403150193143869648699696267160190976" + ], + [ + "24", + "856088688271571925121795590359513505862816145312677049190608831465779386961680789989308456831559267706838345015436931980715049579120247195467604099993919919482993955680600977735576040863921018123253503730163/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "32", + "748143875017067833248964876349203569055678766198535066034163561834356926316844381981526203551155014262176084165430059644760016124985604376712436767648255628975543295549881244522464753987174575169390531802717/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "40", + "847436036897464386493228737096174067968939664100569171719439608193156435735262497592112376817730674670430400911334546749029374189674701096529342602987105788522939800791029409454288115039192506918553093504369/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "48", + "229600350834780091065935413581514986725791999856538639645275286213873149459335027038077063007571347731274348630770820066529087212881461966543282278579032628009552041213614567777473266410311091637726594702223/9498638314000792355165473617926944626103842571610354974708369436637254031771406703029560878764964075396156634293716386825686714499269321397758702696312963183716702403150193143869648699696267160190976" + ], + [ + "56", + "631562996035090654919722961315772683317974883677487377724077355336059586763163144877261426275505798269602532071793336589400752361279663590080048581705942424031813503714298932732574297001867787549077626652789/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "64", + "633523510114313878046049409500025570222399827710829299368046875773311528623963756736270637013195838191618066664433487158192344227542152077676668886204729077651159351492133563364297659390824802769303080335317/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "80", + "267982894376967439112264207941839640054189438454479642697906683300999059370006644670798173089290336103742438065024030984390765341810336291605411547949672640622036148321871672965543304653778882872959051944167/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "96", + "53735824068362524297636141198122717824742352838320153130873561735570115749309280612484462362961685271820735735970578786652424992130166705673891257491509851261954300859772929219578383357678776948697270911439/9498638314000792355165473617926944626103842571610354974708369436637254031771406703029560878764964075396156634293716386825686714499269321397758702696312963183716702403150193143869648699696267160190976" + ], + [ + "112", + "52245398018286449164385136863359000336400537778601430689019495330977561349843156205905340931105401859469364489906341367183347474735300123374098241092280864490779868019013782017396885659173258498106043460275/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ] + ], + "greedy_directed_flow": [ + [ + "112", + "258", + "22056397712344932897568932634069521830560489735722143710719529017739014621836460186884287859108923111979114537352740500695888971130733240010897038555763431509918043676486279254285070611808252487412726789625/1780994683875148566593526303361302117394470482176941557757819269369485130957138756818042664768430764136779368930071822529816258968612997762079756755558680596946881700590661214475559131193050092535808" + ], + [ + "96", + "258", + "52245398018286449164385136863359000336400537778601430689019495330977561349843156205905340931105401859469364489906341367183347474735300123374098241092280864490779868019013782017396885659173258498106043460275/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "96", + "130", + "83474725687441597679291488917385577294389485212975643226931605117531539766761784623318601867713821319479629862382982995093373138988237286591880542261697954227320215544784073736623600435341276828765923026025/9498638314000792355165473617926944626103842571610354974708369436637254031771406703029560878764964075396156634293716386825686714499269321397758702696312963183716702403150193143869648699696267160190976" + ], + [ + "80", + "130", + "52985571332946355967698140926681939240366027880887469372635843883256064175663588896257136762004500011757252591049983565897112028096165295869765176844786405411529910602258417977928726263415220109720063855775/9498638314000792355165473617926944626103842571610354974708369436637254031771406703029560878764964075396156634293716386825686714499269321397758702696312963183716702403150193143869648699696267160190976" + ], + [ + "80", + "129", + "66544978162455206387400698044805336095703125586975702326628698678009407/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "80", + "114", + "30398837423165703165296896405798019322139226403439954395351179775252816271706750366557114359543220136704548720399714689824825295078441502774513773259317415160265769704293060957584368450707470169471139230961/9498638314000792355165473617926944626103842571610354974708369436637254031771406703029560878764964075396156634293716386825686714499269321397758702696312963183716702403150193143869648699696267160190976" + ], + [ + "64", + "114", + "33683153426155005259360283704814582905042260242776890918990522827095163321542889568459278892738562151642447250515598850232051952436134076615910982405734019572655422441075698215130258909750026840971110021075/4749319157000396177582736808963472313051921285805177487354184718318627015885703351514780439382482037698078317146858193412843357249634660698879351348156481591858351201575096571934824349848133580095488" + ], + [ + "56", + "114", + "28981870692931082538819635486630519436429715732176826157971688661969069/421249166674228746791672110734681729275580381602196445017243910144" + ], + [ + "48", + "114", + "63923459740814184429776057528699255719510932964476375539994025901176137579948695401033288995168923271872219969290287314206861760931043344313325349016481869566757765897582853043038388806321706606906938135189/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "48", + "98", + "89502270171174967712001940387111205449030383257329553016099037999669542772131419179567980537522124208627007044782415584253534297438040009624610687871888585564022974855011968116060804076362584291150007443397/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "40", + "98", + "41457017006049479599996140649332396532930205869027467700875763060402119/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "32", + "98", + "25611406756537909408480204230666739433411590354971886810568297882612934620824848356010938080114656600089792495445378828751384171961542929368225310317390301174681003390702726664079495197016160136375587697657/7123978735500594266374105213445208469577881928707766231031277077477940523828555027272170659073723056547117475720287290119265035874451991048319027022234722387787526802362644857902236524772200370143232" + ], + [ + "24", + "98", + "1557737185828302294828434044249633234809253098214381364339464939434405/52656145834278593348959013841835216159447547700274555627155488768" + ], + [ + "16", + "98", + "186719576008647759010860594372312492821823077952232180752068646921253262059389967818283961484991277095366572054934902110053721629055610940858466327514140087918222136888440065242121127374754547881399863511/96269982912170192788839259641151465805106512550104949067990230776728925997683176044218522419915176439825911834057936352963041025330432311463770635435604356591723335167062768350030223307732437434368" + ], + [ + "14", + "98", + "8552279827409048086346986693354234654096601231866687625461855970037411765360362866729542831725399933612395727381975994924262011485140780609346123290878039200460012241618087596882694718467674712111755307625/14247957471001188532748210426890416939155763857415532462062554154955881047657110054544341318147446113094234951440574580238530071748903982096638054044469444775575053604725289715804473049544400740286464" + ], + [ + "12", + "98", + "42383698741446524565302470065499772891977321862031380971933802910853130299196980844356394285200007383195392405985916885189596689115023706425710659973185062254211631475041824443371003278365016337249306799375/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "12", + "82", + "4440686281604439346839155127006951326250149727418901625039235006231004993159969724948483175156823839986658765403252326864491473289978902616108113734893031168146724044096295657111213173975127293818393727925/7123978735500594266374105213445208469577881928707766231031277077477940523828555027272170659073723056547117475720287290119265035874451991048319027022234722387787526802362644857902236524772200370143232" + ], + [ + "10", + "82", + "120463217740276059346654886595177233776113205696826286119210165932621435806905733825605050012955055607839606509643121362694055875856131893343513439024812973877319283809918632174183202457620215765780896540525/14247957471001188532748210426890416939155763857415532462062554154955881047657110054544341318147446113094234951440574580238530071748903982096638054044469444775575053604725289715804473049544400740286464" + ], + [ + "10", + "66", + "35801987784655253376589059984016792128884673825212913662336744740393172030729390138079497728488022515903726715661891163967953669550367002384422793481148262604064189173377904329042180271204176660239166981625/7123978735500594266374105213445208469577881928707766231031277077477940523828555027272170659073723056547117475720287290119265035874451991048319027022234722387787526802362644857902236524772200370143232" + ], + [ + "8", + "66", + "10863593384077260944050779076703170883415288644065380339815779677205477678055846330387109100688625540271323516674855294621577719346277659273022469768285965419364030409458898578264051147508172306219317521925/4749319157000396177582736808963472313051921285805177487354184718318627015885703351514780439382482037698078317146858193412843357249634660698879351348156481591858351201575096571934824349848133580095488" + ], + [ + "8", + "65", + "67240264047350220174287915532780331532506613984114779461121586263425711/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "8", + "57", + "29497368673798832723796955495186169674861062226363272885452076294751797/421249166674228746791672110734681729275580381602196445017243910144" + ], + [ + "8", + "50", + "3171422919382236499047410519341045621052751101746067719231597615227103769251740398710358739463538585302822044992335474352167380861712496273862476132429043913797153319175512463922630801258960784571473413113/593664894625049522197842101120434039131490160725647185919273089789828376985712918939347554922810254712259789643357274176605419656204332587359918918519560198982293900196887071491853043731016697511936" + ], + [ + "7", + "50", + "87793782996196055713679902298666423959074265472328084588378949175655/26328072917139296674479506920917608079723773850137277813577744384" + ], + [ + "6", + "50", + "1429620327519064633941648771970666275483839543312808127557294950513491208209759079391524379320740092290951155719590085819308959383793652003003602935060072107022337150965321677971203958613339221093333367729/7123978735500594266374105213445208469577881928707766231031277077477940523828555027272170659073723056547117475720287290119265035874451991048319027022234722387787526802362644857902236524772200370143232" + ], + [ + "6", + "49", + "12686170719943009928245243699612566414642685826732023625612745039416835/210624583337114373395836055367340864637790190801098222508621955072" + ], + [ + "6", + "41", + "42489352067990177745739062079221871541003286876326843348871256781477631/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "6", + "34", + "17938354380715771587361969400561319860023357823369489689456717676191279802673680947297195359696696128655590275264209276944886785535031843353043178766085070757573749470719549022598208667984235992424342103225/4749319157000396177582736808963472313051921285805177487354184718318627015885703351514780439382482037698078317146858193412843357249634660698879351348156481591858351201575096571934824349848133580095488" + ], + [ + "6", + "33", + "8556924663612241689717988226172222622131411517466958745012259921772399/210624583337114373395836055367340864637790190801098222508621955072" + ], + [ + "6", + "25", + "25958155038331052960311558248974140773861495577490278732764850154980875/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "6", + "18", + "117412904453552427792423124051184453368984889850525880148685199383722376232877538347737885569258690997695837168545788312654432139223738757339272722311751931048049249524445883030472817311094493001457829854835/14247957471001188532748210426890416939155763857415532462062554154955881047657110054544341318147446113094234951440574580238530071748903982096638054044469444775575053604725289715804473049544400740286464" + ], + [ + "5", + "18", + "63093559445306573817491260198007919973472316247163681146740562777341609/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "4", + "18", + "8128677252302939612716923285365975273030163028106588740353958349862809480334035889471661691061539305183932916064074793208367459291091858103045860414895842210135029080015767016011013078159161139181851056979/593664894625049522197842101120434039131490160725647185919273089789828376985712918939347554922810254712259789643357274176605419656204332587359918918519560198982293900196887071491853043731016697511936" + ], + [ + "3", + "18", + "1812019054676536532107541603023141614015491345961640292637029833499445/26328072917139296674479506920917608079723773850137277813577744384" + ], + [ + "2", + "18", + "555087663428708977931455043251119283509608004042708706049986329750282612619755114511583820507767244226173377086305233774819555109889530186900451217064740254144481980631842714549642926921835425409305913831169/28495914942002377065496420853780833878311527714831064924125108309911762095314220109088682636294892226188469902881149160477060143497807964193276108088938889551150107209450579431608946099088801480572928" + ], + [ + "2", + "17", + "2209763043667675430108258282393428797183235937710028266265493885726657/105312291668557186697918027683670432318895095400549111254310977536" + ], + [ + "2", + "16", + "10745842103003403331668278189162703298057946943188912091510362292772081532884426482602087236672956843581202671397961928514401558145776758539102183019545825792657081215239682074805134459096929720068221946775/4749319157000396177582736808963472313051921285805177487354184718318627015885703351514780439382482037698078317146858193412843357249634660698879351348156481591858351201575096571934824349848133580095488" + ], + [ + "2", + "14", + "3991063919457555773628593790231976171880794575418433128204026518635498462581185533918396774860304525484475092524486786386151933461338742641171141829926640023846966431081452939905780152115358862718236998825/4749319157000396177582736808963472313051921285805177487354184718318627015885703351514780439382482037698078317146858193412843357249634660698879351348156481591858351201575096571934824349848133580095488" + ], + [ + "2", + "12", + "366746608950391963125970064472729135344748184806620420923088882100957476938585644766011760431387868583866533365346648883927384068367971742878225151663077875019121753527265626154064956880556599710596337775/7123978735500594266374105213445208469577881928707766231031277077477940523828555027272170659073723056547117475720287290119265035874451991048319027022234722387787526802362644857902236524772200370143232" + ], + [ + "2", + "10", + "6728468555431376519420901503806748402415324322675427523957018869121634995190311880803155606177548533324664730173445585346995877175489550531335234349427818191453667802457145126933612786920665372038591961475/4749319157000396177582736808963472313051921285805177487354184718318627015885703351514780439382482037698078317146858193412843357249634660698879351348156481591858351201575096571934824349848133580095488" + ], + [ + "2", + "9", + "389001678726164687770960176981494087928850675799085224096867445922341447/1684996666696914987166688442938726917102321526408785780068975640576" + ], + [ + "2", + "8", + "78808954198742161659161849332715734448148263473790942111553824733123740797582274358400889464545856524828063607239327601101586037849289710584497197522757072513682474687659252779757473001618772174510844682063/9498638314000792355165473617926944626103842571610354974708369436637254031771406703029560878764964075396156634293716386825686714499269321397758702696312963183716702403150193143869648699696267160190976" + ], + [ + "2", + "7", + "491645184778697911996607452872531974168004405805016776537560294965949/105312291668557186697918027683670432318895095400549111254310977536" + ], + [ + "2", + "6", + "920366151984351295546608899004686087645266828088734116479760443953673663810558129108413571210809688207238342645214312319172616265169839635864982357001236821094978108198986047632108445411707439641194281025/3561989367750297133187052606722604234788940964353883115515638538738970261914277513636085329536861528273558737860143645059632517937225995524159513511117361193893763401181322428951118262386100185071616" + ], + [ + "2", + "5", + "13261703577675904050810264882383830312832730956411973389775349433316861/1684996666696914987166688442938726917102321526408785780068975640576" + ], + [ + "2", + "4", + "477608728241205690135851615113472926972424414251180417813250459015795112101291287198342461129451743566716314068754105316300129107091310248039074889472212050081425958699122127292082532044128340846164490985/2374659578500198088791368404481736156525960642902588743677092359159313507942851675757390219691241018849039158573429096706421678624817330349439675674078240795929175600787548285967412174924066790047744" + ], + [ + "2", + "3", + "36182350166766959864069275461442741824499691919319943563187637652082219342509047194718467526390985807746685736087715320630558880325483/25234477777861656639473755536074193462976358347739142921191219553717170208158468632867060882903540086177559668057254559440382722048" + ], + [ + "1", + "3", + "78953420739060565129442642362742406961227236185971790872929782783600498018029884303682826499095637726798685219924040239317/25234477777861656639473755536074193462976358347739142921191219553717170208158468632867060882903540086177559668057254559440382722048" + ], + [ + "1", + "2", + "4600396705770768221895163416194412470819005242535970962154500500169089502185754182085444371434309096124187097207119051028118488485443371/25234477777861656639473755536074193462976358347739142921191219553717170208158468632867060882903540086177559668057254559440382722048" + ], + [ + "1/2", + "2", + "3663985664435146932822078261419590272159171209810411157673761885890540793963183540993788151989951126148899762724514868244891520316157313/5074065423709260181004006817843476545074342374353869625278365159573190039902499299511649885519147403356461230713045843686345551638429696" + ], + [ + "1/2", + "1", + "5114657947098934025591776655204528969107010025121479698598883522934402941432370943106249030513647671534833423271837030039780656279416415617/5074065423709260181004006817843476545074342374353869625278365159573190039902499299511649885519147403356461230713045843686345551638429696" + ] + ], + "unused_directed_capacity": [ + [ + "1", + "236860262217181695388327927088227220883681708557915372618789348350801494054089652911048479497286913180396055659772120717951/5074065423709260181004006817843476545074342374353869625278365159573190039902499299511649885519147403356461230713045843686345551638429696" + ] + ] + }, + "integer_upper_rate": "3898466610885757243/1000000000000000000000", + "integer_upper_at_most_1005": { + "rows": [ + [ + "-27175220794884767337994697645250433013103470713222336990455173897285280", + "808702964781320458587835999875626478623278117858193511314581698864", + "4942081743448718082039999869631742538045772218384757422656065002004283392", + "-26673042355803397696190355775423018360535295496953229768104013241232480" + ], + [ + "4891675987434960653037314340760675776538361390363911948754960058812001168", + "-54203773474404762563820018357571557526905210439669461264671480439960672", + "0", + "9857490444541632766383809383488062057731009141272561615544025990767334304" + ], + [ + "1005", + "0", + "-183312", + "0" + ], + [ + "0", + "0", + "0", + "1" + ] + ], + "positive_multipliers": [ + "1", + "16847978432944176220579916664075551637984960788712364819053785393/1129245280716765886746250382449407448477191884159780443013989175832514", + "26959946667150639794667015087019630673637144422540572481103610249216", + "14977164208118401791858561007492599160008115121214421992940337523335028411931726443191583952475453483966603188734634408657302885746156916624/564622640358382943373125191224703724238595942079890221506994587916257" + ], + "weighted_result": [ + "-4230239277824422232650316772484502715477033927671074184079180480690649083028736675908100447017370144073832444455650848323388832866092888/564622640358382943373125191224703724238595942079890221506994587916257", + "0", + "0", + "0" + ], + "constant_divided_by_unit": "-528779909728052779081289596560562839434629240958884273009897560086331135378592084488512555877171268009229055556956356040423604108261611/1902774533890972569788733868610866311903185139446005536036587228901419815084763951720255584504227706359811512643022352383097951238488064" + }, + "integer_upper_at_least_1006": { + "rows": [ + [ + "405445603077575029653562465354705922770864698560070497265233924448", + "808702964781320458587835999875626478623278117858193511314581698864", + "-13372608009155409696079971976430563370862966240193079101144110702791232", + "-26673042355803397696190355775423018360535295496953229768104013241232480" + ], + [ + "4891675987434960653037314340760675776538361390363911948754960058812001168", + "-54203773474404762563820018357571557526905210439669461264671480439960672", + "0", + "9857490444541632766383809383488062057731009141272561615544025990767334304" + ], + [ + "-1006", + "0", + "183312", + "0" + ], + [ + "0", + "0", + "0", + "1" + ] + ], + "positive_multipliers": [ + "1", + "16847978432944176220579916664075551637984960788712364819053785393/1129245280716765886746250382449407448477191884159780443013989175832514", + "72949986957511836083180435413014769196031717728206986455573616036", + "14977164208118401791858561007492599160008115121214421992940337523335028411931726443191583952475453483966603188734634408657302885746156916624/564622640358382943373125191224703724238595942079890221506994587916257" + ], + "weighted_result": [ + "-1371913709867267127229889769246480278104048370502481614119563612615534815272958615813451506558789267808878552507314481414864/564622640358382943373125191224703724238595942079890221506994587916257", + "0", + "0", + "0" + ], + "constant_divided_by_unit": "-85744606866704195451868110577905017381503023156405100882472725788470925954559913488340719159924329238054909531707155088429/951387266945486284894366934305433155951592569723002768018293614450709907542381975860127792252113853179905756321511176191548975619244032" + }, + "relaxed_lower": { + "rate": "1949233310752884819/500000000000000000000", + "weight_0": "1", + "weight_1": "276081017851472814871896024484052056629802028992999449988123331571743731947587020887869534759762025957196675228578230144439589582057309668905175777541573970892568382986221506713130459016170965161223249/3059203665828499541872590872332110150901104436676197723985663098917349433313219800075803020789696490530139134109976825731993634311877881991524736482152108967651760673599917942478823145448597188406278", + "split_0": "22453437256079237733597774555533230370620926675398502873128525577158002436418968481408238514938524758417815512589169301178635280328286749028380162159237676353735134408943885215445614966052296587239042657791399784626288067863757234869235341913117428210428610899923176827/22335509162001957927023441885130765738622911397817030429983414524543587029330886237189712939774683328352861783758444422693641094417196359269784939701643375840858885690618870738824700474794519264459380955711374236066824669256631390046212231441398135979734859398512640", + "split_1": "0", + "all_cut_margins": [ + [ + "None", + "23035515623346252629647789316391863408661131133480979607478688938946315923170592798401057349255777906864023362033393652774869837600003718270955431330229199676163680591603024790200003208357/1832096446457624445404050181349665005308664286283077250337415836958041550935308177992490393698912053590045939493650449376810531483141272212803835455383317365607362772906608572976191069430746782392909824" + ], + [ + "1/2", + "23035515623346252629647789316391863408661131133480979607478688938946315923170592798401057349255777906864023362033393652774869837600003718270955431330229199676163680591603024790200003208357/1832096446457624445404050181349665005308664286283077250337415836958041550935308177992490393698912053590045939493650449376810531483141272212803835455383317365607362772906608572976191069430746782392909824" + ], + [ + "1", + "23035515623346252629647789316391863408661131133480979607478688938946315923170592798401057349255777906864023362033393652774869837600003718270955431330229199676163680591603024790200003208357/4957406403233501402105784599806223983089992757537469662979452874372420979954576253558258231005642772080730018224417470242199779037865298951391824605788499696326792293274191012787898489421506113699840" + ], + [ + "2", + "7678505207782084209882596438797287802887043711160326535826229646315438641056864266133685783085259302288007787344464550924956612533334572756985143776743066558721226863867674930066667736119/4564772607577841547989096023937067347106573764169243689256941462952374794814340095911535745749079616864961925870785513590443699953914237937802336892256269241922998285442342826365780804881491165184" + ], + [ + "3", + "6088396491378875089692652461911779204390106154539965719601776593929035235499675451162932406813523572973435137218857268165812586631666152934868798646068118442945664619875459485480677917987836153427613852632122211058570542321577023833936433293893098209094845138052047496995/184098142131000169262464214814452783082304750942441699699910536777578292705512566370847873204768812833922592340356160776831300998000069282284328931304048846063630010422133384817694441990370864951002408764361807443493881765028226938562031152879554252776985199640576" + ], + [ + "4", + "169793114991795548632827777247812895407087409487612567841288130319516031392465760320721179003453166035104481728944930883887639092568568013038258520924729169368392419981087024359549546061043699984772864092737572449618457364927548930349847606547468329922497272461628255616881/5154747979668004739348998014804677926304533026388367591597495029772192195754351858383740449733526759349832585529972501751276427944001939903961210076513367689781640291819734774895444375730384218628067445402130608417828689420790354279736872280627519077755585589936128" + ], + [ + "5", + "14058901778413322497856189011063183672202840882070381821498060501046935432987497465015070433147652232899101703426272493373940126589032902555131944691203217333275469054813995703256016144574957942182401680398512583395697160948607412688446725171301586862149685085418543249341/303220469392235572902882236164981054488501942728727505388087942927776011514961874022572967631383927020578387384116029514780966349647172935527130004500786334693037664224690280876202610337081424625180437964831212259872275848281785545866874840036912886926799152349184" + ], + [ + "6", + "14080193979157993605872020369328697065425981263112172899154466984193585254429311488895229195403498885701395390418033829410795060281975019096738578382392207969009225849125259551831395774948269086508705447746890574733437231886578580649747205466510150510957253983765085734673/303220469392235572902882236164981054488501942728727505388087942927776011514961874022572967631383927020578387384116029514780966349647172935527130004500786334693037664224690280876202610337081424625180437964831212259872275848281785545866874840036912886926799152349184" + ], + [ + "7", + "32564559493916827882632600524025999710655984880225068748419770550613136542362748315693030845772883672570656263701570652246880940202618673895185512123990192681097769312087889238764450283737202162457003969741662615078201266148788920454899760924045364132646912561172231186681/644343497458500592418624751850584740788066628298545948949686878721524024469293982297967556216690844918729073191246562718909553493000242487995151259564170961222705036477466846861930546966298027328508430675266326052228586177598794284967109035078439884719448198742016" + ], + [ + "8", + "129671814824903682034679173077742181497842464810184492192810410641841725508878867020062656426015684028831252962195095205392935105209134247408744352320445126929810660615425373735236012840308849471661107073570021359342506088410886127362239772273808939873267092662432165552575/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "10", + "13267089458936352170130398934508699409655487016729714718687973695532234313719472348139008475258373595373842268330894871600616997679041166071164597908656594788458882913713875792123214552830554998121987688166842922038264238478435526604244410084866332869907929649883529776861/234306726348545669970409000672939905741115137563107617799886137716917827079743266290170020442433034515901481160453295534148928542909179086543691367114243985899165467809987944313429289805926555392184883881915027655355849519126834285442585103664887230807072072269824" + ], + [ + "12", + "178515958208820682528130501206158298236542774721279264582989300599627003222886234829823392089598948435215751186589078531924723635297680355233098618919045540120837066772861114706582479087895348680448789680758584561781163379378679930178441666785599556069885968959780542363571/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "14", + "356140734025158214322716570643038928470444937295521609916814240550398734188487393600273300919436652327364811920472588249783106024051720707762353763581313761554244608289705696102708541016560193561464758092522225543146350225938254801741386473408028210387086826373851163411913/5154747979668004739348998014804677926304533026388367591597495029772192195754351858383740449733526759349832585529972501751276427944001939903961210076513367689781640291819734774895444375730384218628067445402130608417828689420790354279736872280627519077755585589936128" + ], + [ + "16", + "72511260946393145687550040836184703699212146676570143537107765117666614032224428776036188642726274856825052959135067294348124324882601681447656974441611237595954222315405126943645482620867735322964648069902375127563920702113352483205920975702006884445674664385986118176485/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "24", + "77430772057568130056264911072198801955910171741465360797055101622433353320394258267865542058991464296250402823773795249133393586278095967936203554940804606694816939140162128641780028089929871626535081339982440730698457075607648771751854320218276986681075691256170900055897/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "32", + "33833736297614590030793859177349278671081369320771845815589302195220816838365299844744120520197421425171293245662517349456781467337424223216625026395108055289263761736914822047654955353522449837349107972334007139107923118899735178541010484896744188739693172749108170378775/1288686994917001184837249503701169481576133256597091897899373757443048048938587964595935112433381689837458146382493125437819106986000484975990302519128341922445410072954933693723861093932596054657016861350532652104457172355197588569934218070156879769438896397484032" + ], + [ + "40", + "76648164499094685682484664674768575889751870899617236742911404728102189132075951340241756148833648241001285302732276613441126787497084396313880530391116300088425220175076802501699398757623828910345775452539924100354655412125362546364984626604621128695601501930701116452833/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "48", + "333155530015880995582469454945530339905010939293985312469352362066177851808896065871113252014454406301152464971221607776250807272205794070163536458659056427685806560357308341894910867244137914518261595370167230423225285270804142655557096273650785787811945983828696401625/13782748608737980586494647098408229749477361033123977517640361042171636887043721546480589437790178500935381244732546796126407561347598769796687727477308469758774439282940467312554664106230973846599110816583236920903285265830990252084857947274405131223945416015872" + ], + [ + "56", + "3570191606143434818865476415735990520266860107358685428373222690027025847162647311249853243624675224967425999752956207101239819986103764260326123135829743082327588374380328733732298958187097234088620090957673506424203106900178228604642659203134110947917497457015191823953/161085874364625148104656187962646185197016657074636487237421719680381006117323495574491889054172711229682268297811640679727388373250060621998787814891042740305676259119366711715482636741574506832127107668816581513057146544399698571241777258769609971179862049685504" + ], + [ + "64", + "28650194294210070661440072698626122077738265351941222198808379574550283864561695358877184808948420902489643935064346475556310201977188721228396161912910133743235956169091967818166322188749134765506156473408444113246725749796025379992155311778885710226344769080432284237985/1288686994917001184837249503701169481576133256597091897899373757443048048938587964595935112433381689837458146382493125437819106986000484975990302519128341922445410072954933693723861093932596054657016861350532652104457172355197588569934218070156879769438896397484032" + ], + [ + "80", + "48867511961785554600785272315813532240963201523116391218270906408321839833213536799183401193970072670105138302308359534767276400910285574845401053081466409798895420143158351909460381026343445093093328966288715784110847532888216371967738422241314310200517057110071503397/5196318527891133809827618966536973716032795389504402814110378054205838907010435341112641582392668104183298977348762602571851237846776149096735090802936862590505685778044087474692988281986274413939584118348921984292166017561280599072315395444180966812253614505984" + ], + [ + "96", + "7290377274147236392582768246997641428642336086801198722341683321345891374395103751002731068356051954275369846942033644154303402421465695315128123999828494791388213161146127741348461935491232076527060852503375546489262545388192374511091206854179578160214697093233150519867/1288686994917001184837249503701169481576133256597091897899373757443048048938587964595935112433381689837458146382493125437819106986000484975990302519128341922445410072954933693723861093932596054657016861350532652104457172355197588569934218070156879769438896397484032" + ], + [ + "112", + "675063820570075871017942401084656165050471566300178973010372723514777372850169704428896292876125232513751342674756475727619563882846307702857242650100487681763899225488850997191443876776593853134154659228944447371997948210009415146734374476632812162021616154792551580103/368196284262000338524928429628905566164609501884883399399821073555156585411025132741695746409537625667845184680712321553662601996000138564568657862608097692127260020844266769635388883980741729902004817528723614886987763530056453877124062305759108505553970399281152" + ] + ], + "greedy_directed_flow": [ + [ + "112", + "258", + "31919008897095320605248070329934987072519717033964246918392076140588007225337226088084500604993294706495730070294904562153370828520474050052844024272535563779595194057074957290910869155894382574872302924174695358688741804221607159873546538635986418459501915773602867605603/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "96", + "258", + "675063820570075871017942401084656165050471566300178973010372723514777372850169704428896292876125232513751342674756475727619563882846307702857242650100487681763899225488850997191443876776593853134154659228944447371997948210009415146734374476632812162021616154792551580103/368196284262000338524928429628905566164609501884883399399821073555156585411025132741695746409537625667845184680712321553662601996000138564568657862608097692127260020844266769635388883980741729902004817528723614886987763530056453877124062305759108505553970399281152" + ], + [ + "96", + "130", + "11325075098500649184756812660519212329453267593652538371474501833284883383960071036087889223110553261279461424748181155754370816033438454011259093962919598115574484674532589800215584307666381813952283292823419311701905019199080781152168623946489998344056981606453323552033/1288686994917001184837249503701169481576133256597091897899373757443048048938587964595935112433381689837458146382493125437819106986000484975990302519128341922445410072954933693723861093932596054657016861350532652104457172355197588569934218070156879769438896397484032" + ], + [ + "80", + "130", + "14377179907167919113822037981788467335750173747589626411221055458274582411225981856029540423724018164567751218603859575174650535453616422874822567164705109615447769897718167750923347838090934224017518918679610925820512473461304677757075134011581671714199960857167419613229/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "80", + "129", + "133089956318041471374105631597109650328094905582923595943383854815129795/1684996666696914987166688442938726917102321526408785780068975640576" + ], + [ + "80", + "114", + "1178351937628952978670679360622693353860772282667814101009760085444718117254876955351446155555604836896936031692687306822277187918425360588660785388542254225707704969898407308537944241480197926884198760388093643627565578254436874589461527215843630227149987645940991897387/368196284262000338524928429628905566164609501884883399399821073555156585411025132741695746409537625667845184680712321553662601996000138564568657862608097692127260020844266769635388883980741729902004817528723614886987763530056453877124062305759108505553970399281152" + ], + [ + "64", + "114", + "1142454314644599122308918231481736317159587453040141969983275499137324256048655409068096826247889874966210273295589777659072966334923804191025730219489369874772881439593724386495065246440587725761833727209496306580147046288309002476241055248010201649149220043773105953957/161085874364625148104656187962646185197016657074636487237421719680381006117323495574491889054172711229682268297811640679727388373250060621998787814891042740305676259119366711715482636741574506832127107668816581513057146544399698571241777258769609971179862049685504" + ], + [ + "56", + "114", + "57963741383384256585992143223623855018269729084613945423554721990520499/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "48", + "114", + "412978143471918921715305758532809648982684265762855784348911820261592163283885283539192860881491417100879453652436874943329882094000254555380920368859503078189680500672019747611103142822302240599325717173796428566458989036458012754722378368278787584789954341257447937777/184098142131000169262464214814452783082304750942441699699910536777578292705512566370847873204768812833922592340356160776831300998000069282284328931304048846063630010422133384817694441990370864951002408764361807443493881765028226938562031152879554252776985199640576" + ], + [ + "48", + "98", + "238094829931218352191644675868982290792869822207242846870491481696765730025035876454887750921796979389672399319156339082709898594746020567456840661178675225348585687284830597175483376060706374762197594926839285964729628553598463434621351289722667120776663256050651407173/75805117348058893225720559041245263622125485682181876347021985731944002878740468505643241907845981755144596846029007378695241587411793233881782501125196583673259416056172570219050652584270356156295109491207803064968068962070446386466718710009228221731699788087296" + ], + [ + "40", + "98", + "41457017004425361759961029194795308199569171495703412921736976028380943/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "32", + "98", + "9265913805346139736356083984011293540620395881085455427610236993356963710195545840121487140112118523156566894920682828023467951714803751900034368278835515617498502409439937221472059781500437455089935986204978816398560221089453255908477960673747969783877859679234699313423/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "24", + "98", + "24923794972411634434086273844934478677359836232634199220016387248405479/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "16", + "98", + "89266471325422796890604211885870409488331326282021523645002888499864485963660778267091178243091884839873482920403893373218845344305278777446107153646644890779292002954745444085067104246638956089052686599062567288882628688650172578234220020052453702687276522512857911075/46024535532750042315616053703613195770576187735610424924977634194394573176378141592711968301192203208480648085089040194207825249500017320571082232826012211515907502605533346204423610497592716237750602191090451860873470441257056734640507788219888563194246299910144" + ], + [ + "14", + "98", + "1547058474074621827237618920807362867997469528561168269643934382674420164734609496457547611696857273878972444535181433877248291762292041624060373557160260228380797046250574322811457433567380014836771749518845288195884298269185227174198662257967141502652940643847343815855/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "12", + "98", + "958371064753306516030447486348022575018263835368679827783148817730609084981646018215978187309615035647591565670187253226377578686196471667579494954392519753161076453752878579351918429352003809985485686787209400864690837880961789281178597489482946170178956840958618098483/644343497458500592418624751850584740788066628298545948949686878721524024469293982297967556216690844918729073191246562718909553493000242487995151259564170961222705036477466846861930546966298027328508430675266326052228586177598794284967109035078439884719448198742016" + ], + [ + "12", + "82", + "51825466862587036778956599002007617012143063206435204951698707167082670269292225650099546160468337868091615284306748466054060732359035186390742416275725540438154618083218025279120541209000372208317860240604210542274992796105377455898171469681403697300349959683822406797/83141096446258140957241903464591579456524726232070445025766048867293422512166965457802265318282689666932783637580201641149619805548418385547761452846989801448090972448705399595087812511780390623033345893582751748674656280980489585157046327106895468996057832095744" + ], + [ + "10", + "82", + "21791106643288593723404079162639313662223034309237045294877222982151214034381747806894423560255509516734584620338196993842343969469463723434978538117033600960362169462116365600885464667373523324885034723998267953030270318127900034598270548669383580322595768619934027099055/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "10", + "66", + "12952749380936685491424700253053599083289043087546126857019464721480479316443943266287174161562793920712223288969147044730688609798972884155734917394000055868374787535141433601954233421047463173045716875216746177034694159762995948780463165399945614041677184669214089569619/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "8", + "66", + "368467849859411348711315685669761583622623324467751917305898885450209249964980291347274342826393429115782857826134533568606369989335016143767135609717488526636554664681321413423880294955450241284194378243371399875499072126830726419642603698866615800388396907198196592271/161085874364625148104656187962646185197016657074636487237421719680381006117323495574491889054172711229682268297811640679727388373250060621998787814891042740305676259119366711715482636741574506832127107668816581513057146544399698571241777258769609971179862049685504" + ], + [ + "8", + "65", + "16810066011092330448229716905350396401698305283292595727434028843767611/210624583337114373395836055367340864637790190801098222508621955072" + ], + [ + "8", + "57", + "58994737345064593391152348650050477851897776866611819272134602055438763/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "8", + "50", + "625846096865353312650841896213640970788005699502139090415220721310531870920394866509518978725870857731876662172357813979736298869884626469001796258143218004954279726769664943961399963613481861821213519518019833791608219903119041755848333813942593100614165996296592500941/117153363174272834985204500336469952870557568781553808899943068858458913539871633145085010221216517257950740580226647767074464271454589543271845683557121992949582733904993972156714644902963277696092441940957513827677924759563417142721292551832443615403536036134912" + ], + [ + "7", + "50", + "1404700527910107926370196193334180776792354420855320824785468145578295/421249166674228746791672110734681729275580381602196445017243910144" + ], + [ + "6", + "50", + "129305066680515097430560829525857420544356663890210730036176967301556522318538190560562795065339045421900352414994293126332452538636330257943627097455306988315564304955007832558362361195088738307054547530637004907929561305719209941884029033302410213262881991902815065569/644343497458500592418624751850584740788066628298545948949686878721524024469293982297967556216690844918729073191246562718909553493000242487995151259564170961222705036477466846861930546966298027328508430675266326052228586177598794284967109035078439884719448198742016" + ], + [ + "6", + "49", + "25372341438837351050286428570375001964132003686143073609707764564318365/421249166674228746791672110734681729275580381602196445017243910144" + ], + [ + "6", + "41", + "165974031509040917859835504084245172244101692925372819240273584348525/3291009114642412084309938365114701009965471731267159726697218048" + ], + [ + "6", + "34", + "9734836926092234286078292074663971107447350541169338226172686084862658849810585010123318251134039694626243660267918936592484452213361132347582681521816260486298963821916148719813554512436389234880504648816854525786943799003573613449298443703287174408468050228185151495985/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "6", + "33", + "17113849326588995605684189411720058888034188449042108987609688681992179/421249166674228746791672110734681729275580381602196445017243910144" + ], + [ + "6", + "25", + "12979077518721843189637040472722662114234543737508525279011649319767023/421249166674228746791672110734681729275580381602196445017243910144" + ], + [ + "6", + "18", + "21239322433393303326455519318264340685551616811277145589980541447278998659941668010566128639582490640150108972761219072490121812132210253939294062689494771586938851842783667905268757995788062898655019818079154625185952757041352846092492124124704528659049152842777187254663/2577373989834002369674499007402338963152266513194183795798747514886096097877175929191870224866763379674916292764986250875638213972000969951980605038256683844890820145909867387447722187865192109314033722701065304208914344710395177139868436140313759538877792794968064" + ], + [ + "5", + "18", + "63093559444228162889436632519347593135210039587024163040207656511419963/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "4", + "18", + "200513344456927937289479405929426964829104294459830825876406954259130641324918994342070681500142425201787517425056463393440593612628662088180332554318160991624603957015820066035172209316637776444136445321712025183220962993560430787382582313577983651956869175455716979701/14644170396784104373150562542058744108819696097694226112492883607307364192483954143135626277652064657243842572528330970884308033931823692908980710444640249118697841738124246519589330612870409712011555242619689228459740594945427142840161568979055451925442004516864" + ], + [ + "3", + "18", + "3624038109310790410909415658229224760120551848006016606859401464736975/52656145834278593348959013841835216159447547700274555627155488768" + ], + [ + "2", + "18", + "100412181406800639589082866292474334039169739611848448476585641915031924129999307922105151108602017576073831309486341709658981571029756954965727908515759982014012826934814869176232515463681370431107226363136011914912262615749176727422252982704613045874328324628250736541547/5154747979668004739348998014804677926304533026388367591597495029772192195754351858383740449733526759349832585529972501751276427944001939903961210076513367689781640291819734774895444375730384218628067445402130608417828689420790354279736872280627519077755585589936128" + ], + [ + "2", + "17", + "4419526087202372796775337999219863630356761777104391808919302763313283/210624583337114373395836055367340864637790190801098222508621955072" + ], + [ + "2", + "16", + "1060288001157495061065660040454179813400908035409726185755652686009232217866544765579441253477377816195478056905592056546326087270900234072008429640710112817692623621001721012039807253418384396855061525144224849307136576085588442974761658219447195725905591394036642854465/468613452697091339940818001345879811482230275126215235599772275433835654159486532580340040884866069031802962320906591068297857085818358173087382734228487971798330935619975888626858579611853110784369767763830055310711699038253668570885170207329774461614144144539648" + ], + [ + "2", + "14", + "154705847407462182723761892080736286798547132823626391033935553918519112775260862349092775718676039381665833882722078161078279888586362795744672399086475670067685876803522729258041362975838771201701892020835836478907694412500488989070039872661378561669586462720457275041/184098142131000169262464214814452783082304750942441699699910536777578292705512566370847873204768812833922592340356160776831300998000069282284328931304048846063630010422133384817694441990370864951002408764361807443493881765028226938562031152879554252776985199640576" + ], + [ + "2", + "12", + "16585590645589707939845867422116848864054159291868427953093635907046996955693265027598530331244010643475930575479295629793958346138783038824677519596630746293867934492954592469141525805985438448802908293007512818759927444331842208272566429835765061061883001202543499293/322171748729250296209312375925292370394033314149272974474843439360762012234646991148983778108345422459364536595623281359454776746500121243997575629782085480611352518238733423430965273483149013664254215337633163026114293088799397142483554517539219942359724099371008" + ], + [ + "2", + "10", + "20746729313828789340064955861281595986431315593382751563645907778518348486954785535529219910778277194916209307689617860920382325770567366064646156625692101520454561233922592573927633172216069369958749412286216562092672561471200966224669523669096433179669925808701739269/14644170396784104373150562542058744108819696097694226112492883607307364192483954143135626277652064657243842572528330970884308033931823692908980710444640249118697841738124246519589330612870409712011555242619689228459740594945427142840161568979055451925442004516864" + ], + [ + "2", + "9", + "389001678717087507774229250190248967967980006191654535312266964520314771/1684996666696914987166688442938726917102321526408785780068975640576" + ], + [ + "2", + "8", + "42768266318210467603041192086509963326971686161456743426692406277374896856099586607326479117289451999434404201864951769571473091409155229623260507989273310225818084241805192332116623201645881526621555921879973124948831934478582659878684614611634105446726449929286457538745/5154747979668004739348998014804677926304533026388367591597495029772192195754351858383740449733526759349832585529972501751276427944001939903961210076513367689781640291819734774895444375730384218628067445402130608417828689420790354279736872280627519077755585589936128" + ], + [ + "2", + "7", + "983290369537075548459137335333926543749025132918799784855231135169441/210624583337114373395836055367340864637790190801098222508621955072" + ], + [ + "2", + "6", + "41622242356513639965407776726716663263780721202205297692945661025263202290233089408699241906977026071384666677584357377890813729107987180024376792029438512041996611961732113771347358026201456994550748749840873777963614393590704938005721629273829210922091216110901081881/161085874364625148104656187962646185197016657074636487237421719680381006117323495574491889054172711229682268297811640679727388373250060621998787814891042740305676259119366711715482636741574506832127107668816581513057146544399698571241777258769609971179862049685504" + ], + [ + "2", + "5", + "6630851788724615845068181124644810743477973345134535170780148845681699/842498333348457493583344221469363458551160763204392890034487820288" + ], + [ + "2", + "4", + "1036760228224338024563091385608672646354279920561902534747830976375178783006781593317979494065920759842170804921072242127875264789328710613095534063912161377177209775645111287806736684349119659456367034603110306110425099180473552417830887796451456435585177097163753628579/5154747979668004739348998014804677926304533026388367591597495029772192195754351858383740449733526759349832585529972501751276427944001939903961210076513367689781640291819734774895444375730384218628067445402130608417828689420790354279736872280627519077755585589936128" + ], + [ + "2", + "3", + "6545180065592101692878178487714270527553407972632524819564660753538727052037371010812480097345748547364415250201205075684170181713593365858978184553580982791484289052257177258692305544649644305071821/4564772607577841547989096023937067347106573764169243689256941462952374794814340095911535745749079616864961925870785513590443699953914237937802336892256269241922998285442342826365780804881491165184" + ], + [ + "1", + "3", + "7678505207782084209882596438797287802887043711160326535826229646315438641056864266133685783085259302288007787344464550924956612533334572756985143776743066558721226863867674930066667736119/4564772607577841547989096023937067347106573764169243689256941462952374794814340095911535745749079616864961925870785513590443699953914237937802336892256269241922998285442342826365780804881491165184" + ], + [ + "1", + "2", + "612092857852657355063340353781979411525478483848478380173626709891664061374506904300604431501372785544058964870684212299502115287181067258751555965534647516520861342012312361110241491497952452998477400694206583011952068784752209705241579448556274554169972276095159526632473548732271585051989188816339647785244408925313014211634085763/3357489275998327172996526252292118246085269258398618982735342237915507278229653691936722582028170552306559050087491105701389346669144082504441200960020791167393971657169701864325534127779115587434242292925434953020935122621075893577630423035642972862235846005853944522329979005570948857597362555813292708154795262536619539824640" + ], + [ + "1/2", + "2", + "23035515623346252629647789316391863408661131133480979607478688938946315923170592798401057349255777906864023362033393652774869837600003718270955431330229199676163680591603024790200003208357/4957406403233501402105784599806223983089992757537469662979452874372420979954576253558258231005642772080730018224417470242199779037865298951391824605788499696326792293274191012787898489421506113699840" + ], + [ + "1/2", + "1", + "1846753218029285417931766959454209695703344284181478459678984030172726275864101704470114393677910551617708957753821746107801653701612749615636428539022665633576790344860661765396320006383167966452049894235/1832096446457624445404050181349665005308664286283077250337415836958041550935308177992490393698912053590045939493650449376810531483141272212803835455383317365607362772906608572976191069430746782392909824" + ] + ], + "unused_directed_capacity": [ + [ + "1", + "23035515623346252629647789316391863408661131133480979607478688938946315923170592798401057349255777906864023362033393652774869837600003718270955431330229199676163680591603024790200003208357/1832096446457624445404050181349665005308664286283077250337415836958041550935308177992490393698912053590045939493650449376810531483141272212803835455383317365607362772906608572976191069430746782392909824" + ] + ] + }, + "relaxed_upper_rate": "3898466621505769639/1000000000000000000000", + "relaxed_upper": { + "rows": [ + [ + "405155367506637045530711499587087141961098120396707703381104275264", + "808124060071705076315802835151195055729793962739534876126597830192", + "-13372608045633657107300453999218678563187752781147715745951055876126944", + "-26673042428366668343875043716155668941922083514933552413822607807307984" + ], + [ + "-27175221085120338275978820496216200631884280479800500353249058026934464", + "808124060071705076315802835151195055729793962739534876126597830192", + "4942081743448718082039999869631742538045772218384757422656065002004283392", + "-26673042428366668343875043716155668941922083514933552413822607807307984" + ], + [ + "4891675987144896087450424525893859418151115663365640450275878407209120528", + "-54203774052910459693315571761054327084746244131109028527978125861369408", + "0", + "9857490444469069495736124695547329407149622353254581292898307396201258800" + ], + [ + "0", + "0", + "0", + "1" + ] + ], + "positive_multipliers": [ + "1", + "36474993578253625259940576719523758846086870420779097238454263431/13479973333575319897333507543509815336818572211270286240551805124608", + "75853938193671889148637997085541518837341437435575908659978392049883284054639550192398254392782374303054103867336153657518021929677/5074065477863714148790794107270752625955871019881079214534294006545244564031216996604132385535371701217535225081612382601230371631661056", + "8434953012236569609263775202075626521757764723657317740736705037038905375642150125002483850290470262583020746198114166318512290671361479945010749608613577749673639344008787810582115720277076860805219907477/317129092366482134299424631704422039122241938742567450908393375409077785251951062287758274095960731326095951567600773912576898226978816" + ], + "weighted_result": [ + "-1143022743479498334237449090563791433122299114905870107641446172120981831518123110982058050695169397470271900604634273619917700863310984983313764765642858220927301574225079670547993877226003/317129092366482134299424631704422039122241938742567450908393375409077785251951062287758274095960731326095951567600773912576898226978816", + "0", + "0", + "0" + ], + "constant_divided_by_unit": "-1143022743479498334237449090563791433122299114905870107641446172120981831518123110982058050695169397470271900604634273619917700863310984983313764765642858220927301574225079670547993877226003/8549783416802247420477843209894166718040276810964434231275960150404243248520587424830210240299857102307737087495597594396807280969532838206954341511536678453726788543893963560683355521624039660512608256" + }, + "arbitrary_scale_subdivision_corollary": { + "rate": "39/10000", + "base_unsplit_directed_upper": "-1296893530822375418205537767619931935588477499111386592293634993215/842498333348457493583344221469363458551160763204392890034487820288", + "strict_decimal_upper": "-1.53934254762", + "scope": "finite positive scale mixtures and finite positive rank-preserving paid subdivisions, fixed targets; compatibility relaxed" + }, + "controls": { + "source_installed_trial": "17145637307/4398046511104", + "baseline_minimum_cut_margin": "118704348015579931096206508667677937581305988010284143666165897/421249166674228746791672110734681729275580381602196445017243910144", + "neighbor_counts_fail": [ + 1005, + 1007 + ], + "mutated_duals_rejected": 3, + "altered_source_rejected": true, + "excess_split_rejected": true, + "forbidden_transfer_rejected": true, + "independent_power_enclosures_checked": true + } +} diff --git a/research/p104-two-type-threshold/LICENSE b/research/p104-two-type-threshold/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/p104-two-type-threshold/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/p104-two-type-threshold/NOTICE.md b/research/p104-two-type-threshold/NOTICE.md new file mode 100644 index 0000000000..9b35affe70 --- /dev/null +++ b/research/p104-two-type-threshold/NOTICE.md @@ -0,0 +1,5 @@ +# Attribution and provenance + +ToikY supplied #8072, its capped allocation, peer source archive and stage materialization. Ali Romman supplied the predecessor #8057 signed frequency-weighted Gaussian producer, native widths, signed caller and compiler. The #8072 notice at `source/upstream/NOTICE.md` and the source notice at `source/canonical/inputs/complex-source/PARENT-NOTICE` preserve credits to SYLforge, Clear1nsight, DreamingOfClouds, Jerry Chen, and other contributors. The curated source files retain their Apache-2.0 license. + +The present exact two-type raw-flow bound and certificate were developed locally with OpenAI Codex assistance. This is an independent, scoped mathematical analysis; it does not assert a source implementation, a new signed κ, or upstream acceptance. diff --git a/research/p104-two-type-threshold/PUBLIC-FILES.json b/research/p104-two-type-threshold/PUBLIC-FILES.json new file mode 100644 index 0000000000..d0c66a00db --- /dev/null +++ b/research/p104-two-type-threshold/PUBLIC-FILES.json @@ -0,0 +1,49 @@ +{ + "schema_version": 1, + "algorithm": "sha256", + "files": { + "CERTIFICATE.json": "6c283a4550600405ab681a302a677f9d1b65cddd704323bd6aeae207f11d9668", + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.md": "91675c36903269f4ed90a6de9e084d93f6dc5b055b6a3a91714073c58907f6a2", + "README.md": "db82159f44f1146e54fe207abbdf8ab713453d2d4206bcd31402f7ab8f1feaf6", + "SOURCES.json": "300e9f2dc3855d6da3251e840ccf249547550e9951e95f4957a8fe169aa77e30", + "TASK.json": "5031dfe314683cfbbfb47f4c1e200225deecb98a7656e339d501d58d73ee5cb7", + "VERIFY.json": "4c63cecc6a946cfb47b0271e35011a5f42b02bfb4e5cd73ec846def321207f47", + "census.json": "6562bc89ec694b521739898c62aa6b336c79ebd154127a4549ca409628044c56", + "directed.py": "a6e7b3ce7f8ee4bf502a7023066eb13d6409daea8fe93e1542a7038894da62c9", + "model.py": "0f1abe94c6d5b152ab378652d64f8220965fa5792b05adc1dffccb1374aa4bf7", + "series_control.py": "9004a118c698c405ac9c2d152ad932e2d6a054d8c4bef2b9ff97a5d5ac8259df", + "source/SOURCE-RECEIPT.json": "6ed3459e228af5b93a766ab82033513ecd6e662498d9749cab810fa48b20d58f", + "source/canonical/inputs/complex-source/BANK-FACTORS.json.gz": "b009cd6bb13036879214cb6d43beb923578ef7fb4c83f36a1cc971ab4ea23543", + "source/canonical/inputs/complex-source/BIDIRECTIONAL-QUOTIENT-RECEIPT.json": "459f519593242a3e8ecf42817f178fb214a6833e0df0e1ce727c5809035d02de", + "source/canonical/inputs/complex-source/BIDIRECTIONAL-QUOTIENT.json.gz": "ed725d5c69a507352efc6a18f3e4f7e5c20592a655a7b80193034232feb43d6f", + "source/canonical/inputs/complex-source/BIDIRECTIONAL.json.gz": "baf07c7085f588ce06201e2a6bf4f5f58632801202783ca195d3b8369ff74836", + "source/canonical/inputs/complex-source/HELPER-SPLITS-RECEIPT.json": "712b783baf1463b738bd5c5ad3023bf42681d7d0105dd550ba3549c02674f711", + "source/canonical/inputs/complex-source/HELPER-SPLITS.json": "f70ba89a9ed5839476bbe298d4cb8f4d9eeb703621d5f478c884861cdd91fb20", + "source/canonical/inputs/complex-source/LAYOUT.json.gz": "84cd1d11ff454eecf3504e4b3f26adc371539b17553bfce1bcfda7a331811998", + "source/canonical/inputs/complex-source/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "source/canonical/inputs/complex-source/PARENT-NOTICE": "b213998c8dae6d88e4a1f0fd17c81dd78c31ef35bc9460fa16ca692326f1a02b", + "source/canonical/inputs/complex-source/WORD.json.gz": "731246c085638706bdb97e7e88618f8923e27ee4ce8eb4869f0847f8f4699f7c", + "source/canonical/inputs/complex-source/replay.py": "9c847a1242e730acf1dfd3a83f4801470e3e2da6c3079f53ccb7ada620b37a7b", + "source/canonical/inputs/complex-source/verify_bidirectional.py": "ef85db5c6f348b55e0db4d61517dde6a58b027737037e14b9fdea04f8b96e716", + "source/canonical/inputs/complex-source/verify_component.py": "163b1ca3a35531da94ef454229f040592c754675f59dfb805d0a9aadb33b8d65", + "source/canonical/inputs/complex-source/verify_split_helpers.py": "6a0b59657bd1902d19b9c0f8badef2caa13c8ba84e0311550d6391360bdf186b", + "source/canonical/inputs/complex-source.json": "b33575085bcaf8e646ad7656d1f8d2c7ad402712e6b49efd307fc926f2fb39b0", + "source/canonical/periodic.py": "6233e1806d29bd386ce39fab398fee4f6b73b11d4bdc1e3608bcccde15d71b19", + "source/canonical/powered.py": "2cd55d3cd17e5f4ad10fcc1d534393d0ca9c709dd1b08f9e43d223ea15ba19f7", + "source/canonical/sparse_helpers.py": "823144823a54b0e79ee9891ed0bc7ba6fb7ecd846fbc1d0d287f19b3a046ecbd", + "source/canonical/strong_complex.py": "b0f18924be837173ccbbd1b7814a7a9a27228d68ff0dcbaf44a90a2065d0574c", + "source/canonical/tagged_sources.py": "6c42f7115c2ea44507e1d959c3886a46c6b4abc22a8bbe49a4f9c5003d5e4a6b", + "source/canonical/vendor/CALLER.json.gz": "d889996a337f648087208ab51c98eaf052705d4fca88b5d01b6e9257a829897a", + "source/canonical/vendor/CONJUGATE-CALLER.json.gz": "80009663da460229a57f09bde90e35294329a210ae7fc7ef6d1f05b61ffccbf4", + "source/canonical/vendor/closed_caller.py": "b82b9710d85d62e0f98aa1a1d7c70f97bdbdd64a6e4c92406019ca580a8c52ce", + "source/canonical/vendor/mixed_caller.py": "4824b2aaadb592550d3a25c16ff0a453705e10b8868f5c22fe10c2874bcb9bae", + "source/upstream/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "source/upstream/NOTICE.md": "4bb4aa63290a19282826ff57529293f8bfd12e3a2afe28bc6d48205c0cc976fc", + "source/upstream/PEER-SOURCE.json": "798c2e6394c258986484a116198cc542a6d2b4c1f289e5816de2cfecf5141c51", + "source/upstream/prepare.py": "76f9d4c6bfd880ee49f6ba5bde9138cf0856d669edb4d525e48ca71a9094eec3", + "source/upstream/verify.py": "10362de3ceaa651cde5b71c6599fd4683d9f1f4d76cc252178e915b43a098fee", + "verify.py": "25fc37ed9e536b4de05c18dc0e9a9a6ce78d690248fdae76e30d880d4c0c1577" + }, + "self_note": "The manifest excludes itself; its SHA-256 is supplied with the portable archive." +} diff --git a/research/p104-two-type-threshold/README.md b/research/p104-two-type-threshold/README.md new file mode 100644 index 0000000000..64df519271 --- /dev/null +++ b/research/p104-two-type-threshold/README.md @@ -0,0 +1,69 @@ +# Two-type raw price threshold with paid half-splits + +This is an aggregate price/stock result for the literal Gaussian 48-call word in [PR #8072](https://github.com/CrocSwap/integer-mult-bounds/pull/8072), head `75f7e1c44f48c43983016bcf8878c4d9e5e87c62`. It is **not a native signed multiplier, a new qualified κ, an ownership proof, or a complete economic invoice**. Source reconstruction, conclusions, and the remaining open boundary are distinct. + +## Model and result + +Rebuilding the staged canonical word gives 52,608 productive target ports, 281,568 paid ports, and 183,312 rank-one paid ports in the unscaled type. Type 0 has those ranks; type 1 scales every target and paid rank by 2. A type-0 rank-one paid port may be replaced by two rank-1/2 paid ports, and a type-1 rank-two paid port by two rank-one ports. A type has a fixed **integer** split count in `0..183312`. Its occurrence frequency is any nonnegative real number; frequencies are not both zero. + +At rate `c`, a rank `r` paid port demands `r^(1-c)` and a rank `k` target supplies `k^(1-c)`, multiplied by its type frequency. Fractional flow is permitted exactly where `5r <= 4k`. Let `c_int` be the supremum of rates `0 <= c <= 1` for which that aggregate flow exists. The following are certified strict bounds: + +```text +0.003898466610885757242 < c_int < 0.003898466610885757243 +``` + +The feasible lower witness has 1,006 type-0 splits, no type-1 splits, and `frequency_1/frequency_0` approximately `90.24604144478511564111`. The exact rational frequency and 51-edge rational flow are in `CERTIFICATE.json`. The flow uses lower target-price and upper paid-price bounds, hence funds the true prices strictly. + +If split counts are instead permitted to be arbitrary reals, the corresponding relaxation has a **different** limit: + +```text +0.003898466621505769638 < c_relaxed < 0.003898466621505769639 +``` + +Its lower witness uses approximately 1,005.279848031309 splits of type 0. That is not a fixed whole-count type installation; it is included to separate the linear-program relaxation from the integer claim. Both upper proofs allow arbitrary nonnegative real frequencies and type-1 split counts, so they do not depend on a numerical optimizer or a restricted search grid. + +The original source's installed raw trial `17145637307/2^42`, type frequencies `5:451`, and 1,008 type-0 splits provide a strict positive comparison control. The new bracket is a **raw** ceiling for this fixed two-scale and split model only; it does not price ordinary work, finite losses, timing, activation, storage, owner returns, or the complete signed caller. + +## A broader raw obstruction at 0.0039 + +For the same unsplit base word at `c = 0.0039`, directed arithmetic gives total productive capacity minus paid demand strictly below `-1.53934254762`. Scaling every rank by a positive factor `s` multiplies both totals by `s^(1-c)`. Thus any finite mixture of such copies with nonnegative frequencies, at least one of which is positive, has a negative total margin. + +The conclusion remains true if any paid rank `r` is subdivided into finitely many positive ranks whose sum is `r`: since `0 < 1-c < 1`, their powered costs sum to at least `r^(1-c)`, strictly more for a subdivision into two or more positive parts. This gives a raw total-price obstruction for **arbitrary finite positive scales and paid subdivisions**, with the productive word and its scaled ranks fixed. It already holds when all rank-compatibility requirements are relaxed. Changing productive ranks, changing the source word, or allowing other financial credits is outside this corollary. The narrower two-type integer bracket above gives the sharper bound near the crossing. + +## Exact proof + +For each paid-rank cutoff `h`, the necessary Hall inequality is + +```text +sum(k^(1-c) for targets with 4k >= 5h) + - sum(r^(1-c) for paid ports with r >= h) >= 0. +``` + +The verifier reconstructs each complete histogram from a curated scientific-source snapshot materialized from the authenticated stage, then rounds the prices outward with integer square roots and products. It brackets the exponent on a `2^-128` grid and values on a `2^-224` grid. A separately written rational atanh/log and exponential-series routine checks overlapping enclosures at representative ranks. All claimed signs and multipliers are exact rational arithmetic; SciPy, floating-point fitting, and the exploratory root digits are not used in the proof. + +For upper certificates let `w0,w1` be the nonnegative frequencies, `u=w0*n0/183312`, and `v=w1*n1/183312`. Each stored row is an optimistic directed upper bound of a necessary Hall margin in the coefficient order `(w0,w1,u,v)`, multiplied by `2^224`. A feasible actual margin must make every row nonnegative. The positive combinations in `CERTIFICATE.json` cancel the last three coefficients exactly and leave a negative coefficient on `w0`: + +* At the integer upper endpoint, the `n0 <= 1005` proof combines cutoff 1, cutoff 2, `1005*w0 - 183312*u >= 0`, and `v >= 0`. The other proof combines the total, cutoff 2, `183312*u - 1006*w0 >= 0`, and `v >= 0`. The two cases exhaust integer `n0`. Their resulting constants, after division by `2^224`, are approximately `-0.2778994044` and `-9.01258718e-14` respectively. +* At the fractional upper endpoint, one combination of the total, cutoff 1, cutoff 2, and `v >= 0` has constant approximately `-1.33690257e-13` in the same units. The exact positive multipliers and coefficients, including the zero cancellations, are saved rather than rounded. + +If `w0 > 0`, a positive combination of nonnegative rows cannot be negative. If `w0 = 0`, the same strict-positive multipliers force `v = 0`; cutoff 2 then has a strictly negative coefficient on `w1`, forcing `w1 = 0`, contrary to the nonzero-frequency requirement. Thus the proofs also cover the pure type-1 endpoint. + +The upper is global in the stated rate domain: if a feasible flow exists at `c2` and `c1 < c2`, let `delta=c2-c1` and multiply every old flow out of rank `r` by `r^delta`. This exactly funds each new paid demand. Since every allowed edge satisfies `r < k`, the load arriving at a target of rank `k` grows by at most `k^delta`, the same factor as that target's new capacity. Therefore feasibility is downward closed, so the certified separator at either upper endpoint also excludes every higher rate in the model. + +## Replay and controls + +From this directory run: + +```sh +python3.12 -I -B verify.py +``` + +Python 3.12 is required; no network, Git, SciPy, or third-party Python package is used by the standalone checker. It checks the minimal #8072 source receipt and the public-file allowlist, reconstructs the canonical graph, labelled word and census from the curated source files, recomputes every exact row and flow, verifies the saved certificate, then runs the controls. It rejects changed dual multipliers, a mutated source census, one extra unavailable split, the neighboring split counts at the lower witness ratio, and a forbidden transfer. It also checks the old source trial and the independent enclosure method. `VERIFY.json` registers the command for the repository's generic research replay; standalone operation does not require the research runner or the original checkout. + +`source/SOURCE-RECEIPT.json` records the public #8072 repository, head, scientific file blob IDs, predecessor archive digest, and the exact curated source-file hashes. The private evidence run authenticated and restored the complete original archive before making this snapshot. The public replay checks the snapshot and reconstructs the graph and word, but does **not** itself restore that omitted complete archive or check the current hosted head and CI. `PUBLIC-FILES.json` gives the exact SHA-256 allowlist of every public file other than the allowlist itself. + +## Open next questions + +* Can the integer-count lower witness be realized with actual native labels, chronology, source windows, return ownership and finite precision? The aggregate flow leaves all of these obligations open. +* After a valid implementation exists, can its ordinary and numerical complete invoices support an improvement in signed κ? The raw bracket alone does not answer that question. +* Do additional scale types, different paid subdivisions, productive changes, or a changed word improve the limit? These possibilities are outside this fixed two-type result. diff --git a/research/p104-two-type-threshold/SOURCES.json b/research/p104-two-type-threshold/SOURCES.json new file mode 100644 index 0000000000..488b0c4089 --- /dev/null +++ b/research/p104-two-type-threshold/SOURCES.json @@ -0,0 +1,19 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81", + "usage": "provenance" + } + ], + "staged_peer": { + "pull_request": 8072, + "head": "75f7e1c44f48c43983016bcf8878c4d9e5e87c62", + "source_receipt": "source/SOURCE-RECEIPT.json", + "source_receipt_sha256": "6ed3459e228af5b93a766ab82033513ecd6e662498d9749cab810fa48b20d58f", + "verification": "The curated source snapshot is checked and rebuilds the canonical word. The full original peer archive was authenticated in the private source run and is intentionally not included or re-restored by the public package." + } +} diff --git a/research/p104-two-type-threshold/TASK.json b/research/p104-two-type-threshold/TASK.json new file mode 100644 index 0000000000..cd5619ef21 --- /dev/null +++ b/research/p104-two-type-threshold/TASK.json @@ -0,0 +1,87 @@ +{ + "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" + } + ] + }, + "scope_status": "changed", + "scope_change_reason": "This follows the source task into the fixed #8072 two-type paid-half-split raw Hall model, without claiming a signed implementation or changing the selected result.", + "actual_scope": "Prove directed lower and global upper brackets for aggregate price/stock flow on two homothetic copies of the staged #8072 Gaussian word with arbitrary nonnegative frequencies and fixed integer rank-one half-split counts per type; separately bound real-count relaxation and the fixed-productive-word total obstruction for arbitrary finite positive scales and paid subdivisions at 0.0039.", + "bottleneck_link": "A raw feasibility or obstruction screen identifies what this fixed two-type price model can fund before physical ownership and complete caller costs are charged.", + "stop_rule": "Check the rebuilt canonical source census, strict rational lower flows, exhaustive whole-count upper cases, positive Farkas combinations and downward closure; preserve every physical and signed-price admission gap.", + "evidence": "README.md, CERTIFICATE.json, census.json, directed.py, model.py, series_control.py, verify.py, PUBLIC-FILES.json, and source/SOURCE-RECEIPT.json.", + "author": "OpenAI Codex on behalf of the research campaign", + "ai_assistance": "Substantial OpenAI Codex assistance in exact arithmetic, implementation and adversarial checks.", + "outcome": "completed", + "open_questions": [ + { + "question": "Can the 1006-split raw flow be installed with legal native ownership and chronology?", + "why_it_matters": "Aggregate price and stock do not imply a physical provider.", + "first_step": "Construct and independently replay the complete labelled owner and return schedule at the exact frequencies.", + "blocked_by": "No native installation is produced by this package." + }, + { + "question": "Can any valid installation improve the complete signed kappa?", + "why_it_matters": "Ordinary costs, finite loss, activation and caller returns can consume the raw margin.", + "first_step": "Price and independently validate the whole signed caller and its ordinary and numerical invoices.", + "blocked_by": "The raw flow alone supplies none of the required full-budget gates." + } + ] +} diff --git a/research/p104-two-type-threshold/VERIFY.json b/research/p104-two-type-threshold/VERIFY.json new file mode 100644 index 0000000000..dc79d2c365 --- /dev/null +++ b/research/p104-two-type-threshold/VERIFY.json @@ -0,0 +1,63 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/p104-two-type-threshold/CERTIFICATE.json", + "research/p104-two-type-threshold/LICENSE", + "research/p104-two-type-threshold/NOTICE.md", + "research/p104-two-type-threshold/PUBLIC-FILES.json", + "research/p104-two-type-threshold/README.md", + "research/p104-two-type-threshold/SOURCES.json", + "research/p104-two-type-threshold/TASK.json", + "research/p104-two-type-threshold/VERIFY.json", + "research/p104-two-type-threshold/census.json", + "research/p104-two-type-threshold/directed.py", + "research/p104-two-type-threshold/model.py", + "research/p104-two-type-threshold/series_control.py", + "research/p104-two-type-threshold/source/SOURCE-RECEIPT.json", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source.json", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/BANK-FACTORS.json.gz", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/BIDIRECTIONAL-QUOTIENT-RECEIPT.json", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/BIDIRECTIONAL-QUOTIENT.json.gz", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/BIDIRECTIONAL.json.gz", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/HELPER-SPLITS-RECEIPT.json", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/HELPER-SPLITS.json", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/LAYOUT.json.gz", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/LICENSE", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/PARENT-NOTICE", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/WORD.json.gz", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/replay.py", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_bidirectional.py", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_component.py", + "research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_split_helpers.py", + "research/p104-two-type-threshold/source/canonical/periodic.py", + "research/p104-two-type-threshold/source/canonical/powered.py", + "research/p104-two-type-threshold/source/canonical/sparse_helpers.py", + "research/p104-two-type-threshold/source/canonical/strong_complex.py", + "research/p104-two-type-threshold/source/canonical/tagged_sources.py", + "research/p104-two-type-threshold/source/canonical/vendor/CALLER.json.gz", + "research/p104-two-type-threshold/source/canonical/vendor/CONJUGATE-CALLER.json.gz", + "research/p104-two-type-threshold/source/canonical/vendor/closed_caller.py", + "research/p104-two-type-threshold/source/canonical/vendor/mixed_caller.py", + "research/p104-two-type-threshold/source/upstream/LICENSE", + "research/p104-two-type-threshold/source/upstream/NOTICE.md", + "research/p104-two-type-threshold/source/upstream/PEER-SOURCE.json", + "research/p104-two-type-threshold/source/upstream/prepare.py", + "research/p104-two-type-threshold/source/upstream/verify.py", + "research/p104-two-type-threshold/verify.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Check the public-file allowlist and curated source receipt, rebuild the canonical word, verify exact two-type Hall witnesses and global Farkas separators, check the arbitrary-scale paid-subdivision obstruction at 0.0039, and run controls." + } + ] +} diff --git a/research/p104-two-type-threshold/census.json b/research/p104-two-type-threshold/census.json new file mode 100644 index 0000000000..6eae76a8d3 --- /dev/null +++ b/research/p104-two-type-threshold/census.json @@ -0,0 +1,72 @@ +{ + "targets_type0": { + "1": 1008, + "2": 432, + "3": 480, + "4": 11568, + "5": 1584, + "6": 48, + "7": 672, + "8": 1584, + "9": 25872, + "17": 1248, + "25": 1248, + "33": 1248, + "41": 1248, + "49": 1248, + "57": 1248, + "65": 1248, + "129": 624 + }, + "targets_type1": { + "2": 1008, + "4": 432, + "6": 480, + "8": 11568, + "10": 1584, + "12": 48, + "14": 672, + "16": 1584, + "18": 25872, + "34": 1248, + "50": 1248, + "66": 1248, + "82": 1248, + "98": 1248, + "114": 1248, + "130": 1248, + "258": 624 + }, + "paid_unsplit_type0": { + "1": 183312, + "2": 38016, + "3": 23040, + "4": 10848, + "5": 15072, + "6": 1968, + "7": 480, + "8": 1344, + "16": 1248, + "24": 1248, + "32": 1248, + "40": 1248, + "48": 1248, + "56": 1248 + }, + "paid_unsplit_type1": { + "2": 183312, + "4": 38016, + "6": 23040, + "8": 10848, + "10": 15072, + "12": 1968, + "14": 480, + "16": 1344, + "32": 1248, + "48": 1248, + "64": 1248, + "80": 1248, + "96": 1248, + "112": 1248 + } +} diff --git a/research/p104-two-type-threshold/directed.py b/research/p104-two-type-threshold/directed.py new file mode 100644 index 0000000000..8a15ae9f63 --- /dev/null +++ b/research/p104-two-type-threshold/directed.py @@ -0,0 +1,54 @@ +"""Integer-only outward bounds for rank^(1-c), including rank 1/2. + +The exponent is bracketed on a 2^-128 grid. Each square root, product, +and reciprocal is rounded outward on a 2^-224 grid. +""" +from fractions import Fraction as Q +from functools import cache +from math import isqrt + +BITS = 224 +UNIT = 1 << BITS +EXP_GRID = 1 << 128 + + +def ceildiv(a, b): + return -(-a // b) + + +@cache +def dyadic_power(rank, numerator): + if rank < 1 or numerator < 0: + raise ValueError('positive integer rank and nonnegative exponent required') + whole, rem = divmod(numerator, EXP_GRID) + low = high = (rank ** whole) * UNIT + root_low = root_high = rank * UNIT + step = EXP_GRID + while step > 1: + step //= 2 + root_low = isqrt(root_low * UNIT) + root_high = 1 + isqrt(root_high * UNIT - 1) + if rem & step: + low = low * root_low // UNIT + high = ceildiv(high * root_high, UNIT) + assert low <= high + return low, high + + +@cache +def power(rank, c): + rank, c = Q(rank), Q(c) + exponent = 1 - c + if not 0 <= exponent <= 1 or rank <= 0: + raise ValueError('rate or rank outside the stated proof domain') + lo = (exponent * EXP_GRID).__floor__() + hi = (exponent * EXP_GRID).__ceil__() + if rank == Q(1, 2): + _, hi2 = dyadic_power(2, hi) + lo2, _ = dyadic_power(2, lo) + return UNIT * UNIT // hi2, ceildiv(UNIT * UNIT, lo2) + if rank.denominator != 1: + raise ValueError('only integer ranks and 1/2 occur in the source') + low, _ = dyadic_power(rank.numerator, lo) + _, high = dyadic_power(rank.numerator, hi) + return low, high diff --git a/research/p104-two-type-threshold/model.py b/research/p104-two-type-threshold/model.py new file mode 100644 index 0000000000..62f11119dd --- /dev/null +++ b/research/p104-two-type-threshold/model.py @@ -0,0 +1,177 @@ +"""Exact directed Hall witnesses and positive separating combinations.""" +from collections import Counter +from fractions import Fraction as Q +import hashlib +import json + +from directed import UNIT, power + +P = 183312 + + +def qstr(x): + return str(Q(x)) + + +def cut_ok(rank, cut, target): + return cut is None or (4 * rank >= 5 * cut if target else rank >= cut) + + +def scales(t0, p0): + return (t0, Counter({2*r:n for r,n in t0.items()})), (p0, Counter({2*r:n for r,n in p0.items()})) + + +def split_paid(p0, n0, n1): + p = [Counter(p0), Counter({2*r:n for r,n in p0.items()})] + if not (0 <= n0 <= P and 0 <= n1 <= P): + raise ValueError('split count exceeds actual rank-one port inventory') + p[0][Q(1)] -= n0 + p[0][Q(1, 2)] += 2*n0 + p[1][Q(2)] -= n1 + p[1][Q(1)] += 2*n1 + return p + + +def margin(target, paid, cut, c, lower): + # Conservative lower capacity minus upper demand, or optimistic upper. + return (sum(n*power(r,c)[0 if lower else 1] for r,n in target.items() if cut_ok(r,cut,True)) + - sum(n*power(r,c)[1 if lower else 0] for r,n in paid.items() if cut_ok(r,cut,False))) + + +def split_row(t0,p0,cut,c,lower): + targets, paid = scales(t0,p0) + a = margin(targets[0],paid[0],cut,c,lower) + b = margin(targets[1],paid[1],cut,c,lower) + idx = 1 if lower else 0 + def charged(r):return power(r,c)[idx] if cut_ok(r,cut,False) else 0 + u = P*(charged(Q(1))-2*charged(Q(1,2))) + v = P*(charged(Q(2))-2*charged(Q(1))) + return tuple(map(Q,(a,b,u,v))) + + +def all_cuts(paid): + return [None, *sorted({Q(r) for pp in paid for r,n in pp.items() if n > 0})] + + +def ratio_witness(t0,p0,c,n0,n1): + targets,_ = scales(t0,p0) + paid=split_paid(p0,n0,n1) + low=Q(0); high=None; named=[] + for cut in all_cuts(paid): + a=Q(margin(targets[0],paid[0],cut,c,True)) + b=Q(margin(targets[1],paid[1],cut,c,True)) + named.append((cut,a,b)) + if b>0: low=max(low,-a/b) + elif b<0: high=a/(-b) if high is None else min(high,a/(-b)) + elif a<0: raise ArithmeticError(('negative zero-slope cut',cut)) + if high is None or not low < high: + raise ArithmeticError(('ratio interval empty',float(low),None if high is None else float(high))) + x=(low+high)/2 + values=[(cut,a+b*x) for cut,a,b in named] + if not all(v>0 for _,v in values): + raise ArithmeticError('missing strict Hall margin') + return x,values,(low,high) + + +def fractional_witness(t0,p0,c): + total=split_row(t0,p0,None,c,True) + one=split_row(t0,p0,Q(1),c,True) + two=split_row(t0,p0,Q(2),c,True) + a,b,u,_=total; a1,b1,u1,_=one; a2,b2,u2,_=two + assert u<0 and u1>0 and u2==0 and b2<0 + denominator=b-u*b1/u1 + assert denominator>0 + lo=-(a-u*a1/u1)/denominator + hi=-a2/b2 + assert 00 for _,v in margins) + return x,n,margins,(lo,hi) + + +def witness_flow(t0,p0,c,x,n0,n1): + targets,_=scales(t0,p0); paid=split_paid(p0,n0,n1) + capacity=Counter(); demand=Counter() + for weight,th,ph in zip((Q(1),x),targets,paid,strict=True): + for k,n in th.items():capacity[k]+=weight*n*power(k,c)[0] + for r,n in ph.items():demand[r]+=weight*n*power(r,c)[1] + flows=[] + for r in sorted((r for r in demand if demand[r]>0),reverse=True): + left=demand[r] + for k in sorted(capacity,reverse=True): + if not cut_ok(k,r,True): continue + amount=min(left,capacity[k]) + if amount>0: + capacity[k]-=amount; left-=amount + flows.append((r,k,amount)) + if left==0: break + if left:raise ArithmeticError(('unfunded paid rank',r,left)) + assert all(v>=0 for v in capacity.values()) + assert all(4*k>=5*r for r,k,_ in flows) + return flows,capacity + + +def addmul(rows,weights): + return tuple(sum(w*row[j] for w,row in zip(weights,rows,strict=True)) for j in range(4)) + + +def continuous_dual(t0,p0,c): + total=split_row(t0,p0,None,c,False) + one=split_row(t0,p0,Q(1),c,False) + two=split_row(t0,p0,Q(2),c,False) + # All rows are optimistic necessary margins in units 2^-224. u and v + # are the frequency-weighted split fractions, and v>=0 is exact. + assert total[2]<0 and one[2]>0 and two[2]==0 and two[1]<0 + lam1=-total[2]/one[2] + lam2=-(total[1]+lam1*one[1])/two[1] + lamv=-(total[3]+lam1*one[3]+lam2*two[3]) + rows=[total,one,two,(Q(0),Q(0),Q(0),Q(1))] + weights=[Q(1),lam1,lam2,lamv] + comb=addmul(rows,weights) + assert all(v>0 for v in weights) and comb[1:]==(0,0,0) and comb[0]<0 + return rows,weights,comb + + +def integer_dual(t0,p0,c,side): + two=split_row(t0,p0,Q(2),c,False) + if side=='at-most-1005': + primary=split_row(t0,p0,Q(1),c,False) + constraint=(Q(1005),Q(0),Q(-P),Q(0)) + assert primary[2]>0 + elif side=='at-least-1006': + primary=split_row(t0,p0,None,c,False) + constraint=(Q(-1006),Q(0),Q(P),Q(0)) + assert primary[2]<0 + else:raise ValueError(side) + assert two[1]<0 and two[2]==0 and primary[1]>0 + lam2=-primary[1]/two[1] + lamn=-primary[2]/constraint[2] + lamv=-(primary[3]+lam2*two[3]) + rows=[primary,two,constraint,(Q(0),Q(0),Q(0),Q(1))] + weights=[Q(1),lam2,lamn,lamv] + comb=addmul(rows,weights) + assert all(v>0 for v in weights) and comb[1:]==(0,0,0) and comb[0]<0 + return rows,weights,comb + + +def dual_record(rows,weights,comb): + return {'rows':[[qstr(x) for x in row] for row in rows], + 'positive_multipliers':[qstr(x) for x in weights], + 'weighted_result':[qstr(x) for x in comb], + 'constant_divided_by_unit':qstr(comb[0]/UNIT)} + + +def flow_record(flows): + return [[qstr(r),qstr(k),qstr(amount/UNIT)] for r,k,amount in flows] + + +def hist_digest(t0,p0): + d={'target':{str(r):n for r,n in sorted(t0.items())},'paid':{str(r):n for r,n in sorted(p0.items())}} + return hashlib.sha256(json.dumps(d,sort_keys=True,separators=(',',':')).encode()).hexdigest() diff --git a/research/p104-two-type-threshold/series_control.py b/research/p104-two-type-threshold/series_control.py new file mode 100644 index 0000000000..e8d2f32e03 --- /dev/null +++ b/research/p104-two-type-threshold/series_control.py @@ -0,0 +1,50 @@ +"""Independent rational atanh/log and exponential-series spot checks.""" +from fractions import Fraction as Q +from functools import cache +from directed import UNIT, power + +G = 1 << 176 + +def grid(lo,hi): + return Q((lo*G).__floor__(),G),Q((hi*G).__ceil__(),G) + +@cache +def log_ratio(z): + assert 0<=z<=Q(1,3) + total=Q(0); term=z; z2=z*z + for j in range(64): + total += term/(2*j+1) + term *= z2 + return grid(2*total,2*(total+term/(129*(1-z2)))) + +@cache +def log_rank(r): + assert isinstance(r,int) and r>=1 + k=r.bit_length()-1; radix=1<= 0 and donor not in needed: + needed.add(donor) + stack.append(donor) + signals = {} + for node in net.schedule(): + if node in needed: + row = {} + for donor, factor in net.forms[node].items(): + add(row, {donor: 1} if donor < 0 else signals[donor], factor) + signals[node] = row + return signals + + +def erase_return(net, event): + from network import Network + + move = event["move"] + calibration = event["calibration"] + pivot = event["pivot"] + receiver = event["receiver"] + sender = event["sender"] + initial = event["source"] + first = net.first_output + require(net.moves[move] == (sender, receiver), "erased move") + require(net.moves[calibration][1] == sender, "calibration receipt") + consumers = {k - first: row[move] for k, row in net.forms.items() if move in row} + require(consumers == {int(k): Fraction(v) for k, v in event["responses"].items()}, + "erased consumers") + require(all(net.initial[r] == initial and net.final[r] == receiver for r in consumers), + "helper endpoints") + form = input_forms(net, [calibration])[calibration] + require(all(net.initial[~i] == initial for i in form), "one calibration source") + pairing = sum(form.get(~r, 0) * value for r, value in consumers.items()) + require(pairing == 1, "calibration pairing") + lift = {i: -q / pairing for i, q in form.items() if i != ~pivot} + lift[~pivot] = 1 / pairing + rows = {} + for node, old in net.forms.items(): + if node == move: + continue + r = node - first + if r == pivot: + row = {calibration: 1} + else: + row = dict(old) + if r in consumers: + add(row, net.forms[first + pivot], -consumers[r] / consumers[pivot]) + require(move not in row, "erasure cancellation") + factor = sum(row.get(~r, 0) * q for r, q in consumers.items()) + row.pop(~pivot, None) + add(row, lift, factor) + rows[node] = row + moves = dict(net.moves) + del moves[move] + final = list(net.final) + final[pivot] = sender + return Network(first, list(net.initial), final, moves, rows) + + +def restrict_source(net, layout, event): + from network import Network + + first = net.first_output + pivot = event["pivot"] + last = len(net.initial) - 1 + require(last == 1289 and net.initial[pivot] == event["initial"] and net.final[pivot] == event["final"], + "old helper stock") + first_leg, second_leg = (entry["move"] for entry in event["receipts"]) + require(net.moves[first_leg] == (event["initial"], event["via"]) and + net.moves[second_leg] == (event["via"], event["final"]), "paid chain") + local = {entry["move"]: {i: Fraction(q) for i, q in entry["donors"]} + for entry in event["receipts"]} + values = input_forms(net, set(local) | {i for row in local.values() for i in row}) + relations = {} + for node, replacement in local.items(): + row = dict(values[node]) + for donor, amount in replacement.items(): + add(row, values[donor], -amount) + relations[node] = row + source = relations[first_leg] + require(source == {j: Fraction(event["proportion"]) * value for j, value in relations[second_leg].items()}, + "proportional source relations") + require(len(source) == event["support"] and all(net.initial[~j] == event["initial"] for j in source), + "one source chart") + divisor = source[~pivot] + require(divisor == Fraction(event["pivot_coefficient"]), "source pivot") + rewrites = dict(local) + rewrites[~pivot] = {j: -v / divisor for j, v in source.items() if j != ~pivot} + rows = {} + for node, row in net.forms.items(): + if node in local or node == first + pivot: + continue + out = {j: v for j, v in row.items() if j not in rewrites} + for donor in row.keys() & rewrites.keys(): + add(out, rewrites[donor], row[donor]) + if ~last in out: + out[~pivot] = out.pop(~last) + rows[first + pivot if node == first + last else node] = out + + def pack(sequence): + result = list(sequence[:-1]) + result[pivot] = sequence[last] + return result + + moves = {k: chart for k, chart in net.moves.items() if k not in local} + require(layout["public"] == last + 1 and layout["source_labels"][last] == 1542, + "public layout") + updated = dict(layout, public=last, source_labels=pack(layout["source_labels"])) + return Network(first, pack(net.initial), pack(net.final), moves, rows), updated + + +def replay(source, layout, journal, engines): + require(sha256(encoded(source)).hexdigest() == journal["source"], "source word pin") + require(sha256(encoded(layout)).hexdigest() == journal["layout"], "source layout pin") + for name, digest in journal["semantic_modules"].items(): + require(sha256((engines / name).read_bytes()).hexdigest() == digest, name) + sys.path[:0] = [str(engines), str(engines / "retained" / "vendor")] + from network import Network + from public_split import split + from birth_event import apply_split + + net = Network(source["first_output"], source["initial"], source["final"], + {k: (a, b) for k, a, b in source["moves"]}, + {k: {i: Fraction(v) for i, v in row} for k, row in source["forms"]}) + for e in journal["splits"]: + net = split(net, e) + net.schedule() + e = journal["subdivide"] + k, j, chart = e["move"], e["new"], e["through"] + a, b = net.moves[k] + require([a, b] == e["original"] and j not in net.moves, "carrier preimage") + moves = dict(net.moves) + forms = dict(net.forms) + moves[j], moves[k] = (a, chart), (chart, b) + forms[j], forms[k] = forms[k], {j: Fraction(1)} + net = apply_split(Network(net.first_output, net.initial, net.final, moves, forms), journal["birth"]) + layout = dict(layout, public=len(net.initial), + source_labels=[*layout["source_labels"], journal["birth_source_label"]]) + net = erase_return(net, journal["erasure"]) + net, layout = restrict_source(net, layout, journal["quotient"]) + require(sha256(encoded(layout)).hexdigest() == journal["child_layout_sha256"], "child layout pin") + graph = dict(first_output=net.first_output, initial=net.initial, final=net.final, frames=source["frames"], + moves=[[k, *pair] for k, pair in sorted(net.moves.items())], + forms=[[k, [[i, str(q)] for i, q in sorted(row.items())]] for k, row in sorted(net.forms.items())], + schedule=net.schedule()) + digest = sha256(encoded(graph)).hexdigest() + require(digest == journal["canonical_sha256"], "child word pin") + audit = verify_integer_grid(net, graph, layout) + return graph, dict(word_sha256=digest, **audit) + + +def main(): + parser = ArgumentParser(description=__doc__) + parser.add_argument("--source", required=True, type=Path) + parser.add_argument("--layout", required=True, type=Path) + parser.add_argument("--engines", required=True, type=Path) + parser.add_argument("--journal", type=Path, default=Path(__file__).with_name("EVENTS.json")) + parser.add_argument("--write-word", type=Path) + parser.add_argument("--write-audit", type=Path) + args = parser.parse_args() + require(sys.flags.optimize == 0, "the source engines use assertions") + graph, audit = replay(read(args.source), read(args.layout), read(args.journal), args.engines) + if args.write_word: + args.write_word.write_bytes(gzip.compress(encoded(graph), mtime=0)) + if args.write_audit: + args.write_audit.write_text(json.dumps(audit, sort_keys=True, indent=2)+"\n") + print(json.dumps(audit, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_bidirectional.py b/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_bidirectional.py new file mode 100644 index 0000000000..dad4414718 --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_bidirectional.py @@ -0,0 +1,152 @@ +"""Rebuild the rational circuit and replay its scalar map and caller tariff.""" +import argparse +from collections import Counter +from fractions import Fraction +from functools import cache +from graphlib import TopologicalSorter +from math import gcd, lcm +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from verify_component import canonical, check, check_decrease, expected_columns, factor, inspect, margin, read + + +@cache +def rational(text): + return Fraction(text) + + +def reconstruct(parent, delta): + check(canonical(parent) == delta["parent"], "parent word") + moves = {k: (a, b) for k, a, b in parent["moves"]} + forms = {k: dict(row) for k, row in parent["forms"]} + for k in delta["removed"]: + del moves[k], forms[k] + for k, a, b in delta["moves"]: + check(k not in forms, "new transfer label") + moves[k], forms[k] = (a, b), {} + + differences = {} + literals = {} + for k, kind, entries in delta["differences"]: + check(k not in differences and k in forms, "changed coefficient row") + weights = {j: rational(s) for j, s in entries} + check(len(weights) == len(entries) and all(weights.values()), "distinct nonzero weights") + if kind == "add": + change = weights + literals[k] = change + else: + check(kind == "combine", "difference format") + change = {} + for j, weight in weights.items(): + for donor, value in literals[j].items(): + change[donor] = change.get(donor, 0) + weight * value + change = {j: v for j, v in change.items() if v} + differences[k] = len(change) + row = forms[k] + for j, v in change.items(): + coefficient = rational(row.get(j, "0")) + v + if coefficient: + row[j] = str(coefficient) + else: + del row[j] + deps = {k: tuple(j for j in sorted(row) if j >= 0) for k, row in sorted(forms.items())} + word = dict(parent, forms=[[k, sorted(row.items())] for k, row in sorted(forms.items())], + moves=[[k, a, b] for k, (a, b) in sorted(moves.items())], + schedule=list(TopologicalSorter(deps).static_order())) + check(canonical(word) == delta["word"], "reconstructed word") + return word, sum(differences.values()) + + +def forward(word, layout): + """Check all terminal rows. Find the smallest grid that contains every scalar product.""" + n, first = len(word["initial"]), word["first_output"] + columns, _ = expected_columns(layout, n) + want = [{} for _ in range(n)] + for i, column in enumerate(columns): + for j, fraction in column.items(): + want[j][i] = Fraction(*fraction) + rows = dict(word["forms"]) + stock = {~i: ({i: 1}, 1, 1) for i in range(n)} + uses = Counter(j for row in rows.values() for j, _ in row) + grid = literal_bits = 1 + products = 0 + for k in word["schedule"]: + terms = [] + divisor = 1 + for j, s in rows[k]: + num, den = factor(s) + literal_bits = max(literal_bits, num.bit_length(), den.bit_length()) + values, source_den, content = stock[j] + total_den = den * source_den + grid = lcm(grid, total_den // gcd(total_den, num * content)) + terms.append((values, num, total_den)) + divisor = lcm(divisor, total_den) + uses[j] -= 1 + if not uses[j]: + del stock[j] + result = {} + for values, num, den in terms: + products += len(values) + multiple = num * (divisor // den) + for i, v in values.items(): + result[i] = result.get(i, 0) + multiple * v + result = {i: v for i, v in result.items() if v} + if first <= k < first + n: + check(result.keys() == want[k-first].keys() and + all(v == divisor * want[k-first][i] for i, v in result.items()), f"terminal row {k-first}") + else: + content = gcd(*result.values()) + common = gcd(content, divisor) + stock[k] = ({i: v // common for i, v in result.items()}, divisor // common, content // common) + return products, grid, literal_bits + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--quotient", action="store_true", help="check the four-term quotient on the rebuilt parent") + args = parser.parse_args() + parent = read("WORD.json.gz") + check(canonical(parent) == read("RATIONAL-RECEIPT.json")["word"], "initial word") + prefix = "BIDIRECTIONAL" + if args.quotient: + parent, _ = reconstruct(parent, read("BIDIRECTIONAL.json.gz")) + check(canonical(parent) == read("BIDIRECTIONAL-RECEIPT.json")["new_word"], "intermediate word") + prefix = "BIDIRECTIONAL-QUOTIENT" + verify_step(parent, prefix) + + +def verify_step(parent, prefix, layout=None): + delta = read(prefix + ".json.gz") + receipt = read(prefix + "-RECEIPT.json") + word, edits = reconstruct(parent, delta) + check(delta["word"] == receipt["new_word"] and len(word["moves"]) == receipt["moves"], "word and charge count") + check(len(parent["moves"]) == receipt["old_moves"] and len(delta["removed"]) == receipt["retired"] + and len(delta["moves"]) == receipt["new_moves"], "changed transfers") + check(edits == receipt["coefficient_edits"] and len(delta["differences"]) == receipt["changed_rows"], + "coefficient count") + check_circuit(word, receipt, read("LAYOUT.json.gz") if layout is None else layout) + return word + + +def check_circuit(word, receipt, layout): + work, grid, bits = forward(word, layout) + check([work, grid, bits] == [receipt["forward_terms"], int(receipt["minimum_product_grid"]), + receipt["literal_peak_bits"]], "forward precision and work") + paid, targets, adjoint = inspect(word, layout, read("CALLER-CENSUS.json")) + check(adjoint == receipt["adjoint_terms"] and len(word["initial"]) == receipt["public"], "adjoint census") + for name, bins in (("paid", paid), ("productive", targets)): + check({str(k): v for k, v in bins.items()} == receipt[name], name) + lower, upper = [Fraction(v, 10**14) for v in receipt["crossing_e14"]] + check(margin(paid, targets, lower)[0] > 0 and margin(paid, targets, upper)[1] < 0, "crossing signs") + check_decrease(paid, targets) + lo, hi = margin(paid, targets, receipt["trial"]) + a, b = map(Fraction, receipt["trial_margin"]) + check(a <= lo <= hi <= b < 0, "trial margin") + print(f"PASS {len(word['moves'])} transfers, {work} forward products, {adjoint} adjoint terms, " + f"{len(word['initial'])} independent fields and both crossing signs") + + +if __name__ == "__main__": + main() diff --git a/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_component.py b/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_component.py new file mode 100644 index 0000000000..6f2aff9a04 --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_component.py @@ -0,0 +1,189 @@ +"""Check the rational graph over every input and price its 48 calls.""" +from collections import Counter, defaultdict +from fractions import Fraction +from functools import cache +from hashlib import sha256 +from math import gcd, isqrt, lcm +from pathlib import Path +import gzip +import json + + +ROOT = Path(__file__).resolve().parent +SCALE = 1 << 192 + + +def check(condition, message): + if not condition: + raise ValueError(message) + + +def read(name): + raw = (ROOT / name).read_bytes() + return json.loads(gzip.decompress(raw) if name.endswith(".gz") else raw) + + +def canonical(value): + return sha256(json.dumps(value, sort_keys=True, separators=(",", ":")).encode()).hexdigest() + + +@cache +def factor(text): + value = Fraction(text) + return value.numerator, value.denominator + + +def frame_span(basis): + points = {0} + for vector in basis: + check(0 < vector < 512 and vector not in points, "invalid frame basis") + points.update([old ^ vector for old in points]) + return points + + +def expected_columns(layout, n): + expected = [{i: (1, 1)} for i in range(n)] + main = set() + hosted = layout["hosted"] + for port, x in enumerate(layout["live"]): + y = x + 112 + main.update((x, y)) + if port in hosted["Dports"]: + expected[x][y] = (1, 1) + else: + expected[x][y] = (1, 2) + expected[y] = {x: (-1, 1), y: (1, 2)} + for x, y in zip(hosted["X2"], hosted["Y2"], strict=True): + main.update((x, y)) + expected[y][x] = (-1, 1) + check(len(main) == 400, "main role count") + return expected, main + + +def inspect(word, layout, caller): + starts, ends = word["initial"], word["final"] + n = len(starts) + check(len(ends) == n == layout["public"] == len(layout["source_labels"]), "endpoint count") + check(word["frames"] == layout["frames"], "layout frames") + expected, main = expected_columns(layout, n) + rank = [len(f) for f in word["frames"]] + spans = list(map(frame_span, word["frames"])) + moves = {k: (a, b) for k, a, b in word["moves"]} + graph = dict(word["forms"]) + order = word["schedule"] + first = word["first_output"] + outputs = set(range(first, first + n)) + check(len(moves) == len(word["moves"]) and moves.keys().isdisjoint(outputs), "paid labels") + check(len(order) == len(graph) == len(word["forms"]), "row count") + check(set(order) == graph.keys() == moves.keys() | outputs, "schedule coverage") + + def grade(a, b): + check(spans[a] < spans[b] or spans[b] < spans[a], "strictly nested charts") + return abs(rank[b] - rank[a]) + + calls = caller["calls"] + paid = Counter({int(k): v for k, v in caller["fixed_caller_paid"].items()}) + targets = Counter({int(k): v for k, v in caller["fixed_root_targets"].items()}) + for i, (a, b) in enumerate(zip(starts, ends, strict=True)): + if i not in main: + targets[grade(a, b)] += calls + + bank = {~i: a for i, a in enumerate(starts)} + consumers = defaultdict(list) + for k in order: + a = moves[k][0] if k in moves else ends[k - first] + for donor, text in graph[k]: + check(bank[donor] == a, f"donor chart at {k}") + num, den = factor(text) + consumers[donor].append((k, num, den)) + if k in moves: + a, b = moves[k] + paid[grade(a, b)] += calls + bank[k] = b + + # Store a common positive denominator for every sparse adjoint row. + back = {first + i: ({i: 1}, 1) for i in range(n)} + terms = 0 + keys = [k for k in reversed(order) if k in moves] + [~i for i in range(n)] + for k in keys: + users = consumers[k] + common = lcm(*(den * back[j][1] for j, num, den in users)) + row = {} + for j, num, den in users: + values, divisor = back[j] + scale = num * (common // (den * divisor)) + for i, value in values.items(): + row[i] = row.get(i, 0) + scale * value + terms += len(values) + divisor = gcd(common, *row.values()) + back[k] = ({i: v // divisor for i, v in row.items() if v}, common // divisor) + for i, want in enumerate(expected): + row, divisor = back[~i] + check(row.keys() == want.keys(), f"column support at {i}") + check(all(v * want[j][1] == divisor * want[j][0] for j, v in row.items()), f"column {i}") + return paid, targets, terms + + +def price(rank, saving): + # Enclose rank**saving by successive integer square roots. Each bit + # selects the next positive root. The last root bounds the full tail. + lo = hi = rank * SCALE + product_lo = product_hi = SCALE + rem = Fraction(saving) + for _ in range(152): + lo = isqrt(lo * SCALE) + hi = 1 + isqrt(hi * SCALE - 1) + rem *= 2 + if rem >= 1: + rem -= 1 + product_lo = product_lo * lo // SCALE + product_hi = (product_hi * hi + SCALE - 1) // SCALE + if rem: + product_hi = (product_hi * hi + SCALE - 1) // SCALE + mass = rank * SCALE * SCALE + return mass // product_hi, (mass + product_lo - 1) // product_lo + + +def margin(paid, targets, saving): + lo = hi = 0 + for rank in targets.keys() | paid.keys(): + count = targets[rank] - paid[rank] + a, b = price(rank, saving) + lo += min(count * a, count * b) + hi += max(count * a, count * b) + return Fraction(lo, SCALE), Fraction(hi, SCALE) + + +def check_decrease(paid, targets): + # Bound the derivative divided by ln(2) from above on [0, 0.004]. + derivative = 0 + for rank in paid.keys() | targets.keys(): + count = targets[rank] - paid[rank] + if count > 0: + derivative -= count * (rank.bit_length() - 1) * price(rank, "0.004")[0] + else: + derivative -= count * (rank - 1).bit_length() * rank * SCALE + check(derivative < 0, "strict decrease on the comparison interval") + + +def main(): + word = read("WORD.json.gz") + layout = read("LAYOUT.json.gz") + receipt = read("RATIONAL-RECEIPT.json") + check(canonical(word) == receipt["word"] == read("EVENTS.json")["canonical_sha256"], "word pin") + check(canonical(layout) == read("EVENTS.json")["child_layout_sha256"], "layout pin") + paid, targets, terms = inspect(word, layout, read("CALLER-CENSUS.json")) + check(terms == receipt["adjoint_terms"] and len(word["initial"]) == receipt["public"], "adjoint census") + for name, bins in (("paid", paid), ("productive", targets)): + check({str(k): v for k, v in bins.items()} == receipt[name], name) + lower, upper = map(Fraction, receipt["crossing"]) + check(margin(paid, targets, lower)[0] > 0 and margin(paid, targets, upper)[1] < 0, "crossing signs") + check_decrease(paid, targets) + probe = margin(paid, targets, "0.00391884648") + left, right = map(Fraction, receipt["target_margin"]) + check(left <= probe[0] <= probe[1] <= right < 0, "target interval") + print(f"PASS {receipt['public']} columns, {terms} adjoint terms, both crossing signs and the target deficit") + + +if __name__ == "__main__": + main() diff --git a/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_split_helpers.py b/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_split_helpers.py new file mode 100644 index 0000000000..d596f75f1f --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/inputs/complex-source/verify_split_helpers.py @@ -0,0 +1,95 @@ +"""Rebuild two helper splits and check the resulting rational program.""" +from fractions import Fraction +from graphlib import TopologicalSorter +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from replay import add +from verify_bidirectional import canonical, check, check_circuit, read, reconstruct, verify_step + + +def split(word, event): + first = word["first_output"] + initial, final = word["initial"].copy(), word["final"].copy() + role, chart = event["role"], event["chart"] + fresh = len(initial) + check((initial[role], final[role]) == (3, 127), "old helper endpoints") + + def load_row(entries): + return {i: Fraction(q) for i, q in entries} + + rows = {k: load_row(entries) for k, entries in word["forms"]} + s, w = load_row(event["covector"]), load_row(event["direction"]) + pairing = sum(s.get(i, 0) * v for i, v in w.items()) + check(pairing and w.get(role), "nonzero helper pivots") + substitute = {~i: -v / pairing for i, v in s.items() if i != role} + substitute[~role] = 1 / pairing + + def change_source(row): + coefficient = sum(row.get(~i, 0) * v for i, v in w.items()) + row.pop(~role, None) + if coefficient: + add(row, substitute, coefficient) + + for row in rows.values(): + change_source(row) + observed = load_row(event["read"]) + change_source(observed) + difference = {~fresh: 1 / pairing} + add(difference, observed, -1 / pairing) + for k, coefficient in load_row(event["inject"]).items(): + add(rows[k], difference, coefficient) + + recovered = {} + for i, v in s.items(): + add(recovered, rows[first + i], v) + old_return = rows[first + role] + for i, v in w.items(): + if i != role: + add(rows[first + i], old_return, -v / w[role]) + rows[first + role] = observed + rows[first + fresh] = recovered + initial.append(chart) + final.append(final[role]) + final[role] = chart + deps = {k: tuple(j for j in sorted(row) if j >= 0) for k, row in sorted(rows.items())} + return dict(word, initial=initial, final=final, schedule=list(TopologicalSorter(deps).static_order()), + forms=[[k, [[j, str(q)] for j, q in sorted(row.items())]] for k, row in sorted(rows.items())]) + + +def rebuild(check_parents=False): + parent = read("WORD.json.gz") + for name in ("BIDIRECTIONAL", "BIDIRECTIONAL-QUOTIENT"): + if check_parents: + parent = verify_step(parent, name) + else: + parent, _ = reconstruct(parent, read(name + ".json.gz")) + journal, receipt = read("HELPER-SPLITS.json"), read("HELPER-SPLITS-RECEIPT.json") + check(canonical(parent) == journal["parent"] == read("BIDIRECTIONAL-QUOTIENT-RECEIPT.json")["new_word"], + "split parent") + events = journal["splits"] + check(len(events) == receipt["splits"], "split count") + word = parent + for event in events: + word = split(word, event) + check(canonical(word) == journal["word"] == receipt["new_word"], "split word") + check(word["moves"] == parent["moves"] and len(word["moves"]) == receipt["moves"], "shared paid transfers") + layout = read("LAYOUT.json.gz") + labels = layout["source_labels"] + first_label = max(labels) + 1 + layout = dict(layout, public=len(word["initial"]), + source_labels=[*labels, *range(first_label, first_label + len(events))]) + check(canonical(layout) == journal["layout"], "new public labels") + return word, layout + + +def main(): + word, layout = rebuild(check_parents=True) + receipt = read("HELPER-SPLITS-RECEIPT.json") + check_circuit(word, receipt, layout) + verify_step(word, "BANK-FACTORS", layout) + + +if __name__ == "__main__": + main() diff --git a/research/p104-two-type-threshold/source/canonical/periodic.py b/research/p104-two-type-threshold/source/canonical/periodic.py new file mode 100644 index 0000000000..16b2381ea5 --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/periodic.py @@ -0,0 +1,223 @@ +"""Compile finite-order tensor jobs from a strict chronological mixed rule.""" + +from dataclasses import dataclass +from functools import cache +from itertools import product +from math import prod + + +@dataclass(frozen=True) +class Rule: + ambient: int + targets: tuple + paid: tuple + + def __post_init__(self): + if not self.targets or not self.paid: + raise ValueError("Supply positive target and paid occurrence lists") + if not 1 <= min(self.paid) <= max(self.paid) < min(self.targets) <= max(self.targets) <= self.ambient: + raise ValueError("The paid ceiling must be below the productive floor") + + +def power_ceiling(x): + return 1 << (x - 1).bit_length() + + +def period(length, rank): + """Return the power-of-two number of full rank-rank jobs for one field.""" + if length <= 0 or length % 4 or not 1 <= rank <= length // 4: + raise ValueError("Use a positive multiple of four with four rank blocks") + return power_ceiling((length + rank - 1) // rank) + + +def row_axes(length, rank, rounds, row): + """Emit the actual ordered axis subset for this complete invocation.""" + if rounds != period(length, rank) or not 0 <= row < rounds: + raise ValueError("Invalid period or invocation") + five = (rounds * rank - length) // 4 + for ticket in range(row, rounds * rank, rounds): + yield ticket // 5 if ticket < 5 * five else ticket - 4 * five + + +@dataclass(frozen=True) +class Unit: + future: tuple + columns: int + # Each port is (source, source-id) or (parent, future of the paying unit). + ports: tuple + + +@dataclass(frozen=True) +class Forest: + # The key is a chronological path of individual paid occurrence labels. + layers: dict + sources: tuple + exits: dict + height: int + + +def forest(rule, limit): + """Enumerate the source ports and the separate paid cuts of the live forest.""" + if limit < rule.ambient: + raise ValueError("The live forest needs one full working ambient") + height, smallest = 0, rule.ambient + while smallest * min(rule.targets) <= limit: + smallest *= min(rule.targets) + height += 1 + layers, sources, exits = {}, [], {} + target_ids = range(len(rule.targets)) + paid_ids = range(len(rule.paid)) + for depth in range(height + 1): + for path in product(paid_ids, repeat=depth): + history = prod(rule.paid[i] for i in path) + units = [] + for future in product(target_ids, repeat=height - depth): + columns = history * prod(rule.targets[i] for i in future) + if columns * rule.ambient > limit: + continue + ports = [] + for i, rank in enumerate(rule.targets): + parent = (i,) + future + if path and columns // rule.paid[path[-1]] * rank * rule.ambient <= limit: + ports.append(("parent", parent)) + else: + ports.append(("source", len(sources))) + sources.append((path, future, i, rank * columns)) + units.append(Unit(future, columns, tuple(ports))) + layers[path] = tuple(units) + if depth == height: + if len(units) != 1: + raise ArithmeticError("The final paid cut lost its only unit") + for j, rank in enumerate(rule.paid): + exits[path + (j,)] = rank * history + return Forest(layers, tuple(sources), exits, height) + + +@dataclass(frozen=True) +class Plan: + rank: int + active: int + forest: object + periods: tuple + offsets: tuple + rounds: int + copies: int + owners_per_copy: int + width: int + leaves: int + + +def make_planner(rule): + @cache + def plan(n): + if n < 1: + raise ValueError("A positive rank is required") + active = n - n % 4 + if active // 4 < rule.ambient: + return Plan(n, n, None, (), (), 0, 0, 1, 1, n) + f = forest(rule, active // 4) + periods = tuple(period(active, item[-1]) for item in f.sources) + rounds = max(periods) + offsets, slots = [], 0 + for k in periods: + offsets.append(slots) + slots += rounds // k + divisor = max(plan(e).width for e in f.exits.values()) + raw = divisor * slots + width = power_ceiling(15 * raw) + copies = ((width + raw - 1) // raw) * divisor + if not 15 * width <= 15 * copies * slots < 16 * width: + raise ArithmeticError("Incorrect dyadic batch padding") + leaves = (n - active) * width + for e in f.exits.values(): + smaller = plan(e) + if copies % smaller.width: + raise ArithmeticError("A chronological child lost a full group") + leaves += rounds * (copies // smaller.width) * smaller.leaves + return Plan(n, active, f, periods, tuple(offsets), rounds, copies, slots, width, leaves) + return plan + + +@dataclass(frozen=True) +class Job: + """Use an ordered active basis on this field. Store full adapters at the boundary.""" + + owner: object + axes: tuple + + def select(self, indices): + return Job(self.owner, tuple(self.axes[i] for i in indices)) + + +def run(rule, n, fields, machine, *, planner=None): + """Run all root, native, adapter, leaf, guard and cleanup operations in order. + + The native iterator supplied by the source performs its local instructions. + It yields one actual paid job at each chronological source position. + A full-data adapter may instead open a rank job in its canonical basis, + run the resulting subcall, and close the adapter after it returns. + """ + plan = make_planner(rule) if planner is None else planner + + def satisfy(rank, lanes): + p = plan(rank) + if (len(lanes) != p.width or len({j.owner for j in lanes}) != len(lanes) + or any(len(j.axes) != rank for j in lanes)): + raise ValueError("Expected one independent full field per live lane") + if p.forest is None: + for job in lanes: + for axis in job.axes: + machine.leaf(Job(job.owner, (axis,))) + return + # Every slot beyond the dyadic productive width has its own owned field. + expanded = list(lanes) + for _ in range(p.copies * p.owners_per_copy - p.width): + expanded.append(machine.zero(lanes[0])) + for iteration in range(p.rounds): + def process(path, previous): + units = p.forest.layers[path] + frames = [] + for u in units: + per_copy = [] + for replica in range(p.copies): + ports = [] + for kind, label in u.ports: + if kind == "parent": + ports.append(previous[label][replica]) + else: + k = p.periods[label] + index = (replica * p.owners_per_copy + p.offsets[label] + + iteration // k) + s = p.forest.sources[label][-1] + subset = row_axes(p.active, s, k, iteration % k) + ports.append(expanded[index].select(subset)) + per_copy.append(iter(machine.native(tuple(ports), u.columns))) + frames.append(per_copy) + for j, paid in enumerate(rule.paid): + requests = {} + for u, group in zip(units, frames, strict=True): + jobs = [next(frame) for frame in group] + if any(len(job.axes) != paid * u.columns for job in jobs): + raise ValueError("The actual native request has a different rank") + requests[u.future] = jobs + cut = path + (j,) + if len(path) < p.forest.height: + process(cut, requests) + else: + e = p.forest.exits[cut] + width = plan(e).width + group = requests[()] + for i in range(0, len(group), width): + satisfy(e, group[i:i + width]) + sentinel = object() + for group in frames: + for frame in group: + if next(frame, sentinel) is not sentinel: + raise ValueError("An unserved native request remained") + process((), {}) + for job in lanes: + for axis in job.axes[p.active:]: + machine.leaf(Job(job.owner, (axis,))) + for job in reversed(expanded[len(lanes):]): + machine.retire_zero(job) + satisfy(n, fields) diff --git a/research/p104-two-type-threshold/source/canonical/powered.py b/research/p104-two-type-threshold/source/canonical/powered.py new file mode 100644 index 0000000000..e492c67e1a --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/powered.py @@ -0,0 +1,128 @@ +"""Bind a powered chronological word to the strict-rule compiler.""" + +from dataclasses import dataclass +from itertools import product +from math import prod + +from periodic import Rule + + +@dataclass(frozen=True) +class Port: + tag: tuple + rank: int + + +@dataclass(frozen=True) +class Block: + tags: tuple + first: int + rank: int + + +@dataclass(frozen=True) +class PoweredWord: + ambient: int + targets: tuple + paid: tuple + power: int + floor: int + low_cut: int + high_cut: int + + def target(self, indices): + return Port(tuple(self.targets[i].tag for i in indices), + prod(self.targets[i].rank for i in indices)) + + def target_paths(self): + for indices in product(range(len(self.targets)), repeat=self.power): + port = self.target(indices) + yield port, port.rank >= self.floor ** self.power + + def blocks(self, indices): + rank = prod(self.paid[i].rank for i in indices) + cap = (self.low_cut if self.paid[indices[0]].rank <= 4 else self.high_cut) ** self.power + tags = tuple(self.paid[i].tag for i in indices) + for first in range(0, rank, cap): + yield Block(tags, first, min(cap, rank - first)) + + def paid_paths(self): + for indices in product(range(len(self.paid)), repeat=self.power): + yield from self.blocks(indices) + + def tables(self, target_sink, paid_sink): + """Write original labels, zero assignments, true split offsets and ranks.""" + for port, keep in self.target_paths(): + target_sink(port, keep) + for child in self.paid_paths(): + paid_sink(child) + + def rule(self): + """Use resident tables where available. The tape output follows tables().""" + return Rule(self.ambient ** self.power, + tuple(p.rank for p, keep in self.target_paths() if keep), + tuple(p.rank for p in self.paid_paths())) + + def native(self, productive, columns, physical): + """Run each raw occurrence and yield the actual owner's split job in turn. + + raw receives (raw port tag, full job) pairs. It applies complete native + entry/exit charts and local instructions, yielding (paid tag, full job). + fresh receives a full ambient exemplar, active extent and zero port path. + """ + live = iter(productive) + if not productive: + raise ValueError("At least one retained productive field is required") + exemplar = productive[0] + fields, owned = {}, [] + for indices in product(range(len(self.targets)), repeat=self.power): + port = self.target(indices) + if port.rank >= self.floor ** self.power: + job = next(live) + else: + job = physical.fresh(exemplar, port.rank * columns, port.tag) + owned.append(job) + if len(job.axes) != port.rank * columns: + raise ValueError("Wrong extent at original productive location") + fields[indices] = job + sentinel = object() + if next(live, sentinel) is not sentinel: + raise ValueError("Unbound productive owner") + + def tensor(depth, ports, factor, prefix): + frames = {} + for suffix in product(range(len(self.targets)), repeat=depth - 1): + axes = prod(self.targets[i].rank for i in suffix) + inputs = tuple((port.tag, ports[(i,) + suffix]) + for i, port in enumerate(self.targets)) + frames[suffix] = iter(physical.raw(inputs, factor * axes)) + for j, cut in enumerate(self.paid): + requests = {} + for suffix, frame in frames.items(): + tag, job = next(frame) + axes = prod(self.targets[i].rank for i in suffix) + if tag != cut.tag or len(job.axes) != cut.rank * factor * axes: + raise ValueError("Wrong chronological raw request or extent") + requests[suffix] = job + full = prefix + (j,) + if depth > 1: + yield from tensor(depth - 1, requests, factor * cut.rank, full) + else: + native_job = requests[()] + for block in self.blocks(full): + first = block.first * columns + yield native_job.select(range(first, first + block.rank * columns)) + for frame in frames.values(): + if next(frame, sentinel) is not sentinel: + raise ValueError("Pending raw request after its final slot") + yield from tensor(self.power, fields, columns, ()) + for job in reversed(owned): + physical.retire(job) + + +def bit_word(targets, paid): + return PoweredWord(134, tuple(targets), tuple(paid), 480, 16, 10, 11) + + +def complex_word(targets, paid): + return PoweredWord(153, tuple(targets), tuple(paid), 264, 17, 10, 10) diff --git a/research/p104-two-type-threshold/source/canonical/sparse_helpers.py b/research/p104-two-type-threshold/source/canonical/sparse_helpers.py new file mode 100644 index 0000000000..da57d5d6ad --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/sparse_helpers.py @@ -0,0 +1,118 @@ +"""Apply the two helper changes without materializing rational copies of untouched rows. + +The signed row update, tests and owner convention follow verify_split_helpers. +Each output still uses every term of the original program. +""" + +from functools import cache +from fractions import Fraction +from graphlib import TopologicalSorter + + +def split(word, event): + from replay import add + from verify_bidirectional import check + + rational = cache(Fraction) + + def read_row(entries): + return {i: rational(q) for i, q in entries} + + first = word["first_output"] + initial, final = word["initial"].copy(), word["final"].copy() + role, chart = event["role"], event["chart"] + fresh = len(initial) + check((initial[role], final[role]) == (3, 127), "old helper endpoints") + original = dict(word["forms"]) + edited = {} + + def row(k): + if k not in edited: + edited[k] = read_row(original[k]) + return edited[k] + + covector, direction = read_row(event["covector"]), read_row(event["direction"]) + pairing = sum(covector.get(i, 0) * w for i, w in direction.items()) + check(pairing and direction.get(role), "nonzero helper pivots") + substitute = {~i: -s / pairing for i, s in covector.items() if i != role} + substitute[~role] = 1 / pairing + + def change_source(values): + coefficient = sum(values.get(~i, 0) * w for i, w in direction.items()) + values.pop(~role, None) + if coefficient: + add(values, substitute, coefficient) + + touched = {~i for i in direction} + touched.add(~role) + for k, entries in original.items(): + if any(j in touched for j, _ in entries): + change_source(row(k)) + observed = read_row(event["read"]) + change_source(observed) + difference = {~fresh: 1 / pairing} + add(difference, observed, -1 / pairing) + for k, a in read_row(event["inject"]).items(): + add(row(k), difference, a) + recovered = {} + for i, v in covector.items(): + add(recovered, row(first + i), v) + old_return = row(first + role) + for i, v in direction.items(): + if i != role: + add(row(first + i), old_return, -v / direction[role]) + edited[first + role] = observed + edited[first + fresh] = recovered + + for k, values in edited.items(): + original[k] = [[j, str(q)] for j, q in sorted(values.items())] + forms = [[k, values] for k, values in sorted(original.items())] + deps = {k: tuple(j for j, _ in values if j >= 0) for k, values in forms} + initial.append(chart) + final.append(final[role]) + final[role] = chart + return dict( + word, + initial=initial, + final=final, + forms=forms, + schedule=list(TopologicalSorter(deps).static_order()), + ) + + +def rebuild(): + from verify_bidirectional import canonical, check, read, reconstruct + + word = read("WORD.json.gz") + for name in ("BIDIRECTIONAL", "BIDIRECTIONAL-QUOTIENT"): + word, _ = reconstruct(word, read(name + ".json.gz")) + journal = read("HELPER-SPLITS.json") + receipt = read("HELPER-SPLITS-RECEIPT.json") + check( + canonical(word) + == journal["parent"] + == read("BIDIRECTIONAL-QUOTIENT-RECEIPT.json")["new_word"], + "split parent", + ) + check(len(journal["splits"]) == receipt["splits"], "split count") + parent_moves = word["moves"] + for event in journal["splits"]: + word = split(word, event) + check(canonical(word) == journal["word"] == receipt["new_word"], "split word") + check( + word["moves"] == parent_moves and len(parent_moves) == receipt["moves"], + "shared paid transfers", + ) + layout = read("LAYOUT.json.gz") + labels = layout["source_labels"] + first_label = max(labels) + 1 + layout = dict( + layout, + public=len(word["initial"]), + source_labels=[ + *labels, + *range(first_label, first_label + len(journal["splits"])), + ], + ) + check(canonical(layout) == journal["layout"], "new public labels") + return word, layout diff --git a/research/p104-two-type-threshold/source/canonical/strong_complex.py b/research/p104-two-type-threshold/source/canonical/strong_complex.py new file mode 100644 index 0000000000..fbabddd81f --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/strong_complex.py @@ -0,0 +1,118 @@ +"""Bind the 48-call physical receiver to the 5,674-transfer source.""" + +from functools import cache +from types import SimpleNamespace +from hashlib import sha256 +from pathlib import Path +import gzip +import json + +WORD = "38d2b3a2311a9ba5fee091cc7aa204c7ed95651aec95d75184b2391df090cbfb" +LAYOUT = "0ce3f9e383fc4bfdd22612b9e34fc9759d97204215937b82d23aec2cedd9b8ee" +ADDITIONAL = "6ff19e063214b1698165d9da1fcd6182d9b837ac2d6e61aa71658b629aabbc95" +GRID = 154113755636630124932500335624192000 +DYADIC = 30 +ODD = GRID >> DYADIC + + +def digest(value): + raw = json.dumps(value, separators=(",", ":"), sort_keys=True).encode() + return sha256(raw).hexdigest() + + +def packed(path): + return json.loads(gzip.decompress(path.read_bytes())) + + +@cache +def load_changed(data): + """Reconstruct the 1,291-role program from the literal graph and its three journals.""" + import sys + + data = Path(data) + source = data / "complex-source" + for name, pin in json.loads((data / "complex-source.json").read_bytes()).items(): + if sha256((source / name).read_bytes()).hexdigest() != pin: + raise ValueError(f"The circuit source differs at {name}") + sys.path.insert(0, str(source)) + from verify_split_helpers import read, reconstruct + from sparse_helpers import rebuild + + parent, layout = rebuild() + graph, _ = reconstruct(parent, read("BANK-FACTORS.json.gz")) + if digest(graph) != WORD or digest(layout) != LAYOUT: + raise ValueError("The reconstructed Gaussian graph or its owner layout differs") + return graph, layout + + +def required_pairs(graph, layout): + main = ( + set(layout["live"]) + | {x + 112 for x in layout["live"]} + | set(layout["hosted"]["X2"]) + | set(layout["hosted"]["Y2"]) + ) + helpers = { + (a, b) + for i, (a, b) in enumerate(zip(graph["initial"], graph["final"], strict=True)) + if i not in main + } + return helpers | {(a, b) for _, a, b in graph["moves"]} + + +def word(graph, layout): + from powered import PoweredWord + from tagged_sources import PINS, complex_ports, pinned + import tagged_sources + + local = { + key: pinned(key, PINS[key]) + for key in ("mixed_caller.py", "closed_caller.py", "data/CONJUGATE-CALLER.json.gz") + } + key = "data/CALLER.json.gz" + caller = tagged_sources.packed(pinned(key, PINS[key])) + raw = complex_ports(graph, layout, caller, local) + return PoweredWord(153, raw.targets, raw.paid, 128, 16, 12, 12) + + +@cache +def artifacts(grade, data): + """Construct every paid Clifford factor and true port from its signed frame.""" + from phase_atlas import catalogue as native_catalogue, coefficient_rows + from closed_caller import placement, templates + from mixed_caller import instructions, layout_bindings + from raw48 import contact, monomial, read_json + + graph, layout = load_changed(data) + catalogue = native_catalogue(graph, layout) + if digest(catalogue) != "8a9ff9558bf5fa3854699937fe063f98c86467d5d32a4488bfc878d2be081e70": + raise ValueError("The generated all-column Clifford catalogue differs") + tables = Path(grade) / "retained/data" + bases = read_json(tables / "CALLER-PHASE-BASES.json")["by_q"] + contacts = [contact(q, tuple(bases[str(q)])) for q in layout["ports"]] + caller = read_json(tables / "CALLER.json.gz") + words, roots = templates(caller), placement(caller) + binds, offsets, census = layout_bindings(words, roots, layout, 48) + hosted = layout["hosted"] + pairs = dict(zip(hosted["Dports"], zip(hosted["X2"], hosted["Y2"], strict=True), strict=True)) + regs = [(x, x + 112) + pairs.get(i, ()) for i, x in enumerate(layout["live"])] + return SimpleNamespace( + graph=graph, + layout=layout, + contacts=contacts, + words=words, + roots=roots, + offsets=offsets, + instructions=lambda: instructions(words, roots, binds, offsets), + binding_receipt=census, + factors={ + (a, b): (r["rank"], monomial(r["right"]), monomial(r["left"])) + for a, b, r in catalogue["pairs"] + }, + port=[(monomial(left), monomial(right)) for _, left, right in catalogue["ports"]], + regs=regs, + main={n for row in regs for n in row}, + odd=ODD, + moves={i: (a, b) for i, a, b in graph["moves"]}, + forms=coefficient_rows(graph["forms"]), + ) diff --git a/research/p104-two-type-threshold/source/canonical/tagged_sources.py b/research/p104-two-type-threshold/source/canonical/tagged_sources.py new file mode 100644 index 0000000000..a3caf3390e --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/tagged_sources.py @@ -0,0 +1,123 @@ +"""Read the ordered 36-call and 48-call words from their authenticated source.""" + +import gzip +import hashlib +import importlib.util +import json +from pathlib import Path +import sys +from tempfile import TemporaryDirectory + +from powered import Port, bit_word, complex_word + +NATIVE = "a7f99a5f5f919dd3ffb2987f90c1e7d6527feb1e" +BASE = "e54523517d0f03e58352e647c403a5af3e525a57" +ROOT = "research/grade14-native-realization/retained/" +PINS = { + "data/complex.json.gz": "1b1b3294e86979f1f41076fb056f3c0a08ace6df7bf80f2886bc579a22962f4b", + "data/binary.json.gz": "d28f0d28d9d87d5fe57b8ef19e12faf98014f0bbef781987ce22daaa82f21cb9", + "data/layout.json.gz": "b0f3ebc5710e469f3e8fc5ce159cbba048b563944182b50993431ef94f4fedbf", + "data/CALLER.json.gz": "d889996a337f648087208ab51c98eaf052705d4fca88b5d01b6e9257a829897a", + "data/CONJUGATE-CALLER.json.gz": "80009663da460229a57f09bde90e35294329a210ae7fc7ef6d1f05b61ffccbf4", + "closed_caller.py": "b82b9710d85d62e0f98aa1a1d7c70f97bdbdd64a6e4c92406019ca580a8c52ce", + "mixed_caller.py": "4824b2aaadb592550d3a25c16ff0a453705e10b8868f5c22fe10c2874bcb9bae", +} +BIT_CALLER = "research/paired-query-only-bit/EFREE-CALLER.json.gz" +BIT_PIN = "757b3523798f840bdb02028b23708c3416627a99ea09e7a3c4bcdc5cd0c7ce4b" + + +def pinned(name, digest): + path = Path(__file__).resolve().parent / "vendor" / Path(name).name + data = path.read_bytes() + if hashlib.sha256(data).hexdigest() != digest: + raise ValueError(f"Wrong source bytes at {name}") + return data + + +def packed(buffer): + return json.loads(gzip.decompress(buffer)) + + +def binary_ports(graph, caller): + starts, ends, frames = graph["start"], graph["final"], graph["frames"] + dims = {int(k): f["dim"] for k, f in frames.items()} + ports = caller["ports"] + paid, targets = [], [] + for i, entry in enumerate(caller["diagonal"]): + for p in range(ports): + targets.append(Port(("root", i, p), 1 + 7 * len(entry["stages"]))) + moves = [(k, row[1], abs(dims[row[2]] - dims[row[3]])) + for k, row in enumerate(graph["program"]) if row[0] == "MOVE"] + for clock, event in enumerate(caller["events"]): + if event[0] == "LOCAL": + for i in range(2 * ports, len(starts)): + targets.append(Port(("helper", clock, i), abs(dims[ends[i]] - dims[starts[i]]))) + for site, bank, rank in moves: + paid.append(Port(("move", clock, site, bank), rank)) + elif event[0] in ("QUERY", "IDLE_ONE"): + rank = 1 if event[0] == "QUERY" else 7 * len(event[2]) + for p in range(ports): + paid.append(Port((event[0], clock, p), rank)) + return bit_word(targets, paid) + + +def import_file(path, name): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def complex_ports(graph, layout, caller, programs): + with TemporaryDirectory() as directory: + root = Path(directory) + (root / "data").mkdir() + for name, data in programs.items(): + (root / name).write_bytes(data) + mixed = import_file(root / "mixed_caller.py", "mixed_caller") + old = sys.modules.get("mixed_caller") + sys.modules["mixed_caller"] = mixed + try: + closed = import_file(root / "closed_caller.py", "closed_caller") + finally: + if old is None: + del sys.modules["mixed_caller"] + else: + sys.modules["mixed_caller"] = old + words, roots = closed.templates(caller), closed.placement(caller) + binds, offsets, _ = mixed.layout_bindings(words, roots, layout, 48) + dims = tuple(map(len, graph["frames"])) + main = (set(layout["live"]) | {i + 112 for i in layout["live"]} + | set(layout["hosted"]["X2"]) | set(layout["hosted"]["Y2"])) + moves = {row: (a, b) for row, a, b in graph["moves"]} + targets, paid = [], [] + for (kind, root_id), visits in roots.items(): + for i, (sign, entries) in enumerate(words[kind][1]): + owner = offsets[kind, root_id] + i + targets.append(Port(("root", kind, root_id, owner, sign), 1 + 8 * len(entries))) + for clock, row in enumerate(mixed.instructions(words, roots, binds, offsets)): + op = row[0] + if op == "NATIVE": + call = row[1] + for i, (a, b) in enumerate(zip(graph["initial"], graph["final"], strict=True)): + if i not in main: + targets.append(Port(("helper", clock, call, layout["source_labels"][i]), dims[b] - dims[a])) + for node in graph["schedule"]: + if node in moves: + a, b = moves[node] + paid.append(Port(("return", clock, call, node), abs(dims[b] - dims[a]))) + elif op == "QUERY" or op.startswith("IDLE_"): + rank = 1 if op == "QUERY" else 8 * len(row[2]) + int(op == "IDLE_ODD") + paid.append(Port((op, clock, row[1]), rank)) + return complex_word(targets, paid) + + +def read_words(): + sources = {name: pinned(name,digest) for name,digest in PINS.items()} + bit_caller = packed(pinned(BIT_CALLER,BIT_PIN)) + bit = binary_ports(packed(sources["data/binary.json.gz"]), bit_caller) + programs = {name: sources[name] for name in + ("mixed_caller.py", "closed_caller.py", "data/CONJUGATE-CALLER.json.gz")} + comp = complex_ports(packed(sources["data/complex.json.gz"]), packed(sources["data/layout.json.gz"]), + packed(sources["data/CALLER.json.gz"]), programs) + return bit, comp diff --git a/research/p104-two-type-threshold/source/canonical/vendor/CALLER.json.gz b/research/p104-two-type-threshold/source/canonical/vendor/CALLER.json.gz new file mode 100644 index 0000000000..26a75a1ae3 Binary files /dev/null and b/research/p104-two-type-threshold/source/canonical/vendor/CALLER.json.gz differ diff --git a/research/p104-two-type-threshold/source/canonical/vendor/CONJUGATE-CALLER.json.gz b/research/p104-two-type-threshold/source/canonical/vendor/CONJUGATE-CALLER.json.gz new file mode 100644 index 0000000000..66185da4b0 Binary files /dev/null and b/research/p104-two-type-threshold/source/canonical/vendor/CONJUGATE-CALLER.json.gz differ diff --git a/research/p104-two-type-threshold/source/canonical/vendor/closed_caller.py b/research/p104-two-type-threshold/source/canonical/vendor/closed_caller.py new file mode 100644 index 0000000000..122d046f84 --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/vendor/closed_caller.py @@ -0,0 +1,59 @@ +"""Build the 48-call P104 word. See CLOSED-CALLER.md. Apache-2.0.""" +from collections import defaultdict + +from mixed_caller import need, split_templates + + +CALLS = 48 +CUT = 1641 + + +def templates(caller): + """Rotate the source word at its restored middle basis.""" + source = split_templates(caller) + original, targets = source['mixed'] + rotated = [] + for row in original[CUT:] + original[:CUT]: + op, first, *args = row + if op.startswith('HOST_'): + rotated.append([op, (first + 8) % 16, *args]) + elif op == 'IDLE_ONE': + rotated.append([op, first, [(j + 8) % 16 for j in args[0]]]) + else: + need(op in ('ADD', 'SCALE', 'SWAP', 'LAMBDA'), 'source ordinary opcode') + rotated.append(row) + hosts = [(r[0], r[1]) for r in rotated if r[0].startswith('HOST_')] + need(hosts == list(zip(['HOST_B'] + ['HOST_A'] * 14 + ['HOST_B'], range(16))), 'two end contacts') + outputs = [[q, [(j + 8) % 16 for j in mask]] for q, mask in targets] + return {'A': source['A'], 'rotated': (rotated, outputs)} + + +def placement(caller): + """Assign all physical ports at all calls. Each root uses every body color once.""" + ports = {k: sorted(s['ports']) for k, s in caller['types'].items()} + need(tuple(map(len, (ports['A'], ports['B']))) == (96, 8), 'physical port inventory') + roots = defaultdict(list) + used = [set() for _ in range(CALLS)] + for start in range(24): + for member, port in enumerate(ports['B']): + root = ('rotated', 8 * start + member) + for time in (start, start + 24): + roots[root].append((time, port)) + used[time].add(port) + + unused = [] + for color in range(16): + starts = [s for s in range(24) if color not in (s % 16, (s + 24) % 16)] + for time in range(color, CALLS, 16): + available = [s for s in starts if s < time < s + 24] + for group, start in enumerate(available[:12]): + starts.remove(start) + for member, port in enumerate(ports['A'][8 * group:8 * group + 8]): + roots['rotated', 8 * start + member].append((time, port)) + used[time].add(port) + need(not starts, 'all interior mixed visits fit') + unused.append([(t, p) for t in range(color, CALLS, 16) for p in ports['A'] if p not in used[t]]) + need(all(len(items) == 120 for items in unused), 'residual visits of each color') + for index, visits in enumerate(zip(*unused, strict=True)): + roots['A', index] = list(visits) + return {r: sorted(visits) for r, visits in sorted(roots.items())} diff --git a/research/p104-two-type-threshold/source/canonical/vendor/mixed_caller.py b/research/p104-two-type-threshold/source/canonical/vendor/mixed_caller.py new file mode 100644 index 0000000000..a7b85d921f --- /dev/null +++ b/research/p104-two-type-threshold/source/canonical/vendor/mixed_caller.py @@ -0,0 +1,186 @@ +"""Construct the finite P104 caller with sixteen body blocks. Apache-2.0.""" +from collections import Counter, defaultdict +from fractions import Fraction +from hashlib import sha256 +from pathlib import Path +import gzip +import json + +HERE = Path(__file__).resolve().parent +MIXED_SHA256 = '54a44134a6f9bb3d9e1a27d3bd7ba5fb1cffea3cdfe00f6a72e80f0bbd99d2d7' + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def split_templates(caller): + """Use zero-based stage colors and private register numbers in each template.""" + words = {} + for kind, spec in caller['types'].items(): + off = spec['offset'] + events = [] + for event in caller['events']: + if event[0] == 'J': + if kind == 'A': + regs = event[2] + need((Fraction(spec['alpha2']), Fraction(spec['beta2'])) == (-1, 0), + 'secondary shear coefficients') + else: + regs = event[3][:2] + need(tuple(map(Fraction, event[3][2:])) == (-1, Fraction(1, 2)), + 'coupled port coefficients') + events.append(['HOST_' + kind, event[1] - 1, *(i - off for i in regs)]) + elif event[0] == kind: + op, target, *args = event[1:] + target -= off + if op == 'ADD': + args = [args[0] - off, [args[1], '0']] + elif op == 'SCALE': + args = [[args[0], '0']] + elif op in ('SWAP', 'QUERY'): + args[0] -= off + elif op in ('IDLE_ONE', 'IDLE_ODD'): + args[0] = [j - 1 for j in args[0]] + else: + need(op == 'LAMBDA', 'known inherited caller event') + events.append([op, target, *args]) + rows = [] + for phase, scalar, *mask in spec['diagonal']: + need(scalar == 0 and len(mask) == 16 and set(mask) <= {0, 1}, 'source target mask') + rows.append([phase, [j for j, bit in enumerate(mask) if bit]]) + words[kind] = (events, rows) + raw = gzip.decompress((HERE / 'data/CONJUGATE-CALLER.json.gz').read_bytes()) + need(sha256(raw).hexdigest() == MIXED_SHA256, 'conjugate word digest') + mixed = json.loads(raw) + need((mixed['schema'], mixed['roles'], mixed['local_calls']) == ('p104-conjugate-root/1', 30, 16), + 'conjugate word schema') + words['mixed'] = (mixed['events'], mixed['diagonal']) + for kind, (events, rows) in words.items(): + heads = [e for e in events if e[0].startswith('HOST_')] + need([e[1] for e in heads] == list(range(16)), 'sixteen ordered calls per root') + if kind == 'mixed': + need([e[0] for e in heads] == ['HOST_A']*7 + ['HOST_B']*2 + ['HOST_A']*7, + 'two central quarter-turns') + for op, *args in events: + if op.startswith('HOST_'): + regs = args[1:] + need(len(regs) == len(set(regs)) == (4 if op == 'HOST_A' else 2), + 'native template input width') + else: + regs = args[:2] if op in ('ADD', 'SWAP', 'QUERY') else args[:1] + need(all(0 <= r < len(rows) for r in regs), 'local register owner') + need(all(q in (-1, 1) and ss and len(set(ss)) == len(ss) and all(0 <= j < 16 for j in ss) + for q, ss in rows), 'positive whole recursive targets') + return words + + +def place_roots(caller, calls): + """Return one chronological list of (real call, physical port) per root.""" + need(calls >= 32 and calls % 16 == 0, 'whole batches of sixteen calls') + ports = {k: tuple(s['ports']) for k, s in caller['types'].items()} + need(len(ports['A']) == 96 and len(ports['B']) == 8 and + sorted(ports['A'] + ports['B']) == list(range(104)), 'native port partition') + occupied = [set() for _ in range(calls)] + roots = defaultdict(list) + starts = range(2, calls - 15, 2) + for block, start in enumerate(starts): + for slot in range(16): + t = start + slot + kind = 'B' if slot in (7, 8) else 'A' + free = [p for p in ports[kind] if p not in occupied[t]][:8] + need(len(free) == 8, 'eight free ports for a new group') + for pair, port in enumerate(free): + roots['mixed', 8*block + pair].append((t, port)) + occupied[t].update(free) + for kind, pp in ports.items(): + by_color = [[] for _ in range(16)] + for t in range(calls): + by_color[t % 16].extend((t, p) for p in pp if p not in occupied[t]) + need(len({len(v) for v in by_color}) == 1, 'equal capacity in the sixteen colors') + for i, visits in enumerate(zip(*by_color, strict=True)): + roots[kind, i] = sorted(visits) + return dict(sorted(roots.items())) + + +def layout_bindings(words, roots, layout, calls): + """Bind every template occurrence to distinct native main and helper addresses.""" + hosted = layout['hosted'] + second = dict(zip(hosted['Dports'], zip(hosted['X2'], hosted['Y2'], strict=True), strict=True)) + need(len(layout['live']) == 104 and len(second) == 96, 'all physical ports') + need(tuple(Fraction(hosted[k]) for k in ('alpha', 'beta', 'alpha2', 'beta2')) == + (-1, Fraction(1, 2), -1, 0), 'signed native coefficients') + slots = {p: (x, x+112) + second.get(p, ()) for p, x in enumerate(layout['live'])} + main = {r for regs in slots.values() for r in regs} + labels = layout['source_labels'] + need(len(labels) == len(set(labels)) == layout['public'] and len(main) == 400 + and main <= set(range(len(labels))), 'physical owner inventory') + helpers = sorted(label for r, label in enumerate(labels) if r not in main) + local = {k: [e for e in ev if e[0].startswith('HOST_')] for k, (ev, _) in words.items()} + bound = [{} for _ in range(calls)] + offsets = {} + roles = 0 + for root, visits in sorted(roots.items()): + kind, _ = root + need(len(visits) == 16 and visits == sorted(visits) and + sorted(t % 16 for t, _ in visits) == list(range(16)), 'independent root colors') + offsets[root] = roles + for j, (t, port) in enumerate(visits): + op, slot, *regs = local[kind][j] + native_kind = 'A' if port in second else 'B' + need(0 <= t < calls and port in slots and op == 'HOST_' + native_kind and slot == j, + 'native port type and time') + need(port not in bound[t] and len(set(regs)) == len(regs) == len(slots[port]), + 'signed main owner alias') + bound[t][port] = [r + roles for r in regs] + roles += len(words[kind][1]) + digest = sha256() + helper_digest = sha256(json.dumps(helpers, separators=(',', ':')).encode()).hexdigest() + for t, ports in enumerate(bound): + need(set(ports) == set(slots), 'all physical ports at each call') + labels_in_use = {label: owner for port in ports + for label, owner in zip(slots[port], ports[port], strict=True)} + need(set(labels_in_use) == main and len(set(labels_in_use.values())) == 400, + 'four hundred independent main inputs') + # A helper address is (native occurrence, source label). Caller owners have a separate namespace. + record = [t, t % 16, sorted(labels_in_use.items()), helper_digest] + digest.update(json.dumps(record, separators=(',', ':')).encode()) + counts = Counter(root[0] for root in roots) + receipt = dict(calls=calls, local_colors=16, ambient=137, template_roots=dict(counts), + root_owners=roles, stage_helper_owners=calls*len(helpers), + physical_port_contacts=104*calls, native_main_bindings=400*calls, + stage_binding_sha256=digest.hexdigest(), helper_label_sha256=helper_digest) + return bound, offsets, receipt + + +def instructions(words, roots, bindings, offsets): + """Emit the full chronological program. A NATIVE row contains all 104 port bindings.""" + chunks = {} + for kind, (events, _) in words.items(): + chunks[kind] = [[]] + for op, *args in events: + if op.startswith('HOST_'): + chunks[kind].append([]) + else: + chunks[kind][-1].append((op, args)) + tails = defaultdict(list) + for root, visits in sorted(roots.items()): + times = [t for t, _ in visits] + [len(bindings)] + for t, block in zip(times, chunks[root[0]], strict=True): + tails[t].append((offsets[root], visits, block)) + for t in range(len(bindings)+1): + for offset, visits, block in tails[t]: + for op, local in block: + args = local.copy() + args[0] += offset + if op in ('ADD', 'SWAP', 'QUERY'): + args[1] += offset + if op.startswith('IDLE_'): + args[1] = [visits[j][0] % 16 for j in args[1]] + yield [op, *args] + if t < len(bindings): + ports = [bindings[t][p] for p in range(104)] + yield ['PORT_VIEWS', 'ENTER', t, ports] + yield ['NATIVE', t, t % 16, ports] + yield ['PORT_VIEWS', 'EXIT', t, ports] diff --git a/research/p104-two-type-threshold/source/upstream/LICENSE b/research/p104-two-type-threshold/source/upstream/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/p104-two-type-threshold/source/upstream/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/p104-two-type-threshold/source/upstream/NOTICE.md b/research/p104-two-type-threshold/source/upstream/NOTICE.md new file mode 100644 index 0000000000..cac7f9814f --- /dev/null +++ b/research/p104-two-type-threshold/source/upstream/NOTICE.md @@ -0,0 +1,5 @@ +# Attribution + +Ali Romman supplied the signed #8057 frequency-weighted Gaussian producer, both native widths, signed caller and compiler, and the earlier #8055 setup proof. SYLforge supplied the #8052 K7 ordinary circuit and physical replay. The prior allocation proofs at #8068–#8069 supply the exact integer comparison method. #8070 supplies the Gaussian booking and #8071 the finer ordinary booking and the complete signed comparator. This package changes the terminal allocation at the simultaneously charged limits. The signed operator schedules and purpose-specific native implementation are inherited. + +The archive retains its exact Apache-2.0 sources and notices. The separate historical CI prerequisite reuses Jerry Chen's #7257 source navigation and historical snapshot repair. OpenAI Codex materially assisted the mathematical screen, literal retune and independent replay. [Predecessor scientific source](https://github.com/CrocSwap/integer-mult-bounds/tree/cbe847a953b971f9c6c5a0a6661e2008acd29086/research/frequency-weighted-native-multiplier) · [Proof and credits](PROOF.md) · [License](LICENSE) diff --git a/research/p104-two-type-threshold/source/upstream/PEER-SOURCE.json b/research/p104-two-type-threshold/source/upstream/PEER-SOURCE.json new file mode 100644 index 0000000000..6f84b3aef4 --- /dev/null +++ b/research/p104-two-type-threshold/source/upstream/PEER-SOURCE.json @@ -0,0 +1,94 @@ +{ + "archive_sha256": "0e0d559bdb15e7b647f88a2b5e27fcdc9e28e81d8f4145459876ba6da2e9314c", + "files_sha256": { + "research/frequency-weighted-native-multiplier/FINITE-LOSS.md": "12c6069437a0cbb61c80804f89f027ef9709c186e67d26fb0584ad6e71048052", + "research/frequency-weighted-native-multiplier/GaussianFiniteLoss.lean": "9d247f73d9da2748399b821612b30f20140783c08d761b6d4ef7d3c7c3d07064", + "research/frequency-weighted-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/frequency-weighted-native-multiplier/MEASUREMENTS.json": "9ea26ae002146ae21291ecc0a6b224e5cccb9e3b5d199522558a645863da4f7b", + "research/frequency-weighted-native-multiplier/NOTICE.md": "02e69a1d57e2208ce49b3362a5672136887c1968d66de83a8f358e6d4a9353df", + "research/frequency-weighted-native-multiplier/PROOF.md": "4dbb38cdbe5b691edf4845fe8cf2a99be5d43455cc73199ab7e305abaa91acca", + "research/frequency-weighted-native-multiplier/README.md": "173313f895d9f810e5c32853ff383c8ee962e475dead35e5634047aa9c8a1453", + "research/frequency-weighted-native-multiplier/RESULT.json": "2f4faa6648592f589df22a8a0a07ba6856d20786294a44a7776c7d6e0efa14a5", + "research/frequency-weighted-native-multiplier/SOURCES.json": "01d9e6b6b28cd174800cadfb59f4f064b3844575da297d82e16eb19a0d11c868", + "research/frequency-weighted-native-multiplier/TASK.json": "9db85415d252a595907a8c1ddf8ce64acc5c0aa67dc8f6b4656139053bb40a52", + "research/frequency-weighted-native-multiplier/VERIFICATION.md": "58568a8f5e097a1d828aeff33ea33c63863c4b28dd1a87fd7dca9adebb5d6c1f", + "research/frequency-weighted-native-multiplier/VERIFY.json": "4f5506a41e62585e34c80c6838922d33b04d42e010fab310690f340a5be3721e", + "research/frequency-weighted-native-multiplier/WeightedNumerical.lean": "2017bae8064554efb13c564503d8f88c4615e9f733a74aa5eaf4047e5bd8af94", + "research/frequency-weighted-native-multiplier/bootstrap.py": "a824c0ba9bb5efe5ad5b6c9b891b363b6d2ac31b0a57b9e27b68a6c2bca6f7ee", + "research/frequency-weighted-native-multiplier/check_calendar.py": "1c51b8bd75ef2d9d8847b2ebf88d7dbcc44d89954146c2bdede8854915392b8c", + "research/frequency-weighted-native-multiplier/check_exterior.py": "aee4fd29eb2fa021f806c987e0db23ecb7148e5dc846581f62d3ba39ed7ef725", + "research/frequency-weighted-native-multiplier/check_lean.py": "32e49adef4502f193b5ded2cc4e7f8cea6a285283fda4db2152570a4b68098cb", + "research/frequency-weighted-native-multiplier/check_nested.py": "9b2eaf387abbeeef43dd9bb31081ba73f3423e8233fb3446d61fce802a1c6b5b", + "research/frequency-weighted-native-multiplier/check_ownership.py": "a1fdaf5eaaa4215bc90051db48e17d0bf9cf7fe03f67a4d2bdf4e328f3c1a73a", + "research/frequency-weighted-native-multiplier/check_placement.py": "e4317a1eb36f692912ca4739364859118711620838705d8e33b1eabec32b0990", + "research/frequency-weighted-native-multiplier/check_raw.py": "d62d50279969bfecf23d2e14412949fa643394c1539ccb87db7dac5f79e2d97e", + "research/frequency-weighted-native-multiplier/grades.py": "8d2e3d14ac2149f985d7f6a75bf36182d7f68aadf8df6595fc0774224d4951ac", + "research/frequency-weighted-native-multiplier/independent_price.py": "448811cdb4a2bdefd4f736c2bad81c2a833bde634bcf65498e05267b5ee7ead0", + "research/frequency-weighted-native-multiplier/measure_setup.py": "cbfe019024fbeee428c415549db10180af69995078825b6341bc9021f3d08723", + "research/frequency-weighted-native-multiplier/portable/EVIDENCE.json": "3bfffdda94bbc6a14282399eca69b8619c96bd587c7957b3bdf854e03ef89427", + "research/frequency-weighted-native-multiplier/portable/NOTICE.md": "57d7e187fb48df97838976a7942e41dc381f00daeff7c2b5c392fb1a6f252517", + "research/frequency-weighted-native-multiplier/portable/README.md": "141d07df12c9e5352a8f83a03a033dd2c41cc5d0d6e0edb3532cab462536a974", + "research/frequency-weighted-native-multiplier/portable/STACK-LOCALITY.md": "0211732aaa6083a305e861f8172b581b0a9c98e10191d8432d546ee224c0bf5f", + "research/frequency-weighted-native-multiplier/portable/TRACE-CLOCK.md": "9f2b0d125cc35f91bb037363505d027331c79153211ea21de838405ae01a1a2a", + "research/frequency-weighted-native-multiplier/portable/bounded_wasi.py": "8232cc247e5910aab7a0fecb03426088c8f851fd93cbf8fb3587a4a5d7ee143d", + "research/frequency-weighted-native-multiplier/portable/compare.py": "7a906b2b871011595f66882897e7ff0fa79f007fc7887ae0c21b555d778a75c8", + "research/frequency-weighted-native-multiplier/portable/compiler_state.py": "11f371903410a53aa138bb9b9c49e9441393a34092fff922716a78b5521e1870", + "research/frequency-weighted-native-multiplier/portable/consumer.py": "411cc1052a70f7084de81f6f1e54636737d5e5155d0756b8271d5d82c268d3b3", + "research/frequency-weighted-native-multiplier/portable/fixed_directory.py": "c99e9945295b954b453f4995474db4ec8da9e7d8d6ba1a564456213d066e5904", + "research/frequency-weighted-native-multiplier/portable/guest_opcodes.py": "9b2a1b128939cc8d2ef379199c09af74c52ed4b696640fce01606c431d931db6", + "research/frequency-weighted-native-multiplier/portable/module_census.py": "f22218fc37012f5c14b17afba3e8b868fd7268f25931836397f00fbdd319f6f7", + "research/frequency-weighted-native-multiplier/portable/producer.py": "5a76b94efb0bb59a686255f212b532a0f44a586649befda07dbfc5fe86c6a8b7", + "research/frequency-weighted-native-multiplier/portable/record_census.py": "8132c345cfcc5e7d89494fa437685673273f878f2dc40e0187bf2b84eee17e08", + "research/frequency-weighted-native-multiplier/portable/run.py": "6a1e17556326107cac9e70f446b2a90c35e9b4b07bfb7c4b31e5fe9b081f7d9b", + "research/frequency-weighted-native-multiplier/portable/signed.py": "7620e713be7a8064c5b9f83e6573cfabab801b627f0133b7998fdb51a6bac449", + "research/frequency-weighted-native-multiplier/portable/source_image.py": "e354c3fb2bb05eb36dc2438d89c30b18b7973638c51af526d8e55b56803c73ba", + "research/frequency-weighted-native-multiplier/portable/tape_directory.py": "70bf289334f724cabf1cfa9e074199e6be93ef0aeba8193f279e5ef1336de97b", + "research/frequency-weighted-native-multiplier/portable/verify_receipt.py": "8b42d3c5f35d6810321eb000e10b4e5593d543296cc670c3c8847e7051c1b30c", + "research/frequency-weighted-native-multiplier/positive_debit.py": "7320b6a4ef1320d765e9b41a9b1e286db83a1d36d96f46bee0bef37974e8b8d9", + "research/frequency-weighted-native-multiplier/receipt.py": "82d921fdc33006e2d356d8bf78f3c85777722322d716be44b42bc763a04c8095", + "research/frequency-weighted-native-multiplier/runtime.patch": "f35d37cc1746b5a7ac137a3f6de6de887a24f3af578283c24a64c8a25ccc584b", + "research/frequency-weighted-native-multiplier/typed_raw.py": "0c268432c9d48798c17d927f2d900b5e69dfc6585166cd71f253913e389c3b47", + "research/frequency-weighted-native-multiplier/typed_transport.py": "b76b9ad3dc0dd91473026c079585f830387eaa3c34c25a7820ee5057d5cbf941", + "research/frequency-weighted-native-multiplier/verify.py": "07730c6859c26de43b8621bf7e5b778187f41ac17419569ada7c6e10f5d04d4a", + "research/tiered-native-multiplier/CLOCK.md": "cf71e4a3216df23eb7e4fa8a8d9de3735e6257c65ca8a60a5085d9f3c90c4ecb", + "research/tiered-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/tiered-native-multiplier/MEASUREMENTS.json": "a1083bc55178baf0015ef83ef169f45df61475fcc648f487e03c852c871f1f00", + "research/tiered-native-multiplier/NOTICE.md": "c386dabe3fd1d046bddc782c671219757c7708e9ec874a6ede55b540edc95f2c", + "research/tiered-native-multiplier/NUMERICAL.md": "14b86724db522393981ed54b540a35f27bd952f3d95d6e6d14c5b23896811dc9", + "research/tiered-native-multiplier/README.md": "d2c214591f03313dece24592cde3193deffb2f1057b891604597b5e8c6d020ca", + "research/tiered-native-multiplier/RESULT.json": "661e16fcb533b69b97ad2dc91ab81bed79c44e7fdce01306ce573cb6f0ed7fa7", + "research/tiered-native-multiplier/SERIAL-SETUP.md": "1ca7e23ae113647605a31fa309c3bbdde2baf2d442913247fcda4c8a1eef7e7c", + "research/tiered-native-multiplier/SETUP.md": "6951a98f2f8a0bf73c8d60b16ebbbd66bf87584251df8afbefe4e3a0330bfbf3", + "research/tiered-native-multiplier/SOURCES.json": "7a10012734132909e99b0c6160d68d0b8647e1607d25679efb1f5315cf8e23de", + "research/tiered-native-multiplier/ScaledEntrance.lean": "e404be78622db98e9c3b490a15d0e9f002a2cf1eee9ecbd0a9516efbd0db5329", + "research/tiered-native-multiplier/TASK.json": "2cfe7fe1ea4ee8cd07d24048d45e543fdb8a6fa6585ebdc20b1ede55982a16a7", + "research/tiered-native-multiplier/TierCost.lean": "668a248d1060dd4fe97a0edb6652cb3782b8ba4ccc0d00ec73ee6ae253eb9945", + "research/tiered-native-multiplier/VERIFICATION.md": "343f4b2de9b49c1536d35046eee086898bad48023b7da528c5096ca43a1358d0", + "research/tiered-native-multiplier/VERIFY.json": "c684d5b86039809900c85fb0ce64d531db23c62e06bfcf210d6b2cc349480492", + "research/tiered-native-multiplier/bootstrap.py": "74ac8f1d3af21f86cda48a3d50084d6fa5faf84b44ec2e5929b587f40f5bcfd1", + "research/tiered-native-multiplier/check_gaussian.py": "383a3385bc9763d6eb557163ee62aa9ab999b0d98c719a004db87abfee063d24", + "research/tiered-native-multiplier/check_lean.py": "0d53ee2a814887bb53e78f62f2d2e73544641f2cac470dbecec93cdb0aa17203", + "research/tiered-native-multiplier/check_phase_passes.py": "6afd65da931476680d88cb54336ffedf531c3063af181f75403d511e24e83b94", + "research/tiered-native-multiplier/check_placement.py": "d416329ba75727d8f968abc39caded0c1a1fd3f21ffc9286274c5b834aab7154", + "research/tiered-native-multiplier/check_serial_setup.py": "11d1c3209cb523a360ab9abaefb3122507fdf5cb469169890fe2dac636812c47", + "research/tiered-native-multiplier/grades.py": "340684fdd5ca0e611836b0e7301f1c339282ba532bf9e3ec8055944d8981f3c8", + "research/tiered-native-multiplier/independent_price.py": "0b2ecc4a1845a2807782644b6b2675e2fcb194fcbb3ae80b50af9a775363e952", + "research/tiered-native-multiplier/installations.py": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df", + "research/tiered-native-multiplier/measure_setup.py": "896349b654c7b8195e9823beaee080d2d30b3f72a562de90c7b6e2554bdd20bb", + "research/tiered-native-multiplier/receipt.py": "3d0219eb2262ea64ccf2dc8da4d2877e32c519c4670d99577703f8bfc236ba61", + "research/tiered-native-multiplier/runtime.patch": "6c93961841be2abc3629928074e2c7917d264e94187276fc88a33f922a3c62e4", + "research/tiered-native-multiplier/serial_setup.py": "61b5058d394ed74e943303e4bdbf21d58ccf5d8bb39fc4b02e97bc135d7bdbbc", + "research/tiered-native-multiplier/source/INSTALLER-NOTICE.md": "c6b1753ad6ebda2a2143b1a9efc80fadad6c1b27552c3ec8bc7bfdb431fb8eeb", + "research/tiered-native-multiplier/source/K7-NOTICE.md": "9c5ae9750012d305d917e625d14a33cc880e810e801e73364725bcdc24bffdb5", + "research/tiered-native-multiplier/source/K7-STACK-LEDGER.json": "a0c0d5b241e6861a5c49a287617e48fba56b09824f5ef4fcb7f03152edf37e8e", + "research/tiered-native-multiplier/source/activation.py": "6e7f89d40a4d10ecd40a50e5b96334dfc64db90841ece7e3ef12eeca5ee5093b", + "research/tiered-native-multiplier/source/check_binary_k7.py": "5eeb8f818725249cbabf215c323c3f8351b1c4ed3c127119341e6ed09f490dd6", + "research/tiered-native-multiplier/source/installer.tar.gz": "6696459e2e3552f802e7caaaf93dc86c9bb6b62ee38631702bff2e3a8a9a481a", + "research/tiered-native-multiplier/source/ordinary_clock.py": "91dcf0ef72dddbde998b80f3d8b30c8036de9ce97e06e2bbd9c4159bf292020d", + "research/tiered-native-multiplier/source/outer_budget.py": "ca4438db28a447ed5c43d87d43f0ac10a0cb2b4e183342ac93139d517b9d4d02", + "research/tiered-native-multiplier/source/outer_clock.py": "63363c3da673365f3ac5e1b7e318c6938005f1e9c9896799504cc598efbf96fa", + "research/tiered-native-multiplier/source/strong-bit-k7.json.gz": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "research/tiered-native-multiplier/verify.py": "d6cf9085e87743db14932a21cf895f8bd4d0f126b6c0bb7220d3255268dba39a" + }, + "head": "cbe847a953b971f9c6c5a0a6661e2008acd29086" +} diff --git a/research/p104-two-type-threshold/source/upstream/prepare.py b/research/p104-two-type-threshold/source/upstream/prepare.py new file mode 100644 index 0000000000..048698f08d --- /dev/null +++ b/research/p104-two-type-threshold/source/upstream/prepare.py @@ -0,0 +1,258 @@ +"""Install the capped height optimizer on the exact weighted producer.""" +from hashlib import sha256 +import json + +NEW_INSTALLATION = "c1bba07dfcf95f7a494e59d6e4de85b4d4537c144f0bcf6f7a1a02ecbe832dea" +RAW_FLOOR_IMAGES = { + "before": "0c805a525322acf4eb03f083c2c763f3046c3d488e1f993beb484a3e2c2ff4a9", + "after": "e24bd735598d278dbd46cada584a63da01796d77ad557a45b80a4dfc7bbbd0b0", +} +RAW_FLOOR_PATCH = """--- a/raw_binary_stage.py ++++ b/raw_binary_stage.py +@@ -45,7 +45,7 @@ + @cache + def binary_recipe(height): + word = binary_word() +- return Recipe(height, word.tagged.ambient, word.targets, word.paid, word.cells, BINARY_C) ++ return Recipe(height, word.tagged.ambient, word.targets, word.paid, word.cells, BINARY_C, level_floor=18960) +""" + " \n \n def run(recipe, fields, machine):\n" + + +def replace(path, replacements): + source = path.read_text() + for old, new in replacements: + if source.count(old) != 1: + raise ValueError(f"Expected one change point for {old!r} in {path.name}") + source = source.replace(old, new) + path.write_text(source) + + +OLD_EDGE = ''' # The first three positive terms of log(k/r) suffice for each real edge. + psi = Q(0) + for (r, k), share in cells.items(): + u = Q(k - r, k + r) + log_lower = 2 * (u + u**3 / 3 + u**5 / 5) + psi += paid[r] * share * r * log_lower''' + +DIRECTED_EDGE = ''' # Integrate each exact directed edge, retaining both rounding ends. + # A downward ratio of outward powers bounds ((k/r)^c-1)/c. + psi = Q(0) + for (r, k), share in cells.items(): + floor = intervals(k, c)[0] * UNIT // intervals(r, c)[1] + assert floor > UNIT + psi += paid[r] * share * r * (Q(floor, UNIT) - 1) / c''' + +NATIVE_SETUP = ''' setup = native_clock() + grade_count = len(low[-1].paid.histogram) + len(low[-1].targets.histogram) + actual_roles = sum(len(v.targets) + len(v.paid) for v in high[-1].types()) + assert actual_roles < 2**20 and grade_count < 2**8 + assert len(low) + len(high) == 7 and max(heights[-1].bit_length() for heights in (ENTRY.rank_logs, TERMINAL.rank_logs)) <= 20 + grade_actions = 2**20 * 256 + 2**8 * 256 * 8 + 32 * (grade_count + 2)**2 + 2**12 + assert grade_actions < 2**32 and setup["all_setup"] < 2**228''' + +DIRECTED_ORDINARY = '''def ordinary_debit(): + delta = Q(1, 2**128) + def bounds(floor): + multiplier = ( + Q(47, 20) * Q(256, 255) * Q(4097, 4096) * Q(1028, 1024) + * (1 + Q(64, floor) + delta) / ((1 - Q(10, floor)) * (1 - delta)**3) + ) + lo, hi = powers(1024 * 134 * floor, BINARY_C) + return multiplier * lo, multiplier * hi + + lo, hi = bounds(18960) + old_lo, old_hi = bounds(32768) + allowance = 2 * powers(2, Q(3047, 8192))[0] + finer_allowance = 2 * powers(2, Q(6093, 16384))[1] + assert allowance - hi > Q("0.000062662376093595") + assert lo - finer_allowance > Q("0.000046832527238212") + assert hi**1024 < 2**1405 < old_lo**1024 + assert old_hi**512 < 2**703 + assert Q(75, 32) / Q(47, 20) == Q(375, 376) + print("PASS_DIRECTED_ORDINARY_DEBIT", 18960, "11239/8192", "375/376") + + +''' + +EDITS = { + "runtime.patch": ( + ('TERMINAL = Profile((8192, 129414, 524288), 483871, Q(".00389821"))', + 'TERMINAL = Profile((8192, 124649, 524288), 490950, Q(".003898214283192"))'), + ), + "positive_debit.py": ( + ("from strict_moment import UNIT, power_interval", "from strict_moment import UNIT, power_interval\nfrom unpowered_price import intervals"), + ("POSITIVE_DEBIT = Q(65081, 524288)", "POSITIVE_DEBIT = Q(64939, 524288)"), + (OLD_EDGE, DIRECTED_EDGE), + ("assert psi > Q(1790217668064, 10000)", 'assert psi > Q("926899828.8291")'), + ("assert fringe < Q(7579, 1000)", 'assert fringe < Q("7.335168")'), + ), + "receipt.py": ( + ('sys.path.append(str(HERE / "portable"))', 'sys.path.append(str(HERE.parent / "tiered-native-multiplier"))'), + ("from verify_receipt import verify as fixed_installation", "from check_serial_setup import clock as native_clock"), + ("DEBIT = Q(65081, 2**19)", "DEBIT = Q(64939, 2**19)\nORDINARY_DEBIT = Q(11239, 8192)"), + ("def tape_factor(ambient, rate):", "def tape_factor(ambient, rate, lower):"), + (" delta, lower = Q(1, 2**128), 32768", " delta = Q(1, 2**128)"), + ("assert ordinary.ambient == 134 and ordinary.trial == BINARY_C", + "assert ordinary.ambient == 134 and ordinary.trial == BINARY_C\n" + " assert ordinary.level_floor == 18960"), + ("Q(11, 8 * height)", "ORDINARY_DEBIT / height"), + ("Q(11, 8) / (BINARY_C - TERMINAL.ordinary)", + "ORDINARY_DEBIT / (BINARY_C - TERMINAL.ordinary)"), + (" assert (tape_factor(134, BINARY_C) * Q(47, 20)) ** 8 < 2**11", + " ordinary_upper = Q(2588135791281, 10**12)\n assert tape_factor(134, BINARY_C, 18960) * Q(47, 20) < ordinary_upper\n assert ordinary_upper**8192 < 2**11239\n" + " assert Q(75, 32) / Q(47, 20) == Q(375, 376)"), + ("assert cost == 318259431 and premium == 514", "assert cost == 318292011 and premium == 515"), + ("(517430, 483870)", "(517115, 490950)"), + ('older = Q(".0038982016137")', 'older = Q(".00389821412325")'), + ("assert gain == Q(83863, 10**13)", "assert gain == Q(79971, 500000000000000)"), + (" complete_log2_C=cost,", " complete_log2_C=cost,\n" + " ordinary_floor=18960,\n" + " ordinary_finite_debit=str(ORDINARY_DEBIT),\n" + ' ordinary_child_contraction="375/376",'), + (" setup = fixed_installation()", NATIVE_SETUP), + (''' log2_fixed_setup_upper=setup["trace_exponent"], + log2_portable_setup_guard=setup["conservative_exponent"], + log2_full_store_setup_upper=setup["full_store_trace_exponent"], + portable_setup_transition_upper=setup["transitions"],''', + ''' log2_fixed_setup_upper=setup["setup_exponent"], + native_setup_transition_upper=setup["all_setup"], + native_setup_grade_actions=grade_actions,'''), + ), + "independent_price.py": ( + ("lower = powers(2, Q(65081, 524288))[0]", "lower = powers(2, Q(64939, 524288))[0]"), + ('assert lower - upper > Q("0.00012957")', 'assert lower - upper > Q("0.000007887415")'), + ("TERMINAL.kappa - peer == Q(83863, 10**13)", "TERMINAL.kappa - peer == Q(126694920, 10000000000000000)"), + ("def rounded_peer():", DIRECTED_ORDINARY + "def rounded_peer():"), + (" weighted()\n rounded_peer()", " weighted()\n ordinary_debit()\n rounded_peer()"), + ), +} + + +# Apply exact real-integer frequencies and reprice the full typed calendar. +EDITS["runtime.patch"] += ( + ("+GAUSSIAN_C = Q(17145637167, 2**42)", "+GAUSSIAN_C = Q(17145637307, 2**42)"), +) +EDITS["grades.py"] = (("WEIGHTS = (1, 90)", "WEIGHTS = (5, 451)"),) +EDITS["positive_debit.py"] += ( + ("assert target_axes == 135150528", "assert target_axes == 677246016"), + ("assert 91 / (t * 2**10)", "assert sum((5, 451)) / (t * 2**10)"), +) +EDITS["receipt.py"] += ( + ("def raw_counts(base, multiplicity):", "def raw_counts(base, multiplicity, primary=1):"), + ("t, p = targets.copy(), paid.copy()", + "t = Counter({grade: entry * primary for grade, entry in targets.items()})\n" + " p = Counter({grade: entry * primary for grade, entry in paid.items()})"), + ("p[1] -= 1008\n p[Q(1, 2)] += 2016", + "p[1] -= 1008 * primary\n p[Q(1, 2)] += 2016 * primary"), + ("def total_interval(counts):", "def total_interval(counts, trial=GAUSSIAN_C):"), + ("intervals(grade, 1 - GAUSSIAN_C)", "intervals(grade, 1 - trial)"), + ("WEIGHTS == (1, 90)", "WEIGHTS == (5, 451)"), + ("t, p = raw_counts(base, 90)", "t, p = raw_counts(base, WEIGHTS[1], WEIGHTS[0])"), + ("<= 261", "<= 270"), + (" cuts = {}", + " high = total_interval({k: n for k, n in t.items() if k > 2})\n" + " required = total_interval({r: n for r, n in p.items() if 5 * r > 8})\n" + " assert high[0] - required[1] > 462\n" + " past_targets, past_paid = raw_counts(base, 541, 6)\n" + " assert total_interval(past_targets)[1] < total_interval(past_paid)[0]\n" + " old_tariff = Q(17145637167, 2**42)\n" + " cuts = {\"new\": [str(high[0] - required[1]), str(high[1] - required[0])]}"), + (" cap = total_interval({k: n for k, n in chosen.items() if k > 2})", + " cap = total_interval({k: n for k, n in chosen.items() if k > 2}, old_tariff)"), + (" load = total_interval({r: n for r, n in required.items() if 5 * r > 8})", + " load = total_interval({r: n for r, n in required.items() if 5 * r > 8}, old_tariff)"), + (" net = total_interval(chosen)[0] - total_interval(required)[1]", + " net = total_interval(chosen, old_tariff)[0] - total_interval(required, old_tariff)[1]"), +) +EDITS["independent_price.py"] += ( + ('assert psi > Q("184971191.2157")', 'assert psi > Q("926899828.8291")'), +) +EDITS["check_placement.py"] = ( + ("assert 90 * (hi - lo) * M * pi > 4", "assert WEIGHTS[1] * (hi - lo) * M * pi > 4"), +) +EDITS["check_exterior.py"] = ( + ("from band_product import production_supplier", "from band_product import production_supplier\nfrom installations import GAUSSIAN_C"), + ("c = Q(17145637167, 2**42)", "c = GAUSSIAN_C"), +) +EDITS["check_nested.py"] = ( + (" * cells[1, 2]\n * 90", " * cells[1, 2]\n * types[0].multiplicity\n * types[1].multiplicity"), + ("share == cells[1, 2] * 90 / t[2]", "share == cells[1, 2] * types[1].multiplicity / t[2]"), + ("and grant.numerator // grant.denominator == 899557645", "and 4_400_000_000 < grant.numerator // grant.denominator < 4_600_000_000"), +) +EDITS["check_ownership.py"] = ( + ("def run(freq, ticks, lower, upper, volume, n, rounds, delay):", + "def run(freq, ticks, lower, upper, volume, n, rounds, delay, primary=1):"), + ("NativeType((2,), (1, 1), 1)", "NativeType((2,), (1, 1), primary)"), + ("(1, 1, 0, 2): Q(1, 2 * freq)", "(1, 1, 0, 2): Q(primary, 2 * freq)"), + ("1 - Q(1, 2 * freq)", "1 - Q(primary, 2 * freq)"), + (" frequency=freq,", " frequency=(primary, freq),"), + ("run(90, 8, 10, 42, 450, 384, 32, 4)]", + "run(90, 8, 10, 42, 450, 384, 32, 4), run(451, 8, 10, 42, 90, 384, 32, 4, primary=5)]"), +) + + +# Keep the reproduced lower edge and widen the actual even upper fence. +EDITS["grades.py"] += ( + ("LOWER = 2048", "LOWER = 1874\nUPPER_DIVISOR = 1724"), + ("2048 * self.ambient", "UPPER_DIVISOR * self.ambient"), +) +EDITS["positive_debit.py"] += ( + ("BAND_LOWER = 2048", "BAND_LOWER = 1874"), + ("from unpowered_price import intervals", "from unpowered_price import intervals\nfrom grades import UPPER_DIVISOR"), + (" upper = 2 * (M // (2048 * recipe.ambient))", + " scale = UPPER_DIVISOR * recipe.ambient // 2\n" + " upper = 2 * (M // (2 * scale))\n" + " assert 4 * max(targets) * (upper - 8) < M and 516 * (upper + 2) < M"), + ("1024 * recipe.ambient * upper", "scale * upper"), + ("Q(4 * max(targets), 1024 * recipe.ambient)", "Q(4 * max(targets), scale)"), + ("power_interval(1024 * recipe.ambient * lower, c)", "power_interval(scale * lower, c)"), + (' "lower_band": lower,', ' "lower_band": lower,\n "upper_divisor": UPPER_DIVISOR,\n "upper_scale": scale,'), + ("assert t > Q(996, 1000) and 11 * t > 10", + "assert t > Q(996, 1000) and power_interval(lower, t)[0] > 1024 * UNIT"), +) +EDITS["receipt.py"] += (("and LOWER == 2048", "and LOWER == 1874"),) +EDITS["independent_price.py"] += ( + ("from installations import BINARY_C, TERMINAL", "from installations import BINARY_C, TERMINAL\nfrom grades import LOWER, UPPER_DIVISOR"), + (" upper = (", " scale = UPPER_DIVISOR * recipe.ambient // 2\n upper = ("), + ("Q(4 * 258, 1024 * 306)", "Q(4 * 258, scale)"), + ("powers(1024 * 306 * 2048, c)[1]", "powers(scale * LOWER, c)[1]"), + ("fringe / 2048", "fringe / LOWER"), + (' assert lower - upper > Q("0.000007887415")', + ' assert lower - upper > Q("0.000000684423")\n' + ' psi_hi = sum(recipe.paid.histogram[r] * share * r * (powers(Q(k,r), c)[1] - 1) / c\n' + ' for (r,k), share in recipe.cells.items())\n' + ' prior_fringe = 10 * axes / ((1-c) * psi_hi)\n' + ' prior_scale = 1024 * recipe.ambient\n' + ' prior_factor = ((1+delta) * (1+Q(4*258,prior_scale)) * powers(prior_scale*LOWER,c)[0]\n' + ' * (1+prior_fringe/LOWER+delta) / (1-delta)**4)\n' + ' assert prior_factor - powers(2, Q(64939,524288))[1] > Q("0.000051649827")'), +) +EDITS["check_placement.py"] += ( + ("from grades import numerical_recipe, WEIGHTS", "from grades import numerical_recipe, LOWER, UPPER_DIVISOR, WEIGHTS"), + (" U = 2 * (M // (2048 * 306))", + " scale = UPPER_DIVISOR * recipe.ambient // 2\n" + " assert UPPER_DIVISOR == 1724 and scale == 263772\n" + " U = 2 * (M // (2 * scale))"), + (" assert U < lo < hi < M", " assert LOWER < e < U < lo < hi < M"), + (" assert period == 1620 and tickets == (0, 324, 648) and f.swaps[0] == (1, 324, 1)", + " assert period == 1364 and tickets == (0, 272, 545) and f.swaps[0] == (1, 272, 1)"), +) +EDITS["verify.py"] = ( + ('("check_calendar.py", "check_ownership.py")', + '("check_calendar.py", "check_ownership.py", "check_cutoff.py", "check_stage_seam.py", "check_ordinary_floor.py")'), +) + + +def materialize(package): + for name, replacements in EDITS.items(): + replace(package / name, replacements) + with (package / "runtime.patch").open("a") as patch: + patch.write(RAW_FLOOR_PATCH) + path = package / "SOURCES.json" + pins = json.loads(path.read_bytes()) + pins["runtime_images"]["installations.py"]["after"] = NEW_INSTALLATION + pins["runtime_images"]["raw_binary_stage.py"] = RAW_FLOOR_IMAGES + for name in ("runtime.patch", "grades.py"): + pins["local_sources"][name] = sha256((package / name).read_bytes()).hexdigest() + pins["runtime_images"]["grades.py"]["after"] = pins["local_sources"]["grades.py"] + path.write_text(json.dumps(pins, indent=2) + "\n") diff --git a/research/p104-two-type-threshold/source/upstream/verify.py b/research/p104-two-type-threshold/source/upstream/verify.py new file mode 100644 index 0000000000..f460dbac14 --- /dev/null +++ b/research/p104-two-type-threshold/source/upstream/verify.py @@ -0,0 +1,83 @@ +"""Restore authenticated public inputs, apply one retune and replay a signed mode.""" +from argparse import ArgumentParser +from hashlib import sha256 +import json +from pathlib import Path +import runpy +from subprocess import run +import sys +import tarfile +from tempfile import TemporaryDirectory + +HERE = Path(__file__).resolve().parent +HEAD = "cbe847a953b971f9c6c5a0a6661e2008acd29086" +SOURCE_SHA = "798c2e6394c258986484a116198cc542a6d2b4c1f289e5816de2cfecf5141c51" + + +def unique_object(pairs): + result = {} + for name, value in pairs: + if name in result: + raise ValueError(f"Repeated source key {name}") + result[name] = value + return result + + +def restore(tree): + source = (HERE / "PEER-SOURCE.json").read_bytes() + if sha256(source).hexdigest() != SOURCE_SHA: + raise ValueError("Peer source manifest differs") + pins = json.loads(source, object_pairs_hook=unique_object) + archive = HERE / "peer8057.tar.gz" + if pins["head"] != HEAD or sha256(archive.read_bytes()).hexdigest() != pins["archive_sha256"]: + raise ValueError("Unexpected source archive") + seen = set() + with tarfile.open(archive) as bundle: + for item in bundle: + path = Path(item.name) + if path.is_absolute() or ".." in path.parts or str(path) != item.name: + raise ValueError(f"Invalid source path {item.name}") + if item.isdir(): + continue + if not item.isfile() or item.name in seen or item.name not in pins["files_sha256"]: + raise ValueError(f"Unexpected or repeated peer file {item.name}") + data = bundle.extractfile(item).read() + if sha256(data).hexdigest() != pins["files_sha256"][item.name]: + raise ValueError(f"Source differs at {item.name}") + destination = tree / path + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(data) + seen.add(item.name) + if seen != pins["files_sha256"].keys(): + raise ValueError("Source archive is missing a file") + return tree / "research" / "frequency-weighted-native-multiplier" + + +def main(): + modes = ("price", "calendar", "raw", "exterior", "nested", "product", "setup", "regenerate") + parser = ArgumentParser(description=__doc__) + parser.add_argument("mode", choices=modes) + args = parser.parse_args() + with TemporaryDirectory(prefix="weighted-edge-") as temporary: + tree = Path(temporary) + peer = restore(tree) + runpy.run_path(str(HERE / "prepare.py"))["materialize"](peer) + for name in ("check_cutoff.py", "check_stage_seam.py", "check_ordinary_floor.py"): + (peer / name).write_bytes((HERE / name).read_bytes()) + if args.mode == "regenerate": + runtime = tree / "runtime" + run([sys.executable, "-IB", str(peer / "bootstrap.py"), str(runtime)], check=True) + result = run([sys.executable, "-IB", str(peer / "receipt.py"), str(runtime)], check=True, capture_output=True, text=True) + print(json.dumps(json.loads(result.stdout), indent=2)) + return + if args.mode == "setup": + serial = peer.parent / "tiered-native-multiplier" / "check_serial_setup.py" + run([sys.executable, "-IB", str(serial)], check=True) + else: + (peer / "RESULT.json").write_bytes((HERE / "RESULT.json").read_bytes()) + run([sys.executable, "-IB", str(peer / "verify.py"), args.mode], check=True) + print("PASS_CAPPED_ALLOCATION", args.mode, flush=True) + + +if __name__ == "__main__": + main() diff --git a/research/p104-two-type-threshold/verify.py b/research/p104-two-type-threshold/verify.py new file mode 100644 index 0000000000..a17e62157b --- /dev/null +++ b/research/p104-two-type-threshold/verify.py @@ -0,0 +1,178 @@ +"""Replay the source census, directed witnesses, and positive Farkas proofs.""" +from collections import Counter +from fractions import Fraction as Q +from hashlib import sha1, sha256 +import json +from pathlib import Path +import sys + +HERE=Path(__file__).resolve().parent +sys.path.insert(0,str(HERE)) +from directed import UNIT +from model import (P, addmul, all_cuts, continuous_dual, dual_record, flow_record, + fractional_witness, hist_digest, integer_dual, margin, + qstr, ratio_witness, scales, split_paid, witness_flow) +from series_control import check as independent_series_check + +HEAD='75f7e1c44f48c43983016bcf8878c4d9e5e87c62' +EXPECTED_HIST='49f22c0d2d235138173b599004d49b6593244cca8aa5e3a6e6999444308f9cba' +INT_LO=Q('0.003898466610885757242') +INT_HI=Q('0.003898466610885757243') +RELAX_LO=Q('0.003898466621505769638') +RELAX_HI=Q('0.003898466621505769639') +TRIAL=Q(17145637307,2**42) +SOURCE=HERE/'source' +SOURCE_RECEIPT_SHA='6ed3459e228af5b93a766ab82033513ecd6e662498d9749cab810fa48b20d58f' + + +def public_files(): + """Check the exact allowlist; its own digest is supplied with the archive.""" + manifest=json.loads((HERE/'PUBLIC-FILES.json').read_text()) + assert manifest['algorithm']=='sha256' + listed=manifest['files'] + actual={str(p.relative_to(HERE)) for p in HERE.rglob('*') if p.is_file()} + assert actual==set(listed)|{'PUBLIC-FILES.json'} + for name,digest in listed.items(): + relative=Path(name) + assert not relative.is_absolute() and '..' not in relative.parts + path=HERE/name + assert path.is_file() and not path.is_symlink() + assert sha256(path.read_bytes()).hexdigest()==digest,name + + +def validate_hist(t0,p0,expected): + assert t0==expected[0] and p0==expected[1] + assert sum(t0.values())==52608 and sum(p0.values())==281568 and p0[1]==P + assert hist_digest(t0,p0)==EXPECTED_HIST + + +def census_from_stage(): + receipt_bytes=(SOURCE/'SOURCE-RECEIPT.json').read_bytes() + assert sha256(receipt_bytes).hexdigest()==SOURCE_RECEIPT_SHA + receipt=json.loads(receipt_bytes) + assert receipt['repository']=='CrocSwap/integer-mult-bounds' + assert receipt['pull_request']==8072 and receipt['head']==HEAD + upstream=SOURCE/'upstream' + for path,entry in receipt['head_files'].items(): + if entry.get('included') is False:continue + name=Path(path).name + data=(upstream/name).read_bytes() + assert sha256(data).hexdigest()==entry['sha256'],name + assert sha1(b'blob '+str(len(data)).encode()+b'\0'+data).hexdigest()==entry['git_blob'],name + original=json.loads((upstream/'PEER-SOURCE.json').read_text()) + archive=receipt['head_files']['research/p104-weighted-capped-allocation-490950/peer8057.tar.gz'] + assert original['head']==receipt['peer_head'] and original['archive_sha256']==archive['sha256'] + snapshot=receipt['curated_source_files'] + assert {str(p.relative_to(SOURCE)) for p in (SOURCE/'canonical').rglob('*') if p.is_file()}==set(snapshot) + for name,digest in snapshot.items(): + assert sha256((SOURCE/name).read_bytes()).hexdigest()==digest,name + record=json.loads((HERE/'census.json').read_text()) + expected=(Counter({Q(k):v for k,v in record['targets_type0'].items()}), + Counter({Q(k):v for k,v in record['paid_unsplit_type0'].items()})) + expected_targets,expected_paid=scales(*expected) + assert expected_targets[1]==Counter({Q(k):v for k,v in record['targets_type1'].items()}) + assert expected_paid[1]==Counter({Q(k):v for k,v in record['paid_unsplit_type1'].items()}) + canonical=SOURCE/'canonical' + sys.path.insert(0,str(canonical)) + from strong_complex import load_changed, word + raw=word(*load_changed(canonical/'inputs')) + t0=Counter(Q(port.rank) for port in raw.targets) + p0=Counter(Q(port.rank) for port in raw.paid) + validate_hist(t0,p0,expected) + return t0,p0,expected + + +def lower_record(t0,p0,c,x,n0,n1,margins): + flows,capacity=witness_flow(t0,p0,c,x,n0,n1) + return {'rate':qstr(c),'weight_0':'1','weight_1':qstr(x), + 'split_0':qstr(n0),'split_1':qstr(n1), + 'all_cut_margins':[[str(cut),qstr(v/UNIT)] for cut,v in margins], + 'greedy_directed_flow':flow_record(flows), + 'unused_directed_capacity':[[str(k),qstr(v/UNIT)] for k,v in sorted(capacity.items()) if v]} + + +def verify_controls(t0,p0,expected,x,duals): + # The installed baseline is a strict positive transport control. + targets,_=scales(t0,p0); paid=split_paid(p0,1008,0); ratio=Q(451,5) + baseline=[] + for cut in all_cuts(paid): + baseline.append(margin(targets[0],paid[0],cut,TRIAL,True)+ratio*margin(targets[1],paid[1],cut,TRIAL,True)) + assert min(baseline)>0 + # Neighbouring whole counts fail at the certified lower witness ratio. + for n0,cut in ((1005,Q(1)),(1007,None)): + wrong=split_paid(p0,n0,0) + upper=margin(targets[0],wrong[0],cut,INT_LO,False)+x*margin(targets[1],wrong[1],cut,INT_LO,False) + assert upper<0,(n0,cut) + # Mutated dual multipliers must fail exact cancellation. + for rows,weights,_ in duals: + changed=weights.copy();changed[1]+=1 + assert any(addmul(rows,changed)[1:]) + # Reject altered source census and impossible loan count. + damaged=Counter(t0);damaged[1]+=1 + try:validate_hist(damaged,p0,expected) + except AssertionError:pass + else:raise AssertionError('damaged source census accepted') + try:split_paid(p0,P+1,0) + except ValueError:pass + else:raise AssertionError('out-of-stock split count accepted') + assert not (4*Q(2)>=5*Q(2)) # forbidden r=2 -> k=2 transfer + independent_series_check(INT_HI) + independent_series_check(RELAX_HI) + independent_series_check(Q('0.0039')) + return {'source_installed_trial':qstr(TRIAL), + 'baseline_minimum_cut_margin':qstr(min(baseline)/UNIT), + 'neighbor_counts_fail':[1005,1007], + 'mutated_duals_rejected':len(duals), + 'altered_source_rejected':True,'excess_split_rejected':True, + 'forbidden_transfer_rejected':True,'independent_power_enclosures_checked':True} + + +def run(emit): + assert __debug__,'Do not run with optimizations that disable assertions.' + if not emit:public_files() + t0,p0,expected=census_from_stage() + x,margins,_=ratio_witness(t0,p0,INT_LO,1006,0) + rx,rn,rmargins,_=fractional_witness(t0,p0,RELAX_LO) + integer_lower=lower_record(t0,p0,INT_LO,x,1006,0,margins) + relaxed_lower=lower_record(t0,p0,RELAX_LO,rx,rn,0,rmargins) + d0=integer_dual(t0,p0,INT_HI,'at-most-1005') + d1=integer_dual(t0,p0,INT_HI,'at-least-1006') + d2=continuous_dual(t0,p0,RELAX_HI) + controls=verify_controls(t0,p0,expected,x,[d0,d1,d2]) + general_rate=Q('0.0039') + base_upper=Q(margin(t0,p0,None,general_rate,False),UNIT) + assert 0 < 1-general_rate < 1 and base_upper < Q('-1.53934254762') + certificate={ + 'source_head':HEAD,'source_histogram_sha256':EXPECTED_HIST, + 'exponent_power_grid_bits':{'exponent':128,'values':224}, + 'integer_lower':integer_lower, + 'integer_upper_rate':qstr(INT_HI), + 'integer_upper_at_most_1005':dual_record(*d0), + 'integer_upper_at_least_1006':dual_record(*d1), + 'relaxed_lower':relaxed_lower, + 'relaxed_upper_rate':qstr(RELAX_HI), + 'relaxed_upper':dual_record(*d2), + 'arbitrary_scale_subdivision_corollary':{ + 'rate':qstr(general_rate), + 'base_unsplit_directed_upper':qstr(base_upper), + 'strict_decimal_upper':'-1.53934254762', + 'scope':'finite positive scale mixtures and finite positive rank-preserving paid subdivisions, fixed targets; compatibility relaxed'}, + 'controls':controls, + } + out=HERE/'CERTIFICATE.json' + if emit:out.write_text(json.dumps(certificate,indent=2)+'\n') + else:assert json.loads(out.read_text())==certificate,'The replayed certificate differs' + print('PASS_PINNED_CURATED_SOURCE_AND_CANONICAL_WORD') + print('PASS_INTEGER_LOWER_FLOW_5R_LE_4K') + print('PASS_INTEGER_UPPER_TWO_POSITIVE_FARKAS_COMBINATIONS') + print('PASS_FRACTIONAL_LOWER_FLOW_AND_UPPER_POSITIVE_FARKAS') + print('PASS_ARBITRARY_SCALE_PAID_SUBDIVISION_TOTAL_OBSTRUCTION_0039') + print('PASS_BASELINE_AND_NEGATIVE_CONTROLS_AND_INDEPENDENT_ENCLOSURES') + print('integer',str(INT_LO),'< threshold <',str(INT_HI)) + print('fractional',str(RELAX_LO),'< threshold <',str(RELAX_HI)) + print('scope: aggregate raw price/stock transport only; no signed-multiplier or kappa admission') + +if __name__=='__main__': + if len(sys.argv)>2 or (len(sys.argv)==2 and sys.argv[1]!='--emit'): + raise SystemExit('usage: verify.py [--emit]') + run('--emit' in sys.argv)