# Details of gluing sheaves on a cover

I am sure this is a simple question, but I am really not able to think straight at the moment and this is bugging me. I am doing Exercise 1.22 from Hartshorne. It is the classic gluing of of sheaves on a cover given the cocycle condition question. In particular, we have a space $X$ and a cover for this space $\{ U_{i} \}_{i \in I}$. Further, we are given a family of sheaves indexed by the same set $I$, $\{ \mathcal{F}_{i} \}_{i \in I}$ on each of the $U_{i}$. We are given isomorphisms $$\phi_{ij}: \mathcal{F}_{i}|_{U_{i} \cap U_{j}} \longrightarrow \mathcal{F}_{j}|_{U_{i} \cap U_{j}},$$ along with the so-called cocycle condition $$\phi_{ik} = \phi_{ik} \circ \phi_{ij} \quad \text{on} \quad U_{i} \cap U_{j} \cap U_{k}.$$ The task is to construct a sheaf on $X$ compatible with these local sheaves. I have gone ahead and done the obvious steps of defining a base by taking all open sets contained in one of the $U_{i}$ etc. I then defined a sheaf $\mathcal{G}$ on this base and this is well defined since if there is some $V$ in $U_{i}$ and $U_{j}$ with $i \neq j$, then via the isomorphism $\phi_{ij}$, we have $$\mathcal{F}_{i}(V) \stackrel{\simeq}{\longrightarrow} \mathcal{F}_{j}(V)$$ My understanding is that to make the restriction maps work, you need to invoke the cocycle condition. My issue is that I can't see exactly where. It seems that the isomorphism alone is enough. The frustrating part is that every resource I look at (and there are a lot since this is a common exercise) simply says "the restrictions are compatible because of the cocycle condition" or "this is well defined because of the cocycle condition" or something similar. Nowhere seems to explicitly lay out where the cocyle condition is invoked, and what breaks when it is not. Is someone able to shed some light on this? Other than this small step I feel like I understand the rest of it completely, but I feel like this is a vital thing to not understand.

Thanks

Personally, I find it more intuitive to define the glued-up sheaf $\mathcal F$ like this:
For every open set $V \subset X$, we define the group of sections $\mathcal F(V)$ to be a set consisting of all tuples $(s_i)_{i \in I}$, where each $s_i$ is a section in $\mathcal F_i(V \cap U_i)$, and where the $s_i$'s are required to obey the compatibility condition: $$\phi_{ij}(s_i|_{V \cap U_i \cap U_j}) = s_j |_{V \cap U_i \cap U_j} \ \ \ \ \ (\ast)$$ for all $i, j \in I$. The group addition on $\mathcal F(V)$ is the obvious one.
As far as I can tell, the $\mathcal F$ that I defined is guaranteed to be a sheaf, regardless of whether we impose the cocycle condition. It comes with a natural restriction map, making it a presheaf, and it also obeys all the gluing conditions necessary for it to be a sheaf. I don't think the cocycle condition is needed to verify any of these things.
However, it is not enough to prove that our $\mathcal F$ is a sheaf. We also need to satisfy ourselves that the restriction $\mathcal F|_{U_k}$ really is isomorphic to the $\mathcal F_k$ that we started with, for each $k \in I$. It is here that the cocycle condition is required.
It is easy to write down what the isomorphism $\psi : \mathcal F_k \overset{\cong}\to \mathcal F|_{U_k}$ ought to be. Given an open $V \subset U_k$ and given a section $s \in \mathcal F_k$, we would like to define its image under $\psi$ to be $$\psi(s) = (\phi_{ki}(s|_{V \cap U_i}))_{i \in I}$$ However, we need to be sure that the tuple $(\phi_{ki}(s|_{V \cap U_i}))_{i \in I}$ represents a well-defined element of $\mathcal F(V)$. In particular, we must verify that $(\phi_{ki}(s|_{V \cap U_i}))_{i \in I}$ obeys the condition $(\ast)$, which states that $$\phi_{ij} \circ \phi_{ki}(s|_{V \cap U_i \cap U_j}) = \phi_{kj}(s|_{V \cap U_i \cap U_j})$$ for any $i, j \in I$. This is true by virtue of the cocycle condition.