Prime factorisation and the fundamental theorem of arithmetic [01FT]
- October 31, 2026
- Marcelo Fiore, Jon Sterling
Proposition Existence of prime factorisation [01FU]
- October 31, 2026
- Marcelo Fiore, Jon Sterling
Every natural number n greater than or equal to 2 is a product of finite sequence of primes, i.e. we have n = \prod {\mathopen {}\left (\vec {p}\right )\mathclose {}} for some finite sequence \vec {p} of primes.
Proof.
- October 31, 2026
- Marcelo Fiore, Jon Sterling
Let P{\mathopen {}\left (m\right )\mathclose {}} be the statement “m is the product of some sequence of primes.” We will now prove \forall m \geq 2\mathpunct {.} P{\mathopen {}\left (m\right )\mathclose {}} using the principle of strong induction from basis 2.
- Base case. P{\mathopen {}\left (2\right )\mathclose {}} holds because 2 is prime, so 2 = \prod _{p\in {\mathopen {}\left \{2\right \}\mathclose {}}}p.
- Inductive step. Let n \geq 2 such that we have P{\mathopen {}\left (k\right )\mathclose {}} for all k:{\mathopen {}\left [2\ldots n\right ]\mathclose {}}. We must prove P{\mathopen {}\left (n+1\right )\mathclose {}}, which we will do by cases on whether or not n+1 is prime.
- If n+1 is prime, then P{\mathopen {}\left (n+1\right )\mathclose {}} holds immediately.
- If to the contrary n+1 is composite, then it follows that we may factor n+1 as j\cdot k with both j,k:{\mathopen {}\left [2\ldots n\right ]\mathclose {}}. Our strong induction hypothesis implies P{\mathopen {}\left (j\right )\mathclose {}} and P{\mathopen {}\left (k\right )\mathclose {}} and so we have finite sequences \vec {p} and \vec {q} such that j = \prod {\mathopen {}\left (\vec {p}\right )\mathclose {}} and k =\prod {\mathopen {}\left (\vec {q}\right )\mathclose {}}. We therefore may define a new finite sequence by concatenating \vec {p}\ldots \vec {q} and it follows straightaway that j\cdot k is the product of the concatenated sequence.
Lemma Uniqueness of sorted prime factorisation [01FV]
- November 1, 2026
- Marcelo Fiore, Jon Sterling
Let \vec {p} and \vec {q} be two sorted nonempty finite sequences of primes. (By “sorted” we mean that \vec {p}_i \leq \vec {p}_{j} whenever i\leq j.) Then if \prod {\mathopen {}\left (\vec {p}\right )\mathclose {}} = \prod {\mathopen {}\left (\vec {q}\right )\mathclose {}}, then \vec {p} = \vec {q}.
Remark.
- November 1, 2026
- Marcelo Fiore, Jon Sterling
In other words, the function \prod that sends a sorted nonempty finite sequences of primes to its product is injective; we will learn about injectivity in future lectures, however.
Proof.
- November 1, 2026
- Marcelo Fiore, Jon Sterling
We will proceed by induction with basis 1 on the length of the first sequence of primes. In particular, let P{\mathopen {}\left (\ell \right )\mathclose {}} be the following statement:
For all sorted nonempty finite sequences of primes \vec {p} and \vec {q} such that \vec {p} has length \ell , if \prod {\mathopen {}\left (\vec {p}\right )\mathclose {}} = \prod {\mathopen {}\left (\vec {q}\right )\mathclose {}} then \vec {p}=\vec {q}.
We will show that P{\mathopen {}\left (\ell \right )\mathclose {}} holds for all \ell \geq 1 by induction as follows:
- Base case. To establish P{\mathopen {}\left (1\right )\mathclose {}}, we fix a prime p and a sorted nonempty finite sequence of primes \vec {q}, and we must show that if p = \prod {\mathopen {}\left (\vec {q}\right )\mathclose {}} then \vec {q} is the sequence that contains just the prime p. Our assumption says that \prod {\mathopen {}\left (\vec {q}\right )\mathclose {}} is prime, and therefore (by definition) it cannot contain more than one element, so we are done.
Inductive step. We now fix a positive natural \ell \geq 1 and assume the induction hypothesis P{\mathopen {}\left (\ell \right )\mathclose {}}, and we must show that P{\mathopen {}\left (\ell +1\right )\mathclose {}} holds. To that end, we might fix \vec {p} of length \ell +1 and an arbitrary \vec {q} and we assume \prod {\mathopen {}\left (\vec {p}\right )\mathclose {}} = \prod {\mathopen {}\left (\vec {q}\right )\mathclose {}}.
By Euclid’s theorem, p_0 divides some q_i and therefore equals it. For the same reason, q_0 divides and therefore equals some p_j. Therefore we may deduce q_0 = p_0 as follows, using our assumption that the sequences were sorted:
q_0 \leq q_i = p_0 \qquad p_0 \leq p_j = q_0Writing \vec {r} and \vec {s} for the suffixes of \vec {p} and \vec {q} respectively obtained by removing their first elements, we have:
\begin {aligned} p_0 \cdot \prod {\mathopen {}\left (\vec {r}\right )\mathclose {}} = \prod {\mathopen {}\left (\vec {p}\right )\mathclose {}} = \prod {\mathopen {}\left (\vec {q}\right )\mathclose {}} = q_0\cdot \prod {\mathopen {}\left (\vec {s}\right )\mathclose {}} = p_0\cdot \prod {\mathopen {}\left (\vec {s}\right )\mathclose {}} \end {aligned}Therefore by cancellation, we have \prod {\mathopen {}\left (\vec {r}\right )\mathclose {}} = \prod {\mathopen {}\left (\vec {q}\right )\mathclose {}} and because \vec {r} is of length \ell , our induction hypothesis states that \vec {r} = \vec {s}. We therefore deduce \vec {p}=\vec {q}.
Apology Induction on the length is usually a mistake [01FW]
- November 1, 2026
- Jon Sterling
In our proof of the uniqueness of prime factorisations, we proceeded by induction on the length of a prime factorisation. In all honesty, that is not usually the best proof technique, as it leads to arguments that are technical and artificial rather than getting to the heart of the matter. Mathematical induction is the induction priniciple of the natural numbers, but these are only the simplest and most impoverished data structure that we can come up with; finite sequences also have an induction principle, as do trees (even infinitely branching trees!). These more sophisticated induction principles for data structures get to the heart of the matter, and lead to proofs that have more in common with algorithms that work on the data structures in question. The reason we are not using the induction principle for finite sequences here is simply that we haven’t learned enough yet to apply it.
Corollary The fundamental theorem of arithmetic [01FX]
- November 1, 2026
- Marcelo Fiore, Jon Sterling
Every positive natural number n is the product of a unique sorted sequence of prime numbers.
Proof.
- November 1, 2026
- Marcelo Fiore, Jon Sterling
We consider two cases:
- If n=1, then n is the product of the empty sequence of primes. There can be no non-empty sequence of primes that multiplies to 1, since all primes are strictly greater than 1.
- If n\geq 2, then we have already shown that there exists an (unsorted) prime factorisation of n; of course, we may order it using any sorting algorithm. So it remains to show the remaining sorted factorisation is unique, which follows immediately from our lemma estaablishing uniqueness of sorted prime factorisations.
Theorem Euclid’s infinitude of primes [01FZ]
- November 1, 2026
- Marcelo Fiore, Jon Sterling
The set of prime numbers is infinite.
Proof.
- November 1, 2026
- Marcelo Fiore, Jon Sterling
We will use proof by contradiction. In particular, suppose that the set of primes is finite, and let p_1,\ldots ,p_\ell be the collection of all primes. When then consider the natural number p \coloneqq p_1\cdot \ldots \cdot p_\ell + 1 which we know not to be in the list because it is strictly greater than any p_i. By the prime factorisation existence lemma, p is a product of primes, and so there must exist some p_i in our list of all primes such that p_i\mid p. Because p_i\mid {\mathopen {}\left (p_1\cdot \ldots \cdot p_\ell \right )\mathclose {}}, it also divides their difference p-{\mathopen {}\left (p_1\cdot \ldots \cdot p_\ell \right )\mathclose {}} = 1, so we have p\mid 1, but this is contradictory as p\geq 1.