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.

First it will be shown that:
 * $\left({p}\right) \subsetneqq \left({f}\right)$

Let $x \in \left({p}\right)$.

That is:
 * $\exists q \in D: x = p q$

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:
 * $\exists r \in D: f = r p$

and so from $p = f g$ above:
 * $f = r g f$

Therefore:
 * $r g = 1$

and so $g$ is a unit.

This is 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.

Therefore at least one of $f, g$ must be a unit.

This completes the proof.