A formal proof of the Ramanujan--Nagell theorem in Lean 4
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 x2 + 7 = 2n are (n,x) ∈ \(3,1),(4,3),(5,5),(7,11),(15,181)\. The formalization includes all dependencies, notably the computation of the ring of integers of the quadratic field Q(-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.
Turn this paper into a lesson
ArcXiv compiles a structured reading guide from this paper's metadata: plain-English importance, contributions, prerequisite concepts, which sections to read first, flashcards, and a quiz. Grounded in the abstract, never invented.