Is every PID a UFD?

Every PID is a UFD. Not every UFD is a PID.

Example: A ring $R$ is a unique factorization domain if and only if the polynomial ring $R[X]$ is one. But $R[X]$ is a principal ideal domain if and only if $R$ is a field. So, $\mathbb{Z}[X]$ is an example of a unique factorization domain which is not a principal ideal domain.

The statement "In a PID every non-zero, non-unit element can be written as product of irreducibles" is true, but it is not the definition of a principal ideal domain. Nor is it the definition of a unique factorization domain: as you pointed out, it does not account for uniqueness.

Note that in an integral domain, every prime element is irreducible, but the converse is false.

Here are two equivalent definitions of unique factorization domain:

1 . An integral domain $R$ in which every nonzero nonunit is a product of prime elements,

2 . An integral domain $R$ in which every nonzero nonunit is a product of irreducible elements, and this product is unique up to associates.

In the proof you were reading, I guess what they are trying to say is the following: in a principal ideal domain $R$, it is true that irreducible is the same thing as prime. So once you show that every nonzero nonunit can be written as a product of irreducibles, it follows that $R$ is a unique factorization domain.


In a PID every non-zero,non-unit element can be written as product of irreducibles".

This statement claims that a PID is an atomic domain, i.e., a domain where every non-zero, non unit admit a factorization into irreducibles (aka atoms, hence the name atomic).

As you noted, being a UFD requires the uniqueness of such a factorization and this leads to another definition: an AP-domain is a domain where every atom is prime.

So we have the following characterization of UFDs: $$\text{UFD}\iff \text{Atomic domain}+\text{AP-domain}.$$

Therefore you can prove that a PID is a UFD showing that is both an atomic and an AP-domain. For further reference you can check these notes, specially the sections two and four.