What is the group of units of the localization of a number field? Let $\mathcal{O}_K \subseteq K$ be the ring of integers of a number field. We have Dirichlet's Unit Theorem which says that the group of units of $\mathcal{O}_K$ is a finitely generated abelian group of rank $r- 1$ where $r$ is the number of archimedean valuations of $K$ and whose torsion part is exactly the group of roots of unity in $K$. 
I've seen the statement - but not the proof, although apparently the ideas are similar - that the group of "$S$-Units" is also a finitely generated abelian group, where $S$ is a finite set of prime ideals of $\mathcal{O}_K$ and the set of $S$-units is the set $\{x \in K \mid |x|_P = 0\ \forall P \not \in S\}$. Its rank is $r + s - 1$ where $s = |S|$. 
Do either of these results easily imply that the group of units of the localization $M^{-1} \mathcal{O}_K$ is finitely generated for:


*

*Any multiplicatively closed set $M$?

*$M$ generated by a finite set?

*$M = \mathcal{O}_K \setminus \mathfrak{p}$ for a prime $\mathfrak{p}$? 


If so, what is its rank? If not, is there an easy other proof (or counterexample)?
EDIT As pointed out in the comments, it's too much to expect that the localization at a prime $(\mathcal{O}_K)_{\mathfrak{p}}$ should be finitely generated. But the case where $M$ is generated by a finite set seems plausible. At least in the case that $\mathcal{O}_K$ is a PID, the group of units of $\mathcal{O}_K[f_1^{-1}, \ldots, f_n^{-1}]$ should just be $(\mathcal{O}_K)^* \times f_1 \mathbb{Z} \times \cdots \times f_n \mathbb{Z}$ (assuming that the $f_i$ are multiplicatively independent - i.e. taking a minimal generating set for $M$):
If $a f_1^{e_1} \cdots f_n^{e_n}$ is a unit of $M^{-1}\mathcal{O}_K$ written so that $a \in \mathcal{O}_K$ is coprime to the $f_i$, then its inverse is $b f_1^{e'_1} \cdots f_n^{e'_n}$ with $b \in \mathcal{O}_K$ coprime to the $f_i$, then it must be the case that $a b = 1$ and $e_i + e'_i = 0$ for all $i$. Thus, up to multiplication by the $f_i$, $a$ is a unit of $\mathcal{O}_K$. 
It seems like this result shouldn't depend on $\mathcal{O}_K$ being a principal ideal domain, but I don't know how to fix the proof in that case.
 A: The question for $M$ finitely generated has a positive answer. Indeed, if $M$ is given by products $f_1^{i_1} \cdots f_r^{i_r}$, then localising at the single element $f = f_1 \cdots f_r$ gives the same outcome, so it suffices to consider the case $M = f^\mathbb N$.
Now let $f\mathcal O_K = \mathfrak p_1^{e_1} \cdots \mathfrak p_r^{e_r}$ be the factorisation of $f$ in $\mathcal O_K$. Let $S = \{\mathfrak p_1, \ldots, \mathfrak p_r\}$. Then we have
$$\mathcal O_{K,S}^\times = (M^{-1}\mathcal O_K)^\times.$$
Indeed, if $x$ is an $S$-unit, then $v_\mathfrak p(x) = 0$ for $\mathfrak p \not\in S$. Thus, in the unique (rational) factorisation of $x$, there are only primes of $S$ occurring with nonzero exponent. Multiplying the denominator if necessary, we may assume the denominator is a power of $f$, proving
$$\mathcal O_{K,S}^\times \subseteq (M^{-1}\mathcal O_K)^\times.$$
Conversely, for an element $x \in (M^{-1}\mathcal O_K)^\times$, we can write both $x$ and $y = x^{-1}$ as an element of the form $\frac{a}{f^n}$, where $a \in \mathcal O_K$. Thus, for $\mathfrak p \not\in S$, we get
$$v_{\mathfrak p}(x) = v_{\mathfrak p}(a) - n v_{\mathfrak p}(f) = v_{\mathfrak p}(a) \geq 0,$$
because $\mathfrak p$ does not occur in the factorisation of $f$. Similarly, $v_\mathfrak p(y) \geq 0$, so in fact both valuations have to equal $0$. This proves our claim. Now you can use the $S$-unit theorem to deduce finite generation of $(M^{-1}\mathcal O_K)^\times$.
Remark. If we start with a finite set $S$, we could hope to write the $S$-units as the invertible elements in $(\mathcal O_K)_f$ for some $f$. However, the product $\mathfrak p_1 \cdots \mathfrak p_r$ might not be a principal ideal, so we cannot run the above argument backwards. However, by finiteness of the class group, some power of it is principal, so we can choose $f$ such that $f\mathcal O_K = \mathfrak p_1^n \cdots \mathfrak p_r^n$ for some $n$, and the above argument shows that
$$(M^{-1}\mathcal O_K)^\times = \mathcal O_{K,S}^\times.$$
This ties in to your remark about the non-PID case.
Remark. The canonical (choice-independent) way of thinking about this localisation is that it is given by the multiplicative set $M$ consisting of elements whose prime factorisation only involves primes in $S$. The above shows that this localisation can actually be realised by inverting a single element.
