Epimorphisms in the category of separated schemes So I recently learned that in the category of Hausdorff topological spaces, the epimorphisms are precisely the dominant continuous maps (i.e those whose image is dense in the target space). Since requiring that a scheme be separated is intuitively similar to Hausdorffness, I was wondering if a similar result carries over. Are the epimorphisms in the category of separated schemes precisely those which are dominant? I should say that by separated here I mean just over $\text{spec} \mathbb{Z}$, although I expect that if it holds it should over any base. 
 A: This is false.  For instance, let $k$ be any nonzero ring, let $X=\operatorname{Spec} k$ and $Y=\operatorname{Spec} k[x]/(x^2)$.  Let $f:Y\to X$ be dual to the inclusion $k\to k[x]/(x^2)$ and $g:X\to Y$ be dual to the map which sends $x$ to $0$.  Then $g$ is dominant (in fact, surjective), but $g$ is not an epimorphism, since $gfg=g$ but $gf\neq 1_Y$.
For a counterexample to the other implication, let $k$ be a field, $X=\bigsqcup_n \operatorname{Spec}k[x]/(x^n)$ and $Y=\operatorname{Spec}k[x]$, and let $f:X\to Y$ be the morphism given by the quotient maps $k[x]\to k[x]/(x^n)$.  Then $f$ is not dominant: its image contains only the point where $x=0$.  However, $f$ is an epimorphism.  To prove this,  let $g:\operatorname{Spec} k[[x]]\to Y$ be dual to the inclusion $k[x]\to k[[x]]$.  Note that if $hf=if$ for morphisms $h,i:Y\to Z$, then $hg=ig$ as well, since $k[[x]]$ is the inverse limit of the rings $k[x]/(x^n)$.  But since the inclusion $k[x]\to k[[x]]$ is injective, $hg=ig$ implies $h=i$.

However, it is true if you require your schemes to be both separated and reduced.  First, if $f:X\to Y$ is a dominant morphism of separated reduced schemes, then $f$ is an epimorphism.  Indeed, suppose $g,h:Y\to Z$ are such that $gf=hf$.  Since $Z$ is separated, the diagonal $\Delta:Z\to Z\times Z$ is a closed immersion.  The pullback of $\Delta$ by $(g,h):Y\to Z\times Z$ is then a closed subscheme $D$ of $Y$, and $f$ factors through this closed subscheme.  Since $f$ is dominant, this means $D$ is dense in $Y$ and hence contains all the points of $Y$ since it is closed.  Since $Y$ is reduced, this means $D=Y$, and so $g=h$.
Conversely, suppose $f:X\to Y$ is not dominant; let $K\subset Y$ be the closure of the image of $f$.  Since $X$ is reduced, $f$ factors through the inclusion $i:K\to Y$ when we give $K$ the reduced subscheme structure.
We can now form a scheme $Z=Y\sqcup_K Y$.  Explicitly, for each affine open subset $\operatorname{Spec} A$ of $Y$, let $I$ be the ideal in $A$ corresponding to $K$, and let $A'=A\times_{A/I} A$, the ring of pairs $(a,b)\in A\times A$ which such that $a=b$ mod $I$.  It is easy to see that we can then glue the affine schemes $\operatorname{Spec} A'$ the same way the affine schemes $\operatorname{Spec} A$ are glued to form $Y$ to get a scheme $Z$, which is the pushout of two copies of the inclusion $i:K\to Y$.  There is a canonical "fold" map $Z\to Y$ induced by the diagonal $A\to A'$ on each affine open, which is an affine morphism by construction of $Z$.  In particular, $Z$ is separated over $Y$ and hence separated.  Also each $A'$ is a reduced ring since each $A$ is a reduced ring, so $Z$ is reduced.
Now observe that we have two morphisms $g,h:Y\to Z$ corresponding to the two projections $A'\to A$.  Since $K$ is not all of $Y$, there exists an affine open $\operatorname{Spec} A$ for which $I$ is nonzero.  For such an $A$, the ring $A'$ is strictly larger than the diagonal subring of $A\times A$, so the two projections $A'\to A$ are distinct maps.  Thus $g\neq h$.  However, $gi=hi$, so $gf=hf$ since $f$ factors through $i$.  Thus $f$ is not an epimorphism.
