{"id":"arxiv:2611.36994","source":"arxiv","external_id":"2611.36994","doi":"10.48550/arXiv.2611.36994","title":"Semantics-Preserving Compilers via Operadic Algebras and Factorization Algebras","abstract":"We investigate an operadic approach to semantics-preserving translation from a well-defined subset of C++ to Lean. The proposed development has three components. First, it organizes program constructors and their interpretations using colored operads and their algebras. We give sufficient conditions for a correspondence on fundamental types and basic operations to induce a semantically faithful compiler, and prove that such a compiler extends through finite products and recursion. Second, we use a factorization algebra to describe how the semantics of a program is assembled from its function fragments. The local data include the embedding of each fragment algebra into the program's semantic algebra. We prove that, for a cover by function fragments, the images of these embeddings generate that algebra. Third, we propose a compiler architecture based on the factorization algebra of program fragments and implement it for translation from C++ to Lean. The compiler records each function as a fragment, translates each fragment using the correspondence on types and operations, and assembles the resulting definitions according to their call dependencies. We compile and verify the Milnor multiplication program used by Lin, Wang, and Xu in their computations for the Kervaire invariant one problem in dimension 126. After repairing an uninitialized read, we verify that the translated program computes the product specified by the formalized Milnor coproduct for every ordered basis pair of combined degree at most 180. As another application, we rewrite a Lean-verified algorithm for ML-KEM polynomial multiplication in the Lean fragment accepted by our compiler. We prove in Lean that the two formulations agree on all canonical inputs and compile the rewritten definition to C++. On an Apple M4, the generated C++ code ran 6.1 times as fast as the native Lean version of the same definition.","primary_category":"math.AT","domain":"cs","license_url":"http://arxiv.org/licenses/nonexclusive-distrib/1.0/","license_short":"arXiv Non-Exclusive (Link-Out Only)","can_host_fulltext":false,"pdf_url":"https://arxiv.org/pdf/2611.36994","canonical_url":"https://arxiv.org/abs/2611.36994","source_repo_url":"https://doi.org/10.5281/zenodo.24526469","proof_system":"Lean 4","tcb_grade":"TCB-2","track":"verified","tcb_notes":"Seeded with linked Lean 4 artifact (https://doi.org/10.5281/zenodo.24526469); eligible for sandboxed TCB-0/TCB-1 promotion.","merkle_root":"e3672b32a86cb4173fd636fe6bcc2b85c1b6d7bc9b4cf6ded2f5c1e9c92061b5","published_at":"2026-11-27","ingested_at":"2026-11-30T13:55:03+00:00","version":1,"doi_url":"https://doi.org/10.48550/arXiv.2611.36994","authors":["Yuwen Gu"],"categories":["math.AT","cs.PL","math.LO"],"ai_provenance":{"disclosed":false,"models":["Indexed via arXiv CC0 OAI-PMH"],"human_role":"Original arXiv authors","verification_notes":"31 pages. The compiler, verification scripts, and artifact guide are available at https://doi.org/10.5281/zenodo.24526469"},"audit_report":{"passed":true,"source":"arxiv-oai-pmh","findings":[]},"tcb_meta":{"code":"TCB-2","label":"Reproducible Compute","track":"verified","rank":2,"icon":"●","summary":"Backed by executable verification code, simulation scripts, or hybrid formal+tested artifacts with SHA-256 integrity hash."},"claims":[],"citations":[],"upgrades":[],"verification_jobs":[],"versions":[],"reviews":[],"latest_review":null}