Definition of UFD and the fact that UFDs are integrally closed I am trying to understand the proof of the fact that UFDs are integrally closed. In addition to the lecture notes I have, there are at least two solutions on MSE:
One is here: How to prove that UFD implies normal?
and the other is here: UFDs are integrally closed
In all instances, I am failing to understand where and how exactly we are using the "unique factorization" property of the domain, which makes me think maybe I have never properly understood the definition of a UFD. Let's stick to the notation used in the answer of the first link:

*

*I am thinking one place where we used "unique factorization" is at the end where we are concluding $b$ is a unit. Since $R$ is a UFD, we can write $b=u b_{1} b_{2} ... b_{n}$ where $u$ is a unit and $b_{i}$'s are irreducibles. Since $b$ does not have any irreducibles in its factorization, we get that $b=u,$ i.e., b is a unit. However, I don't think I used "uniqueness" here. I am not sure if this is an actual thing, but if $R$ was just a "factorization domain" (meaning, any nonzero element could be factored into product of irreducibles, but not necessarily in a unique way), I think we would have the same conclusion.


*The other place where we use unique factorization might be at the beginning of the proof, where we take $a$ and $b$ as having no common irreducible factors, i.e. they are relatively prime. I am thinking that if an element of $R$ can have more than one factorization into irreducibles, then the following can happen: Suppose $\dfrac{s}{t}=\dfrac{abcd}{abef}$ where $s, t\in R$ and $abcd$ is one of the possible factorizations of $s$ into irreducibles, and similarly $abef$ for $t$. Then $\dfrac{s}{t}=\dfrac{cd}{ef}$ ($c, d, e, f$ all distinct). Even though $c, d, e, f$ are distinct, the elements $cd, ef \in R$ could have different factorizations into irreducibles, say $cd=klm$ and $ef =knp$. But then $\dfrac{s}{t}=\dfrac{klm}{knp}=\dfrac{lm}{np},$ and we are back to the similar situation we started with, and there is no guarantee that this process will end. i.e., we don't know if $\dfrac{s}{t}$ can be written as $\dfrac{a}{b}$ with $a, b$ relatively prime.
Is there anything I am failing to see?
 A: In a unique factorization domain, if $b$ divides $a^n$, and $r$ is an irreducible that divides $b$, then $r$ also divides $a$.
To see this, you factor $a$ into irreducibles, $a=ur_1\cdots r_k$. Then the factorization of $a^n$ into irreducibles must be
$$a^n = u^n r_1^n\cdots r_k^n$$
because that is a factorization, and hence the factorization. If $b$ divides $a^n$ and $r$ divides $b$, then $r$ divides $a^n$, and hence there exists $c$ such that $rc=a^n$. Expressing $c$ as a product of irreducibles, and using unique factorization, we conclude that $r=r_i$ for some $i$, so $r$ actually divides $a$, and not merely $a^n$.
This chain of reasoning fails without unique factorization, even if the domain is atomic (every elements can be written as a product of irreducibles): for example, $\mathbb{Z}[\sqrt{-5}]$ is an atomic domain that is not a UFD. Let $b=2$, and let $a=1+\sqrt{-5}$. Using the norm map $N\colon \mathbb{Z}[\sqrt{-5}]\to\mathbb{Z}$, defined by
$$N(x+y\sqrt{-5}) = x^2+5y^2$$
it is easy to verify that both $a$ and $b$ are irreducible. It is also plain that $b$ does not divide $a$. But $b$ does divide $a^2 = -4+2\sqrt{-5}$. Thus, we have a situation in which an irreducible divides $b$ (namely $2$), and $b$ divides a power of $a$ (namely, $a^2$), but the irreducible does not divide $a$.
Thus, in the argument you quote, the claim that because $a$ and $b$ have no common irreducible factor, and $b$ divides $a^n$, it follows that $b$ is a unit does not follow without unique factorization. Your thinking in point 1 that you could deduce that is incorrect, because we cannot deduce that $b$ is not divisible by any irreducibles; that deduction comes from concluding that any irreducible factor of $b$ must also divide $a$, but as the example above shows, without unique factorization into irreducibles this assertion would not follow.
A different way to see the initial claim is that in a UFD irreducibles are prime: if $r$ is an irreducible and divides a product $xy$, then $r$ must divide either $x$ or $y$. If your ring is atomic but not a UFD, this does not hold. In $\mathbb{Z}[\sqrt{-5}]$, all of $2$, $3$, $1+\sqrt{-5}$ and $1-\sqrt{-5}$ are irreducibles, but none are prime since
$$2\times 3 = (1+\sqrt{-5})(1-\sqrt{-5}).$$
That's what sinks you.
A: Integral closure is equivalent to RRT = Rational Root Test being true for all polynomials that are monic, i.e. lead coef $= 1$ (or a unit). The common proof of RRT in $\Bbb Z$ immediately generalizes to any UFD or, more generally, any GCD domain (a domain where all gcds exist), since it employs only the following properties of gcds (below, by definition, the gcd $(a,b) = 1\,$ means $\,c\mid a,b\iff c\mid 1,\,$ i.e. every common divisor $\,c\,$ of $\,a,b\,$ is a unit = invertible element, i.e. $\,a,b\,$ are coprime).

*

*$(1)\ $ every fraction  is equivalent to a fraction $\,a/b,\,$ that is irreducible, i.e. $\,(a,b)=1$


*$(2)\ $ if  $\,(a,b)=1\,$ then $\, a\mid b^n c\,\Rightarrow\, a\mid c$.
Both are immediate consequences of basic properties of gcds, namely

*

*$(1)\,$ follows by the gcd Distributive Law, viz. $\,c=(a,b)\Rightarrow (a/c,b/c)=(a,b)/c = 1,\,$ so cancelling $\,c = (a,b)\,$ from $\,a/b\,$ yields an irreducible fraction


*$(2)\,$ follows by iterating Euclid's Lemma $\,(a,b)=1,\ a\mid bc\Rightarrow a\mid c$
Therefore GCD domains satisfy RRT so, in particular are integrally closed (in their fraction field). In particular this is true for every UFD (clearly all gcds exist in a UFD).
Notice prime factorizations play no role in the proof - indeed the proof works fine even in non-UFD gcd domains, e.g. the Bezout ring of all algebraic integers, which has no primes since it has no irreducibles - every element $a$ has a square-root so a  nontivial factorization $\,a = \sqrt a\,\sqrt a$.
The linked proofs show that the gcd Distributive Law and Euclid's Lemma both hold true in every gcd domain, since the proofs don't use prime factorizations but rather use only that all gcds exist.
However, in a UFD it is common to prove the Law and Lemma using prime factorizations - which yields less generality and, further, is  less constructive - since in many effective domains there are efficient algorithms to compute gcds but no known efficient algorithms to compute prime factorizations. In fact in many number theoretic problems it suffices (and is more efficient) to work with coprimes rather than primes, e.g. see the concept of a gcd-free basis in section $4.8$ in Bach and Shallit: $ $ Algorithmic Number Theory.
