TITLE: Hartshorne, exercise II.2.18: a ring morphism is surjective if it induces a homeomorphism into a closed subset, and the sheaf map is surjective
QUESTION [6 upvotes]: Let $\phi:A\to B$ be a ring morphism, and let $f:X=Spec(B)\to Y=Spec(A)$ be the induced map of affine schemes.
I'm trying to show that if $f$ is a homeomorphism onto a closed subset of $Y$ and $f^\#:\mathcal{O}_Y\to f_*(\mathcal{O}_X)$ is surjective, then $\phi$ is surjective.
Hartshorne suggests to factor the map through the quotient. So let $\pi:A\to A/ker \phi$ and $\tilde \phi:A/ker \phi\to B$ be the canonical maps.
$\tilde \phi$ induces a map $\tilde f:X\to Y'=Spec (A/ker\phi)$, and $\pi$ induces a map $g:Y'\to Y$.

My idea is: prove that $g_*\tilde f^\#$ is an isomorphism. Then, if we apply the global sections functor to it, we get $\tilde \phi$ which is then also an isomorphism.

First, $g_*\tilde f^\#$ is surjective, since $f^\#=g_*\tilde f^\# \circ g^\#$, and $f^\#$ is surjective by hypothesis.
Now, since $\tilde \phi$ is injective, we get get that $\tilde f^\#$ is injective (previous part of the exercise). The direct image functor $g_*$ is left exact (since it is the right adjoint to the inverse image functor $g^{-1}$), so $g_*\tilde f^\#$ is also injective.
Thus $g_*\tilde f^\#$ is an isomorphism.
Then $(g_*\tilde f^\#)_Y=\tilde f^\#_{Y'}=\tilde \phi$ is an isomorphism. QED

Something must be wrong with my argument since I didn't use the hypothesis that $f$ is an homeomorphism onto a closed subset of $Y$.

I've seen solutions online that do the following: prove that $\tilde f$ is an homeo, then somehow (not explicited) from surjectivity of $g_*\tilde f^\#$ we get surjectivity of $\tilde f^\#$. Then $\tilde f$ is an isomorphism of affine schemes, thus $\tilde \phi$ is an isomorphism of rings.

How do they deduce surjectivity of $\tilde f^\#$ from surjectivity of $g_*\tilde f^\#$?

REPLY [9 votes]: Your solution is correct. The hypothesis on the underlying map is superfluous, and actually follows from the surjectivity of the sheaf map. I remember being thrown off by this question for the same reason, last year. There are a few of those in Hartshorne; stay vigilant!
Here's another way to see this, if you want to familiarize yourself with this line of thought. Let $\mathcal I$ be the kernel of $f^\sharp$. Then we have the sequence of quasi-coherent sheaves on $Y$:
$$0 \to \mathcal I \to \mathcal O_Y \to f_* \mathcal O_X \to 0.$$
Since an affine scheme has no cohomology, we get an exact sequence
$$0 \to I \to A \to B \to 0,$$
so the map $A \to B$ is surjective.