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/paid-fusion-moment-ceiling/PROOF.md b/research/paid-fusion-moment-ceiling/PROOF.md new file mode 100644 index 0000000000..e6f82b7839 --- /dev/null +++ b/research/paid-fusion-moment-ceiling/PROOF.md @@ -0,0 +1,133 @@ +# Paid-fusion moment ceiling + +A legal rewrite that fuses paid child jobs keeps the productive multiset `T` +fixed and replaces paid ranks `b_1,...,b_m` by their sum. This package proves +what such a rewrite can and cannot buy at a crossing exponent `c` with +`0 < c < 1`, and gives the exact ceiling. Nothing here is source-bound: it is a +statement about the moment model the signed invoice uses, not about a word. + +## Definitions + +For a finite multiset `H` of positive integers (ranks) and real `c`, write + + `M_H(c) = sum_{h in H} h^c`. + +The gate compares `M_T(c)` with `M_P(c)`; a rewrite is favourable at `c` when it +increases `M_T(c) - M_P(c)`. The crossing exponent is the root of that +difference on the relevant interval. + +## Results + +Throughout `0 < c < 1` and all ranks are integers `>= 1`. + +1. **Strict subadditivity.** `(a+b)^c < a^c + b^c` for all `a,b >= 1`. + Consequently every paid fusion strictly lowers the paid moment at every + exponent in `(0,1)`, and every productive split strictly raises the + productive moment at every such exponent. The sign is exactly reversed for + `c > 1` and everything is an equality at `c = 1`. + +2. **m-block form.** For `m >= 2` and `b_i >= 1`, + `(b_1+...+b_m)^c < b_1^c + ... + b_m^c`. + +3. **Sharp single-fusion cap.** With `D(a,b) = a^c + b^c - (a+b)^c`, + + `0 < D(a,b) < min(a,b)^c`, + + and the constant one is sharp: for fixed `a`, `D(a,b)/a^c -> 1` as + `b/a -> infinity`. It is never attained. For a fixed total rank `r = a+b`, + `D(a,r-a)` is instead maximized by the balanced split and minimized by the + unbalanced ones. So no single fusion is worth one full copy of its smaller + job's moment; very unequal pairs approach that cap when the smaller rank is + held fixed, while at a fixed total paid mass a balanced merge buys most. + +4. **Global fusion ceiling.** Let `P` be a paid multiset and let any partition + of `P` into blocks be replaced by the block sums. The paid moment falls, and + it stays at least the single-job moment of the whole paid mass: + + `M_{P'}(c) >= (sum_{p in P} p)^c`, so `M_P(c) - M_{P'}(c) <= G(c)`, + + where `G(c) = sum_{p in P} p^c - (sum_{p in P} p)^c`, with equality only for + the one-block (full) fusion. `G` is therefore the total budget every + paid-only fusion scheme shares. + +5. **Crossing consequence.** If a rewrite fuses paid jobs and leaves `T` fixed, + then at every `c` in `(0,1)` + + `M_T(c) - M_{P'}(c) <= M_T(c) - (sum_{p in P} p)^c`. + + Hence the crossing exponent after any paid-only fusion is at most the root + of `M_T(c) = (sum_P p)^c`. No choice of which jobs to fuse, and no number of + fusions, can pass that root. This is the stopping rule: a paid-fusion search + that cannot reach the root against one collapsed paid job cannot reach the + claim either. + +## Proofs + +1. `x -> x^c` is concave on `[0,inf)` for `0 b^c` and `(a+b)^c > a^c`. For `c>1` the + derivative is increasing and both inequalities reverse; at `c=1` the two + sides are equal. + +2. Induct on `m`, applying (1) to `(b_1+...+b_{m-1})` and `b_m`; the sum of the + first `m-1` terms is itself strictly greater than their `c`-power sum. + +3. Lower bound: `D > 0` is (1). Upper bound: assume `a <= b`; then + `D = a^c + b^c - (a+b)^c < a^c` because `b^c < (a+b)^c`. Sharpness: put + `s = b/a`; then `D/a^c = 1 + s^c - (1+s)^c`, and + `(1+s)^c - s^c = s^c((1+1/s)^c - 1) -> 0`, so the ratio tends to one. The + fixed-sum claim: `g(a) = a^c + (r-a)^c` has + `g''(a) = c(c-1)(a^{c-2} + (r-a)^{c-2}) < 0`, so `g` is concave and + symmetric; a concave symmetric function is maximized at its midpoint and + minimized at an endpoint, so `D = g - r^c` has the same two extrema in the + same order. Over integers `a >= 1` the endpoints are `a = 1` and `a = r-1`. + +4. Apply (2) inside every block: the merged moment is strictly smaller than + `M_P(c)` unless every block is a singleton. Apply (2) to the block sums + themselves: `(sum_j s_j)^c < sum_j s_j^c` whenever there are at least two + blocks, so `M_{P'}(c) > (sum_P p)^c` for every non-trivial partition. The + one-block partition gives `M_{P'} = (sum_P p)^c` exactly, which is the + smallest value any partition can reach and the ceiling `G(c)`. + +5. Substitute (4) into the definition of the difference; both sides are + monotone in `c`, so the root cannot move right of the root against the + collapsed paid job. + +## Verification + +`verify.py` encloses every `a^c` in an exact rational interval and then checks +the statements above by exact rational comparison on finite grids: + +- subadditivity and the sharp cap for all `1 <= a <= b <= 40` at five + exponents, including `c = 363005817/100000000000` (the selected record's + exponent) and `c = 1/279`, `1/1000` (`BIT`-scale and millesimal regimes); +- the `m`-block form for `m = 2,3,4` on five block shapes per exponent; +- the approach of `D(1,b)` to its cap for `b = 10^2..10^12` with exact integer + square roots at `c = 1/2`, certifying `0.99 < D < 1` from `b = 10^4`; +- balanced-split optimality at fixed total rank against every other split of + the same total for `3 <= r <= 60`; +- the global ceiling over five explicit multisets and every partition shape, + with full collapse attaining the bound, plus a non-fusion control showing a + paid split strictly raises the moment; +- rejection controls: `c = 1, 2, 3/2` (hypothesis fails), and non-positive + ranks or `c = 0` (rejected). + +The transcendental step is CPython `decimal` at 90 digits, correctly rounded +per its documentation, widened by one unit in the last place; all later +arithmetic is exact rational. A certified inequality is therefore a proof of +that finite case, not a floating-point observation. + +## Limitations + +- The result is a statement about the moment model. It does not certify that any + word, caller, compiler, precision tape or outer row exists, and it does not + bound the productive side, where #6651 already gives the balanced-split + optimum for a concave tariff. +- Lemma 1 is classical. What is new here is the quantitative cap in (3), the + total budget in (4) and the crossing consequence in (5), which turn the + classical inequality into a search-stopping rule. +- No source-bound invoice is evaluated: the package proves a ceiling that any + such invoice must respect. diff --git a/research/paid-fusion-moment-ceiling/README.md b/research/paid-fusion-moment-ceiling/README.md new file mode 100644 index 0000000000..1db6284da8 --- /dev/null +++ b/research/paid-fusion-moment-ceiling/README.md @@ -0,0 +1,113 @@ +# Paid-fusion moment ceiling + +How much can a paid-side rewrite buy at a crossing exponent `c` with +`0 < c < 1`? This package answers the fusion case exactly. + +## Scope + +A *paid fusion* replaces paid ranks `b_1,...,b_m` by their sum `b_1+...+b_m` +and leaves the productive multiset `T` fixed. Write `M_H(c) = sum_{h in H} h^c` +for a finite multiset of positive integer ranks. No word, caller, compiler, +precision tape or outer row is claimed; this is a statement about the moment +model that the signed invoice evaluates. + +## Result + +Claim type: scoped written proof with exact finite corroboration. No κ change. + +1. `(a+b)^c < a^c + b^c` strictly for all integers `a,b >= 1` and every + `c` in `(0,1)`; equality at `c = 1`; the inequality reverses for `c > 1`. + Every paid fusion therefore strictly lowers `M_P(c)` and every productive + split strictly raises `M_T(c)` on the whole sub-unit exponent range. +2. The single-fusion saving `D(a,b) = a^c + b^c - (a+b)^c` obeys + `0 < D(a,b) < min(a,b)^c`. The constant one is sharp + (`D(a,b)/a^c -> 1` as `b/a -> infinity` for fixed `a`) and never attained. +3. At a fixed total paid rank `r = a+b`, `D(a,r-a)` is maximized by the + balanced split and minimized by the unbalanced ones. +4. Let any partition of a paid multiset `P` be replaced by its block sums. The + paid moment falls, and for every partition + + `M_{P'}(c) >= (sum_{p in P} p)^c`, hence + `M_P(c) - M_{P'}(c) <= G(c) = sum_{p in P} p^c - (sum_{p in P} p)^c`, + + with equality only for the one-block collapse. `G(c)` is the total budget + that all paid-only fusion schemes share. +5. Consequently the crossing exponent after any paid-only fusion is at most the + root of `M_T(c) = (sum_{p in P} p)^c`. No set of fusions, and no choice of + which jobs to fuse, can pass that root. + +Point 5 is the usable form: it converts a fusion family into one scalar test +that needs no word replay. + +## Evidence + +`verify.py` encloses each `a^c` in an exact rational interval and then compares +exactly. It certifies, with zero inconclusive cases: + +- points 1 and 2 for all `1 <= a <= b <= 40` at five exponents: `1/1000`, + `1/279`, `363005817/100000000000` (the selected record's exponent), `1/2` + and `3/4`; +- the `m`-block form for `m = 2,3,4` on five block shapes per exponent; +- the sharpness approach `0.99 < D(1,b) < 1` for `b = 10^4..10^12` at + `c = 1/2`, with exact Newton enclosures of both square roots; +- point 3 against every other split of the same total for `3 <= r <= 60`; +- point 4 on five explicit multisets and every partition shape, with the full + collapse attaining the bound, plus a non-fusion control where a paid split + strictly raises the moment; +- rejection controls at `c = 1, 2, 3/2` and for non-positive ranks or `c = 0`. + +The transcendental step is CPython `decimal` at 90 digits (correctly rounded per +its documentation), widened by one unit in the last place; all later arithmetic +is exact rational, so a certified inequality is a proof of that finite case. +`RESULT.json` stores the SHA-256 of the canonical summary and of `PROOF.md`; +`verify.py` recomputes both and fails on any mismatch. + +## Reproduction + +From the repository root with CPython 3.12: + +```sh +python3.12 -B scripts/research_package.py --package research/paid-fusion-moment-ceiling +python3.12 -B scripts/check_research_commit.py --package research/paid-fusion-moment-ceiling --check-source-history +``` + +The registered command is `{python} -B {package}/verify.py`. It runs in a few +seconds. + +## Limitations + +- The ceiling is a moment-model statement. A legal realization, native delivery, + dirty restoration, the compiler, the precision tape and the nine outer rows + remain separate obligations. +- Only the paid side is bounded here. The productive side already has a + balanced-split optimum and halving test for a concave rank tariff in #6651; + that result is cited, not re-derived or replayed. +- The package does not evaluate any invoice. Points 4 and 5 are a template: an + application needs the exact `T` and `P` the gate consumes. + +## Open next questions + +1. **Apply the ceiling to one live fusion family.** Take the exact invoice + histogram the interval gate consumes, collapse `P` to one job of rank + `sum p`, and compute the root of `M_T(c) = (sum p)^c`. Report whether the + family's target lies above that root. First step: read the gate's own audit + input rather than the `invoice` summary block of + `research/shared-wire-split-composition/FULL-RESULT.json`, because the + summary histograms are not interchangeable with the gate's argument. Why it + matters: one scalar decides whether more fusion exclusions are worth + running. Blocked by: pinning the rank convention of that audit input. +2. **Fusion plus productive credit.** Extend to rewrites that fuse paid jobs and + also add productive targets. Does the budget stay separable, or does the + joint movement of both sides need a two-parameter bound? First step: state + the joint model and look for a counterexample to separability. Blocked by: + no joint model is fixed in the current packages. + +## Credit + +The quantitative cap, the global fusion budget and the crossing consequence, +with the verifier and certificate, were produced by Nick Petalas. Credit +thakrarsagar's #718 for the scoped `(5,1)`-versus-`(4,2)` paid-read comparison +that exhibits the same subadditivity on specific ranks, and Nick Petalas's #6651 +for the balanced-split optimum and halving test on the productive side; both are +cited background, not replayed. Concavity of `x^c` is classical. Apache-2.0. +Independent human review and formal proof-kernel acceptance are unclaimed. diff --git a/research/paid-fusion-moment-ceiling/RESULT.json b/research/paid-fusion-moment-ceiling/RESULT.json new file mode 100644 index 0000000000..a57edff475 --- /dev/null +++ b/research/paid-fusion-moment-ceiling/RESULT.json @@ -0,0 +1,10 @@ +{ + "claim_type": "scoped written proof with exact finite corroboration", + "result": "For 0 < c < 1 and integer ranks, every fusion of paid child jobs strictly lowers the paid moment; a single fusion of ranks a,b saves D(a,b) with 0 < D(a,b) < min(a,b)^c and sharp constant one; at fixed total rank the balanced split maximizes D; any fusion scheme lowers the paid moment by at most G(c) = sum p^c - (sum p)^c, so a paid-only rewrite cannot push the crossing exponent past the root against one paid job of the total paid rank. No kappa change.", + "exponents_checked": ["1/1000", "1/279", "363005817/100000000000", "1/2", "3/4"], + "precision_digits": 90, + "receipt_sha256": "d6f45214086f34643da291c9919120f0d3bb79d41016d67386c302c174027593", + "proof_sha256": "127cef22ad813fe99b9ef132ce44c11786522093c9b4bd6bfa9de7717ba59bf7", + "interpretation": "A searching contributor can reject a whole paid-fusion family without a word replay: compute the root against one collapsed paid job; if it is below the target, no fusion scheme reaches the target.", + "limitations": "Moment model only. No word, caller, compiler, precision tape or outer row is certified. The productive side is not bounded; #6651 gives the balanced-split optimum there." +} diff --git a/research/paid-fusion-moment-ceiling/SOURCES.json b/research/paid-fusion-moment-ceiling/SOURCES.json new file mode 100644 index 0000000000..5335fa97d9 --- /dev/null +++ b/research/paid-fusion-moment-ceiling/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + } + ] +} diff --git a/research/paid-fusion-moment-ceiling/TASK.json b/research/paid-fusion-moment-ceiling/TASK.json new file mode 100644 index 0000000000..3e0248a89e --- /dev/null +++ b/research/paid-fusion-moment-ceiling/TASK.json @@ -0,0 +1,113 @@ +{ + "schema_version": 1, + "task_id": "scalar-to-moment", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "scalar-to-moment", + "question": "Can a scalar/frame rewrite improve the complete signed moment through paid jobs, productive targets, or both?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "docs/research/recursive-invoice-preflight.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "Require a legal chronological rewrite and favorable complete signed target-minus-paid moment with all extra charges. Unchanged ADD counts or unchanged paid-call counts alone decide neither success nor failure. Compiler, native and outer admission remain separate obligations.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Construct one legal source-bound rewrite and compare complete before/after P and T. Charge restoration, source windows and owned helpers. A paid call need not disappear: a legal target split or rank redistribution may win. Stop if the signed moment is unchanged or the consumer repays the gain. Do not extend a scalar-only census on ADD counts.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "signed moment", + "target split", + "rank exchange", + "scalar rewrite" + ], + "existing_checks": [ + { + "scope": "PR #3998: consecutive A2 scalar contraction", + "evidence": "research/staged544-a2-graph-rewrite/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "389268a6b5e0373a3125d5c6fcd6995f4ea324f5", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4019: separated A2 sites with unchanged recursive histogram", + "evidence": "research/staged544-separated-a2/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "f408e09df300b575235f7f77f81948071397e16d", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4112: composition audit", + "evidence": "research/staged544-a2-composition-audit/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "205b7380656ba4b6316a8a493b1a3c679b8f7a0e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4152: A1858 contraction audit", + "evidence": "research/staged544-a1858-contraction-audit/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "caaa14cde5962adc372fdca71f63d0f29e73c8b2", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Exact paid-side fusion ceiling in the signed moment model at a sub-unit crossing exponent: strict superadditivity, the sharp single-fusion cap min(a,b)^c, the total fusion budget G(c), and the resulting upper bound on the crossing exponent for any paid-only fusion scheme. No source-bound word, caller or invoice instance is evaluated.", + "scope_change_reason": "The card asks for a source-bound rewrite or a target-specific obstruction. This package takes the card's second method but at the model level: it bounds the whole paid-fusion mechanism with one scalar, before any word is chosen. The reduction is recorded here; a source-bound instance remains the open next question.", + "bottleneck_link": "Paid-fusion families are a recurring search direction in the current P104 and BIT exclusion rounds. The ceiling decides a whole family with one root computation instead of one replay per member, and it shows that the sub-unit exponent is exactly what makes fusion profitable at all.", + "budget_minutes": 60, + "stop_rule": "Stop after the sharp cap, the global budget and the crossing consequence are proved and exactly corroborated; do not extend to a source-bound invoice in this package.", + "outcome": "completed", + "evidence": "research/paid-fusion-moment-ceiling/PROOF.md and verify.py; certificate summary hash d6f45214086f34643da291c9919120f0d3bb79d41016d67386c302c174027593 over 12,631 certified comparisons with zero inconclusive cases.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "For one live invoice the interval gate consumes, does the root of M_T(c) = (sum_P p)^c lie above or below the fusion family's target?", + "why_it_matters": "One scalar verdict replaces a search over fusion schemes for that word.", + "first_step": "Read the gate's audit input (not the invoice summary block of research/shared-wire-split-composition/FULL-RESULT.json), collapse P, and bisect the root.", + "blocked_by": "The rank convention of the gate's audit histogram must be pinned first." + }, + { + "question": "Does the fusion budget stay separable when a rewrite also adds productive credit?", + "why_it_matters": "Real candidates move both sides, and a separable bound would keep the one-scalar test.", + "first_step": "State the joint model and search for a counterexample to separability.", + "blocked_by": "No joint model is fixed in the current packages." + } + ] +} diff --git a/research/paid-fusion-moment-ceiling/VERIFY.json b/research/paid-fusion-moment-ceiling/VERIFY.json new file mode 100644 index 0000000000..861e7960d3 --- /dev/null +++ b/research/paid-fusion-moment-ceiling/VERIFY.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact rational-interval certificate for strict subadditivity, the sharp single-fusion cap min(a,b)^c with its sharpness approach, balanced-split optimality at fixed total rank, the global fusion budget with full-collapse attainment, a non-fusion control, and hypothesis rejection controls; receipt hash bound to RESULT.json and PROOF.md." + } + ] +} diff --git a/research/paid-fusion-moment-ceiling/verify.py b/research/paid-fusion-moment-ceiling/verify.py new file mode 100644 index 0000000000..54131cfe2b --- /dev/null +++ b/research/paid-fusion-moment-ceiling/verify.py @@ -0,0 +1,247 @@ +#!/usr/bin/env python3 +"""Exact certificate for the paid-fusion moment ceiling. + +Every power a^c with integer a >= 1 and rational 0 < c < 1 is enclosed in an +exact rational interval [lo, hi]. The transcendental step uses CPython +``decimal`` at PREC digits, whose ``ln`` and ``exp`` are correctly rounded to +the context precision; each result is widened by one unit in the last place, so +the enclosure is rigorous. All later arithmetic and every comparison is exact +rational arithmetic, so a certified inequality is a proof of that finite case. + +The file also regenerates a canonical summary and compares its SHA-256 with the +value stored in RESULT.json, so the receipt is bound to the exact numbers. +""" +from __future__ import annotations + +import hashlib +import json +import sys +from decimal import Decimal, localcontext +from fractions import Fraction as F +from math import isqrt +from pathlib import Path + +if not __debug__: + raise RuntimeError("run without -O; assertions are proof checks") + +PREC = 90 +HERE = Path(__file__).resolve().parent + + +def _ulp(x: Decimal) -> Decimal: + """One unit in the last place of a PREC-digit decimal.""" + return Decimal(1).scaleb(x.adjusted() - PREC + 1) + + +def _ln_bounds(n: int) -> tuple[F, F]: + assert n >= 1 + with localcontext() as ctx: + ctx.prec = PREC + v = Decimal(n).ln() + u = _ulp(v) + return F(v - u), F(v + u) + + +def _exp_bounds(x: F) -> tuple[F, F]: + """exp on a rational argument, rigorous both sides.""" + with localcontext() as ctx: + ctx.prec = PREC + 20 + d = Decimal(x.numerator) / Decimal(x.denominator) + with localcontext() as ctx: + ctx.prec = PREC + lo = d.exp() + hi = d.exp() + ulo = _ulp(lo) + uhi = _ulp(hi) + return F(lo - ulo), F(hi + uhi) + + +def power_interval(base: int, c: F) -> tuple[F, F]: + """Rigorous [lo, hi] with lo <= base**c <= hi for integer base >= 1, c > 0.""" + assert isinstance(base, int) and base >= 1 + assert isinstance(c, F) and c > 0 + if c == 1: + return F(base), F(base) + ll, lh = _ln_bounds(base) + lo, _ = _exp_bounds(ll * c) + _, hi = _exp_bounds(lh * c) + return lo, hi + + +def split_deficit_bounds(a: int, b: int, c: F) -> tuple[F, F]: + """Bounds for D(a,b) = a**c + b**c - (a+b)**c.""" + lo_a, hi_a = power_interval(a, c) + lo_b, hi_b = power_interval(b, c) + lo_s, hi_s = power_interval(a + b, c) + return lo_a + lo_b - hi_s, hi_a + hi_b - lo_s + + +def min_power_bounds(a: int, b: int, c: F) -> tuple[F, F]: + return power_interval(min(a, b), c) + + +class Certificate: + def __init__(self) -> None: + self.counts: dict[str, int] = {} + self.inconclusive: dict[str, int] = {} + self.hashes: list[str] = [] + + def record(self, tag: str, ok: bool) -> None: + self.counts[tag] = self.counts.get(tag, 0) + 1 + if not ok: + self.inconclusive[tag] = self.inconclusive.get(tag, 0) + 1 + + +CS = [ + ("1/1000", F(1, 1000)), + ("1/279", F(1, 279)), + ("kappa_363005817/100000000000", F(363005817, 100000000000)), + ("1/2", F(1, 2)), + ("3/4", F(3, 4)), +] + +cert = Certificate() + +# --- Lemma 1: strict subadditivity, 0 < D(a,b) < min(a,b)**c ----------------- +for cname, c in CS: + for a in range(1, 41): + for b in range(a, 41): + d_lo, d_hi = split_deficit_bounds(a, b, c) + m_lo, m_hi = min_power_bounds(a, b, c) + cert.record(f"subadditivity[{cname}]", d_lo > 0) + cert.record(f"sharp_cap[{cname}]", d_hi < m_lo) + + +# --- Lemma 2: m-block strict subadditivity ---------------------------------- +def block_bounds(parts: list[int], c: F) -> tuple[F, F]: + lo = sum(power_interval(p, c)[0] for p in parts) + hi = sum(power_interval(p, c)[1] for p in parts) + return lo, hi + + +for cname, c in CS: + for m in (2, 3, 4): + for parts in ( + [1] * m, + [1] + [2] * (m - 1), + [2] * m, + [1, 2, 3, 4][:m], + [3, 5, 7, 11][:m], + ): + lo, hi = block_bounds(parts, c) + s_lo, s_hi = power_interval(sum(parts), c) + cert.record(f"mblock[{cname}]", hi > s_lo) + +# --- Sharpness of the cap: D(1,b) / 1 tends to one (c = 1/2, exact bounds) --- +def sqrt_bounds(n: int) -> tuple[F, F]: + """Exact rational enclosure of sqrt(n); Newton gives x >= sqrt(n) >= n/x.""" + s = max(isqrt(n), 1) + x = F(s) + for _ in range(12): + x = (x + F(n) / x) / 2 + lo, hi = (F(n) / x, x) if x >= F(n) / x else (x, F(n) / x) + assert lo * lo <= n <= hi * hi + return lo, hi + + +for k in range(2, 13): + b = 10 ** k + lb, ub = sqrt_bounds(b) + lb1, ub1 = sqrt_bounds(b + 1) + lo = 1 + lb - ub1 # lower bound of 1 + sqrt(b) - sqrt(b+1) + hi = 1 + ub - lb1 + assert lo <= hi + cert.record("sharpness_gap_below_one", hi < 1) + if k >= 4: + cert.record("sharpness_gap_above_0.99", lo > F(99, 100)) + +# --- Balanced split maximizes the single fusion saving at fixed total rank --- +for cname, c in CS: + for r in range(3, 61): + m = r // 2 + e_lo, e_hi = split_deficit_bounds(m, r - m, c) + for a in range(1, m): + o_lo, o_hi = split_deficit_bounds(a, r - a, c) + cert.record(f"balanced_split_max[{cname}]", o_hi < e_lo) + +# --- Global fusion ceiling -------------------------------------------------- +def merged_moment_bounds(multiset: list[int], blocks: list[list[int]], c: F): + assert sorted(p for block in blocks for p in block) == sorted(multiset) + lo = sum(power_interval(sum(block), c)[0] for block in blocks) + hi = sum(power_interval(sum(block), c)[1] for block in blocks) + return lo, hi + + +MULTISETS = [ + [1, 1, 1, 1, 2, 2, 3], + [1] * 7, + [1, 2, 3, 4, 5, 8, 16], + [2, 2, 3, 3, 5, 7, 11, 13], + [1] * 12 + [6, 6], +] +for cname, c in CS: + for ms in MULTISETS: + total_lo, total_hi = power_interval(sum(ms), c) + blocks = [[p] for p in ms] + m_lo, m_hi = merged_moment_bounds(ms, blocks, c) + base_lo = sum(power_interval(p, c)[0] for p in ms) + base_hi = sum(power_interval(p, c)[1] for p in ms) + # the singleton partition is the identity rewrite + assert m_lo <= base_hi and base_lo <= m_hi + # ceiling: M(P') >= (sum P)**c for every partition + cert.record(f"fusion_ceiling[{cname}]", m_lo > total_hi) + # full collapse attains the ceiling value + full_lo, full_hi = merged_moment_bounds(ms, [ms], c) + assert full_lo <= total_hi and total_lo <= full_hi + # a genuine fusion strictly lowers the paid moment + for blocks2 in ([[ms[0], ms[1]]] + [[p] for p in ms[2:]], + [[p] for p in ms[:-2]] + [[ms[-2], ms[-1]]], + [[ms[0], ms[1], ms[2]]] + [[p] for p in ms[3:]]): + f_lo, f_hi = merged_moment_bounds(ms, blocks2, c) + cert.record(f"fusion_monotone[{cname}]", f_hi < base_lo) + # non-fusion control: splitting any paid job raises the moment + split = ms + [1] + s_lo = sum(power_interval(p, c)[0] for p in split) + cert.record(f"split_control[{cname}]", s_lo > base_hi) + +# --- Rejection controls: the hypothesis 0 < c < 1 is necessary -------------- +for c in (F(1), F(2), F(3, 2)): + a, b = 3, 5 + d_lo, d_hi = split_deficit_bounds(a, b, c) + cert.record("control_non_strict_or_reversed", d_lo <= 0) + +for bad in (0, -2): + try: + power_interval(bad, F(1, 2)) + except AssertionError: + cert.record("control_nonpositive_rank_rejected", True) + else: + cert.record("control_nonpositive_rank_rejected", False) + +try: + power_interval(4, F(0)) +except AssertionError: + cert.record("control_zero_exponent_rejected", True) +else: + cert.record("control_zero_exponent_rejected", False) + +# --- Receipt --------------------------------------------------------------- +failures = {tag: n for tag, n in cert.inconclusive.items() if n} +summary = { + "checked": dict(sorted(cert.counts.items())), + "inconclusive": failures, + "precision_digits": PREC, + "exponents": [name for name, _ in CS], + "proof_sha256": hashlib.sha256((HERE / "PROOF.md").read_bytes()).hexdigest(), +} +canonical = json.dumps(summary, sort_keys=True, separators=(",", ":")).encode() +summary_sha = hashlib.sha256(canonical).hexdigest() + +result = json.loads((HERE / "RESULT.json").read_text()) +print(json.dumps(summary, indent=1, sort_keys=True)) +print("summary_sha256", summary_sha) +print("expected ", result["receipt_sha256"]) +assert not failures, f"inconclusive cases: {failures}" +assert summary_sha == result["receipt_sha256"], "receipt mismatch" +assert summary["proof_sha256"] == result["proof_sha256"], "proof hash mismatch" +print("PASS_PAID_FUSION_MOMENT_CEILING")