From bb05c40c3e6319aa8c131b06a105e3648ac6c95b Mon Sep 17 00:00:00 2001 From: Ali Romman <226877337+aliromman@users.noreply.github.com> Date: Mon, 12 Oct 2026 23:04:28 -0500 Subject: [PATCH] Research: compose R420 block circuits with hosted replay --- .../CERTIFICATE.json | 576 ++++++++++++ .../r420-two-block-composition/CLAIM.json | 56 ++ .../LOCAL-CERTIFICATE.json | 58 ++ research/r420-two-block-composition/README.md | 182 ++++ .../r420-two-block-composition/SOURCES.json | 181 ++++ .../VALIDATION.json | 72 ++ research/r420-two-block-composition/hosted.py | 78 ++ research/r420-two-block-composition/native.py | 70 ++ .../vendor/pr670/CERTIFICATE.json | 211 +++++ .../vendor/pr670/README.md | 202 ++++ .../vendor/pr670/candidate.json | 199 ++++ .../vendor/pr674/README.md | 164 ++++ .../vendor/pr674/certificate.json | 865 ++++++++++++++++++ research/r420-two-block-composition/verify.py | 211 +++++ 14 files changed, 3125 insertions(+) create mode 100644 research/r420-two-block-composition/CERTIFICATE.json create mode 100644 research/r420-two-block-composition/CLAIM.json create mode 100644 research/r420-two-block-composition/LOCAL-CERTIFICATE.json create mode 100644 research/r420-two-block-composition/README.md create mode 100644 research/r420-two-block-composition/SOURCES.json create mode 100644 research/r420-two-block-composition/VALIDATION.json create mode 100644 research/r420-two-block-composition/hosted.py create mode 100644 research/r420-two-block-composition/native.py create mode 100644 research/r420-two-block-composition/vendor/pr670/CERTIFICATE.json create mode 100644 research/r420-two-block-composition/vendor/pr670/README.md create mode 100644 research/r420-two-block-composition/vendor/pr670/candidate.json create mode 100644 research/r420-two-block-composition/vendor/pr674/README.md create mode 100644 research/r420-two-block-composition/vendor/pr674/certificate.json create mode 100644 research/r420-two-block-composition/verify.py diff --git a/research/r420-two-block-composition/CERTIFICATE.json b/research/r420-two-block-composition/CERTIFICATE.json new file mode 100644 index 0000000000..ed994f586d --- /dev/null +++ b/research/r420-two-block-composition/CERTIFICATE.json @@ -0,0 +1,576 @@ +{ + "status": "PASS_R420_TWO_BLOCK_COMPOSITION", + "components": [ + { + "pr": 670, + "inputs": 4096, + "before": 50, + "after": 33 + }, + { + "pr": 674, + "inputs": 4096, + "before": 46, + "after": 34 + } + ], + "labels": { + "labels": 120, + "lattice_rank": 8, + "gram_det": 1, + "frames": 672 + }, + "full_word": { + "columns": 660, + "gates": { + "D": 120, + "A": 2064, + "B": 808, + "C": 2632 + }, + "scatter_terms": 568 + }, + "hypotheses": { + "H1_no_target_feeds_z": true, + "H2_D_frame0_targets_from_helpers": true, + "H3_A_z_only_scatter_targets_B_split": true, + "H4_C_literal_reverse_at_full": true, + "H5_V_identity": true + }, + "conclusion": { + "U_block_form": true, + "J_identity": true, + "K_equals_D": true, + "C_is_U_inverse": true + }, + "controls": { + "wrong_block_670_with_correct_inverse": "targets not y + x: [19, 24, 35, 40, 54]", + "wrong_block_674_with_correct_inverse": "targets not y + x: [21, 29, 37, 53, 62]", + "missing_cleanup_gate": "sources not restored: [45]", + "unpaid_low_frame": "climb not nested: register 45 from frame 182 (dim 2) to frame 47 (dim 1)", + "ascending_stale_slice_offsets": "targets not y + x: [8, 13, 21, 29, 33]", + "stale_cleanup": "scalar map accepted; H4 literal-reversal contract rejected" + }, + "unchanged_register_paths": 660, + "original_additions": 26916, + "replacement_additions": 26858, + "replacement_canonical_sha256": "362325782cc1b2b3c427312d56b0450d7255f2afcaf17e07a29827e722159026", + "native": { + "baseline": { + "legality": { + "all_final_frames_pass": true, + "common_frame_ADDs": 26916, + "containment_pairs_checked": 2460, + "copies": 9, + "donor_intersections": 0, + "erasures": 9, + "max_inherited_integer_abs": 2, + "nested_MOVEs": 2940, + "new_frame_ids_collision": false, + "nondegeneracy_checked_by_separate_exact_bank_audit": true, + "old_max_frame_id": 671, + "paid_histogram": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "rank_mass": 5112, + "records": 29874, + "scope": "Independent chronological geometry/copy/source-owner audit. F2 all-column replay is in the separately freshly compiled transform receipt; address transform theorem and bank completion remain separate.", + "selected_helpers": 0, + "selected_pairs": 0, + "source_owner_intersections": 0, + "status": "PASS_INDEPENDENT_COHORT_LEGALITY_SOURCE_OWNERS_AND_LIFECYCLE" + }, + "stages": { + "5": { + "formal_columns_checked": 900, + "local_scalar_additions": 26916, + "local_raw_H": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "payload_prefix_bits": 100, + "payload_prefix_upper": "998206739997057013039187410944", + "signed_lift_prefix": [ + { + "bits": 18, + "cancellation_free_signed_row_l1_upper": "144651", + "reverse": false + }, + { + "bits": 22, + "cancellation_free_signed_row_l1_upper": "2270064", + "reverse": true + } + ] + }, + "9": { + "formal_columns_checked": 1380, + "local_scalar_additions": 26916, + "local_raw_H": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "payload_prefix_bits": 100, + "payload_prefix_upper": "998206739997057013039187410944", + "signed_lift_prefix": [ + { + "bits": 18, + "cancellation_free_signed_row_l1_upper": "144651", + "reverse": false + }, + { + "bits": 22, + "cancellation_free_signed_row_l1_upper": "2270064", + "reverse": true + } + ] + }, + "11": { + "formal_columns_checked": 1620, + "local_scalar_additions": 26916, + "local_raw_H": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "payload_prefix_bits": 100, + "payload_prefix_upper": "998206739997057013039187410944", + "signed_lift_prefix": [ + { + "bits": 18, + "cancellation_free_signed_row_l1_upper": "144651", + "reverse": false + }, + { + "bits": 22, + "cancellation_free_signed_row_l1_upper": "2270064", + "reverse": true + } + ] + } + } + }, + "replacement": { + "legality": { + "all_final_frames_pass": true, + "common_frame_ADDs": 26858, + "containment_pairs_checked": 2460, + "copies": 9, + "donor_intersections": 0, + "erasures": 9, + "max_inherited_integer_abs": 2, + "nested_MOVEs": 2940, + "new_frame_ids_collision": false, + "nondegeneracy_checked_by_separate_exact_bank_audit": true, + "old_max_frame_id": 671, + "paid_histogram": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "rank_mass": 5112, + "records": 29816, + "scope": "Independent chronological geometry/copy/source-owner audit. F2 all-column replay is in the separately freshly compiled transform receipt; address transform theorem and bank completion remain separate.", + "selected_helpers": 0, + "selected_pairs": 0, + "source_owner_intersections": 0, + "status": "PASS_INDEPENDENT_COHORT_LEGALITY_SOURCE_OWNERS_AND_LIFECYCLE" + }, + "stages": { + "5": { + "formal_columns_checked": 900, + "local_scalar_additions": 26858, + "local_raw_H": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "payload_prefix_bits": 100, + "payload_prefix_upper": "891657555717214384197895351296", + "signed_lift_prefix": [ + { + "bits": 18, + "cancellation_free_signed_row_l1_upper": "144651", + "reverse": false + }, + { + "bits": 22, + "cancellation_free_signed_row_l1_upper": "2145492", + "reverse": true + } + ] + }, + "9": { + "formal_columns_checked": 1380, + "local_scalar_additions": 26858, + "local_raw_H": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "payload_prefix_bits": 100, + "payload_prefix_upper": "891657555717214384197895351296", + "signed_lift_prefix": [ + { + "bits": 18, + "cancellation_free_signed_row_l1_upper": "144651", + "reverse": false + }, + { + "bits": 22, + "cancellation_free_signed_row_l1_upper": "2145492", + "reverse": true + } + ] + }, + "11": { + "formal_columns_checked": 1620, + "local_scalar_additions": 26858, + "local_raw_H": [ + [ + 1, + 1320 + ], + [ + 2, + 1440 + ], + [ + 4, + 60 + ], + [ + 5, + 120 + ], + [ + 8, + 9 + ] + ], + "payload_prefix_bits": 100, + "payload_prefix_upper": "891657555717214384197895351296", + "signed_lift_prefix": [ + { + "bits": 18, + "cancellation_free_signed_row_l1_upper": "144651", + "reverse": false + }, + { + "bits": 22, + "cancellation_free_signed_row_l1_upper": "2145492", + "reverse": true + } + ] + } + } + } + }, + "hosted": { + "baseline": { + "parent_mutations": [ + "omit an idle child", + "omit a bridge", + "omit terminal exchange", + "remove a local invocation", + "understate live stock", + "omit a local paid move", + "wrong reflected copy charge", + "alter residual orthogonal basis", + "misstate replication count", + "misstate stage count", + "alias data across stages", + "delay an idle advance past its level", + "truncate the last idle advance", + "re-use a helper bank slot", + "wrong residual frame", + "alias data across replica groups", + "omit the fourth replica group" + ], + "hosted_audit": { + "status": "PASS_INDEPENDENT_REPLICATED_HOSTING_AUDIT", + "template_sha256": "9b74a1a6bf4dc4fc6c139a2d342b5c882538c000e7532d761652d11831197bf3", + "emitted_program_sha256": "2d219ab9a59aaf8f7163f28cac55a3d7a010dd9aa93ec53108491c1e5d434ab5", + "emitted_events": 8603712, + "profile": { + "1": 380160, + "2": 426624, + "4": 32640, + "5": 34560, + "6": 15360, + "7": 23040, + "8": 2592, + "42": 3456 + }, + "live": 30720, + "physical": 30729, + "hosted_residuals": 120960, + "bank_assignments": 0, + "rank_mass": 1956096, + "deficit": 9984, + "maxchild": 42, + "mutations_rejected": [ + "slot outside window", + "copy index outside family", + "negative slot offset", + "wrong residual width", + "duplicate helper", + "omitted helper", + "hosted owner in another replica or outside the data stock", + "hosted owner on a wrong data family", + "wrong call orientation", + "duplicate call", + "changed idle rank", + "understated live stock", + "missing remainder summary", + "stale stage count", + "hosted coordinate beyond the pending set", + "overlapping hosted coordinates" + ] + }, + "bit_lower": "413456747036699736067/250000000000000000000000", + "bit_lower_decimal": "0.001653826988146798944268", + "invoice": { + "live": 30720, + "physical": 30729, + "maxchild": 42, + "rank_mass": 1956096, + "hosted_residuals": 120960, + "bank_assignments": 0, + "prefix_bits": 189, + "charged_prefix_bits": 192, + "coefficient_bits": 189, + "two_level_coefficient_bits": 416, + "charged_two_level_coefficient_bits": 512, + "row_coefficient": 18355, + "halving_depth": 2 + }, + "global_prefix_bound": "440858815560454746902811617646181283465263876766227759104", + "bit_profile": { + "1": 380160, + "2": 426624, + "4": 32640, + "5": 34560, + "6": 15360, + "7": 23040, + "8": 2592, + "42": 3456 + }, + "local_additions": 26916 + }, + "replacement": { + "parent_mutations": [ + "omit an idle child", + "omit a bridge", + "omit terminal exchange", + "remove a local invocation", + "understate live stock", + "omit a local paid move", + "wrong reflected copy charge", + "alter residual orthogonal basis", + "misstate replication count", + "misstate stage count", + "alias data across stages", + "delay an idle advance past its level", + "truncate the last idle advance", + "re-use a helper bank slot", + "wrong residual frame", + "alias data across replica groups", + "omit the fourth replica group" + ], + "hosted_audit": { + "status": "PASS_INDEPENDENT_REPLICATED_HOSTING_AUDIT", + "template_sha256": "b52f11a193ff29e67b0be5843eafbe98a7878edeef589901d037b78382f3a14f", + "emitted_program_sha256": "519fe16ca8eddfa597a5c04e7b725bfa18d9b9f6930e11a55bc9117ff654225e", + "emitted_events": 8587008, + "profile": { + "1": 380160, + "2": 426624, + "4": 32640, + "5": 34560, + "6": 15360, + "7": 23040, + "8": 2592, + "42": 3456 + }, + "live": 30720, + "physical": 30729, + "hosted_residuals": 120960, + "bank_assignments": 0, + "rank_mass": 1956096, + "deficit": 9984, + "maxchild": 42, + "mutations_rejected": [ + "slot outside window", + "copy index outside family", + "negative slot offset", + "wrong residual width", + "duplicate helper", + "omitted helper", + "hosted owner in another replica or outside the data stock", + "hosted owner on a wrong data family", + "wrong call orientation", + "duplicate call", + "changed idle rank", + "understated live stock", + "missing remainder summary", + "stale stage count", + "hosted coordinate beyond the pending set", + "overlapping hosted coordinates" + ] + }, + "bit_lower": "413456747036699736067/250000000000000000000000", + "bit_lower_decimal": "0.001653826988146798944268", + "invoice": { + "live": 30720, + "physical": 30729, + "maxchild": 42, + "rank_mass": 1956096, + "hosted_residuals": 120960, + "bank_assignments": 0, + "prefix_bits": 188, + "charged_prefix_bits": 192, + "coefficient_bits": 188, + "two_level_coefficient_bits": 416, + "charged_two_level_coefficient_bits": 512, + "row_coefficient": 18355, + "halving_depth": 2 + }, + "global_prefix_bound": "351766697684262297071477576485319782838024676062552653824", + "bit_profile": { + "1": 380160, + "2": 426624, + "4": 32640, + "5": 34560, + "6": 15360, + "7": 23040, + "8": 2592, + "42": 3456 + }, + "local_additions": 26858 + } + } +} diff --git a/research/r420-two-block-composition/CLAIM.json b/research/r420-two-block-composition/CLAIM.json new file mode 100644 index 0000000000..2715c72067 --- /dev/null +++ b/research/r420-two-block-composition/CLAIM.json @@ -0,0 +1,56 @@ +{ + "track": "Bit supplier", + "assignment_seed": 15, + "random_source": "secrets.randbelow(100), backed by operating-system randomness", + "started_utc": "2026-10-13T03:24:37Z", + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "selected_kappa": "51110230636731/31250000000000000", + "candidates": [ + { + "task": "Retiming R420 phase-B frames", + "decision": "Excluded: PR661 covers all fixed-order simultaneous frame reassignments." + }, + { + "task": "Change the nine retained decoder totals", + "decision": "Deferred: decoder-rank work and prior fitting experiments make this a larger interface change." + }, + { + "task": "Resynthesize R420 block 5 at frame 547", + "decision": "Selected: replace the fixed 46-gate, 12-wire scalar map using two-sided elimination, outside the random LU and fixed-order frame classes." + } + ], + "scope": "Only B[371:417] of the pinned R420 word and its literal inverse in C. Keep the exact ordered output map, arbitrary-input restoration, every other gate, stock and decoder interface. Check full frame paths and cancellation-free coefficient bills. No new kappa claim.", + "method": "Bounded two-sided binary row/column elimination with deterministic seed 15; exact matrix and full-word checks; reject any unpaid work or invalid frame path.", + "stopping_rule": "At most 10000 synthesis trials or 10 CPU minutes for the initial search. One evidence-driven pivot is permitted. Reserve final quarter for verification and handoff.", + "expected_deliverable": "One exact smaller local circuit and reproducible verifier, or a precisely scoped negative result if the experiment warrants publication.", + "expected_finish_utc": "2026-10-13T04:35:00Z", + "coordination": "No pinned issues in GitHub GraphQL; only open issue #650 concerns Discussions. Claim recorded locally.", + "overlap_checked": [ + 543, + 589, + 612, + 661 + ], + "contributor": "Ali Romman", + "assistance": "Substantial OpenAI Codex assistance.", + "pivot": { + "reason": "Concurrent PR674 supplies a stronger 34-gate circuit on the same block. PR670 supplies a separate block-3 circuit. Neither reports native multistage or whole-owner replay.", + "scope": "Compose only the pinned PR670 and PR674 local replacements in PR543 R420; rebuild cleanup; add native 5/9/11-stage and nine-stage whole-owner/invoice verification. Credit both circuit authors. No new kappa.", + "original_search": "10000 greedy two-sided trials with seed 15 found a 37-gate circuit. It is archived locally and is not submitted as a competing construction.", + "expected_deliverable": "Combined finite bit circuit with 58 fewer local ADDs and fresh integration evidence." + }, + "result": { + "status": "PASS focused local, native, whole-owner and invoice replay", + "local_additions_before": 26916, + "local_additions_after": 26858, + "canonical_word_sha256": "362325782cc1b2b3c427312d56b0450d7255f2afcaf17e07a29827e722159026", + "predecessors": [ + 670, + 674 + ], + "publication": "The submitted PR link will be recorded in the workspace sprint handoff.", + "physical_emitted_instructions_before": 8603712, + "physical_emitted_instructions_after": 8587008, + "full_suite": "Interrupted for disk resource limit; not a pass" + } +} diff --git a/research/r420-two-block-composition/LOCAL-CERTIFICATE.json b/research/r420-two-block-composition/LOCAL-CERTIFICATE.json new file mode 100644 index 0000000000..2f68ee4c38 --- /dev/null +++ b/research/r420-two-block-composition/LOCAL-CERTIFICATE.json @@ -0,0 +1,58 @@ +{ + "status": "PASS_R420_TWO_BLOCK_COMPOSITION", + "components": [ + { + "pr": 670, + "inputs": 4096, + "before": 50, + "after": 33 + }, + { + "pr": 674, + "inputs": 4096, + "before": 46, + "after": 34 + } + ], + "labels": { + "labels": 120, + "lattice_rank": 8, + "gram_det": 1, + "frames": 672 + }, + "full_word": { + "columns": 660, + "gates": { + "D": 120, + "A": 2064, + "B": 808, + "C": 2632 + }, + "scatter_terms": 568 + }, + "hypotheses": { + "H1_no_target_feeds_z": true, + "H2_D_frame0_targets_from_helpers": true, + "H3_A_z_only_scatter_targets_B_split": true, + "H4_C_literal_reverse_at_full": true, + "H5_V_identity": true + }, + "conclusion": { + "U_block_form": true, + "J_identity": true, + "K_equals_D": true, + "C_is_U_inverse": true + }, + "controls": { + "wrong_block_670_with_correct_inverse": "targets not y + x: [19, 24, 35, 40, 54]", + "wrong_block_674_with_correct_inverse": "targets not y + x: [21, 29, 37, 53, 62]", + "missing_cleanup_gate": "sources not restored: [45]", + "unpaid_low_frame": "climb not nested: register 45 from frame 182 (dim 2) to frame 47 (dim 1)", + "ascending_stale_slice_offsets": "targets not y + x: [8, 13, 21, 29, 33]", + "stale_cleanup": "scalar map accepted; H4 literal-reversal contract rejected" + }, + "unchanged_register_paths": 660, + "original_additions": 26916, + "replacement_additions": 26858, + "replacement_canonical_sha256": "362325782cc1b2b3c427312d56b0450d7255f2afcaf17e07a29827e722159026" +} diff --git a/research/r420-two-block-composition/README.md b/research/r420-two-block-composition/README.md new file mode 100644 index 0000000000..eb535b98e0 --- /dev/null +++ b/research/r420-two-block-composition/README.md @@ -0,0 +1,182 @@ +# Compose and replay the PR670 and PR674 R420 circuits + +This package combines **yongjae321's PR670 block-3 circuit** and +**x0hu's PR674 block-5 circuit** in eumemic's PR543 R420 supplier. The new +contribution is their checked composition and fresh native and whole-owner +replay. The two input circuit improvements belong to those authors. + +The combined word uses **26,858 scalar ADDs instead of 26,916**, a saving of +58 per local invocation, including literal cleanup. Its 660 register frame +paths, 420 helpers, nine retained totals and paid rank mass 5,112 stay the +same. **There is no new bit exponent or integer κ.** No selected-frontier +file or predecessor source is changed. + +## Reproduce + +From the repository root, use Python 3.10 or later for the standard-library +check of the composition, complete local word and controls: + +```sh +python3 -B research/r420-two-block-composition/verify.py +``` + +For the full contribution, provide NumPy, SciPy, SymPy, a C++17 compiler and +Boost headers, then run: + +```sh +python3 -B research/r420-two-block-composition/verify.py --hosted +``` + +`--hosted` includes fresh five-, nine- and eleven-stage C++ checks on both +words, then the nine-stage physical hosting and invoice checks on both. +`--native` runs only the C++ part. Run with Python assertions enabled. +Set `CXX` and `BOOST_INCLUDE` for installations outside the default search +paths. The author used `CXX=/opt/homebrew/bin/g++-16` and +`BOOST_INCLUDE=/opt/homebrew/include` on macOS. + +The command creates a temporary output directory and prints its path. +Use `--output /absolute/new/directory` to keep outputs at another location. +Expected final line: + +```text +PASS_R420_TWO_BLOCK_COMPOSITION local_additions=26916->26858 saved=58 kappa=unchanged +``` + +The outputs include both words, exact receipts and each subprocess log. +Use the canonical decoded JSON hash in `RESULT.json` to identify a generated +word. Gzip container bytes can differ across environments. + +## Pins and provenance + +Base: `66849e1475c930fd7732b1a0067ffee7e1e95f60`. +The selected conditional κ at this base is +`51110230636731/31250000000000000 = 0.001635527380375392`, from #626 with +#543. This composition does not depend on claims in newer frontier PRs. + +| Source | Pinned head | Role | +|---|---|---| +| PR543, eumemic | `2065fe4f72a914d907f1046603f5a36f17018535` | Original R420 word and replay chain | +| PR670, yongjae321 | `2e31fcad7f9ecc8b97039ecb2333e581fd725fa1` | Block 3: 50 to 33 XORs | +| PR674, x0hu | `1b01fd8b135fb2c458554fbbbab4338336bf366d` | Block 5: 46 to 34 XORs | + +[SOURCES.json](SOURCES.json) pins every consumed research source and input +by SHA-256 and Git blob ID. The original circuit certificates and READMEs +are retained byte for byte under `vendor/`. Neither predecessor's verifier +is imported. Each single-block reconstruction must match its author's +canonical complete-word hash before the circuits are combined. + +Assignment seed 15 came from operating-system randomness. It initially +selected block 5. A 10,000-trial two-sided synthesis search found a 37-gate +word, but PR674 then supplied a stronger circuit for the same block. That +local experiment is archived and is not submitted as a competing result. +The one scope pivot was to compose and verify the two concurrent circuits. +[CLAIM.json](CLAIM.json) records the selection and pivot. No pinned sprint +issue existed at the claim or overlap checks. This composition performs no +new search and makes no optimality claim. + +## Exact composition argument + +The original slices are `B[263:313]` at frame 545 and `B[371:417]` at frame +547. These are zero-based, half-open intervals. The circuits use disjoint +sets of twelve source registers. No target reads occur inside either slice. +The builder applies the higher slice first, so the first replacement does +not invalidate the second slice's offsets. It then regenerates C once as +the literal reverse of all non-target gates in A and the new B. + +The checker independently enumerates all 4,096 scalar inputs for each +block. Each replacement has exactly the same ordered F2 output map as its +original, with no free output permutation. Thus each block produces the +same values for all later gates, including partially formed sums. Their +composition has the same raw source and target maps. Literal reverse +cleanup restores arbitrary source and helper values. The inherited PR543 +checker verifies this conclusion on all 660 symbolic columns, and checks +H1–H5 and all 672 closed rational frames. + +The checker also constructs the forward and reverse nonnegative transfer +matrices for both blocks. Each replacement matrix is entrywise no larger +than the original. This establishes non-increase for arbitrary nonnegative +input bounds at each substituted slice. These matrices bound the signed +lift; F2 equality is not presented as an integer-ring endpoint identity. +Fresh C++ replay checks the actual complete lifted word at all three stage +counts and computes its prefix bounds. + +Every register has exactly the same ordered frame path. D, A, scatter, +retained totals, labels, endpoints and helper stock are unchanged. Thus +source access, dirty compensation, copies, restoration and all recursive +children are included. The paid local profile remains + +```text +1320 H_1 + 1440 H_2 + 60 H_4 + 120 H_5 + 9 H_8. +``` + +| Local quantity | Original | Composition | +|---|---:|---:| +| B gates | 837 | 808 | +| C gates | 2,661 | 2,632 | +| Scalar ADDs, including D and scatter | 26,916 | 26,858 | +| Serialized native records | 29,874 | 29,816 | +| Forward cancellation-free signed row bound | 144,651 | 144,651 | +| Reverse cancellation-free signed row bound | 2,270,064 | 2,145,492 | +| Payload prefix charge, in bits | 100 | 100 | + +The nine-stage replay uses the original frozen owner selection. It does +not rerun the discovery optimizer. The unchanged emitter and independent +auditor check the actual new scalar stream, every whole helper owner, +idle window, residual coordinate and paid remainder. Both the baseline +and composition must pass the 17 parent-template and 16 hosted-template +mutation controls. The 120,960 helper invocations remain fully hosted, +with zero banks. The physical program has 288 local invocations, so the +replay must show exactly `288 * 58 = 16,704` fewer emitted instructions. + +Both exact moment engines and the finite invoice are rerun. The bit +exponent must remain `0.001653826988146798944268`. The rounded invoice and +paid global profile must match the fresh baseline. The unrounded global +prefix and coefficient bounds each decrease from 189 to 188 bits; their +charged prefix stays at 192 bits. The two-level charge stays at 512 bits. +The emitted instruction count decreases from 8,603,712 to 8,587,008. +The inherited price +script also runs its historical cited-PR484 arithmetic control. That is +not a replay of PR484's complex construction or a new selected assembly. + +## Controls and verification boundary + +The local controls deliberately break each component's map while rebuilding +its correct inverse, omit a cleanup gate, use an unpaid low frame, and +apply both edits with stale ascending offsets. Each must fail for its +stated target, restoration or frame reason. Keeping the old cleanup still +passes scalar replay because its map is the same, but fails the required +literal-reversal hypothesis H4. It is classified as an interface failure. +The C++ replay also rejects 6, 18 and 24 omitted bridges at five, nine and +eleven stages for each word, covering 900, 1,380 and 1,620 formal columns. + +See [VALIDATION.json](VALIDATION.json) for the actual runs and limits. +The repository-wide `make verify` was started once. It passed the earlier +community, producer, partial-gauge, three-stage-cover and paired-cube +groups, then was stopped during recycled-bit verification after free disk +space fell below the workspace's prior resource threshold. It is not a +full-suite pass. Extra checkout copies from that broad run were removed; +existing research and `upstream/` were preserved. + +No new complex supplier, selected outer assembly, Lean theorem or practical +runtime speedup is claimed. The all-size compiler, common-label and mutable +basis realization, whole-owner hosting, precision/tape and analytic-transfer +assumptions remain. Finite replay does not prove the full multiplication +theorem. The original PR612 Lean literals do not certify these new gates. +PR661 fixes the gate stream and excludes resynthesis, so its frame result +is not contradicted. + +## Credit and license + +The block-3 circuit is yongjae321's PR670 contribution. The block-5 circuit +is x0hu's PR674 contribution. Both disclose substantial OpenAI Codex +assistance. Their original notices remain in the vendored READMEs. +Ali Romman prepared this composition and integration replay with +substantial OpenAI Codex assistance. No separate human review is claimed. +New files are under the repository's Apache-2.0 license. + +The R420 word, scalar interface and independent local checker are eumemic's +PR543/493 work. Credit is retained for Zhihao Chen's interface and geometry; +Dylan Crow's bit format, exporter and cohort checkers; DaysSky's bridged +checker and hosting; DreamingOfClouds' nine-stage accounting and moment +engines; chafreaky's owner emitter, audit and invoice; and the cumulative +supplier lineage in the original R420 README. Their sources stay unchanged. diff --git a/research/r420-two-block-composition/SOURCES.json b/research/r420-two-block-composition/SOURCES.json new file mode 100644 index 0000000000..42f0d9530b --- /dev/null +++ b/research/r420-two-block-composition/SOURCES.json @@ -0,0 +1,181 @@ +{ + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "pr543_head": "2065fe4f72a914d907f1046603f5a36f17018535", + "files": { + "research/e8-bit-r420/data/bitE8mut-r420.json.gz": { + "sha256": "9721a3819efd68307f66f00d84a952eb28eb7c3ad2ce79653ce295c98a764784", + "git_blob": "0c63ca62759dc63d302be6552aeeee1ede70350f" + }, + "research/e8-bit-r420/code/xcheck.py": { + "sha256": "5737d18a7826fd51e131035f2d7bebba2e2868af91dd7672a5f11208b036d424", + "git_blob": "fbff8607e4c61e18481f696b99dd38a32444e90d" + }, + "research/e8-bit-r420/code/nodeopt.py": { + "sha256": "6a5896f60b1fe05c41ab28ce822dff782c635e12d0c74fad20b5ce2a4010fa3f", + "git_blob": "dd30a2e4e6e33ba60669d7b421229a2f6e53d6ad" + }, + "research/e8-bit-r420/code/gen_l3.py": { + "sha256": "d5c802447c99255db1bdfcae62b2116bfc9612c9dc9000d41aa4f5f2fec9f2f2", + "git_blob": "6bbd36540c5527950a547b0e80d3aacdc653d497" + }, + "research/e8-bit-carrier-skeleton/code/bit/export_records.py": { + "sha256": "8a5999601f917dbb492bb9ae9a344611f18cc7cedc53dc3c76496a369e530eb3", + "git_blob": "3632d370486a02f5456f7643ced03f8c925b2350" + }, + "research/e8-bit-carrier-skeleton/code/bit/regression/stage_cohort.py": { + "sha256": "6c288f6f234b528c1a7c0a4adfb724e91e0fe6b18c8dffad96af3f973de1829a", + "git_blob": "f6d7afe3e623208c4207b6a683a1e3e49249e31c" + }, + "research/e8-bit-carrier-skeleton/code/bit/checkers/legality_h.cpp": { + "sha256": "6c1ef2b24e57781d6951c172a1024fc4300e6fd392c9d6672079a7806ab663b3", + "git_blob": "cb1233c7e96b1aa8bbf4d2e4165d75ab0dca64b9" + }, + "research/e8-bit-carrier-skeleton/code/bit/checkers/columns_h.cpp": { + "sha256": "d1297f9052be4f2496e1ff2a77e4db2c0cdbd7d460d489b4c03e50bf317238ce", + "git_blob": "00c5a3a5d81d083582f60f33dd2e7bea5049c37f" + }, + "research/e8-bit-carrier-skeleton/code/bit/checkers/columns_k.cpp": { + "sha256": "1c344d18fcd494eeca93e259f10cafae7705780e6592f6dcb35b34752dab9bc2", + "git_blob": "42bb232fbec4de703e70cc13dc2f39a3b43a3a01" + }, + "research/e8-bit-carrier-skeleton/code/bit/checkers/json.hpp": { + "sha256": "aaf127c04cb31c406e5b04a63f1ae89369fccde6d8fa7cdda1ed4f32dfc5de63", + "git_blob": "82d69f7c5d044c9887c96b90c97f5639083ecd14" + }, + "research/e8-bit-carrier-skeleton/portable-include/bits/stdc++.h": { + "sha256": "420094be2af295eed03a983dd66debbbe9cfb78d8252859f4498a615a0074b99", + "git_blob": "fc5664e929d9a81d9b4926bee049a93330be86ec" + }, + "research/r420-two-block-composition/vendor/pr670/candidate.json": { + "sha256": "56044254a15b52ae91ec166f37ba8a75c63df05d62f4e13fa594df86677ba3f8", + "git_blob": "325c18cd442bc97de6abc70e29270be369ae2fce" + }, + "research/r420-two-block-composition/vendor/pr670/README.md": { + "sha256": "fec0d2a1616439d928501fa5c8242ae9aa29773ee6e09a5bc5fb4d4935b990bb", + "git_blob": "27ae6013c1e790275012b84b7b9e8a436bb621d7" + }, + "research/r420-two-block-composition/vendor/pr670/CERTIFICATE.json": { + "sha256": "13022fa6b92c8bc9ef54904317fcc6bee262345c8fc8878310dd01a7ea9c0893", + "git_blob": "f12ced35c28e1f3815f77ced9184e23c601e9264" + }, + "research/r420-two-block-composition/vendor/pr674/README.md": { + "sha256": "634d29b7895b60fc6efbaf342401600661785715466f01d9fcb2e912e12094a1", + "git_blob": "1366b768f1f407788f2a92d72df327f7ea802ef3" + }, + "research/r420-two-block-composition/vendor/pr674/certificate.json": { + "sha256": "8283275a39b5b7167e562af95a9cfe7cc4602385523ca653900b62f4da2a77fe", + "git_blob": "cc1657413365ba695f6d610186c761f64e160ef5" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/code/assemble9.py": { + "sha256": "4bf6768224a3fac81ccda26df24f3763f9a4fbc35ad62bef2888595cdae519fe", + "git_blob": "238226c568742dd5723b03eabae564a2eaa2bda9" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/code/adapt.py": { + "sha256": "27b6b77cc4ebf439f9019e63a22dedc1ef72ee65fe120aad3d17316b1df06d7b", + "git_blob": "7c595c50bc3910577f8587ca94ce8b9c0e6f55b0" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/idle-axis-hosting/hosting_core.py": { + "sha256": "d8b90cd5d152df3c7c351230863d9e61816ad5e1f21d69bea1a86a5daad559a3", + "git_blob": "68b536daa9e6546c0aa046934bf840aaa3c3fde3" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r740-replica32/code/config.py": { + "sha256": "283d7fad45155ee91e704d63ec947cf4a60aeff5cc43510bc0e835f7da7d8767", + "git_blob": "c6824d9c4ea37d58c0d24cb7a3021c4dfcc6f3bb" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r740-replica32/code/e8core.py": { + "sha256": "1cb286196c1530d06f50f0997febc5993b388f33464e295611b920ba30a24eeb", + "git_blob": "78983b368715e89fe8524a6dd2c13585d2b5394e" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r740-replica32/code/bank_routes.py": { + "sha256": "7c6997c455bd55acca3a1603797c34e7733d557c27a7694a1429ff15773a505d", + "git_blob": "9e43a876664a26899762f3b8e9a582e684a3650a" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r740-replica32/code/tile_m.py": { + "sha256": "d6ae4a556472d403773cd2117c992bfc10e1187112da1b3893f3fae628a131dd", + "git_blob": "cd5fd9b5399f5e7afe5d2a95bd3504bd543c0d60" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r740-replica32/code/engines/base_two_moment.py": { + "sha256": "aee70c242a2f1d225528fabe2002e1564d1dc884797c07d28a831c7878ee9098", + "git_blob": "14a90fa0e788217856f070382c9e61bd7c603c61" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r740-replica32/code/engines/moment.py": { + "sha256": "81cbc864e106418fc7854322746f72180cb8110ff39f74450a3b8d55a82c1482", + "git_blob": "7d697cb45203fe72d97037403d6da41f71f3b7fd" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r740-replica32/code/engines/outer.py": { + "sha256": "c1ebb52163a7219504c728a5c2b098bf1e50bf20148a2879c5a74c3cadc7c03c", + "git_blob": "43007488ad2c43187c77cc6798beff8b1cd76ad2" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r715-eleven-stage-whole/code/bank_routes_k.py": { + "sha256": "ea678a7befda10c6f1b9dd38a36fe1437c6468472bd649f60b9f01522047e0bf", + "git_blob": "aaab9d5ae3f280dcb82775337d88dc244984e225" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r715-eleven-stage-whole/code/global_k.py": { + "sha256": "6368196a393ac25bb2918880e4c4bd31ed733b762c27b6873ab391cbc0c5c3c8", + "git_blob": "3df12bd632f1fdba825ced57110a1fee82eb2857" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r715-eleven-stage-whole/code/emit_k.py": { + "sha256": "298b16c3d4f58a468ad1a64564c8500cb281414a3f3c0428fd467908eeb4a4b4", + "git_blob": "b84c795a045143639efe6aefb0562b3c20a2c9d7" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r715-eleven-stage-whole/code/audit_hosted_k.py": { + "sha256": "57e558c80a2fea6e291587b04afd76dfaee3550729997798b61f33daf90b8ec9", + "git_blob": "8864ca9b942a3507171edca0cf6cbaaf10fcf434" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r715-eleven-stage-whole/code/audit_parent_k.py": { + "sha256": "374e1d983589463bbfa06b6e9f2ffafb9d2c14acf97b1f858593a3cef90e93d2", + "git_blob": "ee54ca566ff9d8553f845144dd4570fa1fe21495" + }, + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r715-eleven-stage-whole/code/hosting_k.py": { + "sha256": "081c3b95b18d900d97ce82af64fb428f085b6adc6d8ca93ea920797dad7eb81e", + "git_blob": "02fea8320b676e14f8ffa242c3ddfa85fa829e31" + }, + "research/e8-bit-carrier-skeleton/code/hub/e8-r740-replica32/code/engines/base_two_moment.py": { + "sha256": "aee70c242a2f1d225528fabe2002e1564d1dc884797c07d28a831c7878ee9098", + "git_blob": "14a90fa0e788217856f070382c9e61bd7c603c61" + }, + "research/e8-bit-carrier-skeleton/code/hub/e8-r740-replica32/code/engines/moment.py": { + "sha256": "81cbc864e106418fc7854322746f72180cb8110ff39f74450a3b8d55a82c1482", + "git_blob": "7d697cb45203fe72d97037403d6da41f71f3b7fd" + }, + "research/e8-bit-carrier-skeleton/code/hub/e8-r740-replica32/code/engines/outer.py": { + "sha256": "c1ebb52163a7219504c728a5c2b098bf1e50bf20148a2879c5a74c3cadc7c03c", + "git_blob": "43007488ad2c43187c77cc6798beff8b1cd76ad2" + }, + "research/e8-bit-r420/data/selection9-r420.json": { + "sha256": "9737b5f39367ee5a8affa52e5fbb92d1408f0f9e9f14ed64d6f00ea9428b291c", + "git_blob": "ea2a3ad0d5bcda741f32a2acfbd8e091cd5a05e4" + }, + "research/e8-bit-carrier-skeleton/code/nine/geometry.py": { + "sha256": "36eeda3184bd009e89462b65c8725d10860c444f8da8f1f87e5f6e50120011ca", + "git_blob": "91594e0223e8fac49162b5aef834ffaa8e94a254" + }, + "research/e8-bit-carrier-skeleton/data/bit/bitE8-r865.json.gz": { + "sha256": "1fb726ea3818fe0837cceb0dd22a71a0814f064e5e781628104610d6468e0e55", + "git_blob": "8bec1751f7e33c3a1e4673ef5dbc34d6f205321e" + }, + "research/e8-bit-carrier-skeleton/data/eleven/residual-isometries.json": { + "sha256": "0fa5b353a0321af2ce4e2045db1d4c2d6418a11663894e2afcdb1eaa1984bddc", + "git_blob": "5c645b267861fd0994d2679885f8e0bbf99640b0" + }, + "research/e8-bit-carrier-skeleton/data/complex-b.json": { + "sha256": "dce3f4b76aa3f6c3ba826ce556ffa61398b33e81e4d1a226dd2a36ce684fb02e", + "git_blob": "0df48f8e590fc9ad01ca4d6eaf97b9acc10aac7d" + } + }, + "context_prs": { + "589": "a5afc8c6169ea61ba7c51dfd3cade02cc7b13b46", + "612": "ce37f3ce35ba8891771e01492b3a21978763bebb", + "661": "9ca7aa3ab0a3260a2f36ac86b9911a31fd88bd89" + }, + "concurrent_sources": { + "670": { + "head": "2e31fcad7f9ecc8b97039ecb2333e581fd725fa1", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/670" + }, + "674": { + "head": "1b01fd8b135fb2c458554fbbbab4338336bf366d", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/674" + } + } +} diff --git a/research/r420-two-block-composition/VALIDATION.json b/research/r420-two-block-composition/VALIDATION.json new file mode 100644 index 0000000000..c7a5844b2a --- /dev/null +++ b/research/r420-two-block-composition/VALIDATION.json @@ -0,0 +1,72 @@ +{ + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "verified_utc": "2026-10-13T04:01:23.951039+00:00", + "status": "PASS focused composition, native, whole-owner and bit-invoice checks", + "environment": { + "platform": "macOS-26.6.1-arm64-arm-64bit-Mach-O", + "python": "3.14.7", + "numpy": "2.5.4", + "scipy": "1.18.1", + "sympy": "1.14.0", + "compiler": "g++-16 (Homebrew GCC 16.2.0) 16.2.0", + "boost": "1.92" + }, + "reproduction": "python3 -B research/r420-two-block-composition/verify.py --hosted", + "runs": { + "standard_library": "PASS", + "all_4096_inputs_per_block": "PASS", + "full_dirty_columns": 660, + "native_formal_columns": [ + 900, + 1380, + 1620 + ], + "native_omitted_bridge_controls_per_word": [ + 6, + 18, + 24 + ], + "parent_template_controls_per_word": 17, + "hosted_template_controls_per_word": 16, + "whole_owner_helper_invocations_per_word": 120960, + "selected_record_check": "PASS", + "optimized_python": "refused before inherited checks", + "existing_output": "refused without overwrite", + "remote_ci": "not run", + "final_source_native_replay": "PASS; semantic receipt equals the full hosted run after removal of an unused import" + }, + "repository_wide_suite": { + "command": "make verify", + "status": "INTERRUPTED, not a pass", + "exit_code": 143, + "reason": "Stopped this task process tree during recycled-bit verification after observed free disk space fell to about 2.2 GiB. No failure of a mathematical check was observed before interruption. Extra checkout copies were then removed.", + "completed_groups": [ + "verify-community", + "verify-producers", + "verify-partial-gauge", + "verify-three-stage-cover", + "verify-paired-cube" + ], + "log_sha256": "3385d40e122d5bda2b30337efa16f04bc2268b10c4893a179765220370a8be8f" + }, + "overlap": { + "checked_through_pr": 680, + "main_head": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "pr670_head": "2e31fcad7f9ecc8b97039ecb2333e581fd725fa1", + "pr674_head": "1b01fd8b135fb2c458554fbbbab4338336bf366d", + "distinct_evidence": "Composition plus new C++ multistage and whole-owner/invoice replay, absent from both predecessor submissions." + }, + "source_sha256": { + "hosted.py": "b2de36cf635053a5732153a3f983ff96dac374a493d58acf1495daf2d9065bd7", + "native.py": "2b7d0c5451c55dea8524a2bad04d347db2eb17fe7a8402f6814bb41206a4e0cb", + "verify.py": "68b407c5f5629e17f7a475c9dba44dabe0e14553aafd02b6ed34de93404902d4" + }, + "certificate_sha256": "d1412f76c924c5ea0d4da5702f7edd3a9e0949648c57dca39bd9ea1de266e573", + "limitations": [ + "No new kappa or new bit exponent.", + "No complex supplier replay or new selected outer assembly.", + "No full repository-wide suite pass.", + "No full Lean multiplication theorem or separate human review.", + "Inherited all-size, physical, precision/tape and analytic assumptions remain." + ] +} diff --git a/research/r420-two-block-composition/hosted.py b/research/r420-two-block-composition/hosted.py new file mode 100644 index 0000000000..51acf58bf5 --- /dev/null +++ b/research/r420-two-block-composition/hosted.py @@ -0,0 +1,78 @@ +"""Replay the frozen nine-stage owner plan for both words, then compare invoices. + +Ali Romman, with substantial OpenAI Codex assistance. Apache-2.0. +Uses the unchanged PR543 / PR510 / PR463 / PR442 verification chain. +""" +import json +import shutil +import subprocess +import sys + + +def run(root, out): + package = root / "research/e8-bit-r420" + predecessor = root / "research/e8-bit-carrier-skeleton" + price = package / "vendor/pr510/e8-r480-nine-stage" + code = price / "vendor/e8-r715-eleven-stage-whole/code" + python = [sys.executable, "-B"] + results = {} + + def call(name, command): + print("RUN", name, flush=True) + with (out / (name + ".log")).open("w") as log: + subprocess.run(list(map(str, command)), check=True, stdout=log, stderr=subprocess.STDOUT) + + geometry = out / "geometry" + call("geometry", python + [predecessor / "code/nine/geometry.py", "--source", predecessor, "--out", geometry]) + call("parent-audit-adapter", python + [price / "code/adapt.py", code, out / "adapted"]) + for name in ("baseline", "replacement"): + base = out / name + parent = base / "nine" + parent.mkdir() + shutil.copy2(geometry / "GEOMETRY.json", parent / "GEOMETRY.json") + word = out / (name + ".json.gz") + call(name + "-parent", python + [code / "global_k.py", "--word", word, + "--local-check", base, "--out", parent, "--isometries", predecessor / "data/eleven/residual-isometries.json"]) + call(name + "-parent-audit", python + [out / "adapted/audit_parent_k.py", + "--word", word, "--local-check", base, "--out", parent]) + hosted = base / "hosted" + call(name + "-hosted", python + [code / "emit_k.py", parent, base, hosted, + "--selection", package / "data/selection9-r420.json", "--key", "bit"]) + call(name + "-hosted-audit", python + [code / "audit_hosted_k.py", base, hosted, hosted / "AUDIT.json"]) + + # The unchanged pr484 price is a historical arithmetic control only. + # No complex construction is replayed or selected by this command. + call(name + "-invoice", python + [price / "code/assemble9.py", base, hosted, + hosted / "AUDIT.json", predecessor, base / "PRICE.json", "pr484"]) + pg = json.loads((parent / "GLOBAL.json").read_text()) + parent_audit = json.loads((parent / "AUDIT.json").read_text()) + audit = json.loads((hosted / "AUDIT.json").read_text()) + invoice = json.loads((base / "PRICE.json").read_text()) + if (parent_audit["status"] != "PASS_INDEPENDENT_COMPRESSED_BIT_TEMPLATE_AUDIT" + or audit["status"] != "PASS_INDEPENDENT_REPLICATED_HOSTING_AUDIT" + or invoice["status"] != "PASS_NINE_STAGE_WHOLE_HOSTED_BIT_PRICE_AND_CITED_ASSEMBLY"): + raise ValueError("Hosted verification did not pass") + if audit["hosted_residuals"] != 120960 or audit["bank_assignments"] != 0: + raise ValueError("Whole-owner inventory changed") + if len(parent_audit["mutations_rejected"]) != 17 or len(audit["mutations_rejected"]) != 16: + raise ValueError("Incomplete inherited mutation coverage") + results[name] = {"parent_mutations": parent_audit["mutations_rejected"], "hosted_audit": audit, + "bit_lower": invoice["bit_lower"], "bit_lower_decimal": invoice["bit_lower_decimal"], + "invoice": invoice["bit"], "global_prefix_bound": pg["global_prefix_bound"], + "bit_profile": invoice["bit_profile"], "local_additions": pg["local_additions"]} + old, new = results["baseline"], results["replacement"] + if old["bit_profile"] != new["bit_profile"] or old["bit_lower"] != new["bit_lower"]: + raise ValueError("The recursive profile or bit exponent changed") + if new["bit_lower_decimal"] != "0.001653826988146798944268": + raise ValueError("The original R420 bit price was not reproduced") + if old["hosted_audit"]["emitted_events"] - new["hosted_audit"]["emitted_events"] != 288 * 58: + raise ValueError("Wrong physical instruction saving") + if int(new["global_prefix_bound"]) > int(old["global_prefix_bound"]): + raise ValueError("The global prefix bound increased") + raw_bounds = {"prefix_bits", "coefficient_bits", "two_level_coefficient_bits"} + if any(new["invoice"][key] > old["invoice"][key] for key in raw_bounds): + raise ValueError("An unrounded finite bound increased") + if ({k: v for k, v in old["invoice"].items() if k not in raw_bounds} + != {k: v for k, v in new["invoice"].items() if k not in raw_bounds}): + raise ValueError("The charged finite invoice changed") + return results diff --git a/research/r420-two-block-composition/native.py b/research/r420-two-block-composition/native.py new file mode 100644 index 0000000000..84afab02a9 --- /dev/null +++ b/research/r420-two-block-composition/native.py @@ -0,0 +1,70 @@ +"""Compare the original and replacement words with the pinned cohort checkers. + +Ali Romman, with substantial OpenAI Codex assistance. Apache-2.0. +""" +import json +import os +import shlex +import subprocess +import sys + + +def run(root, out): + package = root / "research/e8-bit-carrier-skeleton" + bit = package / "code/bit" + checkers = bit / "checkers" + python = [sys.executable, "-B"] + compiler = shlex.split(os.environ.get("CXX", "c++")) + include = os.environ.get("BOOST_INCLUDE", "/usr/include") + flags = ["-O2", "-std=c++17", "-DHDIM=8", "-DNCOPY=9", "-DVPORTS=120", "-DRHELP=420", + "-I" + str(package / "portable-include"), "-I" + str(checkers), "-I" + include] + bindir = out / "bin" + bindir.mkdir() + + def call(name, command): + with (out / (name + ".log")).open("w") as log: + subprocess.run(list(map(str, command)), check=True, stdout=log, stderr=subprocess.STDOUT) + + call("compile-legality", compiler + flags + ["-o", bindir / "legality", checkers / "legality_h.cpp"]) + for pairs in (2, 4, 5): + call("compile-columns" + str(pairs), compiler + flags + ["-DKPAIRS=" + str(pairs), "-o", + bindir / ("columns" + str(pairs)), checkers / "columns_k.cpp"]) + results = {} + for name in ("baseline", "replacement"): + base = out / name + records, cin, cout = (base / item for item in ("records", "cin", "cout")) + call(name + "-export", python + [bit / "export_records.py", out / (name + ".json.gz"), records]) + call(name + "-cohort", python + [bit / "regression/stage_cohort.py", records, records, cin, cout]) + call(name + "-legality", [bindir / "legality", cin, cout, cout / "legality.json"]) + legality = json.loads((cout / "legality.json").read_text()) + if legality["status"] != "PASS_INDEPENDENT_COHORT_LEGALITY_SOURCE_OWNERS_AND_LIFECYCLE": + raise ValueError("Legality did not pass") + results[name] = {"legality": legality, "stages": {}} + for pairs in (2, 4, 5): + receipt = cout / ("columns.json" if pairs == 2 else "columns" + str(pairs) + ".json") + call(name + "-columns" + str(pairs), [bindir / ("columns" + str(pairs)), + cout / "COHORT249-RECORDS.bin", receipt]) + data = json.loads(receipt.read_text()) + expected_status = ("PASS_NEW_COHORT249_ALL_FIVE_STAGE_FORMAL_COLUMNS_AND_PREFIX_BILL" if pairs == 2 + else "PASS_NEW_COHORT249_ALL_BRIDGED_STAGE_FORMAL_COLUMNS_AND_PREFIX_BILL") + if data["status"] != expected_status: + raise ValueError("Formal columns did not pass") + expected = 6 * (pairs - 1) + if (len(data["negative_controls"]) != expected + or not all(c["rejected"] for c in data["negative_controls"])): + raise ValueError("A bridge control failed") + if data["formal_columns_checked"] != 240 * pairs + 420: + raise ValueError("Wrong formal column count") + results[name]["stages"][str(2 * pairs + 1)] = { + key: data[key] for key in ("formal_columns_checked", "local_scalar_additions", "local_raw_H", + "payload_prefix_bits", "payload_prefix_upper", "signed_lift_prefix")} + for stages in ("5", "9", "11"): + old, new = (results[name]["stages"][stages] for name in ("baseline", "replacement")) + if old["local_raw_H"] != new["local_raw_H"] or old["local_scalar_additions"] - new["local_scalar_additions"] != 58: + raise ValueError("Paid profile or XOR saving differs") + if int(new["payload_prefix_upper"]) > int(old["payload_prefix_upper"]): + raise ValueError("Payload bound increased") + for a, b in zip(old["signed_lift_prefix"], new["signed_lift_prefix"]): + if a["reverse"] != b["reverse"] or int(b["cancellation_free_signed_row_l1_upper"]) > int(a["cancellation_free_signed_row_l1_upper"]): + raise ValueError("Signed bound increased") + return results diff --git a/research/r420-two-block-composition/vendor/pr670/CERTIFICATE.json b/research/r420-two-block-composition/vendor/pr670/CERTIFICATE.json new file mode 100644 index 0000000000..f12ced35c2 --- /dev/null +++ b/research/r420-two-block-composition/vendor/pr670/CERTIFICATE.json @@ -0,0 +1,211 @@ +{ + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "block": { + "frame": 545, + "index": 3, + "original_gates": 50, + "registers": [21, 29, 37, 45, 53, 62, 71, 73, 81, 89, 97, 105], + "replacement_gates": 33 + }, + "candidate_sha256": "6f6c4ac73957585ad5aaef96612b4e8a681d7e91a493720639f57c015accf3c6", + "conclusion": { + "C_is_U_inverse": true, + "J_identity": true, + "K_equals_D": true, + "U_block_form": true + }, + "frame_paths_equal": true, + "frame_paths_sha256": "ef52add0118de86406ed3c58d6ff53b06b127c05238895b475181e55b98021ca", + "hypotheses": { + "H1_no_target_feeds_z": true, + "H2_D_frame0_targets_from_helpers": true, + "H3_A_z_only_scatter_targets_B_split": true, + "H4_C_literal_reverse_at_full": true, + "H5_V_identity": true + }, + "independent": { + "baseline_content_sha256": "e597e3885c0a8daa262afa5985ee2930443329126aece76d33159d81882bdcc2", + "block_columns_checked": 12, + "block_map_sha256": "c63d2346c766de7e48e3c5c23d6bf2b7f804babe9e61fcbb5c854a2b755ec644", + "candidate_content_sha256": "b5dc0d0af4e499f8304cc76e5ffe8cfee86e29e1185f88dab2f3009bdc30c9c7", + "certificate_sha256": "6f6c4ac73957585ad5aaef96612b4e8a681d7e91a493720639f57c015accf3c6", + "componentwise_nonnegative_transfer_dominance": { + "forward_transfer": true, + "reverse_transfer": true + }, + "dirty_helper_columns": 420, + "exported_local_scalar_prefix": { + "baseline": { + "forward": 144651, + "fresh_copies": 9, + "payload_prefix_bits": 100, + "payload_prefix_upper": 998206739997057013039187410944, + "reverse": 2270064, + "scalar_additions": 26916 + }, + "candidate": { + "forward": 144651, + "fresh_copies": 9, + "payload_prefix_bits": 100, + "payload_prefix_upper": 925614833593522808541496863744, + "reverse": 2185964, + "scalar_additions": 26882 + }, + "no_increase": { + "forward": true, + "payload_prefix_upper": true, + "reverse": true + } + }, + "fixed_physical_output_assignment": true, + "full_word_columns_checked_per_word": 660, + "full_word_map_sha256": "c4ac5e49d00e5565a8b43c356114a419f9a7dc2e9dbe1ced8c98d27862c10817", + "helpers_restored": true, + "literal_reversed_cleanup": true, + "local_gates": { + "baseline": 50, + "candidate": 33, + "whole_word_binary_ADD_saving": 34 + }, + "local_round_trip_unit_max": { + "baseline": 2431, + "candidate": 587 + }, + "method": "One F2 input column at a time; active-register sets; no builder or checker imports", + "paid_frame_profile": { + "per_register_frame_paths_sha256": "ef52add0118de86406ed3c58d6ff53b06b127c05238895b475181e55b98021ca", + "rank_mass": 5112, + "raw_H": { + "1": 1320, + "2": 1440, + "4": 60, + "5": 120, + "8": 9 + } + }, + "scope": "Finite local word and cohort prefix only; no hosted invoice or kappa claim.", + "sources_restored": true, + "status": "PASS_INDEPENDENT_BLOCK_AND_ALL_DIRTY_INPUT_COLUMNS", + "targets_equal_y_plus_x": true, + "unchanged_each_register_frame_path": true + }, + "labels": { + "frames": 672, + "gram_det": 1, + "labels": 120, + "lattice_rank": 8 + }, + "local_histogram": { + "1": 1320, + "2": 1440, + "4": 60, + "5": 120, + "8": 9 + }, + "negative_controls": [ + "wrong source fingerprint", + "new register outside the claimed interface", + "singular self XOR", + "incorrect endpoint certificate", + "dropped gate changes the F2 map", + "changed B map with matching cleanup", + "F2-correct old cleanup violates literal-reversal H4", + "illegal line frame for a block gate", + "missing dirty-helper compensation", + "F2-neutral repeated gates increase the positive bill" + ], + "original_gates": { + "A": 2064, + "B": 837, + "C": 2661, + "D": 120 + }, + "original_prefix_bill": { + "forward": 144651, + "payload_bits": 100, + "payload_upper": 998206739997057013039187410944, + "reverse": 2270064, + "scalar_additions": 26916 + }, + "positive_transfer_matrices": { + "forward": { + "original": [ + [1, 1, 1, 1, 1, 1, 0, 0, 1, 2, 1, 1], + [1, 2, 3, 1, 1, 1, 1, 1, 1, 3, 2, 1], + [1, 1, 3, 1, 1, 2, 1, 1, 2, 2, 1, 1], + [0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1], + [1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1], + [1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1], + [2, 1, 3, 1, 3, 3, 1, 1, 3, 3, 2, 1], + [1, 1, 2, 1, 1, 1, 1, 1, 2, 3, 1, 1], + [1, 2, 3, 1, 1, 1, 1, 1, 1, 3, 3, 1], + [2, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 2] + ], + "replacement": [ + [1, 1, 1, 1, 1, 1, 0, 0, 1, 2, 1, 1], + [1, 2, 3, 1, 1, 1, 1, 1, 1, 3, 2, 1], + [1, 1, 3, 1, 1, 2, 1, 1, 2, 2, 1, 1], + [0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1], + [1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1], + [1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1], + [2, 1, 3, 1, 3, 3, 1, 1, 3, 3, 2, 1], + [1, 1, 2, 1, 1, 1, 1, 1, 0, 3, 1, 1], + [1, 2, 3, 1, 1, 1, 1, 1, 1, 3, 3, 1], + [2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2] + ] + }, + "reverse": { + "original": [ + [2, 1, 1, 18, 2, 1, 3, 5, 1, 1, 1, 0], + [2, 4, 3, 34, 2, 1, 3, 13, 2, 1, 3, 0], + [1, 1, 2, 15, 1, 1, 2, 5, 1, 0, 1, 0], + [8, 10, 9, 111, 8, 3, 11, 40, 7, 4, 9, 1], + [0, 0, 0, 2, 1, 0, 1, 0, 0, 0, 0, 0], + [0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0], + [2, 1, 1, 23, 3, 2, 6, 5, 1, 1, 1, 0], + [6, 4, 5, 74, 8, 5, 14, 21, 4, 3, 4, 0], + [1, 1, 1, 11, 1, 0, 1, 4, 1, 0, 1, 0], + [1, 1, 1, 13, 1, 0, 1, 5, 1, 1, 1, 0], + [0, 1, 0, 4, 0, 0, 0, 2, 0, 0, 1, 0], + [3, 2, 2, 33, 3, 1, 4, 11, 2, 2, 2, 1] + ], + "replacement": [ + [2, 1, 1, 4, 2, 1, 3, 1, 1, 1, 1, 0], + [2, 4, 3, 6, 2, 1, 3, 3, 2, 1, 3, 0], + [1, 1, 2, 3, 1, 1, 2, 1, 1, 0, 1, 0], + [4, 4, 3, 11, 4, 1, 5, 4, 3, 2, 3, 1], + [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], + [2, 1, 1, 5, 1, 0, 2, 1, 1, 1, 1, 0], + [2, 2, 3, 8, 2, 1, 4, 3, 2, 1, 2, 0], + [1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0], + [1, 1, 1, 3, 1, 0, 1, 1, 1, 1, 1, 0], + [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], + [3, 2, 2, 9, 3, 1, 4, 3, 2, 2, 2, 1] + ] + } + }, + "rank_mass": 5112, + "replacement_gates": { + "A": 2064, + "B": 820, + "C": 2644, + "D": 120 + }, + "replacement_prefix_bill": { + "forward": 144651, + "payload_bits": 100, + "payload_upper": 925614833593522808541496863744, + "reverse": 2185964, + "scalar_additions": 26882 + }, + "revised_content_sha256": "b5dc0d0af4e499f8304cc76e5ffe8cfee86e29e1185f88dab2f3009bdc30c9c7", + "schema": "r420-block3-xor-verification/1", + "scope": "Finite local circuit improvement; no new kappa, paid supplier or global optimality claim", + "source_sha256": "9721a3819efd68307f66f00d84a952eb28eb7c3ad2ce79653ce295c98a764784", + "symbolic_columns": 660 +} diff --git a/research/r420-two-block-composition/vendor/pr670/README.md b/research/r420-two-block-composition/vendor/pr670/README.md new file mode 100644 index 0000000000..27ae6013c1 --- /dev/null +++ b/research/r420-two-block-composition/vendor/pr670/README.md @@ -0,0 +1,202 @@ +# R420 block 3: 50 to 33 XOR gates, with unchanged paid frame paths + +**Finite local circuit improvement; no new kappa or supplier certificate.** +The phase-B block-3 circuit in eumemic's [PR #543](https://github.com/CrocSwap/integer-mult-bounds/pull/543) +R420 word can use **33 binary XOR gates instead of 50**, with exactly the same +ordered output values on its original twelve registers. Replacing its literal +reverse cleanup saves **34 scalar ADDs** in the complete local word. +No helper, COPY, retained total, compensation gate, recursive child, or physical +frame path is added. Both orientations' cancellation-free transfer matrices +are entrywise no larger than the original matrices. + +The selected result at base **66849e1475c930fd7732b1a0067ffee7e1e95f60** is +the conditional #626/#622/#623 construction with #543, with +`kappa = 51110230636731/31250000000000000 = 0.001635527380375392`. +Its [actual assembly](../community-k492-audit/pr626/replay/ASSEMBLY.json) is +complex-bound. This package leaves that selection untouched. In particular, +fewer common-frame additions with the same paid rank profile do **not** establish +an improved recursive exponent. + +## Reproduce + +From the repository root, with Python 3.11 or later: + +```sh +python -m pip install -r research/r420-block3-xor/requirements.txt +python -B research/r420-block3-xor/verify.py +``` + +Expected final line: + +```text +PASS_R420_BLOCK3_XOR gates=50->33 saved_with_cleanup=34 columns=660 rank_mass=5112 controls=10 +``` + +The command verifies the frozen result without rerunning the search, and writes +`word.json.gz` plus `verification.json` to a **new, uniquely named** directory +under `build/`. `--output PATH` selects a fresh destination; existing paths are +refused. Input words, predecessor code and previous results are read-only. +The output word is compared by canonical decompressed JSON, not its gzip +container hash. `SOURCES.json` binds all consumed predecessor code/data by +SHA-256 and Git blob ID, with explicit LF normalization for text checkouts. + +On Windows, install Python with its `py` launcher and the dependencies above, +then double-click `verify.cmd` for routine verification. Alternatively, +`R420_PYTHON` may select an already installed Python executable. The launcher +needs no code edits and uses the same verifier. Tested on Windows with +Python **3.12.14**, SymPy **1.14.0**, and mpmath **1.3.0**. The independent checker +and search use only the Python standard library; SymPy is used by #543's +inherited exact lattice checker. No packaged executable or GUI is needed for +this fixed mathematical certificate. + +An independent invocation (no optimizer, producer or primary-checker imports): + +```sh +python -B research/r420-block3-xor/independent.py research/e8-bit-r420/data/bitE8mut-r420.json.gz research/r420-block3-xor/candidate.json +``` + +It reports `PASS_INDEPENDENT_BLOCK_AND_ALL_DIRTY_INPUT_COLUMNS`. Its optional +`--word PATH` also checks a separately produced full word against its own +reconstruction. Both implementations are AI-assisted; “independent” describes +their algorithms and import separation, not independent human peer review. + +## Exact object and evidence + +The original half-open range is `B[263:313]`, frame **545** (rank 4), on physical +source registers +`[21,29,37,45,53,62,71,73,81,89,97,105]`. +There are no external reads interleaved within this contiguous block. The +replacement retains the exact physical output assignment, so downstream +needers and target reads require no relabeling or extra source access. +Every other B gate and every D/A/scatter gate is unchanged; C is rebuilt as +the literal reverse of all z-destination gates of A then B, at the full frame. + +`candidate.json` contains both circuits and the twelve output row bitmasks. +`CERTIFICATE.json` contains the exact nonnegative matrices, hashes, full-word +checks, paid profile and prefix quantities, recomputed by the verifier. + +| Quantity | Original | Replacement | +|---|---:|---:| +| Selected block binary XORs | 50 | 33 | +| B gate records | 837 | 820 | +| C gate records | 2661 | 2644 | +| Complete local scalar ADDs, including multisource gates and scatter | 26916 | 26882 | +| Source / target / dirty-helper columns | 120 / 120 / 420 | unchanged | +| Helpers / retained copies | 420 / 9 | unchanged | +| Local rank mass | 5112 | 5112 | +| Local block + reverse unit-weight maximum | 2431 | 587 | +| Exported local forward prefix bound F | 144651 | 144651 | +| Exported local reverse prefix bound B | 2270064 | 2185964 | +| `64 F^3 B^2` | 998206739997057013039187410944 | 925614833593522808541496863744 | +| Payload bound bits | 100 | 100 | + +The last three rows use the **local cohort** convention of the pinned +`export_records.py` and `columns_k.cpp`. Baseline quantities reproduce the +archived #543 `columns_k4.json` receipt exactly. They are not the full hosted +physical invoice. No runtime speedup is inferred from the operation counts. + +Every register has the same sequence of physical frames, not merely the same +aggregate rank sum. Including COPY charges, the local paid profile remains +`{1:1320, 2:1440, 4:60, 5:120, 8:9}`. Thus its moment remains +`1320 + 1440*2^p + 60*4^p + 120*5^p + 9*8^p` for all exponents p. +Existing #543 frame/copy/helper expenses have not been omitted or repriced. + +## Why the replacement is safe for the stated finite scope + +For the twelve-register block, let P and Q be its original and replacement +transfer matrices with **integer addition instead of XOR**. Exact checks give +`0 <= Q <= P` entrywise, and separately give the same inequality for the +literal reversed circuits. Their reductions modulo 2 are identical, with +unchanged row order. Consequently the block's full F2 map is identical for +arbitrary inputs, not just clean helpers or selected examples. + +For any nonnegative vector x of entry bounds, `Qx <= Px`. Inside an ADD-only +block every coordinate increases monotonically, so every replacement prefix +is bounded by its replacement endpoint, hence by the original endpoint. This +is a maximum-prefix statement, not a comparison of equal-index intermediate +steps. Unchanged exterior ADD/COPY/ERASE operations are monotone maps on +nonnegative bounds, so endpoint domination propagates through the rest of the +word. Apply the argument at both changed segments, and separately in the +reversed orientation. The block has no internal COPY/ERASE or outside read. +Frame legality and all per-register frame paths are checked separately. + +The primary verifier reuses #543's exact root-lattice/frame check, simultaneous +F2 replay, H1–H5 interface checks, and their decomposed conclusion. The second +implementation derives the block independently, uses active-register sets to +propagate **each of all 660 input columns separately**, computes rational frame +ranks independently, and checks its full reconstructed word against the primary +word. Both independently compute the scalar prefixes and frame-path hashes. + +Ten negative controls reject: a wrong source fingerprint; a new register; +a singular self XOR; an incorrect endpoint certificate; a dropped gate; +a changed B map with matching cleanup; an F2-correct old cleanup that violates +the **literal-reversal H4 interface**; an illegal line-frame gate; missing +dirty-helper compensation; and an F2-neutral repeated-gate insertion that +increases the positive transfer. The old-cleanup control is deliberately +not described as a scalar counterexample: either equivalent inverse circuit +restores F2 values, but only the matching literal reverse satisfies H4. + +## Bounded search and overlap + +The operating-system assignment seed was **13**, giving the bit-supplier track; +`13 mod 10 = 3` selects this block. See `CLAIM.json` for the three candidate +tasks, local claim and timing. No pinned coordination issue existed. + +The hypothesis was that changing the scalar factorization, while fixing its +ordered outputs, could reduce XOR work without worsening the positive bill. +The nomination uses commuting adjacent transvections and exact adjacent +three-gate replacement by at most two gates. The lookup covers all 132 +directed non-self XORs and all 17,424 ordered two-gate pairs on twelve registers. +Each accepted shortening also has forward and reverse entrywise nonnegative +domination. The seeded outer walk completed **50 trials x 400 shuffle attempts += 20,000 attempts**, accepting 170 shortening steps across trial paths. The +first 33-gate result occurred at zero-based trial 2, step 364. The complete +coverage and improvement trace are in `candidate.json`. + +```sh +python -B research/r420-block3-xor/search.py --seed 13 --trials 50 --steps 400 --output NEW-candidate.json +``` + +This deterministically reproduces the frozen candidate on the tested Python. +The search is bounded and heuristic; it does not enumerate all equivalent +circuits, and 33 is **not** claimed optimal. Verification does not trust the +random walk or require its history. + +[PR #661](https://github.com/CrocSwap/integer-mult-bounds/pull/661) studies +simultaneous frame reassignment with fixed scalar gates/order and explicitly +excludes resynthesis. This contribution changes that excluded mechanism; +it does not reopen the closed fixed-order frame search. #661 is not a code or +proof dependency. [PR #589](https://github.com/CrocSwap/integer-mult-bounds/pull/589) +changes frame transports on the different punctured R439 word. Decoder-floor +work in #620/#631 concerns another object. Final live overlap checks and test +outcomes are recorded in `VALIDATION.json`. + +## Scope, credit and handoff + +This result certifies a finite scalar circuit and local frame/prefix accounting. +It is not an integer-ring endpoint identity: XOR-circuit equivalence is over F2. +The positive matrices bound the absolute-value signed lift; they do not prove +its signed endpoint. Full five/nine/eleven-stage C++ replay, hosted physical +invoices, the supplier assembly and the repository-wide `make verify` were +not rerun for this standalone addition. No replacement is installed into the +selected supplier. Applying it there would require the corresponding full +replays and binding updates by a follow-up contribution. + +Inherited all-size compiler, common-label/mutable-basis realization, pooled +hosting, normalized residual, precision/tape/exact recovery and analytic +transfer assumptions remain. This is not a complete multiplication theorem, +a Lean proof, a general lower bound, or a claim that a stronger kappa exists. + +The predecessor circuit, plan, realization objective and scalar-interface lemma +are **eumemic's #543**, pinned to reviewed head +`2065fe4f72a914d907f1046603f5a36f17018535`, building on #493. +Credit is retained for Dylan Crow's #370 E8 word/exporter, DreamingOfClouds' +#503/#510 construction/pricing, Zhihao Chen's #425 interface, Chafik Boukhalfa's +#472 common-label realization/emitter, DaysSky's #381 bridged-column checker, +and the full lineage listed in +[the original README](../e8-bit-r420/README.md) and +[selected maintainer review](../../docs/research/community-k492-review.md). + +Prepared for GitHub contributor **yongjae321** with substantial **OpenAI Codex** +assistance, including separate workers for nomination, independent checking and +adversarial review. New files are under the repository's **Apache-2.0** license. diff --git a/research/r420-two-block-composition/vendor/pr670/candidate.json b/research/r420-two-block-composition/vendor/pr670/candidate.json new file mode 100644 index 0000000000..325c18cd44 --- /dev/null +++ b/research/r420-two-block-composition/vendor/pr670/candidate.json @@ -0,0 +1,199 @@ +{ + "schema": "r420-block3-xor-candidate/1", + "source_path": "research/e8-bit-r420/data/bitE8mut-r420.json.gz", + "source_sha256": "9721a3819efd68307f66f00d84a952eb28eb7c3ad2ce79653ce295c98a764784", + "block_index": 3, + "b_start": 263, + "b_stop": 313, + "frame": 545, + "registers": [21, 29, 37, 45, 53, 62, 71, 73, 81, 89, 97, 105], + "seed": 13, + "method": "commuting transvections plus exact 3-to-at-most-2 lookup", + "domain": "12 original registers; same ordered 12x12 F2 endpoint; no helpers or relabelling", + "coverage": { + "trials": 50, + "shuffle_steps_per_trial": 400, + "attempted_shuffle_steps": 20000, + "accepted_reductions": 170, + "stopping_rule": "fixed trials times steps; no claim of exhaustive optimality" + }, + "original_gate_count": 50, + "replacement_gate_count": 33, + "original_local_ops": [ + [3, 1], + [3, 11], + [3, 2], + [3, 9], + [3, 8], + [3, 10], + [7, 6], + [7, 0], + [7, 4], + [7, 2], + [7, 9], + [7, 5], + [6, 0], + [6, 4], + [6, 5], + [1, 2], + [1, 9], + [1, 10], + [11, 0], + [11, 9], + [0, 4], + [0, 9], + [0, 5], + [2, 8], + [2, 5], + [9, 8], + [8, 10], + [10, 3], + [10, 7], + [10, 1], + [5, 3], + [5, 6], + [8, 3], + [8, 7], + [8, 0], + [8, 4], + [8, 2], + [9, 3], + [9, 7], + [2, 3], + [2, 7], + [4, 3], + [4, 6], + [0, 3], + [11, 3], + [11, 7], + [1, 3], + [1, 7], + [6, 3], + [7, 3] + ], + "replacement_local_ops": [ + [3, 11], + [1, 2], + [11, 0], + [0, 5], + [0, 4], + [6, 0], + [7, 2], + [2, 5], + [2, 8], + [0, 9], + [7, 6], + [11, 7], + [1, 10], + [1, 9], + [3, 1], + [7, 9], + [9, 3], + [2, 7], + [3, 8], + [11, 3], + [8, 2], + [8, 4], + [8, 10], + [6, 3], + [4, 6], + [5, 6], + [9, 7], + [7, 3], + [1, 7], + [10, 1], + [0, 3], + [2, 3], + [8, 0] + ], + "endpoint_rows": [3391, 3069, 3295, 3854, 3951, 3935, 3967, 3579, 3070, 3835, 4093, 2042], + "nonnegative_forward_componentwise_no_worse": true, + "nonnegative_reverse_componentwise_no_worse": true, + "improvements": [ + { + "trial": 0, + "step": 26, + "gates": 49 + }, + { + "trial": 0, + "step": 40, + "gates": 48 + }, + { + "trial": 0, + "step": 50, + "gates": 47 + }, + { + "trial": 0, + "step": 85, + "gates": 46 + }, + { + "trial": 0, + "step": 89, + "gates": 45 + }, + { + "trial": 0, + "step": 159, + "gates": 44 + }, + { + "trial": 0, + "step": 174, + "gates": 43 + }, + { + "trial": 0, + "step": 212, + "gates": 42 + }, + { + "trial": 0, + "step": 218, + "gates": 41 + }, + { + "trial": 0, + "step": 227, + "gates": 40 + }, + { + "trial": 0, + "step": 237, + "gates": 39 + }, + { + "trial": 1, + "step": 62, + "gates": 38 + }, + { + "trial": 1, + "step": 68, + "gates": 37 + }, + { + "trial": 1, + "step": 121, + "gates": 36 + }, + { + "trial": 1, + "step": 220, + "gates": 35 + }, + { + "trial": 1, + "step": 256, + "gates": 34 + }, + { + "trial": 2, + "step": 364, + "gates": 33 + } + ] +} diff --git a/research/r420-two-block-composition/vendor/pr674/README.md b/research/r420-two-block-composition/vendor/pr674/README.md new file mode 100644 index 0000000000..1366b768f1 --- /dev/null +++ b/research/r420-two-block-composition/vendor/pr674/README.md @@ -0,0 +1,164 @@ +# A 34-gate replacement for R420 block 5 + +This finite bit-circuit improvement replaces one 46-gate phase-B block of +eumemic's PR #543 R420 word with 34 gates on the same twelve registers. +Regenerating its literal cleanup saves another twelve gates. The full native +word uses 26,892 scalar ADDs instead of 26,916. All 660 symbolic input columns, +including arbitrary helper dirt, pass the predecessor's exact replay. + +The paid rank profile and every register's frame path are unchanged. This +contribution claims no new bit exponent or kappa. It does not change the +selected construction or any predecessor package. + +| Quantity | Original | Replacement | +|---|---:|---:| +| Block-5 XOR gates | 46 | 34 | +| Block plus literal cleanup, unit-input norm bound | 1,075 | 485 | +| Native word scalar ADDs | 26,916 | 26,892 | +| Native forward cancellation-free bound | 144,651 | 144,651 | +| Native reverse cancellation-free bound | 2,270,064 | 2,229,592 | +| Paid rank mass | 5,112 | 5,112 | +| Nine-stage prefix bound, bit length | 189 | 189 | +| Nine-stage charged prefix bits | 192 | 192 | + +## Reproduce + +From the repository root, with Python 3.11 or newer and no external packages: + +```sh +python3 -B research/r420-block5-resynthesis/verify.py +``` + +Expected final line: + +```text +PASS_R420_BLOCK5_RESYNTHESIS block=46->34 native_adds=26916->26892 rank_mass=5112 kappa=unchanged +``` + +To retain the rebuilt word and exported records, add +`--output /tmp/r420-block5-replay`. The default uses a temporary directory. +Verification reconstructs the candidate from the pinned original, checks the +exact matrices, replays both native words and compares the complete result with +`certificate.json`. Gzip containers are not compared: the certificate pins the +canonical decompressed JSON. Runs with Python's `-O` option are refused. + +## Exact change and proof + +The object is zero-based D4 block 5, at the half-open slice `B[371:417]` in +`research/e8-bit-r420/data/bitE8mut-r420.json.gz`. Its frame ID is 547 and its +registers, in matrix order, are + +```text +19, 24, 35, 40, 54, 56, 65, 74, 84, 95, 100, 111 +``` + +Each operation below means `destination += source`; reduce modulo two for the +bit circuit. Five explicit rewrites advance an existing addition before readers +that need the resulting sum, then remove their redundant direct reads: + +1. Advance `111 += 100` before the first read by register 54. Remove + `54 += 100`, `65 += 100` and `56 += 100`. +2. Advance `74 += 100` to immediately before the late reads by register 40. + Remove the additions from 100 to 40, 84, 19 and 95. +3. Advance `65 += 54` before `74 += 56`. Remove the additions from 54 to 74 + and 56. +4. Advance `56 += 65` before `74 += 56`. Remove `74 += 65`. +5. Advance `40 += 35` to the beginning of the block. Remove the additions + from 35 to 100 and 95. + +The gate counts after these steps are 43, 39, 37, 36 and 34. The certificate +includes the resulting operation list, original gate offsets, forward integer +matrix and both reverse majorant matrices. Each step preserves the full integer +forward matrix, with outputs on their original wires. Equality over the integers +implies equality over F2 and on arbitrary dirty register contents. No temporary +register, copy, source-access operation or extra frame change is introduced. + +For a list of additions, replace each evolving value by a nonnegative bound on +its norm and perform the same additions. The resulting nonnegative integer matrix +maps input norm bounds to output norm bounds. Norms never decrease within this +calculation, so terminal row bounds also bound every prefix. The replacement's +forward matrix equals the original's. Its literal-reverse majorant is entrywise +no larger, with 28 strict entries. Its forward-plus-reverse majorant has 97 strict +improvements. This comparison holds for every nonnegative starting-bound vector, +not only for the unit-input numbers in the table. The verifier also compares the +signed inverse matrices, obtained by reversing and negating the additions. + +All rewrites occur at one D4 frame between the same outside gates. Every affected +register still visits that frame. Exact replay checks legal nesting and equality +of the full per-register frame paths, including final climbs. Phase C is rebuilt +as the literal reverse of every source/helper write in A and B at the full frame. +The old D remains valid because the new block has the same map on all its inputs. +The predecessor's H1-H5 interface checks and U/J/K/U-inverse conclusions all pass. + +## Complete cost and limits + +`record_audit.py` independently interprets the predecessor exporter's MOVE, ADD, +COPY and ERASE stream in both directions. It checks all 660 columns, copied-center +lifecycle, complete frame paths, the rank histogram and cancellation-free prefix +bounds. The local histogram remains +`{1:1320, 2:1440, 4:60, 5:120, 8:9}`, including all nine rank-8 copies. +There are still 420 helpers, nine retained totals and 2,940 MOVE records. + +The five-stage prefix expression is `64 * cf^3 * cb^2`. The nine-stage expression +is `2^18 * cf^5 * cb^4`, with `cf` and `cb` the native forward and reverse bounds. +Both formulas and the nine-stage invoice code are pinned in `SOURCES.json`. +The exact unrounded bounds are in the certificate. The five-stage bound still +uses 100 bits and the nine-stage bound still uses 189 bits, charged at 192. + +In the inherited nine-stage, 32-replica invoice, the local-ADD term would decrease +by `9 * 32 * 24 = 6912`. The paid recursive profile is unchanged. This is a +reduction in finite circuit work and a prefix bound, not an asymptotic saving or +a measured multiplication speedup. No new owner assignment, hosted global program, +outer assembly or full frontier replay is supplied. Reusing the construction in +a selected supplier still calls for that supplier's normal complete replay. + +All-size compilation, common-label and mutable-basis realization, pooled hosting, +normalized residuals, precision/tape recovery and analytic transfer remain +inherited assumptions. Exact finite replay is not a formal proof of the full +integer multiplication theorem. + +## Coverage, controls and prior work + +Assignment seed 5 selected the bit-supplier track and block index `5 mod 10`. +The bounded experiment applied the five recorded sum-sharing rewrites to this +one block and stopped once they produced a verified improvement. A separate +worker briefly explored bidirectional elimination and did not supply the chosen +circuit. There is no exhaustive circuit search or optimality claim. In particular, +34 is an attained gate count, not a lower bound. + +Negative controls omit a block gate, alter its source, insert a doubled pair +that preserves F2 semantics but worsens the positive matrix, omit a cleanup gate, +use an illegal zero frame and reuse stale cleanup. The stale cleanup still has +the right scalar map but fails the required literal-reverse interface. Record +controls independently alter an ADD, a MOVE rank and COPY/ERASE lifecycle data. + +The exact base commit is +`66849e1475c930fd7732b1a0067ffee7e1e95f60`. The source is eumemic's +[PR #543](https://github.com/CrocSwap/integer-mult-bounds/pull/543), pinned at +`2065fe4f72a914d907f1046603f5a36f17018535`. That contribution supplies the R420 +construction, interleaved interface argument and bill-aware LU circuit. +Eumemic's #493 supplies its skeleton; Dylan Crow's #370 lineage supplies the word +format and exporter; DreamingOfClouds' #510 and the #463/#442 lineage supply the +retained nine-stage accounting. Original source files and notices remain intact. + +[PR #661](https://github.com/CrocSwap/integer-mult-bounds/pull/661), inspected at +`9ca7aa3ab0a3260a2f36ac86b9911a31fd88bd89`, proves a fixed-order phase-B frame +bound and explicitly excludes circuit resynthesis. This contribution changes +the circuit while retaining its frame paths, consistent with that result. +DreamingOfClouds' incorporated #589 instead changes frames of the punctured bit +word and improves its paid profile. Decoder research in #620/#631 concerns a +different mechanism. Open-PR metadata and the review ledger informed the scope; +pending PR claims are not treated as accepted frontier results. + +The final refresh found yongjae321's concurrent +[PR #670](https://github.com/CrocSwap/integer-mult-bounds/pull/670), at +`2e31fcad7f9ecc8b97039ecb2333e581fd725fa1`. It reports a 50-to-33-gate replacement +for block 3. The contribution here replaces the separate 46-gate block 5 and +adds exact forward equality over the integers for its five explicit rewrites. +It does not depend on #670, and this package does not certify their composition. +Both contributions improve finite work while retaining the paid frame profile. + +Prepared for GitHub contributor **x0hu** with substantial OpenAI Codex assistance, +including separate Codex workers for circuit and record-level verification. No +independent human review is claimed. New files are under the repository's +Apache-2.0 license. diff --git a/research/r420-two-block-composition/vendor/pr674/certificate.json b/research/r420-two-block-composition/vendor/pr674/certificate.json new file mode 100644 index 0000000000..cc16574133 --- /dev/null +++ b/research/r420-two-block-composition/vendor/pr674/certificate.json @@ -0,0 +1,865 @@ +{ + "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", + "baseline_local_roundtrip_peak": 1075, + "baseline_reverse_majorant": [ + [ + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 1, + 7, + 1 + ], + [ + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 1, + 3, + 0 + ], + [ + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 3, + 1, + 1, + 5, + 0 + ], + [ + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 5, + 2, + 1, + 9, + 0 + ], + [ + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 3, + 0, + 0, + 7, + 2 + ], + [ + 0, + 0, + 0, + 0, + 2, + 4, + 1, + 9, + 0, + 0, + 23, + 7 + ], + [ + 0, + 0, + 0, + 0, + 1, + 2, + 1, + 5, + 0, + 0, + 13, + 4 + ], + [ + 0, + 0, + 0, + 0, + 4, + 7, + 2, + 18, + 0, + 0, + 44, + 13 + ], + [ + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 5, + 2, + 1, + 9, + 1 + ], + [ + 0, + 0, + 2, + 1, + 0, + 0, + 0, + 10, + 3, + 3, + 18, + 1 + ], + [ + 1, + 2, + 5, + 2, + 0, + 0, + 0, + 29, + 8, + 8, + 52, + 3 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 2, + 1 + ] + ], + "candidate_canonical_sha256": "aef2fc8c510b87b4da62d5756c2be3d16da1c2557bfd8358e01ee25d02ffbc99", + "candidate_local_roundtrip_peak": 485, + "candidate_reverse_majorant": [ + [ + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 1, + 3, + 1 + ], + [ + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 1, + 1, + 0 + ], + [ + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 3, + 1, + 1, + 1, + 0 + ], + [ + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 5, + 2, + 1, + 1, + 0 + ], + [ + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 3, + 0, + 0, + 3, + 2 + ], + [ + 0, + 0, + 0, + 0, + 0, + 2, + 1, + 3, + 0, + 0, + 3, + 3 + ], + [ + 0, + 0, + 0, + 0, + 1, + 2, + 1, + 5, + 0, + 0, + 5, + 4 + ], + [ + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 0, + 2, + 1 + ], + [ + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 5, + 2, + 1, + 3, + 1 + ], + [ + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 4, + 1, + 1, + 2, + 1 + ], + [ + 1, + 2, + 1, + 2, + 0, + 0, + 0, + 17, + 4, + 4, + 10, + 3 + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 2, + 1 + ] + ], + "cost": { + "baseline": { + "adds_by_phase": { + "1": 19922, + "2": 2376, + "3": 568, + "4": 1077, + "5": 2973 + }, + "five_stage_payload_bits": 100, + "five_stage_payload_bound": "998206739997057013039187410944", + "forward": { + "all_columns": 660, + "bits": 18, + "cancellation_free_row_l1": 144651, + "maximum_at": { + "destination": 528, + "phase": 5, + "record_in_direction": 29536 + } + }, + "negative_controls": { + "broken_COPY_source": "ERASE source frame or workspace mismatch", + "missing_ERASE": "copy workspace already open", + "modified_MOVE_rank": "MOVE rank mismatch", + "omitted_B_source_ADD": "scalar endpoint mismatch" + }, + "nine_stage_charged_prefix_bits": 192, + "nine_stage_prefix_bits": 189, + "nine_stage_prefix_bound": "440858815560454746902811617646181283465263876766227759104", + "operations": { + "0": 2940, + "1": 26916, + "2": 9, + "3": 9 + }, + "paid_histogram": { + "1": 1320, + "2": 1440, + "4": 60, + "5": 120, + "8": 9 + }, + "paid_rank_mass": 5112, + "records": 29874, + "reverse": { + "all_columns": 660, + "bits": 22, + "cancellation_free_row_l1": 2270064, + "maximum_at": { + "destination": 141, + "phase": 1, + "record_in_direction": 26356 + } + } + }, + "candidate": { + "adds_by_phase": { + "1": 19922, + "2": 2376, + "3": 568, + "4": 1065, + "5": 2961 + }, + "five_stage_payload_bits": 100, + "five_stage_payload_bound": "962930826045767086638403792896", + "forward": { + "all_columns": 660, + "bits": 18, + "cancellation_free_row_l1": 144651, + "maximum_at": { + "destination": 528, + "phase": 5, + "record_in_direction": 29512 + } + }, + "negative_controls": { + "broken_COPY_source": "ERASE source frame or workspace mismatch", + "missing_ERASE": "copy workspace already open", + "modified_MOVE_rank": "MOVE rank mismatch", + "omitted_B_source_ADD": "scalar endpoint mismatch" + }, + "nine_stage_charged_prefix_bits": 192, + "nine_stage_prefix_bits": 189, + "nine_stage_prefix_bound": "410250116818741208821899034315310017378193525612293914624", + "operations": { + "0": 2940, + "1": 26892, + "2": 9, + "3": 9 + }, + "paid_histogram": { + "1": 1320, + "2": 1440, + "4": 60, + "5": 120, + "8": 9 + }, + "paid_rank_mass": 5112, + "records": 29850, + "reverse": { + "all_columns": 660, + "bits": 22, + "cancellation_free_row_l1": 2229592, + "maximum_at": { + "destination": 141, + "phase": 1, + "record_in_direction": 26332 + } + } + }, + "formula_and_exporter_sources": { + "research/e8-bit-carrier-skeleton/code/bit/checkers/columns_h.cpp": "d1297f9052be4f2496e1ff2a77e4db2c0cdbd7d460d489b4c03e50bf317238ce", + "research/e8-bit-carrier-skeleton/code/bit/export_records.py": "8a5999601f917dbb492bb9ae9a344611f18cc7cedc53dc3c76496a369e530eb3", + "research/e8-bit-r420/vendor/pr510/e8-r480-nine-stage/vendor/e8-r715-eleven-stage-whole/code/global_k.py": "6368196a393ac25bb2918880e4c4bd31ed733b762c27b6873ab391cbc0c5c3c8" + }, + "same_frame_paths": true, + "status": "PASS_LOCAL_SCALAR_PROFILE_AND_PREFIX_AUDIT" + }, + "full_word_checks": { + "H1_H5_and_conclusion": true, + "closed_frames": 672, + "columns": 660 + }, + "integer_forward_matrix": [ + [ + 2, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + [ + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1 + ], + [ + 0, + 0, + 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 2 + ], + [ + 1, + 1, + 3, + 2, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1, + 3, + 2, + 2, + 1, + 1, + 1, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1, + 2, + 1, + 2, + 0, + 1, + 1, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0 + ], + [ + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1 + ], + [ + 1, + 1, + 2, + 2, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0 + ], + [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + ], + "negative_controls": [ + "omit block gate", + "change block source", + "parity-preserving duplicated pair", + "omit cleanup gate", + "block gate at zero frame", + "stale cleanup violates literal-reverse interface" + ], + "registers": [ + 19, + 24, + 35, + 40, + 54, + 56, + 65, + 74, + 84, + 95, + 100, + 111 + ], + "replacement_ops": [ + [ + 40, + 35 + ], + [ + 100, + 95 + ], + [ + 100, + 19 + ], + [ + 100, + 84 + ], + [ + 100, + 40 + ], + [ + 100, + 24 + ], + [ + 65, + 54 + ], + [ + 56, + 65 + ], + [ + 74, + 56 + ], + [ + 95, + 40 + ], + [ + 95, + 111 + ], + [ + 19, + 111 + ], + [ + 19, + 24 + ], + [ + 84, + 111 + ], + [ + 84, + 35 + ], + [ + 35, + 74 + ], + [ + 35, + 95 + ], + [ + 35, + 84 + ], + [ + 111, + 100 + ], + [ + 54, + 74 + ], + [ + 54, + 111 + ], + [ + 54, + 56 + ], + [ + 65, + 111 + ], + [ + 65, + 56 + ], + [ + 24, + 74 + ], + [ + 24, + 95 + ], + [ + 56, + 111 + ], + [ + 111, + 74 + ], + [ + 74, + 100 + ], + [ + 40, + 74 + ], + [ + 40, + 84 + ], + [ + 84, + 74 + ], + [ + 19, + 74 + ], + [ + 95, + 74 + ] + ], + "scope": "Finite block and native-word improvement; no new kappa, full hosting replay or full theorem proof", + "source_B_slice": [ + 371, + 417 + ], + "source_offsets": [ + 16, + 0, + 1, + 2, + 3, + 4, + 19, + 17, + 6, + 9, + 10, + 12, + 13, + 14, + 15, + 20, + 21, + 22, + 34, + 24, + 25, + 26, + 28, + 29, + 30, + 31, + 33, + 35, + 45, + 37, + 38, + 40, + 42, + 44 + ], + "status": "PASS_R420_BLOCK5_RESYNTHESIS", + "steps": [ + { + "gates": 43, + "roundtrip_unit_peak": 1075 + }, + { + "gates": 39, + "roundtrip_unit_peak": 809 + }, + { + "gates": 37, + "roundtrip_unit_peak": 809 + }, + { + "gates": 36, + "roundtrip_unit_peak": 809 + }, + { + "gates": 34, + "roundtrip_unit_peak": 485 + } + ], + "strict_reverse_entries": 28 +} diff --git a/research/r420-two-block-composition/verify.py b/research/r420-two-block-composition/verify.py new file mode 100644 index 0000000000..8e7acc6e03 --- /dev/null +++ b/research/r420-two-block-composition/verify.py @@ -0,0 +1,211 @@ +#!/usr/bin/env python3 +"""Compose the pinned PR670 and PR674 circuits and verify their complete word. + +Ali Romman, with substantial OpenAI Codex assistance. Apache-2.0. +The input circuits are by yongjae321 and x0hu, respectively. +""" +import argparse +import copy +import gzip +import hashlib +import importlib.util +import json +from pathlib import Path +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +WORD = ROOT / "research/e8-bit-r420/data/bitE8mut-r420.json.gz" +CHECKER = ROOT / "research/e8-bit-r420/code/xcheck.py" + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def load_module(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 source_check(): + for name, pin in json.loads((HERE / "SOURCES.json").read_text())["files"].items(): + data = (ROOT / name).read_bytes() + require(hashlib.sha256(data).hexdigest() == pin["sha256"], "Source changed: " + name) + blob = b"blob " + str(len(data)).encode() + b"\0" + data + require(hashlib.sha1(blob).hexdigest() == pin["git_blob"], "Blob changed: " + name) + + +def cleanup(word): + v = word["v"] + full = next(i for i, f in enumerate(word["frames"]) if len(f) == v) + word["C"] = [[full, d, s[:]] for _, d, s in (word["A"] + word["B"])[::-1] + if not v <= d < 2 * v] + + +def blocks(): + a = json.loads((HERE / "vendor/pr670/candidate.json").read_text()) + b = json.loads((HERE / "vendor/pr674/certificate.json").read_text()) + return [ + {"pr": 670, "start": 263, "stop": 313, "frame": 545, "registers": a["registers"], + "gates": [[545, a["registers"][d], [a["registers"][s]]] for d, s in a["replacement_local_ops"]], + "single_word_sha256": json.loads((HERE / "vendor/pr670/CERTIFICATE.json").read_text())["revised_content_sha256"]}, + {"pr": 674, "start": 371, "stop": 417, "frame": 547, "registers": b["registers"], + "gates": [[547, d, [s]] for d, s in b["replacement_ops"]], + "single_word_sha256": b["candidate_canonical_sha256"]}] + + +def build(original, changes): + word = copy.deepcopy(original) + for block in sorted(changes, key=lambda b: b["start"], reverse=True): + word["B"][block["start"]:block["stop"]] = copy.deepcopy(block["gates"]) + cleanup(word) + return word + + +def truth_table(gates, registers): + index = {r: i for i, r in enumerate(registers)} + ops = [(index[d], index[s[0]]) for _, d, s in gates] + table = [] + for value in range(4096): + bits = [(value >> i) & 1 for i in range(12)] + for destination, source in ops: + bits[destination] = (bits[destination] + bits[source]) % 2 + table.append(sum(bit << i for i, bit in enumerate(bits))) + return table + + +def positive_matrix(gates, registers): + index = {r: i for i, r in enumerate(registers)} + rows = [[int(i == j) for j in range(12)] for i in range(12)] + for _, d, sources in gates: + require(len(sources) == 1 and d != sources[0], "Not a binary transvection") + d, s = index[d], index[sources[0]] + rows[d] = [a + b for a, b in zip(rows[d], rows[s])] + return rows + + +def paths(word): + result = [[f] for f in word["start"]] + for phase in ("D", "A", "B", "C"): + for frame, destination, sources in word[phase]: + for register in [destination] + sources: + if result[register][-1] != frame: + result[register].append(frame) + for register, frame in enumerate(word["final"]): + if result[register][-1] != frame: + result[register].append(frame) + return result + + +def additions(word): + return sum(len(s) for phase in ("D", "A", "B", "C") for _, _, s in word[phase]) + sum( + len(row) for row in word["scatter"]) + + +def check(original, word, changes): + require(set(changes[0]["registers"]).isdisjoint(changes[1]["registers"]), "Blocks share a register") + component_checks = [] + for block in changes: + registers = block["registers"] + old, new = original["B"][block["start"]:block["stop"]], block["gates"] + require(len(registers) == len(set(registers)) == 12, "Need twelve distinct registers") + require(all(f == block["frame"] for f, _, _ in old + new), "A block frame changed") + require(truth_table(old, registers) == truth_table(new, registers), "Block map differs") + single = build(original, [block]) + require(hashlib.sha256(canonical(single)).hexdigest() == block["single_word_sha256"], + "Single-word reconstruction differs from its author's certificate") + for before, after in ((old, new), (old[::-1], new[::-1])): + a, b = positive_matrix(before, registers), positive_matrix(after, registers) + require(all(y <= x for ar, br in zip(a, b) for x, y in zip(ar, br)), "Positive transfer increased") + component_checks.append({"pr": block["pr"], "inputs": 4096, "before": len(old), "after": len(new)}) + require(paths(original) == paths(word), "A register frame path changed") + require(additions(original) == 26916 and additions(word) == 26858, "Wrong composed XOR count") + require(all(original[k] == word[k] for k in original if k not in ("B", "C")), "An exterior field changed") + reference = load_module("r420_reference_check", CHECKER) + checked, labels, full, hypotheses, conclusion, _ = reference.check(word) + require(all(hypotheses.values()) and all(conclusion.values()), "Interface failed") + controls = {} + + def reject(name, mutant, expected): + audit = copy.copy(checked) + audit.w = mutant + try: + audit.full() + except reference.Reject as error: + require(expected in str(error), name + " failed for a different reason: " + str(error)) + controls[name] = str(error) + else: + raise ValueError("Control was accepted: " + name) + + offset = 0 + for block in changes: + start = block["start"] - offset + mutant = copy.deepcopy(word) + del mutant["B"][start] + cleanup(mutant) + reject("wrong_block_%d_with_correct_inverse" % block["pr"], mutant, "targets not y + x") + offset += block["stop"] - block["start"] - len(block["gates"]) + mutant = copy.deepcopy(word) + z_prefix = sum(not 120 <= d < 240 for _, d, _ in word["A"] + word["B"][:263]) + del mutant["C"][len(word["C"]) - 1 - z_prefix] + reject("missing_cleanup_gate", mutant, "sources not restored") + mutant = copy.deepcopy(word) + mutant["B"][263][0] = word["start"][mutant["B"][263][1]] + reject("unpaid_low_frame", mutant, "climb not nested") + mutant = copy.deepcopy(original) + for block in changes: + mutant["B"][block["start"]:block["stop"]] = copy.deepcopy(block["gates"]) + cleanup(mutant) + reject("ascending_stale_slice_offsets", mutant, "targets not y + x") + mutant = copy.deepcopy(word) + mutant["C"] = copy.deepcopy(original["C"]) + audit = copy.copy(checked) + audit.w = mutant + audit.full() + h, c, _ = audit.interface() + require(not h["H4_C_literal_reverse_at_full"] and all(c.values()), "Stale cleanup control failed") + controls["stale_cleanup"] = "scalar map accepted; H4 literal-reversal contract rejected" + return {"status": "PASS_R420_TWO_BLOCK_COMPOSITION", "components": component_checks, + "labels": labels, "full_word": full, "hypotheses": hypotheses, "conclusion": conclusion, + "controls": controls, "unchanged_register_paths": len(paths(word)), + "original_additions": additions(original), "replacement_additions": additions(word), + "replacement_canonical_sha256": hashlib.sha256(canonical(word)).hexdigest()} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--output", type=Path, help="New output directory; default is a temporary directory") + parser.add_argument("--native", action="store_true", help="Run native 5-, 9- and 11-stage checks") + parser.add_argument("--hosted", action="store_true", help="Also run the nine-stage whole-owner and price checks") + args = parser.parse_args() + require(not sys.flags.optimize, "Run with assertions enabled for the inherited checks") + out = args.output.resolve() if args.output else Path(tempfile.mkdtemp(prefix="r420-compose-")) + if args.output: + out.mkdir(parents=True, exist_ok=False) + source_check() + original = json.loads(gzip.decompress(WORD.read_bytes())) + changes = blocks() + word = build(original, changes) + result = check(original, word, changes) + for name, value in (("baseline", original), ("replacement", word)): + (out / (name + ".json.gz")).write_bytes(gzip.compress(canonical(value) + b"\n", mtime=0)) + if args.native or args.hosted: + result["native"] = load_module("r420_compose_native", HERE / "native.py").run(ROOT, out) + if args.hosted: + result["hosted"] = load_module("r420_compose_hosted", HERE / "hosted.py").run(ROOT, out) + (out / "RESULT.json").write_text(json.dumps(result, indent=2) + "\n") + print("OUTPUT", out) + print("PASS_R420_TWO_BLOCK_COMPOSITION local_additions=26916->26858 saved=58 kappa=unchanged") + + +if __name__ == "__main__": + main()