diff --git a/research/clean-rational-clear-witness/.gitattributes b/research/clean-rational-clear-witness/.gitattributes new file mode 100644 index 0000000000..4f7fc3ef14 --- /dev/null +++ b/research/clean-rational-clear-witness/.gitattributes @@ -0,0 +1 @@ +* -text whitespace=cr-at-eol diff --git a/research/clean-rational-clear-witness/EXAMPLE-PROVENANCE.json b/research/clean-rational-clear-witness/EXAMPLE-PROVENANCE.json new file mode 100644 index 0000000000..99a8f156dc --- /dev/null +++ b/research/clean-rational-clear-witness/EXAMPLE-PROVENANCE.json @@ -0,0 +1,35 @@ +{ + "candidate_canonical_sha256": "ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d", + "event_zero_based": 88937, + "target": 1502, + "target_chart": 353, + "donors": { + "1072": { + "coefficient": 1, + "chart": 359 + }, + "500": { + "coefficient": -1, + "chart": 359 + } + }, + "output_limb": [ + "real", + 0 + ], + "source_columns_checked": 512, + "realified_source_columns": 1024, + "integer_coefficients": [ + 1, + 1, + 1, + 1, + -1, + -1, + -1, + -1 + ], + "denominator": 2, + "phase_negative_control": true, + "scope": "One real output row; exact published native interpreter reused. No rounded-input reachability, complete CLEAR or physical compiler claim." +} diff --git a/research/clean-rational-clear-witness/INDEPENDENT-AUDIT-V1.json b/research/clean-rational-clear-witness/INDEPENDENT-AUDIT-V1.json new file mode 100644 index 0000000000..f365bfa186 --- /dev/null +++ b/research/clean-rational-clear-witness/INDEPENDENT-AUDIT-V1.json @@ -0,0 +1,8 @@ +{ + "independent_contracts": 27, + "all_source_and_target_pairs": 1686, + "all_wire_indices_distinct_per_gate": true, + "inverse_roundtrips_arbitrary_nonzero_ancillas": 100, + "manifest_and_regenerated_result_match": true, + "limits": "No full project chart binding or supplier/tape/cost verification." +} diff --git a/research/clean-rational-clear-witness/INDEPENDENT-EDGE-AUDIT-V1.json b/research/clean-rational-clear-witness/INDEPENDENT-EDGE-AUDIT-V1.json new file mode 100644 index 0000000000..56b6af126c --- /dev/null +++ b/research/clean-rational-clear-witness/INDEPENDENT-EDGE-AUDIT-V1.json @@ -0,0 +1,22 @@ +[ + { + "case": "positive_edge_exact", + "target_zero": true, + "invalid": 0 + }, + { + "case": "negative_edge_exact", + "target_zero": true, + "invalid": 0 + }, + { + "case": "fraction", + "target_zero": true, + "invalid": 1 + }, + { + "case": "overflow", + "target_zero": true, + "invalid": 1 + } +] diff --git a/research/clean-rational-clear-witness/LICENSE b/research/clean-rational-clear-witness/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/clean-rational-clear-witness/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/clean-rational-clear-witness/MANIFEST.json b/research/clean-rational-clear-witness/MANIFEST.json new file mode 100644 index 0000000000..08437b768e --- /dev/null +++ b/research/clean-rational-clear-witness/MANIFEST.json @@ -0,0 +1,29 @@ +{ + "purpose": "public standalone no-kappa package integrity receipts; not scientific admission gates", + "files": { + ".gitattributes": "730a35ae3d558080083c3103d9ac8100c3f6561678092abe341701dfa331eb1d", + "EXAMPLE-PROVENANCE.json": "9bfc1559a0d35a1067ac1dd8d5b39dc28259da0298a6512f5907f7651bdb5f53", + "INDEPENDENT-AUDIT-V1.json": "bfa8d9a0e5ac3ff4548f989e33295abbc8725c848996aa233f39bcc3888d0fde", + "INDEPENDENT-EDGE-AUDIT-V1.json": "c2851c7333eca9ccf061c2ddb830a256cc75f7b03896e9681bcb4266e9737717", + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.md": "402c0096e090b9cae9e36b57fb2171aba7329053db998394dbad59591d40ef8c", + "PROOF.md": "dffcb2e804f3173094a02946374174583543d8777e98cee6600ce1b2f482e82c", + "public_source_binding.py": "fd6d480713478a170aafce5ad87cf20b5de09a47b0051393ecdc4ecfb6c8d330", + "README.md": "d89b77e20214f657fc989147862141e9701e4568b21f483ea4cd5fe891d746ac", + "REFERENCES.md": "edf54764b7fc360d1f04487aa7f3ca4851cbe9c13db5d2c0edf607c674dbe4ac", + "RESULT.json": "b0c15b779d09beb5d4f3679aa44ec052a279da6fb4a0e5aa7ae5616b3688a48e", + "reversible_linear.py": "f5d4b523538285a6de744e88d4d663203da0501a1fd8e5c0ec8f72f1bccc4b9b", + "source7669/data/CERTS.json": "5bca98812eb29a0c5f9239598c84e4be734f3d61a0aedb29d3e5b496bdc83cf2", + "source7669/data/K372-2-WORD.json.gz": "631babeca90e78c5caac713484fe618328b9beee8294baef6ac45ffc9a75dd3b", + "source7669/EDIT.json": "05b84f9578fddc7adc7805f20afdfe5ea679d298b2232d7f718193185f471656", + "source7669/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "source7669/native_verify.py": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38", + "source7669/PROVENANCE.md": "706c6c852e87e371ddf1828244b2f0c2b00279728818023aa911c8947d69ab83", + "source7669/replay.py": "23ab234e7262d5994f563f1118fdc4ace2a8a533cd83fa2342d833c13fe3308f", + "SOURCES.json": "0761fd793723c2df1e2ca51733251cfd597ff3e120f7e2ee8ebb8e10e8e98c08", + "TASK.json": "8d9a42c0766d2c5acd4d08252abefac30eebb06176ecd3aafbdd26af6bc7f53e", + "VENDORED.json": "3a891c1c8172544b2f4afec3baf052a788348918ec148ce2bdd46f17d6769cd3", + "VERIFY.json": "e3ac2f3f86283a6cae1e2b047c4599721d8ee9a005fbf80951426a7f832be06c", + "verify.py": "061aa83c28879390fabeaf8c600e6374f66683707b93b9373ff2ea76cfd825ac" + } +} diff --git a/research/clean-rational-clear-witness/NOTICE.md b/research/clean-rational-clear-witness/NOTICE.md new file mode 100644 index 0000000000..d8d0fb40c2 --- /dev/null +++ b/research/clean-rational-clear-witness/NOTICE.md @@ -0,0 +1,9 @@ +# Attribution and scope + +New implementation and tests prepared for SYLforge with substantial OpenAI Codex assistance, including separate agent review. New work is Apache-2.0. No independent human or proof-kernel review is claimed. + +The rational composition, ideal CLEAR certificates and reconstruction in source7669 are SYLforge PR7669 and their retained predecessor lineage. source7669/PROVENANCE.md and LICENSE are copied unchanged. The native_verify.py interpreter is reused unchanged from the published signed-caller source at 07a76c5e2738882c0cb322278e56f6cae3c9885d and retains its attribution header; exact URL and SHA256 are in VENDORED.json. No source interpreter or original formal CLEAR theorem is claimed as new. + +Ali Romman's PR7671/7672 rounding and native-error analyses and PR7680 temporary-grid distinction are context, not theorems supplied here. Classical Boolean arithmetic and reversible compute/copy/uncompute are standard methods. Related local gate work includes Nick Petalas PR3081 (guarded dyadic ADD) and zxv PR6092 (signed-half gate/tape kernel); their different interfaces and physical costs are not replayed or superseded here. + +Only a standalone rational-witness validity/cleanup primitive and one public source-row binding are proposed. No kappa, 16-call numerical state,new construction,selected frontier change or physical supplier admission. diff --git a/research/clean-rational-clear-witness/PROOF.md b/research/clean-rational-clear-witness/PROOF.md new file mode 100644 index 0000000000..817a71fb3a --- /dev/null +++ b/research/clean-rational-clear-witness/PROOF.md @@ -0,0 +1,31 @@ +# Proof of the clean rational-witness contract + +Let each source be a signed w-bit integer and let N=sum a_i*x_i, D>0. Define B=sum|a_i|*2^(w-1), O=D*ceil(B/D), and n=max(w,bit_length(2B+D)+1). + +## Exact numerator and division +For every source bitstring, |N|<=B, so 0<=N+O<=2B+D-1<2^n. Sign extension and modular n-bit addition/multiplication/subtraction therefore compute the exact nonnegative N+O. Negative coefficients use subtraction of the magnitude term. + +The unsigned division loop maintains a remainder r in [0,D). Reading the next numerator bit b gives 2r+b<2D. Subtract D exactly when that value is at least D; the resulting remainder is again in [0,D). Induction gives quotient floor((N+O)/D) and remainder N mod D. Subtracting the integer O/D yields q=floor(N/D). The bound on n ensures the signed q fits in n bits. + +## Validity and exact acceptance +The diagnostic is the OR of (i) nonzero remainder bits and (ii) upper q bits that disagree with the sign bit of its lowest w bits. Thus it is zero exactly when D divides N and q is a signed w-bit integer. + +The target output is its input bitstring XOR the lowest w quotient bits. For signed w-bit target t, target output AND diagnostic both zero (meaning each output is zero) iff N=D*t. Fractional results whose floor matches t and out-of-range quotients that wrap to t cannot be accepted. A target mismatch remains a bitwise mismatch, not an arithmetic residual. + +## Reversible realization and scratch cleanup +Each Boolean intermediate is written into a new zero bit through X, CNOT and Toffoli gates. Their controls and targets are distinct for Toffoli; duplicated AND controls use CNOT. Every gate is an involution. After computing the quotient and diagnostic, copy them by CNOT into the separate target and initially-zero diagnostic output. Reverse every internal gate in reverse order. Sources are unchanged and all internal ancillas return to zero for every input, independently of validity. Output wires are not uncomputed or discarded. + +This gives a total reversible transformation. On the exact-relation domain its target/diagnostic outputs are zero and can be considered clean in this gate model. On any other domain the nonzero mismatch or diagnostic must be retained. The implementation does not authorize physical retirement of unknown outputs. + +## Applying to chart-aware witnesses +A fixed rational Gaussian chart map becomes a rational matrix on real and imaginary limbs. Every output row can be written as sum a_i*x_i/D using a common positive denominator, so the construction applies row by row. Donor sources must be live, immutable during reconstruction and different from the target. A complete call additionally requires the actual physical chart convention, all rows, permitted input domain, scratch allocation and cost schedule. This package supplies neither the whole project matrix nor a physical tape compiler. + +An ideal row identity R_t L_t=0 alone is insufficient after rounding: for actual state L_t*z+e_t the residual is R_t*e_t. Exact-prefix invariants or an error-kernel proof are still necessary to claim every project CLEAR is clean. Fresh helper payload is not zero-initialized scratch. + +## Cost statement +Gate counts in RESULT.json are exact counts for the generated X/CNOT/Toffoli network. They are not project tape actions, optimized physical bounds, or evidence of a kappa reduction. The baseline retains intermediate Boolean bits until inverse execution; arithmetic word width is not total scratch space. + +The compute-copy-uncompute method and Boolean arithmetic are standard constructions; no novelty of those general principles is claimed. + +## Version 2 public example binding +The portable verifier now reconstructs the published #7669 word and evaluates all 512 complex basis columns of its chart 359-to353 map for selected real output0 at event 88937. It reuses the unchanged published native interpreter, so this is source-bound replay of that coordinate, not an independent native implementation or complete project replay. The generic iff theorem is unchanged. The extreme-width tests are implementation regressions, not an exhaustive enumeration of1076-bit inputs. diff --git a/research/clean-rational-clear-witness/README.md b/research/clean-rational-clear-witness/README.md new file mode 100644 index 0000000000..91cedb80cb --- /dev/null +++ b/research/clean-rational-clear-witness/README.md @@ -0,0 +1,75 @@ +# Clean rational CLEAR witnesses: exact validity flags and reversible cleanup + +This no-kappa contribution implements a finite-width rational-witness circuit. Its useful boundary is precise: the target output and diagnostic bit are both zero **if and only if the exact signed integer witness relation holds**. Invalid fraction, overflow or target mismatch is retained rather than mistaken for erasable zero. Internal work bits are uncomputed for every input. + +## Why a target-zero check alone is insufficient + +| Input | Naive low-bit floor check | Required behavior | +|---|---|---| +| N=1, D=2, t=0 | floor(1/2)=0, apparently clean | Fraction flag=1 | +| signed width 3, N=6, D=1, t=-2 | 6 mod8 equals encoded -2, apparently clean | Overflow flag=1 | +| N=2, D=1, t=3 | Different target/witness | Nonzero target mismatch | + +These are counterexamples to an incomplete **local erasure criterion**, not reachable-input counterexamples against the project or any contributor. The included negative controls exercise all three cases. + +## Exact result +For immutable signed w-bit donor limbs x_i, fixed integer a_i, D>0 and signed target t, put N=sum(a_i*x_i), q=floor(N/D). The generated X/CNOT/Toffoli network returns: + +1. unchanged donor bits; +2. target XOR (q modulo 2^w); +3. a diagnostic for nonzero N mod D or q outside signed w-bit range; +4. every internal ancilla restored to zero. + +Hence target_output=0 AND diagnostic=0 iff N=D*t. PROOF.md gives the bound and division-loop invariants and explains compute/copy/uncompute. This is an all-bitstring proof for this local circuit, not an assertion that every rounded caller state lies in its zero-output domain. Standard Boolean arithmetic and compute-copy-uncompute are prior methods, not new inventions here. + +## A reproducible public-project coordinate +The package reconstructs the published #7669 word from its unchanged predecessor and edit, pinned to eaef5d1580e5761feaed09262b964871f3e5f553. At zero-based event 88937, CLEAR target 1502 is in chart 353; its certificate is donor 1072 minus donor 500, both live in chart 359. + +Using the unchanged published exact native interpreter, all 512 complex source basis columns determine the real output at address 0. That row is + + (u_Re0 + u_Re102 + u_Im0 + u_Im102 + - v_Re0 - v_Re102 - v_Im0 - v_Im102) / 2, + +where u=field 1072 and v=field 500. This gives the concrete integer coefficients [1,1,1,1,-1,-1,-1,-1], D=2 used by the full-width circuit. A wrong global phase is rejected. + +This is one selected output row. The original interpreter and reconstruction routine are reused explicitly, not presented as independent implementations. No full native application or original complete scientific suite is rerun. + +## Reproduce +Python 3.10+ standard library, no network or external checkout: + + python -I -B verify.py + +Expected marker: PASS_CLEAN_REVERSIBLE_WITNESS. RESULT.json and EXAMPLE-PROVENANCE.json are regenerated. -O is explicitly rejected because these tests use assertions. This differs from packages supporting optimized replay; we do not claim -O support. VENDORED.json authenticates retained source bytes; MANIFEST.json covers the final package. Hashes are provenance receipts, not eligibility rules for other candidates. + +Evidence includes 308 baseline cases, 100 additional random contracts, three false-clean/mismatch controls, 100 arbitrary-initial-state inverse roundtrips, and complete 1076-bit circuit runs at signed maximum, signed minimum, fractional and overflow inputs. The first two edge runs are clean; the latter two preserve diagnostic 1 even when target bits become 0. An earlier independent agent audit additionally exercised 1686 source/target pairs and 100 inverse roundtrips; its unchanged receipts are clearly marked version 1. No human or formal-kernel review is claimed. + +## Space and gate count for the displayed row + +| Source width | Arithmetic width | Input bits | Internal ancillas | Complete gate count | +|---:|---:|---:|---:|---:| +|4|9|32|765|2425| +|1076|1081|8608|86525|277929| +|1108|1113|8864|89085|286153| + +Counts are generated from actual gate lists and include output copying plus inverse execution. Internal ancillas exclude immutable inputs and target/diagnostic output wires.1076-bit edge cases execute the actual network; widths 4 and 1108 in this table are generated resource counts. Arithmetic width alone is not total workspace. These are X/CNOT/Toffoli counts, not tape actions, an optimized implementation claim or a physical cost bound for all CLEARs. + +## Credit, overlap and limits +The published composition, certificates and native/caller/helper lineage are prior project work, including SYLforge's #7669. Unchanged PROVENANCE.md and LICENSE accompany the reused source; native_verify.py retains its own attribution. Ali Romman's #7671 sharpened the distinction between rational identity and a specified rounded execution. #7680 distinguishes completed-state precision from temporary product precision. Those observations motivate precise contracts here; their proofs and results are not claimed as ours. REFERENCES.md records pinned comparisons and how they shaped this document. Prepared with OpenAI Codex assistance. + +This contribution adds the runnable local clean-witness implementation, explicit false-clean controls and resource accounting. It does NOT replace existing ideal CLEAR checks or impose a new mandatory verifier. No kappa change, selected frontier update, supplier admission, source-program error or unchanged-cost claim follows. + +Open closure steps: prove which rounded states satisfy the relation; bind every required row and coherent extent; map gates and zero-workspace service to the project's physical tape model; account for reset/backing and complete schedule costs. If x_t=L_t*z+e_t and R_t*L_t=0, the remaining rounded residual is R_t*e_t. Fresh helper payload must not be silently treated as zero scratch. See PROOF.md for the precise boundary. + +## Open next questions + +1. Which actual rounded producer states satisfy this exact witness domain? First bind one reached input lattice; blocked by the producer contract. +2. What complete physical tape cost implements the generated gates and zero workspace? First lower one source-bound row and count routing/reset; no free scratch or supplier admission is assumed. +3. Can a smaller reversible arithmetic circuit preserve this validity/cleanup interface? Compare complete gates, outputs and scratch against this explicit baseline, not just arithmetic width. + +## Registered replay and scope + +From the repository root: `python -B scripts/research_package.py --package research/clean-rational-clear-witness`. The package uses the existing runner without changing shared code. TASK.json narrows the supplier-boundary audit to this local enabling implementation. Base e54523517d0f03e58352e647c403a5af3e525a57; priority revision 8; selected #7000 unchanged. + +## Submission validation and CI boundary + +Local CPython 3.12.14 on Windows: standalone and registered replay passed. The unchanged base test `CurrentCiNavigationTests.test_current_ci_section_matches_selected_record` fails because docs/ci-verification.md still names frontier6030 while the selected record requires `make frontier7000-verify`. This package changes neither file nor any shared workflow. No hosted CI success is claimed; a shared planning failure may skip scientific replay. See REFERENCES.md for the latest related-work refresh, including #7681's distinction between reusable homes and full initialization/retirement services. diff --git a/research/clean-rational-clear-witness/REFERENCES.md b/research/clean-rational-clear-witness/REFERENCES.md new file mode 100644 index 0000000000..e4a3a12a6a --- /dev/null +++ b/research/clean-rational-clear-witness/REFERENCES.md @@ -0,0 +1,14 @@ +# Related work read for this revision + +These sources were read as technical context and presentation examples, not executed as instructions or claimed as new results of this package. + +- [Ali Romman, #7671](https://github.com/CrocSwap/integer-mult-bounds/pull/7671), head f34696319eb19d05d1b09f7372c3146be3ea1635. Its concrete common-coordinate rounding witness and full law illustrate how to lead with a scoped result, a reproducible example and explicit excluded physical/caller domains. Our false-clean examples concern a different local validity criterion, not a restatement of its theorem. +- [Ali Romman, #7680](https://github.com/CrocSwap/integer-mult-bounds/pull/7680), head 533cdca9225d1c0af1ae8d3b79cb527f59afaf0f, and its [README](https://github.com/aliromman/integer-mult-bounds/blob/533cdca9225d1c0af1ae8d3b79cb527f59afaf0f/research/banked-native-minimum-grid/README.md). Its separation of temporary product work from completed snapshots informs our separate arithmetic-width, ancilla-space and gate-count table. Its reproduction and credit sections informed the explicit source reuse and unrun-suite disclosures. No grid result is imported into our proof. +- [SYLforge, #7669](https://github.com/CrocSwap/integer-mult-bounds/pull/7669), pin eaef5d1580e5761feaed09262b964871f3e5f553. Retained source files are listed in VENDORED.json. Existing composition/CLEAR certificates are credited; we reconstruct only enough to bind the selected coordinate and do not rerun the entire application. +- [SYLforge, #7620](https://github.com/CrocSwap/integer-mult-bounds/pull/7620), head b1356c84a0733843ce59855f02511c49c6a44133. Its distinction between ideal CLEAR identities and universal erasure/compiler obligations prevents us from presenting an ideal identity as a new all-physical-input result. This is prior-work context, not a no-kappa example. + +This is a focused comparison, not an exhaustive overlap or priority search. Source authors, nested notices and credit remain with the original work. See source7669/PROVENANCE.md and source7669/LICENSE. The separately retained native interpreter comes from its exact published URL in VENDORED.json and preserves its original header. + +## Submission refresh + +Canonical main remains e54523517d0f03e58352e647c403a5af3e525a57. Ali Romman's [#7681](https://github.com/CrocSwap/integer-mult-bounds/pull/7681), head 1753a3ff56be34b09a217b12b590f51eba15defb, gives a fixed-order snapshot-bank allocation for the #7674 graph while retaining all logical initialization/retirement services. Our local zero-ancilla circuit does not supply that full reset service or replace its allocation result. [#7682](https://github.com/CrocSwap/integer-mult-bounds/pull/7682) changes a banked construction; [#7685](https://github.com/CrocSwap/integer-mult-bounds/pull/7685) concerns conditional Lean ceilings. Neither is incorporated here. Recent scoped PR searches found no matching rational-witness gate/invalid-flag package; historical or unpublished overlap remains a coverage limit. diff --git a/research/clean-rational-clear-witness/RESULT.json b/research/clean-rational-clear-witness/RESULT.json new file mode 100644 index 0000000000..86860e4d10 --- /dev/null +++ b/research/clean-rational-clear-witness/RESULT.json @@ -0,0 +1,223 @@ +{ + "cases": 308, + "all_signed_inputs_exhaustive_for_first_four_contracts": true, + "last_contract_deterministic_random_cases": 100, + "all_sources_preserved_all_ancillas_zero": true, + "nonzero_target_mismatch_preserved": true, + "invalid_fraction_or_signed_overflow_flag_exact": true, + "adversarial_controls": [ + { + "coefficients": [ + 1 + ], + "D": 2, + "width": 3, + "input": [ + 1 + ], + "target": 0, + "target_output": 0, + "invalid_output": 1, + "illegal_erasure_blocked": true + }, + { + "coefficients": [ + 2 + ], + "D": 1, + "width": 3, + "input": [ + 3 + ], + "target": -2, + "target_output": 0, + "invalid_output": 1, + "illegal_erasure_blocked": true + }, + { + "coefficients": [ + 1, + -1 + ], + "D": 1, + "width": 4, + "input": [ + 3, + 1 + ], + "target": 3, + "target_output": 1, + "invalid_output": 0, + "illegal_erasure_blocked": true + } + ], + "additional_random_contracts_all_zero_iff_exact_integer_relation": 100, + "script_sha256": "f5d4b523538285a6de744e88d4d663203da0501a1fd8e5c0ec8f72f1bccc4b9b", + "fullwidth_network": { + "width": 1076, + "stats": { + "numerator_abs_bound": 3238436052916969893639925547502676912792906396226273893710421728438885433087925550271366139222993991922993245829068990582236939798172695629872214399051816158744278788425061781831470523873491461459836282855563921096992119734795083177889653690386552901452960904197740312837334633843688040514981240138336100212923323857495916544, + "offset": 3238436052916969893639925547502676912792906396226273893710421728438885433087925550271366139222993991922993245829068990582236939798172695629872214399051816158744278788425061781831470523873491461459836282855563921096992119734795083177889653690386552901452960904197740312837334633843688040514981240138336100212923323857495916544, + "arithmetic_bits": 1081, + "input_bits": 8608, + "ancilla_bits": 86525, + "forward_gates": { + "X": 9737, + "CX": 99494, + "CCX": 29195 + }, + "clean_CLEAR_gates": 277929, + "output_bits": 1076 + }, + "executed": true + }, + "fullwidth_edges": [ + { + "case": "positive_max_exact", + "inputs": [ + "404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989567", + "404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989567", + "0", + "0", + "0", + "0", + "0", + "0" + ], + "target": "404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989567", + "target_output": 0, + "invalid_output": 0 + }, + { + "case": "negative_min_exact", + "inputs": [ + "-404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989568", + "-404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989568", + "0", + "0", + "0", + "0", + "0", + "0" + ], + "target": "-404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989568", + "target_output": 0, + "invalid_output": 0 + }, + { + "case": "fraction", + "inputs": [ + "1", + "0", + "0", + "0", + "0", + "0", + "0", + "0" + ], + "target": "0", + "target_output": 0, + "invalid_output": 1 + }, + { + "case": "positive_overflow", + "inputs": [ + "404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989567", + "404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989567", + "2", + "0", + "0", + "0", + "0", + "0" + ], + "target": "-404804506614621236704990693437834614099113299528284236713802716054860679135990693783920767402874248990374155728633623822779617474771586953734026799881477019843034848553132722728933815484186432682479535356945490137124014966849385397236206711298319112681620113024717539104666829230461005064372655017292012526615415482186989568", + "target_output": 0, + "invalid_output": 1 + } + ], + "arbitrary_initial_state_gate_inverse_roundtrips": 100, + "example_cost_table": [ + { + "width": 4, + "numerator_abs_bound": 64, + "offset": 64, + "arithmetic_bits": 9, + "input_bits": 32, + "ancilla_bits": 765, + "forward_gates": { + "X": 89, + "CX": 870, + "CCX": 251 + }, + "clean_CLEAR_gates": 2425, + "output_bits": 4 + }, + { + "width": 1076, + "numerator_abs_bound": 3238436052916969893639925547502676912792906396226273893710421728438885433087925550271366139222993991922993245829068990582236939798172695629872214399051816158744278788425061781831470523873491461459836282855563921096992119734795083177889653690386552901452960904197740312837334633843688040514981240138336100212923323857495916544, + "offset": 3238436052916969893639925547502676912792906396226273893710421728438885433087925550271366139222993991922993245829068990582236939798172695629872214399051816158744278788425061781831470523873491461459836282855563921096992119734795083177889653690386552901452960904197740312837334633843688040514981240138336100212923323857495916544, + "arithmetic_bits": 1081, + "input_bits": 8608, + "ancilla_bits": 86525, + "forward_gates": { + "X": 9737, + "CX": 99494, + "CCX": 29195 + }, + "clean_CLEAR_gates": 277929, + "output_bits": 1076 + }, + { + "width": 1108, + "numerator_abs_bound": 13908976937465711096600078626398891812899776992581064189424841418012806069803436530898321493204542046513744141264739720678439654956272568290463281503027843811211021823392143699745652883624633068305241252378852532749105598230661075510635812896975954309914377965895883760737161220166774910038167424447676066270684312523561526010025345024, + "offset": 13908976937465711096600078626398891812899776992581064189424841418012806069803436530898321493204542046513744141264739720678439654956272568290463281503027843811211021823392143699745652883624633068305241252378852532749105598230661075510635812896975954309914377965895883760737161220166774910038167424447676066270684312523561526010025345024, + "arithmetic_bits": 1113, + "input_bits": 8864, + "ancilla_bits": 89085, + "forward_gates": { + "X": 10025, + "CX": 102438, + "CCX": 30059 + }, + "clean_CLEAR_gates": 286153, + "output_bits": 1108 + } + ], + "public_source_binding": { + "candidate_canonical_sha256": "ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d", + "event_zero_based": 88937, + "target": 1502, + "target_chart": 353, + "donors": { + "1072": { + "coefficient": 1, + "chart": 359 + }, + "500": { + "coefficient": -1, + "chart": 359 + } + }, + "output_limb": [ + "real", + 0 + ], + "source_columns_checked": 512, + "realified_source_columns": 1024, + "integer_coefficients": [ + 1, + 1, + 1, + 1, + -1, + -1, + -1, + -1 + ], + "denominator": 2, + "phase_negative_control": true, + "scope": "One real output row; exact published native interpreter reused. No rounded-input reachability, complete CLEAR or physical compiler claim." + } +} diff --git a/research/clean-rational-clear-witness/SOURCES.json b/research/clean-rational-clear-witness/SOURCES.json new file mode 100644 index 0000000000..5335fa97d9 --- /dev/null +++ b/research/clean-rational-clear-witness/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + } + ] +} diff --git a/research/clean-rational-clear-witness/TASK.json b/research/clean-rational-clear-witness/TASK.json new file mode 100644 index 0000000000..18f4e7436f --- /dev/null +++ b/research/clean-rational-clear-witness/TASK.json @@ -0,0 +1,97 @@ +{ + "schema_version": 1, + "task_id": "supplier-boundary-audit", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "supplier-boundary-audit", + "question": "Does one changed supplier have complete source-bound native, caller, ordinary and outer admission coverage?", + "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" + ], + "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": "Pin the current sources and one obligation; the historical owner audit is an example, not evidence of a current bug.", + "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": "Choose one latest uncovered candidate and build a delta coverage map against the selected review. For P104, #5717 changes owned-lifetime assumptions and #5719 covers exact #5713 causal premises; neither automatically transfers to #5718. For BIT, #5679/#5708 need component admission and compatible outer use. Check controls and exact source identity before reuse; stop with one resolved gap or explicit remaining obligation. A heavy full replay requires a separate serial resource budget.", + "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": [ + "supplier admission", + "5717", + "5719", + "5708", + "owned lifetime" + ], + "existing_checks": [ + { + "scope": "PR #4088: author-checked local words, native receipts, owner/phase fill and exact moment.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Rebind and validate ordinary/outer admission with all four providers; full mixed release not established.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #3801: successor scatter-boundary decision package.", + "evidence": "research/scatter-boundary-decision/README.md", + "remaining": "Consult its exact acceptance scope before any new exporter audit; not proof of a selected failure.", + "status": "author-checked", + "source_commit": "911f8800ba7a4b03603ef62c5ffc6240e53cb5fd", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "refined", + "actual_scope": "One local finite-width reversible rational CLEAR witness with exact fraction/overflow flags, clean internal workspace, and public PR7669 coordinate binding; no kappa or full supplier admission.", + "scope_change_reason": "User explicitly selected the previously reviewed standalone no-kappa contribution, not the broader caller or supplier effort.", + "bottleneck_link": "Separates exact integer witness validity and actual reversible scratch cleanup from ideal row identities; physical tape and reachable-state admission remain separate.", + "budget_minutes": 60, + "stop_rule": "Publish only the tested standalone primitive and pinned public example; do not add unpublished caller or candidate results.", + "outcome": "completed", + "evidence": "PROOF.md; RESULT.json; EXAMPLE-PROVENANCE.json; independent version1 audit receipts.", + "author": "SYLforge, with substantial OpenAI Codex assistance", + "ai_assistance": "Substantial OpenAI Codex assistance for implementation, proof, source binding, independent agent audit and packaging; no human/formal-kernel review.", + "open_questions": [ + { + "question": "Which reached rounded states satisfy the exact CLEAR relation?", + "why_it_matters": "A clean local circuit cannot certify caller input admission.", + "first_step": "Bind one actual producer lattice and full error state.", + "blocked_by": "Producer precision and reachability contract." + }, + { + "question": "What is the complete physical tape and workspace cost?", + "why_it_matters": "Boolean gates and arithmetic width are not tape tariff.", + "first_step": "Lower one row with all routing,backing,initialization and retirement charged.", + "blocked_by": "Physical gate/workspace supplier." + } + ] +} diff --git a/research/clean-rational-clear-witness/VENDORED.json b/research/clean-rational-clear-witness/VENDORED.json new file mode 100644 index 0000000000..14b3ba4e3f --- /dev/null +++ b/research/clean-rational-clear-witness/VENDORED.json @@ -0,0 +1,46 @@ +{ + "files": [ + { + "path": "source7669/data/K372-2-WORD.json.gz", + "git_blob": "1273c83178693e1627a2324680907f9b0e95e995", + "sha256": "631babeca90e78c5caac713484fe618328b9beee8294baef6ac45ffc9a75dd3b", + "url": "https://github.com/SYLforge/integer-mult-bounds/blob/eaef5d1580e5761feaed09262b964871f3e5f553/research/ee251f60-composition/data/K372-2-WORD.json.gz" + }, + { + "path": "source7669/EDIT.json", + "git_blob": "23368c8750e6d981ee10664187c6a2c3859be542", + "sha256": "05b84f9578fddc7adc7805f20afdfe5ea679d298b2232d7f718193185f471656", + "url": "https://github.com/SYLforge/integer-mult-bounds/blob/eaef5d1580e5761feaed09262b964871f3e5f553/research/ee251f60-composition/EDIT.json" + }, + { + "path": "source7669/data/CERTS.json", + "git_blob": "d6a595fda94f2e141d70f014443d68398013e8e0", + "sha256": "5bca98812eb29a0c5f9239598c84e4be734f3d61a0aedb29d3e5b496bdc83cf2", + "url": "https://github.com/SYLforge/integer-mult-bounds/blob/eaef5d1580e5761feaed09262b964871f3e5f553/research/ee251f60-composition/data/CERTS.json" + }, + { + "path": "source7669/replay.py", + "git_blob": "9c390e5fc8f468fd9fb967368c0a60aa7493fb27", + "sha256": "23ab234e7262d5994f563f1118fdc4ace2a8a533cd83fa2342d833c13fe3308f", + "url": "https://github.com/SYLforge/integer-mult-bounds/blob/eaef5d1580e5761feaed09262b964871f3e5f553/research/ee251f60-composition/replay.py" + }, + { + "path": "source7669/LICENSE", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "url": "https://github.com/SYLforge/integer-mult-bounds/blob/eaef5d1580e5761feaed09262b964871f3e5f553/research/ee251f60-composition/LICENSE" + }, + { + "path": "source7669/PROVENANCE.md", + "git_blob": "bbee2437f012c3268eb5cd920adfa37394c1de72", + "sha256": "706c6c852e87e371ddf1828244b2f0c2b00279728818023aa911c8947d69ab83", + "url": "https://github.com/SYLforge/integer-mult-bounds/blob/eaef5d1580e5761feaed09262b964871f3e5f553/research/ee251f60-composition/PROVENANCE.md" + }, + { + "path": "source7669/native_verify.py", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38", + "url": "https://github.com/CrocSwap/integer-mult-bounds/blob/07a76c5e2738882c0cb322278e56f6cae3c9885d/research/signed-caller-8x9/replay/supplier7112/short-caller/admission-source/frozen/native_verify.py" + } + ], + "scope": "Unchanged source bytes. Reuse is explicit; this is not an independent native interpreter or original project full replay." +} diff --git a/research/clean-rational-clear-witness/VERIFY.json b/research/clean-rational-clear-witness/VERIFY.json new file mode 100644 index 0000000000..257391440c --- /dev/null +++ b/research/clean-rational-clear-witness/VERIFY.json @@ -0,0 +1,19 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact signed witness iff contract, fraction/overflow/mismatch controls, reversible scratch cleanup, fullwidth edge networks, source reconstruction and one public chart row." + } + ] +} diff --git a/research/clean-rational-clear-witness/public_source_binding.py b/research/clean-rational-clear-witness/public_source_binding.py new file mode 100644 index 0000000000..11961f6fa2 --- /dev/null +++ b/research/clean-rational-clear-witness/public_source_binding.py @@ -0,0 +1,36 @@ +"""Bind one real CLEAR output coordinate to a public pinned WORD and native map.""" +import hashlib,importlib.util,json +from pathlib import Path +from fractions import Fraction as Q + +def module(path,name): + spec=importlib.util.spec_from_file_location(name,path);m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);return m + +def verify(): + root=Path(__file__).parent + pins=json.loads((root/'VENDORED.json').read_text()) + for r in pins['files']: + if hashlib.sha256((root/r['path']).read_bytes()).hexdigest()!=r['sha256']:raise ValueError('source integrity mismatch') + src=root/'source7669';m=module(src/'replay.py','public_replay');v=module(src/'native_verify.py','public_native') + word=m.reconstruct(m.read(src/'data/K372-2-WORD.json.gz'),m.read(src/'EDIT.json')) + cert=m.read(src/'data/CERTS.json');assert m.digest(word)=='ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d' + event=88937;assert word['program'][event]==['CLEAR',1502,353] + charts=dict(enumerate(word['initial'])) + for e in word['program'][:event]: + if e[0]=='INIT':assert e[1] not in charts;charts[e[1]]=e[2] + elif e[0]=='MOVE':assert charts[e[1]]==e[2];charts[e[1]]=e[3] + elif e[0]=='CLEAR':del charts[e[1]] + assert cert['clear_event_index'][str(event)]=={'1072':'1','500':'-1'} + assert charts[1072]==charts[500]==359 and charts[1502]==353 + route=v.adjoint(v.frame(tuple(word['frames'][359]),9))+v.frame(tuple(word['frames'][353]),9) + row=[] + # Each complex column determines both its real and imaginary input columns. + for basis in range(512): + col,power=v.state(route,basis);re,im=col.get(0,(0,0)) + for limb,n in [(0,re),(1,-im)]: + if n:row.append((limb,basis,Q(n,1<>i)&1) for i in range(n)] + def add(self,a,b,carry=None): + carry=self.const(0) if carry is None else carry; out=[] + for x,y in zip(a,b): + t=self.xor(x,y); out.append(self.xor(t,carry)) + carry=self.xor(self.land(x,y),self.land(t,carry)) + return out,carry + def subtract(self,a,b): return self.add(a,[self.inv(v) for v in b],self.const(1)) + def multiply_constant(self,a,k): + n=len(a) + if k==1: return a + if k<0: + positive=self.multiply_constant(a,-k) + return self.add([self.inv(v) for v in positive],self.vector(0,n),self.const(1))[0] + out=self.vector(0,n) + for shift in range(min(n,k.bit_length())): + if k>>shift&1: + out,_=self.add(out,self.vector(0,shift)+a[:n-shift]) + return out + def divide_unsigned(self,a,d): + # remainder < d at each iteration; temporary doubled remainder <2*d. + width=d.bit_length()+1; rem=self.vector(0,width); divisor=self.vector(d,width); q=[None]*len(a) + for i in range(len(a)-1,-1,-1): + rem=[a[i]]+rem[:-1] + delta,ge=self.subtract(rem,divisor) + rem=[self.choose(ge,x,y) for x,y in zip(delta,rem)] + q[i]=ge + return q,rem + +def compile_linear(coefficients,denominator,width): + if type(denominator) is not int or denominator <= 0 or type(width) is not int or width <= 0: + raise ValueError("positive integer denominator and width required") + if not isinstance(coefficients,(list,tuple)) or any(type(a) is not int for a in coefficients): + raise ValueError("integer coefficient list required") + count=len(coefficients); c=Circuit(count*width) + # Covers ALL signed width-bit input strings, not sampled trajectories. + bound=sum(abs(a) for a in coefficients)*(1<<(width-1)) + offset=((bound+denominator-1)//denominator)*denominator + n=max(width,(2*bound+denominator).bit_length()+1) + accum=c.vector(offset,n) + for j,k in enumerate(coefficients): + bits=list(range(j*width,(j+1)*width)); extended=bits+[bits[-1]]*(n-width) + term=c.multiply_constant(extended,abs(k)) + accum,_=c.subtract(accum,term) if k<0 else c.add(accum,term) + quotient,remainder=c.divide_unsigned(accum,denominator) + result,_=c.subtract(quotient,c.vector(offset//denominator,n)) + invalid=c.const(0) + for bit in remainder+[c.xor(bit,result[width-1]) for bit in result[width:]]: + invalid=c.xor(c.xor(invalid,bit),c.land(invalid,bit)) + c.invalid=invalid + return c,result[:width],{'numerator_abs_bound':bound,'offset':offset,'arithmetic_bits':n,'input_bits':count*width,'ancilla_bits':c.next-c.inputs,'forward_gates':dict(Counter(g[0] for g in c.gates)),'clean_CLEAR_gates':2*len(c.gates)+width+1,'output_bits':width} + +def apply(state,gates): + for gate in gates: + if gate[0]=='X': state[gate[1]]^=1 + elif gate[0]=='CX': state[gate[2]]^=state[gate[1]] + elif gate[0]=='CCX': state[gate[3]]^=state[gate[1]]&state[gate[2]] + else: raise ValueError('unknown gate') + +def clear(c,out,inputs,target,width): + bits=[(x>>i)&1 for x in inputs for i in range(width)] + state=bits+[0]*(c.next-c.inputs)+[(target>>i)&1 for i in range(width)]+[0] + apply(state,c.gates) + reconstructed=sum(state[b]< editorially normalized SHA-256): + +- `evidence/BUILD.json`: `4744201691120223ded62a3e0d55ea1029203f3ea996305163e7db8d9e3679a4` -> `a0bafbb3f44920ed6ac1ed3d83385f025f5bbbcf5e9c8013ab1ca55ccf23c32d`. + +- `evidence/NATIVE-EVIDENCE-REUSE.json`: `6615b8a051ac9e4d8c73b5decf8a70d2a33d14da0c4c369574dec946984aa351` -> `84bab14d5c584aa8853b8e1025b562541ac6657e458d120ec803f2bc149c3eb8`. + +- `evidence/ROLE770-BUILD.json`: `c4ee72317678791d4b801479df0af052f3a50662c11ce3f3393b2151368fc92d` -> `1c400f16efbc427c40c811a57dc656fe97c2c84f94c71529e2c5c0598b146369`. + +- `evidence/PRICE-SUMMARY.json`: `c2777382c677634f7017b68c55dbd831a40945b77057f26b738f857c17ee8759` -> `d13741fe3217a01edd0b79b40dad037e644e441fbbc300838df99c0b050a5f42`. diff --git a/research/clean-rational-clear-witness/source7669/data/CERTS.json b/research/clean-rational-clear-witness/source7669/data/CERTS.json new file mode 100644 index 0000000000..d6a595fda9 --- /dev/null +++ b/research/clean-rational-clear-witness/source7669/data/CERTS.json @@ -0,0 +1 @@ +{"actual_live_row_certificates_verified":true,"candidate_canonical_sha256":"ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d","certificate_rule":"Exact equality to other live public/owned rows; cross-chart sources allowed","clear_event_index":{"100003":{"501":"1"},"100006":{"295":"1"},"100045":{"547":"-1/2"},"100095":{"474":"1"},"100132":{"577":"-1/2"},"100144":{"1463":"1/2"},"100305":{"511":"1"},"100317":{"1405":"1","354":"-1/2"},"100655":{"498":"-3/2","540":"2"},"100693":{"344":"2","512":"-3/2"},"100710":{"28":"2","513":"-3/2"},"100720":{"1435":"1","366":"1"},"100795":{"274":"1","457":"1"},"100830":{"510":"-3/2","528":"2"},"100846":{"151":"-2","501":"-1","528":"-4","60":"-2","623":"-1","625":"-1/2","626":"1","628":"2","629":"2","630":"2","768":"1/2"},"100868":{"917":"-1"},"100876":{"1016":"-1","1018":"-1","1031":"-1","1033":"-1","1043":"-1/2","1047":"-1/2","1049":"-1/2","1205":"-2","1206":"2","1232":"-1","1238":"1/2","129":"-1/2","1291":"-1","1302":"-1","1303":"-1/2","1322":"-1","1323":"-1","1324":"1/2","1325":"1/2","1394":"1/2","1427":"-1","150":"-1/2","28":"-1","296":"-1","344":"-1","402":"-2","407":"-2","418":"-2","423":"-2","484":"-2","485":"2","540":"-1","568":"2","569":"2","570":"-1/2","575":"2","576":"3/2","651":"-1","661":"-1","662":"-1","707":"-1/2","732":"-1/2","810":"-1/2","882":"-1","883":"-1","888":"-1","889":"1","894":"-1","895":"-1","897":"-1","898":"-1","907":"1","908":"1","910":"-1","918":"-1","919":"-1","920":"-1","921":"-1","928":"-1","930":"-1","932":"-1","933":"-1","934":"-1","935":"1","950":"-1","952":"-1","953":"1","954":"-1","957":"1","958":"-1","959":"-1","963":"1","968":"-1","975":"-1","976":"-1","977":"-1","979":"1","980":"-1","981":"-1","982":"-1","995":"-2"},"100985":{"580":"1"},"100989":{"428":"-3","474":"-1/2"},"101012":{"294":"-3/2","408":"2"},"101054":{"553":"1"},"101125":{"295":"-1/2","424":"-3"},"101213":{"546":"1","577":"-1"},"101221":{"547":"1","578":"-1"},"101311":{"558":"1","575":"-1"},"101318":{"558":"-1","575":"1"},"101333":{"559":"1","576":"-1"},"101340":{"559":"-1","576":"1"},"101390":{"546":"-1","577":"1"},"101463":{"516":"2"},"101479":{"523":"1","580":"2"},"101486":{"523":"1/2","580":"-2"},"101505":{"268":"-1","568":"1"},"101657":{"1410":"-1","526":"-3/2"},"101672":{"1399":"-1","527":"-3/2"},"101687":{"490":"1/2","550":"-2"},"101757":{"1434":"1/2","553":"-2"},"101779":{"430":"-2","457":"-1/4"},"101907":{"547":"-1","578":"1"},"101941":{},"101953":{"356":"2","500":"-3/2"},"101986":{"295":"-3/2","424":"2"},"102010":{"428":"2","474":"-3/2"},"102030":{"278":"-3/2","562":"2"},"102067":{"438":"-1","585":"-2"},"102088":{"106":"-5/4","1162":"4","1163":"-4","1365":"1","1373":"2","1380":"1","1385":"7/4","1392":"-1/2","1397":"-8","1448":"-1","240":"3/4","405":"-2","41":"-1","42":"1/2","728":"1","813":"2"},"102097":{"1342":"-2","1437":"2","256":"1","336":"1"},"102111":{"1342":"-2","1437":"2","256":"1","336":"1"},"102313":{"862":"-1"},"102319":{"1000":"-1/2","1206":"-3","1207":"1","1208":"-1/2","1343":"-1/4","1344":"-1/4","1346":"-1/4","1347":"-1/4","1354":"1","1393":"-1/4","1445":"1","1458":"-1/2","1460":"-2","1466":"1","1477":"1","1490":"2","226":"1","230":"1","449":"-4","473":"1","485":"1","496":"1","508":"1","521":"1","544":"1","7":"-1/2","779":"-1/2","857":"-1/2","87":"-1/2","882":"-1/2","883":"-1/2","884":"-1/2","888":"-1/2","889":"1/2","890":"-1/2","894":"-1/2","898":"-1/2","902":"-1/2","903":"-1/2","904":"-1/2","905":"-1/2","906":"-1/2","907":"-1/2","910":"-1/2","914":"-1/2","918":"-1/2","919":"-1/2","920":"-1/2","921":"-1/2","922":"-1/2","931":"-1/2","932":"-1/2","933":"-1/2","934":"-1/2","940":"-1/2","941":"-1/2","942":"-1/2","946":"-1/2","947":"-1/2","948":"-1/2","949":"-1/2","950":"-1/2","951":"-1/2","958":"-1/2","959":"-1/2","960":"-1/2","965":"-1/2","966":"-1/2","967":"-1/2","971":"-1/2","972":"-1/2","973":"-1/2","976":"-1/2","977":"-1/2","978":"-1/2","980":"-1/2","981":"-1/2","982":"-1/2","983":"-1/2","984":"-1/2","985":"-1/2","990":"1","994":"1/2"},"102346":{"742":"1/4","998":"1/2"},"102435":{"126":"1/4","15":"1/4","164":"1/4","679":"-1/4","682":"-1/4"},"102445":{"126":"-1/4","164":"1/4","413":"1/2","679":"-1/4","682":"-1/4"},"102583":{"126":"1/4","15":"1/4","164":"1/4","679":"-1/4","682":"-1/4"},"102587":{"126":"-1/4","164":"1/4","413":"1/2","679":"-1/4","682":"-1/4"},"102636":{},"102723":{"108":"-1","1492":"-2","22":"-1/2","23":"-1/2","320":"-1/2","333":"-1","49":"1"},"102817":{},"102819":{},"102820":{},"102822":{},"102823":{},"102841":{},"102858":{},"102898":{},"102902":{},"102945":{"1082":"-1","794":"-4"},"102993":{},"103157":{"1074":"1/2","1221":"1","1222":"1","1255":"1","1311":"1","1312":"1","1313":"1","1314":"1/2","1356":"1","757":"1/2","796":"1/2","890":"-1","906":"-1","942":"-1","943":"1","956":"1","964":"1","971":"-1"},"103176":{},"103239":{},"103322":{},"103323":{},"103331":{},"103338":{},"103339":{},"103349":{},"103352":{},"103363":{},"103369":{},"103372":{},"103373":{},"103377":{},"103390":{},"103391":{},"103398":{},"103412":{},"103413":{},"103429":{"1025":"-2","1029":"-5/2","831":"-1","864":"2"},"103460":{"1499":"1","998":"-1"},"103465":{},"103466":{},"103484":{"863":"1"},"103487":{},"150521":{"770":"1"},"88002":{},"88740":{"233":"1"},"88937":{"1072":"1","500":"-1"},"89286":{"1089":"1","510":"-1"},"89288":{"22":"1/4","23":"-3/4","320":"1/4","321":"-1/2","323":"-1","325":"1/2","330":"-1"},"89671":{},"90032":{"110":"-3/8","20":"1/8","37":"1/8","432":"1/2","433":"1/8","435":"1/2","437":"-1/4","442":"3/2","735":"3/8"},"90127":{"29":"-1/4","30":"-3/4","352":"-1/8","353":"1/4","355":"-1/2","357":"1/4","362":"-1/2","59":"1/4"},"90200":{},"90269":{},"90353":{"500":"1"},"90544":{"628":"-2","630":"-2"},"90546":{"30":"1/4","352":"-1/8","353":"-1/4","355":"1/2","357":"-1/4","362":"-1/2","59":"-1/2"},"90551":{"106":"-2","1165":"-1","1365":"1","1380":"-1","1385":"1","240":"1","403":"2","405":"1/4","728":"-4","729":"4","730":"4","813":"2"},"90554":{"30":"-3/4","352":"-1/8","353":"1/4","355":"1/2","357":"1/4","362":"-1/2"},"90557":{"30":"-1/4","352":"-1/8","353":"-1/4","355":"-1/2","357":"-1/4","362":"-1/2"},"90578":{"30":"-3/2","352":"-1/4","353":"1/2","355":"-1","357":"-1/2","362":"1","59":"1"},"90848":{"17":"-5/8","273":"-1/2","275":"-1","277":"1/2","282":"-1","77":"-1/2"},"90875":{},"90911":{"22":"1/8","23":"1/8","320":"1/8","321":"1/4","323":"1/2","325":"1/4","330":"-1/2"},"90968":{"1385":"-1/4","240":"-1/4"},"90979":{"385":"-1/4","387":"-1/2","389":"-1/4","394":"-1/2","64":"1/8"},"90986":{"1173":"1","573":"-1"},"90988":{"106":"-3/2","1162":"-2","1165":"-2","1365":"1/4","1380":"-1/4","1385":"-1/2","240":"-1/2","401":"1/16","403":"2","405":"7/16","41":"1/2","730":"2","813":"-1/2","814":"-2","876":"-1/2"},"91018":{"18":"1/4","288":"-1/4","289":"-1/2","291":"-1/2","298":"1","39":"1/4","40":"1/4"},"91099":{"103":"1/2","17":"-5/8","272":"-1/2","273":"-1/2","275":"-1","277":"1/2","282":"1"},"91105":{"23":"-1/4","320":"-1/4","321":"-1/2","323":"-1","325":"1/2","330":"1"},"91213":{"30":"1/4","353":"1/2","355":"-1","357":"-1/2","362":"-1"},"91223":{"385":"1/2","387":"-1","389":"-1/2","394":"-1","64":"1/4","96":"1"},"91240":{},"91260":{"385":"-1/2","387":"-1","389":"1/2","394":"-1","64":"-1/4","65":"-1/2","96":"1/2"},"91264":{"29":"-1/2","30":"-1/4","353":"-1/2","355":"-1","357":"1/2","362":"-1","59":"1/2"},"91516":{"18":"1/4","288":"1/4","289":"1/2","291":"5/2","293":"-1","298":"-1","39":"1/4","40":"1/4"},"91697":{"104":"1/2","1179":"-1","416":"-1/2","417":"1","421":"1/2","426":"2"},"91722":{"17":"-1/4","273":"1/2","275":"-1","277":"-1/2","282":"-1"},"91836":{"224":"1/8","225":"1/2","227":"-1","229":"-1/4","234":"-1/2","57":"-1/8","81":"1/8"},"91879":{"23":"1/4","320":"1/4","321":"1/2","323":"1","325":"1/2","330":"-1"},"91884":{"108":"1/2","23":"1/4","320":"-1/4","321":"1/2","323":"-1","325":"-1/2","330":"-1"},"91916":{"18":"1/4","288":"1/4","289":"-1/2","298":"-1","39":"-1/4","40":"1/4"},"91948":{"384":"-1/2","385":"-1/2","387":"-1","389":"1/2","394":"1","64":"-3/4"},"91983":{"1120":"1","358":"-1"},"91985":{"30":"-1/4","352":"-1/2","353":"-1/2","355":"-1","357":"1/2","362":"1","59":"1/2"},"91989":{"26":"1/4","368":"-3/4","369":"-1/2","371":"-1","373":"1/2","378":"1","8":"1/4"},"92043":{"18":"1/4","288":"1/4","289":"1/2","293":"-1","298":"1","39":"1/4","40":"1/4"},"92053":{"107":"-1/4","304":"-1/4","305":"1/2","307":"-1","309":"-1/2","314":"1","35":"1/4","45":"1/4"},"92091":{"17":"-1/4","273":"1/2","275":"-1","277":"-1/2","282":"1"},"92098":{"1086":"1","513":"-1"},"92100":{"108":"1/2","23":"1/4","320":"-1/4","321":"1/2","323":"-1","325":"-1/2","330":"1"},"92255":{"106":"-5/64","1154":"1/2","1162":"-1/2","1163":"-1/4","1168":"-1","1173":"1/2","1349":"1/4","1365":"1/16","1373":"1/8","1380":"1/16","1385":"-9/64","1392":"-1/32","1448":"-1/16","240":"-13/64","402":"1/4","405":"-1/8","41":"-1/16","42":"1/32","570":"-1","573":"1/2","728":"5/16","813":"1/8","875":"1/2"},"92258":{"106":"-5/4","1162":"-8","1163":"-4","1365":"1","1373":"2","1380":"1","1385":"7/4","1392":"-1/2","1448":"-1","240":"3/4","405":"-2","41":"-1","42":"1/2","728":"1","813":"2"},"92309":{"1343":"-1","1344":"-1","1346":"-1","1347":"-1"},"92399":{"26":"-1/8","368":"1/8","369":"1/4","371":"-1/2","372":"-1/2","373":"-1/4","377":"-1","378":"1/2","8":"1/8"},"93305":{"26":"-3/8","368":"1/8","369":"1/4","371":"-1/2","373":"1/4","378":"-1/2","8":"-3/8"},"93660":{},"93873":{"104":"-3/8","1179":"1/2","1185":"4","1388":"-4","1391":"-3","416":"3/8","417":"-1/4","419":"-1/2","421":"-1/8","426":"1/2","43":"-1/2","788":"4","815":"-4"},"93910":{"86":"1"},"94044":{"385":"1/4","387":"-1/2","389":"1/4","394":"-1/2","64":"-1/8","65":"-1/4","96":"3/8"},"94851":{"1402":"1","290":"1"},"94925":{"1112":"1/2","350":"1/2"},"94986":{"1470":"-1","169":"1"},"95126":{"1471":"-1","203":"1"},"95339":{"103":"1","108":"1","18":"1","45":"1","61":"1","63":"1"},"95373":{"1206":"1/3","1455":"-2/3","1460":"2/3","449":"4/3"},"95406":{"368":"1/4","721":"-1","723":"-1","724":"-1","725":"-1","9":"1/4"},"95424":{"368":"1/4","9":"1/4"},"95463":{"368":"1","9":"1"},"95501":{"1144":"4","1390":"-2","26":"5/2","368":"3/8","369":"-1/4","371":"1/2","373":"-1/4","378":"-1/2","381":"2","723":"2","725":"-2","8":"1/8","865":"8","95":"1/4"},"95504":{"1138":"4","1390":"-2","26":"5/2","368":"3/8","369":"-1/4","371":"-1/2","373":"-1/4","378":"-1/2","381":"2","723":"2","724":"-2","8":"1/8","865":"8","95":"1/4"},"95703":{},"95936":{"256":"1/4","336":"1/4"},"95971":{"1020":"2/3","1023":"-4/3","1025":"-2/3","1029":"-1/3","831":"1/3"},"96173":{"1098":"1","337":"-1/4","341":"1/4","346":"-1/2","58":"-1/8","712":"-7/4","714":"1/4","93":"-1/4"},"96198":{"1207":"-2","1479":"3","451":"2","581":"-1","582":"-1"},"96213":{"1105":"1","1134":"1","1137":"1","1138":"-1/2","1144":"-1/2","1390":"-1/4","26":"1/16","3":"1/16","546":"1","550":"-1/2","553":"-1/2","67":"1/32","721":"-1/4","724":"-1/4","725":"-1/4","775":"1/2","837":"1","942":"1/2","956":"-1/2"},"96222":{"1102":"1","1106":"1/2","1110":"1/2","1113":"-1/2","1224":"-1/2","1249":"1","1280":"1","1341":"-1/4","1342":"-1/4","1355":"1","338":"-1/4","348":"1/2","526":"1/2","712":"-1/4","714":"-1/4","863":"-2"},"96248":{"640":"-1/2","641":"-1/2"},"96270":{"913":"-1","927":"1"},"96304":{"228":"1"},"96330":{"92":"1/4"},"96347":{"1078":"1","1080":"1","1258":"1","1259":"1","1340":"1","146":"-2","1479":"1","451":"1","496":"2","497":"-2","581":"-1","582":"-1","889":"-1","895":"1","897":"1","898":"-1","907":"1","919":"-1"},"96356":{"146":"-1/2"},"96402":{"1469":"-1","223":"1"},"96453":{"1484":"1/2","34":"-1/2","49":"-1/2"},"96838":{"125":"1","1457":"-1"},"96862":{"139":"1","1474":"-1"},"96899":{"1472":"-1","163":"1"},"96906":{"1465":"-1","201":"1"},"97046":{"752":"-1","891":"1","937":"-1"},"97051":{"611":"1","613":"1","752":"1","891":"-1","937":"1"},"97057":{"1277":"-1","1279":"2","1368":"-3","1374":"2","1551":"2","476":"-1","489":"-1","524":"1","607":"-1","608":"-1/4","610":"3/4","611":"-1","612":"-1","613":"-1/2","770":"1"},"97285":{"128":"1","1476":"-1"},"97293":{"119":"1","1475":"-1"},"97296":{"1458":"-1","154":"1"},"97337":{"225":"-1/2","229":"1/4"},"97427":{"707":"4"},"97446":{"1233":"1","1381":"1"},"97532":{"108":"1","22":"1/2","23":"1/2","320":"-1/2","333":"2","49":"-1"},"97536":{"1466":"-1"},"97947":{"1208":"1","1461":"-3","454":"12"},"98043":{"1154":"1/2","1168":"-1","1173":"1/2","13":"1/4","1349":"1/4","1353":"-1","1385":"-3/16","1448":"1/4","1474":"1/2","240":"-3/16","402":"1/4","52":"-1/2","570":"-1","573":"1/2","737":"-1/2","875":"1/2","882":"1/2","895":"1/2","897":"1/2","907":"-1/2","928":"1/2","954":"1/2","957":"-1/2","968":"1/2","975":"1/2"},"98197":{"1031":"-1","1033":"-1","1221":"-1","1222":"-1","1224":"-1","1302":"-1","1311":"-1","1312":"-1","1319":"-1","1338":"-1/2","1360":"-1","1361":"-1","1366":"-1","1426":"2","251":"2","265":"-2","471":"4","549":"2","650":"-1","674":"-1","704":"-1/2","882":"-1","884":"-1","889":"1","905":"-1","907":"-1","934":"1","938":"1","939":"1","946":"-1","947":"-1","948":"-1","952":"-1","955":"1","957":"1","963":"-1","965":"-1","968":"1","970":"1"},"98258":{"68":"1","777":"1"},"98261":{"68":"1","777":"1"},"98278":{"68":"1"},"98298":{"1322":"-1","1325":"1/2","1394":"1/2","1427":"-1","30":"-1/8","353":"-1/4","355":"-1/2","357":"-1/4","362":"-1/2","538":"-1","59":"1/8"},"98441":{"1495":"-2"},"98541":{"1208":"1"},"98555":{"1277":"-1/4","1279":"1/2","1280":"3/8","1368":"-3/4","1374":"1/2","1551":"1/4","173":"1/2","476":"-1/4","489":"-1/4","524":"1/4","608":"-1/16","610":"3/16","611":"-1/4","612":"-1/4","613":"-1/8","770":"1/4","891":"3/8","905":"3/8"},"98570":{"151":"1/2"},"98755":{"382":"1/2","816":"-1/2"},"98824":{"559":"-1/2"},"98836":{"546":"-1/2"},"98844":{"568":"-1/2"},"98851":{"575":"-1/2"},"98859":{"292":"1"},"98862":{"558":"-1/2"},"98869":{"1399":"1","563":"1"},"98876":{"1436":"1","364":"1"},"98895":{"428":"1"},"98919":{"512":"1"},"98945":{"527":"1"},"98966":{"523":"-1/2"},"99022":{"550":"1"},"99052":{"578":"-1/2"},"99105":{"1334":"1","1336":"-2","1337":"-1","1362":"1","1377":"-2","1386":"-1/2","483":"-1","519":"-1","543":"-1","696":"-1","697":"1/4","698":"1/2","700":"1/2","702":"1","767":"1/2","901":"-1"},"99119":{"1255":"1/3","133":"1","1334":"-2/3","1336":"4/3","1337":"2/3","1362":"-1/3","1377":"4/3","1386":"1","483":"1","494":"2/3","506":"1/2","519":"7/6","543":"7/6","695":"5/3","697":"-2/3","698":"2/3","700":"-1/3","701":"-1/3","702":"-1/2","733":"1/3","767":"-5/6","883":"2/3","892":"2/3","901":"2/3","929":"2/3","962":"2/3","981":"2/3"},"99126":{"1255":"1/2","133":"3/2","1334":"-1","1336":"1/2","1337":"1","1362":"-1/2","1377":"2","1386":"3/2","1498":"2","483":"3/2","494":"1","506":"3/4","519":"7/4","543":"7/4","695":"5/2","697":"-1","698":"1","700":"-1/2","701":"-1/2","702":"-3/4","733":"1/2","767":"-5/4","883":"1","892":"1","901":"1","929":"1","962":"1","981":"1"},"99180":{"1255":"1/2","1262":"-2","133":"-1/2","1334":"1","1337":"-1/2","1362":"2","1377":"-2","1386":"-1/2","1498":"-1","483":"-1","499":"-2","519":"-1","543":"-1","695":"-1","696":"-1","697":"1/4","698":"1/2","700":"1/2","702":"1","733":"1/2","767":"1/2","883":"1","892":"1","900":"1","901":"-1","929":"1","962":"1","981":"1"},"99183":{"1158":"-1/2","1160":"-1","1207":"2","1243":"-2","1400":"2","146":"4","1463":"-4/3","1479":"-3","1495":"-2","228":"2","428":"-1","430":"-1","451":"-1","508":"2","581":"1","582":"1","637":"-1","922":"-1","925":"1","974":"1","983":"-1"},"99243":{"1449":"1","1450":"1","268":"-1","38":"1","546":"1/2","578":"-1/2","648":"-1","652":"-1","654":"-1"},"99348":{"1473":"-1","165":"1"},"99631":{"133":"-3","1334":"2","1336":"-1","1337":"-1","1362":"2","1377":"-4","1386":"-3","1498":"-2","483":"-3","494":"-2","506":"-3/2","519":"-7/2","543":"-7/2","695":"-7/2","697":"2","698":"-2","700":"1","701":"1","702":"-3/2","767":"5/2","901":"-2","986":"2"},"99754":{"242":"1","499":"1"},"99810":{"430":"1"},"99829":{"1404":"1","359":"-1/2"},"99834":{"328":"1","573":"1"},"99876":{"498":"1"},"99879":{"1395":"1","551":"1"},"99882":{"1410":"1","392":"1"},"99995":{"294":"1"}}} \ No newline at end of file diff --git a/research/clean-rational-clear-witness/source7669/data/K372-2-WORD.json.gz b/research/clean-rational-clear-witness/source7669/data/K372-2-WORD.json.gz new file mode 100644 index 0000000000..1273c83178 Binary files /dev/null and b/research/clean-rational-clear-witness/source7669/data/K372-2-WORD.json.gz differ diff --git a/research/clean-rational-clear-witness/source7669/native_verify.py b/research/clean-rational-clear-witness/source7669/native_verify.py new file mode 100644 index 0000000000..2c209dfa9c --- /dev/null +++ b/research/clean-rational-clear-witness/source7669/native_verify.py @@ -0,0 +1,277 @@ +"""Check native operators with exact Gaussian dyadic arithmetic. + +The interpreter is adapted from the independent campaign native review. +It does not import the source-code producer or the Clifford compiler. +Research used OpenAI Codex under the user's direction. +""" + +from functools import lru_cache + + +def require(condition, label): + if not condition: + raise ValueError(label) + + +def parity(value): + return value.bit_count() % 2 + + +def mul(matrix, vector): + return sum(parity(row & vector) << i for i, row in enumerate(matrix)) + + +def transpose(matrix): + return tuple(sum(((row >> j) & 1) << i for i, row in enumerate(matrix)) for j in range(len(matrix))) + + +def inverse(matrix): + n = len(matrix) + rows = [row | (1 << (n+i)) for i, row in enumerate(matrix)] + for j in range(n): + pivot = next((i for i in range(j, n) if rows[i] >> j & 1), None) + require(pivot is not None, 'singular binary chart') + rows[j], rows[pivot] = rows[pivot], rows[j] + for i in range(n): + if i != j and rows[i] >> j & 1: + rows[i] ^= rows[j] + require([row & ((1 << n)-1) for row in rows] == [1 << i for i in range(n)], 'binary inverse') + return tuple(row >> n for row in rows) + + +def extend(vectors, n): + columns, pivots = [], {} + for value in tuple(vectors) + tuple(1 << i for i in range(n)): + reduced = value + while reduced: + j = reduced.bit_length()-1 + if j not in pivots: + pivots[j] = reduced + columns.append(value) + break + reduced ^= pivots[j] + require(len(columns) == n, 'frame basis extension') + return tuple(columns) + + +def adjoint(circuit): + out = [] + for gate in reversed(circuit): + if gate[0] == 'P': + out.append(('P', inverse(gate[1]))) + elif gate[0] == 'D': + out.append(('D', gate[1], tuple(-a % 4 for a in gate[2]))) + elif gate[0] == 'C': + out.append(('C', gate[1], -gate[2])) + elif gate[0] == 'phase': + out.append(('phase', -gate[1] % 4)) + else: + require(gate[0] == 'X', 'adjoint gate type') + out.append(gate) + return tuple(out) + + +def fourier(rank): + return tuple(('C', 1 << i, 1) for i in range(rank)) + + +def frame(vectors, n): + rank = len(vectors) + if rank == 0: + return () + if rank == n: + return fourier(n) + matrix = transpose(extend(vectors, n)) + columns = transpose(inverse(matrix)) + quadratic = tuple((1 << i) ^ sum(parity(a & b) << j for j, b in enumerate(columns)) for i, a in enumerate(columns)) + diagonal = tuple((row >> i) & 1 for i, row in enumerate(quadratic)) + chart = (('P', matrix), ('D', quadratic, diagonal)) + return adjoint(chart) + fourier(rank) + chart + + +def monomial(record): + matrix = tuple(record['matrix_rows']) + quadratic = tuple(record['quadratic_rows']) + linear = tuple(record['linear_Z4']) + require(transpose(quadratic) == quadratic, 'quadratic symmetry') + require(len(matrix) == len(quadratic) == len(linear) == 9, 'monomial dimension') + require(all(a % 2 == (quadratic[i] >> i) & 1 for i, a in enumerate(linear)), 'diagonal parity') + inverse(matrix) + return (('D', quadratic, linear), ('P', matrix), ('X', record['offset']), ('phase', record['phase'])) + + +def recipe(record): + rank = record['rank'] + require(isinstance(rank, int) and 0 <= rank <= 9, 'child rank') + if rank == 0: + require(record['right'] is None, 'rank zero right factor') + return monomial(record['left']) + return monomial(record['right']) + fourier(rank) + monomial(record['left']) + + +def tableau(circuit, n=9): + rows = [(1 << i, 0, 0) for i in range(n)] + [(0, 1 << i, 0) for i in range(n)] + for gate in circuit: + tag = gate[0] + out = [] + inverse_transpose = transpose(inverse(gate[1])) if tag == 'P' else None + for x, z, phase in rows: + if tag == 'P': + x, z = mul(gate[1], x), mul(inverse_transpose, z) + elif tag == 'X': + phase += 2 * parity(z & gate[1]) + elif tag == 'C': + if parity(z & gate[1]): + x ^= gate[1] + phase += 3 * gate[2] + elif tag == 'D': + quadratic, linear = gate[1:] + phase += sum(linear[i] for i in range(n) if x >> i & 1) + phase += 2 * sum(parity((quadratic[i] >> (i+1)) & (x >> (i+1))) for i in range(n) if x >> i & 1) + z ^= mul(quadratic, x) + else: + require(tag == 'phase', 'tableau gate type') + out.append((x, z, phase % 4)) + rows = out + return tuple(rows) + + +@lru_cache(maxsize=512) +def action(gate): + if gate[0] == 'P': + return tuple(mul(gate[1], x) for x in range(512)) + require(gate[0] == 'D', 'state action type') + quadratic, linear = gate[1:] + return tuple((sum(linear[i] for i in range(9) if x >> i & 1) + + 2 * sum(parity((quadratic[i] >> (i+1)) & (x >> (i+1))) for i in range(9) if x >> i & 1)) % 4 for x in range(512)) + + +def rotate(pair, power): + a, b = pair + return ((a, b), (-b, a), (-a, -b), (b, -a))[power % 4] + + +def state(circuit, basis=0): + value, denominator = {basis: (1, 0)}, 0 + for gate in circuit: + tag = gate[0] + result = {} + if tag == "C": + direction, sign = gate[1:] + for address, (a, b) in value.items(): + for target, pair in ((address, (a - sign*b, b + sign*a)), + (address ^ direction, (a + sign*b, b - sign*a))): + old = result.get(target, (0, 0)) + result[target] = (old[0] + pair[0], old[1] + pair[1]) + denominator += 1 + else: + for address, pair in value.items(): + if tag == "P": + target = mul(gate[1], address) + elif tag == "X": + target = address ^ gate[1] + else: + target = address + if tag == "D": + pair = rotate(pair, action(gate)[address]) + else: + require(tag == "phase", "Unknown Gaussian state gate") + pair = rotate(pair, gate[1]) + require(target not in result, "A monomial address map is not injective") + result[target] = pair + value = {address: pair for address, pair in result.items() if pair != (0, 0)} + while denominator and all((a | b) % 2 == 0 for a, b in value.values()): + denominator -= 1 + value = {address: (a//2, b//2) for address, (a, b) in value.items()} + return value, denominator + + +def equal(actual, expected, label): + require(tableau(actual) == tableau(expected), label + ": signed Pauli action") + require(state(actual) == state(expected), label + ": exact global phase") + + +def verify(data, certificate): + word = data["word"] + original, clean = data["programs"], data["clean_programs"] + source_recipes = data["recipes"] + residuals = data["residuals"]["recipes"] + native_tags = {"climb", "adapter", "residual_adapter"} + for orientation in ("forward", "backward"): + native = [event for event in clean[orientation] if event[0] in native_tags] + require(native == [event for event in original[orientation] if event[0] in native_tags], + "A retained native event changed") + require(len(native) == 5056, "The retained native event count changed") + frames = [frame(tuple(vectors), 9) for vectors in word["frames"]] + used = {(event[3], event[4]) for program in clean.values() + for event in program if event[0] == "climb"} + children = {(record["old"], record["new"]): record for record in source_recipes["children"]} + require(len(children) == len(source_recipes["children"]) and used <= set(children), + "The retained child recipe coverage is incomplete") + for old, new in sorted(used): + record = children[old, new] + require(record["rank"] == len(word["frames"][new]) - len(word["frames"][old]), + "A retained child has the wrong rank") + equal(recipe(record), adjoint(frames[old]) + frames[new], "Retained child") + endpoints = {(record["role"], record["port"]): record + for record in source_recipes["endpoint_adapters"]} + require(len(endpoints) == len(source_recipes["endpoint_adapters"]) + and set(endpoints) == {(role, p) for role in ("source", "target") for p in range(112)}, + "The endpoint adapter coverage is incomplete") + for (role, port), record in endpoints.items(): + direction = word["ports"][port] + conventional = (("C", direction, 1),) if role == "source" else ( + ("C", direction, -1),) + fourier(9) + index = word["start"][port] if role == "source" else word["final"][112 + port] + require(record["frame"] == index and record["rank"] == 0, "An endpoint frame changed") + equal(recipe(record), adjoint(conventional) + frames[index], "Endpoint adapter") + used_residuals = set() + for program in clean.values(): + for event in program: + if event[0] != "residual_adapter": + continue + _, position, register, entry, *tail = event + terminal = tail[0] if tail else 1 + key = str(entry) if terminal == 1 else str(entry) + ":" + str(terminal) + require(key in residuals and position in ("pre", "post"), "A residual binding changed") + require(entry == word["start"][register] and terminal == word["final"][register], + "A residual endpoint changed") + used_residuals.add(key) + for key in sorted(used_residuals): + record = residuals[key] + equal(recipe(record), adjoint(frames[record["frame"]]) + frames[record.get("terminal", 1)], + "Residual adapter") + records = certificate["input_recipes"] + ports = certificate["compensation_ports"] + require([record["port"] for record in records] == ports and len(records) == 8, + "The eight input recipes changed") + columns = 0 + for item in records: + port, label = item["port"], item["label"] + require(label == word["ports"][port] and item["canonical_start_frame_id"] == word["start"][port], + "An input recipe has the wrong supplier label") + record = item["recipe"] + require(record["rank"] == 1, "An input copy has the wrong child rank") + for side in ("left", "right"): + factor = record[side] + require(factor["quadratic_rows"] == [0] * 9 and factor["linear_Z4"] == [0] * 9 + and factor["offset"] == factor["phase"] == 0, + "An input factor is not an address permutation") + actual, expected = recipe(record), (("C", label, 1),) + equal(actual, expected, "Positive inherited input line") + for basis in range(512): + require(state(actual, basis) == state(expected, basis), "A complete input Gaussian column differs") + columns += 1 + negative = monomial(record["right"]) + (("C", 1, -1),) + monomial(record["left"]) + require(tableau(negative) != tableau(expected) or state(negative) != state(expected), + "An inverse input child was not detected") + phased = actual + (("phase", 1),) + require(tableau(phased) == tableau(actual) and state(phased) != state(expected), + "An input phase-only error was not detected") + return {"status": "PASS_EXACT_INPUT_NATIVE_FRAMES", "retained_native_events_per_orientation": 5056, + "retained_child_recipes": len(used), "endpoint_adapter_recipes": len(endpoints), + "residual_adapter_recipes": len(used_residuals), "new_input_recipes": len(records), + "new_exact_gaussian_columns": columns, "inverse_input_child_controls": len(records), + "phase_only_controls": len(records), "address_permutation_factors": 2 * len(records), + "method": "Independent signed Pauli and exact Gaussian interpretation; no compiler import", + "scope": "Positive inherited input frames before every retained adapter. No recursive hosting claim."} diff --git a/research/clean-rational-clear-witness/source7669/replay.py b/research/clean-rational-clear-witness/source7669/replay.py new file mode 100644 index 0000000000..9c390e5fc8 --- /dev/null +++ b/research/clean-rational-clear-witness/source7669/replay.py @@ -0,0 +1,124 @@ +"""Source-bound reconstruction and scoped checks, not a universal acceptance gate. +Apache-2.0; prepared with substantial OpenAI Codex assistance. +""" +import argparse +import copy +import gzip +import hashlib +import importlib.util +import json +from pathlib import Path +import subprocess +import sys + +def canonical(x): + return json.dumps(x, sort_keys=True, separators=(",", ":")).encode() + +def digest(x): + return hashlib.sha256(canonical(x)).hexdigest() + +def need(x, message): + if not x: + raise ValueError(message) + +def read(p): + raw = p.read_bytes() + return json.loads(gzip.decompress(raw) if raw[:2] == b"\x1f\x8b" else raw) + +def reconstruct(source, patch): + need(digest(source) == patch["source"], "wrong predecessor for this edit, not another candidate gate") + word = copy.deepcopy(source) + previous = 0 + program = [] + for e in patch["edits"]: + i, j = e["start"], e["stop"] + need(type(i) is int and type(j) is int and previous <= i <= j <= len(source["program"]), "invalid edit interval") + need(source["program"][i:j] == e["before"], "edit preimage mismatch") + program.extend(source["program"][previous:i]) + program.extend(e["after"]) + previous = j + program.extend(source["program"][previous:]) + word["program"] = program + need(digest(word) == patch["candidate"], "wrong reconstructed artifact") + return word + +def load(path, name): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--out", required=True, type=Path) + args = parser.parse_args() + root = Path(__file__).resolve().parent + out = args.out.resolve() + need(not out.exists(), "fresh output directory required") + manifest = read(root / "MANIFEST.json") + for entry in manifest["files"]: + p = (root / entry["path"]).resolve() + need(p.is_relative_to(root), "manifest path escape") + need(hashlib.sha256(p.read_bytes()).hexdigest() == entry["sha256"], "changed input: " + entry["path"]) + source = read(root / "data/K372-2-WORD.json.gz") + patch = read(root / "EDIT.json") + word = reconstruct(source, patch) + out.mkdir(parents=True) + candidate_path = out / "WORD.json.gz" + candidate_path.write_bytes(gzip.compress(canonical(word), mtime=0)) + audit = load(root / "src/integer_grid_audit.py", "ee251_audit") + finite = audit.run_audit(candidate_path, root / "data/CERTS.json", root / "data/HEADER.json", out / "finite", 225 * 2**40) + need(finite["status"] == "PASS_FINITE_INTEGER_ROWS_AND_CLEAR_RELATIONS", "finite audit failed") + counts = load(root / "src/ordinary_tape_audit.py", "ee251_counts") + caller = read(root / "data/CALLER.json.gz") + counts.validate_caller(caller) + inventory = counts.native_inventory(word) + paid, targets, empty = counts.invoice_counts(caller, inventory) + invoice = read(root / "data/INVOICE.json") + need({str(k):v for k,v in paid.items()} == invoice["paid"], "paid histogram mismatch") + need({str(k):v for k,v in targets.items()} == invoice["targets"], "target histogram mismatch") + expected = read(root / "evidence/PRICE-SUMMARY.json") + prices = [] + for point in expected["outcomes"]: + exponent = str(__import__('decimal').Decimal(1) - __import__('decimal').Decimal(point["kappa"])) + command = [sys.executable, "-I", "-B", str(root / "src/evaluate_recursive_power.py"), str(root / "data/INVOICE-ZERO.json"), str(root / "data/INVOICE.json"), "--exponent", exponent, "--bits", "256"] + result = subprocess.run(command, capture_output=True, text=True, encoding="utf-8", timeout=120, check=True) + actual = json.loads(result.stdout) + need(actual["classification"] == point["classification"] and actual["new_minus_old"] == point["new_minus_old"], "directed price result mismatch") + (out / ("price-" + point["label"] + ".json")).write_text(result.stdout, encoding="utf-8") + prices.append({"kappa":point["kappa"], "classification":actual["classification"]}) + # Two rejection controls test reconstruction; a third tests actual row semantics. + bad_patch = copy.deepcopy(patch) + bad_patch["edits"][0]["before"].append(["invalid"]) + try: + reconstruct(source, bad_patch) + except ValueError: + pass + else: + raise ValueError("preimage mutation was accepted") + bad_source = copy.deepcopy(source) + bad_source["program"][0] = ["invalid"] + try: + reconstruct(bad_source, patch) + except ValueError: + pass + else: + raise ValueError("source mutation was accepted") + mutant = copy.deepcopy(word) + index = next(i for i,e in enumerate(mutant["program"]) if e[0] == "ADD") + from fractions import Fraction + mutant["program"][index][3] = str(-Fraction(mutant["program"][index][3])) + try: + audit.audit_word(mutant, read(root / "data/CERTS.json"), 225 * 2**40, read(root / "data/HEADER.json")) + except audit.AuditFailure as error: + rejection = error.kind + else: + raise ValueError("semantic sign mutation was accepted") + report = {"status":"PASS_SCOPED_EE251F60_REPLAY", "candidate":digest(word), "source":digest(source), "events":len(word["program"]), "finite_status":finite["status"], "inventory":inventory, "prices":prices, "rejection_controls":["wrong source", "wrong edit preimage", rejection], "scope":"Fresh exact reconstruction, all public rows/CLEAR, actual caller paid/target recount and original 256-bit price CLI. Recorded ordinary/precision/native-phase evidence is reused, not rerun; whole physical and analytic obligations remain open."} + for entry in manifest["files"]: + need(hashlib.sha256((root / entry["path"]).read_bytes()).hexdigest() == entry["sha256"], "input changed during replay") + (out / "RESULT.json").write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8") + print(json.dumps(report)) + +if __name__ == "__main__": + main() diff --git a/research/clean-rational-clear-witness/verify.py b/research/clean-rational-clear-witness/verify.py new file mode 100644 index 0000000000..fd1b1dfaa2 --- /dev/null +++ b/research/clean-rational-clear-witness/verify.py @@ -0,0 +1,61 @@ +if not __debug__: + raise RuntimeError("Run verification without -O; assertions are required") +import sys, json, hashlib, random +from pathlib import Path +sys.path.insert(0,str(Path(__file__).parent)) +from reversible_linear import compile_linear,clear,selftest +r=selftest(); controls=[] +for a,d,w,x,t in [([1],2,3,[1],0),([2],1,3,[3],-2),([1,-1],1,4,[3,1],3)]: + c,o,s=compile_linear(a,d,w); target,_,invalid=clear(c,o,x,t,w) + assert target or invalid + controls.append({'coefficients':a,'D':d,'width':w,'input':x,'target':t,'target_output':target,'invalid_output':invalid,'illegal_erasure_blocked':True}) +r['adversarial_controls']=controls +rng=random.Random(89208) +for _ in range(100): + w=rng.randrange(1,11);a=[rng.randrange(-12,13) for _ in range(rng.randrange(1,5))];d=rng.randrange(1,17) + c,o,s=compile_linear(a,d,w) + x=[rng.randrange(-(1<<(w-1)),1<<(w-1)) for _ in a];t=rng.randrange(-(1<<(w-1)),1<<(w-1)) + target,_,invalid=clear(c,o,x,t,w) + assert (not target and not invalid)==(sum(k*v for k,v in zip(a,x))==d*t) +r['additional_random_contracts_all_zero_iff_exact_integer_relation']=100 +r['script_sha256']=hashlib.sha256(Path(__file__).with_name('reversible_linear.py').read_bytes()).hexdigest() +c,o,stats=compile_linear([1]*4+[-1]*4,2,1076) +x=[1,3,-2,2,4,-1,5,-4]; n=sum(x[:4])-sum(x[4:]) +target,_,invalid=clear(c,o,x,n//2,1076) +assert not target and not invalid +r['fullwidth_network']={'width':1076,'stats':stats,'executed':True} + +# Independent-review edge cases, now permanent reproducible regressions. +A=1<<1075; M=A-1 +edge_cases=[ + ('positive_max_exact',[M,M,0,0,0,0,0,0],M,0), + ('negative_min_exact',[-A,-A,0,0,0,0,0,0],-A,0), + ('fraction',[1,0,0,0,0,0,0,0],0,1), + ('positive_overflow',[M,M,2,0,0,0,0,0],-A,1)] +r['fullwidth_edges']=[] +for label,x,target,expected_flag in edge_cases: + after,_,flag=clear(c,o,x,target,1076) + assert after==0 and flag==expected_flag + r['fullwidth_edges'].append({'case':label,'inputs':[str(t) for t in x],'target':str(target),'target_output':after,'invalid_output':flag}) +# Full reversible-network roundtrips from arbitrary bitstrings verify gate +# bijectivity; these are NOT zero-ancilla clean-computation claims. +from reversible_linear import apply +small,outputs,_=compile_linear([1,-2],3,3) +rng_inverse=random.Random(7680) +for _ in range(100): + state=[rng_inverse.randrange(2) for _ in range(small.next+4)] + initial=list(state) + gates=small.gates+[('CX',b,small.next+i) for i,b in enumerate(outputs)]+[('CX',small.invalid,small.next+3)]+list(reversed(small.gates)) + apply(state,gates);apply(state,reversed(gates));assert state==initial +r['arbitrary_initial_state_gate_inverse_roundtrips']=100 + +r['example_cost_table']=[] +for width in (4,1076,1108): + circuit,output,cost=compile_linear([1]*4+[-1]*4,2,width) + r['example_cost_table'].append({'width':width,**cost}) +from public_source_binding import verify as verify_public +r['public_source_binding']=verify_public() +Path(__file__).with_name('EXAMPLE-PROVENANCE.json').write_text(json.dumps(r['public_source_binding'],indent=2)+'\n',encoding='utf-8',newline='\n') +Path(__file__).with_name('RESULT.json').write_text(json.dumps(r,indent=2)+'\n',encoding='utf-8',newline='\n') +print(json.dumps(r)) +print("PASS_CLEAN_REVERSIBLE_WITNESS")