Deep Vision: A Formal Proof of Wolstenholmes Theorem in Lean 4
Alexandre Linhares

TL;DR
This paper provides the first formal proof of Wolstenholme's theorem in Lean 4, verifying a key number theory result through detailed formalization without any gaps.
Contribution
It introduces a complete formal verification of Wolstenholme's theorem in Lean 4, demonstrating the theorem's proof structure and implementation in proof assistant.
Findings
Formal proof comprises nine lemmas and about 800 lines of Lean code.
The proof confirms the divisibility of the quadratic coefficient by p.
No gaps or 'sorry' declarations remain in the formalization.
Abstract
We present a formal verification of Wolstenholme's theorem -- for prime -- in Lean~4 with Mathlib. The proof proceeds by expanding the shifted factorial product to second order in , identifying the quadratic coefficient as the second elementary symmetric product, and showing its divisibility by via power sum vanishing in . The formalization comprises nine lemmas across approximately 800 lines of Lean, with zero \texttt{sorry} declarations. To our knowledge, this is the first formal verification of Wolstenholme's theorem in Lean~4. The proof was discovered through a collaboration between a relational analogy engine for theorem proving and human-directed formalization.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
