Uses AI coding agents (Claude Code, Codex, Aristotle) to formalize scientific-computing proofs in Lean with Mathlib and TorchLean, analyzing failure modes.
Abstract
Agentic AI tools have recently had success in mathematical reasoning. Both general purpose coding agents such as Claude Code and Codex, and specialized mathematics agents such as Aristotle, have been used for formalizing mathematical problems such as Fermat's last theorem, Erdős problems and several IMO level math problems. However, much of these efforts are concentrated in the pure mathematics domain, which benefits from relatively self-contained theorem statements, fixed mathematical representation and extensive support in existing formal libraries. Applied mathematics, on the other hand, presents additional challenges because the source may describe a computational procedure or modeling transformation rather than a declarative theorem. In this work, we present a systematic study of AI-assisted auto-formalization for scientific computing (SC), a domain in applied mathematics central to U.S. Department of Energy applications. Through case studies spanning hierarchical abstraction layers in SC software stack, we evaluate not only whether AI agents can complete numerical proofs, but also where and why they fail across the stack. Our primary contribution is a cross-layer taxonomy of failure modes and an analysis of the form of expert feedback required at each layer to recover mathematical soundness. From these observations, we derive a workflow for recurring proof patterns and practical guidance for using AI agents while preserving mathematical soundness. Our results characterize both the practical value and the current limitations of AI-assisted formalization for trustworthy scientific computing.
Problem
Most AI-assisted autoformalization work targets pure mathematics. Scientific computing proofs instead involve computational procedures, numerical models, and implementation details, and these pose different challenges.
Approach
Pen-and-paper proofs (TeX) plus a CLAUDE.md file were given to Claude Code, Codex and Aristotle. The CLAUDE.md file specified the workflow, a modular Lean file structure, and guardrails against unsound hypotheses. Case studies span four layers of the scientific-computing stack: finite-difference and Mehrstellen stencils, convergence of conjugate-gradient and stationary iterative solvers, floating-point error bounds for parallel tree reduction (built on TorchLean), and equivalence of SPIRAL IR rewrite rules using Mathlib Kronecker products. Failure modes and the expert feedback needed at each layer were catalogued.
Figure 1. Workflow for auto-formalization of pen-and-paper proof in Lean
Results
Simpler cases (second-order stencils, the SPIRAL Kronecker identity) were formalized by Codex in minutes without sorry or human intervention. Implementation-level cases, such as the floating-point reductions, needed several expert feedback rounds. Agents tended to weaken statements or add unsound assumptions to get proofs to compile, so humans had to audit the formal specifications.
Layer
Representative case
Characteristic obligation
Numerical discretization
stencil operators
indexing, boundaries, neighborhood equivalence
Numerical algorithm
stationary/Krylov recurrences and convergence
norms, spectra, convergence assumptions
Finite precision
summation/dot product reductions
IEEE-754 rounding, underflow, error bounds
Implementation/refinement
program or IR equivalence
loops, arrays, memory, compiler transformations
Layers of the scientific-computing stack and their characteristic proof obligations