TL;DR
Formalizing research-level mathematics isn't a simple "Google Translate" job; it requires a mathematician to bridge the gap between intuitive prose and the rigid requirements of code. This paper introduces a dataset of over 4,000 audited "discrepancies" where Lean code intentionally departs from its source text, proving that training AI on these specific human-made adjustments nearly doubles its success rate in writing complex mathematical proofs.
What Problem Does This Paper Address?
When a mathematician sits down to turn a research paper into Lean (a formal proof language), they quickly realize that a word-for-word translation is impossible. To make the math "compile," they must generalize definitions, add "obvious" hypotheses the author skipped, or split one long argument into several smaller lemmas.
Current AI models often fall into the "verbatim trap." They spend millions of tokens trying to translate natural language literally, only to hit a wall when the code doesn't fit the existing library (Mathlib) or fails to account for hidden assumptions. Furthermore, most AI benchmarks focus on "toy" problems—short, isolated competition exercises. In the real world, math happens in massive repositories with tens of thousands of lines of interconnected code. The authors tackle the challenge of autoformalization within these large-scale, research-level projects.
Methods
The researchers took a "learning from the gaps" approach. Instead of just showing a model correct code, they focused on the differences between the paper and the code.
- Auditing Discrepancies: They identified 4,076 instances where Lean formalizations deliberately deviated from their natural language sources.
- Fine-Tuning: They used a LoRA (Low-Rank Adaptation) adapter to fine-tune a base model, Qwen3.8-27B. This "writer adapter" was trained on pairs consisting of a file's prefix (the context), the informal math passage, and the actual Lean declaration a human wrote to bridge the gap.
- Evaluation: They tested the model on its ability to write definitions, theorem statements, and proofs within 27 held-out projects. Crucially, they measured success using "Gold Agreement"—whether the AI's output matched the specific mathematical choices made by the project's human authors, rather than just being a "correct-ish" translation.
Datasets
The study introduces a new benchmark derived from 832 Lean repositories. After rigorous auditing for code quality and formalization accuracy, they narrowed this down to:
- Training Set: 3,431 tasks from 141 repositories.
- Test Set: 645 tasks from 27 held-out repositories.
The researchers categorized the discrepancies into 17 distinct types, such as hypothesis_change, representation_change, and proof_detail_expansion.
Key Insights and Ideas
- The "Verbatim Trap" is Real: Models that are great at translating sentences in isolation often fail in large projects because they don't understand the "project-specific" dialect or the necessary generalizations required by the underlying math library.
- Gold vs. Natural Language (NL) Agreement: A model might write a theorem that perfectly reflects a sentence in a paper (NL Agreement), but if it misses a hypothesis that the rest of the project relies on, it’s useless. "Gold Agreement" is the stricter, more meaningful metric for real-world utility.
- Hints Aren't Enough: Interestingly, simply telling the model how the code should differ (e.g., "add a hypothesis") didn't help much. The model needed to see the actual examples of the code-text pairs to internalize the "style" of research-level formalization.
- Small Models, Big Gains: A 27B parameter model with a small amount of targeted, in-project training can become competitive with much larger models like the 120B parameter
gpt-oss-120b.
Key Results
The "writer adapter" showed significant improvements across the board, particularly in the most difficult tasks:
- Proof Completion: The success rate for writing complete, compiling proofs nearly doubled, jumping from 11.2% to 20.4%.
- Gold Agreement: For theorem statements, the share of AI outputs in "gold agreement" with human-written code rose from 30.4% to 39.2%.
- Efficiency: While some models (like Goedel-Prover) were better at writing code that simply compiled, the fine-tuned Qwen model was far superior at writing code that was mathematically correct for the specific project context.
Limitations and Future Work
- Search and Feedback: The models were tested using "greedy decoding" (one shot, no second guesses). In a real workflow, an agentic system that uses compiler feedback to self-correct would likely perform much better.
- Dataset Scope: While 4,000 examples is a great start, research-level math is vast. The authors note that the gain grows with more data, suggesting that further scaling of this "discrepancy" dataset could yield even better results.
- The "Dark Matter" of Math: The study doesn't yet account for how much of the gain comes from the specific choice of discrepancy examples versus just having more in-project Lean data in general. This remains a fertile ground for future investigation.
Summary updated