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-gaussian-frame-price/GLOBAL-FRAMES.json b/research/p104-gaussian-frame-price/GLOBAL-FRAMES.json new file mode 100644 index 0000000000..2afb4c4f99 --- /dev/null +++ b/research/p104-gaussian-frame-price/GLOBAL-FRAMES.json @@ -0,0 +1,41 @@ +{ + "target": "39/10000", + "projection_sha256": "dc5f08a2499662a0d228583aa0fd092b1946bea7b2657899a22fbe46bcf4123c", + "anchored_main_charts": 210, + "mutable_active_charts": 768, + "incidence_pairs": 2958, + "signed_terms_per_native": 6565, + "anchored_unit_paid_moves_per_native": 847, + "guaranteed_paid_unit_roles_in_48_call_invoice": 41136, + "split_count": 1008, + "tariff_scale": "6277101735386680763835789423207666416102355444464034512896", + "rounding_budget_doubled_grid": "283047917910754750", + "midpoint_only_upper_gain_per_native": "141523958955377375/6277101735386680763835789423207666416102355444464034512896", + "true_maximum_gain_per_native": "0", + "toy": { + "families": 28, + "selections": 736, + "legal": 113, + "legal_with_contraction": 45, + "positive_optima": 14, + "hand_closure_value": 4 + }, + "grow": { + "cases": 511, + "zero_midpoint_maxima": 511, + "zero_directed_upper_maxima": 511, + "min_positive_residual_doubled_grid": "3440725855595812174076952386583042024909598591777889135", + "free_components": 48, + "max_free_sites": 2, + "max_active_sites": 59 + }, + "shrink": { + "cases": 511, + "zero_midpoint_maxima": 511, + "zero_directed_upper_maxima": 511, + "min_positive_residual_doubled_grid": "6345852314472986651520439580108862179541120223077932927", + "free_components": 240, + "max_free_sites": 15, + "max_active_sites": 147 + } +} diff --git a/research/p104-gaussian-frame-price/GLOBAL-FRAMES.md b/research/p104-gaussian-frame-price/GLOBAL-FRAMES.md new file mode 100644 index 0000000000..194e5bbe26 --- /dev/null +++ b/research/p104-gaussian-frame-price/GLOBAL-FRAMES.md @@ -0,0 +1,58 @@ +# An exact price bound for simultaneous changes in a common direction + +At κ = 39/10000 the maximum gain in productive-minus-paid Gaussian mass is **exactly zero** when any subset of the 768 unanchored active charts grows by one common line, or any subset is restricted to one common hyperplane. The empty change attains the maximum. This holds even in a price relaxation that makes a paid transfer free when its two endpoint spaces become equal. A productive helper always requires a proper inclusion. The ordinary strict-incidence supplier is a subfamily. The conclusion concerns a fixed normalized word, main interface, public role labels, and occurrence schedule. [Source projection and prior finite families](README.md) · [Exact results](GLOBAL-FRAMES.json) + +## Enumerating the directions and writing the price + +Every nonzero vector $v$ in $V=\mathbb F_2^9$ specifies exactly one line $\langle v\rangle$ and, using the standard coordinate pairing, one hyperplane $v^\perp$. There are 511 choices of each. For the first family choose a subset of active mutable charts and replace each chosen space $F$ by $F+\langle v\rangle$. For the second family replace each chosen $F$ by $F\cap v^\perp$. A change flag is necessary only at a site where the operation changes the actual subspace. The 210 charts carrying main endpoints are fixed. + +Group the 5,674 paid MOVE occurrences and 891 productive helper targets by their original nested pair $A\subset B$. Give each pair weight $w$ equal to its number of helper occurrences minus its number of paid occurrences. Retain every pair as a containment constraint, including any whose weight cancels. Record independently whether it carries a helper. With $r=\dim B-\dim A$, write $p_r=r^{1-39/10000}$, and set $p_0=0$ in the relaxation. A paid-only pair may become equal there. The original positive-grade transfer compiler would need a separate implementation for a contraction. Omitting that expense gives an upper bound for this fixed schedule. + +For growth there are three possibilities. + +* If $v\in A$, both endpoints are unchanged. +* If $v\in B\setminus A$, only $A$ can change. Choosing it reduces $r$ by one. At $r=1$ equality is forbidden whenever the pair carries a helper. The strict subfamily forbids it also for paid-only pairs. +* If $v\notin B$, both endpoints can change. Growing $A$ forces growing $B$, since the changed $A$ would contain $v$ while the original $B$ does not. Choosing just $B$ increases the grade by one. Choosing both preserves it. + +For restriction use $H=v^\perp$. If $B\subseteq H$, neither endpoint changes. If $A\subseteq H$ but $B\nsubseteq H$, only $B$ can change and choosing it reduces $r$ by one, with the same equality rule. If $A\nsubseteq H$, both can change, and restricting $B$ forces restricting $A$. The original $A$ contains a point outside $H$, which the restricted $B$ omits. Choosing just $A$ increases the grade by one. Choosing both preserves it. In each case the listed rules are sufficient for containment as well. An originally strictly lower endpoint can never reverse the inclusion after a one-dimensional change of this kind. + +For a pair with both change flags available, write $i\Rightarrow j$ for the required implication. Its price increment on any permitted assignment is +$$ +w(p_{r+1}-p_r)(x_j-x_i). +$$ +For a pair with only one susceptible site $i$, the increment is $w(p_{r-1}-p_r)x_i$, subject to the equality rule. Propagate every prohibited flag backwards through implications. On the remaining sites the legal subsets are exactly the sets closed under those implications. These formulas give an integer signed histogram $h_{ik}$ at each site. The true gain of a closed subset $C$ is $\sum_{i\in C}\sum_{k=0}^9 h_{ik}p_k$. This representation accounts for every shared edge once even when many helpers and internal frames move jointly. + +## Directed upper profits and a rational optimality certificate + +Let $S=2^{192}$ and use the outward enclosures $L_k\le S p_k\le U_k$ from the base verifier. Combine all occurrences into $h_{ik}$ **before** pricing. For site $i$ assign the integer profit +$$ +u_i=\sum_k\max(h_{ik}L_k,h_{ik}U_k). +$$ +Then $S$ times the true gain of any closed set is at most $\sum_{i\in C}u_i$. + +Given any integer vertex profits $q_i$, connect a source to every positive-profit vertex with capacity $q_i$. Connect each negative-profit vertex to the sink with capacity $-q_i$. For each implication $i\Rightarrow j$ add a forward arc of capacity strictly greater than $P=\sum_{q_i>0}q_i$. The empty selection gives a cut of capacity $P$. A minimum cut therefore respects all implications. A feasible cut with chosen set $C$ has capacity $P-\sum_{i\in C}q_i$. Each replayed flow is checked for admissible integer arc values and conservation at every vertex. The corresponding feasible cut has the same capacity, which proves optimality. + +In all 1,022 networks with $q_i=u_i$ the maximum closure profit is exactly zero. The minimum cut value in each instance equals its own $P$. The empty assignment attains true gain zero, establishing equality for the exact real tariff. + +## Midpoint and tie check + +A second flow uses $m_k=L_k+U_k$ and site profits $\sum_k h_{ik}m_k$ in units of $1/(2S)$. Every one of its 1,022 maxima is also zero. With $N=6,565$ signed term occurrences per native invocation, the largest error of any new-minus-old midpoint total in doubled-grid units is at most +$$ +E=2N\max_{0\le k\le9}(U_k-L_k)=283047917910754750 . +$$ +Each original and candidate occurrence contributes at most one interval width in these units. The resulting coarse upper gain is $141523958955377375/S<3\cdot10^{-41}$ per native invocation. + +For any cut, its capacity minus the certified flow is the sum of its outward residual capacities, including backward residual arcs for incoming flow. Thus any strictly suboptimal cut is separated from the midpoint maximum by at least the smallest positive residual capacity of that network. Across all 1,022 networks this lower bound is +$$ +3440725855595812174076952386583042024909598591777889135>E. +$$ +Every midpoint loss remains a strict loss under the actual tariff. + +A minimum cut admits no outward residual arc. It must include the source and exclude every vertex having a residual path to the sink. All source capacity is saturated here, so the source forces no other vertex. Every optimal subset is a union of strongly connected components among the remaining residual vertices. The verifier checks that each such component has a zero signed grade histogram in every coordinate. There are 48 component occurrences across the growth directions and 240 across the restriction directions. Their unions preserve the complete signed histogram. These component counts describe residual graphs across separate directions and need no interpretation as counts of distinct frame assignments. + +## The 48-call invoice and controls + +The priced template appears 48 times. Its raw invoice change is $48D$ for an unscaled single-invocation change $D$, and its two-type change is $48(5+451\cdot2^{1-39/10000})D$. Exactly 847 grade-one MOVE occurrences per native invocation connect two anchored main charts. Together with 480 fixed caller roles they guarantee 41,136 grade-one paid roles before splitting. The source can therefore make its same 1,008 small-type splits in every tested assignment, and their fixed charge cancels from the difference. At the best price the raw invoice still has a deficit exceeding 1.539342547620186178214 and the two-type deficit exceeds 1,406.078231652772. The bound concerns one common direction at a time. Sequences with independently chosen directions, changes of main endpoints, altered contact schedules, and new supplier return contracts require other arguments. [Baseline intervals and split tariff](PROOF.md) + +The independent $\mathbb F_2^3$ oracle constructs transformed spaces as literal sets of points on an eight-chart graph. It exhausts both strict and relaxed choices for every line and hyperplane, checking all 736 subsets against containment and exact grade differences. It compares both flow objectives with exhaustive optima. Of 113 permitted selections, 45 contract a paid-only edge. Fourteen of the 28 toy families have positive midpoint optima. A separate four-vertex closure has positive optimum four. The source calculation uses the same authenticated projection as the one- and two-site tests at the original #8075 head. Clear1nsight prepared the common-direction price calculation and separate directed-flow, residual and point-set checks with substantial OpenAI Codex assistance. [Verifier](global_frames.py) · [Base head](https://github.com/CrocSwap/integer-mult-bounds/commit/a4d65b8c7868413bf0fd26803081117a0d9dda3d) · [Attribution](NOTICE.md) + diff --git a/research/p104-gaussian-frame-price/LICENSE b/research/p104-gaussian-frame-price/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/p104-gaussian-frame-price/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-gaussian-frame-price/NOTICE.md b/research/p104-gaussian-frame-price/NOTICE.md new file mode 100644 index 0000000000..3b560fad9e --- /dev/null +++ b/research/p104-gaussian-frame-price/NOTICE.md @@ -0,0 +1,7 @@ +# Attribution and licensing + +ToikY supplied the exact capped allocation and source-restoration drivers at #8072 and the ordinary K7 improvement at #8073. Ali Romman supplied the literal normalized Gaussian circuit, journals, 48-call schedule and signed factor compiler, including the frequency-weighted supplier at #8057. SYLforge supplied the ordinary K7 circuit. Clear1nsight’s iterated-return programs and the other predecessor contributions are credited in the inherited notice. [Inherited notice](PARENT-NOTICE) · [Apache License 2.0](LICENSE) + +The offline binary-subspace enumeration, strict-flag counts, independent helper-price comparison, directed checks and phase fixtures were developed for Clear1nsight with substantial assistance from OpenAI Codex. The rational price routine follows the source’s integer square-root interval method. The local gaussian_review.py retains the independent native operator interpreter through its exact equality function from the source below. Its original SHA-256 is 3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38. This package extracts the part of that file used for signed frames and Gaussian columns. [Original native interpreter](https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/research/shared-wire-split-composition/frozen/native_verify.py) + +The campaign board credits Rohan Arun for the earlier output rechart and Dillona for the pivot split and independent same-word export. [Prior work](https://github.com/CrocSwap/integer-mult-bounds/discussions/7111#discussioncomment-19530793) diff --git a/research/p104-gaussian-frame-price/PARENT-NOTICE b/research/p104-gaussian-frame-price/PARENT-NOTICE new file mode 100644 index 0000000000..fe51894a1a --- /dev/null +++ b/research/p104-gaussian-frame-price/PARENT-NOTICE @@ -0,0 +1,31 @@ +Mixed paid cutoffs for the P104 ordinary BIT supplier + +Prepared for Clear1nsight with substantial OpenAI Codex assistance. The +new schedule, directed comparison, occurrence controls, and documentation +are offered under Apache-2.0. + +verify.py adapts the Apache-2.0 verifiers from Dugongue's PR #7831 +(2d1fb9c878ae1e292cb918de40fa8e4f7fa7f75e) and Rohan Arun's PR #7835 +(43007c979859fa84ccc3a3509ccacc9620d181fa). Rohan Arun submitted #7835 +through the original X request at +https://x.com/RohanArun/status/2123655584797143516. The source manifest +retains the published #7835 NOTICE. + +Retained predecessor NOTICE from the grade-14 package follows. + +Iterated returns on the P104 ordinary suppliers + +Clear1nsight prepared the successor construction, explicit witnesses and verification +with substantial OpenAI Codex assistance, including independent computational checks. +The new material is offered under Apache-2.0. + +The exact starting words and the rational and binary replay interfaces are from +Clear1nsight's PR #7781. The paid and productive scalar operations, the 48-call +complex schedule, the punctured binary supplier and the common outer application +come from Ali Romman's PR #7776. The two paid projections build on the local +quotient and terminal repair in #7774 and #7781. The binary paired caller and +finite compiler use work by DreamingOfClouds, Jerry Chen (CubeJerry), zxv and the +contributors cited in their retained sources. SYLforge, Rohan Arun, Cinna Davis, +Douglas Colkitt and other predecessors contributed the caller, physical and +analytic framework. The source-fetch helper is adapted from #7774. The immutable +source manifest identifies the public inputs and their notices. diff --git a/research/p104-gaussian-frame-price/PROOF.md b/research/p104-gaussian-frame-price/PROOF.md new file mode 100644 index 0000000000..82df3bc9fc --- /dev/null +++ b/research/p104-gaussian-frame-price/PROOF.md @@ -0,0 +1,46 @@ +# Counting the strict frame families + +## The object and the necessary price + +The frozen program has 1,103 chart labels, 978 active charts, 1,291 public role slots and 5,674 MOVE occurrences in one native invocation. Its normalized rational forms and their chronological schedule stay fixed. The source requires the subspaces at a MOVE to be strictly nested and charges the absolute difference of their dimensions. A helper target must run from a proper subspace to its superspace and earns that positive dimension difference. Main ports fix both endpoint frames. The compiler checks the grade of the signed Gaussian factor against this dimension difference and requires a positive value. An equal neighboring frame therefore falls outside the existing interface. Different ordered bases for one subspace carry the same mandatory grade under this check. + +Put $t=1-39/10000$. A grade $r$ contributes $r^t$. Write $D$ for new productive-minus-paid mass minus its old value in one unscaled native invocation. A site with a productive helper endpoint has both incident productive and paid counts. All other word roles cancel. Since the native graph occurs 48 times, the full unscaled difference is $48D$. The two installed types have weights 5 and 451 and scales one and two, so the full two-type difference is $48(5+451\,2^t)D$. The tariff for splitting 1,008 unit paid roles in the small type subtracts $5\cdot1008(2^{1-t}-1)$ from the weighted margin. Each allowed choice leaves enough grade-one roles for those exact splits. The verifier bounds the number that could be lost using 96 times the largest eligible incident MOVE count. Thus this tariff cancels from every difference and is charged once in the absolute margin. + +The baseline exact weighted margin lies between −1406.078231652773 and −1406.078231652772. With no positive difference the full supplier cannot reach the target trial in these families, even before a finite-calendar debit. The fixed caller’s other paid events and productive roots are recovered from the actual source streams in `rebuild.py`. Additional phase or tape work cannot remove the required paid rank at a valid incident transfer. Changing the source tariff or transferring uncharged equal-frame values would be a different construction. + +## A single chart + +Take a trial dimension $d$. An incident neighbor of dimension $d$ makes strict containment impossible. Every smaller neighbor’s space must be contained in the candidate $X$. The candidate must be contained in every larger neighbor. For a productive edge the scan also requires its original increasing orientation. Set $A$ to the linear span of the smaller neighbors and $B$ to the intersection of the larger neighbors. Empty lower and upper lists give the zero space and the full nine-dimensional ambient space. The exact test is $A\subseteq B$ and $\dim A\le d\le\dim B$. The admissible choices correspond to subspaces of $B/A$ of dimension $d-\dim A$, hence number +$$ +{\dim B-\dim A\brack d-\dim A}_2. +$$ +Every choice at a fixed site and dimension has the same change of grade on every edge. The verifier sums the occurrence multiplicities before computing the tariff difference. + +There are 79,413 reachable site/subspace combinations on the 706 purely internal charts, including 706 copies of the original placement. The same dimension at every individual chart forces its original subspace. Among the 78,707 nonidentical single internal assignments, 18 preserve the complete histogram. The other 78,689 strictly worsen it. The 62 helper-only sites give 8,793 site/subspace combinations. All 8,731 changes cost mass. For chart 1094 at dimension six the signed grade difference is $2[1]-2[2]-[3]+[4]-[5]+[6]$, where $[r]=r^t$. The independently recorded interval for its per-call change lies strictly below −0.00843834771094. + +## Two incident charts + +Fix two adjacent internal chart IDs, allocate each outside edge to its original endpoint, and count the shared MOVE multiplicity once. Equal trial dimensions are impossible by strict nesting. Orient the calculation so the trial ranks are $u> j) & 1) << i for i, row in enumerate(matrix)) for j in range(len(matrix))) + + +def inverse(matrix): + n = len(matrix) + rows = [row | (1 << (n+i)) for i, row in enumerate(matrix)] + for j in range(n): + pivot = next((i for i in range(j, n) if rows[i] >> j & 1), None) + require(pivot is not None, 'singular binary chart') + rows[j], rows[pivot] = rows[pivot], rows[j] + for i in range(n): + if i != j and rows[i] >> j & 1: + rows[i] ^= rows[j] + require([row & ((1 << n)-1) for row in rows] == [1 << i for i in range(n)], 'binary inverse') + return tuple(row >> n for row in rows) + + +def extend(vectors, n): + columns, pivots = [], {} + for value in tuple(vectors) + tuple(1 << i for i in range(n)): + reduced = value + while reduced: + j = reduced.bit_length()-1 + if j not in pivots: + pivots[j] = reduced + columns.append(value) + break + reduced ^= pivots[j] + require(len(columns) == n, 'frame basis extension') + return tuple(columns) + + +def adjoint(circuit): + out = [] + for gate in reversed(circuit): + if gate[0] == 'P': + out.append(('P', inverse(gate[1]))) + elif gate[0] == 'D': + out.append(('D', gate[1], tuple(-a % 4 for a in gate[2]))) + elif gate[0] == 'C': + out.append(('C', gate[1], -gate[2])) + elif gate[0] == 'phase': + out.append(('phase', -gate[1] % 4)) + else: + require(gate[0] == 'X', 'adjoint gate type') + out.append(gate) + return tuple(out) + + +def fourier(rank): + return tuple(('C', 1 << i, 1) for i in range(rank)) + + +def frame(vectors, n): + rank = len(vectors) + if rank == 0: + return () + if rank == n: + return fourier(n) + matrix = transpose(extend(vectors, n)) + columns = transpose(inverse(matrix)) + quadratic = tuple((1 << i) ^ sum(parity(a & b) << j for j, b in enumerate(columns)) for i, a in enumerate(columns)) + diagonal = tuple((row >> i) & 1 for i, row in enumerate(quadratic)) + chart = (('P', matrix), ('D', quadratic, diagonal)) + return adjoint(chart) + fourier(rank) + chart + + +def monomial(record): + matrix = tuple(record['matrix_rows']) + quadratic = tuple(record['quadratic_rows']) + linear = tuple(record['linear_Z4']) + require(transpose(quadratic) == quadratic, 'quadratic symmetry') + require(len(matrix) == len(quadratic) == len(linear) == 9, 'monomial dimension') + require(all(a % 2 == (quadratic[i] >> i) & 1 for i, a in enumerate(linear)), 'diagonal parity') + inverse(matrix) + return (('D', quadratic, linear), ('P', matrix), ('X', record['offset']), ('phase', record['phase'])) + + +def recipe(record): + rank = record['rank'] + require(isinstance(rank, int) and 0 <= rank <= 9, 'child rank') + if rank == 0: + require(record['right'] is None, 'rank zero right factor') + return monomial(record['left']) + return monomial(record['right']) + fourier(rank) + monomial(record['left']) + + +def tableau(circuit, n=9): + rows = [(1 << i, 0, 0) for i in range(n)] + [(0, 1 << i, 0) for i in range(n)] + for gate in circuit: + tag = gate[0] + out = [] + inverse_transpose = transpose(inverse(gate[1])) if tag == 'P' else None + for x, z, phase in rows: + if tag == 'P': + x, z = mul(gate[1], x), mul(inverse_transpose, z) + elif tag == 'X': + phase += 2 * parity(z & gate[1]) + elif tag == 'C': + if parity(z & gate[1]): + x ^= gate[1] + phase += 3 * gate[2] + elif tag == 'D': + quadratic, linear = gate[1:] + phase += sum(linear[i] for i in range(n) if x >> i & 1) + phase += 2 * sum(parity((quadratic[i] >> (i+1)) & (x >> (i+1))) for i in range(n) if x >> i & 1) + z ^= mul(quadratic, x) + else: + require(tag == 'phase', 'tableau gate type') + out.append((x, z, phase % 4)) + rows = out + return tuple(rows) + + +@lru_cache(maxsize=512) +def action(gate): + if gate[0] == 'P': + return tuple(mul(gate[1], x) for x in range(512)) + require(gate[0] == 'D', 'state action type') + quadratic, linear = gate[1:] + return tuple((sum(linear[i] for i in range(9) if x >> i & 1) + + 2 * sum(parity((quadratic[i] >> (i+1)) & (x >> (i+1))) for i in range(9) if x >> i & 1)) % 4 for x in range(512)) + + +def rotate(pair, power): + a, b = pair + return ((a, b), (-b, a), (-a, -b), (b, -a))[power % 4] + + +def state(circuit, basis=0): + value, denominator = {basis: (1, 0)}, 0 + for gate in circuit: + tag = gate[0] + result = {} + if tag == "C": + direction, sign = gate[1:] + for address, (a, b) in value.items(): + for target, pair in ((address, (a - sign*b, b + sign*a)), + (address ^ direction, (a + sign*b, b - sign*a))): + old = result.get(target, (0, 0)) + result[target] = (old[0] + pair[0], old[1] + pair[1]) + denominator += 1 + else: + for address, pair in value.items(): + if tag == "P": + target = mul(gate[1], address) + elif tag == "X": + target = address ^ gate[1] + else: + target = address + if tag == "D": + pair = rotate(pair, action(gate)[address]) + else: + require(tag == "phase", "Unknown Gaussian state gate") + pair = rotate(pair, gate[1]) + require(target not in result, "A monomial address map is not injective") + result[target] = pair + value = {address: pair for address, pair in result.items() if pair != (0, 0)} + while denominator and all((a | b) % 2 == 0 for a, b in value.values()): + denominator -= 1 + value = {address: (a//2, b//2) for address, (a, b) in value.items()} + return value, denominator + + +def equal(actual, expected, label): + require(tableau(actual) == tableau(expected), label + ": signed Pauli action") + require(state(actual) == state(expected), label + ": exact global phase") diff --git a/research/p104-gaussian-frame-price/geometry.py b/research/p104-gaussian-frame-price/geometry.py new file mode 100644 index 0000000000..2190e0b685 --- /dev/null +++ b/research/p104-gaussian-frame-price/geometry.py @@ -0,0 +1,127 @@ +"""Intervals and two-step flags of labeled binary subspaces, represented by point masks.""" + +from functools import cache + +FULL = (1 << 512) - 1 +ZERO = 1 + + +def space_mask(basis): + points = {0} + for vector in basis: + if not 0 < vector < 512 or vector in points: + raise ValueError("The supplied vectors are dependent or exceed nine axes") + points.update([v ^ vector for v in points]) + return sum(1 << v for v in points) + + +def elements(space): + while space: + bit = space & -space + yield bit.bit_length() - 1 + space ^= bit + + +def dimension(space): + size = space.bit_count() + assert size and size.bit_count() == 1 + return size.bit_length() - 1 + + +def included(smaller, larger): + return smaller & larger == smaller + + +@cache +def join(first, second): + if included(first, second): + return second + for vector in elements(second): + if not first & (1 << vector): + others = [v ^ vector for v in elements(first)] + first |= sum(1 << u for u in others) + return first + + +@cache +def gaussian(n, k): + if not 0 <= k <= n: + return 0 + a = b = 1 + for j in range(k): + a *= 2**n - 2**j + b *= 2**k - 2**j + assert a % b == 0 + return a // b + + +def endpoint_options(site, other, paid, starts, ends, ranks, subspaces): + """Return every possible dimension and its exact lower/upper interval.""" + neighbors = (set(paid[site]) | set(starts[site]) | set(ends[site])) - {other} + options = [] + for rank in range(10): + if any(ranks[h] == rank for h in neighbors): + continue + if any(ranks[h] <= rank for h in starts[site]): + continue + if any(ranks[h] >= rank for h in ends[site]): + continue + low, high = ZERO, FULL + for h in neighbors: + if ranks[h] < rank: + low = join(low, subspaces[h]) + else: + high &= subspaces[h] + if included(low, high) and dimension(low) <= rank <= dimension(high): + options.append((rank, low, high)) + return options + + +def space_count(option): + rank, low, high = option + return gaussian(dimension(high) - dimension(low), rank - dimension(low)) + + +def flags(smaller, larger): + """Count X < Y in two independent subspace intervals with fixed ranks.""" + u, a, b = smaller + v, e, f = larger + assert u < v + c = b & f + if not included(a, c) or dimension(c) < u: + return 0 + d = dimension(a & e) + n = dimension(c) - dimension(a) + k = u - dimension(a) + p = dimension(c & e) - d + total = 0 + for ell in range(max(0, k - n + p), min(k, p) + 1): + joined_rank = dimension(e) + u - d - ell + choices_x = gaussian(p, ell) * gaussian(n - p, k - ell) * 2**((p - ell) * (k - ell)) + total += choices_x * gaussian(dimension(f) - joined_rank, v - joined_rank) + return total + + +def finite_control(): + """Compare the formula against explicit pairs for every interval in F2^3.""" + seen = {frozenset([0])} + for rank in range(3): + for a in list(seen): + if len(a) == 2**rank: + for vector in set(range(8)) - a: + seen.add(frozenset(a | {j ^ vector for j in a})) + spaces = sorted(sum(1 << v for v in a) for a in seen) + intervals = [(d, a, b) for a in spaces for b in spaces if included(a, b) + for d in range(dimension(a), dimension(b) + 1)] + members = {i: [v for v in spaces if dimension(v) == i[0] + and included(i[1], v) and included(v, i[2])] for i in intervals} + checks = positive = 0 + for i in intervals: + for j in intervals: + if i[0] < j[0]: + literal = sum(included(x, y) for x in members[i] for y in members[j]) + assert flags(i, j) == literal + checks += 1 + positive += bool(literal) + assert (len(spaces), checks, positive) == (16, 5956, 4948) + return checks diff --git a/research/p104-gaussian-frame-price/global_frames.py b/research/p104-gaussian-frame-price/global_frames.py new file mode 100644 index 0000000000..88214a36d4 --- /dev/null +++ b/research/p104-gaussian-frame-price/global_frames.py @@ -0,0 +1,437 @@ +"""Exact maximum-closure certificate for joint common-line and common-hyperplane frame changes.""" + +from collections import Counter, deque +from fractions import Fraction as Q +from functools import cache +from hashlib import sha256 +from itertools import combinations +from pathlib import Path +import gzip +import json +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +from geometry import space_mask +from verify import tariff, UNIT + +PROJ_SHA = "dc5f08a2499662a0d228583aa0fd092b1946bea7b2657899a22fbe46bcf4123c" +RANKS = range(1, 10) +PRICE = tuple([(0, 0)] + [tariff(k) for k in RANKS]) + + +def load_input(): + data = gzip.decompress((HERE / "source-projection.json.gz").read_bytes()) + assert sha256(data).hexdigest() == PROJ_SHA + g = json.loads(data) + starts, ends = g["initial"], g["final"] + anchored = {roles[i] for roles in (starts, ends) for i in g["main_roles"]} + spaces = [space_mask(v) for v in g["frames"]] + dims = list(map(len, g["frames"])) + incidence = Counter() + helpers = set() + + def put(a, b, units): + if dims[a] > dims[b]: + a, b = b, a + assert spaces[a] & spaces[b] == spaces[a] and dims[a] < dims[b] + incidence[a, b] += units + + fixed_unit = 0 + for _, a, b in g["moves"]: + put(a, b, -1) + fixed_unit += a in anchored and b in anchored and abs(dims[a] - dims[b]) == 1 + main = set(g["main_roles"]) + for i, (a, b) in enumerate(zip(starts, ends, strict=True)): + if i not in main: + assert dims[a] < dims[b] + put(a, b, 1) + helpers.add((a, b)) + # Keep every geometric edge, including one with zero net price coefficient. + edges = tuple( + (a, b, dims[b] - dims[a], w, (a, b) in helpers) + for (a, b), w in sorted(incidence.items()) + ) + vertices = {item for a, b, *_ in edges for item in (a, b)} + assert (len(anchored), len(vertices - anchored), len(edges), fixed_unit) == ( + 210, + 768, + 2958, + 847, + ) + templates = len(g["moves"]) + len(starts) - len(main) + assert templates == 6565 and dict(g["fixed_paid"])[1] + 48 * fixed_unit == 41136 + assert (g["native_calls"], g["splits"], g["weights"], g["scales"]) == ( + 48, + 1008, + [5, 451], + [1, 2], + ) + return g, anchored, spaces, edges, templates, fixed_unit + + +def model(changing, anchored, edges, kind, allow_paid_contractions): + # Each coefficient vector is an exact signed difference of grade multiplicities. + n = len(changing) + coeff = [[0] * 10 for _ in range(n)] + forbidden = set(anchored) + implications = set() + active = set() + for a, b, r, w, helper in edges: + if changing[a]: + active.add(a) + if changing[b]: + active.add(b) + if changing[a] and changing[b]: + must, other = (a, b) if kind == "grow" else (b, a) + implications.add((must, other)) + coeff[other][r + 1] += w + coeff[other][r] -= w + coeff[must][r + 1] -= w + coeff[must][r] += w + elif changing[a] or changing[b]: + who = a if changing[a] else b + assert (who == a) == (kind == "grow") + if r == 1 and (helper or not allow_paid_contractions): + forbidden.add(who) + else: + coeff[who][r - 1] += w + coeff[who][r] -= w + reverse = {} + for a, b in implications: + reverse.setdefault(b, []).append(a) + stack = list(forbidden) + while stack: + for other in reverse.get(stack.pop(), ()): + if other not in forbidden: + forbidden.add(other) + stack.append(other) + sites = sorted(active - forbidden) + index = {v: i for i, v in enumerate(sites)} + arcs = sorted((index[a], index[b]) for a, b in implications if a in index) + return sites, [tuple(coeff[v]) for v in sites], arcs + + +@cache +def prices(coeff): + mid = sum(n * (lo + hi) for n, (lo, hi) in zip(coeff, PRICE)) + upper = sum(max(n * lo, n * hi) for n, (lo, hi) in zip(coeff, PRICE)) + return mid, upper + + +def optimize(profits, implications, hard_floor=1): + n = len(profits) + s = n + t = n + 1 + funds = sum(v for v in profits if v > 0) + hard = 2 * (funds + hard_floor) + graph = [[] for _ in range(n + 2)] + dest = [] + res = [] + edges = [] + + def edge(u, v, c): + if not c: + return + j = len(res) + graph[u].append(j) + graph[v].append(j + 1) + dest.extend([v, u]) + res.extend([c, 0]) + edges.append((u, v, c)) + + for j, v in enumerate(profits): + if v > 0: + edge(s, j, v) + elif v < 0: + edge(j, t, -v) + for u, v in implications: + edge(u, v, hard) + flow = 0 + while True: + levels = [-1] * (n + 2) + levels[s] = 0 + queue = deque([s]) + while queue: + u = queue.popleft() + for j in graph[u]: + v = dest[j] + if res[j] and levels[v] < 0: + levels[v] = levels[u] + 1 + queue.append(v) + if levels[t] < 0: + break + pointers = [0] * (n + 2) + + def push(u, budget): + if u == t: + return budget + while pointers[u] < len(graph[u]): + j = graph[u][pointers[u]] + v = dest[j] + if res[j] and levels[u] + 1 == levels[v]: + sent = push(v, min(res[j], budget)) + if sent: + res[j] -= sent + res[j ^ 1] += sent + return sent + pointers[u] += 1 + return 0 + + while True: + added = push(s, hard) + if not added: + break + flow += added + # Validate the primal and dual certificate independently of augmentation order. + balance = [0] * (n + 2) + out = [[] for _ in range(n + 2)] + back = [[] for _ in range(n + 2)] + min_positive = None + for j, (u, v, c) in enumerate(edges): + forward = res[2 * j] + reverse = res[2 * j + 1] + assert forward >= 0 and reverse >= 0 and forward + reverse == c + balance[u] -= reverse + balance[v] += reverse + for first, last, qty in [(u, v, forward), (v, u, reverse)]: + if qty: + out[first].append(last) + back[last].append(first) + min_positive = qty if min_positive is None else min(min_positive, qty) + assert balance == [0] * n + [-flow, flow] + cut = {i for i, depth in enumerate(levels[:n]) if depth >= 0} + assert all(u not in cut or v in cut for u, v in implications) + value = sum(profits[v] for v in cut) + assert value == funds - flow + return value, cut, out, back, min_positive + + +def components(graph, reverse, which): + # Kosaraju on the induced free residual graph. + finished = [] + seen = set() + for root in which: + if root in seen: + continue + seen.add(root) + stack = [(root, 0)] + while stack: + u, p = stack[-1] + if p == len(graph[u]): + finished.append(u) + stack.pop() + else: + v = graph[u][p] + stack[-1] = (u, p + 1) + if v in which and v not in seen: + seen.add(v) + stack.append((v, 0)) + seen.clear() + for root in reversed(finished): + if root in seen: + continue + comp = [] + seen.add(root) + stack = [root] + while stack: + u = stack.pop() + comp.append(u) + for v in reverse[u]: + if v in which and v not in seen: + seen.add(v) + stack.append(v) + yield comp + + +def reach(graph, root): + seen = {root} + stack = [root] + while stack: + for v in graph[stack.pop()]: + if v not in seen: + seen.add(v) + stack.append(v) + return seen + + +def hist(coeff, chosen): + return tuple(sum(coeff[i][j] for i in chosen) for j in range(10)) + + +def check_one(g, fixed, spaces, edges, kind, v, err): + active = ( + [not bool(p & (1 << v)) for p in spaces] + if kind == "grow" + else [any((a & v).bit_count() % 2 for a in basis) for basis in g["frames"]] + ) + sites, coeff, arcs = model(active, fixed, edges, kind, True) + p = [prices(h) for h in coeff] + upper, upper_choice, *_ = optimize([b for a, b in p], arcs) + assert upper == 0 and not upper_choice + top, cut, out, back, gap = optimize([a for a, b in p], arcs, hard_floor=2 * UNIT) + assert top == 0 and not cut + s = len(sites) + t = s + 1 + forced = reach(out, s) - {s} + nonfree = reach(back, t) + assert not forced and s not in nonfree + free = set(range(s)) - nonfree + zero = 0 + for comp in components(out, back, free): + assert not any(hist(coeff, comp)), (kind, v, comp, hist(coeff, comp)) + zero += 1 + assert gap is None or gap > err + return dict(sites=s, gap=gap, neutral_components=zero, free=len(free)) + + +def toy_oracle(): + """Compare every subset against literal point sets, then verify optimum by enumeration.""" + # Include an anchored lower/upper endpoint, a zero-net helper pair, mixed weights, + # and rank-one paid-only pairs admitting equality in the relaxation. + frames = [ + {0}, + {0, 1}, + {0, 1, 2, 3}, + set(range(8)), + {0, 2}, + {0, 2, 4, 6}, + {0, 4}, + {0, 1, 4, 5}, + ] + edges = [ + (0, 1, 1, -2, False), + (1, 2, 1, 3, True), + (2, 3, 1, -1, False), + (4, 2, 1, 1, True), + (4, 5, 1, -1, False), + (5, 3, 1, 2, True), + (0, 2, 2, 2, True), + (0, 5, 2, -3, False), + (6, 5, 1, 0, True), + (6, 7, 1, -1, False), + (7, 3, 1, 2, True), + ] + anchors = {0, 3} + tested = legal = contracted = positive = 0 + for kind in ("grow", "shrink"): + for v in range(1, 8): + trial = [ + ( + f | {p ^ v for p in f} + if kind == "grow" + else {p for p in f if (p & v).bit_count() % 2 == 0} + ) + for f in frames + ] + changing = [f != t for f, t in zip(frames, trial)] + possible = [i for i, c in enumerate(changing) if c and i not in anchors] + for relaxed in (False, True): + sites, coeff, arcs = model(changing, anchors, edges, kind, relaxed) + site_set = set(sites) + true_profits = [] + upper_profits = [] + for size in range(len(possible) + 1): + for subset in combinations(possible, size): + tested += 1 + chosen = set(subset) + actual = [ + trial[i] if i in chosen else f for i, f in enumerate(frames) + ] + fits = all( + ( + actual[a] < actual[b] + if helper or not relaxed + else actual[a] <= actual[b] + ) + for a, b, _, _, helper in edges + ) + ids = {i for i, x in enumerate(sites) if x in chosen} + permitted = chosen <= site_set and all( + a not in ids or b in ids for a, b in arcs + ) + assert fits == permitted + if not fits: + continue + legal += 1 + contracted += any(actual[a] == actual[b] for a, b, *_ in edges) + literal = [0] * 10 + for a, b, r, w, _ in edges: + grade = ( + len(actual[b]).bit_length() + - len(actual[a]).bit_length() + ) + literal[grade] += w + literal[r] -= w + assert tuple(literal) == hist(coeff, ids) + nominal, direct_upper = prices(tuple(literal)) + vertex_upper = sum(prices(coeff[j])[1] for j in ids) + assert nominal <= 2 * direct_upper <= 2 * vertex_upper + true_profits.append(nominal) + upper_profits.append(vertex_upper) + expected = max(true_profits) + actual, *_ = optimize([prices(h)[0] for h in coeff], arcs) + assert actual == expected + upper_optimum, *_ = optimize([prices(h)[1] for h in coeff], arcs) + assert upper_optimum == max(upper_profits) + positive += expected > 0 + assert 0 < contracted < legal < tested and 0 < positive < 28 + # A four-vertex independent closure control exercises a nonempty optimum. + value, selected, *_ = optimize([6, -2, 2, -8], [(0, 1), (2, 3)]) + assert (value, selected) == (4, {0, 1}) + return dict( + families=28, + selections=tested, + legal=legal, + legal_with_contraction=contracted, + positive_optima=positive, + hand_closure_value=value, + ) + + +def run(): + g, fixed, spaces, edges, count, unit_moves = load_input() + width = max(b - a for a, b in PRICE) + err = 2 * count * width + assert Q(err, 2 * UNIT) == Q(141523958955377375, UNIT) + result = { + "target": "39/10000", + "projection_sha256": PROJ_SHA, + "anchored_main_charts": len(fixed), + "mutable_active_charts": 768, + "incidence_pairs": len(edges), + "signed_terms_per_native": count, + "anchored_unit_paid_moves_per_native": unit_moves, + "guaranteed_paid_unit_roles_in_48_call_invoice": dict(g["fixed_paid"])[1] + + 48 * unit_moves, + "split_count": g["splits"], + "tariff_scale": str(UNIT), + "rounding_budget_doubled_grid": str(err), + "midpoint_only_upper_gain_per_native": str(Q(err, 2 * UNIT)), + "true_maximum_gain_per_native": "0", + "toy": toy_oracle(), + } + for kind in ("grow", "shrink"): + vals = [check_one(g, fixed, spaces, edges, kind, v, err) for v in range(1, 512)] + result[kind] = { + "cases": len(vals), + "zero_midpoint_maxima": len(vals), + "zero_directed_upper_maxima": len(vals), + "min_positive_residual_doubled_grid": str( + min(x["gap"] for x in vals if x["gap"] is not None) + ), + "free_components": sum(x["neutral_components"] for x in vals), + "max_free_sites": max(x["free"] for x in vals), + "max_active_sites": max(x["sites"] for x in vals), + } + return result + + +if __name__ == "__main__": + observed = run() + expected = json.loads((HERE / "GLOBAL-FRAMES.json").read_text()) + assert expected == observed, "joint frame result differs from the recorded receipt" + print( + "PASS_GLOBAL_FRAME_CLOSURE: 1022 exact zero upper profits, 1022 midpoint duals, " + "288 neutral residual components and 736 literal toy selections" + ) diff --git a/research/p104-gaussian-frame-price/neutral-factors.json.gz b/research/p104-gaussian-frame-price/neutral-factors.json.gz new file mode 100644 index 0000000000..b51273c713 Binary files /dev/null and b/research/p104-gaussian-frame-price/neutral-factors.json.gz differ diff --git a/research/p104-gaussian-frame-price/rebuild.py b/research/p104-gaussian-frame-price/rebuild.py new file mode 100644 index 0000000000..4b1f9d2ba8 --- /dev/null +++ b/research/p104-gaussian-frame-price/rebuild.py @@ -0,0 +1,82 @@ +"""Rebuild the frozen frame-price projection from either authenticated ToikY package.""" + +from argparse import ArgumentParser +from collections import Counter +from hashlib import sha256 +from pathlib import Path +from tempfile import TemporaryDirectory +import gzip +import json +import runpy +import subprocess +import sys + + +HERE=Path(__file__).resolve().parent +WORD="38d2b3a2311a9ba5fee091cc7aa204c7ed95651aec95d75184b2391df090cbfb" +LAYOUT="0ce3f9e383fc4bfdd22612b9e34fc9759d97204215937b82d23aec2cedd9b8ee" +PINS={ + "8072":("10362de3ceaa651cde5b71c6599fd4683d9f1f4d76cc252178e915b43a098fee", + "76f9d4c6bfd880ee49f6ba5bde9138cf0856d669edb4d525e48ca71a9094eec3"), + "8073":("9443a8ca39b9f0366305b67ba218875050c1574710b0d4ca4465cf8270f53119", + "c6a7037712bc56a22b879c8ea94e57e210ca66402e367bb196f02d1a22b72a8a"), +} + + +def canonical(obj): + return json.dumps(obj,sort_keys=True,separators=(",",":")).encode() + + +def projection(runtime): + sys.path.insert(0,str(runtime)) + from upstream import install + install() + from strong_complex import digest,load_changed,word + from grades import WEIGHTS,SCALES,SPLITS + graph,layout=load_changed(runtime/"inputs") + if digest(graph)!=WORD or digest(layout)!=LAYOUT: + raise ValueError("Gaussian word or owner layout differs") + receiver=word(graph,layout) + paid=Counter(p.rank for p in receiver.paid) + productive=Counter(p.rank for p in receiver.targets) + main=set(layout["live"])|{k+112 for k in layout["live"]}|set(layout["hosted"]["X2"])|set(layout["hosted"]["Y2"]) + moves={k:(a,b) for k,a,b in graph["moves"]} + dims=list(map(len,graph["frames"])) + for a,b in moves.values(): + paid[abs(dims[a]-dims[b])]-=48 + for i,(a,b) in enumerate(zip(graph["initial"],graph["final"])): + if i not in main: + productive[dims[b]-dims[a]]-=48 + if any(n<0 for n in list(paid.values())+list(productive.values())): + raise ValueError("A derived caller count is negative") + return {**{key:graph[key] for key in ("frames","initial","final","moves")}, + "paid_schedule":[k for k in graph["schedule"] if k in moves], + "main_roles":sorted(main),"native_calls":48,"weights":WEIGHTS,"scales":SCALES, + "splits":SPLITS,"complete_word_sha256":WORD,"complete_layout_sha256":LAYOUT, + "fixed_paid":sorted((r,n) for r,n in paid.items() if n), + "fixed_productive":sorted((r,n) for r,n in productive.items() if n)} + + +def main(): + parser=ArgumentParser(description=__doc__) + parser.add_argument("source_package",type=Path) + parser.add_argument("--pr",required=True,choices=PINS) + args=parser.parse_args() + p=args.source_package.resolve() + for filename,pin in zip(("verify.py","prepare.py"),PINS[args.pr]): + if sha256((p/filename).read_bytes()).hexdigest()!=pin: + raise ValueError(f"The source driver differs at {filename}") + with TemporaryDirectory(prefix="frame-price-rebuild-") as tmp: + work=Path(tmp) + peer=runpy.run_path(str(p/"verify.py"))["restore"](work) + runpy.run_path(str(p/"prepare.py"))["materialize"](peer) + runtime=work/"runtime" + subprocess.run([sys.executable,"-I","-B",str(peer/"bootstrap.py"),str(runtime)],check=True) + rebuilt=canonical(projection(runtime)) + if rebuilt!=gzip.decompress((HERE/"source-projection.json.gz").read_bytes()): + raise ValueError("Pinned source projection differs") + print("PASS_SOURCE_PROJECTION",args.pr,sha256(rebuilt).hexdigest()) + + +if __name__=="__main__": + main() diff --git a/research/p104-gaussian-frame-price/source-projection.json.gz b/research/p104-gaussian-frame-price/source-projection.json.gz new file mode 100644 index 0000000000..1ea4ef35e3 Binary files /dev/null and b/research/p104-gaussian-frame-price/source-projection.json.gz differ diff --git a/research/p104-gaussian-frame-price/verify.py b/research/p104-gaussian-frame-price/verify.py new file mode 100644 index 0000000000..6d16639dee --- /dev/null +++ b/research/p104-gaussian-frame-price/verify.py @@ -0,0 +1,265 @@ +"""Replay the strict frame-family price, two-vertex counts and neutral native controls.""" + +from collections import Counter, defaultdict +from fractions import Fraction as Q +from functools import cache +from hashlib import sha256 +from itertools import combinations +from math import isqrt +from pathlib import Path +import gzip +import json +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +from geometry import dimension, endpoint_options, finite_control, flags, space_count, space_mask +import gaussian_review as review + +UNIT = 2**192 +TARGET = Q(39, 10000) + + +def frozen(name, expected): + raw = gzip.decompress((HERE / name).read_bytes()) + if sha256(raw).hexdigest() != expected: + raise ValueError(f"Frozen input differs at {name}") + return json.loads(raw) + + +@cache +def tariff(rank): + """Enclose rank^(1−TARGET) using successive directed square roots.""" + assert rank > 0 + root_lo = root_hi = rank * UNIT + prod_lo = prod_hi = UNIT + rem = TARGET + for _ in range(152): + root_lo = isqrt(root_lo * UNIT) + root_hi = 1 + isqrt(root_hi * UNIT - 1) + rem *= 2 + if rem >= 1: + rem -= 1 + prod_lo = prod_lo * root_lo // UNIT + prod_hi = -(-prod_hi * root_hi // UNIT) + if rem: + prod_hi = -(-prod_hi * root_hi // UNIT) + numerator = rank * UNIT**2 + return numerator // prod_hi, -(-numerator // prod_lo) + + +def bounds(hist): + low = high = 0 + for rank, count in hist.items(): + a, b = tariff(rank) + low += min(count*a, count*b) + high += max(count*a, count*b) + return low, high + + +def classify(hist): + low, high = bounds(hist) + if high < 0: + return "worse" + if low > 0: + return "gain" + if low == high == 0: + return "tie" + raise ArithmeticError("An interval straddled zero") + + +def source_graph(g): + starts = defaultdict(Counter) + ends = defaultdict(Counter) + paid = defaultdict(Counter) + ranks = list(map(len,g["frames"])) + spaces = list(map(space_mask,g["frames"])) + main = set(g["main_roles"]) + assert len(main) == 400 and len(g["initial"]) == len(g["final"]) == 1291 + assert len(g["paid_schedule"]) == len(g["moves"]) == len(set(g["paid_schedule"])) == 5674 + assert {k for k,a,b in g["moves"]} == set(g["paid_schedule"]) + assert (g["weights"],g["scales"],g["splits"],g["native_calls"]) == ([5,451],[1,2],1008,48) + static_paid = Counter(dict(g["fixed_paid"])) + productive = Counter(dict(g["fixed_productive"])) + gross = static_paid.copy() + for _,a,b in g["moves"]: + assert spaces[a] != spaces[b] and (spaces[a] & spaces[b]) in (spaces[a],spaces[b]) + paid[a][b] += 1 + paid[b][a] += 1 + gross[abs(ranks[a]-ranks[b])] += 48 + for i,(a,b) in enumerate(zip(g["initial"],g["final"],strict=True)): + if i not in main: + assert spaces[a] != spaces[b] and spaces[a] & spaces[b] == spaces[a] + starts[a][b] += 1 + ends[b][a] += 1 + productive[ranks[b]-ranks[a]] += 48 + anchors = {g[key][i] for key in ("initial","final") for i in main} + helper_sites = (set(starts)|set(ends))-anchors + internal = set(paid) - set(g["initial"]) - set(g["final"]) + assert not internal & helper_sites and len(anchors) == 210 and len(helper_sites) == 62 + assert len(internal) == 706 and len(paid)==978 + return paid,starts,ends,ranks,spaces,internal,helper_sites,gross,productive + + +def single_delta(i,d,paid,starts,ends,ranks): + delta = Counter() + for h in set(paid[i])|set(starts[i])|set(ends[i]): + weight = starts[i][h] + ends[i][h] - paid[i][h] + delta[abs(d-ranks[h])] += weight + delta[abs(ranks[i]-ranks[h])] -= weight + return delta + + +def single_prices(sites, paid, starts, ends, ranks, spaces): + per_site = {} + feasible = different_dims = changes = 0 + closest = None + neutral_frames = {} + for i in sites: + count = Counter() + original = 0 + for option in endpoint_options(i,None,paid,starts,ends,ranks,spaces): + d = option[0] + number = space_count(option) + feasible += number + if d == ranks[i]: + original += number + continue + different_dims += 1 + changes += number + hist = single_delta(i,d,paid,starts,ends,ranks) + result = classify(hist) + count[result] += number + if result == "tie": + assert number == 1 + unique = option[1] if dimension(option[1])==d else option[2] + assert dimension(unique)==d + neutral_frames[i] = unique + if result == "worse": + lo, hi = bounds(hist) + if closest is None or hi > closest[0]: + closest = (hi,i,d,lo) + assert original == 1 + per_site[i] = count + return per_site,neutral_frames,(feasible,different_dims,changes),closest + + +def pair_prices(internal, paid, starts, ends, ranks, spaces, singles): + adjacent = {(i,j) for i in internal for j in paid[i] if i=0 for n in row.values()) + exclusive.update(row) + distant=Counter() + for i,j in combinations(sorted(internal),2): + if (i,j) in adjacent: + continue + a,b=singles[i],singles[j] + assert not a["gain"] and not b["gain"] + tie=a["tie"]*b["tie"] + distant["tie"]+=tie + distant["worse"]+=sum(a.values())*sum(b.values())-tie + return len(adjacent),dict(dimension_cases),dict(all_eligible),exclusive,distant + + +def neutral_actions(g, factors, neutral_frames, paid, spaces): + replacements=dict(factors["substitutions"]) + assert set(replacements)==set(neutral_frames) + frames=g["frames"].copy() + for i,basis in replacements.items(): + assert space_mask(basis)==neutral_frames[i] + assert spaces[i]!=neutral_frames[i] and not set(paid[i])&set(replacements) + frames[i]=basis + touched={(a,b) for _,a,b in g["moves"] if a in replacements or b in replacements} + records={(a,b):r for a,b,r in factors["pairs"]} + assert set(records)==touched and len(touched)==len(factors["pairs"])==72 + for (a,b),record in records.items(): + assert record["rank"]==abs(len(frames[b])-len(frames[a]))>0 + actual=review.recipe(record) + expected=review.adjoint(review.frame(frames[a],9))+review.frame(frames[b],9) + review.equal(actual,expected,"strict frame transfer") + if [a,b,record["rank"]]==factors["full_replay"]["all_column_control"]: + for basis in range(512): + assert review.state(actual,basis)==review.state(expected,basis) + shifted=actual+(("phase",1),) + assert review.tableau(shifted)==review.tableau(expected) and review.state(shifted)!=review.state(expected) + assert factors["full_replay"]["all_column_control"]==[292,1032,3] + assert sum(a in replacements or b in replacements for _,a,b in g["moves"])==104 + + +def main(): + expected=json.loads((HERE/"RESULT.json").read_bytes()) + g=frozen("source-projection.json.gz",expected["projection_sha256"]) + factors=frozen("neutral-factors.json.gz",expected["factors_sha256"]) + assert g["complete_word_sha256"] == expected["word_sha256"] + assert g["complete_layout_sha256"] == expected["layout_sha256"] + paid,starts,ends,ranks,spaces,internal,helpers,P,T=source_graph(g) + si,nf,sc,_=single_prices(internal,paid,starts,ends,ranks,spaces) + sh,hn,hc,hbest=single_prices(helpers,paid,starts,ends,ranks,spaces) + assert not hn and sc==(79413,3041,78707) and hc==(8793,171,8731) + assert hbest[1:3]==(1094,6) and Q(hbest[0],UNIT)=1008 + raw=T.copy() + raw.subtract(P) + lo,hi=(Q(x,UNIT) for x in bounds(raw)) + assert list(map(str,(lo,hi)))==expected["raw_margin"] + assert classify({1: 1})=="gain" and classify({1: -1})=="worse" + # The signed helper endpoints on chart 1094 contribute to both tariffs. + old_paid_only=single_delta(1094,6,paid,defaultdict(Counter),defaultdict(Counter),ranks) + full=single_delta(1094,6,paid,starts,ends,ranks) + assert dict(+full)!=dict(+old_paid_only) and bounds(full)!=(0,0) + zlo,zhi=(Q(x,UNIT) for x in tariff(2)) + wlo,whi=5+451*zlo,5+451*zhi + weighted_lo=whi*lo-5*1008*(2/zlo-1) + weighted_hi=wlo*hi-5*1008*(2/zhi-1) + assert Q("-1406.078231652773")0 and hi<0 + neutral_actions(g,factors,nf,paid,spaces) + print("PASS_STRICT_FRAME_PRICE",dict(total),"raw and two-type deficit at 39/10000", + "helper 1094 closest", "512 exact columns and 72 signed pairs") + + +if __name__=="__main__": + main()