TorchLean: Formalizing Neural Networks in Lean
Robert Joseph George, Jennifer Cruden, Xiangru Zhong, Huan Zhang, and Anima Anandkumar

TL;DR
TorchLean is a framework in Lean 4 that formalizes neural networks with a unified semantics, enabling verified, end-to-end analysis and certification of neural models in safety-critical applications.
Contribution
It introduces a semantics-first approach that integrates verified API, explicit IEEE-754 semantics, and formal verification methods within Lean 4.
Findings
Validated on certified robustness and neural controllers
Achieved physics-informed residual bounds for PINNs
Provided mechanized theoretical results including a universal approximation theorem
Abstract
Neural networks are increasingly deployed in safety- and mission-critical pipelines, yet many verification and analysis results are produced outside the programming environment that defines and runs the model. This separation creates a semantic gap between the executed network and the analyzed artifact, so guarantees can hinge on implicit conventions such as operator semantics, tensor layouts, preprocessing, and floating-point corner cases. We introduce TorchLean, a framework in the Lean 4 theorem prover that treats learned models as first-class mathematical objects with a single, precise semantics shared by execution and verification. TorchLean unifies (1) a PyTorch-style verified API with eager and compiled modes that lower to a shared op-tagged SSA/DAG computation-graph IR, (2) explicit Float32 semantics via an executable IEEE-754 binary32 kernel and proof-relevant rounding models,…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdversarial Robustness in Machine Learning · Formal Methods in Verification · Explainable Artificial Intelligence (XAI)
