Improving semantic equivalence in research-level math formalization
Ayush Khaitan, Liam Fowl, Tomàs Ortega, Alex Kontorovich, Sanjeev Arora
cs.AI
Nov 21, 2026 · v1
TL;DR
Builds a dataset and benchmark of differences between papers and their Lean formalizations, and fine-tunes models to write Lean inside research projects.
Abstract
Formalizing mathematics in Lean is never a word-for-word translation of a paper: a Lean formalization changes definitions, strengthens hypotheses, splits arguments, and adds lemmas the paper never mentions. It stands to reason that a model that is good at autoformalization must be a good predictor of how a natural language source must differ from its faithful Lean formalization. With that in mind, we collect 4{,}076 audited examples of such changes from 832 Lean projects that formalize research-level mathematics, and use them to ask a practical question: how well can a model write Lean inside a real research-level project that may contain tens of thousands of lines of code, and does training on discrepancies between natural language sources and their faithful Lean formalizations help? Our training set consists of 3{,}431 tasks from 141 repositories, and the test set consists of 645 tasks from the remaining 27 repositories. Training on in-project Lean nearly doubles complete proofs ($11\% \to 20\%$) and raises the share of statements in gold agreement with the project's own formalization by nearly a third ($30\%$ to $39\%$). The gain comes from the pairs themselves: an adapter trained only to predict how the Lean will differ, or a model told the difference in advance, barely helps. Training on where formalizations depart from their sources is thus an effective way of improving semantic equivalence in research-level formalization.
Problem
Faithful Lean formalizations of research mathematics differ from their natural-language sources: definitions change, hypotheses are added, and proofs are restructured. Existing benchmarks focus on short, self-contained problems rather than writing Lean inside large research projects.
Approach
The authors audited 832 public Lean repositories, kept 171, and collected 4,076 records of source-to-formalization differences, each linked to a Lean line and a source sentence. A LoRA writer adapter on Qwen3.8-27B was trained on 3,256 in-project writing examples (file prefix plus informal passage to Lean declaration). Seven models were evaluated on 645 held-out tasks from 27 projects covering definitions, statements and proofs. Statements were scored on compilation, agreement with the paper (NL agreement), and agreement with the project's own declaration (gold agreement).
Results
The writer adapter raised proof completion from 11.2% to 20.4% and statement gold agreement from 30.4% to 39.2%, the highest of all models tested, while slightly lowering statement compilation. A gap adapter trained only to predict differences, and hints that state the difference in advance, helped little.
| Model | Compiles thm | Compiles proof | NL agr. thm | Gold agr. thm |
|---|
| Qwen3.8-27B | .744 | .112 | .360 | .304 |
| + writer adapter | .700 | .204 | .356 | .392 |
| gpt-oss-120b | .647 | .224 | .332 | .332 |
| Goedel-Prover-32B | .784 | .244 | .304 | .288 |
Selected results (rates) on held-out research-level Lean tasks