Abstract
Large Language Models (LLMs) hold the potential to revolutionize autoformalization. The introduction of Lean4, a mathematical programming language, presents an unprecedented opportunity to rigorously assess the autoformalization capabilities of LLMs. This paper introduces a novel evaluation benchmark designed for Lean4, applying it to test the abilities of state-of-the-art LLMs, including GPT-3.5, GPT-4, and Gemini Pro. Our comprehensive analysis reveals that, despite recent advancements, these LLMs still exhibit limitations in autoformalization, particularly in more complex areas of mathematics. These findings underscore the need for further development in LLMs to fully harness their potential in scientific research and development. This study not only benchmarks current LLM capabilities but also sets the stage for future enhancements in autoformalization.
Introduction
Autoformalization—the process of translating natural language mathematical statements into formal, machine-verifiable code—is a critical frontier for automated theorem proving and software verification. While LLMs have demonstrated remarkable proficiency in general-purpose programming languages like Python, the rigorous logical demands of formal mathematics present a unique challenge. This paper evaluates the state of autoformalization in Lean4, the non-backwards-compatible successor to Lean3, which has become a primary target for the formalization community.
The Lean4 Autoformalization Benchmark
To address the limitations of existing datasets, we introduce a new benchmark consisting of 101 pairs of formal and informal mathematical statements. These theorems were curated from mathlib4, the standard library for Lean4, ensuring relevance to modern formalization efforts. The dataset is diverse, covering 17 distinct mathematical topics ranging from Algebra to Topology.
Methodology
Traditional automated metrics, such as perplexity or string matching, often fail to capture the logical correctness of a formalization. Consequently, we adopted a manual expert evaluation approach. We tested three leading models—GPT-3.5, GPT-4, and Gemini Pro—using zero-shot prompting. Success was measured on a Correction Effort scale (0–4):
- 0: Flawless autoformalization.
- 1-3: Varying degrees of manual adjustment required.
- 4: Total failure; the output requires a complete rewrite.
Results and Analysis
Our evaluation reveals that while LLMs provide a useful starting point, they are not yet capable of autonomous formalization. GPT-3.5 and GPT-4 both averaged a correction effort of 2.238, while Gemini Pro followed closely at 2.248. A score exceeding 2.0 indicates that a human mathematician must still perform significant work to make the model's output usable.
Subject Matter Sensitivity
Model performance is highly dependent on the mathematical domain. The models excelled in Logic and Information Theory, likely due to an abundance of similar content in their training data. In contrast, they struggled with high-abstraction fields such as Category Theory and Model Theory.
Model Comparisons
Gemini Pro demonstrated a notable "hit or miss" performance profile. It produced the highest number of perfect (score 0) formalizations in certain categories but also a higher frequency of total failures (score 4) compared to the GPT models. This suggests that while Gemini may have a better grasp of recent Lean4 syntax—likely due to more contemporary training data—it may lack the consistent reasoning stability of GPT-4. Conversely, GPT-4 occasionally "hallucinated" Lean4 capabilities, likely a result of interference from its stronger familiarity with Lean3 syntax.
Limitations and Future Work
The primary limitation of this study is the scale of evaluation; manual grading by experts is time-intensive, limiting the dataset to 101 statements. Future research should explore:
- Automated Metrics: Developing LLM-based judges to scale the "Correction Effort" metric.
- Difficulty Labeling: Distinguishing between failures in linguistic translation and failures in underlying mathematical reasoning.
- Fine-tuning: Utilizing this benchmark to specialize models on Lean4-specific syntax to bridge the version gap.
Conclusion
This benchmark provides a rigorous framework for assessing the autoformalization capabilities of modern LLMs in Lean4. While the results highlight significant progress, the "Correction Effort" required remains high, particularly in abstract mathematical domains. Continued development in both model reasoning and specialized training on formal languages will be essential to realize the full potential of LLMs in mathematical research.
Summary updated