A formal proof of the Ramanujan--Nagell theorem in Lean 4

📅 2026-04-10
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This work presents a complete formalization of the Ramanujan–Nagell theorem in Lean 4, leveraging the Mathlib library to establish that the Diophantine equation $x^2 + 7 = 2^n$ admits exactly five integer solutions: $(n, x) = (3, \pm1), (4, \pm3), (5, \pm5), (7, \pm11), (15, \pm181)$. The proof is carried out within an interactive theorem prover by developing foundational structures from algebraic number theory, including the ring of integers, class group, and unit group of the quadratic field $\mathbb{Q}(\sqrt{-7})$. This effort not only provides the first machine-verified proof of the theorem but also significantly extends the reusable infrastructure for algebraic number theory in formalized mathematics.

Technology Category

Knowledge Representation and Reasoning: Automated Reasoning and Theorem ProvingConstraint Satisfaction and Optimization: Satisfiability Modulo TheoriesMultiagent Systems: Mechanism Design

Application Category

Semantics and Knowledge: Data modeling to support human-machine intelligence, including LLMs agents, intelligent system behavior, explanations, and user-friendly interactionsSystems and Infrastructure for Web, Mobile and WoT: Applied ML and AI for Web-based mobile applicationsResponsible Web: Data and user privacy-enhancing technologies for the Web
📝 Abstract
We present a complete formalization, in the Lean interactive theorem prover with the Mathlib library, of the Ramanujan--Nagell theorem: the only integer solutions to the Diophantine equation $x^2 + 7 = 2^n$ are $(n,x) \in \{(3,\pm1),(4,\pm3),(5,\pm5),(7,\pm11),(15,\pm181)\}$. The formalization includes all dependencies, notably the computation of the ring of integers of the quadratic field $\mathbb{Q}(\sqrt{-7})$, its class number, and unit group. We describe the proof strategy, the architecture of the formalization, and the challenges encountered in bridging the gap between textbook proofs and their machine-checked counterparts, with particular attention to the algebraic number theory infrastructure required.
Innovation

Methods, ideas, or system contributions that make the work stand out.

formal proof
Lean 4
Ramanujan–Nagell theorem
algebraic number theory
interactive theorem proving
🔎 Similar Papers
2024-03-20Conference on Empirical Methods in Natural Language ProcessingCitations: 1