TITLE: Non-isomorphic rings that are localizations of each other
QUESTION [17 upvotes]: Do there exist commutative rings $A$ and $B$ and multiplicative subsets $S\subseteq A$, $T\subseteq B$ such that $A\not\simeq B$ but $S^{-1}A \simeq B$ and $T^{-1} B\simeq A$?

This question comes from a deleted claim in an answer of Qiaochu Yuan. The original claim says that (the proper class of isomorphism classes of) commutative rings equipped with the relation $A\ge B$ iff $B$ is a localization of $A$ is a (large) poset. The claim is clearly equivalent to the negative answer to the question. However, I do not find any reason that such examples do not exist; neither can I construct an example.

REPLY [37 votes]: Example. Let $k$ be a field, and let $K = k(x_1,x_2,\ldots)$ be the fraction field of $k[x_1,x_2,\ldots]$. Let
$$A = K[y_1,y_2,\ldots],$$
and
$$B = A[y_1^{-1}].$$
Then $B$ is a localisation of $A$. If we further localise at the multiplicative set $S = K[y_1]\setminus\{0\} \subseteq B$, we get a ring that is isomorphic to $A$ by shifting all the indices by $1$:
\begin{align*}
S^{-1} B &\stackrel\sim\longrightarrow A\\
x_i &\longmapsto x_{i+1},\\
y_i &\longmapsto \left\{\begin{array}{ll}x_1 & \text{if } i = 1,\\ y_{i-1} & \text{if } i > 1.\end{array}\right.\\
\end{align*}
To see that $A$ and $B$ are not isomorphic (even as rings), note that the set $A^\times \cup \{0\}$ is closed under addition, and the same is not true in $B$. $\square$

Remark. There are no examples of finite presentation (in a ridiculously general setting):

Lemma. Let $R$ be a ring, and assume $A$ and $B$ are $R$-algebras of finite presentation. Assume there exist multiplicative sets $S \subseteq A$ and $T \subseteq B$ and $R$-linear isomorphisms
  \begin{align*}
 S^{-1}A \stackrel\sim\longrightarrow B, & & T^{-1}B \stackrel\sim\longrightarrow A.
\end{align*}
  Then $A$ and $B$ are isomorphic (as $R$-algebras).

Proof. Consider the composite map $\phi \colon A \to A$ obtained by
$$A \to S^{-1} A \stackrel\sim\to B \to T^{-1}B \stackrel\sim\to A.$$
Note that this map is the localisation at the inverse image of $ST \subseteq B$ in $A$. To avoid confusion, denote the codomain of $\phi$ by $A'$. Since the natural map
$$A' \otimes_A A' \to A'$$
is an isomorphism (this is always true for localisations), we conclude that the map
$$\phi^* \colon \operatorname{Spec} A \to \operatorname{Spec A}$$
induced by $\phi$ is a monomorphism. By EGA IV$_4$, Proposition 17.9.6 (you can think of this as a fancy version of the Ax-Grothendieck theorem), this implies that $\phi^*$ is an automorphism, so $\phi$ is an isomorphism. But a localisation that is an isomorphism is the identity (i.e. $ST$ consists of units of $A$). Then $S$ contains only units of $A$, so $S^{-1}A = A$. $\square$
Remark. We actually only used that one of them was of finite presentation.
Remark. One may object that the example above is not $K$-linear (and therefore it violates two of the assumptions of the lemma). However, it is $k$-linear (or $\mathbb Z$-linear...), so in that sense it only violates the finite presentation assumption.