I was recently reading this excerpt from Mumford's Red Book. It concerns showing that every closed subscheme of an affine scheme $\text{Spec }R$ is determined by an ideal $R$. The individual steps themselves don't seem too hard, but once I realized what he was actually proving I became very confused. He defines the inclusion morphism $f: Y \longrightarrow \text{Spec }R$ where $Y$ is a closed subscheme of $\text{Spec }R$. He then proves, in the second paragraph of the excerpt I linked above, that $f$ is surjective. I originally thought this was a typo, but it seems to be the genuine conclusion of his argument. How is this possibly? How is the inclusion of a closed subscheme of an affine scheme surjective? That would mean that every closed subscheme of an affine scheme is homeomorphic to the whole affine scheme itself. That surely can't be the case, can it? It seems that either it is a mistake, or I have hugely misunderstood something. Knowing me, it's the latter.
Note also for those not familiar with the older terminology, Mumford uses the term "prescheme" in the same way modern authors use the term "scheme", and reserves that term for those preschemes which are separated.
$\DeclareMathOperator{\Spec}{Spec}$ The morphism $f: Y \rightarrow X$ is a closed subscheme of $X = \Spec R$. This means that the underlying space of $Y$ is a closed subset of $X$, the underlying map of $f$ is inclusion, and $f^{\#}: \mathcal O_X \rightarrow f_{\ast} \mathcal O_Y$ is a surjective morphism of sheaves. In Mumford's notation, $\mathcal Q$ is the kernel of the morphism $f^{\#}$; it is a sheaf of ideals of $\mathcal O_X$.
In particular, $A := \mathcal Q(X)$ is the kernel of the ring homomorphism $f^{\#}(X)$ going from $\mathcal O_X(X) = R$ to $f_{\ast}\mathcal O_Y(X) = \mathcal O_Y(Y)$. So by the first isomorphism theorem, there exists a unique ring homomorphism $\phi: R/A \rightarrow \mathcal O_Y(Y)$ such that $\phi \circ \pi = f^{\#}(X)$. It is injective.
A homomorphism from a ring into the global section of a scheme, corresponds bijectively to a morphism from that scheme to the spectrum of the ring. Therefore, the morphism of schemes $g: Y \rightarrow \textrm{Spec}(R/A)$ corresponding to the ring homomorphism $\phi$, is the unique morphism of schemes such that $i \circ g = f$, where $i: \textrm{Spec}(R/A) \rightarrow X$ is the morphism of schemes corresponding to $\pi$.
Mumford wants to show that $g$ is an isomorphism of schemes. In particular, $Y$ will be affine, and the morphism $g$ will basically be the morphism coming from the projection onto a quotient ring. There are two things you can check about $g$:
Thus $\textrm{Spec}(R/A)$ becomes your new $X$, and $g$ becomes your new $f$, and you have reduced to showing that $f$ is an isomorphism of schemes in the special case where the map on global sections is injective.