Abstract
Autoformalization is the task of automatically translating mathematical content written in natural language to a formal language expression. The growing language interpretation capabilities of Large Language Models (LLMs), including in formal languages, are lowering the barriers for autoformalization. However, LLMs alone are not capable of consistently and reliably delivering autoformalization, in particular as the complexity and specialization of the target domain grows. As the field evolves into the direction of systematically applying autoformalization towards large mathematical libraries, the need to improve syntactic, terminological and semantic control increases. This paper proposes the coordinated use of three mechanisms, most-similar retrieval augmented generation (MS-RAG), denoising steps, and auto-correction with syntax error feedback (Auto-SEF) to improve autoformalization quality. The empirical analysis, across different models, demonstrates that these mechanisms can deliver autoformalizaton results which are syntactically, terminologically and semantically more consistent. These mechanisms can be applied across different LLMs and have shown to deliver improve results across different model types.
Introduction
Autoformalization—the translation of "informal" mathematics into formal languages like Isabelle/ZF or Lean—is essential for creating computer-verifiable mathematical libraries. While Large Language Models (LLMs) have shown impressive capabilities in this area, they face significant hurdles: specialized mathematical concepts often fall outside their training distribution, and they frequently struggle with the strict syntactic and terminological consistency required by formal theorem provers. This paper introduces a neuro-symbolic framework designed to turn "chatty" LLMs into reliable tools for large-scale formalization.
Methodology
The authors propose a coordinated three-stage pipeline to enhance the accuracy and consistency of formal code generation:
- Most-Similar Retrieval Augmented Generation (MS-RAG): Instead of using static few-shot examples, the system dynamically retrieves the most mathematically similar theorems from a Knowledge Base (KB). This provides the LLM with the specific vocabulary and stylistic conventions of the target mathematical sub-field.
- Denoising: LLMs often generate unsolicited conversational filler. The framework employs rule-based Code-Based Denoising (CBD) and LLM-driven Prompt-Based Denoising (PBD) to strip irrelevant text while maintaining library alignment.
- Auto-correction with Syntax Error Feedback (Auto-SEF): This symbolic loop sends generated code to the Isabelle theorem prover. If the code fails, the prover's error messages are fed back to the LLM, which iteratively attempts to fix the syntax (up to 9 cycles).
Experimental Results
The framework was evaluated on MathLibForm, a new benchmark derived from the IsarMathLib library containing 2,744 items. The results demonstrate that the proposed mechanisms significantly boost performance across various models, including Mistral-7B and GPT-3.5-Turbo.
Key insights from the evaluation include:
- Retrieval vs. Fixed Examples: MS-RAG is far more effective than standard few-shot prompting, as it helps models adapt to the specific "dialect" of a library.
- Syntactic Gains: For Mistral-7B, the baseline zero-shot pass rate was 0%, but it climbed to 33.58% with the full pipeline. GPT-3.5-Turbo reached a pass rate of 70.80%.
- The Semantic-Syntactic Trade-off: While smaller models like Mistral improved their syntax through Auto-SEF, they occasionally suffered from "semantic drift," where the mathematical meaning changed to satisfy the compiler. Larger models like GPT-3.5 remained more stable.
- Metric Reliability: The RUBY metric (based on edit distance) was found to correlate most strongly with other evaluation metrics, serving as a useful shorthand for quality.
Conclusion
By combining the generative power of LLMs with symbolic feedback from theorem provers, this framework provides a path toward more consistent and reliable autoformalization. Future work will focus on preventing semantic drift during iterative correction and expanding the framework to other formal languages such as Lean 4.
Summary updated