Fundamental Theorem of Arithmetic

lean4-proofnumber-theoryvisualization
n=p1a1p2a2pkakn = p_1^{a_1} \cdot p_2^{a_2} \cdots p_k^{a_k}

Statement

Every integer n>1n > 1 can be written as a product of prime numbersInfinitude of PrimesnN,  p>n  such that  p  is prime\forall\, n \in \mathbb{N},\; \exists\, p > n \;\text{such that}\; p \;\text{is prime}Euclid's classic proof that there are infinitely many prime numbersRead more →:

n=p1a1p2a2pkakn = p_1^{a_1} \cdot p_2^{a_2} \cdots p_k^{a_k}

and this representation is unique up to the order of the factors.

Proof Outline

Existence (by strong induction)

  • Base case: n=2n = 2 is prime, so it is its own factorization.
  • Inductive step: If n>2n > 2, either nn is prime (done) or n=abn = ab with 1<a,b<n1 < a, b < n. By the inductive hypothesis, both aa and bb have prime factorizations, so nn does too.

Uniqueness (by contradiction)

Suppose n=p1p2pj=q1q2qkn = p_1 p_2 \cdots p_j = q_1 q_2 \cdots q_k are two prime factorizations. Since p1q1q2qkp_1 \mid q_1 q_2 \cdots q_k and p1p_1 is prime, Euclid's lemma gives p1qip_1 \mid q_i for some ii. Since qiq_i is also prime, p1=qip_1 = q_i. Cancel and repeat by induction.

Connections

The existence part relies on the Infinitude of PrimesInfinitude of PrimesnN,  p>n  such that  p  is prime\forall\, n \in \mathbb{N},\; \exists\, p > n \;\text{such that}\; p \;\text{is prime}Euclid's classic proof that there are infinitely many prime numbersRead more →. This theorem is in turn a prerequisite for Fermat's Little TheoremFermat's Little Theoremapa(modp)a^p \equiv a \pmod{p}For prime p, a^p is congruent to a mod pRead more → and many results in modular arithmetic.

Lean4 Proof

/-- Existence: every nonzero natural number equals the product of its
    prime factors raised to their multiplicities. The
    `Nat.factorization` finsupp records each multiplicity, and Mathlib
    proves the product reconstructs the original number. -/
theorem fta_existence (n : ) (hn : n  0) :
    n.factorization.prod (fun p k => p ^ k) = n :=
  Nat.factorization_prod_pow_eq_self hn

/-- Uniqueness: two natural numbers with the same prime factorization
    are equal. Since `Nat.factorization` is a function, equal
    factorizations force equal nonzero numbers. -/
theorem fta_uniqueness {m n : } (hm : m  0) (hn : n  0)
    (h : m.factorization = n.factorization) : m = n :=
  Nat.eq_of_factorization_eq hm hn (fun p => by rw [h])