A commutative algebra is a PID if and only if it is a UFD and all nonzero prime ideals are maximal. This leads to an interesting method to construct PID's: Let $R$ be a UFD and let $S \subset R$ be a multiplicative set such that, for any prime $\mathfrak{p} \subset R$ of height $\geq 2$, there is some $f \in S$ with $f \in P$. Then $S^{-1} R$ will be a PID, because localizations of UFD's are UFD's and the poset of prime ideals in $S^{-1} R$ is obtained from the poset of prime ideals in $R$ by deleting those ideals containing an element of $S$.

This can be useful for building counterexamples, because $S^{-1} R$ is the forward limit of $f^{-1} R$ over all $f \in S$, and each of the $f^{-1} R$ will be a UFD but not a PID, so one can take counterexamples in UFD's and make them into PID counterexamples by this trick.

I learned about this construction from Grayson's paper [$SK_1$ of an interesting principal ideal domain][1]. The PID in question is to take $R = \mathbb{Z}[T]$ and $S = \{ T \} \cup \{ T^n-1 : n > 0 \}$, and the interesting property is that $SL_n(S^{-1} R)$ is <b>not</b> generated by elementary matrices.

I can't resist showing off: After I read Grayson's paper, I come up with the following simpler example for $SL_2$. Let $R = \mathbb{R}[x,y]$ and let $S$ be the set of nonzero polynomials in $\mathbb{R}[x^2+y^2]$. Then $S^{-1} R$ is a PID by the above argument. I claim that $M=\tfrac{1}{x^2+y^2} \left[ \begin{smallmatrix} x&y \\ -y&x \end{smallmatrix} \right]$ is not a product of elementary matrices. Suppose that it were such a product $E_1 E_2 \cdots E_n$. Then the denominators of the $E_j$ only contain finitely many elements of $S$, so all the $E_j$ lie in $f(x^2+y^2)^{-1} R$ for some nonzero polynomial $f$. Choose some real number $r$ so that $f(r^2) \neq 0$, then each of the $E_j$ is a well defined continuous function on the circle $x^2+y^2 = r^2$. So $E_1 E_2 \cdots E_n$ gives a map from this circle to $SL_2(\mathbb{R})$, and hence a class in $\pi_1(SL_2(\mathbb{R}))$. Using that the matrices are elementary, this $\pi_1$ class is trivial. But $\tfrac{1}{x^2+y^2} \left[ \begin{smallmatrix} x&y \\ -y&x \end{smallmatrix} \right]$ represents a nontrival class in $\pi_1(SL_2(\mathbb{R})) \cong \mathbb{Z}$, a contradiction.


  [1]: https://doi.org/10.1016/0022-4049(81)90089-X