Anatomy of a Formal Proof

Jeremy Avigad, Johan Commelin, Heather Macbeth, Adam Topaz

Introduction

Traditional mathematical proofs are written by humans for humans. While this social method of verification has served the community for centuries, it is increasingly strained by the growing complexity of modern mathematics. Human-readable proofs often skip "obvious" steps, rely on social consensus, and are prone to subtle gaps that can remain undetected for years.

This paper explores the "formal turn" in mathematics—the transition toward translating abstract reasoning into machine-checkable code. Using the Lean proof assistant as a primary example, we examine how formalization transforms mathematics from a static prose-based discipline into a collaborative, verifiable, and increasingly automated software engineering process.

Methods: Proving as an Interactive Process

The core of modern formalization lies in interactive theorem proving. Rather than writing a finished document, a mathematician interacts with a proof assistant like Lean through a series of "tactics." Using a classic theorem from linear algebra—that eigenvectors with distinct eigenvalues are linearly independent—we can observe several key formalization techniques:

  • Tactic-based Proving: The user issues commands such as intro, apply, or exact. These tactics transform the current mathematical goal into simpler sub-goals until the proof is logically complete.
  • Structured Calculation (calc): For algebraic proofs, Lean supports chains of equality that mirror traditional mathematical notation while ensuring every step is rigorously checked against the library's axioms.
  • Automation and Simplification: The simp tactic leverages a massive database of lemmas to automatically close trivial logical gaps. Domain-specific tactics, such as module for linear algebra, further reduce the manual burden on the mathematician.
  • Interactive Refactoring: Formal proofs allow for immediate testing of generalizations. A mathematician can weaken a hypothesis—for instance, moving from a vector space over a field to a module over a commutative ring—and the system will instantly highlight exactly where the logic fails or holds.

The Mathlib Ecosystem

At the heart of the Lean community is Mathlib, a unified mathematical library that functions as a central repository of formal knowledge. Unlike traditional fragmented mathematical literature, Mathlib is a monolithic, integrated dataset. At the time of this writing, it contains:

  • Over 80,000 definitions and 160,000 theorems.
  • Approximately 1.5 million lines of code.
  • Contributions from a global community of over 300 individuals.

This repository enables "library discovery" through tools like exact?, which allows users to search the entire corpus of formalized mathematics to find specific lemmas needed to bridge logical gaps.

Key Insights: Mathematics as Software

The formalization of mathematics introduces the rigors and tools of software engineering to pure logic. This includes the use of version control (Git), continuous integration (CI) to ensure new theorems do not break existing ones, and a high degree of modularity.

One of the most significant insights is that generalization is "free." Once a proof is formalized, the computer can verify its validity under broader conditions without requiring the author to rewrite the proof script. Furthermore, the integration of AI "copilots," such as DeepMind’s AlphaProof, suggests a future where neural networks and symbolic logic combine to solve complex problems, such as those found in the International Mathematical Olympiad.

Results and Impact

The viability of large-scale formalization is no longer theoretical. Major recent mathematical breakthroughs have been formally verified, including:

  • The Polynomial Freiman–Ruzsa (PFR) conjecture.
  • Foundational work for condensed mathematics.

These projects demonstrate that collaborative formalization can scale to meet the needs of frontier research, providing a level of certainty that traditional peer review cannot match. Additionally, the process of formalization serves as a powerful educational tool, forcing researchers and students to achieve a level of precision and clarity often missing in informal prose.

Limitations and Future Outlook

Despite its progress, formalization faces a steep learning curve. The syntax of proof assistants can be "fiddly," and mastering the "grammar" of formal logic requires significant effort. There remains a gap between the intuitive way mathematicians think and the rigid way they must communicate with a computer.

However, the trajectory of the field suggests that the next generation of mathematicians may be "native speakers" of formal languages. As AI tools continue to lower the barrier to entry by handling routine details, mathematicians will be increasingly free to focus on high-level strategy and conceptual innovation, ushering in a new era of verifiable mathematical discovery.

Summary updated

BibTeX
@inproceedings{avigad2025anatomy,
  author = {Jeremy Avigad and Johan Commelin and Heather Macbeth and Adam Topaz},
  title = {{Anatomy of a Formal Proof}},
  booktitle = {Notices},
  year = {2025},
  doi = {10.1090/noti3114},
}
Figure