Examples of surjective sheaf morphisms which are not surjective on sections Let $X$ be a topological space, and let $\mathscr{F}, \mathscr{G}$ be sheaves of sets on $X$. It is well-known that a morphism $\varphi : \mathscr{F} \to \mathscr{G}$ is epic (in the category of sheaves on $X$) if and only if the induced map of stalks $\varphi_P : \mathscr{F}_P \to \mathscr{G}_P$ is surjective for every point $P$ in $X$, but the section maps $\varphi_U : \mathscr{F}(U) \to \mathscr{G}(U)$ need not be surjective. I know of a couple of examples from complex analysis:


*

*Let $X$ be the punctured complex plane, $\mathscr{F}$ the sheaf of meromorphic functions, $\mathscr{G}$ the sheaf of differential $1$-forms, and $\varphi$ the differential map; then $\varphi$ is epic and indeed the sequence $0 \to \mathscr{F} \to \mathscr{G} \to 0$ is even exact, but there are global sections of $\mathscr{G}$ which are not the image of a global section of $\mathscr{F}$, e.g. $z \mapsto \frac{1}{z} \, \mathrm{d}z$. 

*Let $X$ be the punctured complex plane again, $\mathscr{F}$ the sheaf of meromorphic functions, $\mathscr{G}$ the sheaf of nowhere-zero meromorphic functions, and let $\varphi : \mathscr{F} \to \mathscr{G}$ be composition with $\exp : \mathbb{C} \to \mathbb{C}$; then $\varphi$ is epic but again fails to be surjective on (global) sections: after all, there is no holomorphic function $f : X \to \mathbb{C}$ such that $\exp f(z) = z$ for all non-zero $z$.
Question. Are there simpler examples which do not require much background knowledge beyond knowing the definition of sheaves and stalks?
 A: The statement that section maps are not always surjective for surjective map of sheaves is equivalent to non-exactness of the functor of global sections — or equivalently, to non-triviality of sheaf cohomology.
