A formal verification of amicable numbers theory in Lean 4 using Mathlib.
Two positive integers m and n are amicable if each is the sum of the proper divisors of the other:
- s(m) = n
- s(n) = m
where s(k) = σ(k) - k is the sum of proper divisors of k, and σ is the divisor sum function.
The study of amicable numbers dates back to the ancient Greeks, with the pair (220, 284) known to the Pythagoreans around 500 BC.
Nat.properDivisorSum: Sum of proper divisors of nNat.IsAmicablePair: Predicate for amicable pairsNat.IsAmicable: Predicate for amicable numbersNat.thabit: The Thabit-ibn-Qurra numbers t_n = 3·2^n - 1
| Pair | Theorem | Discoverer | Year |
|---|---|---|---|
| (220, 284) | isAmicablePair_220_284 |
Pythagoreans | ~500 BC |
| (1184, 1210) | isAmicablePair_1184_1210 |
Niccolò Paganini | 1866 |
| (17296, 18416) | isAmicablePair_17296_18416 |
Pierre de Fermat | 1636 |
IsAmicablePair.symm: Amicable pairs are symmetricIsAmicablePair.ne: Members of an amicable pair are distinctIsAmicablePair.one_lt_left/right: Members are greater than 1not_isAmicable_prime: Primes cannot be amicablenot_isAmicable_one: 1 is not amicable
properDivisorSum_eq_sum_divisors_sub: s(n) = σ(n) - nisAmicablePair_iff_sum_divisors: Characterization via σIsAmicablePair.lt_iff: Relation with abundant/deficient numbers
The Thabit rule (9th century) provides a method for generating amicable pairs: If p = 3·2^(n-1) - 1, q = 3·2^n - 1, and r = 9·2^(2n-1) - 1 are all prime, then (2^n · p · q, 2^n · r) is an amicable pair.
ThabitRuleStatement: Formal statement of the rulethabit_rule_holds_n2: Verified for n=2, giving (220, 284)thabit_rule_holds_n4: Verified for n=4, giving (17296, 18416)thabit_rule_n2,thabit_rule_n4: Arithmetic verifications
OddOddAmicableConj: No odd-odd amicable pairs existInfinitelyManyAmicableConj: There are infinitely many amicable pairsNoCoprimeAmicableConj: No coprime amicable pairs exist
amicable-numbers/
├── Amicable/
│ └── Basic.lean # Main definitions and theorems
├── Amicable.lean # Root import file
├── lakefile.toml # Lake configuration
├── lean-toolchain # Lean version specification
└── README.md # This file
# Install dependencies
lake update
# Build the project
lake buildRequires Lean 4 and Mathlib. The project uses Mathlib v4.15.0.
- Ancient Greece (~500 BC): The Pythagoreans knew the pair (220, 284)
- 9th century: Thābit ibn Qurra discovered the rule for generating pairs
- 1636: Fermat rediscovered (17296, 18416)
- 1638: Descartes found (9363584, 9437056)
- 1747: Euler found 60 new pairs
- 1866: 16-year-old Niccolò Paganini discovered (1184, 1210)
- Present: Over 1.2 billion pairs are known
Despite centuries of study, fundamental questions remain:
- Are there infinitely many amicable pairs?
- Do odd-odd amicable pairs exist?
- Do coprime amicable pairs exist?
- Amicable numbers - Wikipedia
- OEIS A063990 - Amicable numbers
- OEIS A259180 - Amicable pairs
- Thābit ibn Qurra, "On the determination of amicable numbers" (9th century)
- Dickson, L.E., "History of the Theory of Numbers", Vol. 1, Ch. I
Contributions are welcome! Potential areas for extension:
- Prove the general Thabit rule for all n (currently verified for n=2,4)
- Verify more amicable pairs from Euler's list (2620, 2924), etc.
- Prove additional structural properties
- Connect with Mathlib's
ArithmeticFunction.sigma - Prove properties about the parity of amicable pairs
Apache 2.0