From ec30476096b2f9aed718152a2fa3712d1c4e884d Mon Sep 17 00:00:00 2001 From: ToikY <27568617+ToikY@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:16:35 -0800 Subject: [PATCH] Fuse five paid MOVE stops in the P104 shared-wire supplier --- .../shared-wire-stop-fusion/DEPENDENCIES.json | 102 ++ research/shared-wire-stop-fusion/EDITS.json | 201 ++++ research/shared-wire-stop-fusion/LICENSE | 201 ++++ research/shared-wire-stop-fusion/NOTICE | 3 + research/shared-wire-stop-fusion/PROOF.md | 74 ++ research/shared-wire-stop-fusion/README.md | 78 ++ research/shared-wire-stop-fusion/RESULT.json | 919 ++++++++++++++++++ research/shared-wire-stop-fusion/SOURCES.json | 132 +++ research/shared-wire-stop-fusion/TASK.json | 115 +++ .../shared-wire-stop-fusion/VALIDATION.md | 40 + research/shared-wire-stop-fusion/VERIFY.json | 59 ++ .../shared-wire-stop-fusion/audit_native.py | 241 +++++ .../shared-wire-stop-fusion/audit_price.py | 119 +++ .../build_candidate.py | 144 +++ .../shared-wire-stop-fusion/slide_stops.py | 193 ++++ research/shared-wire-stop-fusion/verify.py | 226 +++++ 16 files changed, 2847 insertions(+) create mode 100644 research/shared-wire-stop-fusion/DEPENDENCIES.json create mode 100644 research/shared-wire-stop-fusion/EDITS.json create mode 100644 research/shared-wire-stop-fusion/LICENSE create mode 100644 research/shared-wire-stop-fusion/NOTICE create mode 100644 research/shared-wire-stop-fusion/PROOF.md create mode 100644 research/shared-wire-stop-fusion/README.md create mode 100644 research/shared-wire-stop-fusion/RESULT.json create mode 100644 research/shared-wire-stop-fusion/SOURCES.json create mode 100644 research/shared-wire-stop-fusion/TASK.json create mode 100644 research/shared-wire-stop-fusion/VALIDATION.md create mode 100644 research/shared-wire-stop-fusion/VERIFY.json create mode 100644 research/shared-wire-stop-fusion/audit_native.py create mode 100644 research/shared-wire-stop-fusion/audit_price.py create mode 100644 research/shared-wire-stop-fusion/build_candidate.py create mode 100644 research/shared-wire-stop-fusion/slide_stops.py create mode 100644 research/shared-wire-stop-fusion/verify.py diff --git a/research/shared-wire-stop-fusion/DEPENDENCIES.json b/research/shared-wire-stop-fusion/DEPENDENCIES.json new file mode 100644 index 0000000000..4ae6821773 --- /dev/null +++ b/research/shared-wire-stop-fusion/DEPENDENCIES.json @@ -0,0 +1,102 @@ +{ + "source_commit": "93effe2a135bf57b9e484cb630d8dd057159aec9", + "source_pr": 7000, + "files": [ + { + "source_path": "research/shared-wire-split-composition/LICENSE", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "source_path": "research/shared-wire-split-composition/NOTICE", + "git_blob": "a3687d65a00794277cdaad37558d24008cbc37f5", + "sha256": "da12736e2e824167ff56f2ecb623a5f88f75a270410360890f61dffc33bab249" + }, + { + "source_path": "research/shared-wire-split-composition/INDEPENDENT-NOTICE.md", + "git_blob": "1bc9b4da2b8398954cd7a49356eb9d397785d0a6", + "sha256": "cadbc642ca84311d2c7a6cf704c7828cb4cf77e3c784b66e4c6e8a5c28002fb8" + }, + { + "source_path": "research/shared-wire-split-composition/NATIVE-INPUTS.json", + "git_blob": "347b2c4df65e55aacf289addc96d6558e8e1eaf2", + "sha256": "9bb6c1567783661334d6c1d23f715ce5635cbbb513678819ab9e020a34c7e4c0" + }, + { + "source_path": "research/shared-wire-split-composition/INDEPENDENT-SOURCES.json", + "git_blob": "95afd397782ada3dfcf0f4d9fa1fdb76ab6ea617", + "sha256": "dced1457df5230466ba6202fd6d4595bc2b7fb2a65302806bf2720b1837ff350" + }, + { + "source_path": "research/shared-wire-split-composition/data/final.json.gz", + "git_blob": "74563a7867d9d762b6588f65362369668841bb3e", + "sha256": "2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883" + }, + { + "source_path": "research/shared-wire-split-composition/data/caller.json", + "git_blob": "cf55f4271009a06ad192a070d330a4466b6d44fa", + "sha256": "3828d53e80ea97e8b866320f081af20b6b93bfebd58b95b56b85a7afe151af5e" + }, + { + "source_path": "research/shared-wire-split-composition/data/bit-admission.json", + "git_blob": "575f76487f9999ecc3e7b1b70f9f71bc582ef8a8", + "sha256": "a46b6c6040f75184cab5467656811ad988c216e3bc8e44d595a5015b6e49620b" + }, + { + "source_path": "research/shared-wire-split-composition/independent.py", + "git_blob": "1ae1d7c680ad86c0fa999f2e8f0c09e966fc07a0", + "sha256": "21f46a8340331abb1486b50bd4e04453f1968b0a5950d86ff7780dd368590874" + }, + { + "source_path": "research/shared-wire-split-composition/interval_gate.py", + "git_blob": "e24dc46079b4c25152f5afc096dda2ce8ee58ff5", + "sha256": "60a743d13f668ef86db4b8215b4d5d04430a671ba6f1fe06d9c1c4c3dfe86da5" + }, + { + "source_path": "research/shared-wire-split-composition/precision_replay.py", + "git_blob": "fafa1611dded2746f021714aad6837aed61041cb", + "sha256": "850d9098c5946ab27ef5228acc54d59df2196e72259d3e21588ec0c319c8f5ee" + }, + { + "source_path": "research/shared-wire-split-composition/frozen/clifford_exact.py", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "source_path": "research/shared-wire-split-composition/frozen/native_verify.py", + "git_blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + { + "source_path": "research/shared-wire-split-composition/frozen/physical.py", + "git_blob": "5e0b17b9ef2151e3dee68378b71b3d0d47a56233", + "sha256": "4e995d1158033d83bf69b671f23dc7924d66edbbe07623ba063ba7421234ea20" + }, + { + "source_path": "research/shared-wire-split-composition/frozen/verify_host3_odd.py", + "git_blob": "2117502bedfc9fc0a7abade8243eb5a43d0b514e", + "sha256": "e75ad2096ba2587d1dc9c8982b2c2eb7c6fd2636a80adcd943314ef2cf6fd258" + }, + { + "source_path": "research/shared-wire-split-composition/retained/odd-native-common-grid/independent_bounds.py", + "git_blob": "8fe729386f81e6973bbe7ecaa5dbb4bf86281908", + "sha256": "198521def614fe78fa728f1dde2b7fb820c0c0e0ac3ad0c9224dccbf51eac0d5" + }, + { + "source_path": "research/shared-wire-split-composition/retained/query-only-precision-envelope/envelopes.py", + "git_blob": "70c8ca23763e30c924fb726b74b82f44d344c65f", + "sha256": "783da6b5b450fc07434946cb9ec86070dfee01df6b5fa1c385cb024def2c9a9f" + }, + { + "source_path": "research/shared-wire-split-composition/retained/query-only-precision-envelope/source_binding.py", + "git_blob": "9f0e0a8cbaf48266cf9c6aa8b263505e9569390c", + "sha256": "624c459311c58f3847b7713b818bfd340153abf42919f02ac9aa8892ed52a2bd" + }, + { + "source_path": "research/shared-wire-split-composition/FULL-RESULT.json", + "git_blob": "ff3256f0d3ffbfc56b062f9ec0fdbbc7b30e76d5", + "sha256": "d9ba709fa5dcefffe3f3abdcf34600ce188224703cfd743e6db8b58ba4816cb7" + } + ], + "archived_base": "17469fff78c22941280f04d39dc5a1faee09c840" +} diff --git a/research/shared-wire-stop-fusion/EDITS.json b/research/shared-wire-stop-fusion/EDITS.json new file mode 100644 index 0000000000..cbd31fd084 --- /dev/null +++ b/research/shared-wire-stop-fusion/EDITS.json @@ -0,0 +1,201 @@ +{ + "source_head": "93effe2a135bf57b9e484cb630d8dd057159aec9", + "source_canonical_sha256": "91429a6b96729292a8764836e00c87a6f7cd3b76f05159033f4867f69a98d097", + "plans": [ + { + "role": 444, + "old_moves": [ + { + "index": 42729, + "event": [ + "MOVE", + 444, + 930, + 246, + false + ] + }, + { + "index": 43417, + "event": [ + "MOVE", + 444, + 246, + 127, + false + ] + } + ], + "slides": [ + { + "index": 42730, + "event": [ + "ADD", + 589, + 444, + "-1", + 246 + ], + "before_event": 44026, + "new_frame": 127 + } + ] + }, + { + "role": 448, + "old_moves": [ + { + "index": 42564, + "event": [ + "MOVE", + 448, + 902, + 246, + false + ] + }, + { + "index": 44023, + "event": [ + "MOVE", + 448, + 246, + 127, + false + ] + } + ], + "slides": [ + { + "index": 42566, + "event": [ + "ADD", + 448, + 231, + "-1", + 246 + ], + "before_event": 44024, + "new_frame": 127 + } + ] + }, + { + "role": 655, + "old_moves": [ + { + "index": 33974, + "event": [ + "MOVE", + 655, + 3, + 106, + false + ] + }, + { + "index": 33991, + "event": [ + "MOVE", + 655, + 106, + 1052, + false + ] + } + ], + "slides": [ + { + "index": 33989, + "event": [ + "ADD", + 171, + 655, + "-1", + 106 + ], + "before_event": 33971, + "new_frame": 3 + } + ] + }, + { + "role": 671, + "old_moves": [ + { + "index": 33683, + "event": [ + "MOVE", + 671, + 3, + 105, + false + ] + }, + { + "index": 33731, + "event": [ + "MOVE", + 671, + 105, + 1048, + false + ] + } + ], + "slides": [ + { + "index": 33730, + "event": [ + "ADD", + 208, + 671, + "-1", + 105 + ], + "before_event": 29913, + "new_frame": 3 + } + ] + }, + { + "role": 1306, + "old_moves": [ + { + "index": 30801, + "event": [ + "MOVE", + 1306, + 3, + 106, + false + ] + }, + { + "index": 33977, + "event": [ + "MOVE", + 1306, + 106, + 1052, + false + ] + } + ], + "slides": [ + { + "index": 33976, + "event": [ + "ADD", + 1306, + 936, + "1", + 106 + ], + "before_event": 30798, + "new_frame": 3 + } + ] + } + ] +} diff --git a/research/shared-wire-stop-fusion/LICENSE b/research/shared-wire-stop-fusion/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/shared-wire-stop-fusion/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/shared-wire-stop-fusion/NOTICE b/research/shared-wire-stop-fusion/NOTICE new file mode 100644 index 0000000000..2ed927f940 --- /dev/null +++ b/research/shared-wire-stop-fusion/NOTICE @@ -0,0 +1,3 @@ +Shared-wire stop fusion, prepared for ToikY with substantial OpenAI Codex assistance. +Licensed under Apache-2.0. Retained predecessor notices are in the archived +shared-wire-split-composition package. See README.md for construction credit. diff --git a/research/shared-wire-stop-fusion/PROOF.md b/research/shared-wire-stop-fusion/PROOF.md new file mode 100644 index 0000000000..f7441e2651 --- /dev/null +++ b/research/shared-wire-stop-fusion/PROOF.md @@ -0,0 +1,74 @@ +# From relocated scalar contacts to a strict recursive gain + +## Exact source edits + +Indices are zero-based in the exact #7000 word. The insertion point is +immediately before the indicated original event. + +| Role | Old MOVE indices | Charts | ADD index | Insert before | New ADD chart | +|---:|---|---|---:|---:|---:| +| 444 | 42729, 43417 | 930 → 246 → 127 | 42730 | 44026 | 127 | +| 448 | 42564, 44023 | 902 → 246 → 127 | 42566 | 44024 | 127 | +| 655 | 33974, 33991 | 3 → 106 → 1052 | 33989 | 33971 | 3 | +| 671 | 33683, 33731 | 3 → 105 → 1048 | 33730 | 29913 | 3 | +| 1306 | 30801, 33977 | 3 → 106 → 1052 | 33976 | 30798 | 3 | + +The exact event literals in `EDITS.json` are authoritative. The generator +checks every old MOVE and ADD against the pinned word, enumerates every +intermediate contact with the moved role, and verifies the insertion chart +and operand chronology in the combined edited word. + +## Arbitrary-input identity and retained interfaces + +Express the value of a field in chart A as its normalized coordinate +vector obtained by applying the inverse of the chart operator `C_A`. +Every MOVE is the identity on this normalized vector. An ADD at a common +chart is `I + a E_ij` on the normalized fields. Two such ADDs commute if +neither writes the other's source. This follows from +`E_ij E_kl = δ_jk E_il`. Events on disjoint fields commute. The relocation +certificate checks every reversed relative order. The eight crossed +overlapping scalar events are all commuting ADDs. No crossed noncommuting +source write, SCALE, COPY, INIT or CLEAR is permitted. The exact grid audit +also compares every affected scalar source row and all 54 owned CLEAR rows +between the source and candidate. Each moved coefficient is a unit ±1. + +After each stop contact moves, the intermediate chart has no use on that +field. The two chart transitions compose exactly to `C_C C_A^-1` because +the adjacent `C_B^-1 C_B` cancel. The spans strictly nest `A ⊂ B ⊂ C`, so the +direct MOVE lowers to a positive child of rank `dim C − dim A` with the +retained rank-zero adapters. The four distinct direct maps have their +signed Pauli action, absolute phase and all 512 exact Gaussian columns +checked. The normalized proof acts on arbitrary vectors in every factor +under the retained all-column contract. The finite width-512 replay is a +separate control. No main endpoints, helper credit, owned lifetime, operand +alphabet, caller event or BIT source changes. + +## Complete price + +The paid rank delta per LOCAL is `{1:−7, 2:+2, 4:−3, 5:+3}`. The complete +delta is 18 times this vector. The sum of paid ranks and all target counts +are unchanged, so the complete rank-mass surplus stays 1,520. For +`p = 1−κ` with `0 < p < 1`, the increase in target-minus-paid moment is + +``` +18 · [2(2 − 2^p) + 3(1 + 4^p − 5^p)] > 0. +``` + +Strict subadditivity of `r^p` proves the sign for each fusion. The two +rational checkers use the full literal paid and target profiles. The new +invoice has 23,392 productive targets and 117,522 paid requests. The 90 +removed routes reduce #7000's conservative ordinary invoice by 90,000. +The scalar and adapter tariffs retain #7000's units and the proof makes +no new physical conversion assumption. + +The tested rational price is 0.00363166992007, with compiler gap +`1/100000000000000`. At this price, the directed enclosures give +`alpha < 1−10^-27`, `gamma < 31/32` and `delta < 31/32`. The written +logarithm power is 2,229, with threshold 14,181,100,000,000,000,000. +The exact input-lift, outer stock and 54+4 ledger inequalities pass. +The complex tested price lies strictly below the retained conservative BIT +pin 0.00376669, which in turn lies below the paired E-free BIT 0.00385248. +The candidate's prefix grid still passes at `S=1125`, with the same source +majorant parameters and an authenticated replay of the attributed envelope +engines. The five framework assumptions and specific source contracts in +the README apply throughout. diff --git a/research/shared-wire-stop-fusion/README.md b/research/shared-wire-stop-fusion/README.md new file mode 100644 index 0000000000..1ba57075e4 --- /dev/null +++ b/research/shared-wire-stop-fusion/README.md @@ -0,0 +1,78 @@ +# Five commuting MOVE fusions at conditional κ = 0.00363166992 + +The complete #7000 construction admits **κ = 22697937/6250000000** after +five paid MOVE fusions per native call. The exact gain in the conditional +claim is **6447/4000000000 = 0.00000161175** over #7000. A separate rational +engine encloses the new raw crossing in +`(0.00363166992015115785886325297974980, 0.00363166992015115785886325297974981)`. +The written claim exceeds the upper endpoint of #7000's raw crossing. + +Five existing scalar contacts move to other common charts by commuting +past intervening events. Two pairs of paid ranks `(1,1)` become rank `2` +and three pairs `(1,4)` become rank `5`. The candidate keeps the same +arbitrary-input endpoint, 1,080 independent native helpers, 54 owned +lifetimes, 23 owned rises, the 18-LOCAL QUERY-only caller, and the paired +empty-root-free BIT backend. All 90 paid jobs removed across the 18 LOCALs +are counted. The ordinary bound under #7000's tariff is 826,700,496. +The complete conditional certificate leaves the selected reviewed record +at 0.003125804. + +## Reproduce + +Python 3.12, standard library only. From the repository root: + +```sh +python3 -B scripts/research_package.py --package research/shared-wire-stop-fusion +``` + +The registered commands run the deterministic discovery census, regenerate +the frozen word from `EDITS.json`, check both exact native endpoints and +odd-grid history, verify all 2,048 changed Gaussian columns and all 1,480 +outputs in the retained width-512 physical test, replay the exact formal +caller, and reprice the complete invoice and 54+4 outer inequalities. The +second price engine independently checks the strict comparison. The main +native and pricing checkers explicitly require assertions enabled. + +For a Git-free replay, retain the repository-relative inputs listed in +`VERIFY.json` alongside this package and run `slide_stops.py`, `verify.py`, +and `audit_price.py` with `python3 -I -B`. The SHA-256 and Git blob of each +input are pinned in `DEPENDENCIES.json`. The canonical archive and exact +#7000 head `93effe2a135bf57b9e484cb630d8dd057159aec9` share the same package +tree. `RESULT.json` is compared in full by the +verifier. The candidate's canonical JSON SHA-256 is +`d0de7804e56b2c8fe6db9d323560e53041810fd0377b91680cbed19b5176ebc0`. + +See [the proof and invoice](PROOF.md) and [validation](VALIDATION.md). + +## Conditional scope + +The five framework assumptions remain native-all-columns, owned erasure, +compiler, precision/tape and analytic recovery. The comparison also retains +#7000's exact child returns, odd scalars in `Z[1/2,1/3,1/5]`, the grid and +per-call wrapper, A6 owned ascent, per-port roots, one-field idles, the +paired BIT admission and the ordinary native/caller tariff contracts. The +native ascents and their entire lifetime traces are unchanged. The physical +tariff conversion identified in #6998 and a rounded all-width fixed-tape +multiplier remain open. The finite replay and exponent comparison establish +no runtime measurement or maintainer acceptance. + +## Open next questions + +- Can a total physical scalar provider and common-volume tariff bridge + admit the inherited odd-scalar, owned-ascent and QUERY-only word? Start + with the complete #6998 replacement invoice and a source-bound width + model before using physical costs in the recurrence. +- Can jointly relocated contacts remove more paid work? The search covers + a bounded class of two-MOVE public stops with existing coframes and + commuting ADDs. Crossed dependencies or changed bases require their own + exact source-version and precision proof. + +## Credit + +Prepared for **@ToikY** with substantial OpenAI Codex assistance, including +separately implemented native and price checks. Credit @CubeJerry for +#7000 and #7001, DreamingOfClouds for #6936 and #6937, the commuting retiming +in #6932, the earlier carrier-mediated fusion in #6529, and the retained +Ali Romman, zxv, Cinna Davis, icekylinx, unpaidmoon and native/compiler +lineage. The archived predecessor retains its `NOTICE` and +`INDEPENDENT-NOTICE.md`. Apache-2.0. diff --git a/research/shared-wire-stop-fusion/RESULT.json b/research/shared-wire-stop-fusion/RESULT.json new file mode 100644 index 0000000000..d6467b91de --- /dev/null +++ b/research/shared-wire-stop-fusion/RESULT.json @@ -0,0 +1,919 @@ +{ + "status": "PASS_SHARED_WIRE_STOP_FUSION", + "source_head": "93effe2a135bf57b9e484cb630d8dd057159aec9", + "candidate_canonical_sha256": "d0de7804e56b2c8fe6db9d323560e53041810fd0377b91680cbed19b5176ebc0", + "native": { + "public": 1480, + "events": 71256, + "paid": { + "1": 4068, + "2": 830, + "3": 811, + "4": 238, + "5": 323, + "6": 17, + "7": 12, + "8": 6 + }, + "helpers": { + "1": 13, + "2": 18, + "3": 44, + "4": 215, + "5": 68, + "6": 42, + "7": 18, + "8": 67, + "9": 595 + }, + "rises": { + "1": 10, + "2": 4, + "3": 1, + "4": 6, + "5": 1, + "6": 1 + }, + "owned_peak": 43, + "lifetimes": 54, + "bad_inputs": [] + }, + "invoice": { + "T": { + "1": 234, + "2": 324, + "3": 792, + "4": 3870, + "5": 1224, + "6": 756, + "7": 324, + "8": 1206, + "9": 11126, + "17": 416, + "25": 416, + "33": 416, + "41": 416, + "49": 416, + "57": 416, + "65": 416, + "73": 416, + "145": 208 + }, + "P": { + "1": 73640, + "2": 14940, + "3": 14598, + "4": 4284, + "5": 5814, + "6": 306, + "7": 216, + "8": 812, + "16": 416, + "24": 416, + "32": 416, + "40": 416, + "48": 416, + "56": 416, + "64": 416 + }, + "S": 1520, + "raw_crossing": "0.0036316699201511578588632529797498015355883000419308395762643623482", + "empty_root_credits": 0, + "no_E_credit_crossing": "0.0036316699201511578588632529797498015355883000419308395762643623482" + }, + "ordinary": { + "scalar_upper": 1777040, + "init_clear_allowance": 216, + "route_items": { + "moves": 6305, + "helper_boundary": 2160, + "first_main_boundary": 208, + "second_main_boundary": 192, + "first_main_adapter": 416, + "second_main_adapter": 384, + "owned_lifetime": 216 + }, + "routing": 9881000, + "caller_items": { + "A": { + "envelope": 124674048, + "thin": 6144, + "field_boundary": 94848, + "output_routes": 229056000, + "idle_routes": 185472000, + "query_routes": 1152000 + }, + "B": { + "envelope": 19893760, + "thin": 512, + "field_boundary": 7904, + "output_routes": 19088000, + "idle_routes": 20064000, + "query_routes": 96000 + } + }, + "caller_total": 599605216, + "raw_upper": 809449936, + "per_input_conversion": 2770560, + "lambda_second_charge": 14480000, + "conservative_total": 826700496, + "margin_to_billion": 173299504, + "odd_divisions": { + "ADD": 4079, + "SCALE": 64 + }, + "lambda_paid_rank1_would_reduce_S_by": 14480 + }, + "caller": { + "bad_outputs": [], + "max_terms": 2713, + "caller_mass_bound": "16246698892210214036146399419475929893435/256", + "caller_mass_ceiling_bits": 126, + "caller_denominator_height_bound": 163 + }, + "gate": { + "claim": "22697937/6250000000", + "tested": "363166992007/100000000000000", + "raw_bracket": [ + "181583496007557892943162648987/50000000000000000000000000000000", + "14526679680604631435453011919/4000000000000000000000000000000" + ], + "moment_margins": { + "181583496007557892943162648987/50000000000000000000000000000000": [ + "101788724592692921382354343350612393116084602929355743/25000000000000000000000000000000000000000000000000000000000000000000000000000000", + "203577449185385842764708686701224786232169205879484317/50000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "14526679680604631435453011919/4000000000000000000000000000000": [ + "-4122096820847548552430833264539256423650617172892851/50000000000000000000000000000000000000000000000000000000000000000000000000000000", + "-2061048410423774276215416632269628211825308575967087/25000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "363166992007/100000000000000": [ + "5267640762730763352652061930288447380581161206621623202957681003009347/156250000000000000000000000000000000000000000000000000000000000000000000000000", + "842822522036922136424329908846151580892985793059459712473228960491949357/25000000000000000000000000000000000000000000000000000000000000000000000000000000" + ] + }, + "moment_margin_float": { + "181583496007557892943162648987/50000000000000000000000000000000": [ + 4.071548983707717e-27, + 4.071548983707717e-27 + ], + "14526679680604631435453011919/4000000000000000000000000000000": [ + -8.244193641695097e-29, + -8.244193641695097e-29 + ], + "363166992007/100000000000000": [ + 3.371290088147689e-08, + 3.371290088147689e-08 + ] + }, + "derivative_upper": -408425.0538827444, + "alpha": [ + 0.9999999999998939, + 0.9999999999998939 + ], + "gamma": [ + 0.9497769356914381, + 0.9497769356914381 + ], + "delta": [ + 0.8759379974447428, + 0.8759379974447428 + ], + "minimum_log_power": 2228, + "written_log_power": 2229, + "compiler_gap": "1/100000000000000", + "H": "14181100000000000000", + "BIT_pin": "376669/100000000", + "BIT_margin": "13502007993/100000000000000", + "outer": { + "strict_count": 54, + "functional_count": 4, + "minimum_margin": "1/1000000000000000", + "BIT_just_below_effective_rejected": true + }, + "input_lift": { + "margins": { + "22697937/6250000000": [ + "123924292468834521814363771000382628250593438787061035193252429451040789774269/100000000000000000000000000000000000000000000000000000000000000000000000000000000", + "123924292468834521814363771000382628250593438787061035193252429451040789776191/100000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "363166992007/100000000000000": [ + "12392429247112162022898917943549212014836772918357905359823212279709031127623/10000000000000000000000000000000000000000000000000000000000000000000000000000000", + "61962146235560810114494589717746060074183864591789526799116061398545155639089/50000000000000000000000000000000000000000000000000000000000000000000000000000000" + ] + }, + "interval_kappa_cap": "376669/100000000", + "derivative_upper_on_required_interval": "-2299831290525933154178526076272396899996972093654613095735772838275432653960006518819/2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "source_BIT_wide_crude_bound_would_be": "-2299831290525933154178526076272396899996972093654613095735772838275432653960006518819/2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } + }, + "gain": { + "claim_gain": "6447/4000000000", + "claim_vs_old_raw_upper": "16117453116329140664232351/10000000000000000000000000000000", + "raw_gain_interval": [ + "40293636569769323241905371/25000000000000000000000000000000", + "80587273139538646483810743/50000000000000000000000000000000" + ], + "new_margin_at_old_upper": [ + "4184498983014853233499991885104267130482251352356871069652779020828911388192421/6250000000000000000000000000000000000000000000000000000000000000000000000000000", + "33475991864118825867999935080834137043858010818854968557222232166631291126206863/50000000000000000000000000000000000000000000000000000000000000000000000000000000" + ] + }, + "precision": { + "method": "attributed source-engine reuse", + "helper_census_substitutions": [ + [ + "word[\"public\"] - len(mains) == 1061", + "word[\"public\"] - len(mains) == 1080" + ], + [ + "fresh_arbitrary_helpers=18 * 1061", + "fresh_arbitrary_helpers=18 * 1080" + ] + ], + "common_grid": { + "word": { + "odd_scale_lcm": 1125, + "dyadic_height": 24, + "maximum_scaled_mass": "1636346757402225/16384", + "mass_witness": [ + 63460, + "stored add" + ], + "numerator_bits": 24, + "coefficient_visits": 14087282 + }, + "caller": { + "maximum_mass": "16246698892210214036146399419475929893435/256", + "pre_joint_mass": "758143798823020519902612486795530419693/64", + "denominator_height": 163, + "pre_joint_height": 154 + }, + "context_height": 178, + "context_mass_bits": 161, + "context_c": 356 + }, + "rounded_envelope": { + "native": { + "census": { + "events": 71256, + "public": 1480, + "owned_labels": 51, + "lifetimes": 54, + "peak_owned": 43, + "opcodes": { + "ADD": 61180, + "SCALE": 3662, + "MOVE": 6305, + "INIT": 54, + "COPY": 1, + "CLEAR": 54 + }, + "scalars": { + "integer": 38902, + "dyadic": 60700, + "noninteger": 25941, + "odd": 4143 + }, + "max_numerator": 14729531, + "numerator_bits": 24, + "max_denominator": 393216, + "denominator_bits": 19 + }, + "bounds": { + "M": { + "exact": "43054641548846615602104987524321069905599046554250600543037273660730652457482272541839730515070648167947373736069817/313353572444111882083840819200000000000000000", + "strict_power_of_two": 237, + "witness": { + "cut": 71220, + "register": 1443, + "factor": "1", + "kind": "stored" + } + }, + "Sigma": { + "exact": "49042140230293998707783330736939147773355026633889243363309955241604634320856117755537679249840200828104732776001/1224037392359812039390003200000000000000000", + "strict_power_of_two": 235, + "witness": { + "cut": 71220, + "register": 1443, + "factor": "1", + "kind": "stored" + } + }, + "Gamma": { + "exact": "49042140230293998707783330736939147773355026633889243363309955241604634320856117755537679249840200828104732776001/1224037392359812039390003200000000000000000", + "strict_power_of_two": 235, + "witness": { + "cut": 71256, + "register": 1443, + "factor": "1", + "kind": "public-return" + } + } + }, + "independent_adjoint": { + "M": { + "entrance_mass": "43054641548846615602104987524321069905599046554250600543037273660730652457482272541839730515070648167947373736069817/313353572444111882083840819200000000000000000", + "residual_mass": "49042140230293998707783330736939147773355026633889243363309955241604634320856117755537679249840200828104732776001/1224037392359812039390003200000000000000000", + "active_residual_sites": 24531 + }, + "Sigma": { + "entrance_mass": "43054641548846615602104987524321069905599046554250600543037273660730652457482272541839730515070648167947373736069817/313353572444111882083840819200000000000000000", + "residual_mass": "49042140230293998707783330736939147773355026633889243363309955241604634320856117755537679249840200828104732776001/1224037392359812039390003200000000000000000", + "active_residual_sites": 24531 + }, + "Gamma": { + "entrance_mass": "43054641548846615602104987524321069905599046554250600543037273660730652457482272541839730515070648167947373736069817/313353572444111882083840819200000000000000000", + "residual_mass": "49042140230293998707783330736939147773355026633889243363309955241604634320856117755537679249840200828104732776001/1224037392359812039390003200000000000000000", + "active_residual_sites": 24531 + } + } + }, + "caller": { + "bounds": { + "M_caller": { + "exact": "1683307283016999532839217702665847040", + "strict_power_of_two": 121, + "witness": { + "event": 3049, + "register": 38, + "cut": 3050, + "factor": "1", + "kind": "stored" + } + }, + "Sigma_caller": { + "exact": "2695731259664671076054039120630302290807170666389990427760914462684574300233033338017868618330691681743989716808381077807778556824792697624737901/489614956943924815756001280000000000000000", + "strict_power_of_two": 342, + "witness": { + "event": 3049, + "register": 38, + "cut": 3050, + "factor": "1", + "kind": "stored" + } + }, + "M_joint_entrance": { + "exact": "363421601940370671219209686545270656", + "strict_power_of_two": 119, + "witness": { + "event": 2958, + "register": 39, + "cut": 2958, + "factor": "1", + "kind": "stored" + } + }, + "E_joint_entrance": { + "exact": "107778012552827346405847104423459712044091204174915720927038598293389916160756229994638078765512640389070714203314649564279002071746068822744901/90669436471097188102963200000000000000000", + "strict_power_of_two": 340, + "witness": { + "event": 2958, + "register": 39, + "cut": 2958, + "factor": "1", + "kind": "stored" + } + }, + "M_context": { + "exact": "122242084395705304046405775033171708619552680284104135118685413362275751985828880546444259743657610652201504084362728377506070228340477415557984198359/2448074784719624078780006400000000000000000", + "strict_power_of_two": 355, + "witness": { + "event": 2958, + "register": null, + "cut": 2959, + "factor": "1", + "kind": "stored" + } + }, + "Sigma_context": { + "exact": "4640343697309072360426864039639398425323698691457297480226731324552426910539360988204800873215378559024454556530238470444629470161897688561609262440677193925127285900515809052352862295728477081215778601873520126328966022756201370807056733585720922317716753117/28411591829712752729879633148004541902111328635453440000000000000000000000000000000000", + "strict_power_of_two": 576, + "witness": { + "event": 2958, + "register": null, + "cut": 2959, + "factor": "1", + "kind": "stored" + } + }, + "Gamma_context": { + "exact": "5042543099912900584634479237866816375714959978199371983555924465478695914890855896880723670033343580129971146052169638034801848579828230759374251/26112797703675990173653401600000000000000000", + "strict_power_of_two": 337, + "witness": { + "register": 75, + "cut": 3095, + "factor": "1", + "kind": "public-return" + } + } + }, + "sites": { + "ADD": 2108, + "noninteger_scalar": 297, + "SWAP": 455, + "LAMBDA": 226, + "SCALE": 180, + "J": 18, + "IDLE_ONE": 100, + "QUERY": 8 + }, + "joint_entries": [ + { + "event": 21, + "stage": 1, + "entrance_mass": "3328", + "entrance_defect": "1" + }, + { + "event": 66, + "stage": 2, + "entrance_mass": "34560", + "entrance_defect": "49042140230293998707783330736939147773355026633889243363309955241605576340033277866883193796302920828104732776001/489614956943924815756001280000000000000000" + }, + { + "event": 117, + "stage": 3, + "entrance_mass": "267520", + "entrance_defect": "2108812029902641944434683221688383354254266145257237464622328075389039470736703374995869696668210235608503509368043/2448074784719624078780006400000000000000000" + }, + { + "event": 168, + "stage": 4, + "entrance_mass": "2019072", + "entrance_defect": "16134864135766725574860715812452979617433803762549561066528975274488231807439555387851827582560318872446457083304329/2448074784719624078780006400000000000000000" + }, + { + "event": 219, + "stage": 5, + "entrance_mass": "15211776", + "entrance_defect": "121771634191819998791426010219819903921240531131946991271098618864906624520505667420489347694551861856184051482810483/2448074784719624078780006400000000000000000" + }, + { + "event": 270, + "stage": 6, + "entrance_mass": "114566912", + "entrance_defect": "61155548867176616388605813428963117273373718212459886474047514186282142857251990646691721334804073152646601771673247/163204985647974938585333760000000000000000" + }, + { + "event": 321, + "stage": 7, + "entrance_mass": "862823680", + "entrance_defect": "55270492039541336543671813740530419540571115016393177270450319557289474736631709230321049654100735338074033838553127/19584598277756992630240051200000000000000" + }, + { + "event": 372, + "stage": 8, + "entrance_mass": "6498041600", + "entrance_defect": "17343801934583702937006282698449266549194778524101564804677928981149050603324448993845988267752114866260066850965529651/816024928239874692926668800000000000000000" + }, + { + "event": 423, + "stage": 9, + "entrance_mass": "48937594112", + "entrance_defect": "130618492994383424100319168601448567605519364451514173549136191620805577627371588484043940508558245549768348542471631393/816024928239874692926668800000000000000000" + }, + { + "event": 2166, + "stage": 10, + "entrance_mass": "2869851357661739006410624", + "entrance_defect": "11489803575218235511805117697701134113480218869673228159080398436813967004246120022800959502749874177476380957781746603727642347438883/1224037392359812039390003200000000000000000" + }, + { + "event": 2299, + "stage": 11, + "entrance_mass": "87987819921824138957327936", + "entrance_defect": "704540160391535167843708995319467954787148271049247100772820775546772061835491095158490262631639101903071648106627282596547306912051141/2448074784719624078780006400000000000000000" + }, + { + "event": 2399, + "stage": 12, + "entrance_mass": "2447027986812579413618418560", + "entrance_defect": "19593956207157814585542099171637083484399536383624515439519123579992273011070767829678915696763880133064580087939060906770438647639366057/2448074784719624078780006400000000000000000" + }, + { + "event": 2497, + "stage": 13, + "entrance_mass": "56556669663990103089614108160", + "entrance_defect": "452863193470205634175612401907111710258587553206913017938364343826269321349958557589024927000063584866778594443587603578149439404997611301/2448074784719624078780006400000000000000000" + }, + { + "event": 2593, + "stage": 14, + "entrance_mass": "1300380918848168161545814930560", + "entrance_defect": "3470823506970942577122482455505317346975950263088315745340912271169147263558828301965588012069803833245998486279949784240511975565156769293/816024928239874692926668800000000000000000" + }, + { + "event": 2687, + "stage": 15, + "entrance_mass": "29898949589421721863235314186112", + "entrance_defect": "47881651705850994435603572472068300623416695703612381880976634110649232768332859227000758396286188661213265593995896177334797525842861545957/489614956943924815756001280000000000000000" + }, + { + "event": 2779, + "stage": 16, + "entrance_mass": "687449590445880987173716162586496", + "entrance_defect": "1834859435257293951043017457492339542930895530500403467319398321342400394957593719271156117553868944530412724249343898830615952516894442180689/816024928239874692926668800000000000000000" + }, + { + "event": 2869, + "stage": 17, + "entrance_mass": "15806139033147704339825284871898752", + "entrance_defect": "126563650963042505306559371472874199746790380352600147326223640029014941135024237977168700785973597108281578476470227734553151811316232889247301/2448074784719624078780006400000000000000000" + }, + { + "event": 2958, + "stage": 18, + "entrance_mass": "363421601940370671219209686545270656", + "entrance_defect": "107778012552827346405847104423459712044091204174915720927038598293389916160756229994638078765512640389070714203314649564279002071746068822744901/90669436471097188102963200000000000000000" + } + ], + "independent_adjoint": { + "M_caller": { + "entrance_mass": "1683307283016999532839217702665847040", + "residual_mass": "2695731259664671076054039120630302290807170666389990427760914462684574300233033338017868618330691681743989716808381077807778556824792697624737901/489614956943924815756001280000000000000000", + "joint_coefficient": "274838256141142176415070287809505/2", + "primitive_coefficient": "104781665096099932454228246133920343" + }, + "Sigma_caller": { + "entrance_mass": "1683307283016999532839217702665847040", + "residual_mass": "2695731259664671076054039120630302290807170666389990427760914462684574300233033338017868618330691681743989716808381077807778556824792697624737901/489614956943924815756001280000000000000000", + "joint_coefficient": "274838256141142176415070287809505/2", + "primitive_coefficient": "104781665096099932454228246133920343" + }, + "M_joint_entrance": { + "entrance_mass": "363421601940370671219209686545270656", + "residual_mass": "107778012552827346405847104423459712044091204174915720927038598293389916160756229994638078765512640389070714203314649564279002071746068822744901/90669436471097188102963200000000000000000", + "joint_coefficient": "59336854494143543914675236360327/2", + "primitive_coefficient": "22622085086540611235550148326673690" + }, + "E_joint_entrance": { + "entrance_mass": "363421601940370671219209686545270656", + "residual_mass": "107778012552827346405847104423459712044091204174915720927038598293389916160756229994638078765512640389070714203314649564279002071746068822744901/90669436471097188102963200000000000000000", + "joint_coefficient": "59336854494143543914675236360327/2", + "primitive_coefficient": "22622085086540611235550148326673690" + }, + "Gamma_context": { + "entrance_mass": "59038824075417799032780136585499589", + "residual_mass": "5042543099912900584634479237866816375714959978199371983555924465478695914890855896880723670033343580129971146052169638034801848579828230759374251/26112797703675990173653401600000000000000000", + "joint_coefficient": "308461849925427171118076353794753/64", + "primitive_coefficient": "117600608836679351835159084859338679/32" + } + }, + "physical_main_inputs": 3952, + "fresh_arbitrary_helpers": 19440, + "helper_allocation_premise": "distinct (stage, helper) public inputs as in frozen caller proof" + } + }, + "threshold": { + "H": 14181100000000000000, + "LP": 2229, + "Kstar_bits": 14073, + "scaled4096_Kstar_bits": 14085 + }, + "negative_grid_controls": { + "S375_f24": "integer grid rejection at event 36837: denominator 48", + "S225_f24": "integer grid rejection at event 1118: denominator 250", + "S1125_f23": "integer grid rejection at event 61561: denominator 64" + }, + "scope": "Exact children for common grid. Total RDiv plus complete-fibre unitary contracts for rounded envelopes. Neither is a physical provider admission." + }, + "new_chart_maps": [ + { + "a": 3, + "b": 1048, + "recipe": { + "rank": 5, + "left": { + "matrix_rows": [ + 58, + 3, + 4, + 81, + 137, + 16, + 8, + 281, + 25 + ], + "offset": 0, + "quadratic_rows": [ + 26, + 27, + 0, + 19, + 11, + 0, + 0, + 0, + 0 + ], + "linear_Z4": [ + 2, + 3, + 2, + 2, + 2, + 0, + 0, + 0, + 0 + ], + "phase": 0 + }, + "right": { + "matrix_rows": [ + 250, + 257, + 4, + 243, + 235, + 259, + 328, + 304, + 384 + ], + "offset": 29, + "quadratic_rows": [ + 27, + 483, + 0, + 337, + 297, + 498, + 490, + 482, + 250 + ], + "linear_Z4": [ + 3, + 3, + 2, + 2, + 2, + 3, + 3, + 1, + 0 + ], + "phase": 0 + } + }, + "exact_columns": 512 + }, + { + "a": 3, + "b": 1052, + "recipe": { + "rank": 5, + "left": { + "matrix_rows": [ + 1, + 60, + 6, + 82, + 8, + 138, + 16, + 282, + 26 + ], + "offset": 0, + "quadratic_rows": [ + 0, + 28, + 30, + 22, + 14, + 0, + 0, + 0, + 0 + ], + "linear_Z4": [ + 2, + 2, + 3, + 2, + 2, + 0, + 0, + 0, + 0 + ], + "phase": 0 + }, + "right": { + "matrix_rows": [ + 1, + 252, + 258, + 246, + 222, + 262, + 280, + 352, + 384 + ], + "offset": 27, + "quadratic_rows": [ + 0, + 46, + 470, + 306, + 476, + 330, + 500, + 468, + 252 + ], + "linear_Z4": [ + 2, + 3, + 3, + 2, + 3, + 2, + 3, + 1, + 0 + ], + "phase": 0 + } + }, + "exact_columns": 512 + }, + { + "a": 902, + "b": 127, + "recipe": { + "rank": 2, + "left": { + "matrix_rows": [ + 5, + 10, + 16, + 32, + 65, + 2, + 3, + 128, + 256 + ], + "offset": 0, + "quadratic_rows": [ + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "linear_Z4": [ + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "phase": 0 + }, + "right": { + "matrix_rows": [ + 65, + 66, + 96, + 32, + 4, + 8, + 112, + 128, + 256 + ], + "offset": 75, + "quadratic_rows": [ + 32, + 96, + 0, + 0, + 0, + 3, + 66, + 0, + 0 + ], + "linear_Z4": [ + 2, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0 + ], + "phase": 0 + } + }, + "exact_columns": 512 + }, + { + "a": 930, + "b": 127, + "recipe": { + "rank": 2, + "left": { + "matrix_rows": [ + 5, + 9, + 16, + 32, + 66, + 2, + 128, + 256, + 3 + ], + "offset": 0, + "quadratic_rows": [ + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "linear_Z4": [ + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "phase": 0 + }, + "right": { + "matrix_rows": [ + 257, + 272, + 288, + 290, + 4, + 8, + 32, + 64, + 128 + ], + "offset": 75, + "quadratic_rows": [ + 32, + 0, + 0, + 0, + 288, + 17, + 0, + 0, + 272 + ], + "linear_Z4": [ + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1 + ], + "phase": 0 + } + }, + "exact_columns": 512 + } + ], + "controls": { + "native_scalar": 44020, + "deleted_query": 532, + "closed_compiler_gap": true, + "unfunded_upper_endpoint": true, + "chart_phases": 4 + } +} diff --git a/research/shared-wire-stop-fusion/SOURCES.json b/research/shared-wire-stop-fusion/SOURCES.json new file mode 100644 index 0000000000..d924e61f79 --- /dev/null +++ b/research/shared-wire-stop-fusion/SOURCES.json @@ -0,0 +1,132 @@ +{ + "schema_version": 1, + "base_commit": "17469fff78c22941280f04d39dc5a1faee09c840", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "research/shared-wire-split-composition/LICENSE", + "usage": "input", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "path": "research/shared-wire-split-composition/NOTICE", + "usage": "input", + "git_blob": "a3687d65a00794277cdaad37558d24008cbc37f5", + "sha256": "da12736e2e824167ff56f2ecb623a5f88f75a270410360890f61dffc33bab249" + }, + { + "path": "research/shared-wire-split-composition/INDEPENDENT-NOTICE.md", + "usage": "input", + "git_blob": "1bc9b4da2b8398954cd7a49356eb9d397785d0a6", + "sha256": "cadbc642ca84311d2c7a6cf704c7828cb4cf77e3c784b66e4c6e8a5c28002fb8" + }, + { + "path": "research/shared-wire-split-composition/NATIVE-INPUTS.json", + "usage": "input", + "git_blob": "347b2c4df65e55aacf289addc96d6558e8e1eaf2", + "sha256": "9bb6c1567783661334d6c1d23f715ce5635cbbb513678819ab9e020a34c7e4c0" + }, + { + "path": "research/shared-wire-split-composition/INDEPENDENT-SOURCES.json", + "usage": "input", + "git_blob": "95afd397782ada3dfcf0f4d9fa1fdb76ab6ea617", + "sha256": "dced1457df5230466ba6202fd6d4595bc2b7fb2a65302806bf2720b1837ff350" + }, + { + "path": "research/shared-wire-split-composition/data/final.json.gz", + "usage": "input", + "git_blob": "74563a7867d9d762b6588f65362369668841bb3e", + "sha256": "2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883" + }, + { + "path": "research/shared-wire-split-composition/data/caller.json", + "usage": "input", + "git_blob": "cf55f4271009a06ad192a070d330a4466b6d44fa", + "sha256": "3828d53e80ea97e8b866320f081af20b6b93bfebd58b95b56b85a7afe151af5e" + }, + { + "path": "research/shared-wire-split-composition/data/bit-admission.json", + "usage": "input", + "git_blob": "575f76487f9999ecc3e7b1b70f9f71bc582ef8a8", + "sha256": "a46b6c6040f75184cab5467656811ad988c216e3bc8e44d595a5015b6e49620b" + }, + { + "path": "research/shared-wire-split-composition/independent.py", + "usage": "input", + "git_blob": "1ae1d7c680ad86c0fa999f2e8f0c09e966fc07a0", + "sha256": "21f46a8340331abb1486b50bd4e04453f1968b0a5950d86ff7780dd368590874" + }, + { + "path": "research/shared-wire-split-composition/interval_gate.py", + "usage": "input", + "git_blob": "e24dc46079b4c25152f5afc096dda2ce8ee58ff5", + "sha256": "60a743d13f668ef86db4b8215b4d5d04430a671ba6f1fe06d9c1c4c3dfe86da5" + }, + { + "path": "research/shared-wire-split-composition/precision_replay.py", + "usage": "input", + "git_blob": "fafa1611dded2746f021714aad6837aed61041cb", + "sha256": "850d9098c5946ab27ef5228acc54d59df2196e72259d3e21588ec0c319c8f5ee" + }, + { + "path": "research/shared-wire-split-composition/frozen/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "path": "research/shared-wire-split-composition/frozen/native_verify.py", + "usage": "input", + "git_blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + { + "path": "research/shared-wire-split-composition/frozen/physical.py", + "usage": "input", + "git_blob": "5e0b17b9ef2151e3dee68378b71b3d0d47a56233", + "sha256": "4e995d1158033d83bf69b671f23dc7924d66edbbe07623ba063ba7421234ea20" + }, + { + "path": "research/shared-wire-split-composition/frozen/verify_host3_odd.py", + "usage": "input", + "git_blob": "2117502bedfc9fc0a7abade8243eb5a43d0b514e", + "sha256": "e75ad2096ba2587d1dc9c8982b2c2eb7c6fd2636a80adcd943314ef2cf6fd258" + }, + { + "path": "research/shared-wire-split-composition/retained/odd-native-common-grid/independent_bounds.py", + "usage": "input", + "git_blob": "8fe729386f81e6973bbe7ecaa5dbb4bf86281908", + "sha256": "198521def614fe78fa728f1dde2b7fb820c0c0e0ac3ad0c9224dccbf51eac0d5" + }, + { + "path": "research/shared-wire-split-composition/retained/query-only-precision-envelope/envelopes.py", + "usage": "input", + "git_blob": "70c8ca23763e30c924fb726b74b82f44d344c65f", + "sha256": "783da6b5b450fc07434946cb9ec86070dfee01df6b5fa1c385cb024def2c9a9f" + }, + { + "path": "research/shared-wire-split-composition/retained/query-only-precision-envelope/source_binding.py", + "usage": "input", + "git_blob": "9f0e0a8cbaf48266cf9c6aa8b263505e9569390c", + "sha256": "624c459311c58f3847b7713b818bfd340153abf42919f02ac9aa8892ed52a2bd" + }, + { + "path": "research/shared-wire-split-composition/FULL-RESULT.json", + "usage": "input", + "git_blob": "ff3256f0d3ffbfc56b062f9ec0fdbbc7b30e76d5", + "sha256": "d9ba709fa5dcefffe3f3abdcf34600ce188224703cfd743e6db8b58ba4816cb7" + } + ] +} diff --git a/research/shared-wire-stop-fusion/TASK.json b/research/shared-wire-stop-fusion/TASK.json new file mode 100644 index 0000000000..ecdf6742b1 --- /dev/null +++ b/research/shared-wire-stop-fusion/TASK.json @@ -0,0 +1,115 @@ +{ + "schema_version": 1, + "task_id": "p104-side-correction", + "base_commit": "17469fff78c22941280f04d39dc5a1faee09c840", + "original_card": { + "id": "p104-side-correction", + "question": "Can joint helper bases and a legal causal split improve the complete P104 productive/paid invoice?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "research/p104-helper-subspace-splits/README.md", + "research/dyadic-helper-channel-capacity/README.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "An exact arbitrary-input identity, source/target frame availability and restoration at the chosen cut, plus the complete channel+correction+idle/hosting bill or an explicit favorable bound. The native channel alone is not a supplier. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Start with the selected #5599 emitted word and review pending #5718 distinct input/output bases plus #5717/#5719 coverage before claiming work. Pick one uncovered source word, helper group and cut region. Prove the arbitrary-input relation and legal entry/exit corrections, then compare full target and paid profiles. Reject if completion, owned lifetimes or consumer costs repay the gain. A static pairing rank alone is not a physical split.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "P104", + "helper basis", + "helper split", + "5718", + "dyadic capacity" + ], + "existing_checks": [ + { + "scope": "PR #4133: literal-slot defect", + "evidence": "research/p104-literal-slot-defect/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "88666f1dee93fbd85b31fd5d6f91a219e111b5f4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4136: uniform commutation gap", + "evidence": "research/p104-uniform-commutation-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "281ce601a8be9db470de630759179c23e1dfaa88", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4140: uniform encoding gap", + "evidence": "research/p104-uniform-encoding-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "de25c6525aa866962309df5d107b32d55e6e5628", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4153: source-chart shortcut exhausts its optimistic allowance", + "evidence": "research/p104-source-chart-shortcut/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "9123241fea53df77e51ffe30d9aca1625d4bf3a8", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4154: fiber-tag seam mismatch", + "evidence": "research/p104-fiber-tag-seam/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "status": "author-checked", + "source_commit": "4ffcdaee5d6255a9cea1fe53a5424435068089d0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Move existing scalar contacts to another common chart and fuse five paid MOVE pairs on exact #7000. Rebuild and price the complete conditional supplier.", + "scope_change_reason": "The live witness already uses the earlier split mechanisms. Its binding paid invoice can improve by removing chronologically avoidable intermediate charts.", + "bottleneck_link": "Lower the complete paid moment with all targets, recursive caller and source contracts retained.", + "stop_rule": "Require a literal exact word, frozen receipt equality, independent native and strict rational complete price checks.", + "outcome": "completed", + "evidence": "PROOF.md, EDITS.json, DEPENDENCIES.json, RESULT.json and both independent checks.", + "author": "ToikY", + "ai_assistance": "Substantial OpenAI Codex assistance with separate native and price checks. No human or proof-kernel review.", + "open_questions": [ + { + "question": "Can a total physical provider and common-volume tariff bridge admit the retained odd-scalar word?", + "why_it_matters": "The exponent retains the source tariff and all-width contracts.", + "first_step": "Start from #6998 and audit the source/provider conversion and A6 trace under one tape width model.", + "blocked_by": "The fixed-tape conversion and total rounded provider are unresolved." + } + ] +} diff --git a/research/shared-wire-stop-fusion/VALIDATION.md b/research/shared-wire-stop-fusion/VALIDATION.md new file mode 100644 index 0000000000..a80afde380 --- /dev/null +++ b/research/shared-wire-stop-fusion/VALIDATION.md @@ -0,0 +1,40 @@ +# Validation record + +CPython 3.12.14, standard library, numerical threads fixed to one. The +canonical #7000 package tree `bfa28b1df589c76e8d93bca13a72b895f4da7612` +matches the exact author head. The candidate replay read all 19 declared +archived inputs from canonical base `17469fff78c22941280f04d39dc5a1faee09c840`. + +| Command | Exit | Seconds | +|---|---:|---:| +| `python3 -B scripts/research_package.py --package research/shared-wire-split-composition` at exact #7000 | 0 | 71.69 | +| `python3 -B scripts/research_package.py --package research/shared-wire-stop-fusion` with canonical archive inputs | 0 | 186.97 | +| `make frontier6030-verify` on the selected source closure | 0 | 522.30 | +| `make verify` on unmodified canonical `306de2c215cf973d9f27cd23f6d649345ccf30da` | 2 | 30.88 | + +The archive-based run passed all three registered commands. The primary +checked six construction mutants, every native endpoint at the fixed odd +grid, all four distinct direct chart maps with 2,048 exact Gaussian columns, +the separately implemented native and caller replays, complete strict price, +compiler and outer inequalities, and the retained precision engines. The +separate native audit compared 13 affected source rows, all 1,480 outputs, +the COPY input, and all 54 owned clear rows. The width-512 physical control +used prime 1,000,000,009 and seed 11 and accepted all 400 main and 1,080 +helper outputs. The second interval implementation rechecked the full +before/after invoices and the written claim's strict separation. + +Candidate replay stdout SHA-256 +`6846ad5bcce167cc24fc1d7d9e6a5a269fb0396ad61513c958d5a539f2932234`. +Frozen result SHA-256 +`98ff3277ca65dba06337363dcd80ae5d305bb580979d8ccedc1454b4fc987298`. +The deterministic canonical word SHA-256 is +`d0de7804e56b2c8fe6db9d323560e53041810fd0377b91680cbed19b5176ebc0`. + +The historical aggregate stopped in `copied-fixed-reversed-check` before +later Make groups ran. Its legacy manifest expects `scripts/partial_swap/shared.py` +SHA-256 `81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34`, +whereas the unmodified canonical file and GitHub bytes both hash to +`5a0646a50b9f3e8ea55168620a78e8853b0ab810517cefc8cfb8696aedee278a`. +The Makefile, witness, manifest and failing shared source are byte-identical +at the submission base. The historical check and source pin were left +intact. The selected incremental replay passed all five stages separately. diff --git a/research/shared-wire-stop-fusion/VERIFY.json b/research/shared-wire-stop-fusion/VERIFY.json new file mode 100644 index 0000000000..b594999d0e --- /dev/null +++ b/research/shared-wire-stop-fusion/VERIFY.json @@ -0,0 +1,59 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/shared-wire-split-composition/LICENSE", + "research/shared-wire-split-composition/NOTICE", + "research/shared-wire-split-composition/INDEPENDENT-NOTICE.md", + "research/shared-wire-split-composition/NATIVE-INPUTS.json", + "research/shared-wire-split-composition/INDEPENDENT-SOURCES.json", + "research/shared-wire-split-composition/data/final.json.gz", + "research/shared-wire-split-composition/data/caller.json", + "research/shared-wire-split-composition/data/bit-admission.json", + "research/shared-wire-split-composition/independent.py", + "research/shared-wire-split-composition/interval_gate.py", + "research/shared-wire-split-composition/precision_replay.py", + "research/shared-wire-split-composition/frozen/clifford_exact.py", + "research/shared-wire-split-composition/frozen/native_verify.py", + "research/shared-wire-split-composition/frozen/physical.py", + "research/shared-wire-split-composition/frozen/verify_host3_odd.py", + "research/shared-wire-split-composition/retained/odd-native-common-grid/independent_bounds.py", + "research/shared-wire-split-composition/retained/query-only-precision-envelope/envelopes.py", + "research/shared-wire-split-composition/retained/query-only-precision-envelope/source_binding.py", + "research/shared-wire-split-composition/FULL-RESULT.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/slide_stops.py" + ], + "timeout_seconds": 60, + "checks": "Deterministic source-bound stop search and scalar-order controls." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "Cold reconstruction, two exact native replays, odd-grid and owned history, changed Gaussian columns, exact caller, complete price and precision, compiler and outer ledger, finite physical streams." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/audit_price.py" + ], + "timeout_seconds": 180, + "checks": "Independent rational complete price comparison." + } + ] +} diff --git a/research/shared-wire-stop-fusion/audit_native.py b/research/shared-wire-stop-fusion/audit_native.py new file mode 100644 index 0000000000..a2a06f319d --- /dev/null +++ b/research/shared-wire-stop-fusion/audit_native.py @@ -0,0 +1,241 @@ +"""Independent order, integer-grid and chart audit. Apache-2.0, OpenAI Codex assisted.""" +from collections import Counter, defaultdict +from copy import deepcopy +from fractions import Fraction as Q +import gzip +from hashlib import sha256 +import importlib.util +import json +from math import gcd, lcm +from pathlib import Path +import sys + +INPUTS = Path(__file__).resolve().parent +PKG = INPUTS.parent / "shared-wire-split-composition" +if not __debug__: + raise RuntimeError("Run without -O; assertions are proof checks.") + + +def read(path): + raw = path.read_bytes() + return json.loads(gzip.decompress(raw) if raw.startswith(b"\x1f\x8b") else raw) + + +def digest(word): + return sha256(json.dumps(word, sort_keys=True, separators=(",", ":")).encode()).hexdigest() + + +def touched(e): + return set(e[1:3] if e[0] in ("ADD", "COPY") else e[1:2]) + + +def build(old, edit): + seq = old["program"] + insert, remove, repl, moved = defaultdict(list), set(), {}, set() + for p in edit["plans"]: + r = p["role"] + a, b = (m["index"] for m in p["old_moves"]) + first, last = seq[a], seq[b] + assert [first, last] == [m["event"] for m in p["old_moves"]] + assert 0 <= a < b and r < old["public"] and first[3] == last[2] + assert first[:2] == last[:2] == ["MOVE", r] and not first[4] and not last[4] + assert {i for i in range(a + 1, b) if r in touched(seq[i])} == {s["index"] for s in p["slides"]} + repl[a] = ["MOVE", r, first[2], last[3], False] + remove.add(b) + for s in p["slides"]: + i, k, chart = s["index"], s["before_event"], s["new_frame"] + assert seq[i] == s["event"] and seq[i][0] == "ADD" and seq[i][-1] == first[3] + assert i not in moved + assert (k <= a and chart == first[2]) or (k > b and chart == last[3]) + insert[k].append((i, [*seq[i][:-1], chart])) + moved.add(i) + tagged = [] + for i in range(len(seq) + 1): + tagged.extend(sorted(insert[i])) + if i < len(seq) and i not in remove and i not in moved: + tagged.append((i, repl.get(i, seq[i]))) + loc = {j: i for i, (j, _) in enumerate(tagged)} + assert len(loc) == len(tagged) == len(seq) - 5 + crossings, version_checks = Counter(), set(moved) + for i in moved: + a, b = seq[i][1:3] + for j in loc: + if (i < j) == (loc[i] < loc[j]): + continue + other = seq[j] + crossings["all"] += 1 + if not touched(seq[i]) & touched(other): + continue + op = other[0] + crossings[op] += 1 + if op == "MOVE": + continue + # E_ab E_cd = E_cd E_ab = 0 is sufficient for arbitrary values. + assert op == "ADD" and b != other[1] and other[2] != a, (i, j) + version_checks.add(j) + return tagged, crossings, version_checks + + +def subspace(basis): + span = {0} + for v in basis: + assert v not in span and 0 < v < 512 + span |= {x ^ v for x in span} + return span + + +def replay(word, tagged, checked, grid=1125): + n, m, unit = word["public"], word["owned_fields"], 2**24 + span = [subspace(f) for f in word["frames"]] + frames = word["initial"] + [None] * m + rows = [{r: grid * unit} for r in range(n)] + [{} for _ in range(m)] + live, versions, clear, copy = {}, {}, {}, {} + lifetimes, owned_moves = [], [] + paid, up, ops, odd = Counter(), Counter(), Counter(), Counter() + peak, max_mass, odd_lcm, high = 0, grid * unit, 1, 0 + + def measure(row): + nonlocal max_mass, odd_lcm, high + max_mass = max(max_mass, sum(abs(x) for x in row.values())) + for value in row.values(): + odd_lcm = lcm(odd_lcm, grid // gcd(grid, value)) + high = max(high, 25 - (abs(value) & -abs(value)).bit_length()) + + for origin, e in tagged: + op, r = e[:2] + ops[op] += 1 + if op == "INIT": + assert r >= n and frames[r] is None and r not in live + live[r] = origin + frames[r], rows[r] = e[2], {} + peak = max(peak, len(live)) + elif op == "CLEAR": + assert r in live and frames[r] == e[2] + clear[origin] = tuple(sorted(rows[r].items())) + lifetimes.append((live.pop(r), origin, r)) + frames[r], rows[r] = None, {} + elif op == "MOVE": + _, r, a, b, owned = e + assert frames[r] == a and owned == (r >= n) and (not owned or r in live) + assert span[a] < span[b] or (owned and span[b] < span[a]) + rank = abs(len(word["frames"][a]) - len(word["frames"][b])) + paid[rank] += 1 + if owned: + owned_moves.append((origin, live[r], e)) + if span[a] < span[b]: + up[rank] += 1 + frames[r] = b + else: + assert op in ("ADD", "COPY", "SCALE") + s = r if op == "SCALE" else e[2] + q = Q(e[-2]) + assert frames[r] is not None and frames[r] == frames[s] == e[-1] and q + assert (r == s) == (op == "SCALE") and abs(q) + 1 < 2**16 + if origin in checked: + versions[origin] = tuple(sorted(rows[s].items())) + if q.denominator & (q.denominator - 1): + odd[op] += 1 + product = {} + for j, value in rows[s].items(): + z, rem = divmod(value * q.numerator, q.denominator) + if rem: + raise ValueError(("grid", origin, q.denominator)) + if z: + product[j] = z + measure(product) + if op == "COPY": + assert r in live and not rows[r] + copy[origin] = tuple(sorted(product.items())) + if op == "SCALE": + rows[r] = product + else: + for j, z in product.items(): + if v := rows[r].get(j, 0) + z: + rows[r][j] = v + else: + rows[r].pop(j, None) + measure(rows[r]) + assert not live and frames == word["final"] + [None] * m + assert all(v % grid == 0 for row in rows[:n] for v in row.values()) + return (rows, versions, clear, copy, lifetimes, owned_moves), { + "opcodes": ops, "paid": paid, "owned_rises": up, "owned_peak": peak, + "owned_lifetimes": len(lifetimes), "owned_rise_mass": sum(r*n for r,n in up.items()), + "odd_divisions": odd, "odd_grid_lcm": odd_lcm, + "dyadic_height": high, "maximum_scaled_mass": str(Q(max_mass, unit)), + } + + +def module(name, path): + spec = importlib.util.spec_from_file_location(name, path) + obj = importlib.util.module_from_spec(spec) + sys.modules[name] = obj + spec.loader.exec_module(obj) + return obj + + +def lower(word, edit): + c = module("stop_compiler", PKG / "frozen/clifford_exact.py") + v = module("stop_interpreter", PKG / "frozen/native_verify.py") + pairs = sorted({(p["old_moves"][0]["event"][2], p["old_moves"][1]["event"][3]) + for p in edit["plans"]}) + frames = word["frames"] + result = [] + for a, b in pairs: + ca, cb = (c.canonical_frame(9, tuple(frames[i])) for i in (a,b)) + recipe, _ = c.lower_child(ca.adjoint().then(cb)) + expected = v.adjoint(v.frame(frames[a],9)) + v.frame(frames[b],9) + v.equal(v.recipe(recipe), expected, "absolute phase and signed-Pauli chart") + assert recipe["rank"] == len(frames[b]) - len(frames[a]) + result.append([a, b, recipe["rank"]]) + wrong = deepcopy(recipe) + wrong["left"]["phase"] = (wrong["left"]["phase"] + 1) % 4 + try: + v.equal(v.recipe(wrong), expected, "wrong absolute phase") + except ValueError: + pass + else: + raise AssertionError("Changed phase accepted") + return result + + +def main(): + source = read(PKG / "data/final.json.gz") + edit = read(INPUTS / "EDITS.json") + candidate = read(Path(sys.argv[1])) + assert digest(source) == edit["source_canonical_sha256"] == "91429a6b96729292a8764836e00c87a6f7cd3b76f05159033f4867f69a98d097" + assert digest(candidate) == "d0de7804e56b2c8fe6db9d323560e53041810fd0377b91680cbed19b5176ebc0" + tagged, crossings, checked = build(source, edit) + assert candidate == source | {"program": [e for _, e in tagged]} + base, a = replay(source, list(enumerate(source["program"])), checked) + new, b = replay(source, tagged, checked) + assert base == new, "Source versions, endpoints or owned history changed" + delta = b["paid"].copy() + delta.subtract(a["paid"]) + assert +delta == {2:2,5:3} and -delta == {1:7,4:3} + assert sum(r*n for r,n in delta.items()) == 0 + assert b["owned_rise_mass"] == 56 and sum(b["owned_rises"].values()) == 23 + assert b["owned_peak"] == 43 and b["owned_lifetimes"] == 54 and b["odd_grid_lcm"] == 1125 + assert all(a[k] == b[k] for k in ("dyadic_height", "odd_divisions", "maximum_scaled_mass")) + missing = {s["index"] for s in edit["plans"][0]["slides"]} + assert replay(source, [(i,e) for i,e in tagged if i not in missing], checked)[0][0] != new[0] + try: + replay(source, tagged, checked, grid=375) + except ValueError as err: + rejected_grid = str(err) + else: + raise AssertionError("Insufficient odd scale accepted") + print(json.dumps({ + "source_canonical_sha256": digest(source), "candidate_canonical_sha256": digest(candidate), + "edits_sha256": sha256((INPUTS/"EDITS.json").read_bytes()).hexdigest(), + "crossings": crossings, "exact_source_rows_compared": len(checked), + "exact_output_rows_compared": source["public"], "exact_owned_clear_rows_compared": len(new[2]), + "owned_move_events_and_lifetimes_identical": True, + "base": a, "candidate": b, "local_paid_delta": {r:n for r,n in delta.items() if n}, + "complete_paid_delta": {r:18*n for r,n in delta.items() if n}, + "checked_new_chart_pairs": lower(source, edit), + "controls": ["omitted slide changes endpoint", rejected_grid, "wrong absolute phase rejected"], + }, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/shared-wire-stop-fusion/audit_price.py b/research/shared-wire-stop-fusion/audit_price.py new file mode 100644 index 0000000000..f05fb5522d --- /dev/null +++ b/research/shared-wire-stop-fusion/audit_price.py @@ -0,0 +1,119 @@ +"""Independent directed rational price enclosure of the audited STOP invoice. + +Prepared for ToikY with substantial OpenAI Codex assistance. Apache-2.0. +""" +from collections import Counter +from decimal import Decimal, localcontext +from fractions import Fraction as Q +from functools import lru_cache +from hashlib import sha256 +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +PKG = HERE.parent / "shared-wire-split-composition" +GRID = 10**65 +if not __debug__: + raise RuntimeError("Run without -O; assertions are proof checks.") + + +def down(x): + return Q((x * GRID).__floor__(), GRID) + + +def up(x): + return Q((x * GRID).__ceil__(), GRID) + + +def log_series(x): + z = (x-1)/(x+1) + series = sum(2*z**(2*i+1)/(2*i+1) for i in range(80)) + tail = 2*z**161/(161*(1-z*z)) + return series, series + tail + + +@lru_cache(None) +def log(r): + a = r.bit_length() - 1 + l1,h1 = log_series(Q(r, 2**a)) + l2,h2 = log_series(Q(2)) + return down(l1 + a*l2), up(h1 + a*h2) + + +def exp_pos(x): + assert 0 <= x < 1 + term = total = Q(1) + for i in range(1, 48): + term *= x/i + total += term + # Terms after index 48 have ratio < 1/2. + return total, total + 2*term*x/48 + + +def raw_margin(hist, kappa): + lower = upper = Q(0) + for r,c in sorted(hist.items()): + lo,hi = log(r) + x = down(Q(kappa)*lo) + y = up(Q(kappa)*hi) + a,b = down(r/exp_pos(y)[1]), up(r/exp_pos(x)[0]) + lower += c*(a if c >= 0 else b) + upper += c*(b if c >= 0 else a) + return lower, upper + + +def crossing(hist): + with localcontext() as ctx: + ctx.prec = 66 + logs = {r: Decimal(r).ln() for r in hist} + lo,hi = Decimal(0), Decimal(".00376669") + for _ in range(145): + mid = (lo + hi)/2 + m = sum(c*r*(-mid*logs[r]).exp() for r,c in hist.items()) + if m > 0: + lo = mid + else: + hi = mid + diagnostic = (lo+hi)/2 + unit = 10**35 + floored = (Q(diagnostic)*unit).__floor__() + lo,hi = Q(floored,unit), Q(floored+1,unit) + lower_margin = raw_margin(hist, lo) + upper_margin = raw_margin(hist, hi) + assert lower_margin[0] > 0 and upper_margin[1] < 0 + return str(diagnostic), (lo,hi), (lower_margin,upper_margin) + + +def main(): + full = PKG / "FULL-RESULT.json" + raw = full.read_bytes() + assert sha256(raw).hexdigest() == FULL_SHA + source = json.loads(raw) + audit = json.loads((HERE/"RESULT.json").read_text()) + assert source["word_canonical_json_sha256"] == "91429a6b96729292a8764836e00c87a6f7cd3b76f05159033f4867f69a98d097" + assert audit["candidate_canonical_sha256"] == "d0de7804e56b2c8fe6db9d323560e53041810fd0377b91680cbed19b5176ebc0" + assert audit["invoice"]["T"] == source["invoice"]["T"] + hist = Counter({int(r): n for r,n in source["invoice"]["T"].items()}) + hist.subtract({int(r): n for r,n in source["invoice"]["P"].items()}) + new = Counter({int(r): n for r,n in audit["invoice"]["T"].items()}) + new.subtract({int(r): n for r,n in audit["invoice"]["P"].items()}) + assert {r: new[r]-hist[r] for r in new.keys() | hist.keys() if new[r] != hist[r]} == {1:126,2:-36,4:54,5:-54} + old_d, old_interval, old_m = crossing(hist) + new_d, new_interval, new_m = crossing(new) + assert old_interval[1] < Q(audit["gate"]["claim"]) < new_interval[0] + assert sum(r*n for r,n in hist.items()) == sum(r*n for r,n in new.items()) == 1520 + out = { + "status": "PASS_INDEPENDENT_STOP_PRICE", "source_full_result_sha256": FULL_SHA, + "baseline_diagnostic": old_d, "candidate_diagnostic": new_d, + "baseline_bracket": list(map(str,old_interval)), "candidate_bracket": list(map(str,new_interval)), + "baseline_bracket_margins": [list(map(str,row)) for row in old_m], + "candidate_bracket_margins": [list(map(str,row)) for row in new_m], + "strict_improvement_in_raw_crossing": str(new_interval[0] - old_interval[1]), + "complete_signed_rank_mass_surplus": 1520, + } + print(json.dumps(out, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + FULL_SHA = "d9ba709fa5dcefffe3f3abdcf34600ce188224703cfd743e6db8b58ba4816cb7" + main() diff --git a/research/shared-wire-stop-fusion/build_candidate.py b/research/shared-wire-stop-fusion/build_candidate.py new file mode 100644 index 0000000000..873acbab4a --- /dev/null +++ b/research/shared-wire-stop-fusion/build_candidate.py @@ -0,0 +1,144 @@ +"""Apply the frozen commuting ADD slides and emit a literal native candidate. + +Prepared for ToikY with substantial OpenAI Codex assistance. Apache-2.0. +""" + +from collections import Counter, defaultdict +from copy import deepcopy +from hashlib import sha256 +from pathlib import Path +import argparse +import gzip +import json +import sys + + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +from slide_stops import HEAD, PAYLOAD_SHA, SOURCE, commute, inventory, need, payload, roles, span + + +def place(old, edit, spaces, history): + need(edit["source_head"] == HEAD and edit["source_canonical_sha256"] == PAYLOAD_SHA, "Pinned edit manifest") + events = old["program"] + previous = set() + move_replace, remove, add_at, shifted = {}, set(), defaultdict(list), {} + changed = [] + for plan in edit["plans"]: + role = plan["role"] + need(type(role) is int and role < old["public"], "Only public MOVE contractions") + first, second = (m["index"] for m in plan["old_moves"]) + need(type(first) is int and type(second) is int and 0 <= first < second < len(events), "Two ordered MOVE indices") + left, right = events[first], events[second] + need(all(events[m["index"]] == m["event"] for m in plan["old_moves"]), "Bound source MOVE") + need(left[:2] == right[:2] == ["MOVE", role] and left[3] == right[2] + and left[4] is False and right[4] is False, "Public MOVE chain") + a, b, c = left[2], left[3], right[3] + need(spaces[a] < spaces[b] < spaces[c], "Three strict nested charts") + middle = [i for i in history[role] if first < i < second] + need(middle == [s["index"] for s in plan["slides"]], "Every stop contact must be moved exactly once") + footprints = {role} + cuts = [] + for slide in plan["slides"]: + i, j, frame = slide["index"], slide["before_event"], slide["new_frame"] + need(type(i) is int and type(j) is int and 0 <= j <= len(events), "Slide cut") + need(events[i] == slide["event"] and events[i][0] == "ADD" and events[i][-1] == b, "Bound scalar opcode") + need((j <= first and frame == a) or (j > second and frame == c), "Slide outside the vacated chart") + need(i not in shifted, "Unique shifted ADD") + footprints.update(roles(events[i])) + cuts.append(j) + shifted[i] = (j, 0, i) + add_at[j].append((i, [*events[i][:-1], frame])) + need(cuts == sorted(cuts), "Original contact order is retained") + need(not (footprints & previous), "Disjoint changed operand sets") + previous.update(footprints) + move_replace[first] = ["MOVE", role, a, c, False] + remove.add(second) + changed.append({"role": role, "direct_chart_pair": [a, c], + "retired_chart_pairs": [[a, b], [b, c]], "operand_roles": sorted(footprints)}) + require_crossings = Counter() + for i, new_key in shifted.items(): + touched = set().union(*(history[r] for r in roles(events[i]))) + for j in touched - {i}: + other_key = shifted.get(j, (j, 1, j)) + if (i < j) == (new_key < other_key): + continue + need(commute(events[i], events[j]), ("Noncommuting relative-order change", i, j)) + require_crossings[events[j][0]] += 1 + new_program = [] + for i in range(len(events) + 1): + new_program.extend(e for _, e in sorted(add_at.get(i, ()))) + if i < len(events) and i not in remove and i not in shifted: + new_program.append(move_replace.get(i, events[i])) + new = old | {"program": new_program} + inventory(new, spaces) + return new, dict(require_crossings), changed + + +def moves(word): + dim = list(map(len, word["frames"])) + return Counter(abs(dim[e[3]] - dim[e[2]]) for e in word["program"] if e[0] == "MOVE") + + +def controls(old, edit, spaces, history): + changes = [ + ("missing stop contact", lambda p: p["slides"].clear(), "Every stop contact"), + ("changed coefficient", lambda p: p["slides"][0]["event"].__setitem__(3, "1"), "Bound scalar opcode"), + ("wrong target frame", lambda p: p["slides"][0].__setitem__("new_frame", 246), "vacated chart"), + ("changed original MOVE", lambda p: p["old_moves"][1]["event"].__setitem__(2, 0), "Bound source MOVE"), + ("illegal coframe after slide", lambda p: p["slides"][0].__setitem__("before_event", 43418), "Scalar chart"), + ("crossed noncommuting source write", lambda p: p["slides"][0].__setitem__("before_event", 45545), + "Noncommuting relative-order change"), + ] + passed = [] + for label, mutation, expected in changes: + bad = deepcopy(edit) + mutation(bad["plans"][0]) + try: + place(old, bad, spaces, history) + except ValueError as exc: + need(expected in str(exc), (label, "Wrong failure reason", str(exc))) + else: + raise ValueError((label, "negative control passed")) + passed.append(label) + return passed + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--source", type=Path, default=SOURCE) + parser.add_argument("--edit", type=Path, default=HERE / "EDITS.json") + parser.add_argument("--candidate", type=Path, required=True) + args = parser.parse_args() + old = json.loads(gzip.decompress(args.source.read_bytes())) + need(sha256(payload(old)).hexdigest() == PAYLOAD_SHA, "Pinned source word") + edit = json.loads(args.edit.read_bytes()) + spaces = [span(basis) for basis in old["frames"]] + history, _, _ = inventory(old, spaces) + new, reordered, changed = place(old, edit, spaces, history) + passed = controls(old, edit, spaces, history) + paid_old, paid_new = moves(old), moves(new) + paid_delta = paid_new.copy() + paid_delta.subtract(paid_old) + paid_delta = {r: n for r, n in sorted(paid_delta.items()) if n} + need(paid_delta == {1: -7, 2: 2, 4: -3, 5: 3}, "Literal paid rank change") + need(sum(r * n for r, n in paid_delta.items()) == 0, "Paid rank mass unchanged") + need(all(new[k] == old[k] for k in old if k != "program"), "Boundary and hosted metadata unchanged") + raw = payload(new) + compressed = gzip.compress(raw, mtime=0) + args.candidate.write_bytes(compressed) + print(json.dumps({ + "source_head": HEAD, "source_canonical_sha256": PAYLOAD_SHA, + "edit_sha256": sha256(args.edit.read_bytes()).hexdigest(), + "candidate_canonical_sha256": sha256(raw).hexdigest(), + "candidate_gzip_sha256": sha256(compressed).hexdigest(), + "old_events": len(old["program"]), "new_events": len(new["program"]), + "old_paid": dict(sorted(paid_old.items())), "new_paid": dict(sorted(paid_new.items())), + "native_paid_delta": paid_delta, "native_target_delta": {}, "owned_change": {}, + "crossed_common_operand_events": reordered, + "changed": changed, "controls": passed, + }, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/shared-wire-stop-fusion/slide_stops.py b/research/shared-wire-stop-fusion/slide_stops.py new file mode 100644 index 0000000000..16ac095ea5 --- /dev/null +++ b/research/shared-wire-stop-fusion/slide_stops.py @@ -0,0 +1,193 @@ +"""Find removable MOVE stops after commuting scalar contacts to another chart. + +Prepared for ToikY with substantial OpenAI Codex assistance. Apache-2.0. +""" + +from bisect import bisect_left, bisect_right +from collections import Counter, defaultdict +from hashlib import sha256 +from itertools import chain +from pathlib import Path +import gzip +import json + + +SOURCE = Path(__file__).resolve().parents[1] / "shared-wire-split-composition/data/final.json.gz" +HEAD = "93effe2a135bf57b9e484cb630d8dd057159aec9" +PAYLOAD_SHA = "91429a6b96729292a8764836e00c87a6f7cd3b76f05159033f4867f69a98d097" + + +def need(value, why): + if not value: + raise ValueError(why) + + +def payload(word): + return json.dumps(word, sort_keys=True, separators=(",", ":")).encode() + + +def span(basis): + space = {0} + for x in basis: + need(0 < x < 512 and x not in space, "Invalid binary basis") + space.update(x ^ y for y in tuple(space)) + return frozenset(space) + + +def roles(event): + return event[1:3] if event[0] in {"ADD", "COPY"} else event[1:2] + + +def commute(left, right): + """MOVE is chart transport, hence identity in normalized coordinates.""" + if right[0] == "MOVE" or not set(roles(left)).intersection(roles(right)): + return True + if left[0] == right[0] == "ADD": + return left[2] != right[1] and right[2] != left[1] + if left[0] == right[0] == "SCALE": + return True + return False + + +def inventory(word, spaces): + program = word["program"] + public = len(word["initial"]) + all_roles = public + word["owned_fields"] + history = defaultdict(list) + transitions = [[-1] for _ in range(all_roles)] + charts = [[f] for f in word["initial"]] + [[None] for _ in range(word["owned_fields"])] + for i, event in enumerate(program): + op, role = event[:2] + for touched in roles(event): + history[touched].append(i) + current = charts[role][-1] + if op == "MOVE": + a, b, private = event[2:] + need(current == a and private == (role >= public), ("MOVE frame", i)) + need(spaces[a] < spaces[b] or (private and spaces[b] < spaces[a]), ("MOVE nested", i)) + transitions[role].append(i) + charts[role].append(b) + elif op == "INIT": + need(current is None and role >= public, ("INIT", i)) + transitions[role].append(i) + charts[role].append(event[2]) + elif op == "CLEAR": + need(current == event[2] and role >= public, ("CLEAR", i)) + transitions[role].append(i) + charts[role].append(None) + elif op in {"ADD", "COPY", "SCALE"}: + need(all(charts[s][-1] == event[-1] for s in roles(event)), ("Scalar chart", i)) + else: + raise ValueError(("Unknown event", i)) + need([c[-1] for c in charts] == word["final"] + [None] * word["owned_fields"], "Final charts") + return history, transitions, charts + + +def scalar_interval(index, program, history, moved): + event = program[index] + conflicts = set(chain.from_iterable(history[r] for r in roles(event))) - moved + incompatible = [i for i in conflicts if not commute(event, program[i])] + lo = max((i + 1 for i in incompatible if i < index), default=0) + hi = min((i for i in incompatible if i > index), default=len(program)) + return lo, hi + + +def first_slot(lo, hi, role, chart, transitions, charts): + if lo > hi: + return None + for j in range(bisect_left(transitions[role], lo) - 1, bisect_left(transitions[role], hi)): + if charts[role][j] == chart: + cut = max(lo, transitions[role][j] + 1) + if cut <= hi: + return cut + return None + + +def placement(role, contacts, bounds, frame, program, trans, charts): + lo, hi = bounds + chosen = [] + for index, available_lo, available_hi in contacts: + left = max(lo, available_lo) + right = min(hi, available_hi) + event = program[index] + if event[0] == "SCALE": + cut = left if left <= right else None + else: + other = event[1] if event[2] == role else event[2] + cut = first_slot(left, right, other, frame, trans, charts) + if cut is None: + return None + lo = cut + chosen.append((index, cut, frame)) + return chosen + + +def plans(word, spaces, history, trans, charts): + program = word["program"] + stats = Counter() + hits = [] + for role, route in enumerate(trans): + for idx, (first, second) in enumerate(zip(route, route[1:])): + if first < 0 or program[first][0] != "MOVE" or program[second][0] != "MOVE": + continue + e, f = program[first], program[second] + a, b, c = e[2], e[3], f[3] + need(b == f[2], "Consecutive MOVE endpoint") + stats["two_hops"] += 1 + if not (a == c or spaces[a] < spaces[c] or (e[4] and spaces[c] < spaces[a])): + stats["unnested_shortcut"] += 1 + continue + start = bisect_right(history[role], first) + stop = bisect_left(history[role], second) + contacts = history[role][start:stop] + stats[f"eligible_{len(contacts)}_contacts"] += 1 + if any(program[i][0] not in {"ADD", "SCALE"} for i in contacts): + stats["exclusive_middle_contact"] += 1 + continue + moved = set(contacts) + contacts = [(i, *scalar_interval(i, program, history, moved)) for i in contacts] + prev_event = route[idx - 1] + next_event = route[idx + 2] if idx + 2 < len(route) else len(program) + for pivot in range(len(contacts) + 1): + left = placement(role, contacts[:pivot], (prev_event + 1, first), a, program, trans, charts) + if left is None: + continue + right = placement(role, contacts[pivot:], (second + 1, next_event), c, program, trans, charts) + if right is None: + continue + remove_ranks = [abs(len(word["frames"][a]) - len(word["frames"][b])), + abs(len(word["frames"][b]) - len(word["frames"][c]))] + replacement_rank = abs(len(word["frames"][a]) - len(word["frames"][c])) + hits.append({"role": role, "moves": [first, second], "frames": [a, b, c], + "repositioned": left + right, "old_move_ranks": remove_ranks, + "replacement_rank": replacement_rank}) + break + return stats, hits + + +def controls(): + e = ["ADD", 1, 2, "1", 0] + need(commute(e, ["ADD", 1, 3, "-1", 0]), "Shared destination commutes") + need(commute(e, ["ADD", 3, 2, "-1", 0]), "Shared source commutes") + need(not commute(e, ["ADD", 2, 3, "-1", 0]), "Source version must be preserved") + need(not commute(e, ["COPY", 4, 1, "1", 0]), "Copy barrier") + trans, charts = [[-1, 3, 6]], [[4, 7, 9]] + need(first_slot(3, 6, 0, 7, trans, charts) == 4, "Correct cut after MOVE") + need(first_slot(3, 3, 0, 7, trans, charts) is None, "Chart not reached") + return 6 + + +def main(): + count = controls() + word = json.loads(gzip.decompress(SOURCE.read_bytes())) + digest = sha256(payload(word)).hexdigest() + need(digest == PAYLOAD_SHA, "Native word differs from pinned source") + spans = [span(basis) for basis in word["frames"]] + history, trans, charts = inventory(word, spans) + stats, hits = plans(word, spans, history, trans, charts) + print(json.dumps({"head": HEAD, "source_sha256": digest, "controls": count, + "stats": dict(stats), "nominations": hits}, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/shared-wire-stop-fusion/verify.py b/research/shared-wire-stop-fusion/verify.py new file mode 100644 index 0000000000..0f7942e6b8 --- /dev/null +++ b/research/shared-wire-stop-fusion/verify.py @@ -0,0 +1,226 @@ +#!/usr/bin/env python3 +"""Rebuild and certify the five public MOVE fusions on the exact #7000 word. + +Prepared for ToikY with substantial OpenAI Codex assistance. Apache-2.0. +""" + +import argparse +from collections import Counter +from copy import deepcopy +from fractions import Fraction +import hashlib +import importlib.util +import gzip +import json +from pathlib import Path +import subprocess +import sys +from tempfile import TemporaryDirectory + + +HERE = Path(__file__).resolve().parent +VENDOR = HERE.parent / "shared-wire-split-composition" +SOURCE = VENDOR / "data/final.json.gz" +SOURCE_HEAD = "93effe2a135bf57b9e484cb630d8dd057159aec9" +CANDIDATE_SHA = "d0de7804e56b2c8fe6db9d323560e53041810fd0377b91680cbed19b5176ebc0" +PAID_DELTA = {1: -7, 2: 2, 4: -3, 5: 3} + + +def need(ok, reason): + if not ok: + raise ValueError(reason) + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def module(name, relative): + path = VENDOR / relative + spec = importlib.util.spec_from_file_location(name, path) + value = importlib.util.module_from_spec(spec) + sys.modules[name] = value + spec.loader.exec_module(value) + return value + + +def authenticate(): + deps = json.loads((HERE / "DEPENDENCIES.json").read_bytes()) + need(deps["source_commit"] == SOURCE_HEAD, "Pinned #7000 source head") + registered = json.loads((HERE / "VERIFY.json").read_bytes())["inputs"] + need([row["source_path"] for row in deps["files"]] == registered, "Complete registered source inventory") + for row in deps["files"]: + path = HERE.parents[1] / row["source_path"] + need(path.resolve().is_relative_to(VENDOR), "Input is within the archived source") + raw = path.read_bytes() + git_blob = hashlib.sha1(f"blob {len(raw)}\0".encode() + raw).hexdigest() + need(sha(raw) == row["sha256"] and git_blob == row["git_blob"], row["source_path"]) + + +def signed_delta(before, after): + delta = Counter(after) + delta.subtract(before) + return {r: n for r, n in sorted(delta.items()) if n} + + +def margin(engine, invoice, kappa): + return engine.sub(engine.moment(invoice["T"], kappa), engine.moment(invoice["P"], kappa)) + + +def certify_price(engine, baseline, candidate, source): + old_lo, old_hi = map(Fraction, (source["raw_lower"], source["raw_upper"])) + bit = Fraction(source["numeric_BIT_price"]) + need(margin(engine, baseline, old_lo)[0] > 0 and margin(engine, baseline, old_hi)[1] < 0, + "Original literal invoice crosses in the pinned bracket") + need(margin(engine, candidate, old_hi)[0] > 0, "Positive strict gain at the old upper endpoint") + scale = 10**32 + lo, hi = int(old_hi * scale), int(bit * scale) + need(margin(engine, candidate, Fraction(hi, scale))[1] < 0, "Complex price binds below BIT") + while hi - lo > 1: + middle = (hi + lo) // 2 + value = margin(engine, candidate, Fraction(middle, scale)) + if value[0] > 0: + lo = middle + else: + need(value[1] < 0, "Every crossing-bisection sign is exact") + hi = middle + lower, upper = Fraction(lo, scale), Fraction(hi, scale) + gap = Fraction(1, 10**14) + claim = Fraction((lower - 7*gap) * 10**11 // 1, 10**11) + tested = claim + 7*gap + old_claim = Fraction(source["claim"]) + need(old_claim < old_hi < claim, "Published rational claim exceeds the previous raw upper bound") + gate = engine.gate(candidate, claim, tested, lower, upper, bit) + need(gate["compiler_gap"] == str(gap), "Exact compiler gap") + return gate, {"claim_gain": str(claim - old_claim), + "claim_vs_old_raw_upper": str(claim - old_hi), + "raw_gain_interval": [str(lower - old_hi), str(upper - old_lo)], + "new_margin_at_old_upper": engine.show(margin(engine, candidate, old_hi))} + + +def chart_maps(word, edits): + compiler = module("stop_fusion_clifford", "frozen/clifford_exact.py") + check = module("stop_fusion_native", "frozen/native_verify.py") + frames = word["frames"] + recipes = [] + changed = {(p["old_moves"][0]["event"][2], p["old_moves"][1]["event"][3]) for p in edits["plans"]} + for a, b in sorted(changed): + ca, cb = (compiler.canonical_frame(9, tuple(frames[k])) for k in (a, b)) + recipe, _ = compiler.lower_child(ca.adjoint().then(cb)) + expected = check.adjoint(check.frame(frames[a], 9)) + check.frame(frames[b], 9) + need(recipe["rank"] == len(frames[b]) - len(frames[a]) > 0, "Fused paid rank") + lowered = check.recipe(recipe) + check.equal(lowered, expected, "Every signed Pauli and absolute phase") + for column in range(512): + need(check.state(lowered, column) == check.state(expected, column), "Changed Gaussian column") + wrong = deepcopy(recipe) + wrong["left"]["phase"] = (wrong["left"]["phase"] + 1) % 4 + try: + check.equal(check.recipe(wrong), expected, "Wrong absolute phase") + except ValueError: + pass + else: + raise ValueError("Accepted a wrong absolute phase") + recipes.append({"a": a, "b": b, "recipe": recipe, "exact_columns": 512}) + need(len(recipes) == 4, "Four distinct fused chart maps") + return recipes + + +def bit_binding(independent, manifest): + bit = independent.load(VENDOR / "data/bit-admission.json") + previous = Fraction(bit["previous_ordinary"]) + need(previous == Fraction(".0034") and bit["empty_body_targets"] == + {"count": 0, "rank1_productive_credit": 0}, "Selected start and E-free BIT targets") + for row in bit["ordinary_bootstrap"]: + atom, covered, admitted = map(Fraction, (row["atom"], row["covered"], row["admitted"])) + envelope = (1-atom)*covered + atom*previous + need(previous == Fraction(row["previous"]) and envelope == Fraction(row["envelope"]) and + previous < admitted < envelope, "Exact BIT bootstrap") + previous = admitted + need(previous == Fraction(bit["ordinary_admitted"]) == Fraction(".00385248") and + Fraction(manifest["numeric_BIT_price"]) < previous, "Retained BIT margin") + + +def certify(candidate_path, edits): + independent = module("stop_fusion_independent", "independent.py") + engine = module("stop_fusion_intervals", "interval_gate.py") + precision = module("stop_fusion_precision", "precision_replay.py") + manifest = independent.load(VENDOR / "INDEPENDENT-SOURCES.json") + word, baseline = map(independent.load, (candidate_path, SOURCE)) + caller = independent.load(VENDOR / "data/caller.json") + bit_binding(independent, manifest) + original_native = independent.native(baseline) + native = independent.native(word) + need(not original_native["bad_inputs"] and not native["bad_inputs"], "Independent all-input native adjoint") + need(all(original_native[name] == native[name] for name in + ("public", "helpers", "rises", "owned_peak", "lifetimes")), "Same target and owned census") + need(native["events"] == original_native["events"] - 5, "Five paid fusions in literal word") + need(signed_delta(original_native["paid"], native["paid"]) == PAID_DELTA, "Literal local paid histogram") + old_invoice = independent.invoices(baseline, caller, original_native) + invoice = independent.invoices(word, caller, native) + need(old_invoice["T"] == invoice["T"] and old_invoice["S"] == invoice["S"] == 1520 and + invoice["empty_root_credits"] == 0, "Complete T and rank surplus unchanged") + need(signed_delta(old_invoice["P"], invoice["P"]) == {r: 18*n for r, n in PAID_DELTA.items()}, + "Complete paid profile over the 18 literal LOCALs") + old_ordinary = independent.ordinary(baseline, caller, original_native) + ordinary = independent.ordinary(word, caller, native) + need(ordinary["conservative_total"] == old_ordinary["conservative_total"] - 90000 < 10**9, + "Conservative ordinary tariff and route savings") + caller_result = independent.caller(caller) + need(not caller_result["bad_outputs"], "Exact formal caller") + gate, gain = certify_price(engine, old_invoice, invoice, manifest) + precision_result = precision.run(word, caller, gate, manifest) + changed_maps = chart_maps(word, edits) + + bad_event = next(i for i, e in enumerate(word["program"]) + if e[:4] == edits["plans"][0]["slides"][0]["event"][:4] and e[-1] == 127) + need(independent.native(word, mutant=bad_event)["bad_inputs"], "Fused-word scalar mutation must fail") + wrong = deepcopy(caller) + query = next(i for i, e in enumerate(wrong["events"]) if e[0] != "J" and e[1] == "QUERY") + del wrong["events"][query] + need(independent.caller(wrong)["bad_outputs"], "Omitted QUERY must fail") + lower, upper = gate["raw_bracket"] + try: + engine.gate(invoice, gate["claim"], gate["claim"], lower, upper, gate["BIT_pin"]) + except AssertionError: + pass + else: + raise ValueError("Closed compiler gap accepted") + need(margin(engine, invoice, Fraction(upper))[1] < 0, "Unfunded upper crossing rejected") + return {"status": "PASS_SHARED_WIRE_STOP_FUSION", "source_head": SOURCE_HEAD, + "candidate_canonical_sha256": CANDIDATE_SHA, "native": native, "invoice": invoice, + "ordinary": ordinary, "caller": caller_result, "gate": gate, "gain": gain, + "precision": precision_result, "new_chart_maps": changed_maps, + "controls": {"native_scalar": bad_event, "deleted_query": query, "closed_compiler_gap": True, + "unfunded_upper_endpoint": True, "chart_phases": len(changed_maps)}} + + +def command(*args): + subprocess.run([sys.executable, "-I", "-B", *map(str, args)], check=True) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--out", type=Path, help="Write a new, explicit result path for a clean comparison") + args = parser.parse_args() + authenticate() + with TemporaryDirectory(prefix="p104-stop-fusion-") as temporary: + word = Path(temporary) / "word.json.gz" + command(HERE / "build_candidate.py", "--source", SOURCE, "--candidate", word) + need(sha(gzip.decompress(word.read_bytes())) == CANDIDATE_SHA, "Frozen candidate payload") + command(VENDOR / "frozen/verify_host3_odd.py", word, "1125") + command(HERE / "audit_native.py", word) + result = certify(word, json.loads((HERE / "EDITS.json").read_bytes())) + command(VENDOR / "frozen/physical.py", word, VENDOR / "frozen/clifford_exact.py", "1000000009", "11") + canonical = json.loads(json.dumps(result)) + if args.out is not None: + with args.out.open("x") as stream: + json.dump(canonical, stream, indent=2) + stream.write("\n") + else: + need(canonical == json.loads((HERE / "RESULT.json").read_bytes()), "Frozen proof-relevant receipt") + print(result["status"], result["gate"]["claim"], result["gain"]["claim_gain"], flush=True) + + +if __name__ == "__main__": + main()