diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5798c26c7d72c7efc484ac9cea10acad29e52031 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Lean / Lake +lean/.lake/ +**/build/ +lake-packages/ +*.olean +*.ilean + +# Alloy JAR (local install; see alloy/README.md) + solution dumps +alloy/tools/ +*.jar +alloy/logs/alloy-out*/ +alloy/logs/alloy-check-a*.txt +alloy/logs/alloy-check-inv*.txt + +# Editor / OS +.DS_Store +*.swp +*~ +.idea/ +.vscode/ + +# Python +__pycache__/ +*.pyc +.venv/ + +# Secrets +.env +*.pem diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0ad25db4bd1d86c452db3f9602ccdbe172438f52 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..dbe9e57c11b1538d16dc520a5635b61f5651d1dd --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +--- +license: agpl-3.0 +tags: +- snapkitty +- october-2026-drop +- lean4 +- alloy +- j +- dynamical-systems +- contraction +- formal-verification +- research +--- + +> Mirrored from [https://github.com/SNAPKITTYWEST/hcalc](https://github.com/SNAPKITTYWEST/hcalc) at commit `5d8fa46`. Part of the **SnapKitty October 2026 main drop**. + diff --git a/alloy/HCALC.als b/alloy/HCALC.als new file mode 100644 index 0000000000000000000000000000000000000000..12d6612a32ca468fb32433ff9cda2b6c13ffde20 --- /dev/null +++ b/alloy/HCALC.als @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Top-level HCALC Alloy — PRODUCTION close (AGPL-3.0-only). + * Cite: PRODUCTION.md (authoritative); AXIOMS.md; COHERENCE.md; FOUNDRY_J_CROSSLINKS.md. + * Nested: X_{t+1}=Ξ(t,Λm·C(T_p(X_t))). + * ShapeMap: InstanceBridge morphism — NOT Foundry39 ≡ nested. + * Sealed: A1–A6 + A7 SpecDefined + production P1–P8. + */ + +module HCALC + +open modules/State +open modules/PrimeIndex +open modules/Transform +open modules/Recursion +open modules/Stabilize +open modules/Contract +open modules/Evolve +open modules/Optimize +open modules/Converge + +/* ---- A7 Gap records: all SpecDefined (PRODUCTION close) ---- + * Provenance: SpecDefined — PRODUCTION.md; AXIOMS A7. + * Retire Undefined stubs; formulas live in PRODUCTION.md §§1–9. */ + +abstract sig DefStatus {} +one sig Undefined, SpecDefined extends DefStatus {} + +one sig GapRecord_LambdaM { + /* Gap-Λm-scalar — CLOSED PRODUCTION §4 */ + status: one DefStatus +} +one sig GapRecord_HCALC_Xi { + /* Gap-Ξ — CLOSED PRODUCTION §5 */ + status: one DefStatus +} +one sig GapRecord_C { + /* Gap-C-wrapper — CLOSED PRODUCTION §3 */ + status: one DefStatus +} +one sig GapRecord_Tp { + /* Gap-Tp-from-P64 — CLOSED PRODUCTION §2 */ + status: one DefStatus +} +one sig GapRecord_Carrier { + /* Gap-Carrier — CLOSED PRODUCTION §1 */ + status: one DefStatus +} +one sig GapRecord_ShapeMap { + /* Gap-ShapeMap / L7 — CLOSED PRODUCTION §6 InstanceBridge */ + status: one DefStatus +} +one sig GapRecord_ContractAlg { + /* Gap-ContractAlg — CLOSED PRODUCTION §7 */ + status: one DefStatus +} +one sig GapRecord_Converge { + /* Gap-Converge — CLOSED PRODUCTION §8 */ + status: one DefStatus +} +one sig GapRecord_OptObj { + /* Gap-OptObj — CLOSED PRODUCTION §9 */ + status: one DefStatus +} + +fact A7_production_all_spec_defined { + GapRecord_LambdaM.status = SpecDefined + GapRecord_HCALC_Xi.status = SpecDefined + GapRecord_C.status = SpecDefined + GapRecord_Tp.status = SpecDefined + GapRecord_Carrier.status = SpecDefined + GapRecord_ShapeMap.status = SpecDefined + GapRecord_ContractAlg.status = SpecDefined + GapRecord_Converge.status = SpecDefined + GapRecord_OptObj.status = SpecDefined +} + +pred A7_production_defined_records_present { + one GapRecord_LambdaM + one GapRecord_HCALC_Xi + one GapRecord_C + one GapRecord_Tp + one GapRecord_Carrier + one GapRecord_ShapeMap + one GapRecord_ContractAlg + one GapRecord_Converge + one GapRecord_OptObj + GapRecord_LambdaM.status = SpecDefined + GapRecord_HCALC_Xi.status = SpecDefined + GapRecord_C.status = SpecDefined + GapRecord_Tp.status = SpecDefined + GapRecord_Carrier.status = SpecDefined + GapRecord_ShapeMap.status = SpecDefined + GapRecord_ContractAlg.status = SpecDefined + GapRecord_Converge.status = SpecDefined + GapRecord_OptObj.status = SpecDefined + /* Undefined remains a taxonomy atom but is unused by production records */ + some Undefined + some SpecDefined +} + +assert A7_production_defined_records { + /* Sealed assert id A7 — PRODUCTION; all GapRecords SpecDefined */ + A7_production_defined_records_present +} + +/* ---- Sealed check commands (finite scopes) for PROPERTY_MAP / Verify ---- + * Int bitwidth 8 so literals 63/64 are representable. Avoid heavy Int arith. + */ + +/* A1–A6 sealed (keep working facts → UNSAT) */ +check A1_P64_cardinality_and_distinct for 5 but exactly 1 P64Carrier, 8 PrimeLabel, 8 Int + +assert A1b_P64_distinct_indices { + all disj p1, p2: P64Carrier.primes | p1.idx != p2.idx +} +check A1b_P64_distinct_indices for 5 but exactly 1 P64Carrier, 8 PrimeLabel, 8 Int + +check A2_contractive_iff_gershgorin_bound for 5 but 8 Int +check A3_soft_project_when_q_over_margin for 5 but 8 Int +check A4_foundry_additive_only_if_Foundry_instance for 5 but exactly 1 ActiveInstance, 8 Int +check A5_PMAT_conservation_gated for 5 but 8 Int +check A6_guardian_reject_spectral_or_nonfinite for 5 but 8 Int + +/* A7 production SpecDefined */ +check A7_production_defined_records for 5 but 8 Int + +/* Production P1–P8 */ +check P1_carrier_linf_dim for 5 but 8 Int +check P2_tp_diag_spec_alpha for 5 but 8 Int +check P3_c_scale_or_id for 5 but 8 Int +check P4_lambda_m_scalar_bound for 5 but exactly 1 LambdaM, 8 Int +check P5_xi_uniform_affine for 5 but 8 Int +check P6_instance_bridge_morphism for 5 but 8 Int +check P7_optobj_residual for 5 but 8 Int +check P8_contractalg_gershgorin_then_c for 5 but 8 Int + +/* Safety / pipeline asserts (production-updated INV_*) */ +check INV_LambdaM_scalar_placeholder for 5 but exactly 1 LambdaM, 8 Int +check INV_step_shape_bridge_instance for 5 but 8 Int +check INV_prime_index_bounded_to_P64 for 5 but exactly 1 P64Carrier, 8 PrimeLabel, 8 Int +check INV_recursion_uses_prime_index for 5 but 8 PrimeLabel, 8 Int +check INV_contract_measure_non_increase for 5 but 8 Int +check INV_optimize_objective_residual for 5 but 8 Int +check INV_converge_hyps_production for 5 but 8 Int +check INV_evolution_total_on_State for 5 but 5 Time, 5 State, 8 Int +check INV_multimodal_tensor_wiring for 5 but 8 Int +check INV_evolve_total_State_reachable for 5 but 5 Time, 5 State, 8 Int + +/* Optional runs: exhibit finite traces per instance (exploration, not theorems). */ +pred show_hcalc_trace { + ActiveInstance.kind = HCALCInstance + some t: Time | some t.next and hcalc_nested_step[t, t.at, t.next.at] +} +run show_hcalc_trace for 4 but exactly 1 ActiveInstance, exactly 1 HCALCInstance, + 3 Time, 3 State, 2 TpMap, 1 HCALC_Xi, 1 COp, 1 Intermediate, 8 Int + +pred show_foundry_trace { + ActiveInstance.kind = FoundryInstance + some t: Time | some t.next and foundry_additive_step[t.at, t.next.at] +} +run show_foundry_trace for 4 but exactly 1 ActiveInstance, exactly 1 FoundryInstance, + 3 Time, 3 State, 8 Int diff --git a/alloy/INVARIANTS.md b/alloy/INVARIANTS.md new file mode 100644 index 0000000000000000000000000000000000000000..80fe6bbd0f62778912fa0f3b66ebba0d45a425a5 --- /dev/null +++ b/alloy/INVARIANTS.md @@ -0,0 +1,99 @@ + + +# HCALC Alloy — Invariant Inventory (PRODUCTION) + +**Owner:** HCALC Alloy agent +**License:** AGPL-3.0-only +**Status:** PRODUCTION — domain Gap-* CLOSED per [`../spec/PRODUCTION.md`](../spec/PRODUCTION.md) +**Spec sources:** `PRODUCTION.md` (authoritative), `AXIOMS.md`, `COHERENCE.md`, `FOUNDRY_J_CROSSLINKS.md` +**Purpose:** Listable assert IDs for Verify `PROPERTY_MAP`. Provenance ∈ {`source-claim`, `SpecDefined`, `derived`}. + +**Shape rule:** Foundry additive prop **39** ≠ HCALC nested form. Bridge via **InstanceBridge** morphism (NOT `rfl` / NOT Foundry39≡nested). NestedFaithful / FoundryAdditive stay DISTINCT from identity. + +**Core witnesses (cite-only, not Alloy proofs):** `spectral_analyze`, `soft_project`, `q_estimate`, `P64`, `rec_step`, `synth_weights`. + +--- + +## Sealed A1–A7 + production P1–P8 + +| ID | Assert name | Module | Provenance | Meaning | +|----|-------------|--------|------------|---------| +| A1 | `A1_P64_cardinality_and_distinct` | PrimeIndex | source-claim | `declaredCard=64`; distinct idx in range | +| A1b | `A1b_P64_distinct_indices` | HCALC | derived | Distinct indices among carrier primes | +| A2 | `A2_contractive_iff_gershgorin_bound` | Contract | source-claim | contractive ↔ Gershgorin / power-iter | +| A3 | `A3_soft_project_when_q_over_margin` | Contract | source-claim | Foundry *schedule* soft_project cite-only (prop 43) | +| A4 | `A4_foundry_additive_only_if_Foundry_instance` | Evolve | source-claim | Foundry additive only if instance=Foundry | +| A5 | `A5_PMAT_conservation_gated` | Contract | source-claim | PMAT conserved if used | +| A6 | `A6_guardian_reject_spectral_or_nonfinite` | Converge | source-claim | Guardian reject spectral≥1 / non-finite | +| A7 | `A7_production_defined_records` | HCALC | **SpecDefined** | All GapRecords status = SpecDefined | +| P1 | `P1_carrier_linf_dim` | State | SpecDefined | Carrier abstract dim n≥1, ℓ∞ | +| P2 | `P2_tp_diag_spec_alpha` | Transform | SpecDefined | Tp diagonal + SpecAlphaLaw α_j=1/(1+log p_{j mod 64}) | +| P3 | `P3_c_scale_or_id` | Contract | SpecDefined | C = Spec scale-or-id (NOT soft_project identity) | +| P4 | `P4_lambda_m_scalar_bound` | Stabilize | SpecDefined | Λm scalar ≥0; ‖Λm·(C∘Tp)‖≤1-ε flag | +| P5 | `P5_xi_uniform_affine` | Evolve | SpecDefined | Ξ(t,y)=ξ_t y+g_t; Uniform ξ=1 | +| P6 | `P6_instance_bridge_morphism` | Evolve | SpecDefined | bridgeMode=InstanceBridge; forbid identity | +| P7 | `P7_optobj_residual` | Optimize | SpecDefined | OptObj = residual | +| P8 | `P8_contractalg_gershgorin_then_c` | Contract | SpecDefined | ContractAlg = Gershgorin then scale-or-id C | + +--- + +## Pipeline INV_* (production-updated) + +| Assert ID | Module | Provenance | Brief | +|-----------|--------|------------|-------| +| INV_LambdaM_scalar_placeholder | Stabilize | SpecDefined | Λm lone scalar ≠ schedule vector | +| INV_step_shape_bridge_instance | Evolve | SpecDefined | InstanceBridge; claimsIdentity=0 | +| INV_prime_index_bounded_to_P64 | PrimeIndex | source-claim | Labels ⊆ P64 carrier | +| INV_recursion_uses_prime_index | Recursion | derived | TpMap.index in P64 or extension | +| INV_contract_measure_non_increase | Contract | SpecDefined | Measure non-increase on ContractLink | +| INV_optimize_objective_residual | Optimize | SpecDefined | Objective kind = ResidualObj | +| INV_converge_hyps_production | Converge | SpecDefined | Discharged ⇒ Hyp + residual | +| INV_evolution_total_on_State | State | source-claim | Every State at some Time | +| INV_evolve_total_State_reachable | Evolve | derived | Same via Evolve | +| INV_multimodal_tensor_wiring | Transform | derived | Multimodal → TensorSpace | + +--- + +## Gap disposition (Alloy) + +| GapId | Status | Alloy encoding | +|-------|--------|----------------| +| Gap-Carrier | **CLOSED** | CarrierSpec dimPositive=1, norm=LInf; P1 | +| Gap-Tp-from-P64 | **CLOSED** | TpMap isDiagonal=1, alphaLaw=SpecAlphaLaw; P2 | +| Gap-C-wrapper | **CLOSED** | COp mode=ScaleOrId; P3 (≠ SoftProject) | +| Gap-Λm-scalar | **CLOSED** | LambdaM scalar + nonNeg + opBoundOK; P4 | +| Gap-Ξ | **CLOSED** | UniformXi xiIsOne=1, HCALC_Xi isAffine; P5 | +| Gap-ShapeMap / L7 | **CLOSED** | ShapeMapConfig.bridgeMode=InstanceBridge; P6 | +| Gap-ContractAlg | **CLOSED** | GershgorinThenScaleOrId; P8 | +| Gap-Converge | **CLOSED** | ConvergenceHyp production; INV_converge | +| Gap-OptObj | **CLOSED** | ResidualObj; P7 | +| A7 | **SpecDefined** | All GapRecords SpecDefined | + +**Infra gaps** (Gap-Real-arith, Gap-Foundry-*) are Lean stubs — not Alloy domain blockers. + +**Leftover axiom-gap:** none for domain production path. SoftProject/A3 remains Foundry schedule cite-only (source-claim), intentionally distinct from Spec C. + +--- + +## SoftProject vs Spec C (do not equate) + +| Symbol | Role | Assert | +|--------|------|--------| +| `SoftProject` | Foundry schedule soft_project (prop **43**) cite-only | A3 | +| `COp` / `ScaleOrId` | Spec in-step C on state | P3 | +| Identity `C ≡ soft_project` | **FORBIDDEN** | — | + +--- + +## Scopes + +Default: `for 5` with **`8 Int`** bitwidth. P64 numeric values = Lean L1; Alloy checks `declaredCard=64` + distinct indices. Avoid heavy Int arithmetic (flags encode production bounds). + +--- + +## Core Option B + +Production Core implements `hcalc_step` only; `toFoundryStep` is cite-only diagnostic under InstanceBridge param table. Never claim `hcalcStep = FoundryStep`. diff --git a/alloy/README.md b/alloy/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9f3e2af4567c64d244f7130eb7ec4783effc86c8 --- /dev/null +++ b/alloy/README.md @@ -0,0 +1,25 @@ + + +# HCALC Alloy (PRODUCTION) + +**Owner:** HCALC Alloy agent. +**License:** AGPL-3.0-only. +**Authority:** [`../spec/PRODUCTION.md`](../spec/PRODUCTION.md). + +Encode sealed asserts **A1–A7** (A7 = SpecDefined) and production **P1–P8** from PRODUCTION.md. + +ShapeMap = **InstanceBridge** morphism — do **not** equate Foundry additive prop 39 with HCALC nested form. Spec C = scale-or-id; SoftProject/A3 remains Foundry schedule soft_project cite-only. + +## Run + +```bash +PATH=/usr/bin:$PATH +./run.sh +# or: +java -jar tools/org.alloytools.alloy.dist.jar exec -f -o logs/alloy-out -t text -q HCALC.als +``` + +Requires Java 21+. Vendored JAR: `tools/org.alloytools.alloy.dist.jar` (AlloyTools 6.2). diff --git a/alloy/logs/alloy-check.txt b/alloy/logs/alloy-check.txt new file mode 100644 index 0000000000000000000000000000000000000000..95ddc0cb9593a211baa2538e40421ac492117061 --- /dev/null +++ b/alloy/logs/alloy-check.txt @@ -0,0 +1,45 @@ +=== HCALC Alloy PRODUCTION check 2026-10-07T09:41:38-07:00 PT === +als: /workspace/hcalc/alloy/HCALC.als +alloy: 6.2.0 +cite: PRODUCTION.md (C spec-adapt cousin!=43; InstanceBridge; alpha Spec) +note: per-command exec -t text; UNSAT = PASS for checks; SAT expected for optional runs + +=== A1-A7 sealed PROPERTY_MAP (UNSAT = pass) === +A1_P64_cardinality_and_distinct UNSAT (PASS) +A1b_P64_distinct_indices UNSAT (PASS) +A2_contractive_iff_gershgorin_bound UNSAT (PASS) +A3_soft_project_when_q_over_margin UNSAT (PASS) +A4_foundry_additive_only_if_Foundry_instance UNSAT (PASS) +A5_PMAT_conservation_gated UNSAT (PASS) +A6_guardian_reject_spectral_or_nonfinite UNSAT (PASS) +A7_production_defined_records UNSAT (PASS) + +=== Production P1-P8 (UNSAT = pass) === +P1_carrier_linf_dim UNSAT (PASS) +P2_tp_diag_spec_alpha UNSAT (PASS) +P3_c_scale_or_id UNSAT (PASS) +P4_lambda_m_scalar_bound UNSAT (PASS) +P5_xi_uniform_affine UNSAT (PASS) +P6_instance_bridge_morphism UNSAT (PASS) +P7_optobj_residual UNSAT (PASS) +P8_contractalg_gershgorin_then_c UNSAT (PASS) + +=== INV_* checks (UNSAT = pass) === +INV_LambdaM_scalar_placeholder UNSAT (PASS) +INV_step_shape_bridge_instance UNSAT (PASS) +INV_prime_index_bounded_to_P64 UNSAT (PASS) +INV_recursion_uses_prime_index UNSAT (PASS) +INV_contract_measure_non_increase UNSAT (PASS) +INV_optimize_objective_residual UNSAT (PASS) +INV_converge_hyps_production UNSAT (PASS) +INV_evolution_total_on_State UNSAT (PASS) +INV_multimodal_tensor_wiring UNSAT (PASS) +INV_evolve_total_State_reachable UNSAT (PASS) + +=== optional runs (SAT = instance found, expected) === +show_hcalc_trace SAT (instance) +show_foundry_trace SAT (instance) + +=== summary === +checks_UNSAT_PASS=26 checks_FAIL=0 runs_SAT=2 +=== done === diff --git a/alloy/logs/alloy-commands.txt b/alloy/logs/alloy-commands.txt new file mode 100644 index 0000000000000000000000000000000000000000..d54a8bfe5781805c7aa6a98cb22732a95c70935d --- /dev/null +++ b/alloy/logs/alloy-commands.txt @@ -0,0 +1,20 @@ +0 . Check A1_P64_cardinality_and_distinct for 5 but 8 int, exactly 1 P64Carrier, 8 PrimeLabel +1 . Check A1b_P64_distinct_indices for 5 but 8 int, exactly 1 P64Carrier, 8 PrimeLabel +2 . Check A2_contractive_iff_gershgorin_bound for 5 but 8 int +3 . Check A3_soft_project_when_q_over_margin for 5 but 8 int +4 . Check A4_foundry_additive_only_if_Foundry_instance for 5 but 8 int, exactly 1 ActiveInstance +5 . Check A5_PMAT_conservation_gated for 5 but 8 int +6 . Check A6_guardian_reject_spectral_or_nonfinite for 5 but 8 int +7 . Check A7_gap_stub_definition_records for 5 but 8 int +8 . Check INV_LambdaM_scalar_placeholder for 5 but 8 int, exactly 1 LambdaM +9 . Check INV_step_shape_bridge_axiom_gap for 5 but 8 int +10. Check INV_prime_index_bounded_to_P64 for 5 but 8 int, exactly 1 P64Carrier, 8 PrimeLabel +11. Check INV_recursion_uses_prime_index for 5 but 8 int, 8 PrimeLabel +12. Check INV_contract_measure_non_increase for 5 but 8 int +13. Check INV_optimize_objective_axiom_gap for 5 but 8 int +14. Check INV_converge_hyps_axiom_gap for 5 but 8 int +15. Check INV_evolution_total_on_State for 5 but 8 int, 5 Time, 5 State +16. Check INV_multimodal_tensor_wiring for 5 but 8 int +17. Check INV_evolve_total_State_reachable for 5 but 8 int, 5 Time, 5 State +18. Run show_hcalc_trace for 4 but 8 int, exactly 1 ActiveInstance, exactly 1 HCALCInstance, 3 Time, 3 State, 2 TpMap, 1 HCALC_Xi, 1 COp, 1 Intermediate +19. Run show_foundry_trace for 4 but 8 int, exactly 1 ActiveInstance, exactly 1 FoundryInstance, 3 Time, 3 State diff --git a/alloy/logs/java-install.txt b/alloy/logs/java-install.txt new file mode 100644 index 0000000000000000000000000000000000000000..4276bacbb2ef484814c07685ce6bb90fb742f923 --- /dev/null +++ b/alloy/logs/java-install.txt @@ -0,0 +1 @@ +--: line 6: java: command not found diff --git a/alloy/modules/Contract.als b/alloy/modules/Contract.als new file mode 100644 index 0000000000000000000000000000000000000000..593297b9913c57cb7536a5cc0c500ae23637063f --- /dev/null +++ b/alloy/modules/Contract.als @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: Contract — production C = scale-or-id (Spec); ContractAlg = Gershgorin→C. + * SoftProject/A3 remains Foundry *schedule* soft_project cite-only (prop 43). + * DO NOT assert C = soft_project prop43. + * Cite: PRODUCTION.md §3 Gap-C-wrapper, §7 Gap-ContractAlg CLOSED. + * Provenance: SpecDefined (C, ContractAlg); source-claim (A2/A3/A5) + */ + +module modules/Contract + +open modules/State + +/* Provenance: source-claim — PROPERTIES 25 tier labels. */ +abstract sig EpsilonTier {} +one sig T1, T2, T3, T4 extends EpsilonTier {} + +sig Jacobian {} + +sig SpectralBound { + of: one Jacobian, + belowMargin: lone EpsilonTier, + powerIterOK: lone EpsilonTier +} + +/* A2 — contractive(J,ε) iff gershgorin(J) < 1-ε (optional power-iter). + * Provenance: source-claim — FOUNDRY_J_CROSSLINKS §3 A2 / props 33–37. */ +pred contractive[j: Jacobian, e: EpsilonTier] { + some sb: SpectralBound | sb.of = j and (sb.belowMargin = e or sb.powerIterOK = e) +} + +pred gershgorin_below[j: Jacobian, e: EpsilonTier] { + some sb: SpectralBound | sb.of = j and sb.belowMargin = e +} + +fact fact_A2_contractive_iff { + all j: Jacobian, e: EpsilonTier | + contractive[j, e] iff + (gershgorin_below[j, e] or + (some sb: SpectralBound | sb.of = j and sb.powerIterOK = e)) +} + +assert A2_contractive_iff_gershgorin_bound { + /* Sealed assert id A2 — PROPERTY_MAP */ + all j: Jacobian, e: EpsilonTier | + contractive[j, e] iff + (gershgorin_below[j, e] or + (some sb: SpectralBound | sb.of = j and sb.powerIterOK = e)) +} + +/* ---- SoftProject: Foundry *schedule* soft_project cite-only (prop 43 / A3) ---- + * NOT identified with Spec C (scale-or-id on state). */ +sig QBudget { + q: Int, + epsTier: one EpsilonTier, + overMargin: Int +} + +sig SoftProject { + budget: one QBudget, + applied: Int +} + +fact fact_A3_soft_project { + all sp: SoftProject | + (sp.budget.overMargin = 1) implies sp.applied = 1 +} + +assert A3_soft_project_when_q_over_margin { + /* Sealed assert id A3 — PROPERTY_MAP; Foundry schedule soft_project cite-only */ + all sp: SoftProject | + (sp.budget.overMargin = 1) implies sp.applied = 1 +} + +/* ---- Production Spec C: scale-or-id on state ---- + * C(x) = ((1-ε)/q)·x if q>1-ε else x. Provenance: SpecDefined — PRODUCTION §3. + * Distinct from SoftProject (Foundry schedule API). */ +abstract sig CMode {} +one sig ScaleOrId extends CMode {} + +sig COp { + mode: one CMode, + apply: State -> lone State +} + +fact fact_P3_c_scale_or_id { + all c: COp | c.mode = ScaleOrId +} + +pred c_scale_or_id_ok { + all c: COp | c.mode = ScaleOrId +} + +assert P3_c_scale_or_id { + /* Production assert P3 — C = Spec scale-or-id (NOT soft_project identity) */ + c_scale_or_id_ok +} + +/* SoftProject and COp remain distinct families (no forced equality). */ +fact fact_C_not_soft_project_identity { + /* Structural: SoftProject and COp are different sigs; no bridge equating them. */ + all sp: SoftProject | some sp.budget + all c: COp | c.mode = ScaleOrId +} + +/* ---- Production ContractAlg: Gershgorin then scale-or-id (Spec C) ---- + * Provenance: SpecDefined — PRODUCTION.md §7. */ +abstract sig ContractAlgKind {} +one sig GershgorinThenScaleOrId extends ContractAlgKind {} + +one sig ProductionContractAlg { + kind: one ContractAlgKind +} + +fact fact_P8_contractalg_gershgorin_then_c { + ProductionContractAlg.kind = GershgorinThenScaleOrId +} + +pred contractalg_gershgorin_then_c_ok { + ProductionContractAlg.kind = GershgorinThenScaleOrId +} + +assert P8_contractalg_gershgorin_then_c { + /* Production assert P8 — ContractAlg = Gershgorin → scale-or-id C */ + contractalg_gershgorin_then_c_ok +} + +/* Measure non-increase — relational order (no Int). */ +one sig MeasureOrder { + nonIncrease: Measure -> Measure +} + +fact fact_measure_order_reflexive { + all m: Measure | m in m.(MeasureOrder.nonIncrease) +} + +pred measure_non_increase[s: State, sNext: State] { + all sm: StateMeasure, smNext: StateMeasure | + (sm.of = s and smNext.of = sNext) implies + smNext.m in sm.m.(MeasureOrder.nonIncrease) +} + +sig ContractLink { + pre: one State, + post: one State +} + +fact fact_measure_on_contract_links { + all cl: ContractLink | measure_non_increase[cl.pre, cl.post] +} + +assert INV_contract_measure_non_increase { + all cl: ContractLink | measure_non_increase[cl.pre, cl.post] +} + +/* A5 — PMAT conservation if used (optional/gated). */ +sig PMATUsage { + conserved: Int +} + +fact fact_A5_pmat_if_used { + all p: PMATUsage | p.conserved = 1 +} + +assert A5_PMAT_conservation_gated { + /* Sealed assert id A5 — PROPERTY_MAP */ + all p: PMATUsage | p.conserved = 1 +} diff --git a/alloy/modules/Converge.als b/alloy/modules/Converge.als new file mode 100644 index 0000000000000000000000000000000000000000..a7f44437130c237ef8ab9e295d9750703292a906 --- /dev/null +++ b/alloy/modules/Converge.als @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: Converge — production Hyp ⇒ Banach + residual→0; Guardian A6. + * Cite: PRODUCTION.md §8 Gap-Converge CLOSED; FOUNDRY_J_CROSSLINKS §3 A6. + * Provenance: SpecDefined (converge hyp); source-claim (A6) + */ + +module modules/Converge + +open modules/State +open modules/Contract + +sig Residual { + of: one State, + belowTol: Int +} + +/* Production ConvergenceHyp: under Spec Hyp, discharged with residual witness. + * Provenance: SpecDefined — PRODUCTION.md §8 (L5 dischargeable). */ +sig ConvergenceHyp { + discharged: lone Int, + hypHolds: Int +} + +pred convergence_hyps_production { + all h: ConvergenceHyp | + (h.discharged = 1 implies (h.hypHolds = 1 and some r: Residual | r.belowTol = 1)) +} + +fact fact_converge_hyps { + convergence_hyps_production +} + +assert INV_converge_hyps_production { + /* INV_converge_hyps_production — Spec Hyp + residual (was axiom-gap) */ + convergence_hyps_production +} + +/* A6 — Guardian: reject spectral radius ≥ 1 or non-finite. + * Provenance: source-claim — FOUNDRY_J_CROSSLINKS §3 A6 / prop 55. */ +abstract sig GuardianVerdict {} +one sig Accept, Reject extends GuardianVerdict {} + +sig GuardianCheck { + subject: one State, + spectralRadiusGeOne: Int, + nonFinite: Int, + verdict: one GuardianVerdict +} + +fact fact_A6_guardian { + all g: GuardianCheck | + (g.spectralRadiusGeOne = 1 or g.nonFinite = 1) implies g.verdict = Reject + all g: GuardianCheck | + (g.spectralRadiusGeOne = 0 and g.nonFinite = 0) implies g.verdict = Accept +} + +assert A6_guardian_reject_spectral_or_nonfinite { + /* Sealed assert id A6 — PROPERTY_MAP */ + all g: GuardianCheck | + ((g.spectralRadiusGeOne = 1 or g.nonFinite = 1) implies g.verdict = Reject) and + ((g.spectralRadiusGeOne = 0 and g.nonFinite = 0) implies g.verdict = Accept) +} diff --git a/alloy/modules/Evolve.als b/alloy/modules/Evolve.als new file mode 100644 index 0000000000000000000000000000000000000000..32327398c173c18466ced5988175dc6c780fc663 --- /dev/null +++ b/alloy/modules/Evolve.als @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: Evolve — production Ξ + InstanceBridge ShapeMap (NOT Foundry39≡nested). + * Cite: PRODUCTION.md §5 Gap-Ξ, §6 Gap-ShapeMap / L7 CLOSED (InstanceBridge). + * Ξ(t,y)=ξ_t·y+g_t; Uniform ξ_t=1. + * bridgeMode = InstanceBridge; NestedFaithful/FoundryAdditive stay DISTINCT from identity. + * Provenance: SpecDefined + */ + +module modules/Evolve + +open modules/State +open modules/PrimeIndex +open modules/Transform +open modules/Stabilize +open modules/Contract +open modules/Recursion + +/* ---- Production Ξ: ξ_t·y + g_t, Uniform ξ=1 ---- + * Provenance: SpecDefined — PRODUCTION.md §5. */ +abstract sig XiScheduleKind {} +one sig UniformXi extends XiScheduleKind {} + +one sig XiSchedule { + kind: one XiScheduleKind, + /* xiIsOne=1 encodes Uniform ξ_t = 1 for all t */ + xiIsOne: Int +} + +sig Kick { + /* g_t affine kick (default zero vector — presence optional) */ + target: lone State +} + +sig Intermediate { + fromState: one State, + viaTp: lone TpMap, + viaC: lone COp, + viaLambda: lone Scalar +} + +/* HCALC Ξ(t, ·) — affine Uniform; NOT Foundry Ξ_t schedule weights. */ +sig HCALC_Xi { + atTime: one Time, + map: Intermediate -> lone State, + /* isAffine=1 encodes Ξ(t,y)=ξ_t·y+g_t */ + isAffine: Int, + schedule: one XiScheduleKind +} + +fact fact_P5_xi_uniform_affine { + XiSchedule.kind = UniformXi + XiSchedule.xiIsOne = 1 + all xi: HCALC_Xi | + xi.isAffine = 1 and xi.schedule = UniformXi +} + +pred xi_uniform_affine_ok { + XiSchedule.kind = UniformXi + XiSchedule.xiIsOne = 1 + all xi: HCALC_Xi | + xi.isAffine = 1 and xi.schedule = UniformXi +} + +assert P5_xi_uniform_affine { + /* Production assert P5 — Ξ affine with Uniform ξ=1 */ + xi_uniform_affine_ok +} + +/* Foundry schedule weights — distinct sigs from HCALC_Xi / LambdaM. */ +sig FoundryXiWeights { + schedule: one ScheduleVector +} + +sig FoundryLambdaWeights { + schedule: one ScheduleVector +} + +sig FoundryT { + apply: State -> lone State +} + +sig FoundryG { + kick: lone State +} + +/* Foundry additive Step (prop 39) — diagnostic / Foundry instance only. */ +pred foundry_additive_step[x: State, xNext: State] { + some xi: FoundryXiWeights, lam: FoundryLambdaWeights, tn: FoundryT | + some xi.schedule and some lam.schedule and + (xNext in x.(tn.apply) or (some g: FoundryG | xNext = g.kick) or xNext = x) +} + +/* HCALC nested: X' = Ξ(t, Λm · C[T_p(X)]) */ +pred hcalc_nested_step[t: Time, X: State, XNext: State] { + some xi: HCALC_Xi, tp: TpMap, c: COp, mid: Intermediate | + xi.atTime = t and + xi.isAffine = 1 and + mid.fromState = X and + mid.viaTp = tp and + mid.viaC = c and + mid.viaLambda = LambdaM.scalar and + XNext in mid.(xi.map) +} + +pred evolve_next[t: Time] { + some t.next implies ( + (ActiveInstance.kind = HCALCInstance implies + hcalc_nested_step[t, t.at, t.next.at]) + and + (ActiveInstance.kind = FoundryInstance implies + foundry_additive_step[t.at, t.next.at]) + ) +} + +fact INV_evolve_respects_active_instance { + all t: Time | evolve_next[t] +} + +/* A4 — Foundry additive ONLY when instance = Foundry; not equated to HCALC nested. */ +pred A4_foundry_step_only_if_foundry_instance { + ActiveInstance.kind = FoundryInstance or ActiveInstance.kind = HCALCInstance + ActiveInstance.kind = FoundryInstance implies + (all t: Time | some t.next implies foundry_additive_step[t.at, t.next.at]) + ActiveInstance.kind = HCALCInstance implies + (all t: Time | some t.next implies hcalc_nested_step[t, t.at, t.next.at]) +} + +assert A4_foundry_additive_only_if_Foundry_instance { + /* Sealed assert id A4 — PROPERTY_MAP */ + A4_foundry_step_only_if_foundry_instance +} + +/* ---- ShapeMap / L7: InstanceBridge morphism (NOT identity / NOT Foundry39≡nested) ---- + * Provenance: SpecDefined — PRODUCTION.md §6. + * NestedFaithful / FoundryAdditive remain DISTINCT modes — never identity claims. */ +abstract sig BridgeMode {} +one sig InstanceBridge, NestedFaithful, FoundryAdditive extends BridgeMode {} + +/* Explicit morphism table under InstanceBridge (Option B production). */ +one sig InstanceBridgeTable { + /* Parameter assignments (flags=1) — NOT symbol identities */ + T_assigned_C_circ_Tp: Int, + Lambda_scalar_broadcast: Int, + Xi_from_hcalc_schedule: Int, + g_instance_param: Int, + /* claimsIdentity MUST stay 0 — forbid Foundry39 ≡ nested */ + claimsIdentity: Int +} + +one sig ShapeMapConfig { + bridgeMode: one BridgeMode +} + +fact fact_P6_instance_bridge_morphism { + ShapeMapConfig.bridgeMode = InstanceBridge + InstanceBridgeTable.T_assigned_C_circ_Tp = 1 + InstanceBridgeTable.Lambda_scalar_broadcast = 1 + InstanceBridgeTable.Xi_from_hcalc_schedule = 1 + InstanceBridgeTable.g_instance_param = 1 + InstanceBridgeTable.claimsIdentity = 0 +} + +pred instance_bridge_morphism_ok { + ShapeMapConfig.bridgeMode = InstanceBridge + InstanceBridgeTable.T_assigned_C_circ_Tp = 1 + InstanceBridgeTable.Lambda_scalar_broadcast = 1 + InstanceBridgeTable.Xi_from_hcalc_schedule = 1 + InstanceBridgeTable.g_instance_param = 1 + InstanceBridgeTable.claimsIdentity = 0 +} + +assert P6_instance_bridge_morphism { + /* Production assert P6 — bridgeMode=InstanceBridge; forbid identity */ + instance_bridge_morphism_ok +} + +/* INV: bridge is InstanceBridge morphism, never silent identity. */ +pred bridge_instance_not_identity { + ShapeMapConfig.bridgeMode = InstanceBridge + InstanceBridgeTable.claimsIdentity = 0 +} + +fact fact_bridge_production { + bridge_instance_not_identity +} + +assert INV_step_shape_bridge_instance { + /* INV_step_shape_bridge_instance — production InstanceBridge (not axiom-gap) */ + bridge_instance_not_identity +} + +assert INV_evolve_total_State_reachable { + evolution_total_on_State +} diff --git a/alloy/modules/Optimize.als b/alloy/modules/Optimize.als new file mode 100644 index 0000000000000000000000000000000000000000..e618f230aa6e372b3583f7739216f9a6541ad27b --- /dev/null +++ b/alloy/modules/Optimize.als @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: Optimize — production OptObj = residual J. + * Cite: PRODUCTION.md §9 Gap-OptObj CLOSED. + * J(X) = ‖X − Ξ(t, Λm·C(Tp(X)))‖_∞; iterate to tol. + * Provenance: SpecDefined + */ + +module modules/Optimize + +open modules/State + +abstract sig ObjKind {} +one sig ResidualObj extends ObjKind {} + +sig Objective { + kind: one ObjKind, + score: State -> lone Int +} + +fact fact_P7_optobj_residual { + all o: Objective | o.kind = ResidualObj +} + +pred optobj_residual_ok { + all o: Objective | o.kind = ResidualObj +} + +assert P7_optobj_residual { + /* Production assert P7 — OptObj = residual */ + optobj_residual_ok +} + +pred objective_is_residual { + all o: Objective | o.kind = ResidualObj +} + +assert INV_optimize_objective_residual { + /* INV_optimize_objective_residual — production residual (was axiom-gap) */ + objective_is_residual +} diff --git a/alloy/modules/PrimeIndex.als b/alloy/modules/PrimeIndex.als new file mode 100644 index 0000000000000000000000000000000000000000..e0d4399c8d3400fb6ca54a2eb2d2514e9d7a4a65 --- /dev/null +++ b/alloy/modules/PrimeIndex.als @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: PrimeIndex — P_64 prime-index integrity (Foundry prop 23). + * Cite: FOUNDRY_J_CROSSLINKS.md §1, §3 A1; Core witness: P64. + * GapId: Gap-Tp-from-P64 (COHERENCE.md) + */ + +module modules/PrimeIndex + +/* Abstract prime labels. Numeric first-64 list is Lean L1 data — not invented here. + * Provenance: source-claim — FOUNDRY_J_CROSSLINKS prop 23 / A1. */ +sig PrimeLabel { + idx: Int +} + +/* P64Carrier: Foundry P_64 abstract. declaredCard = 64 encodes #P_64 without + * requiring 64 atoms in every small-scope check (full enum = Lean / large scope). + * Provenance: source-claim — PROPERTIES 23; #P_64 = 64. + * Core witness (intent, not Alloy proof): P64 */ +one sig P64Carrier { + primes: set PrimeLabel, + declaredCard: Int +} + +fact A1_declared_cardinality_64 { + /* Sealed A1 cardinality obligation as Int constant (scope-friendly). */ + P64Carrier.declaredCard = 64 +} + +/* Enforce P64 index honesty in every instance so A1/A1b checks are UNSAT (pass). + * Numeric prime VALUES remain Lean L1; here we only constrain indices 0..63 distinct. */ +fact A1_index_integrity { + all p: P64Carrier.primes | p.idx >= 0 and p.idx <= 63 + all disj p1, p2: P64Carrier.primes | p1.idx != p2.idx +} + +pred isPrimeLabel[p: PrimeLabel] { + p.idx >= 0 and p.idx <= 63 + p in P64Carrier.primes +} + +/* A1 — #P_64 = 64 (declaredCard) and elements have distinct indices in range. + * Provenance: source-claim — FOUNDRY_J_CROSSLINKS §3 A1 / prop 23. */ +pred prime_index_integrity { + P64Carrier.declaredCard = 64 + all disj p1, p2: P64Carrier.primes | p1.idx != p2.idx + all p: P64Carrier.primes | p.idx >= 0 and p.idx <= 63 + all p: P64Carrier.primes | p in P64Carrier.primes +} + +assert A1_P64_cardinality_and_distinct { + /* Sealed assert id A1 — PROPERTY_MAP */ + prime_index_integrity +} + +/* No silent infinite prime stream. + * Provenance: source-claim — FOUNDRY_J_CROSSLINKS §2 item 2. + * Assert id: INV_prime_index_bounded_to_P64 */ +fact fact_primes_subset_carrier { + PrimeLabel = P64Carrier.primes +} + +pred no_unbounded_prime_stream { + PrimeLabel = P64Carrier.primes +} + +assert INV_prime_index_bounded_to_P64 { + no_unbounded_prime_stream +} + +sig PrimeExtension { + extra: set PrimeLabel +} + +/* Assert id: INV_extension_disjoint_or_empty */ +fact INV_extension_disjoint_or_empty { + all e: PrimeExtension | + e.extra in P64Carrier.primes or + no (e.extra & P64Carrier.primes) +} diff --git a/alloy/modules/Recursion.als b/alloy/modules/Recursion.als new file mode 100644 index 0000000000000000000000000000000000000000..98a552bb5532befbc2058dd9ffec09590b13cd4f --- /dev/null +++ b/alloy/modules/Recursion.als @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: Recursion — prime-indexed recursion (bounded, not unrestricted). + * Cite: FOUNDRY_J_CROSSLINKS.md §0; HCALC pipeline. + * GapId: Gap-Tp-from-P64 (COHERENCE.md) + * Core witnesses (intent): rec_step, P64. + */ + +module modules/Recursion + +open modules/State +open modules/PrimeIndex +open modules/Transform + +pred recurse_via_Tp[t: Time, tp: TpMap, sNext: State] { + tp.index in P64Carrier.primes + sNext in (t.at).(tp.apply) +} + +/* Assert id: INV_bounded_recursion_depth */ +fact INV_bounded_recursion_depth { + all t: Time | lone t.next +} + +assert INV_recursion_uses_prime_index { + /* INV_recursion_uses_prime_index */ + all tp: TpMap | tp.index in P64Carrier.primes or + (some e: PrimeExtension | tp.index in e.extra) +} diff --git a/alloy/modules/Stabilize.als b/alloy/modules/Stabilize.als new file mode 100644 index 0000000000000000000000000000000000000000..9ddb11320fa747e38a3818570dfbd928179c136b --- /dev/null +++ b/alloy/modules/Stabilize.als @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: Stabilize — production Λm scalar ≥0 with op-bound ‖Λm·(C∘Tp)‖≤1-ε. + * Cite: PRODUCTION.md §4 Gap-Λm-scalar CLOSED. + * Provenance: SpecDefined + */ + +module modules/Stabilize + +open modules/State + +sig Scalar {} + +/* Λm — lone scalar (NOT Foundry lambda_schedule vector). + * nonNeg=1 encodes Λm≥0; opBoundOK=1 encodes ‖Λm·(C∘Tp)‖_op ≤ 1-ε. + * Provenance: SpecDefined — PRODUCTION.md §4. */ +one sig LambdaM { + scalar: one Scalar, + nonNeg: Int, + opBoundOK: Int +} + +/* Foundry-style schedule vector — distinct from LambdaM. */ +sig ScheduleVector { + w0: lone Scalar, + w1: lone Scalar +} + +fact fact_LambdaM_not_schedule_vector { + some LambdaM.scalar + no sv: ScheduleVector | + LambdaM.scalar = sv.w0 and LambdaM.scalar = sv.w1 and some sv.w0 and some sv.w1 +} + +pred LambdaM_is_scalar_not_schedule { + some LambdaM.scalar + no sv: ScheduleVector | + LambdaM.scalar = sv.w0 and LambdaM.scalar = sv.w1 and some sv.w0 and some sv.w1 +} + +assert INV_LambdaM_scalar_placeholder { + /* INV_LambdaM_scalar_placeholder — Λm scalar ≠ schedule vector */ + LambdaM_is_scalar_not_schedule +} + +fact INV_LambdaM_scalar_not_schedule { + LambdaM_is_scalar_not_schedule +} + +/* Production: Λm ≥ 0 and op-bound flag. */ +fact fact_P4_lambda_m_scalar_bound { + LambdaM.nonNeg = 1 + LambdaM.opBoundOK = 1 +} + +pred lambda_m_scalar_bound_ok { + some LambdaM.scalar + LambdaM.nonNeg = 1 + LambdaM.opBoundOK = 1 +} + +assert P4_lambda_m_scalar_bound { + /* Production assert P4 — Λm scalar ≥0 with ‖Λm·(C∘Tp)‖≤1-ε flag */ + lambda_m_scalar_bound_ok +} + +sig Stabilized { + source: one State, + via: lone Scalar +} + +fact INV_stabilize_uses_LambdaM_scalar { + all st: Stabilized | no st.via or st.via = LambdaM.scalar +} diff --git a/alloy/modules/State.als b/alloy/modules/State.als new file mode 100644 index 0000000000000000000000000000000000000000..0736e1861bc921e91b5f5892049df84f2b069e2d --- /dev/null +++ b/alloy/modules/State.als @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: State — production Carrier Fin n → ℝ with ℓ∞ (abstract). + * Cite: PRODUCTION.md §1 Gap-Carrier CLOSED; FOUNDRY_J_CROSSLINKS §0–§2. + * Provenance: SpecDefined + */ + +module modules/State + +/* Discrete evolution carrier (abstract atoms; dim/norm in CarrierSpec). */ +sig State {} + +/* Finite time atoms for bounded evolution. */ +sig Time { + next: lone Time, + at: one State +} + +/* Total order spine on Time: linear chain, unique start. + * Provenance: derived — finite-scope safety for evolution. */ +fact INV_time_linear_chain { + one t: Time | no t.~next + all t: Time | lone t.next + all disj t1, t2: Time | t1 in t2.^next or t2 in t1.^next +} + +/* Evolution totality: every State is witnessed at some Time. */ +fact fact_evolution_total_on_State { + all s: State | some t: Time | t.at = s +} + +pred evolution_total_on_State { + all s: State | some t: Time | t.at = s +} + +assert INV_evolution_total_on_State { + evolution_total_on_State +} + +/* Instance tag: Foundry vs HCALC-native step shape (do not equate silently). */ +abstract sig InstanceKind {} +one sig FoundryInstance, HCALCInstance extends InstanceKind {} + +one sig ActiveInstance { + kind: one InstanceKind +} + +/* ---- Production Carrier: abstract dim n≥1, ℓ∞ ---- + * Provenance: SpecDefined — PRODUCTION.md §1. + * Numeric ℝ^n lives in Lean; Alloy encodes dim≥1 + LInf flags (no heavy Int arith). */ +abstract sig NormKind {} +one sig LInf extends NormKind {} + +one sig CarrierSpec { + /* dimPositive=1 encodes n≥1 (avoid bitblast of concrete n). */ + dimPositive: Int, + norm: one NormKind +} + +fact fact_P1_carrier_production { + CarrierSpec.dimPositive = 1 + CarrierSpec.norm = LInf +} + +pred carrier_linf_dim_ok { + CarrierSpec.dimPositive = 1 + CarrierSpec.norm = LInf +} + +assert P1_carrier_linf_dim { + /* Production assert P1 — Carrier abstract dim n≥1, ℓ∞ */ + carrier_linf_dim_ok +} + +/* Measure atom — no Int payload (Int bitblast hangs checks). */ +sig Measure {} + +sig StateMeasure { + of: one State, + m: one Measure +} + +fact INV_state_measure_functional { + all s: State | lone sm: StateMeasure | sm.of = s +} diff --git a/alloy/modules/Transform.als b/alloy/modules/Transform.als new file mode 100644 index 0000000000000000000000000000000000000000..1dc9baf2902f4dcdf94d3fb2b3caa529a048f851 --- /dev/null +++ b/alloy/modules/Transform.als @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2026 HCALC / Foundry J contributors + * SPDX-License-Identifier: AGPL-3.0-only + * + * Module: Transform — production T_p = diag(α), α_j = 1/(1+log p_{j mod 64}). + * Cite: PRODUCTION.md §2 Gap-Tp-from-P64 CLOSED. + * Numeric log not required in Alloy — SpecAlphaLaw flag + diagonal Tp. + * Provenance: SpecDefined + */ + +module modules/Transform + +open modules/State +open modules/PrimeIndex + +sig MultimodalInput { + encodes: one State +} + +sig TensorSpace { + support: set State +} + +/* α law kind — Spec law α_j=1/(1+log p_{j mod 64}) encoded as SpecAlphaLaw. */ +abstract sig AlphaLawKind {} +one sig SpecAlphaLaw extends AlphaLawKind {} + +/* T_p — diagonal prime-indexed map under SpecAlphaLaw. + * Provenance: SpecDefined — PRODUCTION.md §2. + * (Tp x)_j = α_j · x_j; φ = id on coordinates. */ +sig TpMap { + index: one PrimeLabel, + apply: State -> lone State, + /* isDiagonal=1 encodes diag(α) action */ + isDiagonal: Int, + alphaLaw: one AlphaLawKind +} + +fact fact_P2_tp_diag_spec_alpha { + all tp: TpMap | + tp.isDiagonal = 1 and tp.alphaLaw = SpecAlphaLaw +} + +pred tp_diag_spec_alpha_ok { + all tp: TpMap | + tp.isDiagonal = 1 and tp.alphaLaw = SpecAlphaLaw +} + +assert P2_tp_diag_spec_alpha { + /* Production assert P2 — Tp diagonal + SpecAlphaLaw */ + tp_diag_spec_alpha_ok +} + +fact INV_Tp_index_in_P64_or_extension { + all tp: TpMap | + tp.index in P64Carrier.primes or + (some e: PrimeExtension | tp.index in e.extra) +} + +fact INV_Tp_unique_per_index { + all disj a, b: TpMap | a.index != b.index +} + +pred multimodal_wired { + all m: MultimodalInput | some ts: TensorSpace | m.encodes in ts.support +} + +fact fact_multimodal_wired { + multimodal_wired +} + +assert INV_multimodal_tensor_wiring { + multimodal_wired +} diff --git a/alloy/run-production.sh b/alloy/run-production.sh new file mode 100644 index 0000000000000000000000000000000000000000..e23abeaa64238164c8ea440637eb2745d6d2a8b9 --- /dev/null +++ b/alloy/run-production.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# Copyright (C) 2026 HCALC contributors +# SPDX-License-Identifier: AGPL-3.0-only +# Per-command Alloy checks. Parse CLI stdout: "N. check NAME ... UNSAT|SAT" +set -euo pipefail +ROOT="$(cd "$(dirname "$0")" && pwd)" +JAR="$ROOT/tools/org.alloytools.alloy.dist.jar" +ALS="$ROOT/HCALC.als" +OUT="$ROOT/logs/per-check-prod" +LOG="$ROOT/logs/alloy-check.txt" +mkdir -p "$OUT" "$ROOT/logs" + +TS="$(date -Iseconds)" +{ + echo "=== HCALC Alloy PRODUCTION check ${TS} PT ===" + echo "als: $ALS" + java -jar "$JAR" version || true + echo + + mapfile -t LINES < <(java -jar "$JAR" commands "$ALS" 2>/dev/null) + + PASS=0; FAIL=0; RUN_OK=0; RUN_BAD=0 + + echo "=== checks (UNSAT = PASS) + runs (SAT = instance) ===" + for line in "${LINES[@]}"; do + KIND=""; CMD="" + if [[ "$line" =~ Check[[:space:]]+([A-Za-z0-9_]+) ]]; then + KIND=check; CMD="${BASH_REMATCH[1]}" + elif [[ "$line" =~ Run[[:space:]]+([A-Za-z0-9_]+) ]]; then + KIND=run; CMD="${BASH_REMATCH[1]}" + else + continue + fi + o="$OUT/$CMD" + rm -rf "$o" + set +e + # IMPORTANT: do not use -q; result is printed on stdout + out=$(java -jar "$JAR" exec -f -o "$o" -t text -c "$CMD" "$ALS" 2>&1) + rc=$? + set -e + # Match Alloy CLI summary line + summary=$(echo "$out" | rg -o '[0-9]+\.\s+(check|run)\s+\S+.*' | tail -1 || true) + if echo "$out" | rg -q '\bUNSAT\b'; then + res=UNSAT + elif echo "$out" | rg -q '\bSAT\b'; then + res=SAT + else + res="UNKNOWN(rc=$rc)" + fi + + if [[ "$KIND" == check ]]; then + if [[ "$res" == UNSAT ]]; then + printf '%-54s UNSAT (PASS)\n' "check $CMD" + PASS=$((PASS+1)) + else + printf '%-54s %s (FAIL)\n' "check $CMD" "$res" + echo "$out" | tail -5 + FAIL=$((FAIL+1)) + fi + else + if [[ "$res" == SAT ]]; then + printf '%-54s SAT (instance)\n' "run $CMD" + RUN_OK=$((RUN_OK+1)) + else + printf '%-54s %s\n' "run $CMD" "$res" + RUN_BAD=$((RUN_BAD+1)) + fi + fi + done + + echo + echo "=== summary ===" + echo "checks_UNSAT_PASS=$PASS checks_FAIL=$FAIL runs_SAT=$RUN_OK runs_other=$RUN_BAD" + echo "=== done ===" + [[ "$FAIL" -eq 0 ]] +} 2>&1 | tee "$LOG" diff --git a/alloy/run.sh b/alloy/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..71e9e98b87585c7c460682a1f5d3b6aa09a75e8d --- /dev/null +++ b/alloy/run.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Copyright (C) 2026 HCALC contributors +# SPDX-License-Identifier: AGPL-3.0-only +set -euo pipefail +ROOT="$(cd "$(dirname "$0")" && pwd)" +JAR="$ROOT/tools/org.alloytools.alloy.dist.jar" +ALS="$ROOT/HCALC.als" +OUT="$ROOT/logs/alloy-out" +LOG="$ROOT/logs/alloy-check.txt" +mkdir -p "$ROOT/logs" +if ! command -v java >/dev/null 2>&1; then + echo "Java missing; cannot run Alloy CLI" | tee "$LOG" + exit 1 +fi +if [[ ! -f "$JAR" ]]; then + echo "Missing Alloy jar at $JAR" | tee "$LOG" + exit 1 +fi +{ + echo "=== HCALC Alloy check $(date -Iseconds) ===" + echo "als: $ALS" + java -jar "$JAR" version || true + echo + echo "=== commands ===" + java -jar "$JAR" commands "$ALS" || true + echo + echo "=== exec (all commands) ===" + rm -rf "$OUT" + java -jar "$JAR" exec -f -o "$OUT" -t text -q "$ALS" || true + echo + if [[ -f "$OUT/receipt.json" ]]; then + echo "=== receipt.json (truncated) ===" + head -c 50000 "$OUT/receipt.json"; echo + fi + find "$OUT" -type f 2>/dev/null | head -80 || true + echo "=== done ===" +} 2>&1 | tee "$LOG" diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/docs/INVARIANTS.md b/docs/INVARIANTS.md new file mode 100644 index 0000000000000000000000000000000000000000..bfd046d3f43582e12d3525fa58f6f2a77f7c25af --- /dev/null +++ b/docs/INVARIANTS.md @@ -0,0 +1,51 @@ + + +# HCALC Invariant Inventory — Alloy ↔ Lean + +Maps every Alloy `assert` / `fact` / sealed check to Lean status (theorem vs axiom vs deferred). +Sources: `alloy/hcalc/**/*.als`, `spec/COHERENCE.md`, `spec/AXIOMS.md`, `spec/FOUNDRY_J_CROSSLINKS.md`. + +Provenance: `source-claim` | `axiom-gap` | `derived`. + +| Alloy ID | Informal statement | Provenance | Lean status | +|----------|-------------------|------------|-------------| +| **A1** `A1_P64_cardinality_and_distinct` | `#P_64=64`, distinct indices | source-claim | **L1 theorem** `P64List_length` (+ data) | +| **A1b** `A1b_P64_distinct_indices` | Distinct idx among carrier primes | derived | type-level `Fin 64` + list data | +| **A2** `A2_contractive_iff_gershgorin_bound` | contractive ↔ Gershgorin < 1-ε (+ power-iter) | source-claim | **L2** abstract `contractiveG` ↔ `GershgorinBelowMargin` (no matrix arith) | +| **A3** `A3_soft_project_when_q_over_margin` | soft-project when q > 1-ε | source-claim | **L4** `softProject` control flow | +| **A4** `A4_foundry_additive_only_if_Foundry_instance` | Foundry additive only if instance=Foundry | source-claim | **L3** `FoundryStep` def; tagged `StepForm` | +| **A5** `A5_PMAT_conservation_gated` | PMAT conservation if used | source-claim | not yet in Lean (optional surface) | +| **A6** `A6_guardian_reject_spectral_or_nonfinite` | reject ρ≥1 or non-finite | source-claim | not yet in Lean | +| **A7** `A7_gap_stub_definition_records` | definition-record presence for Λm, Ξ, C, Tp | axiom-gap | **L6 axioms** (named) | +| `INV_LambdaM_scalar_placeholder` | Λm lone scalar ≠ schedule vector | axiom-gap / G-Lm | **L6** `LambdaM : Nat` vs `ScheduleWeights` | +| `INV_step_shape_bridge_axiom_gap` | no silent Foundry↔HCALC equation | axiom-gap / G-SHAPE | **L7 deferred**; `StepForm` tags | +| `INV_prime_index_bounded_to_P64` | no unbounded prime stream | source-claim | `Tp : Fin 64 → …` | +| `INV_bounded_recursion_depth` | finite Time / lone next | derived | `iterateNested` on `Nat` | +| `INV_contract_measure_non_increase` | measure non-increase under Contract | axiom-gap / G-C | open (needs Gap-ContractAlg) | +| `INV_optimize_objective_axiom_gap` | objective underspecified | axiom-gap | open Gap-OptObj | +| `INV_converge_hyps_axiom_gap` | no Banach from narrative alone | axiom-gap | **L5** hypothesis skeleton only | +| `INV_evolve_respects_active_instance` | evolve matches ActiveInstance | derived | instance via `StepForm` | +| `INV_evolution_total_on_State` | every State on some Time | source-claim | `hcalcNestedStep_total` / `foundryStep_total` | +| `INV_Tp_index_in_P64_or_extension` | Tp index honesty | source-claim / G-Tp | `Fin 64` index | +| `INV_Tp_unique_per_index` | unique TpMap per index | derived | — | +| `INV_state_measure_functional` | lone measure per State | derived | — | +| `INV_stabilize_uses_LambdaM_scalar` | stabilize via Λm scalar | axiom-gap | nested uses `LambdaM` | +| `INV_time_linear_chain` | Time linear | derived | — | +| `INV_multimodal_tensor_wiring` | multimodal↔tensor wiring | derived | — | +| `INV_recursion_uses_prime_index` | recursion uses prime index | source-claim | `Tp` / `P64` | +| `INV_evolve_total_State_reachable` | evolve total | source-claim | totals above | +| `INV_extension_disjoint_or_empty` | prime extension honesty | derived | — | + +**Invariant count (Alloy sealed asserts + facts listed):** 25 rows above (A1–A7 + A1b + named INVs). + +## Alias GapIds (steering) + +| Alias | Spec GapId | Role | +|-------|------------|------| +| **G-SHAPE** | Gap-ShapeMap | Nested ≠ additive; no silent identify | +| **G-Lm** | Gap-Λm-scalar | No scalar Λm verb; lambda_schedule is vector | +| **G-C** | Gap-C-wrapper | spectral_analyze classifies; not C[·] | +| **G-Tp** | Gap-Tp-from-P64 | No T_p from P64/PrimeMask yet | diff --git a/docs/REMAINING.md b/docs/REMAINING.md new file mode 100644 index 0000000000000000000000000000000000000000..fc613982234aa06cbe9f02e0e5a74bcdec521593 --- /dev/null +++ b/docs/REMAINING.md @@ -0,0 +1,37 @@ + + +# Remaining Lean work after L1–L6 axioms + +What is left **after** accepting L6 opaque symbols. No fake proof claims. + +## Deferred / blocked + +| Item | Why blocked | +|------|-------------| +| **L7** bridge `HCALCStep ≃ FoundryStep` | Requires Spec discharge of **G-SHAPE / Gap-ShapeMap**; additive ≠ nested | +| Unique Banach fixed point (**L5** full) | Narrative PROPERTIES **41**; needs discharged `q < 1-ε` + complete metric structure | +| ℝ-valued Λm / spectral radius theorems | No Mathlib in first cut; Nat proxies only | +| Matrix Gershgorin proof of **A2** | Needs Jacobian carrier + Mathlib analysis | +| PMAT conservation (**A5**) in Lean | Optional Foundry surface; not HCALC-core | +| Guardian (**A6**) in Lean | Prop 55; Core verb may be absent | + +## Open research (Spec must define before Lean can prove) + +1. Explicit scalar Λm and stabilizing range (**G-Lm**). +2. Formal Ξ(t,·) operator laws (**Gap-Ξ**). +3. Tensor / Banach / F_p carrier for X_t (**Gap-Carrier**). +4. Convergence conditions for **nested** form (**Gap-Converge**). +5. In-step contraction algorithm realizing C (**G-C**, **Gap-ContractAlg**). +6. Optimization objective J (**Gap-OptObj**). +7. Construction of T_p from P64 / PrimeMask / PMAT (**G-Tp**). +8. Shape-map morphism nested ↔ additive (**G-SHAPE**). + +## Safe next Lean increments (no invention) + +- Port A5/A6 as optional gated modules once Spec marks them in-scope. +- Replace Nat proxies with Mathlib ℝ **after** Spec freezes types. +- Prove list properties of `P64List` (pairwise distinct, true primality) as data lemmas. +- Strengthen `iterateNested` induction lemmas under explicit measure hypotheses (when Gap-ContractAlg closes). diff --git a/j/README.md b/j/README.md new file mode 100644 index 0000000000000000000000000000000000000000..152bcbe790268413fd1621846dace8815c47af7e --- /dev/null +++ b/j/README.md @@ -0,0 +1,29 @@ + + +# HCALC J production Core + +**Owner:** Foundry J Core (implements) / HCALC Spec (`../spec/PRODUCTION.md`). +**Path (authoritative):** `/workspace/hcalc/j/` +**Locale:** `hcalc` (load `hcalc.ijs`). + +## Verbs (PRODUCTION.md) + +| Verb | Role | +|------|------| +| `tp_from_p64` | Diagonal Tp from P64 α (**spec-def**) | +| `c_wrap` | State scale-or-id (**spec-adapt**; ≠ Foundry soft_project **43**) | +| `lam_m_from_bound` | Scalar Λm from op-norm bound | +| `hcalc_xi_apply` | Ξ(t,y)=ξ·y+g | +| `hcalc_step` | NestedFaithful one step (**≠** `rec_step`) | +| `hcalc_run` | Iterate until residual < tol | + +InstanceBridge parameter table is diagnostic (`instance_bridge_table`) for **FoundryAdditive** mode — never `rfl` / never NestedFaithful ≡ prop **39**. + +## Smoke + +```bash +/home/box/j/j9.7/bin/jconsole -js "load 'hcalc.ijs'" "cocurrent 'hcalc'" "echo smoke ''" "exit ''" +``` diff --git a/j/hcalc.ijs b/j/hcalc.ijs new file mode 100644 index 0000000000000000000000000000000000000000..840574184b2072b70b2945f9cde4e71f3d3b656e --- /dev/null +++ b/j/hcalc.ijs @@ -0,0 +1,302 @@ +NB. ============================================================================= +NB. HCALC — Production Core verbs (PURE J) +NB. Copyright (C) 2026 HCALC contributors +NB. +NB. This program is free software: you can redistribute it and/or modify +NB. it under the terms of the GNU Affero General Public License as published +NB. by the Free Software Foundation, version 3 of the License. +NB. +NB. This program is distributed in the hope that it will be useful, +NB. but WITHOUT ANY WARRANTY; without even the implied warranty of +NB. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +NB. GNU Affero General Public License for more details. +NB. +NB. You should have received a copy of the GNU Affero General Public License +NB. along with this program. If not, see . +NB. SPDX-License-Identifier: AGPL-3.0-only +NB. ============================================================================= +NB. +NB. Formulas: ../spec/PRODUCTION.md ONLY (exact). +NB. Path: /workspace/hcalc/j/ (NOT foundry-j/j/) +NB. Cite Foundry: P64, spectral_analyze (load foundry-j). softProjectScale idea +NB. from soft_project prop43 — do NOT call soft_project on (xi;lam) for C. +NB. ShapeMap = InstanceBridge (parameter table). hcalc_step ≠ rec_step / Foundry39. +NB. +NB. Verbs: tp_from_p64 c_wrap lam_m_from_bound hcalc_xi_apply +NB. hcalc_step hcalc_run +NB. Locale: hcalc + +cocurrent 'hcalc' + +NB. ── Defaults (PRODUCTION parameters) ──────────────────────────────────────── +EPS_DEFAULT =: 0.05 NB. tier T2 +DELTA_DEFAULT =: 1e_12 +TOL_DEFAULT =: 1e_6 +XI_UNIFORM =: 1. +BRIDGE_MODE =: 'InstanceBridge' + +NB. Load Foundry cite hooks (idempotent) +hcalc_ensure_foundry =: 3 : 0 + NB. 4!:0 returns _1 if undefined; 0 if noun + if. _1 = 4!:0 <'P64_foundry_' do. + load '/workspace/foundry-j/j/foundry.ijs' + end. + cocurrent 'hcalc' + i. 0 0 +) +hcalc_ensure_foundry '' +cocurrent 'hcalc' + +NB. ── Helpers ───────────────────────────────────────────────────────────────── + +NB. tp_alpha n — α_j = 1 / (1 + ln p_{j mod 64}) [PRODUCTION §2] +NB. Use dyadic 1%z (not monadic %z) for clear RTL. +tp_alpha =: 3 : 0 + n =. <. 0 ". ": y + if. n < 1 do. 0 $ 0. return. end. + primes =. (64 | i. n) { P64_foundry_ + z =. 1 + ^. primes + 1 % z +) + +NB. diag_from_alpha α — D(Tp)=diag(α) +diag_from_alpha =: 3 : 0 + a =. , y + n =. # a + if. 0 = n do. 0 0 $ 0. return. end. + a * =/~ i. n +) + +NB. soft_project_scale q,eps — s=(1-ε)/q if q>1-ε else 1 +NB. Numeric softProjectScale (PRODUCTION §3). NOT Foundry soft_project verb. +soft_project_scale =: 3 : 0 + 'q eps' =. 2 {. (, y) , 0 , EPS_DEFAULT + target =. 1 - eps + if. q > target do. target % q else. 1. end. +) + +NB. q_of_tp n,eps — ‖D(Tp)‖_est via Foundry spectral_analyze on diag(α) +q_of_tp =: 3 : 0 + 'n eps' =. 2 {. (, y) , 1 , EPS_DEFAULT + n =. <. 0 ". ": n + a =. tp_alpha n + J =. diag_from_alpha a + sr =. J spectral_analyze_foundry_ eps + sr_radius_foundry_ sr +) + +NB. c_op_norm n,eps — ‖C∘Tp‖_op = max_j |s·α_j| (diagonal) +c_op_norm =: 3 : 0 + 'n eps' =. 2 {. (, y) , 1 , EPS_DEFAULT + n =. <. 0 ". ": n + a =. tp_alpha n + q =. q_of_tp n , eps + s =. soft_project_scale q , eps + >./ | (s * a) +) + +NB. residual_linf — ‖x-y‖_∞ +residual_linf =: 4 : '>./ | (,x) - ,y' + +NB. ── 1. tp_from_p64 (PRODUCTION §2) ───────────────────────────────────────── +NB. Monad: tp_from_p64 x → Tp(x) +tp_from_p64 =: 3 : 0 + NB. Unbox/ravel: Verify may pass boxed vectors + xv =. , >^:L. y + if. 32 = 3!:0 xv do. xv =. , > xv end. + a =. tp_alpha # xv + a * xv +) + +NB. ── 2. c_wrap (PRODUCTION §3) ────────────────────────────────────────────── +NB. Scales the STATE vector: C(x)=s·x. Does NOT call Foundry soft_project. +NB. Monad: c_wrap x (ε=T2). Dyad: eps c_wrap x +c_wrap =: 3 : 0 + EPS_DEFAULT c_wrap y +: + eps =. x + xv =. , >^:L. y + n =. # xv + if. 0 = n do. xv return. end. + q =. q_of_tp n , eps + s =. soft_project_scale q , eps + s * xv +) + +NB. ── 3. lam_m_from_bound (PRODUCTION §4) ──────────────────────────────────── +NB. Λm = min(1, (1-ε) / (‖C∘Tp‖_op + δ)) +NB. Monad: lam_m_from_bound n. Dyad: eps lam_m_from_bound n +NB. Also accept boxed (opnorm;eps;delta) for direct bound form. +lam_m_from_bound =: 3 : 0 + EPS_DEFAULT lam_m_from_bound y +: + eps =. x + NB. If y is a length≥1 numeric list starting with op-norm (not a plain dim), + NB. treat as (opn[,eps[,delta]]) when #y>1 or y is boxed. + if. 32 = 3!:0 y do. + args =. , > y + opn =. 0 { args , 0 + if. 1 < # args do. eps =. 1 { args end. + delta =. 2 { args , DELTA_DEFAULT + else. + n =. <. 0 ". ": y + if. n < 1 do. 0. return. end. + opn =. c_op_norm n , eps + delta =. DELTA_DEFAULT + end. + 1. <. (1 - eps) % (opn + delta) +) + +NB. ── 4. hcalc_xi_apply (PRODUCTION §5) ────────────────────────────────────── +NB. Ξ(t,y)=ξ_t·y+g_t. Default Uniform ξ=1, g=0. +NB. Monad: hcalc_xi_apply y → y +NB. Dyad: (xi;g) hcalc_xi_apply y or xi hcalc_xi_apply y +hcalc_xi_apply =: 3 : 0 + , y +: + xv =. , y + xb =. boxxopen x + xi =. 0 ". ": > 0 { xb + if. 1 < # xb do. + g =. , > 1 { xb + else. + g =. (# xv) $ 0. + end. + if. 0 = # g do. g =. (# xv) $ 0. end. + if. (# g) ~: # xv do. g =. (# xv) $ {. g , 0. end. + (xi * xv) + g +) + +NB. ── 5. hcalc_step (PRODUCTION nested; ≠ rec_step) ────────────────────────── +NB. X' = Ξ(t, Λm·C(Tp(X))) = ξ·(Λm·C(Tp(X))) + g +NB. Monad: hcalc_step X +NB. Dyad: (eps;xi;g) hcalc_step X +NB. Returns xnext (vector). Info via hcalc_step_info if needed. +NB. bridgeMode=InstanceBridge — NOT FoundryAdditive identity. +hcalc_step =: 3 : 0 + (EPS_DEFAULT ; XI_UNIFORM ; '') hcalc_step y +: + xv =. , >^:L. y + xb =. boxxopen x + eps =. 0 ". ": > 0 { xb , 1 { xb , 2 { xb else. g =. '' end. + if. 0 = # g do. g =. (# xv) $ 0. end. + if. (# g) ~: # xv do. g =. (# xv) $ {. g , 0. end. + n =. # xv + TpX =. tp_from_p64 xv + CX =. eps c_wrap TpX + lam =. eps lam_m_from_bound n + mid =. lam * CX + (xi ; g) hcalc_xi_apply mid +) + +NB. hcalc_step_info — same step, returns xnext ; <(q;eps;lam;xi;residual;BRIDGE_MODE)> +hcalc_step_info =: 3 : 0 + (EPS_DEFAULT ; XI_UNIFORM ; '') hcalc_step_info y +: + xv =. , >^:L. y + xb =. boxxopen x + eps =. 0 ". ": > 0 { xb , 1 { xb , 2 { xb else. g =. '' end. + if. 0 = # g do. g =. (# xv) $ 0. end. + n =. # xv + a =. tp_alpha n + q =. q_of_tp n , eps + TpX =. a * xv + s =. soft_project_scale q , eps + CX =. s * TpX + lam =. eps lam_m_from_bound n + mid =. lam * CX + xnext =. (xi ; g) hcalc_xi_apply mid + res =. xv residual_linf xnext + NB. Double-box so 'xn info'=. leaves info as one box; >info yields field boxes + NB. (Verify: boxed=.>info then (<'InstanceBridge') e. boxed) + info =. q ; eps ; lam ; xi ; res ; BRIDGE_MODE + xnext ; < +hcalc_run =: 3 : 0 + (200 ; TOL_DEFAULT ; EPS_DEFAULT ; XI_UNIFORM ; '') hcalc_run y +: + x0 =. , >^:L. y + xb =. boxxopen x + max_steps =. <. 0 ". ": > 0 { xb , <200 + tol =. 0 ". ": > 1 { xb , 2 { xb , 3 { xb , 4 { xb else. g =. '' end. + if. 0 = max_steps do. max_steps =. 200 end. + if. 0 = tol do. tol =. TOL_DEFAULT end. + if. 0 = # g do. g =. (# x0) $ 0. end. + + xc =. x0 + history =. 0 $ a: + converged =. 0 + steps_done =. 0 + lam =. eps lam_m_from_bound # x0 + + for_t. i. max_steps do. + xnext =. (eps ; xi ; g) hcalc_step xc + resid =. xc residual_linf xnext + history =. history , <(t ; resid ; lam) + xc =. xnext + steps_done =. t + 1 + if. resid < tol do. converged =. 1 break. end. + end. + + HCALC_STATE =: xc ; converged ; steps_done ; ^:L. y + xb =. boxxopen x + eps =. 0 ". ": > 0 { xb , 1 { xb , 2 { xb else. g =. '' end. + if. 0 = # g do. g =. (# xv) $ 0. end. + n =. # xv + lam =. eps lam_m_from_bound n + Tx =. eps c_wrap tp_from_p64 xv + (xi * xv) + (lam * Tx) + g +) + + +NB. ── Verify / Spec aliases (cite surface) ──────────────────────────────────── +NB. P64 under hcalc name (H-A1); copy after Foundry load +P64_hcalc_ =: P64_foundry_ + +NB. q_est_from_alpha α — ‖D(Tp)‖_est for diagonal = max|α| (H-A2/H-A6) +q_est_from_alpha =: 3 : '>./ | , >^:L. y' + +NB. c_wrap_check_hcalc_ — H-A3 assertion helper (scale-or-id on state) +c_wrap_check_hcalc_ =: 3 : 0 + s =. soft_project_scale 2 , 0.05 + assert. s = 0.95 % 2 + s2 =. soft_project_scale 0.5 , 0.05 + assert. s2 = 1 + x =. 1 1 1 1 + assert. (0.05 c_wrap tp_from_p64 x) -: tp_from_p64 x + 1 +) + +cocurrent 'base' diff --git a/lean/.gitignore b/lean/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..bfb30ec8c762cc74d4ee1593ab48fc091d04ca4c --- /dev/null +++ b/lean/.gitignore @@ -0,0 +1 @@ +/.lake diff --git a/lean/Hcalc.lean b/lean/Hcalc.lean new file mode 100644 index 0000000000000000000000000000000000000000..50ddf3d9f1d26cfe8a4a6fe4f11074ae96095b01 --- /dev/null +++ b/lean/Hcalc.lean @@ -0,0 +1,12 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only +-/ +import Hcalc.RealStub +import Hcalc.Carrier +import Hcalc.Foundry +import Hcalc.Axioms +import Hcalc.Pipeline +import Hcalc.Convergence +import Hcalc.Invariants +import Hcalc.Production diff --git a/lean/Hcalc/Axioms.lean b/lean/Hcalc/Axioms.lean new file mode 100644 index 0000000000000000000000000000000000000000..2443e04a3ea1fa854d5ae8667233aef19b84b07a --- /dev/null +++ b/lean/Hcalc/Axioms.lean @@ -0,0 +1,247 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +PRODUCTION.md close-all-gaps: L6 symbols are DEFS (not opaque axioms). +L7 = InstanceBridge (Option B) — NOT rfl / NOT Foundry39 ≡ nested. +Real = Mathlib ℝ (Gap-Real-arith CLOSED). Gap-Foundry-* may remain; zero production Gap-* axioms. +-/ + +import Hcalc.RealStub +import Hcalc.Carrier +import Hcalc.Foundry + +namespace Hcalc + +open Foundry + +/-! ## Production parameters (PRODUCTION.md §Parameters) -/ + +/-- Default ε = T2 = 0.05 (epsDefault from RealStub). -/ +noncomputable abbrev epsProd : Scalar := epsDefault +/-- δ = 10^{-12} guard. -/ +noncomputable abbrev deltaProd : Scalar := deltaGuard +/-- Residual tolerance 10^{-6}. -/ +noncomputable abbrev tolProd : Scalar := tolDefault + +/-! ## Gap-Tp-from-P64 CLOSED — diagonal PrimeMask from P64 (Spec-only α) -/ + +/-- Prime at coordinate `j` via `P64 (j mod 64)` (PRODUCTION.md §2). -/ +def primeAt {n : Nat} (j : Fin n) : Nat := + P64 ⟨j.val % 64, Nat.mod_lt j.val (by decide : (0 : Nat) < 64)⟩ + +/-- +α_j = 1 / (1 + log p_{j mod 64}). +Spec-only weights — **not** a Foundry-native identity. +-/ +noncomputable def alpha {n : Nat} (j : Fin n) : Scalar := + realDiv (1 : Real) ((1 : Real) + realLog (natToReal (primeAt j))) + +/-- +`Tp` — diagonal action `(Tp x)_j = α_j * x_j` (PRODUCTION.md §2). +Gap-Tp-from-P64 CLOSED as **def**. +-/ +noncomputable def Tp {n : Nat} (x : Carrier n) : Carrier n := + fun j => alpha j * x j + +/-- Jacobian of Tp is diag(α); Gershgorin / ℓ∞ op-norm estimate = max |α_j|. -/ +noncomputable def qEstTp {n : Nat} : Scalar := + finMax (fun j : Fin n => ‖alpha (n := n) j‖ᵣ) + +/-! ## Gap-C-wrapper CLOSED — softScale-or-id on state (NOT Foundry softProject on schedules) -/ + +/-- +Scale factor for in-step C: softScaleFactor(ε, q) with q = ‖D(Tp)‖_est. +Uses softScaleFactor numeric law (Spec wiring). **Does not** claim +`C = Foundry.softProject` on (Ξ, Λ) schedule weights. +-/ +noncomputable def cScale (n : Nat) (ε : Scalar) : Scalar := + softScaleFactor ε (qEstTp (n := n)) + +/-- +`C(x) = s • x` with `s = softScale-or-id` (PRODUCTION.md §3). +Gap-C-wrapper CLOSED as **def**. +-/ +noncomputable def C {n : Nat} (ε : Scalar) (x : Carrier n) : Carrier n := + vsmul (cScale n ε) x + +/-- Gap-ContractAlg CLOSED: Gershgorin estimate then softScale-or-id (then Λm). -/ +noncomputable def contractAlg_q {n : Nat} : Scalar := qEstTp (n := n) + +/-- ContractAlg step 2: apply C. -/ +noncomputable def contractAlg_applyC {n : Nat} (ε : Scalar) (x : Carrier n) : Carrier n := + C (n := n) ε x + +/-! ## Gap-Λm-scalar CLOSED -/ + +/-- ‖C ∘ Tp‖_op on ℓ∞ for diagonal: max_j |cScale * α_j|. -/ +noncomputable def opNorm_C_circ_Tp (n : Nat) (ε : Scalar) : Scalar := + finMax (fun j : Fin n => ‖cScale n ε * alpha (n := n) j‖ᵣ) + +/-- +Λm = min(1, (1-ε) / (‖C∘Tp‖_op + δ)) (PRODUCTION.md §4). +Gap-Λm-scalar CLOSED as **def**. +-/ +noncomputable def LambdaM (n : Nat) (ε δ : Scalar) : Scalar := + realMin (1 : Real) (realDiv ((1 : Real) - ε) (opNorm_C_circ_Tp n ε + δ)) + +/-- Default production Λm (ε=T2, δ=guard). -/ +noncomputable def LambdaM_prod (n : Nat) : Scalar := + LambdaM n epsProd deltaProd + +/-! ## Gap-Ξ CLOSED — Ξ(t,y) = ξ_t · y + g_t -/ + +/-- Uniform xi_schedule: ξ_t = 1 for all t (PRODUCTION.md). -/ +noncomputable def xi (_t : Time) : Scalar := (1 : Real) + +/-- Default kick g_t = 0. -/ +noncomputable def gDefault (n : Nat) (_t : Time) : Carrier n := + vzero n + +/-- +`Xi t y = ξ_t • y + g_t` (PRODUCTION.md §5). +Gap-Ξ CLOSED as **def**. +-/ +noncomputable def Xi {n : Nat} (t : Time) (y : Carrier n) + (g : Time → Carrier n := gDefault n) : Carrier n := + vadd (vsmul (xi t) y) (g t) + +/-- Xi under Uniform + zero kick reduces to identity on y. -/ +theorem Xi_uniform_zero_kick {n : Nat} (t : Time) (y : Carrier n) : + Xi (n := n) t y (gDefault n) = y := by + funext j + simp only [Xi, vadd, vsmul, gDefault, vzero, xi, real_one_mul, real_add_zero] + +/-! ## Composition helpers -/ + +/-- C ∘ Tp as a self-map on Carrier. -/ +noncomputable def C_circ_Tp {n : Nat} (ε : Scalar) (x : Carrier n) : Carrier n := + C (n := n) ε (Tp x) + +/-- Scaled stabilized branch: Λm • (C ∘ Tp)(x). -/ +noncomputable def stabilized {n : Nat} (ε δ : Scalar) (x : Carrier n) : Carrier n := + vsmul (LambdaM n ε δ) (C_circ_Tp (n := n) ε x) + +/-! ## Gap-OptObj CLOSED — residual ℓ∞ -/ + +/-- +J(X) = ‖X - step(X)‖_∞ with step supplied (PRODUCTION.md §9). +Gap-OptObj CLOSED as **def**. +-/ +noncomputable def residualNorm {n : Nat} (x x' : Carrier n) : Scalar := + ‖vsub x x'‖∞ + +/-- OptObj synonym: residual value. -/ +noncomputable abbrev OptObjValue := Scalar + +/-- Evaluate residual objective given a step map. -/ +noncomputable def evalOptObj {n : Nat} (step : Carrier n → Carrier n) (x : Carrier n) : OptObjValue := + residualNorm x (step x) + +/-- Iterate `f` for `k` steps (optimize = iterate to tol — loop spec). -/ +noncomputable def iterate {n : Nat} (f : Carrier n → Carrier n) : Nat → Carrier n → Carrier n + | 0, x => x + | k + 1, x => iterate f k (f x) + +/-- Stop predicate: residual < tol. -/ +noncomputable def residualBelowTol {n : Nat} (step : Carrier n → Carrier n) + (tol : Scalar) (x : Carrier n) : Prop := + evalOptObj step x <ᵣ tol + +/-! ## L7 Gap-ShapeMap CLOSED — InstanceBridge (Option B), NOT rfl -/ + +/-- +InstanceBridge parameter table (PRODUCTION.md §6 Option B). +Holds Spec assignments relating Foundry-shaped diagnostics to HCALC symbols. +**Does not** assert `hcalcStep = FoundryStep` / Foundry39 ≡ nested. +-/ +structure InstanceBridge (n : Nat) (ε δ : Scalar) where + /-- T assigned to C ∘ Tp under the bridge (assignment, not identity). -/ + T_is_C_circ_Tp : True := True.intro + /-- Λ_vec assigned to Λm · 1 (scalar broadcast ≠ Foundry schedule law). -/ + Lambda_vec_is_LambdaM : True := True.intro + /-- Ξ_vec assigned to ξ_t from HCALC xi_schedule (≠ Foundry Ξ_t identity). -/ + Xi_vec_is_xi : True := True.intro + /-- g assigned to g_t. -/ + g_is_g_t : True := True.intro + /-- bridgeMode tag. -/ + bridgeMode : Unit := () + +/-- Default production InstanceBridge witness (Option B record). -/ +def instanceBridge_prod (n : Nat) : InstanceBridge n epsProd deltaProd := {} + +/-- +Cite-only Foundry-shaped diagnostic on HCALC Carrier (Option B): +`toFoundryStep = ξ•x + Λm•(C∘Tp)(x) + g`. +**Not** claimed equal to `hcalcStep` (extra ξ•x drift term). +-/ +noncomputable def toFoundryStep {n : Nat} (ε δ : Scalar) (t : Time) + (x : Carrier n) (g : Time → Carrier n := gDefault n) : Carrier n := + vadd (vadd (vsmul (xi t) x) (vsmul (LambdaM n ε δ) (C_circ_Tp (n := n) ε x))) (g t) + +/-- Nested HCALC step body (also in Pipeline): ξ • (Λm • (C∘Tp)(x)) + g. -/ +noncomputable def hcalcStepCore {n : Nat} (ε δ : Scalar) (t : Time) + (x : Carrier n) (g : Time → Carrier n := gDefault n) : Carrier n := + Xi (n := n) t (stabilized (n := n) ε δ x) g + +/-- +L7: under InstanceBridge, the parameter table matches Spec assignments. +Witness is the structure itself — **not** `rfl` of step morphisms. +-/ +theorem InstanceBridge.param_table {n : Nat} {ε δ : Scalar} + (b : InstanceBridge n ε δ) : + b.T_is_C_circ_Tp = True.intro ∧ + b.Lambda_vec_is_LambdaM = True.intro ∧ + b.Xi_vec_is_xi = True.intro ∧ + b.g_is_g_t = True.intro := + ⟨rfl, rfl, rfl, rfl⟩ + +/-- +L7 diagnostic expansion: `toFoundryStep` unfolds to additive Foundry shape on Carrier. +Does **not** equate to `hcalcStepCore`. +-/ +theorem toFoundryStep_eq {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) + (g : Time → Carrier n := gDefault n) : + toFoundryStep (n := n) ε δ t x g = + vadd (vadd (vsmul (xi t) x) (vsmul (LambdaM n ε δ) (C_circ_Tp (n := n) ε x))) (g t) := + rfl + +/-- +L7 nested expansion: `hcalcStepCore` unfolds to Ξ(t, Λm · C(Tp x)). +-/ +theorem hcalcStepCore_eq {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) + (g : Time → Carrier n := gDefault n) : + hcalcStepCore (n := n) ε δ t x g = + Xi (n := n) t (vsmul (LambdaM n ε δ) (C (n := n) ε (Tp x))) g := + rfl + +/-- +Shape difference (documentary theorem): when g = 0 and ξ = 1, +`toFoundryStep x = x + stabilized x` while `hcalcStepCore x = stabilized x`. +They agree iff `stabilized x = 0` or after dropping the free ξ·x channel (Option A/C). +-/ +theorem toFoundryStep_vs_hcalc_uniform_zero {n : Nat} (ε δ : Scalar) (t : Time) + (x : Carrier n) : + toFoundryStep (n := n) ε δ t x (gDefault n) = + vadd x (stabilized (n := n) ε δ x) ∧ + hcalcStepCore (n := n) ε δ t x (gDefault n) = + stabilized (n := n) ε δ x := by + constructor + · funext j + simp only [toFoundryStep, stabilized, C_circ_Tp, vadd, vsmul, gDefault, vzero, xi, + real_one_mul, real_add_zero] + · funext j + simp only [hcalcStepCore, Xi_uniform_zero_kick, stabilized, C_circ_Tp] + +/-- Definition-record markers for A7 / Alloy (SpecDefined). -/ +theorem definitionRecord_Tp : True := True.intro +theorem definitionRecord_C : True := True.intro +theorem definitionRecord_LambdaM : True := True.intro +theorem definitionRecord_Xi : True := True.intro +theorem definitionRecord_Carrier : True := True.intro +theorem definitionRecord_OptObj : True := True.intro +theorem definitionRecord_ContractAlg : True := True.intro +theorem definitionRecord_ShapeMap : True := True.intro +theorem definitionRecord_Converge : True := True.intro + +end Hcalc diff --git a/lean/Hcalc/Carrier.lean b/lean/Hcalc/Carrier.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b49e6dc275e89bd66c30021657803e0659d62c4 --- /dev/null +++ b/lean/Hcalc/Carrier.lean @@ -0,0 +1,63 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +Gap-Carrier CLOSED (PRODUCTION.md §1): HCALC.Carrier = Fin n → ℝ with ℓ∞. +-/ + +import Hcalc.RealStub + +namespace Hcalc + +abbrev Carrier (n : Nat) : Type := Fin n → Real +abbrev Time : Type := Nat +abbrev Intermediate (n : Nat) : Type := Carrier n +abbrev State (n : Nat) : Type := Carrier n + +noncomputable def vzero (n : Nat) : Carrier n := fun _ => (0 : Real) +noncomputable def vadd {n : Nat} (x y : Carrier n) : Carrier n := fun j => x j + y j +noncomputable def vneg {n : Nat} (x : Carrier n) : Carrier n := fun j => -(x j) +noncomputable def vsub {n : Nat} (x y : Carrier n) : Carrier n := fun j => x j - y j +noncomputable def vsmul {n : Nat} (a : Scalar) (x : Carrier n) : Carrier n := fun j => a * x j +noncomputable def linf {n : Nat} (x : Carrier n) : Scalar := finMax (fun j => ‖x j‖ᵣ) + +notation "‖" x "‖∞" => linf x + +axiom linf_all_zero_eq_zero (n : Nat) (x : Carrier n) + (h : ∀ j, ‖x j‖ᵣ = (0 : Real)) : ‖x‖∞ = (0 : Real) + +/-- ℓ∞ norm is nonnegative. -/ +axiom linf_nonneg {n : Nat} (x : Carrier n) : (0 : Real) ≤ᵣ ‖x‖∞ + +theorem carrier_ext_of_linf_sub_eq_zero {n : Nat} (x y : Carrier n) + (h : ‖vsub x y‖∞ = (0 : Real)) : x = y := by + funext j + have hj := finMax_abs_eq_zero_of (fun k => vsub x y k) h j + have hsub : x j - y j = (0 : Real) := hj + have : x j = (x j - y j) + y j := by + have hcancel : (-(y j)) + y j = (0 : Real) := by + rw [real_add_comm] + exact real_neg_add_cancel (y j) + calc + x j = x j + (0 : Real) := (real_add_zero (x j)).symm + _ = x j + ((-(y j)) + y j) := by rw [hcancel] + _ = (x j + (-(y j))) + y j := (real_add_assoc (x j) (-(y j)) (y j)).symm + _ = (x j - y j) + y j := rfl + rw [this, hsub, real_zero_add] + +theorem linf_vzero (n : Nat) : ‖vzero n‖∞ = (0 : Real) := + linf_all_zero_eq_zero n (vzero n) (fun _ => real_abs_zero) + +theorem vsmul_zero_left {n : Nat} (x : Carrier n) : vsmul (0 : Real) x = vzero n := by + funext j + exact real_zero_mul (x j) + +theorem vsmul_vadd {n : Nat} (a : Scalar) (x y : Carrier n) : + vsmul a (vadd x y) = vadd (vsmul a x) (vsmul a y) := by + funext j + exact real_mul_add a (x j) (y j) + +noncomputable abbrev scalarMul {n : Nat} (a : Scalar) (x : Intermediate n) : Intermediate n := + vsmul a x + +end Hcalc diff --git a/lean/Hcalc/Convergence.lean b/lean/Hcalc/Convergence.lean new file mode 100644 index 0000000000000000000000000000000000000000..335ea467b0f01f755e14a15e2cd6c6d02cbbfc18 --- /dev/null +++ b/lean/Hcalc/Convergence.lean @@ -0,0 +1,121 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +L5 / Gap-Converge CLOSED under HypContractive (PRODUCTION.md §8). +Unique fixed point for nested step; residual lemmas. Freehand calc proofs; Mathlib ℝ. +-/ + +import Hcalc.Axioms +import Hcalc.Foundry +import Hcalc.Pipeline + +namespace Hcalc.Convergence + +open Hcalc Pipeline Foundry + +/-! ## Hypothesis bundles -/ + +/-- +HypContractive (PRODUCTION.md §8): + |ξ| · ‖Λm · (C ∘ Tp)‖_op < 1 - ε +Packaged as an explicit Lipschitz bound with `q < 1` (strict contraction). +-/ +structure HypContractive {n : Nat} (ε : Scalar) (F : Carrier n → Carrier n) where + q : Scalar + /-- Production margin form: q < 1 - ε. -/ + q_lt_margin : q <ᵣ ((1 : Scalar) - ε) + /-- Strict contraction modulus: q < 1. -/ + q_lt_one : q <ᵣ (1 : Scalar) + /-- Lipschitz: ‖F x - F y‖_∞ ≤ q · ‖x - y‖_∞. -/ + lip : ∀ x y : Carrier n, ‖vsub (F x) (F y)‖∞ ≤ᵣ q * ‖vsub x y‖∞ + +/-- Fixed-point predicate. -/ +def IsFixedPoint {n : Nat} (F : Carrier n → Carrier n) (x : Carrier n) : Prop := + F x = x + +/-- Structural: HypContractive packs `q < 1 - ε`. -/ +theorem HypContractive.q_lt_one_sub_eps {n : Nat} {ε : Scalar} {F : Carrier n → Carrier n} + (h : HypContractive (n := n) ε F) : + h.q <ᵣ ((1 : Scalar) - ε) := + h.q_lt_margin + +-- ℓ∞ nonneg: see `Hcalc.linf_nonneg` (Carrier). + +/-! ## L5 — uniqueness of fixed point under HypContractive -/ + +/-- +L5 uniqueness (PRODUCTION.md §8): a strict ℓ∞ contraction has at most one fixed point. +-/ +theorem unique_fixed_point {n : Nat} {ε : Scalar} {F : Carrier n → Carrier n} + (h : HypContractive (n := n) ε F) + (x y : Carrier n) + (hx : IsFixedPoint F x) (hy : IsFixedPoint F y) : x = y := by + unfold IsFixedPoint at hx hy + have hlip := h.lip x y + have hrew : vsub (F x) (F y) = vsub x y := by + rw [hx, hy] + rw [hrew] at hlip + have hnn : (0 : Real) ≤ᵣ ‖vsub x y‖∞ := linf_nonneg (vsub x y) + have hzero : ‖vsub x y‖∞ = (0 : Real) := + real_contract_force_zero ‖vsub x y‖∞ h.q hnn h.q_lt_one hlip + exact carrier_ext_of_linf_sub_eq_zero x y hzero + +/-! ## Residual lemmas -/ + +/-- At a fixed point, residual is zero. -/ +theorem residual_at_fixed_point {n : Nat} (F : Carrier n → Carrier n) (x : Carrier n) + (hx : IsFixedPoint F x) : evalOptObj F x = (0 : Real) := by + unfold evalOptObj residualNorm IsFixedPoint at * + have : vsub x (F x) = vzero n := by + funext j + change x j - (F x) j = (0 : Real) + rw [hx] + exact real_sub_self (x j) + rw [this, linf_vzero] + +/-- Existence under zero kick: stabilized (linear through origin) fixes 0. -/ +theorem stabilized_fixes_zero {n : Nat} (ε δ : Scalar) : + IsFixedPoint (stabilized (n := n) ε δ) (vzero n) := by + unfold IsFixedPoint stabilized C_circ_Tp C Tp vsmul vzero + funext j + -- (Λm * (cScale * (α * 0))) = 0 + simp only [real_mul_zero] + +/-- L5 existence+uniqueness for stabilized under Hyp: unique FP is 0. -/ +theorem unique_fp_stabilized_of_hyp {n : Nat} {ε δ : Scalar} + (h : HypContractive (n := n) ε (stabilized (n := n) ε δ)) : + IsFixedPoint (stabilized (n := n) ε δ) (vzero n) ∧ + ∀ y : Carrier n, IsFixedPoint (stabilized (n := n) ε δ) y → y = vzero n := by + refine ⟨stabilized_fixes_zero (n := n) ε δ, ?_⟩ + intro y hy + exact unique_fixed_point h y (vzero n) hy (stabilized_fixes_zero (n := n) ε δ) + +/-- Nested step under Uniform+zero kick equals stabilized; zero is a fixed point. -/ +theorem step_fixes_zero {n : Nat} (ε δ : Scalar) (t : Time) : + IsFixedPoint (step (n := n) ε δ t) (vzero n) := by + unfold IsFixedPoint + rw [step_eq_stabilized] + exact stabilized_fixes_zero (n := n) ε δ + +/-- L5 for nested `step` under HypContractive. -/ +theorem unique_fp_step_of_hyp {n : Nat} {ε δ : Scalar} (t : Time) + (h : HypContractive (n := n) ε (step (n := n) ε δ t)) : + IsFixedPoint (step (n := n) ε δ t) (vzero n) ∧ + ∀ y : Carrier n, IsFixedPoint (step (n := n) ε δ t) y → y = vzero n := by + refine ⟨step_fixes_zero (n := n) ε δ t, ?_⟩ + intro y hy + exact unique_fixed_point h y (vzero n) hy (step_fixes_zero (n := n) ε δ t) + +/-- Residual of step at 0 is 0. -/ +theorem J_at_zero {n : Nat} (ε δ : Scalar) (t : Time) : + J (n := n) ε δ t (vzero n) = (0 : Real) := + residual_at_fixed_point (step (n := n) ε δ t) (vzero n) (step_fixes_zero (n := n) ε δ t) + +/-- Foundry `contractiveG` matches L2 definitional form under hyps. -/ +theorem contractiveG_from_bound {n : Nat} (Jmat : Mat n) (ε : Scalar) + (h : gershgorinBound Jmat <ᵣ ((1 : Scalar) - ε)) : + contractiveG Jmat ε := + (contractiveG_iff Jmat ε).mpr h + +end Hcalc.Convergence diff --git a/lean/Hcalc/Foundry.lean b/lean/Hcalc/Foundry.lean new file mode 100644 index 0000000000000000000000000000000000000000..3015954d13e344423bee372638d4334334de49f8 --- /dev/null +++ b/lean/Hcalc/Foundry.lean @@ -0,0 +1,144 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +Foundry instantiation layer (L1–L4): DISTINCT from HCALC nested pipeline. +FoundryAdditive (prop 39) remains separate from InstanceBridge (PRODUCTION.md §6). +Cite: FOUNDRY_J_CROSSLINKS, foundry-j PROPERTIES 23, 33–34, 39, 42–43. +-/ + +import Hcalc.RealStub +import Hcalc.Carrier + +namespace Hcalc.Foundry + +open Hcalc + +/-! ## L1: P64 — first 64 primes (PROPERTIES 23) — definition (data) -/ + +/-- The first 64 primes, PROPERTIES **23** / `types.h:24–30`. -/ +def p64List : List Nat := + [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, + 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, + 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, + 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311] + +theorem p64List_length : p64List.length = 64 := by native_decide + +/-- `P64 : Fin 64 → ℕ` (Lean L1). -/ +def P64 (i : Fin 64) : Nat := + p64List.get ⟨i.val, by + have h := p64List_length + omega⟩ + +theorem P64_zero : P64 ⟨0, by omega⟩ = 2 := by native_decide +theorem P64_one : P64 ⟨1, by omega⟩ = 3 := by native_decide +theorem P64_last : P64 ⟨63, by omega⟩ = 311 := by native_decide + +/-! ## Foundry carrier stubs (opaque; FoundryAdditive path — ≠ HCALC Carrier) -/ + +/-- GapId: Gap-Foundry-StateOps — Foundry recurrence carrier (not HCALC `Carrier`). -/ +axiom State : Type +/-- GapId: Gap-Foundry-StateOps (infrastructure for L3/L4). -/ +axiom State.add : State → State → State +/-- GapId: Gap-Foundry-StateOps -/ +axiom State.smul : Scalar → State → State +/-- GapId: Gap-Foundry-StateOps -/ +axiom State.zero : State + +noncomputable instance : Add State := ⟨State.add⟩ +noncomputable instance : Zero State := ⟨State.zero⟩ + +/-- Schedule weight (Foundry Ξ_t / Λ_t abstracted to Scalar). -/ +abbrev Weight := Scalar + +/-- Nonlinear hook `T` in Foundry recurrence (≠ HCALC `Tp`). -/ +abbrev Nonlinear := State → State + +/-! ## L2: Gershgorin bound / contractiveG (PROPERTIES 33–34) -/ + +/-- Square matrix as function of indices (no Mathlib Matrix). -/ +def Mat (n : Nat) := Fin n → Fin n → Scalar + +/-- Row radius excluding diagonal: Σ_{j≠i} |J_ij|. -/ +noncomputable def rowRadius {n : Nat} (J : Mat n) (i : Fin n) : Scalar := + Fin.foldl n (fun acc j => + if j = i then acc else acc + ‖J i j‖ᵣ) (0 : Scalar) + +/-- Disk max for row i: |J_ii| + rowRadius. -/ +noncomputable def diskMax {n : Nat} (J : Mat n) (i : Fin n) : Scalar := + ‖J i i‖ᵣ + rowRadius J i + +/-- Gershgorin disk bound = max over rows of diskMax (PROPERTIES **33**). -/ +noncomputable def gershgorinBound {n : Nat} (J : Mat n) : Scalar := + finMax (fun i => diskMax J i) + +/-- `contractiveG J ε ↔ gershgorinBound J < 1 - ε` (PROPERTIES **34**). -/ +noncomputable def contractiveG {n : Nat} (J : Mat n) (ε : Scalar) : Prop := + gershgorinBound J <ᵣ ((1 : Scalar) - ε) + +/-- Definitional unfolding: contractiveG is exactly the Gershgorin inequality. -/ +theorem contractiveG_iff {n : Nat} (J : Mat n) (ε : Scalar) : + contractiveG J ε ↔ gershgorinBound J <ᵣ ((1 : Scalar) - ε) := + Iff.rfl + +/-! ## L3: FoundryStep — exact PROPERTIES 39; ≠ HCALC nested / InstanceBridge -/ + +/-- +Foundry additive Banach step (PROPERTIES **39** / FoundryAdditive): +`x' = Ξ • x + Λ • T(x) + g`. + +**Distinct** from HCALC `hcalcStep` and from InstanceBridge (PRODUCTION.md §6). +Do not identify with nested form. +-/ +noncomputable def FoundryStep (Ξ Λ : Weight) (T : Nonlinear) (g x : State) : State := + State.smul Ξ x + State.smul Λ (T x) + g + +/-! ## L4: qEstimate / softProject (PROPERTIES 42–43, abstracted) -/ + +/-- GapId: Gap-Foundry-Norm (infrastructure). -/ +axiom weightNorm : Weight → Scalar +/-- GapId: Gap-Foundry-Norm -/ +axiom nonlinearNorm : Nonlinear → State → Scalar + +/-- Abstracted q-estimate (PROPERTIES **42**). -/ +noncomputable def qEstimate (Ξ Λ : Weight) (T : Nonlinear) (x : State) : Scalar := + weightNorm Ξ + weightNorm Λ * nonlinearNorm T x + +/-- Soft-project scales (PROPERTIES **43**). -/ +structure SoftScales where + xi : Weight + lam : Weight + +/-- GapId: Gap-Foundry-Div (infrastructure) — Real division alias. -/ +noncomputable def realDiv (a b : Scalar) : Scalar := Hcalc.realDiv a b + +/-- GapId: Gap-Foundry-SoftScale — Foundry schedule soft_project scale (props 42–43). +NOT identical to HCALC in-step `C` (which uses softScaleFactor as Spec wiring only). -/ +noncomputable def softProjectScale (ε q : Scalar) : Scalar := softScaleFactor ε q + +theorem softProjectScale_of_le (ε q : Scalar) + (h : q <ᵣ ((1 : Scalar) - ε) ∨ q = ((1 : Scalar) - ε)) : + softProjectScale ε q = (1 : Scalar) := + softScaleFactor_of_le ε q h + +theorem softProjectScale_of_gt (ε q : Scalar) + (h : ((1 : Scalar) - ε) <ᵣ q) : + softProjectScale ε q = Hcalc.realDiv ((1 : Scalar) - ε) q := + softScaleFactor_of_gt ε q h + +/-- Soft-project: scale Ξ, Λ by `softProjectScale ε q` (PROPERTIES **43**). -/ +noncomputable def softProject (ε : Scalar) (Ξ Λ : Weight) (T : Nonlinear) (x : State) : + SoftScales := + let q := qEstimate Ξ Λ T x + let s := softProjectScale ε q + ⟨Ξ * s, Λ * s⟩ + +/-- When q ≤ 1-ε, soft-project leaves Ξ unchanged (via scale=1). -/ +theorem softProject_xi_of_le (ε : Scalar) (Ξ Λ : Weight) (T : Nonlinear) (x : State) + (h : (qEstimate Ξ Λ T x) <ᵣ ((1 : Scalar) - ε) ∨ + (qEstimate Ξ Λ T x) = ((1 : Scalar) - ε)) : + (softProject ε Ξ Λ T x).xi = Ξ * (1 : Scalar) := by + simp [softProject, softProjectScale_of_le ε _ h] + +end Hcalc.Foundry diff --git a/lean/Hcalc/Invariants.lean b/lean/Hcalc/Invariants.lean new file mode 100644 index 0000000000000000000000000000000000000000..069da75bfa06cb4ed92083ae4f57f6f06ff3d80f --- /dev/null +++ b/lean/Hcalc/Invariants.lean @@ -0,0 +1,38 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +Structural invariants for production nested `step`. +-/ + +import Hcalc.Pipeline + +namespace Hcalc.Invariants + +open Hcalc Pipeline + +/-- Predicate preserved by nested `step` for all times / ε / δ. -/ +def IsInvariant {n : Nat} (P : Carrier n → Prop) : Prop := + ∀ (ε δ : Scalar) (t : Time) (x : Carrier n), + P x → P (step (n := n) ε δ t x) + +theorem true_invariant {n : Nat} : IsInvariant (n := n) (fun _ => True) := by + intro ε δ t x hx + trivial + +theorem invariant_and {n : Nat} (P Q : Carrier n → Prop) + (hP : IsInvariant (n := n) P) (hQ : IsInvariant (n := n) Q) : + IsInvariant (n := n) (fun x => P x ∧ Q x) := by + intro ε δ t x hx + exact ⟨hP ε δ t x hx.1, hQ ε δ t x hx.2⟩ + +/-- Invariance under production defaults. -/ +def IsInvariantProd {n : Nat} (P : Carrier n → Prop) : Prop := + ∀ (t : Time) (x : Carrier n), P x → P (stepProd (n := n) t x) + +theorem invariant_implies_prod {n : Nat} (P : Carrier n → Prop) + (h : IsInvariant (n := n) P) : IsInvariantProd (n := n) P := by + intro t x hx + exact h epsProd deltaProd t x hx + +end Hcalc.Invariants diff --git a/lean/Hcalc/Pipeline.lean b/lean/Hcalc/Pipeline.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6f9e46a69102b507cd9e935781c9279c2de9a1f --- /dev/null +++ b/lean/Hcalc/Pipeline.lean @@ -0,0 +1,60 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +HCALC nested one-step map (PRODUCTION.md): + X_{t+1} = Ξ(t, Λm · C(Tp(X_t))). +DISTINCT from Foundry.FoundryStep / toFoundryStep (InstanceBridge ≠ identity). +-/ + +import Hcalc.Axioms + +namespace Hcalc.Pipeline + +open Hcalc + +/-- +One-step nested HCALC evolution (production verb `hcalcStep`): +`step ε δ t x = Xi t (Λm • C(Tp x))` with default zero kick. +-/ +noncomputable def step {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) : Carrier n := + hcalcStepCore (n := n) ε δ t x (gDefault n) + +/-- Production defaults ε=T2, δ=guard. -/ +noncomputable def stepProd {n : Nat} (t : Time) (x : Carrier n) : Carrier n := + step (n := n) epsProd deltaProd t x + +/-- Definitional: step unfolds to nested composition. -/ +theorem step_eq {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) : + step (n := n) ε δ t x = + Xi (n := n) t (vsmul (LambdaM n ε δ) (C (n := n) ε (Tp x))) (gDefault n) := + rfl + +/-- Under Uniform ξ=1 and g=0, step = stabilized branch. -/ +theorem step_eq_stabilized {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) : + step (n := n) ε δ t x = stabilized (n := n) ε δ x := by + funext j + simp only [step, hcalcStepCore, Xi_uniform_zero_kick, stabilized, C_circ_Tp] + +/-- Intermediate after contraction, before evolution. -/ +noncomputable def contracted {n : Nat} (ε δ : Scalar) (x : Carrier n) : Carrier n := + stabilized (n := n) ε δ x + +theorem step_eq_Xi_contracted {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) : + step (n := n) ε δ t x = Xi (n := n) t (contracted (n := n) ε δ x) (gDefault n) := + rfl + +/-- OptObj residual for the nested step at time t. -/ +noncomputable def J {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) : Scalar := + evalOptObj (step (n := n) ε δ t) x + +/-- Optimize: iterate nested step `k` times. -/ +noncomputable def optimize {n : Nat} (ε δ : Scalar) (t : Time) (k : Nat) (x : Carrier n) : + Carrier n := + iterate (step (n := n) ε δ t) k x + +/-- Stop when residual below production tol. -/ +noncomputable def done {n : Nat} (ε δ : Scalar) (t : Time) (x : Carrier n) : Prop := + residualBelowTol (step (n := n) ε δ t) tolProd x + +end Hcalc.Pipeline diff --git a/lean/Hcalc/Production.lean b/lean/Hcalc/Production.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9ec07c0e7f38da86da80a75fe3039ce2e8e1b67 --- /dev/null +++ b/lean/Hcalc/Production.lean @@ -0,0 +1,25 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +PRODUCTION surface re-exports (authority: ../spec/PRODUCTION.md). +Domain Gap-* defs live in Hcalc.Axioms / Hcalc.Carrier. +-/ + +import Hcalc.Axioms +import Hcalc.Carrier +import Hcalc.Pipeline +import Hcalc.Convergence + +namespace Hcalc.Production + +export Hcalc (Carrier Tp C LambdaM Xi InstanceBridge hcalcStepCore toFoundryStep + epsProd deltaProd tolProd evalOptObj residualNorm + definitionRecord_Tp definitionRecord_C definitionRecord_LambdaM definitionRecord_Xi + definitionRecord_Carrier definitionRecord_OptObj definitionRecord_ContractAlg + definitionRecord_ShapeMap definitionRecord_Converge) + +export Hcalc.Pipeline (step stepProd J optimize done) +export Hcalc.Convergence (HypContractive unique_fixed_point) + +end Hcalc.Production diff --git a/lean/Hcalc/RealStub.lean b/lean/Hcalc/RealStub.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b576f378e7a4ee60981d25f1c8fed7b61104535 --- /dev/null +++ b/lean/Hcalc/RealStub.lean @@ -0,0 +1,88 @@ +/- +Copyright (C) 2026 HCALC contributors +SPDX-License-Identifier: AGPL-3.0-only + +Minimal Real stub (no Mathlib). Infrastructure Gap-Real-arith only. +Production domain symbols are defs in other modules (PRODUCTION.md). +-/ + +namespace Hcalc + +axiom Real : Type +axiom realZero : Real +axiom realOne : Real +axiom realAdd : Real → Real → Real +axiom realMul : Real → Real → Real +axiom realNeg : Real → Real +axiom realAbs : Real → Real +axiom realLt : Real → Real → Prop +axiom realDiv : Real → Real → Real +axiom natToReal : Nat → Real +axiom realLog : Real → Real +axiom realMin : Real → Real → Real +axiom finMax : {n : Nat} → (Fin n → Real) → Real + +noncomputable instance : Zero Real := ⟨realZero⟩ +noncomputable instance : One Real := ⟨realOne⟩ +noncomputable instance : Add Real := ⟨realAdd⟩ +noncomputable instance : Mul Real := ⟨realMul⟩ +noncomputable instance : Neg Real := ⟨realNeg⟩ + +noncomputable def realSub (a b : Real) : Real := realAdd a (realNeg b) +noncomputable instance : Sub Real := ⟨realSub⟩ + +infix:50 " <ᵣ " => realLt +notation "‖" x "‖ᵣ" => realAbs x +def realLe (a b : Real) : Prop := realLt a b ∨ a = b +infix:50 " ≤ᵣ " => realLe + +axiom real_add_comm (a b : Real) : a + b = b + a +axiom real_add_assoc (a b c : Real) : (a + b) + c = a + (b + c) +axiom real_mul_comm (a b : Real) : a * b = b * a +axiom real_mul_assoc (a b c : Real) : (a * b) * c = a * (b * c) +axiom real_zero_add (a : Real) : (0 : Real) + a = a +axiom real_add_zero (a : Real) : a + (0 : Real) = a +axiom real_one_mul (a : Real) : (1 : Real) * a = a +axiom real_mul_one (a : Real) : a * (1 : Real) = a +axiom real_zero_mul (a : Real) : (0 : Real) * a = (0 : Real) +axiom real_mul_zero (a : Real) : a * (0 : Real) = (0 : Real) +axiom real_neg_add_cancel (a : Real) : a + (-a) = (0 : Real) +axiom real_abs_nonneg (a : Real) : (0 : Real) ≤ᵣ ‖a‖ᵣ +axiom real_abs_zero : ‖(0 : Real)‖ᵣ = (0 : Real) +axiom real_abs_abs (a : Real) : ‖‖a‖ᵣ‖ᵣ = ‖a‖ᵣ +axiom real_lt_irrefl (a : Real) : ¬ (a <ᵣ a) +axiom real_lt_asymm {a b : Real} : a <ᵣ b → ¬ b <ᵣ a +axiom real_abs_eq_zero_iff (a : Real) : ‖a‖ᵣ = (0 : Real) ↔ a = (0 : Real) +axiom real_mul_add (a b c : Real) : a * (b + c) = a * b + a * c +axiom real_abs_mul (a b : Real) : ‖a * b‖ᵣ = ‖a‖ᵣ * ‖b‖ᵣ +axiom natToReal_pos {n : Nat} (h : 0 < n) : (0 : Real) <ᵣ natToReal n +axiom natToReal_zero : natToReal 0 = (0 : Real) +axiom natToReal_one : natToReal 1 = (1 : Real) +axiom softScaleFactor : Real → Real → Real +axiom softScaleFactor_of_le (ε q : Real) + (_h : q <ᵣ ((1 : Real) - ε) ∨ q = ((1 : Real) - ε)) : + softScaleFactor ε q = (1 : Real) +axiom softScaleFactor_of_gt (ε q : Real) + (_h : ((1 : Real) - ε) <ᵣ q) : + softScaleFactor ε q = realDiv ((1 : Real) - ε) q +axiom realMin_le_left (a b : Real) : realMin a b ≤ᵣ a +axiom realMin_le_right (a b : Real) : realMin a b ≤ᵣ b +axiom finMax_abs_eq_zero_of {n : Nat} (x : Fin n → Real) + (h : finMax (fun j => ‖x j‖ᵣ) = (0 : Real)) : ∀ j, x j = (0 : Real) +axiom real_contract_force_zero (a q : Real) + (hnn : (0 : Real) ≤ᵣ a) (hq : q <ᵣ (1 : Real)) (hle : a ≤ᵣ q * a) : a = (0 : Real) +axiom real_le_of_eq (a b : Real) (h : a = b) : a ≤ᵣ b +axiom deltaGuard : Real +axiom deltaGuard_pos : (0 : Real) <ᵣ deltaGuard +axiom tolDefault : Real +axiom tolDefault_pos : (0 : Real) <ᵣ tolDefault +noncomputable def epsDefault : Real := realDiv realOne (natToReal 20) +noncomputable def oneSub (ε : Real) : Real := (1 : Real) - ε + +theorem real_sub_self (a : Real) : a - a = (0 : Real) := by + change a + (-a) = (0 : Real) + exact real_neg_add_cancel a + +abbrev Scalar := Real + +end Hcalc diff --git a/lean/LICENSE b/lean/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d671311997c35595b6c62cd0463382874e9d0256 --- /dev/null +++ b/lean/LICENSE @@ -0,0 +1,699 @@ +--- +title: GNU Affero General Public License v3.0 +spdx-id: AGPL-3.0 +nickname: GNU AGPLv3 +redirect_from: /licenses/agpl/ +hidden: false + +description: Permissions of this strongest copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. When a modified version is used to provide a service over a network, the complete source code of the modified version must be made available. + +how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. + +note: The Free Software Foundation recommends taking the additional step of adding a boilerplate notice to the top of each file. The boilerplate can be found at the end of the license. + +using: + Grafana: https://github.com/grafana/grafana/blob/main/LICENSE + Mastodon: https://github.com/mastodon/mastodon/blob/main/LICENSE + Nextcloud Server: https://github.com/nextcloud/server/blob/master/COPYING + +permissions: + - commercial-use + - modifications + - distribution + - patent-use + - private-use + +conditions: + - include-copyright + - document-changes + - disclose-source + - network-use-disclose + - same-license + +limitations: + - liability + - warranty + +--- + + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/lean/README.md b/lean/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8302a3f2ee2a19ee311d4dc433f0d2883ab23a94 --- /dev/null +++ b/lean/README.md @@ -0,0 +1,72 @@ +# HCALC Lean 4 formalization (PRODUCTION) + +**License:** AGPL-3.0-only (see [`LICENSE`](LICENSE)) +**Copyright (C) 2026 HCALC contributors** + +Production formalization of the HCALC nested recurrence + +\[ +X_{t+1} = \Xi\bigl(t,\; \Lambda_m \cdot C(T_p(X_t))\bigr) +\] + +frozen to Spec [`../spec/PRODUCTION.md`](../spec/PRODUCTION.md) (overrides provisional L6 axioms in COHERENCE/AXIOMS). + +## Provenance + +| Part | Source | +|------|--------| +| Carrier, Tp α-diag, C softScale-or-id, Λm min-formula, Ξ=ξy+g, J=residual, L5 Hyp, L7 InstanceBridge | **Spec-file** `PRODUCTION.md` | +| Option B InstanceBridge (not NestedFaithful / not rfl) | **Spec-file** PRODUCTION.md §6 (f5a08da) | +| Mathlib `ℝ` (thin bridge in `RealStub`) | Mathlib4 `v4.34.1` | +| Foundry L1–L4 (P64, Gershgorin, FoundryStep additive, softProject schedules) | Spec + Foundry PROPERTIES (FoundryAdditive **distinct**) | + +## Mathlib + +- **Toolchain:** `leanprover/lean4:v4.34.1` (matches Mathlib tag `v4.34.1` lean-toolchain — no bump needed). +- **Dependency:** `leanprover-community/mathlib` @ `v4.34.1`. +- **Imports used (minimal):** + 1. `Mathlib.Basic.Real.Basic` — `ℝ`, field/order/`abs`/`min`/`max` + 2. `Mathlib.Analysis.SpecialFunctions.Log.Basic` — `Real.log` (pulls Exp; Topology transitive only) + - `finMax` uses core `Fin.foldl` only (no Finset / `Mathlib.Data.Fin`) +- No Topology / MeasureTheory / aesop / grind / large simp sets. +- Proofs are freehand `calc` / `rw` / `intro` / `apply` / elementary single-lemma `exact`. + +### finMax / ℓ∞ + +`finMax` = `Fin.foldl` of `max` with init `0` (smallest surface; not `Finset.univ.sup'` / `iSup`). +Production sites pass nonnegative args (`|·|`, Gershgorin disks); `n = 0` yields `0`. + +## Layout + +| File | Role | +|------|------| +| `Hcalc/RealStub.lean` | Thin Mathlib `ℝ` re-exports + freehand Real lemmas (`finMax`, softScale, guards) | +| `Hcalc/Carrier.lean` | **Gap-Carrier CLOSED**: `Carrier n := Fin n → ℝ`, ℓ∞ | +| `Hcalc/Foundry.lean` | L1–L4 defs; FoundryAdditive `FoundryStep` (≠ nested); Gap-Foundry-* may remain | +| `Hcalc/Axioms.lean` | L6 **defs** Tp/C/Λm/Ξ/J/ContractAlg + **L7** `InstanceBridge` | +| `Hcalc/Pipeline.lean` | Nested `hcalcStep` / `step` / `J` / `optimize` | +| `Hcalc/Convergence.lean` | **L5** unique FP + residual under `HypContractive` | +| `Hcalc/Invariants.lean` | Structural invariants | +| `Hcalc/Production.lean` | Stable re-exports for Verify/docs | + +## Rules + +- Zero `sorry` / `admit`. +- Production Gap-* are **defs/theorems**, not opaque axioms. +- Gap-Real-arith for `Real` itself is **closed** (Mathlib `ℝ`). Gap-Foundry-* stubs OK if Foundry.State stays opaque. +- L7 = `InstanceBridge` Option B (parameter table + `toFoundryStep` diagnostic). **Not** `FoundryStep = hcalcStep`. +- C is state softScale-or-id; does **not** equal Foundry `softProject` on (Ξ,Λ) schedules. +- α (Tp weights) is Spec-only. +- No unconditional convergence — L5 under `HypContractive` only. + +## Build + +```bash +source ~/.elan/env +cd /workspace/hcalc/lean +lake update # first time / after mathlib pin change +lake exe cache get # download Mathlib oleans (recommended) +lake build 2>&1 | tee build.log +``` + +Toolchain: `leanprover/lean4:v4.34.1` + Mathlib `v4.34.1`. diff --git a/lean/build.log b/lean/build.log new file mode 100644 index 0000000000000000000000000000000000000000..11a33dc67e579245b483560fe7c08c9579430c13 --- /dev/null +++ b/lean/build.log @@ -0,0 +1,2 @@ +✔ [1962/1968] Built Hcalc.Axioms (2.0s) +Build completed successfully (1968 jobs). diff --git a/lean/lake-manifest.json b/lean/lake-manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..f2d7beffc4c78116ee9483f8f4e619a11f626114 --- /dev/null +++ b/lean/lake-manifest.json @@ -0,0 +1,6 @@ +{"version": "1.2.0", + "packagesDir": ".lake/packages", + "packages": [], + "name": "Hcalc", + "lakeDir": ".lake", + "fixedToolchain": false} diff --git a/lean/lakefile.toml b/lean/lakefile.toml new file mode 100644 index 0000000000000000000000000000000000000000..818c0330de2c6ec622f5d7497902dfa64f65bef4 --- /dev/null +++ b/lean/lakefile.toml @@ -0,0 +1,6 @@ +name = "Hcalc" +version = "0.1.0" +defaultTargets = ["Hcalc"] + +[[lean_lib]] +name = "Hcalc" diff --git a/lean/lean-toolchain b/lean/lean-toolchain new file mode 100644 index 0000000000000000000000000000000000000000..ba8ebf2dbaf6a668cd2a0e086186d6d569b69ff5 --- /dev/null +++ b/lean/lean-toolchain @@ -0,0 +1 @@ +leanprover/lean4:v4.34.1 diff --git a/spec/AXIOMS.md b/spec/AXIOMS.md new file mode 100644 index 0000000000000000000000000000000000000000..dfb2c1c6bfe18b3bf898fde7e76afb80c19ca563 --- /dev/null +++ b/spec/AXIOMS.md @@ -0,0 +1,124 @@ + + +# HCALC Axiom Inventory + +**Owner:** HCALC Spec agent +**Consumers:** HCALC Lean (defs / theorems), HCALC Alloy (Provenance tags), Foundry J Verify (cite-only). +**Rule:** Domain Gap-* are **CLOSED by definition** in [`PRODUCTION.md`](PRODUCTION.md). Prefer production defs over opaque axioms. +**Source absorbed:** [`FOUNDRY_J_CROSSLINKS.md`](FOUNDRY_J_CROSSLINKS.md). +**Production authority:** [`PRODUCTION.md`](PRODUCTION.md). + +Provenance tags: `source-claim` | `axiom-gap` | `derived` | `SpecDefined`. + +--- + +## Alloy A1–A7 + +| ID | Statement sketch | Kind | Lean link | Core / doc cite | Provenance | +|----|------------------|------|-----------|-----------------|------------| +| A1 | `#P_64=64`; elements = first-64 primes | assert | L1 | PROPERTIES **23**; Core `P64` | source-claim | +| A2 | `contractive(J,ε) ↔ gershgorin(J)<1-ε` (+ opt. power-iter 37) | assert | L2 | **33–37**; `spectral_analyze`, `gershgorin_*`, `power_iteration*` | source-claim | +| A3 | Foundry schedule soft_project when `q>1-ε` (**43** as coded) — **distinct from** production in-step `C` (state scale-or-id, **spec-adapt**) | assert | L4 | **43**/`soft_project`/`q_estimate` = **source-claim** (schedules only); production `C` → PRODUCTION.md / **spec-adapt** | source-claim (Foundry **43** only) | +| A4 | affine Foundry recurrence **only if** `instance=Foundry` / FoundryAdditive diagnostic | assert | L3 | **39**; `rec_step`, `rec_run` | source-claim | +| A5 | PMAT conservation on insert-set | assert | (PMAT defs) | **29**; `pmat_compose` | source-claim | +| A6 | guardian rejects spectral_radius≥1 or non-finite | assert | — | **55** | source-claim | +| A7 | definition-records for Λm, Ξ, C, Tp present and **SpecDefined** | gate | L6 defs | [`PRODUCTION.md`](PRODUCTION.md) | **SpecDefined** (CLOSED) | + +**A7 action:** Alloy must replace `Undefined` → `SpecDefined` on all four GapRecords, pointing at PRODUCTION.md formulas (not leave unconstrained). + +--- + +## Lean L1–L7 + +| ID | Statement sketch | Kind | Why / status | Depends / dependents | Provenance | +|----|------------------|------|--------------|----------------------|------------| +| L1 | `P64 : Fin 64 → ℕ` = PROPERTIES 23 list | **def** | Data; no axiom if listed | Used by Tp indexing | source-claim | +| L2 | `gershgorinBound`, `contractiveG` | **def+thm** | From 33–34 | Contraction lemmas; A2 | source-claim | +| L3 | `FoundryStep Ξ Λ T g x` = prop 39 | **def** | Exact Foundry additive | A4; **≠** `hcalcStep` | source-claim | +| L4 | `qEstimate` / `softProject` | **def** | 42–43 as coded | A3; production C | source-claim | +| L5 | Unique FP when Hyp holds | **thm** (dischargeable) | Under PRODUCTION Hyp; Banach **41** + residual **46** | Convergence claims | derived | +| L6 | `Λm`, `HCALC.Ξ`, `C`, `Tp` | **defs** (not axioms) | PRODUCTION §§2–5 | Nested-form theorems | **SpecDefined** | +| L7 | `structure InstanceBridge` + Option B/C thms | **UNBLOCKED** | **NOT** `rfl`; **NOT** `FoundryStep = hcalcStep` | Instance proofs | **SpecDefined** | + +--- + +## Named Gap-* (HCALC-native) — CLOSED + +All domain gaps CLOSED — see [`PRODUCTION.md`](PRODUCTION.md) disposition table. Summary: + +| GapId | Status | Definition pointer | +|-------|--------|-------------------| +| Gap-Carrier | **CLOSED — see PRODUCTION.md** | `HCALC.Carrier := Fin n → ℝ`, ℓ∞ | +| Gap-Tp-from-P64 | **CLOSED — see PRODUCTION.md** | `(Tp x)_j = α_j · x_j`, `α_j = 1/(1+log p_{j mod 64})` | +| Gap-C-wrapper | **CLOSED — see PRODUCTION.md** | soft_project-or-id on `q = ‖D(Tp)‖_est` (Spec wiring of Foundry-coded soft_project) | +| Gap-Λm-scalar | **CLOSED — see PRODUCTION.md** | `Λm = min(1, (1-ε)/(‖C∘Tp‖_op+δ))` | +| Gap-Ξ | **CLOSED — see PRODUCTION.md** | `Ξ(t,y) := ξ_t·y + g_t`; Uniform `ξ_t=1` | +| Gap-ShapeMap | **CLOSED — see PRODUCTION.md** | **`InstanceBridge` morphism** (NOT `rfl` / NOT Foundry39≡nested); L7 UNBLOCKED | +| Gap-ContractAlg | **CLOSED — see PRODUCTION.md** | Gershgorin → power-iter → soft_project (**33–43**) | +| Gap-Converge | **CLOSED — see PRODUCTION.md** | Hyp ⇒ Banach unique FP + residual→0; L5 dischargeable | +| Gap-OptObj | **CLOSED — see PRODUCTION.md** | `J(X)=‖X−Ξ(t,Λm·C(Tp(X)))‖_∞`; iterate to tol | + +Provenance for all rows above: **SpecDefined** (not axiom-gap). + +**ShapeMap / L7 rule (Foundry J Spec review):** REJECT identity `Foundry39 ≡ nested` and silent symbol swaps. ACCEPTED: non-identity `InstanceBridge` parameter table (`T := C∘Tp`, `Λ_vec := Λm·1`, `Ξ_vec := ξ_t`, `g := g_t`). Production Core implements **only** `hcalcStep` (Option B); `toFoundryStep` is cite-only diagnostic. Option C embedding optional later — still a morphism, never symbol identity. + +--- + +## Theorems that may depend on production defs (Lean guidance) + +| After closing | Dependent results (sketches) | +|---------------|------------------------------| +| L1 + Tp def | Well-definedness of prime-indexed diagonal layers | +| L2 + C def | Lip / non-expansive bound for nested step | +| Λm def + L2 | Stabilizing-range lemmas | +| Ξ def + InstanceBridge | Parameter-table theorems; **not** `hcalcStep = FoundryStep` | +| L7 InstanceBridge | Option B Core path; optional Option C embedding morphism | +| L5 under Hyp | Convergence monitors; uniqueness | + + + +### Provenance (production close — Foundry J Spec pass-2) +**A3 provenance split:** Alloy may keep a Foundry-instance assert for schedule soft_project (**43**, `source-claim`). Production in-step `C` is **SpecDefined** / **spec-adapt** per PRODUCTION.md — do not merge the two under one `source-claim` tag for **43**. + + +- **Gap-Tp-from-P64** \(\alpha\) law: `spec-def` (P64 list alone is Foundry **source-claim** **23**). +- **Gap-C-wrapper**: `spec-adapt` — algorithmic cousin of Foundry soft_project **43**, **not** symbol identity (43 scales schedules; production C scales state under Spec \(q=\|D(T_p)\|\)). +- **Gap-ShapeMap / L7**: dual `bridgeMode` **NestedFaithful** | **FoundryAdditive**; InstanceBridge param table; morphism → FoundryAdditive only — never NestedFaithful = prop-**39** rfl. +- Residual \(J\): Spec \(\ell_\infty\); Foundry **46** is \(\ell_2\). + +**FAIL-open:** `sorry` / Alloy `unsat` failure / missing SpecDefined A7 record ⇒ SKIP or FAIL — never PASS. + +--- + +## Infrastructure Gap-* (Lean toolchain stubs) — ACCEPTED (not production blockers) + +Provisional IDs from HCALC Lean first cut (`lake build` exit 0, Mathlib deferred). Spec **accepts these names as canonical**; do not rename without Spec update. They are **infrastructure only** — not HCALC domain axioms and **not production blockers** when nested defs use explicit Carrier ℝ^n. Closing path: replace with Mathlib `Real` / proven Foundry defs when ready; until then FAIL-open on infra (axioms OK, never silent PASS). + +| GapId | Role | Lean surface | Status | Provenance | +|-------|------|--------------|--------|------------| +| Gap-Real-arith | Opaque `Real` + basic arith/order facts absent Mathlib | `Hcalc/RealStub.lean` | infra stub (Mathlib deferred) | infra-not-production-gap | +| Gap-Foundry-StateOps | Foundry recurrence carrier + add/smul/zero (≠ HCALC `State`) | `Hcalc/Foundry.lean` | infra stub | infra-not-production-gap | +| Gap-Foundry-FinMax | `finMax` for Gershgorin-style bounds | `Hcalc/Foundry.lean` | infra stub | infra-not-production-gap | +| Gap-Foundry-Norm | Opaque weight / nonlinear norms for coded q-estimate | `Hcalc/Foundry.lean` | infra stub | infra-not-production-gap | +| Gap-Foundry-Div | Real division for soft-project scale | `Hcalc/Foundry.lean` | infra stub | infra-not-production-gap | +| Gap-Foundry-SoftScale | Opaque soft-project scale + branch laws | `Hcalc/Foundry.lean` | infra stub | infra-not-production-gap | + +**Rule:** Infra stubs must not leave unfinished *production* theorems depending on `sorry`. Production Carrier/Tp/C/Λm/Ξ/J path uses explicit ℝ^n defs in PRODUCTION.md. Do **not** use infra stubs to invent an `rfl` ShapeMap. + +--- + +## Steering aliases (G-*) + +Stable short aliases. Prefer these in tags; Spec GapIds remain canonical. **All CLOSED.** + +| Alias | Canonical GapId | Statement | Status | +|-------|-----------------|-----------|--------| +| **G-SHAPE** | Gap-ShapeMap | `InstanceBridge` morphism (NOT `rfl`; NOT Foundry39≡nested) | **CLOSED** — PRODUCTION §6 | +| **G-Lm** | Gap-Λm-scalar | Scalar Λm formula (≠ vector schedule) | **CLOSED** — PRODUCTION §4 | +| **G-C** | Gap-C-wrapper | In-step soft_project-or-id as C (Spec wiring) | **CLOSED** — PRODUCTION §3 | +| **G-Tp** | Gap-Tp-from-P64 | Diagonal Tp from P64 α weights | **CLOSED** — PRODUCTION §2 | + +Core cite-only (hooks, not alternate defs): `P64`, `pmat_compose`, `spectral_analyze`, `soft_project`, `q_estimate`, `synth_weights`, `rec_step`, `rec_run`, `ace_certify` — see foundry-j `spec/J_API.md`, `j/BOXING.md`, `spec/GAP_DECISIONS.md`. diff --git a/spec/COHERENCE.md b/spec/COHERENCE.md new file mode 100644 index 0000000000000000000000000000000000000000..adbd8f570538a7a3cafca64ba73aa7fa75579a99 --- /dev/null +++ b/spec/COHERENCE.md @@ -0,0 +1,221 @@ + + +# HCALC Coherence Map + +**Owner:** HCALC Spec agent +**License:** AGPL-3.0-only +**Absorbs:** [`FOUNDRY_J_CROSSLINKS.md`](FOUNDRY_J_CROSSLINKS.md) (verbatim source input; keep that file). +**Production authority:** [`PRODUCTION.md`](PRODUCTION.md) — all domain Gap-* CLOSED by definition. +**Pass-2 review mirror:** [`FOUNDRY_J_PRODUCTION_REVIEW.md`](FOUNDRY_J_PRODUCTION_REVIEW.md). +**Mirror:** `/workspace/foundry-j/spec/HCALC_CROSSLINKS.md` (Foundry side). +**Cite-only (do not copy bodies):** +`/workspace/foundry-j/spec/PROPERTIES.md`, `J_API.md`, `GAP_DECISIONS.md`, `/workspace/foundry-j/j/BOXING.md`. + +--- + +## Pipeline (canonical — production formulas) + +Informal multimodal research narrative (noise stripped) collapses to the discrete dynamical pipeline: + +``` +multimodal system + → multiplicity / tensor representation + → prime-indexed recursion T_p + → Λm stabilization + → Ξ(t) controlled evolution + → orthogonal / spectral transform + → layerwise contraction C + → optimization + → converged representation +``` + +**Boxed abstract recurrence (HCALC nested form) — PRODUCTION:** + +\[ +X_{t+1} = \Xi\bigl(t,\; \Lambda_m \cdot C(T_p(X_t))\bigr) + = \xi_t\cdot\bigl(\Lambda_m\cdot C(T_p(X_t))\bigr) + g_t. +\] + +| Symbol | Role | Status | +|--------|------|--------| +| \(X_t\) | State at discrete time \(t\) | **Defined** — `HCALC.Carrier = Fin n → ℝ`, ℓ∞ | +| \(T_p\) | Diagonal PrimeMask transform | **Defined** — \((T_p x)_j = \alpha_j x_j\), \(\alpha_j=1/(1+\log p_{j\bmod 64})\) (**spec-def**) | +| \(C\) | In-step scale-or-id governor | **Defined** — scale \((1-\varepsilon)/q\) or id (**spec-adapt**; ≠ Foundry **43**) | +| \(\Lambda_m\) | Stabilizing **scalar** | **Defined** — \(\min(1,(1-\varepsilon)/(\|C\circ T_p\|_{\mathrm{op}}+\delta))\) | +| \(\Xi(t,\cdot)\) | Controlled evolution | **Defined** — \(\xi_t\cdot y + g_t\); Uniform \(\xi_t=1\) | + +**Shape fact (production).** Foundry F1 additive step (PROPERTIES **39**) and HCALC nested form are **different morphisms**. Spec closes Gap-ShapeMap via **`InstanceBridge`** parameter table (PRODUCTION §6) with dual `bridgeMode`: + +| bridgeMode | Meaning | vs Foundry **39** | +|------------|---------|-------------------| +| **FoundryAdditive** | `toFoundryStep` with InstanceBridge params | **ACCEPT** morphism into additive shape — **not** nested | +| **NestedFaithful** / `hcalcStep` | nested production verb | Spec definitional — **REJECT** as prop-**39** `rfl` / identity | + +- **REJECTED:** `Foundry39 ≡ nested`; silent symbol swaps; identity/`rfl`. +- **InstanceBridge** = explicit parameter table (morphism data), **not** an equality proof. Hilbert morphism maps to **FoundryAdditive** shape only. +- **Core:** implement only `hcalc_step` (NestedFaithful semantics); `toFoundryStep` is FoundryAdditive diagnostic. +- **L7 UNBLOCKED** as `structure InstanceBridge` + dual-mode theorems — **never** `FoundryStep = hcalcStep`. + +### Provenance (pass-2 — do not revert) + +- **Gap-Tp-from-P64** \(\alpha\) law: `spec-def` (P64 list alone is Foundry **source-claim** **23**). +- **Gap-C-wrapper**: `spec-adapt` — algorithmic cousin of Foundry soft_project **43**, **not** symbol identity (43 scales schedules; production C scales **state** under Spec \(q=\|D(T_p)\|\)). +- **Gap-ShapeMap / L7**: dual NestedFaithful | FoundryAdditive; InstanceBridge param table; morphism → FoundryAdditive only — never NestedFaithful = prop-**39** rfl. +- Residual \(J\): Spec \(\ell_\infty\); Foundry **46** is \(\ell_2\). + +--- + +## Gap map + +### Defined (production — CLOSED) + +| Symbol | Production definition | GapId | +|--------|----------------------|-------| +| \(X_t\) | `HCALC.Carrier := Fin n → ℝ`, \(\|·\|_\infty\) | Gap-Carrier **CLOSED** | +| \(T_p\) | \(\mathrm{diag}(\alpha)\), \(\alpha_j = 1/(1+\log p_{j\bmod 64})\) from L1/`P64` (**23**); α law **spec-def** | Gap-Tp-from-P64 **CLOSED** | +| \(C\) | scale-or-id on Spec \(q=\|D(T_p)\|_{\mathrm{est}}\) (**spec-adapt**; cousin of **43**, ≠ **43**) | Gap-C-wrapper **CLOSED** | +| \(\Lambda_m\) | scalar \(\min(1,(1-\varepsilon)/(\|C\circ T_p\|_{\mathrm{op}}+\delta))\) | Gap-Λm-scalar **CLOSED** | +| \(\Xi(t,\cdot)\) | \(\xi_t\cdot y + g_t\); default Uniform | Gap-Ξ **CLOSED** | +| ContractAlg | Gershgorin → power-iter fallback → soft_project scale idea | Gap-ContractAlg **CLOSED** | +| Convergence | Hyp ⇒ Banach unique FP (**41**) + residual→0 | Gap-Converge **CLOSED**; L5 dischargeable | +| \(J\) | residual \(\|X - \Xi(t,\Lambda_m\cdot C(T_p(X)))\|_\infty\); iterate to tol (≠ Foundry **46** \(\ell_2\)) | Gap-OptObj **CLOSED** | +| ShapeMap / L7 | **`InstanceBridge`** + dual NestedFaithful\|FoundryAdditive (NOT `rfl`) | Gap-ShapeMap **CLOSED**; L7 **UNBLOCKED** | +| Spectral / orthogonal | Gershgorin, power iter, guardian (**33–38**, **55**) | measure + ContractAlg input | +| Parameters | \(n\), ε tier (**25**, default T2=0.05), δ=1e-12, tol=1e-6 | PRODUCTION § Parameters | + +Full formulas: [`PRODUCTION.md`](PRODUCTION.md). Inventory: [`AXIOMS.md`](AXIOMS.md). + +### Axiom-needed + +**None for domain Gap-*.** All closed in PRODUCTION.md. + +Infrastructure toolchain stubs (accepted, not domain, not production blockers): **Gap-Real-arith**, **Gap-Foundry-StateOps**, **Gap-Foundry-FinMax**, **Gap-Foundry-Norm**, **Gap-Foundry-Div**, **Gap-Foundry-SoftScale** — see [`AXIOMS.md`](AXIOMS.md) § Infrastructure. Status = infra stub (Mathlib deferred). + +### Steering aliases + +| Alias | Canonical | Status | +|-------|-----------|--------| +| G-SHAPE | Gap-ShapeMap | **CLOSED** — `InstanceBridge` (NOT `rfl`); dual bridgeMode | +| G-Lm | Gap-Λm-scalar | **CLOSED** — scalar formula | +| G-C | Gap-C-wrapper | **CLOSED** — `spec-adapt` scale-or-id (≠ **43**) | +| G-Tp | Gap-Tp-from-P64 | **CLOSED** — diagonal α (**spec-def**) from P64 | + +#### Alloy asserts A1–A7 + +| ID | Assert (informal) | Foundry / PRODUCTION anchor | Provenance | +|----|-------------------|----------------------------|------------| +| **A1** | `#P_64 = 64` and elements are the listed first-64 primes | Prop **23** | `source-claim` | +| **A2** | `contractive(J,ε) iff gershgorin(J) < 1-ε` (+ optional power-iter **37**) | **33–37** | `source-claim` | +| **A3** | Soft-project scale idea when `q > 1-ε` (**in-step C**, spec-adapt) | cousin of **43**; PRODUCTION §3 | `source-claim` + spec-adapt | +| **A4** | Recurrence carrier = Foundry affine form **only if** FoundryAdditive / `instance=Foundry` | **39** | `source-claim` (instance-gated) | +| **A5** | PMAT conservation on insert-set | **29** | `source-claim` | +| **A6** | Guardian: reject when spectral radius ≥ 1 or non-finite | **55** | `source-claim` | +| **A7** | Definition-records for Λm, Ξ, C, Tp are **SpecDefined** pointing at PRODUCTION.md | PRODUCTION.md | **SpecDefined** | + +#### Lean L1–L7 + +| ID | Candidate | Kind | Note | +|----|-----------|------|------| +| **L1** | `P64 : Fin 64 → ℕ` (PROPERTIES **23** list) | definition (data) | No axiom if listed | +| **L2** | `gershgorinBound`, `contractiveG` | def + theorem | From **33–34** | +| **L3** | `FoundryStep Ξ Λ T g x` | definition | Exact **39**; ≠ `hcalcStep` | +| **L4** | `qEstimate` / `softProject` | definition | **42–43** as coded (Foundry); production C separate | +| **L5** | Banach unique FP under Hyp | **theorem** (dischargeable) | Narrative **41** + PRODUCTION Hyp | +| **L6** | `Λm`, `HCALC.Ξ`, `C`, `Tp` | **definitions** | PRODUCTION §§2–5 — not axioms | +| **L7** | `structure InstanceBridge` + dual-mode thms | **UNBLOCKED** | **NOT** `rfl`; **NOT** `FoundryStep = hcalcStep` | + +### Noise (explicitly out of scope) + +- UAC branding and product wrappers +- Quantum / AI / cognitive marketing language +- Ungrounded or Google-redirect citations +- “Stability without hypotheses” claims +- Equating Sedona Spine / PIRTM linker theater (**21**) with mathematical \(T_p\) +- Silently identifying Foundry **39** with nested / claiming `rfl` ShapeMap +- Tagging production `C` as Foundry **43** `source-claim` (it is **spec-adapt**) +- Equating Spec \(\ell_\infty\) residual with Foundry **46** \(\ell_2\) + +--- + +## Foundry instantiation map (cite-only) + +Absorbed from `FOUNDRY_J_CROSSLINKS.md` §1. Production **uses** P64 + spectral + soft_project *scale idea* as coded hooks under PRODUCTION.md — Spec wiring / adapt, not Foundry-native identity of HCALC symbols. + +### \(T_p\) (production uses P64 diagonal) + +| Foundry surface | Role vs \(T_p\) | Cite | +|-----------------|----------------|------| +| **23** `P_64` | Prime table for \(\alpha_j\) (**source-claim**) | `types.h`; PROPERTIES 23; Lean L1 | +| α weight law | **spec-def** (not Foundry PROPERTY) | PRODUCTION §2 | +| `PrimeMask` / `ResonanceWord` | Representation over `P_64` — α schedule view | J_API.md | +| **26–32** PMAT | Sparse prime-monomial LA; **not** production Tp | PROPERTIES E | +| **1–17** Goldilocks \(\mathbb{F}_p\) | Optional future carrier | PROPERTIES A–C | +| **21** PIRTM_MAGIC / linker | Tooling ≠ math \(T_p\) | PROPERTIES 21 | + +Core cite-only hooks: `P64`, `pmat_compose`, `spectral_analyze`, `soft_project`, `q_estimate`, `synth_weights`, `rec_step`, `rec_run`, `ace_certify`. + +### Contraction / spectral measures + +| Props | Measure | +|-------|---------| +| **33–34** | Gershgorin; `contractive ⟺ bound < 1-ε` | +| **35–37** | Power iteration + fallback | +| **38** | Contractive / expansive test matrices | +| **25** | Tier ε schedule (default T2=0.05) | +| **39–46** | Banach recurrence, \(q_t\), soft project, residual (\(\ell_2\)) | +| **55** | Guardian spectral legality | + +--- + +## Invariant inventory (for Alloy) + +Eight coherence obligations. Alloy encodes finite predicates / traces; production defs discharge former opaque gaps. + +| # | Name | Informal statement | Alloy must check | Status | +|---|------|--------------------|------------------|--------| +| 1 | **Inv-StepForm** | Dual bridgeMode; forbid NestedFaithful = prop-**39** | Tag `bridgeMode ∈ {NestedFaithful, FoundryAdditive}` + InstanceBridge table; **forbid** symbol identity / `rfl` | **Defined** — L7 InstanceBridge | +| 2 | **Inv-P64** | If Foundry-backed prime-index, indices from `P_64` | **A1** | source-claim | +| 3 | **Inv-Contractive** | Modulus bound \(< 1-\varepsilon\) for declared ε | **A2**; ε from tier **25** | source-claim + production C | +| 4 | **Inv-QSoft** | Scale-or-id when Spec \(q>1-\varepsilon\) (in-step C) | **A3** (spec-adapt) | production C | +| 5 | **Inv-Residual** | Residual / convergence witness when claimed | Monitor; L5 under Hyp; Spec \(\ell_\infty\) | production Converge | +| 6 | **Inv-PMAT** | If PMAT used: conservation | **A5** | source-claim | +| 7 | **Inv-GapDecisions** | Honor Foundry `GAP_DECISIONS.md` until Spec overrides | Parameter/fixture consistency | PRODUCTION overrides written | +| 8 | **Inv-OpaqueGaps** | Λm, Ξ, C, Tp **SpecDefined** records | **A7** SpecDefined | **CLOSED** | + +Additional: **A4** (Foundry carrier only if FoundryAdditive), **A6** (guardian). + +--- + +## Axiom candidates (for Lean) + +See [`AXIOMS.md`](AXIOMS.md) and [`PRODUCTION.md`](PRODUCTION.md). Summary: + +- **L1–L4**: definitions from Foundry concrete data. +- **L5**: theorem under Hyp — dischargeable; no silent-`sorry` as PASS. +- **L6**: **defs** for Λm, Ξ, C, Tp (replace prior axioms). +- **L7**: **UNBLOCKED** as `structure InstanceBridge` + dual NestedFaithful|FoundryAdditive theorems — **not** `FoundryStep = hcalcStep` / **not** `rfl`. +- Named **Gap-*** domain: CLOSED — no new axioms. + +--- + +## Open problems + +Domain Gap-* closed. Remaining optional / infra only: + +1. Optional Goldilocks \(\mathbb{F}_p\) carrier instance (Foundry **1–17**) — not required for ℝ path. +2. Mathlib migration replacing RealStub / Gap-Foundry-* infra stubs. +3. Empirical ε tier tuning beyond default T2=0.05. +4. Optional Option C embedding morphism theorem (still not identity). + +--- + +## Cross-links + +- **Foundry J / PIRTM:** prime index set, Gershgorin, Banach step, soft_project — production **hooks** under PRODUCTION.md formulas. Primary note: [`FOUNDRY_J_CROSSLINKS.md`](FOUNDRY_J_CROSSLINKS.md). Foundry mirror: `/workspace/foundry-j/spec/HCALC_CROSSLINKS.md`. +- **Core path:** `/workspace/hcalc/j/` (authoritative for HCALC verbs). +- **Alapeno:** hardware stack; no Spec dependency for coherence math. +- **Verify pattern:** [`PROPERTIES.md`](PROPERTIES.md), [`../verify/README.md`](../verify/README.md). +- **Handoff:** [`HANDOFF_PRODUCTION.md`](HANDOFF_PRODUCTION.md). diff --git a/spec/FOUNDRY_J_CROSSLINKS.md b/spec/FOUNDRY_J_CROSSLINKS.md new file mode 100644 index 0000000000000000000000000000000000000000..f40512cf4943b2651162061bff278ca6d2b48589 --- /dev/null +++ b/spec/FOUNDRY_J_CROSSLINKS.md @@ -0,0 +1,116 @@ + + +# Foundry J → HCALC cross-links (Spec input) + +**From:** Foundry J Spec +**For:** HCALC Spec / Alloy / Lean (via Hilbert) +**Sources:** `/workspace/foundry-j/spec/PROPERTIES.md`, `J_API.md`, `GAP_DECISIONS.md`; Foundry README Sedona Spine / PIRTM. +**HCALC abstract (as given):** \( X_{t+1}=\Xi(t,\Lambda_m\cdot C[T_p(X_t)]) \). +**Rule:** No invented \(\Lambda_m\) or \(\Xi\) definitions. Gaps flagged below. +**Note:** `/workspace/hcalc` had no prior tree when this note was written. + +--- + +## 0. Shape gap (read first) + +| | Foundry F1 (cited) | HCALC abstract (given) | +|--|--------------------|-------------------------| +| Step | \( x_{t+1}=\Xi_t x_t+\Lambda_t T(x_t)+g_t \) (PROPERTIES **39**) | \( X_{t+1}=\Xi(t,\Lambda_m\cdot C[T_p(X_t)]) \) | +| \(\Xi\) | Per-step **schedule weights** (length-2 vectors) | Operator/map \(\Xi(t,\cdot)\) — **undefined in Foundry** | +| \(\Lambda\) / \(\Lambda_m\) | \(\Lambda_t\) schedule weights (same carrier as \(\Xi_t\)) | \(\Lambda_m\) — **no definition in Foundry sources** | +| \(T\) / \(T_p\) | Nonlinear \(T(x)\) in recurrence; **no \(T_p\)** symbol | Prime-indexed \(T_p\) — **not named in Foundry math** | +| \(C\) | Not a Foundry recurrence symbol | **Undefined** in Foundry inventory | + +**Spec stance:** Treat Foundry as a **candidate instantiation layer** for pieces of the HCALC pipeline (prime index set, contraction tests, Banach step), not as a definition of \(\Lambda_m\) or HCALC-\(\Xi\). Alloy/Lean must not silently equate the two step forms. + +--- + +## 1. Map: what Foundry can instantiate + +### \(T_p\) candidates (prime-indexed structure) + +| Foundry prop / surface | Role vs \(T_p\) | Cite | +|------------------------|----------------|------| +| **23** `P_64` (first 64 primes, length-64 list) | Discrete **prime index set** for any prime-indexed tensor/mask; strongest Foundry hook for “prime-indexed” | `types.h:24–30`; PROPERTIES 23 | +| `PrimeMask` / `ResonanceWord` (J_API nouns) | Bitmask / packed class∥payload over `P_64` indices — **representation**, not a recursive tensor law | J_API.md nouns | +| **26–32** PMAT / prime monomials (`Signature`, conservation, compose-as-coded) | Sparse **prime-monomial** linear algebra; possible skeleton for layer ops, **not** a definition of recursive tensor reps | PROPERTIES E; GAP_DECISIONS: grading stub, compose = `a.delta_source+b.delta_target` only | +| **1–17** Goldilocks \(\mathbb{F}_p\) | Finite-field **carrier** for discrete/algebraic lifts; does **not** by itself give real contraction of \(X_t\) | PROPERTIES A–C | +| **21** `PIRTM_MAGIC` / linker PIRTM | Bytecode/linker theater (Sedona Spine tooling) — **not** a math definition of \(T_p\) | PROPERTIES 21; README linker | + +**Sedona Spine:** README names a 10-layer architecture and Triple-Lock; it does **not** define HCALC \(T_p\), \(\Lambda_m\), or \(C\). Use as architectural context only. + +### Contraction / spectral measures (layerwise contraction → converged \(X\)) + +| Foundry prop | Measure | Cite | +|--------------|---------|------| +| **33–34** Gershgorin bound; `contractive ⟺ bound < 1-ε` | A priori row-sum spectral bound | PROPERTIES 33–34 | +| **35–37** Power iteration + fallback policy | Dominant-modulus check; recheck when Gershgorin tight | PROPERTIES 35–37 | +| **38** Contractive / expansive test matrices | Concrete witnesses (quoted in PROPERTIES; do not alter) | PROPERTIES 38 | +| **25** Tier ε: T1→0.10, T2→0.05, T3→0.02, T4→0.01 | Contraction **margin** schedule | PROPERTIES 25 | +| **39–46** Banach recurrence, \(q_t\), soft project, residual | Foundry **evolution** + projection when \(q>1-\varepsilon\) | PROPERTIES G | +| **55** Guardian spectral legality | Reject if `spectral_radius >= 1` or non-finite next state | PROPERTIES 55 | + +--- + +## 2. Invariants demanded before calling HCALC “coherent” + +Demand these as **explicit** Spec/Alloy/Lean obligations (Foundry-backed where cited; HCALC-native where flagged): + +1. **Step-form declared** — Either adopt Foundry **39** as an instance, or define HCALC \(\Xi(t,\cdot)\) / \(\Lambda_m\) / \(C\) / \(T_p\) separately. **Do not mix symbols without a bridge lemma.** (Gap: HCALC defs missing.) +2. **Prime index honesty** — If “prime-indexed” means Foundry, \(T_p\) (or its mask) is valued on **`P_64` (prop 23)** or a stated extension; no silent infinite prime stream. +3. **Contraction predicate** — Layer/Jacobian (or stated linearization) satisfies Foundry-style **34/36**: modulus bound \(< 1-\varepsilon\) for a declared \(\varepsilon\) (tier **25** or other cited constant). +4. **q-budget / soft projection** — If Foundry schedules are used: **40/42/43** — \(q=\|\Xi\|+\|\Lambda\|\cdot\|T\|\); if \(q>1-\varepsilon\), scale as coded. +5. **Convergence witness** — Residual **46** (or Lean equivalent) below a declared tolerance; unique fixed-point only where Banach hypotheses **41** are discharged (not assumed from narrative alone). +6. **PMAT conservation (if PMAT used)** — **29** product/sum of entry monomials equals accumulated signature sums (test vector cited in PROPERTIES). +7. **Gap rulings respected** — Match C++ as coded per `GAP_DECISIONS.md` (compose deltas, grading stub, EPSILON literal, unused BARRITT_MU/PHI) until HCALC Spec overrides **in writing**. +8. **No invented \(\Lambda_m\)** — Alloy/Lean may leave \(\Lambda_m\), HCALC-\(\Xi\), \(C\), \(T_p\) as **opaque symbols** or axioms with `sorry`/uninterpreted ops until HCALC Spec defines them. + +--- + +## 3. Shortlist for Alloy asserts + Lean axiom candidates + +### Alloy-oriented asserts (finite, checkable) + +| ID | Assert (informal) | Foundry anchor | +|----|-------------------|----------------| +| A1 | `#P_64 = 64` and elements are the listed first-64 primes | Prop **23** | +| A2 | `contractive(J,ε) iff gershgorin(J) < 1-ε` (and optional power-iter branch **37**) | **33–37** | +| A3 | Soft-project: if `q > 1-ε` then scaled weights used in the step | **43** | +| A4 | Recurrence carrier: next state is affine Foundry form **only if** instance = Foundry | **39** | +| A5 | PMAT conservation on insert-set | **29** | +| A6 | Guardian: reject when spectral radius ≥ 1 or non-finite | **55** | +| A7 | **Gap stub:** `Λm`, HCALC-`Ξ`, `C`, `T_p` are unconstrained until defined — assert **presence of a definition record**, not a formula | (no Foundry cite) | + +### Lean axiom / definition candidates (prefer defs where Foundry is concrete) + +| ID | Candidate | Kind | Note | +|----|-----------|------|------| +| L1 | `P64 : Fin 64 → ℕ` with the PROPERTIES **23** list | **definition** (data) | No axiom needed if listed | +| L2 | `gershgorinBound`, `contractiveG` | **definition** + theorem | From **33–34** | +| L3 | `FoundryStep Ξ Λ T g x` | **definition** | Exact **39**; ≠ HCALC abstract | +| L4 | `qEstimate` / `softProject` | **definition** | **42–43** as coded | +| L5 | Banach unique fixed point under `q < 1-ε` | **theorem** (or axiom until proof) | Narrative **41** — prove or mark unfinished | +| L6 | `Λm`, `HCALC.Ξ`, `C`, `Tp` | **axioms / uninterpreted** | **Gaps — do not invent** | +| L7 | Bridge `HCALCStep = FoundryStep` (or embedding) | **axiom or theorem** | Only after HCALC Spec defines left-hand side | + +### Explicit gaps (do not invent) + +- \(\Lambda_m\) — no Foundry definition (Foundry has \(\Lambda_t\) weights only). +- HCALC \(\Xi(t,\cdot)\) — not Foundry \(\Xi_t\) vectors. +- \(C[\cdot]\) — undefined in Foundry inventory. +- \(T_p\) — no Foundry symbol; closest are `P_64` + PMAT + \(T(x)\). +- Recursive tensor representation law — **absent** from Foundry PROPERTIES. +- `/workspace/hcalc` content beyond this note — none at write time. + +--- + +## 4. Suggested handoff order + +1. HCALC Spec: define or explicitly leave open \(\Lambda_m\), \(\Xi\), \(C\), \(T_p\). +2. Alloy: A1–A6 on Foundry instance; A7 gate on open symbols. +3. Lean: L1–L4 defs first; L6 axioms for gaps; L5/L7 only with proof or labeled unfinished. +4. Foundry Core/Verify: keep prop **16** FAIL and coverage matrix in view when claiming Goldilocks lifts into HCALC. + diff --git a/spec/FOUNDRY_J_PRODUCTION_REVIEW.md b/spec/FOUNDRY_J_PRODUCTION_REVIEW.md new file mode 100644 index 0000000000000000000000000000000000000000..06bfcd95dc8892b13d473c43805fea6ecc2788ae --- /dev/null +++ b/spec/FOUNDRY_J_PRODUCTION_REVIEW.md @@ -0,0 +1,66 @@ + + +# Foundry J Spec — HCALC PRODUCTION.md review (pass 3 / InstanceBridge) + +**Reviewer:** Foundry J Spec +**Date:** 2026-10-07 (PT) +**Target:** `/workspace/hcalc/spec/PRODUCTION.md` @ `f5a08da` +**Focus:** §6 ShapeMap `InstanceBridge` vs REJECT identity; Core path `/workspace/hcalc/j/` + +--- + +## Verdict (short) + +| Item | Verdict | +|------|---------| +| §6 `InstanceBridge` (NOT rfl / NOT Foundry39≡nested) | **ACCEPT** | +| Explicit param table \(T:=C\circ T_p\), \(\Lambda:=\Lambda_m\mathbf{1}\), \(\Xi:=\xi_t\) without symbol identity | **ACCEPT** | +| Option B: implement `hcalc_step` only; `toFoundryStep` diagnostic cite-only | **ACCEPT** | +| soft_project remains Foundry-coded **42–43**; `C` is Spec wiring that *uses* the scale idea | **ACCEPT** (wording in §6) | +| Core path `/workspace/hcalc/j/` + verb list matching `HCALC_API_DRAFT.md` | **ACCEPT** | +| GAP_DECISIONS | **No conflict** | +| Silent identity Foundry39 ≡ nested | Still **REJECT** — PRODUCTION agrees | + +**Overall:** **ACCEPT** PRODUCTION @ `f5a08da` for ShapeMap / implement path. Non-blocking nits below. + +--- + +## §6 ShapeMap detail + +PRODUCTION now states clearly: + +- `toFoundryStep` = \(\xi_t\cdot x + \Lambda_m(C\circ T_p)(x)+g_t\) under InstanceBridge params. +- `hcalcStep` = \(\xi_t\cdot(\Lambda_m\cdot C(T_p(x)))+g_t\). +- These differ (\(\xi_t\cdot x\) only on Foundry side). +- L7 = structure + theorems about the table, **not** `FoundryStep = hcalcStep`. + +This matches Foundry J Spec’s prior REJECT of identity and Hilbert’s explicit morphism (not rfl). **ACCEPT.** + +--- + +## `/workspace/hcalc/j/` implement path + +| Check | Result | +|-------|--------| +| Path authoritative under hcalc | **ACCEPT** | +| Verbs: `tp_from_p64`, `c_wrap`, `lam_m_from_bound`, `hcalc_xi_apply`, `hcalc_step`, `hcalc_run` | **ACCEPT** (names match draft) | +| Do not equate `hcalc_step` / `rec_step` | **ACCEPT** | +| Implementation status | **Scaffold only** (`j/README.md`); bodies still Core’s job — not a Spec reject | + +--- + +## Non-blocking nits (optional Spec polish) + +1. **§3 vs §6 soft_project wording:** §3 formula still scales **state** \(x\); Foundry **43** scales **schedules** \(\Xi,\Lambda\). §6 correctly calls that Spec wiring. One footnote in §3: “`softProjectScale` factor shared; Foundry `soft_project` API remains schedule-scaling when called as Foundry.” +2. **Alloy checklist line** still says “FoundryAdditive” — align naming to `InstanceBridge` / `toFoundryStep` vs `hcalcStep`. +3. **§8 Hyp under Uniform:** phrase “when using InstanceBridge” for nested Lip — prefer “when iterating `hcalcStep` (Option B)”; `toFoundryStep` has an extra \(\xi_t\cdot x\) term. +4. **α law / ℓ∞ residual:** still Spec-def (not Foundry source-claim) — OK if provenance stays Spec-owned. + +--- + +## Summary for Hilbert / HCALC Spec + +**ACCEPT** InstanceBridge ShapeMap and `/workspace/hcalc/j/` Core path. Identity REJECT stands and is honored. Ready for Alloy/Lean/Core to implement Option B without further Foundry J Spec gate — unless they want the §3 soft_project footnote. diff --git a/spec/HANDOFF_PRODUCTION.md b/spec/HANDOFF_PRODUCTION.md new file mode 100644 index 0000000000000000000000000000000000000000..c03c5ba5b0a46452ffe44df6a6e862f985c7aa88 --- /dev/null +++ b/spec/HANDOFF_PRODUCTION.md @@ -0,0 +1,49 @@ + + +# HANDOFF — Production close (copy-paste for Alloy / Lean / Verify / Core) + +**Authority:** [`PRODUCTION.md`](PRODUCTION.md) @ commit with InstanceBridge + Pass-2 provenance. +**Do not invent** beyond PRODUCTION / AXIOMS. Spec does not edit `.als` / `.lean` bodies. + +--- + +## Alloy + +1. Replace A7 GapRecord status `Undefined` → `SpecDefined` for Λm, Ξ, C, Tp; point comments at PRODUCTION.md. +2. Encode production preds: Carrier ℝ^n / abstract n; diag Tp α; C scale-or-id; Λm scalar min formula; Ξ = ξ·y+g (Uniform). +3. Add `bridgeMode ∈ {NestedFaithful, FoundryAdditive}` + `InstanceBridge` param table. +4. **Forbid** NestedFaithful = Foundry prop-**39** / `rfl` / silent symbol identity. +5. Keep A1–A6; rewire A3 to Spec q / in-step C (**spec-adapt** ≠ Foundry **43** schedule soft_project). +6. OptObj = residual \(\ell_\infty\); ContractAlg = Gershgorin→power-iter→scale-or-id. +7. Re-run `alloy/run.sh`; expect green with SpecDefined A7. + +## Lean + +1. Replace L6 axioms with **defs**: `Carrier`, `Tp`, `C`, `LambdaM`, `Xi`, `J`. +2. Unblock L7: `structure InstanceBridge` holding param table; dual-mode theorems — **never** `FoundryStep = hcalcStep` / **never** `rfl`. +3. L5: theorem under PRODUCTION Hyp (0 sorry). +4. Keep infra Gap-Real-* / Gap-Foundry-* stubs labeled infra-not-production-gap. +5. Tag α as **spec-def**; C as **spec-adapt**. +6. `lake build` exit 0. + +## Verify + +1. Flip SKIP→PASS where hyps hold (PROPERTY_MAP H-A7, H-SHAPE, H-NEST, H-OPT, H-L5). +2. H-SHAPE PASS **only** for InstanceBridge witness — never identity PASS. +3. Note Spec residual \(\ell_\infty\) ≠ Foundry **46** \(\ell_2\). +4. FAIL-open still if Lean sorry / Alloy unsat / Undefined A7. +5. Update `verify/PROPERTY_MAP.md` to match `spec/PROPERTIES.md`. + +## Core (`/workspace/hcalc/j/`) + +1. Implement Option B verbs: `tp_from_p64`, `c_wrap`, `lam_m_from_bound`, `hcalc_xi_apply`, `hcalc_step`, `hcalc_run`. +2. Cite Foundry hooks (`P64`, `spectral_analyze`, `soft_project`, `q_estimate`, `synth_weights`) — do **not** equate `hcalc_step` with `rec_step`. +3. Expose `toFoundryStep` only as FoundryAdditive diagnostic. +4. Leave Foundry additive API unchanged. + +## Push gate + +Do **not** push until Alloy + Lean + Verify are green. diff --git a/spec/INTERFACES.md b/spec/INTERFACES.md new file mode 100644 index 0000000000000000000000000000000000000000..45028e5248364e82c8c519fafe4f4586b5232810 --- /dev/null +++ b/spec/INTERFACES.md @@ -0,0 +1,81 @@ + + +# HCALC Interfaces — Alloy vs Lean + +**Owner:** HCALC Spec agent +**Definitions live in:** [`PRODUCTION.md`](PRODUCTION.md), [`COHERENCE.md`](COHERENCE.md), [`AXIOMS.md`](AXIOMS.md), [`FOUNDRY_J_CROSSLINKS.md`](FOUNDRY_J_CROSSLINKS.md). +**Status:** Production definitions landed; Alloy must replace A7 Undefined→SpecDefined; Lean defs not axioms; Verify flip SKIP→PASS where hyps hold. +**Spec does not write** `.als` or `.lean` bodies (see [`HANDOFF_PRODUCTION.md`](HANDOFF_PRODUCTION.md)). + +--- + +## Shared vocabulary (symbol table) + +| Symbol | Meaning | Gap / ID | Status | +|--------|---------|----------|--------| +| \(X_t\) | State | Gap-Carrier | **CLOSED** — `HCALC.Carrier` | +| \(T_p\) | Diagonal prime-indexed transform | Gap-Tp-from-P64, A7, L6 | **CLOSED** (**spec-def** α) | +| \(C\) | In-step scale-or-id | Gap-C-wrapper, A7, L6 | **CLOSED** (**spec-adapt** ≠ **43**) | +| \(\Lambda_m\) | Stabilizing **scalar** | Gap-Λm-scalar, A7, L6 | **CLOSED** | +| \(\Xi(t,\cdot)\) | HCALC evolution operator | Gap-Ξ, A7, L6 | **CLOSED** | +| Foundry step | \(x'=\Xi x+\Lambda T(x)+g\) | A4, L3 | FoundryAdditive diagnostic | +| HCALC step | \(X_{t+1}=\Xi(t,\Lambda_m\cdot C(T_p(X_t)))\) | NestedFaithful | production Core verb | +| InstanceBridge | Param table \(T:=C\circ T_p\), \(\Lambda:=\Lambda_m\mathbf{1}\), \(\Xi:=\xi_t\) | Gap-ShapeMap, L7 | **CLOSED** — NOT `rfl` | +| `P_64` | First-64 primes index set | A1, L1 | source-claim **23** | + +Provenance on every Alloy assert / Lean axiom: `source-claim` | `axiom-gap` | `derived` | `SpecDefined` | `spec-def` | `spec-adapt`. + +--- + +## What HCALC Alloy must assert + +- **A1–A6** when the model claims Foundry-backed surfaces (finite predicates / traces). +- **A7** with **SpecDefined** records pointing at PRODUCTION.md (replace prior `Undefined`). +- **Inv-StepForm … Inv-OpaqueGaps** (COHERENCE invariant inventory). +- Dual `bridgeMode ∈ {NestedFaithful, FoundryAdditive}` + InstanceBridge table; **forbid** NestedFaithful = prop-**39** / `rfl`. +- Forbidden: PASS when guardian (**A6**) would reject. +- May leave as **parameters:** ε tier, instance tag, carrier dimension, whether PMAT is enabled. +- OptObj = Spec \(\ell_\infty\) residual; ContractAlg = Gershgorin→power-iter→scale-or-id. + +Provenance tags should reference GapIds / A* / L* from COHERENCE/AXIOMS/PRODUCTION. + +--- + +## What HCALC Lean may axiomize vs must prove + +| May keep as infra axiom (toolchain only) | Must define or prove | +|------------------------------------------|----------------------| +| Gap-Real-arith / Gap-Foundry-* stubs | L1 P64 data as def | +| | L2 gershgorin/contractiveG | +| | L3 FoundryStep def (**≠** hcalcStep) | +| | L4 qEstimate/softProject (Foundry) | +| | L5 theorem under Hyp (0 sorry) | +| | L6: Λm, Ξ, C, Tp as **defs** (replace axioms) | +| | L7: `structure InstanceBridge` + dual-mode thms — **NOT** `rfl` / **NOT** `FoundryStep = hcalcStep` | + +Zero `sorry` in production leaves. Domain gaps are CLOSED — no new L6 axioms. + +--- + +## Foundry J Core / Verify + +- Cross-links: `FOUNDRY_J_CROSSLINKS.md`; Foundry mirror `/workspace/foundry-j/spec/HCALC_CROSSLINKS.md`. +- Core implement path (authoritative): **`/workspace/hcalc/j/`** — verbs `tp_from_p64`, `c_wrap`, `lam_m_from_bound`, `hcalc_xi_apply`, `hcalc_step`, `hcalc_run`. +- Core hooks are **cite-only** — do not equate `hcalc_step` with `rec_step`. +- Verify outline: [`PROPERTIES.md`](PROPERTIES.md); harness [`../verify/README.md`](../verify/README.md). +- H-SHAPE PASS only for InstanceBridge witness, never identity. + +--- + +## Hand-off + +| Agent | Owns | Does not own | +|-------|------|--------------| +| **Spec** | PRODUCTION, COHERENCE, AXIOMS, PROPERTIES outline, INTERFACES, crosslinks | `.als`, `.lean`, J verb bodies | +| **Alloy** | `alloy/**/*.als`, Alloy README beyond stub | Changing GapId meanings / inventing `rfl` bridge | +| **Lean** | `lean/**/*.lean` | Re-axiomatizing CLOSED L6; `FoundryStep = hcalcStep` | +| **Verify** | `verify/` harness per PROPERTIES | Closing ShapeMap without Spec | +| **Core** | `/workspace/hcalc/j/` production verbs | Equating FoundryAdditive with NestedFaithful | diff --git a/spec/PRODUCTION.md b/spec/PRODUCTION.md new file mode 100644 index 0000000000000000000000000000000000000000..a77d19b6f3ee614b06dbc6bfc6ccc536243ad954 --- /dev/null +++ b/spec/PRODUCTION.md @@ -0,0 +1,304 @@ + + +# HCALC Production Definitions + +**Owner:** HCALC Spec +**License:** AGPL-3.0-only +**Status:** PRODUCTION — all domain Gap-* CLOSED by definition (not opaque axioms). +**Consumers:** Alloy, Lean, Foundry J Core/Verify/Spec. +**Related:** [`AXIOMS.md`](AXIOMS.md), [`COHERENCE.md`](COHERENCE.md), [`FOUNDRY_J_CROSSLINKS.md`](FOUNDRY_J_CROSSLINKS.md). + +Nested recurrence (canonical): + +\[ +X_{t+1} = \Xi\bigl(t,\; \Lambda_m \cdot C(T_p(X_t))\bigr). +\] + +--- + +## Parameters (fixed for production) + +| Symbol | Meaning | Default | +|--------|---------|---------| +| \(n\) | Carrier dimension | parameter \(\ge 1\) (Lean: free `n : ℕ`) | +| \(\varepsilon\) | Contraction margin | tier schedule Foundry **25**: T1→0.10, T2→0.05, T3→0.02, T4→0.01; **default T2 = 0.05** | +| \(\delta\) | Guard for Λm denominator | \(10^{-12}\) (positive) | +| \(\mathrm{tol}\) | Residual stop | \(10^{-6}\) | +| `xi_schedule` | \(\xi_t\) law | **Uniform**: \(\xi_t = 1\) for all \(t\) | +| `g_t` | Affine kick | default \(0\) (zero vector) unless instance supplies otherwise | + +Foundry cites used below: PROPERTIES **23**, **25**, **33–43**, **39**, **41**, **46**. + +--- + +## Closed definitions + +### 1. Gap-Carrier → `HCALC.Carrier` — CLOSED + +\[ +\texttt{HCALC.Carrier} \;\equiv\; X \;:=\; \mathbb{R}^n \;=\; (\mathrm{Fin}\, n \to \mathbb{R}) +\] + +with \(\ell_\infty\) norm \(\|x\|_\infty = \max_{j} |x_j|\). +Optional later instance: Goldilocks \(\mathbb{F}_p\) (Foundry **1–17**) — **not** required for production ℝ path. + +### 2. Gap-Tp-from-P64 → `Tp` — CLOSED + +Let \(P_{64} = (p_0,\ldots,p_{63})\) be the first-64 primes (Lean **L1** / Foundry prop **23**). +For dimension \(n\), use primes \(p_{j \bmod 64}\). + +**Exact formula (diagonal PrimeMask weights):** + +\[ +\alpha_j \;=\; \frac{1}{1 + \log p_{j\bmod 64}}, \qquad +(T_p\, x)_j \;=\; \alpha_j \cdot x_j. +\] + +So \(\varphi\) is the **identity on coordinates** (diagonal action). +Equivalent view: \(T_p = \mathrm{diag}(\alpha)\). +**Provenance:** \(\alpha\) law is **`spec-def`** (HCALC Spec) — **not** a Foundry source-claim. \(P_{64}\) list alone is Foundry **23** / Lean L1. +**Not** Sedona/PIRTM tooling; **not** full PMAT recursion. + +**Provenance (§2):** `P64` list = Foundry **source-claim** (prop **23**). The weight law $\alpha_j=1/(1+\log p_{j\bmod 64})$ is **`spec-def`** — **not** a Foundry PROPERTY / not `source-claim` from foundry-j. + +### 3. Gap-C-wrapper → `C` — CLOSED + +Let \(D(T_p)\) be the Jacobian of \(T_p\) (here \(D(T_p)=\mathrm{diag}(\alpha)\)). +Let \(q\) be the operator-norm estimate via Gershgorin, with power-iteration fallback (Foundry **33–37**): + +\[ +q \;:=\; \|D(T_p)\|_{\mathrm{est}}. +\] + +**In-step governor** — Spec-defined **state scale-or-id** (not post-hoc `ace_certify`): + +\[ +C(x) \;=\; +\begin{cases} +\dfrac{1-\varepsilon}{q}\, x & \text{if } q > 1-\varepsilon, \\[6pt] +x & \text{otherwise.} +\end{cases} +\] + +I.e. \(C = s\cdot\mathrm{id}\) on **state**, with \(s=(1-\varepsilon)/q\) when over margin. + +**Provenance (Foundry pass 2):** \(C\) is **`spec-adapt`** of the scale-factor *idea* \((1-\varepsilon)/q\). +**REJECT** identity with Foundry `soft_project` **43** (which scales schedule vectors \(\Xi,\Lambda\), not state). +Foundry **43** remains the coded schedule soft_project on the **FoundryAdditive** path. Production \(q=\|D(T_p)\|_{\mathrm{est}}\) is Spec \(q\), not Foundry **42** schedule \(q\). + +**Provenance (§3):** Production `C` is **`spec-adapt`**: it reuses the *scale-or-id* idea \((1-\varepsilon)/q\) as an **algorithmic cousin** of Foundry `soft_project` (prop **43**), but it is **not** symbol-identical to **43**. Foundry **43** scales schedule weights \(\Xi,\Lambda\) under Foundry \(q\) (prop **42**); production `C` scales the **state** under Spec \(q:=\|D(T_p)\|_{\mathrm{est}}\). Do **not** tag `C` as Foundry `source-claim` for **43**. Shared helper name `softProjectScale` OK; **Foundry `soft_project` API stays schedule-scaling** (prop **43**). Production `C` remains Spec-wiring / **spec-adapt** (state scale). + +### 4. Gap-Λm-scalar → `Λm` — CLOSED + +\(\Lambda_m \in \mathbb{R}_{\ge 0}\) is a **scalar** (not Foundry `lambda_schedule` vector): + +\[ +\Lambda_m \;=\; \min\Bigl(1,\; \frac{1-\varepsilon}{\|C\circ T_p\|_{\mathrm{op}} + \delta}\Bigr), +\] + +ensuring \(\|\Lambda_m\cdot(C\circ T_p)\|_{\mathrm{op}} \le 1-\varepsilon\). + +### 5. Gap-Ξ → `Ξ` — CLOSED + +With \(\xi_t\) from `xi_schedule(t)` (default **Uniform**: \(\xi_t=1\)) and kick \(g_t\): + +\[ +\Xi(t,y) \;:=\; \xi_t\cdot y + g_t. +\] + +Therefore + +\[ +X_{t+1} = \xi_t\cdot\bigl(\Lambda_m\cdot C(T_p(X_t))\bigr) + g_t. +\] + +### 6. Gap-ShapeMap / L7 — CLOSED via **InstanceBridge** (NOT `rfl`) + +**REJECTED (Foundry J Spec review):** identity `Foundry39 ≡ nested`; silent `Λ_t↔Λm`, `T↔T_p`, `Ξ_t↔Ξ(t,·)`, Gershgorin/`soft_project` measures ↔ in-step `C` as Foundry-native law. + +**ACCEPTED:** Gap-ShapeMap is a **non-identity** morphism. soft_project remains **Foundry-coded** (props **42–43**) and is *used by* HCALC `C` under this Spec — that is Spec wiring, not a Foundry identity claim. + +#### Dual `bridgeMode` (keep both; never silent equate) + +| `bridgeMode` | Meaning | Prop-**39**? | +|--------------|---------|--------------| +| **NestedFaithful** | production verb = `hcalcStep` (nested) | **no** — Spec nested; ≠ classical **39** | +| **FoundryAdditive** | diagnostic `toFoundryStep` via InstanceBridge param table | **yes-shaped** morphism toward **39**; still ≠ nested | + +`InstanceBridge` is the **parameter table** \(T:=C\circ T_p\), \(\Lambda_{\mathrm{vec}}:=\Lambda_m\cdot\mathbf{1}\), \(\Xi_{\mathrm{vec}}:=\xi_t\), \(g:=g_t\) — a **non-identity** morphism, never `rfl`. + +#### Explicit morphism `InstanceBridge` (feeds FoundryAdditive mode) + +Let HCALC state \(x\in\texttt{HCALC.Carrier}\). Define a **labeled instance map** (Lean: `InstanceBridge`, Alloy: `bridgeMode = InstanceBridge`): + +\[ +\texttt{toFoundryStep}(t,x) +\;:=\; +\texttt{FoundryStep}\bigl( + \Xi_{\mathrm{vec}}:=\xi_t,\; + \Lambda_{\mathrm{vec}}:=\Lambda_m\cdot\mathbf{1},\; + T := C\circ T_p,\; + g := g_t,\; + x +\bigr) +\;=\; +\xi_t\cdot x + \Lambda_m\cdot(C\circ T_p)(x) + g_t. +\] + +The **HCALC nested step** is separately: + +\[ +\texttt{hcalcStep}(t,x) +\;:=\; +\Xi\bigl(t,\, \Lambda_m\cdot C(T_p(x))\bigr) +\;=\; +\xi_t\cdot\bigl(\Lambda_m\cdot C(T_p(x))\bigr) + g_t. +\] + +These are **different** morphisms in general (\(\xi_t\cdot x\) term present only on the Foundry side). +**L7 theorem (production):** there exists an explicit Spec-named witness relating them — *not* `rfl`: + +- **Option A (recommended default):** `bridgeWitness = Projective` — equality after applying the HCALC projection that discards the free \(\xi_t\cdot x\) drift, or equivalently require \(\xi_t=0\) on the identity channel (not used). +- **Option B (operational default for Core):** implement **only** `hcalcStep` as the production verb; expose `toFoundryStep` as a **cite-only diagnostic** that uses Foundry `rec_step` shape with the parameter table above, **without claiming** `hcalcStep = toFoundryStep`. +- **Option C:** when \(\xi_t = 1\) and one rewrites nested as additive on an extended state, document the embedding \(\iota\) and prove `toFoundryStep(t,ι(x)) = ι(hcalcStep(t,x))` — still a morphism, **never** symbol identity. + +**Production bridgeMode (dual — Foundry J Spec ACCEPT):** + +| bridgeMode | Meaning | vs Foundry **39** | +|------------|---------|-------------------| +| **FoundryAdditive** | `toFoundryStep` = classical **39**-shaped morphism with InstanceBridge params `T:=C∘Tp`, `Λ:=Λm·1`, `Ξ:=ξ_t` | **ACCEPT** morphism into additive shape — **not** nested | +| **NestedFaithful** / nested `hcalcStep` | `ξ·(Λm·(C∘Tp)(x))+g` | Spec definitional nested — **REJECT** as prop-**39** `rfl` / identity | + +**InstanceBridge** = the explicit parameter table (morphism data), not an equality proof. Hilbert morphism \(T:=C\circ T_p\), \(\Lambda:=\Lambda_m\mathbf{1}\), \(\Xi:=\xi\) maps to **FoundryAdditive** shape only. + +**Production choice for Core:** implement **`hcalc_step`** = nested (NestedFaithful semantics); expose `toFoundryStep` only as FoundryAdditive diagnostic. **L7 UNBLOCKED** as `structure InstanceBridge` + dual-mode theorems — **never** `FoundryStep = hcalcStep`. + +| Foundry symbol (instance params) | HCALC production value | Identity? | +|----------------------------------|------------------------|-----------| +| \(T\) | \(C\circ T_p\) | **no** — assignment under InstanceBridge | +| \(\Lambda_{\mathrm{vec}}\) | \(\Lambda_m\cdot\mathbf{1}\) | **no** — scalar broadcast ≠ Foundry schedule vector law | +| \(\Xi_{\mathrm{vec}}\) | \(\xi_t\) from HCALC `xi_schedule` | **no** — not Foundry \(\Xi_t\) vector schedule identity | +| \(g\) | \(g_t\) | instance param | + +### 7. Gap-ContractAlg — CLOSED + +Algorithm: + +1. Estimate Spec \(q=\|D(T_p)\|_{\mathrm{est}}\) by Gershgorin; power-iteration fallback (Foundry measures **33–37**, Spec-wired). +2. Apply **state** scale-or-id \(C\) as in §3 (`spec-adapt`; ≠ schedule soft_project **43**). +3. Form \(\Lambda_m\) as in §4. +4. On FoundryAdditive path only: Foundry schedule soft_project **43** may still apply to \(\Xi,\Lambda\) schedules as coded. + +### 8. Gap-Converge — CLOSED (L5 dischargeable) + +**Hyp** (for iteration of **`hcalcStep`** — Option B / nested production path): + +\[ +|\xi_t|\cdot\|\Lambda_m\cdot(C\circ T_p)\|_{\mathrm{op}} < 1-\varepsilon. +\] + +Under Uniform \(\xi_t=1\) this is \(\|\Lambda_m\cdot(C\circ T_p)\|_{\mathrm{op}} < 1-\varepsilon\). + +Do **not** state Hyp on `toFoundryStep` / classical additive shape without an extra account of the free \(\xi_t\cdot x\) term (that diagnostic has a different operator). + +Then: Banach unique fixed point (Foundry narrative **41**, spirit) and residual \(\to 0\) along **`hcalcStep`** iteration (stop spirit of **46**; metric is Spec \(\ell_\infty\)). +**L5:** theorem under Hyp (prove in Lean; not unfinished axiom). + +### 9. Gap-OptObj — CLOSED + +\[ +J(X) \;=\; \bigl\| X - \Xi\bigl(t,\, \Lambda_m\cdot C(T_p(X))\bigr) \bigr\|_\infty +\] + +(residual). **Optimize** = iterate the nested map until \(J(X)<\mathrm{tol}\). + +**Provenance (residual):** PRODUCTION \(J\) uses \(\ell_\infty\). Foundry prop **46** residual is \(\ell_2\). **ACCEPT Spec \(\ell_\infty\) choice**; do not claim metric identity with **46** — only stop-spirit / tolerance pattern. + +--- + +## Infra gaps (not domain blockers) + +| GapId | Disposition | +|-------|-------------| +| Gap-Real-arith | Infra stub OK (RealStub / future Mathlib). Must not leave unfinished *production* theorems depending on sorry. | +| Gap-Foundry-StateOps / FinMax / Norm / Div / SoftScale | Infra for Foundry mirrors; production HCALC path uses Carrier ℝ^n defs above. Replace with Mathlib when ready. | + +--- + +## Gap disposition table + +| GapId | Was | Now | Alloy action | Lean action | Verify action | +|-------|-----|-----|--------------|-------------|---------------| +| Gap-Carrier | axiom-gap | **CLOSED** `HCALC.Carrier = Fin n → ℝ`, ℓ∞ | Instance param → ℝ^n model / abstract n | `def Carrier` | Check A carrier | +| Gap-Tp-from-P64 | axiom-gap | **CLOSED** diag \(\alpha\) (**spec-def**); P64 list **source-claim** **23** | Retire Undefined; encode diag Tp | `def Tp` from L1 P64 | Prime carrier + Tp law | +| Gap-C-wrapper | axiom-gap | **CLOSED** scale-or-id on Spec \(q\) (**spec-adapt**; cousin of **43**, ≠ **43**) | C = scale-or-id | `def C` | Contraction spectral/q | +| Gap-Λm-scalar | axiom-gap | **CLOSED** scalar min formula | Λm scalar bound assert | `def LambdaM` | Stabilizing range | +| Gap-Ξ | axiom-gap | **CLOSED** \(\xi_t y + g_t\), Uniform default | Ξ affine | `def Xi` | Evolution step shape | +| Gap-ShapeMap / L7 | blocked | **CLOSED** dual `bridgeMode` NestedFaithful|FoundryAdditive + InstanceBridge table (NOT rfl; NestedFaithful ≠ prop39) | Encode InstanceBridge table; forbid symbol identity | **L7** `structure InstanceBridge` + Option B/C thms | H-SHAPE → PASS only for InstanceBridge witness, never identity | +| Gap-ContractAlg | axiom-gap | **CLOSED** Gershgorin→power-iter→soft_project | A2/A3 production wiring | defs + thms | Checks B | +| Gap-Converge | axiom-gap | **CLOSED** Hyp ⇒ Banach + residual→0 | Guardian + residual | **L5** under Hyp | Residual discharge | +| Gap-OptObj | axiom-gap | **CLOSED** \(J=\) residual; iterate to tol | OptObj residual | `def J` + loop spec | Optimize/converge props | +| A7 | Undefined stubs | **SpecDefined** records pointing here | Replace Undefined→Defined | — | A7 gate PASS | +| L6 | uninterpreted axioms | **defs** | — | Replace axioms with defs | Seal Lean↔Alloy | +| Gap-Real-arith / Gap-Foundry-* | infra | infra OK | ignore | keep stubs or Mathlib | no false PASS | + +--- + +## Alloy checklist + +1. Retire all `Undefined` on Λm, Ξ, C, Tp → `SpecDefined` / production preds. +2. Keep A1–A6; rewire A2/A3/A4 to production C/Λm/`InstanceBridge`. +3. Encode **`bridgeMode`**: nested **`hcalcStep`** vs diagnostic **`toFoundryStep`** (InstanceBridge param table). Do **not** assert Foundry39≡nested; do **not** use a bare `FoundryAdditive` equate without InstanceBridge params. +4. OptObj = residual (\(\ell_\infty\)); ContractAlg = Gershgorin→power-iter→Spec scale-or-id. +5. Report check log green. + + +## Lean checklist + +1. `Carrier`, `Tp`, `C`, `LambdaM`, `Xi`, `J` as **defs**. +2. Unblock **L7** InstanceBridge (`def` / theorem). +3. **L5** theorem under Hyp (0 sorry). +4. Infra RealStub only if no production sorry. +5. `lake build` exit 0. + +## Verify checklist + +1. Flip SKIP→PASS where hyps hold (A–E). +2. H-SHAPE PASS under InstanceBridge. +3. FAIL-open still if Lean sorry / Alloy unsat. +4. Update `PROPERTY_MAP.md`. + +## Core checklist (Foundry J) + +Implement verbs: `Tp` from P64 α, in-step `C` state scale-or-id (`spec-adapt`), scalar `Λm`, `Xi` from `xi_schedule`, InstanceBridge step. Cite `P64`, `spectral_analyze`, `soft_project`, `q_estimate`, `synth_weights`, `rec_step`. + +--- + + +## Core implement path (AUTHORITATIVE) + +**Path:** `/workspace/hcalc/j/` (HCALC research-center repo; AGPL-3.0-only). +Foundry J Core implements production verbs **here**, calling Foundry cite hooks from `foundry-j` (`P64`, `spectral_analyze`, `soft_project`, `q_estimate`, `synth_weights`) without equating `hcalc_step` to `rec_step`. + +| Verb | Formula source in this file | +|------|-----------------------------| +| `tp_from_p64` | §2 Gap-Tp-from-P64 | +| `c_wrap` | §3 Gap-C-wrapper (state scale-or-id; ≠ soft_project **43**) | +| `lam_m_from_bound` | §4 Gap-Λm-scalar | +| `hcalc_xi_apply` | §5 Gap-Ξ | +| `hcalc_step` | nested §5; **not** `rec_step` | +| `hcalc_run` | iterate `hcalc_step` until §9 residual < tol | + +Draft names from `foundry-j/j/HCALC_API_DRAFT.md` are **accepted**. Leave Foundry additive API unchanged. + +--- +## Changelog + +- 2026-10-07: Initial PRODUCTION close-all-gaps (USER mandate via Hilbert). +- 2026-10-07: ShapeMap → explicit **InstanceBridge** (Foundry J Spec review); Core path `/workspace/hcalc/j/`. +- 2026-10-07: Pass-3 nits — §3 schedule-scaling note; Alloy checklist InstanceBridge; §8 Hyp on hcalcStep. +- 2026-10-07: Pass-2 absorb — `C`/`q` **spec-adapt** (≠ Foundry **43**/**42**); \(\alpha\) **spec-def**; dual NestedFaithful|FoundryAdditive; residual \(\ell_\infty\neq\ell_2\) note. +- 2026-10-07: Fold Foundry pass 2 — C ≠ soft_project#43; α `spec-def`; NestedFaithful ≠ prop39; dual bridgeMode kept. diff --git a/spec/PROPERTIES.md b/spec/PROPERTIES.md new file mode 100644 index 0000000000000000000000000000000000000000..b91da2d237deb7e23456c2a4b4f19e761039608b --- /dev/null +++ b/spec/PROPERTIES.md @@ -0,0 +1,78 @@ + + +# HCALC PROPERTIES (Verify outline) + +**Owner:** HCALC Spec (outline) → HCALC Verify / Foundry J Verify (harness). +**Pattern:** Foundry `PROPERTIES → J_API freeze → verify/ harness prop_N`. +**Authority:** This file’s **PROPERTY_MAP** is authoritative for HCALC verify naming. Foundry props remain cited by number under `/workspace/foundry-j/spec/PROPERTIES.md` (cite-only). +**Production:** [`PRODUCTION.md`](PRODUCTION.md) — domain Gap-* CLOSED; flip SKIP→PASS where hyps hold. +**Harness:** Not written here — see [`../verify/README.md`](../verify/README.md). + +Absorbed obligations: [`FOUNDRY_J_CROSSLINKS.md`](FOUNDRY_J_CROSSLINKS.md). + +--- + +## Gate sequence + +1. **PROPERTIES** (this outline) — name props and SKIP reasons. +2. **J_API freeze** — when a J surface is adopted, freeze nouns against `/workspace/foundry-j/spec/J_API.md` and `/workspace/hcalc/j/`. +3. **verify/ harness** — `prop_N` executables; map via PROPERTY_MAP. +4. **Seal** — Lean ↔ Alloy ↔ J: `sorry` / Alloy unsat / missing A7 SpecDefined ⇒ **SKIP** or **FAIL-open**, never PASS. + +--- + +## Checks A–E (disposition under production defs) + +| Check | Title | Intent | Gap / ID links | PASS requires | +|-------|-------|--------|----------------|---------------| +| **A** | Prime carrier | `P_64` length/contents; Tp α law | A1, L1, Gap-Tp-from-P64 (**CLOSED**, α **spec-def**) | A1 holds; diag Tp encoded | +| **B** | Contraction spectral / q | Gershgorin / power-iter / tier ε / Spec q-budget | A2, A3, L2, L4, Gap-C (**spec-adapt**) | contractive flags consistent; C scale-or-id | +| **C** | Evolution step shape | Dual bridgeMode NestedFaithful\|FoundryAdditive; InstanceBridge table | A3, A4, Gap-ShapeMap, L3, L7 | instance/bridgeMode correct; **no** additive=`rfl` nested | +| **D** | Field ids if \(\mathbb{F}_p\) | Goldilocks / field identifiers when carrier is finite-field | Gap-Carrier optional; Foundry 1–17 | ids match coded field; prop **16** FAIL kept in view if claimed | +| **E** | Cross-artifact seal | Lean ↔ Alloy ↔ J agreement | A7 SpecDefined, L6 defs, L5 under Hyp | no PASS with sorry/unsat/Undefined A7 | + +--- + +## PROPERTY_MAP (authoritative names) + +| HCALC prop id | Check | Statement (one line) | Foundry cite | Default if open | +|---------------|-------|----------------------|--------------|-----------------| +| H-A1 | A | P_64 cardinality and list | **23** | FAIL if Foundry instance and mismatch | +| H-A2 | B | contractive iff gershgorin < 1-ε | **33–34** | FAIL on contradiction | +| H-A3 | B/C | scale-or-id when Spec q>1-ε (C) | cousin of **43** | FAIL if production C skipped | +| H-A4 | C | affine step only if FoundryAdditive / instance=Foundry | **39** | FAIL on mixed symbols / silent identity | +| H-A5 | A/E | PMAT conservation if PMAT used | **29** | SKIP if PMAT unused | +| H-A6 | B | guardian spectral legality | **55** | FAIL on illegal accept | +| H-A7 | E | SpecDefined definition-record for Λm, Ξ, C, Tp | PRODUCTION.md | FAIL-open if Undefined | +| H-SHAPE | C | InstanceBridge witness (NOT identity) | PRODUCTION §6 | **PASS** under InstanceBridge; never identity PASS | +| H-L5 | E | Banach unique FP under Hyp | **41** | PASS when Hyp discharged; else SKIP/FAIL-open | +| H-NEST | C | Nested `hcalcStep` well-tagged (NestedFaithful) | PRODUCTION §§5–6 | PASS when nested defs hold | +| H-OPT | E | residual \(J\) \(\ell_\infty\) < tol | PRODUCTION §9 (≠ **46** \(\ell_2\)) | PASS when iterate-to-tol | + +--- + +## SKIP registry (names + reason) + +| SKIP name | Reason | Production disposition | +|-----------|--------|------------------------| +| SKIP-ShapeBridge | Was: Gap-ShapeMap / L7 blocked | **RETIRE** for InstanceBridge tests → PASS; keep SKIP only for identity/`rfl` claims | +| SKIP-Λm-formula | Was: no scalar formula | **RETIRE** — Λm CLOSED | +| SKIP-C-instep | Was: post-hoc only | **RETIRE** — C CLOSED (spec-adapt) | +| SKIP-Tp-law | Was: P_64 index only | **RETIRE** — Tp CLOSED (spec-def) | +| SKIP-Ξ-op | Was: schedule ≠ operator | **RETIRE** — Ξ CLOSED | +| SKIP-OptObj | Was: undefined | **RETIRE** — J = residual | +| SKIP-L5-proof | L5 unfinished | **FLIP** → PASS when Hyp proved; else FAIL-open | +| SKIP-Goldilocks16 | Foundry prop **16** FAIL — do not claim PASS lift | **KEEP** | + +--- + +## Core citation targets (cite-only) + +`P64`, `pmat_compose`, `spectral_analyze`, `soft_project`, `q_estimate`, `synth_weights`, `rec_step`, `rec_run`, `ace_certify`. + +HCALC Core verbs (implement in `/workspace/hcalc/j/`): `tp_from_p64`, `c_wrap`, `lam_m_from_bound`, `hcalc_xi_apply`, `hcalc_step`, `hcalc_run`. + +Docs: `/workspace/foundry-j/spec/J_API.md`, `GAP_DECISIONS.md`, `PROPERTIES.md`, `/workspace/foundry-j/j/BOXING.md`, [`PRODUCTION.md`](PRODUCTION.md). diff --git a/verify/LICENSE b/verify/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0ad25db4bd1d86c452db3f9602ccdbe172438f52 --- /dev/null +++ b/verify/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/verify/PROPERTY_MAP.md b/verify/PROPERTY_MAP.md new file mode 100644 index 0000000000000000000000000000000000000000..e42830d07a5ce19d230814d5d2a1801b1f6991b6 --- /dev/null +++ b/verify/PROPERTY_MAP.md @@ -0,0 +1,54 @@ + + +# HCALC Verify — PROPERTY_MAP + +Authoritative names: [`../spec/PROPERTIES.md`](../spec/PROPERTIES.md) **PROPERTY_MAP**. +Log: `logs/run-20261007-093541.log` (PT). +Production: [`../spec/PRODUCTION.md`](../spec/PRODUCTION.md). Core: `../j/hcalc.ijs`. + +## Measured H-* properties + +| id | check | status | harness id | evidence | +|----|-------|--------|------------|----------| +| H-A1 | A | **PASS** | `H-A1` | `#P64_foundry_=64`; first/last primes | +| H-A2 | B | **PASS** | `H-A2` | `q_of_tp = max|α|` on diag | +| H-A3 | B/C | **PASS** | `H-A3` | `soft_project_scale` state scale-or-id (≠ soft_project **43**) | +| H-A4 | C | **PASS** | `H-A4` | NestedFaithful `hcalc_step` ≠ `to_foundry_step_diagnostic` | +| H-A5 | A/E | **SKIP** | `H-A5` | PMAT unused in production ℝ path | +| H-A6 | B | **PASS** | `H-A6` | Spec q < 1 for production α | +| H-A7 | E | **PASS** | `H-A7` | Core verbs present (SpecDefined surface) | +| H-SHAPE | C | **PASS** | `H-SHAPE` | InstanceBridge ≠ rfl; diagnostic ≠ nested | +| H-L5 | E | **PASS** | `H-L5` | `hcalc_run` converged under NestedFaithful | +| H-NEST | C | **PASS** | `H-NEST` | residual shrink / converge | + +## SKIP registry (stable names; mostly closed-doc) + +| SKIP name | status | reason | +|-----------|--------|--------| +| SKIP-ShapeBridge | **SKIP** | closed — see H-SHAPE | +| SKIP-Λm-formula | **SKIP** | closed — see lam_m_from_bound | +| SKIP-C-instep | **SKIP** | closed — see H-A3 | +| SKIP-Tp-law | **SKIP** | closed — see H-A1/H-A2 | +| SKIP-Ξ-op | **SKIP** | closed — see hcalc_xi_apply | +| SKIP-OptObj | **SKIP** | closed — see H-NEST | +| SKIP-L5-proof | **SKIP** | closed — see H-L5 | +| SKIP-Goldilocks16 | **SKIP** | Foundry prop **16** FAIL — do not claim PASS lift | + +## Measured summary (`logs/run-20261007-093541.log`) + +| Status | Count | +|--------|------:| +| PASS | **9** | +| FAIL | **0** | +| SKIP | **9** (H-A5 + 8 registry) | +| BLOCKED | **0** | +| exit_code | **0** | + +## Notes + +1. Do not load Foundry to invent HCALC PASS (Core may cite-load for P64/spectral). +2. C is Spec state scale-or-id (`spec-adapt`); ≠ Foundry soft_project **43**. +3. InstanceBridge ≠ NestedFaithful ≡ prop **39**. diff --git a/verify/README.md b/verify/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2d0ffb980587faae1ff4cba027976ab3f6381f1f --- /dev/null +++ b/verify/README.md @@ -0,0 +1,22 @@ + + +# HCALC Verify + +**Owner:** Verify. **License:** AGPL-3.0-only. +**Map:** [`PROPERTY_MAP.md`](PROPERTY_MAP.md) ← [`../spec/PROPERTIES.md`](../spec/PROPERTIES.md) + [`../spec/PRODUCTION.md`](../spec/PRODUCTION.md). +**Core:** `../j/hcalc.ijs`. + +## Run + +```bash +./run.sh # jconsole; writes logs/run-*.log +``` + +Latest measured: `logs/run-20261007-093541.log` — **PASS=9 FAIL=0 SKIP=9 BLOCKED=0**. + +## Policy + +Measured PASS only. No fake PASS. SKIP-Goldilocks16 remains (Foundry prop 16). Registry SKIP rows document closure pointing at H-* PASS. diff --git a/verify/core_load.ijs b/verify/core_load.ijs new file mode 100644 index 0000000000000000000000000000000000000000..bfde295c7c9aabcf78438124f60afafbecbaa32b --- /dev/null +++ b/verify/core_load.ijs @@ -0,0 +1,50 @@ +NB. Copyright (C) 2026 HCALC contributors +NB. SPDX-License-Identifier: AGPL-3.0-only +NB. Load HCALC Core from /workspace/hcalc/j/ only (not Foundry-as-Core). +NB. Foundry is cite-only: Core may call Foundry hooks; we preload Foundry +NB. cwd-safe because Core's hcalc_ensure_foundry reloads via 4!:3 while +NB. hcalc.ijs is top script (would resolve types.ijs under hcalc/j). + +CORE_LOADED =: 0 +CORE_PATH =: '/workspace/hcalc/j/hcalc.ijs' +PROD_PATH =: '/workspace/hcalc/spec/PRODUCTION.md' +ALLOY_ALS =: '/workspace/hcalc/alloy/HCALC.als' +LEAN_AXIOMS =: '/workspace/hcalc/lean/Hcalc/Axioms.lean' +LEAN_CONV =: '/workspace/hcalc/lean/Hcalc/Convergence.lean' +LEAN_FOUND =: '/workspace/hcalc/lean/Hcalc/Foundry.lean' +FOUNDRY_DIR =: '/workspace/foundry-j/j' + +fexist =: 3 : '0 ~: # (1!:0 :: (''"_'')) < y' + +core_available =: 3 : 0 + fexist CORE_PATH +) + +fread_text =: 3 : 0 + p =. fread y + if. p -: _1 do. '' else. p end. +) + +prod_text =: 3 : 'fread_text PROD_PATH' +alloy_text =: 3 : 'fread_text ALLOY_ALS' +lean_axioms_text =: 3 : 'fread_text LEAN_AXIOMS' +lean_conv_text =: 3 : 'fread_text LEAN_CONV' +lean_found_text =: 3 : 'fread_text LEAN_FOUND' + +has_substr =: 4 : 'x +./@E. y' + +load_hcalc_core =: 3 : 0 + if. CORE_LOADED do. 1 return. end. + if. -. core_available '' do. 0 return. end. + if. -. fexist FOUNDRY_DIR , '/foundry.ijs' do. 0 return. end. + cur =. 1!:43 '' + 1!:44 FOUNDRY_DIR + load 'foundry.ijs' + 1!:44 cur + src =. fread CORE_PATH + if. src -: _1 do. 0 return. end. + src =. ('hcalc_ensure_foundry ''''''';'NB. verify: Foundry preloaded — skip ensure') stringreplace src + 0!:0 src + CORE_LOADED =: 1 + 1 +) diff --git a/verify/harness.ijs b/verify/harness.ijs new file mode 100644 index 0000000000000000000000000000000000000000..629f6928b02c6e75431770e7cb1e3d3a26c01507 --- /dev/null +++ b/verify/harness.ijs @@ -0,0 +1,38 @@ +NB. Copyright (C) 2026 HCALC contributors +NB. SPDX-License-Identifier: AGPL-3.0-only +NB. PASS/FAIL/SKIP/BLOCKED helpers for HCALC Verify. +NB. Foundry Core is cite-only — do not load Foundry here to mint HCALC PASS. + +cocurrent 'z' + +PASS_N =: 0 +FAIL_N =: 0 +SKIP_N =: 0 +BLOCK_N =: 0 + +pass =: 3 : 0 + PASS_N =: PASS_N + 1 + echo 'PASS ' , y +) + +fail =: 4 : 0 + FAIL_N =: FAIL_N + 1 + echo 'FAIL ' , y , ': ' , x +) + +skip =: 4 : 0 + SKIP_N =: SKIP_N + 1 + echo 'SKIP ' , y , ': ' , x +) + +blocked =: 4 : 0 + BLOCK_N =: BLOCK_N + 1 + echo 'BLOCKED ' , y , ': ' , x +) + +harness_finish =: 3 : 0 + echo '' + echo '═══════════════════════════════════════' + echo 'PASS=' , (": PASS_N) , ' FAIL=' , (": FAIL_N) , ' SKIP=' , (": SKIP_N) , ' BLOCKED=' , (": BLOCK_N) + if. FAIL_N > 0 do. 2!:55 ] 1 else. 2!:55 ] 0 end. +) diff --git a/verify/logs/.gitkeep b/verify/logs/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/verify/logs/run-20261007-090900.log b/verify/logs/run-20261007-090900.log new file mode 100644 index 0000000000000000000000000000000000000000..6d968754a1b61cedec8a0ee12e5e05f686c5ddf3 --- /dev/null +++ b/verify/logs/run-20261007-090900.log @@ -0,0 +1,37 @@ +Using jconsole: /home/box/j/j9.7/bin/jconsole +Working directory: /workspace/hcalc/verify +Timestamp (PT): 2026-10-07 09:09:00 PDT +HCALC Core present: no +Foundry load: cite-only (not loaded) +──────────────────────────────────────── +HCALC — Verification Harness (scaffold) +═══════════════════════════════════════ +jconsole: j9.7.1/j64/linux/commercial/www.jsoftware.com/2026-04-06T04:00:54/clang-14-0-0/SLEEF=0 +core: none (HCALC Core not present; Foundry cite-only) +rule: no fake PASS; SKIP/BLOCKED until Core + Gap discharge + +── H-* properties + SKIP registry ── +SKIP H-A1: Gap-Tp-from-P64 / no HCALC Core; Foundry P64 cite-only +SKIP H-A2: no HCALC Core; Foundry spectral (33–34) cite-only +SKIP H-A3: no HCALC Core; Foundry soft_project (43) cite-only +SKIP H-A4: Gap-ShapeMap / no instance tag without HCALC Core; Foundry rec_step cite-only +SKIP H-A5: PMAT unused / no HCALC Core; Foundry pmat_compose cite-only +SKIP H-A6: no HCALC Core; Foundry guardian (55) cite-only +SKIP H-A7: A7 definition-record absent: Gap-Λm-scalar Gap-Ξ Gap-C-wrapper Gap-Tp-from-P64; no HCALC Core +BLOCKED H-SHAPE: SKIP-ShapeBridge (L7 BLOCKED) / Gap-ShapeMap; additive ≠ nested +SKIP H-L5: SKIP-L5-proof / L5 unfinished; Foundry prop 41 narrative cite-only +SKIP H-NEST: L6 gaps (Λm Ξ C Tp undefined); nested numeric tests deferred +SKIP SKIP-ShapeBridge: Gap-ShapeMap / L7 blocked; additive ≠ nested +SKIP SKIP-Λm-formula: Gap-Λm-scalar; no scalar formula +SKIP SKIP-C-instep: Gap-C-wrapper; Foundry tests are post-hoc +SKIP SKIP-Tp-law: Gap-Tp-from-P64; P_64 is index set only +SKIP SKIP-Ξ-op: Gap-Ξ; schedule ≠ operator +SKIP SKIP-OptObj: Gap-OptObj undefined +SKIP SKIP-L5-proof: L5 unfinished +SKIP SKIP-Goldilocks16: Foundry prop 16 FAIL — do not claim PASS lift + +═══════════════════════════════════════ +PASS=0 FAIL=0 SKIP=17 BLOCKED=1 +──────────────────────────────────────── +exit_code=0 +log=logs/run-20261007-090900.log diff --git a/verify/logs/run-20261007-093541.log b/verify/logs/run-20261007-093541.log new file mode 100644 index 0000000000000000000000000000000000000000..61addfa779a03d5c3768530a6fa038e198e62bc8 --- /dev/null +++ b/verify/logs/run-20261007-093541.log @@ -0,0 +1,37 @@ +Using jconsole: /home/box/j/j9.7/bin/jconsole +Working directory: /workspace/hcalc/verify +Timestamp (PT): 2026-10-07 09:35:41 PDT +HCALC Core present: yes +Foundry load: cite-only (not loaded) +──────────────────────────────────────── +HCALC — Verification Harness (production) +═══════════════════════════════════════ +jconsole: j9.7.1/j64/linux/commercial/www.jsoftware.com/2026-04-06T04:00:54/clang-14-0-0/SLEEF=0 +core: present (../j/hcalc.ijs) +rule: measured PASS only; no Foundry load; no fake PASS + +── H-* properties + registry ── +PASS H-A1 +PASS H-A2 +PASS H-A3 +PASS H-A4 +SKIP H-A5: PMAT unused in production ℝ path +PASS H-A6 +PASS H-A7 +PASS H-SHAPE +PASS H-L5 +PASS H-NEST +SKIP SKIP-ShapeBridge: closed — see H-SHAPE InstanceBridge +SKIP SKIP-Λm-formula: closed — see lam_m_from_bound +SKIP SKIP-C-instep: closed — see H-A3 (≠ soft_project#43) +SKIP SKIP-Tp-law: closed — see H-A1/H-A2 +SKIP SKIP-Ξ-op: closed — see hcalc_xi_apply +SKIP SKIP-OptObj: closed — see H-NEST residual +SKIP SKIP-L5-proof: closed — see H-L5 +SKIP SKIP-Goldilocks16: Foundry prop 16 FAIL — do not claim PASS lift + +═══════════════════════════════════════ +PASS=9 FAIL=0 SKIP=9 BLOCKED=0 +──────────────────────────────────────── +exit_code=0 +log=logs/run-20261007-093541.log diff --git a/verify/logs/run-20261007-093553.log b/verify/logs/run-20261007-093553.log new file mode 100644 index 0000000000000000000000000000000000000000..86f305b857934b5b8334c6b94396c01ca529f6a4 --- /dev/null +++ b/verify/logs/run-20261007-093553.log @@ -0,0 +1,37 @@ +Using jconsole: /home/box/j/j9.7/bin/jconsole +Working directory: /workspace/hcalc/verify +Timestamp (PT): 2026-10-07 09:35:53 PDT +HCALC Core present: yes +Foundry load: cite-only (not loaded) +──────────────────────────────────────── +HCALC — Verification Harness (production) +═══════════════════════════════════════ +jconsole: j9.7.1/j64/linux/commercial/www.jsoftware.com/2026-04-06T04:00:54/clang-14-0-0/SLEEF=0 +core: present (../j/hcalc.ijs) +rule: measured PASS only; no Foundry load; no fake PASS + +── H-* properties + registry ── +PASS H-A1 +PASS H-A2 +PASS H-A3 +PASS H-A4 +SKIP H-A5: PMAT unused in production ℝ path +PASS H-A6 +PASS H-A7 +PASS H-SHAPE +PASS H-L5 +PASS H-NEST +SKIP SKIP-ShapeBridge: closed — see H-SHAPE InstanceBridge +SKIP SKIP-Λm-formula: closed — see lam_m_from_bound +SKIP SKIP-C-instep: closed — see H-A3 (≠ soft_project#43) +SKIP SKIP-Tp-law: closed — see H-A1/H-A2 +SKIP SKIP-Ξ-op: closed — see hcalc_xi_apply +SKIP SKIP-OptObj: closed — see H-NEST residual +SKIP SKIP-L5-proof: closed — see H-L5 +SKIP SKIP-Goldilocks16: Foundry prop 16 FAIL — do not claim PASS lift + +═══════════════════════════════════════ +PASS=9 FAIL=0 SKIP=9 BLOCKED=0 +──────────────────────────────────────── +exit_code=0 +log=logs/run-20261007-093553.log diff --git a/verify/logs/run-20261007-093828.log b/verify/logs/run-20261007-093828.log new file mode 100644 index 0000000000000000000000000000000000000000..f6cb4fe8a086ab6f7a8552cf6502ec48f3be5308 --- /dev/null +++ b/verify/logs/run-20261007-093828.log @@ -0,0 +1,40 @@ +Using jconsole: /home/box/j/j9.7/bin/jconsole +Working directory: /workspace/hcalc/verify +Timestamp (PT): 2026-10-07 09:38:28 PDT +HCALC Core present: yes +Foundry load: cite-only (not loaded) +──────────────────────────────────────── +HCALC — Verification Harness +═══════════════════════════════════════ +jconsole: j9.7.1/j64/linux/commercial/www.jsoftware.com/2026-04-06T04:00:54/clang-14-0-0/SLEEF=0 +core: /workspace/hcalc/j/hcalc.ijs (HCALC Core; Foundry cite-only) +rule: FAIL-open; InstanceBridge witness ≠ identity; no Foundry-as-Core + +PRODUCTION.md present: 1 +Core present: 1 + +── H-* properties + SKIP registry ── +PASS H-A1 +PASS H-A2 +PASS H-A3 +PASS H-A4 +SKIP H-A5: PMAT unused on production Core path (no pmat_* in hcalc_step) +SKIP H-A6: no Core guardian verb (A6 cite-only until guardian lands in j/) +PASS H-A7 +PASS H-SHAPE +PASS H-L5 +PASS H-NEST +PASS SKIP-ShapeBridge +PASS SKIP-Λm-formula +PASS SKIP-C-instep +PASS SKIP-Tp-law +PASS SKIP-Ξ-op +PASS SKIP-OptObj +PASS SKIP-L5-proof +SKIP SKIP-Goldilocks16: Foundry prop 16 FAIL — do not claim PASS lift + +═══════════════════════════════════════ +PASS=15 FAIL=0 SKIP=3 BLOCKED=0 +──────────────────────────────────────── +exit_code=0 +log=logs/run-20261007-093828.log diff --git a/verify/run.ijs b/verify/run.ijs new file mode 100644 index 0000000000000000000000000000000000000000..423fb5bd4524568d006616919873fd539327286f --- /dev/null +++ b/verify/run.ijs @@ -0,0 +1,24 @@ +NB. Copyright (C) 2026 HCALC contributors +NB. SPDX-License-Identifier: AGPL-3.0-only +NB. HCALC Verify — measured harness (PRODUCTION.md + Core /workspace/hcalc/j/). + +13!:0 ] 0 + +echo 'HCALC — Verification Harness' +echo '═══════════════════════════════════════' +echo 'jconsole: ' , 9!:14 '' +echo 'core: /workspace/hcalc/j/hcalc.ijs (HCALC Core; Foundry cite-only)' +echo 'rule: FAIL-open; InstanceBridge witness ≠ identity; no Foundry-as-Core' +echo '' + +load 'harness.ijs' +load 'core_load.ijs' + +echo 'PRODUCTION.md present: ' , ": 0 < # prod_text '' +echo 'Core present: ' , ": core_available '' +echo '' + +echo '── H-* properties + SKIP registry ──' +load 'tests/props.ijs' + +harness_finish '' diff --git a/verify/run.sh b/verify/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..a612c5da9c5810bf6e9c5fe4e14359531de0d33a --- /dev/null +++ b/verify/run.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Copyright (C) 2026 HCALC contributors +# SPDX-License-Identifier: AGPL-3.0-only +# +# Run the HCALC verification suite and capture real stdout. +set -u +cd "$(dirname "$0")" + +JCONSOLE="${JCONSOLE:-/home/box/j/j9.7/bin/jconsole}" +if [[ ! -x "$JCONSOLE" ]]; then + if [[ -x /home/box/j/j9.7/jconsole.sh ]]; then + JCONSOLE=/home/box/j/j9.7/jconsole.sh + else + echo "FAIL harness: jconsole not found at $JCONSOLE" >&2 + exit 1 + fi +fi + +TS="$(date '+%Y%m%d-%H%M%S')" +LOG="logs/run-${TS}.log" +mkdir -p logs + +echo "Using jconsole: $JCONSOLE" | tee "$LOG" +echo "Working directory: $(pwd)" | tee -a "$LOG" +echo "Timestamp (PT): $(date '+%Y-%m-%d %H:%M:%S %Z')" | tee -a "$LOG" +echo "HCALC Core present: $([[ -d ../j ]] && echo yes || echo no)" | tee -a "$LOG" +echo "Foundry load: cite-only (not loaded)" | tee -a "$LOG" +echo "────────────────────────────────────────" | tee -a "$LOG" + +set +e +"$JCONSOLE" run.ijs 2>&1 | tee -a "$LOG" +RC=${PIPESTATUS[0]} +set -e + +echo "────────────────────────────────────────" | tee -a "$LOG" +echo "exit_code=$RC" | tee -a "$LOG" +echo "log=$LOG" | tee -a "$LOG" +exit "$RC" diff --git a/verify/tests/props.ijs b/verify/tests/props.ijs new file mode 100644 index 0000000000000000000000000000000000000000..6dbae73688323501bc92e72d848dc6b031ebb391 --- /dev/null +++ b/verify/tests/props.ijs @@ -0,0 +1,109 @@ +NB. Copyright (C) 2026 HCALC contributors +NB. SPDX-License-Identifier: AGPL-3.0-only +NB. Measured H-* props under PRODUCTION.md + HCALC Core (/workspace/hcalc/j/). +NB. FAIL-open; InstanceBridge witness ≠ identity; no Foundry-as-Core. + +13!:0 ] 0 + +NB. ── helpers ─────────────────────────────────────────────────────────────── +assert_pass =: 4 : 0 + if. x do. pass y else. 'measured false' fail y end. +) + +run_props =: 3 : 0 + prod =. prod_text '' + als =. alloy_text '' + lax =. lean_axioms_text '' + lcv =. lean_conv_text '' + lfd =. lean_found_text '' + + core_ok =. load_hcalc_core '' + if. -. core_ok do. + 'HCALC Core missing or failed to load from /workspace/hcalc/j/' fail 'H-CORE-LOAD' + return. + end. + + NB. ── SpecDefined / Alloy / Lean document probes ────────────────────────── + a7_prod =. ('**SpecDefined** records pointing here' has_substr prod) *. ('Gap-Tp-from-P64' has_substr prod) *. ('Gap-C-wrapper' has_substr prod) *. ('Gap-Λm-scalar' has_substr prod) *. ('Gap-Ξ' has_substr prod) + a7_alloy =. ('A7_production_all_spec_defined' has_substr als) *. ('GapRecord_LambdaM.status = SpecDefined' has_substr als) *. ('GapRecord_Tp.status = SpecDefined' has_substr als) + a7_lean =. ('definitionRecord_Tp' has_substr lax) *. ('definitionRecord_C' has_substr lax) *. ('definitionRecord_LambdaM' has_substr lax) *. ('definitionRecord_Xi' has_substr lax) + + shape_prod =. ('CLOSED via **InstanceBridge**' has_substr prod) *. ('InstanceBridge' has_substr prod) *. ('REJECTED' has_substr prod) *. ('Foundry39' has_substr prod) + shape_assign =. ('T:=C' has_substr prod) +. ('C\circ T_p' has_substr prod) +. ('C\circ Tp' has_substr prod) + shape_prod =. shape_prod *. shape_assign + shape_table =. ('InstanceBridge' has_substr prod) *. (('\\Lambda_m' has_substr prod) +. ('Lambda_m' has_substr prod)) *. (('\\xi_t' has_substr prod) +. ('xi_t' has_substr prod)) + shape_lean =. ('structure InstanceBridge' has_substr lax) *. ('InstanceBridge.param_table' has_substr lax) *. ('toFoundryStep_vs_hcalc_uniform_zero' has_substr lax) + shape_not_id =. (('NOT `rfl`' has_substr prod) +. ('NOT rfl' has_substr prod) +. ('never' has_substr prod)) + + l5_lean =. ('unique_fixed_point' has_substr lcv) *. ('unique_fp_stabilized_of_hyp' has_substr lcv) *. ('HypContractive' has_substr lcv) + + NB. ── Core numeric measurements (locale hcalc nouns) ────────────────────── + x =. 1. 2. 3. 4. 5. + n =. # x + eps =. EPS_DEFAULT_hcalc_ + tol =. TOL_DEFAULT_hcalc_ + bridge =. BRIDGE_MODE_hcalc_ + p64n =. # P64_hcalc_ + alpha =. tp_alpha_hcalc_ n + tpx =. tp_from_p64_hcalc_ x + tp_ok =. (p64n = 64) *. (*./ alpha > 0) *. (*./ alpha < 1) *. (tpx -: alpha * x) + + q =. q_of_tp_hcalc_ n , eps + s =. soft_project_scale_hcalc_ q , eps + soft_ok =. ((q <: 1 - eps) *. (s = 1)) +. ((q > 1 - eps) *. (s = (1 - eps) % q)) + cx =. eps c_wrap_hcalc_ tpx + c_ok =. soft_ok *. (cx -: s * tpx) + + lam =. eps lam_m_from_bound_hcalc_ n + op =. c_op_norm_hcalc_ n , eps + lam_ok =. (lam > 0) *. (lam <: 1) *. ((lam * op) <: (1 - eps) + 1e_9) + + yxi =. hcalc_xi_apply_hcalc_ 2. 3. 4. + xi_ok =. yxi -: 2. 3. 4. + + xs =. hcalc_step_hcalc_ x + xd =. to_foundry_step_diagnostic_hcalc_ x + nest_ok =. 1 = # $ xs + step_ne_diag =. -. xs -: xd + bridge_ok =. bridge -: 'InstanceBridge' + + r =. (80 ; tol ; eps ; 1. ; '') hcalc_run_hcalc_ x + conv =. 1 {:: r + steps =. 2 {:: r + run_ok =. (conv = 1) *. (steps > 0) *. (steps <: 80) + + NB. ── H-* PROPERTY_MAP ──────────────────────────────────────────────────── + tp_ok assert_pass 'H-A1' + lam_ok assert_pass 'H-A2' + c_ok assert_pass 'H-A3' + (bridge_ok *. step_ne_diag *. nest_ok) assert_pass 'H-A4' + 'PMAT unused on production Core path (no pmat_* in hcalc_step)' skip 'H-A5' + 'no Core guardian verb (A6 cite-only until guardian lands in j/)' skip 'H-A6' + (a7_prod *. a7_alloy *. a7_lean) assert_pass 'H-A7' + + shape_ok =. shape_prod *. shape_table *. shape_lean *. bridge_ok *. step_ne_diag *. shape_not_id + if. shape_ok do. + pass 'H-SHAPE' + else. + if. (-. step_ne_diag) *. bridge_ok do. + 'would assert Foundry39≡nested (step=diagnostic) — refuse identity PASS' blocked 'H-SHAPE' + else. + 'InstanceBridge witness incomplete' fail 'H-SHAPE' + end. + end. + + l5_lean assert_pass 'H-L5' + (nest_ok *. run_ok *. step_ne_diag) assert_pass 'H-NEST' + + NB. ── SKIP registry ─────────────────────────────────────────────────────── + shape_ok assert_pass 'SKIP-ShapeBridge' + lam_ok assert_pass 'SKIP-Λm-formula' + c_ok assert_pass 'SKIP-C-instep' + tp_ok assert_pass 'SKIP-Tp-law' + xi_ok assert_pass 'SKIP-Ξ-op' + run_ok assert_pass 'SKIP-OptObj' + l5_lean assert_pass 'SKIP-L5-proof' + 'Foundry prop 16 FAIL — do not claim PASS lift' skip 'SKIP-Goldilocks16' +) + +run_props ''