Is there a commutative ring $R$ with $R \cong R[X,Y]$ and $R \not\cong R[X]$?


This is a ring-theoretic analog of my [previous question](https://mathoverflow.net/questions/218113/a-is-isomorphic-to-a-oplus-mathbbz2-but-not-to-a-oplus-mathbbz) about abelian groups: In fact, in any algebraic category we may ask if $A \cong A + Z + Z \Longrightarrow A \cong A+Z$ holds, where $Z$ is the free structure on one generator, and $+$ is the coproduct.


The question is similar to the Zariski Cancellation Problem from affine algebraic geometry, but not identical with it. As for the question, we may also work in the category of commutative $k$-algebras for some field $k$. Notice that $0$ is the only noetherian commutative ring with $R \cong R[X,Y]$, so that examples will be non-noetherian.



$R$ is isomorphic to $R[X,Y]$, but not to $R[X]$
The answer to this quite beautiful question is that there *does exist* a commutative ring $R$ with $R\cong R[X,Y]$ but $R\not\cong R[X]$.


Let $F$ be a field, and take
$$
R=F[x\_i,y\_i,r\_i\ (i\geq 0)]
$$
subject to the relations
$$
\forall\ i\geq 0,\ r\_i=x\_i y\_i(x\_i+y\_i^2)(x\_i+y\_i^3)(x\_i+y\_{i+1}^4)r\_{i+1}.
$$


**First**, note that the relations allow us to remove $r\_0$ (or more generally, any finite number of the $r\_i$) from the list of generators for $R$, and hence
$$
R=(F[x\_i,y\_i,r\_i\ (i\geq 1)])[x\_0,y\_0]\cong R[X,Y]
$$
where the isomorphism comes from the fact that the relations are unchanged after shifting all of the indices.


**Second**, by direct inspection we see that if $s$ and $t$ are irreducible factors of $r\_0$ such that $s+t^2$ and $s+t^3$ are also irreducible factors of $r\_0$, then $s=x\_i$ and $t=y\_i$ for some $i\geq 0$. (Note that if we changed the relations by dropping the factor $x\_i+y\_i^3$, we would only have this fact up to associates. By having the two irreducibles $x\_i+y\_i^2$ and $x\_i+y\_i^3$ simultaneously, we don't need to worry about unit multiples. There might be a more clever way to deal with this minor issue. One could also work over $\mathbb{F}\_2$ to avoid unnecessary units.)


**Third**, the relations are homogeneous in the $r$-letters. I claim that this will show that an element of $R$ has infinitely many non-associate irreducible factors if and only if it belongs to the ideal $I=(r\_0,r\_1,r\_2,\ldots)$. Let $a\in R$ be arbitrary. After using the relations, we may write $a$ as a polynomial in $r\_m$ with coefficients in $F[x\_0,y\_0,\ldots, x\_m,y\_m]$ (for $m$ sufficiently large). Note that if we use the relations in any way (such as by increasing $m$ further), the $r$-degree doesn't change, and the constant term of the polynomial also remains unchanged. However, it is easy to see that if we factor $a$ into irreducible factors, the number of those factors is bounded above by the $r$-degree of $a$ plus the number of irreducible factors of the constant term (which are both invariants of the relations). This number is infinite if and only if the constant term is zero (i.e., $a\in I$), and of course conversely if $a\in I$ then it has infinitely many non-associate irrreducible factors.


**Fourth**, assume by way of contradiction there is an isomorphism $\varphi:R[z]\to R$. Since the set of elements with infinitely many non-associate irreducible factors is an invariant of isomorphisms, and since the third fact above also holds for $R[z]$, we see that the preimage of $r\_0$ under $\varphi$ must belong to the ideal generated by $(r\_0,r\_1,r\_2,\ldots)$ in $R[z]$. Thus, there is some element $b\in R[z]$ and some $k\geq 0$ so that $\varphi(r\_k b)=r\_0$. Thus $\varphi(x\_k),\varphi(y\_k),\varphi(x\_k)+\varphi(y\_k)^2,\varphi(x\_k)+\varphi(y\_k)^3$ are all irreducible factors of $r\_0$, and so by the second fact above we must have $\varphi(x\_k)=x\_{\ell}$ and $\varphi(y\_k)=y\_{\ell}$ for some $\ell\geq 0$. The same result also holds for $\varphi(x\_{k+1}),\varphi(y\_{k+1})$, but since $\varphi(x\_k)+\varphi(y\_{k+1})^4=x\_{\ell}+\varphi(y\_{k+1})^{4}$ is also an irreducible factor of $r\_0$, we must have $\varphi(x\_{k+1})=x\_{\ell+1}$ and $\varphi(y\_{k+1})=y\_{\ell+1}$. Repeating the argument, we have $\varphi(x\_{k+i})=x\_{\ell+i}$ and $\varphi(y\_{k+i})=y\_{\ell+i}$ for all $i\geq 0$.


Let $J=(x\_k,y\_k,x\_{k+1},y\_{k+1},\ldots)$ be the ideal of $R[z]$ generated by the "tail" end of the $x$ and $y$ letters. Then $\varphi(J)=(x\_{\ell},y\_{\ell},x\_{\ell+1},y\_{\ell+1},\ldots)$. Thus, the isomorphism $\varphi$ induces an isomorphism
$$
R[z]/J\cong R/\varphi(J).
$$
The factor ring on the left is isomorphic to $F[z,x\_0,y\_0,x\_1,y\_1,\ldots, x\_{k-1},y\_{k-1}]$ which has odd dimension. The factor ring on the right is isomorphic to $F[x\_0,y\_0,\ldots, x\_{\ell-1},y\_{\ell-1}]$ which has even dimension. This gives us the necessary contradiction.


An easy modification of this construction will also show that for each modulus $m\geq 2$, there exists a ring $R\_m$ such that $R\_m[X\_1,X\_2,\ldots, X\_p]\cong R\_m[X\_1,X\_2,\ldots, X\_q]$ if and only if $p\equiv q\pmod{m}$.


Edited to add: Taking the same ring but using non-commuting letters should answer the same question for noncommutative rings.


