TorchLean: Formalizing Neural Networks in Lean
Not on the map. Why?
Abstract (arXiv)
Neural networks are increasingly deployed in scientific, safety critical, and mission critical pipelines, yet verification and analysis are often performed outside the programming environment that defines and runs the model. This creates a semantic gap between the executed network and the analyzed artifact: guarantees can depend on implicit conventions about operator semantics, tensor layouts, preprocessing, floating-point behavior, graph transformations, accelerated kernels, and external certificates. We present TorchLean, a unified framework for formalizing, executing, and verifying neural networks in Lean 4. TorchLean treats learned models as executable programs and mathematical objects with a shared semantics for computation, verification, and theorem proving. The framework provides a PyTorch style API for typed tensors, layers, objectives, optimizers, automatic differentiation, and graph programs, with eager and compiled execution paths that lower to a common computation-graph representation. TorchLean supports exact and finite-precision tensor semantics, verified reverse-mode differentiation, interval and affine bound propagation, CROWN/LiRPA style certificate checking, import/export workflows, and CUDA-backed execution through explicit FFI boundaries. It also includes semantic layers for attention and FlashAttention, state-space sequence models, diffusion and sampling processes, probability kernels, reinforcement-learning objectives and Markov decision processes, and self-supervised objectives such as masked autoencoding, JEPA-style predictive views, and variance/correlation-based anti-collapse losses. Together, these components provide a semantic foundation for verified machine learning, where executable neural network artifacts, verification procedures, runtime boundaries, and mathematical claims can be stated and related inside one theorem-proving environment.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 23 of its 53 references that are in the map. First posted on arXiv 26 Feb 2026.
Builds on
23 of 53 references.
References · 23
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
- 2014Explaining and Harnessing Adversarial Examplescited by 7,364
- 2013Intriguing properties of neural networkscited by 5,155
- 2017Reluplex: An Efficient SMT Solver for Verifying Deep Neural Networkscited by 744
- 2016Error bounds for approximations with deep ReLU networkscited by 574
- 2017Provable defenses against adversarial examples via the convex outer adversarial polytopecited by 567
- 2018Efficient Neural Network Robustness Certification with General Activation Functionscited by 445
- 2018On the Effectiveness of Interval Bound Propagation for Training Verifiably Robust Modelscited by 328
- 2018Certified Defenses against Adversarial Examplescited by 306
- 2021Beta-CROWN: Efficient Bound Propagation with Per-neuron Split Constraints for Complete and Incomplete Neural Network Robustness Verificationcited by 228
- 2020Fast and Complete: Enabling Complete Neural Network Verification with Rapid and Massively Parallel Incomplete Verifierscited by 187
- 2018Efficient Formal Safety Analysis of Neural Networkscited by 165
11 more
- 2018A Dual Approach to Scalable Verification of Deep Networkscited by 125
- 2020Exploiting Verified Neural Networks via Floating Point Numerical Errorcited by 35
- 2025The 6th International Verification of Neural Networks Competition (VNN-COMP 2025): Summary and Resultscited by 27
- 2018Verification for Machine Learning, Autonomy, and Neural Networks Surveycited by 24
- 2024Verification-Aided Learning of Neural Network Barrier Functions with Termination Guaranteescited by 7
- 2025No Soundness in the Real World: On the Challenges of the Verification of Deployed Neural Networkscited by 6
- 2025Two-Stage Learning of Stabilizing Neural Controllers via Zubov Sampling and Iterative Domain Expansioncited by 6
- 2023Formalizing Piecewise Affine Activation Functions of Neural Networks in Coqcited by 4
- 2025Floating-Point Neural Networks Are Provably Robust Universal Approximatorscited by 3
- 2021An Empirical Study on Tensor Shape Faults in Deep Learning Systemscited by 2
- 2025Formalized Hopfield Networks and Boltzmann Machinescited by 2
Built on by
Citing papers per year: 2026: 4.
4 papers.
- 2026Lazy Arithmetic using Systolic Arrays for Closing the Verification Gap on Embedded Systemscited by 0
- 2026PROVE-RT: Generating Mechanized Theorem Prover Scripts for Real-Time Systems using LLMscited by 0
- 2026Certified but Private: Scalable Zero-Knowledge Proofs for Neural Network Guaranteescited by 0
- 2026Finite-Sample Probabilistic Safety Certification for AI-Based Grid-Edge Coordinationcited by 0
- 2026Finite-Sample Probabilistic Safety Certification for AI-Based Grid-Edge Coordination23 Sep 2026
- 2026Certified but Private: Scalable Zero-Knowledge Proofs for Neural Network Guarantees17 Aug 2026
- 2026PROVE-RT: Generating Mechanized Theorem Prover Scripts for Real-Time Systems using LLMs13 Aug 2026
- 2026Lazy Arithmetic using Systolic Arrays for Closing the Verification Gap on Embedded Systems16 Jul 2026