Introduction
While AI theorem provers have become incredibly adept at solving mathematical problems written in formal code, they struggle significantly with real-world mathematics expressed in natural language. This paper introduces Mathesis, an end-to-end pipeline that leverages reinforcement learning to automatically translate natural language math into formal code (like Lean 4) and prove it. Mathesis achieves massive jumps in accuracy and introduces a challenging new benchmark based on the Chinese Gaokao exams.
The Autoformalization Bottleneck
Recent AI models, such as DeepSeek-Prover, are highly capable of formal mathematical reasoning, but they operate within a "Formal-to-Formal" (F2F) paradigm. They require inputs to be written in highly specific formal verification languages like Lean 4 or Coq.
However, real-world math is written in natural language. The process of translating informal math into formal code is known as autoformalization. If an autoformalizer makes a mistake—such as accidentally including the goal in the assumptions or mistranslating a summation range—the downstream prover will either solve a trivially broken problem or fail entirely. Existing autoformalizers rely mostly on static supervised fine-tuning and lack dynamic feedback to learn from their mistakes. Furthermore, evaluating whether a translation is "semantically correct" is notoriously difficult, usually relying on brittle binary pass/fail checks by Large Language Models (LLMs).
Methods: The Mathesis Pipeline
To address these limitations, the authors propose a comprehensive pipeline featuring two major innovations: the RL-trained Mathesis-Autoformalizer and the LeanScorer evaluation framework.
1. Mathesis-Autoformalizer (Trained via RL)
Instead of relying solely on static examples, the authors employ a two-stage reinforcement learning approach called Hierarchical Preference Optimization (HPO):
- Stage 1 (GRPO): The model generates candidate translations and receives rewards based on two criteria: Syntactic validity (does it compile in the Lean 4 compiler?) and Semantic correctness (does it mean the same thing as the English prompt?).
- Stage 2 (DPO): The model is fine-tuned using Direct Preference Optimization based on downstream prover success. It learns to prefer formalizations that actually lead to successful, verifiable proofs. This prover feedback creates "prover-friendly" code. For example, the model learns to avoid overly abstract measure-theoretic constructs for geometry, switching instead to concrete area formulas that are much easier for the prover to solve.
2. LeanScorer Framework
Evaluating semantic correctness is a major hurdle. Standard "LLM-as-a-judge" prompts for semantic equivalence are often inconsistent. To solve this, the authors introduce LeanScorer, a novel evaluation framework.
LeanScorer uses an LLM to break the natural language problem into subtasks (premises, conclusions) and grades each against the formal code (categorizing them as Match, Minor Inconsistency, or Major Inconsistency). It then aggregates these scores using the Sugeno Fuzzy Integral, a mathematical method that tolerates minor LLM judging errors while strictly penalizing fatal translation mistakes.
Datasets and the Gaokao-Formal Benchmark
The model was trained on a mix of an in-house Gaokao corpus, the Goedel P-Set, and the Lean Workbook (totaling ~32k problems). For evaluation, the authors used MiniF2F-test, PutnamBench, and introduced a new benchmark: Gaokao-Formal.
Gaokao-Formal consists of 495 complex proof problems from China's National Higher Education Entrance Examination. It is specifically designed to be difficult to formalize, featuring multi-domain concepts and complex linguistic structures that existing benchmarks often filter out.
Key Results
The authors found that for hard problems, upgrading the autoformalizer yielded bigger performance gains than upgrading the prover, as a bad formalization obscures the problem's structure and dooms even the best provers.
- Autoformalization Quality: On the new Gaokao-Formal benchmark, Mathesis achieved a 71% overall correctness score (compiles + semantically correct), crushing the previous state-of-the-art (Kimina-Autoformalizer), which scored 49%. On MiniF2F, it set a new record of 96%.
- Downstream Proving Accuracy: When paired with DeepSeek-Prover-V2, swapping the baseline autoformalizer for Mathesis increased the end-to-end proof success rate on Gaokao-Formal by 122%.
- Evaluation Reliability: LeanScorer achieved a 0.92 F1 score in agreement with human expert annotations, significantly outperforming standard LLM-as-a-Judge (0.85) and Re-informalization techniques (0.65).
Limitations and Future Work
The authors acknowledge that defining the "correctness" of a formalization is inherently ambiguous. Sometimes, whether a translation is "correct" depends entirely on whether it includes explicit domain declarations that a specific prover needs to succeed. Because of this ambiguity, semantic evaluation remains an ongoing challenge. While Mathesis represents a massive leap forward, fully automated, real-world formal theorem proving from natural language remains an open and exciting frontier for future research.
Summary updated