Principal Ideal of Principal Ideal Domain is of Irreducible Element iff Maximal/Reverse Implication

Theorem
Let $\left({D, +, \circ}\right)$ be a principal ideal domain.

Let $\left({p}\right)$ be the principal ideal of $D$ generated by $p$.

Let $\left({p}\right)$ be a maximal ideal of $D$.

Then $p$ is irreducible.

Proof
Let $\left({p}\right)$ be a maximal ideal of $D$.

Let $p = f g$ be any factorization of $p$.

We must show that one of $f, g$ is a unit.

Suppose that neither of $f, g$ is a unit.


 * Claim: $\left({p}\right) \subsetneqq \left({f}\right)$


 * Proof: Let $x \in \left({p}\right)$, i.e. $x = p q$ for some $q \in D$.


 * Then $x = f g q \in \left({f}\right)$, so $\left({p}\right) \subseteq \left({f}\right)$.


 * Now suppose $f \in \left({p}\right)$.


 * Then there is $r \in D$ such that $f = r p$, and $f = r g f$.


 * Therefore $r g = 1$, and $g$ is a unit, a contradiction.


 * Thus $f \notin \left({p}\right)$, and clearly $f \in \left({f}\right)$, so $\left({p}\right) \subsetneqq \left({f}\right)$ as claimed.

Therefore, since $\left({p}\right)$ is maximal, we must have $\left({f}\right) = D$.

But we assumed that $f$ is not a unit, so there is no $h \in D$ such that $f h = 1$.

Therefore $1 \notin \left({f}\right) = \left\{{f h: h \in D}\right\}$, and $\left({f}\right) \subsetneqq D$.

This is a contradiction, so at least one of $f, g$ must be a unit.

This completes the proof.