# Glueing morphisms of sheaves together - can I just do this?

While trying to solve a certain exercise in Hartshorne I realized that I need to use the following result:

Let $X,Y$ be two ringed topological spaces. Suppose we have a covering $\{U_i\}$ of $X$ and morphisms $f_i :U_i \to Y$ such that $f_i|_{U_i \cap U_j} = f_j|_{U_i \cap U_j}$ for every $i,j$. The bar just denotes ordinary restriction of morphisms to a subspace. Then there is a morphism $f : X \to Y$ such that $f|_{U_i} = f_i$.

Now the obvious choice for a morphism $f(x) = f_i(x)$ if $x \in U_i$ should work. Indeed for every $i$ we have maps $f_i^\sharp : \mathcal{O}_Y \to {f_i}_\ast(\mathcal{O}_X|_{U_i})$ and using this I want to build a morphism $f^\sharp : \mathcal{O}_Y \to f_\ast \mathcal{O}_X$. It suffices to define $f^\sharp$ open set by open set so choose $V \subseteq Y$ open. Choose $s \in \mathcal{O}_Y(V)$ and define $$s_i := f^\sharp_i(s) \in {f_i}_\ast (\mathcal{O}_X|_{U_i})(V).$$

My question is: Why should it be the case that $s_i|_{f_i^{-1}(V) \cap f_j^{-1}(V)} = s_j|_{f_i^{-1}(V) \cap f_j^{-1}(V)}$? I ask this because the $\{f_i^{-1}(V)\}$ cover $f^{-1}(V)$ and then I can invoke the gluing property of a sheaf to give me a section of $f_\ast \mathcal{O}_X(V)$. I am tempted to say from the diagram

$\hspace{1in}$

that I can apply the functor $\mathcal{O}_Y(-)$ to the bottom right corner and $\mathcal{O}_X(-)$ to the other three corners and still obtain a commutative square, but is this legal?

You are defining maps $$\mathcal{O}_Y(V) \stackrel{s_i^V}{\longrightarrow} \mathcal{O}_X(f^{-1}(V) \cap U_i) = \mathcal{O}_X(f_i^{-1}(U))$$ and then wanting to use the fact that $U_i$ covers $f^{-1}(V)$ to define the unique value of $s^V$ by virtue of $\mathcal{O}_X$ being a sheaf. So we have to restriction maps $$\mathcal{O}_X(f^{-1}(V)\cap U_i) \stackrel{\mbox{res}_{ij}}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i \cap U_j) \\ \mathcal{O}_X(f^{-1}(V)\cap U_j) \stackrel{\mbox{res}_{ji}}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i \cap U_j)$$ and we want these maps to agree for outputs of $s_i$ . But what is the sheaf morphism for $f_i |_{U_i \cap U_j}$? It restricts $f_i$ to $U_j$, so it's exactly the map $$\mathcal{O}_Y(V) \stackrel{s_i^V}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i) \stackrel{\mbox{res}_{ij}}{\longrightarrow} \mathcal{O}_X(f^{-1}(V)\cap U_i \cap U_j).$$ The assumed agreement of the restictions of the $f_i$ then gives the desired agreement of the restrictions of the $e_i^V$.
First, I think your notation $f_i^\sharp : \mathcal{O}_Y \to {f_i}_\ast(\mathcal{O}_X)|_{U_i}$ is slightly confusing. (If I were being very careful, and I usually am when I work with sheaves, I would write $f_i^\sharp : \mathcal{O}_Y \to {f_i}_\ast(\mathcal{O}_{U_i}) = {f_i}_\ast(\mathcal{O}_X|_{U_i}).$) Anyway, we have $$s_i := f^\sharp_i(s) \in {f_i}_\ast (\mathcal{O}_{U_i})(V) = \Gamma(f_i^{-1}(V),\mathcal O_{U_i}) = \Gamma(f_i^{-1}(V),\mathcal O_{X}).$$ Thus, we consider $s_i$ as a section of $\mathcal O_X$ on $f_i^{-1}(V)\subseteq U_i.$
Set $s_{ij} = f_{ij}^\sharp(s),$ where $f_{ij} = f_i|_{U_{ij}} = f_i\circ\iota_{ij},$ with $\iota_{ij}$ the inclusion of $U_{ij}$ into $U_i.$ Since we assume that $f_{ij} = f_{ji},$ it suffices to show that $s_i|_{f_i^{-1}(V)\cap U_{ij}} = s_{ij}.$ I claim the relevant property we need is the following:
Let $f:X\to Y$ and $g:Y\to Z$ be morphisms of locally ringed spaces. Then $f^\sharp:\mathcal O_Y\to f_\ast \mathcal O_X$ induces a morphism $g_\ast f^\sharp:g_\ast\mathcal O_Y\to g_\ast (f_\ast\mathcal O_X) = (g\circ f)_\ast\mathcal O_X$ of sheaves on $Z$ satisfying $(g\circ f)^\sharp = g_\ast f^\sharp\circ g^\sharp.$
This is essentially what it means to compose two morphisms of locally ringed spaces. To see why this is true, simply consider what happens on an open neighbourhood $V\subseteq Z.$ We want to use this when $X = U_{ij},Y = U_i,Z = Y$ (somewhat confusingly), and $f = \iota_{ij},g = f_i.$
We get $s_{ij} = f_{ij}^\sharp(s) = (f_i\circ\iota_{ij})^\sharp(s) = (f_{i\ast}\iota_{ij}^\sharp\circ f_i^\sharp)(s) = f_{i\ast}\iota_{ij}^\sharp (s_i)$ which is just $s_i$ restricted to $U_{ij},$ with notational bookkeeping that reminds us we have to consider these as sheaves on $Z.$ (Note that the definition of a morphisms of sheaves applied to the inclusion $U_{ij}\subseteq U_i$ guarantees that $\iota_{ij}^\sharp(s_i)$ is the same as restricting $s_i$ to $f_i^{-1}(V)\cap U_{ij}$ as considering it as a section of $\mathcal O_{U_{ij}}$.)