diff --git a/research/current-triangle-native-error/LICENSE b/research/current-triangle-native-error/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/current-triangle-native-error/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/current-triangle-native-error/NOTICE b/research/current-triangle-native-error/NOTICE new file mode 100644 index 0000000000..2cb9b69b60 --- /dev/null +++ b/research/current-triangle-native-error/NOTICE @@ -0,0 +1,10 @@ +Complete local triangle error operator in native charts. +Prepared by Ali Romman with substantial OpenAI Codex assistance. +New work is Apache-2.0. + +SYLforge supplied the candidate, edit and prior rational identity. +The source PROVENANCE.md preserves the complete native and caller lineage. +The source reconstruction is unchanged from Ali Romman's PR #7671. +The exact Gaussian frame checker was prepared for CubeJerry with Codex +assistance; its retained NOTICE and README give the prior attribution. +SOURCES.json and VENDORED.json record every retained source origin. diff --git a/research/current-triangle-native-error/PROOF.md b/research/current-triangle-native-error/PROOF.md new file mode 100644 index 0000000000..a45b7d47b6 --- /dev/null +++ b/research/current-triangle-native-error/PROOF.md @@ -0,0 +1,210 @@ +# Complete local error operator in the actual triangle charts + +## Quantified contract + +Use the exact three-field blocks of PR #7669, candidate +`ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d`. +The source and edit are pinned at +`95d476623f1468822057554475dc8badb19bfa44`. The copied PR #7671 verifier +reconstructs the complete candidate and binds both local windows. The +source's later documentation head does not change those words or tapes. + +Let H be the complex Hilbert space of a complete native field, including +all positive column multiplicities and complete spectators. Let T_A,T_B,T_C +be the exact unitary frames for A=265, B=751 and C=927. Write + +```text +U = T_B T_A*, V = T_C T_A*, W = T_C T_B*. +V = WU. +``` + +At entry, x=role236 and z=role1000 are in A; y=role544 is in B. Reference +MOVE applies its exact frame quotient. Each actual MOVE can return that +reference value plus a local error vector. Each fractional scalar ADD +can also return its exact value plus an error vector. Integral scalar +ADDs are exact under the stated no-overflow contract. This proof does +not construct the error allowances or establish an admitted input grid. + +The comparison is between each actual block and its exact evaluation on +the same entry fields. Earlier input error is not silently set to zero: +relative to a different ideal entry it must also pass through the source +rational matrix M. This result gives the additional local error. + +At exit, the old charts are `(B,C,B)` and the new charts are `(C,C,B)`. +For the output norm, represent all three fields in C. The old x and both +z outputs are transformed only in this mathematical comparison. These +isometries are not added program operations or free physical conversions. + +## Native frames and all-size lift + +The retained direct frame implementation expresses a frame as phase and +permutation conjugation of Gaussian gates. One gate is + +```text +C_v = ((1+i)/2) I + ((1-i)/2) X_v, +``` + +where X_v is a self-adjoint involution. The squared moduli of the two +coefficients sum to one, and their cross term has zero real part. Thus +`C_v* C_v = I`. The opposite sign gives its adjoint. Address permutations +and phases in `{1,i,-1,-i}` are unitary. Their products and conjugates +are therefore unitary, with the exact global phase retained. + +A tensor product of these frames remains unitary for every positive +column multiplicity. A tensor identity on complete spectators also +preserves the norm. The quotient relation `V=WU` holds in each case. +This supplies the mathematical frame property used below. It does not +construct a finite-tape provider at any proposed error or time allowance. + +The verifier checks all 512 forward/adjoint columns of each of the three +literal one-column frames. It also executes both local tapes on complete +512-component complex fields. These finite checks bind the exact source +formula and phase. The preceding tensor argument gives the stated lift. + +## New block: all six residuals + +Name the residuals in chronological order: + +| Name | Literal operation | Frame of the residual | +| --- | --- | --- | +| e1 | x += z/4 | A | +| m1 | MOVE x from A to C | C | +| m2 | MOVE z from A to B | B | +| e2 | y += z/2 | B | +| m3 | MOVE y from B to C | C | +| e3 | x += y/2 | C | + +The integral updates `z-=2x`, `z+=2y`, and `y-=x` remain in the tape. +Substitution through all nine events gives the exit error in physical +charts `(C,C,B)`: + +```text +error_x = (1/2)m1 + (1/4)Wm2 + (1/2)We2 + (1/2)m3 + e3 +error_y = -2Ve1 - m1 + (1/2)Wm2 + We2 + m3 +error_z = -4Ue1 + 2m2 + 2e2. +``` + +The first scalar residual cancels from x. It remains in y and z. The +native MOVE residuals do not share that cancellation. + +Align the residual vector as +`d_new=(Ve1,m1,Wm2,We2,m3,e3)`. Align z to C. The complete output error +is exactly `N d_new`, with scalar coefficients acting on H: + +```text +N = [ 0 1/2 1/4 1/2 1/2 1 ] + [-2 -1 1/2 1 1 0 ] + [-4 0 2 2 0 0 ]. +``` + +The input alignment is unitary on each port. It preserves the sum of +squared residual norms. This identity applies to any realized errors, +including errors that depend on the current fields or on earlier errors. +No statistical or algebraic independence is needed for the upper bound. + +## Old block and direct comparison + +Let m1o be the old x MOVE residual in B, m2o the old z MOVE residual in B, +e0 the old quarter-ADD residual in B, and m3o the old y MOVE residual in C. +After alignment to C, use `d_old=(Wm1o,Wm2o,We0,m3o)`. The error is +exactly `O d_old`, where + +```text +O = [ 0 1/4 1 0 ] + [-2 0 0 1 ] + [-4 1 0 0 ]. +``` + +Both exact blocks have the same aligned output, so the difference of +actual outputs is `[N|-O](d_new,d_old)`. This comparison retains every +local error from both executions. It does not identify errors at two +different sites merely because their nominal operations have equal cost. + +## Exact induced constants + +For any real scalar matrix K acting on H-valued columns, +`||K tensor I_H||_2 = sqrt(lambda_max(K K^T))`. An upper bound follows by +diagonalizing the real Gram matrix. Equality is attained by a largest +left singular vector and any unit vector of H. Because each port's +frame alignment is a unitary bijection, the same sharp constant applies +to arbitrary residual vectors in their physical frames. + +This sharpness statement concerns the stated unrestricted residual +contract. It does not assert that independent extremal errors are +reachable under a particular floor quantizer or caller input. + +The integer matrices below are 16 times the three Gram matrices: + +```text +16 O O^T = [17 0 4] + [ 0 80 128] + [ 4 128 272] + +16 N N^T = [29 10 24] + [10 116 176] + [24 176 384]. + +16 [N|-O][N|-O]^T is the sum of these two matrices. +``` + +Their characteristic polynomials are respectively + +```text +p_old(t) = t^3 - 369t^2 + 11344t - 90112 +p_new(t) = t^3 - 529t^2 + 27392t - 372736 +p_difference(t) = t^3 - 898t^2 + 74468t - 1614336. +``` + +For each polynomial, divide its largest root by 16 and take the square +root to obtain the induced constant. Exact rational intervals certify: + +```text +4.582849288401 < C_old < 4.582849288402 +5.435547392075 < C_new < 5.435547392076 +7.107859846622 < C_difference < 7.107859846623. +``` + +The receipt gives rational endpoints for each squared constant, separated +by less than 10^-20. At the upper endpoint all leading principal minors +of `qI-G` are positive, so it is positive definite. At the lower endpoint +the first two minors are positive and the determinant is negative, so it +has one negative eigenvalue. This isolates the largest eigenvalue. The +stated square-root intervals are also checked by exact rational squaring. +No floating-point eigenvalue is used in the certificate. + +If E_new is the square root of the sum of all six squared residual +norms, the new local error is at most `C_new E_new`. Corresponding bounds +hold for the four old ports and the ten-port difference. These constants +use a joint error budget; they are not a comparison at an equal per-site +allowance or a claim that the new tape has smaller error. + +For example, if all three fractional scalar operations have grid spacing +Delta on N complex coordinates and all stored operands are on that grid, +their squared error allowances sum to at most `17N Delta^2/8`. If the three +native residual norms are at most rho1,rho2,rho3, then + +```text +new local error <= C_new sqrt(rho1^2+rho2^2+rho3^2+17N Delta^2/8). +``` + +This is a valid upper bound under those premises. It is not claimed sharp +for floor rounding. The native allowances and grid/range premises remain +to be supplied. A later caller must also propagate earlier input error +through its exact rational map and account for later work. + +## Verification and limits + +The symbolic derivation follows the literal event order, tracks all +current charts and inserts one formal residual at each listed site. It +matches the separately derived matrices above. A distinct exact Gaussian +field execution checks each of the ten ports on all 512 complex +coordinates, with the actual native quotients and output alignment. Each +one-port squared gain is also checked directly. Four controls detect an +omitted native residual, a lost factor two, a native global-phase fault +and a missing old x exit alignment. + +The proof does not choose native quantizers, prove reachable residues, +set signed widths, construct physical conversion services or price a +complete caller. Full native/caller replay, analytic recovery and all +five inherited framework assumptions remain open. No new kappa or +selected-frontier change is claimed. diff --git a/research/current-triangle-native-error/README.md b/research/current-triangle-native-error/README.md new file mode 100644 index 0000000000..1a1ec275a1 --- /dev/null +++ b/research/current-triangle-native-error/README.md @@ -0,0 +1,81 @@ +# Complete triangle error operator in native charts + +This scoped proof accounts for all three scalar rounding sites and all +three native MOVE error sites in the current PR #7669 triangle. It +compares the actual output charts, including the different old/new x +frames. It does not assume that chart transport commutes with rounding. + +If E is the square root of the sum of all six squared local residual +norms, the new block's output error is at most `C_new E`, where +`5.435547392075 < C_new < 5.435547392076`. The constant is sharp for +arbitrary residual vectors with this joint budget. Sharpness for a +particular floor quantizer or actual caller is not asserted. The proof +also gives the old four-port constant and the complete ten-port +old/new difference. No new kappa is claimed. + +Read [PROOF.md](PROOF.md) for the quantified interface, exact propagation +matrices, rational eigenvalue certificates and tensor/spectator lift. +[RESULT.json](RESULT.json) gives every source clock, matrix, norm interval, +512-column frame check, full-field residual check and fault control. +[error_operator.py](error_operator.py) derives the formal residual matrix. +[verify.py](verify.py) checks it with the retained direct Gaussian frames. + +## Source and distinct scope + +The exact candidate in +[PR #7669](https://github.com/CrocSwap/integer-mult-bounds/pull/7669) is +`ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d`. +Its source files are pinned at `95d476623f1468822057554475dc8badb19bfa44`. +The source's later documentation head leaves the words and local tapes +unchanged. The copied verifier from +[PR #7671](https://github.com/CrocSwap/integer-mult-bounds/pull/7671), +head `f34696319eb19d05d1b09f7372c3146be3ea1635`, supplies complete source +reconstruction and local window binding. Its common-coordinate scalar +law is not used as a transport-aware error bound. + +This takes that proof's explicit native-transport question. The source +contributor is studying actual rounding and reachability. This result +has a separate scope: it takes local residual allowances as inputs and +proves their propagation. It supplies no native allowance, reachable +grid, signed range, physical runtime or free correction. Those unknown +costs and premises cannot be set to zero. All five selected assumptions +and the selected frontier remain unchanged. + +The exact input and copy pins are in [SOURCES.json](SOURCES.json) and +[VENDORED.json](VENDORED.json). The copied source directory is a partial +dependency snapshot, not the source's full replay package. + +## Reproduce + +Use Python 3.12 and the standard library, from the repository root: + +```sh +python3.12 -B scripts/research_package.py --package research/current-triangle-native-error +``` + +Normal and optimized commands must print `PASS_CURRENT_TRIANGLE_NATIVE_ERROR`, +followed by the registered package pass. The bounded checks cover all +1536 forward/adjoint columns of the three one-column frames, all ten +local residual ports on full 512-component fields, exact spectral +certificates and four semantic faults. The whole native word, sixteen-call +caller, price CLI and complete multiplier are not replayed. + +## Open next questions + +Supply native error allowances and reachable scalar grids at the six +literal sites. Then use the proved operator to combine those allowances +with earlier and later caller errors. The first step is the source's +transport-aware quantizer and reachability analysis; this package does +not reserve or duplicate that work. A complete physical tariff and signed +range argument are still required before this local bound can enter a +multiplication theorem. + +## Credit + +Prepared by Ali Romman with substantial OpenAI Codex assistance. +SYLforge supplied the candidate, exact edit and prior rational identity. +Ali Romman supplied the pinned source reconstruction and scalar audit. +CubeJerry supplied the retained direct Gaussian frame checker, prepared +with Codex assistance. Its notices and the copied source provenance +preserve the earlier native, caller, compiler and helper contributors. +New work is Apache-2.0. All retained source bytes are unchanged. diff --git a/research/current-triangle-native-error/RESULT.json b/research/current-triangle-native-error/RESULT.json new file mode 100644 index 0000000000..ec039b17ef --- /dev/null +++ b/research/current-triangle-native-error/RESULT.json @@ -0,0 +1,622 @@ +{ + "binding": { + "source_sha256": "3dd1199d95291ee96e6c0aeb6f55f86244a569b1d4975840bf0207e2dcf9c025", + "candidate_sha256": "ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d", + "source_window": [ + 97747, + 97753 + ], + "candidate_window": [ + 97842, + 97851 + ], + "first_later_event": [ + "ADD", + 544, + 972, + "1/2", + 927 + ], + "frames": { + "265": [ + 21, + 38, + 448 + ], + "751": [ + 3, + 4, + 17, + 33, + 72, + 392 + ], + "927": [ + 3, + 4, + 17, + 33, + 72, + 128, + 264 + ] + }, + "old_events": [ + [ + "MOVE", + 236, + 265, + 751, + false + ], + [ + "ADD", + 544, + 236, + "-2", + 751 + ], + [ + "MOVE", + 1000, + 265, + 751, + false + ], + [ + "ADD", + 1000, + 544, + "2", + 751 + ], + [ + "ADD", + 236, + 1000, + "1/4", + 751 + ], + [ + "MOVE", + 544, + 751, + 927, + false + ] + ], + "new_events": [ + [ + "ADD", + 236, + 1000, + "1/4", + 265 + ], + [ + "ADD", + 1000, + 236, + "-2", + 265 + ], + [ + "MOVE", + 236, + 265, + 927, + false + ], + [ + "MOVE", + 1000, + 265, + 751, + false + ], + [ + "ADD", + 544, + 1000, + "1/2", + 751 + ], + [ + "ADD", + 1000, + 544, + "2", + 751 + ], + [ + "MOVE", + 544, + 751, + 927, + false + ], + [ + "ADD", + 544, + 236, + "-1", + 927 + ], + [ + "ADD", + 236, + 544, + "1/2", + 927 + ] + ] + }, + "ports": { + "old": [ + { + "offset": 0, + "clock": 97747, + "kind": "MOVE", + "role": 236, + "frame": 751 + }, + { + "offset": 2, + "clock": 97749, + "kind": "MOVE", + "role": 1000, + "frame": 751 + }, + { + "offset": 4, + "clock": 97751, + "kind": "ADD", + "role": 236, + "frame": 751 + }, + { + "offset": 5, + "clock": 97752, + "kind": "MOVE", + "role": 544, + "frame": 927 + } + ], + "new": [ + { + "offset": 0, + "clock": 97842, + "kind": "ADD", + "role": 236, + "frame": 265 + }, + { + "offset": 2, + "clock": 97844, + "kind": "MOVE", + "role": 236, + "frame": 927 + }, + { + "offset": 3, + "clock": 97845, + "kind": "MOVE", + "role": 1000, + "frame": 751 + }, + { + "offset": 4, + "clock": 97846, + "kind": "ADD", + "role": 544, + "frame": 751 + }, + { + "offset": 6, + "clock": 97848, + "kind": "MOVE", + "role": 544, + "frame": 927 + }, + { + "offset": 8, + "clock": 97850, + "kind": "ADD", + "role": 236, + "frame": 927 + } + ] + }, + "exit_charts": { + "old": [ + 751, + 927, + 751 + ], + "new": [ + 927, + 927, + 751 + ] + }, + "certificates": { + "old": { + "matrix": [ + [ + "0", + "1/4", + "1", + "0" + ], + [ + "-2", + "0", + "0", + "1" + ], + [ + "-4", + "1", + "0", + "0" + ] + ], + "scaled_gram": [ + [ + 17, + 0, + 4 + ], + [ + 0, + 80, + 128 + ], + [ + 4, + 128, + 272 + ] + ], + "scaled_characteristic": [ + 1, + -369, + 11344, + -90112 + ], + "squared_norm_interval": [ + "793452303579209723713425/37778931862957161709568", + "6347618428633677789707425/302231454903657293676544" + ], + "norm_interval": [ + "4582849288401/1000000000000", + "2291424644201/500000000000" + ], + "lower_leading_minors": [ + "753312188474817739397009/37778931862957161709568", + "455420642060013524077728125978205554448288735265/1427247692705959881058285969449495136382746624", + "-424702490154796571458106542123957193623947712079/53919893334301279589334030174039261347274288845081144962207220498432" + ], + "upper_leading_minors": [ + "6026497507798541915176097/302231454903657293676544", + "29146921091840865540974871636571703333021391576385/91343852333181432387730302044767688728495783936", + "693451063227545832507263469646162151548876461367777/27606985387162255149739023449108101809804435888681546220650096895197184" + ], + "one_port_squared_gains": [ + "20", + "17/16", + "1", + "1" + ] + }, + "new": { + "matrix": [ + [ + "0", + "1/2", + "1/4", + "1/2", + "1/2", + "1" + ], + [ + "-2", + "-1", + "1/2", + "1", + "1", + "0" + ], + [ + "-4", + "0", + "2", + "2", + "0", + "0" + ] + ], + "scaled_gram": [ + [ + 29, + 10, + 24 + ], + [ + 10, + 116, + 176 + ], + [ + 24, + 176, + 384 + ] + ], + "scaled_characteristic": [ + 1, + -529, + 27392, + -372736 + ], + "squared_norm_interval": [ + "8929481362091204657198675/302231454903657293676544", + "2232370340522801164299675/75557863725914323419136" + ], + "norm_interval": [ + "217421895683/40000000000", + "1358886848019/250000000000" + ], + "lower_leading_minors": [ + "8381686850078325812409939/302231454903657293676544", + "56442667086808018084175419683585697806626972376809/91343852333181432387730302044767688728495783936", + "-1469441290189323471160048277312624688449627636913269/27606985387162255149739023449108101809804435888681546220650096895197184" + ], + "upper_leading_minors": [ + "2095421712519581453102491/75557863725914323419136", + "3527666692925501130260987355208737547312764607449/5708990770823839524233143877797980545530986496", + "4588623841537344079016469760600232754883036954979/431359146674410236714672241392314090778194310760649159697657763987456" + ], + "one_port_squared_gains": [ + "20", + "5/4", + "69/16", + "21/4", + "5/4", + "1" + ] + }, + "difference": { + "matrix": [ + [ + "0", + "1/2", + "1/4", + "1/2", + "1/2", + "1", + "0", + "-1/4", + "-1", + "0" + ], + [ + "-2", + "-1", + "1/2", + "1", + "1", + "0", + "2", + "0", + "0", + "-1" + ], + [ + "-4", + "0", + "2", + "2", + "0", + "0", + "4", + "-1", + "0", + "0" + ] + ], + "scaled_gram": [ + [ + 46, + 10, + 28 + ], + [ + 10, + 196, + 304 + ], + [ + 28, + 304, + 656 + ] + ], + "scaled_characteristic": [ + 1, + -898, + 74468, + -1614336 + ], + "squared_norm_interval": [ + "15269238311600217161008925/302231454903657293676544", + "7634619155800108580504475/151115727451828646838272" + ], + "norm_interval": [ + "3553929923311/500000000000", + "7107859846623/1000000000000" + ], + "lower_leading_minors": [ + "14400322878752202441688861/302231454903657293676544", + "166531456556924276350522147206536264252391658658121/91343852333181432387730302044767688728495783936", + "-2559029315324010966155853383033548883675714057970619/27606985387162255149739023449108101809804435888681546220650096895197184" + ], + "upper_leading_minors": [ + "7200161439376101220844443/151115727451828646838272", + "41632864139231069087630699096795739704458884415449/22835963083295358096932575511191922182123945984", + "330133006759789607683569704264676815566318166078307/3450873173395281893717377931138512726225554486085193277581262111899648" + ], + "one_port_squared_gains": [ + "20", + "5/4", + "69/16", + "21/4", + "5/4", + "1", + "20", + "17/16", + "1", + "1" + ] + } + }, + "native": { + "frames": [ + { + "chart": 265, + "rank": 3, + "columns": 512, + "forward_numerator_sha256": "3ad8b53970c8364022ab4c5539248523d96d5813596e694a4de8d66e1fe0d02d", + "denominator_power": 3 + }, + { + "chart": 751, + "rank": 6, + "columns": 512, + "forward_numerator_sha256": "d89bbfabf4fad5fb941c24af38a61e7c8162f1c899adeed1b9bb741f89c0b7c5", + "denominator_power": 6 + }, + { + "chart": 927, + "rank": 7, + "columns": 512, + "forward_numerator_sha256": "ef97e5d8da1fcbc23b4752b7534545f468214af354aae85ebeb3e722e610ce1a", + "denominator_power": 7 + } + ], + "single_port_full_field_cases": [ + { + "tape": "old", + "active_port": 0, + "squared_output_error": "20", + "output_error_sha256": [ + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d", + "3917680049f7e6b4bc7ca8b0b8ead18041eb99fba7b7d1b1dca391f01fab1225", + "aa3ba3c8d937cd83035677741bec37c5e69959471f9959dff68a5af1b7f3e07f" + ] + }, + { + "tape": "old", + "active_port": 1, + "squared_output_error": "17/16", + "output_error_sha256": [ + "d5c3feea4d2e91246da4c0eb6831bbabbd603c5158040eeb4ee4025b2d2814b4", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d", + "5897b437b937366213232b77f31529fbbab800eefc619232972b197298b67318" + ] + }, + { + "tape": "old", + "active_port": 2, + "squared_output_error": "1", + "output_error_sha256": [ + "1d47836ee0ddd0dce122c55806a7b9fb3f2208605a44dde8d4face52fa2f2684", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d" + ] + }, + { + "tape": "old", + "active_port": 3, + "squared_output_error": "1", + "output_error_sha256": [ + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d", + "b35f4a0956cfb6ab649a010d93cc1d255f02b44f4b96d03b72f14cd6af53fc26", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d" + ] + }, + { + "tape": "new", + "active_port": 0, + "squared_output_error": "20", + "output_error_sha256": [ + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d", + "f577e08c8dc4a79f8b649db940725ecf7a92409bdaad7b0e08d3584428dcb2db", + "bdf4152768769450e0bed8b0d6b69d3fdcc3f832b4edb23880c3dceab05badbe" + ] + }, + { + "tape": "new", + "active_port": 1, + "squared_output_error": "5/4", + "output_error_sha256": [ + "f03724a6493fc2c5fd9f317b95a837667a96bed38b615f85c969f3243387d77f", + "30d57c481c725a3fcf111b0567f9b67bb688b5297e5fa76d627b3437511420d8", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d" + ] + }, + { + "tape": "new", + "active_port": 2, + "squared_output_error": "69/16", + "output_error_sha256": [ + "a56fa794741a6c153fda3932335a21e2333147d29e4638061adc902c69bace68", + "71bdd8c10e614a8705f33a305c44421206535626fe2851f777610281698f6b2c", + "b9253629cfab6dcb3ea01e4a55f717d13a75f3f57d444e8a94f53d5ba49178c5" + ] + }, + { + "tape": "new", + "active_port": 3, + "squared_output_error": "21/4", + "output_error_sha256": [ + "0c0e181c778563176ea6ce2febedc2d5f90c3e34bdd917ebb0c300f78f39000e", + "f22ba74dc5f61aaee245773eb3efced20ce89e8b519a63bc3c783c4bdfe50c17", + "5a970d8be6d28f220e73a4c6c2c8cf78f5ac11fc236555931ae7337ddc81320a" + ] + }, + { + "tape": "new", + "active_port": 4, + "squared_output_error": "5/4", + "output_error_sha256": [ + "5f4cc8f9786ec6ec16de53a1e50e8b4f1c686a1c51cd4d9950473230144b18e1", + "2e51ea84480c7edacc4c4e6c0b25cf0aadb422e2fcc1d8e393f86ce484509dce", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d" + ] + }, + { + "tape": "new", + "active_port": 5, + "squared_output_error": "1", + "output_error_sha256": [ + "a27c52fd6cac2c184eb165fc7b2dc01a171eb7b96253ef60dfa3d75de69e017f", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d", + "7c0a2175670b002957639c784ed41a608e34d78e84a3f930db44026128afc58d" + ] + } + ], + "controls": [ + "omitted x native MOVE residual", + "lost factor two on z native residual", + "wrong global phase on x native MOVE", + "omitted old x exit alignment" + ], + "exact_aligned_output_sha256": [ + "ec3b3bb7cabd7cfb2e3d0bc0783d0baa4f2b10b8f2d47f5357a5128f8c57f95b", + "5a70ed66b5037dac6d6b0225d3cc386ce82462a4fb1384b7b979d5a3dc249536", + "66f21561bd0f9b3e1924afae80b7199fdc96b21ba4a680401fc43a68dadfbf98" + ] + }, + "sharpness_scope": "arbitrary local residual vectors with a joint squared Euclidean budget; floor reachability is not asserted" +} diff --git a/research/current-triangle-native-error/SOURCES.json b/research/current-triangle-native-error/SOURCES.json new file mode 100644 index 0000000000..1611bbf50e --- /dev/null +++ b/research/current-triangle-native-error/SOURCES.json @@ -0,0 +1,42 @@ +{ + "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" + }, + { + "path": "research/owned-ascent-contract/LICENSE", + "usage": "input", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "path": "research/owned-ascent-contract/NOTICE", + "usage": "input", + "git_blob": "3afd187f227f5c536e30aa305afc46b9e2358522", + "sha256": "a68ca5d276b58e273558efe3a8ee9c06fea0fc3cfb35628bd0d5d868ecc98629" + }, + { + "path": "research/owned-ascent-contract/README.md", + "usage": "input", + "git_blob": "2549ca4f706befcd855e7676f63c844013521a0c", + "sha256": "d135eeb7d5ee767ee40da014810c63e98e21d005c7f9c2eb80c35cd2155fe85a" + }, + { + "path": "research/owned-ascent-contract/independent.py", + "usage": "input", + "git_blob": "abfe09abd22a929fae4a6d5a7520bd83856d48b0", + "sha256": "927b865e043c17abeb4017985432d0c8c38812237259c75ca59aac5be6a03bb5" + } + ] +} diff --git a/research/current-triangle-native-error/TASK.json b/research/current-triangle-native-error/TASK.json new file mode 100644 index 0000000000..eea746c83f --- /dev/null +++ b/research/current-triangle-native-error/TASK.json @@ -0,0 +1,83 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Can one of the selected record's five inherited assumptions be proved at its actual caller?", + "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": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "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 assumption ID (native_all_columns, owned_erasure, compiler, precision_tape, analytic_recovery), one quantified implication and exact dependency closure. Check current handoffs, including #5625 row reentry and #5707 root-prefix lowering, without treating their partial scope as the whole theorem. Prove or falsify that implication with a caller-bound argument; stop at the chosen obligation. Finite tests or root digits do not discharge an all-size statement.", + "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": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "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": "Complete six-site native/scalar residual operator for the literal PR7669 triangle, with actual exit-chart alignment and exact induced norm.", + "scope_change_reason": "Resolve the transport limit in PR7671 while leaving actual quantizer, reachable-grid and signed-range work to the source contributor.", + "bottleneck_link": "Supply a complete local precision inequality with every native MOVE error charged; it can consume actual per-site allowances once those are proved.", + "budget_minutes": 60, + "stop_rule": "Stop at the local residual operator, exact norm certificate, tensor/spectator proof and bounded native checks. Do not claim a full rounded caller or physical tariff.", + "outcome": "partial", + "evidence": "PROOF.md; RESULT.json; literal formal residual derivation; exact rational spectral brackets; 1536 native columns; ten full-field residual checks and four semantic faults.", + "author": "Ali Romman", + "ai_assistance": "Substantial OpenAI Codex assistance for design, proof, implementation, verification and publication.", + "open_questions": [ + { + "question": "What native residual allowances and scalar grids are reachable at the six sites?", + "why_it_matters": "The local propagation bound takes those allowances as inputs and cannot establish the whole caller by itself.", + "first_step": "Consume the source contributor's transport-aware quantizer/reachability result, then include preceding and following caller error.", + "blocked_by": "Actual native quantizers, reachable grids, signed range and a complete physical tariff." + } + ] +} diff --git a/research/current-triangle-native-error/VENDORED.json b/research/current-triangle-native-error/VENDORED.json new file mode 100644 index 0000000000..79b3d17c1b --- /dev/null +++ b/research/current-triangle-native-error/VENDORED.json @@ -0,0 +1,60 @@ +{ + "files": [ + { + "path": "source/README.md", + "repository": "SYLforge/integer-mult-bounds", + "commit": "95d476623f1468822057554475dc8badb19bfa44", + "source_path": "research/ee251f60-composition/README.md", + "git_blob": "e3a5a57c053c41fa40150fc8b985ec2542323e78", + "sha256": "fe62fab887429a1daae72d9ef333a68b2d1e61fdaaf326ce5ffb39adc22382e4" + }, + { + "path": "source/PROVENANCE.md", + "repository": "SYLforge/integer-mult-bounds", + "commit": "95d476623f1468822057554475dc8badb19bfa44", + "source_path": "research/ee251f60-composition/PROVENANCE.md", + "git_blob": "f45da332072bd4044ceb7c9a752bc64caefdcc96", + "sha256": "f36ca952da2b24573f2e95ce2490b25b6d0dff9a35557305e4123d16a1ec2e56" + }, + { + "path": "source/EDIT.json", + "repository": "SYLforge/integer-mult-bounds", + "commit": "95d476623f1468822057554475dc8badb19bfa44", + "source_path": "research/ee251f60-composition/EDIT.json", + "git_blob": "23368c8750e6d981ee10664187c6a2c3859be542", + "sha256": "05b84f9578fddc7adc7805f20afdfe5ea679d298b2232d7f718193185f471656" + }, + { + "path": "source/evidence/BUILD.json", + "repository": "SYLforge/integer-mult-bounds", + "commit": "95d476623f1468822057554475dc8badb19bfa44", + "source_path": "research/ee251f60-composition/evidence/BUILD.json", + "git_blob": "17471691487841800604f97706ada2d3ca253b49", + "sha256": "4744201691120223ded62a3e0d55ea1029203f3ea996305163e7db8d9e3679a4" + }, + { + "path": "source/data/K372-2-WORD.json.gz", + "repository": "SYLforge/integer-mult-bounds", + "commit": "95d476623f1468822057554475dc8badb19bfa44", + "source_path": "research/ee251f60-composition/data/K372-2-WORD.json.gz", + "git_blob": "1273c83178693e1627a2324680907f9b0e95e995", + "sha256": "631babeca90e78c5caac713484fe618328b9beee8294baef6ac45ffc9a75dd3b" + }, + { + "path": "source/LICENSE", + "repository": "SYLforge/integer-mult-bounds", + "commit": "95d476623f1468822057554475dc8badb19bfa44", + "source_path": "research/ee251f60-composition/LICENSE", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "path": "scalar_source.py", + "repository": "aliromman/integer-mult-bounds", + "commit": "f34696319eb19d05d1b09f7372c3146be3ea1635", + "source_path": "research/current-triangle-rounded-contract/verify.py", + "git_blob": "c5a4d7965158e647fe78a6e0105f2009664aefd2", + "sha256": "c57280544a9eb898caecf2afd5a6ab1b25ab5856d0201c74dd5a9425a1e8f063" + } + ] +} diff --git a/research/current-triangle-native-error/VERIFY.json b/research/current-triangle-native-error/VERIFY.json new file mode 100644 index 0000000000..a16a351f64 --- /dev/null +++ b/research/current-triangle-native-error/VERIFY.json @@ -0,0 +1,33 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/owned-ascent-contract/LICENSE", + "research/owned-ascent-contract/NOTICE", + "research/owned-ascent-contract/README.md", + "research/owned-ascent-contract/independent.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 300, + "checks": "Complete source binding, all local native/scalar residuals, exact induced norm certificates, 1536 actual frame columns, ten full-field error ports and four semantic faults." + }, + { + "argv": [ + "{python}", + "-B", + "-O", + "{package}/verify.py" + ], + "timeout_seconds": 300, + "checks": "Complete source binding, all local native/scalar residuals, exact induced norm certificates, 1536 actual frame columns, ten full-field error ports and four semantic faults." + } + ] +} diff --git a/research/current-triangle-native-error/error_operator.py b/research/current-triangle-native-error/error_operator.py new file mode 100644 index 0000000000..dca1f8ed51 --- /dev/null +++ b/research/current-triangle-native-error/error_operator.py @@ -0,0 +1,96 @@ +"""Derive every scalar and native residual from the literal local tapes.""" +from fractions import Fraction as F +from math import isqrt + +ROLES = (236, 544, 1000) +INITIAL = {236: 265, 544: 751, 1000: 265} +OLD = [[F(0), F(1, 4), F(1), F(0)], + [F(-2), F(0), F(0), F(1)], [F(-4), F(1), F(0), F(0)]] +NEW = [[F(0), F(1, 2), F(1, 4), F(1, 2), F(1, 2), F(1)], + [F(-2), F(-1), F(1, 2), F(1), F(1), F(0)], + [F(-4), F(0), F(2), F(2), F(0), F(0)]] + + +def need(ok, reason): + if not ok: + raise ValueError(reason) + + +def ports(events, clock): + return [{'offset': i, 'clock': clock + i, 'kind': event[0], 'role': event[1], + 'frame': event[3] if event[0] == 'MOVE' else event[-1]} + for i, event in enumerate(events) + if event[0] == 'MOVE' or F(event[3]).denominator != 1] + + +def derive(events, clock): + sites = ports(events, clock) + at = {row['offset']: i for i, row in enumerate(sites)} + current = dict(INITIAL) + rows = {role: [F(0)] * len(sites) for role in ROLES} + for i, event in enumerate(events): + op, role = event[:2] + if op == 'MOVE': + need(current[role] == event[2] and event[4] is False, 'literal native source chart') + current[role] = event[3] + else: + need(op == 'ADD' and current[role] == current[event[2]] == event[-1], 'literal scalar common chart') + q = F(event[3]) + rows[role] = [a + q * b for a, b in zip(rows[role], rows[event[2]], strict=True)] + if i in at: + rows[role][at[i]] += 1 + return [rows[role] for role in ROLES], sites, [current[role] for role in ROLES] + + +def gram(matrix): + return [[sum(a * b for a, b in zip(row, other, strict=True)) for other in matrix] for row in matrix] + + +def determinant(a): + return (a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + - a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) + + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0])) + + +def minors(matrix, value): + a = [[int(i == j) * value - matrix[i][j] for j in range(3)] for i in range(3)] + return [a[0][0], a[0][0] * a[1][1] - a[0][1] * a[1][0], determinant(a)] + + +def spectral_certificate(matrix): + g = gram(matrix) + scaled = [[16 * x for x in row] for row in g] + need(all(x.denominator == 1 for row in scaled for x in row), 'integral scaled Gram matrix') + scaled = [[int(x) for x in row] for row in scaled] + trace = sum(scaled[i][i] for i in range(3)) + second = sum(scaled[i][i] * scaled[j][j] - scaled[i][j] * scaled[j][i] + for i in range(3) for j in range(i + 1, 3)) + polynomial = [1, -trace, second, -determinant(scaled)] + lo, hi = F(0), F(100) + need(all(x > 0 for x in minors(g, hi)), 'initial positive definite upper bound') + for _ in range(80): + mid = (lo + hi) / 2 + if all(x > 0 for x in minors(g, mid)): + hi = mid + else: + lo = mid + low, high = minors(g, lo), minors(g, hi) + need(low[0] > 0 and low[1] > 0 and low[2] < 0 and all(x > 0 for x in high), 'strict largest-eigenvalue bracket') + need(hi - lo < F(1, 10 ** 20), 'rational eigenvalue interval width') + scale = 10 ** 12 + norm_lo = F(isqrt(lo.numerator * scale ** 2 // lo.denominator), scale) + norm_hi = F(isqrt(hi.numerator * scale ** 2 // hi.denominator) + 1, scale) + need(norm_lo ** 2 <= lo and norm_hi ** 2 > hi, 'exact square-root bracket') + # A second calculation checks det(tI-16G) without the minor formula. + for t in range(-2, 6): + literal = determinant([[int(i == j) * t - scaled[i][j] for j in range(3)] for i in range(3)]) + value = 0 + for coefficient in polynomial: + value = value * t + coefficient + need(literal == value, 'characteristic polynomial coefficients') + return {'matrix': [[str(x) for x in row] for row in matrix], + 'scaled_gram': scaled, 'scaled_characteristic': polynomial, + 'squared_norm_interval': [str(lo), str(hi)], + 'norm_interval': [str(norm_lo), str(norm_hi)], + 'lower_leading_minors': list(map(str, low)), 'upper_leading_minors': list(map(str, high)), + 'one_port_squared_gains': [str(sum(row[j] ** 2 for row in matrix)) for j in range(len(matrix[0]))]} diff --git a/research/current-triangle-native-error/scalar_source.py b/research/current-triangle-native-error/scalar_source.py new file mode 100644 index 0000000000..c5a4d79651 --- /dev/null +++ b/research/current-triangle-native-error/scalar_source.py @@ -0,0 +1,193 @@ +#!/usr/bin/env python3 +"""Check the exact rounded scalar law of the pinned three-field repair.""" +from fractions import Fraction as F +from hashlib import sha1, sha256 +from itertools import product +import gzip +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROLES = (236, 544, 1000) +SOURCE = '3dd1199d95291ee96e6c0aeb6f55f86244a569b1d4975840bf0207e2dcf9c025' +CANDIDATE = 'ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d' +MATRIX = ((F(0), F(1, 2), F(1, 4)), (F(-2), F(1), F(0)), (F(-4), F(2), F(1))) +PERIODS = ((1, 0, 0), (0, 2, 0), (0, 0, 4)) + + +def need(ok, reason): + if not ok: + raise ValueError(reason) + + +def encoded(value): + return json.dumps(value, sort_keys=True, separators=(',', ':')).encode() + + +def sources(): + for row in json.loads((HERE / 'VENDORED.json').read_text())['files']: + raw = (HERE / row['path']).read_bytes() + need(sha256(raw).hexdigest() == row['sha256'], 'copied source hash') + need(sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() == row['git_blob'], 'copied source Git blob') + old = json.loads(gzip.decompress((HERE / 'source/data/K372-2-WORD.json.gz').read_bytes())) + edit = json.loads((HERE / 'source/EDIT.json').read_text()) + need(sha256(encoded(old)).hexdigest() == SOURCE == edit['source'], 'complete source identity') + cursor, program = 0, [] + for block in edit['edits']: + start, stop = block['start'], block['stop'] + need(cursor <= start <= stop <= len(old['program']), 'ordered source edit') + need(old['program'][start:stop] == block['before'], 'exact edit preimage') + program.extend(old['program'][cursor:start]) + program.extend(block['after']) + cursor = stop + program.extend(old['program'][cursor:]) + new = dict(old, program=program) + need(sha256(encoded(new)).hexdigest() == CANDIDATE == edit['candidate'], 'complete candidate identity') + before, after = old['program'][97747:97753], program[97842:97851] + build = json.loads((HERE / 'source/evidence/BUILD.json').read_text()) + need(before == build['old_local_events'] and after == build['replacement_local_events'], 'literal local source tapes') + next_event = ['ADD', 544, 972, '1/2', 927] + need(old['program'][97753] == program[97851] == next_event, 'first later external operand') + need([[str(x) for x in row] for row in MATRIX] == build['exact_local_matrix'], 'source rational matrix') + return before, after, {'source_sha256': SOURCE, 'candidate_sha256': CANDIDATE, + 'source_window': [97747, 97753], 'candidate_window': [97842, 97851], + 'first_later_event': next_event, + 'frames': {str(k): old['frames'][k] for k in (265, 751, 927)}, + 'old_events': before, 'new_events': after} + + +def core(events): + result = [] + for event in events: + need(event[0] in ('ADD', 'MOVE'), 'scalar core operation') + need(event[1] in ROLES, 'local output role') + if event[0] == 'ADD': + need(event[2] in ROLES, 'local input role') + result.append((ROLES.index(event[1]), ROLES.index(event[2]), F(event[3]))) + return result + + +def rational_run(tape, point, mode='exact'): + state = list(map(F, point)) + exact = True + for dest, source, coefficient in tape: + value = state[dest] + coefficient * state[source] + exact &= value.denominator == 1 + if mode == 'floor': + value = F(value.numerator // value.denominator) + elif mode == 'truncate': + value = F(int(value)) + state[dest] = value + return tuple(state), exact + + +def integer_run(tape, point): + state = list(point) + for dest, source, coefficient in tape: + state[dest] += coefficient.numerator * state[source] // coefficient.denominator + return tuple(state) + + +def expected(point): + x, y, z = point + old = ((2 * y + z) // 4, y - 2 * x, z + 2 * y - 4 * x) + h = (z % 4) // 2 + new = (old[0], old[1] + h, old[2] + 2 * h) + return old, new + + +def matrix(tape): + columns = [rational_run(tape, [int(i == j) for i in range(3)])[0] for j in range(3)] + return tuple(tuple(columns[j][i] for j in range(3)) for i in range(3)) + + +def squared(values): + return sum(x * x for x in values) + + +def verify_point(old, new, point): + a, exact_a = rational_run(old, point, 'floor') + b, exact_b = rational_run(new, point, 'floor') + need((a, b) == expected(point), 'complete rounded residue law') + need(a == integer_run(old, point) and b == integer_run(new, point), 'independent integer arithmetic') + x, y, z = point + need(exact_a == ((2 * y + z) % 4 == 0), 'old exactness lattice') + need(exact_b == (z % 4 == 0 and y % 2 == 0), 'new exactness lattice') + exact = tuple(sum(row[i] * point[i] for i in range(3)) for row in MATRIX) + old_error = squared([a[i] - exact[i] for i in range(3)]) + new_error = squared([b[i] - exact[i] for i in range(3)]) + difference = squared([a[i] - b[i] for i in range(3)]) + need(old_error <= F(9, 16) and new_error <= F(89, 16) and difference <= 5, 'sharp local error bounds') + return {'input': list(point), 'old': list(map(int, a)), 'new': list(map(int, b)), + 'old_exact': exact_a, 'new_exact': exact_b, + 'squared_old_error': str(old_error), 'squared_new_error': str(new_error), + 'squared_difference': str(difference)} + + +def controls(old, new): + results = [] + for label, index, coefficient in [('wrong first quarter', 0, F(1, 2)), + ('wrong middle sign', 3, F(-2)), + ('wrong final half', 5, F(-1, 2))]: + changed = list(new) + dest, source, _ = changed[index] + changed[index] = (dest, source, coefficient) + need(matrix(changed) != MATRIX, 'arithmetic mutation changes matrix') + witness = next((point for point in product(range(-2, 3), repeat=3) + if rational_run(changed, point, 'floor')[0] != expected(point)[1]), None) + need(witness is not None, 'actual arithmetic mutation detected') + results.append({'fault': label, 'witness': list(witness)}) + witness = next((point for point in product(range(-2, 3), repeat=3) + if rational_run(new, point, 'truncate')[0] != expected(point)[1]), None) + need(witness is not None, 'signed truncation differs from floor') + results.append({'fault': 'truncate signed fractions toward zero', 'witness': list(witness)}) + need(rational_run(old, (0, 1, 2), 'floor')[0] != rational_run(new, (0, 1, 2), 'floor')[0], 'exact matrix does not imply rounded equality') + return results + + +def main(): + before, after, binding = sources() + old, new = core(before), core(after) + need(len(old) == 3 and len(new) == 6 and matrix(old) == matrix(new) == MATRIX, 'exact rational identity') + prefixes = [] + for name, tape in [('old', old), ('new', new)]: + for length in range(len(tape) + 1): + shifts = [rational_run(tape[:length], period)[0] for period in PERIODS] + need(all(x.denominator == 1 for shift in shifts for x in shift), 'every prefix has integral period shifts') + prefixes.append({'tape': name, 'prefix_length': length, 'shifts': [list(map(int, shift)) for shift in shifts]}) + residues = [verify_point(old, new, (0, y, z)) for y in range(2) for z in range(4)] + for point in product(range(-9, 10), repeat=3): + verify_point(old, new, point) + need(max(F(row['squared_old_error']) for row in residues) == F(9, 16), 'old bound attained') + need(max(F(row['squared_new_error']) for row in residues) == F(89, 16), 'new bound attained') + need(max(F(row['squared_difference']) for row in residues) == 5, 'difference bound attained') + need(sum(row['old_exact'] for row in residues) == 2 and sum(row['new_exact'] for row in residues) == 1, 'exactness indices four and eight') + paths = [] + for point in ((0, 1, 2), (0, 0, 3)): + for name, tape in [('old', old), ('new', new)]: + states = [list(map(int, rational_run(tape[:i], point, 'floor')[0])) for i in range(len(tape) + 1)] + need(all(-8 <= value <= 7 for state in states for value in state), 'four-bit witness has no stored overflow') + paths.append({'input': list(point), 'tape': name, 'states': states}) + result = {'binding': binding, 'scope': 'common-coordinate scalar core; native MOVE transports are not rounded here', + 'matrix': [[str(x) for x in row] for row in MATRIX], + 'period_generators': PERIODS, 'integral_prefix_shifts': prefixes, + 'residues': residues, 'signed_box_cases': 19 ** 3, + 'four_bit_paths': paths, + 'old_exact_new_inexact': verify_point(old, new, (0, 1, 2)), + 'worst_new_error': verify_point(old, new, (0, 0, 3)), + 'controls': controls(old, new)} + file = HERE / 'RESULT.json' + if sys.argv[1:] == ['--write']: + need(not file.exists(), 'do not replace checked receipt') + file.write_text(json.dumps(result, indent=2) + '\n') + else: + need(not sys.argv[1:], 'unexpected arguments') + need(encoded(result) == encoded(json.loads(file.read_text())), 'complete result receipt') + print('PASS_CURRENT_TRIANGLE_ROUNDED_CONTRACT ' + json.dumps({'residues': 8, 'signed_cases': 19 ** 3, + 'old_exactness_index': 4, 'new_exactness_index': 8, 'new_squared_error': '89/16', + 'squared_difference': 5, 'controls': len(result['controls'])}, sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/current-triangle-native-error/source/EDIT.json b/research/current-triangle-native-error/source/EDIT.json new file mode 100644 index 0000000000..23368c8750 --- /dev/null +++ b/research/current-triangle-native-error/source/EDIT.json @@ -0,0 +1,979 @@ +{ + "schema": "source-bound-exact-event-edit/v1", + "source": "3dd1199d95291ee96e6c0aeb6f55f86244a569b1d4975840bf0207e2dcf9c025", + "candidate": "ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d", + "unchanged_headers": true, + "edits": [ + { + "start": 0, + "stop": 0, + "before": [], + "after": [ + [ + "ADD", + 112, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 113, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 114, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 116, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 117, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 118, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 119, + 607, + "1/2", + 3 + ], + [ + "ADD", + 120, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 122, + 607, + "1/2", + 3 + ], + [ + "ADD", + 123, + 607, + "1/2", + 3 + ], + [ + "ADD", + 137, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 138, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 139, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 140, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 141, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 142, + 607, + "-1", + 3 + ], + [ + "ADD", + 169, + 607, + "1/2", + 3 + ], + [ + "ADD", + 170, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 171, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 172, + 607, + "-1", + 3 + ], + [ + "ADD", + 173, + 607, + "1/4", + 3 + ], + [ + "ADD", + 174, + 607, + "1/2", + 3 + ], + [ + "ADD", + 175, + 607, + "1/2", + 3 + ], + [ + "ADD", + 176, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 177, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 178, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 179, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 180, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 181, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 182, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 183, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 184, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 185, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 186, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 187, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 191, + 607, + "1/2", + 3 + ], + [ + "ADD", + 192, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 193, + 607, + "1/2", + 3 + ], + [ + "ADD", + 194, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 195, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 196, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 198, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 199, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 200, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 201, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 202, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 203, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 204, + 607, + "1/2", + 3 + ], + [ + "ADD", + 206, + 607, + "1/2", + 3 + ], + [ + "ADD", + 207, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 208, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 209, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 228, + 607, + "1/4", + 3 + ], + [ + "ADD", + 236, + 607, + "1/4", + 3 + ], + [ + "ADD", + 255, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 272, + 607, + "1/4", + 3 + ], + [ + "ADD", + 279, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 306, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 311, + 607, + "-1", + 3 + ], + [ + "ADD", + 313, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 316, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 336, + 607, + "1/4", + 3 + ], + [ + "ADD", + 347, + 607, + "1/4", + 3 + ], + [ + "ADD", + 351, + 607, + "1/4", + 3 + ], + [ + "ADD", + 436, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 437, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 438, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 439, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 522, + 607, + "1", + 3 + ], + [ + "ADD", + 530, + 607, + "1", + 3 + ], + [ + "ADD", + 536, + 607, + "1/4", + 3 + ], + [ + "ADD", + 599, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 600, + 607, + "1/4", + 3 + ], + [ + "ADD", + 609, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 611, + 607, + "1/4", + 3 + ], + [ + "ADD", + 617, + 607, + "1/4", + 3 + ], + [ + "ADD", + 625, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 627, + 607, + "1/4", + 3 + ], + [ + "ADD", + 635, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 640, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 655, + 607, + "1/4", + 3 + ], + [ + "ADD", + 697, + 607, + "-1/4", + 3 + ], + [ + "ADD", + 752, + 607, + "17/8", + 3 + ], + [ + "ADD", + 812, + 607, + "1/2", + 3 + ], + [ + "ADD", + 1079, + 607, + "1/2", + 3 + ], + [ + "ADD", + 1122, + 607, + "-1", + 3 + ], + [ + "ADD", + 1176, + 607, + "-1/4", + 3 + ], + [ + "ADD", + 1228, + 607, + "1/8", + 3 + ], + [ + "ADD", + 1233, + 607, + "1/8", + 3 + ], + [ + "ADD", + 1234, + 607, + "1/4", + 3 + ], + [ + "ADD", + 1255, + 607, + "1/4", + 3 + ], + [ + "ADD", + 1265, + 607, + "-1/2", + 3 + ], + [ + "ADD", + 1279, + 607, + "1/8", + 3 + ], + [ + "ADD", + 1331, + 607, + "-1/2", + 3 + ] + ] + }, + { + "start": 87321, + "stop": 87321, + "before": [], + "after": [ + [ + "INIT", + 1551, + 115 + ], + [ + "ADD", + 1551, + 770, + "1", + 115 + ] + ] + }, + { + "start": 96905, + "stop": 96905, + "before": [], + "after": [ + [ + "ADD", + 1279, + 1551, + "-1", + 115 + ] + ] + }, + { + "start": 96959, + "stop": 96961, + "before": [ + [ + "MOVE", + 1517, + 549, + 115, + true + ], + [ + "ADD", + 1517, + 1518, + "1/4", + 115 + ] + ], + "after": [ + [ + "MOVE", + 1517, + 549, + 593, + true + ] + ] + }, + { + "start": 96963, + "stop": 96964, + "before": [ + [ + "MOVE", + 1517, + 115, + 593, + true + ] + ], + "after": [] + }, + { + "start": 97747, + "stop": 97749, + "before": [ + [ + "MOVE", + 236, + 265, + 751, + false + ], + [ + "ADD", + 544, + 236, + "-2", + 751 + ] + ], + "after": [ + [ + "ADD", + 236, + 1000, + "1/4", + 265 + ], + [ + "ADD", + 1000, + 236, + "-2", + 265 + ], + [ + "MOVE", + 236, + 265, + 927, + false + ] + ] + }, + { + "start": 97750, + "stop": 97750, + "before": [], + "after": [ + [ + "ADD", + 544, + 1000, + "1/2", + 751 + ] + ] + }, + { + "start": 97751, + "stop": 97752, + "before": [ + [ + "ADD", + 236, + 1000, + "1/4", + 751 + ] + ], + "after": [] + }, + { + "start": 97753, + "stop": 97753, + "before": [], + "after": [ + [ + "ADD", + 544, + 236, + "-1", + 927 + ], + [ + "ADD", + 236, + 544, + "1/2", + 927 + ] + ] + }, + { + "start": 99687, + "stop": 99687, + "before": [], + "after": [ + [ + "ADD", + 614, + 1551, + "1", + 115 + ] + ] + }, + { + "start": 100116, + "stop": 100117, + "before": [ + [ + "MOVE", + 236, + 751, + 127, + false + ] + ], + "after": [ + [ + "MOVE", + 236, + 927, + 127, + false + ] + ] + }, + { + "start": 150409, + "stop": 150409, + "before": [], + "after": [ + [ + "ADD", + 278, + 770, + "1/2", + 127 + ], + [ + "ADD", + 566, + 770, + "1", + 127 + ], + [ + "ADD", + 567, + 770, + "1/2", + 127 + ], + [ + "ADD", + 612, + 770, + "1", + 127 + ], + [ + "ADD", + 613, + 770, + "1", + 127 + ], + [ + "ADD", + 614, + 770, + "1", + 127 + ], + [ + "ADD", + 1078, + 770, + "1/2", + 127 + ], + [ + "ADD", + 1204, + 770, + "-1/4", + 127 + ], + [ + "ADD", + 1259, + 770, + "-1/4", + 127 + ], + [ + "ADD", + 1280, + 770, + "1", + 127 + ], + [ + "ADD", + 1368, + 770, + "1", + 127 + ], + [ + "ADD", + 1374, + 770, + "2", + 127 + ], + [ + "SCALE", + 770, + "-1", + 127 + ], + [ + "CLEAR", + 1551, + 115 + ] + ] + } + ] +} diff --git a/research/current-triangle-native-error/source/LICENSE b/research/current-triangle-native-error/source/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/current-triangle-native-error/source/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/current-triangle-native-error/source/PROVENANCE.md b/research/current-triangle-native-error/source/PROVENANCE.md new file mode 100644 index 0000000000..f45da33207 --- /dev/null +++ b/research/current-triangle-native-error/source/PROVENANCE.md @@ -0,0 +1,29 @@ +# Provenance, credit and scope + +This is a cumulative contribution. Thank you to everyone who has made their constructions, exact inputs, failure cases and careful reviews available. Those contributions made this composition possible; the small increment here should not obscure the much larger body of work it rests on. We aim to leave equally inspectable material for the next researcher. + +## Direct lineage and reused methods + +- **SYLforge, #7637:** the H5B frame-restored233-CLEAR construction is the published ancestor of this research. The present Mac K372-2 source retains its descendants rather than starting a new independent construction. [PR7637](https://github.com/CrocSwap/integer-mult-bounds/pull/7637). +- **DreamingOfClouds, #7641 and #7658:** #7641 combines20 edits over #7637. #7658 supplies the large-neighbourhood construction and its exact joint hub reconstruction: helper360/537 SWAP-NULL relabel, main176 bypass, helper236 contact re-chart, helper370 last-stay removal and helper461 first-stay removal. The source explicitly credits its #7630/#7636 relabel lineage and #7634 swap law. Our source descends from this word; those gains are not claimed as new work here. [PR7641](https://github.com/CrocSwap/integer-mult-bounds/pull/7641), [PR7658](https://github.com/CrocSwap/integer-mult-bounds/pull/7658). +- **Clear1nsight:** the contact re-chart type from #7612 and the24-bit coefficient-splitting report are part of the construction's lineage. #7626 contributed source isolation/portable materialization, and #7631/#7633 are credited by the parent lineage. #7660 separately published the role379 shortcut already present in our source; we do not count its rediscovery as another improvement. [PR7612](https://github.com/CrocSwap/integer-mult-bounds/pull/7612), [coefficient report](https://github.com/CrocSwap/integer-mult-bounds/discussions/7111#discussioncomment-19691406), [PR7660](https://github.com/CrocSwap/integer-mult-bounds/pull/7660). +- **ToikY, #7643:** the contact re-chart work is explicitly credited by #7658 alongside Clear1nsight's #7612. Its74-erasure contract and κ are not added to this candidate. No shared CI repair is copied by this PR. [PR7643](https://github.com/CrocSwap/integer-mult-bounds/pull/7643). +- **Rohan Arun, #7113:** the signed caller/accounting lineage underlies the actual16-call composition. Its original source commit is07a76c5e2738882c0cb322278e56f6cae3c9885d. We recount the literal16-call input here; we do not substitute historical17-call constants. [PR7113](https://github.com/CrocSwap/integer-mult-bounds/pull/7113). +- **Ali Romman and upstream contributors:** #7605 supplies an earlier exact protected/application checkpoint cited by the #7637 lineage. The two unmodified directed invoice comparison files are copied from canonical upstream base e54523517d0f03e58352e647c403a5af3e525a57, retaining their attribution and Apache-2.0 headers. Their arithmetic is not a full scientific acceptance gate. [PR7605](https://github.com/CrocSwap/integer-mult-bounds/pull/7605). +- **CubeJerry, Douglas Colkitt and the earlier source contributors:** the retained framework, primitive/service work and repository infrastructure form part of the inherited basis. This package does not claim that their open supplier obligations are resolved by a successful finite replay. + +## What this contribution adds + +The Mac branch supplied K372-2's five EARLY edits (1188,1013,940,1141,1195, with940/1141 sharing one ADD). The5080 branch recomputed the1517/770 bypass on that actual source and combined it with a three-field triangle repair. The new contribution is their compatible composition, exact12-block edit, final235 CLEAR witnesses and a small reproducible publication package. The two machines are work environments of the same user, not unnamed independent human contributors. Substantial OpenAI Codex assistance was used for research and packaging. New work is Apache-2.0. + +Exact source canonical:3dd1199d95291ee96e6c0aeb6f55f86244a569b1d4975840bf0207e2dcf9c025. Exact candidate canonical:ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d. Byte hashes are in MANIFEST.json. The12 edit blocks specify every changed event and leave all other fields unchanged. The parent research generators are not silently imported; this publication uses the transparent exact edit as its deterministic reconstruction recipe. + +## Related work, not automatically incorporated + +Ali Romman's #7662 studies one half-ADD rounding-error propagation with CubeJerry's service contract. Nick Petalas's #7654 provides a scoped minimal-rank interpolation result used as background when assessing structural repairs. Neither is a substitute for this candidate's entire rounded caller or physical supply proof. Their actual domains and assumptions must be checked before application. [PR7662](https://github.com/CrocSwap/integer-mult-bounds/pull/7662), [PR7654](https://github.com/CrocSwap/integer-mult-bounds/pull/7654). + +At the publication checkpoint, upstream main remained e54523517d0f03e58352e647c403a5af3e525a57. Ali Romman's #7663 uses a separate17-call full-private-bank model and changed helper endpoints; Clear1nsight's #7664 concerns180erasures/17calls; #7666 charges bank selection and return without claiming a new κ. K372-4 is later, separate research with changed helper-boundary conditions. None is silently folded into ee251f60 or used to assert identical physical assumptions. This is not a claim to the greatest bound across all models. + +## Fresh versus reused evidence + +Publication replay freshly reconstructs the whole word, runs exact rows/CLEAR, recounts native/caller histograms and checks the four directed price points. Normal, optimized Python and a Git-free committed-byte export were tested. The recorded ordinary/precision/native-phase/owner evidence retains its narrower scope and original source identifiers; it is not advertised as freshly rerun. No selected record, frozen predecessor package or common verifier is changed. diff --git a/research/current-triangle-native-error/source/README.md b/research/current-triangle-native-error/source/README.md new file mode 100644 index 0000000000..e3a5a57c05 --- /dev/null +++ b/research/current-triangle-native-error/source/README.md @@ -0,0 +1,44 @@ +# K372-2 / 5080 composition: conditional κ ≥ 0.0037218793483 + +This is the exact **ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d** candidate, not the later K372-4 research. The declared 16-call invoice has a directed 256-bit crossing in **(0.0037218793483, 0.0037218793484)**. It is cheaper at κ=.00372, not at .00374. This is a conditional computational research contribution, not a complete multiplication theorem or a change to the selected frontier. + +## Change + +The supplied predecessor is Mac K372-2, canonical `3dd1199d95291ee96e6c0aeb6f55f86244a569b1d4975840bf0207e2dcf9c025`, retaining five EARLY edits. The 5080 combination adds: + +1. Owned role 1517 goes directly 549→593 instead of 549→115→593. The actual Mac source row is (input770−input607)/4. A new lifetime of role1551 at chart115 preserves input770; G/F boundary corrections and corrections at roles1279/614 restore the required operator. See `evidence/ROLE770-BUILD.json` and `ROLE770-PROBE.json` for measured rows, coefficients, chronology and the source-bound recipe. +2. The Mac 940/1141 edits share `236 += 1000/4`, which conflicts with simply inserting the earlier 5080 swap. With x=236,y=544,z=1000, the new sequence uses `x+=z/4; z-=2x` at265, `y+=z/2; z+=2y` at751, and `y-=x; x+=y/2` at927. The three values are restored at the local boundary. This costs three additional ADDs and changes two MOVE routes. `evidence/BUILD.json` gives both local tapes and their exact matrix. + +`EDIT.json` is the complete, readable source-bound edit: 12 blocks, seven removed events and120 inserted events, net113. All non-program fields are unchanged. It is a reconstruction recipe for this published candidate, not a new optimization search or a requirement for other researchers. `replay.py` applies the exact preimages and independently checks the resulting complete operator. The earlier exploratory search code is deliberately not bundled; the exact edit, input, certificates and scoped replay are self-contained. + +## Reproduce from a fresh directory + +Python3.12+ standard library; no installation or network needed. From this directory: + +```sh +python -I -B replay.py --out /path/to/a/new/output-directory +``` + +The output path must not already exist. Expected: `PASS_SCOPED_EE251F60_REPLAY`. The run reconstructs the candidate, freshly checks all public rows and every CLEAR, recounts the actual native/caller paid and target histograms, and executes the unchanged project price CLI at four points. It also rejects a changed predecessor, a wrong patch preimage, and an actual arithmetic sign mutation. All source/input bytes are checked before and after. Regenerated gzip container bytes are not the mathematical identity: the complete canonical JSON is compared. + +`src/integer_grid_audit.py` is our separately written exact integer interpreter. It does not import, change, or claim a pass from the original frozen checker. `src/ordinary_tape_audit.py` is reused only for its metadata inventory and literal invoice-count functions; its full ordinary/admission entry point is not run. The two project price files are unmodified copies of base e54523517d0f03e58352e647c403a5af3e525a57. Price success validates declared invoice arithmetic, not a circuit or physical supplier. + +## Evidence and scope + +The candidate has150,522 events:139,735 ADD,4,160 SCALE,6,157 MOVE and235 INIT/CLEAR each. It uses53 of68 reserved labels, peak51 concurrent owned lifetimes. The exact finite check covers1,501 public output rows and235 CLEARs (1,135 witness terms;42 are zero rows). It checks live sources, headers, frame containment, COPY-zero and exact divisions on supplied grid225·2^40; observed minimum denominators were225·2^14 and maximum reduced row numerator20bits. + +Recorded results in `evidence/` are explicitly distinguished from fresh replay. The prior ordinary substitution is raw730,213,664/signed733,928,608, and precision majorant context1324/height339/mass662. The prior16-call phase/owner/occurrence binding and three identical ordered-basis512-forward/512-adjoint/Pauli/phase measurements are reused under their recorded source bindings. No new512-column native run, complete signed application or physical tape execution is performed by this package. The empty unverified-pairs list is not a universal phase proof. + +## Conditions and open next questions + +The five inherited framework assumptions remain. Complete fixed-tape service domain, common-U whole-extent supply and reset tariff, helper325/1087 supply, uniform native/owned/compiler closure, actual rounded16-call error and analytic recovery remain open. The nominal scalar service32 and life count235 do not establish a physical implementation at that tariff. No selected result, shared verifier or acceptance gate is modified. + +1. Review the G/F reconstruction and three-field identity against the retained exact edit and finite witnesses. First step: fresh replay and inspect the12 edit blocks; physical supply is outside this check. +2. Bind the unchanged and changed native services to the complete admitted domain and tariff. First step: audit the recorded ordered-basis evidence and residual obligations; matching finite columns alone is insufficient. +3. Establish the full rounded caller error and analytic recovery. First step: trace changed scalar operations with their actual input domains and charged conversions. + +K372-4 and Ali Romman's later #7663 helper-boundary/private-bank work use changed conditions and are not silently folded into this candidate. A stronger headline from another model is not evidence that its assumptions transfer. Current related work is recorded in `PROVENANCE.md`. + +## Credit and license + +Preserve SYLforge #7637, DreamingOfClouds #7641/#7658, Clear1nsight's24-bit coefficient-splitting contribution, 5080 role379/325/1087 work and Mac EARLY composition. Rohan Arun #7113 supplies the caller and upstream signed-accounting lineage, with CubeJerry, Douglas Colkitt and other source contributors credited in the source records. This composition and package were prepared for SYLforge with substantial OpenAI Codex assistance. Apache-2.0; see LICENSE and PROVENANCE.md. Review or merge does not by itself scientifically validate the conditional claim. diff --git a/research/current-triangle-native-error/source/data/K372-2-WORD.json.gz b/research/current-triangle-native-error/source/data/K372-2-WORD.json.gz new file mode 100644 index 0000000000..1273c83178 Binary files /dev/null and b/research/current-triangle-native-error/source/data/K372-2-WORD.json.gz differ diff --git a/research/current-triangle-native-error/source/evidence/BUILD.json b/research/current-triangle-native-error/source/evidence/BUILD.json new file mode 100644 index 0000000000..1747169148 --- /dev/null +++ b/research/current-triangle-native-error/source/evidence/BUILD.json @@ -0,0 +1 @@ +{"CLEAR_coefficients_unchanged":true,"SCALE_delta":0,"candidate":"ee251f6005d2a92b887c5b804bd7aac05989d278b2c9ccb3c3091b50d533b08d","clear_count":235,"events":150522,"exact_local_identity_verified":true,"exact_local_matrix":[["0","1/2","1/4"],["-2","1","0"],["-4","2","1"]],"inputs_sha256":{"certificates":"49cc8b2737a4338db881416521f7e41e41be144aa8e993bdbb66ace9b5b4cb70","composer":"4df7e7bda29caae84dba183520c46657c25cd28680d6d2fb4a68e0bac5a6bf9b","hits":"a5d4c49a1fc14ca4af1383de33fb9347422607891207c0787dcc6de7736f4b60","word":"d96ddc490dd1c95736189e5fa973b62f6988f9a451f178a194d29ca4f129ab68"},"local_start":97842,"mac_hit_provenance":{"composer_rule":"Once per identical touched tuple, insert chosen ADD before original absolute slot[4]","preserved_hit_indices":[9,11,21,137,99],"selected_hits":{"11":{"chosen":[{"alpha_mod_p":2,"literal_ok":true,"q_est":"2","slot":[11149,249,938,683,98069]}],"item":{"c1":551,"c2":683,"c3":127,"gain":0.014209345760366213,"i1":94395,"i2":101951,"k":3,"kind":"STAY","touched":[94397],"x":1013},"mode":"EARLY"},"137":{"chosen":[{"alpha_mod_p":250000002,"literal_ok":true,"q_est":"1/4","slot":[10431,236,1000,751,97352]}],"item":{"c1":748,"c2":1065,"c3":1072,"gain":0.007123114717961903,"i1":97329,"i2":97333,"k":3,"kind":"STAY","touched":[97331],"x":1141},"mode":"EARLY"},"21":{"chosen":[{"alpha_mod_p":250000002,"literal_ok":true,"q_est":"1/4","slot":[10431,236,1000,751,97352]}],"item":{"c1":449,"c2":1065,"c3":928,"gain":0.01252692319001784,"i1":97330,"i2":97337,"k":1,"kind":"STAY","touched":[97331],"x":940},"mode":"EARLY"},"9":{"chosen":[{"alpha_mod_p":1000000006,"literal_ok":true,"q_est":"-1","slot":[9495,431,895,651,96415]},{"alpha_mod_p":1,"literal_ok":true,"q_est":"1","slot":[9495,431,928,651,96415]}],"item":{"c1":545,"c2":651,"c3":127,"gain":0.014209345760366213,"i1":96390,"i2":101958,"k":3,"kind":"STAY","touched":[96393],"x":1188},"mode":"EARLY"},"99":{"chosen":[{"alpha_mod_p":1000000005,"literal_ok":true,"q_est":"-2","slot":[12543,438,911,911,99464]},{"alpha_mod_p":2,"literal_ok":true,"q_est":"2","slot":[12543,438,925,911,99464]}],"item":{"c1":772,"c2":911,"c3":245,"gain":0.008384152313843303,"i1":99208,"i2":99211,"k":4,"kind":"STAY","touched":[99210],"x":1195},"mode":"EARLY"}},"shared_hit_indices":[21,137],"shared_q":"1/4","shared_slot":[10431,236,1000,751,97352],"shared_touched":[97331]},"new_edge_pairs":[[265,927],[927,127]],"old_local_events":[["MOVE",236,265,751,false],["ADD",544,236,"-2",751],["MOVE",1000,265,751,false],["ADD",1000,544,"2",751],["ADD",236,1000,"1/4",751],["MOVE",544,751,927,false]],"old_x_exit":100212,"original_ADD_indices":[97843,97845,97846],"owned_events_and_lifetimes_unchanged":true,"paid_delta_1e12_at_kappa00374":-1261037596,"paid_profile_delta":{"2":1,"3":-2,"4":1},"ports_byte_sha256":"8e55055da81bddced50a91a35d69504de1e942eac53a7d80080318fd686f13dd","public_headers_unchanged":true,"replacement_local_events":[["ADD",236,1000,"1/4",265],["ADD",1000,236,"-2",265],["MOVE",236,265,927,false],["MOVE",1000,265,751,false],["ADD",544,1000,"1/2",751],["ADD",1000,544,"2",751],["MOVE",544,751,927,false],["ADD",544,236,"-1",927],["ADD",236,544,"1/2",927]],"scalar_ADD_delta":3,"scope":"All three values restored at the local block boundary before the next scalar/CLEAR observation. Original Mac5 hit data and hub tapes preserved. Source certificates remapped with unchanged coefficients. Actual full finite/CLEAR, ordinary/precision, native phase, caller/invoice and supplier checks remain separate.","source":"be33ebb71f8c900315795b130efb457c1bb61cb3d575652b8ddd6dd354902772","source_events":150519,"status":"CONSTRUCTED_LOCAL_TRIANGLE_IDENTITY_FULL_REPLAY_PENDING","tool_byte_sha256":"e9927b125081682973d7ac1e368014a50765c2c7b2d475bfb03930958948b2ed"} \ No newline at end of file diff --git a/research/current-triangle-native-error/verify.py b/research/current-triangle-native-error/verify.py new file mode 100644 index 0000000000..76f5c261b9 --- /dev/null +++ b/research/current-triangle-native-error/verify.py @@ -0,0 +1,177 @@ +#!/usr/bin/env python3 +"""Check the complete local error operator in the three actual native charts.""" +from fractions import Fraction as F +from hashlib import sha256 +import importlib.util +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import scalar_source as source +import error_operator as op +need, encoded = op.need, source.encoded + +for row in json.loads((HERE / 'SOURCES.json').read_text())['files']: + if row['usage'] == 'input': + need(sha256((HERE.parents[1] / row['path']).read_bytes()).hexdigest() == row['sha256'], 'retained exact frame input') +path = HERE.parents[1] / 'research/owned-ascent-contract/independent.py' +spec = importlib.util.spec_from_file_location('retained_exact_frames', path) +frames = importlib.util.module_from_spec(spec) +spec.loader.exec_module(frames) +SIZE = 512 + + +def zero(): + return (tuple(F(0) for _ in range(SIZE)), tuple(F(0) for _ in range(SIZE))) + + +def plus(a, b, q=F(1)): + return tuple(tuple(x + q * y for x, y in zip(u, v, strict=True)) for u, v in zip(a, b, strict=True)) + + +def norm2(a): + return sum(x * x for row in a for x in row) + + +def digest(a): + return sha256(encoded([[str(x) for x in row] for row in a])).hexdigest() + + +def mover(descriptions): + def move(value, start, end): + if start == end: + return value + data = tuple([[x] for x in component] for component in value) + data, a = frames.apply_frame(data, descriptions[start], -1) + data, b = frames.apply_frame(data, descriptions[end], 1) + divisor = 1 << (a + b) + return tuple(tuple(F(row[0], divisor) for row in component) for component in data) + return move + + +def execute(events, sites, initial, residuals, move, omitted=None, phase_fault=None, align=True): + fields, current = dict(initial), dict(op.INITIAL) + at = {site['offset']: i for i, site in enumerate(sites)} + for offset, event in enumerate(events): + kind, role = event[:2] + if kind == 'MOVE': + fields[role] = move(fields[role], event[2], event[3]) + current[role] = event[3] + if offset == phase_fault: + fields[role] = plus(zero(), fields[role], F(-1)) + else: + fields[role] = plus(fields[role], fields[event[2]], F(event[3])) + if offset in at and at[offset] != omitted: + fields[role] = plus(fields[role], residuals[at[offset]]) + return [move(fields[role], current[role], 927) if align else fields[role] for role in op.ROLES] + + +def predicted(matrix, sites, residuals, move): + aligned = [move(value, site['frame'], 927) for value, site in zip(residuals, sites, strict=True)] + result = [] + for row in matrix: + value = zero() + for q, field in zip(row, aligned, strict=True): + if q: + value = plus(value, field, q) + result.append(value) + return result + + +def frame_checks(descriptions): + identity = ([[int(i == j) for j in range(SIZE)] for i in range(SIZE)], [[0] * SIZE for _ in range(SIZE)]) + results = [] + for chart, description in sorted(descriptions.items()): + forward, a = frames.apply_frame(identity, description, 1) + backward, b = frames.apply_frame(forward, description, -1) + scale = 1 << (a + b) + need(all(value == scale * int(i == j) for i, row in enumerate(backward[0]) for j, value in enumerate(row)), 'all exact real adjoint columns') + need(all(value == 0 for row in backward[1] for value in row), 'all exact imaginary adjoint columns') + results.append({'chart': chart, 'rank': a, 'columns': SIZE, + 'forward_numerator_sha256': sha256(encoded(forward)).hexdigest(), 'denominator_power': a}) + return results + + +def field_checks(old, new, binding, derived, certificates): + descriptions = {int(chart): frames.frame_data(basis) for chart, basis in binding['frames'].items()} + move = mover(descriptions) + native = frame_checks(descriptions) + initial = {role: (tuple(F((i * (j + 1) + j) % (7 + 2 * j) - (3 + j)) for i in range(SIZE)), + tuple(F((i + 2 * j) % 5 - 2) for i in range(SIZE))) for j, role in enumerate(op.ROLES)} + old_matrix, old_sites, _ = derived['old'] + new_matrix, new_sites, _ = derived['new'] + old_exact = execute(old, old_sites, initial, [zero() for _ in old_sites], move) + new_exact = execute(new, new_sites, initial, [zero() for _ in new_sites], move) + need(old_exact == new_exact, 'actual native exact output alignment') + entry = [move(initial[role], op.INITIAL[role], 927) for role in op.ROLES] + direct = [] + for row in source.MATRIX: + value = zero() + for q, field in zip(row, entry, strict=True): + value = plus(value, field, q) + direct.append(value) + need(old_exact == direct, 'rational map in actual aligned charts') + tests, controls = [], [] + for name, events, matrix, sites in [('old', old, old_matrix, old_sites), ('new', new, new_matrix, new_sites)]: + high = F(certificates[name]['squared_norm_interval'][1]) + for active in range(len(sites)): + residuals = [zero() for _ in sites] + value = [[F(0)] * SIZE for _ in range(2)] + value[active % 2][(37 + 29 * active) % SIZE] = F((-1) ** active) + residuals[active] = tuple(map(tuple, value)) + actual = execute(events, sites, initial, residuals, move) + error = [plus(a, b, F(-1)) for a, b in zip(actual, direct, strict=True)] + reference = predicted(matrix, sites, residuals, move) + need(error == reference, 'full-field residual operator') + error_norm = sum(norm2(field) for field in error) + need(error_norm == F(certificates[name]['one_port_squared_gains'][active]), 'exact native one-port gain') + need(error_norm < high * sum(norm2(field) for field in residuals), 'certified joint residual bound') + tests.append({'tape': name, 'active_port': active, 'squared_output_error': str(error_norm), + 'output_error_sha256': [digest(field) for field in error]}) + if name == 'new' and active == 1: + omitted = execute(events, sites, initial, residuals, move, omitted=1) + need(omitted != actual, 'missing native residual is detected') + controls.append('omitted x native MOVE residual') + if name == 'new' and active == 2: + wrong = [row.copy() for row in matrix] + wrong[2][active] = F(1) + need(predicted(wrong, sites, residuals, move) != error, 'lost native amplification is detected') + controls.append('lost factor two on z native residual') + wrong_phase = execute(new, new_sites, initial, [zero() for _ in new_sites], move, phase_fault=2) + need(wrong_phase != direct, 'native global phase fault') + controls.append('wrong global phase on x native MOVE') + raw = execute(old, old_sites, initial, [zero() for _ in old_sites], move, align=False) + need(raw[0] != direct[0], 'old x exit requires chart alignment') + controls.append('omitted old x exit alignment') + return {'frames': native, 'single_port_full_field_cases': tests, 'controls': controls, + 'exact_aligned_output_sha256': [digest(field) for field in direct]} + + +def main(): + old, new, binding = source.sources() + derived = {'old': op.derive(old, 97747), 'new': op.derive(new, 97842)} + need(derived['old'][0] == op.OLD and derived['new'][0] == op.NEW, 'independent hand-derived residual matrices') + need(derived['old'][2] == [751, 927, 751] and derived['new'][2] == [927, 927, 751], 'literal mixed exit charts') + matrices = {'old': op.OLD, 'new': op.NEW, + 'difference': [a + [-x for x in b] for a, b in zip(op.NEW, op.OLD, strict=True)]} + certificates = {name: op.spectral_certificate(matrix) for name, matrix in matrices.items()} + result = {'binding': binding, 'ports': {name: value[1] for name, value in derived.items()}, + 'exit_charts': {name: value[2] for name, value in derived.items()}, + 'certificates': certificates, 'native': field_checks(old, new, binding, derived, certificates), + 'sharpness_scope': 'arbitrary local residual vectors with a joint squared Euclidean budget; floor reachability is not asserted'} + file = HERE / 'RESULT.json' + if sys.argv[1:] == ['--write']: + need(not file.exists(), 'do not replace checked receipt') + file.write_text(json.dumps(result, indent=2) + '\n') + else: + need(not sys.argv[1:], 'unexpected arguments') + need(encoded(result) == encoded(json.loads(file.read_text())), 'complete error-operator receipt') + print('PASS_CURRENT_TRIANGLE_NATIVE_ERROR ' + json.dumps({'native_columns': 1536, 'full_field_ports': 10, + 'controls': len(result['native']['controls']), + 'norm_intervals': {name: row['norm_interval'] for name, row in certificates.items()}}, sort_keys=True)) + + +if __name__ == '__main__': + main()