Why AI-generated Lean proofs need more than just a compile check
A new analysis reveals that AI-generated formal proofs in Lean require rigorous verification steps beyond compilation to ensure they actually match the intended mathematical statements.
Recent claims that artificial intelligence has solved major mathematical problems using the Lean proof assistant require careful scrutiny. A detailed examination of OpenAI’s recent theorem dump and similar outputs from DeepMind shows that simply having code that compiles is not enough to guarantee correctness. Engineers and mathematicians must perform specific validation tests to bridge the gap between informal paper claims and formal code.
What happened
Last month, OpenAI released a collection of 722 mathematics papers, with approximately 45 percent accompanied by Lean code. Since the release, three of the papers without formal code were retracted due to sign errors, raising questions about the reliability of the entire batch. While some observers argue that Lean’s strict type system guarantees truth, others point out that AI models can exploit loopholes or that the formalization might not match the original intent. The reality lies in a nuanced middle ground where verification is possible but requires deliberate effort.
The core issue is that many of these AI-generated repositories have not yet undergone systematic testing. For instance, in the OpenAI dump, about 38 of the 290 theorems with Lean code do not even state, let alone prove, the main result claimed in the corresponding PDF. In one case, a paper claiming to solve Lech’s multiplicity conjecture only formalized a minor corollary. This discrepancy highlights that "having Lean code" is not synonymous with "having a verified proof of the headline theorem."
Similar issues appear in work by other organizations. DeepMind’s formalization of the Hodge conjecture relies on over 10,000 lines of custom code because standard libraries lack necessary definitions. Axiom’s claim regarding the classification of finite simple groups depends on a massive, AI-generated library called Tau Ceti, which contains over 250,000 lines of code. Without human experts verifying these foundational definitions, the correctness of the statement itself remains uncertain, regardless of whether the proof compiles.
How it works
To trust an AI-generated Lean proof, one must answer four critical questions. First, does the Lean statement match the informal statement in the paper? Lean distinguishes sharply between a theorem’s statement and its proof. A statement can be syntactically correct but mathematically wrong, such as defining Fermat’s Last Theorem over natural numbers including zero, which makes the statement trivially false. Verifying this match often requires reading thousands of lines of dependency code, especially when standard libraries like Mathlib are insufficient.
Second, does the code compile? AI-generated code can be resource-intensive or potentially malicious. Anthropic’s formalization of Fermat’s Last Theorem required 96 cores and 500 gigabytes of RAM to compile, while OpenAI’s Navier-Stokes resolution fits on a laptop. Developers should always sandbox AI-generated code before running it to prevent potential system damage. Compilation confirms syntactic validity but not semantic truth.
Third, does the code prove the theorem as stated? The proof files may import millions of lines of untrusted code that could subtly redefine terms or add axioms. To verify that the proof in the untrusted files matches the statement in the trusted files, developers use a tool called lake comparator. This tool ensures that the theorem proved is identical to the theorem stated and that no extra axioms were introduced during the proof process.
Fourth, does the code exploit a bug in Lean’s kernel? While rare, soundness bugs can exist. To mitigate this, one can use lake comparator --paranoid, which checks the proof against multiple independent kernels, including formally verified ones. If a proof passes across different kernels, it is highly unlikely to rely on a specific implementation bug.
Key details
- OpenAI’s recent dump included 722 papers, with 45% having associated Lean code.
- Approximately 38 of the 290 Lean-associated theorems do not formalize the paper's main result.
- Verifying the statement of complex theorems may require reviewing over 10,000 lines of custom definition code.
- The
lake comparatortool checks that the proven theorem matches the stated theorem without hidden axioms. - Using
lake comparator --paranoidvalidates proofs against multiple independent kernels to rule out software bugs. - Even if Lean code is correct, the accompanying PDF may still contain errors or diverge from the formal proof.
Why it matters
For software engineers and technical leads building with AI, this analysis underscores the importance of verification pipelines. It is not sufficient to accept AI output because it runs without errors. In safety-critical domains, assuming correctness based on compilation alone introduces significant risk. The distinction between a compiling statement and a valid proof is subtle but crucial, requiring tools and processes that go beyond basic execution.
This situation also highlights the current limitations of automated formalization. While AI can generate vast amounts of code, the semantic alignment between informal human language and formal logic remains a bottleneck. Teams adopting these technologies must invest in robust testing frameworks, such as kernel comparison and sandboxed compilation, to ensure that their AI assistants are not just generating plausible-looking but fundamentally flawed artifacts.
What you can do
- Always sandbox AI-generated Lean code before compiling to protect your local environment from potential malicious or erratic behavior.
- Use
lake comparatorto verify that the theorem proved in untrusted files matches the statement in trusted files exactly. - Run
lake comparator --paranoidto check proofs against multiple independent kernels, reducing the risk of undetected software bugs. - Manually inspect the headline theorem statement in the Lean code to ensure it matches the informal claim in the associated paper.
- Be skeptical of claims where the Lean code base is significantly larger than standard libraries, as this may indicate unverified custom definitions.
- Recognize that a correct Lean proof does not automatically validate the accompanying PDF, which may still contain logical errors or divergences.



