= Affine gluing along closed subschemes
{title2=$R=A\times_CB$}
Suppose a scheme is the scheme-theoretic union of affine closed subschemes $Y=\operatorname{Spec}A$ and $Z=\operatorname{Spec}B$, meaning their ideal sheaves have zero intersection. The intersection $W$ is closed in both, hence affine with coordinate ring $C$ and surjections $A\to C$, $B\to C$. Then the whole scheme is $\operatorname{Spec}(A\times_CB)$. Both projections of this fiber product are surjective; their kernels have zero intersection and product, and their quotient by the sum is $C$. Thus its spectrum has the same closed pieces, intersection and topology. The structure sheaf is the kernel of $i_*\mathcal O_Y\oplus j_*\mathcal O_Z\to k_*\mathcal O_W$ on both spaces, identifying their locally ringed structures. A reduced Noetherian scheme has finitely many irreducible components, so induction proves it is affine if and only if its reduced irreducible components are affine. The intersection $W$ need not be reduced.
Back to article page