showing a ring is a principal ideal domain 
Suppose $R$ is a principal ideal domain. Let $S$ be a multiplicatively closed subset of $R$ not containing $0$. Show that $S^{-1}R$, the localization of $R$ by $S$, is a principal ideal domain.

I think that every ideal of $S^{-1}R$ is of the form $S^{-1}I$ for some ideal of $R$. Let $K$ be an ideal of $S^{-1}R$. Then $K = S^{-1}I$ for some subset $I$ of $R.$ We claim that $I$ is an ideal of $R$. Since $K$ is an ideal, $0/1\in K$ so $0\in I.$ Let $a,b \in I.$ Then $\frac{a}1 - \frac{b}1 =\frac{a-b}1\in K$ so $a-b \in I.$ Now suppose $r \in R.$ Then $\frac{a}1 \cdot \frac{r}1 = \frac{ar}1\in K$ so $ar \in I$ and similarly $ra \in I$. Is it correct to say that if $ar \not\in I,$ then $\frac{ar}1\not\in K$ (I'm just trying to confirm my understanding of localization)?
Thus, $I$ is an ideal of $R.$ So $I = (a)$ for some $a$ in $R$ as $I$ is a PID. We claim that $S^{-1}I = (\frac{a}1).$ Let $\frac{ka}b \in (\frac{a}1).$ Then $ka\in I$ and $b \in S\Rightarrow \frac{ka}b \in S^{-1}I.$ Now let $\frac{a}b \in S^{-1}I.$ Then $\frac{a}b = \frac{1}b \cdot \frac{a}1 \in (\frac{a}1).$ Thus, $S^{-1}I = (\frac{a}1)$ so it is principal.

If I've madea mistake, could you point it out?


I'm starting a bounty for this question because I'd like to clarify one thing in a comment by the answerer:

What is the answerer's claim about considering a finite subset of $\mathbb{Q}$? In particular, how would one choose $S, R,$ and how would one show that $K$ is not of the form $S^{-1}I$ for any subset $I$ of $R$? What would $K$ be in your counterexample?

Would it be correct to define $I$ as $\{x\in R : \frac{x}1 \in K\}$?

 A: Hint: you haven't proved that any ideal $K$ of $S^{-1}R$ has the form $S^{-1}I$ for some ideal $I$ of $R$. Apart from that, your argument is good. To prove the bit you have missed, assume $K$ is an ideal in $S^{-1}R$ and let $I$ be $K \cap R$. Now prove that $I$ is an ideal of $R$ and hence a principal ideal, so that, in $R$, $I = (a)$ for some $a \in R$ and conclude that, in $S^{-1}R$, $K = (a/1)$.
To address the point added after my answer, it is not the case that any subset $K$ of $S^{-1}R$ has the form $S^{-1}I$ for some subset $I$ of $R$. To see this, take $R = \Bbb{Z}$ and $S = \Bbb{Z} \setminus \{0\}$, so that $S^{-1}R$ is $\Bbb{Q}$. If $I$ is any subset of $R = \Bbb{Z}$ containing a non-zero element $x$, then $S^{-1}I$ contains all rational numbers of the form $x/n$ and hence is infinite. So no finite subset $K$ of $S^{-1}R = \Bbb{Q}$ containing a non-zero element has the form $S^{-1}I$ for $I \subseteq R = \Bbb{Z}$. Specifically, you could take $K = \{1\}$. Note also that there are lots of infinite sets that are not of the form $S^{-1}I$ for any $I$, e.g., the set $2\Bbb{Z}$ of even integers is not of this form.
