diff --git a/research/wordram-ntt-kernel/INTEGRATION-RESULTS.json b/research/wordram-ntt-kernel/INTEGRATION-RESULTS.json new file mode 100644 index 0000000000..f8df94a147 --- /dev/null +++ b/research/wordram-ntt-kernel/INTEGRATION-RESULTS.json @@ -0,0 +1,396 @@ +{ + "status": "PASS", + "cases": 277, + "models": "Literal tcslib ISA at W=64; fixed lengths and fixed modulus; interpreted program includes setup, constant synthesis, arithmetic, carry, clearing and final accept", + "tests": "All single-hex-digit pairs; boundary/random cases through 1024-bit operands; dirty owned memory; operand/exterior preservation; all owned temporaries zero; independent NTT and integer product oracles; same-ABI fused vs recomputation control", + "records": [ + { + "lengths": [ + 1, + 1 + ], + "n": 1, + "butterflies": 0, + "fused_static_instructions": 369, + "duplicate_static_instructions": 369, + "owned_temporary_words": 24, + "output_words": 2, + "comparisons": { + "exhaustive_256_cases": true, + "minimum_steps": 313, + "maximum_steps": 319 + } + }, + { + "lengths": [ + 1, + 2 + ], + "n": 2, + "butterflies": 3, + "fused_static_instructions": 726, + "duplicate_static_instructions": 873, + "owned_temporary_words": 38, + "output_words": 3, + "comparisons": [ + { + "fused_steps": 563, + "duplicate_steps": 662, + "saved_instructions": 99, + "fused_instruction_histogram": { + "one": 19, + "sub": 204, + "add": 190, + "mul": 7, + "bltz": 142, + "accept": 1 + } + }, + { + "fused_steps": 583, + "duplicate_steps": 682, + "saved_instructions": 99, + "fused_instruction_histogram": { + "one": 19, + "sub": 204, + "add": 210, + "mul": 7, + "bltz": 142, + "accept": 1 + } + }, + { + "fused_steps": 571, + "duplicate_steps": 670, + "saved_instructions": 99, + "fused_instruction_histogram": { + "one": 19, + "sub": 204, + "add": 198, + "mul": 7, + "bltz": 142, + "accept": 1 + } + } + ] + }, + { + "lengths": [ + 2, + 2 + ], + "n": 4, + "butterflies": 12, + "fused_static_instructions": 1610, + "duplicate_static_instructions": 2198, + "owned_temporary_words": 71, + "output_words": 5, + "comparisons": [ + { + "fused_steps": 1182, + "duplicate_steps": 1578, + "saved_instructions": 396, + "fused_instruction_histogram": { + "one": 20, + "sub": 496, + "add": 253, + "mul": 20, + "bltz": 392, + "accept": 1 + } + }, + { + "fused_steps": 1243, + "duplicate_steps": 1650, + "saved_instructions": 407, + "fused_instruction_histogram": { + "one": 20, + "sub": 496, + "add": 314, + "mul": 20, + "bltz": 392, + "accept": 1 + } + }, + { + "fused_steps": 1226, + "duplicate_steps": 1628, + "saved_instructions": 402, + "fused_instruction_histogram": { + "one": 20, + "sub": 496, + "add": 297, + "mul": 20, + "bltz": 392, + "accept": 1 + } + } + ] + }, + { + "lengths": [ + 3, + 5 + ], + "n": 8, + "butterflies": 36, + "fused_static_instructions": 3737, + "duplicate_static_instructions": 5501, + "owned_temporary_words": 149, + "output_words": 9, + "comparisons": [ + { + "fused_steps": 2677, + "duplicate_steps": 3865, + "saved_instructions": 1188, + "fused_instruction_histogram": { + "one": 22, + "sub": 1206, + "add": 396, + "mul": 52, + "bltz": 1000, + "accept": 1 + } + }, + { + "fused_steps": 2832, + "duplicate_steps": 4061, + "saved_instructions": 1229, + "fused_instruction_histogram": { + "one": 22, + "sub": 1206, + "add": 551, + "mul": 52, + "bltz": 1000, + "accept": 1 + } + }, + { + "fused_steps": 2817, + "duplicate_steps": 4048, + "saved_instructions": 1231, + "fused_instruction_histogram": { + "one": 22, + "sub": 1206, + "add": 536, + "mul": 52, + "bltz": 1000, + "accept": 1 + } + } + ] + }, + { + "lengths": [ + 8, + 8 + ], + "n": 16, + "butterflies": 96, + "fused_static_instructions": 8689, + "duplicate_static_instructions": 13393, + "owned_temporary_words": 328, + "output_words": 17, + "comparisons": [ + { + "fused_steps": 6161, + "duplicate_steps": 9329, + "saved_instructions": 3168, + "fused_instruction_histogram": { + "one": 25, + "sub": 2877, + "add": 698, + "mul": 128, + "bltz": 2432, + "accept": 1 + } + }, + { + "fused_steps": 6582, + "duplicate_steps": 9901, + "saved_instructions": 3319, + "fused_instruction_histogram": { + "one": 25, + "sub": 2877, + "add": 1119, + "mul": 128, + "bltz": 2432, + "accept": 1 + } + }, + { + "fused_steps": 6653, + "duplicate_steps": 10054, + "saved_instructions": 3401, + "fused_instruction_histogram": { + "one": 25, + "sub": 2877, + "add": 1190, + "mul": 128, + "bltz": 2432, + "accept": 1 + } + } + ] + }, + { + "lengths": [ + 16, + 13 + ], + "n": 32, + "butterflies": 240, + "fused_static_instructions": 20073, + "duplicate_static_instructions": 31833, + "owned_temporary_words": 736, + "output_words": 33, + "comparisons": [ + { + "fused_steps": 14201, + "duplicate_steps": 22121, + "saved_instructions": 7920, + "fused_instruction_histogram": { + "one": 33, + "sub": 6725, + "add": 1410, + "mul": 304, + "bltz": 5728, + "accept": 1 + } + }, + { + "fused_steps": 15228, + "duplicate_steps": 23628, + "saved_instructions": 8400, + "fused_instruction_histogram": { + "one": 33, + "sub": 6725, + "add": 2437, + "mul": 304, + "bltz": 5728, + "accept": 1 + } + }, + { + "fused_steps": 15413, + "duplicate_steps": 24051, + "saved_instructions": 8638, + "fused_instruction_histogram": { + "one": 33, + "sub": 6725, + "add": 2622, + "mul": 304, + "bltz": 5728, + "accept": 1 + } + } + ] + }, + { + "lengths": [ + 64, + 64 + ], + "n": 128, + "butterflies": 1344, + "fused_static_instructions": 103751, + "duplicate_static_instructions": 169607, + "owned_temporary_words": 3712, + "output_words": 129, + "comparisons": [ + { + "fused_steps": 73735, + "duplicate_steps": 118087, + "saved_instructions": 44352, + "fused_instruction_histogram": { + "one": 129, + "sub": 34901, + "add": 7280, + "mul": 1600, + "bltz": 29824, + "accept": 1 + } + }, + { + "fused_steps": 79413, + "duplicate_steps": 126822, + "saved_instructions": 47409, + "fused_instruction_histogram": { + "one": 129, + "sub": 34901, + "add": 12958, + "mul": 1600, + "bltz": 29824, + "accept": 1 + } + }, + { + "fused_steps": 81919, + "duplicate_steps": 131791, + "saved_instructions": 49872, + "fused_instruction_histogram": { + "one": 129, + "sub": 34901, + "add": 15464, + "mul": 1600, + "bltz": 29824, + "accept": 1 + } + } + ] + }, + { + "lengths": [ + 256, + 256 + ], + "n": 512, + "butterflies": 6912, + "fused_static_instructions": 507701, + "duplicate_static_instructions": 846389, + "owned_temporary_words": 17920, + "output_words": 513, + "comparisons": [ + { + "fused_steps": 361525, + "duplicate_steps": 589621, + "saved_instructions": 228096, + "fused_instruction_histogram": { + "one": 513, + "sub": 171797, + "add": 34334, + "mul": 7936, + "bltz": 146944, + "accept": 1 + } + }, + { + "fused_steps": 391079, + "duplicate_steps": 636835, + "saved_instructions": 245756, + "fused_instruction_histogram": { + "one": 513, + "sub": 171797, + "add": 63888, + "mul": 7936, + "bltz": 146944, + "accept": 1 + } + }, + { + "fused_steps": 406526, + "duplicate_steps": 667219, + "saved_instructions": 260693, + "fused_instruction_histogram": { + "one": 513, + "sub": 171797, + "add": 79335, + "mul": 7936, + "bltz": 146944, + "accept": 1 + } + } + ] + } + ] +} diff --git a/research/wordram-ntt-kernel/LICENSE b/research/wordram-ntt-kernel/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/wordram-ntt-kernel/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/wordram-ntt-kernel/MANIFEST.json b/research/wordram-ntt-kernel/MANIFEST.json new file mode 100644 index 0000000000..915d43afc7 --- /dev/null +++ b/research/wordram-ntt-kernel/MANIFEST.json @@ -0,0 +1,37 @@ +{ + "algorithm": "sha256", + "files": { + "INTEGRATION-RESULTS.json": "fd866e701664a240059bdb3212898fa97fd5f5a1759e2fb84c37f07947e69d40", + "lean/IntegerKernelRecovery20261024.lean": "1cfed8b805c3236ae205d5774badd79118e5743fa9343ee70313083efc308e9a", + "lean/STATUS.json": "1b66f49217a082e44d56e97f7ce8e6edc9f3199ffec23cb6b168e9bd26672361", + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.txt": "c7a35a43ceeca4d0b820c00e5b3c589d119033748a46de91769f284e869ac33b", + "ntt/CATCRYPT-LICENSE.txt": "1ae0577444a82462c225f35a8cbd770e449ef4507e58f8638e5f121b6238712a", + "ntt/exact_ntt.py": "b512200d63c736c5d347247028eb1b1f3431cea44aba01c86f2772910d6b41bf", + "ntt/MANIFEST.json": "2cb299d5166af9ea5a849e23af64f92f137a1ae0da5fd85ae83581dce67a9a61", + "ntt/NTT-APPLICATION.txt": "09ed4367c0808d786c6a9ca9e552bc4592da1da16b66ffa60812c6a2dd65753a", + "ntt/sources.json": "b7ddef8bb58bdcf2c6a5029826291c83dc7492e2b06cbfb66cf0828e7ad017e4", + "ntt/TEST-RESULT.json": "16e4463688fd7b08a8056e842e78baeb24091a11136ac2899984d2cd938f6a92", + "ntt/test_exact_ntt.py": "e2fcd058685ab49f2cec71f806563888452ee5dce6b696e04b0ef0ea84687123", + "PROOF.txt": "f1d6549b55337e6704b575806fb6be6cec8bbc9a761a6bf3a320aec40cbee9df", + "ram/circuit-verification.json": "d7423872b05db58c6157930f9f89ffd5bf36e0059ed51a4a8739900a4ece5d7d", + "ram/circuit_sharing.py": "0eadf9ef954c5d97aa5e5f0949b6bf90ecb90fbb9d0321f472b2c6e97140c24f", + "ram/PROOFS.txt": "e62d76c0caaa4e24651d2282a7a19cb935c63e16932c90a14cb74182d3934df8", + "ram/sources.json": "329ce129c36e78d93710104864a94eb0ed1918733e78fd2fcde96ab7f5b58929", + "ram/verification.json": "8d3efbc0916af425143ae6bd5bd94bb9d70ac72d1de2b920a3b2d4bcc9e3b46b", + "ram/verify_wordram.py": "02b2c09ff1542e6f947aedaad67c9a1872ed0098a447b71076cfbfe14373efbb", + "ram/wordram_kernel.py": "b1a6133e505e5faf5832a5274eea23f96b033257c3d16cc24479c4a4c7059a2e", + "ram_multiplier.py": "6c3ae23ad90c92741f5a505ae9dd85a4bbaaafb72ebdf50291e07d1ae4c52476", + "README.md": "23084a8deb72003a42d79e01816f2275e9f38d8250e2ad411fed74a1e6d7bed8", + "recovery/fixedpoint_fft.py": "e9ffceb08684d73e9971b8be9451caefdd2836235eaf059356fc38dc43861bb6", + "recovery/REPORT.txt": "eff4e3bdabdf0216604493e2d768cbe9862e40c61cba21c8964d6fc339b85138", + "recovery/SOURCES.json": "3f29acd9aee095197f2b0829774d40ba930e1977fe9ab1a5f7efb4b2935a07c3", + "recovery/verification-31bits.json": "8a56a5bbe68cee7540a39e03ee041ca4fc5a6aaaa2bf39b109002c05fa0adc6b", + "recovery/verification.json": "3593b43218392896cbcccad591b3bfdf2fb65f1b8d1b60d1b28320ebb1134041", + "SOURCES.json": "3610732a3a0accd3766c92b1de904ed7a41c05970942e0fe5eb89fa697b26f7d", + "TASK.json": "33d03eb9b15b920ae29387a91212fcd67d3a95be81723670a5177b3b56fe612e", + "VERIFY.json": "a6125ea7187eaed24f883dd9600c5cef692e61d1788dabd82d8a521333870a58", + "verify.py": "84283f0581ed63f099a453be34e8d615d90a3ca5dd6f24cdc4a38d93710e594a", + "verify_integration.py": "ef0f3721a9db3f96985f11f446e7bb0bd9c8e20763344c30e4b39f57cbcaaea5" + } +} diff --git a/research/wordram-ntt-kernel/NOTICE.txt b/research/wordram-ntt-kernel/NOTICE.txt new file mode 100644 index 0000000000..b0dc94cb9d --- /dev/null +++ b/research/wordram-ntt-kernel/NOTICE.txt @@ -0,0 +1,3 @@ +Original bounded-kernel integration prepared for Dugongue with substantial OpenAI Codex assistance. Apache-2.0. Reusable mathematical/formal interfaces retain all upstream credit listed in SOURCES.json and README.md. CatCrypt source attribution and MIT notice are retained in ntt/. No complete upstream library is vendored. + +The base Word RAM semantics retain Anthropic, PBC / anthropics/formal-math [AFM26], `3sum-apsp/EndStatement.lean` at `e1a4e6508154ea59f030480661590a9fe3018011`, as attributed in tcslib’s source header. diff --git a/research/wordram-ntt-kernel/PROOF.txt b/research/wordram-ntt-kernel/PROOF.txt new file mode 100644 index 0000000000..d0d0d6486e --- /dev/null +++ b/research/wordram-ntt-kernel/PROOF.txt @@ -0,0 +1,38 @@ +BOUNDED INTEGER MULTIPLICATION: SUFFICIENT ASSEMBLY AND COST PROOF + +1. Frozen scope and computation model. +Fix 1<=s,t<=256, hexadecimal digits a_i,b_j in {0,...,15}, p=65537 and N the least power of two >=s+t-1. Thus N<=512. Input words occupy addresses 1000+i and 2000+j; output words 3000..3000+N. The owned temporary region is exactly the generated fresh addresses >=10000 plus the explicitly reserved scratch set. Regions are disjoint. Arbitrary other memory, including negative signed addresses, is permitted. Initial owned words can be dirty. +The machine uses 64-bit modular words, signed comparison against zero, direct arithmetic operands and a charged halt. Word multiplication is unit cost by this explicitly chosen model; full arbitrary-size multiplication is not a primitive. The program generator uses only lengths and fixed field constants, never input digits. It creates a fixed finite program for each pair of lengths; its generation is not claimed as free work in an all-size algorithm. + +2. Prime and roots. +The concrete checker tests primality by trial divisors through floor(sqrt(p)); every integer in that finite exhaustive divisor interval is checked, so a passing test is a primality certificate by the elementary least-prime-factor argument. For each actual N it sets omega=3^((p-1)/N) mod p and checks omega^N=1 and, if N>1, omega^(N/2)!=1. Since N is a power of two, these two conditions imply exact order N: every proper divisor of N divides N/2. N=1 is direct. Hence geometric-sum orthogonality and division by N are valid in F_p. + +3. No wrap and unique coefficients. +Extend both digit vectors by zero to N. Ordinary product coefficients c_k=sum_{i+j=k}a_i b_j satisfy 0<=c_k<=225 min(s,t)<=57600