An Evaluation Benchmark for Autoformalization in Lean4

Jasdeep Sidhu, Shubhra Mishra, Aryan Gulati, Devanshu Ladsaria, Brando Miranda

Introduction

In the advancing field of computational mathematics, Large Language Models (LLMs) hold the potential to revolutionize "autoformalization"—the ability to translate natural language mathematics into formal, machine-checkable code. Researchers from Stanford have introduced a novel benchmark of 101 mathematical theorem statements to rigorously evaluate how effectively state-of-the-art LLMs can autoformalize plain English into Lean4 code. Their study reveals that while models like GPT-4 and Gemini Pro show promise, they still struggle significantly with complex mathematical domains, often requiring substantial human correction.

The Challenge of Autoformalization in Lean4

Autoformalization is notoriously difficult because formal languages are unforgiving of ambiguity, whereas natural language thrives on it. The researchers focused on Lean4, the newest version of the Lean theorem prover. Because Lean4 is not backwards-compatible with its predecessor (Lean3), existing benchmarks are outdated.

Furthermore, many previous evaluations relied on "perplexity"—a metric measuring how well a model predicts the next word. However, perplexity does not indicate whether the resulting code is logically correct or runnable. To address this, the authors created a Lean4-specific benchmark and utilized a more meaningful, human-centric metric.

Datasets and Methodology

The authors introduced a new, publicly available benchmark on HuggingFace, curated from mathlib4, the comprehensive mathematical library for Lean4.

Dataset composition across 17 mathematical topics.

The dataset spans 17 diverse mathematical topics, comprising 101 pairs of formal (Lean4) and informal (natural language) theorem statements.

To evaluate the models, the researchers employed a zero-shot prompting strategy, asking GPT-3.5, GPT-4, and Gemini Pro to formalize the statements without providing prior examples. To measure success, they adopted a qualitative Correction Effort scale (0–4) rather than automated string matching:

  • 0: Flawless formalization.
  • 1–3: Varying degrees of minor to major manual adjustments required.
  • 4: The output is so poor it requires formalizing the statement from scratch.

This approach provides a much clearer picture of the actual "human-in-the-loop" effort saved by using an LLM.

Key Insights and Results

The quantitative results demonstrate that we are still far from "push-button" autoformalization. Across all three models, the average correction effort hovered around a score of 2.24 to 2.25, meaning the average output requires significant manual editing before it is usable.

Average correction efforts required by GPT-3.5, GPT-4, and Gemini across different mathematical topics.

Several key insights emerged from the evaluation:

  • The "Internet Frequency" Hypothesis: Models performed exceptionally well in fields like Logic and Information Theory but stumbled in Category Theory and Computability. The authors hypothesize that LLM performance is directly tied to how frequently these subjects appear in their training data (i.e., the public internet).
  • Model Nuances: While GPT-4 and Gemini Pro are generally more capable than GPT-3.5, their average correction scores were surprisingly similar. Gemini Pro boasted the highest number of "near-perfect" (0 or 1) scores, indicating high potential, but it also produced more "total failures" (score of 4), suggesting higher variance.
  • Lean4 Hallucinations: Despite its power, GPT-4 occasionally hallucinated Lean3 syntax or misinterpreted Lean4’s capabilities, likely because its training data included more legacy Lean3 content.
  • Translation Difficulty: Some subjects are inherently harder to describe in natural language, adding a layer of "translation difficulty" on top of the mathematical complexity.

Limitations and Future Work

While this benchmark is a solid foundation, the authors acknowledge several areas for future growth. Expanding the dataset beyond 101 problems would allow for more robust statistical conclusions. Additionally, while the "Correction Effort" scale is highly informative, it relies on subjective and time-consuming manual human evaluation.

Future iterations of the benchmark should label the inherent difficulty of the math problems to determine if LLMs fail due to mathematical complexity or niche Lean4 syntax. Ultimately, the goal is to use these benchmarks to fine-tune models specifically for Lean4, paving the way for systems that can seamlessly assist mathematicians in real-time research.

Summary updated

BibTeX
@inproceedings{sidhu2024evaluation,
  author = {Jasdeep Sidhu and Shubhra Mishra and Aryan Gulati and Devanshu Ladsaria and Brando Miranda},
  title = {{An Evaluation Benchmark for Autoformalization in Lean4}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=22ITxc8y5p},
}
Figure