Machine-verified proofs in Lean 4 / Mathlib4.
A perfect number is a positive integer
This repository formalizes two of the oldest and most foundational constraints: Euler's structure theorem (1747) and Touchard's congruence (1953). Both are necessary conditions on any hypothetical OPN. Neither approaches a proof of nonexistence. That gap — between precise characterization and existence — is part of what the formalization makes explicit.
Euler's theorem (1747) — euler_opn_form
Every odd perfect number
-
$p$ is prime $p \equiv k \equiv 1 \pmod{4}$ $p \nmid m$
The proof turns on a single
The argument is so tight — exactly one prime, exactly one exponent pattern — that it feels like the object is being painted into a corner. But the corner is not empty, or at least has not been proved empty.
Touchard's congruence (1953) — touchard_congruence
Any odd perfect number
The proof combines the Euler form with a
touchard_congruence is unconditional — it calls euler_opn_form internally rather than assuming the Euler form as a hypothesis.
The formalization is structured in five layers, each depending necessarily on the one below:
| Layer | Contents |
|---|---|
| 1 — Arithmetic helpers |
geom_sum_mod2, geom_sum_mod4, geom_sum_mod3_q2: modular arithmetic on geometric sums |
| 2 — |
v₂_mul, v₂_odd, v₂_prod, v2_eq_one_of_mod4_eq2
|
| 3 — Valuation of |
sigma_prime_pow_mod2/mod4_of_p1/mod4_zero_of_p3 and specialized |
| 4 — Euler's theorem |
v2_sigma_odd_perfect, sigma_prod_factorization, euler_opn_form
|
| 5 — Touchard's congruence |
sigma_dvd3_of_p2_kodd, touchard_congruence
|
The
| Name | Statement |
|---|---|
sigma_mul_of_coprime |
|
opn_product_constraint |
|
sigma_prime_pow_ratio |
|
v2_sigma_prime_power |
|
v2_sigma_square_factor |
|
sigma_dvd3_of_p2_kodd |
|
| File | Description |
|---|---|
OddPerfectNumbers.lean |
Full Lean 4 formalization (~600 lines) |
Euler_&_Touchard.md |
Expository paper with proof narrative and formalization details |
Euler_&_Touchard.pdf |
Compiled PDF of the above |
lakefile.lean |
Lake build configuration |
lean-toolchain |
Pinned Lean toolchain version |
lake build OddPerfectNumbersThe lakefile.lean references Mathlib4 via a local relative path (../mathlib4_PROOFS/mathlib4). To use the published Mathlib instead, replace that block with a git require (see the comment in lakefile.lean) and run lake update.
Toolchain: leanprover/lean4:v4.30.0-rc2
- Euler, L. (1747). De numeris perfectis. Opera Omnia I.2, 86–162.
- Touchard, J. (1953). On prime numbers and perfect numbers. Scripta Math. 19, 35–39.
- Ochem, P. and Rao, M. (2012). Odd perfect numbers are greater than $10^{1500}$. Math. Comp. 81, 1869–1877.
- The Mathlib Community. Mathlib4. https://github.com/leanprover-community/mathlib4
Author: umpolungfish
Released to the public domain under the UNLICENSE.