Proof
Existence of a factorization. Let $D$ be a PID and $a$ be a nonzero element in $D$ that is not a unit. If $a$ is irreducible, then we are done. If not, then there exists a factorization $a = a_1 b_1\\text{,}$ where neither $a_1$ nor $b_1$ is a unit. Hence, $\\langle a \\rangle \\subset \\langle a_1 \\rangle\\text{.}$ By Lemma 18.11, we know that $\\langle a \\rangle \\neq \\langle a_1 \\rangle\\text{;}$ otherwise, $a$ and $a_1$ would be associates and $b_1$ would be a unit, which would contradict our assumption. Now suppose that $a_1 = a_2 b_2\\text{,}$ where neither $a_2$ nor $b_2$ is a unit. By the same argument as before, $\\langle a_1 \\rangle \\subset \\langle a_2 \\rangle\\text{.}$ We can continue with this construction to obtain an ascending chain of ideals
\n\\begin{equation*}\n\\langle a \\rangle \\subset \\langle a_1 \\rangle \\subset \\langle a_2 \\rangle \\subset \\cdots.\n\\end{equation*}\n
By Lemma 18.14, there exists a positive integer $N$ such that $\\langle a_n \\rangle = \\langle a_N \\rangle$ for all $n \\geq N\\text{.}$ Consequently, $a_N$ must be irreducible. We have now shown that $a$ is the product of two elements, one of which must be irreducible.
Now suppose that $a = c_1 p_1\\text{,}$ where $p_1$ is irreducible. If $c_1$ is not a unit, we can repeat the preceding argument to conclude that $\\langle a \\rangle \\subset \\langle c_1 \\rangle\\text{.}$ Either $c_1$ is irreducible or $c_1 = c_2 p_2\\text{,}$ where $p_2$ is irreducible and $c_2$ is not a unit. Continuing in this manner, we obtain another chain of ideals
\n\\begin{equation*}\n\\langle a \\rangle \\subset \\langle c_1 \\rangle \\subset \\langle c_2 \\rangle \\subset \\cdots.\n\\end{equation*}\n
This chain must satisfy the ascending chain condition; therefore,
\n\\begin{equation*}\na = p_1 p_2 \\cdots p_r\n\\end{equation*}\n
for irreducible elements $p_1, \\ldots, p_r\\text{.}$
Uniqueness of the factorization. To show uniqueness, let
\n\\begin{equation*}\na = p_1 p_2 \\cdots p_r = q_1 q_2 \\cdots q_s,\n\\end{equation*}\n
where each $p_i$ and each $q_i$ is irreducible. Without loss of generality, we can assume that $r \\lt s\\text{.}$ Since $p_1$ divides $q_1 q_2 \\cdots q_s\\text{,}$ by Corollary 18.13 it must divide some $q_i\\text{.}$ By rearranging the $q_i$'s, we can assume that $p_1 \\mid q_1\\text{;}$ hence, $q_1 = u_1 p_1$ for some unit $u_1$ in $D\\text{.}$ Therefore,
\n\\begin{equation*}\na = p_1 p_2 \\cdots p_r = u_1 p_1 q_2 \\cdots q_s\n\\end{equation*}\n
or
\n\\begin{equation*}\np_2 \\cdots p_r = u_1 q_2 \\cdots q_s.\n\\end{equation*}\n
Continuing in this manner, we can arrange the $q_i$'s such that $p_2 = q_2, p_3 = q_3, \\ldots, p_r = q_r\\text{,}$ to obtain
\n\\begin{equation*}\nu_1 u_2 \\cdots u_r q_{r+1} \\cdots q_s = 1.\n\\end{equation*}\n
In this case $q_{r + 1} \\cdots q_s$ is a unit, which contradicts the fact that $q_{r + 1}, \\ldots, q_s$ are irreducibles. Therefore, $r = s$ and the factorization of $a$ is unique.