# Are all subrings of the rationals Euclidean domains?

This is a purely recreational question -- I came up with it when setting an undergraduate example sheet.

Let's go with Wikipedia's definition of a Euclidean domain. So an ID $R$ is a Euclidean domain (ED) if there's some $\phi:R\backslash\{0\}\to\mathbf{Z}_{\geq0}$ or possibly $\mathbf{Z}_{>0}$ (I never know what $\mathbf{N}$ means, and the Wikipedia page (at the time of writing) uses $\mathbf{N}$ as the target of $\phi$, but in this case it doesn't matter, because I can just add one to $\phi$ if necessary) such that the usual axioms hold.

Now onto subrings of the rationals. The subrings of the rationals turn out to be in bijection with the subsets of the prime numbers. If $X$ is a set of primes, then define $\mathbf{Z}_X$ to be the rationals $a/b$ with $b$ only divisible by primes in $X$. Different sets $X$ give different subrings, and all subrings are of this form. This needs a little proof, but a little thought, or a little googling, leads you there.

If $X$ is empty, then $\mathbf{Z}_X=\mathbf{Z}$, which is an ED: the usual $\phi$ taken is $\phi(x)=|x|$.

If $X$ is all the primes then $\mathbf{Z}_X=\mathbf{Q}$ and this is an ED too (at least according to Wikipedia -- I think some sources demand that an ED is not a field, but let's not go there); we can just let $\phi$ be constant.

If $X$ is all but one prime, say $p$, then $\mathbf{Z}_X$ is the localisation of $\mathbf{Z}$ at $(p)$, and $\phi$ can be taken to be the $p$-adic valuation (if we're allowing $\phi$ to take the value zero, which we may as well). Note however that this is a rather different "style" of $\phi$ to the case $X$ empty: this $\phi$ is "non-archimedean" in origin, whereas in the case of $X$ empty we used an "archimedean" $\phi$. This sort of trick generalises to the case where $X$ is all but a finite set of primes -- see the "Dedekind domain with only finitely many non-zero primes" example on the Wikipedia page.

Of course the question is: if $X$ is now an arbitrary set of primes, is $\mathbf{Z}_X$ an ED?

-
What happens when $X$ is finite? In particular, when $X=\{2\}$ and $X=\{2,3\}$. –  lhf Jan 6 '12 at 14:53
I think that in general one strategy for constructing $\phi$, for any ID, is this: you let $A_0$ be zero, you let $A_1$ be the units, and for $n\geq2$ you let $A_n$ be the elements $r$ of $R$ not in any earlier $A_i$ but such that the map $\cup_{j<i}A_j\to R/(r)$ is surjective. The idea is that $\phi(r)=i$ for $r\in A_i$ and you hope that the union of the $A_i$ is $R$: you've then proved $R$ is an ED, and I think that what I sketch here is basically an iff. –  Kevin Buzzard Jan 6 '12 at 15:24
So if $X=\{2\}$ then $A_2$ contains (amongst other things) the primes such that 2 is a primitive root, and then $A_3$ contains (amongst other things) the primes such that either 2 or one of these primes in $A_2$ is a primitive root and etc etc. And then you just have to hope that you get everything shrug. –  Kevin Buzzard Jan 6 '12 at 15:24
Given Alex's (very nice, +1) answer below, I wonder if you can follow-up to ask for a more "coherent" system of $\phi_X$'s such that $\phi_X$ agrees with the $p$-adic valuation when $X$ is the complement of a prime, and/or that $\phi_X$ behaves nicely with respect to shrinking/enlarging $X$. –  Cam McLeman Jan 6 '12 at 17:11

Yes. Let $\phi(a/b) = |a|$ where $a/b$ is written in lowest terms. To see that this is a Euclidean function, let $a/b,c/d\in \mathbb{Z}_X$ be nonzero and in lowest terms and write $$\frac{a}{b}=\frac{nd}{b}\cdot \frac{c}{d}+\frac{s}{t}$$ which means that $\phi(s/t)=\phi((a-nc)/b)\leq |a-nc|$ which for a suitable value of $n$ is less than $\phi(a/b) = |a|$.
Very nice. Note that you implicitly use the fact that if $a/b$ is in the subring then so is $m/b$ for any integer $m$. I wonder if you've proved that any subring of the field of fractions of an ED is an ED?? –  Kevin Buzzard Jan 6 '12 at 16:07
PS I now see that my mistake was to be too hung up on the $p$-adic side of the story. –  Kevin Buzzard Jan 6 '12 at 16:08