Yes, because (quadratic) number rings are easily shown to have dimension at most one (i.e. every nonzero prime ideal is maximal). But $\rm PID$s are precisely the $\rm UFD$s which have dimension $\le 1.\, $ Below is a sketch of a proof of this and closely related results.
Theorem $\rm\ \ TFAE\ $ for a $\rm UFD\ D$
$(1)\ \ $ prime ideals are maximal if nonzero, $ $ i.e. $\rm\ dim\,\ D \le 1$
$(2)\ \ $ prime ideals are principal
$(3)\ \ $ maximal ideals are principal
$(4)\ \ \rm\ gcd(a,b) = 1\, \Rightarrow\, (a,b) = 1,\, $ i.e. $ $ coprime $\Rightarrow$ comaximal
$(5)\ \ $ $\rm D$ is Bezout, i.e. all ideals $\,\rm (a,b)\,$ are principal.
$(6)\ \ $ $\rm D$ is a $\rm PID$
Proof $\ $ (sketch of $\,1 \Rightarrow 2 \Rightarrow 3 \Rightarrow 4 \Rightarrow 5 \Rightarrow 6 \Rightarrow 1)\ $ where $\rm\,p_i,\,P\,$ denote primes $\neq 0$
$(1\Rightarrow 2)$ $\rm\ \ p_1^{e_1}\cdots p_n^{e_n}\in P\,\Rightarrow\,$ some $\rm\,p_j\in P\,$ so $\rm\,P\supseteq (p_j)\, \Rightarrow\, P = (p_j)\:$ by dim $\le1$
$(2\Rightarrow 3)$ $ \ $ max ideals are prime, so principal by $(2)$
$(3\Rightarrow 4)$ $\ \rm \gcd(a,b)=1\,\Rightarrow\,(a,b) \subsetneq (p) $ for all max $\rm\,(p),\,$ so $\rm\ (a,b) = 1$
$(4\Rightarrow 5)$ $\ \ \rm c = \gcd(a,b)\, \Rightarrow\, (a,b) = c\ (a/c,b/c) = (c)$
$(5\Rightarrow 6)$ $\ $ Ideals $\neq 0\,$ in Bezout UFDs are generated by an elt with least #prime factors
$(6\Rightarrow 1)$ $\ \ \rm (d) \supsetneq (p)$ properly $\rm\Rightarrow\,d\mid p\,$ properly $\rm\,\Rightarrow\,d\,$ unit $\,\rm\Rightarrow\,(d)=(1),\,$ so $\rm\,(p)\,$ is max
Remark $ $ Examples of non-PID UFDs are easy in polynomial rings: if $D$ is a non-field domain then it has a nonzero nonunit $d$ so by here the ideal $(d,x)$ is not principal.
Thus it appears that existence of GCD is not necessary to guarantee existence of unique factorization.
Effectively there is not necessary the existence of GCD in order to prove the fundamental theorem of arithmetic. It's enough a weaker condition, namely we only need the four number lemma, see e.g., this answer. This lemma in a more abstract setting give rise to two special classes of domains known as Schreier domains and pre-Schreier domains (or Riesz domains).
Egreg wrote:
It turns out that this is one of the keys for a domain to have unique factorization. Indeed, a domain $R$ has unique factorization if and only if
$R$ has the ascending chain condition on principal ideals;
every irreducible element in $R$ is prime.
The first condition ensures existence of a factorization into a product of irreducible elements; the second condition ensures uniqueness.
Domains satisfying the first condition are called ACCP domains, whereas the domains satisfying the second condition are called AP-domains (atom $\implies$ prime), where atom=irreducible.
An important result is the following:
Theorem: If $R$ is an ACCP domain, then $R[x]$ is also an ACPP domain.
Proof: This is theorem 17a) in Pete L. Clark's notes on factorization in integral domains.
I'm not aware of any characterization of AP domains, but what I know is that every GCD domain is an AP-domain, even more: both Schreier and pre-Schreier domains are AP-domains and more exactly we have the following chain:
$$\text{GCD-domain} \implies \text{Schreier domain} \implies \text{pre-Schreier domain} \implies \text{AP-domain}.$$
Therefore we have the following characterization of unique factorization domains:
$$\text{UFD} \iff \text{ACCP domain}+\text{Schreier domain}\; (^*)$$
On the other hand, it turn out the being a Schreier domain behaves well under polynomial ring extensions, namely we have the following:
Theorem (Cohn): If $R$ is a Schreier domain, then so is $R[x]$.
Proof: This is theorem 2.7 in the paper Bezout rings and their subrings.
So we can apply (*) to the particular cases of $\Bbb Z$ and $\Bbb Z[x]$ in this way:
i) For $\Bbb Z$:
- We can use induction (or the well-ordering principle) to ensure the existence of a prime factorization. Note that $\Bbb Z$ satisfying the well-ordering principle is equivalent to $\Bbb Z$ being an ACPP domain.
- We can use the four number lemma to guarantee the uniqueness.
ii) For $\Bbb Z[x]$:
Since $\Bbb Z$ satisfies the ACCP condition, then $\Bbb Z[x]$ also satisfies the ACCP condition, so this will give us the existence of the irreducible factorization.
Since $\Bbb Z$ is a Schreier domain, then $\Bbb Z[x]$ is also a Schrier domain, so this will guarantee the uniqueness.
However, there is a little more to say. The classical proof of: $$D\; \text{UFD} \implies D[x]\; \text{UFD}\; (^{**})$$ uses, as you've noted, Gauss' lemma: the product of two primitive polynomials is primitive, but the above result isn't necessary because we can proof (**) without it. For instance, you can check theorem 27 of Pete L. Clark's notes cited lines above.
Returning to Gauss' lemma, this result gives rise to the class of domains known as GL-domains, and Anderson and Zafrullah proved that they are between the class of pre-Schreier and AP-domains. So in conclusion we have the chain:
$$\text{GCD-domain} \implies \text{Schreier domain} \implies \text{pre-Schreier domain}$$ $$\implies \text{GL-domain} \implies \text{AP-domain}.$$
For more info related to Schreier, pre-Schreier and GL-domains you can check these papers:
- M. Zafrullah, On a property of pre-Schreier domains, Communications in Algebra, 15 (1987), 1895-1920.
- S. McAdam and D. Rush, Schreier Rings, Bulletin of the London Mathematical Society, 10 (1978), 77-80.
- J. Arnold and P. Sheldon, Integral domains that satisfy Gauss's lemma, The Michigan Mathematical Journal, 22 (1975), 39-51.
- D. Anderson and M. Zafrullah The Schreier property and Gauss' lemma, Bollettino U. MI, 8 (2007), 43-62.
Best Answer
It's true for a principal ideal domain, since for $J=(x)$ this then becomes $$\mathrm{gcd}(ab,x)=\mathrm{gcd}(a,x)\cdot\mathrm{gcd}(b,x).$$
It's not true in general for unique factorisation domains. For example, let $R=K[x,y]$ be the polynomial ring over some field $K$, and take $a=x$, $b=y$ and $J=(x+y)$. Then $$(xy)+J=(xy,x+y) \quad \textrm{and}\quad (x)+J=(x,y)=(y)+J,$$ and clearly $(xy,x+y)\neq(x,y)$.