Infinitude of Primes
Statement
For every natural number , there exists a prime number greater than . In other words, there is no largest prime. This is a foundational result used in the proof of the Fundamental Theorem of ArithmeticFundamental Theorem of ArithmeticEvery integer greater than 1 has a unique prime factorizationRead more →.
Proof Sketch (Euclid)
- Assume we have some natural number .
- Consider , the factorial of plus one.
- Observe that , so has at least one prime factor .
- Key insight: Every integer from to divides , so if then . But , which would force — a contradiction since .
- Conclude that .
Definitions
IsPrime. We define to be prime when:
Factorial positivity. For all :
Divisibility of factorial. If , then:
Key Lemma
Every integer has a prime factor:
This is the essential tool — once we know , we extract a prime factor and show it must exceed .
Lean4 Proof
import Mathlib.Data.Nat.Prime.Basic
import Mathlib.Data.Nat.Factorial.Basic
/-!
# Infinitude of Primes (Euclid's Proof)
A demonstration proof formalized in Lean 4 with Mathlib.
We use Euclid's classical argument: for any n, the number n! + 1
has a prime factor p, and p must be greater than n.
-/
/-- Our custom definition of primality, shown equivalent to Mathlib's `Nat.Prime`. -/
def IsPrime (p : Nat) : Prop :=
p ≥ 2 ∧ ∀ m : Nat, m ∣ p → m = 1 ∨ m = p
/-- `Nat.Prime p` implies our custom `IsPrime p`. -/
theorem natPrime_to_isPrime {p : Nat} (hp : Nat.Prime p) : IsPrime p :=
⟨hp.two_le, hp.eq_one_or_self_of_dvd⟩
/-- Our custom `IsPrime p` implies `Nat.Prime p`. -/
theorem isPrime_to_natPrime {p : Nat} (hp : IsPrime p) : Nat.Prime p :=
Nat.prime_def.mpr hp
/-- For any n ≥ 2, there exists a prime factor. -/
theorem exists_prime_factor (n : Nat) (hn : n ≥ 2) :
∃ p, IsPrime p ∧ p ∣ n := by
have h : n ≠ 1 := by omega
obtain ⟨p, hp, hdvd⟩ := Nat.exists_prime_and_dvd h
exact ⟨p, natPrime_to_isPrime hp, hdvd⟩
/-- n! ≥ 1 for all n. -/
theorem factorial_pos (n : Nat) : Nat.factorial n ≥ 1 :=
Nat.factorial_pos n
/-- If 1 ≤ p ≤ n then p ∣ n!. -/
theorem dvd_factorial (p n : Nat) (h1 : 1 ≤ p) (h2 : p ≤ n) :
p ∣ Nat.factorial n :=
Nat.dvd_factorial (by omega : 0 < p) h2
/-- For every natural number n, there exists a prime greater than n. -/
theorem InfinitudeOfPrimes (n : Nat) :
∃ p, p > n ∧ IsPrime p := by
have h1 : Nat.factorial n + 1 ≥ 2 := by
have := Nat.factorial_pos n; omega
obtain ⟨p, hp, hdvd⟩ := exists_prime_factor _ h1
use p
constructor
· by_contra h
push_neg at h
have hp2 := hp.1
have hdvd_fact : p ∣ Nat.factorial n :=
dvd_factorial p n (by omega) h
have hdvd_sub := Nat.dvd_sub hdvd hdvd_fact
rw [Nat.add_sub_cancel_left] at hdvd_sub
exact absurd (Nat.le_of_dvd Nat.one_pos hdvd_sub) (by omega)
· exact hpReferenced by
- Constructible NumbersGalois Theory
- Fundamental Theorem of ArithmeticNumber Theory
- Fundamental Theorem of ArithmeticNumber Theory
- Prime Counting Function π(n)Number Theory
- Fermat's Little TheoremNumber Theory
- Mertens' TheoremsNumber Theory
- Wilson's TheoremNumber Theory