hcju/stacksqa huggingface dataset:
Let $j : U \to X$ and $j' : U' \to X$ be the open immersions. Recall that $j_!\mathcal{O}_U$ is the extension by zero of $\mathcal{O}_U = \mathcal{O}_X|_U$, see Sheaves, Section \ref{sheaves-section-open-immersions}. Since $j_!$ is a left adjoint to restriction we see that for any sheaf $\mathcal{F}$ of $\mathcal{O}_X$-modules $$ \Hom_{\mathcal{O}_X}(j_!\mathcal{O}_U, \mathcal{F}) = \Hom_{\mathcal{O}_U}(\mathcal{O}_U, \mathcal{F}|_U) = \mathcal{F}(U) $$ see Sheaves, Lemma \ref{sheaves-lemma-j-shriek-modules}. Similarly, the sheaf $j'_!\mathcal{O}_{U'}$ represents the functor $\mathcal{F} \mapsto \mathcal{F}(U')$. Moreover there is an obvious canonical map of $\mathcal{O}_X$-modules $$ j'_!\mathcal{O}_{U'} \longrightarrow j_!\mathcal{O}_U $$ which corresponds to the restriction mapping $\mathcal{F}(U) \to \mathcal{F}(U')$ via Yoneda's lemma (Categories, Lemma \ref{categories-lemma-yoneda}). By the description of the stalks of the sheaves $j'_!\mathcal{O}_{U'}$, $j_!\mathcal{O}_U$ we see that the displayed map above is injective (see lemma cited above). Hence if $\mathcal{I}$ is an injective $\mathcal{O}_X$-module, then the map $$ \Hom_{\mathcal{O}_X}(j_!\mathcal{O}_U, \mathcal{I}) \longrightarrow \Hom_{\mathcal{O}_X}(j'_!\mathcal{O}_{U'}, \mathcal{I}) $$ is surjective, see Homology, Lemma \ref{homology-lemma-characterize-injectives}. Putting everything together we obtain the lemma.
The sheaf condition says that the kernel of $(1, -1) : \mathcal{F}(U) \oplus \mathcal{F}(V) \to \mathcal{F}(U \cap V)$ is equal to the image of $\mathcal{F}(X)$ by the first map for any abelian sheaf $\mathcal{F}$. Lemma \ref{lemma-injective-restriction-surjective} above implies that the map $(1, -1) : \mathcal{I}(U) \oplus \mathcal{I}(V) \to \mathcal{I}(U \cap V)$ is surjective whenever $\mathcal{I}$ is an injective $\mathcal{O}_X$-module. Hence if $\mathcal{F} \to \mathcal{I}^\bullet$ is an injective resolution of $\mathcal{F}$, then we get a short exact sequence of complexes $$ 0 \to \mathcal{I}^\bullet(X) \to \mathcal{I}^\bullet(U) \oplus \mathcal{I}^\bullet(V) \to \mathcal{I}^\bullet(U \cap V) \to 0. $$ Taking cohomology gives the result (use Homology, Lemma \ref{homology-lemma-long-exact-sequence-cochain}). We omit the proof of the functoriality of the sequence.
Let $\mathcal{F} \to \mathcal{I}^\bullet$ be an injective resolution of $\mathcal{F}$. We claim that we get a short exact sequence of complexes $$ 0 \to f_*\mathcal{I}^\bullet \to a_*\mathcal{I}^\bullet|_U \oplus b_*\mathcal{I}^\bullet|_V \to c_*\mathcal{I}^\bullet|_{U \cap V} \to 0. $$ Namely, for any open $W \subset Y$, and for any $n \geq 0$ the corresponding sequence of groups of sections over $W$ $$ 0 \to \mathcal{I}^n(f^{-1}(W)) \to \mathcal{I}^n(U \cap f^{-1}(W)) \oplus \mathcal{I}^n(V \cap f^{-1}(W)) \to \mathcal{I}^n(U \cap V \cap f^{-1}(W)) \to 0 $$ was shown to be short exact in the proof of Lemma \ref{lemma-mayer-vietoris}. The lemma follows by taking cohomology sheaves and using the fact that $\mathcal{I}^\bullet|_U$ is an injective resolution of $\mathcal{F}|_U$ and similarly for $\mathcal{I}^\bullet|_V$, $\mathcal{I}^\bullet|_{U \cap V}$ see Lemma \ref{lemma-cohomology-of-open}.
By Lemma \ref{lemma-cech-exact-presheaves} a short exact sequence of presheaves of $\mathcal{O}_X$-modules $0 \to \mathcal{F}_1 \to \mathcal{F}_2 \to \mathcal{F}_3 \to 0$ is turned into a short exact sequence of complexes of $\mathcal{O}_X(U)$-modules. Hence we can use Homology, Lemma \ref{homology-lemma-long-exact-sequence-cochain} to get the boundary maps $\delta_{\mathcal{F}_1 \to \mathcal{F}_2 \to \mathcal{F}_3} : \check{H}^n(\mathcal{U}, \mathcal{F}_3) \to \check{H}^{n + 1}(\mathcal{U}, \mathcal{F}_1)$ and a corresponding long exact sequence. We omit the verification that these maps are compatible with maps between short exact sequences of presheaves.
We saw in the discussion just above the lemma that $$ \Hom_{\mathcal{O}_X}( (j_{i_0\ldots i_p})_{p!}\mathcal{O}_{U_{i_0\ldots i_p}}, \mathcal{F}) = \mathcal{F}(U_{i_0\ldots i_p}). $$ Hence we see that it is indeed the case that the direct sum $$ \bigoplus\nolimits_{i_0 \ldots i_p} (j_{i_0 \ldots i_p})_{p!}\mathcal{O}_{U_{i_0 \ldots i_p}} $$ represents the functor $$ \mathcal{F} \longmapsto \prod\nolimits_{i_0\ldots i_p} \mathcal{F}(U_{i_0\ldots i_p}). $$ Hence by Categories, Yoneda Lemma \ref{categories-lemma-yoneda} we see that there is a complex $K(\mathcal{U})_\bullet$ with terms as given. It is a simple matter to see that the maps are as given in the lemma.
An injective $\mathcal{O}_X$-module is also injective as an object in the category $\textit{PMod}(\mathcal{O}_X)$ (for example since sheafification is an exact left adjoint to the inclusion functor, using Homology, Lemma \ref{homology-lemma-adjoint-preserve-injectives}). Hence we can apply Lemma \ref{lemma-cech-cohomology-derived-presheaves} (or its proof) to see the result.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module. Choose an injective resolution $\mathcal{F} \to \mathcal{I}^\bullet$. Consider the double complex $\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet)$ with terms $\check{\mathcal{C}}^p(\mathcal{U}, \mathcal{I}^q)$. There is a map of complexes $$ \alpha : \Gamma(U, \mathcal{I}^\bullet) \longrightarrow \text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet)) $$ coming from the maps $\mathcal{I}^q(U) \to \check{H}^0(\mathcal{U}, \mathcal{I}^q)$ and a map of complexes $$ \beta : \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \longrightarrow \text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet)) $$ coming from the map $\mathcal{F} \to \mathcal{I}^0$. We can apply Homology, Lemma \ref{homology-lemma-double-complex-gives-resolution} to see that $\alpha$ is a quasi-isomorphism. Namely, Lemma \ref{lemma-injective-trivial-cech} implies that the $q$th row of the double complex $\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet)$ is a resolution of $\Gamma(U, \mathcal{I}^q)$. Hence $\alpha$ becomes invertible in $D^{+}(\mathcal{O}_X(U))$ and the transformation of the lemma is the composition of $\beta$ followed by the inverse of $\alpha$. We omit the verification that this is functorial.
To see this we construct an inverse map. Namely, let $\mathcal{F}$ be a $\mathcal{H}$-torsor whose restriction to $U_i$ is trivial. By Lemma \ref{lemma-trivial-torsor} this means there exists a section $s_i \in \mathcal{F}(U_i)$. On $U_{i_0} \cap U_{i_1}$ there is a unique section $s_{i_0i_1}$ of $\mathcal{H}$ such that $s_{i_0i_1} \cdot s_{i_0}|_{U_{i_0} \cap U_{i_1}} = s_{i_1}|_{U_{i_0} \cap U_{i_1}}$. A computation shows that $s_{i_0i_1}$ is a {\v C}ech cocycle and that its class is well defined (i.e., does not depend on the choice of the sections $s_i$). The inverse maps the isomorphism class of $\mathcal{F}$ to the cohomology class of the cocycle $(s_{i_0i_1})$. We omit the verification that this map is indeed an inverse.
This is a Grothendieck spectral sequence (see Derived Categories, Lemma \ref{derived-lemma-grothendieck-spectral-sequence}) for the functors $$ i :  \textit{Mod}(\mathcal{O}_X) \to \textit{PMod}(\mathcal{O}_X) \quad\text{and}\quad \check{H}^0(\mathcal{U}, - ) : \textit{PMod}(\mathcal{O}_X) \to \text{Mod}_{\mathcal{O}_X(U)}. $$ Namely, we have $\check{H}^0(\mathcal{U}, i(\mathcal{F})) = \mathcal{F}(U)$ by Lemma \ref{lemma-cech-h0}. We have that $i(\mathcal{I})$ is {\v C}ech acyclic by Lemma \ref{lemma-injective-trivial-cech}. And we have that $\check{H}^p(\mathcal{U}, -) = R^p\check{H}^0(\mathcal{U}, -)$ as functors on $\textit{PMod}(\mathcal{O}_X)$ by Lemma \ref{lemma-cech-cohomology-derived-presheaves}. Putting everything together gives the lemma.
Let $\mathcal{F}$ be a sheaf satisfying the assumption of the lemma. We will indicate this by saying ``$\mathcal{F}$ has vanishing higher {\v C}ech cohomology for any open covering''. Choose an embedding $\mathcal{F} \to \mathcal{I}$ into an injective $\mathcal{O}_X$-module. By Lemma \ref{lemma-injective-trivial-cech} $\mathcal{I}$ has vanishing higher {\v C}ech cohomology for any open covering. Let $\mathcal{Q} = \mathcal{I}/\mathcal{F}$ so that we have a short exact sequence $$ 0 \to \mathcal{F} \to \mathcal{I} \to \mathcal{Q} \to 0. $$ By Lemma \ref{lemma-ses-cech-h1} and our assumptions this sequence is actually exact as a sequence of presheaves! In particular we have a long exact sequence of {\v C}ech cohomology groups for any open covering $\mathcal{U}$, see Lemma \ref{lemma-cech-cohomology-delta-functor-presheaves} for example. This implies that $\mathcal{Q}$ is also an $\mathcal{O}_X$-module with vanishing higher {\v C}ech cohomology for all open coverings. \medskip\noindent Next, we look at the long exact cohomology sequence $$ \xymatrix{ 0 \ar[r] & H^0(U, \mathcal{F}) \ar[r] & H^0(U, \mathcal{I}) \ar[r] & H^0(U, \mathcal{Q}) \ar[lld] \\ & H^1(U, \mathcal{F}) \ar[r] & H^1(U, \mathcal{I}) \ar[r] & H^1(U, \mathcal{Q}) \ar[lld] \\ & \ldots & \ldots & \ldots \\ } $$ for any open $U \subset X$. Since $\mathcal{I}$ is injective we have $H^n(U, \mathcal{I}) = 0$ for $n > 0$ (see Derived Categories, Lemma \ref{derived-lemma-higher-derived-functors}). By the above we see that $H^0(U, \mathcal{I}) \to H^0(U, \mathcal{Q})$ is surjective and hence $H^1(U, \mathcal{F}) = 0$. Since $\mathcal{F}$ was an arbitrary $\mathcal{O}_X$-module with vanishing higher {\v C}ech cohomology we conclude that also $H^1(U, \mathcal{Q}) = 0$ since $\mathcal{Q}$ is another of these sheaves (see above). By the long exact sequence this in turn implies that $H^2(U, \mathcal{F}) = 0$. And so on and so forth.
Let $\mathcal{F}$ and $\text{Cov}$ be as in the lemma. We will indicate this by saying ``$\mathcal{F}$ has vanishing higher {\v C}ech cohomology for any $\mathcal{U} \in \text{Cov}$''. Choose an embedding $\mathcal{F} \to \mathcal{I}$ into an injective $\mathcal{O}_X$-module. By Lemma \ref{lemma-injective-trivial-cech} $\mathcal{I}$ has vanishing higher {\v C}ech cohomology for any $\mathcal{U} \in \text{Cov}$. Let $\mathcal{Q} = \mathcal{I}/\mathcal{F}$ so that we have a short exact sequence $$ 0 \to \mathcal{F} \to \mathcal{I} \to \mathcal{Q} \to 0. $$ By Lemma \ref{lemma-ses-cech-h1} and our assumption (2) this sequence gives rise to an exact sequence $$ 0 \to \mathcal{F}(U) \to \mathcal{I}(U) \to \mathcal{Q}(U) \to 0. $$ for every $U \in \mathcal{B}$. Hence for any $\mathcal{U} \in \text{Cov}$ we get a short exact sequence of {\v C}ech complexes $$ 0 \to \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \to \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}) \to \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{Q}) \to 0 $$ since each term in the {\v C}ech complex is made up out of a product of values over elements of $\mathcal{B}$ by assumption (1). In particular we have a long exact sequence of {\v C}ech cohomology groups for any open covering $\mathcal{U} \in \text{Cov}$. This implies that $\mathcal{Q}$ is also an $\mathcal{O}_X$-module with vanishing higher {\v C}ech cohomology for all $\mathcal{U} \in \text{Cov}$. \medskip\noindent Next, we look at the long exact cohomology sequence $$ \xymatrix{ 0 \ar[r] & H^0(U, \mathcal{F}) \ar[r] & H^0(U, \mathcal{I}) \ar[r] & H^0(U, \mathcal{Q}) \ar[lld] \\ & H^1(U, \mathcal{F}) \ar[r] & H^1(U, \mathcal{I}) \ar[r] & H^1(U, \mathcal{Q}) \ar[lld] \\ & \ldots & \ldots & \ldots \\ } $$ for any $U \in \mathcal{B}$. Since $\mathcal{I}$ is injective we have $H^n(U, \mathcal{I}) = 0$ for $n > 0$ (see Derived Categories, Lemma \ref{derived-lemma-higher-derived-functors}). By the above we see that $H^0(U, \mathcal{I}) \to H^0(U, \mathcal{Q})$ is surjective and hence $H^1(U, \mathcal{F}) = 0$. Since $\mathcal{F}$ was an arbitrary $\mathcal{O}_X$-module with vanishing higher {\v C}ech cohomology for all $\mathcal{U} \in \text{Cov}$ we conclude that also $H^1(U, \mathcal{Q}) = 0$ since $\mathcal{Q}$ is another of these sheaves (see above). By the long exact sequence this in turn implies that $H^2(U, \mathcal{F}) = 0$. And so on and so forth.
Set $\mathcal{U} : f^{-1}(V) = \bigcup_{j \in J} f^{-1}(V_j)$. It is an open covering of $X$ and $$ \check{\mathcal{C}}^\bullet(\mathcal{V}, f_*\mathcal{I}) = \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}). $$ This is true because $$ f_*\mathcal{I}(V_{j_0 \ldots j_p}) = \mathcal{I}(f^{-1}(V_{j_0 \ldots j_p})) = \mathcal{I}(f^{-1}(V_{j_0}) \cap \ldots \cap f^{-1}(V_{j_p})) = \mathcal{I}(U_{j_0 \ldots j_p}). $$ Thus the first statement of the lemma follows from Lemma \ref{lemma-injective-trivial-cech}. The second statement follows from the first and Lemma \ref{lemma-cech-vanish}.
The statement for $p = 0$ is true because the product of sheaves is equal to the product of the underlying presheaves, see Sheaves, Section \ref{sheaves-section-limits-sheaves}. Proof for $p = 1$. Set $\mathcal{F} = \prod \mathcal{F}_i$. Let $\xi \in H^1(U, \mathcal{F})$ map to zero in $\prod H^1(U, \mathcal{F}_i)$. By locality of cohomology, see Lemma \ref{lemma-kill-cohomology-class-on-covering}, there exists an open covering $\mathcal{U} : U = \bigcup U_j$ such that $\xi|_{U_j} = 0$ for all $j$. By Lemma \ref{lemma-cech-h1} this means $\xi$ comes from an element $\check \xi \in \check H^1(\mathcal{U}, \mathcal{F})$. Since the maps $\check H^1(\mathcal{U}, \mathcal{F}_i) \to H^1(U, \mathcal{F}_i)$ are injective for all $i$ (by Lemma \ref{lemma-cech-h1}), and since the image of $\xi$ is zero in $\prod H^1(U, \mathcal{F}_i)$ we see that the image $\check \xi_i = 0$ in $\check H^1(\mathcal{U}, \mathcal{F}_i)$. However, since $\mathcal{F} = \prod \mathcal{F}_i$ we see that $\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})$ is the product of the complexes $\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}_i)$, hence by Homology, Lemma \ref{homology-lemma-product-abelian-groups-exact} we conclude that $\check \xi = 0$ as desired.
We will prove this using Derived Categories, Lemma \ref{derived-lemma-subcategory-right-acyclics}. Since every injective module is flasque we see that we can embed every $\mathcal{O}_X$-module into a flasque module, see Injectives, Lemma \ref{injectives-lemma-abelian-sheaves-space}. Thus it suffices to show that given a short exact sequence $$ 0 \to \mathcal{F} \to \mathcal{G} \to \mathcal{H} \to 0 $$ with $\mathcal{F}$, $\mathcal{G}$ flasque, then $\mathcal{H}$ is flasque and the sequence remains short exact after taking sections on any open of $X$. In fact, the second statement implies the first. Thus, let $U \subset X$ be an open subspace. Let $s \in \mathcal{H}(U)$. We will show that we can lift $s$ to a section of $\mathcal{G}$ over $U$. To do this consider the set $T$ of pairs $(V, t)$ where $V \subset U$ is open and $t \in \mathcal{G}(V)$ is a section mapping to $s|_V$ in $\mathcal{H}$. We put a partial ordering on $T$ by setting $(V, t) \leq (V', t')$ if and only if $V \subset V'$ and $t'|_V = t$. If $(V_\alpha, t_\alpha)$, $\alpha \in A$ is a totally ordered subset of $T$, then $V = \bigcup V_\alpha$ is open and there is a unique section $t \in \mathcal{G}(V)$ restricting to $t_\alpha$ over $V_\alpha$ by the sheaf condition on $\mathcal{G}$. Thus by Zorn's lemma there exists a maximal element $(V, t)$ in $T$. We will show that $V = U$ thereby finishing the proof. Namely, pick any $x \in U$. We can find a small open neighbourhood $W \subset U$ of $x$ and $t' \in \mathcal{G}(W)$ mapping to $s|_W$ in $\mathcal{H}$. Then $t'|_{W \cap V} - t|_{W \cap V}$ maps to zero in $\mathcal{H}$, hence comes from some section $r' \in \mathcal{F}(W \cap V)$. Using that $\mathcal{F}$ is flasque we find a section $r \in \mathcal{F}(W)$ restricting to $r'$ over $W \cap V$. Modifying $t'$ by the image of $r$ we may assume that $t$ and $t'$ restrict to the same section over $W \cap V$. By the sheaf condition of $\mathcal{G}$ we can find a section $\tilde t$ of $\mathcal{G}$ over $W \cup V$ restricting to $t$ and $t'$. By maximality of $(V, t)$ we see that $V \cup W = V$. Thus $x \in V$ and we are done.
The presheaves $\underline{H}^q(\mathcal{F})$ used in the statement of Lemma \ref{lemma-cech-spectral-sequence} are zero by Lemma \ref{lemma-flasque-acyclic}. Hence $\check{H}^p(U, \mathcal{F}) = H^p(U, \mathcal{F}) = 0$ by Lemma \ref{lemma-flasque-acyclic} again.
Let $Y$ be the set of nonempty subsets of $I$. We will use the letters $A, B, C, \ldots$ to denote elements of $Y$, i.e., nonempty subsets of $I$. For a finite nonempty subset $J \subset I$ let $$ V_J = \{A \in Y \mid J \subset A\} $$ This means that $V_{\{i\}} = \{A \in Y \mid i \in A\}$ and $V_J = \bigcap_{j \in J} V_{\{j\}}$. Then $V_J \subset V_K$ if and only if $J \supset K$. There is a unique topology on $Y$ such that the collection of subsets $V_J$ is a basis for the topology on $Y$. Any open is of the form $$ V = \bigcup\nolimits_{t \in T} V_{J_t} $$ for some family of finite subsets $J_t$. If $J_t \subset J_{t'}$ then we may remove $J_{t'}$ from the family without changing $V$. Thus we may assume there are no inclusions among the $J_t$. In this case the minimal elements of $V$ are the sets $A = J_t$. Hence we can read off the family $(J_t)_{t \in T}$ from the open $V$. \medskip\noindent We can completely understand open coverings in $Y$. First, because the elements $A \in Y$ are nonempty subsets of $I$ we have $$ Y = \bigcup\nolimits_{i \in I} V_{\{i\}} $$ To understand other coverings, let $V$ be as above and let $V_s \subset Y$ be an open corresponding to the family $(J_{s, t})_{t \in T_s}$. Then $$ V = \bigcup\nolimits_{s \in S} V_s $$ if and only if for each $t \in T$ there exists an $s \in S$ and $t_s \in T_s$ such that $J_t = J_{s, t_s}$. Namely, as the family $(J_t)_{t \in T}$ is minimal, the minimal element $A = J_t$ has to be in $V_s$ for some $s$, hence $A \in V_{J_{t_s}}$ for some $t_s \in T_s$. But since $A$ is also minimal in $V_s$ we conclude that $J_{t_s} = J_t$. \medskip\noindent Next we map the set of opens of $Y$ to opens of $X$. Namely, we send $Y$ to $U$, we use the rule $$ V_J \mapsto U_J = \bigcap\nolimits_{i \in J} U_i $$ on the opens $V_J$, and we extend it to arbitrary opens $V$ by the rule $$ V = \bigcup\nolimits_{t \in T} V_{J_t} \mapsto \bigcup\nolimits_{t \in T} U_{J_t} $$ The classification of open coverings of $Y$ given above shows that this rule transforms open coverings into open coverings. Thus we obtain an abelian sheaf $\mathcal{G}$ on $Y$ by setting $\mathcal{G}(Y) = \mathcal{F}(U)$ and for $V = \bigcup\nolimits_{t \in T} V_{J_t}$ setting $$ \mathcal{G}(V) = \mathcal{F}\left(\bigcup\nolimits_{t \in T} U_{J_t}\right) $$ and using the restriction maps of $\mathcal{F}$. \medskip\noindent With these preliminaries out of the way we can prove our lemma as follows. We have an open covering $\mathcal{V} : Y = \bigcup_{i \in I} V_{\{i\}}$ of $Y$. By construction we have an equality $$ \check{C}^\bullet(\mathcal{V}, \mathcal{G}) = \check{C}^\bullet(\mathcal{U}, \mathcal{F}) $$ of {\v C}ech complexes. Since the sheaf $\mathcal{G}$ is flasque on $Y$ (by our assumption on $\mathcal{F}$ in the statement of the lemma) the vanishing follows from Lemma \ref{lemma-flasque-acyclic-cech}.
Let $\Gamma_{res} : \textit{Mod}(\mathcal{O}_X) \to \text{Mod}_{\mathcal{O}_Y(Y)}$ be the functor which associates to an $\mathcal{O}_X$-module $\mathcal{F}$ the global sections of $\mathcal{F}$ viewed as a $\mathcal{O}_Y(Y)$-module via the map $f^\sharp : \mathcal{O}_Y(Y) \to \mathcal{O}_X(X)$. Let $restriction : \text{Mod}_{\mathcal{O}_X(X)} \to \text{Mod}_{\mathcal{O}_Y(Y)}$ be the restriction functor induced by $f^\sharp : \mathcal{O}_Y(Y) \to \mathcal{O}_X(X)$. Note that $restriction$ is exact so that its right derived functor is computed by simply applying the restriction functor, see Derived Categories, Lemma \ref{derived-lemma-right-derived-exact-functor}. It is clear that $$ \Gamma_{res} = restriction \circ \Gamma(X, -) = \Gamma(Y, -) \circ f_* $$ We claim that Derived Categories, Lemma \ref{derived-lemma-compose-derived-functors} applies to both compositions. For the first this is clear by our remarks above. For the second, it follows from Lemma \ref{lemma-pushforward-injective} which implies that injective $\mathcal{O}_X$-modules are mapped to $\Gamma(Y, -)$-acyclic sheaves on $Y$.
Consider the morphism of ringed spaces $(X, \mathcal{O}_X) \to (X, \underline{\mathbf{Z}}_X)$ given by the identity on the underlying topological space and by the unique map of sheaves of rings $\underline{\mathbf{Z}}_X \to \mathcal{O}_X$. Let $\mathcal{F}$ be an $\mathcal{O}_X$-module. Denote $\mathcal{F}_{ab}$ the same sheaf seen as an $\underline{\mathbf{Z}}_X$-module, i.e., seen as a sheaf of abelian groups. Let $\mathcal{F} \to \mathcal{I}^\bullet$ be an injective resolution. By Remark \ref{remark-elucidate-lemma} we see that $\Gamma(X, \mathcal{I}^\bullet)$ computes both $R\Gamma(X, \mathcal{F})$ and $R\Gamma(X, \mathcal{F}_{ab})$. This proves (1). \medskip\noindent To prove (2) we use (1) and Lemma \ref{lemma-describe-higher-direct-images}. The result follows immediately.
This is just the Grothendieck spectral sequence Derived Categories, Lemma \ref{derived-lemma-grothendieck-spectral-sequence} coming from the composition of functors $\Gamma_{res} = \Gamma(Y, -) \circ f_*$ where $\Gamma_{res}$ is as in the proof of Lemma \ref{lemma-before-Leray}. To see that the assumptions of Derived Categories, Lemma \ref{derived-lemma-grothendieck-spectral-sequence} are satisfied, see the proof of Lemma \ref{lemma-before-Leray} or Remark \ref{remark-elucidate-lemma}.
We are going to apply Derived Categories, Lemma \ref{derived-lemma-compose-derived-functors}. It is clear that $g_* \circ f_* = (g \circ f)_*$, see Sheaves, Lemma \ref{sheaves-lemma-pushforward-composition}. It remains to show that $f_*\mathcal{I}$ is $g_*$-acyclic. This follows from Lemma \ref{lemma-pushforward-injective} and the description of the higher direct images $R^ig_*$ in Lemma \ref{lemma-describe-higher-direct-images}.