diff --git a/.github/workflows/balanced-split.yml b/.github/workflows/balanced-split.yml new file mode 100644 index 0000000000..d244c1909e --- /dev/null +++ b/.github/workflows/balanced-split.yml @@ -0,0 +1,25 @@ +name: Balanced split finite witness + +on: + pull_request: + paths: + - 'research/balanced-split-reclamation/**' + - 'research/pair-assembly/**' + - 'scripts/experiments/binary_frame*' + - 'references/frame-compiler/pr48/**' + - '.github/workflows/balanced-split.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + verify: + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: make -C research/balanced-split-reclamation verify diff --git a/research/balanced-split-reclamation/Makefile b/research/balanced-split-reclamation/Makefile new file mode 100644 index 0000000000..d030bb7e8c --- /dev/null +++ b/research/balanced-split-reclamation/Makefile @@ -0,0 +1,17 @@ +.PHONY: verify replay test note + +verify: + python3 -B verify.py --rebuild + python3 -B -m unittest discover -s . -p test_witness.py -v + +replay: + python3 -B verify.py + +test: + python3 -B -m unittest discover -s . -p test_witness.py -v + +note: + mkdir -p ../../build/balanced-split-reclamation/pdf + pdflatex -interaction=nonstopmode -halt-on-error -output-directory=../../build/balanced-split-reclamation/pdf paper.tex + pdflatex -interaction=nonstopmode -halt-on-error -output-directory=../../build/balanced-split-reclamation/pdf paper.tex + cp ../../build/balanced-split-reclamation/pdf/paper.pdf paper.pdf diff --git a/research/balanced-split-reclamation/NOTICE b/research/balanced-split-reclamation/NOTICE new file mode 100644 index 0000000000..2a89a91c9e --- /dev/null +++ b/research/balanced-split-reclamation/NOTICE @@ -0,0 +1,38 @@ +Balanced coarse sums on anchored split frames +Prepared for huxint with substantial OpenAI Codex assistance, October 9, 2026. +Distributed under the repository's Apache License 2.0. + +The selected finite network composes previously attributed constructions. +Preserve all repository notices and these source-specific attributions: + +eumemic: PR57 joint reversible frame compiler and independent physical replay; +PR69 balanced coarse column sums, with OpenAI Codex assistance. +Avi Eisenberg / ikeboy: PR62 interval strips and core-aware pair assembly, +with Anthropic Claude assistance. +Rohan Garg / rohangar1: PR59 split-pair operation, with OpenAI Codex assistance. +Rohan Arun: PR65 schedule/refined arithmetic and PR67 profile-cost compiler, +with OpenAI Codex assistance. +Dominik Scholz: PR63 ranked composition and PR68 compatible pending controls, +with OpenAI GPT-6 Astra / Codex assistance. +Chafik Boukhalfa: PR60 ranked reclamation and PR71 anchored split graph and +next-use scoring, with OpenAI Codex assistance. + +The original code comments and preserved vendor snapshots retain their own +attributions. The inherited framework also credits icekylinx, RaD / hipotures, +James Chang, Zhihao Chen / jacklightChen, Aurel Prosz / Paureel, Swapnil Jain, +Douglas Colkitt, OpenAI, David Harvey, Joris van der Hoeven, and other +contributors identified in the root NOTICE and inherited source files. + +The new package's finite checks are conditional evidence. They are not a +complete theorem formalization, an independent human referee report, or a +practical multiplication benchmark. + +The refined witness also uses Thomas DiFiore's PR74 envelope ordering, +Alejandro Zarzuelo Urdiales's PR70 carry-exchange methodology, Dominik +Scholz's PR76 composition, Chafik Boukhalfa's PR79 future-compatible unit +completion and half-plane coarse choice, and Rohan Arun's PR78/82 coordinate +flags and coordinate-aware pricing. Their original notices and AI-assistance +disclosures remain applicable. The two-region exchange experiment, shifted +coarse boundary and selected h25 cyclic flag in this package were evaluated +by huxint with OpenAI Codex assistance; no global optimum or priority for +general matroid exchange or coordinate conjugation is asserted. diff --git a/research/balanced-split-reclamation/README.md b/research/balanced-split-reclamation/README.md new file mode 100644 index 0000000000..938f3110e4 --- /dev/null +++ b/research/balanced-split-reclamation/README.md @@ -0,0 +1,106 @@ +# Coarse-threshold and coordinate refinement on anchored split frames + +The selected finite construction gives the conditional bound + +\[ +T(n)=O\bigl(n(\log n)^{1-\kappa}\bigr),\qquad +\kappa=\frac{52062354654791}{10^{18}} +=5.2062354654791\times10^{-5}. +\] + +This is **0.0568021906% above the complete PR82 witness** frozen at +`3410b940aa26e5876202152dfa7c4f66451ee22c`. Newer community submissions have +larger reported values. This is a scoped historical comparison, not a claim +to the latest record, global optimality, or measured multiplication speed. +The initial PR77 witness `5.1547855889988e-5` remains reproducible at commit +`83298467291d3bd4b53f76faaef60dbf585be171`. + +| Paid quantity | Pinned PR82 | This construction | +|---|---:|---:| +| Roles at h=23 | 27,075 | 27,043 | +| Roles at h=25 | 35,500 | 35,505 | +| Physical width W | 133,289,600 | 133,224,855 | +| Complete recursive rank mass | 76,639,673,100 | 76,602,444,725 | +| Rank deficit | 1,846,900 | 1,846,900 | + +The strict bit witness is `26032532642421/(5*10^17)`. The complete old +PR82 child list, evaluated with its own width, has a rigorous lower moment +above one at this saving. The new list has an upper moment below one. Both +the adjacent `10^-18` bit grid point and the next kappa point are rejected. + +## Selected construction + +Both axes retain the anchored split vector `[1,1,2]`, the original common-point +envelopes, PR74's envelope ordering, and the inherited reversible compiler. +The h23 region schedule is `cover-core`; h25 uses `reverse-node`. + +- At h23, a coarse cell `(i,j)` uses column sums when `i+j < ng+1`, and row + sums otherwise, with zero-based group indices and current group count `ng`. + This shifts the earlier half-plane boundary by two. At h25, every cell uses + row sums. Both parenthesizations compute the same disjoint edge sum. +- Independent unit-completion rows are ordered by compatible future uses, + as in PR79. Three passes of the inherited improving single carry exchanges + are supplemented by legal two-region carry cycles. The selected words use + 113 such cycles at h23 and 86 at h25. Open two-region reassignment paths + were also searched; none was selected in these words. +- h23 retains rank-ordered retired candidates and insertion-ordered live + controls. h25 orders both by actual profile cost against the next use. +- h23 uses the preserved PR82 coordinate flag. h25 uses the point map + `i -> (i+1) mod 25` in both oracle pricing and the final physical word. + h23 oracle pricing remains in the original coordinates. + +Every selected scalar operation is a literal XOR and every operand promotion, +center copy, endpoint correction, source growth and cleanup is charged. +The score is a deterministic discovery heuristic. Only the complete actual +physical profile decides whether a candidate improves the bound. + +The actual width is below `2^27`. The bridge derives wire bits 27, row +coefficient 843 and degree gap `7007/25`; degree 2000, suffix slope 8000, +the complex branch and its scalar charge remain unchanged. Stale width +metadata is rejected. + +## Reproduction + +From the repository root, using Python 3.11+ and a C++17 compiler: + +```sh +make -C research/balanced-split-reclamation verify +make -j1 verify +``` + +The focused target regenerates both complete words byte-for-byte, checks every +input/target/arbitrary-dirty basis vector in both orientations, reconstructs +actual frame transitions, recomputes the bounded-minor/CRT profiles, and +rebuilds the complete recursive profile and exact certificate. A separately +evaluated rational logarithm/exponential enclosure confirms the accepted and +rejected grid points. All 47 strict assembly constraints and seven margins +are recomputed. Seventeen tests cover malformed or aliased ports, uncharged +canceling scatter gates, omitted children, adjacent-grid rejection, three +stale bridge fields, assertion-disabled Python, and read-only pin help. + +`selected/` contains the frozen words, profiles and certificates. `SOURCE.json` +pins consumed sources and deliverables; verification never refreshes it. +An intentional maintainer update uses `python3 pin.py --record`. +`generate.py --output ` writes a fresh reconstruction outside the +selected artifacts. The proof is in [paper.tex](paper.tex) and [paper.pdf](paper.pdf). +Run receipts, including any environmental interruption of the broad suite, +are recorded separately in `VALIDATION.json`. + +## Scope and credit + +The base theorem, all-size residual/frame compiler, fixed finite-alphabet tape +representation, semantic/analytic reduction, routing, prime setup and exact +recovery remain inherited hypotheses. These are finite checks and a written +conditional argument, not a complete formal multiplication theorem or +independent human expert review. + +The initial balanced split/cost-basis experiment and this explicit shifted +coarse rule, coordinate/cost choice, exchange search and reproducible package +were prepared for **huxint with substantial OpenAI Codex assistance**. +Credit eumemic (PR57/69), Avi Eisenberg (PR62), Rohan Garg (PR59), Rohan Arun +(PR65/67/78/82), Dominik Scholz (PR63/68/76), Chafik Boukhalfa (PR60/71/79), +Thomas DiFiore (PR74), Alejandro Zarzuelo Urdiales (PR70), and all earlier +contributors preserved in [NOTICE](NOTICE). Carry exchanges and coordinate +conjugacy are inherited methods; no general novelty claim is made for them. +Original licenses, contributor snapshots and AI-assistance disclosures remain +attached. No contributor endorsement is implied. diff --git a/research/balanced-split-reclamation/SOURCE.json b/research/balanced-split-reclamation/SOURCE.json new file mode 100644 index 0000000000..3edc5616b3 --- /dev/null +++ b/research/balanced-split-reclamation/SOURCE.json @@ -0,0 +1,71 @@ +{ + "files": { + ".github/workflows/balanced-split.yml": "9f45519e842d7412c2c68d349252b57872a1a73e25447ca2ac63c625eb3849d3", + "references/frame-compiler/pr48/SOURCE.json": "6ccc673f88d3650d75ed600b082fe2fc2866dd88a172d182a38c1d0cd27d24b3", + "references/frame-compiler/pr48/research/copied-fixed/balanced_assembly.py": "4d27575dcad2b45a281a34054d311409ecd954f373c0c3a62c29bcc843f06a86", + "references/frame-compiler/pr48/research/copied-fixed/certificate.json": "33b3373c04e18a7f4cee33ba68da6ed71934acc3e0179cca6197696be4befa22", + "references/frame-compiler/pr48/research/copied-fixed/changed_graph.py": "375a7ca6cac6d153c1880fd5ea5b4525e5dca9d4ee3018d24d679c219b59c5b3", + "references/frame-compiler/pr48/research/copied-fixed/profiles.cpp": "b9fbd71c746609948b60c441ba4601e88436956fe636d1810f270ce4ce6a63a6", + "references/frame-compiler/pr48/research/copied-fixed/verify.py": "44932182ce6c4d39776650311262ef0ac1ea9b5da7220bc0f728e2789881f84a", + "references/frame-compiler/pr48/scripts/exclusion_circuit.py": "b253f9d7318becda1c1f3b24e2287ed44a9c27fcea00cf9d531afb950d0457a0", + "references/frame-compiler/pr48/scripts/partial_swap/binary_io.hpp": "7e143eb75bb342ac8f0c82a60005e7c35c9ec827de479bf6fb773151f3af5fa1", + "references/frame-compiler/pr48/scripts/partial_swap/paired.py": "ddcecace3a8e04d690914cbd64873ab8dde8c0c3477a255767b0ed6f639bb0c7", + "references/frame-compiler/pr48/scripts/partial_swap/shared.py": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34", + "research/balanced-split-reclamation/Makefile": "2417f68960e98c9fc5cba82511236c555a3dc8c93650da2b61a7011573d0e015", + "research/balanced-split-reclamation/NOTICE": "0333515c21d1edfcb5d726ad9897d24bd82905cefbdede6b7fe0abc2eebf5f38", + "research/balanced-split-reclamation/README.md": "32033d0061a6d1509aedc47ab511a9bb0fffa297509c712193258282ec1a0107", + "research/balanced-split-reclamation/arithmetic.py": "ba27733959c39c61c0cec2afa955a9441b05f60dcda39d37af4fff035c824542", + "research/balanced-split-reclamation/carry_exchanges.py": "afbe7d22b5f5ac937eb7be50c2ef3e2023dfb0c2ad4eb6f22ac6dd773b48838d", + "research/balanced-split-reclamation/compiler.py": "7fa6e26c2c55b01e0f62ad26f13f7401125887ae569d6f8cc32931581fb21c7d", + "research/balanced-split-reclamation/generate.py": "7392d518d5bc202639b223acdb13cd98fe3a0e9d89f268214a67752e379b12cb", + "research/balanced-split-reclamation/geometry.py": "5ab3acbe0513284ad86a311b3cbcc3514e4acb619337c3558b143afc2fc35440", + "research/balanced-split-reclamation/graph.py": "a5bff49298977c8fd8e3cf5bf6423fe0a813b011d8c0358c7434838a76753881", + "research/balanced-split-reclamation/paper.pdf": "aca03346dac22d1897772179b9ea0cf7de41e6555f96a639ac584d001c69ad5c", + "research/balanced-split-reclamation/paper.tex": "3b1260f837687acf115b8c776d502cdf56d59896e2abd8fd079b6bb97490399f", + "research/balanced-split-reclamation/pin.py": "47881816e7d4200e7f4c238eb797dd9256a60a43ad8d5fdda67cad4299095cdf", + "research/balanced-split-reclamation/profile_oracle.cpp": "d1f6b650de9fb5842b412595369271d9eeb6f54045c76c0fb5cad29854955c35", + "research/balanced-split-reclamation/selected/audit.json": "7c99339822aa4858fd04272c1540424fd170c4eda3bf770892436172d5f747e3", + "research/balanced-split-reclamation/selected/certificate.json": "0fbbac590d0e5be5a8f6f4ed83618a73c1d5166ca7d111902580915b2b4560f6", + "research/balanced-split-reclamation/selected/compiled-23.json": "1e0d0e52df8a0b1eca3cf4df5bf3e540fa77790526ea24bdc5b9bf1fff5c9503", + "research/balanced-split-reclamation/selected/compiled-25.json": "4a48e79e1679b4b9479154423c0bd468c3d6e5c82bcc064b1fb4e272b8b65120", + "research/balanced-split-reclamation/selected/config-23.json": "c81e67af4753b7638bff65665cfdfdd7162180f4fe38f74bfa8514eb7ea4b7b2", + "research/balanced-split-reclamation/selected/config-25.json": "f2278295ea2d1c7e2ff59da6b79de01041cccb025df8da81b0528696e6d2c255", + "research/balanced-split-reclamation/selected/profile-23.json": "44a7e7f8c762aa8009a87c1d8a692c1d0bbb80b1de6fb205f24b9e6f242f71ec", + "research/balanced-split-reclamation/selected/profile-25.json": "9c456fdeaa8899722647b066de0066e656b4f52576ef20eeedda0c2ddf8e4695", + "research/balanced-split-reclamation/selected/replay-23.json": "6e8d2a756d1be404d30fad45c2877134d4f2fd13190d4f1fc2c4d2af119c59b9", + "research/balanced-split-reclamation/selected/replay-25.json": "200e82dcdbb0223497c8edc96493060bdc813cbc2d21a90fba44dc1960a29a8c", + "research/balanced-split-reclamation/selected/transitions-23.json": "cccd22718a6c3b229c10e4d8bfa21c7d7fcc4389531fca1bc1435e232e4c154f", + "research/balanced-split-reclamation/selected/transitions-25.json": "b5029a0d452a5b04bd2293edb94265c889354bb0fb723593b24bbc35fe0b009b", + "research/balanced-split-reclamation/selected/word-23.json.gz": "dbc25e1d94f85e213d73bf4680071830e1959091577f681951a29523b94a382a", + "research/balanced-split-reclamation/selected/word-25.json.gz": "2a0a485a48e5d601a2ab48bcc7bae7d65786d12f5ba50079b48ae42d52a7123b", + "research/balanced-split-reclamation/support.py": "c83e0960c89bec4487b86941a055badd352eeec638ef0572e602667c154f15a5", + "research/balanced-split-reclamation/test_witness.py": "3727f5e47c16e0ef41505226babee3facabde552a304b066489e3043772e1062", + "research/balanced-split-reclamation/vendor/pr68-compiler.py": "58caca9b5336a2d50fcc45b56abfac60bbb795856b5c806ba4bfa5f649412642", + "research/balanced-split-reclamation/vendor/pr69-compiler.py": "bd8169bf9f5df185a8aa4aec22234b4fd483000a1cecc78b71bf32e479af1499", + "research/balanced-split-reclamation/vendor/pr71-certificate.json": "0fcb53fa374273efab6370953c966e8fa065dbfdba43691843a4788cb2cda42e", + "research/balanced-split-reclamation/vendor/pr71-graph.py": "9d4ee7179f880f9576e81c7ad3a5290fe61380a7531d559ef3cf0939bb30089c", + "research/balanced-split-reclamation/vendor/pr76-exchanges.py": "6c3f69db1e212f7d4c16aec17620f62333acbc58db194733282082892843b087", + "research/balanced-split-reclamation/vendor/pr82-README.md": "ed0a825837ca352dda60fc6d0bf977881466d2edeb2c906983d9b2678a34bd12", + "research/balanced-split-reclamation/vendor/pr82-certificate.json": "6eab6266585ecdf5509c2195a139088b7dba8b849e0679ca4be07bebb7c8a540", + "research/balanced-split-reclamation/verify.py": "eb1f7dfb568193dac999165e495b50af4fd4a6313bce88a3ca0412900502749f", + "research/pair-assembly/frame/frame-compiler.json": "86eeb10989a61e571938178b91dfe1b81ba39ec97cc93124c00cecd91dc6ef13", + "research/pair-assembly/frame/frame_verify.py": "fafe25d57166a747eeb847444a2e02dd7eed19038b93a2c495014d147d04a8fb", + "research/pair-assembly/pair_graph.py": "3d47e89d2649c90800a276bdd0480131def50e0bdf92c122a19494b55bf17420", + "scripts/exclusion_circuit.py": "b253f9d7318becda1c1f3b24e2287ed44a9c27fcea00cf9d531afb950d0457a0", + "scripts/experiments/binary_frame_math.py": "1f96e8aafc8ae89f8eeec5d03800131d93d58e01bf8a7fca8feb03702d1740d0", + "scripts/experiments/binary_frame_profile_prepare.py": "8a50381cab00b33e62b3a057d199ba5e19647929135c95b0fd63fc8a8ef7c9b3", + "scripts/experiments/binary_frame_profiles.cpp": "8e2e391d3ee57cbb1372c68e4aa031e1b861321536eabd642ada54e12e678669", + "scripts/experiments/binary_frame_replay.py": "392e78e62d7685c99a5888a7da743ea6c3dcad631af4a743c91e0c09348442bc", + "scripts/partial_swap/paired.py": "ddcecace3a8e04d690914cbd64873ab8dde8c0c3477a255767b0ed6f639bb0c7", + "scripts/partial_swap/shared.py": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" + }, + "scope": "Explicit source and artifact freeze; no automatic refresh in verification", + "upstream": { + "pr67": "b3745601e947a94316bf25c2c6263d93c06e3364", + "pr68": "8778fdb52e834a2a14371590d80ea6e0c734a866", + "pr69": "91aa1f17e6e3fc063241686a41a34ddd0dc24c50", + "pr71": "1bef94fd40a746452548c84a4a8f8834670a3113", + "pr76": "2333abcea79793fe301b479a7c971cc2be45596c", + "pr82": "3410b940aa26e5876202152dfa7c4f66451ee22c" + } +} diff --git a/research/balanced-split-reclamation/VALIDATION.json b/research/balanced-split-reclamation/VALIDATION.json new file mode 100644 index 0000000000..71b385cf4b --- /dev/null +++ b/research/balanced-split-reclamation/VALIDATION.json @@ -0,0 +1,77 @@ +{ + "status": "PASS refined focused verification and root integration tests; inherited broad groups completed by recorded sequential continuation", + "construction_commit": "f277632899847e058bb8774c5138e1995109a6d2", + "source_manifest_sha256": "a5b9ca4284b38feab4abf2f87358b2f296a0d1442fac8ccb7953cdb317fbc7ce", + "source_and_artifact_pins": 58, + "all_pins_match_working_and_committed_bytes": true, + "kappa": "52062354654791/1000000000000000000", + "bit_saving": "26032532642421/500000000000000000", + "focused": { + "command": "make -C research/balanced-split-reclamation verify", + "exit_code": 0, + "construction_commit": "f277632899847e058bb8774c5138e1995109a6d2", + "modules": 1, + "test_methods": 17, + "patch_checks": 0, + "log_sha256": "7ebc6ea67eef00d5a01e05bf8244da15b17558ffe4a95f817617f774af3dce32", + "raw_words_regenerated_byte_for_byte": true, + "all_dirty_basis_both_orientations": true, + "complete_actual_CRT_profiles": true, + "strict_assembly_constraints": 47, + "margins": 7 + }, + "refined_root_integration": { + "command": "make -j1 verify-tests", + "exit_code": 0, + "construction_commit": "f277632899847e058bb8774c5138e1995109a6d2", + "environment": "CPLUS_INCLUDE_PATH points to the task-local Boost headers", + "modules": 78, + "test_methods": 516, + "patch_checks": 20, + "log_sha256": "3b5eac83947d3d401786efcbc0977cf247ca19b173b06781f9072e57a0f8c172" + }, + "inherited_broad_groups": { + "tested_submission_commit": "83298467291d3bd4b53f76faaef60dbf585be171", + "upstream_base": "230b5ea8eb9344fd36f13daa2933ab7b027ce046", + "initial_command": "make -j1 verify", + "initial_exit_code": 2, + "initial_failure": "Boost multiprecision headers absent in the host environment", + "initial_log_sha256": "ae741a0388cecc4ec78726d680ab0ba88b8f25c03d16a9163b08a0d2d75654a8", + "passed_prefix": [ + "verify-community", + "verify-producers", + "verify-certificates", + "verify-ternary", + "verify-research", + "verify-strips", + "verify-clones" + ], + "first_resume_exit_code": 2, + "first_resume_failure": "Stale temporary clone directory left by the initial interrupted build", + "first_resume_log_sha256": "960b4b3be85c25ab82f96823d26773cd64d6e295513cfb73d633a16a1bcb5118", + "remediation": "Verified Boost package checksum, extracted headers under ignored build/deps, supplied CPLUS_INCLUDE_PATH, and moved the interrupted temporary directory aside.", + "boost_package": "boost-1.92.0-1-x86_64.pkg.tar.zst", + "boost_sha256": "0d795c6401c8bfa16012ada7e2e7f34934fb268f9174470edac1b389056f79bb", + "successful_continuation": "make -j1 verify-positive verify-joint verify-pair verify-tests", + "continuation_exit_code": 0, + "modules": 81, + "test_methods": 552, + "patch_checks": 20, + "log_sha256": "f3c014e953da818e46643b5caa6e56c6a7a17995c2a83ccce50500d3dbd8a73a", + "all_11_top_level_groups_completed": true, + "tested_submission_worktree_clean_afterward": true, + "refinement_changes_only_its_package": true, + "unchanged_consumed_inherited_files_checked": 21, + "scope": "This records interrupted and resumed verification, not one uninterrupted full-suite exit. The changed package and root integration tests were rerun separately on the refined construction." + }, + "paper": { + "pages": 6, + "tex_and_pdf_included": true, + "build_log_sha256": "9b4415a54b2755cabc6a02bc747fee11ae4ba9727a6dae7e17f3f223a083a28f", + "overfull_boxes": 0, + "all_rendered_pages_inspected": true + }, + "python": "3.14.7", + "recorded_utc": "2026-10-08T22:20:59.956905+00:00", + "scope": "Finite conditional construction and exact arithmetic; not a full formal theorem, independent human expert review, latest-record claim, or practical speed benchmark." +} diff --git a/research/balanced-split-reclamation/arithmetic.py b/research/balanced-split-reclamation/arithmetic.py new file mode 100644 index 0000000000..2af3846b49 --- /dev/null +++ b/research/balanced-split-reclamation/arithmetic.py @@ -0,0 +1,157 @@ +"""Exact complete-profile certificate and a separately evaluated enclosure. + +Directed Taylor certification follows Rohan Arun's PR65/67. The 3/2 range +reduction follows the independently evaluated PR67 audit. Existing PR48 +balanced assembly and contributor attributions remain in their source. +Integration by huxint with OpenAI Codex assistance. Apache-2.0. +""" +from functools import lru_cache +from fractions import Fraction as Q +import json +from math import factorial +from support import HERE, ROOT, SELECTED, load, json_value +import binary_frame_math as inherited + +balanced = load(ROOT/'references/frame-compiler/pr48/research/copied-fixed/balanced_assembly.py', 'balanced_split_assembly') +GRID = 10**18 +BACKOFF = Q(1, 10**12) + + +def down(value, grid=10**40): + return Q(value.numerator*grid//value.denominator, grid) + + +def up(value, grid=10**40): + return -down(-value, grid) + + +def moment(profile, saving): + assert type(saving) is Q and 0 < saving < 1 + lower, upper = Q(), Q() + rows = {int(t): n for t, n in profile['child_multiplicities'].items()} + assert sum(t*n for t, n in rows.items()) == profile['total_rank'] + terms = {} + for t, n in sorted(rows.items()): + assert type(n) is int and n > 0 and 0 < t < profile['m'] + lo, hi = inherited.logs(Q(profile['m'], t)) + u, v = saving*lo, saving*hi + assert 0 <= u <= v < 1 + elo = sum((u**j/factorial(j) for j in range(9)), Q()) + ehi = sum((v**j/factorial(j) for j in range(9)), Q()) + ehi += v**9/factorial(9)/(1-v/10) + weight = Q(t*n, profile['m']*profile['W']) + lower += weight*down(elo) + upper += weight*up(ehi) + terms[t] = dict(weight=weight, log_lower=lo, log_upper=hi) + return dict(saving=saving, lower=lower, upper=upper, strict_gap=1-upper, terms=terms) + + +def bridge_for(profile): + source = ROOT/'references/frame-compiler/pr48/research/copied-fixed/certificate.json' + bridge = json.loads(source.read_text())['finite_bridge'] + bridge['bit']['W'] = profile['W'] + assert bridge['bit']['m'] == profile['m'] == 575 + assert bridge['bit']['maxchild'] == profile['maxchild'] == 529 + bridge['bit']['wire_bits'] = profile['W'].bit_length() + coefficient = sum(bridge[x]['halving_degree']*bridge[x]['wire_bits'] for x in ('bit', 'complex')) + bridge['rows']['coefficient'] = coefficient + bridge['rows']['degree_gap'] = Q(bridge['rows']['degree'])-Q(51, 25)*coefficient + assert bridge['bit']['wire_bits'] == 27 and coefficient == 843 + assert bridge['rows']['degree_gap'] == Q(7007, 25) + assert 2*529**9 < 575**9 and 2*529**8 >= 575**8 + assert bridge['bit']['halving_degree'] == 9 + return bridge + + +def certify(profile): + low, high = 1, 71700000000000 + assert moment(profile, Q(low, GRID))['upper'] < 1 + assert moment(profile, Q(high, GRID))['lower'] > 1 + while low+1 < high: + middle = (low+high)//2 + test = moment(profile, Q(middle, GRID)) + if test['upper'] < 1: + low = middle + elif test['lower'] > 1: + high = middle + else: + raise ArithmeticError('Inconclusive interval; no implicit tolerance is allowed') + saving = Q(low, GRID) + bridge = bridge_for(profile) + first = balanced.assembly(bridge, saving, Q(1, GRID), h=BACKOFF) + margin = first['minimum_margin'] + kappa = up(margin, GRID)-Q(1, GRID) + accepted = balanced.assembly(bridge, saving, kappa, h=BACKOFF) + assert len(accepted['constraints']) == 47 and len(accepted['margins']) == 7 + try: + balanced.assembly(bridge, saving, kappa+Q(1, GRID), h=BACKOFF) + except balanced.InvalidAssembly as error: + next_rejection = str(error) + else: + raise AssertionError('Next kappa grid point unexpectedly passed') + predecessor = json.loads((HERE/'vendor/pr82-certificate.json').read_text()) + old_profile = predecessor['bit'] + old_test = moment(old_profile, saving) + assert old_test['lower'] > 1, 'The complete PR82 profile must be excluded' + a, b = moment(profile, saving), moment(profile, Q(high, GRID)) + assert a['upper'] < 1 < b['lower'] + return dict(status='Finite conditional witness; inherited all-size and analytic interfaces remain assumptions', + kappa=kappa, bit_saving=saving, next_bit_saving=Q(high, GRID), bit=profile, + accepted_moment=a, rejected_moment=b, assembly=accepted, finite_bridge=bridge, + next_kappa_rejection=next_rejection, eventual_bounds=balanced.cutoffs(bridge, accepted), + comparison=dict(pr82_commit='3410b940aa26e5876202152dfa7c4f66451ee22c', + pr82_kappa=Q(predecessor['kappa']), difference=kappa-Q(predecessor['kappa']), + ratio=kappa/Q(predecessor['kappa']), complete_pr82_moment_lower=old_test['lower'], + initial_pr77_commit='83298467291d3bd4b53f76faaef60dbf585be171', + initial_pr77_kappa=Q(12886963972497,250000000000000000))) + + +@lru_cache(None) +def independent_log(x): + k = 0 + while x > Q(3, 2): + x /= Q(3, 2) + k += 1 + def expand(y): + z = (y-1)/(y+1) + power, total = z, Q() + for j in range(60): + total += power/(2*j+1) + power *= z*z + return 2*total, 2*total+2*power/(121*(1-z*z)) + lo, hi = expand(x) + blo, bhi = expand(Q(3, 2)) + return lo+k*blo, hi+k*bhi + + +def independent_moment(profile, saving): + lower, upper = Q(), Q() + for t, n in sorted((int(t), n) for t, n in profile['child_multiplicities'].items()): + lo, hi = independent_log(Q(profile['m'], t)) + u, v = down(lo*saving), up(hi*saving) + assert 0 < u <= v < Q(1, 1000) + tl = th = el = eh = Q(1) + for j in range(1, 13): + tl, th = tl*u/j, th*v/j + el, eh = el+tl, eh+th + eh += 2*th*v/13 + weight = Q(t*n, profile['m']*profile['W']) + lower += weight*down(el) + upper += weight*up(eh) + return lower, upper + + +def independent_audit(certificate): + p = certificate['bit'] + saving, successor = Q(certificate['bit_saving']), Q(certificate['next_bit_saving']) + accepted = independent_moment(p, saving) + rejected = independent_moment(p, successor) + assert accepted[1] < 1 < rejected[0] + actual = balanced.assembly(bridge_for(p), saving, Q(certificate['kappa']), h=BACKOFF) + assert json_value(actual) == certificate['assembly'] + assert all(x > 0 for x in actual['constraints'].values()) + assert all(x > Q(certificate['kappa']) for x in actual['margins'].values()) + return dict(status='PASS separately evaluated logarithm/exponential enclosure and assembly', + accepted_gap=1-accepted[1], rejected_gap=rejected[0]-1, + logarithm_base='3/2', logarithm_terms=60, exponential_degree=12, + constraints=47, margins=7) diff --git a/research/balanced-split-reclamation/carry_exchanges.py b/research/balanced-split-reclamation/carry_exchanges.py new file mode 100644 index 0000000000..0b25d87a0f --- /dev/null +++ b/research/balanced-split-reclamation/carry_exchanges.py @@ -0,0 +1,156 @@ +"""PR70/76 fixed-cardinality profile-cost carry exchanges, reusable adapter. + +Method: Alejandro Zarzuelo Urdiales (PR70). This implementation is adapted +from Dominik Scholz's PR76 run.py at 2333abcea79793fe301b479a7c971cc2be45596c. +Integration with balanced split graphs: huxint with OpenAI Codex assistance. +All inherited Apache-2.0 notices remain applicable. A discovery heuristic; +literal replay and the full exact profile determine correctness and saving. +""" +import json +from pathlib import Path +import struct +import subprocess +from binary_frame_math import logs + + +def install(compiler, h, work, passes, two_cycles=False, two_paths=False): + original = compiler.match + def matching(blocks, uses, enabled): + result = original(blocks, uses, enabled) + edges, chosen, right, stats = result + cardinality = len(chosen) + if not passes: + return result + owner = {x: g for g, b in enumerate(blocks) for x in b['nodes']} + path = Path(work)/'matching-oracle.bin' + with path.open('wb') as stream: + stream.write(struct.pack('<6I2Q', h, h*(h-1)*(h-2)//6, 0, len(blocks)+2, 0, 0, h*(h-1), h*(h-1))) + stream.write(struct.pack('<2QI', 0, 0, 0)) + stream.write(struct.pack('<2QI', 0, 0, h)) + for b in blocks: + stream.write(struct.pack('<2QI', *compiler.oracle_frame(b['frame']), b['rank'])) + oracle = subprocess.Popen([compiler.ORACLE_EXE, str(path)], stdin=subprocess.PIPE, + stdout=subprocess.PIPE, text=True, bufsize=1) + weights = [0]+[int(t*sum(logs(t))*10**30//2) for t in range(1, h+1)] + cache = {} + def entropy(x, y): + if (x, y) not in cache: + oracle.stdin.write(f'{x} {y}\n'); oracle.stdin.flush() + line = oracle.stdout.readline(); assert line + values = list(map(int, line.split())); assert len(values) == h+1 + cache[x, y] = sum(n*w for n, w in zip(values, weights)) + return cache[x, y] + try: + prices = [] + for j, (g, u, i) in enumerate(edges): + provider = owner[blocks[g]['inputs'][i]] + target = uses[u][1] + prices.append(-entropy(g+2, target+2)+entropy(g+2, 1)+ + entropy(0, provider+2)+entropy(provider+2, target+2)) + if j % 20000 == 0: + print('CARRY_PRICES', h, j, len(edges), flush=True) + finally: + oracle.stdin.close() + assert oracle.wait() == 0 + priority = sorted(range(len(edges)), key=lambda e: (prices[e], edges[e])) + by_group_use = {(g, u): e for e, (g, u, _) in enumerate(edges)} + assert len(by_group_use) == len(edges) + by_group = {} + for e in priority: + by_group.setdefault(edges[e][0], []).append(e) + initial = sum(prices[e] for e in chosen) + def can(e, drop=None): + g, u, i = edges[e] + rows = blocks[g]['outbasis']+[1 << edges[f][2] for f in blocks[g]['selected'] if f != drop] + return compiler.independent(compiler.basis(rows), 1 << i) + for phase in range(passes): + changed = 0 + for e in priority: + if e in chosen: + continue + g, u, i = edges[e] + f = right.get(u) + if f is not None: + if prices[e] >= prices[f] or not can(e, f if edges[f][0] == g else None): + continue + else: + f = next((z for z in sorted(blocks[g]['selected'], key=lambda z: (-prices[z], z)) + if prices[e] < prices[z] and can(e, z)), None) + if f is None: + continue + fg, fu, _ = edges[f] + chosen.remove(f); blocks[fg]['selected'].remove(f); del right[fu] + chosen.add(e); blocks[g]['selected'].add(e) + assert u not in right + right[u] = e + changed += 1 + cycles = 0 + paths = 0 + if two_cycles or two_paths: + # Replace two selected edges simultaneously. Each region loses + # its own old row before gaining the other eligible input row. + # Both occupied right uses remain unique, and cardinality is fixed. + for e in priority: + if e in chosen: + continue + g, u, _ = edges[e] + f = right.get(u) + if f is None: + continue + other = edges[f][0] + if other == g: + continue + options = [] + for old in blocks[g]['selected'] if two_cycles else (): + old_use = edges[old][1] + partner = by_group_use.get((other, old_use)) + if partner is None or partner in chosen: + continue + gain = prices[old]+prices[f]-prices[e]-prices[partner] + if gain > 0: + options.append((-gain, old, partner)) + if two_paths: + old = next((z for z in sorted(blocks[g]['selected'], key=lambda z: (-prices[z], z)) + if can(e, z)), None) + if old is not None: + for partner in by_group[other]: + if prices[e]+prices[partner] >= prices[old]+prices[f]: + break + if edges[partner][1] in right: + continue + if can(partner, f): + options.append((prices[e]+prices[partner]-prices[old]-prices[f], old, partner)) + break + for _, old, partner in sorted(options): + if not can(e, old) or not can(partner, f): + continue + old_use = edges[old][1] + chosen.remove(old); chosen.remove(f) + blocks[g]['selected'].remove(old) + blocks[other]['selected'].remove(f) + chosen.add(e); chosen.add(partner) + blocks[g]['selected'].add(e) + blocks[other]['selected'].add(partner) + del right[u]; del right[old_use] + partner_use = edges[partner][1] + assert partner_use not in right and partner_use != u + right[u] = e; right[partner_use] = partner + if partner_use == old_use: + cycles += 1 + else: + paths += 1 + break + stats['carried_signal_exchanges'] += changed + stats['two_region_exchange_cycles'] += cycles + stats['two_region_exchange_paths'] += paths + print('CARRY_EXCHANGES', h, phase, changed, 'cycles2', cycles, 'paths2', paths, flush=True) + if not changed and not cycles and not paths: + break + assert len(chosen) == len(right) == cardinality + for b in blocks: + assert len(compiler.basis(b['outbasis']+[1 << edges[e][2] for e in b['selected']])) == len(b['outbasis'])+len(b['selected']) + stats['exchange_entropy_gain_1e30'] = initial-sum(prices[e] for e in chosen) + stats['exchange_profile_pairs'] = len(cache) + (Path(work)/'matching.json').write_text(json.dumps(dict(edges=edges, chosen=sorted(chosen), stats=dict(stats)), separators=(',', ':'))+'\n') + return edges, chosen, right, stats + compiler.match = matching diff --git a/research/balanced-split-reclamation/compiler.py b/research/balanced-split-reclamation/compiler.py new file mode 100644 index 0000000000..c1d39660eb --- /dev/null +++ b/research/balanced-split-reclamation/compiler.py @@ -0,0 +1,392 @@ +# Live-anchor composition of PR67 all-rank cost selection with PR68. +# Dominik Scholz with substantial OpenAI GPT-6 Astra assistance. +# Next-use-aware scoring experiments by huxint with OpenAI Codex assistance. +# Based on Rohan Arun's PR67 cost selection and Dominik Scholz's PR68 +# compatible live controls (8778fdb52e834a2a14371590d80ea6e0c734a866). +# All-rank profile-cost selection: Rohan Arun, with OpenAI Codex assistance. +# Derived from Dominik Scholz PR63, Chafik Boukhalfa PR60, Avi Eisenberg PR62 +# and eumemic PR57. Apache-2.0; all inherited notices remain applicable. +"""Exact-envelope block synthesis on the pinned PR48 scalar graph. +Experimental finite compiler; no fixed-I+J profile or multiplication claim. +""" +# Derived from eumemic's PR57 compiler; original notices remain applicable. +# Descending-rank reclamation priority: Chafik Boukhalfa, with OpenAI Codex assistance. +import sys +if sys.flags.optimize: + raise ValueError('Assertions must remain enabled') +sys.dont_write_bytecode=True +from pathlib import Path +ROOT=Path(__file__).resolve().parents[2]/'references/frame-compiler/pr48' +from hashlib import sha256 +import json +manifest=json.loads((ROOT/'SOURCE.json').read_text()) +for name,digest in manifest['files'].items(): + assert sha256((ROOT/name).read_bytes()).hexdigest()==digest, 'Changed producer source: '+name +sys.path[:0]=[str(ROOT/'scripts'),str(ROOT/'research/copied-fixed')] +from changed_graph import graph +from collections import defaultdict,Counter,deque +import argparse,json,time,struct + +# Discovery choices only. Every accepted word must pass the independent replay. +CONFIG = {} + +def oracle_frame(frame): + permutation=CONFIG.get('oracle_permutation') + if not permutation:return frame + return tuple(sum(1<>i&1) for mask in frame) + +def independent(rows,vec): + for row in rows: + vec=min(vec,vec^row) + return bool(vec) +def basis(rows): + out=[] + for vec in rows: + for row in out:vec=min(vec,vec^row) + if vec:out.append(vec) + return out + +def build(h): + c=graph(h);groups={};owner={};signal={};blocks=[] + labels={x:(c.core[x],c.union[x]) for x in c.active} + growth=CONFIG.get('enlarge',0) + if growth: + consumers=defaultdict(list) + terminals=set(c.outputs.values()) + for x in sorted(c.active): + for y in c.args[x] or ():consumers[y].append(x) + changed=0 + for x in sorted(c.active,reverse=True): + if not c.args[x] or x in terminals:continue + cap=(1<1 for b in blocks) + pending_points=defaultdict(set);pending_order={};pending_clock=0 + def point_bits(mask): + while mask: + bit=mask&-mask;yield bit;mask^=bit + def set_pending(s,g): + nonlocal pending_clock + assert s not in pending + pending[s]=g;pending_order[s]=pending_clock;pending_clock+=1 + for bit in point_bits(blocks[frames[s]]['frame'][0]):pending_points[bit].add(s) + def pop_pending(s): + for bit in point_bits(blocks[frames[s]]['frame'][0]):pending_points[bit].remove(s) + del pending_order[s] + return pending.pop(s) + def compatible_live(g): + if not CONFIG.get('live',True):return [] + core=blocks[g]['frame'][0];assert core + candidates=pending_points[core&-core] + return sorted((s for s in candidates if + contains(blocks[frames[s]]['frame'],blocks[g]['frame']) and + contains(blocks[g]['frame'],blocks[pending[s]]['frame'])),key=pending_order.__getitem__) + def new(g): + s=len(slots);slots.append(0);frames.append(g);hist[blocks[g]['rank']]+=1;events.append((s,-1,g));return s + def raise_(s,g): + old=frames[s];assert contains(blocks[old]['frame'],blocks[g]['frame']) + if s in pending: + for bit in point_bits(blocks[old]['frame'][0]&~blocks[g]['frame'][0]):pending_points[bit].remove(s) + hist[blocks[g]['rank']-blocks[old]['rank']]+=1;frames[s]=g;events.append((s,old,g)) + def xor(a,b,g): + assert a!=b;raise_(a,g);raise_(b,g);slots[a]^=slots[b];ops.append((a,b,g)) + import subprocess,struct + from binary_frame_math import logs + # Integer midpoint enclosures give a reproducible discovery score. + # Every candidate is independently checked by the complete exact screen. + if CONFIG.get('weight','entropy')=='entropy': + weights=[0]+[int(t*sum(logs(t))*10**30//2) for t in range(1,h+1)] + elif CONFIG['weight']=='moment': + from fractions import Fraction as Q + from math import factorial + saving=Q(51036365162009,10**18) + weights=[0] + for t in range(1,h+1): + x=-saving*sum(logs(t))/2 + # An exact rational discovery approximation, never an acceptance bound. + value=t*sum((x**j/factorial(j) for j in range(9)),Q()) + weights.append(-int(value*10**40)) + else:raise ValueError(CONFIG['weight']) + oracle_input=Path(ORACLE_INPUT) + with oracle_input.open('wb') as stream: + stream.write(struct.pack('<6I2Q',h,v,0,len(blocks)+2,0,0,h*(h-1),h*(h-1))) + stream.write(struct.pack('<2QI',0,0,0));stream.write(struct.pack('<2QI',0,0,h)) + for b in blocks:stream.write(struct.pack('<2QI',*oracle_frame(b['frame']),b['rank'])) + oracle=subprocess.Popen([ORACLE_EXE,str(oracle_input)],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True,bufsize=1) + oracles.append(oracle) + cache={} + def profile_entropy(a,b): + if (a,b) not in cache: + oracle.stdin.write(f'{a} {b}\n');oracle.stdin.flush() + answer=oracle.stdout.readline() + assert answer, 'profile oracle failed' + parts=list(map(int,answer.split()));assert len(parts)==h+1 + cache[a,b]=sum(n*w for n,w in zip(parts,weights)) + return cache[a,b] + def profile_cost(a,g): + old=frames[a]+2;target=g+2 + end=pending[a]+2 if CONFIG.get('horizon','cleanup')=='next-use' and a in pending else 1 + return profile_entropy(old,end)-profile_entropy(old,target)-profile_entropy(target,end) + def acquire(g,anchors): + if reclaim: + bb={} + def ins(s): + row=slots[s];expr=1<>s&1;e^=1<step and contains(b['frame'],blocks[uses[u][1]]['frame']) for u in value_uses[b['inputs'][i]]) + return (-compatible,slots[ins[i]].bit_count(),i) + unit_order.sort(key=future_priority) + for i in unit_order: + if independent(echelon,1<>i&1) + if j!=i: + # Synthesize swap as three XORs at the single common frame. + for a,z in ((i,j),(j,i),(i,j)):rr[a]^=rr[z];elim.append((a,z)) + for j in range(len(ins)): + if j!=i and rr[j]>>i&1:rr[j]^=rr[i];elim.append((j,i)) + assert rr==[1<>i&1:xor(s,value_slots[y],g) + assert slots[s]==signal[x];value_slots[x]=s + used=set() + for u in outuses: + x=uses[u][0];s=value_slots[x] + if x in used: + ss=acquire(g,list(value_slots.values()));xor(ss,s,g);s=ss + used.add(x);assert u not in assign;assign[u]=s;set_pending(s,uses[u][1]) + if step%5000==0:print('compile',h,step,len(slots),'reclaimed',stats['reclaimed'],'seconds',time.time()-t0,flush=True,file=sys.stderr) + output_slots=[];output_records=[];scatter=[0]*v;J=[] + for u,(x,g,target)in enumerate(uses): + if target is None:continue + s=assign[u];assert slots[s]==signal[x];raise_(s,g);output_slots.append(s) + common,triple=target;output_records.append((s,g,common,triple)) + targets=[i for i,t in enumerate(c.inputs)if common in t]if len(triple)==1 else[c.inputs.index(triple)] + for i in targets:scatter[i]^=slots[s];J.append((v+i,2*v+s)) + rank=blocks[g]['rank'] + if len(triple)==1:hist[rank]+=1;hist[h-rank]+=1 + else:hist[h-1-rank]+=1;hist[1]+=1 + assert len(set(output_slots))==len(output_slots) + for s in retired:hist[h-blocks[frames[s]]['rank']]+=1 + assert len(retired)+len(output_slots)==len(slots) + assert scatter==[1<> i & 1) + result = dict(word) + result['frames'] = [[mask(c), mask(u)] for c, u in word['frames']] + result['sources'] = {mapping[int(i)]: s for i, s in word['sources'].items()} + result['scatter'] = [[v+mapping[a-v], b] for a, b in word['scatter']] + result['outputs'] = [[s, g, permutation[c], sorted(permutation[x] for x in t)] + for s, g, c, t in word['outputs']] + return result diff --git a/research/balanced-split-reclamation/graph.py b/research/balanced-split-reclamation/graph.py new file mode 100644 index 0000000000..6e67dc2434 --- /dev/null +++ b/research/balanced-split-reclamation/graph.py @@ -0,0 +1,105 @@ +"""Controlled combinations of the PR62, PR69 and PR71 scalar graphs. + +PR62 graph: Avi Eisenberg with Claude assistance. PR59 split operation: +Rohan Garg. PR69 balanced coarse columns: eumemic with Codex assistance. +PR71 anchored split vector: Chafik Boukhalfa with Codex assistance. +This configurable composition/search adapter: huxint with Codex assistance. +Apache-2.0 and all inherited notices apply. No global search claim. +""" +import sys +if sys.flags.optimize: + raise ValueError('Assertions must remain enabled') +from hashlib import sha256 +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +BASE = ROOT/'research/pair-assembly/pair_graph.py' +BEFORE = ''' coarse = {(i, j): self.total([e(a, b) for a in groups[i] for b in groups[j]]) + for i, j in combinations(range(ng), 2)}''' +AFTER_COLUMNS = ''' def coarse_sum(i, j): + columns = [self.total([e(a,b) for a in groups[i]]) for b in groups[j]] + return self.total(columns) + coarse = {(i,j):coarse_sum(i,j) for i,j in combinations(range(ng),2)}''' +AFTER_ROWS = ''' def coarse_sum(i, j): + rows = [self.total([e(a,b) for b in groups[j]]) for a in groups[i]] + return self.total(rows) + coarse = {(i,j):coarse_sum(i,j) for i,j in combinations(range(ng),2)}''' +AFTER_HALF = ''' def coarse_sum(i, j): + if i+j < ng-1+COARSE_SHIFT: + pieces = [self.total([e(a,b) for a in groups[i]]) for b in groups[j]] + else: + pieces = [self.total([e(a,b) for b in groups[j]]) for a in groups[i]] + return self.total(pieces) + coarse = {(i,j):coarse_sum(i,j) for i,j in combinations(range(ng),2)}''' + + +def reorder_envelopes(c): + """Thomas DiFiore's PR74 scalar-envelope order, also used by PR76.""" + regions = {} + for node in sorted(c.active): + if c.args[node]: + regions.setdefault((c.core[node], c.union[node]), []).append(node) + def key(item): + (core, union), nodes = item + return union.bit_count()-core.bit_count(), -core, union, min(nodes) + variables = len(c.inputs) + ids = list(range(variables+1))+[x for _, nodes in sorted(regions.items(), key=key) for x in nodes] + mapping = {x: i for i, x in enumerate(ids)} + args, core, union, provenance = c.args, c.core, c.union, c.provenance + c.args = [tuple(mapping[y] for y in args[x]) if args[x] else None for x in ids] + c.core = [core[x] for x in ids] + c.union = [union[x] for x in ids] + c.provenance = [provenance[x] for x in ids] + c.active = {mapping[x] for x in c.active} + c.outputs = {k: mapping[v] for k, v in c.outputs.items()} + # The pre-reorder audit populated keys (self,node,common). Their node + # numbers now have different meanings; invalidate that derived cache. + c.support_in.cache_clear() + c.verify() + return c + + +def graph(h, groups=(1, 1, 2), anchor='first', coarse='none', node_order='original', coarse_shift=0): + if h not in (23, 25) or any(type(x) is not int or not 0 <= x <= 3 for x in groups): + raise ValueError('Unsupported finite graph configuration') + source = BASE.read_text() + if coarse != 'none': + assert source.count(BEFORE) == 1 + source = source.replace(BEFORE, {'columns': AFTER_COLUMNS, 'rows': AFTER_ROWS, 'half': AFTER_HALF}[coarse]) + namespace = {'__file__': str(BASE), '__name__': 'next_use_graph_composition', 'COARSE_SHIFT':coarse_shift} + exec(compile(source, str(BASE)+':next_use_composition', 'exec'), namespace) + original_class = namespace['circuit_class'] + + def circuit_class(dimension): + class SplitPair(original_class(dimension)): + def grouping(self, points): + partition = super().grouping(points) + choice = groups[self._level] if self._level < len(groups) else 0 + if len(points) > 3 and choice: + index = {1: 0, 2: (len(partition)-1)//2, 3: len(partition)-1}[choice] + if len(partition[index]) == 2: + partition[index:index+1] = [[x] for x in partition[index]] + assert all(len(g) in (1, 2) for g in partition) + assert len(partition) < len(points) + assert sorted(x for g in partition for x in g) == sorted(points) + return partition + return SplitPair + + namespace['circuit_class'] = circuit_class + original_points = namespace['alternating_points'] + if anchor != 'none': + def points(dimension, common): + old = original_points(dimension, common) + pairs = [(a, a+1) for a in range(0, dimension-1, 2) if common not in (a, a+1)] + chosen = {'first': pairs[0], 'second': pairs[min(1, len(pairs)-1)], 'last': pairs[-1]}[anchor] + result = list(chosen)+[x for x in old if x not in chosen] + assert sorted(result) == [x for x in range(dimension) if x != common] + return result + namespace['alternating_points'] = points + result = namespace['graph'](h) + result.verify() + if node_order == 'envelope': + result = reorder_envelopes(result) + elif node_order != 'original': + raise ValueError(node_order) + return result diff --git a/research/balanced-split-reclamation/paper.pdf b/research/balanced-split-reclamation/paper.pdf new file mode 100644 index 0000000000..1fdd2c6b36 Binary files /dev/null and b/research/balanced-split-reclamation/paper.pdf differ diff --git a/research/balanced-split-reclamation/paper.tex b/research/balanced-split-reclamation/paper.tex new file mode 100644 index 0000000000..a146cb79a1 --- /dev/null +++ b/research/balanced-split-reclamation/paper.tex @@ -0,0 +1,317 @@ +\documentclass[11pt]{article} +\usepackage[T1]{fontenc} +\usepackage{lmodern,amsmath,amssymb,amsthm,booktabs,microtype} +\usepackage[margin=1in]{geometry} +\usepackage[hidelinks]{hyperref} +\newtheorem{proposition}{Proposition} +\newtheorem{theorem}{Theorem} +\newcommand{\F}{\mathbb F_2} +\title{Coarse-threshold and coordinate refinement\\on anchored split frames\\ +\large A conditional integer-multiplication saving of +\(5.2062354654791\times10^{-5}\)} +\author{huxint\\\small With substantial OpenAI Codex assistance} +\date{October 9, 2026} +\begin{document} +\maketitle +\begin{abstract} +We specify a finite refinement of the balanced, anchored split-frame +construction. It combines an offset coarse-cell rule, compatible carry +exchanges, and a cyclic coordinate flag at dimension 25. At dimensions 23 +and 25 the selected words have 27,043 and 35,505 auxiliary roles. Under the +inherited all-size framed-word, residual-compiler, analytic, routing, +exact-recovery and fixed finite-alphabet multitape interfaces, the witness +gives \(T(n)=O(n(\log n)^{1-\kappa})\), with +\(\kappa=52062354654791/10^{18}\). This is 0.0568021906\% above the complete +pinned PR82 profile. Newer community submissions report larger values; no +latest-record or global-optimality claim is made. Exact finite checks and this +written conditional argument do not formalize the complete multiplication theorem. +\end{abstract} + +\section{The selected graph and compiler choices} +We retain the original-envelope geometry, rational \(I+J\) basis, complete +two-stage data network and complex branch of the cited construction chain. +Address geometry is rational; bit payloads are over \(\F\). The graph uses +Avi Eisenberg's interval strips and core-aware pair assembly \cite{pr62}, +Rohan Garg's split operation \cite{pr59}, and Chafik Boukhalfa's anchored +\([1,1,2]\) choices \cite{pr71}. At every common point the lowest intact +global pair is moved to the start of the inherited alternating point order. +The first pair is split at the first two recursive levels and the middle +group at the third, when it is a pair. Splitting is disabled at at most +three remaining points. Thus the groups partition the points, have size one +or two, and strictly reduce the recursive size. + +For groups \(G_i,G_j\), both evaluations +\[ + \sum_{b\in G_j}\left(\sum_{a\in G_i}e(a,b)\right) + =\sum_{a\in G_i}\left(\sum_{b\in G_j}e(a,b)\right) \tag{1} +\] +compute the same disjoint coarse edge sum. The balanced columns originate in +PR69 \cite{pr69}; the row and half-plane choices and future-compatible +completion are from PR79 \cite{pr79}. Our selected rule at \(h=23\) uses +columns for \(i+j0\), the complete characteristic is +\[ + F(a)=\frac1{mW}\sum_t n_t t\exp\!\left(a\log\frac mt\right). + \tag{8} +\] +The strict witness is +\[ + a=\frac{26032532642421}{500000000000000000}. \tag{9} +\] +Rational atanh-series bounds enclose every logarithm. For +\(0\le u\le v<1\), a degree-eight Taylor lower bound at \(u\) and the +upper bound +\[ + \sum_{j=0}^{8}\frac{v^j}{j!}+\frac{v^9}{9!\,(1-v/10)} \tag{10} +\] +are used with outward rounding. Exact arithmetic proves an upper moment +below one at (9) and a lower moment above one at \(a+10^{-18}\). A second +evaluation uses logarithm range reduction by \(3/2\), 60 atanh terms and +a degree-twelve exponential bound and confirms both signs. The complete +PR82 list, with its own width, has a lower moment above one at (9). + +\begin{theorem}[Conditional on the inherited interfaces] +Assume the base multiplication theorem and the all-size ordered residual +compiler, framed-word transfer, fixed finite-alphabet multitape layout, +analytic/semantic reductions, routing, eligible-prime setup and exact-recovery +interfaces used by the cited chain. Then +\[ + T(n)=O\!\left(n(\log n)^{1-\kappa}\right),\qquad + \kappa=\frac{52062354654791}{10^{18}}. +\] +\end{theorem} +\begin{proof} +Use (4)--(9) as the fixed bit interface in the inherited balanced assembly. +The complex saving remains \(717/10^7\), \(\beta=1/20\), and the semantic +guard remains one. Set \(\eta=10^{-12}\), \(q=a(1-2\eta)\), +\(\epsilon=(1-\eta)/(1+q)\). The controlling margin is \(G=\epsilon q\). +All 47 strict constraints and seven margins are recomputed, and +\(\kappa0\), with suffix slope 8000. +The complex literal scalar charge is unchanged. The semantic, row-stock, +remaining strict inequalities and sufficient arithmetic cutoffs are checked +with these derived fields. Positive final slack gives the inherited logarithmic +absorption. Arithmetic cutoffs are not a complete operational threshold. +\end{proof} + +The comparison is to PR82 commit +\href{https://github.com/rohanarun/integer-mult-bounds/tree/3410b940aa26e5876202152dfa7c4f66451ee22c}{\texttt{3410b940aa26}}. +The improvement is 0.0568021906\%. Later community submissions have larger +reported exponents; this is not a latest-record claim. Our earlier PR77 +witness remains reproducible at +\href{https://github.com/huxint/integer-mult-bounds/tree/83298467291d3bd4b53f76faaef60dbf585be171}{\texttt{83298467291d}}. + +\section{Reproduction, attribution and limits} +Run \texttt{make -C research/balanced-split-reclamation verify} for deterministic +word regeneration, independent full dirty-basis replay in both orientations, +actual transition/profile reconstruction, exact arithmetic and 17 focused +failure-mode tests. These include negative indices, aliased sources, omitted +paid children, wrong or canceling uncharged scatter ports, stale bridge fields, +adjacent exponent-grid rejection and disabled Python assertions. Run the +repository's \texttt{make -j1 verify} for its retained broad checks. Run receipts +record environmental interruptions and any sequential continuation separately. +Source freezes are explicit and are never refreshed by verification. + +The finite checks do not execute or formalize the entire asymptotic machine, +prove global optimality, establish the inherited interfaces independently, or +show practical speedup. This package and its additional checks used substantial +OpenAI Codex assistance and are not independent human expert review. The new +contribution is the explicit selected refinement and checked comparison; +general carry exchanges, coordinate conjugacy and inherited graph/compiler +techniques retain their authorship and notices. + +\begin{thebibliography}{99} +\bibitem{pr57} eumemic. Joint reversible frame compiler, PR57. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/57}. +\bibitem{pr59} Rohan Garg. Split-pair recursion, PR59. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/59}. +\bibitem{pr60} Chafik Boukhalfa. Ranked reclamation, PR60. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/60}. +\bibitem{pr62} Avi Eisenberg. Interval strips and core-aware pair graph, PR62. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/62}. +\bibitem{pr67} Rohan Arun. Profile-cost selection and refined arithmetic, PR67. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/67}. +\bibitem{pr68} Dominik Scholz. Compatible pending controls, PR68. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/68}. +\bibitem{pr69} eumemic. Balanced coarse columns, PR69, \texttt{91aa1f17e6e3}. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/69}. +\bibitem{pr70} Alejandro Zarzuelo Urdiales. Profile-aware carry exchanges, PR70. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/70}. +\bibitem{pr71} Chafik Boukhalfa. Anchored split frames, PR71, \texttt{1bef94fd40a7}. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/71}. +\bibitem{pr74} Thomas DiFiore. Envelope ordering and relabeling, PR74. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/74}. +\bibitem{pr76} Dominik Scholz. Envelope-ordered carry exchanges, PR76, +\texttt{2333abcea797}. \url{https://github.com/CrocSwap/integer-mult-bounds/pull/76}. +\bibitem{pr79} Chafik Boukhalfa. Balanced/future-completion choices, PR79. +\url{https://github.com/CrocSwap/integer-mult-bounds/pull/79}. +\bibitem{pr82} Rohan Arun. Envelope-balanced coordinate pricing, PR82, +\texttt{3410b940aa26}. \url{https://github.com/CrocSwap/integer-mult-bounds/pull/82}. +\end{thebibliography} +\end{document} diff --git a/research/balanced-split-reclamation/pin.py b/research/balanced-split-reclamation/pin.py new file mode 100644 index 0000000000..1111b9e469 --- /dev/null +++ b/research/balanced-split-reclamation/pin.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +"""Explicitly freeze the candidate; verification never refreshes this file.""" +from hashlib import sha256 +import argparse +import json +from pathlib import Path +from support import HERE, ROOT, write_json + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--record', action='store_true', help='Explicitly replace SOURCE.json') + args = parser.parse_args() + if not args.record: + parser.error('Pass --record for the intentional source-freeze operation') + local = [p for p in HERE.rglob('*') if p.is_file() and p.name not in ('SOURCE.json', 'VALIDATION.json') + and p.suffix not in ('.pyc', '.log', '.aux', '.out') and '__pycache__' not in p.parts] + inherited = [ROOT/p for p in ( + 'research/pair-assembly/pair_graph.py', 'research/pair-assembly/frame/frame_verify.py', + 'research/pair-assembly/frame/frame-compiler.json', + 'scripts/experiments/binary_frame_math.py', 'scripts/experiments/binary_frame_replay.py', + 'scripts/experiments/binary_frame_profile_prepare.py', 'scripts/experiments/binary_frame_profiles.cpp', + 'scripts/exclusion_circuit.py', 'scripts/partial_swap/paired.py', 'scripts/partial_swap/shared.py', + 'references/frame-compiler/pr48/SOURCE.json', '.github/workflows/balanced-split.yml')] + manifest = json.loads((ROOT/'references/frame-compiler/pr48/SOURCE.json').read_text()) + inherited += [ROOT/'references/frame-compiler/pr48'/p for p in manifest['files']] + files = {str(p.relative_to(ROOT)): sha256(p.read_bytes()).hexdigest() for p in sorted(set(local+inherited))} + write_json(HERE/'SOURCE.json', dict(files=files, scope='Explicit source and artifact freeze; no automatic refresh in verification', + upstream=dict(pr67='b3745601e947a94316bf25c2c6263d93c06e3364', + pr68='8778fdb52e834a2a14371590d80ea6e0c734a866', + pr69='91aa1f17e6e3fc063241686a41a34ddd0dc24c50', + pr71='1bef94fd40a746452548c84a4a8f8834670a3113', + pr76='2333abcea79793fe301b479a7c971cc2be45596c', + pr82='3410b940aa26e5876202152dfa7c4f66451ee22c'))) + print('Pinned', len(files), 'source and artifact files') + + +if __name__ == '__main__': + main() diff --git a/research/balanced-split-reclamation/profile_oracle.cpp b/research/balanced-split-reclamation/profile_oracle.cpp new file mode 100644 index 0000000000..bed146cb88 --- /dev/null +++ b/research/balanced-split-reclamation/profile_oracle.cpp @@ -0,0 +1,90 @@ +// Optimal-matching variant of research/copied-fixed/profiles.cpp (PR #43, Chafik +// Boukhalfa), itself adapted from Dominik Scholz PR35 and icekylinx PR32. +// Change: with LINKS_IN=, the carrier matching is read from a pinned file +// instead of Hopcroft-Karp. Every pinned edge must lie in the same admissible +// adjacency (causal order and frame inclusion); donors and uses are distinct. +// This replay-only adaptation omits the discovery edge dumper. The original +// optimizer and profiler are preserved in references/copied-fixed/pr44. +// Replay-only adaptation prepared with OpenAI Codex assistance. +// Prepared by Rohan Arun with Anthropic Claude assistance. Apache-2.0. +// Adapted at h=23,25; original PR35 by Dominik Scholz, PR32 by icekylinx. +// Dimension adaptation at 45/47; extra primes for all source-growth cases. +// Exact bounded-minor inequalities are checked by verify.py. Original credit below. +// Copyright 2026 icekylinx. Apache-2.0; AI-assisted handoff integration. +// Original round3_rankone_profiles.cpp. Requires GCC/Clang unsigned __int128. + +// Adapted input reader for complete serialized frame-compiler transitions. +// Actual-word fixed-I+J profiling, adapted from PR48 profiles.cpp. +// All projector, pivot and CRT formulas below are unchanged. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using U=uint32_t;using V=uint64_t; +#include "binary_io.hpp" +int main(int argc,char**argv){ +assert(argc==2);std::ifstream f(argv[1],std::ios::binary);U hdr[6];read_array(f,hdr); +U h=hdr[0],v=hdr[1],R=hdr[2],nf=hdr[3],nt=hdr[4];int64_t singles=hdr[5];assert(h==23||h==25); +V sum,loss;f.read(reinterpret_cast(&sum),8);f.read(reinterpret_cast(&loss),8); +struct Frame{V core,cover;U rank;};std::vectorframes; +for(U i=0;i(&a.core),8);f.read(reinterpret_cast(&a.cover),8);f.read(reinterpret_cast(&a.rank),4);frames.push_back(a);} +std::map,int64_t>transitions; +for(U i=0;i(&a),4);f.read(reinterpret_cast(&b),4);f.read(reinterpret_cast(&count),8);transitions[{a,b}]=count;} +assert(f);assert(sum==h*V(R)+loss); +V p=2305843009213693951ULL; +auto mul=[&](V a,V b)->V{return (__uint128_t)a*b%p;}; +auto power=[&](V a,V b)->V{V r=1;for(;b;b>>=1,a=mul(a,a))if(b&1)r=mul(r,a);return r;}; +auto sub=[&](V a,V b)->V{return (a+p-b)%p;}; +std::vector>matrix_cache(frames.size()); +auto matrix=[&](U id)->const std::vector&{auto&A=matrix_cache[id];if(!A.empty())return A;A.assign(h*h,0);if(id==0)return A;if(id==1){for(U i=0;i>i)&1);V zj=((f.core>>j)&1)?3*(h+1)-10:p-10;A[i*h+j]=mul(mul(wi,zj),factor);}return A;} + assert(c==1||c==2);V s=3-c,d=s*s+(c-1)*nn,den=3*(h+1)*d,inv=power(den,p-2); + for(U i=0;i>i)&1,oj=(out>>j)&1,wi=3+((f.core>>i)&1),zj=((f.core>>j)&1)?3*(h+1)-10:p-10; + V num=(mul(s*oi,zj)+3*(h+1)*s*wi*oj+mul(nn*wi,zj))%p;num=sub(num,3*(h+1)*(c-1)*oi*oj);A[i*h+j]=(V(i==j&&oi)+mul(num,inv))%p; + }return A;}; + +std::vectorblocks(h+1);blocks[1]=singles;V done=0,matrices=0,crt_matrices=0,crt_disagreements=0;U longest=0;std::mapcorrection_hist; +U aa,bb; +while(std::cin>>aa>>bb){ + assert(aa=frames[aa].rank); + if(rr<=2){blocks[1]=rr; for(U t=0;t<=h;t++)std::cout<1&&bb>1){ + assert(!(frames[bb].core&~frames[aa].core)); + assert(!(frames[aa].cover&~frames[bb].cover)); + U ca=popcount64(frames[aa].core),cb=popcount64(frames[bb].core); + assert(ca==3||frames[aa].core==frames[bb].core||(ca==2&&cb==1)); + } + const auto&A=matrix(aa);const auto&B=matrix(bb);std::vectorM(h*h);for(U x=0;x>pivots; + for(U i=0;i=0&&!M[i*h+j])j--;if(j<0)continue;pivots.push_back({i,U(j)});V inv=power(M[i*h+j],p-2);for(U k=i+1;k core-one use all three primes at these dimensions. +if(aa>1&&bb>1&&(popcount64(frames[aa].core)==3||(popcount64(frames[aa].core)==2&&popcount64(frames[bb].core)==1))){ + assert(h==23||h==25);crt_matrices++;matrix_cache[aa].clear();matrix_cache[bb].clear();std::vector>> all{pivots}; + for(V extra:{2147483647ULL,524287ULL}){p=extra;matrix_cache[aa].clear();matrix_cache[bb].clear();const auto&C=matrix(aa);const auto&D=matrix(bb);std::vectorY(h*h);for(U z=0;z> pp; + for(U i=0;i=0&&!Y[i*h+j])j--;if(j<0)continue;pp.push_back({i,U(j)});V inv=power(Y[i*h+j],p-2);for(U k=i+1;k corner((h+1)*(h+1));for(U i=0;i=j;best=std::max(best,rank);}corner[(i+1)*(h+1)+j]=best;} + pivots.clear();for(U i=0;i= j+1 proves persistence.", + "common_cutoff": 14000000000000, + "cutoff_log2_input": { + "alpha": 5903156225, + "compact": 23612624897, + "geometry": 3999930584731, + "guard": 4264118, + "log_p": 25, + "normalization": 14000000000000, + "period": 47225249793, + "phase_cell": 19, + "reservoir": 14, + "stopped_leaf": 252 + }, + "power_checkpoints": [ + { + "log2_input": 14000000000000, + "powers": { + "alpha": { + "exponent": 728862973, + "rhs": 112000000153728, + "rhs_bits": 47 + }, + "compact": { + "exponent": 728862973, + "rhs": 448000000614848, + "rhs_bits": 49 + }, + "leaf": { + "exponent": 666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 728862973, + "rhs": 224000000307384, + "rhs_bits": 48 + }, + "rows": { + "exponent": 728862973, + "rhs": 112000000153728000, + "rhs_bits": 57 + } + } + }, + { + "log2_input": 28000000000000, + "powers": { + "alpha": { + "exponent": 1457725947, + "rhs": 224000000153728, + "rhs_bits": 48 + }, + "compact": { + "exponent": 1457725947, + "rhs": 896000000614848, + "rhs_bits": 50 + }, + "leaf": { + "exponent": 1333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 1457725947, + "rhs": 448000000307384, + "rhs_bits": 49 + }, + "rows": { + "exponent": 1457725947, + "rhs": 224000000153728000, + "rhs_bits": 58 + } + } + }, + { + "log2_input": 56000000000000, + "powers": { + "alpha": { + "exponent": 2915451895, + "rhs": 448000000153728, + "rhs_bits": 49 + }, + "compact": { + "exponent": 2915451895, + "rhs": 1792000000614848, + "rhs_bits": 51 + }, + "leaf": { + "exponent": 2666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 2915451895, + "rhs": 896000000307384, + "rhs_bits": 50 + }, + "rows": { + "exponent": 2915451895, + "rhs": 448000000153728000, + "rhs_bits": 59 + } + } + }, + { + "log2_input": 112000000000000, + "powers": { + "alpha": { + "exponent": 5830903790, + "rhs": 896000000153728, + "rhs_bits": 50 + }, + "compact": { + "exponent": 5830903790, + "rhs": 3584000000614848, + "rhs_bits": 52 + }, + "leaf": { + "exponent": 5333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 5830903790, + "rhs": 1792000000307384, + "rhs_bits": 51 + }, + "rows": { + "exponent": 5830903790, + "rhs": 896000000153728000, + "rhs_bits": 60 + } + } + }, + { + "log2_input": 224000000000000, + "powers": { + "alpha": { + "exponent": 11661807580, + "rhs": 1792000000153728, + "rhs_bits": 51 + }, + "compact": { + "exponent": 11661807580, + "rhs": 7168000000614848, + "rhs_bits": 53 + }, + "leaf": { + "exponent": 10666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 11661807580, + "rhs": 3584000000307384, + "rhs_bits": 52 + }, + "rows": { + "exponent": 11661807580, + "rhs": 1792000000153728000, + "rhs_bits": 61 + } + } + }, + { + "log2_input": 448000000000000, + "powers": { + "alpha": { + "exponent": 23323615160, + "rhs": 3584000000153728, + "rhs_bits": 52 + }, + "compact": { + "exponent": 23323615160, + "rhs": 14336000000614848, + "rhs_bits": 54 + }, + "leaf": { + "exponent": 21333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 23323615160, + "rhs": 7168000000307384, + "rhs_bits": 53 + }, + "rows": { + "exponent": 23323615160, + "rhs": 3584000000153728000, + "rhs_bits": 62 + } + } + } + ], + "practical_runtime_claim": false + }, + "finite_bridge": { + "bit": { + "W": 133224855, + "halving_degree": 9, + "m": 575, + "maxchild": 529, + "wire_bits": 27 + }, + "complex": { + "W": 537696432, + "halving_degree": 20, + "m": 784, + "maxchild": 756, + "s": 421548223824, + "scalar_group_upper": 4793351472, + "scalar_terms": [ + { + "c": 78437, + "copied_center_extra_groups": 56, + "h": 28, + "invocations": 3276, + "local_group_upper": 729892, + "v": 3276 + }, + { + "c": 78437, + "copied_center_extra_groups": 56, + "h": 28, + "invocations": 3276, + "local_group_upper": 729892, + "v": 3276 + } + ], + "wire_bits": 30 + }, + "rows": { + "coefficient": 843, + "contract": "W_complex^D_complex * W_bit^D_bit; one preceding prefix and padding; all temporary copies sequential", + "degree": 2000, + "degree_gap": "7007/25", + "suffix_slope": 8000 + }, + "semantic": { + "B": 9696565176891520488614054257040, + "C0": 2358858462850846165593256368932965330169899180021667007021321420800, + "C1": 1, + "E": 9696565176891520488192506033216, + "induction_gap": 533311084729033626873772984137200, + "literal_charge": 2771683137698171397039558468, + "strict_literal_gap": 9693793493753822316795466474748 + } + }, + "kappa": "52062354654791/1000000000000000000", + "next_bit_saving": "52065065284843/1000000000000000000", + "next_kappa_rejection": "{'g3_above_kappa': '-777311878098946637938372653/4464518147612878294061917099625000000000000000'}", + "rejected_moment": { + "lower": "4163276718750000001154395285263690664210433893471/4163276718750000000000000000000000000000000000000", + "saving": "52065065284843/1000000000000000000", + "strict_gap": "-1847032456421905409577082461299/6661242750000000000000000000000000000000000000000", + "terms": { + "1": { + "log_lower": "3177185020398675220004135749131/500000000000000000000000000000", + "log_upper": "6354370040797350440008271498263/1000000000000000000000000000000", + "weight": "77189632/3330621375" + }, + "10": { + "log_lower": "2025892473901652377995140021789/500000000000000000000000000000", + "log_upper": "4051784947803304755990280043579/1000000000000000000000000000000", + "weight": "161972/133224855" + }, + "11": { + "log_lower": "3956474767998979895946327920297/1000000000000000000000000000000", + "log_upper": "1978237383999489947973163960149/500000000000000000000000000000", + "weight": "2842444/3330621375" + }, + "12": { + "log_lower": "3869463391009350129778562018423/1000000000000000000000000000000", + "log_upper": "483682923876168766222320252303/125000000000000000000000000000", + "weight": "1084228/1110207125" + }, + "13": { + "log_lower": "3789420683335813703954784056697/1000000000000000000000000000000", + "log_upper": "1894710341667906851977392028349/500000000000000000000000000000", + "weight": "703326/1110207125" + }, + "14": { + "log_lower": "3715312711182091825485686633361/1000000000000000000000000000000", + "log_upper": "1857656355591045912742843316681/500000000000000000000000000000", + "weight": "2212322/3330621375" + }, + "15": { + "log_lower": "3646319839695140374012266928113/1000000000000000000000000000000", + "log_upper": "1823159919847570187006133464057/500000000000000000000000000000", + "weight": "99327/222041425" + }, + "16": { + "log_lower": "3581781318557569202339343012429/1000000000000000000000000000000", + "log_upper": "358178131855756920233934301243/100000000000000000000000000000", + "weight": "1242448/3330621375" + }, + "17": { + "log_lower": "3521156696741134359758736880389/1000000000000000000000000000000", + "log_upper": "352115669674113435975873688039/100000000000000000000000000000", + "weight": "2294813/1110207125" + }, + "18": { + "log_lower": "3463998282901185747800548902959/1000000000000000000000000000000", + "log_upper": "43299978536264821847506861287/12500000000000000000000000000", + "weight": "180852/1110207125" + }, + "19": { + "log_lower": "1704965530815454989999622033187/500000000000000000000000000000", + "log_upper": "27279448493047279839993952531/8000000000000000000000000000", + "weight": "73663/1110207125" + }, + "2": { + "log_lower": "1415305715059351282647759844201/250000000000000000000000000000", + "log_upper": "1132244572047481026118207875361/200000000000000000000000000000", + "weight": "8267828/3330621375" + }, + "20": { + "log_lower": "83965944181083986164326198053/25000000000000000000000000000", + "log_upper": "3358637767243359446573047922121/1000000000000000000000000000000", + "weight": "8316/222041425" + }, + "21": { + "log_lower": "413730950384240930438459189737/125000000000000000000000000000", + "log_upper": "3309847603073927443507673517897/1000000000000000000000000000000", + "weight": "8652/1930795" + }, + "22": { + "log_lower": "3263327587439034586529095798839/1000000000000000000000000000000", + "log_upper": "81583189685975864663227394971/25000000000000000000000000000", + "weight": "1694/666124275" + }, + "23": { + "log_lower": "804718956217050187300379666613/250000000000000000000000000000", + "log_upper": "3218875824868200749201518666453/1000000000000000000000000000000", + "weight": "122417/5792385" + }, + "25": { + "log_lower": "313549421592914969080675283181/100000000000000000000000000000", + "log_upper": "3135494215929149690806752831811/1000000000000000000000000000000", + "weight": "182259/8881657" + }, + "3": { + "log_lower": "262787887606462037430651313067/50000000000000000000000000000", + "log_upper": "5255757752129240748613026261341/1000000000000000000000000000000", + "weight": "1698567/1110207125" + }, + "4": { + "log_lower": "2484037839838729910586903627673/500000000000000000000000000000", + "log_upper": "4968075679677459821173807255347/1000000000000000000000000000000", + "weight": "4806424/3330621375" + }, + "481": { + "log_lower": "35700554138317851917337677133/200000000000000000000000000000", + "log_upper": "89251385345794629793344192833/500000000000000000000000000000", + "weight": "296296/5792385" + }, + "5": { + "log_lower": "1186233032090812516351878041259/250000000000000000000000000000", + "log_upper": "4744932128363250065407512165037/1000000000000000000000000000000", + "weight": "675734/666124275" + }, + "525": { + "log_lower": "22742944551431673576538712861/250000000000000000000000000000", + "log_upper": "18194355641145338861230970289/200000000000000000000000000000", + "weight": "3827439/8881657" + }, + "529": { + "log_lower": "41690804469525529197382917321/500000000000000000000000000000", + "log_upper": "83381608939051058394765834643/1000000000000000000000000000000", + "weight": "2487956/5792385" + }, + "6": { + "log_lower": "4562610571569295439195794139881/1000000000000000000000000000000", + "log_upper": "2281305285784647719597897069941/500000000000000000000000000000", + "weight": "1672156/1110207125" + }, + "7": { + "log_lower": "4408459891742037134902918754819/1000000000000000000000000000000", + "log_upper": "220422994587101856745145937741/50000000000000000000000000000", + "weight": "3915968/3330621375" + }, + "8": { + "log_lower": "66795757798711164246196486467/15625000000000000000000000000", + "log_upper": "4274928499117514511756575133889/1000000000000000000000000000000", + "weight": "4853632/3330621375" + }, + "9": { + "log_lower": "4157145463461131057217781024417/1000000000000000000000000000000", + "log_upper": "2078572731730565528608890512209/500000000000000000000000000000", + "weight": "1046784/1110207125" + } + }, + "upper": "6661242750000000001847032456421905409577082461299/6661242750000000000000000000000000000000000000000" + }, + "status": "Finite conditional witness; inherited all-size and analytic interfaces remain assumptions" +} diff --git a/research/balanced-split-reclamation/selected/compiled-23.json b/research/balanced-split-reclamation/selected/compiled-23.json new file mode 100644 index 0000000000..73aeddeae4 --- /dev/null +++ b/research/balanced-split-reclamation/selected/compiled-23.json @@ -0,0 +1,53 @@ +{ + "all_physical_frame_inclusions": true, + "baseline_pr48_roles": 36432, + "complete_dirty_basis_both_orientations": true, + "dirty_basis_vectors": 30585, + "elementary_xors": 167165, + "h": 23, + "histogram": { + "0": 335367, + "1": 58286, + "10": 556, + "11": 101, + "12": 688, + "13": 185, + "14": 1878, + "15": 308, + "16": 424, + "17": 540, + "18": 3197, + "19": 6485, + "2": 81025, + "21": 372, + "22": 23, + "3": 10007, + "4": 14585, + "5": 6593, + "6": 2035, + "7": 425, + "8": 1121, + "9": 377 + }, + "mode": { + "matching": true, + "reclaim": true + }, + "rank_mass": 622495, + "roles": 27043, + "stats": { + "augmentations": 58, + "carried_signal_exchanges": 842, + "clearing_xors": 5295, + "exchange_entropy_gain_1e30": 2918796908023380940894383354045136, + "exchange_profile_pairs": 262461, + "live_anchor_candidates": 73287, + "live_anchor_xors": 684, + "matched": 41730, + "multi_node_regions": 8694, + "reclaimed": 2367, + "regions": 59801, + "two_region_exchange_cycles": 113, + "two_region_exchange_paths": 0 + } +} diff --git a/research/balanced-split-reclamation/selected/compiled-25.json b/research/balanced-split-reclamation/selected/compiled-25.json new file mode 100644 index 0000000000..d73d1c2893 --- /dev/null +++ b/research/balanced-split-reclamation/selected/compiled-25.json @@ -0,0 +1,55 @@ +{ + "all_physical_frame_inclusions": true, + "baseline_pr48_roles": 48329, + "complete_dirty_basis_both_orientations": true, + "dirty_basis_vectors": 40105, + "elementary_xors": 233668, + "h": 25, + "histogram": { + "0": 467968, + "1": 77042, + "10": 861, + "11": 25, + "12": 737, + "13": 162, + "14": 670, + "15": 165, + "16": 2222, + "17": 599, + "18": 545, + "19": 904, + "2": 118319, + "20": 4230, + "21": 8483, + "23": 420, + "24": 25, + "3": 13351, + "4": 18573, + "5": 8684, + "6": 3245, + "7": 704, + "8": 1214, + "9": 584 + }, + "mode": { + "matching": true, + "reclaim": true + }, + "rank_mass": 888225, + "roles": 35505, + "stats": { + "augmentations": 85, + "carried_signal_exchanges": 1299, + "clearing_xors": 7689, + "exchange_entropy_gain_1e30": 11955833648306026504727579289297100, + "exchange_profile_pairs": 409601, + "live_anchor_candidates": 99482, + "live_anchor_xors": 1249, + "matched": 60971, + "multi_node_regions": 11575, + "reclaimed": 3442, + "regions": 84843, + "two_region_exchange_cycles": 86, + "two_region_exchange_paths": 0 + } +} diff --git a/research/balanced-split-reclamation/selected/config-23.json b/research/balanced-split-reclamation/selected/config-23.json new file mode 100644 index 0000000000..2274aa0970 --- /dev/null +++ b/research/balanced-split-reclamation/selected/config-23.json @@ -0,0 +1,11 @@ +{ + "completion": "future", + "enlarge": 0, + "horizon": "next-use", + "live": true, + "live_order": "insertion", + "oracle_permutation": null, + "order": "cover-core", + "retired_order": "rank", + "weight": "entropy" +} diff --git a/research/balanced-split-reclamation/selected/config-25.json b/research/balanced-split-reclamation/selected/config-25.json new file mode 100644 index 0000000000..4ae064c8cf --- /dev/null +++ b/research/balanced-split-reclamation/selected/config-25.json @@ -0,0 +1,37 @@ +{ + "completion": "future", + "enlarge": 0, + "horizon": "next-use", + "live": true, + "live_order": "cost", + "oracle_permutation": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 0 + ], + "order": "reverse-node", + "retired_order": "cost", + "weight": "entropy" +} diff --git a/research/balanced-split-reclamation/selected/profile-23.json b/research/balanced-split-reclamation/selected/profile-23.json new file mode 100644 index 0000000000..32633f570d --- /dev/null +++ b/research/balanced-split-reclamation/selected/profile-23.json @@ -0,0 +1,38 @@ +{ + "R": 27043, + "blocks": [ + 0, + 354775, + 21718, + 6767, + 6566, + 3029, + 4269, + 2351, + 3255, + 1438, + 2055, + 1004, + 1370, + 562, + 734, + 338, + 323, + 145, + 112, + 37, + 0, + 23, + 0, + 0 + ], + "crt_disagreements": 0, + "crt_matrices": 5527, + "distinct_matrices": 38099, + "field_prime": 2305843009213693951, + "frames": 59803, + "h": 23, + "loss": 506, + "rank_sum": 622495, + "v": 1771 +} diff --git a/research/balanced-split-reclamation/selected/profile-25.json b/research/balanced-split-reclamation/selected/profile-25.json new file mode 100644 index 0000000000..3ae96189a8 --- /dev/null +++ b/research/balanced-split-reclamation/selected/profile-25.json @@ -0,0 +1,40 @@ +{ + "R": 35505, + "blocks": [ + 0, + 488816, + 25482, + 13271, + 7078, + 4842, + 5314, + 4212, + 3652, + 2664, + 2590, + 2052, + 1741, + 1378, + 1099, + 851, + 589, + 471, + 246, + 103, + 81, + 0, + 5, + 25, + 0, + 0 + ], + "crt_disagreements": 0, + "crt_matrices": 7270, + "distinct_matrices": 50803, + "field_prime": 2305843009213693951, + "frames": 84845, + "h": 25, + "loss": 600, + "rank_sum": 888225, + "v": 2300 +} diff --git a/research/balanced-split-reclamation/selected/replay-23.json b/research/balanced-split-reclamation/selected/replay-23.json new file mode 100644 index 0000000000..28021096fd --- /dev/null +++ b/research/balanced-split-reclamation/selected/replay-23.json @@ -0,0 +1,34 @@ +{ + "elementary_xors": 167165, + "full_basis_vectors": 30585, + "h": 23, + "histogram": { + "0": 184605, + "1": 58286, + "10": 556, + "11": 101, + "12": 688, + "13": 185, + "14": 1878, + "15": 308, + "16": 424, + "17": 540, + "18": 3197, + "19": 6485, + "2": 81025, + "21": 372, + "22": 23, + "3": 10007, + "4": 14585, + "5": 6593, + "6": 2035, + "7": 425, + "8": 1121, + "9": 377 + }, + "output_roles": 5336, + "rank_mass": 622495, + "roles": 27043, + "status": "independent serialized word, exact frames, full input and dirty basis both orientations PASS", + "word_length": 693454 +} diff --git a/research/balanced-split-reclamation/selected/replay-25.json b/research/balanced-split-reclamation/selected/replay-25.json new file mode 100644 index 0000000000..ce371e9c24 --- /dev/null +++ b/research/balanced-split-reclamation/selected/replay-25.json @@ -0,0 +1,36 @@ +{ + "elementary_xors": 233668, + "full_basis_vectors": 40105, + "h": 25, + "histogram": { + "0": 257227, + "1": 77042, + "10": 861, + "11": 25, + "12": 737, + "13": 162, + "14": 670, + "15": 165, + "16": 2222, + "17": 599, + "18": 545, + "19": 904, + "2": 118319, + "20": 4230, + "21": 8483, + "23": 420, + "24": 25, + "3": 13351, + "4": 18573, + "5": 8684, + "6": 3245, + "7": 704, + "8": 1214, + "9": 584 + }, + "output_roles": 6925, + "rank_mass": 888225, + "roles": 35505, + "status": "independent serialized word, exact frames, full input and dirty basis both orientations PASS", + "word_length": 966872 +} diff --git a/research/balanced-split-reclamation/selected/transitions-23.json b/research/balanced-split-reclamation/selected/transitions-23.json new file mode 100644 index 0000000000..0b5aaf4381 --- /dev/null +++ b/research/balanced-split-reclamation/selected/transitions-23.json @@ -0,0 +1,35 @@ +{ + "R": 27043, + "copied_centers": 23, + "distinct_transitions": 151993, + "frames": 59803, + "h": 23, + "rank_histogram_with_side_growth_split_into_singletons": { + "1": 68912, + "10": 556, + "11": 101, + "12": 688, + "13": 185, + "14": 1878, + "15": 308, + "16": 424, + "17": 540, + "18": 3197, + "19": 6485, + "2": 75712, + "21": 372, + "22": 23, + "3": 10007, + "4": 14585, + "5": 6593, + "6": 2035, + "7": 425, + "8": 1121, + "9": 377 + }, + "rank_mass": 622495, + "singles": 15939, + "transition_events_equal_independent_xor_word_reconstruction": true, + "v": 1771, + "word_sha256": "1fa8677dd672a1aef9fd14ede6c912bc6f9bd75439a79548c8f7ad0e3697abc2" +} diff --git a/research/balanced-split-reclamation/selected/transitions-25.json b/research/balanced-split-reclamation/selected/transitions-25.json new file mode 100644 index 0000000000..bfaaa5be40 --- /dev/null +++ b/research/balanced-split-reclamation/selected/transitions-25.json @@ -0,0 +1,37 @@ +{ + "R": 35505, + "copied_centers": 25, + "distinct_transitions": 211996, + "frames": 84845, + "h": 25, + "rank_histogram_with_side_growth_split_into_singletons": { + "1": 90842, + "10": 861, + "11": 25, + "12": 737, + "13": 162, + "14": 670, + "15": 165, + "16": 2222, + "17": 599, + "18": 545, + "19": 904, + "2": 111419, + "20": 4230, + "21": 8483, + "23": 420, + "24": 25, + "3": 13351, + "4": 18573, + "5": 8684, + "6": 3245, + "7": 704, + "8": 1214, + "9": 584 + }, + "rank_mass": 888225, + "singles": 20700, + "transition_events_equal_independent_xor_word_reconstruction": true, + "v": 2300, + "word_sha256": "1421c94f7699a6dfccb184f13fa85f41f79415927e1279de5cd2d14e50535b5e" +} diff --git a/research/balanced-split-reclamation/selected/word-23.json.gz b/research/balanced-split-reclamation/selected/word-23.json.gz new file mode 100644 index 0000000000..93df120f25 Binary files /dev/null and b/research/balanced-split-reclamation/selected/word-23.json.gz differ diff --git a/research/balanced-split-reclamation/selected/word-25.json.gz b/research/balanced-split-reclamation/selected/word-25.json.gz new file mode 100644 index 0000000000..4f5f65879d Binary files /dev/null and b/research/balanced-split-reclamation/selected/word-25.json.gz differ diff --git a/research/balanced-split-reclamation/support.py b/research/balanced-split-reclamation/support.py new file mode 100644 index 0000000000..42b3ce4135 --- /dev/null +++ b/research/balanced-split-reclamation/support.py @@ -0,0 +1,54 @@ +"""Shared paths and serialization for the balanced split witness.""" +import sys +if sys.flags.optimize: + raise ValueError('Assertions must remain enabled') +sys.dont_write_bytecode = True +import importlib.util +import json +from pathlib import Path +from fractions import Fraction + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SELECTED = HERE/'selected' +EXP = ROOT/'scripts/experiments' +sys.path.insert(0, str(EXP)) + + +def load(path, name): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def json_value(value): + if isinstance(value, Fraction): + return str(value) + if isinstance(value, dict): + return {str(k): json_value(v) for k, v in value.items()} + if isinstance(value, (list, tuple)): + return [json_value(v) for v in value] + return value + + +def write_json(path, value): + Path(path).write_text(json.dumps(json_value(value), indent=2, sort_keys=True)+'\n') + + +def config(h): + if type(h) is not int or h not in (23, 25): + raise ValueError('Only h=23 and h=25 are certified') + return dict(order='cover-core' if h == 23 else 'reverse-node', + horizon='next-use', live_order='insertion' if h == 23 else 'cost', weight='entropy', + live=True, completion='future', retired_order='rank' if h == 23 else 'cost', + oracle_permutation=None if h == 23 else permutation(h), enlarge=0) + + +def permutation(h): + if h == 23: + order = [1, 3, 2, *range(4, 20), 21, 20, 22, 0] + return [order.index(i) for i in range(h)] + if h == 25: + return [(i+1) % h for i in range(h)] + raise ValueError('Unsupported coordinate permutation') diff --git a/research/balanced-split-reclamation/test_witness.py b/research/balanced-split-reclamation/test_witness.py new file mode 100644 index 0000000000..964557a696 --- /dev/null +++ b/research/balanced-split-reclamation/test_witness.py @@ -0,0 +1,113 @@ +"""Failure modes of the concrete finite certificate and its literal interface.""" +from copy import deepcopy +from hashlib import sha256 +from fractions import Fraction as Q +import gzip +import json +import subprocess +import sys +import unittest +from support import HERE, SELECTED +import arithmetic +import verify + + +class WitnessTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.word = json.loads(gzip.decompress((SELECTED/'word-23.json.gz').read_bytes())) + cls.cert = json.loads((SELECTED/'certificate.json').read_text()) + + def test_selected_literal_ports(self): + verify.validate_word(self.word) + + def test_negative_role_alias(self): + bad = deepcopy(self.word) + bad['ops'][0][0] = -1 + with self.assertRaises(ValueError): + verify.validate_word(bad) + + def test_negative_frame_alias(self): + bad = deepcopy(self.word) + bad['ops'][0][2] = -1 + with self.assertRaises(ValueError): + verify.validate_word(bad) + + def test_aliased_source(self): + bad = deepcopy(self.word) + bad['sources']['0'] = bad['sources']['1'] + with self.assertRaises(ValueError): + verify.validate_word(bad) + + def test_unpaid_canceling_scatter(self): + bad = deepcopy(self.word) + bad['scatter'].extend([bad['scatter'][0], bad['scatter'][0]]) + with self.assertRaises(ValueError): + verify.validate_word(bad) + + def test_wrong_scatter_destination(self): + bad = deepcopy(self.word) + bad['scatter'][0][0] += 1 + with self.assertRaises(ValueError): + verify.validate_word(bad) + + def test_understated_width(self): + bad = deepcopy(self.word) + bad['R'] -= 1 + with self.assertRaises(ValueError): + verify.validate_word(bad) + + def test_omitted_paid_child(self): + bad = deepcopy(self.cert['bit']) + bad['child_multiplicities']['1'] -= 1 + with self.assertRaises(AssertionError): + arithmetic.moment(bad, Q(self.cert['bit_saving'])) + + def test_exact_accepted_and_rejected_grid(self): + accepted = arithmetic.independent_moment(self.cert['bit'], Q(self.cert['bit_saving'])) + rejected = arithmetic.independent_moment(self.cert['bit'], Q(self.cert['next_bit_saving'])) + self.assertLess(accepted[1], 1) + self.assertGreater(rejected[0], 1) + + def test_complete_predecessor_is_excluded(self): + old = json.loads((HERE/'vendor/pr82-certificate.json').read_text())['bit'] + self.assertGreater(arithmetic.independent_moment(old, Q(self.cert['bit_saving']))[0], 1) + + def test_float_saving_rejected(self): + with self.assertRaises(AssertionError): + arithmetic.moment(self.cert['bit'], float(Q(self.cert['bit_saving']))) + + def test_optimized_python_rejected(self): + result = subprocess.run([sys.executable, '-O', str(HERE/'verify.py')], capture_output=True, text=True) + self.assertNotEqual(result.returncode, 0) + self.assertIn('Assertions must remain enabled', result.stderr) + + def test_commuting_scatter_order(self): + changed = deepcopy(self.word) + changed['scatter'].reverse() + verify.validate_word(changed) + + def reject_stale_bridge(self, section, key, value): + bridge = arithmetic.bridge_for(self.cert['bit']) + bridge[section][key] = value + with self.assertRaises(arithmetic.balanced.InvalidAssembly): + arithmetic.balanced.assembly(bridge, Q(self.cert['bit_saving']), Q(self.cert['kappa']), h=arithmetic.BACKOFF) + + def test_stale_wire_bits(self): + self.reject_stale_bridge('bit', 'wire_bits', 28) + + def test_stale_row_coefficient(self): + self.reject_stale_bridge('rows', 'coefficient', 852) + + def test_stale_degree_gap(self): + self.reject_stale_bridge('rows', 'degree_gap', Q(6548, 25)) + + def test_pin_help_does_not_refresh_sources(self): + before = sha256((HERE/'SOURCE.json').read_bytes()).hexdigest() + result = subprocess.run([sys.executable, str(HERE/'pin.py'), '--help'], capture_output=True, text=True) + self.assertEqual(result.returncode, 0) + self.assertEqual(before, sha256((HERE/'SOURCE.json').read_bytes()).hexdigest()) + + +if __name__ == '__main__': + unittest.main() diff --git a/research/balanced-split-reclamation/vendor/pr68-compiler.py b/research/balanced-split-reclamation/vendor/pr68-compiler.py new file mode 100644 index 0000000000..d10a33b5a6 --- /dev/null +++ b/research/balanced-split-reclamation/vendor/pr68-compiler.py @@ -0,0 +1,275 @@ +# Live-anchor composition of PR67 all-rank cost selection with PR68. +# Dominik Scholz with substantial OpenAI GPT-6 Astra assistance. +# All-rank profile-cost selection: Rohan Arun, with OpenAI Codex assistance. +# Derived from Dominik Scholz PR63, Chafik Boukhalfa PR60, Avi Eisenberg PR62 +# and eumemic PR57. Apache-2.0; all inherited notices remain applicable. +"""Exact-envelope block synthesis on the pinned PR48 scalar graph. +Experimental finite compiler; no fixed-I+J profile or multiplication claim. +""" +# Derived from eumemic's PR57 compiler; original notices remain applicable. +# Descending-rank reclamation priority: Chafik Boukhalfa, with OpenAI Codex assistance. +import sys +if sys.flags.optimize: + raise ValueError('Assertions must remain enabled') +sys.dont_write_bytecode=True +from pathlib import Path +ROOT=Path(__file__).resolve().parents[2]/'references/frame-compiler/pr48' +from hashlib import sha256 +import json +manifest=json.loads((ROOT/'SOURCE.json').read_text()) +for name,digest in manifest['files'].items(): + assert sha256((ROOT/name).read_bytes()).hexdigest()==digest, 'Changed producer source: '+name +sys.path[:0]=[str(ROOT/'scripts'),str(ROOT/'research/copied-fixed')] +from changed_graph import graph +from collections import defaultdict,Counter,deque +import argparse,json,time,struct + +def independent(rows,vec): + for row in rows: + vec=min(vec,vec^row) + return bool(vec) +def basis(rows): + out=[] + for vec in rows: + for row in out:vec=min(vec,vec^row) + if vec:out.append(vec) + return out + +def build(h): + c=graph(h);groups={};owner={};signal={};blocks=[] + for x in sorted(c.active): + key=(c.core[x],c.union[x]) + if key not in groups: + groups[key]=len(blocks);blocks.append(dict(nodes=[],frame=key,inputs=set(),uses=[])) + g=groups[key];owner[x]=g;blocks[g]['nodes'].append(x) + signal[x]=(signal[c.args[x][0]]^signal[c.args[x][1]])if c.args[x]else 1<<(x-1) + for x in sorted(c.active): + for y in c.args[x]or(): + if owner[y]!=owner[x]:blocks[owner[x]]['inputs'].add(y) + uses=[];value_uses=defaultdict(list) + for g,b in enumerate(blocks): + b['inputs']=sorted(b['inputs']);b['source']=not c.args[b['nodes'][0]] + for y in b['inputs']: + k=len(uses);uses.append((y,g,None));value_uses[y].append(k);blocks[owner[y]]['uses'].append(k) + for target,x in c.outputs.items(): + k=len(uses);uses.append((x,owner[x],target));value_uses[x].append(k);blocks[owner[x]]['uses'].append(k) + for g,b in enumerate(blocks): + b['rank']=1 if b['source']else b['frame'][1].bit_count()-b['frame'][0].bit_count() + order=sorted(range(len(blocks)),key=lambda g:(blocks[g]['rank'],min(blocks[g]['nodes']))) + place={g:i for i,g in enumerate(order)} + def contained(a,b):return not(b[0]&~a[0])and not(a[1]&~b[1]) + for g,b in enumerate(blocks): + coeff={y:1<1 for b in blocks) + def new(g): + s=len(slots);slots.append(0);frames.append(g);hist[blocks[g]['rank']]+=1;events.append((s,-1,g));return s + def raise_(s,g): + old=frames[s];assert contains(blocks[old]['frame'],blocks[g]['frame']);hist[blocks[g]['rank']-blocks[old]['rank']]+=1;frames[s]=g;events.append((s,old,g)) + def xor(a,b,g): + assert a!=b;raise_(a,g);raise_(b,g);slots[a]^=slots[b];ops.append((a,b,g)) + import subprocess,struct + from binary_frame_math import logs + # Integer midpoint enclosures give a reproducible discovery score. + # Every candidate is independently checked by the complete exact screen. + weights=[0]+[int(t*sum(logs(t))*10**30//2) for t in range(1,h+1)] + oracle_input=Path(ORACLE_INPUT) + with oracle_input.open('wb') as stream: + stream.write(struct.pack('<6I2Q',h,v,0,len(blocks)+2,0,0,h*(h-1),h*(h-1))) + stream.write(struct.pack('<2QI',0,0,0));stream.write(struct.pack('<2QI',0,0,h)) + for b in blocks:stream.write(struct.pack('<2QI',*b['frame'],b['rank'])) + oracle=subprocess.Popen([ORACLE_EXE,str(oracle_input)],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True,bufsize=1) + oracles.append(oracle) + cache={} + def profile_entropy(a,b): + if (a,b) not in cache: + oracle.stdin.write(f'{a} {b}\n');oracle.stdin.flush() + answer=oracle.stdout.readline() + assert answer, 'profile oracle failed' + parts=list(map(int,answer.split()));assert len(parts)==h+1 + cache[a,b]=sum(n*w for n,w in zip(parts,weights)) + return cache[a,b] + def profile_cost(a,g): + old=frames[a]+2;target=g+2 + return profile_entropy(old,1)-profile_entropy(old,target)-profile_entropy(target,1) + def acquire(g,anchors): + if reclaim: + bb={} + def ins(s): + row=slots[s];expr=1<>s&1;e^=1<>i&1) + if j!=i: + # Synthesize swap as three XORs at the single common frame. + for a,z in ((i,j),(j,i),(i,j)):rr[a]^=rr[z];elim.append((a,z)) + for j in range(len(ins)): + if j!=i and rr[j]>>i&1:rr[j]^=rr[i];elim.append((j,i)) + assert rr==[1<>i&1:xor(s,value_slots[y],g) + assert slots[s]==signal[x];value_slots[x]=s + used=set() + for u in outuses: + x=uses[u][0];s=value_slots[x] + if x in used: + ss=acquire(g,list(value_slots.values()));xor(ss,s,g);s=ss + used.add(x);assert u not in assign;assign[u]=s;assert s not in pending;pending[s]=uses[u][1] + if step%5000==0:print('compile',h,step,len(slots),'reclaimed',stats['reclaimed'],'seconds',time.time()-t0,flush=True,file=sys.stderr) + output_slots=[];output_records=[];scatter=[0]*v;J=[] + for u,(x,g,target)in enumerate(uses): + if target is None:continue + s=assign[u];assert slots[s]==signal[x];raise_(s,g);output_slots.append(s) + common,triple=target;output_records.append((s,g,common,triple)) + targets=[i for i,t in enumerate(c.inputs)if common in t]if len(triple)==1 else[c.inputs.index(triple)] + for i in targets:scatter[i]^=slots[s];J.append((v+i,2*v+s)) + rank=blocks[g]['rank'] + if len(triple)==1:hist[rank]+=1;hist[h-rank]+=1 + else:hist[h-1-rank]+=1;hist[1]+=1 + assert len(set(output_slots))==len(output_slots) + for s in retired:hist[h-blocks[frames[s]]['rank']]+=1 + assert len(retired)+len(output_slots)==len(slots) + assert scatter==[1<= j+1 proves persistence.", + "common_cutoff": 14000000000000, + "cutoff_log2_input": { + "alpha": 6052840001, + "compact": 24211360001, + "geometry": 3999931448325, + "guard": 4317837, + "log_p": 25, + "normalization": 14000000000000, + "period": 48422720001, + "phase_cell": 19, + "reservoir": 14, + "stopped_leaf": 252 + }, + "power_checkpoints": [ + { + "log2_input": 14000000000000, + "powers": { + "alpha": { + "exponent": 719794344, + "rhs": 112000000155664, + "rhs_bits": 47 + }, + "compact": { + "exponent": 719794344, + "rhs": 448000000622592, + "rhs_bits": 49 + }, + "leaf": { + "exponent": 666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 719794344, + "rhs": 224000000311256, + "rhs_bits": 48 + }, + "rows": { + "exponent": 719794344, + "rhs": 112000000155664000, + "rhs_bits": 57 + } + } + }, + { + "log2_input": 28000000000000, + "powers": { + "alpha": { + "exponent": 1439588688, + "rhs": 224000000155664, + "rhs_bits": 48 + }, + "compact": { + "exponent": 1439588688, + "rhs": 896000000622592, + "rhs_bits": 50 + }, + "leaf": { + "exponent": 1333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 1439588688, + "rhs": 448000000311256, + "rhs_bits": 49 + }, + "rows": { + "exponent": 1439588688, + "rhs": 224000000155664000, + "rhs_bits": 58 + } + } + }, + { + "log2_input": 56000000000000, + "powers": { + "alpha": { + "exponent": 2879177377, + "rhs": 448000000155664, + "rhs_bits": 49 + }, + "compact": { + "exponent": 2879177377, + "rhs": 1792000000622592, + "rhs_bits": 51 + }, + "leaf": { + "exponent": 2666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 2879177377, + "rhs": 896000000311256, + "rhs_bits": 50 + }, + "rows": { + "exponent": 2879177377, + "rhs": 448000000155664000, + "rhs_bits": 59 + } + } + }, + { + "log2_input": 112000000000000, + "powers": { + "alpha": { + "exponent": 5758354755, + "rhs": 896000000155664, + "rhs_bits": 50 + }, + "compact": { + "exponent": 5758354755, + "rhs": 3584000000622592, + "rhs_bits": 52 + }, + "leaf": { + "exponent": 5333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 5758354755, + "rhs": 1792000000311256, + "rhs_bits": 51 + }, + "rows": { + "exponent": 5758354755, + "rhs": 896000000155664000, + "rhs_bits": 60 + } + } + }, + { + "log2_input": 224000000000000, + "powers": { + "alpha": { + "exponent": 11516709511, + "rhs": 1792000000155664, + "rhs_bits": 51 + }, + "compact": { + "exponent": 11516709511, + "rhs": 7168000000622592, + "rhs_bits": 53 + }, + "leaf": { + "exponent": 10666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 11516709511, + "rhs": 3584000000311256, + "rhs_bits": 52 + }, + "rows": { + "exponent": 11516709511, + "rhs": 1792000000155664000, + "rhs_bits": 61 + } + } + }, + { + "log2_input": 448000000000000, + "powers": { + "alpha": { + "exponent": 23033419023, + "rhs": 3584000000155664, + "rhs_bits": 52 + }, + "compact": { + "exponent": 23033419023, + "rhs": 14336000000622592, + "rhs_bits": 54 + }, + "leaf": { + "exponent": 21333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 23033419023, + "rhs": 7168000000311256, + "rhs_bits": 53 + }, + "rows": { + "exponent": 23033419023, + "rhs": 3584000000155664000, + "rhs_bits": 62 + } + } + } + ], + "practical_runtime_claim": false + }, + "kappa": "5141463/100000000000", + "next_kappa": "642683/12500000000", + "next_kappa_rejection": "{'g1_above_kappa': '-5644626320470482027/2170250471527777554612500000000', 'g3_above_kappa': '-625190143359860766529/173620037722222204369000000000000', 'g5_above_kappa': '-35845288269697756153/11111682414222221079616000000000', 'g6_above_kappa': '-3786180882823330701649/1388960301777777634952000000000000'}" + }, + "comparison": { + "absolute_gain_pr67": "23805344989/62500000000000000", + "full_pr67_child_list_excluded_at_new_bit_saving": true, + "pr67_commit": "b3745601e947a94316bf25c2c6263d93c06e3364", + "pr67_complete_profile_exclusion_lower": "34287957494011363648350450392318916509349095499539/34287951500000000000000000000000000000000000000000", + "pr67_kappa": "10206752116843/200000000000000000", + "ratio_pr67": "51414646104039/51033760584215" + }, + "dependencies": { + "data_profile": "Unchanged inherited all-pairs data profile: 9 singletons +21+17+481; ten exact rational recoveries", + "geometry": "Unchanged fixed-I+J original-envelope projector and CRT formulas", + "producer": "PR62/63 interval pair assembly, selected split-pair partition and point permutation, PR65 schedules, PR67 profile-cost reclamation, PR68 pending live controls and selected next-use scoring; complete literal words", + "proof_scope": "Ordered affine residual compiler, all-size recursion, finite scalar overhead, routing, prime selection, exact recovery and fixed-tape/analytic transfer remain inherited. Arithmetic cutoffs are not full operational thresholds." + }, + "eventual_bounds": { + "additional_eventual_conditions": [ + "BHP prime threshold and distinct-prime packing", + "Fixed rational basis, eligible common prime and native table setup", + "Catalogue/descriptor domination, logarithm absorption, exact recovery" + ], + "all_interval_argument": "For [Z,Z+k), bound RHS at Z+k and LHS at floor(Z/k). Successive intervals double LHS; the positive affine RHS grows at most linearly, so 2^j >= j+1 proves persistence.", + "common_cutoff": 14000000000000, + "cutoff_log2_input": { + "alpha": 6052840001, + "compact": 24211360001, + "geometry": 3999931448313, + "guard": 4317836, + "log_p": 25, + "normalization": 14000000000000, + "period": 48422720001, + "phase_cell": 19, + "reservoir": 14, + "stopped_leaf": 252 + }, + "power_checkpoints": [ + { + "log2_input": 14000000000000, + "powers": { + "alpha": { + "exponent": 719794344, + "rhs": 112000000155664, + "rhs_bits": 47 + }, + "compact": { + "exponent": 719794344, + "rhs": 448000000622592, + "rhs_bits": 49 + }, + "leaf": { + "exponent": 666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 719794344, + "rhs": 224000000311256, + "rhs_bits": 48 + }, + "rows": { + "exponent": 719794344, + "rhs": 112000000155664000, + "rhs_bits": 57 + } + } + }, + { + "log2_input": 28000000000000, + "powers": { + "alpha": { + "exponent": 1439588688, + "rhs": 224000000155664, + "rhs_bits": 48 + }, + "compact": { + "exponent": 1439588688, + "rhs": 896000000622592, + "rhs_bits": 50 + }, + "leaf": { + "exponent": 1333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 1439588688, + "rhs": 448000000311256, + "rhs_bits": 49 + }, + "rows": { + "exponent": 1439588688, + "rhs": 224000000155664000, + "rhs_bits": 58 + } + } + }, + { + "log2_input": 56000000000000, + "powers": { + "alpha": { + "exponent": 2879177377, + "rhs": 448000000155664, + "rhs_bits": 49 + }, + "compact": { + "exponent": 2879177377, + "rhs": 1792000000622592, + "rhs_bits": 51 + }, + "leaf": { + "exponent": 2666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 2879177377, + "rhs": 896000000311256, + "rhs_bits": 50 + }, + "rows": { + "exponent": 2879177377, + "rhs": 448000000155664000, + "rhs_bits": 59 + } + } + }, + { + "log2_input": 112000000000000, + "powers": { + "alpha": { + "exponent": 5758354755, + "rhs": 896000000155664, + "rhs_bits": 50 + }, + "compact": { + "exponent": 5758354755, + "rhs": 3584000000622592, + "rhs_bits": 52 + }, + "leaf": { + "exponent": 5333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 5758354755, + "rhs": 1792000000311256, + "rhs_bits": 51 + }, + "rows": { + "exponent": 5758354755, + "rhs": 896000000155664000, + "rhs_bits": 60 + } + } + }, + { + "log2_input": 224000000000000, + "powers": { + "alpha": { + "exponent": 11516709511, + "rhs": 1792000000155664, + "rhs_bits": 51 + }, + "compact": { + "exponent": 11516709511, + "rhs": 7168000000622592, + "rhs_bits": 53 + }, + "leaf": { + "exponent": 10666666666666, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 11516709511, + "rhs": 3584000000311256, + "rhs_bits": 52 + }, + "rows": { + "exponent": 11516709511, + "rhs": 1792000000155664000, + "rhs_bits": 61 + } + } + }, + { + "log2_input": 448000000000000, + "powers": { + "alpha": { + "exponent": 23033419023, + "rhs": 3584000000155664, + "rhs_bits": 52 + }, + "compact": { + "exponent": 23033419023, + "rhs": 14336000000622592, + "rhs_bits": 54 + }, + "leaf": { + "exponent": 21333333333333, + "rhs": 3136, + "rhs_bits": 12 + }, + "period": { + "exponent": 23033419023, + "rhs": 7168000000311256, + "rhs_bits": 53 + }, + "rows": { + "exponent": 23033419023, + "rhs": 3584000000155664000, + "rhs_bits": 62 + } + } + } + ], + "practical_runtime_claim": false + }, + "exactness": [ + { + "common_denominator_bound": 34848, + "correction_numerator_bound": 274032, + "h": 23, + "minor_bounds": { + "2": 38218181861376, + "3": 219993996697351151616, + "4": 1206074983422622280129445888 + }, + "modulus_gaps": { + "2": 2305804791031832575, + "3": 2596143476298113163849933497114623, + "4": 2596142270223349735224350718820351 + }, + "prime_product": 2596143476298333157846630848266239, + "primes": [ + 2305843009213693951, + 2147483647, + 524287 + ], + "single_numerator_bound": 6228 + }, + { + "common_denominator_bound": 44928, + "correction_numerator_bound": 353568, + "h": 25, + "minor_bounds": { + "2": 75405344477184, + "3": 613343016893987684352, + "4": 4772090401825349199521120256 + }, + "modulus_gaps": { + "2": 2305767603869216767, + "3": 2596143476297719814829736860581887, + "4": 2596138704207931332497431327145983 + }, + "prime_product": 2596143476298333157846630848266239, + "primes": [ + 2305843009213693951, + 2147483647, + 524287 + ], + "single_numerator_bound": 7366 + } + ], + "finite_bridge": { + "bit": { + "W": 135075665, + "halving_degree": 9, + "m": 575, + "maxchild": 529, + "wire_bits": 28 + }, + "complex": { + "W": 537696432, + "halving_degree": 20, + "m": 784, + "maxchild": 756, + "s": 421548223824, + "scalar_group_upper": 4793351472, + "scalar_terms": [ + { + "c": 78437, + "copied_center_extra_groups": 56, + "h": 28, + "invocations": 3276, + "local_group_upper": 729892, + "v": 3276 + }, + { + "c": 78437, + "copied_center_extra_groups": 56, + "h": 28, + "invocations": 3276, + "local_group_upper": 729892, + "v": 3276 + } + ], + "wire_bits": 30 + }, + "rows": { + "coefficient": 852, + "contract": "W_complex^D_complex * W_bit^D_bit; one preceding prefix and padding; all temporary copies sequential", + "degree": 2000, + "degree_gap": "6548/25", + "suffix_slope": 8000 + }, + "semantic": { + "B": 9696565176891520488614054257040, + "C0": 2358858462850846165593256368932965330169899180021667007021321420800, + "C1": 1, + "E": 9696565176891520488192506033216, + "induction_gap": 533311084729033626873772984137200, + "literal_charge": 2771683137698171397039558468, + "strict_literal_gap": 9693793493753822316795466474748 + } + }, + "grid_denominator": 1000000000000000000, + "independent_enclosures": { + "accepted_lower": "6753783249999999998880644770452946278125051932003/6753783250000000000000000000000000000000000000000", + "accepted_upper": "6753783249999999998880644770452946278126402656533/6753783250000000000000000000000000000000000000000", + "rejected_lower": "33768916250000000010022095404584149735276384834051/33768916250000000000000000000000000000000000000000", + "rejected_upper": "33768916250000000010022095404584149735283138456701/33768916250000000000000000000000000000000000000000" + }, + "kappa": "51414646104039/1000000000000000000", + "next_kappa": "1285366152601/25000000000000000", + "next_kappa_rejection": "{'g3_above_kappa': '-10113375913662396772469161/94701838758494871701270889025000000000000000'}", + "source_manifest_sha256": "9d5a4a7c4cf459f4c5731809de93cfb4b873cb8c9ea95a1be9239733a9a93c72", + "sources": { + "inherited": { + "files": { + "research/copied-fixed/balanced_assembly.py": "4d27575dcad2b45a281a34054d311409ecd954f373c0c3a62c29bcc843f06a86", + "research/copied-fixed/certificate.json": "33b3373c04e18a7f4cee33ba68da6ed71934acc3e0179cca6197696be4befa22", + "research/copied-fixed/changed_graph.py": "375a7ca6cac6d153c1880fd5ea5b4525e5dca9d4ee3018d24d679c219b59c5b3", + "research/copied-fixed/profiles.cpp": "b9fbd71c746609948b60c441ba4601e88436956fe636d1810f270ce4ce6a63a6", + "research/copied-fixed/verify.py": "44932182ce6c4d39776650311262ef0ac1ea9b5da7220bc0f728e2789881f84a", + "scripts/exclusion_circuit.py": "b253f9d7318becda1c1f3b24e2287ed44a9c27fcea00cf9d531afb950d0457a0", + "scripts/partial_swap/binary_io.hpp": "7e143eb75bb342ac8f0c82a60005e7c35c9ec827de479bf6fb773151f3af5fa1", + "scripts/partial_swap/paired.py": "ddcecace3a8e04d690914cbd64873ab8dde8c0c3477a255767b0ed6f639bb0c7", + "scripts/partial_swap/shared.py": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" + }, + "head": "b7194b8586844956904b33e9fe18f0c75606c11b", + "scope": "Unmodified producer inputs for experimental frame compiler; attribution retained in each file", + "source_pr": "https://github.com/CrocSwap/integer-mult-bounds/pull/48" + }, + "pr65": { + "author": "Rohan Arun with OpenAI assistance", + "commit": "49e84f939d15b618b50714eb039cabf97c74256a", + "files": { + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE": "5931cb7d43e09380594b113018cac70258fb66e0673b91f706b01ea482c1be1a", + "references/frame-compiler/pr48/SOURCE.json": "6ccc673f88d3650d75ed600b082fe2fc2866dd88a172d182a38c1d0cd27d24b3", + "references/frame-compiler/pr48/research/copied-fixed/balanced_assembly.py": "4d27575dcad2b45a281a34054d311409ecd954f373c0c3a62c29bcc843f06a86", + "references/frame-compiler/pr48/research/copied-fixed/certificate.json": "33b3373c04e18a7f4cee33ba68da6ed71934acc3e0179cca6197696be4befa22", + "references/frame-compiler/pr48/research/copied-fixed/changed_graph.py": "375a7ca6cac6d153c1880fd5ea5b4525e5dca9d4ee3018d24d679c219b59c5b3", + "references/frame-compiler/pr48/research/copied-fixed/profiles.cpp": "b9fbd71c746609948b60c441ba4601e88436956fe636d1810f270ce4ce6a63a6", + "references/frame-compiler/pr48/research/copied-fixed/verify.py": "44932182ce6c4d39776650311262ef0ac1ea9b5da7220bc0f728e2789881f84a", + "references/frame-compiler/pr48/scripts/exclusion_circuit.py": "b253f9d7318becda1c1f3b24e2287ed44a9c27fcea00cf9d531afb950d0457a0", + "references/frame-compiler/pr48/scripts/partial_swap/binary_io.hpp": "7e143eb75bb342ac8f0c82a60005e7c35c9ec827de479bf6fb773151f3af5fa1", + "references/frame-compiler/pr48/scripts/partial_swap/paired.py": "ddcecace3a8e04d690914cbd64873ab8dde8c0c3477a255767b0ed6f639bb0c7", + "references/frame-compiler/pr48/scripts/partial_swap/shared.py": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34", + "research/pair-assembly/PROOF.md": "30685624bf922bb9d9f7ed4b0d367a660fe373cc9ee28fec33585bd8c7023e75", + "research/pair-assembly/SOURCE.json": "8f8c0fb7ca012ec5092136744eb52a0222697a8275d14aa8f667339c86baf9d0", + "research/pair-assembly/frame/frame-compiler.json": "86eeb10989a61e571938178b91dfe1b81ba39ec97cc93124c00cecd91dc6ef13", + "research/pair-assembly/frame/frame_verify.py": "fafe25d57166a747eeb847444a2e02dd7eed19038b93a2c495014d147d04a8fb", + "research/pair-assembly/pair_graph.py": "3d47e89d2649c90800a276bdd0480131def50e0bdf92c122a19494b55bf17420", + "research/reordered-rank-pair/README.md": "13fbcfe41a4cb22ea6f1d59c98305add85a86a4db4677ab3450fd34b139cf39c", + "research/reordered-rank-pair/arithmetic/README.md": "93a1e4eb52ff3b3f3b24464ce1e7b5498fac2da2789cab5deb76e7342fe36775", + "research/reordered-rank-pair/arithmetic/audit-receipt.json": "f481198b192790b65dde2f93a837fb5e2e7508322f25bbf26f73530febd1f659", + "research/reordered-rank-pair/arithmetic/audit.py": "aa297fffcdaa133f5dee17d97fac72aa5ba2cf943da5a8a5e3f4d62f6f0a7f79", + "research/reordered-rank-pair/arithmetic/certificate.json": "6474f4c638b5a16de5a7ed6054f3ad28404eac17eaa4570aab2ef378d6e7e1a3", + "research/reordered-rank-pair/arithmetic/refine.py": "e0488c919e76850313ff93d7da704a7fcc14a316eee2cac81e2b8dff9c145b5d", + "research/reordered-rank-pair/arithmetic/test_arithmetic.py": "d4824c8c1cc6c726daf9104c820aefe1e57ce6a8625871954a54a538b5af0524", + "research/reordered-rank-pair/current-comparison.json": "be8713b049b34b41d82ef3e03380f6b45d7b33bf8611af9942dea7597406dc07", + "research/reordered-rank-pair/frame-compiler.json": "48f86ffe2c2a16d3817ed3ab814cd1442442ec15f827d43a7383a0a953ff4337", + "research/reordered-rank-pair/frame-profiles-23.json": "fec377bcf1512a427674983256b900229d4133026445b6e680c6e1e6dde5af7d", + "research/reordered-rank-pair/frame-profiles-25.json": "28b4b911e26fbc02dde0d2e1458ed16227f756126ab8144d6d45e164d1165262", + "research/reordered-rank-pair/frame-transitions-23.json": "86646f1110595294cccc15603c552f0a153574a690b69c3b144d84a449891103", + "research/reordered-rank-pair/frame-transitions-25.json": "c333c348665d12b95e168ca4fac48bfdca335104edd0f29c81fe94bec292e774", + "research/reordered-rank-pair/frame-word-23.json.gz": "a44e038e1c548ea8ac31dd04acc2bba7951b22e17df7b7ad3464ea2b504a8da4", + "research/reordered-rank-pair/frame-word-25.json.gz": "ad8b299697f90b185b6b791313b505586be97965519052100d097df6199e00c5", + "research/reordered-rank-pair/paired-candidate.json": "34a500d739537235dfc5d24325c22856ca4567b9eac998a3bce9b13db5501940", + "research/reordered-rank-pair/test_negative.py": "88832242e6f74e3fe08d109d4f21ff188a9ca0ae50c3e8f31da0243fe9501510", + "research/reordered-rank-pair/verify.py": "e84ed21dad24f9b8c429441caae49c13ccae883be2f04e696993cfe665b57352", + "scripts/exclusion_circuit.py": "b253f9d7318becda1c1f3b24e2287ed44a9c27fcea00cf9d531afb950d0457a0", + "scripts/experiments/binary_frame_math.py": "1f96e8aafc8ae89f8eeec5d03800131d93d58e01bf8a7fca8feb03702d1740d0", + "scripts/experiments/binary_frame_profile_prepare.py": "8a50381cab00b33e62b3a057d199ba5e19647929135c95b0fd63fc8a8ef7c9b3", + "scripts/experiments/binary_frame_profiles.cpp": "8e2e391d3ee57cbb1372c68e4aa031e1b861321536eabd642ada54e12e678669", + "scripts/experiments/binary_frame_replay.py": "392e78e62d7685c99a5888a7da743ea6c3dcad631af4a743c91e0c09348442bc", + "scripts/experiments/rank_pair_compiler.py": "9984aaccf880e4840402322d76678bfddb33ce7e494af78430a43429f51b85fd", + "scripts/partial_swap/paired.py": "ddcecace3a8e04d690914cbd64873ab8dde8c0c3477a255767b0ed6f639bb0c7", + "scripts/partial_swap/shared.py": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" + }, + "repo": "rohanarun/integer-mult-bounds", + "scope": "Authenticated PR65 finite source closure and complete published baseline physical words, profiles and arithmetic. Original upstream sources and notices are preserved byte-for-byte. Actual inherited dependencies are additionally checked through the shared PR48 manifest.", + "shared_dependency_manifest": "../pr48/SOURCE.json", + "shared_dependency_manifest_sha256": "6ccc673f88d3650d75ed600b082fe2fc2866dd88a172d182a38c1d0cd27d24b3" + }, + "pr67": { + "author": "Rohan Arun with OpenAI assistance", + "commit": "b3745601e947a94316bf25c2c6263d93c06e3364", + "files": { + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE": "5931cb7d43e09380594b113018cac70258fb66e0673b91f706b01ea482c1be1a", + "research/slot-cost-rank-pair/README.md": "e0fcd8e732c8b8becb3d860eb83dc979ed5e6b33ba16caf9dca1e44f7929c340", + "research/slot-cost-rank-pair/arithmetic/certificate.json": "e66f955f1b76ce3db7ecb84294993a072f42f972b8f3040015c12e6dc953d698", + "research/slot-cost-rank-pair/compiler.py": "29296211e0532aaf19101a6b2f2ceaebe374af95ae3acd63e63656db0afef7ae", + "research/slot-cost-rank-pair/frame-compiler.json": "eb5c0b401e677d3958ecfcd6d8de3bc825c4fb66d1cf79c3fcbcf23938ca6e69", + "research/slot-cost-rank-pair/paired-candidate.json": "be0322ad60f73923953f242eaffaf114ff12438e8617dae38888b77fa03184cc", + "research/slot-cost-rank-pair/profile_oracle.cpp": "d1f6b650de9fb5842b412595369271d9eeb6f54045c76c0fb5cad29854955c35", + "research/slot-cost-rank-pair/verify.py": "3c1d2eac9d3d2f13b60503deaa84e11ab2975aa84af71c8ad74584c5902b2d77" + }, + "repo": "rohanarun/integer-mult-bounds", + "scope": "Preserved immutable source and reported complete baseline profile/arithmetic for all-rank profile-cost reclamation. This package verifies its own composed words, actual paid profile and exact improvement.", + "shared_dependency_manifest": "../pr48/SOURCE.json", + "shared_dependency_manifest_sha256": "6ccc673f88d3650d75ed600b082fe2fc2866dd88a172d182a38c1d0cd27d24b3" + }, + "pr68": { + "author": "Dominik Scholz with OpenAI assistance", + "commit": "734c58e225e9d2254570c3b50296ed96943f62ea", + "files": { + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE": "d9db68e85db965bf7037d535ddc354b096b7c3b8f4cb0eb4887dc61eba5eae23", + "research/global-anchor-screen/PROOF.md": "3023c8c039acb3afc2a1e0c2ee55dcffaa4a1a2961076222ae20b03d0f3c6a38", + "research/global-anchor-screen/SOURCE.json": "f6249b8f91c7721a59ecc6d43a3f2ec65162578203bd430ef76732a3937399f3", + "research/global-anchor-screen/compiler-frozen.py": "12d646fa9ad69e4f3c532fe69080d8fe1509cde0968a6ab52a9d60273803adc0", + "research/global-anchor-screen/selected-manifest.json": "97bd86fc20fb3aee2d1adacd6a485b12e918b7340d2d3ca70e1318889e13e3a0", + "research/global-anchor-screen/selected_compile.py": "86bdfcf599c6b131e376773fe177bca57a9f63c9b60bad5de8aa00982d779b22" + }, + "repo": "DominikScholz/integer-mult-bounds", + "scope": "Preserved original pending live-carrier compiler, selected driver, proof and source provenance. This package composes the pending lifecycle and both containment checks with PR67 profile-cost selection and its own next-use scoring.", + "shared_dependency_manifest": "../pr48/SOURCE.json", + "shared_dependency_manifest_sha256": "6ccc673f88d3650d75ed600b082fe2fc2866dd88a172d182a38c1d0cd27d24b3" + }, + "split_operation": { + "author": "Rohan Garg / rohangar1 with OpenAI Codex assistance", + "commit": "641f22e52913db784f3b6ff1176b0c2945aae45b", + "files": { + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE": "f85437ee441f2a028660dd5e8dbdc0ec7b52bb55c04ea34fa4829c154bfd0ac1", + "research/split-skip/SOURCE.json": "7c2b4646a3ecfef6f881da5c43e4bd0fa9a4d1b00548b8ab458d897e16735134", + "research/split-skip/split_graph.py": "9b16ba907cbd58611fb64bfb9211be7809d54822d44c78fc6167cf4ba79eb905" + }, + "repo": "CrocSwap/integer-mult-bounds", + "scope": "Preserved original split-pair operation and attribution. These files document the adapted grouping operation; they are not imported by this producer. Actual imported source closure is PR65 plus shared PR48." + } + }, + "status": "Finite conditional physical witness and exact balanced assembly; inherited transfer hypotheses remain assumed" +} diff --git a/research/balanced-split-reclamation/vendor/pr71-graph.py b/research/balanced-split-reclamation/vendor/pr71-graph.py new file mode 100644 index 0000000000..acdf4d312d --- /dev/null +++ b/research/balanced-split-reclamation/vendor/pr71-graph.py @@ -0,0 +1,122 @@ +"""Split-pair recursion on PR65's preserved interval/pair graph and schedules. + +PR62 interval strips/core-aware assembly: Avi Eisenberg. PR63 ranked-frame +composition: Dominik Scholz. PR65 region order: Rohan Arun. The [1,1,2] +group vector was selected by Chafik Boukhalfa with OpenAI Codex assistance, +using the split-pair operation introduced in Rohan Garg's PR59. All original +sources and notices remain unchanged in the pinned contributor archive. +""" +import sys +if sys.flags.optimize: + raise ValueError('Assertions must remain enabled') +sys.dont_write_bytecode = True + +from hashlib import sha256 +import importlib.util +import json +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +BASELINE = ROOT / 'references/frame-compiler/pr65' +EXPECTED_CONFIGS = { + 23: dict(groups=[1, 1, 2], schedule='cover-core', anchor=True), + 25: dict(groups=[1, 1, 2], schedule='reverse-node', anchor=True), +} + + +def checked_manifest(directory): + manifest = json.loads((directory / 'SOURCE.json').read_text()) + for name, digest in manifest['files'].items(): + assert sha256((directory / name).read_bytes()).hexdigest() == digest, name + if 'shared_dependency_manifest' in manifest: + path = directory / manifest['shared_dependency_manifest'] + assert sha256(path.read_bytes()).hexdigest() == manifest['shared_dependency_manifest_sha256'] + return manifest + + +def _load(name, path): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def _private_modules(): + checked_manifest(BASELINE) + inherited = ROOT / 'references/frame-compiler/pr48' + checked_manifest(inherited) + for name in ('scripts/partial_swap/paired.py', 'scripts/partial_swap/shared.py', + 'scripts/exclusion_circuit.py'): + assert (BASELINE / name).read_bytes() == (inherited / name).read_bytes() + previous_path = sys.path[:] + try: + sys.path.insert(0, str(inherited / 'scripts')) + graph = _load('split_pair_private_graph', BASELINE / 'research/pair-assembly/pair_graph.py') + schedule = _load('split_pair_private_schedule', BASELINE / 'research/reordered-rank-pair/verify.py') + # Imported aliases may preexist in a test process; verify their bytes. + for module_name, relative in ( + ('partial_swap.paired', 'scripts/partial_swap/paired.py'), + ('partial_swap.shared', 'scripts/partial_swap/shared.py'), + ('exclusion_circuit', 'scripts/exclusion_circuit.py')): + assert Path(sys.modules[module_name].__file__).read_bytes() == (inherited / relative).read_bytes() + return graph, schedule + finally: + sys.path[:] = previous_path + + +_graph, _schedule = _private_modules() + + +def configuration(h): + if type(h) is not int or h not in EXPECTED_CONFIGS: + raise ValueError('Only the certified dimensions 23 and 25 are supported') + config = json.loads((ROOT / f'research/split-pair/config-{h}.json').read_text()) + if (type(config) is not dict or config != EXPECTED_CONFIGS[h] + or any(type(choice) is not int for choice in config['groups']) + or type(config['anchor']) is not bool): + raise ValueError('The certified graph configuration changed') + return config + + +def split_class(parent, choices): + class SplitPair(parent): + def grouping(self, points): + groups = super().grouping(points) + choice = choices[self._level] if self._level < len(choices) else 0 + if len(points) > 3 and choice: + index = {1: 0, 2: (len(groups)-1)//2, 3: len(groups)-1}[choice] + if len(groups[index]) == 2: + groups[index:index+1] = [[point] for point in groups[index]] + assert all(len(group) in (1, 2) for group in groups) + assert len(groups) < len(points) + assert sorted(point for group in groups for point in group) == sorted(points) + return groups + return SplitPair + + +def graph(h): + config = configuration(h) + original = _graph.circuit_class + previous_points = _graph.alternating_points + try: + _graph.circuit_class = lambda dimension: split_class(original(dimension), config['groups']) + if config['anchor']: + def anchored_points(dimension, common): + points = previous_points(dimension, common) + pairs = [(a, a+1) for a in range(0, dimension-1, 2) if common not in (a, a+1)] + chosen = min(pairs) + result = list(chosen) + [x for x in points if x not in chosen] + assert sorted(result) == [x for x in range(dimension) if x != common] + return result + _graph.alternating_points = anchored_points + return _graph.graph(h) + finally: + _graph.circuit_class = original + _graph.alternating_points = previous_points + + +def ordered_build(original, h): + mode = configuration(h)['schedule'] + if mode == 'original': + return original + return _schedule.reordered_build(original, mode) diff --git a/research/balanced-split-reclamation/vendor/pr76-exchanges.py b/research/balanced-split-reclamation/vendor/pr76-exchanges.py new file mode 100644 index 0000000000..7a299e2469 --- /dev/null +++ b/research/balanced-split-reclamation/vendor/pr76-exchanges.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +"""PR70 bounded carried-signal exchanges composed with pinned PR71. + +PR70 exchanges: Alejandro; PR71 split/next-use compiler: Chafik Boukhalfa. +PR67 profile oracle/cost: Rohan Arun; PR68 live controls: Dominik Scholz. +Composition and integer-entropy pricing prepared with substantial OpenAI +Codex assistance. Discovery heuristic only; exact profiles accept candidates. +""" +from pathlib import Path +from collections import Counter +from hashlib import sha256 +import argparse,gzip,json,os,shlex,struct,subprocess,sys,time +if sys.flags.optimize:raise ValueError('Assertions must remain enabled') +sys.dont_write_bytecode=True +HERE=Path(__file__).resolve().parent +BASE=HERE.parent/'round6-pr71/baseline' +sys.path.insert(0,str(BASE/'scripts/experiments')) +import split_pair_engine as compiler +import split_pair_graph as producer +import schedule_variant +from binary_frame_math import logs + + +def main(): + p=argparse.ArgumentParser();p.add_argument('--h',type=int,choices=(23,25),required=True);p.add_argument('--work-dir',type=Path,required=True);p.add_argument('--passes',type=int,default=3);a=p.parse_args() + a.work_dir.mkdir(parents=True,exist_ok=True) + source=Path(compiler.__file__) + expected=json.loads((BASE/'research/split-pair/engine-provenance.json').read_text())['portable_engine_sha256'] + assert sha256(source.read_bytes()).hexdigest()==expected + executable=a.work_dir/'oracle' + subprocess.run([*shlex.split(os.environ.get('CXX','c++')),'-O3','-std=c++17','-I',str(BASE/'references/frame-compiler/pr48/scripts/partial_swap'),str(BASE/'references/frame-compiler/pr67/research/slot-cost-rank-pair/profile_oracle.cpp'),'-o',str(executable)],check=True) + compiler.graph=lambda h: schedule_variant.reorder(producer.graph(h));compiler.build=producer.ordered_build(compiler.build,a.h) + original_match=compiler.match + def exchange_match(blocks,uses,enabled): + result=original_match(blocks,uses,enabled) + edges,chosen,right,stats=result + initial_cardinality=len(chosen) + if not a.passes:return result + owner={x:g for g,b in enumerate(blocks) for x in b['nodes']} + path=a.work_dir/'matching-oracle.bin' + with path.open('wb')as stream: + h=a.h;v=h*(h-1)*(h-2)//6 + stream.write(struct.pack('<6I2Q',h,v,0,len(blocks)+2,0,0,h*(h-1),h*(h-1))) + stream.write(struct.pack('<2QI',0,0,0));stream.write(struct.pack('<2QI',0,0,h)) + for b in blocks:stream.write(struct.pack('<2QI',*b['frame'],b['rank'])) + oracle=subprocess.Popen([str(executable),str(path)],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True,bufsize=1) + weights=[0]+[int(t*sum(logs(t))*10**30//2)for t in range(1,h+1)];cache={} + def entropy(x,y): + if (x,y)not in cache: + oracle.stdin.write(f'{x} {y}\n');oracle.stdin.flush();line=oracle.stdout.readline();assert line + values=list(map(int,line.split()));assert len(values)==h+1 + cache[x,y]=sum(n*w for n,w in zip(values,weights)) + return cache[x,y] + def cost(edge): + g,u,i=edge;p=owner[blocks[g]['inputs'][i]];t=uses[u][1] + return -entropy(g+2,t+2)+entropy(g+2,1)+entropy(0,p+2)+entropy(p+2,t+2) + try: + prices=[] + for j,e in enumerate(edges): + prices.append(cost(e)) + if j%20000==0:print('edge prices',j,len(edges),'pairs',len(cache),flush=True) + finally: + oracle.stdin.close();assert oracle.wait(timeout=10)==0 + priority=sorted(range(len(edges)),key=lambda e:(prices[e],edges[e]));initial=sum(prices[e]for e in chosen) + def can(e,drop=None): + g,u,i=edges[e] + rows=blocks[g]['outbasis']+[1<=prices[f]:continue + if not can(e,f if edges[f][0]==g else None):continue + else: + f=next((z for z in sorted(blocks[g]['selected'],key=lambda z:(-prices[z],z)) if prices[e]= j+1 proves persistence.", + "additional_eventual_conditions": [ + "BHP prime threshold and distinct-prime packing", + "Fixed rational basis, eligible common prime and native table setup", + "Catalogue/descriptor domination, logarithm absorption, exact recovery" + ], + "practical_runtime_claim": false + } + }, + "finite_bridge": { + "bit": { + "W": 133289600, + "halving_degree": 9, + "m": 575, + "maxchild": 529, + "wire_bits": 27 + }, + "complex": { + "W": 537696432, + "halving_degree": 20, + "m": 784, + "maxchild": 756, + "s": 421548223824, + "scalar_group_upper": 4793351472, + "scalar_terms": [ + { + "c": 78437, + "copied_center_extra_groups": 56, + "h": 28, + "invocations": 3276, + "local_group_upper": 729892, + "v": 3276 + }, + { + "c": 78437, + "copied_center_extra_groups": 56, + "h": 28, + "invocations": 3276, + "local_group_upper": 729892, + "v": 3276 + } + ], + "wire_bits": 30 + }, + "rows": { + "coefficient": 843, + "contract": "W_complex^D_complex * W_bit^D_bit; one preceding prefix and padding; all temporary copies sequential", + "degree": 2000, + "degree_gap": "7007/25", + "suffix_slope": 8000 + }, + "semantic": { + "B": 9696565176891520488614054257040, + "C0": 2358858462850846165593256368932965330169899180021667007021321420800, + "C1": 1, + "E": 9696565176891520488192506033216, + "induction_gap": 533311084729033626873772984137200, + "literal_charge": 2771683137698171397039558468, + "strict_literal_gap": 9693793493753822316795466474748 + } + }, + "pr76_kappa": "51738676045141/1000000000000000000", + "gain_percent": "29412284004900/51738676045141", + "scope": "Finite conditional envelope-balanced witness; geometric coordinate-aware oracle pricing on h25; all inherited all-size assumptions remain." +} diff --git a/research/balanced-split-reclamation/verify.py b/research/balanced-split-reclamation/verify.py new file mode 100644 index 0000000000..58b71acb45 --- /dev/null +++ b/research/balanced-split-reclamation/verify.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python3 +"""Verify the frozen sources, literal words, actual profiles and arithmetic.""" +import argparse +from copy import deepcopy +from collections import Counter +import gzip +from hashlib import sha256 +from itertools import combinations +import json +from pathlib import Path +import subprocess +import tempfile +from support import HERE, ROOT, SELECTED, write_json, json_value +from binary_frame_replay import replay +from binary_frame_profile_prepare import prepare +from arithmetic import certify, independent_audit +import generate + + +def require(value, message): + if not value: + raise ValueError(message) + + +def index(value, limit, message): + require(type(value) is int and 0 <= value < limit, message) + + +def validate_word(word): + require(set(word) == {'h', 'v', 'R', 'frames', 'ops', 'events', 'sources', 'outputs', 'scatter'}, 'Unexpected word schema') + h, v, roles = word['h'], word['v'], word['R'] + require(type(h) is int and h in (23, 25), 'Unsupported axis') + triples = list(combinations(range(h), 3)) + require(type(v) is int and v == len(triples), 'Source dimension') + require(type(roles) is int and roles == {23: 27043, 25: 35505}[h], 'Selected role count') + frames = word['frames'] + require(type(frames) is list and len(frames) > 0, 'Missing frames') + for frame in frames: + require(type(frame) is list and len(frame) == 2, 'Frame pair') + c, u = frame + index(c, 1 << h, 'Core mask bounds'); index(u, 1 << h, 'Cover mask bounds') + require(c and not c & ~u, 'Core inclusion') + require(c.bit_count() in (1, 2) or c == u and c.bit_count() == 3, 'Original-envelope frame') + require(len({tuple(f) for f in frames}) == len(frames), 'Duplicate frame ID') + for op in word['ops']: + require(type(op) is list and len(op) == 3, 'XOR schema') + a, b, g = op + index(a, roles, 'XOR destination'); index(b, roles, 'XOR control'); index(g, len(frames), 'XOR frame') + require(a != b, 'Noninvertible self XOR') + for event in word['events']: + require(type(event) is list and len(event) == 3, 'Event schema') + s, a, b = event + index(s, roles, 'Event role'); index(b, len(frames), 'Event target') + require(type(a) is int and -1 <= a < len(frames), 'Event source') + sources = word['sources'] + require(type(sources) is dict and set(sources) == {str(i) for i in range(v)}, 'Canonical complete source ports') + for s in sources.values(): + index(s, roles, 'Source role') + require(len(set(sources.values())) == v, 'Aliased source carriers') + expected_scatter, output_roles = [], set() + triple_index = {t: i for i, t in enumerate(triples)} + for output in word['outputs']: + require(type(output) is list and len(output) == 4, 'Output schema') + s, g, common, triple = output + index(s, roles, 'Output role'); index(g, len(frames), 'Output frame'); index(common, h, 'Common point') + require(s not in output_roles, 'Aliased terminal role'); output_roles.add(s) + require(type(triple) is list and len(triple) in (1, 3), 'Output triple schema') + for x in triple: + index(x, h, 'Triple point') + require(triple == sorted(set(triple)) and common in triple, 'Canonical output triple') + targets = [i for i, t in enumerate(triples) if common in t] if len(triple) == 1 else [triple_index[tuple(triple)]] + expected_scatter.extend([[v+i, 2*v+s] for i in targets]) + for port in word['scatter']: + require(type(port) is list and len(port) == 2, 'Scatter pair schema') + a, b = port + require(type(a) is int and v <= a < 2*v, 'Scatter destination bounds') + require(type(b) is int and 2*v <= b < 2*v+roles, 'Scatter control bounds') + # All these gates read scratch and write targets, so they commute. Point + # conjugation changes their lexical order, but every multiplicity is paid. + require(Counter(map(tuple, word['scatter'])) == Counter(map(tuple, expected_scatter)), + 'Literal scatter multiset must equal the charged terminal ports') + + +def check_manifest(): + source = json.loads((HERE/'SOURCE.json').read_text()) + for name, digest in source['files'].items(): + path = ROOT/name + require(path.resolve().is_relative_to(ROOT.resolve()), 'Manifest path escaped repository') + require(sha256(path.read_bytes()).hexdigest() == digest, 'Changed frozen file: '+name) + return source + + +def check_axis(h, work, profiler, directory=SELECTED): + packed = directory/f'word-{h}.json.gz' + raw = gzip.decompress(packed.read_bytes()) + validate_word(json.loads(raw)) + actual_replay = replay(packed) + expected_replay = json.loads((directory/f'replay-{h}.json').read_text()) + require(json_value(actual_replay) == expected_replay, 'Independent dirty replay changed') + path = work/f'axis-{h}.bin' + actual_transition = prepare(packed, path) + require(json_value(actual_transition) == json.loads((directory/f'transitions-{h}.json').read_text()), 'Literal frame transitions changed') + subprocess.run([str(profiler), str(path)], check=True) + actual_profile = json.loads(Path(str(path)+'.profiles.json').read_text()) + require(actual_profile == json.loads((directory/f'profile-{h}.json').read_text()), 'Exact physical profile changed') + print(f'PASS independent literal word, all dirty basis vectors and paid CRT profile h={h}', flush=True) + + +def verify(rebuild=False): + check_manifest() + with tempfile.TemporaryDirectory(prefix='balanced-split-') as temporary: + work = Path(temporary) + oracle, profiler = generate.binaries(work) + if rebuild: + for h in (23, 25): + generate.generate_axis(h, work, oracle, profiler) + actual = gzip.decompress((work/f'word-{h}.json.gz').read_bytes()) + expected = gzip.decompress((SELECTED/f'word-{h}.json.gz').read_bytes()) + require(actual == expected, 'Regenerated physical word differs byte-for-byte') + for prefix in ('compiled', 'replay', 'profile', 'transitions', 'config'): + require(json.loads((work/f'{prefix}-{h}.json').read_text()) == json.loads((SELECTED/f'{prefix}-{h}.json').read_text()), 'Regenerated '+prefix+' differs') + for h in (23, 25): + check_axis(h, work, profiler) + actual = certify(generate.combine(SELECTED)) + recorded = json.loads((SELECTED/'certificate.json').read_text()) + require(json_value(actual) == recorded, 'Complete exact arithmetic certificate changed') + require(json_value(independent_audit(recorded)) == json.loads((SELECTED/'audit.json').read_text()), 'Independent arithmetic receipt changed') + print('PASS complete PR82 exclusion, adjacent grid rejection, 47 strict constraints and seven margins', flush=True) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--rebuild', action='store_true') + verify(parser.parse_args().rebuild)