Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Fundamental theorem of arithmetic --- uniqueness

Proved
FundamentalTheoremOfArithmetic.fta_uniqueness

by Mayank Kumar · Sep 7, 2026 · Mathlib 0df444a (Lean v4.33.1)

number-theoryprime-numbers

This is the uniqueness half of the Fundamental Theorem of Arithmetic (Apostol, Introduction to Analytic Number Theory, 1976, Theorem 1.10): any two multisets of primes with the same product are equal.

(∀p∈l1, p prime)∧(∀p∈l2, p prime)∧∏p∈l1p=n=∏p∈l2p   ⟹   l1=l2.\left(\forall p \in l_1,\ p \text{ prime}\right) \wedge \left(\forall p \in l_2,\ p \text{ prime}\right) \wedge \prod_{p \in l_1} p = n = \prod_{p \in l_2} p \ \implies\ l_1 = l_2.(∀p∈l1​, p prime)∧(∀p∈l2​, p prime)∧p∈l1​∏​p=n=p∈l2​∏​p ⟹ l1​=l2​.

The conclusion l1=l2l_1 = l_2l1​=l2​ is equality of multisets: the same primes occur in l1l_1l1​ and l2l_2l2​, with exactly the same multiplicities, regardless of the order in which they are listed. Combined with the existence milestone, this yields the mission's goal theorem, that every nonzero nnn has exactly one such multiset.

This lemma is what makes "the" prime factorization of an integer a well-defined object, rather than merely one possible representation among several.

Formalization Note. The standard proof combines strong induction on nnn with Euclid's lemma (p∣ab  ⟹  p∣a∨p∣bp \mid ab \implies p \mid a \vee p \mid bp∣ab⟹p∣a∨p∣b for prime ppp), used to show that a prime occurring in one multiset must also occur in the other before both are reduced by cancellation.

Preamble
import Mathlib
Formal statement
namespace FundamentalTheoremOfArithmetic
theorem fta_uniqueness (n : ℕ) (hn : n ≠ 0) (l₁ l₂ : Multiset ℕ)
    (h1 : ∀ p ∈ l₁, p.Prime) (h2 : l₁.prod = n)
    (h3 : ∀ p ∈ l₂, p.Prime) (h4 : l₂.prod = n) :
    l₁ = l₂ := by sorry
end FundamentalTheoremOfArithmetic
Source
T. M. Apostol, Introduction to Analytic Number Theory, Springer, 1976, Theorem 1.10
Read-back

What the Lean code literally says, in plain math · claude-sonnet-5

This theorem, fta_uniqueness, is stated inside the namespace FundamentalTheoremOfArithmetic, under import Mathlib.

Statement. For every natural number n:Nn : \mathbb{N}n:N, every hypothesis hn:n≠0hn : n \neq 0hn:n=0, and every pair of multisets l1,l2:Multiset Nl_1, l_2 : \text{Multiset}\ \mathbb{N}l1​,l2​:Multiset N (finite unordered lists of natural numbers with multiplicity, drawn from N\mathbb{N}N), if

h1:∀p∈l1, p is prime (in the sense of Nat.Prime),h_1 : \forall p \in l_1,\ p \text{ is prime (in the sense of } \texttt{Nat.Prime}\text{)},h1​:∀p∈l1​, p is prime (in the sense of Nat.Prime), h2:∏p∈l1p=n(the product of the elements of l1, with multiplicity, equals n),h_2 : \prod_{p \in l_1} p = n \quad \text{(the product of the elements of } l_1\text{, with multiplicity, equals } n\text{)},h2​:p∈l1​∏​p=n(the product of the elements of l1​, with multiplicity, equals n), h3:∀p∈l2, p is prime,h_3 : \forall p \in l_2,\ p \text{ is prime},h3​:∀p∈l2​, p is prime, h4:∏p∈l2p=n,h_4 : \prod_{p \in l_2} p = n,h4​:p∈l2​∏​p=n,

then the conclusion is

l1=l2,l_1 = l_2,l1​=l2​,

i.e. l1l_1l1​ and l2l_2l2​ are equal as multisets --- the same primes occur, with exactly the same multiplicities, in both.

Details and edge cases made explicit by the statement.

  • nnn ranges over all of N\mathbb{N}N, but the hypothesis hn:n≠0hn : n \neq 0hn:n=0 excludes n=0n = 0n=0 from consideration; the statement asserts nothing about multisets whose product is 000.
  • l1l_1l1​ and l2l_2l2​ are each an arbitrary Multiset ℕ --- a multiset is unordered and can contain repeated elements, so this in particular covers the case where a prime occurs with multiplicity greater than one.
  • h1h_1h1​ and h3h_3h3​ require every element of l1l_1l1​ (resp. l2l_2l2​) to satisfy Nat.Prime, Mathlib's standard primality predicate on N\mathbb{N}N (an element ppp is prime iff p≥2p \geq 2p≥2 and its only divisors are 111 and ppp); nothing is asserted about elements outside the multiset, and there is no bound on the size (cardinality) of l1l_1l1​ or l2l_2l2​.
  • Multiset.prod is taken with respect to the commutative monoid (N,×,1)(\mathbb{N}, \times, 1)(N,×,1); by the stated convention, if l1l_1l1​ (or l2l_2l2​) is the empty multiset, its product is defined to be 111. Since hnhnhn forces n≠0n \neq 0n=0, and the empty multiset's product is 1≠01 \neq 01=0, an empty multiset is only consistent with h2h_2h2​ (or h4h_4h4​) when n=1n = 1n=1; for any n≥2n \geq 2n≥2 satisfying the hypotheses, l1l_1l1​ and l2l_2l2​ must be nonempty. No hypothesis explicitly forbids l1l_1l1​ or l2l_2l2​ from being empty in general --- this is only excluded indirectly via n≠0n \neq 0n=0 together with h2,h4h_2, h_4h2​,h4​ when n≠1n \neq 1n=1.
  • The conclusion l1=l2l_1 = l_2l1​=l2​ is multiset equality: it asserts equality of multiplicities for every natural number, not merely that the two multisets have the same underlying set of primes, and not merely that they have the same product or the same length.
  • The proof of the theorem is replaced by sorry, meaning the statement is asserted but not actually proved in this code.
Human review
  • Endorsed by Shuze Chen · Sep 7, 2026

  • Endorsed by Mayank Kumar · Sep 7, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me