Introduction
Autoformalization—the process of translating natural language mathematics into formal, executable code like Lean 4—is a critical frontier in AI for science. While modern Large Language Models (LLMs) have demonstrated an increasing ability to generate syntactically correct code that compiles, they frequently suffer from a lack of semantic fidelity. A model may produce code that runs without error but fails to accurately represent the underlying mathematical logic or constraints of the original problem.
The CriticLean Framework
To address this bottleneck, we introduce CriticLean, a reinforcement learning framework that elevates the "critic" from a passive validator to an active driver of the formalization process. Unlike traditional pipelines that rely solely on compiler feedback, CriticLean integrates a specialized critic model, CriticLeanGPT, to evaluate the semantic alignment between natural language statements and formal code.
The framework operates through an iterative refinement loop. When a natural language statement is provided, an AutoFormalizer generates a candidate Lean 4 statement. This candidate undergoes two levels of verification:
- Syntactic Verification: The Lean compiler checks for syntax errors, name resolution, and type consistency.
- Semantic Verification: CriticLeanGPT assesses the logical consistency and mathematical intent, identifying common mistake patterns that a compiler might overlook.
If either stage fails, the feedback is fed back to the generator for a revised attempt, allowing for up to 200 retries to reach a verified solution.
Training the Critic via Reinforcement Learning
The core of this system is CriticLeanGPT, a model based on the Qwen architecture. Its training involves a two-stage process designed to instill deep mathematical reasoning:
- Supervised Fine-Tuning (SFT): The model is trained on a diverse mixture of math-code pairs and reasoning chains to broaden its knowledge base.
- Reinforcement Learning (RL): Using Group Relative Policy Optimization (GRPO), the model is refined through rule-based rewards. This "R1-style" approach encourages the model to "think" through its critiques, significantly improving its ability to catch "plausible but incorrect" formalizations.
To ensure the critic can identify subtle errors, the researchers employed "flaw injection," using advanced models like Gemini 2.5 Pro to deliberately introduce logical fallacies into correct Lean code for the critic to detect.
Analyzing Formalization Errors
The necessity of a semantic critic is underscored by the types of errors prevalent in standard autoformalization attempts. While compilers are excellent at catching syntax errors, they are often blind to premise translation or mathematical representation errors.
As shown in the error distribution analysis, Type Errors (24.9%) and Premise Translation Errors (23.8%) are the most frequent hurdles. Without a semantic critic, a model might correctly translate the syntax of a theorem but misrepresent a "cubic" constraint as a "quadratic" one—an error that would pass a compiler but invalidate the formalization. The integration of CriticLeanGPT improved autoformalization accuracy from 54% to 84% in human evaluations by catching these subtle mismatches.
Data Contributions and Results
CriticLean has enabled the creation of the FineLeanCorpus, a massive dataset of 285,957 verified Lean 4 formalizations. This includes FineLeanCorpus-Diamond, a curated subset of 36,000 high-difficulty problems designed to challenge the limits of automated reasoning.
Key results include:
- Superior Accuracy: The Qwen3-32B-RL critic model achieved 87.0% accuracy on the CriticLeanBench benchmark, outperforming many closed-source alternatives.
- Persistence Pays Off: The multi-attempt strategy allowed the system to formalize 52.8% of a difficult problem set, compared to just 12.6% for a single-pass approach.
- Scaling Laws: Researchers observed that as model parameters increased, the critic's ability to distinguish correct from incorrect formalizations improved consistently.
Conclusion
CriticLean demonstrates that the bottleneck in mathematical autoformalization is not just generation, but evaluation. By training models to be rigorous critics through reinforcement learning, we can generate high-fidelity formal datasets at scale. Future work will focus on closing the loop by using the FineLeanCorpus to train even more capable generators, fostering a virtuous cycle of formal mathematical discovery.
Summary updated