[proofplan]
We prove that an irreducible element $p$ satisfies the defining property of primality: whenever $p \mid ab$, either $p \mid a$ or $p \mid b$. The strategy is to use the unique factorisation hypothesis. Write $ab = pc$ and factorise each of $a$, $b$, and $pc$ into irreducibles. Comparing the two factorisations of $ab$ via uniqueness (up to associates and reordering), we conclude that $p$ must be an associate of one of the irreducible factors of $a$ or $b$, which forces $p \mid a$ or $p \mid b$.
[/proofplan]
[step:Reduce to showing that $p \mid ab$ implies $p \mid a$ or $p \mid b$]
Let $p \in R$ be irreducible. To show that $p$ is [prime](/page/Prime%20Element), we must verify: for all $a, b \in R$, if $p \mid ab$ then $p \mid a$ or $p \mid b$. Suppose $p \mid ab$, so there exists $c \in R$ with $ab = pc$.
If $a = 0_R$, then $p \mid a$ and we are done. If $b = 0_R$, then $p \mid b$ and we are done. So we may assume $a \neq 0_R$ and $b \neq 0_R$. Since $ab = pc$ and $R$ is an [integral domain](/page/Integral%20Domain) (every UFD is an integral domain), $c \neq 0_R$ as well.
[guided]
What does it take to show an irreducible element is prime? Recall that an element $p \in R$ is [prime](/page/Prime%20Element) if two conditions hold: (i) $p$ is a nonzero non-unit, and (ii) whenever $p \mid ab$, either $p \mid a$ or $p \mid b$. Since $p$ is irreducible, the definition of [irreducible element](/page/Irreducible%20Element) already guarantees that $p$ is nonzero and not a unit, so condition (i) is satisfied. The entire content of the proof is therefore to verify condition (ii): the divisibility implication.
Suppose $p \mid ab$, so there exists $c \in R$ with $ab = pc$. We first dispose of the degenerate cases. If $a = 0_R$, then $a = 0_R \cdot p$, so $p \mid a$ and we are done. Similarly, if $b = 0_R$, then $p \mid b$.
Now assume $a \neq 0_R$ and $b \neq 0_R$. Since every [unique factorisation domain](/page/Unique%20Factorisation%20Domain) is an [integral domain](/page/Integral%20Domain), $R$ has no zero divisors, so the product of nonzero elements is nonzero: $ab \neq 0_R$. From $pc = ab \neq 0_R$ and $p \neq 0_R$, the cancellation property in an integral domain gives $c \neq 0_R$.
Note that the nonzero conclusions for $a$, $b$, and $c$ are essential: the UFD factorisation machinery applies only to nonzero elements, and factorisation into irreducibles is guaranteed only for nonzero non-units.
With $a$, $b$, and $c$ all nonzero, we are in a position to apply the UFD factorisation machinery to each of them. The next step carries out this factorisation.
[/guided]
[/step]
[step:Factorise $a$, $b$, and $pc$ into irreducibles using the UFD property]
Since $R$ is a UFD and $a, b \in R$ are nonzero non-units (if either is a unit we handle this below), write
\begin{align*}
a &= u \, q_1 q_2 \cdots q_m, \\
b &= v \, r_1 r_2 \cdots r_k,
\end{align*}
where $u, v \in R^\times$ are units and $q_1, \ldots, q_m, r_1, \ldots, r_k$ are irreducible elements of $R$. (If $a$ is itself a unit, then $a = u$ with $m = 0$, and similarly for $b$.)
Then
\begin{align*}
ab = (uv) \, q_1 \cdots q_m \, r_1 \cdots r_k.
\end{align*}
This is a factorisation of $ab$ into irreducibles (with unit factor $uv$), since each $q_i$ and each $r_j$ is irreducible.
On the other hand, $ab = pc$. If $c$ is a unit, then $ab = pc$ with $p$ irreducible gives a factorisation with a single irreducible factor $p$. If $c$ is not a unit, write $c = w \, s_1 s_2 \cdots s_\ell$ where $w \in R^\times$ and each $s_i$ is irreducible. Then
\begin{align*}
ab = pc = w \, p \, s_1 s_2 \cdots s_\ell,
\end{align*}
which is another factorisation of $ab$ into irreducibles (with unit factor $w$), the irreducible factors being $p, s_1, \ldots, s_\ell$.
[guided]
Why do we need both factorisations? The key idea is that the UFD axiom guarantees uniqueness of factorisation up to reordering and associates. By producing two factorisations of the same element $ab$ -- one coming from the factorisations of $a$ and $b$ separately, and another involving $p$ -- we can compare them and force $p$ to appear among the factors of $a$ or $b$.
Since $R$ is a UFD, every nonzero non-unit element admits a factorisation into irreducibles. Write
\begin{align*}
a &= u \, q_1 q_2 \cdots q_m, \\
b &= v \, r_1 r_2 \cdots r_k,
\end{align*}
where $u, v \in R^\times$ are units and $q_1, \ldots, q_m, r_1, \ldots, r_k$ are irreducible. If $a$ is a unit, we take $m = 0$ so that $a = u$; similarly for $b$. Then
\begin{align*}
ab = (uv) \, q_1 \cdots q_m \, r_1 \cdots r_k.
\end{align*}
From $ab = pc$, if $c$ is a unit then $ab = pc$ is already a factorisation with the single irreducible factor $p$. If $c$ is not a unit, factorise $c = w \, s_1 \cdots s_\ell$ with $w \in R^\times$ and each $s_i$ irreducible, giving
\begin{align*}
ab = w \, p \, s_1 \cdots s_\ell.
\end{align*}
In either case, we have two factorisations of $ab$ into irreducibles. The uniqueness clause of the UFD definition will now let us match $p$ against the $q_i$ and $r_j$.
[/guided]
[/step]
[step:Apply uniqueness of factorisation to conclude $p$ is an associate of some $q_i$ or $r_j$]
By the uniqueness property of the [unique factorisation domain](/page/Unique%20Factorisation%20Domain) $R$, the two factorisations of $ab$ into irreducibles must agree up to reordering and multiplication by units. That is, each irreducible factor in one factorisation is an associate of exactly one irreducible factor in the other.
In particular, $p$ (an irreducible factor in the factorisation $ab = w \, p \, s_1 \cdots s_\ell$) must be an associate of some irreducible factor in the factorisation $ab = (uv) \, q_1 \cdots q_m \, r_1 \cdots r_k$. Therefore, there exists either some $q_i$ (with $1 \le i \le m$) or some $r_j$ (with $1 \le j \le k$) such that $p$ and that factor are associates.
[guided]
This is the heart of the argument. The defining property of a UFD states that if a nonzero non-unit element has two factorisations into irreducibles, say
\begin{align*}
\alpha_1 \alpha_2 \cdots \alpha_s = \beta_1 \beta_2 \cdots \beta_t,
\end{align*}
then $s = t$ and, after reindexing, each $\alpha_i$ is an associate of $\beta_i$. (Two elements $x, y \in R$ are associates if $x = \epsilon y$ for some unit $\epsilon \in R^\times$.)
We apply this to the two factorisations of $ab$:
\begin{align*}
q_1 \cdots q_m \, r_1 \cdots r_k &= p \, s_1 \cdots s_\ell \quad (\text{up to a unit factor}).
\end{align*}
(The unit factors $uv$ and $w$ can be absorbed into one of the irreducible factors without changing the associate class, so we compare the lists of irreducible factors directly.)
Uniqueness forces $m + k = 1 + \ell$ and, after reordering, each factor on the left is an associate of exactly one factor on the right. In particular, $p$ must be matched: there exists some $q_i$ or some $r_j$ such that $p$ is an associate of that element.
Could $p$ fail to match any factor on the left? No -- uniqueness requires a bijection between the two lists of irreducible factors (up to associates). Every factor on the right, including $p$, must correspond to some factor on the left.
[/guided]
[/step]
[step:Conclude that $p \mid a$ or $p \mid b$]
**Case 1:** $p$ is an associate of some $q_i$. Then $q_i = \epsilon p$ for some unit $\epsilon \in R^\times$. Since $q_i$ appears in the factorisation $a = u \, q_1 \cdots q_m$, we have
\begin{align*}
a = u \, q_1 \cdots q_{i-1} \, (\epsilon p) \, q_{i+1} \cdots q_m = (u \epsilon) \, q_1 \cdots q_{i-1} \, p \, q_{i+1} \cdots q_m,
\end{align*}
so $p \mid a$.
**Case 2:** $p$ is an associate of some $r_j$. By the identical argument applied to $b = v \, r_1 \cdots r_k$, we obtain $p \mid b$.
In either case, $p \mid a$ or $p \mid b$. Since $a, b \in R$ with $p \mid ab$ were arbitrary, the irreducible element $p$ satisfies the definition of a [prime element](/page/Prime%20Element). This completes the proof that every irreducible element of a UFD is prime.
[guided]
Suppose $p$ is an associate of $q_i$, so $q_i = \epsilon p$ for some $\epsilon \in R^\times$. Substituting into the factorisation of $a$:
\begin{align*}
a = u \, q_1 \cdots q_{i-1} \, (\epsilon p) \, q_{i+1} \cdots q_m = \underbrace{(u \epsilon \, q_1 \cdots q_{i-1} \, q_{i+1} \cdots q_m)}_{\in R} \cdot p,
\end{align*}
which exhibits $a$ as a multiple of $p$, hence $p \mid a$.
The case where $p$ is an associate of some $r_j$ is identical, with $b$ in place of $a$, yielding $p \mid b$.
Why does this argument fail in a general integral domain that is not a UFD? Because without unique factorisation, there is no way to force $p$ to appear among the factors of $a$ or $b$. The element $p$ might divide $ab$ by combining with factors from both $a$ and $b$ in a way that cannot be disentangled. The uniqueness clause of the UFD definition is precisely what prevents this.
[/guided]
[/step]