TITLE: If $\operatorname{Spec} A$ is not connected then there is a nontrivial idempotent
QUESTION [39 upvotes]: I'm solving a problem from Atiyah-Macdonald.

I have to show that if $X=\operatorname{Spec} A$ is not connected then $A$ contains idempotents $e \neq 0,1$.

The converse is easy. If $e \in A$ is an idempotent then $(e)+(1-e)=(1)$ and $(e)\cdot(1-e)=0$ so that
$$
  V(e) \cup V(1-e) = V(  (e) \cdot(1-e))=V(0) = X, \\
  V(e) \cap V(1-e) = V( (e)+(1-e))=V(1)=\varnothing
$$
then $V(e)$ and $V(1-e)$ are both closed and open and $X$ is not connected.
Now let $\mathfrak{a}$ and $\mathfrak{b}$ be ideals in $A$ such that $V(\mathfrak{a}) \cup V(\mathfrak{b})=X$, $V(\mathfrak{a}) \cap V(\mathfrak{b}) = \varnothing$. Then
$$
   V(\mathfrak{a}) \cup V(\mathfrak{b}) = V( \mathfrak{a} \cap \mathfrak{b} ) = X,
$$
i.e. $\left\{ \mathfrak{p} - \text{prime} \mid \mathfrak{a} \cap \mathfrak{b} \subseteq \mathfrak{p}  \right\} = X$, i.e. $\mathfrak{a} \cap \mathfrak{b} \subseteq \cap \mathfrak{p} = \mathfrak{n}$ (nilradical). On the other hand since
$$
  V(\mathfrak{a}) \cap V(\mathfrak{b}) = V(\mathfrak{a}+\mathfrak{b})=\varnothing
$$
we have $\left\{ \mathfrak{p} - \text{prime} \mid \mathfrak{a}+\mathfrak{b} \subseteq \mathfrak{p} \right\} = \varnothing$. Then $\mathfrak{a}+\mathfrak{b}=(1)$ because any ideal that is not equal to $(1)$ is contained in some maximal ideal. Then $\mathfrak{a}$ and $\mathfrak{b}$ are comprime and $\mathfrak{a} \cdot \mathfrak{b} = \mathfrak{a} \cap \mathfrak{b}$. So I have two ideals $\mathfrak{a}$ and $\mathfrak{b}$ with properties
$$
   \mathfrak{a} + \mathfrak{b} = (1), \\
   \mathfrak{a} \cdot \mathfrak{b} = \mathfrak{a} \cap \mathfrak{b} = \mathfrak{n}.
$$
I don't see any way to obtain a nontrivial idempotent $e \in A$ here. Please help me.

REPLY [3 votes]: If $X={\rm Spec} A$ is the disjoint union of nonempty (cl)open subsets $X_1$ and $X_2$, then since ${\scr O}_X$ is a sheaf of rings, the ring homomorphism $\varphi:A={\scr O}_X(X)\to{\scr O}_X(X_1)\times{\scr O}_X(X_2)$ is an isomorphism. For $i=1,2$, we have $0\neq1$ in ${\scr O}_X(X_i)$, since for $x_i\in X_i$, ${\scr O}_X(X)\to{\scr O}_{X,x_i}$ factors through ${\scr O}_X(X_i)$ and $0\neq1$ in ${\scr O}_{X,x_i}$. Therefore $\varphi^{-1}((1,0))$ and $\varphi^{-1}((0,1))$ are nontrivial idempotents in $A$.