A formal proof of the Ramanujan--Nagell theorem in Lean 4
Number Theory
2026-04-14 v1 Logic in Computer Science
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 are . The formalization includes all dependencies, notably the computation of the ring of integers of the quadratic field , 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.
Cite
@article{arxiv.2604.09808,
title = {A formal proof of the Ramanujan--Nagell theorem in Lean 4},
author = {Barinder S. Banwait},
journal= {arXiv preprint arXiv:2604.09808},
year = {2026}
}
Comments
15 pages, 1 figure, comments welcome