Uniqueness of ring product Sorry for my bad English.
Let $A_1,\dots,A_n,B_1,\dots,B_m$ be commutative integral domains.
We assume $A_1\times \cdots A_n\cong B_1\times \cdots \times B_m$.
Now, is  the following correct?
$n=m$ and there is  $\sigma\in S_n$ such that $A_i\cong B_{\sigma(i)}$?
We have no idea this is correct or false, help me thanks.
 A: It's true under the slightly weaker assumption that each of the $A_i$ and $B_i$ have no nontrivial idempotents; a commutative ring $R$ satisfying this property is called connected, because it's equivalent to $\text{Spec } R$ being connected in the Zariski topology. Conceptually the idea is that, if we write $R = \prod A_i \cong \prod B_i$, then $\text{Spec } A_i, \text{Spec } B_i$ must be two lists of the connected components of $\text{Spec } R$ (as an affine scheme), so must be the same up to permutation.
I mention all this by way of motivation; it's possible to give a completely elementary proof in terms of idempotents without knowing any algebraic geometry (although I find it a little unmotivated without the geometric picture), as follows. Let $e = \prod A_i$ be an idempotent. The condition $e^2 = e$ gives that each component of $e$ is either $0$ or $1$, so $\prod_{i=1}^n A_i$ has exactly $2^n$ idempotents; this already gives $n = m$.
A nonzero idempotent is primitive if it can't be written as the sum of two other nonzero idempotents. The primitive idempotents of $\prod A_i$ are exactly those equal to $1$ in exactly one index and equal to $0$ otherwise, and an isomorphism $\prod A_i \cong \prod B_i$ sends primitive idempotents to primitive idempotents. Given an idempotent $e$ in a commutative ring $R$ we can consider the quotient of $R$ by $1 - e$, which can naturally be identified with $eR$; the quotients corresponding to primitive idempotents in $\prod A_i$ recover each of the factor rings $A_i$, so an isomorphism $\prod A_i \cong \prod B_i$ sends each $A_i$ to some $B_{\sigma(i)}$ as desired.
