diff --git a/research/pr4521-expanded-count-check/.gitattributes b/research/pr4521-expanded-count-check/.gitattributes new file mode 100644 index 0000000000..04cf88b8eb --- /dev/null +++ b/research/pr4521-expanded-count-check/.gitattributes @@ -0,0 +1 @@ +PR4521-RESULT.json -text diff --git a/research/pr4521-expanded-count-check/PR4521-RESULT.json b/research/pr4521-expanded-count-check/PR4521-RESULT.json new file mode 100644 index 0000000000..85ee016696 --- /dev/null +++ b/research/pr4521-expanded-count-check/PR4521-RESULT.json @@ -0,0 +1,267 @@ +{ + "literal_expansions": { + "equal_product_flow_ranks": [ + 8, + 16, + 32, + 64, + 128 + ], + "full_call_tree_cases": [ + { + "last_counts": { + "B": 1, + "P": 1, + "Q": 7, + "U": 3, + "routes": 8 + }, + "last_literal_events": 15, + "paid": { + "1": 1 + }, + "ranks": [ + 0, + 8 + ], + "targets": { + "2": 1 + } + }, + { + "last_counts": { + "B": 8192, + "P": 91904, + "Q": 14592, + "U": 12544, + "routes": 117248 + }, + "last_literal_events": 265025, + "paid": { + "1": 2, + "4": 1 + }, + "ranks": [ + 0, + 13 + ], + "targets": { + "2": 1, + "5": 1 + } + }, + { + "last_counts": { + "B": 3500, + "P": 18500, + "Q": 2500, + "U": 1750, + "routes": 37500 + }, + "last_literal_events": 71421, + "paid": { + "1": 6, + "2": 2 + }, + "ranks": [ + 0, + 6 + ], + "targets": { + "2": 4, + "3": 1 + } + }, + { + "last_counts": { + "B": 6400, + "P": 51200, + "Q": 16000, + "U": 10880, + "routes": 101120 + }, + "last_literal_events": 202501, + "paid": { + "1": 1, + "2": 2 + }, + "ranks": [ + 0, + 13 + ], + "targets": { + "3": 1, + "4": 1 + } + } + ] + }, + "new_kappa": false, + "p7_counted_expansion": { + "expanded_counts": { + "B": { + "bits": 17504, + "unsigned_big_endian_sha256": "49727d4435d62a4a84b79cf2451d374a5bb98234cbe460ec0b0ef3da77c8c9e6" + }, + "P": { + "bits": 17514, + "unsigned_big_endian_sha256": "1f28a559d21f0df473b67fef0c37eb57144955250234a44c998bd837d1e8f3d6" + }, + "Q": { + "bits": 17497, + "unsigned_big_endian_sha256": "0f2b521412ca3f565d734c244b1cf42b8c7d49ef1e61af197ec97b2605078a3c" + }, + "U": { + "bits": 17497, + "unsigned_big_endian_sha256": "0f5ce7310a89be0835b71681538c3e2e57134d2690ff663b8bc1cd10938b9c7f" + }, + "routes": { + "bits": 17514, + "unsigned_big_endian_sha256": "98bde80b4a7bc886645e82f3b9e730545da94beddcbec4e98ce88e1c44a39242" + } + }, + "n": 1000, + "nonbase_ranks": 880, + "positive_invocation_rank_classes": 970, + "scope": "Counted DAG, not literal enumeration of the enormous program.", + "surplus": 608 + }, + "schema_version": 1, + "scope": "Independent finite expanded accounting and a conditional induction proof; native, physical, all-size exponent and precision admission remain outside scope.", + "semantic_rejections": [ + "omitted_source_complement", + "omitted_exit", + "duplicated_child_batch", + "omitted_raw_instance", + "wrong_raw_column", + "division_bound_delta_0", + "division_bound_delta_-1", + "omitted_premature_exit", + "nonintegral_child_batch", + "deduplicated_child_instances", + "missing_replication", + "collapsed_raw_columns", + "missing_base_leaf", + "nondecreasing_paid_rank" + ], + "source_flow_fixtures": [ + { + "n": 20, + "rule": "separated-control" + }, + { + "n": 40, + "rule": "separated-control" + }, + { + "n": 80, + "rule": "separated-control" + }, + { + "n": 20, + "rule": "strict-overlap" + }, + { + "n": 40, + "rule": "strict-overlap" + }, + { + "n": 80, + "rule": "strict-overlap" + }, + { + "n": 20, + "rule": "source-open-equality" + }, + { + "n": 40, + "rule": "source-open-equality" + }, + { + "n": 80, + "rule": "source-open-equality" + } + ], + "source_sha256": { + "vendor/PR4436-README.md": "78351e2419eb1ff1d645addd411158b91b381b23a962a91b6deeebeacd5192a8", + "vendor/PR4436-RESULT.json": "da04256f6f2ef61530f1d642ff1137a2274fd642782a72ef4bf3f1b65395c270", + "vendor/PR4436-flow.py": "460f0b0262d7b6880973f46240b3fff1e9f04601fa1d658dda18688b1e26575a", + "vendor/PR4436-p7-RESULT.json": "9b814be97e3b45fcc28eafa8a65694897a7387f71a14d44796c6aadf303d7fab", + "vendor/PR4476-README.md": "0563dd22edeba4ee82a5ac4a06d965ccb90edbb09bbe646c9f21497bd4789f76", + "vendor/SUSSMAN-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "vendor/SUSSMAN-NOTICE": "8289a4ba75efe5da7bd2e389b951155ff74b3bf49b38ace0906a1e5205c7cd6e" + }, + "status": "PASS_DIRECT_FLOW_EXPANDED_ACCOUNTING", + "toy_counted_expansions": [ + { + "expanded_counts": { + "B": { + "bits": 433, + "unsigned_big_endian_sha256": "35f12bcc6000b703565e2f120e8077641f744909e8ec163921775b2b0c139254" + }, + "P": { + "bits": 439, + "unsigned_big_endian_sha256": "7df4f5875466fa21b225c2b60317e60536fdededbe8473d18fe5fb3fb057bb6f" + }, + "Q": { + "bits": 438, + "unsigned_big_endian_sha256": "f469278cd8f6190ffe6a1ae190299a8d183d1675d4280087d107e5d7016aee25" + }, + "U": { + "bits": 436, + "unsigned_big_endian_sha256": "12b6d174870cd23fd40ad1f4ff56df629ed813fabbbfcf143a914bfdd875609d" + }, + "routes": { + "bits": 439, + "unsigned_big_endian_sha256": "4034ff94efe1f1ab70575b300eebbd2469e9065861c4f2570a59256c47170f74" + } + }, + "n": 100, + "nonbase_ranks": 96, + "paid": { + "1": 2, + "4": 1 + }, + "reverse_expansions": 101, + "targets": { + "2": 1, + "5": 1 + } + }, + { + "expanded_counts": { + "B": { + "bits": 1002, + "unsigned_big_endian_sha256": "398043f007044ec4c1ba14eda89bf66b48733ce7a22bb855a3bc17a4665b5952" + }, + "P": { + "bits": 1008, + "unsigned_big_endian_sha256": "1302eac01cf514d2855c821612c64c9d38a6c9ff55f12115f72bf34a9906b9d5" + }, + "Q": { + "bits": 1007, + "unsigned_big_endian_sha256": "f04dcf1684cd1a5f5708102f230375fb43cd08135626ac91b22478876e21c63e" + }, + "U": { + "bits": 1006, + "unsigned_big_endian_sha256": "ebd327c71dde99fefa5afb70ef8ad5b207723935abb8bed0473a95d67e73fbe7" + }, + "routes": { + "bits": 1010, + "unsigned_big_endian_sha256": "23f8f6398dbe8fe43a321ff79a6c52edfee5c4de97ff2852a6cdcc6c127e7cd7" + } + }, + "n": 100, + "nonbase_ranks": 98, + "paid": { + "1": 6, + "2": 2 + }, + "reverse_expansions": 101, + "targets": { + "2": 4, + "3": 1 + } + } + ] +} diff --git a/research/pr4521-expanded-count-check/README.md b/research/pr4521-expanded-count-check/README.md new file mode 100644 index 0000000000..ca605e3095 --- /dev/null +++ b/research/pr4521-expanded-count-check/README.md @@ -0,0 +1,41 @@ +# Independent check of #4521: #4436's expanded rank-mass identity + +**Task:** independent-moment (independent source-bound coverage). **Base:** canonical main `f626db5c`. **No new κ.** + +Dillon's #4521 (head `d72f2282`) checks the fully expanded counting identity of zxv's #4436, with nested widths: + +`B_n·n − P_n = Δ·Q_n`, and `U_n ≤ Q_n ≤ B_n·n/Δ` for positive surplus. + +Here `B_n` is the width, `P_n` the number of rank-one leaves, `U_n` the number of raw invocations and `Q_n` their column multiplicity. #4521 retains every source complement, exit and integer batch multiplicity, and publishes SHA256 hashes of the exact big-integer totals. + +This package recomputes those totals with **my own** #4436 flow (`flow4436.py`, written for my #4456 checks). Nothing is imported from #4521 or #4436. The recurrence uses `a_n = B_(n−1)` and `B_n = a_n·S_n`, with child batches `a_n S_s / B_(n−s)` (complements) and `a_n E_e / B_e` (exits), which must be integers. + +## Results + +All checked claims are confirmed. + +- **Every rank.** `B_n·n − P_n = Δ·Q_n` and `U_n ≤ Q_n ≤ B_n·n/Δ` hold exactly. All child batches are integral, and ranks strictly descend. +- **Checkpoints.** The exact big integers `B`, `P`, `Q` and `U` match #4521's published SHA256 hashes and bit lengths, **12 of 12**, at: + - two toy rules at rank 100 (`{2:1,5:1} ← {1:2,4:1}` and `{2:4,3:1} ← {1:6,2:2}`); + - raw p7 at rank 1000, bound to main's `higher-moment-strictification/RESULT.json`. At rank 1000, `B` has 17,504 bits, `P` 17,514, `Q` 17,497 and `U` 17,497. + +`#4521`'s `RESULT.json` is vendored (SHA256-pinned) for the published hashes only. #4521's "routes" count is not recomputed. + +## Verify + +```text +python3 -B research/pr4521-expanded-count-check/verify.py +``` + +This runs in about 3 s with the standard library only. + +## Limitations + +- **Finite ranks.** The checks run through rank 1000. The all-rank induction is #4521's written proof, and this corroborates its finite instances. +- **Out of scope.** Native, physical and precision obligations, as #4521 states. + +## Open next questions + +- None new. The same recurrence with #4507's chronological widths is covered by my #4519 and #4588. + +Credit: Dillon (#4521), zxv (#4436), Jacob Alan Sussman (compiler), Cinna Davis (raw p7). Prepared by Ryanson Jonathan with substantial Claude Code (Claude Opus 5.5) assistance. diff --git a/research/pr4521-expanded-count-check/SOURCES.json b/research/pr4521-expanded-count-check/SOURCES.json new file mode 100644 index 0000000000..091e2e8a22 --- /dev/null +++ b/research/pr4521-expanded-count-check/SOURCES.json @@ -0,0 +1,24 @@ +{ + "schema_version": 1, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ed33caef5c5827693e9572d252a66f99cbb73d40", + "sha256": "5732707cc1e460b090b53f2463162749ad860de878a18f7408938671d295a9d9" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + }, + { + "path": "research/higher-moment-strictification/RESULT.json", + "usage": "input", + "git_blob": "e66b39c674028adfd22f0de3170555dccda52f6a", + "sha256": "ad79e3c0459e7b495a0ca34010553b12147779a007389e1695cc1336f123c156" + } + ] +} diff --git a/research/pr4521-expanded-count-check/TASK.json b/research/pr4521-expanded-count-check/TASK.json new file mode 100644 index 0000000000..21627dfe0e --- /dev/null +++ b/research/pr4521-expanded-count-check/TASK.json @@ -0,0 +1,100 @@ +{ + "schema_version": 1, + "task_id": "independent-moment", + "priority_revision": 7, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "original_card": { + "id": "independent-moment", + "question": "Does a new paid-profile or mixture-ceiling claim have independent source-bound coverage of its actual changed ledger?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/staged544-mixed-fourth-entry/README.md", + "research/staged-fourth-mixture-ceiling/README.md", + "research/r437-two-window-carrier/README.md" + ], + "methods": [ + "Independently reconstruct one changed paid ledger or pooled dual with exact source and model binding.", + "Check a genuinely uncovered moment implication with a different enclosure method and semantic controls." + ], + "acceptance_gate": "Demonstrate independence, source binding, positive cases and semantic failure controls. Name the existing checks and the missing coverage. More digits or another equivalent evaluation of an unchanged root is not by itself new verification coverage.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Choose one uncovered implication in #4088 literal mixed fill, #4091 pooled dual/model binding or #4067 changed frame/host bill. #4091 pins an earlier #4088 head: validate word, capacity and stock equivalence before applying that ceiling to the later fill.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Independently reconstruct one changed ledger or pooled certificate with a positive case and a semantic failure control. Compare exact sources and name what existing checks miss. Keep this separate from supplier-boundary-audit (ordinary/outer dispatch) and uniform-transfer-audit (all-size proof). Stop after the chosen implication; more digits of an unchanged root are not additional mechanism coverage.", + "bottleneck_link": "Independent pricing prevents unsupported frontier claims and can reveal genuine accounting slack.", + "allowed_variations": [ + "Reconstruct either a source ledger or a numeric enclosure with a different method." + ], + "scope_change_triggers": [ + "Importing the primary function and calling its output independent verification.", + "Calling an aggregate histogram or source archive an independently accepted physical supplier." + ], + "overlap_terms": [ + "independent moment", + "rank histogram", + "exact enclosure", + "2979", + "rank7 joint endframes", + "paired extraction", + "joint lowering", + "4088", + "4091", + "4067", + "staged544-mixed-fourth-entry", + "staged-fourth-mixture-ceiling", + "r437-two-window-carrier" + ], + "existing_checks": [ + { + "scope": "PR #4088: mixed local/owner/phase ledger and moment reported.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Independent binding of changed construction to paid histogram, distinct from full admission.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4091: sharp pooled ceiling proposed for fixed THREE/FOUR words and inventory.", + "evidence": "research/staged-fourth-mixture-ceiling/README.md", + "remaining": "Validate dual, exhaustive pattern scope and exact source equivalence before applying to newer fills.", + "status": "author-checked", + "source_commit": "a29bdd8f56cd18b805917775cdec09ff935eddc4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4067: paid (2,2) to (1,3) exchange and fixed OQ4 host reported.", + "evidence": "research/r437-two-window-carrier/README.md", + "remaining": "Independent full cost delta; remaining caller/precision/stock obligations are separate.", + "status": "author-checked", + "source_commit": "a95f11c52e3ca1e4c5171b3c20d8f4b0815aee2e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "unchanged", + "actual_scope": "Does a new paid-profile or mixture-ceiling claim have independent source-bound coverage of its actual changed ledger?", + "scope_change_reason": null, + "bottleneck_link": "Independent coverage of the expanded counting identity behind the finite-word envelopes every compiler word pays.", + "budget_minutes": 25, + "stop_rule": "Stop at #4521's published checkpoints.", + "outcome": "completed", + "evidence": "Own #4436 flow: identity and bounds exact at every rank; 12/12 exact big-integer totals (B,P,Q,U) match #4521's SHA256 hashes for two toys at rank 100 and raw p7 at rank 1000.", + "author": "Ryanson Jonathan, with Claude Code (Claude Opus 5.5) assistance", + "ai_assistance": "Substantial Claude Code (Claude Opus 5.5) assistance; no independent human review.", + "open_questions": [ + { + "question": "None new.", + "why_it_matters": "Chronological-width version covered by #4519/#4588.", + "first_step": "n/a", + "blocked_by": "None." + } + ] +} diff --git a/research/pr4521-expanded-count-check/VERIFY.json b/research/pr4521-expanded-count-check/VERIFY.json new file mode 100644 index 0000000000..44be7fce9c --- /dev/null +++ b/research/pr4521-expanded-count-check/VERIFY.json @@ -0,0 +1,20 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/higher-moment-strictification/RESULT.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Own #4436 flow: expanded identity and bounds at every rank; exact B,P,Q,U hashes vs #4521 (toys rank 100, p7 rank 1000)." + } + ] +} diff --git a/research/pr4521-expanded-count-check/flow4436.py b/research/pr4521-expanded-count-check/flow4436.py new file mode 100644 index 0000000000..05f4617328 --- /dev/null +++ b/research/pr4521-expanded-count-check/flow4436.py @@ -0,0 +1,60 @@ +"""Separately written #4436 default-height flow (my #4456 checks). Ryanson Jonathan with Claude Code (Claude Opus 5.5) assistance. Apache-2.0.""" +from fractions import Fraction as Q +from math import factorial +import itertools, json, sys +def multis(n_types, size): + if n_types == 0: + if size == 0: yield () + return + for x in range(size + 1): + for rest in multis(n_types - 1, size - x): yield (x,) + rest +def flow(N, W, P): + ks = sorted(W); m = ks[-1]; kmin = ks[0] + def c(a): + v = 1 + for k, x in zip(ks, a): v *= k ** x + return v + def u(a): + v = factorial(sum(a)) + for k, x in zip(ks, a): v = v // factorial(x) * W[k] ** x + return v + G = 0 + while kmin ** (G + 1) <= N // m: G += 1 + F = [{1: 1}] + for d in range(1, G + 1): + nxt = {} + for rho, cnt in F[d - 1].items(): + for r, pr in P.items(): + if m * rho * r <= N: nxt[rho * r] = nxt.get(rho * r, 0) + cnt * pr + F.append(nxt) + S, X, BX = {}, {}, {} + col = units = matched = 0 + add = lambda D, k, v: D.__setitem__(k, D.get(k, 0) + v) + present = lambda rho, a: m * rho * c(a) <= N + for d in range(G + 1): + for rho, cnt in F[d].items(): + for b in multis(len(ks), G - d): + if not present(rho, b): continue + units += cnt * u(b); col += cnt * u(b) * rho * c(b) + for r, pr in P.items(): + issued = cnt * pr * u(b); rank = r * rho * c(b) + if d == G: + add(X, rank, issued); continue + D = sum(W[k] * u(tuple(x - (i == j) for j, x in enumerate(b))) + for i, k in enumerate(ks) if b[i] > 0 and present(rho * r, tuple(x - (i == j) for j, x in enumerate(b)))) + matched += cnt * pr * D + if issued - cnt * pr * D: + add(X, rank, issued - cnt * pr * D); add(BX, rank, issued - cnt * pr * D) + for a in multis(len(ks), G): + if present(1, a): + for k in ks: add(S, k * c(a), W[k] * u(a)) + for d in range(1, G + 1): + for rho, cnt in F[d - 1].items(): + for r, pr in P.items(): + for a in multis(len(ks), G - d): + if not present(rho * r, a): continue + for i, k in enumerate(ks): + b = list(a); b[i] += 1 + if not present(rho, tuple(b)): + add(S, rho * r * c(tuple(b)), cnt * pr * u(a) * W[k]) + return dict(G=G, S=S, X=X, BX=BX, col=col, units=units, matched=matched) diff --git a/research/pr4521-expanded-count-check/verify.py b/research/pr4521-expanded-count-check/verify.py new file mode 100644 index 0000000000..e78949eec9 --- /dev/null +++ b/research/pr4521-expanded-count-check/verify.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +"""Independent check of PR #4521 (Dillon): #4436's fully expanded rank-mass identity, with separately written code. + +Using my own #4436 default-height flow (flow4436.py, written for my #4456 checks; nothing imported from #4521 or +#4436), this recomputes the expanded counts with #4436's nested widths a_n = B_(n-1), B_n = a_n S_n: +B_n (width), P_n (rank-one leaves), U_n (raw invocations) and Q_n (their column multiplicities), with base values +B = 1, P = n, U = Q = 0 below m, and child batches C = a_n S_s / B_(n-s) (source complements) and a_n E_e / B_e +(exits), required to be integers. At every rank it checks B_n n - P_n = Delta Q_n and U_n <= Q_n <= B_n n / Delta, +and at the checkpoints it compares the exact big integers B, P, Q, U with #4521's published SHA256 hashes and bit +lengths (vendored RESULT.json, blob 85ee0166): two toy rules at rank 100 and raw p7 (bound to main) at rank 1000. +Ryanson Jonathan with Claude Code (Claude Opus 5.5) assistance. Apache-2.0. +""" +import hashlib +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +RESULT = HERE / "PR4521-RESULT.json" +RESULT_SHA256 = "d7c90173a64629da0746015d2f03083204e4a0fdd0d43956341fea0a422062e3" +P7 = ROOT / "research/higher-moment-strictification/RESULT.json" +P7_SHA256 = "ad79e3c0459e7b495a0ca34010553b12147779a007389e1695cc1336f123c156" + + +def need(condition, message): + if not condition: + raise AssertionError(message) + + +def expanded(flow, W, P, N): + m = max(W) + delta = sum(k * x for k, x in W.items()) - sum(r * x for r, x in P.items()) + need(delta > 0, "positive surplus") + B, Pn, U, Q = [1] * m, list(range(m)), [0] * m, [0] * m + for n in range(m, N + 1): + R = flow(n, W, P) + a = B[n - 1] + Bn = a * sum(R["S"].values()) + p = u = q = 0 + children = [(n - s, cnt) for s, cnt in R["S"].items()] + [(e, cnt) for e, cnt in R["X"].items() if cnt] + for r, cnt in children: + need(0 <= r < n and (a * cnt) % B[r] == 0, "integral child batch, strict descent") + c = a * cnt // B[r] + p, u, q = p + c * Pn[r], u + c * U[r], q + c * Q[r] + u += a * R["units"] + q += a * R["col"] + need(Bn * n - p == delta * q, f"identity at n = {n}") + need(u <= q and delta * q <= Bn * n, f"bounds at n = {n}") + B.append(Bn), Pn.append(p), U.append(u), Q.append(q) + return {"B": B[N], "P": Pn[N], "Q": Q[N], "U": U[N]} + + +def digest(x): + return hashlib.sha256(x.to_bytes((x.bit_length() + 7) // 8, "big")).hexdigest() + + +def main(): + ns = {"__name__": "flow4436"} + exec(compile((HERE / "flow4436.py").read_bytes(), str(HERE / "flow4436.py"), "exec"), ns) + raw = RESULT.read_bytes() + need(hashlib.sha256(raw).hexdigest() == RESULT_SHA256, "vendored #4521 RESULT.json") + res = json.loads(raw) + need(hashlib.sha256(P7.read_bytes()).hexdigest() == P7_SHA256, "pinned p7 source") + o = json.loads(P7.read_bytes())["invoice_oracle"] + p7 = ({int(k): v for k, v in o["targets"].items()}, {int(k): v for k, v in o["paid"].items()}) + cases = [] + for entry in res["toy_counted_expansions"]: + W = {int(k): v for k, v in entry["targets"].items()} + P = {int(k): v for k, v in entry["paid"].items()} + cases.append((W, P, entry["n"], entry["expanded_counts"])) + pe = res["p7_counted_expansion"] + cases.append((p7[0], p7[1], pe["n"], pe["expanded_counts"])) + matched = 0 + for W, P, N, published in cases: + got = expanded(ns["flow"], W, P, N) + for key in ("B", "P", "Q", "U"): + need(got[key].bit_length() == published[key]["bits"], f"{key} bit length at N = {N}") + need(digest(got[key]) == published[key]["unsigned_big_endian_sha256"], f"{key} hash at N = {N}") + matched += 1 + print(json.dumps({"status": "PASS_PR4521_EXPANDED_COUNT_CHECK", "rules": len(cases), "exact_totals_matched": matched, + "p7_rank": pe["n"], "new_kappa_claimed": False}, indent=1)) + + +if __name__ == "__main__": + sys.exit(main())