Now it's easy to construct any number of explicit examples. Say, take $X=S^1$, $\mathcal F$ to be the sheaf of $\mathbb R$-valied functions and $\mathcal G$ to be the sheaf of $\mathbb R/\mathbb Z\cong S^1$-valued functions. Locally the map is surjective, but $\operatorname{Coker}(\Gamma(\mathcal F)\to\Gamma(\mathcal G))$ is, of course, $H^1(S^1;\mathbb Z)=\mathbb Z$.
(Well, arguably, it's just an instance of the example Akhil gives: $\mathcal G$ can be identified with $\Omega^1(S^1)$ and the map with the de Rham differential. On the other hand, take any finite model of $S^1$ to get completely finite example.)
A: Ok, here is another answer. Let for $j$ an open immersion, $j_!$ be the "lower shriek" or "extension by zero" functor. Note that $j_!$ is left-adjoint to the functor $j^*$ of restriction from sheaves on $X$ to sheaves on $U$, and that there is a natural transformation $j_!j^* \to \mathrm{Id}$; note also that the stalks of $j_!$ of a sheaf are the same as the sheaf on $U$, and zero outside.
Then, if $\mathcal{F}$ is any locally constant sheaf on the irreducible space $X$, and $X = U_1 \cup U_2$ is a partition of $X$ into two proper open subsets with inclusions $j_1, j_2$, then the map $j_{1!}(j_1^*\mathcal{F}) \oplus j_{2!} (j_2^*\mathcal{F}) \to \mathcal{F}$ is a surjection (as one checks stalkwise). However, I claim that $\Gamma(X, j_{1!} (j_1^* \mathcal{F})) = 0$ and similarly for the other factor. Here's the justification: given a nonzero section of $j_! j_1^* \mathcal{F}$ is the same as giving an open cover $\{V_\alpha\}$ of the space, and sections of $\mathcal{F}$ over $V_\alpha$ for each $V_\alpha \subset U_1$ and zero for other $V_\alpha$'s (by definition of extension by zero); however, at least one of these open sets (say, $V_\beta$) must not be contained in $U_1$, and this will intersect all the other $V_\alpha$'s (even those contained in $U_1$). So since the section must be zero on $V_\beta$, it must be zero on all the other $V_\alpha$'s (by local constancy).
A: Here is a simple 'hands-on' example. Let $X=\{A,B,C\}$ be the three-point space with open sets $\{A,B,C\}$, $\{A,B\}$, $\{B,C\}$, $\{B\}$, and $\emptyset$, and let $\mathscr F$ be the sheaf of abelian groups on $X$ 'generated' by the $\mathbf Z$-valued functions $f\in\mathscr F(\{A,B\})$ and $g\in\mathscr F(\{B,C\})$, defined by
$f : (A,B)\mapsto(1,2)$
(which is shorthand for the function defined on points by $f(A)=1, f(B)=2$), and
$g : (B,C)\mapsto(0,1)$.
By 'generated,' I mean $\mathscr F$ is the sheaf associated to the presheaf obtained by all restrictions of $f$ and $g$ (in this case, the only nontrivial restriction is to $\{B\}$). In particular, using the notation $\langle f\rangle$ for the cyclic group generated by $f$, with $0$ element the $0$ function, we have that
$\mathscr F(\{A,B,C\})=\langle (A,B,C)\mapsto(0,0,1)\rangle$.
Now consider the presheaf induced by the map on functions induced by $\mathbf Z\mapsto\mathbf Z/2\mathbf Z$. That is, $f\mapsto\overline f$, where $\overline f$ is the function $\overline f : (A,B)\mapsto(1,0)$ valued in $\mathbf Z/2\mathbf Z$, and $\overline g : (B,C)\mapsto(0,1)$.
Then the presheaf image $\mathscr G$ has
$\mathscr G(\{A,B,C\})=\langle(A,B,C)\mapsto(0,0,1)\rangle$, but the associated sheaf $\mathscr G^+$ has, for example, the function $(A,B,C)\mapsto(1,0,1)$ in $\mathscr G^+(\{A,B,C\})$, so considered as a morphism of sheaves $\mathscr F\rightarrow\mathscr G^+$, we are (tautologically) surjective (and, of course, surjective on stalks) but not surjective on sections.
($X$ is the same space as in Alex and Georges' answers, so perhaps this example is the same, but maybe not exactly.)
A: Take $X=\mathbb R$ for your  topological space,  the constant sheaf $\underline {\mathbb Z} $ for $\mathcal F$ and for $\mathcal G$ the direct sum of  two skyscraper sheaves with fibers $\mathbb Z$   at two distinct points $P,Q\in \mathbb R$, that is $\mathcal G=\mathbb Z^P \oplus  \mathbb Z^Q$.
The natural restriction  $\mathcal F=\underline {\mathbb Z} \to \mathcal G=\mathbb Z^P \oplus  \mathbb Z^Q$ is a surjective sheaf morphism  but the associated group morphism on global sections $\mathcal F(X)=\mathbb Z \to \mathcal G (X)=\mathbb Z \oplus \mathbb Z$ is not surjective [its image is the diagonal of $\mathbb Z \oplus \mathbb Z$, consisting of pairs $(z,w)$ with $z=w$].
Edit This example can easily be adapted to a three point space space: thanks to Pierre-Yves who, in a comment to Alex's answer,  suggested that.
Take $X=\{P,Q, \eta\}$ with closed sets $X,\emptyset, \{P\}, \{Q\}, \{P,Q\}$ (this is the same space as Alex's).The rest is exactly the same as above. 
Namely $\mathcal F=\underline {\mathbb Z} $, $\mathcal G=\mathbb Z^P \oplus  \mathbb Z^Q$,  $\mathcal F=\underline {\mathbb Z} \to \mathcal G=\mathbb Z^P \oplus  \mathbb Z^Q$ the restriction, which is again a surjective sheaf morphism, and $\mathcal F(X)=\mathbb Z \to \mathcal G (X)=\mathbb Z \oplus \mathbb Z \:$ not surjective (the image being again the diagonal of $\mathbb Z \oplus \mathbb Z$).
The main point is that the stalks of $\mathbb Z^P$  are:
 $(\mathbb Z^P)_P=\mathbb Z,(\mathbb Z^P)_Q=0, (\mathbb Z^P)\eta=0$,  because $P$ is a closed point.  Ditto for $\mathbb Z^Q$.
Tangential remark It might be of some interest to notice that there is a scheme structure on $X$ which makes it the smallest possible non affine scheme. This is explained in the book The Geometry of Schemes by Eisenbud and Harris, on page 22. 
A: Let $M$ be a smooth manifold, and consider the sheaf of closed 1-forms. There is a surjection from the sheaf of smooth functions to the sheaf of closed 1-forms (namely, the exterior derivative, $f \mapsto df$), which is surjective in the category of sheaves (by the Poincare lemma), but which is in general not surjective (if $M$ has nontrivial first de Rham cohomology).
A: Let me try as elementary as is humanly possible:
$X=\{p,q_1,q_2\}$, consisting of only three elements! The open sets are $U_0=\{p\}$, $U_1=\{p,q_1\}$, $U_2=\{p,q_2\}$, and of course the empty set and $X$. Define $\mathscr{F}(U)=\mathscr{G}(U)=\mathbb{Z}$ on all non-empty open sets $U$. Now, the trick is going to be in the restriction maps and the morphism. Define all the restriction maps on $\mathscr{G}$ to be the identity, but the restrictions $\mathscr{F}(X)\rightarrow \mathscr{F}(U_i)$, $i=1,2$ are multiplication by 2. The restrictions $\mathscr{F}(U_i)\rightarrow \mathscr{F}(U_0)$ are again the identity maps (this forces the restriction from $X$ to $U_0$ to also be multiplication by 2).
Define $\phi:\mathscr{F}\rightarrow \mathscr{G}$ to be the identity on all open sets except for $X$, where it is multiplication by 2. Then $\phi(X)$ is not surjective, but it is surjective on all the stalks (check!). I hope I haven't made a mistake.
A: Alex B. gave an example above that was supposed to be surjective on all stalks but not surjective.  According to Hartshorn exercise II.1.2(b) a morphism is surjective $\Leftrightarrow$ it is surjective on all stalks.  So that pursuit is in vain.
But the question was to find a morphism that is surjective but not surjective on sections. Sections are on open sets, not stalks so this doesn't contradict the statement above.  It would be cool to have a very simple example for this.
A: We seek two surjective local homeomorphisms
$\pi_{\mathcal E}\colon\mathcal E\rightarrow\mathcal X$ and
$\pi_{\mathcal H}\colon\mathcal H\rightarrow\mathcal X$ and a surjective
sheaf morphism $f\colon\mathcal E\rightarrow\mathcal H$ such that some
(continuous) section of $\pi_{\mathcal H}$ is not $f\circ s$ for any
(continuous) section $s$ of $\pi_{\mathcal E}$. If the viewpoint of a presheaf
is preferred (assignment of sets to open sets where restriction is respected)
then translate to the presheaves of continuous sections of $\mathcal E$
and $\mathcal H$. Those automatically satisfy the usual sheaf gluing
condition i.e. they are sheaves in the second sense.
$
\newcommand\bbR{{\mathbb R}}
\newcommand\clE{{\mathcal E}} \newcommand\clF{{\mathcal F}}
\newcommand\clH{{\mathcal H}} \newcommand\clX{{\mathcal X}}
\newcommand{\set}[2]{\{\mskip1mu #1\mid#2\mskip1mu\}}
\newcommand{\sset}[1]{\{\mskip1.25mu#1\mskip1.25mu\}}
\newcommand{\rto}[1]{\mathchoice{\bigl|_{#1}}{\vert_{#1}}{|_{#1}}{|_{#1}}}
$
A simple example is the presheaf of real valued continuously differentiable
functions $s(x)$ of a real variable $x$, such that $s(0)=s(1)=0$, this presheaf
being mapped by differentiation to the presheaf of continuous functions
of $x$. The constant section with value $1$ is not hit because if $s'=1$ then
$s(0)$ and $s(1)$ cannot both be zero, by the fundamental theorem of
calculus. But it would be better to find an example that does not use even
undergraduate calculus.

Let $\clX=\sset{A,B,C}$ with topology
$\sset{\emptyset,\sset{B},\sset{A,B},\sset{B,C},\clX}$, and let
$E=\sset{+1,-1}$ with the discrete topology, so that $\clE=\clX\times E$ is a
sheaf (see below). The cartesian products of the open sets of $\clX$ with
$\sset{-1}$ and $\sset{+1}$ is a basis for the $\clE$-topology by the
definition of the product topology. The equivalence relation that collapses
$(B,1)$ and $(B,-1)$ to $(B,0)$ provides the quotient
$f\colon\clE\rightarrow\clH$, where
$$
\clH=\sset{(A,+1),(A,-1),(B,0),(C,1),(C,-1)}.
$$
The images under $f$ of the $\clE$ basis are closed under intersection and they
form a basis of $\clH$ such that $f\colon\clE\rightarrow\clH$ is an open map,
so the topology defined by that basis, and the quotient topology, are the same,
$\clH$ is a sheaf, and $f$ is a sheaf epimorphism. There are two global
constant sections in $\clE$, but $\clH$ has four global sections: the sections
of $\clE$ composed with $f$, and also the two global sections
$$
A\mapsto(A,+1),\; B\mapsto(B,0),\; C\mapsto(C,-1),\quad\mbox{and}\quad
A\mapsto(A,-1),\; B\mapsto(B,0),\; C\mapsto(C,+1).
$$
In the graphic, the kinked green sections are $f\circ s$ for the two constant
sections $s$ of $\clE$, but the two slanted magenta sections of $\pi_\clH$
are not hit.
The example is easily understood: the sections of $\pi_\clE$ cannot go
vertically along the fiber at $B$ even though the singleton $\sset{B}$ is open
because sections are single valued maps. But when $(B,+1)$ and $(B,-1)$ are
collapsed then the germ at $B$ provides no control because it has no extent in
$\clX$, so the sections of $\pi_\clH$ can ``change tracks'' and two more of
them appear.
Below are two background items that place this example in a more general
setting.
Constant sheaves: Let $\clX$ and $E$ be topological spaces and
suppose $E$ has the discrete topology. Then $\clE=\clX\times E$ with
$\pi\colon\clE\rightarrow\clX$ the projection is a sheaf: $\pi$ is continuous
and surjective, and for any $(x,e)\in\clE$ and any open $U\ni x$,
$U'=U\times\sset{e}$ is open because it is the product of open sets, and
$\pi\rto{U'}\rightarrow U$ is continuous with continuous
inverse $x\mapsto(x,e)$. The continuous sections of $\clE$ are the
maps $x\mapsto (x,e(x))$ where $e\colon U\rightarrow E$ is continuous, so the
presheaf of sections of $\clE$ is isomorphic with the presheaf of continuous
functions on $\clX$ with values in $E$. Singletons of $E$ are open-closed so
they are pulled back by any continuous $e\colon U\rightarrow E$ to open-closed
subsets of $U$. Thus the sections of $\clE$ correspond to the functions on
$\clX$ which are constant on connected subsets of $\clX$.
A fiberwise quotient of a sheaf is a sheaf if the quotient map is open:
Given (possibly trivial) equivalence relations in each fiber of a sheaf $\clE$
(equivalently, a fiberwise equivalence relation on $\clE$), the quotient space
$\clH$ is a topological space, the (surjective) quotient map
$f\colon\clE\rightarrow\clH$ is continuous, and there is a unique continuous
surjective $\pi_\clH\colon\clH\rightarrow\clX$ such that
$\pi_\clH\,f=\pi_\clE$.  If $f$ is an open map then $\clH$ is a sheaf and
$f\colon\clE\rightarrow\clH$ is a sheaf epimorphism: Let $\delta\in\clH$ and
$\pi_\clH(\delta)=x$, choose $\gamma\in\clE$ such that $f(\gamma)=\delta$, and
choose open $U'\ni\gamma$, $U\ni x$, and a section $s\colon U\rightarrow\clF$,
such that $\pi_\clE\rto U'\colon U'\rightarrow U$ and $s\colon U\rightarrow U'$
are inverses. Then $V'\equiv f(U')$ is open and $t\equiv f\circ s\colon
U\rightarrow V'$ is surjective. If $y\in U$ then
$\pi_\clH\,t(y)=\pi_\clH(f(s(y)))=\pi_\clE\,s(y)=y$ so $\pi_\clH$ is a
local diffeomorphism.
