The answer of Manos can be generalized to a characterization (references at the end):
Let $R,S$ be rings (not necessarily with identity element). Consider the product $R\times S$. We say that an ideal of the product is a subproduct ideal if it is of the form $I\times J$ with $I$ ideal of $R$, $J$ ideal of $S$. Now fix $R$. The following assertions are equivalent:
- For all rings $S$, the ideals of $R\times S$ are subproduct ideals.
- The ideals of $R\times R$ are subproduct ideals.
- $R$ is a (two-sided) $e$-ring, that is, for every element $r\in R$ we have $r\in Rr+rR+RrR$.
(Observe that $Rr+rR+RrR$ may fell short of being the ideal generated by $r$, as it doesn't necessarily include $\mathbb{Z}r$).
Let us prove the theorem:
3)$\Rightarrow$1) This is essentially Manos' proof. Given $I$ ideal of $R\times S$, we define
$$I_R:=\{r\in R \ | \ \exists s\in S, (r,s)\in I\}, \ I_S:=\{s\in S \ | \ \exists r\in R, (r,s)\in I\}.$$
That $I\subseteq I_R\times I_S$ is straightforward. Pick $(r,s)\in I_R\times I_S$. Then there are $r'\in R$, $s'\in S$ such that $(r,s'),(r',s)\in I$. By hypothesis we know that there exist $a,b,u_i,v_i\in R$ such that $r=ar+rb+\sum_iu_irv_i$. Since $I$ is an ideal, $(ar,0)=(a,0)(r,s')$, $(rb,0)=(r,s')(b,0)$ and $(u_irv_i,0)=(u_i,0)(r,s')(v_i,0)$ are in $I$, and this implies $(r,0)\in I$. Similarly $(r',0)\in I$, and thus $(r,s)=(r-r',0)+(r',s)\in I$. Therefore $I=I_R\times I_S$.
1)$\Rightarrow$2) Trivial.
2)$\Rightarrow$3) Pick $r\in R$ and consider the ideal $I$ generated by $(r,r)$ in $R\times R$. By hypothesis we have $I=J\times K$, with $J,K$ ideals of $R$. Since $(r,r)\in J\times K$ we have $(r,0)\in J\times K=I=$Id$(r,r)$, what means that there exist $z\in\mathbb{Z}$, $a_1,a_2,b_1,b_2,u_i,v_i,x_i,y_i\in R$ such that
$$r=zr+a_1r+rb_1+\sum_iu_irv_i, \ 0=zr+a_2r+rb_2+\sum_ix_iry_i.$$
The key here is that $z$ is the same in both equations, so we can equate by $zr$ to get $r=(a_1-a_2)r+r(b_1-b_2)+\sum_i c_ird_i\in Rr+rR+RrR$.
EDITED: Of course, rings with identity are $e$-rings. Another interesting class of $e$-rings is that of von Neumann regular rings.
Observe that we have a similar (less convoluted, more restrictive) version for one-sided ideals:
- For all rings $S$, the left (resp. right) ideals of $R\times S$ are a subproduct of left (resp. right) ideals.
- The left (resp. right) ideals of $R\times R$ are a subproduct of left (resp. right) ideals.
- $R$ is a left (resp. right) $e$-ring, that is, for every element $r\in R$ exists a "local unit" $e_r\in R$ such that $e_r\cdot r=r$ (resp. $r\cdot e_r=r$).
The proof is analogous.
The "e-ring" and "subproduct" denotations, results and proofs are taken from (anyone of)
- Commutative rngs. Anderson (2006). Proposition 3.1.
- Ideals in direct products of commutative rings. Anderson, Kintzinger (2008). Theorem 2.
- Subgroups of direct products of groups, ideals and subrings of direct products of rings, and Goursat's lemma. Anderson, Camillo (2009). Theorem 10.
Note that references 1) and 3) are to papers published in books. Reference 3) is really interesting, since it determines all ideals (and subrings!) of a direct product of two rings, for any two rings (theorem 11).