TITLE: Bijection between homomorphisms of rings
QUESTION [5 upvotes]: I am trying to show there exists a bijection of sets,
$$\hom \left( \prod_{i\in I} R_i, S\right) \to \coprod_{i\in I} \hom(R_i, S)$$
where $R_i$ are commutative rings, $S$ is a ring with no non-trivial idempotents, and $I$ is a finite set. My initial idea was the obvious but mistaken, $f \mapsto f_i = f \circ \alpha_i$ where $\alpha_i:R_i \to \prod_{j\in I} R_j$ is the naive inclusion, but this fails since $\alpha_i$ is not a homomorphism.
I am unsure of the relevance of $S$ having no idempotents. I know that I have idempotents in $\prod_{i\in I} R_i$ which correspond to $e_j$ which is $(0,\dots,1,\dots,0)$ where $1$ is at the $j$th position, and that these satisfy $e_i e_j =0$ for $i\neq j$ and $\sum_j e_j=1$.
I also know idempotents map to idempotents, so this implies for any $f \in \hom(\prod_{i\in I}R_i, S)$ that $f(e_j)$ must be $0$ or $1$. Moreover we have that, $\sum_j f(e_j) = 1$. I believe $f$ can be $1$ for only one $e_j$ and zero for all others, but I cannot prove this without assuming $S$ has characteristic zero. So there is not much I can say about $\hom(\prod_{i\in I}R_i, S)$.
I also had the idea to try formulating the bijection first the other way around, so for $f_i : R_i \to S$, to try $f_i \mapsto f$, where here $f(r_1,\dots,r_n) = f_1(r_1) + \cdots + f_n(r_n)$ (let's say $I = \{1,\dots,n\}$).
Any help would be appreciated, I am guessing the key must be something about using the idempotents of the product ring. I also believe it can be written as $\prod_{i\in I} R_i = e_1(\prod_{i\in I} R_i) + \cdots + e_n(\prod_{i\in I} R_i)$ but I do not see if this is helpful either.

REPLY [4 votes]: As a general remark, when working with a product, you do not want to use functions $R_i\to \prod_i R_i$ (which as you noted will not give anything useful), but rather the projections $\pi_i: \prod_i R_i\to R_i$. Using those, we can at least associate to every $f: R_i\to S$ some $f':\prod_i R_i\to S$ by $f'=f\circ \pi_i$. (It is similar to what you were first trying to do, but in the correct direction.)
This defines a natural function $\coprod_i \operatorname{hom}(R_i,S)\to \operatorname{hom}(\prod_i R_i,S)$, and we want to check that it is a bijection. I'll let you check that injectivity is easy, and we just need to prove surjectivity. In other words, any morphism $\prod_i R_i\to S$ is obtained by first applying a projection to some $R_i$. This amounts as in your analysis to the fact that exactly one $e_i$ is sent to $1$ and the others are sent to $0$.
First let us make sure that the hypothesis on $S$ is not useless. If $R=\mathbb{Z}$ and $S=\mathbb{Z}\times \mathbb{Z}$, then the identity morphism $R\times R\to S$ is not in the image of the above function, since it cannot be defined by first applying a projection. And indeed $S$ has nontrivial idempotents.
Now assume $S$ has no nontrivial idempotent. As you already noted, $f(e_i)$ must be $1$ or $0$, and we want to show that it is $0$ except for one $i$. If $f(e_i)=f(e_j)=1$ for $i\neq j$, then $f(e_i+e_j)=2\in S$, but $e_i+e_j$ is an idempotent because $e_i$ and $e_j$ are orthogonal, so $f(e_i+e_j)$ must be $0$ or $1$. If it is $1$, it means that $S$ is the zero ring. The question of whether your result is true for the zero ring depends on what is meant by "having no nontrivial idempotent". I would argue that the zero ring has no nontrivial idempotent, and is a counterexample since $\operatorname{hom}(\prod_i R_i,S)$ has $1$ element while $\coprod_i \operatorname{hom}(R_i,S)$ has as many elements as $I$. So I would reformulate the hypothesis to "$S$ has exactly two idempotents".
Let us assume that $S$ is not the zero ring, so $f(e_i+e_j)=0$. This means that $S$ must have characteristic $2$. But then $f(e_i)\dot f(e_i+e_j)=1\cdot 0=0$, while $f(e_i(e_i+e_j))=f(e_i^2=e_ie_j)=f(e_i)=1$: this is a contradiction.
In the end there is exactly one $i$ such that $f(e_i)=1$.

As a bonus, a geometric interpretation (if you don't know any algebraic geometry you can safely ignore this): a ring having no nontrivial idempotent amounts to saying it (or at least its spectrum) is connected. So basically your question can be rephrased as "if $Y=\coprod_i Y_i$ and $X$ is connected, there is a bijection between maps $X\to Y$ and the disjoint union of maps $X\to Y_i$", and this is somewhat clear since the image of $X$ has to be connected. Also, this becomes false when $X$ is empty, which corresponds to the counterexample of the zero ring.