Hartshorne exercise II.2.1 Let $A$ be an abelian group with the discrete topology, and $X$ a topological space.  Define the constant presheaf $\mathcal O$ on $X$ by setting $\mathcal O(U) = A$ for $U \neq \emptyset$, the restriction maps are the identity.  For $U$ open in $X$, let $\mathcal A(U)$ denote the abelian group of continuous functions $f: U \rightarrow A$, i.e. those $f$ for which $f^{-1}\{a\}$ is open and closed in $X$ for all $a \in A$.  Then $\mathcal A$ is a sheaf. The map which sends $a \in A$ to the constant function $x \mapsto a$ for all $x \in U$ defines a morphism of presheaves $\theta: \mathcal O \rightarrow \mathcal A$.
I am trying to show that $(\mathcal A, \theta)$ is a sheafification of $\mathcal O$.  Given a morphism $\alpha: \mathcal O \rightarrow \mathcal F$ for some sheaf $\mathcal F$, I want to find a unique morphism $\overline{\alpha}: \mathcal A \rightarrow \mathcal F$ for which $\overline{\alpha} \circ \theta = \alpha$, but I'm having trouble.
For $U$ open, $\alpha(U)$ is a homomorphism of abelian groups $A \rightarrow \mathcal F(U)$.  For a given $f \in \mathcal A(U)$, I would like to define $\overline{\alpha}(U)(f)$ to be $\alpha(U)(f(x))$, where $x$ is any element of $U$.  But I don't see why we should have $\alpha(U)(f(x)) = \alpha(U)(f(y))$ for any $x, y \in U$.  Somehow this comes from $f$ being continuous and $\mathcal F$ being sheaf.
 A: Consider the construction of the sheafification in the text. For an open $U \subseteq X$, the sections of the sheafification are pointwise functions from $U$ into $A$ that are locally constant (since the stalks at each point are just $A$.) It is a topological fact that a function into a discrete space is continuous if and only if it is locally constant. Thus the sections are isomorphic in this way.
A: Since $U$ is equal to a disjoint union of open sets $$\bigcup\limits_{a \in A} f^{-1}\{a\}$$ and $\mathcal F$ is a sheaf, there is a unique $s \in \mathcal F(U)$ whose restriction to $\mathcal F(f^{-1}\{a\})$ is $\alpha(f^{-1}\{a\})(a)$ (only including those $a$ for which $f^{-1}\{a\} \neq \emptyset$).  You define $\overline{\alpha}(U)(f)$ to be $s$, and everything else falls into place easily with one exception (see below).
On account of the difficulty I had with this problem, as well as with algebraic geometry in general, let me write out the details that $\overline{\alpha}(U)$ is actually a group homomorphism.  Let $f_1, f_2 \in \mathcal A(U)$.  Let $g = f_1 + f_2$, let $V_a^i = f_i^{-1}\{a\}$, and let $W_a = g^{-1}\{a\}$.    Let $s_i = \overline{\alpha}(U)(f_i), s = \overline{\alpha}(U)(g)$.  We want to show that $s = s_1 + s_2$, so we just have to show that $U$ is a union of open sets on which the restrictions of $s$ and $s_1 + s_2$ agree.
Now $U$ is the disjoint union of $W_a : a \in A$, and clearly $$W_a = \bigcup\limits_{b \in A} \{ x \in U : f_1(x) + b = a \} \cap \{x \in U : f_2(x) = b\} = \bigcup\limits_{b \in A} V_{a-b}^1 \cap V_b^2$$ So we just have to show that the restrictions of $s$ and $s_1 + s_2$ to $Y:= V_{a-b}^1 \cap V_b^2$ agree for any $a, b \in A$.  Now $s_{1|V_{a-b}^1} = \alpha(V_{a-b}^1)(a-b)$, and $s_{2|V_b^2} = \alpha(V_b^2)(b)$, and hence $s_{1|Y} = \alpha(Y)(a-b)$ and $s_{2|Y} = \alpha(Y)(b)$ (unless $Y$ or one of $V_{a-b}^1, V_b^2$ is empty, but then we don't care).  At the same time, $s_{|W_{a}} = \alpha(W_a)(a)$, and so $s_{|Y} = \alpha(Y)(a)$.  But then $$s_{1|Y} + s_{2|Y} = \alpha(Y)(a-b) + \alpha(Y)(b) = \alpha(Y)(a) = s_{|Y}$$
