Formalizing Complex Mathematical Statements with LLMs: A Study on Mathematical Definitions

Lan Zhang, Marco Valentino, André FreitasarXiv 2025 · DOI

Abstract

Autoformalization—the translation of informal mathematical prose into machine-verifiable code—is a critical step toward AI-assisted formal verification and scientific claim validation. While Large Language Models (LLMs) have demonstrated proficiency in solving high-school level competition math, their performance on complex, research-level definitions remains a significant challenge. This paper introduces two new benchmarks, Def_Wiki and Def_ArXiv, designed to evaluate LLMs on "wild" mathematical discourse found in Wikipedia and research papers. We evaluate state-of-the-art models using targeted refinement strategies and demonstrate that providing models with formal grounding and detailed feedback from proof assistants is essential for bridging the gap between informal text and formal logic.

1. Introduction

The bridge between informal mathematics (the way humans write in papers) and formal mathematics (machine-verifiable code like Isabelle/HOL or Lean) is currently a major bottleneck in the field of automated reasoning. Most existing research relies on benchmarks like miniF2F, which consists of relatively simple, self-contained high-school problems. However, real-world mathematics is "messy," relying on implicit context, complex definitions (such as Rademacher Complexity or Trimmed Means), and specific library dependencies. This study investigates how well LLMs generalize to the sophisticated, naturally occurring mathematical discourse found in actual research, revealing that the "wild" is significantly harder to formalize than standard benchmarks suggest.

2. Methodology and Pipeline

The researchers evaluated three prominent models—GPT-4o, Llama3-8B, and DeepSeekMath-7B—using a multi-stage intervention pipeline. The process begins with translating informal definitions into Isabelle/HOL and proceeds through iterative refinement based on feedback from a proof assistant.

Figure 1: The proposed autoformalization pipeline, illustrating the flow from informal sources to formal code through iterative refinement and grounding.

The study employed several key strategies to improve formalization accuracy:

  • Zero-Shot Prompting (ZS): Establishing a baseline for direct translation.
  • Categorical Refinement (CR): Providing specific instructions targeting three primary error types: Syntax (SYN), Undefined Items (UDF), and Type Unification (TUF).
  • Formal Definition Grounding (FDG): A post-processing step where the model's code is augmented with correct "preambles" to import necessary mathematical libraries.
  • Symbolic Refinement (SR): Utilizing rule-based algorithms to automatically correct common formatting and symbol mapping errors.

3. Benchmarking "Wild" Mathematics

To capture the complexity of real-world math, the study utilizes three datasets:

  • miniF2F-Test: A standard benchmark of 244 competition-level problems used as a control.
  • Def_Wiki: 56 definitions curated from Wikipedia’s Machine Learning category.
  • Def_ArXiv: 30 definitions extracted from high-impact machine learning papers (e.g., ICML). Compared to miniF2F, these new datasets feature significantly more tokens, more complex mathematical objects (such as vectors, matrices, and probability distributions), and a higher density of formulae per example.

4. Results and Discussion

The evaluation reveals that "wild" math is substantially more difficult for LLMs to describe formally. Success rates for GPT-4o dropped from approximately 25% on miniF2F to roughly 11-13% on the new definition benchmarks.

Figure 5: Error rates across different datasets and refinement strategies, categorized by error type (Overall, SYN, UDF, TUF).

Key Insights:

  • Grounding as a Game-Changer: The most significant performance boost came from Formal Definition Grounding (FDG). Manually ensuring the correct libraries were imported (e.g., HOL.Real) improved syntactic correctness on miniF2F by over 40%. This highlights that a major failure mode is the model's lack of awareness regarding library dependencies.
  • The Importance of Detailed Feedback: Providing LLMs with specific line numbers and error messages from the Isabelle Proof Assistant was significantly more effective than simple binary "Correct/Incorrect" feedback. While GPT-4o showed a meaningful ability to self-correct under these conditions, smaller models like Llama3-8B often saw decreased performance with simple feedback.
  • Error Entanglement: In complex definitions, errors are often "entangled." Fixing a syntax error often reveals a deeper type-mismatch error that was previously hidden. This suggests that autoformalization is an iterative "onion-peeling" process requiring multiple passes.

5. Conclusion

Autoformalizing real-world mathematics requires more than just scaling language models; it requires deep integration with formal proof environments and better methods for library grounding. While specialized models like DeepSeekMath-7B perform remarkably well for their size, the primary bottleneck remains the "grounding" of informal concepts in existing formal libraries. Future work will likely focus on creating autonomous agents that can search formal libraries to find the right definitions to import and developing better metrics for semantic alignment to ensure logical consistency.

Summary updated

BibTeX
@misc{zhang2025formalizing,
  author = {Lan Zhang and Marco Valentino and André Freitas},
  title = {{Formalizing Complex Mathematical Statements with LLMs: A Study on Mathematical Definitions}},
  year = {2025},
  eprint = {2502.12065},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.12065},
}
Figure