\input{preamble}

% OK, start here.
%
\begin{document}

\title{Cohomology of Sheaves}


\maketitle

\phantomsection
\label{section-phantom}

\tableofcontents

\section{Introduction}
\label{section-introduction}

\noindent
In this document we work out some topics on cohomology of sheaves
on topological spaces. We mostly work in the generality of modules
over a sheaf of rings and we work with morphisms of ringed spaces.
To see what happens for sheaves on sites take a look at the chapter
Cohomology on Sites, Section \ref{sites-cohomology-section-introduction}.
Basic references are \cite{Godement} and \cite{Iversen}.





\section{Cohomology of sheaves}
\label{section-cohomology-sheaves}

\noindent
Let $X$ be a topological space. Let $\mathcal{F}$ be an abelian sheaf.
We know that the category of abelian sheaves on $X$ has enough injectives, see
Injectives, Lemma \ref{injectives-lemma-abelian-sheaves-space}.
Hence we can choose an injective resolution
$\mathcal{F}[0] \to \mathcal{I}^\bullet$. As is customary we define
\begin{equation}
\label{equation-cohomology}
H^i(X, \mathcal{F}) = H^i(\Gamma(X, \mathcal{I}^\bullet))
\end{equation}
to be the {\it $i$th cohomology group of the abelian sheaf $\mathcal{F}$}.
The family of functors $H^i(X, -)$ forms a universal $\delta$-functor
from $\textit{Ab}(X) \to \textit{Ab}$.

\medskip\noindent
Let $f : X \to Y$ be a continuous map of topological spaces. With
$\mathcal{F}[0] \to \mathcal{I}^\bullet$ as above
we define
\begin{equation}
\label{equation-higher-direct-image}
R^if_*\mathcal{F} = H^i(f_*\mathcal{I}^\bullet)
\end{equation}
to be the {\it $i$th higher direct image of $\mathcal{F}$}.
The family of functors $R^if_*$ forms a universal $\delta$-functor
from $\textit{Ab}(X) \to \textit{Ab}(Y)$.

\medskip\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}$ be an
$\mathcal{O}_X$-module. We know that the category of $\mathcal{O}_X$-modules
on $X$ has enough injectives, see
Injectives, Lemma \ref{injectives-lemma-sheaves-modules-space}.
Hence we can choose an injective resolution
$\mathcal{F}[0] \to \mathcal{I}^\bullet$. As is customary we define
\begin{equation}
\label{equation-cohomology-modules}
H^i(X, \mathcal{F}) = H^i(\Gamma(X, \mathcal{I}^\bullet))
\end{equation}
to be the {\it $i$th cohomology group of $\mathcal{F}$}.
The family of functors $H^i(X, -)$ forms a universal $\delta$-functor
from $\textit{Mod}(\mathcal{O}_X) \to \text{Mod}_{\mathcal{O}_X(X)}$.

\medskip\noindent
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of ringed
spaces. With $\mathcal{F}[0] \to \mathcal{I}^\bullet$ as above
we define
\begin{equation}
\label{equation-higher-direct-image-modules}
R^if_*\mathcal{F} = H^i(f_*\mathcal{I}^\bullet)
\end{equation}
to be the {\it $i$th higher direct image of $\mathcal{F}$}.
The family of functors $R^if_*$ forms a universal $\delta$-functor
from $\textit{Mod}(\mathcal{O}_X) \to \textit{Mod}(\mathcal{O}_Y)$.





\section{Derived functors}
\label{section-derived-functors}

\noindent
We briefly explain how to get right derived functors using resolution
functors. For the unbounded derived functors, please see
Section \ref{section-unbounded}.

\medskip\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. The category
$\textit{Mod}(\mathcal{O}_X)$ is abelian, see
Modules, Lemma \ref{modules-lemma-abelian}.
In this chapter we will write
$$
K(\mathcal{O}_X) = K(\textit{Mod}(\mathcal{O}_X))
\quad
\text{and}
\quad
D(\mathcal{O}_X) = D(\textit{Mod}(\mathcal{O}_X)).
$$
and similarly for the bounded versions for the triangulated categories
introduced in
Derived Categories, Definition \ref{derived-definition-complexes-notation} and
Definition \ref{derived-definition-unbounded-derived-category}.
By
Derived Categories, Remark \ref{derived-remark-big-abelian-category}
there exists a resolution functor
$$
j = j_X :
K^{+}(\textit{Mod}(\mathcal{O}_X))
\longrightarrow
K^{+}(\mathcal{I})
$$
where $\mathcal{I}$ is the strictly full additive subcategory of
$\textit{Mod}(\mathcal{O}_X)$ consisting of injective sheaves.
For any left exact functor
$F : \textit{Mod}(\mathcal{O}_X) \to \mathcal{B}$
into any abelian category $\mathcal{B}$ we will denote $RF$ the
right derived functor described in
Derived Categories, Section \ref{derived-section-right-derived-functor}
and constructed using the resolution functor $j_X$ just described:
\begin{equation}
\label{equation-RF}
RF = F \circ j_X' : D^{+}(X) \longrightarrow D^{+}(\mathcal{B})
\end{equation}
see
Derived Categories, Lemma \ref{derived-lemma-right-derived-functor}
for notation. Note that we may think of $RF$ as defined on
$\textit{Mod}(\mathcal{O}_X)$,
$\text{Comp}^{+}(\textit{Mod}(\mathcal{O}_X))$,
$K^{+}(X)$, or $D^{+}(X)$
depending on the situation. According to
Derived Categories, Definition \ref{derived-definition-higher-derived-functors}
we obtain the $i$th right derived functor
\begin{equation}
\label{equation-RFi}
R^iF = H^i \circ RF : \textit{Mod}(\mathcal{O}_X) \longrightarrow \mathcal{B}
\end{equation}
so that $R^0F = F$ and $\{R^iF, \delta\}_{i \geq 0}$ is universal
$\delta$-functor, see
Derived Categories, Lemma \ref{derived-lemma-higher-derived-functors}.

\medskip\noindent
Here are two special cases of this construction.
Given a ring $R$ we write $K(R) = K(\text{Mod}_R)$ and
$D(R) = D(\text{Mod}_R)$ and similarly for bounded versions.
For any open $U \subset X$ we have a left exact functor
$
\Gamma(U, -) :
\textit{Mod}(\mathcal{O}_X)
\longrightarrow
\text{Mod}_{\mathcal{O}_X(U)}
$
which gives rise to
\begin{equation}
\label{equation-total-derived-cohomology}
R\Gamma(U, -) :
D^{+}(X)
\longrightarrow
D^{+}(\mathcal{O}_X(U))
\end{equation}
by the discussion above. We set $H^i(U, -) = R^i\Gamma(U, -)$.
If $U = X$ we recover (\ref{equation-cohomology-modules}).
If $f : X \to Y$ is a morphism of ringed spaces, then we have
the left exact functor
$
f_* :
\textit{Mod}(\mathcal{O}_X)
\longrightarrow
\textit{Mod}(\mathcal{O}_Y)
$
which gives rise to the {\it derived pushforward}
\begin{equation}
\label{equation-total-derived-direct-image}
Rf_* :
D^{+}(X)
\longrightarrow
D^{+}(Y)
\end{equation}
The $i$th cohomology sheaf of $Rf_*\mathcal{F}^\bullet$ is denoted
$R^if_*\mathcal{F}^\bullet$ and called the $i$th {\it higher direct image}
in accordance with (\ref{equation-higher-direct-image-modules}).
The two displayed functors above are exact functors
of derived categories.

\medskip\noindent
{\bf Abuse of notation:} When the functor $Rf_*$, or any other
derived functor, is applied to a sheaf $\mathcal{F}$ on $X$ or a complex
of sheaves it is understood that $\mathcal{F}$ has been replaced by a
suitable resolution of $\mathcal{F}$. To facilitate this kind of
operation we will say, given an object
$\mathcal{F}^\bullet \in D(\mathcal{O}_X)$,
that a bounded below complex $\mathcal{I}^\bullet$ of injectives of
$\textit{Mod}(\mathcal{O}_X)$
{\it represents $\mathcal{F}^\bullet$ in the derived category}
if there exists a quasi-isomorphism
$\mathcal{F}^\bullet \to \mathcal{I}^\bullet$. In the same vein the phrase
``let $\alpha : \mathcal{F}^\bullet \to \mathcal{G}^\bullet$ be
a morphism of $D(\mathcal{O}_X)$''
does not mean that $\alpha$ is represented by a
morphism of complexes. If we have an actual morphism of complexes we will
say so.









\section{First cohomology and torsors}
\label{section-h1-torsors}

\begin{definition}
\label{definition-torsor}
Let $X$ be a topological space.
Let $\mathcal{G}$ be a sheaf of (possibly non-commutative) groups on $X$.
A {\it torsor}, or more precisely a {\it $\mathcal{G}$-torsor}, is a sheaf
of sets $\mathcal{F}$ on $X$ endowed with an action
$\mathcal{G} \times \mathcal{F} \to \mathcal{F}$ such that
\begin{enumerate}
\item whenever $\mathcal{F}(U)$ is nonempty the action
$\mathcal{G}(U) \times \mathcal{F}(U) \to \mathcal{F}(U)$
is simply transitive, and
\item for every $x \in X$ the stalk $\mathcal{F}_x$ is nonempty.
\end{enumerate}
A {\it morphism of $\mathcal{G}$-torsors} $\mathcal{F} \to \mathcal{F}'$
is simply a morphism of sheaves of sets compatible with the
$\mathcal{G}$-actions. The {\it trivial $\mathcal{G}$-torsor}
is the sheaf $\mathcal{G}$ endowed with the obvious left
$\mathcal{G}$-action.
\end{definition}

\noindent
It is clear that a morphism of torsors is automatically an isomorphism.

\begin{lemma}
\label{lemma-trivial-torsor}
Let $X$ be a topological space.
Let $\mathcal{G}$ be a sheaf of (possibly non-commutative) groups on $X$.
A $\mathcal{G}$-torsor $\mathcal{F}$ is trivial if and only if
$\mathcal{F}(X) \not = \emptyset$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-torsors-h1}
Let $X$ be a topological space.
Let $\mathcal{H}$ be an abelian sheaf on $X$.
There is a canonical bijection between the set of isomorphism
classes of $\mathcal{H}$-torsors and $H^1(X, \mathcal{H})$.
\end{lemma}

\begin{proof}
Let $\mathcal{F}$ be a $\mathcal{H}$-torsor.
Consider the free abelian sheaf $\mathbf{Z}[\mathcal{F}]$
on $\mathcal{F}$. It is the sheafification of the rule
which associates to $U \subset X$ open the collection of finite
formal sums $\sum n_i[s_i]$ with $n_i \in \mathbf{Z}$
and $s_i \in \mathcal{F}(U)$. There is a natural map
$$
\sigma : \mathbf{Z}[\mathcal{F}] \longrightarrow \underline{\mathbf{Z}}
$$
which to a local section $\sum n_i[s_i]$ associates $\sum n_i$.
The kernel of $\sigma$ is generated by the local section of the form
$[s] - [s']$. There is a canonical map
$a : \Ker(\sigma) \to \mathcal{H}$
which maps $[s] - [s'] \mapsto h$ where $h$ is the local section of
$\mathcal{H}$ such that $h \cdot s = s'$. Consider the pushout diagram
$$
\xymatrix{
0 \ar[r] &
\Ker(\sigma) \ar[r] \ar[d]^a &
\mathbf{Z}[\mathcal{F}] \ar[r] \ar[d] &
\underline{\mathbf{Z}} \ar[r] \ar[d] &
0 \\
0 \ar[r] &
\mathcal{H} \ar[r] &
\mathcal{E} \ar[r] &
\underline{\mathbf{Z}} \ar[r] &
0
}
$$
Here $\mathcal{E}$ is the extension obtained by pushout.
From the long exact cohomology sequence associated to the lower
short exact sequence we obtain an element
$\xi = \xi_\mathcal{F} \in H^1(X, \mathcal{H})$
by applying the boundary operator to $1 \in H^0(X, \underline{\mathbf{Z}})$.

\medskip\noindent
Conversely, given $\xi \in H^1(X, \mathcal{H})$ we can associate to
$\xi$ a torsor as follows. Choose an embedding $\mathcal{H} \to \mathcal{I}$
of $\mathcal{H}$ into an injective abelian sheaf $\mathcal{I}$. We set
$\mathcal{Q} = \mathcal{I}/\mathcal{H}$ so that we have a short exact
sequence
$$
\xymatrix{
0 \ar[r] &
\mathcal{H} \ar[r] &
\mathcal{I} \ar[r] &
\mathcal{Q} \ar[r] &
0
}
$$
The element $\xi$ is the image of a global section $q \in H^0(X, \mathcal{Q})$
because $H^1(X, \mathcal{I}) = 0$ (see
Derived Categories, Lemma \ref{derived-lemma-higher-derived-functors}).
Let $\mathcal{F} \subset \mathcal{I}$ be the subsheaf (of sets) of sections
that map to $q$ in the sheaf $\mathcal{Q}$. It is easy to verify that
$\mathcal{F}$ is a torsor.

\medskip\noindent
We omit the verification that the two constructions given
above are mutually inverse.
\end{proof}







\section{First cohomology and extensions}
\label{section-h1-extensions}

\begin{lemma}
\label{lemma-h1-extensions}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}$ be a sheaf of
$\mathcal{O}_X$-modules. There is a canonical bijection
$$
\Ext^1_{\textit{Mod}(\mathcal{O}_X)}(\mathcal{O}_X, \mathcal{F})
\longrightarrow
H^1(X, \mathcal{F})
$$
which associates to the extension
$$
0 \to \mathcal{F} \to \mathcal{E} \to \mathcal{O}_X \to 0
$$
the image of $1 \in \Gamma(X, \mathcal{O}_X)$ in $H^1(X, \mathcal{F})$.
\end{lemma}

\begin{proof}
Let us construct the inverse of the map given in the lemma. Let
$\xi \in H^1(X, \mathcal{F})$. Choose an injection
$\mathcal{F} \subset \mathcal{I}$ with $\mathcal{I}$ injective in
$\textit{Mod}(\mathcal{O}_X)$.
Set $\mathcal{Q} = \mathcal{I}/\mathcal{F}$.
By the long exact sequence of cohomology, we see that
$\xi$ is the image of a section
$\tilde \xi \in \Gamma(X, \mathcal{Q}) =
\Hom_{\mathcal{O}_X}(\mathcal{O}_X, \mathcal{Q})$.
Now, we just form the pullback
$$
\xymatrix{
0 \ar[r] &
\mathcal{F} \ar[r] \ar@{=}[d] &
\mathcal{E} \ar[r] \ar[d] &
\mathcal{O}_X \ar[r] \ar[d]^{\tilde \xi} &
0 \\
0 \ar[r] &
\mathcal{F} \ar[r] &
\mathcal{I} \ar[r] &
\mathcal{Q} \ar[r] &
0
}
$$
see Homology, Section \ref{homology-section-extensions}.
\end{proof}








\section{First cohomology and invertible sheaves}
\label{section-invertible-sheaves}

\noindent
The Picard group of a ringed space is defined in
Modules, Section \ref{modules-section-invertible}.

\begin{lemma}
\label{lemma-h1-invertible}
Let $(X, \mathcal{O}_X)$ be a locally ringed space.
There is a canonical isomorphism
$$
H^1(X, \mathcal{O}_X^*) = \Pic(X).
$$
of abelian groups.
\end{lemma}

\begin{proof}
Let $\mathcal{L}$ be an invertible $\mathcal{O}_X$-module.
Consider the presheaf $\mathcal{L}^*$ defined by the rule
$$
U \longmapsto \{s \in \mathcal{L}(U)
\text{ such that } \mathcal{O}_U \xrightarrow{s \cdot -} \mathcal{L}_U
\text{ is an isomorphism}\}
$$
This presheaf satisfies the sheaf condition. Moreover, if
$f \in \mathcal{O}_X^*(U)$ and $s \in \mathcal{L}^*(U)$, then clearly
$fs \in \mathcal{L}^*(U)$. By the same token, if $s, s' \in \mathcal{L}^*(U)$
then there exists a unique $f \in \mathcal{O}_X^*(U)$ such that
$fs = s'$. Moreover, the sheaf $\mathcal{L}^*$ has sections locally
by Modules, Lemma \ref{modules-lemma-invertible-is-locally-free-rank-1}.
In other words we
see that $\mathcal{L}^*$ is a $\mathcal{O}_X^*$-torsor. Thus we get
a map
$$
\begin{matrix}
\text{invertible sheaves on }(X, \mathcal{O}_X) \\
\text{ up to isomorphism}
\end{matrix}
\longrightarrow
\begin{matrix}
\mathcal{O}_X^*\text{-torsors} \\
\text{ up to isomorphism}
\end{matrix}
$$
We omit the verification that this is a homomorphism of abelian groups.
By
Lemma \ref{lemma-torsors-h1}
the right hand side is canonically
bijective to $H^1(X, \mathcal{O}_X^*)$.
Thus we have to show this map is injective and surjective.

\medskip\noindent
Injective. If the torsor $\mathcal{L}^*$ is trivial, this means by
Lemma \ref{lemma-trivial-torsor}
that $\mathcal{L}^*$ has a global section.
Hence this means exactly that $\mathcal{L} \cong \mathcal{O}_X$ is
the neutral element in $\Pic(X)$.

\medskip\noindent
Surjective. Let $\mathcal{F}$ be an $\mathcal{O}_X^*$-torsor.
Consider the presheaf of sets
$$
\mathcal{L}_1 : U \longmapsto
(\mathcal{F}(U) \times \mathcal{O}_X(U))/\mathcal{O}_X^*(U)
$$
where the action of $f \in \mathcal{O}_X^*(U)$ on
$(s, g)$ is $(fs, f^{-1}g)$. Then $\mathcal{L}_1$ is a presheaf
of $\mathcal{O}_X$-modules by setting
$(s, g) + (s', g') = (s, g + (s'/s)g')$ where $s'/s$ is the local
section $f$ of $\mathcal{O}_X^*$ such that $fs = s'$, and
$h(s, g) = (s, hg)$ for $h$ a local section of $\mathcal{O}_X$.
We omit the verification that the sheafification
$\mathcal{L} = \mathcal{L}_1^\#$ is an invertible $\mathcal{O}_X$-module
whose associated $\mathcal{O}_X^*$-torsor $\mathcal{L}^*$ is isomorphic
to $\mathcal{F}$.
\end{proof}













\section{Locality of cohomology}
\label{section-locality}

\noindent
The following lemma says there is no ambiguity in defining the cohomology
of a sheaf $\mathcal{F}$ over an open.

\begin{lemma}
\label{lemma-cohomology-of-open}
Let $X$ be a ringed space.
Let $U \subset X$ be an open subspace.
\begin{enumerate}
\item If $\mathcal{I}$ is an injective $\mathcal{O}_X$-module
then $\mathcal{I}|_U$ is an injective $\mathcal{O}_U$-module.
\item For any sheaf of $\mathcal{O}_X$-modules $\mathcal{F}$ we have
$H^p(U, \mathcal{F}) = H^p(U, \mathcal{F}|_U)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Denote $j : U \to X$ the open immersion.
Recall that the functor $j^{-1}$ of restriction to $U$ is a right adjoint
to the functor $j_!$ of extension by $0$, see
Sheaves, Lemma \ref{sheaves-lemma-j-shriek-modules}.
Moreover, $j_!$ is exact. Hence (1) follows from
Homology, Lemma \ref{homology-lemma-adjoint-preserve-injectives}.

\medskip\noindent
By definition $H^p(U, \mathcal{F}) = H^p(\Gamma(U, \mathcal{I}^\bullet))$
where $\mathcal{F} \to \mathcal{I}^\bullet$ is an injective resolution
in $\textit{Mod}(\mathcal{O}_X)$.
By the above we see that $\mathcal{F}|_U \to \mathcal{I}^\bullet|_U$
is an injective resolution in $\textit{Mod}(\mathcal{O}_U)$.
Hence $H^p(U, \mathcal{F}|_U)$ is equal to
$H^p(\Gamma(U, \mathcal{I}^\bullet|_U))$.
Of course $\Gamma(U, \mathcal{F}) = \Gamma(U, \mathcal{F}|_U)$ for
any sheaf $\mathcal{F}$ on $X$.
Hence the equality
in (2).
\end{proof}

\noindent
Let $X$ be a ringed space.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_X$-modules.
Let $U \subset V \subset X$ be open subsets.
Then there is a canonical {\it restriction mapping}
\begin{equation}
\label{equation-restriction-mapping}
H^n(V, \mathcal{F})
\longrightarrow
H^n(U, \mathcal{F}), \quad
\xi \longmapsto \xi|_U
\end{equation}
functorial in $\mathcal{F}$. Namely, choose any injective
resolution $\mathcal{F} \to \mathcal{I}^\bullet$. The restriction
mappings of the sheaves $\mathcal{I}^p$ give a morphism of complexes
$$
\Gamma(V, \mathcal{I}^\bullet)
\longrightarrow
\Gamma(U, \mathcal{I}^\bullet)
$$
The LHS is a complex representing $R\Gamma(V, \mathcal{F})$
and the RHS is a complex representing $R\Gamma(U, \mathcal{F})$.
We get the map on cohomology groups by applying the functor $H^n$.
As indicated we will use the notation $\xi \mapsto \xi|_U$ to denote this map.
Thus the rule $U \mapsto H^n(U, \mathcal{F})$ is a presheaf of
$\mathcal{O}_X$-modules. This presheaf is customarily denoted
$\underline{H}^n(\mathcal{F})$. We will give another interpretation
of this presheaf in Lemma \ref{lemma-include}.

\begin{lemma}
\label{lemma-kill-cohomology-class-on-covering}
Let $X$ be a ringed space.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_X$-modules.
Let $U \subset X$ be an open subspace.
Let $n > 0$ and let $\xi \in H^n(U, \mathcal{F})$.
Then there exists an open covering
$U = \bigcup_{i\in I} U_i$ such that $\xi|_{U_i} = 0$ for
all $i \in I$.
\end{lemma}

\begin{proof}
Let $\mathcal{F} \to \mathcal{I}^\bullet$ be an injective resolution.
Then
$$
H^n(U, \mathcal{F}) =
\frac{\Ker(\mathcal{I}^n(U) \to \mathcal{I}^{n + 1}(U))}
{\Im(\mathcal{I}^{n - 1}(U) \to \mathcal{I}^n(U))}.
$$
Pick an element $\tilde \xi \in \mathcal{I}^n(U)$ representing the
cohomology class in the presentation above. Since $\mathcal{I}^\bullet$
is an injective resolution of $\mathcal{F}$ and $n > 0$ we see that
the complex $\mathcal{I}^\bullet$ is exact in degree $n$. Hence
$\Im(\mathcal{I}^{n - 1} \to \mathcal{I}^n) =
\Ker(\mathcal{I}^n \to \mathcal{I}^{n + 1})$ as sheaves.
Since $\tilde \xi$ is a section of the kernel sheaf over $U$
we conclude there exists an open covering $U = \bigcup_{i \in I} U_i$
such that $\tilde \xi|_{U_i}$ is the image under $d$ of a section
$\xi_i \in \mathcal{I}^{n - 1}(U_i)$. By our definition of the
restriction $\xi|_{U_i}$ as corresponding to the class of
$\tilde \xi|_{U_i}$ we conclude.
\end{proof}

\begin{lemma}
\label{lemma-describe-higher-direct-images}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{F}$ be a $\mathcal{O}_X$-module.
The sheaves $R^if_*\mathcal{F}$ are the sheaves
associated to the presheaves
$$
V \longmapsto H^i(f^{-1}(V), \mathcal{F})
$$
with restriction mappings as in Equation (\ref{equation-restriction-mapping}).
There is a similar statement for $R^if_*$ applied to a
bounded below complex $\mathcal{F}^\bullet$.
\end{lemma}

\begin{proof}
Let $\mathcal{F} \to \mathcal{I}^\bullet$ be an injective resolution.
Then $R^if_*\mathcal{F}$ is by definition the $i$th cohomology sheaf
of the complex
$$
f_*\mathcal{I}^0 \to f_*\mathcal{I}^1 \to f_*\mathcal{I}^2 \to \ldots
$$
By definition of the abelian category structure on $\mathcal{O}_Y$-modules
this cohomology sheaf is the sheaf associated to the presheaf
$$
V
\longmapsto
\frac{\Ker(f_*\mathcal{I}^i(V) \to f_*\mathcal{I}^{i + 1}(V))}
{\Im(f_*\mathcal{I}^{i - 1}(V) \to f_*\mathcal{I}^i(V))}
$$
and this is obviously equal to
$$
\frac{\Ker(\mathcal{I}^i(f^{-1}(V)) \to \mathcal{I}^{i + 1}(f^{-1}(V)))}
{\Im(\mathcal{I}^{i - 1}(f^{-1}(V)) \to \mathcal{I}^i(f^{-1}(V)))}
$$
which is equal to $H^i(f^{-1}(V), \mathcal{F})$
and we win.
\end{proof}

\begin{lemma}
\label{lemma-localize-higher-direct-images}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
Let $V \subset Y$ be an open subspace.
Denote $g : f^{-1}(V) \to V$ the restriction of $f$.
Then we have
$$
R^pg_*(\mathcal{F}|_{f^{-1}(V)}) = (R^pf_*\mathcal{F})|_V
$$
There is a similar statement for the
derived image $Rf_*\mathcal{F}^\bullet$ where $\mathcal{F}^\bullet$
is a bounded below complex of $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
First proof. Apply Lemmas \ref{lemma-describe-higher-direct-images}
and \ref{lemma-cohomology-of-open} to see the displayed equality.
Second proof. Choose an injective resolution
$\mathcal{F} \to \mathcal{I}^\bullet$
and use that $\mathcal{F}|_{f^{-1}(V)} \to \mathcal{I}^\bullet|_{f^{-1}(V)}$
is an injective resolution also.
\end{proof}

\begin{remark}
\label{remark-daniel}
Here is a different approach to the proofs of
Lemmas \ref{lemma-kill-cohomology-class-on-covering} and
\ref{lemma-describe-higher-direct-images} above.
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $i_X : \textit{Mod}(\mathcal{O}_X) \to \textit{PMod}(\mathcal{O}_X)$
be the inclusion functor and let $\#$ be the sheafification functor.
Recall that $i_X$ is left exact and $\#$ is exact.
\begin{enumerate}
\item First prove Lemma \ref{lemma-include} below which says that the
right derived functors of $i_X$ are given by
$R^pi_X\mathcal{F} = \underline{H}^p(\mathcal{F})$.
Here is another proof: The equality is clear for $p = 0$.
Both $(R^pi_X)_{p \geq 0}$ and $(\underline{H}^p)_{p \geq 0}$
are delta functors vanishing on injectives, hence both are universal,
hence they are isomorphic. See Homology,
Section \ref{homology-section-cohomological-delta-functor}.
\item A restatement of Lemma \ref{lemma-kill-cohomology-class-on-covering}
is that $(\underline{H}^p(\mathcal{F}))^\# = 0$, $p > 0$ for any sheaf of
$\mathcal{O}_X$-modules $\mathcal{F}$.
To see this is true, use that ${}^\#$ is exact so
$$
(\underline{H}^p(\mathcal{F}))^\# =
(R^pi_X\mathcal{F})^\# =
R^p(\# \circ i_X)(\mathcal{F}) = 0
$$
because $\# \circ i_X$ is the identity functor.
\item Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module. The presheaf
$V \mapsto H^p(f^{-1}V, \mathcal{F})$ is equal to
$R^p (i_Y \circ f_*)\mathcal{F}$. You can prove this by noticing that
both give universal delta functors as in the argument of (1) above.
Hence Lemma \ref{lemma-describe-higher-direct-images}
says that $R^p f_* \mathcal{F}= (R^p (i_Y \circ f_*)\mathcal{F})^\#$.
Again using that $\#$ is exact a that $\# \circ i_Y$ is the identity
functor we see that
$$
R^p f_* \mathcal{F} =
R^p(\# \circ i_Y \circ f_*)\mathcal{F} =
(R^p (i_Y \circ f_*)\mathcal{F})^\#
$$
as desired.
\end{enumerate}
\end{remark}






\section{Mayer-Vietoris}
\label{section-mayer-vietoris}

\noindent
Below will construct the {\v C}ech-to-cohomology spectral sequence, see
Lemma \ref{lemma-cech-spectral-sequence}.
A special case of that spectral sequence is the Mayer-Vietoris
long exact sequence. Since it is such a basic, useful and easy to understand
variant of the spectral sequence we treat it here separately.

\begin{lemma}
\label{lemma-injective-restriction-surjective}
\begin{slogan}
Local sections in injective sheaves can be extended globally.
\end{slogan}
Let $X$ be a ringed space.
Let $U' \subset U \subset X$ be open subspaces.
For any injective $\mathcal{O}_X$-module $\mathcal{I}$ the
restriction mapping
$\mathcal{I}(U) \to \mathcal{I}(U')$ is surjective.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}[Mayer-Vietoris]
\label{lemma-mayer-vietoris}
Let $X$ be a ringed space. Suppose that $X = U \cup V$ is a
union of two open subsets. For every $\mathcal{O}_X$-module $\mathcal{F}$
there exists a long exact cohomology sequence
$$
0 \to
H^0(X, \mathcal{F}) \to
H^0(U, \mathcal{F}) \oplus H^0(V, \mathcal{F}) \to
H^0(U \cap V, \mathcal{F}) \to
H^1(X, \mathcal{F}) \to \ldots
$$
This long exact sequence is functorial in $\mathcal{F}$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}[Relative Mayer-Vietoris]
\label{lemma-relative-mayer-vietoris}
Let $f : X \to Y$ be a morphism of ringed spaces.
Suppose that $X = U \cup V$ is a union of two open subsets.
Denote $a = f|_U : U \to Y$, $b = f|_V : V \to Y$, and
$c = f|_{U \cap V} : U \cap V \to Y$.
For every $\mathcal{O}_X$-module $\mathcal{F}$
there exists a long exact sequence
$$
0 \to
f_*\mathcal{F} \to
a_*(\mathcal{F}|_U) \oplus b_*(\mathcal{F}|_V) \to
c_*(\mathcal{F}|_{U \cap V}) \to
R^1f_*\mathcal{F} \to \ldots
$$
This long exact sequence is functorial in $\mathcal{F}$.
\end{lemma}

\begin{proof}
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}.
\end{proof}




















\section{The {\v C}ech complex and {\v C}ech cohomology}
\label{section-cech}

\noindent
Let $X$ be a topological space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering,
see Topology, Basic notion (\ref{topology-item-covering}).
As is customary we denote
$U_{i_0\ldots i_p} = U_{i_0} \cap \ldots \cap U_{i_p}$ for the
$(p + 1)$-fold intersection of members of $\mathcal{U}$.
Let $\mathcal{F}$ be an abelian presheaf on $X$.
Set
$$
\check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})
=
\prod\nolimits_{(i_0, \ldots, i_p) \in I^{p + 1}}
\mathcal{F}(U_{i_0\ldots i_p}).
$$
This is an abelian group. For
$s \in \check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})$ we denote
$s_{i_0\ldots i_p}$ its value in $\mathcal{F}(U_{i_0\ldots i_p})$.
Note that if $s \in \check{\mathcal{C}}^1(\mathcal{U}, \mathcal{F})$
and $i, j \in I$ then $s_{ij}$ and $s_{ji}$ are both elements
of $\mathcal{F}(U_i \cap U_j)$ but there is no imposed
relation between $s_{ij}$ and $s_{ji}$. In other words, we are {\it not}
working with alternating cochains (these will be defined
in Section \ref{section-alternating-cech}). We define
$$
d : \check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}^{p + 1}(\mathcal{U}, \mathcal{F})
$$
by the formula
\begin{equation}
\label{equation-d-cech}
d(s)_{i_0\ldots i_{p + 1}}
=
\sum\nolimits_{j = 0}^{p + 1}
(-1)^j
s_{i_0\ldots \hat i_j \ldots i_{p + 1}}|_{U_{i_0\ldots i_{p + 1}}}
\end{equation}
It is straightforward to see that $d \circ d = 0$. In other words
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})$ is a complex.

\begin{definition}
\label{definition-cech-complex}
Let $X$ be a topological space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering.
Let $\mathcal{F}$ be an abelian presheaf on $X$.
The complex $\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})$
is the {\it {\v C}ech complex} associated to $\mathcal{F}$ and the
open covering $\mathcal{U}$. Its cohomology groups
$H^i(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}))$ are
called the {\it {\v C}ech cohomology groups} associated to
$\mathcal{F}$ and the covering $\mathcal{U}$.
They are denoted $\check H^i(\mathcal{U}, \mathcal{F})$.
\end{definition}

\begin{lemma}
\label{lemma-cech-h0}
Let $X$ be a topological space.
Let $\mathcal{F}$ be an abelian presheaf on $X$.
The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is an abelian sheaf and
\item for every open covering $\mathcal{U} : U = \bigcup_{i \in I} U_i$
the natural map
$$
\mathcal{F}(U) \to \check{H}^0(\mathcal{U}, \mathcal{F})
$$
is bijective.
\end{enumerate}
\end{lemma}

\begin{proof}
This is true since the sheaf condition is exactly that
$\mathcal{F}(U) \to \check{H}^0(\mathcal{U}, \mathcal{F})$
is bijective for every open covering.
\end{proof}

\begin{lemma}
\label{lemma-cech-trivial}
Let $X$ be a topological space. Let $\mathcal{F}$ be an abelian presheaf on $X$.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering. If
$U_i = U$ for some $i \in I$, then the extended {\v C}ech complex
$$
\mathcal{F}(U) \to \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
$$
obtained by putting $\mathcal{F}(U)$ in degree $-1$ with differential given by
the canonical map of $\mathcal{F}(U)$ into
$\check{\mathcal{C}}^0(\mathcal{U}, \mathcal{F})$
is homotopy equivalent to $0$.
\end{lemma}

\begin{proof}
Fix an element $i \in I$ with $U = U_i$. Observe that
$U_{i_0 \ldots i_p} = U_{i_0 \ldots \hat i_j \ldots i_p}$ if $i_j = i$.
Let us define a homotopy
$$
h :
\prod\nolimits_{i_0 \ldots i_{p + 1}} \mathcal{F}(U_{i_0 \ldots i_{p + 1}})
\longrightarrow
\prod\nolimits_{i_0 \ldots i_p} \mathcal{F}(U_{i_0 \ldots i_p})
$$
by the rule
$$
h(s)_{i_0 \ldots i_p} = s_{i i_0 \ldots i_p}
$$
In other words, $h : \prod_{i_0} \mathcal{F}(U_{i_0}) \to \mathcal{F}(U)$
is projection onto the factor $\mathcal{F}(U_i) = \mathcal{F}(U)$
and in general the map $h$ equals the projection onto the factors
$\mathcal{F}(U_{i i_1 \ldots i_{p + 1}}) =
\mathcal{F}(U_{i_1 \ldots i_{p + 1}})$.
We compute
\begin{align*}
(dh + hd)(s)_{i_0 \ldots i_p}
& =
\sum\nolimits_{j = 0}^p
(-1)^j
h(s)_{i_0 \ldots \hat i_j \ldots i_p}
+
d(s)_{i i_0 \ldots i_p}\\
& =
\sum\nolimits_{j = 0}^p
(-1)^j
s_{i i_0 \ldots \hat i_j \ldots i_p}
+
s_{i_0 \ldots i_p}
+
\sum\nolimits_{j = 0}^p
(-1)^{j + 1}
s_{i i_0 \ldots \hat i_j \ldots i_p} \\
& =
s_{i_0 \ldots i_p}
\end{align*}
This proves the identity map is homotopic to zero as desired.
\end{proof}






\section{{\v C}ech cohomology as a functor on presheaves}
\label{section-cech-functor}

\noindent
Warning: In this section we work almost exclusively with presheaves and
categories of presheaves and the results are completely wrong in the
setting of sheaves and categories of sheaves!

\medskip\noindent
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering.
Let $\mathcal{F}$ be a presheaf of $\mathcal{O}_X$-modules.
We have the {\v C}ech complex
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})$
of $\mathcal{F}$ just by thinking of $\mathcal{F}$
as a presheaf of abelian groups. However, each term
$\check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})$ has a natural
structure of a $\mathcal{O}_X(U)$-module and the differential is given by
$\mathcal{O}_X(U)$-module maps. Moreover, it is clear that the
construction
$$
\mathcal{F} \longmapsto \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
$$
is functorial in $\mathcal{F}$. In fact, it is a functor
\begin{equation}
\label{equation-cech-functor}
\check{\mathcal{C}}^\bullet(\mathcal{U}, -) :
\textit{PMod}(\mathcal{O}_X)
\longrightarrow
\text{Comp}^{+}(\text{Mod}_{\mathcal{O}_X(U)})
\end{equation}
see
Derived Categories, Definition \ref{derived-definition-complexes-notation}
for notation. Recall that the category of bounded below complexes
in an abelian category is an abelian category, see
Homology, Lemma \ref{homology-lemma-cat-cochain-abelian}.

\begin{lemma}
\label{lemma-cech-exact-presheaves}
The functor given by Equation (\ref{equation-cech-functor})
is an exact functor (see Homology, Lemma \ref{homology-lemma-exact-functor}).
\end{lemma}

\begin{proof}
For any open $W \subset U$ the functor
$\mathcal{F} \mapsto \mathcal{F}(W)$ is an additive exact functor
from $\textit{PMod}(\mathcal{O}_X)$ to $\text{Mod}_{\mathcal{O}_X(U)}$.
The terms
$\check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})$
of the complex are products of these exact functors and hence exact.
Moreover a sequence of complexes is exact if and only if the sequence
of terms in a given degree is exact. Hence the lemma follows.
\end{proof}

\begin{lemma}
\label{lemma-cech-cohomology-delta-functor-presheaves}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering.
The functors $\mathcal{F} \mapsto \check{H}^n(\mathcal{U}, \mathcal{F})$
form a $\delta$-functor from the abelian category of
presheaves of $\mathcal{O}_X$-modules to the category
of $\mathcal{O}_X(U)$-modules (see
Homology, Definition \ref{homology-definition-cohomological-delta-functor}).
\end{lemma}

\begin{proof}
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.
\end{proof}


\noindent
In the formulation of the following lemma we use the functor $j_{p!}$ of
extension by $0$ for presheaves of modules
relative to an open immersion $j : U \to X$.
See Sheaves, Section \ref{sheaves-section-open-immersions}. For any open
$W \subset X$ and any presheaf $\mathcal{G}$ of $\mathcal{O}_X|_U$-modules
we have
$$
(j_{p!}\mathcal{G})(W) =
\left\{
\begin{matrix}
\mathcal{G}(W) & \text{if } W \subset U \\
0 & \text{else.}
\end{matrix}
\right.
$$
Moreover, the functor $j_{p!}$ is a left adjoint to the restriction functor
see Sheaves, Lemma \ref{sheaves-lemma-j-shriek-modules}.
In particular we have the following formula
$$
\Hom_{\mathcal{O}_X}(j_{p!}\mathcal{O}_U, \mathcal{F})
=
\Hom_{\mathcal{O}_U}(\mathcal{O}_U, \mathcal{F}|_U)
=
\mathcal{F}(U).
$$
Since the functor $\mathcal{F} \mapsto \mathcal{F}(U)$ is an exact functor
on the category of presheaves we conclude that the presheaf
$j_{p!}\mathcal{O}_U$ is a projective object in the category
$\textit{PMod}(\mathcal{O}_X)$, see
Homology, Lemma \ref{homology-lemma-characterize-projectives}.

\medskip\noindent
Note that if we are given open subsets $U \subset V \subset X$
with associated open immersions $j_U, j_V$, then we have a canonical
map $(j_U)_{p!}\mathcal{O}_U \to (j_V)_{p!}\mathcal{O}_V$. It is the
identity on sections over any open $W \subset U$ and $0$ else.
In terms of the identification
$\Hom_{\mathcal{O}_X}((j_U)_{p!}\mathcal{O}_U, (j_V)_{p!}\mathcal{O}_V) =
(j_V)_{p!}\mathcal{O}_V(U) = \mathcal{O}_V(U)$ it corresponds to
the element $1 \in \mathcal{O}_V(U)$.

\begin{lemma}
\label{lemma-cech-map-into}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be a covering.
Denote $j_{i_0\ldots i_p} : U_{i_0 \ldots i_p} \to X$ the open immersion.
Consider the chain complex $K(\mathcal{U})_\bullet$
of presheaves of $\mathcal{O}_X$-modules
$$
\ldots
\to
\bigoplus_{i_0i_1i_2} (j_{i_0i_1i_2})_{p!}\mathcal{O}_{U_{i_0i_1i_2}}
\to
\bigoplus_{i_0i_1} (j_{i_0i_1})_{p!}\mathcal{O}_{U_{i_0i_1}}
\to
\bigoplus_{i_0} (j_{i_0})_{p!}\mathcal{O}_{U_{i_0}}
\to 0 \to \ldots
$$
where the last nonzero term is placed in degree $0$
and where the map
$$
(j_{i_0\ldots i_{p + 1}})_{p!}\mathcal{O}_{U_{i_0\ldots i_{p + 1}}}
\longrightarrow
(j_{i_0\ldots \hat i_j \ldots i_{p + 1}})_{p!}
\mathcal{O}_{U_{i_0\ldots \hat i_j \ldots i_{p + 1}}}
$$
is given by $(-1)^j$ times the canonical map.
Then there is an isomorphism
$$
\Hom_{\mathcal{O}_X}(K(\mathcal{U})_\bullet, \mathcal{F})
=
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
$$
functorial in $\mathcal{F} \in \Ob(\textit{PMod}(\mathcal{O}_X))$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-homology-complex}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be a covering.
Let $\mathcal{O}_\mathcal{U} \subset \mathcal{O}_X$
be the image presheaf of the map
$\bigoplus j_{p!}\mathcal{O}_{U_i} \to \mathcal{O}_X$.
The chain complex $K(\mathcal{U})_\bullet$ of presheaves
of Lemma \ref{lemma-cech-map-into} above has homology presheaves
$$
H_i(K(\mathcal{U})_\bullet) =
\left\{
\begin{matrix}
0 & \text{if} & i \not = 0 \\
\mathcal{O}_\mathcal{U} & \text{if} & i = 0
\end{matrix}
\right.
$$
\end{lemma}

\begin{proof}
Consider the extended complex $K^{ext}_\bullet$ one gets by putting
$\mathcal{O}_\mathcal{U}$ in degree $-1$ with the obvious map
$K(\mathcal{U})_0 =
\bigoplus_{i_0} (j_{i_0})_{p!}\mathcal{O}_{U_{i_0}} \to
\mathcal{O}_\mathcal{U}$.
It suffices to show that taking sections of this extended complex over
any open $W \subset X$ leads to an acyclic complex.
In fact, we claim that for every $W \subset X$ the complex
$K^{ext}_\bullet(W)$ is homotopy equivalent to the zero complex.
Write $I = I_1 \amalg I_2$ where $W \subset U_i$ if and only
if $i \in I_1$.

\medskip\noindent
If $I_1 = \emptyset$, then the complex $K^{ext}_\bullet(W) = 0$ so there is
nothing to prove.

\medskip\noindent
If $I_1 \not = \emptyset$, then
$\mathcal{O}_\mathcal{U}(W) = \mathcal{O}_X(W)$
and
$$
K^{ext}_p(W) =
\bigoplus\nolimits_{i_0 \ldots i_p \in I_1} \mathcal{O}_X(W).
$$
This is true because of the simple description of the presheaves
$(j_{i_0 \ldots i_p})_{p!}\mathcal{O}_{U_{i_0 \ldots i_p}}$.
Moreover, the differential of the complex $K^{ext}_\bullet(W)$
is given by
$$
d(s)_{i_0 \ldots i_p} =
\sum\nolimits_{j = 0, \ldots, p + 1} \sum\nolimits_{i \in I_1}
(-1)^j s_{i_0 \ldots i_{j - 1} i i_j \ldots i_p}.
$$
The sum is finite as the element $s$ has finite support.
Fix an element $i_{\text{fix}} \in I_1$. Define a map
$$
h : K^{ext}_p(W) \longrightarrow K^{ext}_{p + 1}(W)
$$
by the rule
$$
h(s)_{i_0 \ldots i_{p + 1}} =
\left\{
\begin{matrix}
0 & \text{if} & i_0 \not = i_{\text{fix}} \\
s_{i_1 \ldots i_{p + 1}} & \text{if} & i_0 = i_{\text{fix}}
\end{matrix}
\right.
$$
We will use the shorthand
$h(s)_{i_0 \ldots i_{p + 1}} = (i_0 = i_{\text{fix}}) s_{i_1 \ldots i_p}$
for this. Then we compute
\begin{eqnarray*}
& & (dh + hd)(s)_{i_0 \ldots i_p} \\
& = &
\sum_j \sum_{i \in I_1} (-1)^j h(s)_{i_0 \ldots i_{j - 1} i i_j \ldots i_p}
+
(i = i_0) d(s)_{i_1 \ldots i_p} \\
& = &
s_{i_0 \ldots i_p} +
\sum_{j \geq 1}\sum_{i \in I_1}
(-1)^j (i_0 = i_{\text{fix}}) s_{i_1 \ldots i_{j - 1} i i_j \ldots i_p}
+
(i_0 = i_{\text{fix}}) d(s)_{i_1 \ldots i_p}
\end{eqnarray*}
which is equal to $s_{i_0 \ldots i_p}$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-cech-cohomology-derived-presheaves}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$
be an open covering of $U \subset X$.
The {\v C}ech cohomology functors $\check{H}^p(\mathcal{U}, -)$
are canonically isomorphic as a $\delta$-functor to
the right derived functors of the functor
$$
\check{H}^0(\mathcal{U}, -) :
\textit{PMod}(\mathcal{O}_X)
\longrightarrow
\text{Mod}_{\mathcal{O}_X(U)}.
$$
Moreover, there is a functorial quasi-isomorphism
$$
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
R\check{H}^0(\mathcal{U}, \mathcal{F})
$$
where the right hand side indicates the right derived functor
$$
R\check{H}^0(\mathcal{U}, -) :
D^{+}(\textit{PMod}(\mathcal{O}_X))
\longrightarrow
D^{+}(\mathcal{O}_X(U))
$$
of the left exact functor $\check{H}^0(\mathcal{U}, -)$.
\end{lemma}

\begin{proof}
Note that the category of presheaves of $\mathcal{O}_X$-modules
has enough injectives, see
Injectives, Proposition \ref{injectives-proposition-presheaves-modules}.
Note that $\check{H}^0(\mathcal{U}, -)$ is a left exact functor
from the category of presheaves of $\mathcal{O}_X$-modules
to the category of $\mathcal{O}_X(U)$-modules.
Hence the derived functor and the right derived functor exist, see
Derived Categories, Section \ref{derived-section-right-derived-functor}.

\medskip\noindent
Let $\mathcal{I}$ be a injective presheaf of $\mathcal{O}_X$-modules.
In this case the functor $\Hom_{\mathcal{O}_X}(-, \mathcal{I})$
is exact on $\textit{PMod}(\mathcal{O}_X)$. By
Lemma \ref{lemma-cech-map-into} we have
$$
\Hom_{\mathcal{O}_X}(K(\mathcal{U})_\bullet, \mathcal{I})
=
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}).
$$
By Lemma \ref{lemma-homology-complex} we have that $K(\mathcal{U})_\bullet$ is
quasi-isomorphic to $\mathcal{O}_\mathcal{U}[0]$. Hence by
the exactness of Hom into $\mathcal{I}$ mentioned above we see
that $\check{H}^i(\mathcal{U}, \mathcal{I}) = 0$ for all
$i > 0$. Thus the $\delta$-functor $(\check{H}^n, \delta)$
(see Lemma \ref{lemma-cech-cohomology-delta-functor-presheaves})
satisfies the assumptions of
Homology, Lemma \ref{homology-lemma-efface-implies-universal},
and hence is a universal $\delta$-functor.

\medskip\noindent
By
Derived Categories, Lemma \ref{derived-lemma-higher-derived-functors}
also the sequence $R^i\check{H}^0(\mathcal{U}, -)$
forms a universal $\delta$-functor. By the uniqueness of universal
$\delta$-functors, see
Homology, Lemma \ref{homology-lemma-uniqueness-universal-delta-functor}
we conclude that
$R^i\check{H}^0(\mathcal{U}, -) = \check{H}^i(\mathcal{U}, -)$.
This is enough for most applications
and the reader is suggested to skip the rest of the proof.

\medskip\noindent
Let $\mathcal{F}$ be any presheaf of $\mathcal{O}_X$-modules.
Choose an injective resolution $\mathcal{F} \to \mathcal{I}^\bullet$
in the category $\textit{PMod}(\mathcal{O}_X)$.
Consider the double complex
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet)$ with terms
$\check{\mathcal{C}}^p(\mathcal{U}, \mathcal{I}^q)$.
Consider the associated total complex
$\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet))$,
see Homology, Definition \ref{homology-definition-associated-simple-complex}.
There is a map of complexes
$$
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet))
$$
coming from the maps
$\check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})
\to \check{\mathcal{C}}^p(\mathcal{U}, \mathcal{I}^0)$
and there is a map of complexes
$$
\check{H}^0(\mathcal{U}, \mathcal{I}^\bullet)
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet))
$$
coming from the maps
$\check{H}^0(\mathcal{U}, \mathcal{I}^q) \to
\check{\mathcal{C}}^0(\mathcal{U}, \mathcal{I}^q)$.
Both of these maps are quasi-isomorphisms by an application of
Homology, Lemma \ref{homology-lemma-double-complex-gives-resolution}.
Namely, the columns of the double complex are exact in positive degrees
because the {\v C}ech complex as a functor is exact
(Lemma \ref{lemma-cech-exact-presheaves})
and the rows of the double complex are exact in positive degrees
since as we just saw the higher {\v C}ech cohomology groups of the injective
presheaves $\mathcal{I}^q$ are zero.
Since quasi-isomorphisms become invertible
in $D^{+}(\mathcal{O}_X(U))$ this gives the last displayed morphism
of the lemma. We omit the verification that this morphism is
functorial.
\end{proof}





\section{{\v C}ech cohomology and cohomology}
\label{section-cech-cohomology-cohomology}

\begin{lemma}
\label{lemma-injective-trivial-cech}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be a covering.
Let $\mathcal{I}$ be an injective $\mathcal{O}_X$-module.
Then
$$
\check{H}^p(\mathcal{U}, \mathcal{I}) =
\left\{
\begin{matrix}
\mathcal{I}(U) & \text{if} & p = 0 \\
0 & \text{if} & p > 0
\end{matrix}
\right.
$$
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-cech-cohomology}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be a covering.
There is a transformation
$$
\check{\mathcal{C}}^\bullet(\mathcal{U}, -)
\longrightarrow
R\Gamma(U, -)
$$
of functors
$\textit{Mod}(\mathcal{O}_X) \to D^{+}(\mathcal{O}_X(U))$.
In particular this provides canonical maps
$\check{H}^p(\mathcal{U}, \mathcal{F}) \to H^p(U, \mathcal{F})$ for
$\mathcal{F}$ ranging over $\textit{Mod}(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-cech-h1}
Let $X$ be a topological space. Let $\mathcal{H}$ be an abelian sheaf
on $X$. Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$ be an open covering.
The map
$$
\check{H}^1(\mathcal{U}, \mathcal{H}) \longrightarrow H^1(X, \mathcal{H})
$$
is injective and identifies $\check{H}^1(\mathcal{U}, \mathcal{H})$ via
the bijection of Lemma \ref{lemma-torsors-h1}
with the set of isomorphism classes of $\mathcal{H}$-torsors
which restrict to trivial torsors over each $U_i$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-include}
Let $X$ be a ringed space.
Consider the functor
$i : \textit{Mod}(\mathcal{O}_X) \to \textit{PMod}(\mathcal{O}_X)$.
It is a left exact functor with right derived functors given by
$$
R^pi(\mathcal{F}) = \underline{H}^p(\mathcal{F}) :
U \longmapsto H^p(U, \mathcal{F})
$$
see discussion in Section \ref{section-locality}.
\end{lemma}

\begin{proof}
It is clear that $i$ is left exact.
Choose an injective resolution $\mathcal{F} \to \mathcal{I}^\bullet$.
By definition $R^pi$ is the $p$th cohomology {\it presheaf}
of the complex $\mathcal{I}^\bullet$. In other words, the
sections of $R^pi(\mathcal{F})$ over an open $U$ are given by
$$
\frac{\Ker(\mathcal{I}^n(U) \to \mathcal{I}^{n + 1}(U))}
{\Im(\mathcal{I}^{n - 1}(U) \to \mathcal{I}^n(U))}.
$$
which is the definition of $H^p(U, \mathcal{F})$.
\end{proof}

\begin{lemma}
\label{lemma-cech-spectral-sequence}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be a covering.
For any sheaf of $\mathcal{O}_X$-modules $\mathcal{F}$ there
is a spectral sequence $(E_r, d_r)_{r \geq 0}$ with
$$
E_2^{p, q} = \check{H}^p(\mathcal{U}, \underline{H}^q(\mathcal{F}))
$$
converging to $H^{p + q}(U, \mathcal{F})$.
This spectral sequence is functorial in $\mathcal{F}$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-cech-spectral-sequence-application}
Let $X$ be a ringed space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be a covering.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
Assume that $H^i(U_{i_0 \ldots i_p}, \mathcal{F}) = 0$
for all $i > 0$, all $p \geq 0$ and all $i_0, \ldots, i_p \in I$.
Then $\check{H}^p(\mathcal{U}, \mathcal{F}) = H^p(U, \mathcal{F})$
as $\mathcal{O}_X(U)$-modules.
\end{lemma}

\begin{proof}
We will use the spectral sequence of
Lemma \ref{lemma-cech-spectral-sequence}.
The assumptions mean that $E_2^{p, q} = 0$ for all $(p, q)$ with
$q \not = 0$. Hence the spectral sequence degenerates at $E_2$
and the result follows.
\end{proof}

\begin{lemma}
\label{lemma-ses-cech-h1}
Let $X$ be a ringed space.
Let
$$
0 \to \mathcal{F} \to \mathcal{G} \to \mathcal{H} \to 0
$$
be a short exact sequence of $\mathcal{O}_X$-modules.
Let $U \subset X$ be an open subset.
If there exists a cofinal system of open coverings $\mathcal{U}$
of $U$ such that $\check{H}^1(\mathcal{U}, \mathcal{F}) = 0$,
then the map $\mathcal{G}(U) \to \mathcal{H}(U)$ is
surjective.
\end{lemma}

\begin{proof}
Take an element $s \in \mathcal{H}(U)$. Choose an open covering
$\mathcal{U} : U = \bigcup_{i \in I} U_i$ such that
(a) $\check{H}^1(\mathcal{U}, \mathcal{F}) = 0$ and (b)
$s|_{U_i}$ is the image of a section $s_i \in \mathcal{G}(U_i)$.
Since we can certainly find a covering such that (b) holds
it follows from the assumptions of the lemma that we can find
a covering such that (a) and (b) both hold.
Consider the sections
$$
s_{i_0i_1} = s_{i_1}|_{U_{i_0i_1}} - s_{i_0}|_{U_{i_0i_1}}.
$$
Since $s_i$ lifts $s$ we see that $s_{i_0i_1} \in \mathcal{F}(U_{i_0i_1})$.
By the vanishing of $\check{H}^1(\mathcal{U}, \mathcal{F})$ we can
find sections $t_i \in \mathcal{F}(U_i)$ such that
$$
s_{i_0i_1} = t_{i_1}|_{U_{i_0i_1}} - t_{i_0}|_{U_{i_0i_1}}.
$$
Then clearly the sections $s_i - t_i$ satisfy the sheaf condition
and glue to a section of $\mathcal{G}$ over $U$ which maps to $s$.
Hence we win.
\end{proof}

\begin{lemma}
\label{lemma-cech-vanish}
\begin{slogan}
If higher {\v C}ech cohomology of an abelian sheaf vanishes for all open covers,
then higher cohomology vanishes.
\end{slogan}
Let $X$ be a ringed space.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module such that
$$
\check{H}^p(\mathcal{U}, \mathcal{F}) = 0
$$
for all $p > 0$ and any open covering $\mathcal{U} : U = \bigcup_{i \in I} U_i$
of an open of $X$. Then $H^p(U, \mathcal{F}) = 0$ for all $p > 0$
and any open $U \subset X$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-cech-vanish-basis}
(Variant of Lemma \ref{lemma-cech-vanish}.)
Let $X$ be a ringed space.
Let $\mathcal{B}$ be a basis for the topology on $X$.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
Assume there exists a set of open coverings $\text{Cov}$
with the following properties:
\begin{enumerate}
\item For every $\mathcal{U} \in \text{Cov}$
with $\mathcal{U} : U = \bigcup_{i \in I} U_i$ we have
$U, U_i \in \mathcal{B}$ and every $U_{i_0 \ldots i_p} \in \mathcal{B}$.
\item For every $U \in \mathcal{B}$ the open coverings of $U$
occurring in $\text{Cov}$ is a cofinal system of open coverings
of $U$.
\item For every $\mathcal{U} \in \text{Cov}$ we have
$\check{H}^p(\mathcal{U}, \mathcal{F}) = 0$ for all $p > 0$.
\end{enumerate}
Then $H^p(U, \mathcal{F}) = 0$ for all $p > 0$ and any $U \in \mathcal{B}$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-pushforward-injective}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{I}$ be an injective $\mathcal{O}_X$-module.
Then
\begin{enumerate}
\item $\check{H}^p(\mathcal{V}, f_*\mathcal{I}) = 0$
for all $p > 0$ and any open covering
$\mathcal{V} : V = \bigcup_{j \in J} V_j$ of $Y$.
\item $H^p(V, f_*\mathcal{I}) = 0$ for all $p > 0$ and
every open $V \subset Y$.
\end{enumerate}
In other words, $f_*\mathcal{I}$ is right acyclic for $\Gamma(V, -)$
(see
Derived Categories, Definition \ref{derived-definition-derived-functor})
for any $V \subset Y$ open.
\end{lemma}

\begin{proof}
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}.
\end{proof}

\noindent
The following lemma implies in particular that
$f_* : \textit{Ab}(X) \to \textit{Ab}(Y)$ transforms injective
abelian sheaves into injective abelian sheaves.

\begin{lemma}
\label{lemma-pushforward-injective-flat}
Let $f : X \to Y$ be a morphism of ringed spaces.
Assume $f$ is flat.
Then $f_*\mathcal{I}$ is an injective $\mathcal{O}_Y$-module
for any injective $\mathcal{O}_X$-module $\mathcal{I}$.
\end{lemma}

\begin{proof}
In this case the functor $f^*$ transforms injections into injections
(Modules, Lemma \ref{modules-lemma-pullback-flat}).
Hence the result follows from
Homology, Lemma \ref{homology-lemma-adjoint-preserve-injectives}.
\end{proof}

\begin{lemma}
\label{lemma-cohomology-products}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $I$ be a set.
For $i \in I$ let  $\mathcal{F}_i$ be an $\mathcal{O}_X$-module.
Let $U \subset X$ be open. The canonical map
$$
H^p(U, \prod\nolimits_{i \in I} \mathcal{F}_i)
\longrightarrow
\prod\nolimits_{i \in I} H^p(U, \mathcal{F}_i)
$$
is an isomorphism for $p = 0$ and injective for $p = 1$.
\end{lemma}

\begin{proof}
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.
\end{proof}







\section{Flasque sheaves}
\label{section-flasque}

\noindent
Here is the definition.

\begin{definition}
\label{definition-flasque}
Let $X$ be a topological space. We say a presheaf of sets
$\mathcal{F}$ is {\it flasque} or {\it flabby} if for every
$U \subset V$ open in $X$ the restriction map
$\mathcal{F}(V) \to \mathcal{F}(U)$ is surjective.
\end{definition}

\noindent
We will use this terminology also for abelian sheaves and
sheaves of modules if $X$ is a ringed space.
Clearly it suffices to assume the restriction maps
$\mathcal{F}(X) \to \mathcal{F}(U)$ is surjective for every
open $U \subset X$.

\begin{lemma}
\label{lemma-injective-flasque}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Then any injective $\mathcal{O}_X$-module is flasque.
\end{lemma}

\begin{proof}
This is a reformulation of Lemma \ref{lemma-injective-restriction-surjective}.
\end{proof}

\begin{lemma}
\label{lemma-flasque-acyclic}
Let $(X, \mathcal{O}_X)$ be a ringed space. Any flasque $\mathcal{O}_X$-module
is acyclic for $R\Gamma(X, -)$ as well as $R\Gamma(U, -)$ for any
open $U$ of $X$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\noindent
The following lemma does not hold for flasque presheaves.

\begin{lemma}
\label{lemma-flasque-acyclic-cech}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_X$-modules.
Let $\mathcal{U} : U = \bigcup U_i$ be an open covering.
If $\mathcal{F}$ is flasque, then
$\check{H}^p(\mathcal{U}, \mathcal{F}) = 0$ for $p > 0$.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}
\label{lemma-flasque-acyclic-pushforward}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism
of ringed spaces. Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_X$-modules.
If $\mathcal{F}$ is flasque, then $R^pf_*\mathcal{F} = 0$ for $p > 0$.
\end{lemma}

\begin{proof}
Immediate from 
Lemma \ref{lemma-describe-higher-direct-images} and
Lemma \ref{lemma-flasque-acyclic}.
\end{proof}

\noindent
The following lemma can be proved by an elementary induction
argument for finite coverings, compare with the discussion
of {\v C}ech cohomology in \cite{FOAG}.

\begin{lemma}
\label{lemma-vanishing-ravi}
Let $X$ be a topological space. Let $\mathcal{F}$ be an abelian sheaf
on $X$. Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an
open covering. Assume the restriction mappings
$\mathcal{F}(U) \to \mathcal{F}(U')$ are surjective
for $U'$ an arbitrary union of opens of the form $U_{i_0 \ldots i_p}$.
Then $\check{H}^p(\mathcal{U}, \mathcal{F})$
vanishes for $p > 0$.
\end{lemma}

\begin{proof}
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}.
\end{proof}




\section{The Leray spectral sequence}
\label{section-Leray}

\begin{lemma}
\label{lemma-before-Leray}
Let $f : X \to Y$ be a morphism of ringed spaces.
There is a commutative diagram
$$
\xymatrix{
D^{+}(X) \ar[rr]_-{R\Gamma(X, -)} \ar[d]_{Rf_*} & &
D^{+}(\mathcal{O}_X(X)) \ar[d]^{\text{restriction}} \\
D^{+}(Y) \ar[rr]^-{R\Gamma(Y, -)} & &
D^{+}(\mathcal{O}_Y(Y))
}
$$
More generally for any $V \subset Y$ open and $U = f^{-1}(V)$ there
is a commutative diagram
$$
\xymatrix{
D^{+}(X) \ar[rr]_-{R\Gamma(U, -)} \ar[d]_{Rf_*} & &
D^{+}(\mathcal{O}_X(U)) \ar[d]^{\text{restriction}} \\
D^{+}(Y) \ar[rr]^-{R\Gamma(V, -)} & &
D^{+}(\mathcal{O}_Y(V))
}
$$
See also Remark \ref{remark-elucidate-lemma} for more explanation.
\end{lemma}

\begin{proof}
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 an $\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$.
\end{proof}

\begin{remark}
\label{remark-elucidate-lemma}
Here is a down-to-earth explanation of the meaning of
Lemma \ref{lemma-before-Leray}. It says that given
$f : X \to Y$ and $\mathcal{F} \in \textit{Mod}(\mathcal{O}_X)$
and given an injective resolution $\mathcal{F} \to \mathcal{I}^\bullet$
we have
$$
\begin{matrix}
R\Gamma(X, \mathcal{F}) & \text{is represented by} &
\Gamma(X, \mathcal{I}^\bullet) \\
Rf_*\mathcal{F} & \text{is represented by} & f_*\mathcal{I}^\bullet \\
R\Gamma(Y, Rf_*\mathcal{F}) & \text{is represented by} &
\Gamma(Y, f_*\mathcal{I}^\bullet)
\end{matrix}
$$
the last fact coming from Leray's acyclicity lemma
(Derived Categories, Lemma \ref{derived-lemma-leray-acyclicity})
and Lemma \ref{lemma-pushforward-injective}.
Finally, it combines this with the trivial observation that
$$
\Gamma(X, \mathcal{I}^\bullet)
=
\Gamma(Y, f_*\mathcal{I}^\bullet).
$$
to arrive at the commutativity of the diagram of the lemma.
\end{remark}

\begin{lemma}
\label{lemma-modules-abelian}
Let $X$ be a ringed space.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
\begin{enumerate}
\item The cohomology groups $H^i(U, \mathcal{F})$ for $U \subset X$ open
of $\mathcal{F}$ computed as an $\mathcal{O}_X$-module, or computed as an
abelian sheaf are identical.
\item Let $f : X \to Y$ be a morphism of ringed spaces.
The higher direct images $R^if_*\mathcal{F}$ of $\mathcal{F}$
computed as an $\mathcal{O}_X$-module, or computed as an abelian sheaf
are identical.
\end{enumerate}
There are similar statements in the case of bounded below
complexes of $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
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.
\end{proof}

\begin{lemma}[Leray spectral sequence]
\label{lemma-Leray}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{F}^\bullet$ be
a bounded below complex of $\mathcal{O}_X$-modules.
There is a spectral sequence
$$
E_2^{p, q} = H^p(Y, R^qf_*(\mathcal{F}^\bullet))
$$
converging to $H^{p + q}(X, \mathcal{F}^\bullet)$.
\end{lemma}

\begin{proof}
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}.
\end{proof}

\begin{remark}
\label{remark-Leray-ss-more-structure}
The Leray spectral sequence, the way we proved it in Lemma \ref{lemma-Leray}
is a spectral sequence of $\Gamma(Y, \mathcal{O}_Y)$-modules. However, it
is quite easy to see that it is in fact a spectral sequence of
$\Gamma(X, \mathcal{O}_X)$-modules. For example $f$ gives rise to
a morphism of ringed spaces
$f' :  (X, \mathcal{O}_X) \to (Y, f_*\mathcal{O}_X)$.
By Lemma \ref{lemma-modules-abelian} the terms $E_r^{p, q}$ of the
Leray spectral sequence for an $\mathcal{O}_X$-module $\mathcal{F}$
and $f$ are identical with those for $\mathcal{F}$ and $f'$
at least for $r \geq 2$. Namely, they both agree with the terms of the Leray
spectral sequence for $\mathcal{F}$ as an abelian sheaf.
And since $(f_*\mathcal{O}_X)(Y) = \mathcal{O}_X(X)$ we see the result.
It is often the case
that the Leray spectral sequence carries additional structure.
\end{remark}

\begin{lemma}
\label{lemma-apply-Leray}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
\begin{enumerate}
\item If $R^qf_*\mathcal{F} = 0$ for $q > 0$, then
$H^p(X, \mathcal{F}) = H^p(Y, f_*\mathcal{F})$ for all $p$.
\item If $H^p(Y, R^qf_*\mathcal{F}) = 0$ for all $q$ and $p > 0$, then
$H^q(X, \mathcal{F}) = H^0(Y, R^qf_*\mathcal{F})$ for all $q$.
\end{enumerate}
\end{lemma}

\begin{proof}
These are two simple conditions that force the Leray spectral sequence to
degenerate at $E_2$. You can also prove these facts directly (without using
the spectral sequence) which is a good exercise in cohomology of sheaves.
\end{proof}

\begin{lemma}
\label{lemma-higher-direct-images-compose}
\begin{slogan}
The total derived functor of a composition is the
composition of the total derived functors.
\end{slogan}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of ringed spaces.
In this case $Rg_* \circ Rf_* = R(g \circ f)_*$ as functors
from $D^{+}(X) \to D^{+}(Z)$.
\end{lemma}

\begin{proof}
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}.
\end{proof}

\begin{lemma}[Relative Leray spectral sequence]
\label{lemma-relative-Leray}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of ringed spaces.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
There is a spectral sequence with
$$
E_2^{p, q} = R^pg_*(R^qf_*\mathcal{F})
$$
converging to $R^{p + q}(g \circ f)_*\mathcal{F}$.
This spectral sequence is functorial in $\mathcal{F}$, and there
is a version for bounded below complexes of $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
This is a Grothendieck spectral sequence for composition of functors
and follows from Lemma \ref{lemma-higher-direct-images-compose} and
Derived Categories, Lemma \ref{derived-lemma-grothendieck-spectral-sequence}.
\end{proof}














\section{Functoriality of cohomology}
\label{section-functoriality}

\begin{lemma}
\label{lemma-functoriality}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{G}^\bullet$, resp.\ $\mathcal{F}^\bullet$ be
a bounded below complex of $\mathcal{O}_Y$-modules,
resp.\ $\mathcal{O}_X$-modules. Let
$\varphi : \mathcal{G}^\bullet \to f_*\mathcal{F}^\bullet$
be a morphism of complexes. There is a canonical morphism
$$
\mathcal{G}^\bullet
\longrightarrow
Rf_*(\mathcal{F}^\bullet)
$$
in $D^{+}(Y)$. Moreover this construction is functorial in the triple
$(\mathcal{G}^\bullet, \mathcal{F}^\bullet, \varphi)$.
\end{lemma}

\begin{proof}
Choose an injective resolution $\mathcal{F}^\bullet \to \mathcal{I}^\bullet$.
By definition $Rf_*(\mathcal{F}^\bullet)$ is represented by
$f_*\mathcal{I}^\bullet$ in $K^{+}(\mathcal{O}_Y)$.
The composition
$$
\mathcal{G}^\bullet \to f_*\mathcal{F}^\bullet \to f_*\mathcal{I}^\bullet
$$
is a morphism in $K^{+}(Y)$ which turns
into the morphism of the lemma upon applying the
localization functor $j_Y : K^{+}(Y) \to D^{+}(Y)$.
\end{proof}

\noindent
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{G}$ be an $\mathcal{O}_Y$-module and let
$\mathcal{F}$ be an $\mathcal{O}_X$-module. Recall that an
$f$-map $\varphi$ from $\mathcal{G}$ to $\mathcal{F}$ is a map
$\varphi : \mathcal{G} \to f_*\mathcal{F}$, or what is the same
thing, a map $\varphi : f^*\mathcal{G} \to \mathcal{F}$.
See Sheaves, Definition \ref{sheaves-definition-f-map}.
Such an $f$-map gives rise to a morphism of complexes
\begin{equation}
\label{equation-functorial-derived}
\varphi :
R\Gamma(Y, \mathcal{G})
\longrightarrow
R\Gamma(X, \mathcal{F})
\end{equation}
in $D^{+}(\mathcal{O}_Y(Y))$. Namely, we use the morphism
$\mathcal{G} \to Rf_*\mathcal{F}$ in $D^{+}(Y)$ of
Lemma \ref{lemma-functoriality}, and we apply $R\Gamma(Y, -)$.
By Lemma \ref{lemma-before-Leray} we see that
$R\Gamma(X, \mathcal{F}) = R\Gamma(Y, Rf_*\mathcal{F})$
and we get the displayed arrow. We spell this out completely in
Remark \ref{remark-explain-arrow} below.
In particular it gives
rise to maps on cohomology
\begin{equation}
\label{equation-functorial}
\varphi : H^i(Y, \mathcal{G}) \longrightarrow H^i(X, \mathcal{F}).
\end{equation}

\begin{remark}
\label{remark-explain-arrow}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{G}$ be an $\mathcal{O}_Y$-module.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
Let $\varphi$ be an $f$-map from $\mathcal{G}$ to $\mathcal{F}$.
Choose a resolution $\mathcal{F} \to \mathcal{I}^\bullet$
by a complex of injective $\mathcal{O}_X$-modules.
Choose resolutions $\mathcal{G} \to \mathcal{J}^\bullet$ and
$f_*\mathcal{I}^\bullet \to (\mathcal{J}')^\bullet$ by complexes
of injective $\mathcal{O}_Y$-modules. By
Derived Categories, Lemma \ref{derived-lemma-morphisms-lift}
there exists a map of complexes
$\beta$ such that the diagram
\begin{equation}
\label{equation-choice}
\xymatrix{
\mathcal{G} \ar[d] \ar[r] &
f_*\mathcal{F} \ar[r] &
f_*\mathcal{I}^\bullet \ar[d] \\
\mathcal{J}^\bullet \ar[rr]^\beta & &
(\mathcal{J}')^\bullet
}
\end{equation}
commutes. Applying global section functors we see
that we get a diagram
$$
\xymatrix{
 & & \Gamma(Y, f_*\mathcal{I}^\bullet) \ar[d]_{qis} \ar@{=}[r] &
\Gamma(X, \mathcal{I}^\bullet) \\
\Gamma(Y, \mathcal{J}^\bullet) \ar[rr]^\beta & &
\Gamma(Y, (\mathcal{J}')^\bullet) &
}
$$
The complex on the bottom left represents $R\Gamma(Y, \mathcal{G})$
and the complex on the top right represents $R\Gamma(X, \mathcal{F})$.
The vertical arrow is a quasi-isomorphism by
Lemma \ref{lemma-before-Leray} which becomes invertible after
applying the localization functor
$K^{+}(\mathcal{O}_Y(Y)) \to D^{+}(\mathcal{O}_Y(Y))$.
The arrow (\ref{equation-functorial-derived}) is given by the
composition of the horizontal map by the inverse of the vertical map.
\end{remark}





\section{Refinements and {\v C}ech cohomology}
\label{section-refinements-cech}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{U} : X = \bigcup_{i \in I} U_i$ and
$\mathcal{V} : X = \bigcup_{j \in J} V_j$ be open coverings.
Assume that $\mathcal{U}$ is a refinement of $\mathcal{V}$.
Choose a map $c : I \to J$ such that $U_i \subset V_{c(i)}$
for all $i \in I$. This induces a map of {\v C}ech complexes
$$
\gamma :
\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}),
\quad
(\xi_{j_0 \ldots j_p})
\longmapsto
(\xi_{c(i_0) \ldots c(i_p)}|_{U_{i_0 \ldots i_p}})
$$
functorial in the sheaf of $\mathcal{O}_X$-modules $\mathcal{F}$.
Suppose that $c' : I \to J$ is a second map such that
$U_i \subset V_{c'(i)}$ for all $i \in I$. Then the corresponding maps
$\gamma$ and $\gamma'$ are homotopic. Namely,
$\gamma - \gamma' = \text{d} \circ h + h \circ \text{d}$
with
$h : \check{\mathcal{C}}^{p + 1}(\mathcal{V}, \mathcal{F}) \to
\check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})$
given by the rule
$$
h(\alpha)_{i_0 \ldots i_p} =
\sum\nolimits_{a = 0}^{p}
(-1)^a
\alpha_{c(i_0)\ldots c(i_a) c'(i_a) \ldots c'(i_p)}
$$
We omit the computation showing this works; please see the discussion
following (\ref{equation-transformation}) for the proof in a more general
case. In particular, the map on {\v C}ech cohomology groups is independent
of the choice of $c$. Moreover, it is clear that if
$\mathcal{W} : X = \bigcup_{k \in K} W_k$ is a third open covering
and $\mathcal{V}$ is a refinement of $\mathcal{W}$, then the composition
of the maps
$$
\check{\mathcal{C}}^\bullet(\mathcal{W}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
$$
associated to maps $I \to J$ and $J \to K$ is the map associated
to the composition $I \to K$.
In particular, we can define the {\v C}ech cohomology
groups
$$
\check{H}^p(X, \mathcal{F}) =
\colim_\mathcal{U} \check{H}^p(\mathcal{U}, \mathcal{F})
$$
where the colimit is over all open coverings of $X$ preordered by refinement.

\medskip\noindent
It turns out that the maps $\gamma$ defined above are compatible with
the map to cohomology, in other words, the composition
$$
\check{H}^p(\mathcal{V}, \mathcal{F}) \to
\check{H}^p(\mathcal{U}, \mathcal{F})
\xrightarrow{\text{Lemma \ref{lemma-cech-cohomology}}}
H^p(X, \mathcal{F})
$$
is the canonical map from the first group to cohomology of
Lemma \ref{lemma-cech-cohomology}. 
In the lemma below we will prove this in a slightly more general
setting. A consequence is that we obtain a well defined map
\begin{equation}
\label{equation-cech-to-cohomology}
\check{H}^p(X, \mathcal{F}) =
\colim_\mathcal{U} \check{H}^p(\mathcal{U}, \mathcal{F})
\longrightarrow
H^p(X, \mathcal{F})
\end{equation}
from {\v C}ech cohomology to cohomology.

\begin{lemma}
\label{lemma-functoriality-cech}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\varphi : f^*\mathcal{G} \to \mathcal{F}$ be an $f$-map
from an $\mathcal{O}_Y$-module $\mathcal{G}$ to an
$\mathcal{O}_X$-module $\mathcal{F}$.
Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$ and
$\mathcal{V} : Y = \bigcup_{j \in J} V_j$ be open coverings.
Assume that $\mathcal{U}$ is a refinement of
$f^{-1}\mathcal{V} : X = \bigcup_{j \in J} f^{-1}(V_j)$.
In this case there exists a commutative diagram
$$
\xymatrix{
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \ar[r] &
R\Gamma(X, \mathcal{F}) \\
\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{G}) \ar[r]
\ar[u]^\gamma &
R\Gamma(Y, \mathcal{G}) \ar[u]
}
$$
in $D^{+}(\mathcal{O}_X(X))$ with horizontal arrows given by
Lemma \ref{lemma-cech-cohomology} and right vertical arrow by
(\ref{equation-functorial-derived}).
In particular we get commutative diagrams of cohomology groups
$$
\xymatrix{
\check{H}^p(\mathcal{U}, \mathcal{F}) \ar[r] &
H^p(X, \mathcal{F}) \\
\check{H}^p(\mathcal{V}, \mathcal{G}) \ar[r]
\ar[u]^\gamma &
H^p(Y, \mathcal{G}) \ar[u]
}
$$
where the right vertical arrow is (\ref{equation-functorial})
\end{lemma}

\begin{proof}
We first define the left vertical arrow. Namely, choose a map
$c : I \to J$ such that $U_i \subset f^{-1}(V_{c(i)})$ for all
$i \in I$. In degree $p$ we define the map by the rule
$$
\gamma(s)_{i_0 \ldots i_p} = \varphi(s)_{c(i_0) \ldots c(i_p)}
$$
This makes sense because $\varphi$ does indeed induce maps
$\mathcal{G}(V_{c(i_0) \ldots c(i_p)}) \to \mathcal{F}(U_{i_0 \ldots i_p})$
by assumption. It is also clear that this defines a morphism of complexes.
Choose injective resolutions
$\mathcal{F} \to \mathcal{I}^\bullet$ on $X$ and
$\mathcal{G} \to J^\bullet$ on $Y$. According to
the proof of Lemma \ref{lemma-cech-cohomology} we introduce the double
complexes $A^{\bullet, \bullet}$ and $B^{\bullet, \bullet}$
with terms
$$
B^{p, q} = \check{\mathcal{C}}^p(\mathcal{V}, \mathcal{J}^q)
\quad
\text{and}
\quad
A^{p, q} = \check{\mathcal{C}}^p(\mathcal{U}, \mathcal{I}^q).
$$
As in Remark \ref{remark-explain-arrow} above we also choose an
injective resolution
$f_*\mathcal{I} \to (\mathcal{J}')^\bullet$ on $Y$ and a morphism
of complexes $\beta : \mathcal{J} \to (\mathcal{J}')^\bullet$
making (\ref{equation-choice}) commutes. We introduce some more
double complexes, namely $(B')^{\bullet, \bullet}$ and
$(B''){\bullet, \bullet}$ with
$$
(B')^{p, q} = \check{\mathcal{C}}^p(\mathcal{V}, (\mathcal{J}')^q)
\quad
\text{and}
\quad
(B'')^{p, q} = \check{\mathcal{C}}^p(\mathcal{V}, f_*\mathcal{I}^q).
$$
Note that there is an $f$-map of complexes from
$f_*\mathcal{I}^\bullet$ to $\mathcal{I}^\bullet$. Hence
it is clear that the same rule as above defines a morphism
of double complexes
$$
\gamma : (B'')^{\bullet, \bullet} \longrightarrow A^{\bullet, \bullet}.
$$
Consider the diagram of complexes
$$
\xymatrix{
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
\ar[r] &
\text{Tot}(A^{\bullet, \bullet}) & & &
\Gamma(X, \mathcal{I}^\bullet) \ar[lll]^{qis}
\ar@{=}[ddl]\\
\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{G})
\ar[r] \ar[u]^\gamma &
\text{Tot}(B^{\bullet, \bullet}) \ar[r]^\beta &
\text{Tot}((B')^{\bullet, \bullet}) &
\text{Tot}((B'')^{\bullet, \bullet}) \ar[l] \ar[llu]_{s\gamma} \\
& \Gamma(Y, \mathcal{J}^\bullet) \ar[u]^{qis} \ar[r]^\beta &
\Gamma(Y, (\mathcal{J}')^\bullet) \ar[u] &
\Gamma(Y, f_*\mathcal{I}^\bullet) \ar[u] \ar[l]_{qis}
}
$$
The two horizontal arrows with targets $\text{Tot}(A^{\bullet, \bullet})$ and
$\text{Tot}(B^{\bullet, \bullet})$
are the ones explained in Lemma \ref{lemma-cech-cohomology}.
The left upper shape (a pentagon) is commutative simply
because (\ref{equation-choice}) is commutative.
The two lower squares are trivially commutative.
It is also immediate from the definitions that the
right upper shape (a square) is commutative.
The result of the lemma now follows from the definitions
and the fact that going around the diagram on the outer sides
from $\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{G})$
to $\Gamma(X, \mathcal{I}^\bullet)$ either on top or on bottom
is the same (where you have to invert any quasi-isomorphisms along the way).
\end{proof}





\section{Cohomology on Hausdorff quasi-compact spaces}
\label{section-cohomology-LC}

\noindent
For such a space {\v C}ech cohomology agrees with cohomology.

\begin{lemma}
\label{lemma-cech-always}
Let $X$ be a topological space. Let $\mathcal{F}$ be an abelian sheaf. Then
the map $\check{H}^1(X, \mathcal{F}) \to H^1(X, \mathcal{F})$ defined
in (\ref{equation-cech-to-cohomology}) is an isomorphism.
\end{lemma}

\begin{proof}
Let $\mathcal{U}$ be an open covering of $X$.
By Lemma \ref{lemma-cech-spectral-sequence}
there is an exact sequence
$$
0 \to \check{H}^1(\mathcal{U}, \mathcal{F}) \to H^1(X, \mathcal{F})
\to \check{H}^0(\mathcal{U}, \underline{H}^1(\mathcal{F}))
$$
Thus the map is injective. To show surjectivity it suffices to show that
any element of $\check{H}^0(\mathcal{U}, \underline{H}^1(\mathcal{F}))$
maps to zero after replacing $\mathcal{U}$ by a refinement.
This is immediate from the definitions and the fact that
$\underline{H}^1(\mathcal{F})$ is a presheaf of abelian groups
whose sheafification is zero by locality of cohomology, see
Lemma \ref{lemma-kill-cohomology-class-on-covering}.
\end{proof}

\begin{lemma}
\label{lemma-cech-Hausdorff-quasi-compact}
Let $X$ be a Hausdorff and quasi-compact topological space. Let
$\mathcal{F}$ be an abelian sheaf on $X$. Then
the map $\check{H}^n(X, \mathcal{F}) \to H^n(X, \mathcal{F})$ defined
in (\ref{equation-cech-to-cohomology}) is an isomorphism for
all $n$.
\end{lemma}

\begin{proof}
We already know that $\check{H}^n(X, -) \to H^n(X, -)$
is an isomorphism of functors for $n = 0, 1$, see
Lemma \ref{lemma-cech-always}.
The functors $H^n(X, -)$ form a universal $\delta$-functor, see
Derived Categories, Lemma \ref{derived-lemma-higher-derived-functors}.
If we show that $\check{H}^n(X, -)$ forms a universal $\delta$-functor
and that $\check{H}^n(X, -) \to H^n(X, -)$ is compatible with boundary
maps, then the map will automatically be an isomorphism by uniqueness
of universal $\delta$-functors, see
Homology, Lemma \ref{homology-lemma-uniqueness-universal-delta-functor}.

\medskip\noindent
Let $0 \to \mathcal{F} \to \mathcal{G} \to \mathcal{H} \to 0$
be a short exact sequence of abelian sheaves on $X$.
Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$ be an open covering.
This gives a complex of complexes
$$
0 \to \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \to
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{G}) \to
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{H}) \to 0
$$
which is in general not exact on the right. The sequence defines
the maps
$$
\check{H}^n(\mathcal{U}, \mathcal{F}) \to
\check{H}^n(\mathcal{U}, \mathcal{G}) \to
\check{H}^n(\mathcal{U}, \mathcal{H})
$$
but isn't good enough to define a boundary operator
$\delta : \check{H}^n(\mathcal{U}, \mathcal{H}) \to
\check{H}^{n + 1}(\mathcal{U}, \mathcal{F})$. Indeed
such a thing will not exist in general. However, given an
element $\overline{h} \in \check{H}^n(\mathcal{U}, \mathcal{H})$
which is the cohomology class of a cocycle
$h = (h_{i_0 \ldots i_n})$
we can choose open coverings
$$
U_{i_0 \ldots i_n} = \bigcup W_{i_0 \ldots i_n, k}
$$
such that $h_{i_0 \ldots i_n}|_{W_{i_0 \ldots i_n, k}}$
lifts to a section of $\mathcal{G}$ over $W_{i_0 \ldots i_n, k}$.
By Topology, Lemma \ref{topology-lemma-refine-covering}
(this is where we use the assumption that $X$ is hausdorff and quasi-compact)
we can choose an open covering $\mathcal{V} : X = \bigcup_{j \in J} V_j$
and $\alpha : J \to I$ such that $V_j \subset U_{\alpha(j)}$
(it is a refinement) and such that for all $j_0, \ldots, j_n \in J$
there is a $k$ such that
$V_{j_0 \ldots j_n} \subset W_{\alpha(j_0) \ldots \alpha(j_n), k}$.
We obtain maps of complexes
$$
\xymatrix{
0 \ar[r] &
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \ar[d] \ar[r] &
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{G}) \ar[d] \ar[r] &
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{H}) \ar[d] \ar[r] &
0 \\
0 \ar[r] &
\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{F}) \ar[r] &
\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{G}) \ar[r] &
\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{H}) \ar[r] &
0
}
$$
In fact, the vertical arrows are the maps of complexes used
to define the transition maps between the {\v C}ech cohomology groups.
Our choice of refinement shows that we may choose
$$
g_{j_0 \ldots j_n} \in
\mathcal{G}(V_{j_0 \ldots j_n}),\quad
g_{j_0 \ldots j_n} \longmapsto
h_{\alpha(j_0) \ldots \alpha(j_n)}|_{V_{j_0 \ldots j_n}}
$$
The cochain $g = (g_{j_0 \ldots j_n})$ is not a cocycle
in general but we know that its {\v C}ech boundary $\text{d}(g)$
maps to zero in $\check{\mathcal{C}}^{n + 1}(\mathcal{V}, \mathcal{H})$
(by the commutative diagram above and the fact that $h$ is a cocycle).
Hence $\text{d}(g)$ is a cocycle in
$\check{\mathcal{C}}^\bullet(\mathcal{V}, \mathcal{F})$.
This allows us to define
$$
\delta(\overline{h}) = \text{class of }\text{d}(g)\text{ in }
\check{H}^{n + 1}(\mathcal{V}, \mathcal{F})
$$
Now, given an element $\xi \in \check{H}^n(X, \mathcal{G})$
we choose an open covering $\mathcal{U}$ and an element
$\overline{h} \in \check{H}^n(\mathcal{U}, \mathcal{G})$
mapping to $\xi$ in the colimit defining {\v C}ech cohomology.
Then we choose $\mathcal{V}$ and $g$ as above and set
$\delta(\xi)$ equal to the image of $\delta(\overline{h})$
in $\check{H}^n(X, \mathcal{F})$.
At this point a lot of properties have to be checked, all of which
are straightforward. For example, we need to check that our construction
is independent of the choice of
$\mathcal{U}, \overline{h}, \mathcal{V}, \alpha : J \to I, g$.
The class of $\text{d}(g)$ is independent of the choice of the lifts
$g_{i_0 \ldots i_n}$ because the difference will be a coboundary.
Independence of $\alpha$ holds\footnote{This is an important
check because the nonuniqueness of $\alpha$ is the only thing preventing
us from taking the colimit of {\v C}ech complexes over all open
coverings of $X$ to get a short exact sequence of complexes computing
{\v C}ech cohomology.}
because a different choice
of $\alpha$ determines homotopic vertical maps of complexes
in the diagram above, see Section \ref{section-refinements-cech}.
For the other choices we use that given a finite collection
of coverings of $X$ we can always find a covering refining all
of them. We also need to check additivity which is shown in the same manner.
Finally, we need to check that the maps
$\check{H}^n(X, -) \to H^n(X, -)$ are compatible
with boundary maps. To do this we choose injective
resolutions
$$
\xymatrix{
0 \ar[r] &
\mathcal{F} \ar[r] \ar[d] &
\mathcal{G} \ar[r] \ar[d] &
\mathcal{H} \ar[r] \ar[d] &
0 \\
0 \ar[r] &
\mathcal{I}_1^\bullet \ar[r] &
\mathcal{I}_2^\bullet \ar[r] &
\mathcal{I}_3^\bullet \ar[r] &
0
}
$$
as in Derived Categories, Lemma \ref{derived-lemma-injective-resolution-ses}.
This will give a commutative diagram
$$
\xymatrix{
0 \ar[r] &
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \ar[r] \ar[d] &
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \ar[r] \ar[d] &
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}) \ar[r] \ar[d] &
0 \\
0 \ar[r] &
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}_1^\bullet))
\ar[r] &
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}_2^\bullet))
\ar[r] &
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}_3^\bullet))
\ar[r] &
0
}
$$
Here $\mathcal{U}$ is an open covering as above and
the vertical maps are those used to define the maps
$\check{H}^n(\mathcal{U}, -) \to H^n(X, -)$, see
Lemma \ref{lemma-cech-cohomology}.
The bottom complex is exact as the sequence of
complexes of injectives is termwise split exact.
Hence the boundary map in cohomology is computed
by the usual procedure for this lower exact sequence, see
Homology, Lemma \ref{homology-lemma-long-exact-sequence-cochain}.
The same will be true after passing to the refinement
$\mathcal{V}$ where the boundary map for {\v C}ech cohomology
was defined. Hence the boundary maps agree because they
use the same construction (whenever the first one is defined
on an element in {\v C}ech cohomology on a given covering).
This finishes our discussion of the construction of
the structure of a $\delta$-functor on {\v C}ech cohomology
and why this structure is compatible with the given
$\delta$-functor structure on usual cohomology.

\medskip\noindent
Finally, we may apply Lemma \ref{lemma-injective-trivial-cech}
to see that higher {\v C}ech cohomology is trivial on injective
sheaves. Hence we see that {\v C}ech cohomology is a universal
$\delta$-functor by
Homology, Lemma \ref{homology-lemma-efface-implies-universal}.
\end{proof}

\begin{lemma}
\label{lemma-cohomology-of-closed}
\begin{reference}
\cite[Expose V bis, 4.1.3]{SGA4}
\end{reference}
Let $X$ be a topological space. Let $Z \subset X$ be a quasi-compact subset
such that any two points of $Z$ have disjoint open neighbourhoods in $X$.
For every abelian sheaf $\mathcal{F}$ on $X$ the canonical
map
$$
\colim H^p(U, \mathcal{F})
\longrightarrow
H^p(Z, \mathcal{F}|_Z)
$$
where the colimit is over open neighbourhoods $U$ of $Z$ in $X$
is an isomorphism.
\end{lemma}

\begin{proof}
We first prove this for $p = 0$. Injectivity follows from
the definition of $\mathcal{F}|_Z$ and holds in general
(for any subset of any topological space $X$). Next, suppose that
$s \in H^0(Z, \mathcal{F}|_Z)$. Then we can find opens $U_i \subset X$
such that $Z \subset \bigcup U_i$ and such that $s|_{Z \cap U_i}$
comes from $s_i \in \mathcal{F}(U_i)$. It follows that
there exist opens $W_{ij} \subset U_i \cap U_j$ with
$W_{ij} \cap Z = U_i \cap U_j \cap Z$ such that
$s_i|_{W_{ij}} = s_j|_{W_{ij}}$. Applying
Topology, Lemma
\ref{topology-lemma-lift-covering-of-quasi-compact-hausdorff-subset}
we find opens $V_i$ of $X$ such that $V_i \subset U_i$ and
such that $V_i \cap V_j \subset W_{ij}$. Hence we see that
$s_i|_{V_i}$ glue to a section of $\mathcal{F}$ over the
open neighbourhood $\bigcup V_i$ of $Z$.

\medskip\noindent
To finish the proof, it suffices to show that if $\mathcal{I}$ is an
injective abelian sheaf on $X$, then $H^p(Z, \mathcal{I}|_Z) = 0$
for $p > 0$. This follows using short exact sequences and dimension
shifting; details omitted. Thus, suppose $\overline{\xi}$ is an element
of $H^p(Z, \mathcal{I}|_Z)$ for some $p > 0$.
By Lemma \ref{lemma-cech-Hausdorff-quasi-compact}
the element $\overline{\xi}$ comes from
$\check{H}^p(\mathcal{V}, \mathcal{I}|_Z)$
for some open covering $\mathcal{V} : Z = \bigcup V_i$ of $Z$.
Say $\overline{\xi}$ is the image of the class of a cocycle
$\xi = (\xi_{i_0 \ldots i_p})$ in
$\check{\mathcal{C}}^p(\mathcal{V}, \mathcal{I}|_Z)$.

\medskip\noindent
Let $\mathcal{I}' \subset \mathcal{I}|_Z$ be the subpresheaf
defined by the rule
$$
\mathcal{I}'(V) =
\{s \in \mathcal{I}|_Z(V) \mid
\exists (U, t),\ U \subset X\text{ open},
\ t \in \mathcal{I}(U),\ V = Z \cap U,\ s = t|_{Z \cap U} \}
$$
Then $\mathcal{I}|_Z$ is the sheafification of $\mathcal{I}'$.
Thus for every $(p + 1)$-tuple $i_0 \ldots i_p$ we can find an
open covering $V_{i_0 \ldots i_p} = \bigcup W_{i_0 \ldots i_p, k}$
such that $\xi_{i_0 \ldots i_p}|_{W_{i_0 \ldots i_p, k}}$ is
a section of $\mathcal{I}'$. Applying
Topology, Lemma \ref{topology-lemma-refine-covering}
we may after refining $\mathcal{V}$ assume that each
$\xi_{i_0 \ldots i_p}$ is a section of the presheaf $\mathcal{I}'$.

\medskip\noindent
Write $V_i = Z \cap U_i$ for some opens $U_i \subset X$.
Since $\mathcal{I}$ is flasque (Lemma \ref{lemma-injective-flasque})
and since $\xi_{i_0 \ldots i_p}$ is a section of $\mathcal{I}'$
for every $(p + 1)$-tuple $i_0 \ldots i_p$ we can choose
a section $s_{i_0 \ldots i_p} \in \mathcal{I}(U_{i_0 \ldots i_p})$
which restricts to $\xi_{i_0 \ldots i_p}$ on
$V_{i_0 \ldots i_p} = Z \cap U_{i_0 \ldots i_p}$.
(This appeal to injectives being flasque can be avoided by an
additional application of
Topology, Lemma
\ref{topology-lemma-lift-covering-of-quasi-compact-hausdorff-subset}.)
Let $s = (s_{i_0 \ldots i_p})$ be the corresponding cochain
for the open covering $U = \bigcup U_i$.
Since $\text{d}(\xi) = 0$ we see that the sections
$\text{d}(s)_{i_0 \ldots i_{p + 1}}$ restrict to zero
on $Z \cap U_{i_0 \ldots i_{p + 1}}$. Hence, by the initial
remarks of the proof, there exists open subsets
$W_{i_0 \ldots i_{p + 1}} \subset U_{i_0 \ldots i_{p + 1}}$
with $Z \cap W_{i_0 \ldots i_{p + 1}} = Z \cap U_{i_0 \ldots i_{p + 1}}$
such that $\text{d}(s)_{i_0 \ldots i_{p + 1}}|_{W_{i_0 \ldots i_{p + 1}}} = 0$.
By Topology, Lemma
\ref{topology-lemma-lift-covering-of-quasi-compact-hausdorff-subset}
we can find $U'_i \subset U_i$ such that $Z \subset \bigcup U'_i$
and such that $U'_{i_0 \ldots i_{p + 1}} \subset W_{i_0 \ldots i_{p + 1}}$.
Then $s' = (s'_{i_0 \ldots i_p})$ with
$s'_{i_0 \ldots i_p} = s_{i_0 \ldots i_p}|_{U'_{i_0 \ldots i_p}}$
is a cocycle for $\mathcal{I}$ for the open covering
$U' = \bigcup U'_i$ of an open neighbourhood of $Z$.
Since $\mathcal{I}$ has trivial higher {\v C}ech cohomology groups
(Lemma \ref{lemma-injective-trivial-cech})
we conclude that $s'$ is a coboundary. It follows that the image of
$\xi$ in the {\v C}ech complex for the open covering
$Z = \bigcup Z \cap U'_i$ is a coboundary and we are done.
\end{proof}






\section{The base change map}
\label{section-base-change-map}

\noindent
We will need to know how to construct the base change map in some cases.
Since we have not yet discussed derived pullback we only discuss
this in the case of a base change by a flat morphism of ringed spaces.
Before we state the result, let us discuss flat pullback on the derived
category. Namely, suppose that $g : X \to Y$ is a flat morphism of
ringed spaces. By Modules, Lemma \ref{modules-lemma-pullback-flat}
the functor $g^* : \textit{Mod}(\mathcal{O}_Y) \to
\textit{Mod}(\mathcal{O}_X)$ is exact. Hence it has a derived functor
$$
g^* : D^{+}(Y) \to D^{+}(X)
$$
which is computed by simply pulling back an representative of a given
object in $D^{+}(Y)$, see
Derived Categories, Lemma \ref{derived-lemma-right-derived-exact-functor}.
Hence as indicated we indicate this functor by $g^*$ rather than
$Lg^*$.

\begin{lemma}
\label{lemma-base-change-map-flat-case}
Let
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} &
X \ar[d]^f \\
S' \ar[r]^g &
S
}
$$
be a commutative diagram of ringed spaces.
Let $\mathcal{F}^\bullet$ be a bounded below complex of
$\mathcal{O}_X$-modules.
Assume both $g$ and $g'$ are flat.
Then there exists a canonical base change map
$$
g^*Rf_*\mathcal{F}^\bullet
\longrightarrow
R(f')_*(g')^*\mathcal{F}^\bullet
$$
in $D^{+}(S')$.
\end{lemma}

\begin{proof}
Choose injective resolutions $\mathcal{F}^\bullet \to \mathcal{I}^\bullet$
and $(g')^*\mathcal{F}^\bullet \to \mathcal{J}^\bullet$.
By Lemma \ref{lemma-pushforward-injective-flat} we see that
$(g')_*\mathcal{J}^\bullet$ is a complex of injectives representing
$R(g')_*(g')^*\mathcal{F}^\bullet$. Hence by
Derived Categories, Lemmas \ref{derived-lemma-morphisms-lift}
and \ref{derived-lemma-morphisms-equal-up-to-homotopy}
the arrow $\beta$ in the diagram
$$
\xymatrix{
(g')_*(g')^*\mathcal{F}^\bullet \ar[r] &
(g')_*\mathcal{J}^\bullet \\
\mathcal{F}^\bullet \ar[u]^{adjunction} \ar[r] &
\mathcal{I}^\bullet \ar[u]_\beta
}
$$
exists and is unique up to homotopy.
Pushing down to $S$ we get
$$
f_*\beta :
f_*\mathcal{I}^\bullet
\longrightarrow
f_*(g')_*\mathcal{J}^\bullet
=
g_*(f')_*\mathcal{J}^\bullet
$$
By adjunction of $g^*$ and $g_*$ we get a map of complexes
$g^*f_*\mathcal{I}^\bullet \to (f')_*\mathcal{J}^\bullet$.
Note that this map is unique up to homotopy since the only
choice in the whole process was the choice of the map $\beta$
and everything was done on the level of complexes.
\end{proof}

\begin{remark}
\label{remark-correct-version-base-change-map}
The ``correct'' version of the base change map is the map
$$
Lg^* Rf_* \mathcal{F}^\bullet
\longrightarrow
R(f')_* L(g')^*\mathcal{F}^\bullet.
$$
The construction of this map involves
unbounded complexes, see Remark \ref{remark-base-change}.
\end{remark}





\section{Proper base change in topology}
\label{section-proper-base-change}

\noindent
In this section we prove a very general version of the proper base change
theorem in topology. It tells us that the stalks of the higher direct
images $R^pf_*$ can be computed on the fibre.

\begin{lemma}
\label{lemma-proper-base-change}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of
ringed spaces. Let $y \in Y$. Assume that
\begin{enumerate}
\item $f$ is closed,
\item $f$ is separated, and
\item $f^{-1}(y)$ is quasi-compact.
\end{enumerate}
Then for $E$ in $D^+(\mathcal{O}_X)$
we have $(Rf_*E)_y = R\Gamma(f^{-1}(y), E|_{f^{-1}(y)})$ in
$D^+(\mathcal{O}_{Y, y})$.
\end{lemma}

\begin{proof}
The base change map of Lemma \ref{lemma-base-change-map-flat-case}
gives a canonical map $(Rf_*E)_y \to R\Gamma(f^{-1}(y), E|_{f^{-1}(y)})$.
To prove this map is an isomorphism, we represent $E$ by a bounded
below complex of injectives $\mathcal{I}^\bullet$.
Set $Z = f^{-1}(\{y\})$. The assumptions of
Lemma \ref{lemma-cohomology-of-closed}
are satisfied, see Topology, Lemma \ref{topology-lemma-separated}.
Hence the restrictions
$\mathcal{I}^n|_Z$ are acyclic for $\Gamma(Z, -)$.
Thus $R\Gamma(Z, E|_Z)$ is represented by the
complex $\Gamma(Z, \mathcal{I}^\bullet|_Z)$, see
Derived Categories, Lemma \ref{derived-lemma-leray-acyclicity}.
In other words, we have to show the map
$$
\colim_V \mathcal{I}^\bullet(f^{-1}(V))
\longrightarrow
\Gamma(Z, \mathcal{I}^\bullet|_Z)
$$
is an isomorphism. Using Lemma \ref{lemma-cohomology-of-closed}
we see that it suffices to show that the collection of open neighbourhoods
$f^{-1}(V)$ of $Z = f^{-1}(\{y\})$
is cofinal in the system of all open neighbourhoods.
If $f^{-1}(\{y\}) \subset U$ is an open neighbourhood, then as $f$ is closed
the set $V = Y \setminus f(X \setminus U)$ is an open neighbourhood
of $y$ with $f^{-1}(V) \subset U$. This proves the lemma.
\end{proof}

\begin{theorem}[Proper base change]
\label{theorem-proper-base-change}
\begin{reference}
\cite[Expose V bis, 4.1.1]{SGA4}
\end{reference}
Consider a cartesian square of topological spaces
$$
\xymatrix{
X' = Y' \times_Y X \ar[d]_{f'} \ar[r]_-{g'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
$$
Assume that $f$ is proper.
Let $E$ be an object of $D^+(X)$. Then the base change map
$$
g^{-1}Rf_*E \longrightarrow Rf'_*(g')^{-1}E
$$
of Lemma \ref{lemma-base-change-map-flat-case} is an isomorphism
in $D^+(Y')$.
\end{theorem}

\begin{proof}
Let $y' \in Y'$ be a point with image $y \in Y$. It suffices to show that
the base change map induces an isomorphism on stalks at $y'$.
As $f$ is proper it follows that $f'$ is proper, the
fibres of $f$ and $f'$ are quasi-compact and $f$ and $f'$ are closed, see
Topology, Theorem \ref{topology-theorem-characterize-proper} and
Lemma \ref{topology-lemma-base-change-separated}.
Thus we can apply Lemma \ref{lemma-proper-base-change} twice to see that
$$
(Rf'_*(g')^{-1}E)_{y'} = R\Gamma((f')^{-1}(y'), (g')^{-1}E|_{(f')^{-1}(y')})
$$
and
$$
(Rf_*E)_y = R\Gamma(f^{-1}(y), E|_{f^{-1}(y)})
$$
The induced map of fibres $(f')^{-1}(y') \to f^{-1}(y)$ is
a homeomorphism of topological spaces and the pull back of
$E|_{f^{-1}(y)}$ is $(g')^{-1}E|_{(f')^{-1}(y')}$. The
desired result follows.
\end{proof}

\begin{lemma}[Proper base change for sheaves of sets]
\label{lemma-proper-base-change-sheaves-of-sets}
Consider a cartesian square of topological spaces
$$
\xymatrix{
X' \ar[d]_{f'} \ar[r]_-{g'} & X \ar[d]^f \\
Y' \ar[r]^g & Y
}
$$
Assume that $f$ is proper. Then
$g^{-1}f_*\mathcal{F} = f'_*(g')^{-1}\mathcal{F}$
for any sheaf of sets $\mathcal{F}$ on $X$.
\end{lemma}

\begin{proof}
We argue exactly as in the proof of Theorem \ref{theorem-proper-base-change}
and we find it suffices to show
$(f_*\mathcal{F})_y = \Gamma(X_y, \mathcal{F}|_{X_y})$.
Then we argue as in Lemma \ref{lemma-proper-base-change}
to reduce this to the $p = 0$ case of Lemma \ref{lemma-cohomology-of-closed}
for sheaves of sets. The first part of the proof of
Lemma \ref{lemma-cohomology-of-closed}
works for sheaves of sets and this finishes the proof.
Some details omitted.
\end{proof}



\section{Cohomology and colimits}
\label{section-limits}

\noindent
Let $X$ be a ringed space. Let $(\mathcal{F}_i, \varphi_{ii'})$ be
a system of sheaves of $\mathcal{O}_X$-modules over the directed set $I$, see
Categories, Section \ref{categories-section-posets-limits}.
Since for each $i$ there is a canonical map
$\mathcal{F}_i \to \colim_i \mathcal{F}_i$ we get a
canonical map
$$
\colim_i H^p(X, \mathcal{F}_i)
\longrightarrow
H^p(X, \colim_i \mathcal{F}_i)
$$
for every $p \geq 0$. Of course there is a similar map for
every open $U \subset X$. These maps are in general not isomorphisms,
even for $p = 0$. In this section we generalize the results of
Sheaves, Lemma \ref{sheaves-lemma-directed-colimits-sections}.
See also
Modules, Lemma \ref{modules-lemma-finite-presentation-quasi-compact-colimit}
(in the special case $\mathcal{G} = \mathcal{O}_X$).

\begin{lemma}
\label{lemma-quasi-separated-cohomology-colimit}
Let $X$ be a ringed space. Assume that the underlying topological space
of $X$ has the following properties:
\begin{enumerate}
\item there exists a basis of quasi-compact open subsets, and
\item the intersection of any two quasi-compact opens is quasi-compact.
\end{enumerate}
Then for any directed system $(\mathcal{F}_i, \varphi_{ii'})$
of sheaves of $\mathcal{O}_X$-modules and for any quasi-compact open
$U \subset X$ the canonical map
$$
\colim_i H^q(U, \mathcal{F}_i)
\longrightarrow
H^q(U, \colim_i \mathcal{F}_i)
$$
is an isomorphism for every $q \geq 0$.
\end{lemma}

\begin{proof}
It is important in this proof to argue for all quasi-compact opens
$U \subset X$ at the same time.
The result is true for $q = 0$ and any quasi-compact open $U \subset X$ by
Sheaves, Lemma \ref{sheaves-lemma-directed-colimits-sections}
(combined with
Topology, Lemma \ref{topology-lemma-topology-quasi-separated-scheme}).
Assume that we have proved the result for all $q \leq q_0$ and let
us prove the result for $q = q_0 + 1$.

\medskip\noindent
By our conventions on directed systems the index set $I$ is directed,
and any system of $\mathcal{O}_X$-modules $(\mathcal{F}_i, \varphi_{ii'})$
over $I$ is directed.
By Injectives, Lemma \ref{injectives-lemma-sheaves-modules-space} the category
of $\mathcal{O}_X$-modules has functorial injective embeddings.
Thus for any system $(\mathcal{F}_i, \varphi_{ii'})$ there exists a
system $(\mathcal{I}_i, \varphi_{ii'})$ with each $\mathcal{I}_i$ an
injective $\mathcal{O}_X$-module and a morphism of systems given
by injective $\mathcal{O}_X$-module maps
$\mathcal{F}_i \to \mathcal{I}_i$. Denote $\mathcal{Q}_i$ the
cokernel so that we have short exact sequences
$$
0 \to
\mathcal{F}_i \to
\mathcal{I}_i \to
\mathcal{Q}_i \to 0.
$$
We claim that the sequence
$$
0 \to
\colim_i \mathcal{F}_i \to
\colim_i \mathcal{I}_i \to
\colim_i \mathcal{Q}_i \to 0.
$$
is also a short exact sequence of $\mathcal{O}_X$-modules.
We may check this on stalks. By
Sheaves, Sections \ref{sheaves-section-limits-presheaves}
and \ref{sheaves-section-limits-sheaves}
taking stalks commutes with colimits. Since a directed colimit
of short exact sequences of abelian groups is short exact
(see Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact})
we deduce the result. We claim that
$H^q(U, \colim_i \mathcal{I}_i) = 0$ for all quasi-compact
open $U \subset X$ and all $q \geq 1$. Accepting this claim
for the moment consider the diagram
$$
\xymatrix{
\colim_i H^{q_0}(U, \mathcal{I}_i) \ar[d] \ar[r] &
\colim_i H^{q_0}(U, \mathcal{Q}_i) \ar[d] \ar[r] &
\colim_i H^{q_0 + 1}(U, \mathcal{F}_i) \ar[d] \ar[r] &
0 \ar[d] \\
H^{q_0}(U, \colim_i \mathcal{I}_i) \ar[r] &
H^{q_0}(U, \colim_i \mathcal{Q}_i) \ar[r] &
H^{q_0 + 1}(U, \colim_i \mathcal{F}_i) \ar[r] &
0
}
$$
The zero at the lower right corner comes from the claim and the
zero at the upper right corner comes from the fact that the sheaves
$\mathcal{I}_i$ are injective.
The top row is exact by an application of
Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}.
Hence by the snake lemma we deduce the
result for $q = q_0 + 1$.

\medskip\noindent
It remains to show that the claim is true. We will use
Lemma \ref{lemma-cech-vanish-basis}.
Let $\mathcal{B}$ be the collection of all quasi-compact open
subsets of $X$. This is a basis for the topology on $X$ by assumption.
Let $\text{Cov}$ be the collection of finite open coverings
$\mathcal{U} : U = \bigcup_{j = 1, \ldots, m} U_j$ with each
of $U$, $U_j$ quasi-compact open in $X$. By the result for $q = 0$
we see that for $\mathcal{U} \in \text{Cov}$ we have
$$
\check{\mathcal{C}}^\bullet(\mathcal{U}, \colim_i \mathcal{I}_i)
=
\colim_i \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}_i)
$$
because all the multiple intersections $U_{j_0 \ldots j_p}$
are quasi-compact. By Lemma \ref{lemma-injective-trivial-cech}
each of the complexes in the colimit of {\v C}ech complexes is
acyclic in degree $\geq 1$. Hence by
Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}
we see that also the {\v C}ech complex
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \colim_i \mathcal{I}_i)$
is acyclic in degrees $\geq 1$. In other words we see that
$\check{H}^p(\mathcal{U},  \colim_i \mathcal{I}_i) = 0$
for all $p \geq 1$. Thus the assumptions of
Lemma \ref{lemma-cech-vanish-basis} are satisfied and the claim follows.
\end{proof}

\noindent
Next we formulate the analogy of
Sheaves, Lemma \ref{sheaves-lemma-descend-opens}
for cohomology.
Let $X$ be a spectral space which is written as a cofiltered limit
of spectral spaces $X_i$ for a diagram with spectral transition morphisms
as in
Topology, Lemma \ref{topology-lemma-directed-inverse-limit-spectral-spaces}.
Assume given
\begin{enumerate}
\item an abelian sheaf $\mathcal{F}_i$ on $X_i$ for all
$i \in \Ob(\mathcal{I})$,
\item for $a : j \to i$ an $f_a$-map
$\varphi_a : \mathcal{F}_i \to \mathcal{F}_j$ of abelian sheaves (see
Sheaves, Definition \ref{sheaves-definition-f-map})
\end{enumerate}
such that $\varphi_c = \varphi_b \circ \varphi_a$
whenever $c = a \circ b$. Set $\mathcal{F} = \colim p_i^{-1}\mathcal{F}_i$
on $X$.

\begin{lemma}
\label{lemma-colimit}
In the situation discussed above.
Let $i \in \Ob(\mathcal{I})$ and let $U_i \subset X_i$ be quasi-compact open.
Then
$$
\colim_{a : j \to i} H^p(f_a^{-1}(U_i), \mathcal{F}_j) =
H^p(p_i^{-1}(U_i), \mathcal{F})
$$
for all $p \geq 0$. In particular we have
$H^p(X, \mathcal{F}) = \colim H^p(X_i, \mathcal{F}_i)$.
\end{lemma}

\begin{proof}
The case $p = 0$ is Sheaves, Lemma \ref{sheaves-lemma-descend-opens}.

\medskip\noindent
In this paragraph we show that we can find a map of systems
$(\gamma_i) : (\mathcal{F}_i, \varphi_a) \to (\mathcal{G}_i, \psi_a)$
with $\mathcal{G}_i$ an injective abelian sheaf and $\gamma_i$ injective.
For each $i$ we pick an injection $\mathcal{F}_i \to \mathcal{I}_i$
where $\mathcal{I}_i$ is an injective abelian sheaf on $X_i$.
Then we can consider the family of maps
$$
\gamma_i :
\mathcal{F}_i
\longrightarrow
\prod\nolimits_{b : k \to i} f_{b, *}\mathcal{I}_k = \mathcal{G}_i
$$
where the component maps are the maps adjoint to the maps
$f_b^{-1}\mathcal{F}_i \to \mathcal{F}_k \to \mathcal{I}_k$.
For $a : j \to i$ in $\mathcal{I}$ there is a canonical map
$$
\psi_a : f_a^{-1}\mathcal{G}_i \to \mathcal{G}_j
$$
whose components are the canonical maps
$f_b^{-1}f_{a \circ b, *}\mathcal{I}_k \to f_{b, *}\mathcal{I}_k$
for $b : k \to j$. Thus we find an injection
$\{\gamma_i\} : \{\mathcal{F}_i, \varphi_a) \to (\mathcal{G}_i, \psi_a)$
of systems of abelian sheaves. Note that $\mathcal{G}_i$ is an injective
sheaf of abelian groups on $X_i$, see
Lemma \ref{lemma-pushforward-injective-flat} and
Homology, Lemma \ref{homology-lemma-product-injectives}.
This finishes the construction.

\medskip\noindent
Arguing exactly as in the proof of
Lemma \ref{lemma-quasi-separated-cohomology-colimit}
we see that it suffices to prove that
$H^p(X, \colim f_i^{-1}\mathcal{G}_i) = 0$ for $p > 0$.

\medskip\noindent
Set $\mathcal{G} = \colim f_i^{-1}\mathcal{G}_i$.
To show vanishing of cohomology of $\mathcal{G}$ on every quasi-compact
open of $X$, it suffices to show that the {\v C}ech cohomology of
$\mathcal{G}$ for any covering $\mathcal{U}$ of a quasi-compact open of
$X$ by finitely many quasi-compact opens is zero, see
Lemma \ref{lemma-cech-vanish-basis}.
Such a covering is the inverse by $p_i$ of such a covering $\mathcal{U}_i$
on the space $X_i$ for some $i$ by
Topology, Lemma \ref{topology-lemma-descend-opens}. We have
$$
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{G}) =
\colim_{a : j \to i}
\check{\mathcal{C}}^\bullet(f_a^{-1}(\mathcal{U}_i), \mathcal{G}_j)
$$
by the case $p = 0$. The right hand side is a filtered colimit of
complexes each of which is acyclic in positive degrees by
Lemma \ref{lemma-injective-trivial-cech}. Thus we conclude by
Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}.
\end{proof}









\section{Vanishing on Noetherian topological spaces}
\label{section-vanishing-Noetherian}

\noindent
The aim is to prove a theorem of Grothendieck namely
Proposition \ref{proposition-vanishing-Noetherian}. See \cite{Tohoku}.

\begin{lemma}
\label{lemma-cohomology-and-closed-immersions}
Let $i : Z \to X$ be a closed immersion of topological spaces.
For any abelian sheaf $\mathcal{F}$ on $Z$ we have
$H^p(Z, \mathcal{F}) = H^p(X, i_*\mathcal{F})$.
\end{lemma}

\begin{proof}
This is true because $i_*$ is exact (see
Modules, Lemma \ref{modules-lemma-i-star-exact}),
and hence $R^pi_* = 0$ as a functor
(Derived Categories, Lemma \ref{derived-lemma-right-derived-exact-functor}).
Thus we may apply Lemma \ref{lemma-apply-Leray}.
\end{proof}

\begin{lemma}
\label{lemma-irreducible-constant-cohomology-zero}
Let $X$ be an irreducible topological space.
Then $H^p(X, \underline{A}) = 0$ for all $p > 0$
and any abelian group $A$.
\end{lemma}

\begin{proof}
Recall that $\underline{A}$ is the constant sheaf as defined
in Sheaves, Definition \ref{sheaves-definition-constant-sheaf}.
It is clear that for any nonempty
open $U \subset X$ we have $\underline{A}(U) = A$ as $X$ is
irreducible (and hence $U$ is connected).
We will show that the higher {\v C}ech cohomology groups
$\check{H}^p(\mathcal{U}, \underline{A})$ are zero for
any open covering $\mathcal{U} : U = \bigcup_{i\in I} U_i$
of an open $U \subset X$. Then the lemma will follow
from Lemma \ref{lemma-cech-vanish}.

\medskip\noindent
Recall that the value of an abelian
sheaf on the empty open set is $0$. Hence we may clearly assume
$U_i \not = \emptyset$ for all $i \in I$. In this case we see
that $U_i \cap U_{i'} \not = \emptyset$ for all $i, i' \in I$.
Hence we see that the {\v C}ech complex is simply the complex
$$
\prod_{i_0 \in I} A \to
\prod_{(i_0, i_1) \in I^2} A \to
\prod_{(i_0, i_1, i_2) \in I^3} A \to
\ldots
$$
We have to see this has trivial higher cohomology groups.
We can see this for example because this is the {\v C}ech complex for the
covering of a $1$-point space and {\v C}ech cohomology agrees with cohomology
on such a space. (You can also directly verify it
by writing an explicit homotopy.)
\end{proof}

\begin{lemma}
\label{lemma-subsheaf-of-constant-sheaf}
\begin{reference}
\cite[Page 168]{Tohoku}.
\end{reference}
Let $X$ be a topological space such that the intersection of any
two quasi-compact opens is quasi-compact. Let
$\mathcal{F} \subset \underline{\mathbf{Z}}$
be a subsheaf generated by finitely many sections over quasi-compact opens.
Then there exists a finite filtration
$$
(0) = \mathcal{F}_0 \subset \mathcal{F}_1 \subset \ldots \subset
\mathcal{F}_n = \mathcal{F}
$$
by abelian subsheaves such that for each $0 < i \leq n$
there exists a short exact sequence
$$
0 \to j'_!\underline{\mathbf{Z}}_V \to j_!\underline{\mathbf{Z}}_U \to
\mathcal{F}_i/\mathcal{F}_{i - 1} \to 0
$$
with $j : U \to X$ and $j' : V \to X$ the inclusion of quasi-compact opens
into $X$.
\end{lemma}

\begin{proof}
Say $\mathcal{F}$ is generated by the sections $s_1, \ldots, s_t$ over the
quasi-compact opens $U_1, \ldots, U_t$. Since $U_i$ is quasi-compact and
$s_i$ a locally constant function to $\mathbf{Z}$ we may assume, after
possibly replacing $U_i$ by the parts of a finite decomposition into open
and closed subsets, that $s_i$ is a constant section.
Say $s_i = n_i$ with $n_i \in \mathbf{Z}$. Of course we can remove
$(U_i, n_i)$ from the list if $n_i = 0$. Flipping signs if necessary
we may also assume $n_i > 0$. Next, for any subset $I \subset \{1, \ldots, t\}$
we may add $\bigcup_{i \in I} U_i$ and $\gcd(n_i, i \in I)$ to the list.
After doing this we see that our list $(U_1, n_1), \ldots, (U_t, n_t)$
satisfies the following property:
For $x \in X$ set $I_x = \{i \in \{1, \ldots, t\} \mid x \in U_i\}$.
Then $\gcd(n_i, i \in I_x)$ is attained by $n_i$ for some $i \in I_x$.

\medskip\noindent
As our filtration we take $\mathcal{F}_0 = (0)$ and
$\mathcal{F}_n$ generated by the sections $n_i$ over $U_i$ for those
$i$ such that $n_i \leq n$. It is clear that
$\mathcal{F}_n = \mathcal{F}$ for $n \gg 0$. Moreover, the quotient
$\mathcal{F}_n/\mathcal{F}_{n - 1}$ is generated by the section
$n$ over $U = \bigcup_{n_i \leq n} U_i$ and the kernel of the map
$j_!\underline{\mathbf{Z}}_U \to \mathcal{F}_n/\mathcal{F}_{n - 1}$
is generated by the section $n$ over $V = \bigcup_{n_i \leq n - 1} U_i$.
Thus a short exact sequence as in the statement of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-vanishing-generated-one-section}
\begin{reference}
This is a special case of \cite[Proposition 3.6.1]{Tohoku}.
\end{reference}
Let $X$ be a topological space. Let $d \geq 0$ be an integer. Assume
\begin{enumerate}
\item $X$ is quasi-compact,
\item the quasi-compact opens form a basis for $X$, and
\item the intersection of two quasi-compact opens is quasi-compact.
\item $H^p(X, j_!\underline{\mathbf{Z}}_U) = 0$ for all $p > d$
and any quasi-compact open $j : U \to X$.
\end{enumerate}
Then $H^p(X, \mathcal{F}) = 0$ for all $p > d$
and any abelian sheaf $\mathcal{F}$ on $X$.
\end{lemma}

\begin{proof}
Let $S = \coprod_{U \subset X} \mathcal{F}(U)$ where $U$ runs over the
quasi-compact opens of $X$.
For any finite subset $A = \{s_1, \ldots, s_n\} \subset S$,
let $\mathcal{F}_A$ be the subsheaf of $\mathcal{F}$ generated
by all $s_i$ (see
Modules, Definition \ref{modules-definition-generated-by-local-sections}).
Note that if $A \subset A'$, then $\mathcal{F}_A \subset \mathcal{F}_{A'}$.
Hence $\{\mathcal{F}_A\}$ forms a system over the
directed partially ordered set of finite subsets of $S$.
By Modules, Lemma \ref{modules-lemma-generated-by-local-sections-stalk}
it is clear that
$$
\colim_A \mathcal{F}_A = \mathcal{F}
$$
by looking at stalks. By
Lemma \ref{lemma-quasi-separated-cohomology-colimit} we have
$$
H^p(X, \mathcal{F}) =
\colim_A H^p(X, \mathcal{F}_A)
$$
Hence it suffices to prove the vanishing for the abelian sheaves
$\mathcal{F}_A$. In other words, it suffices to prove the
result when $\mathcal{F}$ is generated by finitely many local sections
over quasi-compact opens of $X$.

\medskip\noindent
Suppose that $\mathcal{F}$ is generated by the local sections
$s_1, \ldots, s_n$. Let $\mathcal{F}' \subset \mathcal{F}$
be the subsheaf generated by $s_1, \ldots, s_{n - 1}$.
Then we have a short exact sequence
$$
0 \to \mathcal{F}' \to \mathcal{F} \to \mathcal{F}/\mathcal{F}' \to 0
$$
From the long exact sequence of cohomology we see that it suffices
to prove the vanishing for the abelian sheaves $\mathcal{F}'$
and $\mathcal{F}/\mathcal{F}'$ which are generated by fewer than
$n$ local sections. Hence it suffices to prove the vanishing
for sheaves generated by at most one local section. These sheaves
are exactly the quotients of the sheaves $j_!\underline{\mathbf{Z}}_U$
where $U$ is a quasi-compact open of $X$.

\medskip\noindent
Assume now that we have a short exact sequence
$$
0 \to \mathcal{K} \to j_!\underline{\mathbf{Z}}_U \to \mathcal{F} \to 0
$$
with $U$ quasi-compact open in $X$.
It suffices to show that $H^q(X, \mathcal{K})$ is zero for $q \geq d + 1$.
As above we can write $\mathcal{K}$ as the filtered colimit of
subsheaves $\mathcal{K}'$ generated by finitely many sections over
quasi-compact opens. Then $\mathcal{F}$ is the filtered colimit of the
sheaves $j_!\underline{\mathbf{Z}}_U/\mathcal{K}'$. In this way we
reduce to the case that $\mathcal{K}$ is generated by finitely many
sections over quasi-compact opens. Note that $\mathcal{K}$
is a subsheaf of $\underline{\mathbf{Z}}_X$. Thus by
Lemma \ref{lemma-subsheaf-of-constant-sheaf} there exists a finite
filtration of $\mathcal{K}$ whose successive quotients $\mathcal{Q}$ fit
into a short exact sequence
$$
0 \to j''_!\underline{\mathbf{Z}}_W \to
j'_!\underline{\mathbf{Z}}_V \to \mathcal{Q} \to 0
$$
with $j'' : W \to X$ and $j' : V \to X$ the inclusions of quasi-compact opens.
Hence the vanishing of $H^p(X, \mathcal{Q})$ for $p > d$ follows
from our assumption (in the lemma) on the vanishing of the cohomology groups
of $j''_!\underline{\mathbf{Z}}_W$ and $j'_!\underline{\mathbf{Z}}_V$.
Returning to $\mathcal{K}$ this, via an induction argument using the
long exact cohomology sequence, implies the desired vanishing for it as well.
\end{proof}

\begin{example}
\label{example-datta}
Let $X = \mathbf{N}$ endowed with the topology whose opens are
$\emptyset$, $X$, and $U_n = \{i \mid i \leq n\}$ for $n \geq 1$.
An abelian sheaf $\mathcal{F}$ on $X$ is the same as an inverse
system of abelian groups $A_n = \mathcal{F}(U_n)$ and
$\Gamma(X, \mathcal{F}) = \lim A_n$. Since the inverse limit
functor is not an exact functor on the category of inverse systems,
we see that there is an abelian sheaf with nonzero $H^1$.
Finally, the reader can check that $H^p(X, j_!\mathbf{Z}_U) = 0$,
$p \geq 1$ if $j : U = U_n \to X$ is the inclusion. Thus we see
that $X$ is an example of a space satisfying conditions (2), (3), and (4) of
Lemma \ref{lemma-vanishing-generated-one-section} for $d = 0$
but not the conclusion.
\end{example}

\begin{lemma}
\label{lemma-subsheaf-irreducible}
Let $X$ be an irreducible topological space.
Let $\mathcal{H} \subset \underline{\mathbf{Z}}$ be
an abelian subsheaf of the constant sheaf.
Then there exists a nonempty open $U \subset X$ such
that $\mathcal{H}|_U = \underline{d\mathbf{Z}}_U$
for some $d \in \mathbf{Z}$.
\end{lemma}

\begin{proof}
Recall that $\underline{\mathbf{Z}}(V) = \mathbf{Z}$
for any nonempty open $V$ of $X$ (see proof of
Lemma \ref{lemma-irreducible-constant-cohomology-zero}).
If $\mathcal{H} = 0$, then the lemma holds with $d = 0$.
If $\mathcal{H} \not = 0$, then there exists a nonempty open
$U \subset X$ such that $\mathcal{H}(U) \not = 0$.
Say $\mathcal{H}(U) = n\mathbf{Z}$ for some $n \geq 1$.
Hence we see that
$\underline{n\mathbf{Z}}_U
\subset \mathcal{H}|_U \subset
\underline{\mathbf{Z}}_U$. If the first inclusion is strict we
can find a nonempty $U' \subset U$ and an integer $1 \leq n' < n$
such that
$\underline{n'\mathbf{Z}}_{U'}
\subset \mathcal{H}|_{U'} \subset
\underline{\mathbf{Z}}_{U'}$.
This process has to stop after a finite number of steps, and
hence we get the lemma.
\end{proof}

\begin{proposition}[Grothendieck]
\label{proposition-vanishing-Noetherian}
\begin{reference}
\cite[Theorem 3.6.5]{Tohoku}.
\end{reference}
Let $X$ be a Noetherian topological space.
If $\dim(X) \leq d$, then $H^p(X, \mathcal{F}) = 0$
for all $p > d$ and any abelian sheaf $\mathcal{F}$
on $X$.
\end{proposition}

\begin{proof}
We prove this lemma by induction on $d$.
So fix $d$ and assume the lemma holds for all
Noetherian topological spaces of dimension $< d$.

\medskip\noindent
Let $\mathcal{F}$ be an abelian sheaf on $X$.
Suppose $U \subset X$ is an open. Let $Z \subset X$
denote the closed complement.
Denote $j : U \to X$ and $i : Z \to X$ the inclusion maps.
Then there is a short exact sequence
$$
0 \to j_{!}j^*\mathcal{F} \to \mathcal{F} \to i_*i^*\mathcal{F} \to 0
$$
see Modules, Lemma \ref{modules-lemma-canonical-exact-sequence}.
Note that $j_!j^*\mathcal{F}$ is supported on
the topological closure $Z'$ of $U$, i.e., it is of
the form $i'_*\mathcal{F}'$ for some abelian sheaf $\mathcal{F}'$
on $Z'$, where $i' : Z' \to X$ is the inclusion.

\medskip\noindent
We can use this to reduce to the case where $X$ is irreducible.
Namely, according to
Topology, Lemma \ref{topology-lemma-Noetherian}
$X$ has finitely
many irreducible components. If $X$ has more than one irreducible
component, then let $Z \subset X$ be an irreducible component of $X$
and set $U = X \setminus Z$. By the above, and the long exact sequence
of cohomology, it suffices to prove the vanishing of
$H^p(X, i_*i^*\mathcal{F})$ and $H^p(X, i'_*\mathcal{F}')$ for $p > d$.
By Lemma \ref{lemma-cohomology-and-closed-immersions} it suffices to prove
$H^p(Z, i^*\mathcal{F})$ and $H^p(Z', \mathcal{F}')$ vanish for $p > d$.
Since $Z'$ and $Z$ have fewer irreducible components we indeed
reduce to the case of an irreducible $X$.

\medskip\noindent
If $d = 0$ and $X$ is irreducible, then $X$ is the only nonempty
open subset of $X$. Hence every sheaf is constant and higher cohomology
groups vanish (for example by
Lemma \ref{lemma-irreducible-constant-cohomology-zero}).

\medskip\noindent
Suppose $X$ is irreducible of dimension $d > 0$.
By Lemma \ref{lemma-vanishing-generated-one-section}
we reduce to the case where
$\mathcal{F} = j_!\underline{\mathbf{Z}}_U$ for some open $U \subset X$.
In this case we look at the short exact sequence
$$
0 \to j_!(\underline{\mathbf{Z}}_U) \to
\underline{\mathbf{Z}}_X \to i_*\underline{\mathbf{Z}}_Z \to 0
$$
where $Z = X \setminus U$.
By Lemma \ref{lemma-irreducible-constant-cohomology-zero}
we have the vanishing of $H^p(X, \underline{\mathbf{Z}}_X)$
for all $p \geq 1$. By induction we have
$H^p(X, i_*\underline{\mathbf{Z}}_Z) = H^p(Z, \underline{\mathbf{Z}}_Z) = 0$
for $p \geq d$. Hence we win by the long exact cohomology sequence.
\end{proof}





\section{Cohomology with support in a closed}
\label{section-cohomology-support}

\noindent
This section just discusses the bare minimum -- the discussion
will be continued in Section \ref{section-cohomology-support-bis}.

\medskip\noindent
Let $X$ be a topological space and let $Z \subset X$ be a closed subset.
Let $\mathcal{F}$ be an abelian sheaf on $X$. We let
$$
\Gamma_Z(X, \mathcal{F}) =
\{s \in \mathcal{F}(X) \mid \text{Supp}(s) \subset Z\}
$$
be the subset of sections whose support is contained in $Z$.
The support of a section is defined in
Modules, Definition \ref{modules-definition-support}.
Modules, Lemma \ref{modules-lemma-support-section-closed}
implies that $\Gamma_Z(X, \mathcal{F})$ is a subgroup of
$\Gamma(X, \mathcal{F})$. The same lemma guarantees that
the assignment $\mathcal{F} \mapsto \Gamma_Z(X, \mathcal{F})$
is a functor in $\mathcal{F}$.
This functor is left exact but not exact in general.

\medskip\noindent
Since the category of abelian sheaves has enough injectives
(Injectives, Lemma \ref{injectives-lemma-abelian-sheaves-space})
we we obtain a right derived functor
$$
R\Gamma_Z(X, -) : D^+(X) \longrightarrow D^+(\textit{Ab})
$$
by
Derived Categories, Lemma \ref{derived-lemma-enough-injectives-right-derived}.
The value of $R\Gamma_Z(X, -)$ on an object $K$ is computed by representing
$K$ by a bounded below complex $\mathcal{I}^\bullet$ of injective abelian
sheaves and taking $\Gamma_Z(X, \mathcal{I}^\bullet)$, see
Derived Categories, Lemma \ref{derived-lemma-injective-acyclic}.
The cohomology groups of an abelian sheaf $\mathcal{F}$
with support in $Z$ defined by
$H^q_Z(X, \mathcal{F}) = R^q\Gamma_Z(X, \mathcal{F})$.

\medskip\noindent
Let $\mathcal{I}$ be an injective abelian sheaf on $X$. Let
$U = X \setminus Z$. Then the restriction map
$\mathcal{I}(X) \to \mathcal{I}(U)$ is surjective
(Lemma \ref{lemma-injective-restriction-surjective})
with kernel $\Gamma_Z(X, \mathcal{I})$. It immediately follows that
for $K \in D^+(X)$ there is a distinguished triangle
$$
R\Gamma_Z(X, K) \to R\Gamma(X, K) \to R\Gamma(U, K) \to R\Gamma_Z(X, K)[1]
$$
in $D^+(\textit{Ab})$. As a consequence we obtain a long exact cohomology
sequence
$$
\ldots \to H^i_Z(X, K) \to H^i(X, K) \to H^i(U, K) \to
H^{i + 1}_Z(X, K) \to \ldots
$$
for any $K$ in $D^+(X)$.

\medskip\noindent
For an abelian sheaf $\mathcal{F}$ on $X$ we can consider the
{\it subsheaf of sections with support in $Z$}, denoted
$\mathcal{H}_Z(\mathcal{F})$, defined by the rule
$$
\mathcal{H}_Z(\mathcal{F})(U) =
\{s \in \mathcal{F}(U) \mid \text{Supp}(s) \subset U \cap Z\} =
\Gamma_{Z \cap U}(U, \mathcal{F}|_U)
$$
Using the equivalence of Modules, Lemma \ref{modules-lemma-i-star-exact}
we may view $\mathcal{H}_Z(\mathcal{F})$ as an abelian sheaf on $Z$, see
Modules, Remark \ref{modules-remark-sections-support-in-closed}.
Thus we obtain a functor
$$
\textit{Ab}(X) \longrightarrow \textit{Ab}(Z),\quad
\mathcal{F} \longmapsto
\mathcal{H}_Z(\mathcal{F})\text{ viewed as a sheaf on }Z
$$
This functor is left exact, but in general not exact. Exactly as above
we obtain a right derived functor
$$
R\mathcal{H}_Z : D^+(X) \longrightarrow D^+(Z)
$$
the derived functor. We set
$\mathcal{H}^q_Z(\mathcal{F}) = R^q\mathcal{H}_Z(\mathcal{F})$ so that
$\mathcal{H}^0_Z(\mathcal{F}) = \mathcal{H}_Z(\mathcal{F})$.

\medskip\noindent
Observe that we have
$\Gamma_Z(X, \mathcal{F}) = \Gamma(Z, \mathcal{H}_Z(\mathcal{F}))$
for any abelian sheaf $\mathcal{F}$. By
Lemma \ref{lemma-sections-with-support-acyclic} below
the functor $\mathcal{H}_Z$ transforms injective abelian sheaves
into sheaves right acyclic for $\Gamma(Z, -)$. Thus by
Derived Categories, Lemma \ref{derived-lemma-grothendieck-spectral-sequence}
we obtain a convergent Grothendieck spectral sequence
$$
E_2^{p, q} = H^p(Z, \mathcal{H}^q_Z(K)) \Rightarrow H^{p + q}_Z(X, K)
$$
functorial in $K$ in $D^+(X)$.

\begin{lemma}
\label{lemma-sections-with-support-acyclic}
Let $i : Z \to X$ be the inclusion of a closed subset.
Let $\mathcal{I}$ be an injective abelian sheaf on $X$.
Then $\mathcal{H}_Z(\mathcal{I})$ is an injective abelian sheaf on $Z$.
\end{lemma}

\begin{proof}
This follows from
Homology, Lemma \ref{homology-lemma-adjoint-preserve-injectives}
as $\mathcal{H}_Z(-)$ is right adjoint to the exact functor $i_*$.
See Modules, Lemmas \ref{modules-lemma-i-star-exact} and
\ref{modules-lemma-i-star-right-adjoint}.
\end{proof}




\section{Cohomology on spectral spaces}
\label{section-spectral}

\noindent
A key result on the cohomology of spectral spaces is Lemma \ref{lemma-colimit}
which loosely speaking says that cohomology commutes with cofiltered limits
in the category of spectral spaces as defined in
Topology, Definition \ref{topology-definition-spectral-space}.
This can be applied to give analogues of
Lemmas \ref{lemma-cohomology-of-closed} and \ref{lemma-proper-base-change}
as follows.

\begin{lemma}
\label{lemma-cohomology-of-neighbourhoods-of-closed}
Let $X$ be a spectral space. Let $\mathcal{F}$ be an abelian sheaf on $X$.
Let $E \subset X$ be a quasi-compact subset. Let $W \subset X$ be the set of
points of $X$ which specialize to a point of $E$.
\begin{enumerate}
\item $H^p(W, \mathcal{F}|_W) = \colim H^p(U, \mathcal{F})$
where the colimit is over quasi-compact open neighbourhoods of $E$,
\item $H^p(W \setminus E, \mathcal{F}|_{W \setminus E}) =
\colim H^p(U \setminus E, \mathcal{F}|_{U \setminus E})$
if $E$ is a constructible subset.
\end{enumerate}
\end{lemma}

\begin{proof}
From Topology, Lemma \ref{topology-lemma-make-spectral-space}
we see that $W = \lim U$ where the limit is over the quasi-compact
opens containing $E$. Each $U$ is a spectral space by
Topology, Lemma \ref{topology-lemma-spectral-sub}.
Thus we may apply Lemma \ref{lemma-colimit} to conclude that (1) holds.
The same proof works for part (2) except we use
Topology, Lemma \ref{topology-lemma-make-spectral-space-minus}.
\end{proof}

\begin{lemma}
\label{lemma-proper-base-change-spectral}
Let $f : X \to Y$ be a spectral map of spectral spaces. Let $y \in Y$.
Let $E \subset Y$ be the set of points specializing to $y$.
Let $\mathcal{F}$ be an abelian sheaf on $X$.
Then $(R^pf_*\mathcal{F})_y = H^p(f^{-1}(E), \mathcal{F}|_{f^{-1}(E)})$.
\end{lemma}

\begin{proof}
Observe that $E = \bigcap V$ where $V$ runs over the quasi-compact
open neighbourhoods of $y$ in $Y$. Hence $f^{-1}(E) = \bigcap f^{-1}(V)$.
This implies that $f^{-1}(E) = \lim f^{-1}(V)$ as topological spaces.
Since $f$ is spectral, each $f^{-1}(V)$ is a spectral space too
(Topology, Lemma \ref{topology-lemma-spectral-sub}).
We conclude that $f^{-1}(E)$ is a spectral space and that
$$
H^p(f^{-1}(E), \mathcal{F}|_{f^{-1}(E)}) =
\colim H^p(f^{-1}(V), \mathcal{F})
$$
by Lemma \ref{lemma-colimit}. On the other hand, the stalk of
$R^pf_*\mathcal{F}$ at $y$ is given by the colimit on the right.
\end{proof}

\begin{lemma}
\label{lemma-vanishing-for-profinite}
Let $X$ be a profinite topological space. Then $H^q(X, \mathcal{F}) = 0$
for all $q > 0$ and all abelian sheaves $\mathcal{F}$.
\end{lemma}

\begin{proof}
Any open covering of $X$ can be refined by a finite disjoint union
decomposition with open parts, see
Topology, Lemma \ref{topology-lemma-profinite-refine-open-covering}.
Hence if $\mathcal{F} \to \mathcal{G}$ is a surjection of abelian
sheaves on $X$, then $\mathcal{F}(X) \to \mathcal{G}(X)$ is surjective.
In other words, the global sections functor is an exact functor.
Therefore its higher derived functors are zero, see
Derived Categories, Lemma \ref{derived-lemma-right-derived-exact-functor}.
\end{proof}

\noindent
The following result on cohomological vanishing
improves Grothendieck's result
(Proposition \ref{proposition-vanishing-Noetherian})
and can be found in \cite{Scheiderer}.

\begin{proposition}
\label{proposition-cohomological-dimension-spectral}
\begin{reference}
Part (1) is the main theorem of \cite{Scheiderer}.
\end{reference}
Let $X$ be a spectral space of Krull dimension $d$.
Let $\mathcal{F}$ be an abelian sheaf on $X$.
\begin{enumerate}
\item $H^q(X, \mathcal{F}) = 0$ for $q > d$,
\item $H^d(X, \mathcal{F}) \to H^d(U, \mathcal{F})$ is surjective
for every quasi-compact open $U \subset X$,
\item $H^q_Z(X, \mathcal{F}) = 0$ for $q > d$ and any constructible
closed subset $Z \subset X$.
\end{enumerate}
\end{proposition}

\begin{proof}
We prove this result by induction on $d$.

\medskip\noindent
If $d = 0$, then $X$ is a profinite space, see
Topology, Lemma \ref{topology-lemma-characterize-profinite-spectral}.
Thus (1) holds by Lemma \ref{lemma-vanishing-for-profinite}.
If $U \subset X$ is quasi-compact open, then $U$ is
also closed as a quasi-compact subset of a Hausdorff space.
Hence $X = U \amalg (X \setminus U)$ as a topological space
and we see that (2) holds. Given $Z$ as in (3) we consider the
long exact sequence
$$
H^{q - 1}(X, \mathcal{F}) \to
H^{q - 1}(X \setminus Z, \mathcal{F}) \to
H^q_Z(X, \mathcal{F}) \to H^q(X, \mathcal{F})
$$
Since $X$ and $U = X \setminus Z$ are profinite (namely $U$ is quasi-compact
because $Z$ is constructible) and since
we have (2) and (1) we obtain the desired vanishing of the
cohomology groups with support in $Z$.

\medskip\noindent
Induction step. Assume $d \geq 1$ and assume
the proposition is valid for all spectral
spaces of dimension $< d$. We first prove part (2) for $X$.
Let $U$ be a quasi-compact open. Let $\xi \in H^d(U, \mathcal{F})$.
Set $Z = X \setminus U$. Let $W \subset X$ be the set of points
specializing to $Z$. By
Lemma \ref{lemma-cohomology-of-neighbourhoods-of-closed} we have
$$
H^d(W \setminus Z, \mathcal{F}|_{W \setminus Z}) =
\colim_{Z \subset V} H^d(V \setminus Z, \mathcal{F})
$$
where the colimit is over the quasi-compact open neighbourhoods $V$
of $Z$ in $X$.
By Topology, Lemma \ref{topology-lemma-make-spectral-space} we see that
$W \setminus Z$ is a spectral space.
Since every point of $W$ specializes to a point of $Z$, we see that
$W \setminus Z$ is a spectral space of Krull dimension $< d$.
By induction hypothesis we see that the image of $\xi$ in
$H^d(W \setminus Z, \mathcal{F}|_{W \setminus Z})$ is zero.
By the displayed formula, there exists a $Z \subset V \subset X$
quasi-compact open such that $\xi|_{V \setminus Z} = 0$.
Since $V \setminus Z = V \cap U$ we conclude by the Mayer-Vietoris
(Lemma \ref{lemma-mayer-vietoris}) for the covering $X = U \cup V$
that there exists a $\tilde \xi \in H^d(X, \mathcal{F})$ which restricts
to $\xi$ on $U$ and to zero on $V$. In other words, part (2) is true.

\medskip\noindent
Proof of part (1) assuming (2). Choose an injective resolution
$\mathcal{F} \to \mathcal{I}^\bullet$. Set
$$
\mathcal{G} = \Im(\mathcal{I}^{d - 1} \to \mathcal{I}^d) =
\Ker(\mathcal{I}^d \to \mathcal{I}^{d + 1})
$$
For $U \subset X$ quasi-compact open we have a map of exact sequences
as follows
$$
\xymatrix{
\mathcal{I}^{d - 1}(X) \ar[r] \ar[d] &
\mathcal{G}(X) \ar[r] \ar[d] &
H^d(X, \mathcal{F}) \ar[d] \ar[r] & 0 \\
\mathcal{I}^{d - 1}(U) \ar[r] &
\mathcal{G}(U) \ar[r] &
H^d(U, \mathcal{F}) \ar[r] & 0
}
$$
The sheaf $\mathcal{I}^{d - 1}$ is flasque by
Lemma \ref{lemma-injective-flasque} and the fact that $d \geq 1$.
By part (2) we see that the right vertical arrow is surjective.
We conclude by a diagram chase that the map
$\mathcal{G}(X) \to \mathcal{G}(U)$ is surjective.
By Lemma \ref{lemma-vanishing-ravi} we conclude that
$\check{H}^q(\mathcal{U}, \mathcal{G}) = 0$ for $q > 0$ and
any finite covering $\mathcal{U} : U = U_1 \cup \ldots \cup U_n$
of a quasi-compact open by quasi-compact opens. Applying
Lemma \ref{lemma-cech-vanish-basis} we find that $H^q(U, \mathcal{G}) = 0$
for all $q > 0$ and all quasi-compact opens $U$ of $X$.
By Leray's acyclicity lemma
(Derived Categories, Lemma \ref{derived-lemma-leray-acyclicity})
we conclude that
$$
H^q(X, \mathcal{F}) =
H^q\left(
\Gamma(X, \mathcal{I}^0) \to \ldots \to
\Gamma(X, \mathcal{I}^{d - 1}) \to \Gamma(X, \mathcal{G})
\right)
$$
In particular the cohomology group vanishes if $q > d$.

\medskip\noindent
Proof of (3).  Given $Z$ as in (3) we consider the long exact sequence
$$
H^{q - 1}(X, \mathcal{F}) \to
H^{q - 1}(X \setminus Z, \mathcal{F}) \to
H^q_Z(X, \mathcal{F}) \to H^q(X, \mathcal{F})
$$
Since $X$ and $U = X \setminus Z$ are spectral spaces
(Topology, Lemma \ref{topology-lemma-spectral-sub})
of dimension $\leq d$
and since we have (2) and (1) we obtain the desired vanishing.
\end{proof}













\section{The alternating {\v C}ech complex}
\label{section-alternating-cech}

\noindent
This section compares the {\v C}ech complex with the alternating {\v C}ech
complex and some related complexes.

\medskip\noindent
Let $X$ be a topological space. Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$
be an open covering. For $p \geq 0$ set
$$
\check{\mathcal{C}}_{alt}^p(\mathcal{U}, \mathcal{F})
=
\left\{
\begin{matrix}
s \in  \check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})
\text{ such that }
s_{i_0 \ldots i_p} = 0 \text{ if } i_n = i_m \text{ for some } n \not = m\\
\text{ and }
s_{i_0\ldots i_n \ldots i_m \ldots i_p}
=
-s_{i_0\ldots i_m \ldots i_n \ldots i_p}
\text{ in any case.}
\end{matrix}
\right\}
$$
We omit the verification that the differential $d$ of
Equation (\ref{equation-d-cech}) maps
$\check{\mathcal{C}}^p_{alt}(\mathcal{U}, \mathcal{F})$ into
$\check{\mathcal{C}}^{p + 1}_{alt}(\mathcal{U}, \mathcal{F})$.

\begin{definition}
\label{definition-alternating-cech-complex}
Let $X$ be a topological space. Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$
be an open covering. Let $\mathcal{F}$ be an abelian presheaf on $X$.
The complex $\check{\mathcal{C}}_{alt}^\bullet(\mathcal{U}, \mathcal{F})$
is the {\it alternating {\v C}ech complex} associated to $\mathcal{F}$ and the
open covering $\mathcal{U}$.
\end{definition}

\noindent
Hence there is a canonical morphism of complexes
$$
\check{\mathcal{C}}_{alt}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
$$
namely the inclusion of the alternating {\v C}ech complex into the
usual {\v C}ech complex.

\medskip\noindent
Suppose our covering $\mathcal{U} : U = \bigcup_{i \in I} U_i$ comes
equipped with a total ordering $<$ on $I$. In this case, set
$$
\check{\mathcal{C}}_{ord}^p(\mathcal{U}, \mathcal{F})
=
\prod\nolimits_{(i_0, \ldots, i_p) \in I^{p + 1}, i_0 < \ldots < i_p}
\mathcal{F}(U_{i_0\ldots i_p}).
$$
This is an abelian group. For
$s \in \check{\mathcal{C}}_{ord}^p(\mathcal{U}, \mathcal{F})$ we denote
$s_{i_0\ldots i_p}$ its value in $\mathcal{F}(U_{i_0\ldots i_p})$.
We define
$$
d : \check{\mathcal{C}}_{ord}^p(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}_{ord}^{p + 1}(\mathcal{U}, \mathcal{F})
$$
by the formula
$$
d(s)_{i_0\ldots i_{p + 1}}
=
\sum\nolimits_{j = 0}^{p + 1}
(-1)^j
s_{i_0\ldots \hat i_j \ldots i_{p + 1}}|_{U_{i_0\ldots i_{p + 1}}}
$$
for any $i_0 < \ldots < i_{p + 1}$. Note that this formula is identical
to Equation (\ref{equation-d-cech}).
It is straightforward to see that $d \circ d = 0$. In other words
$\check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})$ is a complex.

\begin{definition}
\label{definition-ordered-cech-complex}
Let $X$ be a topological space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering.
Assume given a total ordering on $I$.
Let $\mathcal{F}$ be an abelian presheaf on $X$.
The complex $\check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})$
is the {\it ordered {\v C}ech complex} associated to $\mathcal{F}$, the
open covering $\mathcal{U}$ and the given total ordering on $I$.
\end{definition}

\noindent
This complex is sometimes called the alternating {\v C}ech complex.
The reason is that there is an obvious comparison map between
the ordered {\v C}ech complex and the alternating {\v C}ech complex.
Namely, consider the map
$$
c :
\check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
$$
given by the rule
$$
c(s)_{i_0\ldots i_p} =
\left\{
\begin{matrix}
0 &
\text{if} &
i_n = i_m \text{ for some } n \not = m\\
\text{sgn}(\sigma) s_{i_{\sigma(0)}\ldots i_{\sigma(p)}} &
\text{if} &
i_{\sigma(0)} < i_{\sigma(1)} < \ldots < i_{\sigma(p)}
\end{matrix}
\right.
$$
Here $\sigma$ denotes a permutation of $\{0, \ldots, p\}$ and
$\text{sgn}(\sigma)$ denotes its sign. The alternating and ordered
{\v C}ech complexes are often identified in the literature via the map
$c$. Namely we have the following easy lemma.

\begin{lemma}
\label{lemma-ordered-alternating}
Let $X$ be a topological space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering.
Assume $I$ comes equipped with a total ordering.
The map $c$ is a morphism of complexes. In fact it induces
an isomorphism
$$
c : \check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})
\to \check{\mathcal{C}}_{alt}^\bullet(\mathcal{U}, \mathcal{F})
$$
of complexes.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\noindent
There is also a map
$$
\pi :
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})
$$
which is described by the rule
$$
\pi(s)_{i_0\ldots i_p} = s_{i_0\ldots i_p}
$$
whenever $i_0 < i_1 < \ldots < i_p$.

\begin{lemma}
\label{lemma-project-to-ordered}
Let $X$ be a topological space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering.
Assume $I$ comes equipped with a total ordering.
The map $\pi : \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
\to \check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})$
is a morphism of complexes. It induces an isomorphism
$$
\pi : \check{\mathcal{C}}_{alt}^\bullet(\mathcal{U}, \mathcal{F})
\to \check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})
$$
of complexes which is a left inverse to the morphism $c$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{remark}
\label{remark-compared-ordered-complexes}
This means that if we have two total orderings $<_1$ and $<_2$ on
the index set $I$, then we get an isomorphism of complexes
$\tau = \pi_2 \circ c_1 :
\check{\mathcal{C}}_{ord\text{-}1}(\mathcal{U}, \mathcal{F}) \to
\check{\mathcal{C}}_{ord\text{-}2}(\mathcal{U}, \mathcal{F})$.
It is clear that
$$
\tau(s)_{i_0 \ldots i_p} =
\text{sign}(\sigma) s_{i_{\sigma(0)} \ldots i_{\sigma(p)}}
$$
where $i_0 <_1 i_1 <_1 \ldots <_1 i_p$ and
$i_{\sigma(0)} <_2 i_{\sigma(1)} <_2 \ldots <_2 i_{\sigma(p)}$.
This is the sense in which the ordered {\v C}ech complex is independent
of the chosen total ordering.
\end{remark}

\begin{lemma}
\label{lemma-alternating-usual}
Let $X$ be a topological space.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering.
Assume $I$ comes equipped with a total ordering.
The map $c \circ \pi$ is homotopic to the identity on
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})$.
In particular the inclusion map
$\check{\mathcal{C}}_{alt}^\bullet(\mathcal{U}, \mathcal{F}) \to
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})$
is a homotopy equivalence.
\end{lemma}

\begin{proof}
For any multi-index $(i_0, \ldots, i_p) \in I^{p + 1}$ there exists
a unique permutation $\sigma : \{0, \ldots, p\} \to \{0, \ldots, p\}$
such that
$$
i_{\sigma(0)} \leq i_{\sigma(1)} \leq \ldots \leq i_{\sigma(p)}
\quad
\text{and}
\quad
\sigma(j) < \sigma(j + 1)
\quad
\text{if}
\quad
i_{\sigma(j)} = i_{\sigma(j + 1)}.
$$
We denote this permutation $\sigma = \sigma^{i_0 \ldots i_p}$.

\medskip\noindent
For any permutation $\sigma : \{0, \ldots, p\} \to \{0, \ldots, p\}$
and any $a$, $0 \leq a \leq p$ we denote $\sigma_a$
the permutation of $\{0, \ldots, p\}$ such that
$$
\sigma_a(j) =
\left\{
\begin{matrix}
\sigma(j) & \text{if} & 0 \leq j < a, \\
\min\{j' \mid j' > \sigma_a(j - 1), j' \not = \sigma(k), \forall k < a\}
& \text{if} & a \leq j
\end{matrix}
\right.
$$
So if $p = 3$ and $\sigma$, $\tau$ are given by
$$
\begin{matrix}
\text{id} & 0 & 1 & 2 & 3 \\
\sigma & 3 & 2 & 1 & 0
\end{matrix}
\quad \text{and} \quad
\begin{matrix}
\text{id} & 0 & 1 & 2 & 3 \\
\tau & 3 & 0 & 2 & 1
\end{matrix}
$$
then we have
$$
\begin{matrix}
\text{id} & 0 & 1 & 2 & 3 \\
\sigma_0 & 0 & 1 & 2 & 3 \\
\sigma_1 & 3 & 0 & 1 & 2 \\
\sigma_2 & 3 & 2 & 0 & 1 \\
\sigma_3 & 3 & 2 & 1 & 0 \\
\end{matrix}
\quad \text{and} \quad
\begin{matrix}
\text{id} & 0 & 1 & 2 & 3 \\
\tau_0 & 0 & 1 & 2 & 3 \\
\tau_1 & 3 & 0 & 1 & 2 \\
\tau_2 & 3 & 0 & 1 & 2 \\
\tau_3 & 3 & 0 & 2 & 1 \\
\end{matrix}
$$
It is clear that always $\sigma_0 = \text{id}$ and $\sigma_p = \sigma$.

\medskip\noindent
Having introduced this notation we define for
$s \in \check{\mathcal{C}}^{p + 1}(\mathcal{U}, \mathcal{F})$
the element $h(s) \in \check{\mathcal{C}}^p(\mathcal{U}, \mathcal{F})$
to be the element with components
\begin{equation}
\label{equation-first-homotopy}
h(s)_{i_0\ldots i_p} =
\sum\nolimits_{0 \leq a \leq p}
(-1)^a \text{sign}(\sigma_a)
s_{i_{\sigma(0)} \ldots i_{\sigma(a)} i_{\sigma_a(a)} \ldots i_{\sigma_a(p)}}
\end{equation}
where $\sigma = \sigma^{i_0 \ldots i_p}$. The index
$i_{\sigma(a)}$ occurs twice in
$i_{\sigma(0)} \ldots i_{\sigma(a)} i_{\sigma_a(a)} \ldots i_{\sigma_a(p)}$
once in the first group of $a + 1$ indices and once in the second group
of $p - a + 1$ indices since $\sigma_a(j) = \sigma(a)$ for some
$j \geq a$ by definition of $\sigma_a$. Hence the sum makes sense since each
of the elements
$s_{i_{\sigma(0)} \ldots i_{\sigma(a)} i_{\sigma_a(a)} \ldots i_{\sigma_a(p)}}$
is defined over the open $U_{i_0 \ldots i_p}$.
Note also that for $a = 0$ we get $s_{i_0 \ldots i_p}$ and
for $a = p$ we get
$(-1)^p \text{sign}(\sigma) s_{i_{\sigma(0)} \ldots i_{\sigma(p)}}$.

\medskip\noindent
We claim that
$$
(dh + hd)(s)_{i_0 \ldots i_p} =
s_{i_0 \ldots i_p} -
\text{sign}(\sigma) s_{i_{\sigma(0)} \ldots i_{\sigma(p)}}
$$
where $\sigma = \sigma^{i_0 \ldots i_p}$. We omit the verification
of this claim. (There is a PARI/gp script called first-homotopy.gp
in the stacks-project subdirectory scripts which can be used to check
finitely many instances of this claim.
We wrote this script to make sure the signs are correct.)
Write
$$
\kappa :
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})
$$
for the operator given by the rule
$$
\kappa(s)_{i_0 \ldots i_p} =
\text{sign}(\sigma^{i_0 \ldots i_p}) s_{i_{\sigma(0)} \ldots i_{\sigma(p)}}.
$$
The claim above implies that $\kappa$ is a morphism of complexes and that
$\kappa$ is homotopic to the identity map of the {\v C}ech complex.
This does not immediately imply the lemma since
the image of the operator $\kappa$ is not the alternating subcomplex.
Namely, the image of $\kappa$ is the ``semi-alternating'' complex
$\check{\mathcal{C}}_{semi\text{-}alt}^p(\mathcal{U}, \mathcal{F})$
where $s$ is a $p$-cochain of this complex if and only if
$$
s_{i_0 \ldots i_p} = \text{sign}(\sigma) s_{i_{\sigma(0)} \ldots i_{\sigma(p)}}
$$
for any $(i_0, \ldots, i_p) \in I^{p + 1}$ with
$\sigma = \sigma^{i_0 \ldots i_p}$.
We introduce yet another variant {\v C}ech complex, namely the semi-ordered
{\v C}ech complex defined by
$$
\check{\mathcal{C}}_{semi\text{-}ord}^p(\mathcal{U}, \mathcal{F})
=
\prod\nolimits_{i_0 \leq i_1 \leq \ldots \leq i_p}
\mathcal{F}(U_{i_0 \ldots i_p})
$$
It is easy to see that Equation (\ref{equation-d-cech}) also defines
a differential and hence that we get a complex. It is also clear
(analogous to Lemma \ref{lemma-project-to-ordered}) that the projection map
$$
\check{\mathcal{C}}_{semi\text{-}alt}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}_{semi\text{-}ord}^\bullet(\mathcal{U}, \mathcal{F})
$$
is an isomorphism of complexes.

\medskip\noindent
Hence the Lemma follows if we can show that the obvious inclusion map
$$
\check{\mathcal{C}}_{ord}^p(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}_{semi\text{-}ord}^p(\mathcal{U}, \mathcal{F})
$$
is a homotopy equivalence. To see this we use the homotopy
\begin{equation}
\label{equation-second-homotopy}
h(s)_{i_0 \ldots i_p} =
\left\{
\begin{matrix}
0 & \text{if} & i_0 < i_1 < \ldots < i_p \\
(-1)^a s_{i_0 \ldots i_{a - 1} i_a i_a i_{a + 1} \ldots i_p}
& \text{if} & i_0 < i_1 < \ldots < i_{a - 1} < i_a = i_{a + 1}
\end{matrix}
\right.
\end{equation}
We claim that
$$
(dh + hd)(s)_{i_0 \ldots i_p} =
\left\{
\begin{matrix}
0 & \text{if} & i_0 < i_1 < \ldots < i_p \\
s_{i_0 \ldots i_p}
& \text{else} &
\end{matrix}
\right.
$$
We omit the verification. (There is a PARI/gp script called second-homotopy.gp
in the stacks-project subdirectory scripts which can be used to check
finitely many instances of this claim.
We wrote this script to make sure the signs are correct.)
The claim clearly shows that the composition
$$
\check{\mathcal{C}}_{semi\text{-}ord}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})
\longrightarrow
\check{\mathcal{C}}_{semi\text{-}ord}^\bullet(\mathcal{U}, \mathcal{F})
$$
of the projection with the natural inclusion
is homotopic to the identity map as desired.
\end{proof}

\begin{lemma}
\label{lemma-alternating-cech-trivial}
Let $X$ be a topological space. Let $\mathcal{F}$ be an abelian presheaf on $X$.
Let $\mathcal{U} : U = \bigcup_{i \in I} U_i$ be an open covering. If
$U_i = U$ for some $i \in I$, then the extended alternating {\v C}ech complex
$$
\mathcal{F}(U) \to \check{\mathcal{C}}_{alt}^\bullet(\mathcal{U}, \mathcal{F})
$$
obtained by putting $\mathcal{F}(U)$ in degree $-1$ with differential given by
the canonical map of $\mathcal{F}(U)$ into
$\check{\mathcal{C}}^0(\mathcal{U}, \mathcal{F})$
is homotopy equivalent to $0$. Similarly, for any total ordering on $I$
the extended ordered {\v C}ech complex
$$
\mathcal{F}(U) \to
\check{\mathcal{C}}_{ord}^\bullet(\mathcal{U}, \mathcal{F})
$$
is homotopy equivalent to $0$.
\end{lemma}

\begin{proof}[First proof]
Combine Lemmas \ref{lemma-cech-trivial} and \ref{lemma-alternating-usual}.
\end{proof}

\begin{proof}[Second proof]
Since the alternating and ordered {\v C}ech complexes are isomorphic
it suffices to prove this for the ordered one.
We will use standard notation: a cochain $s$ of degree $p$
in the extended ordered {\v C}ech complex has the form
$s = (s_{i_0 \ldots i_p})$ where $s_{i_0 \ldots i_p}$ is in
$\mathcal{F}(U_{i_0 \ldots i_p})$ and $i_0 < \ldots < i_p$.
With this notation we have
$$
d(x)_{i_0 \ldots i_{p + 1}} =
\sum\nolimits_j (-1)^j x_{i_0 \ldots \hat i_j \ldots i_p}
$$
Fix an index $i \in I$ with $U = U_i$.
As homotopy we use the maps
$$
h : \text{cochains of degree }p + 1 \to \text{cochains of degree }p
$$
given by the rule
$$
h(s)_{i_0 \ldots i_p} = 0 \text{ if } i \in \{i_0, \ldots, i_p\}
\text{ and }
h(s)_{i_0 \ldots i_p} = 
(-1)^j s_{i_0 \ldots i_j i i_{j + 1} \ldots i_p} \text{ if not}
$$
Here $j$ is the unique index such that $i_j < i < i_{j + 1}$ in the
second case; also, since $U = U_i$ we have the equality
$$
\mathcal{F}(U_{i_0 \ldots i_p}) =
\mathcal{F}(U_{i_0 \ldots i_j i i_{j + 1} \ldots i_p})
$$
which we can use to make sense of thinking of
$(-1)^j s_{i_0 \ldots i_j i i_{j + 1} \ldots i_p}$
as an element of $\mathcal{F}(U_{i_0 \ldots i_p})$.
We will show by a computation that $d h + h d$ equals
the negative of the identity map which finishes the proof.
To do this fix $s$ a cochain of degree $p$ and let
$i_0 < \ldots < i_p$ be elements of $I$.

\medskip\noindent
Case I: $i \in \{i_0, \ldots, i_p\}$. Say $i = i_t$. Then we have
$h(d(s))_{i_0 \ldots i_p} = 0$. On the other hand we have
$$
d(h(s))_{i_0 \ldots i_p} =
\sum (-1)^j h(s)_{i_0 \ldots \hat i_j \ldots i_p} =
(-1)^t h(s)_{i_0 \ldots \hat i \ldots i_p} =
(-1)^t (-1)^{t - 1} s_{i_0 \ldots i_p}
$$
Thus $(dh + hd)(s)_{i_0 \ldots i_p} = -s_{i_0 \ldots i_p}$ as desired.

\medskip\noindent
Case II: $i \not \in \{i_0, \ldots, i_p\}$. Let $j$ be such that
$i_j < i < i_{j + 1}$. Then we see that
\begin{align*}
h(d(s))_{i_0 \ldots i_p}
& =
(-1)^j d(s)_{i_0 \ldots i_j i i_{j + 1} \ldots i_p} \\
& =
\sum\nolimits_{j' \leq j} (-1)^{j + j'}
s_{i_0 \ldots \hat i_{j'} \ldots i_j i i_{j + 1} \ldots i_p} -
s_{i_0 \ldots i_p} \\
&
+ \sum\nolimits_{j' > j} (-1)^{j + j' + 1}
s_{i_0 \ldots i_j i i_{j + 1} \ldots \hat i_{j'} \ldots i_p}
\end{align*}
On the other hand we have
\begin{align*}
d(h(s))_{i_0 \ldots i_p}
& =
\sum\nolimits_{j'} (-1)^{j'} h(s)_{i_0 \ldots \hat i_{j'} \ldots i_p} \\
& =
\sum\nolimits_{j' \leq j} (-1)^{j' + j - 1}
s_{i_0 \ldots \hat i_{j'} \ldots i_j i i_{j + 1} \ldots i_p} \\
& +
\sum\nolimits_{j' > j} (-1)^{j' + j}
s_{i_0 \ldots i_j i i_{j + 1} \ldots \hat i_{j'} \ldots i_p}
\end{align*}
Adding these up we obtain
$(dh + hd)(s)_{i_0 \ldots i_p} = - s_{i_0 \ldots i_p}$
as desired.
\end{proof}





\section{Alternative view of the {\v C}ech complex}
\label{section-locally-finite-cech}

\noindent
In this section we discuss an alternative way to establish the relationship
between the {\v C}ech complex and cohomology.

\begin{lemma}
\label{lemma-covering-resolution}
Let $X$ be a ringed space. Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$
be an open covering of $X$. Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
Denote $\mathcal{F}_{i_0 \ldots i_p}$ the restriction of
$\mathcal{F}$ to $U_{i_0 \ldots i_p}$. There exists a complex
${\mathfrak C}^\bullet(\mathcal{U}, \mathcal{F})$
of $\mathcal{O}_X$-modules with
$$
{\mathfrak C}^p(\mathcal{U}, \mathcal{F}) =
\prod\nolimits_{i_0 \ldots i_p}
(j_{i_0 \ldots i_p})_* \mathcal{F}_{i_0 \ldots i_p}
$$
and differential
$d : {\mathfrak C}^p(\mathcal{U}, \mathcal{F})
\to {\mathfrak C}^{p + 1}(\mathcal{U}, \mathcal{F})$
as in Equation (\ref{equation-d-cech}). Moreover, there exists a canonical
map
$$
\mathcal{F} \to {\mathfrak C}^\bullet(\mathcal{U}, \mathcal{F})
$$
which is a quasi-isomorphism, i.e.,
${\mathfrak C}^\bullet(\mathcal{U}, \mathcal{F})$
is a resolution of $\mathcal{F}$.
\end{lemma}

\begin{proof}
We check
$$
0 \to \mathcal{F} \to \mathfrak{C}^0(\mathcal{U}, \mathcal{F}) \to
\mathfrak{C}^1(\mathcal{U}, \mathcal{F}) \to  \ldots
$$
is exact on stalks. Let $x \in X$ and choose $i_{\text{fix}} \in I$
such that $x \in U_{i_{\text{fix}}}$. Then define 
$$
h : \mathfrak{C}^p(\mathcal{U}, \mathcal{F})_x
\to \mathfrak{C}^{p - 1}(\mathcal{U}, \mathcal{F})_x
$$
as follows: If $s \in \mathfrak{C}^p(\mathcal{U}, \mathcal{F})_x$, take
a representative
$$
\widetilde{s} \in
\mathfrak{C}^p(\mathcal{U}, \mathcal{F})(V) =
\prod\nolimits_{i_0 \ldots i_p}
\mathcal{F}(V \cap U_{i_0} \cap \ldots \cap U_{i_p})
$$
defined on some neighborhood $V$ of $x$, and set
$$
h(s)_{i_0 \ldots i_{p - 1}} =
\widetilde{s}_{i_{\text{fix}} i_0 \ldots i_{p - 1}, x}.
$$
By the same formula (for $p = 0$) we get a map
$\mathfrak{C}^{0}(\mathcal{U},\mathcal{F})_x \to \mathcal{F}_x$.
We compute formally as follows:
\begin{align*}
(dh + hd)(s)_{i_0 \ldots i_p}
& =
\sum\nolimits_{j = 0}^p
(-1)^j
h(s)_{i_0 \ldots \hat i_j \ldots i_p}
+
d(s)_{i_{\text{fix}} i_0 \ldots i_p}\\
& =
\sum\nolimits_{j = 0}^p
(-1)^j
s_{i_{\text{fix}} i_0 \ldots \hat i_j \ldots i_p}
+
s_{i_0 \ldots i_p}
+
\sum\nolimits_{j = 0}^p
(-1)^{j + 1}
s_{i_{\text{fix}} i_0 \ldots \hat i_j \ldots i_p} \\
& =
s_{i_0 \ldots i_p}
\end{align*}
This shows $h$ is a homotopy from the identity map of
the extended complex
$$
0 \to \mathcal{F}_x \to \mathfrak{C}^0(\mathcal{U}, \mathcal{F})_x
\to \mathfrak{C}^1(\mathcal{U}, \mathcal{F})_x \to \ldots
$$
to zero and we conclude.
\end{proof}

\noindent
With this lemma it is easy to reprove the {\v C}ech to cohomology spectral
sequence of Lemma \ref{lemma-cech-spectral-sequence}. Namely,
let $X$, $\mathcal{U}$, $\mathcal{F}$ as in
Lemma \ref{lemma-covering-resolution}
and let $\mathcal{F} \to \mathcal{I}^\bullet$ be an injective resolution.
Then we may consider the double complex
$$
A^{\bullet, \bullet} =
\Gamma(X, {\mathfrak C}^\bullet(\mathcal{U}, \mathcal{I}^\bullet)).
$$
By construction we have
$$
A^{p, q} = \prod\nolimits_{i_0 \ldots i_p} \mathcal{I}^q(U_{i_0 \ldots i_p})
$$
Consider the two spectral sequences of
Homology, Section \ref{homology-section-double-complex} associated
to this double complex, see especially
Homology, Lemma \ref{homology-lemma-ss-double-complex}.
For the spectral sequence $({}'E_r, {}'d_r)_{r \geq 0}$ we get
${}'E_2^{p, q} = \check{H}^p(\mathcal{U}, \underline{H}^q(\mathcal{F}))$
because taking products is exact
(Homology, Lemma \ref{homology-lemma-product-abelian-groups-exact}).
For the spectral sequence $({}''E_r, {}''d_r)_{r \geq 0}$ we get
${}''E_2^{p, q} = 0$ if $p > 0$ and ${}''E_2^{0, q} = H^q(X, \mathcal{F})$.
Namely, for fixed $q$ the complex of sheaves
${\mathfrak C}^\bullet(\mathcal{U}, \mathcal{I}^q)$
is a resolution (Lemma \ref{lemma-covering-resolution})
of the injective sheaf $\mathcal{I}^q$
by injective sheaves (by Lemmas \ref{lemma-cohomology-of-open} and
\ref{lemma-pushforward-injective-flat}
and
Homology, Lemma \ref{homology-lemma-product-injectives}).
Hence the cohomology of
$\Gamma(X, {\mathfrak C}^\bullet(\mathcal{U}, \mathcal{I}^q))$
is zero in positive degrees and equal to $\Gamma(X, \mathcal{I}^q)$
in degree $0$. Taking cohomology of the next differential
we get our claim about the spectral sequence $({}''E_r, {}''d_r)_{r \geq 0}$.
Whence the result since both spectral sequences converge to the
cohomology of the associated total complex of $A^{\bullet, \bullet}$.

\begin{definition}
\label{definition-covering-locally-finite}
Let $X$ be a topological space.
An open covering $X = \bigcup_{i \in I} U_i$ is said to be
{\it locally finite} if for every $x \in X$ there exists an open neighbourhood
$W$ of $x$ such that $\{i \in I \mid W \cap U_i \not = \emptyset\}$ is finite.
\end{definition}

\begin{remark}
\label{remark-locally-finite-sections}
Let $X = \bigcup_{i \in I} U_i$ be a locally finite open covering.
Denote $j_i : U_i \to X$ the inclusion map. Suppose that for each $i$
we are given an abelian sheaf $\mathcal{F}_i$ on $U_i$. Consider the
abelian sheaf $\mathcal{G} = \bigoplus_{i \in I} (j_i)_*\mathcal{F}_i$.
Then for $V \subset X$ open we actually have
$$
\Gamma(V, \mathcal{G}) = \prod\nolimits_{i \in I} \mathcal{F}_i(V \cap U_i).
$$
In other words we have
$$
\bigoplus\nolimits_{i \in I} (j_i)_*\mathcal{F}_i =
\prod\nolimits_{i \in I} (j_i)_*\mathcal{F}_i
$$
This seems strange until you realize that the direct sum of a collection
of sheaves is the sheafification of what you think it should be.
See discussion in Modules, Section \ref{modules-section-kernels}.
Thus we conclude that in this case the complex of
Lemma \ref{lemma-covering-resolution} has terms
$$
{\mathfrak C}^p(\mathcal{U}, \mathcal{F}) =
\bigoplus\nolimits_{i_0 \ldots i_p}
(j_{i_0 \ldots i_p})_* \mathcal{F}_{i_0 \ldots i_p}
$$
which is sometimes useful.
\end{remark}











\section{{\v C}ech cohomology of complexes}
\label{section-cech-cohomology-of-complexes}

\noindent
In general for sheaves of abelian groups
${\mathcal F}$ and ${\mathcal G}$ on $X$ there is a cup product map
$$
H^i(X, {\mathcal F}) \times H^j(X, {\mathcal G})
\longrightarrow
H^{i + j}(X, {\mathcal F} \otimes_{\mathbf Z} {\mathcal G}).
$$
In this section we define it using {\v C}ech cocycles by an explicit formula
for the cup product. If you are worried about the fact that cohomology may not
equal {\v C}ech cohomology, then you can use hypercoverings and still
use the cocycle notation. This also has the advantage that
it works to define the cup product for hypercohomology on any topos (insert
future reference here).

\medskip\noindent
Let ${\mathcal F}^\bullet$ be a bounded below complex of presheaves of abelian
groups on $X$. We can often compute $H^n(X, {\mathcal F}^\bullet)$
using {\v C}ech cocycles. Namely, let
${\mathcal U} : X = \bigcup_{i \in I} U_i$
be an open covering of $X$. Since the {\v C}ech complex
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F})$
(Definition \ref{definition-cech-complex})
is functorial in the presheaf $\mathcal{F}$ we obtain a double complex
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet)$.
The associated total complex to
$\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet)$
is the complex with degree $n$ term
$$
\text{Tot}^n(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
=
\bigoplus\nolimits_{p + q = n}
\prod\nolimits_{i_0\ldots i_p} {\mathcal F}^q(U_{i_0\ldots i_p})
$$
see
Homology, Definition \ref{homology-definition-associated-simple-complex}.
A typical element in $\text{Tot}^n$ will be denoted
$\alpha = \{\alpha_{i_0\ldots i_p}\}$ where
$\alpha_{i_0 \ldots i_p} \in \mathcal{F}^q(U_{i_0\ldots i_p})$.
In other words the $\mathcal{F}$-degree of $\alpha_{i_0\ldots i_p}$ is
$q = n - p$. This notation requires us to be aware of the degree $\alpha$
lives in at all times. We indicate this situation by the formula
$\deg_{\mathcal F}(\alpha_{i_0\ldots i_p}) = q$.
According to our conventions in
Homology, Definition \ref{homology-definition-associated-simple-complex}
the differential of an element $\alpha$ of degree $n$ is given by
$$
d(\alpha)_{i_0\ldots i_{p + 1}}
=
\sum\nolimits_{j = 0}^{p + 1}
(-1)^j \alpha_{i_0 \ldots \hat i_j \ldots i_{p + 1}} + 
(-1)^{p + 1}d_{{\mathcal F}}(\alpha_{i_0 \ldots i_{p + 1}})
$$
where $d_\mathcal{F}$ denotes the differential on the complex
$\mathcal{F}^\bullet$.
The expression $\alpha_{i_0 \ldots \hat i_j \ldots i_{p + 1}}$ means the
restriction of $\alpha_{i_0 \ldots \hat i_j \ldots i_{p + 1}}
\in {\mathcal F}(U_{i_0\ldots\hat i_j\ldots i_{p + 1}})$ to
$U_{i_0 \ldots i_{p + 1}}$.

\medskip\noindent
The construction of
$\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))$
is functorial in ${\mathcal F}^\bullet$. As well there is a functorial
transformation
\begin{equation}
\label{equation-global-sections-to-cech}
\Gamma(X, {\mathcal F}^\bullet)
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\end{equation}
of complexes defined by the following rule: The section
$s\in \Gamma(X, {\mathcal F}^n)$
is mapped to the element $\alpha = \{\alpha_{i_0\ldots i_p}\}$
with $\alpha_{i_0} = s|_{U_{i_0}}$ and $\alpha_{i_0\ldots i_p} = 0$
for $p > 0$.

\medskip\noindent
Refinements. Let ${\mathcal V} = \{ V_j \}_{j\in J}$ be a
refinement of ${\mathcal U}$. This means there is a map $t: J \to I$
such that $V_j \subset U_{t(j)}$ for all $j\in J$. This gives
rise to a functorial transformation
\begin{equation}
\label{equation-transformation}
T_t :
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal V}, {\mathcal F}^\bullet)).
\end{equation}
defined by the rule
$$
T_t(\alpha)_{j_0\ldots j_p}
=
\alpha_{t(j_0)\ldots t(j_p)}|_{V_{j_0\ldots j_p}}.
$$
Given two maps $t, t' : J \to I$ as above the maps
$T_t$ and $T_{t'}$ constructed above are homotopic.
The homotopy is given by
$$
h(\alpha)_{j_0\ldots j_p}
=
\sum\nolimits_{a = 0}^{p}
(-1)^a
\alpha_{t(j_0)\ldots t(j_a) t'(j_a) \ldots t'(j_p)}
$$
for an element $\alpha$ of degree $n$. This works
because of the following computation, again with
$\alpha$ an element of degree $n$ (so $d(\alpha)$
has degree $n + 1$ and $h(\alpha)$ has degree $n - 1$):
\begin{align*}
(
d(h(\alpha)) + h(d(\alpha))
)_{j_0\ldots j_p}
= &
\sum\nolimits_{k = 0}^p
(-1)^k
h(\alpha)_{j_0 \ldots \hat j_k \ldots j_p}
+ \\
&
(-1)^p
d_{\mathcal F}(h(\alpha)_{j_0 \ldots j_p})
+ \\
&
\sum\nolimits_{a = 0}^p
(-1)^a
d(\alpha)_{t(j_0) \ldots t(j_a) t'(j_a) \ldots t'(j_p)}
\\
= &
\sum\nolimits_{k = 0}^p
\sum\nolimits_{a = 0}^{k - 1}
(-1)^{k + a}
\alpha_{t(j_0)\ldots t(j_a)t'(j_a)\ldots \hat{t'(j_k)}\ldots t'(j_p)}
+ \\
&
\sum\nolimits_{k = 0}^p
\sum\nolimits_{a = k + 1}^p
(-1)^{k + a - 1}
\alpha_{t(j_0)\ldots \hat{t(j_k)}\ldots t(j_a)t'(j_a)\ldots t'(j_p)}
+ \\
&
\sum\nolimits_{a = 0}^p
(-1)^{p + a}
d_{\mathcal F}(\alpha_{t(j_0)\ldots t(j_a) t'(j_a) \ldots t'(j_p)})
+ \\
&
\sum\nolimits_{a = 0}^p
\sum\nolimits_{k = 0}^a
(-1)^{a + k}
\alpha_{t(j_0)\ldots\hat{t(j_k)}\ldots t(j_a)t'(j_a)\ldots t'(j_p)}
+ \\
&
\sum\nolimits_{a = 0}^p
\sum\nolimits_{k = a}^p
(-1)^{a + k + 1}
\alpha_{t(j_0) \ldots t(j_a) t'(j_a) \ldots \hat{t'(j_k)} \ldots t'(j_p)}
+ \\
&
\sum\nolimits_{a = 0}^p
(-1)^{a + p + 1}
d_{\mathcal F}(\alpha_{t(j_0)\ldots t(j_a) t'(j_a) \ldots t'(j_p)})
\\
= &
\alpha_{t'(j_0)\ldots t'(j_p)} +
(-1)^{2p + 1}\alpha_{t(j_0)\ldots t(j_p)}
\\
= &
T_{t'}(\alpha)_{j_0\ldots j_p} - T_t(\alpha)_{j_0\ldots j_p}
\end{align*}
We leave it to the reader to verify the cancellations. (Note that the
terms having both $k$ and $a$ in the 1st, 2nd and 4th, 5th summands
cancel, except the ones where $a = k$ which only occur in the 4th and 5th
and these cancel against each other except for the two desired terms.)
It follows that the induced map
$$
H^n(T_t) :
H^n(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
)
\to
H^n(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal V}, {\mathcal F}^\bullet))
)
$$
is independent of the choice of $t$. We define
{\it {\v C}ech hypercohomology} as the limit of the
{\v C}ech cohomology groups
over all refinements via the maps $H^\bullet(T_t)$.

\medskip\noindent
In the limit (over all open coverings of $X$) the following lemma provides
a map of {\v C}ech hypercohomology into cohomology, which is often an
isomorphism and is always an isomorphism if we use hypercoverings.

\begin{lemma}
\label{lemma-cech-complex-complex}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$ be
an open covering. For a bounded below complex $\mathcal{F}^\bullet$
of $\mathcal{O}_X$-modules there is a canonical map
$$
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet))
\longrightarrow
R\Gamma(X, \mathcal{F}^\bullet)
$$
functorial in $\mathcal{F}^\bullet$ and compatible with
(\ref{equation-global-sections-to-cech}) and (\ref{equation-transformation}).
There is a spectral sequence $(E_r, d_r)_{r \geq 0}$ with
$$
E_2^{p, q} =
H^p(\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U},
\underline{H}^q(\mathcal{F}^\bullet)))
$$
converging to $H^{p + q}(X, \mathcal{F}^\bullet)$.
\end{lemma}

\begin{proof}
Let ${\mathcal I}^\bullet$ be a bounded below complex of injectives.
The map (\ref{equation-global-sections-to-cech}) for
$\mathcal{I}^\bullet$ is a map
$\Gamma(X, {\mathcal I}^\bullet) \to
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal I}^\bullet))$.
This is a quasi-isomorphism of complexes of abelian groups
as follows from
Homology, Lemma \ref{homology-lemma-double-complex-gives-resolution}
applied to the double complex
$\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal I}^\bullet)$ using
Lemma \ref{lemma-injective-trivial-cech}.
Suppose ${\mathcal F}^\bullet \to {\mathcal I}^\bullet$ is a quasi-isomorphism
of ${\mathcal F}^\bullet$ into a bounded below complex of injectives.
Since $R\Gamma(X, {\mathcal F}^\bullet)$ is represented by the complex
$\Gamma(X, {\mathcal I}^\bullet)$ we obtain the map of the lemma
using
$$
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal I}^\bullet)).
$$
We omit the verification of functoriality and compatibilities.
To construct the spectral sequence of the lemma, choose a Cartan-Eilenberg
resolution $\mathcal{F}^\bullet \to \mathcal{I}^{\bullet, \bullet}$, see
Derived Categories, Lemma \ref{derived-lemma-cartan-eilenberg}. In this
case $\mathcal{F}^\bullet \to \text{Tot}(\mathcal{I}^{\bullet, \bullet})$
is an injective resolution and hence
$$
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U},
\text{Tot}({\mathcal I}^{\bullet, \bullet})))
$$
computes $R\Gamma(X, \mathcal{F}^\bullet)$ as we've seen above.
By Homology, Remark \ref{homology-remark-triple-complex}
we can view this as the total complex associated to the
triple complex
$\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal I}^{\bullet, \bullet})$
hence, using the same remark we can view it as the total complex
associate to the double complex $A^{\bullet, \bullet}$ with terms
$$
A^{n, m} =
\bigoplus\nolimits_{p + q = n}
\check{\mathcal{C}}^p({\mathcal U}, \mathcal{I}^{q, m})
$$
Since $\mathcal{I}^{q, \bullet}$ is an injective resolution of
$\mathcal{F}^q$ we can apply the first spectral sequence associated to
$A^{\bullet, \bullet}$
(Homology, Lemma \ref{homology-lemma-ss-double-complex})
to get a spectral sequence with
$$
E_1^{n, m} =
\bigoplus\nolimits_{p + q = n}
\check{\mathcal{C}}^p(\mathcal{U}, \underline{H}^m(\mathcal{F}^q))
$$
which is the $n$th term of the complex
$\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U},
\underline{H}^m(\mathcal{F}^\bullet))$. Hence we obtain
$E_2$ terms as described in the lemma. Convergence by
Homology, Lemma \ref{homology-lemma-first-quadrant-ss}.
\end{proof}

\begin{lemma}
\label{lemma-cech-complex-complex-computes}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$ be
an open covering. Let $\mathcal{F}^\bullet$ be a bounded below complex
of $\mathcal{O}_X$-modules. If $H^i(U_{i_0 \ldots i_p}, \mathcal{F}^q) = 0$
for all $i > 0$ and all $p, i_0, \ldots, i_p, q$, then the map
$
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet))
\to
R\Gamma(X, \mathcal{F}^\bullet)
$
of Lemma \ref{lemma-cech-complex-complex} is an isomorphism.
\end{lemma}

\begin{proof}
Immediate from the spectral sequence of Lemma \ref{lemma-cech-complex-complex}.
\end{proof}

\begin{remark}
\label{remark-shift-complex-cech-complex}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{U} : X = \bigcup_{i \in I} U_i$ be
an open covering. Let $\mathcal{F}^\bullet$ be a bounded below complex
of $\mathcal{O}_X$-modules. Let $b$ be an integer.
We claim there is a commutative diagram
$$
\xymatrix{
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet))[b]
\ar[r] \ar[d]_\gamma &
R\Gamma(X, \mathcal{F}^\bullet)[b] \ar[d] \\
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet[b]))
\ar[r] &
R\Gamma(X, \mathcal{F}^\bullet[b])
}
$$
in the derived category where the map $\gamma$ is the map on complexes
constructed in Homology, Remark \ref{homology-remark-shift-double-complex}.
This makes sense because the double complex
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet[b])$
is clearly the same as the double complex
$\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet)[0, b]$
introduced in Homology, Remark \ref{homology-remark-shift-double-complex}.
To check that the diagram commutes, we may choose an injective resolution
$\mathcal{F}^\bullet \to \mathcal{I}^\bullet$ as in the proof of
Lemma \ref{lemma-cech-complex-complex}. Chasing diagrams, we see that
it suffices to check the diagram commutes when we replace $\mathcal{F}^\bullet$
by $\mathcal{I}^\bullet$. Then we consider the extended diagram
$$
\xymatrix{
\Gamma(X, \mathcal{I}^\bullet)[b] \ar[r] \ar[d] &
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet))[b]
\ar[r] \ar[d]_\gamma &
R\Gamma(X, \mathcal{I}^\bullet)[b] \ar[d] \\
\Gamma(X, \mathcal{I}^\bullet[b]) \ar[r] &
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}^\bullet[b]))
\ar[r] &
R\Gamma(X, \mathcal{I}^\bullet[b])
}
$$
where the left horizontal arrows are (\ref{equation-global-sections-to-cech}).
Since in this case the horizonal arrows are isomorphisms in the derived
category (see proof of Lemma \ref{lemma-cech-complex-complex}) it
suffices to show that the left square commutes. This is true because
the map $\gamma$ uses the sign $1$ on the summands
$\check{\mathcal{C}}^0(\mathcal{U}, \mathcal{I}^{q + b})$, see
formula in Homology, Remark \ref{homology-remark-shift-double-complex}.
\end{remark}

\noindent
Let $X$ be a topological space, let $\mathcal{U} : X = \bigcup_{i \in I} U_i$
be an open covering, and let $\mathcal{F}^\bullet$ be a bounded below
complex of presheaves of abelian groups. Consider the map
$\tau :
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\to
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))$
defined by
$$
\tau(\alpha)_{i_0 \ldots i_p} = (-1)^{p(p + 1)/2} \alpha_{i_p \ldots i_0}.
$$
Then we have for an element $\alpha$ of degree $n$ that
\begin{align*}
& d(\tau(\alpha))_{i_0 \ldots i_{p + 1}} \\
& =
\sum\nolimits_{j = 0}^{p + 1}
(-1)^j
\tau(\alpha)_{i_0 \ldots \hat i_j \ldots i_{p + 1}}
+
(-1)^{p + 1}
d_{\mathcal F}(\tau(\alpha)_{i_0 \ldots i_{p + 1}})
\\
& =
\sum\nolimits_{j = 0}^{p + 1}
(-1)^{j + \frac{p(p + 1)}{2}}
\alpha_{i_{p + 1} \ldots \hat i_j \ldots i_0}
+
(-1)^{p + 1 + \frac{(p + 1)(p + 2)}{2}}
d_{\mathcal F}(\alpha_{i_{p + 1} \ldots i_0})
\end{align*}
On the other hand we have
\begin{align*}
& \tau(d(\alpha))_{i_0\ldots i_{p + 1}} \\
& =
(-1)^{\frac{(p + 1)(p + 2)}{2}} d(\alpha)_{i_{p + 1} \ldots i_0}
\\
& =
(-1)^{\frac{(p + 1)(p + 2)}{2}}
\left(
\sum\nolimits_{j = 0}^{p + 1}
(-1)^j
\alpha_{i_{p + 1}\ldots \hat i_{p + 1 - j} \ldots i_0}
+
(-1)^{p + 1}
d_{\mathcal F}(\alpha_{i_{p + 1}\ldots i_0})
\right)
\end{align*}
Thus we conclude that $d(\tau(\alpha)) = \tau(d(\alpha))$
because $p(p + 1)/2 \equiv (p + 1)(p + 2)/2 + p + 1 \bmod 2$. In other words
$\tau$ is an endomorphism of the complex
$\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))$.
Note that the diagram
$$
\begin{matrix}
\Gamma(X, {\mathcal F}^\bullet) &
\longrightarrow &
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet)) \\
\downarrow \text{id} & & \downarrow \tau \\
\Gamma(X, {\mathcal F}^\bullet) &
\longrightarrow &
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\end{matrix}
$$
commutes. In addition $\tau$ is clearly compatible with refinements.
This suggests that $\tau$ acts as the identity on {\v C}ech cohomology
(i.e., in the limit -- provided {\v C}ech hypercohomology agrees with
hypercohomology, which is always the case if we use hypercoverings).
We claim that $\tau$ actually is homotopic to the identity on the
total {\v C}ech complex
$\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))$.
To prove this, we use as homotopy
$$
h(\alpha)_{i_0 \ldots i_p}
=
\sum\nolimits_{a = 0}^p
\epsilon_p(a)
\alpha_{i_0 \ldots i_a i_p \ldots i_a}
\quad\text{with}\quad
\epsilon_p(a) = (-1)^{\frac{(p - a)(p - a - 1)}{2} + p}
$$
for $\alpha$ of degree $n$. As usual we omit writing
$|_{U_{i_0 \ldots i_p}}$. This works
because of the following computation, again with
$\alpha$ an element of degree $n$:
\begin{align*}
(d(h(\alpha)) + h(d(\alpha)))_{i_0 \ldots i_p}
= &
\sum\nolimits_{k = 0}^p
(-1)^k
h(\alpha)_{i_0 \ldots \hat i_k \ldots i_p}
+ \\
&
(-1)^p
d_{\mathcal F}(h(\alpha)_{i_0 \ldots i_p})
+ \\
&
\sum\nolimits_{a = 0}^p
\epsilon_p(a)
d(\alpha)_{i_0 \ldots i_a i_p \ldots i_a}
\\
= &
\sum\nolimits_{k = 0}^p
\sum\nolimits_{a = 0}^{k - 1}
(-1)^k \epsilon_{p - 1}(a)
\alpha_{i_0 \ldots i_a i_p \ldots \hat{i_k} \ldots i_a}
+ \\
&
\sum\nolimits_{k = 0}^p
\sum\nolimits_{a = k + 1}^p
(-1)^k \epsilon_{p - 1}(a - 1)
\alpha_{i_0 \ldots \hat{i_k} \ldots i_a i_p \ldots i_a}
+ \\
&
\sum\nolimits_{a = 0}^p
(-1)^p \epsilon_p(a)
d_{\mathcal F}(\alpha_{i_0 \ldots i_a i_p \ldots i_a})
+ \\
&
\sum\nolimits_{a = 0}^p
\sum\nolimits_{k = 0}^a
\epsilon_p(a) (-1)^k
\alpha_{i_0 \ldots \hat{i_k} \ldots i_a i_p \ldots i_a}
+ \\
&
\sum\nolimits_{a = 0}^p
\sum\nolimits_{k = a}^p
\epsilon_p(a) (-1)^{p + a + 1 - k}
\alpha_{i_0 \ldots i_a i_p \ldots \hat{i_k} \ldots i_a}
+ \\
&
\sum\nolimits_{a = 0}^p
\epsilon_p(a) (-1)^{p + 1}
d_{\mathcal F}(\alpha_{i_0 \ldots i_a i_p \ldots i_a})
\\
= &
\epsilon_p(0) \alpha_{i_p \ldots i_0} +
\epsilon_p(p) (-1)^{p + 1} \alpha_{i_0 \ldots i_p} \\
= &
(-1)^{\frac{p(p + 1)}{2}}\alpha_{i_p \ldots i_0}
- \alpha_{i_0 \ldots i_p}
\end{align*}
The cancellations follow because
$$
(-1)^k \epsilon_{p - 1}(a) + \epsilon_p(a)(-1)^{p + a + 1 - k} = 0
\quad\text{and}\quad
(-1)^k\epsilon_{p - 1}(a - 1) + \epsilon_p(a) (-1)^k = 0
$$
We leave it to the reader to verify the cancellations.

\medskip\noindent
Suppose we have two bounded below complexes of abelian sheaves
${\mathcal F}^\bullet$ and ${\mathcal G}^\bullet$. We define the complex
$\text{Tot}({\mathcal F}^\bullet\otimes_{\mathbf Z} {\mathcal G}^\bullet)$
to be to complex with terms
$\bigoplus_{p + q = n} {\mathcal F}^p \otimes {\mathcal G}^q$
and differential according to the rule
\begin{equation}
\label{equation-differential-tensor-product-complexes}
d(\alpha \otimes \beta) =
d(\alpha)\otimes \beta + (-1)^{\deg(\alpha)} \alpha \otimes d(\beta)
\end{equation}
when $\alpha$ and $\beta$ are homogeneous, see
Homology, Definition \ref{homology-definition-associated-simple-complex}.

\medskip\noindent
Suppose that $M^\bullet$ and $N^\bullet$ are two bounded below
complexes of abelian groups. Then if $m$, resp.\ $n$
is a cocycle for $M^\bullet$, resp.\ $N^\bullet$, it is immediate
that $m \otimes n$ is a cocycle for $\text{Tot}(M^\bullet\otimes N^\bullet)$.
Hence a cup product
$$
H^i(M^\bullet) \times H^j(N^\bullet)
\longrightarrow
H^{i + j}(Tot(M^\bullet\otimes N^\bullet)).
$$
This is discussed also in
More on Algebra, Section \ref{more-algebra-section-products-tor}.

\medskip\noindent
So the construction of the cup product in hypercohomology
of complexes rests on a construction of a map of complexes
\begin{equation}
\label{equation-needs-signs}
\text{Tot}\left(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\otimes_{\mathbf Z}
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal G}^\bullet))
\right)
\longrightarrow
\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U},
\text{Tot}({\mathcal F}^\bullet\otimes {\mathcal G}^\bullet)
))
\end{equation}
This map is denoted $\cup$ and is given by the rule
$$
(\alpha \cup \beta)_{i_0 \ldots i_p}
=
\sum\nolimits_{r = 0}^p
\epsilon(n, m, p, r)
\alpha_{i_0 \ldots i_r} \otimes \beta_{i_r \ldots i_p}.
$$
where $\alpha$ has degree $n$ and $\beta$ has degree $m$
and with
$$
\epsilon(n, m, p, r) = (-1)^{(p + r)n + rp + r}.
$$
Note that $\epsilon(n, m, p, n) = 1$. Hence if
$\mathcal{F}^\bullet = \mathcal{F}[0]$ is the complex
consisting in a single abelian sheaf $\mathcal{F}$ placed in degree $0$,
then there no signs in the formula for $\cup$ (as in that case
$\alpha_{i_0 \ldots i_r} = 0$ unless $r = n$).
For an explanation of why there has to be a sign and how to
compute it see \cite[Exposee XVII]{SGA4} by Deligne.
To check (\ref{equation-needs-signs})
is a map of complexes we have to show that
$$
d(\alpha \cup \beta) =
d(\alpha) \cup \beta +
(-1)^{\deg(\alpha)} \alpha \cup d(\beta)
$$
by the definition of the differential on
$\text{Tot}(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\otimes_{\mathbf Z}
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal G}^\bullet))
)$
as given in
Homology, Definition \ref{homology-definition-associated-simple-complex}.
We compute first
\begin{align*}
d(\alpha \cup \beta)_{i_0 \ldots i_{p + 1}}
= &
\sum\nolimits_{j = 0}^{p + 1}
(-1)^j
(\alpha \cup \beta)_{i_0 \ldots \hat i_j \ldots i_{p + 1}}
+
(-1)^{p + 1}
d_{{\mathcal F} \otimes {\mathcal G}}
((\alpha \cup \beta)_{i_0 \ldots i_{p + 1}})
\\
= &
\sum\nolimits_{j = 0}^{p + 1}
\sum\nolimits_{r = 0}^{j - 1}
(-1)^j \epsilon(n, m, p, r)
\alpha_{i_0 \ldots i_r} \otimes \beta_{i_r \ldots \hat i_j \ldots i_{p + 1}}
+ \\
&
\sum\nolimits_{j = 0}^{p + 1}
\sum\nolimits_{r = j + 1}^{p + 1}
(-1)^j \epsilon(n, m, p, r - 1)
\alpha_{i_0 \ldots \hat i_j \ldots i_r} \otimes \beta_{i_r \ldots i_{p + 1}}
+ \\
&
\sum\nolimits_{r = 0}^{p + 1}
(-1)^{p + 1} \epsilon(n, m, p + 1, r)
d_{{\mathcal F} \otimes {\mathcal G}}
(\alpha_{i_0 \ldots i_r} \otimes \beta_{i_r \ldots i_{p + 1}})
\end{align*}
and note that the summands in the last term equal
$$
(-1)^{p + 1} \epsilon(n, m, p + 1, r)
\left(
d_{\mathcal F}(\alpha_{i_0 \ldots i_r}) \otimes 
\beta_{i_r \ldots i_{p + 1}} +
(-1)^{n - r}
\alpha_{i_0 \ldots i_r} \otimes d_{\mathcal G}(\beta_{i_r \ldots i_{p + 1}})
\right).
$$
because $\deg_\mathcal{F}(\alpha_{i_0 \ldots i_r}) = n - r$.
On the other hand
\begin{align*}
(d(\alpha) \cup \beta)_{i_0\ldots i_{p + 1}}
= &
\sum\nolimits_{r = 0}^{p + 1}
\epsilon(n + 1, m, p + 1, r)
d(\alpha)_{i_0\ldots i_r} \otimes \beta_{i_r\ldots i_{p + 1}}
\\
= &
\sum\nolimits_{r = 0}^{p + 1}
\sum\nolimits_{j = 0}^{r}
\epsilon(n + 1, m, p + 1, r) (-1)^j
\alpha_{i_0\ldots\hat{i_j}\ldots i_r} \otimes \beta_{i_r\ldots i_{p + 1}}
+ \\
&
\sum\nolimits_{r = 0}^{p + 1}
\epsilon(n + 1, m, p + 1, r) (-1)^r
d_{\mathcal F}(\alpha_{i_0 \ldots i_r}) \otimes \beta_{i_r\ldots i_{p + 1}}
\end{align*}
and
\begin{align*}
(\alpha \cup d(\beta))_{i_0\ldots i_{p + 1}}
= &
\sum\nolimits_{r = 0}^{p + 1}
\epsilon(n, m + 1, p + 1, r)
\alpha_{i_0 \ldots i_r} \otimes d(\beta)_{i_r \ldots i_{p + 1}}
\\
= &
\sum\nolimits_{r = 0}^{p + 1}
\sum\nolimits_{j = r}^{p + 1}
\epsilon(n, m + 1, p + 1, r) (-1)^{j - r}
\alpha_{i_0 \ldots i_r} \otimes \beta_{i_r \ldots \hat{i_j}\ldots i_{p + 1}}
+ \\
&
\sum\nolimits_{r = 0}^{p + 1}
\epsilon(n, m + 1, p + 1, r) (-1)^{p + 1 - r}
\alpha_{i_0 \ldots i_r} \otimes d_{\mathcal G}(\beta_{i_r \ldots i_{p + 1}})
\end{align*}
The desired equality holds if we have
\begin{align*}
(-1)^{p + 1} \epsilon(n, m, p + 1, r)
& =
\epsilon(n + 1, m, p + 1, r) (-1)^r \\
(-1)^{p + 1} \epsilon(n, m, p + 1, r) (-1)^{n - r}
& =
(-1)^n \epsilon(n, m + 1, p + 1, r) (-1)^{p + 1 - r} \\
\epsilon(n + 1, m, p + 1, r) (-1)^r
& =
(-1)^{1 + n} \epsilon(n, m + 1, p + 1, r - 1) \\
(-1)^j \epsilon(n, m, p, r)
& =
(-1)^n \epsilon(n, m + 1, p + 1, r) (-1)^{j - r} \\
(-1)^j \epsilon(n, m, p, r - 1)
& =
\epsilon(n + 1, m, p + 1, r) (-1)^j
\end{align*}
(The third equality is necessary to get the terms with $r = j$
from $d(\alpha) \cup \beta$ and $(-1)^n \alpha \cup d(\beta)$
to cancel each other.) We leave the verifications to the reader.
(Alternatively, check the script signs.gp in the scripts subdirectory
of the Stacks project.)

\medskip\noindent
Associativity of the cup product. Suppose that ${\mathcal F}^\bullet$,
${\mathcal G}^\bullet$ and ${\mathcal H}^\bullet$ are bounded below
complexes of abelian groups on $X$. The obvious map
(without the intervention of signs) is an isomorphism
of complexes
$$
\text{Tot}(
\text{Tot}({\mathcal F}^\bullet \otimes_{\mathbf Z} {\mathcal G}^\bullet)
\otimes_{\mathbf Z} {\mathcal H}^\bullet
)
\longrightarrow
\text{Tot}(
{\mathcal F}^\bullet \otimes_{\mathbf Z}
\text{Tot}({\mathcal G}^\bullet \otimes_{\mathbf Z} {\mathcal H}^\bullet)
).
$$
Another way to say this is that the triple complex
${\mathcal F}^\bullet \otimes_{\mathbf Z} {\mathcal G}^\bullet
\otimes_{\mathbf Z} {\mathcal H}^\bullet$ gives rise to a well defined
total complex with differential satisfying
$$
d(\alpha \otimes \beta \otimes \gamma) =
d(\alpha) \otimes \beta \otimes \gamma +
(-1)^{\deg(\alpha)} \alpha \otimes d(\beta) \otimes \gamma +
(-1)^{\deg(\alpha) + \deg(\beta)} \alpha \otimes \beta \otimes d(\gamma)
$$
for homogeneous elements. Using this map it is easy to verify that
$$
(\alpha \cup \beta) \cup \gamma = \alpha \cup ( \beta \cup \gamma)
$$
namely, if $\alpha$ has degree $a$, $\beta$ has degree $b$ and
$\gamma$ has degree $c$, then
\begin{align*}
((\alpha \cup \beta) \cup \gamma)_{i_0 \ldots i_p}
= &
\sum\nolimits_{r = 0}^p
\epsilon(a + b, c, p, r)
(\alpha \cup \beta)_{i_0 \ldots i_r} \otimes \gamma_{i_r \ldots i_p}
\\
= &
\sum\nolimits_{r = 0}^p
\sum\nolimits_{s = 0}^r
\epsilon(a + b, c, p, r) \epsilon(a, b, r, s)
\alpha_{i_0 \ldots i_s} \otimes
\beta_{i_s \ldots i_r} \otimes
\gamma_{i_r \ldots i_p}
\end{align*}
and
\begin{align*}
(\alpha \cup (\beta \cup \gamma)_{i_0\ldots i_p}
= &
\sum\nolimits_{s = 0}^p
\epsilon(a, b + c, p, s)
\alpha_{i_0 \ldots i_s} \otimes (\beta \cup \gamma)_{i_s \ldots i_p}
\\
= &
\sum\nolimits_{s = 0}^p
\sum\nolimits_{r = s}^p
\epsilon(a, b + c, p, s) \epsilon(b, c, p - s, r - s)
\alpha_{i_0 \ldots i_s} \otimes \beta_{i_s \ldots i_r} \otimes
\gamma_{i_r \ldots i_p}
\end{align*}
and a trivial mod $2$ calculation shows the signs match up.
(Alternatively, check the script signs.gp in the scripts subdirectory
of the Stacks project.)

\medskip\noindent
Finally, we indicate why the cup product preserves a graded commutative
structure, at least on a cohomological level. For this we use the operator
$\tau$ introduced above. Let ${\mathcal F}^\bullet$ be a bounded below
complexes of abelian groups, and assume we are given a graded commutative
multiplication
$$
\wedge^\bullet :
\text{Tot}({\mathcal F}^\bullet\otimes {\mathcal F}^\bullet)
\longrightarrow
{\mathcal F}^\bullet.
$$
This means the following: For $s$ a local section of
${\mathcal F}^a$, and $t$ a local section of ${\mathcal F}^b$
we have $s \wedge t$ a local section of ${\mathcal F}^{a + b}$.
Graded commutative means we have
$s \wedge t = (-1)^{ab} t \wedge s$. Since $\wedge$ is a map
of complexes we have
$d(s\wedge t) = d(s) \wedge t + (-1)^a s \wedge d(t)$.
The composition
$$
\text{Tot}(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
\otimes
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
)
\to
\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U},
\text{Tot}({\mathcal F}^\bullet\otimes_{\mathbf Z}{\mathcal F}^\bullet))
)
\to
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
$$
induces a cup product on cohomology
$$
H^n(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
)
\times
H^m(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
)
\longrightarrow
H^{n + m}(
\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))
)
$$
and so in the limit also a product on {\v C}ech cohomology
and therefore (using hypercoverings if needed) a product
in cohomology of ${\mathcal F}^\bullet$. We claim this product
(on cohomology) is graded commutative as well. To prove this
we first consider an element $\alpha$ of degree $n$ in
$\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))$
and an element $\beta$ of degree $m$ in
$\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}^\bullet))$
and we compute
\begin{align*}
\wedge^\bullet(\alpha \cup \beta)_{i_0 \ldots i_p}
= &
\sum\nolimits_{r = 0}^p
\epsilon(n, m, p, r)
\alpha_{i_0 \ldots i_r} \wedge \beta_{i_r \ldots i_p} \\
= &
\sum\nolimits_{r = 0}^p
\epsilon(n, m, p, r)
(-1)^{\deg(\alpha_{i_0 \ldots i_r})\deg(\beta_{i_r \ldots i_p})}
\beta_{i_r \ldots i_p} \wedge \alpha_{i_0 \ldots i_r}
\end{align*}
because $\wedge$ is graded commutative. On the other hand we have
\begin{align*}
\tau(\wedge^\bullet(\tau(\beta) \cup \tau(\alpha)))_{i_0 \ldots i_p}
= &
\chi(p)
\sum\nolimits_{r = 0}^p
\epsilon(m, n, p, r)
\tau(\beta)_{i_p \ldots i_{p - r}} \wedge \tau(\alpha)_{i_{p - r} \ldots i_0}
\\
= &
\chi(p)
\sum\nolimits_{r = 0}^p
\epsilon(m, n, p, r) \chi(r) \chi(p - r)
\beta_{i_{p - r} \ldots i_p} \wedge \alpha_{i_0 \ldots i_{p - r}}
\\
= &
\chi(p)
\sum\nolimits_{r = 0}^p
\epsilon(m, n, p, p - r) \chi(r) \chi(p - r)
\beta_{i_r \ldots i_p} \wedge \alpha_{i_0 \ldots i_r}
\end{align*}
where $\chi(t) = (-1)^{\frac{t(t + 1)}{2}}$. Since we proved earlier that
$\tau$ acts as the identity on cohomology we have to verify that
$$
\epsilon(n, m, p, r)
(-1)^{(n - r)(m - (p - r))}
=
(-1)^{nm} \chi(p)\epsilon(m, n, p, p - r) \chi(r) \chi(p - r)
$$
A trivial mod $2$ calculation shows these signs match up.
(Alternatively, check the script signs.gp in the scripts subdirectory
of the Stacks project.)

\medskip\noindent
Finally, we study the compatibility of cup product with boundary maps.
Suppose that
$$
0
\to
{\mathcal F}_1^\bullet
\to
{\mathcal F}_2^\bullet
\to
{\mathcal F}_3^\bullet
\to
0
\quad\text{and}\quad
0
\leftarrow
{\mathcal G}_1^\bullet
\leftarrow
{\mathcal G}_2^\bullet
\leftarrow
{\mathcal G}_3^\bullet
\leftarrow
0
$$
are short exact sequences of bounded below complexes of abelian
sheaves on $X$. Let ${\mathcal H}^\bullet$ be another bounded below
complex of abelian sheaves, and suppose we have maps of complexes
$$
\gamma_i :
\text{Tot}({\mathcal F}_i^\bullet \otimes_{\mathbf Z} {\mathcal G}_i^\bullet)
\longrightarrow
{\mathcal H}^\bullet
$$
which are compatible with the maps between the complexes, namely such that
the diagrams
$$
\xymatrix{
\text{Tot}({\mathcal F}_1^\bullet \otimes_{\mathbf Z} {\mathcal G}_1^\bullet)
\ar[d]_{\gamma_1}
&
\text{Tot}({\mathcal F}_1^\bullet \otimes_{\mathbf Z} {\mathcal G}_2^\bullet)
\ar[l] \ar[d]
\\
\mathcal{H}^\bullet &
\text{Tot}({\mathcal F}_2^\bullet \otimes_{\mathbf Z} {\mathcal G}_2^\bullet)
\ar[l]_-{\gamma_2}
}
$$
and
$$
\xymatrix{
\text{Tot}({\mathcal F}_2^\bullet \otimes_{\mathbf Z} {\mathcal G}_2^\bullet)
\ar[d]_{\gamma_2}
&
\text{Tot}({\mathcal F}_2^\bullet \otimes_{\mathbf Z} {\mathcal G}_3^\bullet)
\ar[l] \ar[d]
\\
\mathcal{H}^\bullet &
\text{Tot}({\mathcal F}_3^\bullet \otimes_{\mathbf Z} {\mathcal G}_3^\bullet)
\ar[l]_-{\gamma_3}
}
$$
are commutative.

\begin{lemma}
\label{lemma-compute-sign-cup-product-boundaries}
In the situation above, assume {\v C}ech cohomology agrees with cohomology
for the sheaves $\mathcal{F}_i^p$ and $\mathcal{G}_j^q$.
Let $a_3 \in H^n(X, \mathcal{F}_3^\bullet)$ and
$b_1 \in H^m(X, \mathcal{G}_1^\bullet)$. Then we have
$$
\gamma_1( \partial a_3 \cup b_1) =
(-1)^{n + 1} \gamma_3( a_3 \cup \partial b_1)
$$
in $H^{n + m}(X, \mathcal{H}^\bullet)$ where $\partial$ indicates the
boundary map on cohomology associated to the short exact sequences of
complexes above.
\end{lemma}

\begin{proof}
We will use the following conventions and notation. We think of
${\mathcal F}_1^p$ as a subsheaf of ${\mathcal F}_2^p$ and we think of
${\mathcal G}_3^q$ as a subsheaf of ${\mathcal G}_2^q$. Hence if $s$ is
a local section of ${\mathcal F}_1^p$ we use $s$ to denote
the corresponding section of ${\mathcal F}_2^p$ as well. Similarly
for local sections of ${\mathcal G}_3^q$. Furthermore,
if $s$ is a local section of ${\mathcal F}_2^p$ then we denote
$\bar s$ its image in ${\mathcal F}_3^p$. Similarly for the
map ${\mathcal G}_2^q \to {\mathcal G}^q_1$. In particular if
$s$ is a local section of ${\mathcal F}_2^p$ and $\bar s = 0$
then $s$ is a local section of ${\mathcal F}_1^p$. The commutativity
of the diagrams above implies, for local sections $s$ of
${\mathcal F}_2^p$ and $t$ of ${\mathcal G}_3^q$ that
$\gamma_2(s \otimes t) = \gamma_3(\bar s \otimes t)$ as sections of
${\mathcal H}^{p + q}$.

\medskip\noindent
Let ${\mathcal U} : X =  \bigcup_{i \in I} U_i$
be an open covering of $X$. Suppose that $\alpha_3$,
resp.\ $\beta_1$ is a degree $n$, resp.\ $m$ cocycle of
$\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}_3^\bullet))$,
resp.\ $\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal G}_1^\bullet))$
representing $a_3$, resp.\ $b_1$. After refining $\mathcal{U}$ if necessary,
we can find cochains $\alpha_2$, resp.\ $\beta_2$ of
degree $n$, resp.\ $m$ in
$\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}_2^\bullet))$,
resp.\ $\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal G}_2^\bullet))$
mapping to $\alpha_3$, resp.\ $\beta_1$.
Then we see that
$$
\overline{d(\alpha_2)} = d(\bar \alpha_2) = 0
\quad\text{and}\quad
\overline{d(\beta_2)} = d(\bar \beta_2) = 0.
$$
This means that $\alpha_1 = d(\alpha_2)$ is a degree $n + 1$ cocycle in
$\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal F}_1^\bullet))$
representing $\partial a_3$. Similarly, $\beta_3 = d(\beta_2)$ is
a degree $m + 1$ cocycle in
$\text{Tot}(\check{\mathcal{C}}^\bullet({\mathcal U}, {\mathcal G}_3^\bullet))$
representing $\partial b_1$.
Thus we may compute
\begin{align*}
d(\gamma_2(\alpha_2 \cup \beta_2))
& =
\gamma_2(d(\alpha_2 \cup \beta_2))
\\
& =
\gamma_2(d(\alpha_2) \cup \beta_2 + (-1)^n \alpha_2 \cup d(\beta_2) )
\\
& =
\gamma_2( \alpha_1 \cup \beta_2)  + (-1)^n \gamma_2( \alpha_2 \cup \beta_3)
\\
& =
\gamma_1(\alpha_1 \cup \beta_1) + (-1)^n \gamma_3(\alpha_3 \cup \beta_3)
\end{align*}
So this even tells us that the sign is $(-1)^{n + 1}$ as indicated
in the lemma\footnote{The sign depends on the convention for the
signs in the long exact sequence in cohomology associated to a triangle
in $D(X)$. The conventions in the Stacks project are (a) distinguished
triangles correspond to termwise split exact sequences and (b) the boundary
maps in the long exact sequence are given by the maps in the snake lemma
without the intervention of signs. See
Derived Categories, Section \ref{derived-section-homotopy-triangulated}.}.
\end{proof}

\begin{lemma}
\label{lemma-boundary-derivation-over-cup-product}
Let $X$ be a topological space. Let $\mathcal{O}' \to \mathcal{O}$ be a
surjection of sheaves of rings whose kernel $\mathcal{I} \subset \mathcal{O}'$
has square zero. Then $M = H^1(X, \mathcal{I})$ is a
$R = H^0(X, \mathcal{O})$-module and the boundary map
$\partial : R \to M$ associated to the short exact sequence
$$
0 \to \mathcal{I} \to \mathcal{O}' \to \mathcal{O} \to 0
$$
is a derivation (Algebra, Definition \ref{algebra-definition-derivation}).
\end{lemma}

\begin{proof}
The map $\mathcal{O}' \to \SheafHom(\mathcal{I}, \mathcal{I})$
factors through $\mathcal{O}$ as $\mathcal{I} \cdot \mathcal{I} = 0$
by assumption. Hence $\mathcal{I}$ is a sheaf of $\mathcal{O}$-modules
and this defines the $R$-module structure on $M$.
The boundary map is additive hence it suffices to prove
the Leibniz rule. Let $f \in R$. Choose an open covering
$\mathcal{U} : X = \bigcup U_i$ such that there exist
$f_i \in \mathcal{O}'(U_i)$ lifting $f|_{U_i} \in \mathcal{O}(U_i)$.
Observe that $f_i - f_j$ is an element of $\mathcal{I}(U_i \cap U_j)$.
Then $\partial(f)$ corresponds to the {\v C}ech cohomology class of
the $1$-cocycle $\alpha$ with $\alpha_{i_0i_1} = f_{i_0} - f_{i_1}$.
(Observe that by Lemma \ref{lemma-cech-h1} the first {\v C}ech cohomology
group with respect to $\mathcal{U}$ is a submodule of $M$.)
Next, let $g \in R$ be a second element and assume (after possibly
refining the open covering) that $g_i \in \mathcal{O}'(U_i)$ lifts
$g|_{U_i} \in \mathcal{O}(U_i)$. Then we see that
$\partial(g)$ is given by the cocycle $\beta$ with
$\beta_{i_0i_1} = g_{i_0} - g_{i_1}$. Since $f_ig_i \in \mathcal{O}'(U_i)$
lifts $fg|_{U_i}$ we see that
$\partial(fg)$ is given by the cocycle $\gamma$ with
$$
\gamma_{i_0i_1} = f_{i_0}g_{i_0} - f_{i_1}g_{i_1} =
(f_{i_0} - f_{i_1})g_{i_0} + f_{i_1}(g_{i_0} - g_{i_1}) =
\alpha_{i_0i_1}g + f\beta_{i_0i_1}
$$
by our definition of the $\mathcal{O}$-module structure on $\mathcal{I}$.
This proves the Leibniz rule and the proof is complete.
\end{proof}









\section{Flat resolutions}
\label{section-flat}

\noindent
A reference for the material in this section is \cite{Spaltenstein}.
Let $(X, \mathcal{O}_X)$ be a ringed space. By
Modules, Lemma \ref{modules-lemma-module-quotient-flat}
any $\mathcal{O}_X$-module is a quotient of a flat $\mathcal{O}_X$-module.
By
Derived Categories, Lemma \ref{derived-lemma-subcategory-left-resolution}
any bounded above complex of $\mathcal{O}_X$-modules has a left
resolution by a bounded above complex of flat $\mathcal{O}_X$-modules.
However, for unbounded complexes, it turns out that flat resolutions
aren't good enough.

\begin{lemma}
\label{lemma-derived-tor-exact}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{G}^\bullet$ be a complex of $\mathcal{O}_X$-modules.
The functors
$$
K(\textit{Mod}(\mathcal{O}_X))
\longrightarrow
K(\textit{Mod}(\mathcal{O}_X)),
\quad
\mathcal{F}^\bullet \longmapsto
\text{Tot}(\mathcal{G}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}^\bullet)
$$
and
$$
K(\textit{Mod}(\mathcal{O}_X))
\longrightarrow
K(\textit{Mod}(\mathcal{O}_X)),
\quad
\mathcal{F}^\bullet \longmapsto
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{G}^\bullet)
$$
are exact functors of triangulated categories.
\end{lemma}

\begin{proof}
This follows from Derived Categories, Remark
\ref{derived-remark-double-complex-as-tensor-product-of}.
\end{proof}

\begin{definition}
\label{definition-K-flat}
Let $(X, \mathcal{O}_X)$ be a ringed space.
A complex $\mathcal{K}^\bullet$ of $\mathcal{O}_X$-modules is
called {\it K-flat} if for every acyclic complex $\mathcal{F}^\bullet$
of $\mathcal{O}_X$-modules the complex
$$
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}^\bullet)
$$
is acyclic.
\end{definition}

\begin{lemma}
\label{lemma-K-flat-quasi-isomorphism}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{K}^\bullet$ be a K-flat complex.
Then the functor
$$
K(\textit{Mod}(\mathcal{O}_X))
\longrightarrow
K(\textit{Mod}(\mathcal{O}_X)), \quad
\mathcal{F}^\bullet
\longmapsto
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}^\bullet)
$$
transforms quasi-isomorphisms into quasi-isomorphisms.
\end{lemma}

\begin{proof}
Follows from
Lemma \ref{lemma-derived-tor-exact}
and the fact that quasi-isomorphisms are characterized by having
acyclic cones.
\end{proof}

\begin{lemma}
\label{lemma-check-K-flat-stalks}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{K}^\bullet$
be a complex of $\mathcal{O}_X$-modules. Then $\mathcal{K}^\bullet$
is K-flat if and only if for all $x \in X$ the complex
$\mathcal{K}_x^\bullet$ of $\mathcal{O}_{X, x}$-modules is K-flat
(More on Algebra, Definition \ref{more-algebra-definition-K-flat}).
\end{lemma}

\begin{proof}
If $\mathcal{K}_x^\bullet$ is K-flat for all $x \in X$ then we see
that $\mathcal{K}^\bullet$ is K-flat because $\otimes$ and
direct sums commute with taking stalks and because we can check exactness
at stalks, see
Modules, Lemma \ref{modules-lemma-abelian}.
Conversely, assume $\mathcal{K}^\bullet$ is K-flat. Pick $x \in X$
$M^\bullet$ be an acyclic complex of $\mathcal{O}_{X, x}$-modules.
Then $i_{x, *}M^\bullet$ is an acyclic complex of $\mathcal{O}_X$-modules.
Thus $\text{Tot}(i_{x, *}M^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}^\bullet)$
is acyclic. Taking stalks at $x$ shows that
$\text{Tot}(M^\bullet \otimes_{\mathcal{O}_{X, x}} \mathcal{K}_x^\bullet)$
is acyclic.
\end{proof}

\begin{lemma}
\label{lemma-tensor-product-K-flat}
Let $(X, \mathcal{O}_X)$ be a ringed space.
If $\mathcal{K}^\bullet$, $\mathcal{L}^\bullet$ are K-flat complexes
of $\mathcal{O}_X$-modules, then
$\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet)$
is a K-flat complex of $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
Follows from the isomorphism
$$
\text{Tot}(\mathcal{M}^\bullet \otimes_{\mathcal{O}_X}
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet))
=
\text{Tot}(\text{Tot}(\mathcal{M}^\bullet \otimes_{\mathcal{O}_X}
\mathcal{K}^\bullet) \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet)
$$
and the definition.
\end{proof}

\begin{lemma}
\label{lemma-K-flat-two-out-of-three}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $(\mathcal{K}_1^\bullet, \mathcal{K}_2^\bullet, \mathcal{K}_3^\bullet)$
be a distinguished triangle in $K(\textit{Mod}(\mathcal{O}_X))$.
If two out of three of $\mathcal{K}_i^\bullet$ are K-flat, so is the third.
\end{lemma}

\begin{proof}
Follows from
Lemma \ref{lemma-derived-tor-exact}
and the fact that in a distinguished triangle in
$K(\textit{Mod}(\mathcal{O}_X))$
if two out of three are acyclic, so is the third.
\end{proof}

\begin{lemma}
\label{lemma-K-flat-two-out-of-three-ses}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$0 \to \mathcal{K}_1^\bullet \to \mathcal{K}_2^\bullet \to
\mathcal{K}_3^\bullet \to 0$ be a short exact sequence of complexes
such that the terms of $\mathcal{K}_3^\bullet$ are flat $\mathcal{O}_X$-modules.
If two out of three of $\mathcal{K}_i^\bullet$ are K-flat, so is the third.
\end{lemma}

\begin{proof}
By Modules, Lemma \ref{modules-lemma-flat-tor-zero}
for every complex $\mathcal{L}^\bullet$
we obtain a short exact sequence
$$
0 \to
\text{Tot}(\mathcal{L}^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}_1^\bullet)
\to
\text{Tot}(\mathcal{L}^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}_1^\bullet)
\to
\text{Tot}(\mathcal{L}^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}_1^\bullet)
\to 0
$$
of complexes. Hence the lemma follows from the long exact sequence of
cohomology sheaves and the definition of K-flat complexes.
\end{proof}

\begin{lemma}
\label{lemma-pullback-K-flat}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of
ringed spaces. The pullback of a K-flat complex of $\mathcal{O}_Y$-modules
is a K-flat complex of $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
We can check this on stalks, see
Lemma \ref{lemma-check-K-flat-stalks}.
Hence this follows from
Sheaves, Lemma \ref{sheaves-lemma-stalk-pullback-modules}
and
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-K-flat}.
\end{proof}

\begin{lemma}
\label{lemma-bounded-flat-K-flat}
Let $(X, \mathcal{O}_X)$ be a ringed space. A bounded above complex
of flat $\mathcal{O}_X$-modules is K-flat.
\end{lemma}

\begin{proof}
We can check this on stalks, see
Lemma \ref{lemma-check-K-flat-stalks}.
Thus this lemma follows from
Modules, Lemma \ref{modules-lemma-flat-stalks-flat}
and
More on Algebra, Lemma \ref{more-algebra-lemma-derived-tor-quasi-isomorphism}.
\end{proof}

\noindent
In the following lemma by a colimit of a system of complexes we mean
the termwise colimit.

\begin{lemma}
\label{lemma-colimit-K-flat}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{K}_1^\bullet \to \mathcal{K}_2^\bullet \to \ldots$
be a system of K-flat complexes.
Then $\colim_i \mathcal{K}_i^\bullet$ is K-flat.
\end{lemma}

\begin{proof}
Because we are taking termwise colimits it is clear that
$$
\colim_i \text{Tot}(
\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}_i^\bullet)
=
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X}
\colim_i \mathcal{K}_i^\bullet)
$$
Hence the lemma follows from the fact that filtered colimits are
exact.
\end{proof}

\begin{lemma}
\label{lemma-resolution-by-direct-sums-extensions-by-zero}
Let $(X, \mathcal{O}_X)$ be a ringed space.
For any complex $\mathcal{G}^\bullet$ of $\mathcal{O}_X$-modules
there exists a commutative diagram of complexes of $\mathcal{O}_X$-modules
$$
\xymatrix{
\mathcal{K}_1^\bullet \ar[d] \ar[r] &
\mathcal{K}_2^\bullet \ar[d] \ar[r] & \ldots \\
\tau_{\leq 1}\mathcal{G}^\bullet \ar[r] &
\tau_{\leq 2}\mathcal{G}^\bullet \ar[r] & \ldots
}
$$
with the following properties: (1) the vertical arrows are quasi-isomorphisms
and termwise surjective,
(2) each $\mathcal{K}_n^\bullet$ is a bounded above complex whose terms
are direct sums of $\mathcal{O}_X$-modules of the form
$j_{U!}\mathcal{O}_U$, and
(3) the maps $\mathcal{K}_n^\bullet \to \mathcal{K}_{n + 1}^\bullet$ are
termwise split injections whose cokernels are direct sums of
$\mathcal{O}_X$-modules of the form $j_{U!}\mathcal{O}_U$. Moreover, the map
$\colim \mathcal{K}_n^\bullet \to \mathcal{G}^\bullet$ is a quasi-isomorphism.
\end{lemma}

\begin{proof}
The existence of the diagram and properties (1), (2), (3) follows immediately
from
Modules, Lemma \ref{modules-lemma-module-quotient-flat}
and
Derived Categories, Lemma \ref{derived-lemma-special-direct-system}.
The induced map
$\colim \mathcal{K}_n^\bullet \to \mathcal{G}^\bullet$
is a quasi-isomorphism because filtered colimits are exact.
\end{proof}

\begin{lemma}
\label{lemma-K-flat-resolution}
Let $(X, \mathcal{O}_X)$ be a ringed space.
For any complex $\mathcal{G}^\bullet$ there exists a $K$-flat complex
$\mathcal{K}^\bullet$ whose terms are flat $\mathcal{O}_X$-modules
and a quasi-isomorphism $\mathcal{K}^\bullet \to \mathcal{G}^\bullet$
which is termwise surjective.
\end{lemma}

\begin{proof}
Choose a diagram as in
Lemma \ref{lemma-resolution-by-direct-sums-extensions-by-zero}.
Each complex $\mathcal{K}_n^\bullet$ is a bounded
above complex of flat modules, see
Modules, Lemma \ref{modules-lemma-j-shriek-flat}.
Hence $\mathcal{K}_n^\bullet$ is K-flat by
Lemma \ref{lemma-bounded-flat-K-flat}.
Thus $\colim \mathcal{K}_n^\bullet$ is K-flat by
Lemma \ref{lemma-colimit-K-flat}.
The induced map
$\colim \mathcal{K}_n^\bullet \to \mathcal{G}^\bullet$
is a quasi-isomorphism and termwise surjective by construction.
Property (3) of Lemma \ref{lemma-resolution-by-direct-sums-extensions-by-zero}
shows that $\colim \mathcal{K}_n^m$ is a direct sum of
flat modules and hence flat which proves the final assertion.
\end{proof}

\begin{lemma}
\label{lemma-derived-tor-quasi-isomorphism-other-side}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\alpha : \mathcal{P}^\bullet \to \mathcal{Q}^\bullet$ be a
quasi-isomorphism of K-flat complexes of $\mathcal{O}_X$-modules.
For every complex $\mathcal{F}^\bullet$ of $\mathcal{O}_X$-modules
the induced map
$$
\text{Tot}(\text{id}_{\mathcal{F}^\bullet} \otimes \alpha) :
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{P}^\bullet)
\longrightarrow
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{Q}^\bullet)
$$
is a quasi-isomorphism.
\end{lemma}

\begin{proof}
Choose a quasi-isomorphism $\mathcal{K}^\bullet \to \mathcal{F}^\bullet$
with $\mathcal{K}^\bullet$ a K-flat complex, see
Lemma \ref{lemma-K-flat-resolution}.
Consider the commutative diagram
$$
\xymatrix{
\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X} \mathcal{P}^\bullet) \ar[r] \ar[d] &
\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X} \mathcal{Q}^\bullet) \ar[d] \\
\text{Tot}(\mathcal{F}^\bullet
\otimes_{\mathcal{O}_X} \mathcal{P}^\bullet) \ar[r] &
\text{Tot}(\mathcal{F}^\bullet
\otimes_{\mathcal{O}_X} \mathcal{Q}^\bullet)
}
$$
The result follows as by
Lemma \ref{lemma-K-flat-quasi-isomorphism}
the vertical arrows and the top horizontal arrow are quasi-isomorphisms.
\end{proof}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{F}^\bullet$ be an object of $D(\mathcal{O}_X)$.
Choose a K-flat resolution $\mathcal{K}^\bullet \to \mathcal{F}^\bullet$, see
Lemma \ref{lemma-K-flat-resolution}.
By
Lemma \ref{lemma-derived-tor-exact}
we obtain an exact functor of triangulated categories
$$
K(\mathcal{O}_X)
\longrightarrow
K(\mathcal{O}_X),
\quad
\mathcal{G}^\bullet
\longmapsto
\text{Tot}(\mathcal{G}^\bullet \otimes_{\mathcal{O}_X} \mathcal{K}^\bullet)
$$
By
Lemma \ref{lemma-K-flat-quasi-isomorphism}
this functor induces a functor
$D(\mathcal{O}_X) \to D(\mathcal{O}_X)$ simply because
$D(\mathcal{O}_X)$ is the localization of $K(\mathcal{O}_X)$
at quasi-isomorphisms. By
Lemma \ref{lemma-derived-tor-quasi-isomorphism-other-side}
the resulting functor (up to isomorphism)
does not depend on the choice of the K-flat resolution.

\begin{definition}
\label{definition-derived-tor}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{F}^\bullet$ be an object of $D(\mathcal{O}_X)$.
The {\it derived tensor product}
$$
- \otimes_{\mathcal{O}_X}^{\mathbf{L}} \mathcal{F}^\bullet :
D(\mathcal{O}_X)
\longrightarrow
D(\mathcal{O}_X)
$$
is the exact functor of triangulated categories described above.
\end{definition}

\noindent
It is clear from our explicit constructions that
there is a canonical isomorphism
$$
\mathcal{F}^\bullet \otimes_{\mathcal{O}_X}^{\mathbf{L}} \mathcal{G}^\bullet
\cong
\mathcal{G}^\bullet \otimes_{\mathcal{O}_X}^{\mathbf{L}} \mathcal{F}^\bullet
$$
for $\mathcal{G}^\bullet$ and $\mathcal{F}^\bullet$ in $D(\mathcal{O}_X)$.
Here we use sign rules as given in More on Algebra, Section
\ref{more-algebra-section-sign-rules}. Hence when we write
$\mathcal{F}^\bullet \otimes_{\mathcal{O}_X}^{\mathbf{L}} \mathcal{G}^\bullet$
we will usually be agnostic about which variable we are using to
define the derived tensor product with.

\begin{definition}
\label{definition-tor}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{F}$, $\mathcal{G}$ be $\mathcal{O}_X$-modules.
The {\it Tor}'s of $\mathcal{F}$ and $\mathcal{G}$ are define by
the formula
$$
\text{Tor}_p^{\mathcal{O}_X}(\mathcal{F}, \mathcal{G}) =
H^{-p}(\mathcal{F} \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{G})
$$
with derived tensor product as defined above.
\end{definition}

\noindent
This definition implies that for every short exact sequence
of $\mathcal{O}_X$-modules
$0 \to \mathcal{F}_1 \to \mathcal{F}_2 \to \mathcal{F}_3 \to 0$
we have a long exact cohomology sequence
$$
\xymatrix{
\mathcal{F}_1 \otimes_{\mathcal{O}_X} \mathcal{G} \ar[r] &
\mathcal{F}_2 \otimes_{\mathcal{O}_X} \mathcal{G} \ar[r] &
\mathcal{F}_3 \otimes_{\mathcal{O}_X} \mathcal{G} \ar[r] & 0 \\
\text{Tor}_1^{\mathcal{O}_X}(\mathcal{F}_1, \mathcal{G}) \ar[r] &
\text{Tor}_1^{\mathcal{O}_X}(\mathcal{F}_2, \mathcal{G}) \ar[r] &
\text{Tor}_1^{\mathcal{O}_X}(\mathcal{F}_3, \mathcal{G}) \ar[ull]
}
$$
for every $\mathcal{O}_X$-module $\mathcal{G}$. This will be called
the long exact sequence of $\text{Tor}$ associated to the situation.

\begin{lemma}
\label{lemma-flat-tor-zero}
\begin{slogan}
Tor measures the deviation of flatness.
\end{slogan}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is a flat $\mathcal{O}_X$-module, and
\item $\text{Tor}_1^{\mathcal{O}_X}(\mathcal{F}, \mathcal{G}) = 0$
for every $\mathcal{O}_X$-module $\mathcal{G}$.
\end{enumerate}
\end{lemma}

\begin{proof}
If $\mathcal{F}$ is flat, then $\mathcal{F} \otimes_{\mathcal{O}_X} -$
is an exact functor and the satellites vanish. Conversely assume (2)
holds. Then if $\mathcal{G} \to \mathcal{H}$ is injective with cokernel
$\mathcal{Q}$, the long exact sequence of $\text{Tor}$ shows that
the kernel of
$\mathcal{F} \otimes_{\mathcal{O}_X} \mathcal{G} \to
\mathcal{F} \otimes_{\mathcal{O}_X} \mathcal{H}$
is a quotient of
$\text{Tor}_1^{\mathcal{O}_X}(\mathcal{F}, \mathcal{Q})$
which is zero by assumption. Hence $\mathcal{F}$ is flat.
\end{proof}

\begin{lemma}
\label{lemma-factor-through-K-flat}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $a : \mathcal{K}^\bullet \to \mathcal{L}^\bullet$ be a map of complexes
of $\mathcal{O}_X$-modules. If $\mathcal{K}^\bullet$ is K-flat, then
there exist a complex $\mathcal{N}^\bullet$ and maps of complexes
$b : \mathcal{K}^\bullet \to \mathcal{N}^\bullet$
and $c : \mathcal{N}^\bullet \to \mathcal{L}^\bullet$ such that
\begin{enumerate}
\item $\mathcal{N}^\bullet$ is K-flat,
\item $c$ is a quasi-isomorphism,
\item $a$ is homotopic to $c \circ b$.
\end{enumerate}
If the terms of $\mathcal{K}^\bullet$ are flat, then we may choose
$\mathcal{N}^\bullet$, $b$, and $c$
such that the same is true for $\mathcal{N}^\bullet$.
\end{lemma}

\begin{proof}
We will use that the homotopy category $K(\textit{Mod}(\mathcal{O}_X))$
is a triangulated category, see Derived Categories, Proposition
\ref{derived-proposition-homotopy-category-triangulated}.
Choose a distinguished triangle
$\mathcal{K}^\bullet \to \mathcal{L}^\bullet \to
\mathcal{C}^\bullet \to \mathcal{K}^\bullet[1]$.
Choose a quasi-isomorphism $\mathcal{M}^\bullet \to \mathcal{C}^\bullet$ with
$\mathcal{M}^\bullet$ K-flat with flat terms, see
Lemma \ref{lemma-K-flat-resolution}.
By the axioms of triangulated categories,
we may fit the composition
$\mathcal{M}^\bullet \to \mathcal{C}^\bullet \to \mathcal{K}^\bullet[1]$
into a distinguished triangle
$\mathcal{K}^\bullet \to \mathcal{N}^\bullet \to
\mathcal{M}^\bullet \to \mathcal{K}^\bullet[1]$.
By Lemma \ref{lemma-K-flat-two-out-of-three} we see that
$\mathcal{N}^\bullet$ is K-flat.
Again using the axioms of triangulated categories,
we can choose a map $\mathcal{N}^\bullet \to \mathcal{L}^\bullet$ fitting into
the following morphism of distinghuised triangles
$$
\xymatrix{
\mathcal{K}^\bullet \ar[r] \ar[d] &
\mathcal{N}^\bullet \ar[r] \ar[d] &
\mathcal{M}^\bullet \ar[r] \ar[d] &
\mathcal{K}^\bullet[1] \ar[d] \\
\mathcal{K}^\bullet \ar[r] &
\mathcal{L}^\bullet \ar[r] &
\mathcal{C}^\bullet \ar[r] &
\mathcal{K}^\bullet[1]
}
$$
Since two out of three of the arrows are quasi-isomorphisms, so is
the third arrow $\mathcal{N}^\bullet \to \mathcal{L}^\bullet$
by the long exact sequences
of cohomology associated to these distinguished triangles
(or you can look at the image of this diagram in $D(\mathcal{O}_X)$ and use
Derived Categories, Lemma \ref{derived-lemma-third-isomorphism-triangle}
if you like). This finishes the proof of (1), (2), and (3).
To prove the final assertion, we may choose $\mathcal{N}^\bullet$
such that $\mathcal{N}^n \cong \mathcal{M}^n \oplus \mathcal{K}^n$, see
Derived Categories, Lemma
\ref{derived-lemma-improve-distinguished-triangle-homotopy}.
Hence we get the desired flatness
if the terms of $\mathcal{K}^\bullet$ are flat.
\end{proof}











\section{Derived pullback}
\label{section-derived-pullback}

\noindent
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. We can use K-flat resolutions to define
a derived pullback functor
$$
Lf^* : D(\mathcal{O}_Y) \to D(\mathcal{O}_X)
$$
Namely, for every complex of $\mathcal{O}_Y$-modules $\mathcal{G}^\bullet$
we can choose a K-flat resolution
$\mathcal{K}^\bullet \to \mathcal{G}^\bullet$ and set
$Lf^*\mathcal{G}^\bullet = f^*\mathcal{K}^\bullet$.
You can use
Lemmas \ref{lemma-pullback-K-flat},
\ref{lemma-K-flat-resolution}, and
\ref{lemma-derived-tor-quasi-isomorphism-other-side}
to see that this is well defined. However, to cross all the t's and dot all
the i's it is perhaps more convenient to use some general theory.

\begin{lemma}
\label{lemma-derived-base-change}
The construction above is independent of choices and defines an exact
functor of triangulated categories
$Lf^* : D(\mathcal{O}_Y) \to D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
To see this we use the general theory developed in
Derived Categories, Section \ref{derived-section-derived-functors}.
Set $\mathcal{D} = K(\mathcal{O}_Y)$ and $\mathcal{D}' = D(\mathcal{O}_X)$.
Let us write $F : \mathcal{D} \to \mathcal{D}'$ the exact functor
of triangulated categories defined by the rule
$F(\mathcal{G}^\bullet) = f^*\mathcal{G}^\bullet$.
We let $S$ be the set of quasi-isomorphisms in
$\mathcal{D} = K(\mathcal{O}_Y)$.
This gives a situation as in
Derived Categories, Situation \ref{derived-situation-derived-functor}
so that
Derived Categories, Definition
\ref{derived-definition-right-derived-functor-defined}
applies. We claim that $LF$ is everywhere defined.
This follows from
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
with $\mathcal{P} \subset \Ob(\mathcal{D})$ the collection
of $K$-flat complexes: (1) follows from
Lemma \ref{lemma-K-flat-resolution}
and to see (2) we have to show that for a quasi-isomorphism
$\mathcal{K}_1^\bullet  \to \mathcal{K}_2^\bullet$ between
K-flat complexes of $\mathcal{O}_Y$-modules the map
$f^*\mathcal{K}_1^\bullet  \to f^*\mathcal{K}_2^\bullet$ is a
quasi-isomorphism. To see this write this as
$$
f^{-1}\mathcal{K}_1^\bullet \otimes_{f^{-1}\mathcal{O}_Y} \mathcal{O}_X
\longrightarrow
f^{-1}\mathcal{K}_2^\bullet \otimes_{f^{-1}\mathcal{O}_Y} \mathcal{O}_X
$$
The functor $f^{-1}$ is exact, hence the map
$f^{-1}\mathcal{K}_1^\bullet  \to f^{-1}\mathcal{K}_2^\bullet$ is a
quasi-isomorphism. By
Lemma \ref{lemma-pullback-K-flat}
applied to the morphism $(X, f^{-1}\mathcal{O}_Y) \to (Y, \mathcal{O}_Y)$
the complexes $f^{-1}\mathcal{K}_1^\bullet$ and $f^{-1}\mathcal{K}_2^\bullet$
are K-flat complexes of $f^{-1}\mathcal{O}_Y$-modules. Hence
Lemma \ref{lemma-derived-tor-quasi-isomorphism-other-side}
guarantees that the displayed map is a quasi-isomorphism.
Thus we obtain a derived functor
$$
LF :
D(\mathcal{O}_Y) = S^{-1}\mathcal{D}
\longrightarrow
\mathcal{D}' = D(\mathcal{O}_X)
$$
see
Derived Categories, Equation (\ref{derived-equation-everywhere}).
Finally,
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
also guarantees that
$LF(\mathcal{K}^\bullet) = F(\mathcal{K}^\bullet) = f^*\mathcal{K}^\bullet$
when $\mathcal{K}^\bullet$ is K-flat, i.e., $Lf^* = LF$ is
indeed computed in the way described above.
\end{proof}

\begin{lemma}
\label{lemma-derived-pullback-composition}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of ringed spaces.
Then $Lf^* \circ Lg^* = L(g \circ f)^*$ as functors
$D(\mathcal{O}_Z) \to D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Let $E$ be an object of $D(\mathcal{O}_Z)$.
By construction $Lg^*E$ is computed by choosing a K-flat complex
$\mathcal{K}^\bullet$ representing $E$ on $Z$ and
setting $Lg^*E = g^*\mathcal{K}^\bullet$.
By Lemma \ref{lemma-pullback-K-flat} we see that $g^*\mathcal{K}^\bullet$
is K-flat on $Y$. Then $Lf^*Lg^*E$ is given by
$f^*g^*\mathcal{K}^\bullet = (g \circ f)^*\mathcal{K}^\bullet$
which also represents $L(g \circ f)^*E$.
\end{proof}

\begin{lemma}
\label{lemma-pullback-tensor-product}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. There is a canonical bifunctorial
isomorphism
$$
Lf^*(
\mathcal{F}^\bullet \otimes_{\mathcal{O}_Y}^{\mathbf{L}} \mathcal{G}^\bullet
) =
Lf^*\mathcal{F}^\bullet 
\otimes_{\mathcal{O}_X}^{\mathbf{L}}
Lf^*\mathcal{G}^\bullet 
$$
for $\mathcal{F}^\bullet, \mathcal{G}^\bullet \in \Ob(D(\mathcal{O}_X))$.
\end{lemma}

\begin{proof}
We may assume that $\mathcal{F}^\bullet$ and $\mathcal{G}^\bullet$
are K-flat complexes. In this case
$\mathcal{F}^\bullet \otimes_{\mathcal{O}_Y}^{\mathbf{L}} \mathcal{G}^\bullet$
is just the total complex associated to the double complex
$\mathcal{F}^\bullet \otimes_{\mathcal{O}_Y} \mathcal{G}^\bullet$.
By
Lemma \ref{lemma-tensor-product-K-flat}
$\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_Y} \mathcal{G}^\bullet)$
is K-flat also. Hence the isomorphism of the lemma comes from the
isomorphism
$$
\text{Tot}(f^*\mathcal{F}^\bullet \otimes_{\mathcal{O}_X}
f^*\mathcal{G}^\bullet)
\longrightarrow
f^*\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_Y} \mathcal{G}^\bullet)
$$
whose constituents are the isomorphisms
$f^*\mathcal{F}^p \otimes_{\mathcal{O}_X} f^*\mathcal{G}^q \to
f^*(\mathcal{F}^p \otimes_{\mathcal{O}_Y} \mathcal{G}^q)$ of
Modules, Lemma \ref{modules-lemma-tensor-product-pullback}.
\end{proof}

\begin{lemma}
\label{lemma-variant-derived-pullback}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. There is a canonical bifunctorial
isomorphism
$$
\mathcal{F}^\bullet
\otimes_{\mathcal{O}_X}^{\mathbf{L}}
Lf^*\mathcal{G}^\bullet
=
\mathcal{F}^\bullet 
\otimes_{f^{-1}\mathcal{O}_Y}^{\mathbf{L}}
f^{-1}\mathcal{G}^\bullet 
$$
for $\mathcal{F}^\bullet$ in $D(\mathcal{O}_X)$ and
$\mathcal{G}^\bullet$ in $D(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module and let $\mathcal{G}$
be an $\mathcal{O}_Y$-module. Then
$\mathcal{F} \otimes_{\mathcal{O}_X} f^*\mathcal{G} =
\mathcal{F} \otimes_{f^{-1}\mathcal{O}_Y} f^{-1}\mathcal{G}$
because
$f^*\mathcal{G} =
\mathcal{O}_X \otimes_{f^{-1}\mathcal{O}_Y} f^{-1}\mathcal{G}$.
The lemma follows from this and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-tensor-pull-compatibility}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism
of ringed spaces. Let $\mathcal{K}^\bullet$ and $\mathcal{M}^\bullet$
be complexes of $\mathcal{O}_Y$-modules. The diagram
$$
\xymatrix{
Lf^*(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
\mathcal{M}^\bullet) \ar[r] \ar[d] &
Lf^*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
\mathcal{M}^\bullet) \ar[d] \\
Lf^*\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L}
Lf^*\mathcal{M}^\bullet \ar[d] &
f^*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
\mathcal{M}^\bullet) \ar[d] \\
f^*\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L}
f^*\mathcal{M}^\bullet \ar[r] &
\text{Tot}(f^*\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}
f^*\mathcal{M}^\bullet)
}
$$
commutes.
\end{lemma}

\begin{proof}
We will use the existence of K-flat resolutions as in
Lemma \ref{lemma-pullback-K-flat}. If we choose such
resolutions $\mathcal{P}^\bullet \to \mathcal{K}^\bullet$
and $\mathcal{Q}^\bullet \to \mathcal{M}^\bullet$, then
we see that
$$
\xymatrix{
Lf^*\text{Tot}(\mathcal{P}^\bullet
\otimes_{\mathcal{O}_Y}
\mathcal{Q}^\bullet) \ar[r] \ar[d] &
Lf^*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
\mathcal{M}^\bullet) \ar[d] \\
f^*\text{Tot}(\mathcal{P}^\bullet
\otimes_{\mathcal{O}_Y}
\mathcal{Q}^\bullet) \ar[d] \ar[r] &
f^*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
\mathcal{M}^\bullet) \ar[d] \\
\text{Tot}(f^*\mathcal{P}^\bullet \otimes_{\mathcal{O}_X}
f^*\mathcal{Q}^\bullet) \ar[r] &
\text{Tot}(f^*\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}
f^*\mathcal{M}^\bullet)
}
$$
commutes. However, now the left hand side of the diagram
is the left hand side of the diagram by our choice of
$\mathcal{P}^\bullet$ and $\mathcal{Q}^\bullet$ and
Lemma \ref{lemma-tensor-product-K-flat}.
\end{proof}









\section{Cohomology of unbounded complexes}
\label{section-unbounded}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space.
The category $\textit{Mod}(\mathcal{O}_X)$ is a Grothendieck
abelian category: it has all colimits,
filtered colimits are exact, and it has a generator, namely
$$
\bigoplus\nolimits_{U \subset X\text{ open}} j_{U!}\mathcal{O}_U,
$$
see Modules, Section \ref{modules-section-kernels} and
Lemmas \ref{modules-lemma-j-shriek-flat} and
\ref{modules-lemma-module-quotient-flat}.
By Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}
for every complex $\mathcal{F}^\bullet$ of $\mathcal{O}_X$-modules
there exists an injective quasi-isomorphism
$\mathcal{F}^\bullet \to \mathcal{I}^\bullet$ to a K-injective complex
of $\mathcal{O}_X$-modules all of whose terms are injective
$\mathcal{O}_X$-modules and moreover this embedding can be
chosen functorial in the complex $\mathcal{F}^\bullet$.
It follows from
Derived Categories, Lemma \ref{derived-lemma-enough-K-injectives-implies}
that
\begin{enumerate}
\item any exact functor $F : K(\textit{Mod}(\mathcal{O}_X)) \to \mathcal{D}$
into a trianguated category $\mathcal{D}$ has a right derived functor
$RF : D(\mathcal{O}_X) \to \mathcal{D}$,
\item for any additive functor
$F : \textit{Mod}(\mathcal{O}_X) \to \mathcal{A}$
into an abelian category $\mathcal{A}$ we consider the exact functor
$F : K(\textit{Mod}(\mathcal{O}_X)) \to D(\mathcal{A})$ induced by $F$
and we obtain a right derived functor
$RF : D(\mathcal{O}_X) \to K(\mathcal{A})$.
\end{enumerate}
By construction we have $RF(\mathcal{F}^\bullet) = F(\mathcal{I}^\bullet)$
where $\mathcal{F}^\bullet \to \mathcal{I}^\bullet$ is as above.

\medskip\noindent
Here are some examples of the above:
\begin{enumerate}
\item The functor $\Gamma(X, -) : \textit{Mod}(\mathcal{O}_X) \to
\text{Mod}_{\Gamma(X, \mathcal{O}_X)}$ gives rise to
$$
R\Gamma(X, -) : D(\mathcal{O}_X) \to D(\Gamma(X, \mathcal{O}_X))
$$
We shall use the notation $H^i(X, K) = H^i(R\Gamma(X, K))$ for cohomology.
\item For an open $U \subset X$ we consider the functor
$\Gamma(U, -) : \textit{Mod}(\mathcal{O}_X) \to
\text{Mod}_{\Gamma(U, \mathcal{O}_X)}$. This gives rise to
$$
R\Gamma(U, -) : D(\mathcal{O}_X) \to D(\Gamma(U, \mathcal{O}_X))
$$
We shall use the notation $H^i(U, K) = H^i(R\Gamma(U, K))$ for cohomology.
\item For a morphism of ringed spaces
$f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ we consider the functor
$f_* : \textit{Mod}(\mathcal{O}_X) \to \textit{Mod}(\mathcal{O}_Y)$
which gives rise to the total direct image
$$
Rf_* : D(\mathcal{O}_X) \longrightarrow D(\mathcal{O}_Y)
$$
on unbounded derived categories.
\end{enumerate}

\begin{lemma}
\label{lemma-adjoint}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of
ringed spaces. The functor $Rf_*$ defined above and the functor $Lf^*$
defined in Lemma \ref{lemma-derived-base-change} are adjoint:
$$
\Hom_{D(\mathcal{O}_X)}(Lf^*\mathcal{G}^\bullet, \mathcal{F}^\bullet)
=
\Hom_{D(\mathcal{O}_Y)}(\mathcal{G}^\bullet, Rf_*\mathcal{F}^\bullet)
$$
bifunctorially in $\mathcal{F}^\bullet \in \Ob(D(\mathcal{O}_X))$ and
$\mathcal{G}^\bullet \in \Ob(D(\mathcal{O}_Y))$.
\end{lemma}

\begin{proof}
This follows formally from the fact that $Rf_*$ and $Lf^*$ exist, see
Derived Categories, Lemma \ref{derived-lemma-derived-adjoint-functors}.
\end{proof}

\begin{lemma}
\label{lemma-derived-pushforward-composition}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of ringed spaces.
Then $Rg_* \circ Rf_* = R(g \circ f)_*$ as functors
$D(\mathcal{O}_X) \to D(\mathcal{O}_Z)$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-adjoint} we see that $Rg_* \circ Rf_*$
is adjoint to $Lf^* \circ Lg^*$. We have
$Lf^* \circ Lg^* = L(g \circ f)^*$ by
Lemma \ref{lemma-derived-pullback-composition}
and hence by
uniqueness of adjoint functors we have $Rg_* \circ Rf_* = R(g \circ f)_*$.
\end{proof}

\begin{remark}
\label{remark-base-change}
The construction of unbounded derived functor $Lf^*$ and $Rf_*$
allows one to construct the base change map in full generality.
Namely, suppose that
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} &
X \ar[d]^f \\
S' \ar[r]^g &
S
}
$$
is a commutative diagram of ringed spaces. Let $K$ be an object of
$D(\mathcal{O}_X)$. Then there exists a canonical base change
map
$$
Lg^*Rf_*K \longrightarrow R(f')_*L(g')^*K
$$
in $D(\mathcal{O}_{S'})$. Namely, this map is adjoint to a map
$L(f')^*Lg^*Rf_*K \to L(g')^*K$
Since $L(f')^*Lg^* = L(g')^*Lf^*$ we see this is the same as a map
$L(g')^*Lf^*Rf_*K \to L(g')^*K$
which we can take to be $L(g')^*$ of the adjunction map
$Lf^*Rf_*K \to K$.
\end{remark}

\begin{remark}
\label{remark-compose-base-change}
Consider a commutative diagram
$$
\xymatrix{
X' \ar[r]_k \ar[d]_{f'} & X \ar[d]^f \\
Y' \ar[r]^l \ar[d]_{g'} & Y \ar[d]^g \\
Z' \ar[r]^m & Z
}
$$
of ringed spaces. Then the base change maps of
Remark \ref{remark-base-change}
for the two squares compose to give the base
change map for the outer rectangle. More precisely,
the composition
\begin{align*}
Lm^* \circ R(g \circ f)_*
& =
Lm^* \circ Rg_* \circ Rf_* \\
& \to Rg'_* \circ Ll^* \circ Rf_* \\
& \to Rg'_* \circ Rf'_* \circ Lk^* \\
& = R(g' \circ f')_* \circ Lk^*
\end{align*}
is the base change map for the rectangle. We omit the verification.
\end{remark}

\begin{remark}
\label{remark-compose-base-change-horizontal}
Consider a commutative diagram
$$
\xymatrix{
X'' \ar[r]_{g'} \ar[d]_{f''} & X' \ar[r]_g \ar[d]_{f'} & X \ar[d]^f \\
Y'' \ar[r]^{h'} & Y' \ar[r]^h & Y
}
$$
of ringed spaces. Then the base change maps of
Remark \ref{remark-base-change}
for the two squares compose to give the base
change map for the outer rectangle. More precisely,
the composition
\begin{align*}
L(h \circ h')^* \circ Rf_*
& =
L(h')^* \circ Lh_* \circ Rf_* \\
& \to L(h')^* \circ Rf'_* \circ Lg^* \\
& \to Rf''_* \circ L(g')^* \circ Lg^* \\
& = Rf''_* \circ L(g \circ g')^*
\end{align*}
is the base change map for the rectangle. We omit the verification.
\end{remark}

\begin{lemma}
\label{lemma-adjoints-push-pull-compatibility}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. Let $\mathcal{K}^\bullet$
be a complex of $\mathcal{O}_X$-modules.
The diagram
$$
\xymatrix{
Lf^*f_*\mathcal{K}^\bullet \ar[r] \ar[d] &
f^*f_*\mathcal{K}^\bullet \ar[d] \\
Lf^*Rf_*\mathcal{K}^\bullet \ar[r] &
\mathcal{K}^\bullet
}
$$
coming from $Lf^* \to f^*$ on complexes, $f_* \to Rf_*$ on complexes,
and adjunction $Lf^* \circ Rf_* \to \text{id}$
commutes in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
We will use the existence of K-flat resolutions and
K-injective resolutions, see Lemma \ref{lemma-pullback-K-flat}
and the discussion above. Choose a quasi-isomorphism
$\mathcal{K}^\bullet \to \mathcal{I}^\bullet$ where $\mathcal{I}^\bullet$
is K-injective as a complex of $\mathcal{O}_X$-modules.
Choose a quasi-isomorphism $\mathcal{Q}^\bullet \to f_*\mathcal{I}^\bullet$
where $\mathcal{Q}^\bullet$ is K-flat as a complex of
$\mathcal{O}_Y$-modules. We can choose a K-flat complex of
$\mathcal{O}_Y$-modules $\mathcal{P}^\bullet$
and a diagram of morphisms of complexes
$$
\xymatrix{
\mathcal{P}^\bullet \ar[r] \ar[d] &
f_*\mathcal{K}^\bullet \ar[d] \\
\mathcal{Q}^\bullet \ar[r] & f_*\mathcal{I}^\bullet
}
$$
commutative up to homotopy where the top horizontal arrow
is a quasi-isomorphism. Namely, we can first choose such a
diagram for some complex $\mathcal{P}^\bullet$ because
the quasi-isomorphisms form a multiplicative system in
the homotopy category of complexes and then we can replace
$\mathcal{P}^\bullet$ by a K-flat complex.
Taking pullbacks we obtain a diagram of morphisms of complexes
$$
\xymatrix{
f^*\mathcal{P}^\bullet \ar[r] \ar[d] &
f^*f_*\mathcal{K}^\bullet \ar[d] \ar[r] &
\mathcal{K}^\bullet \ar[d] \\
f^*\mathcal{Q}^\bullet \ar[r] &
f^*f_*\mathcal{I}^\bullet \ar[r] &
\mathcal{I}^\bullet
}
$$
commutative up to homotopy. The outer rectangle witnesses the
truth of the statement in the lemma.
\end{proof}

\begin{remark}
\label{remark-cup-product}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of
ringed spaces. The adjointness of $Lf^*$ and $Rf_*$ allows us to construct
a relative cup product
$$
Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*L
\longrightarrow
Rf_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} L)
$$
in $D(\mathcal{O}_Y)$ for all $K, L$ in $D(\mathcal{O}_X)$.
Namely, this map is adjoint to a map
$Lf^*(Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*L) \to
K \otimes_{\mathcal{O}_X}^\mathbf{L} L$ for which we can take the
composition of the isomorphism
$Lf^*(Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*L) =
Lf^*Rf_*K \otimes_{\mathcal{O}_X}^\mathbf{L} Lf^*Rf_*L$
(Lemma \ref{lemma-pullback-tensor-product})
with the map
$Lf^*Rf_*K \otimes_{\mathcal{O}_X}^\mathbf{L} Lf^*Rf_*L
\to K \otimes_{\mathcal{O}_X}^\mathbf{L} L$
coming from the counit $Lf^* \circ Rf_* \to \text{id}$.
\end{remark}






\section{Cohomology of filtered complexes}
\label{section-cohomology-filtered-object}

\noindent
Filtered complexes of sheaves frequently come up in a natural fashion
when studying cohomology of algebraic varieties, for example the de Rham
complex comes with its Hodge filtration. In this sectionwe use the very general
Injectives, Lemma \ref{injectives-lemma-K-injective-embedding-filtration}
to find construct spectral sequences on cohomology and we relate these to
previously constructed spectral sequences.

\begin{lemma}
\label{lemma-spectral-sequence-filtered-object}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}^\bullet$ be a
filtered complex of $\mathcal{O}_X$-modules. There exists a canonical
spectral sequence $(E_r, \text{d}_r)_{r \geq 1}$ of bigraded
$\Gamma(X, \mathcal{O}_X)$-modules with $d_r$ of bidegree $(r, -r + 1)$ and
$$
E_1^{p, q} = H^{p + q}(X, \text{gr}^p\mathcal{F}^\bullet)
$$
If for every $n$ we have
$$
H^n(X, F^p\mathcal{F}^\bullet) = 0\text{ for }p \gg 0
\quad\text{and}\quad
H^n(X, F^p\mathcal{F}^\bullet) = H^n(X, \mathcal{F}^\bullet)\text{ for }p \ll 0
$$
then the spectral sequence is bounded and converges to
$H^*(X, \mathcal{F}^\bullet)$.
\end{lemma}

\begin{proof}
(For a proof in case the complex is a bounded below complex
of modules with finite filtrations, see the remark below.)
Choose an map of filtered complexes
$j : \mathcal{F}^\bullet \to \mathcal{J}^\bullet$ as in
Injectives, Lemma
\ref{injectives-lemma-K-injective-embedding-filtration}.
The spectral sequence is the spectral sequence of
Homology, Section \ref{homology-section-filtered-complex}
associated to the filtered complex
$$
\Gamma(X, \mathcal{J}^\bullet)
\quad\text{with}\quad
F^p\Gamma(X, \mathcal{J}^\bullet) = \Gamma(X, F^p\mathcal{J}^\bullet)
$$
Since cohomology is computed by evaluating on K-injective representatives
we see that the $E_1$ page is as stated in the lemma.
The convergence and boundedness under the stated conditions
follows from Homology, Lemma \ref{homology-lemma-ss-converges-trivial}.
\end{proof}

\begin{remark}
\label{remark-spectral-sequence-filtered-object}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}^\bullet$ be a
filtered complex of $\mathcal{O}_X$-modules. If $\mathcal{F}^\bullet$
is bounded from below and for each $n$ the filtration on $\mathcal{F}^n$
is finite, then there is a construction of the spectral sequence
in Lemma \ref{lemma-spectral-sequence-filtered-object}
avoiding Injectives, Lemma
\ref{injectives-lemma-K-injective-embedding-filtration}.
Namely, by
Derived Categories, Lemma
\ref{derived-lemma-right-resolution-by-filtered-injectives}
there is a filtered quasi-isomorphism
$i : \mathcal{F}^\bullet \to \mathcal{I}^\bullet$
of filtered complexes
with $\mathcal{I}^\bullet$ bounded below,
the filtration on $\mathcal{I}^n$ is finite for all $n$,
and with each $\text{gr}^p\mathcal{I}^n$ an
injective $\mathcal{O}_X$-module.
Then we take the spectral sequence associated to
$$
\Gamma(X, \mathcal{I}^\bullet)
\quad\text{with}\quad
F^p\Gamma(X, \mathcal{I}^\bullet) = \Gamma(X, F^p\mathcal{I}^\bullet)
$$
Since cohomology can be computed by evaluating on
bounded below complexes of injectives
we see that the $E_1$ page is as stated in the lemma.
The convergence and boundedness under the stated conditions
follows from
Homology, Lemma \ref{homology-lemma-biregular-ss-converges}.
In fact, this is a special case of the spectral sequence
in Derived Categories, Lemma \ref{derived-lemma-ss-filtered-derived}.
\end{remark}

\begin{example}
\label{example-spectral-sequence}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}^\bullet$ be a
complex of $\mathcal{O}_X$-modules. We can apply
Lemma \ref{lemma-spectral-sequence-filtered-object}
with $F^p\mathcal{F}^\bullet = \tau_{\leq -p}\mathcal{F}^\bullet$.
(If $\mathcal{F}^\bullet$ is bounded below we can use
Remark \ref{remark-spectral-sequence-filtered-object}.)
Then we get a spectral sequence
$$
E_1^{p, q} = H^{p + q}(X, H^{-p}(\mathcal{F}^\bullet)[p]) =
H^{2p + q}(X, H^{-p}(\mathcal{F}^\bullet))
$$
After renumbering $p = -j$ and $q = i + 2j$ we find that for any
$K \in D(\mathcal{O}_X)$ there is a spectral sequence
$(E'_r, d'_r)_{r \geq 2}$ of bigraded modules with
$d'_r$ of bidegree $(r, -r + 1)$, with
$$
(E'_2)^{i, j} = H^i(X, H^j(K))
$$
If $K$ is bounded below (for example), then this spectral sequence
is bounded and converges to $H^{i + j}(X, K)$.
In the bounded below case this spectral sequence is an example
of the second spectral sequence of
Derived Categories, Lemma \ref{derived-lemma-two-ss-complex-functor}
(constructed using Cartan-Eilenberg resolutions).
\end{example}

\begin{example}
\label{example-spectral-sequence-bis}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}^\bullet$ be a
complex of $\mathcal{O}_X$-modules. We can apply
Lemma \ref{lemma-spectral-sequence-filtered-object}
with $F^p\mathcal{F}^\bullet = \sigma_{\geq p}\mathcal{F}^\bullet$.
Then we get a spectral sequence
$$
E_1^{p, q} = H^{p + q}(X, \mathcal{F}^p[-p]) = H^q(X, \mathcal{F}^p)
$$
If $\mathcal{F}^\bullet$ is bounded below, then
\begin{enumerate}
\item we can use
Remark \ref{remark-spectral-sequence-filtered-object}
to construct this spectral sequence,
\item the spectral sequence is bounded and converges to
$H^{i + j}(X, \mathcal{F}^\bullet)$, and
\item the spectral sequence is equal to the first spectral sequence of
Derived Categories, Lemma \ref{derived-lemma-two-ss-complex-functor}
(constructed using Cartan-Eilenberg resolutions).
\end{enumerate}
\end{example}

\begin{lemma}
\label{lemma-relative-spectral-sequence-filtered-object}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of
ringed spaces. Let $\mathcal{F}^\bullet$ be a filtered complex of
$\mathcal{O}_X$-modules. There exists a canonical spectral sequence
$(E_r, \text{d}_r)_{r \geq 1}$ of bigraded
$\mathcal{O}_Y$-modules with $d_r$ of bidegree $(r, -r + 1)$ and
$$
E_1^{p, q} = R^{p + q}f_*\text{gr}^p\mathcal{F}^\bullet
$$
If for every $n$ we have
$$
R^nf_*F^p\mathcal{F}^\bullet = 0 \text{ for }p \gg 0
\quad\text{and}\quad
R^nf_*F^p\mathcal{F}^\bullet = R^nf_*\mathcal{F}^\bullet \text{ for }p \ll 0
$$
then the spectral sequence is bounded and converges to
$Rf_*\mathcal{F}^\bullet$.
\end{lemma}

\begin{proof}
The proof is exactly the same as the proof of
Lemma \ref{lemma-spectral-sequence-filtered-object}.
\end{proof}





\section{Godement resolution}
\label{section-godement}

\noindent
A reference is \cite{Godement}.

\medskip\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Denote $X_{disc}$ the discrete
topological space with the same points as $X$. Denote $f : X_{disc} \to X$
the obvious continuous map. Set $\mathcal{O}_{X_{disc}} = f^{-1}\mathcal{O}_X$.
Then $f : (X_{disc}, \mathcal{O}_{X_{disc}}) \to (X, \mathcal{O}_X)$
is a flat morphism of ringed spaces. We can apply the
{\it dual} of the material in
Simplicial, Section \ref{simplicial-section-standard} to the adjoint pair of
functors $f^*, f_*$ on sheaves of modules. Thus we obtain an augmented
cosimplicial object
$$
\xymatrix{
\text{id} \ar[r] &
f_*f^* \ar@<1ex>[r] \ar@<-1ex>[r] &
f_*f^*f_*f^* \ar@<0ex>[l] \ar@<-2ex>[r] \ar@<0ex>[r] \ar@<2ex>[r] &
f_*f^*f_*f^*f_*f^* \ar@<1ex>[l] \ar@<-1ex>[l]
}
$$
in the category of functors from $\textit{Mod}(\mathcal{O}_X)$
to itself, see Simplicial, Lemma \ref{simplicial-lemma-standard-simplicial}.
Moreover, the augmentation
$$
\xymatrix{
f^* \ar[r] &
f^*f_*f^* \ar@<1ex>[r] \ar@<-1ex>[r] &
f^*f_*f^*f_*f^* \ar@<0ex>[l] \ar@<-2ex>[r] \ar@<0ex>[r] \ar@<2ex>[r] &
f^*f_*f^*f_*f^*f_*f^* \ar@<1ex>[l] \ar@<-1ex>[l]
}
$$
is a homotopy equivalence, see
Simplicial, Lemma \ref{simplicial-lemma-standard-simplicial-homotopy}.

\begin{lemma}
\label{lemma-godement-resolution}
Let $(X, \mathcal{O}_X)$ be a ringed space. For every sheaf of
$\mathcal{O}_X$-modules $\mathcal{F}$ there is a resolution
$$
0 \to
\mathcal{F} \to
f_*f^*\mathcal{F} \to
f_*f^*f_*f^*\mathcal{F} \to
f_*f^*f_*f^*f_*f^*\mathcal{F} \to \ldots
$$
functorial in $\mathcal{F}$ such that each term
$f_*f^* \ldots f_*f^*\mathcal{F}$ is a flasque
$\mathcal{O}_X$-module and such that for all $x \in X$ the
map
$$
\mathcal{F}_x[0] \to \Big(
(f_*f^*\mathcal{F})_x \to
(f_*f^*f_*f^*\mathcal{F})_x \to
(f_*f^*f_*f^*f_*f^*\mathcal{F})_x \to \ldots
\Big)
$$
is a homotopy equivalence in the category of complexes
of $\mathcal{O}_{X, x}$-modules.
\end{lemma}

\begin{proof}
The complex $f_*f^*\mathcal{F} \to  f_*f^*f_*f^*\mathcal{F} \to
f_*f^*f_*f^*f_*f^*\mathcal{F} \to \ldots$ is the complex associated
to the cosimplicial object with terms
$f_*f^*\mathcal{F}, f_*f^*f_*f^*\mathcal{F},
f_*f^*f_*f^*f_*f^*\mathcal{F}, \ldots$ described above, see
Simplicial, Section \ref{simplicial-section-dold-kan-cosimplicial}.
The augmentation gives rise to the map $\mathcal{F} \to f_*f^*\mathcal{F}$
as indicated. For any abelian sheaf $\mathcal{H}$ on $X_{disc}$ the
pushforward $f_*\mathcal{H}$ is flasque because $X_{disc}$
is a discrete space and the pushforward of a flasque sheaf is flasque.
Hence the terms of the complex are flasque $\mathcal{O}_X$-modules.

\medskip\noindent
If $x \in X_{disc} = X$ is a point, then $(f^*\mathcal{G})_x = \mathcal{G}_x$
for any $\mathcal{O}_X$-module $\mathcal{G}$. Hence $f^*$ is an exact functor
and a complex of $\mathcal{O}_X$-modules
$\mathcal{G}_1 \to \mathcal{G}_2 \to \mathcal{G}_3$
is exact if and only if
$f^*\mathcal{G}_1 \to f^*\mathcal{G}_2 \to f^*\mathcal{G}_3$
is exact (see Modules, Lemma \ref{modules-lemma-abelian}).
The result mentioned in the introduction to this section
proves the pullback by $f^*$ gives a homotopy equivalence from
the constant cosimplicial object $f^*\mathcal{F}$ to the
cosimplicial object with terms
$f_*f^*\mathcal{F}, f_*f^*f_*f^*\mathcal{F},
f_*f^*f_*f^*f_*f^*\mathcal{F}, \ldots$.
By Simplicial, Lemma \ref{simplicial-lemma-homotopy-equivalence-s-Q}
we obtain that
$$
f^*\mathcal{F}[0] \to \Big(
f^*f_*f^*\mathcal{F} \to
f^*f_*f^*f_*f^*\mathcal{F} \to
f^*f_*f^*f_*f^*f_*f^*\mathcal{F} \to \ldots
\Big)
$$
is a homotopy equivalence. This immediately implies the two remaining
statements of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-godement-resolution-bounded-below}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{F}^\bullet$ be a bounded below complex of
$\mathcal{O}_X$-modules. There exists a quasi-isomorphism
$\mathcal{F}^\bullet \to \mathcal{G}^\bullet$
where $\mathcal{G}^\bullet$ be a bounded below complex of flasque
$\mathcal{O}_X$-modules and for all $x \in X$ the
map $\mathcal{F}^\bullet_x \to \mathcal{G}^\bullet_x$
is a homotopy equivalence in the category of complexes
of $\mathcal{O}_{X, x}$-modules.
\end{lemma}

\begin{proof}
Let $\mathcal{A}$ be the category of complexes of $\mathcal{O}_X$-modules
and let $\mathcal{B}$ be the category of complexes of $\mathcal{O}_X$-modules.
Then we can apply the discussion above to the adjoint functors
$f^*$ and $f_*$ between $\mathcal{A}$ and $\mathcal{B}$.
Arguing exactly as in the proof of
Lemma \ref{lemma-godement-resolution}
we get a resolution
$$
0 \to
\mathcal{F}^\bullet \to
f_*f^*\mathcal{F}^\bullet \to
f_*f^*f_*f^*\mathcal{F}^\bullet \to
f_*f^*f_*f^*f_*f^*\mathcal{F}^\bullet \to \ldots
$$
in the abelian category $\mathcal{A}$ such that each term of each
$f_*f^*\ldots f_*f^*\mathcal{F}^\bullet$ is a flasque
$\mathcal{O}_X$-module and such that for all $x \in X$ the
map
$$
\mathcal{F}^\bullet_x[0] \to \Big(
(f_*f^*\mathcal{F}^\bullet)_x \to
(f_*f^*f_*f^*\mathcal{F}^\bullet)_x \to
(f_*f^*f_*f^*f_*f^*\mathcal{F}^\bullet)_x \to \ldots
\Big)
$$
is a homotopy equivalence in the category of complexes of complexes
of $\mathcal{O}_{X, x}$-modules. Since a complex of complexes is the
same thing as a double complex, we can consider the induced map
$$
\mathcal{F}^\bullet \to
\mathcal{G}^\bullet =
\text{Tot}(
f_*f^*\mathcal{F}^\bullet \to
f_*f^*f_*f^*\mathcal{F}^\bullet \to
f_*f^*f_*f^*f_*f^*\mathcal{F}^\bullet \to \ldots
)
$$
Since the complex $\mathcal{F}^\bullet$ is bounded below, the
same is true for $\mathcal{G}^\bullet$ and in fact each term
of $\mathcal{G}^\bullet$ is a finite direct sum of
terms of the complexes $f_*f^*\ldots f_*f^*\mathcal{F}^\bullet$
and hence is flasque. The final assertion of the lemma
now follows from
Homology, Lemma \ref{homology-lemma-homotopy-complex-complexes}.
Since this in particular shows that
$\mathcal{F}^\bullet \to \mathcal{G}^\bullet$
is a quasi-isomorphism, the proof is complete.
\end{proof}














\section{Cup product}
\label{section-cup-product}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, M$ be objects
of $D(\mathcal{O}_X)$. Set $A = \Gamma(X, \mathcal{O}_X)$.
The (global) cup product in this setting is a map
$$
\mu :
R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(X, M)
\longrightarrow
R\Gamma(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
in $D(A)$. We define it as the relative cup product for the
morphism of ringed spaces $f : (X, \mathcal{O}_X) \to (pt, A)$
as in Remark \ref{remark-cup-product} via $D(pt, A) = D(A)$.
This map in particular defines pairings
$$
\cup :
H^i(X, K) \times H^j(X, M)
\longrightarrow
H^{i + j}(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
Namely, given $\xi \in H^i(X, K) = H^i(R\Gamma(X, K))$ and
$\eta \in H^j(X, M) = H^j(R\Gamma(X, M))$ we can
first ``tensor'' them to get an element $\xi \otimes \eta$ in
$H^{i + j}(R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(X, M))$, see
More on Algebra, Section \ref{more-algebra-section-products-tor}.
Then we can apply $\mu$ to get the desired element
$\xi \cup \eta = \mu(\xi \otimes \eta)$
of $H^{i + j}(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)$.

\medskip\noindent
Here is another way to think of the cup product of $\xi$ and $\eta$.
Namely, we can write
$$
R\Gamma(X, K) = R\Hom_X(\mathcal{O}_X, K)
\quad\text{and}\quad
R\Gamma(X, M) = R\Hom_X(\mathcal{O}_X, M)
$$
because $\Hom(\mathcal{O}_X, -) = \Gamma(X, -)$.
Thus $\xi$ and $\eta$ are the ``same'' thing as maps
$$
\tilde \xi : \mathcal{O}_X[-i] \to K
\quad\text{and}\quad
\tilde \eta : \mathcal{O}_X[-j] \to M
$$
Combining this with the functoriality of the derived tensor product
we obtain
$$
\mathcal{O}_X[-i - j] =
\mathcal{O}_X[-i] \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{O}_X[-j]
\xrightarrow{\tilde \xi \otimes \tilde \eta}
K \otimes_{\mathcal{O}_X}^\mathbf{L} M
$$
which by the same token as above is an element of
$H^{i + j}(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)$.

\begin{lemma}
\label{lemma-second-cup-equals-first}
This construction gives the cup product.
\end{lemma}

\begin{proof}
With $f : (X, \mathcal{O}_X) \to (pt, A)$ as above we have
$Rf_*(-) = R\Gamma(X, -)$ and our map $\mu$ is adjoint to the map
$$
Lf^*(Rf_*K \otimes_A^\mathbf{L} Rf_*M) =
Lf^*Rf_*K \otimes_{\mathcal{O}_X}^\mathbf{L} Lf^*Rf_*M
\xrightarrow{\epsilon_K \otimes \epsilon_M}
K \otimes_{\mathcal{O}_X}^\mathbf{L} M
$$
where $\epsilon$ is the counit of the adjunction between
$Lf^*$ and $Rf_*$.
If we think of $\xi$ and $\eta$ as maps $\xi : A[-i] \to R\Gamma(X, K)$
and $\eta : A[-j] \to R\Gamma(X, M)$, then
the tensor $\xi \otimes \eta$ corresponds to the map\footnote{There
is a sign hidden here, namely, the equality is defined by
the composition
$$
A[-i - j] \to (A \otimes_A^\mathbf{L} A)[-i - j] \to
A[-i] \otimes_A^\mathbf{L} A[-j]
$$
where in the second step we use the identification of
More on Algebra, Item (\ref{more-algebra-item-shift-tensor})
which uses a sign in principle.
Except, in this case the sign is $+1$ by our convention and even if it wasn't
$+1$ it wouldn't matter since we used the same sign
in the identification
$\mathcal{O}_X[-i - j] =
\mathcal{O}_X[-i] \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{O}_X[-j]$.}
$$
A[-i - j] = A[-i] \otimes_A^\mathbf{L} A[-j]
\xrightarrow{\xi \otimes \eta}
R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(X, M)
$$
By definition the cup product $\xi \cup \eta$ is the map
$A[-i - j] \to R\Gamma(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)$
which is adjoint to
$$
(\epsilon_K \otimes \epsilon_M) \circ Lf^*(\xi \otimes \eta) =
(\epsilon_K \circ Lf^*\xi) \otimes (\epsilon_M \circ Lf^*\eta)
$$
However, it is easy to see that
$\epsilon_K \circ Lf^*\xi = \tilde \xi$ and
$\epsilon_M \circ Lf^*\eta = \tilde \eta$.
We conclude that $\widetilde{\xi \cup \eta} = \tilde \xi \otimes \tilde \eta$
which means we have the desired agreement.
\end{proof}

\begin{remark}
\label{remark-cup-with-element-map-total-cohomology}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, M$ be objects
of $D(\mathcal{O}_X)$. Set $A = \Gamma(X, \mathcal{O}_X)$.
Given $\xi \in H^i(X, K)$ we get an associated map
$$
\xi = ``\xi \cup -'' :
R\Gamma(X, M)[-i]
\to
R\Gamma(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
by representing $\xi$ as a map $\xi : A[-i] \to R\Gamma(X, K)$ as in the
proof of Lemma \ref{lemma-second-cup-equals-first}
and then using the composition
$$
R\Gamma(X, M)[-i] = A[-i] \otimes_A^\mathbf{L} R\Gamma(X, M)
\xrightarrow{\xi \otimes 1}
R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(X, M)
\to
R\Gamma(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
where the second arrow is the global cup product $\mu$ above.
On cohomology this recovers the cup product by $\xi$ as is clear
from Lemma \ref{lemma-second-cup-equals-first} and its proof.
\end{remark}

\noindent
Let us formulate and prove a natural compatibility of the
relative cup product. Namely, suppose that we have a morphism
$f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ of ringed spaces.
Let $\mathcal{K}^\bullet$ and $\mathcal{M}^\bullet$
be complexes of $\mathcal{O}_X$-modules.
There is a naive cup product
$$
\text{Tot}(
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
f_*\mathcal{M}^\bullet)
\longrightarrow
f_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
$$
We claim that this is related to the relative cup product.

\begin{lemma}
\label{lemma-cup-compatible-with-naive}
In the situation above the following diagram commutes
$$
\xymatrix{
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f_*\mathcal{M}^\bullet \ar[r] \ar[d]
&
Rf_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
Rf_*\mathcal{M}^\bullet \ar[d]^{\text{Remark \ref{remark-cup-product}}} \\
\text{Tot}(
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
f_*\mathcal{M}^\bullet) \ar[d]_{\text{naive cup product}} &
Rf_*(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}^\mathbf{L}
\mathcal{M}^\bullet) \ar[d] \\
f_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet) \ar[r] &
Rf_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
}
$$
\end{lemma}

\begin{proof}
By the construction in Remark \ref{remark-cup-product} we see that
going around the diagram clockwise the map
$$
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f_*\mathcal{M}^\bullet 
\longrightarrow
Rf_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
$$
is adjoint to the map
\begin{align*}
Lf^*(f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f_*\mathcal{M}^\bullet)
& =
Lf^*f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
Lf^*f_*\mathcal{M}^\bullet \\
& \to
Lf^*Rf_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
Lf^*Rf_*\mathcal{M}^\bullet \\
& \to
\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
\mathcal{M}^\bullet \\
& \to
\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
\end{align*}
By Lemma \ref{lemma-adjoints-push-pull-compatibility} this is also equal to
\begin{align*}
Lf^*(f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f_*\mathcal{M}^\bullet)
& =
Lf^*f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
Lf^*f_*\mathcal{M}^\bullet \\
& \to
f^*f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f^*f_*\mathcal{M}^\bullet \\
& \to
\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
\mathcal{M}^\bullet \\
& \to
\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
\end{align*}
Going around anti-clockwise we obtain the map adjoint to the map
\begin{align*}
Lf^*(f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f_*\mathcal{M}^\bullet)
& \to
Lf^*\text{Tot}(
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
f_*\mathcal{M}^\bullet) \\
& \to
Lf^*f_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet) \\
& \to
Lf^*Rf_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet) \\
& \to
\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
\end{align*}
By Lemma \ref{lemma-adjoints-push-pull-compatibility} this is also equal to
\begin{align*}
Lf^*(f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f_*\mathcal{M}^\bullet)
& \to
Lf^*\text{Tot}(
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
f_*\mathcal{M}^\bullet) \\
& \to
Lf^*f_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet) \\
& \to
f^*f_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet) \\
& \to
\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
\end{align*}
Now the proof is finished by a contemplation of the diagram
$$
\xymatrix{
Lf^*(f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}^\mathbf{L}
f_*\mathcal{M}^\bullet) \ar[d] \ar[rr] & &
Lf^*f_*\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L}
Lf^*f_*\mathcal{M}^\bullet \ar[d] \\
Lf^*\text{Tot}(
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
f_*\mathcal{M}^\bullet) \ar[d]_{naive} \ar[r] &
f^*\text{Tot}(
f_*\mathcal{K}^\bullet
\otimes_{\mathcal{O}_Y}
f_*\mathcal{M}^\bullet) \ar[ldd]^{naive} \ar[dd] &
f^*f_*\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L}
f^*f_*\mathcal{M}^\bullet \ar[dd] \ar[ldd] \\
Lf^*f_*\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet) \ar[d] \\
f^*f_*\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet) \ar[rd] &
\text{Tot}(f^*f_*\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}
f^*f_*\mathcal{M}^\bullet) \ar[d] &
\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L}
\mathcal{M}^\bullet \ar[ld] \\
& \text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)
}
$$
All of the polygons in this diagram commute. The top one commutes
by Lemma \ref{lemma-tensor-pull-compatibility}.
The square with the two naive cup products commutes because
$Lf^* \to f^*$ is functorial in the complex of modules.
Similarly with the square involving the two maps
$\mathcal{A}^\bullet \otimes^\mathbf{L} \mathcal{B}^\bullet \to
\text{Tot}(\mathcal{A}^\bullet \otimes \mathcal{B}^\bullet)$.
Finally, the commutativity of the remaining square
is true on the level of complexes and may be viewed as the
definiton of the naive cup product (by the adjointness
of $f^*$ and $f_*$). The proof is finished because
going around the diagram on the outside are the two maps
given above.
\end{proof}

\noindent
Let $(X, \mathcal{O}_X)$ be a ring space. Let $\mathcal{K}^\bullet$ and
$\mathcal{M}^\bullet$ be complexes of $\mathcal{O}_X$-modules.
Then we have a ``naive'' cup product
$$
\mu' :
\text{Tot}(
\Gamma(X, \mathcal{K}^\bullet) \otimes_A \Gamma(X, \mathcal{M}^\bullet))
\longrightarrow
\Gamma(X, \text{Tot}(
\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{M}^\bullet))
$$
By Lemma \ref{lemma-cup-compatible-with-naive}
applied to the morphism $(X, \mathcal{O}_X) \to (pt, A)$
this naive cup product is related to the cup product $\mu$
defined in the first paragraph of this section by the
following commutative diagram
$$
\xymatrix{
\Gamma(X, \mathcal{K}^\bullet)
\otimes_A^\mathbf{L}
\Gamma(X, \mathcal{M}^\bullet) \ar[d] \ar[r] &
R\Gamma(X, \mathcal{K}^\bullet)
\otimes_A^\mathbf{L}
R\Gamma(X, \mathcal{M}^\bullet) \ar[d]^-\mu \\
\text{Tot}(\Gamma(X, \mathcal{K}^\bullet)
\otimes_A
\Gamma(X, \mathcal{M}^\bullet)) \ar[d]_-{\mu'} &
R\Gamma(X, \mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}^\mathbf{L}
\mathcal{M}^\bullet) \ar[d] \\
\Gamma(X, \text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)) \ar[r] &
R\Gamma(X, \text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet))
}
$$
in $D(A)$. On cohomology we obtain the commutative diagram
$$
\xymatrix{
H^i(\Gamma(X, \mathcal{K}^\bullet)) \times
H^j(\Gamma(X, \mathcal{M}^\bullet)) \ar[d] \ar[r] &
H^{i + j}(X,
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{M}^\bullet)) \\
H^i(X, \mathcal{K}^\bullet) \times
H^j(X, \mathcal{M}^\bullet) \ar[r]^\cup &
H^{i + j}(X, \mathcal{K}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L}
\mathcal{M}^\bullet) \ar[u]
}
$$
relating the naive cup product with the actual cuproduct.

\begin{lemma}
\label{lemma-diagrams-commute}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{K}^\bullet$ and $\mathcal{M}^\bullet$
be bounded below complexes of $\mathcal{O}_X$-modules.
Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$ be an open covering
Then
$$
\xymatrix{
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{K}^\bullet))
\otimes_A^\mathbf{L}
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{M}^\bullet))
\ar[d] \ar[r] &
R\Gamma(X, \mathcal{K}^\bullet)
\otimes_A^\mathbf{L}
R\Gamma(X, \mathcal{M}^\bullet) \ar[d]^\mu \\
\text{Tot}(
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{K}^\bullet))
\otimes_A
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{M}^\bullet)))
\ar[d]^{(\ref{equation-needs-signs})} &
R\Gamma(X,
\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{M}^\bullet)
\ar[d] \\
\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U},
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{M}^\bullet)
)) \ar[r] &
R\Gamma(X,
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{M}^\bullet))
}
$$
where the horizontal arrows are the ones in
Lemma \ref{lemma-cech-complex-complex}
commutes in $D(A)$.
\end{lemma}

\begin{proof}
Choose quasi-isomorphisms of complexes
$a : \mathcal{K}^\bullet \to \mathcal{K}_1^\bullet$ and
$b : \mathcal{M}^\bullet \to \mathcal{M}_1^\bullet$
as in Lemma \ref{lemma-godement-resolution-bounded-below}.
Since the maps $a$ and $b$ on stalks are homotopy equivalences
we see that the induced map
$$
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{M}^\bullet)
\to
\text{Tot}(\mathcal{K}_1^\bullet \otimes_{\mathcal{O}_X} \mathcal{M}_1^\bullet)
$$
is a homotopy equivalence on stalks too (More on Algebra, Lemma
\ref{more-algebra-lemma-derived-tor-homotopy}) and hence a quasi-isomorphism.
Thus the targets
$$
R\Gamma(X,
\text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X} \mathcal{M}^\bullet)) =
R\Gamma(X,
\text{Tot}(\mathcal{K}_1^\bullet
\otimes_{\mathcal{O}_X} \mathcal{M}_1^\bullet))
$$
of the two diagrams are the same in $D(A)$. It follows that it suffices
to prove the diagram commutes for $\mathcal{K}$ and $\mathcal{M}$
replaced by $\mathcal{K}_1$ and $\mathcal{M}_1$. This reduces us to
the case discussed in the next paragraph.

\medskip\noindent
Assume $\mathcal{K}^\bullet$ and $\mathcal{M}^\bullet$ are bounded
below complexes of flasque $\mathcal{O}_X$-modules and
consider the diagram relating the cup product with the cup product
(\ref{equation-needs-signs}) on {\v C}ech complexes.
Then we can consider the commutative diagram
$$
\xymatrix{
\Gamma(X, \mathcal{K}^\bullet)
\otimes_A^\mathbf{L}
\Gamma(X, \mathcal{M}^\bullet) \ar[d] \ar[r] &
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{K}^\bullet))
\otimes_A^\mathbf{L}
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{M}^\bullet))
\ar[d] \\
\text{Tot}(\Gamma(X, \mathcal{K}^\bullet)
\otimes_A
\Gamma(X, \mathcal{M}^\bullet)) \ar[d] \ar[r] &
\text{Tot}(
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{K}^\bullet))
\otimes_A
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{M}^\bullet)))
\ar[d]^{(\ref{equation-needs-signs})} \\
\Gamma(X, \text{Tot}(\mathcal{K}^\bullet
\otimes_{\mathcal{O}_X}
\mathcal{M}^\bullet)) \ar[r] &
\text{Tot}(
\check{\mathcal{C}}^\bullet({\mathcal U},
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{M}^\bullet)
))
}
$$
In this diagram the horizontal arrows are isomorphisms in $D(A)$ because
for a bounded below complex of flasque modules such as $\mathcal{K}^\bullet$
we have
$$
\Gamma(X, \mathcal{K}^\bullet) =
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{K}^\bullet)) =
R\Gamma(X, \mathcal{K}^\bullet)
$$
in $D(A)$. This follows from
Lemma \ref{lemma-flasque-acyclic},
Derived Categories, Lemma \ref{derived-lemma-leray-acyclicity}, and
Lemma \ref{lemma-cech-complex-complex-computes}.
Hence the commutativity of the diagram of the lemma involving
(\ref{equation-needs-signs}) follows from the already proven
commutativity of Lemma \ref{lemma-cup-compatible-with-naive}
where $f$ is the morphism to a point (see discussion
following Lemma \ref{lemma-cup-compatible-with-naive}).
\end{proof}

\begin{lemma}
\label{lemma-cup-product-associative}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. The relative cup product of
Remark \ref{remark-cup-product} is associative in the sense that
the diagram
$$
\xymatrix{
Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L}
Rf_*L \otimes_{\mathcal{O}_Y}^\mathbf{L}
Rf_*M \ar[r] \ar[d] &
Rf_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} L)
\otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*M \ar[d] \\
Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L}
Rf_*(L \otimes_{\mathcal{O}_X}^\mathbf{L} M) \ar[r] &
Rf_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} 
L \otimes_{\mathcal{O}_X}^\mathbf{L} M)
}
$$
is commutative in $D(\mathcal{O}_Y)$ for all $K, L, M$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Going around either side we obtain the map adjoint to the obvious map
\begin{align*}
Lf^*(Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L}
Rf_*L \otimes_{\mathcal{O}_Y}^\mathbf{L}
Rf_*M) & =
Lf^*(Rf_*K) \otimes_{\mathcal{O}_X}^\mathbf{L}
Lf^*(Rf_*L) \otimes_{\mathcal{O}_X}^\mathbf{L}
Lf^*(Rf_*M) \\
& \to
K \otimes_{\mathcal{O}_X}^\mathbf{L} 
L \otimes_{\mathcal{O}_X}^\mathbf{L} M
\end{align*}
in $D(\mathcal{O}_X)$.
\end{proof}

\begin{lemma}
\label{lemma-cup-product-commutative}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. The relative cup product of
Remark \ref{remark-cup-product} is commutative in the sense that
the diagram
$$
\xymatrix{
Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*L \ar[r] \ar[d]_\psi &
Rf_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} L) \ar[d]^{Rf_*\psi} \\
Rf_*L \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*K \ar[r] &
Rf_*(L \otimes_{\mathcal{O}_X}^\mathbf{L} K)
}
$$
is commutative in $D(\mathcal{O}_Y)$ for all $K, L$ in $D(\mathcal{O}_X)$.
Here $\psi$ is the commutativity constraint on the derived category
(Lemma \ref{lemma-symmetric-monoidal-derived}).
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-compose-cup-product}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ and
$g : (Y, \mathcal{O}_Y) \to (Z, \mathcal{O}_Z)$
be morphisms of ringed spaces. The relative cup product of
Remark \ref{remark-cup-product} is compatible with compositions
in the sense that the diagram
$$
\xymatrix{
R(g \circ f)_*K \otimes_{\mathcal{O}_Z}^\mathbf{L} R(g \circ f)_*L
\ar@{=}[rr] \ar[d] & &
Rg_*Rf_*K \otimes_{\mathcal{O}_Z}^\mathbf{L} Rg_*Rf_*L \ar[d] \\
R(g \circ f)_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} L) \ar@{=}[r] &
Rg_*Rf_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} L) &
Rg_*(Rf_*K \otimes_{\mathcal{O}_Y}^\mathbf{L}  Rf_*L) \ar[l]
}
$$
is commutative in $D(\mathcal{O}_Z)$ for all $K, L$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This is true because going around the diagram either way we obtain the map
adjoint to the map
\begin{align*}
& L(g \circ f)^*\left(R(g \circ f)_*K
\otimes_{\mathcal{O}_Z}^\mathbf{L}
R(g \circ f)_*L\right) \\
& =
L(g \circ f)^*R(g \circ f)_*K
\otimes_{\mathcal{O}_X}^\mathbf{L}
L(g \circ f)^*R(g \circ f)_*L) \\
& \to
K \otimes_{\mathcal{O}_X}^\mathbf{L} L
\end{align*}
in $D(\mathcal{O}_X)$. To see this one uses that the composition
of the counits like so
$$
L(g \circ f)^*R(g \circ f)_* =
Lf^* Lg^* Rg_* Rf_*  \to
Lf^* Rf_* \to \text{id}
$$
is the counit for $L(g \circ f)^*$ and $R(g \circ f)_*$. See
Categories, Lemma \ref{categories-lemma-compose-counits}.
\end{proof}















\section{Some properties of K-injective complexes}
\label{section-properties-K-injective}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $U \subset X$ be an
open subset. Denote $j : (U, \mathcal{O}_U) \to (X, \mathcal{O}_X)$
the corresponding open immersion. The pullback functor $j^*$ is exact
as it is just the restriction functor. Thus derived pullback $Lj^*$ is
computed on any complex by simply restricting the complex. We often
simply denote the corresponding functor
$$
D(\mathcal{O}_X) \to D(\mathcal{O}_U),
\quad
E \mapsto j^*E = E|_U
$$
Similarly, extension by zero
$j_! : \textit{Mod}(\mathcal{O}_U) \to \textit{Mod}(\mathcal{O}_X)$
(see Sheaves, Section \ref{sheaves-section-open-immersions})
is an exact functor (Modules, Lemma \ref{modules-lemma-j-shriek-exact}).
Thus it induces a functor
$$
j_! : D(\mathcal{O}_U) \to D(\mathcal{O}_X),\quad
F \mapsto j_!F
$$
by simply applying $j_!$ to any complex representing the object $F$.

\begin{lemma}
\label{lemma-restrict-K-injective-to-open}
Let $X$ be a ringed space. Let $U \subset X$ be an open subspace.
The restriction of a K-injective complex of $\mathcal{O}_X$-modules
to $U$ is a K-injective complex of $\mathcal{O}_U$-modules.
\end{lemma}

\begin{proof}
Follows from
Derived Categories, Lemma \ref{derived-lemma-adjoint-preserve-K-injectives}
and the fact that the restriction functor has the
exact left adjoint $j_!$.
For the construction of $j_!$ see
Sheaves, Section \ref{sheaves-section-open-immersions}
and for exactness see Modules, Lemma \ref{modules-lemma-j-shriek-exact}.
\end{proof}

\begin{lemma}
\label{lemma-unbounded-cohomology-of-open}
Let $X$ be a ringed space. Let $U \subset X$ be an open subspace.
For $K$ in $D(\mathcal{O}_X)$ we have
$H^p(U, K) = H^p(U, K|_U)$.
\end{lemma}

\begin{proof}
Let $\mathcal{I}^\bullet$ be a K-injective complex of $\mathcal{O}_X$-modules
representing $K$. Then
$$
H^q(U, K) = H^q(\Gamma(U, \mathcal{I}^\bullet)) =
H^q(\Gamma(U, \mathcal{I}^\bullet|_U))
$$
by construction of cohomology. By Lemma \ref{lemma-restrict-K-injective-to-open}
the complex $\mathcal{I}^\bullet|_U$ is a K-injective complex
representing $K|_U$ and the lemma follows.
\end{proof}

\begin{lemma}
\label{lemma-sheafification-cohomology}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K$ be an object of
$D(\mathcal{O}_X)$. The sheafification of
$$
U \mapsto H^q(U, K) = H^q(U, K|_U)
$$
is the $q$th cohomology sheaf $H^q(K)$ of $K$.
\end{lemma}

\begin{proof}
The equality $H^q(U, K) = H^q(U, K|_U)$ holds by
Lemma \ref{lemma-unbounded-cohomology-of-open}.
Choose a K-injective complex $\mathcal{I}^\bullet$ representing $K$.
Then
$$
H^q(U, K) =
\frac{\Ker(\mathcal{I}^q(U) \to \mathcal{I}^{q + 1}(U))}
{\Im(\mathcal{I}^{q - 1}(U) \to \mathcal{I}^q(U))}.
$$
by our construction of cohomology. Since
$H^q(K) = \Ker(\mathcal{I}^q \to \mathcal{I}^{q + 1})/
\Im(\mathcal{I}^{q - 1} \to \mathcal{I}^q)$ the result is clear.
\end{proof}

\begin{lemma}
\label{lemma-restrict-direct-image-open}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of ringed
spaces. Given an open subspace $V \subset Y$, set $U = f^{-1}(V)$ and denote
$g : U \to V$ the induced morphism. Then
$(Rf_*E)|_V = Rg_*(E|_U)$ for $E$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Represent $E$ by a K-injective complex $\mathcal{I}^\bullet$ of
$\mathcal{O}_X$-modules. Then $Rf_*(E) = f_*\mathcal{I}^\bullet$
and $Rg_*(E|_U) = g_*(\mathcal{I}^\bullet|_U)$ by
Lemma \ref{lemma-restrict-K-injective-to-open}.
Since it is clear that $(f_*\mathcal{F})|_V = g_*(\mathcal{F}|_U)$
for any sheaf $\mathcal{F}$ on $X$ the result follows.
\end{proof}

\begin{lemma}
\label{lemma-Leray-unbounded}
Let $f : X \to Y$ be a morphism of ringed spaces.
Then $R\Gamma(Y, -) \circ Rf_* = R\Gamma(X, -)$ as functors
$D(\mathcal{O}_X) \to D(\Gamma(Y, \mathcal{O}_Y))$.
More generally for $V \subset Y$ open and $U = f^{-1}(V)$
we have $R\Gamma(U, -) = R\Gamma(V, -) \circ Rf_*$.
\end{lemma}

\begin{proof}
Let $Z$ be the ringed space consisting of a singleton
space with $\Gamma(Z, \mathcal{O}_Z) = \Gamma(Y, \mathcal{O}_Y)$.
There is a canonical morphism $Y \to Z$ of ringed spaces
inducing the identification on global sections of structure sheaves.
Then $D(\mathcal{O}_Z) = D(\Gamma(Y, \mathcal{O}_Y))$.
Hence the assertion $R\Gamma(Y, -) \circ Rf_* = R\Gamma(X, -)$
follows from Lemma \ref{lemma-derived-pushforward-composition}
applied to $X \to Y \to Z$.

\medskip\noindent
The second (more general) statement follows from the first statement
after applying Lemma \ref{lemma-restrict-direct-image-open}.
\end{proof}

\begin{lemma}
\label{lemma-unbounded-describe-higher-direct-images}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of ringed
spaces. Let $K$ be in $D(\mathcal{O}_X)$. Then $H^i(Rf_*K)$ is the sheaf
associated to the presheaf
$$
V \mapsto H^i(f^{-1}(V), K) = H^i(V, Rf_*K)
$$
\end{lemma}

\begin{proof}
The equality $H^i(f^{-1}(V), K) = H^i(V, Rf_*K)$ follows upon taking
cohomology from the second statement in
Lemma \ref{lemma-Leray-unbounded}. Then the statement on sheafification
follows from Lemma \ref{lemma-sheafification-cohomology}.
\end{proof}

\begin{lemma}
\label{lemma-modules-abelian-unbounded}
Let $X$ be a ringed space. Let $K$ be an object of $D(\mathcal{O}_X)$
and denote $K_{ab}$ its image in $D(\underline{\mathbf{Z}}_X)$.
\begin{enumerate}
\item For any open $U \subset X$ there is a canonical map
$R\Gamma(U, K) \to R\Gamma(U, K_{ab})$
which is an isomorphism in $D(\textit{Ab})$.
\item Let $f : X \to Y$ be a morphism of ringed spaces.
There is a canonical map $Rf_*K \to Rf_*(K_{ab})$ which
is an isomorphism in $D(\underline{\mathbf{Z}}_Y)$.
\end{enumerate}
\end{lemma}

\begin{proof}
The map is constructed as follows. Choose a K-injective complex
$\mathcal{I}^\bullet$ representing $K$. Choose a quasi-isomorpism
$\mathcal{I}^\bullet \to \mathcal{J}^\bullet$ where $\mathcal{J}^\bullet$
is a K-injective complex of abelian groups. Then the map in (1)
is given by $\Gamma(U, \mathcal{I}^\bullet) \to \Gamma(U, \mathcal{J}^\bullet)$
and the map in (2) is given by
$f_*\mathcal{I}^\bullet \to f_*\mathcal{J}^\bullet$.
To show that these maps are isomorphisms, it suffices to prove
they induce isomorphisms on cohomology groups and cohomology sheaves.
By Lemmas \ref{lemma-unbounded-cohomology-of-open} and
\ref{lemma-unbounded-describe-higher-direct-images}
it suffices to show that the map
$$
H^0(X, K) \longrightarrow H^0(X, K_{ab})
$$
is an isomorphism. Observe that
$$
H^0(X, K) = \Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X, K)
$$
and similarly for the other group. Choose any complex $\mathcal{K}^\bullet$
of $\mathcal{O}_X$-modules representing $K$. By construction of the
derived category as a localization we have
$$
\Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X, K) =
\colim_{s : \mathcal{F}^\bullet \to \mathcal{O}_X}
\Hom_{K(\mathcal{O}_X)}(\mathcal{F}^\bullet, \mathcal{K}^\bullet)
$$
where the colimit is over quasi-isomorphisms $s$ of complexes of
$\mathcal{O}_X$-modules. Similarly, we have
$$
\Hom_{D(\underline{\mathbf{Z}}_X)}(\underline{\mathbf{Z}}_X, K) =
\colim_{s : \mathcal{G}^\bullet \to \underline{\mathbf{Z}}_X}
\Hom_{K(\underline{\mathbf{Z}}_X)}(\mathcal{G}^\bullet, \mathcal{K}^\bullet)
$$
Next, we observe that the quasi-isomorphisms
$s : \mathcal{G}^\bullet \to \underline{\mathbf{Z}}_X$
with $\mathcal{G}^\bullet$ bounded above complex of flat
$\underline{\mathbf{Z}}_X$-modules is cofinal in the system.
(This follows from Modules, Lemma \ref{modules-lemma-module-quotient-flat} and
Derived Categories, Lemma \ref{derived-lemma-subcategory-left-resolution};
see discussion in Section \ref{section-flat}.)
Hence we can construct an inverse to the map
$H^0(X, K) \longrightarrow H^0(X, K_{ab})$
by representing an element $\xi \in H^0(X, K_{ab})$ by a pair
$$
(s : \mathcal{G}^\bullet \to \underline{\mathbf{Z}}_X,
a : \mathcal{G}^\bullet \to \mathcal{K}^\bullet)
$$
with $\mathcal{G}^\bullet$ a bounded above complex of flat
$\underline{\mathbf{Z}}_X$-modules and sending this to
$$
(\mathcal{G}^\bullet \otimes_{\underline{\mathbf{Z}}_X} \mathcal{O}_X
\to \mathcal{O}_X,
\mathcal{G}^\bullet  \otimes_{\underline{\mathbf{Z}}_X} \mathcal{O}_X
\to \mathcal{K}^\bullet)
$$
The only thing to note here is that the first arrow
is a quasi-isomorphism by
Lemmas \ref{lemma-derived-tor-quasi-isomorphism-other-side} and
\ref{lemma-bounded-flat-K-flat}.
We omit the detailed verification that this construction
is indeed an inverse.
\end{proof}

\begin{lemma}
\label{lemma-adjoint-lower-shriek-restrict}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $U \subset X$ be an
open subset. Denote $j : (U, \mathcal{O}_U) \to (X, \mathcal{O}_X)$
the corresponding open immersion. The restriction functor
$D(\mathcal{O}_X) \to D(\mathcal{O}_U)$ is a right adjoint to
extension by zero $j_! : D(\mathcal{O}_U) \to D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This follows formally from the fact that $j_!$ and $j^*$ are adjoint and
exact (and hence $Lj_! = j_!$ and $Rj^* = j^*$ exist), see
Derived Categories, Lemma \ref{derived-lemma-derived-adjoint-functors}.
\end{proof}

\begin{lemma}
\label{lemma-K-injective-flat}
Let $f : X \to Y$ be a flat morphism of ringed spaces.
If $\mathcal{I}^\bullet$ is a K-injective complex of $\mathcal{O}_X$-modules,
then $f_*\mathcal{I}^\bullet$ is K-injective as a complex of
$\mathcal{O}_Y$-modules.
\end{lemma}

\begin{proof}
This is true because
$$
\Hom_{K(\mathcal{O}_Y)}(\mathcal{F}^\bullet, f_*\mathcal{I}^\bullet)
=
\Hom_{K(\mathcal{O}_X)}(f^*\mathcal{F}^\bullet, \mathcal{I}^\bullet)
$$
by
Sheaves, Lemma
\ref{sheaves-lemma-adjoint-pullback-pushforward-modules}
and the fact that $f^*$ is exact as $f$ is assumed to be flat.
\end{proof}





\section{Unbounded Mayer-Vietoris}
\label{section-unbounded-mayer-vietoris}

\noindent
There is a Mayer-Vietoris sequence for unbounded cohomology as well.

\begin{lemma}
\label{lemma-exact-sequence-lower-shriek}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $X = U \cup V$ be the union of two open subspaces.
For any object $E$ of $D(\mathcal{O}_X)$ we have a distinguished
triangle
$$
j_{U \cap V!}E|_{U \cap V} \to
j_{U!}E|_U \oplus j_{V!}E|_V \to E \to 
j_{U \cap V!}E|_{U \cap V}[1]
$$
in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
We have seen in Section \ref{section-properties-K-injective}
that the restriction functors and the extension
by zero functors are computed by just applying the functors to
any complex. Let $\mathcal{E}^\bullet$ be a complex of $\mathcal{O}_X$-modules
representing $E$. The distinguished triangle of the lemma is the
distinguished triangle associated (by
Derived Categories, Section
\ref{derived-section-canonical-delta-functor} and especially
Lemma \ref{derived-lemma-derived-canonical-delta-functor})
to the short exact sequence of complexes of $\mathcal{O}_X$-modules
$$
0 \to j_{U \cap V!}\mathcal{E}^\bullet|_{U \cap V} \to
j_{U!}\mathcal{E}^\bullet|_U \oplus j_{V!}\mathcal{E}^\bullet|_V
\to \mathcal{E}^\bullet \to 0
$$
To see this sequence is exact one checks on stalks using
Sheaves, Lemma \ref{sheaves-lemma-j-shriek-modules}
(computation omitted).
\end{proof}

\begin{lemma}
\label{lemma-exact-sequence-j-star}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $X = U \cup V$ be the union of two open subspaces.
For any object $E$ of $D(\mathcal{O}_X)$ we have a distinguished
triangle
$$
E \to 
Rj_{U, *}E|_U \oplus Rj_{V, *}E|_V \to
Rj_{U \cap V, *}E|_{U \cap V} \to
E[1]
$$
in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$ representing $E$
whose terms $\mathcal{I}^n$ are injective objects of
$\textit{Mod}(\mathcal{O}_X)$, see Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}.
We have seen that $\mathcal{I}^\bullet|U$ is a K-injective complex
as well (Lemma \ref{lemma-restrict-K-injective-to-open}). Hence
$Rj_{U, *}E|_U$ is represented by $j_{U, *}\mathcal{I}^\bullet|_U$.
Similarly for $V$ and $U \cap V$. Hence the distinguished triangle
of the lemma is the distinguished triangle associated (by
Derived Categories, Section
\ref{derived-section-canonical-delta-functor} and especially
Lemma \ref{derived-lemma-derived-canonical-delta-functor})
to the short exact sequence of complexes
$$
0 \to
\mathcal{I}^\bullet \to
j_{U, *}\mathcal{I}^\bullet|_U \oplus j_{V, *}\mathcal{I}^\bullet|_V \to
j_{U \cap V, *}\mathcal{I}^\bullet|_{U \cap V} \to
0.
$$
This sequence is exact because for any $W \subset X$ open
and any $n$ the sequence
$$
0 \to
\mathcal{I}^n(W) \to
\mathcal{I}^n(W \cap U) \oplus \mathcal{I}^n(W \cap V) \to
\mathcal{I}^n(W \cap U \cap V) \to
0
$$
is exact (see proof of Lemma \ref{lemma-mayer-vietoris}).
\end{proof}

\begin{lemma}
\label{lemma-mayer-vietoris-hom}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $X = U \cup V$ be
the union of two open subspaces of $X$.
For objects $E$, $F$ of $D(\mathcal{O}_X)$ we have a
Mayer-Vietoris sequence
$$
\xymatrix{
& \ldots \ar[r] & \Ext^{-1}(E_{U \cap V}, F_{U \cap V}) \ar[lld] \\
\Hom(E, F) \ar[r] &
\Hom(E_U, F_U) \oplus
\Hom(E_V, F_V) \ar[r] &
\Hom(E_{U \cap V}, F_{U \cap V})
}
$$
where the subscripts denote restrictions to the relevant opens
and the $\Hom$'s and $\Ext$'s are taken in the relevant
derived categories.
\end{lemma}

\begin{proof}
Use the distinguished triangle of
Lemma \ref{lemma-exact-sequence-lower-shriek}
to obtain a long exact sequence of $\Hom$'s
(from Derived Categories, Lemma \ref{derived-lemma-representable-homological})
and use that
$$
\Hom_{D(\mathcal{O}_X)}(j_{U!}E|_U, F) =
\Hom_{D(\mathcal{O}_U)}(E|_U, F|_U)
$$
by Lemma \ref{lemma-adjoint-lower-shriek-restrict}.
\end{proof}

\begin{lemma}
\label{lemma-unbounded-mayer-vietoris}
Let $(X, \mathcal{O}_X)$ be a ringed space. Suppose that
$X = U \cup V$ is a union of two open subsets. For an object $E$
of $D(\mathcal{O}_X)$ we have a distinguished triangle
$$
R\Gamma(X, E) \to R\Gamma(U, E) \oplus R\Gamma(V, E) \to
R\Gamma(U \cap V, E) \to R\Gamma(X, E)[1]
$$
and in particular a long exact cohomology sequence
$$
\ldots \to
H^n(X, E) \to
H^n(U, E) \oplus H^0(V, E) \to
H^n(U \cap V, E) \to
H^{n + 1}(X, E) \to \ldots
$$
The construction of the distinguished triangle and the
long exact sequence is functorial in $E$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$
representing $E$. We may assume $\mathcal{I}^n$ is an injective
object of $\textit{Mod}(\mathcal{O}_X)$ for all $n$, see
Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}.
Then $R\Gamma(X, E)$ is computed by $\Gamma(X, \mathcal{I}^\bullet)$.
Similarly for $U$, $V$, and $U \cap V$ by
Lemma \ref{lemma-restrict-K-injective-to-open}.
Hence the distinguished triangle of the lemma is the distinguished
triangle associated (by
Derived Categories, Section
\ref{derived-section-canonical-delta-functor} and especially
Lemma \ref{derived-lemma-derived-canonical-delta-functor})
to the 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.
$$
We have seen this is a short exact sequence in the proof of
Lemma \ref{lemma-mayer-vietoris}.
The final statement follows from the functoriality of the construction
in Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}.
\end{proof}

\begin{lemma}
\label{lemma-unbounded-relative-mayer-vietoris}
Let $f : X \to Y$ be a morphism of ringed spaces.
Suppose that $X = U \cup V$ is a union of two open subsets.
Denote $a = f|_U : U \to Y$, $b = f|_V : V \to Y$, and
$c = f|_{U \cap V} : U \cap V \to Y$.
For every object $E$ of $D(\mathcal{O}_X)$ there exists a
distinguished triangle
$$
Rf_*E \to
Ra_*(E|_U) \oplus Rb_*(E|_V) \to
Rc_*(E|_{U \cap V}) \to
Rf_*E[1]
$$
This triangle is functorial in $E$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$
representing $E$. We may assume $\mathcal{I}^n$ is an injective
object of $\textit{Mod}(\mathcal{O}_X)$ for all $n$, see
Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}.
Then $Rf_*E$ is computed by $f_*\mathcal{I}^\bullet$.
Similarly for $U$, $V$, and $U \cap V$ by
Lemma \ref{lemma-restrict-K-injective-to-open}.
Hence the distinguished triangle of the lemma is the distinguished
triangle associated (by
Derived Categories, Section
\ref{derived-section-canonical-delta-functor} and especially
Lemma \ref{derived-lemma-derived-canonical-delta-functor})
to the 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.
$$
This is a short exact sequence of complexes by
Lemma \ref{lemma-relative-mayer-vietoris}
and the fact that $R^1f_*\mathcal{I} = 0$
for an injective object $\mathcal{I}$ of $\textit{Mod}(\mathcal{O}_X)$.
The final statement follows from the functoriality of the construction
in Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}.
\end{proof}

\begin{lemma}
\label{lemma-pushforward-restriction}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $j : U \to X$ be an
open subspace. Let $T \subset X$ be a closed subset contained in $U$.
\begin{enumerate}
\item If $E$ is an object of $D(\mathcal{O}_X)$ whose cohomology sheaves
are supported on $T$, then $E \to Rj_*(E|_U)$ is an isomorphism.
\item If $F$ is an object of $D(\mathcal{O}_U)$ whose cohomology sheaves
are supported on $T$, then $j_!F \to Rj_*F$ is an isomorphism.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $V = X \setminus T$ and $W = U \cap V$. Note that $X = U \cup V$ is an
open covering of $X$. Denote $j_W : W \to V$ the open immersion.
Let $E$ be an object of $D(\mathcal{O}_X)$ whose cohomology sheaves are
supported on $T$. By
Lemma \ref{lemma-restrict-direct-image-open} we have
$(Rj_*E|_U)|_V = Rj_{W, *}(E|_W) = 0$ because $E|_W = 0$ by our assumption.
On the other hand, $Rj_*(E|_U)|_U = E|_U$. Thus (1) is clear.
Let $F$ be an object of $D(\mathcal{O}_U)$ whose cohomology sheaves
are supported on $T$. By
Lemma \ref{lemma-restrict-direct-image-open} we have
$(Rj_*F)|_V = Rj_{W, *}(F|_W) = 0$ because $F|_W = 0$ by our assumption.
We also have $(j_!F)|_V = j_{W!}(F|_W) = 0$ (the first equality is immediate
from the definition of extension by zero). Since both
$(Rj_*F)|_U = F$ and $(j_!F)|_U = F$ we see that (2) holds.
\end{proof}

\begin{lemma}
\label{lemma-mayer-vietoris-cup}
Let $(X, \mathcal{O}_X)$ be a ringed space. Set $A = \Gamma(X, \mathcal{O}_X)$.
Suppose that $X = U \cup V$ is a union of two open subsets. For objects
$K$ and $M$ of $D(\mathcal{O}_X)$ we have a map of distinguished triangles
$$
\xymatrix{
R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(X, M) \ar[r] \ar[d] &
R\Gamma(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M) \ar[d] \\
R\Gamma(X, K) \otimes_A^\mathbf{L}
(R\Gamma(U, M) \oplus R\Gamma(V, M)) \ar[r] \ar[d] &
R\Gamma(U, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
\oplus R\Gamma(V, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)) \ar[d] \\
R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(U \cap V, M) \ar[r] \ar[d] &
R\Gamma(U \cap V, K \otimes_{\mathcal{O}_X}^\mathbf{L} M) \ar[d] \\
R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(X, M)[1] \ar[r] &
R\Gamma(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)[1]
}
$$
where
\begin{enumerate}
\item the horizontal arrows are given by cup product,
\item on the right hand side we have the distinguished triangle
of Lemma \ref{lemma-unbounded-mayer-vietoris} for
$K \otimes_{\mathcal{O}_X}^\mathbf{L} M$, and
\item on the left hand side we have the exact functor
$R\Gamma(X, K) \otimes_A^\mathbf{L} - $ applied to the
distinguished triangle of Lemma \ref{lemma-unbounded-mayer-vietoris} for $M$.
\end{enumerate}
\end{lemma}

\begin{proof}
Choose a K-flat complex $T^\bullet$ of flat $A$-modules representing
$R\Gamma(X, K)$, see
More on Algebra, Lemma \ref{more-algebra-lemma-K-flat-resolution}.
Denote $T^\bullet \otimes_A \mathcal{O}_X$ the pullback of $T^\bullet$
by the morphism of ringed spaces $(X, \mathcal{O}_X) \to (pt, A)$.
There is a natural adjunction map
$\epsilon : T^\bullet \otimes_A \mathcal{O}_X \to K$ in $D(\mathcal{O}_X)$.
Observe that $T^\bullet \otimes_A \mathcal{O}_X$ is a K-flat
complex of $\mathcal{O}_X$-modules with flat terms, see
Lemma \ref{lemma-pullback-K-flat} and
Modules, Lemma \ref{modules-lemma-pullback-flat}.
By Lemma \ref{lemma-factor-through-K-flat} we can find a morphism of complexes
$$
T^\bullet \otimes_A \mathcal{O}_X \longrightarrow \mathcal{K}^\bullet
$$
of $\mathcal{O}_X$-modules representing $\epsilon$
such that $\mathcal{K}^\bullet$ is a
K-flat complex with flat terms. Namely, by the construction of
$D(\mathcal{O}_X)$ we can first represent $\epsilon$ by some map of complexes
$e : T^\bullet \otimes_A \mathcal{O}_X \to \mathcal{L}^\bullet$
of $\mathcal{O}_X$-modules representing $\epsilon$
and then we can apply the lemma to $e$. Choose a K-injective
complex $\mathcal{I}^\bullet$ whose terms are injective $\mathcal{O}_X$-modules
representing $M$. Finally, choose a quasi-isomorphism
$$
\text{Tot}(\mathcal{K}^\bullet \otimes_\mathcal{O} \mathcal{I}^\bullet)
\longrightarrow
\mathcal{J}^\bullet
$$
into a K-injective complex whose terms are injective $\mathcal{O}_X$-modules.
Observe that source and target of this arrow represent
$K \otimes_{\mathcal{O}_X}^\mathbf{L} M$ in $D(\mathcal{O}_X)$.
At this point, for any open $W \subset X$ we obtain a map of complexes
$$
\text{Tot}(T^\bullet \otimes_A \mathcal{I}^\bullet(W))
\to
\text{Tot}(\mathcal{K}^\bullet(W) \otimes_A \mathcal{I}^\bullet(W))
\to
\mathcal{J}^\bullet(W)
$$
of $A$-modules whose composition represents the map
$$
R\Gamma(X, K) \otimes_A^\mathbf{L} R\Gamma(W, M)
\longrightarrow
R\Gamma(W, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
in $D(A)$. Clearly, these maps are compatible with restriction mappings.
OK, so now we can consider the following commutative(!) diagram
of complexes of $A$-modules
$$
\xymatrix{
0 \ar[d] & 0 \ar[d] \\
\text{Tot}(T^\bullet \otimes_A \mathcal{I}^\bullet(X)) \ar[d] \ar[r] &
\mathcal{J}^\bullet(X) \ar[d] \\
\text{Tot}(T^\bullet \otimes_A
(\mathcal{I}^\bullet(U) \oplus \mathcal{I}^\bullet(V)) \ar[d] \ar[r] &
\mathcal{J}^\bullet(U) \oplus \mathcal{J}^\bullet(V) \ar[d] \\
\text{Tot}(T^\bullet \otimes_A \mathcal{I}^\bullet(U \cap V)) \ar[r] \ar[d] &
\mathcal{J}^\bullet(U \cap V) \ar[d] \\
0 & 0
}
$$
By the proof of Lemma \ref{lemma-mayer-vietoris} the columns are
exact sequences of complexes of $A$-modules (this also uses that
$\text{Tot}(T^\bullet \otimes_A -)$ transforms short exact sequences
of complexes of $A$-modules into short exact sequences as the terms
of $T^\bullet$ are flat $A$-modules). Since the distinguished triangles
of Lemma \ref{lemma-unbounded-mayer-vietoris}
are the distinguished triangles associated to these
short exact sequences of complexes, the desired result follows from
the functoriality of ``taking the associated distinguished triangle''
discussed in
Derived Categories, Section \ref{derived-section-canonical-delta-functor}.
\end{proof}












\section{Cohomology with support in a closed, II}
\label{section-cohomology-support-bis}

\noindent
We continue the discussion started in
Section \ref{section-cohomology-support}.

\medskip\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $Z \subset X$ be
a closed subset. In this situation we can consider the functor
$\textit{Mod}(\mathcal{O}_X) \to \textit{Mod}(\mathcal{O}_X(X))$
given by $\mathcal{F} \mapsto \Gamma_Z(X, \mathcal{F})$. See
Modules, Definition \ref{modules-definition-support}
and
Modules, Lemma \ref{modules-lemma-support-section-closed}.
Using K-injective resolutions, see Section \ref{section-unbounded},
we obtain the right derived functor
$$
R\Gamma_Z(X, - ) : D(\mathcal{O}_X) \to D(\mathcal{O}_X(X))
$$
Given an object $K$ in $D(\mathcal{O}_X)$ we denote
$H^q_Z(X, K) = H^q(R\Gamma_Z(X, K))$ the cohomology module with
support in $Z$. We will see later
(Lemma \ref{lemma-sections-support-abelian-unbounded}) that this
agrees with the construction in Section \ref{section-cohomology-support}.

\medskip\noindent
For an $\mathcal{O}_X$-module $\mathcal{F}$ we can consider the
{\it subsheaf of sections with support in $Z$}, denoted
$\mathcal{H}_Z(\mathcal{F})$, defined by the rule
$$
\mathcal{H}_Z(\mathcal{F})(U) =
\{s \in \mathcal{F}(U) \mid \text{Supp}(s) \subset U \cap Z\} =
\Gamma_{Z \cap U}(U, \mathcal{F}|_U)
$$
As discussed in
Modules, Remark \ref{modules-remark-sections-support-in-closed-modules}
we may view $\mathcal{H}_Z(\mathcal{F})$ as an $\mathcal{O}_X|_Z$-module
on $Z$ and we obtain a functor
$$
\textit{Mod}(\mathcal{O}_X) \longrightarrow \textit{Mod}(\mathcal{O}_X|_Z),
\quad
\mathcal{F} \longmapsto \mathcal{H}_Z(\mathcal{F})
\text{ viewed as an }\mathcal{O}_X|_Z\text{-module on }Z
$$
This functor is left exact, but in general not exact. Exactly as above
we obtain a right derived functor
$$
R\mathcal{H}_Z : D(\mathcal{O}_X) \longrightarrow D(\mathcal{O}_X|_Z)
$$
We set $\mathcal{H}^q_Z(K) = H^q(R\mathcal{H}_Z(K))$ so that
$\mathcal{H}^0_Z(\mathcal{F}) = \mathcal{H}_Z(\mathcal{F})$
for any sheaf of $\mathcal{O}_X$-modules $\mathcal{F}$.

\begin{lemma}
\label{lemma-cohomology-with-support-sheaf-on-support}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $i : Z \to X$ be the
inclusion of a closed subset.
\begin{enumerate}
\item $R\mathcal{H}_Z : D(\mathcal{O}_X) \to D(\mathcal{O}_X|_Z)$
is right adjoint to $i_* : D(\mathcal{O}_X|_Z) \to D(\mathcal{O}_X)$.
\item For $K$ in $D(\mathcal{O}_X|_Z)$ we have $R\mathcal{H}_Z(i_*K) = K$.
\item Let $\mathcal{G}$ be a sheaf of
$\mathcal{O}_X|_Z$-modules on $Z$. Then
$\mathcal{H}^p_Z(i_*\mathcal{G}) = 0$ for $p > 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
The functor $i_*$ is exact, so $i_* = Ri_* = Li_*$. Hence part (1)
of the lemma follows from
Modules, Lemma \ref{modules-lemma-adjoint-section-with-support}
and
Derived Categories, Lemma \ref{derived-lemma-derived-adjoint-functors}.
Let $K$ be as in (2). We can represent $K$ by a K-injective complex
$\mathcal{I}^\bullet$ of $\mathcal{O}_X|_Z$-modules. By
Lemma \ref{lemma-K-injective-flat}
the complex $i_*\mathcal{I}^\bullet$, which represents $i_*K$,
is a K-injective complex of $\mathcal{O}_X$-modules. Thus
$R\mathcal{H}_Z(i_*K)$ is computed by
$\mathcal{H}_Z(i_*\mathcal{I}^\bullet) = \mathcal{I}^\bullet$
which proves (2). Part (3) is a special case of (2).
\end{proof}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space and let $Z \subset X$
be a closed subset. The category of $\mathcal{O}_X$-modules whose
support is contained in $Z$ is a Serre subcategory of the
category of all $\mathcal{O}_X$-modules, see
Homology, Definition \ref{homology-definition-serre-subcategory}
and
Modules, Lemma \ref{modules-lemma-support-section-closed}.
We denote $D_Z(\mathcal{O}_X)$
the strictly full saturated triangulated subcategory of
$D(\mathcal{O}_X)$ consisting of complexes whose cohomology sheaves
are supported on $Z$, see
Derived Categories, Section \ref{derived-section-triangulated-sub}.

\begin{lemma}
\label{lemma-complexes-with-support-on-closed}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $i : Z \to X$ be the
inclusion of a closed subset.
\begin{enumerate}
\item For $K$ in $D(\mathcal{O}_X|_Z)$ we have $i_*K$ in $D_Z(\mathcal{O}_X)$.
\item The functor $i_* : D(\mathcal{O}_X|_Z) \to D_Z(\mathcal{O}_X)$
is an equivalence with quasi-inverse
$i^{-1}|_{D_Z(\mathcal{O}_X)} = R\mathcal{H}_Z|_{D_Z(\mathcal{O}_X)}$.
\item The functor
$i_* \circ R\mathcal{H}_Z : D(\mathcal{O}_X) \to D_Z(\mathcal{O}_X)$
is right adjoint to the inclusion functor
$D_Z(\mathcal{O}_X) \to D(\mathcal{O}_X)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) is immediate from the definitions. Part (3) is a formal
consequence of part (2) and
Lemma \ref{lemma-cohomology-with-support-sheaf-on-support}.
In the rest of the proof we prove part (2).

\medskip\noindent
Let us think of $i$ as the morphism of ringed spaces
$i : (Z, \mathcal{O}_X|_Z) \to (X, \mathcal{O}_X)$.
Recall that $i^*$ and $i_*$ is an adjoint pair of functors.
Since $i$ is a closed immersion, $i_*$ is exact.
Since $i^{-1}\mathcal{O}_X = \mathcal{O}_X|_Z$ is the structure
sheaf of $(Z, \mathcal{O}_X|_Z)$ we see that $i^* = i^{-1}$
is exact and we see that that $i^*i_* = i^{-1}i_*$
is isomorphic to the identify functor. See
Modules, Lemmas \ref{modules-lemma-exactness-pushforward-pullback} and
\ref{modules-lemma-i-star-exact}. Thus
$i_* : D(\mathcal{O}_X|_Z) \to D_Z(\mathcal{O}_X)$
is fully faithful and $i^{-1}$ determines
a left inverse. On the other hand, suppose that $K$ is an object of
$D_Z(\mathcal{O}_X)$ and consider the adjunction map
$K \to i_*i^{-1}K$.
Using exactness of $i_*$ and $i^{-1}$ this induces the adjunction maps
$H^n(K) \to i_*i^{-1}H^n(K)$ on cohomology sheaves. Since these cohomology
sheaves are supported on $Z$ we see these adjunction maps are isomorphisms
and we conclude that $i_* : D(\mathcal{O}_X|_Z) \to D_Z(\mathcal{O}_X)$
is an equivalence.

\medskip\noindent
To finish the proof it suffices to show that $R\mathcal{H}_Z(K) = i^{-1}K$ if
$K$ is an object of $D_Z(\mathcal{O}_X)$. To do this we can use that
$K = i_*i^{-1}K$ as we've just proved this is the case. Then
Lemma \ref{lemma-cohomology-with-support-sheaf-on-support}
tells us what we want.
\end{proof}

\begin{lemma}
\label{lemma-sections-with-support-K-injective}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $i : Z \to X$
be the inclusion of a closed subset. If $\mathcal{I}^\bullet$ is a K-injective
complex of $\mathcal{O}_X$-modules, then
$\mathcal{H}_Z(\mathcal{I}^\bullet)$ is K-injective complex of
$\mathcal{O}_X|_Z$-modules.
\end{lemma}

\begin{proof}
Since $i_* : \textit{Mod}(\mathcal{O}_X|_Z) \to \textit{Mod}(\mathcal{O}_X)$
is exact and left adjoint to $\mathcal{H}_Z$
(Modules, Lemma \ref{modules-lemma-adjoint-section-with-support})
this follows from
Derived Categories, Lemma \ref{derived-lemma-adjoint-preserve-K-injectives}.
\end{proof}

\begin{lemma}
\label{lemma-local-to-global-sections-with-support}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $i : Z \to X$ be the
inclusion of a closed subset. Then
$R\Gamma(Z, - ) \circ R\mathcal{H}_Z = R\Gamma_Z(X, - )$
as functors $D(\mathcal{O}_X) \to D(\mathcal{O}_X(X))$.
\end{lemma}

\begin{proof}
Follows from the construction of right derived functors using
K-injective resolutions, Lemma \ref{lemma-sections-with-support-K-injective},
and the fact that $\Gamma_Z(X, -) = \Gamma(Z, -) \circ \mathcal{H}_Z$.
\end{proof}

\begin{lemma}
\label{lemma-triangle-sections-with-support}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $i : Z \to X$ be the
inclusion of a closed subset. Let $U = X \setminus Z$.
There is a distinguished triangle
$$
R\Gamma_Z(X, K) \to R\Gamma(X, K) \to R\Gamma(U, K) \to
R\Gamma_Z(X, K)[1]
$$
in $D(\mathcal{O}_X(X))$ functorial for $K$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$ all of whose terms
are injective $\mathcal{O}_X$-modules representing $K$. See
Section \ref{section-unbounded}. Recall that $\mathcal{I}^\bullet|_U$
is a K-injective complex of $\mathcal{O}_U$-modules, see
Lemma \ref{lemma-restrict-K-injective-to-open}. Hence each
of the derived functors in the distinguished triangle is gotten
by applying the underlying functor to $\mathcal{I}^\bullet$.
Hence we find that it suffices to prove that
for an injective $\mathcal{O}_X$-module $\mathcal{I}$ we have
a short exact sequence
$$
0 \to \Gamma_Z(X, \mathcal{I}) \to \Gamma(X, \mathcal{I})
\to \Gamma(U, \mathcal{I}) \to 0
$$
This follows from Lemma \ref{lemma-injective-restriction-surjective}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-triangle-sections-with-support-sheaves}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $i : Z \to X$ be the
inclusion of a closed subset. Denote $j : U = X \setminus Z \to X$
the inclusion of the complement. There is a distinguished triangle
$$
i_*R\mathcal{H}_Z(K) \to K \to Rj_*(K|_U) \to
i_*R\mathcal{H}_Z(K)[1]
$$
in $D(\mathcal{O}_X)$ functorial for $K$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$ all of whose terms
are injective $\mathcal{O}_X$-modules representing $K$. See
Section \ref{section-unbounded}. Recall that $\mathcal{I}^\bullet|_U$
is a K-injective complex of $\mathcal{O}_U$-modules, see
Lemma \ref{lemma-restrict-K-injective-to-open}. Hence each
of the derived functors in the distinguished triangle is gotten
by applying the underlying functor to $\mathcal{I}^\bullet$.
Hence it suffices to prove that
for an injective $\mathcal{O}_X$-module $\mathcal{I}$ we have
a short exact sequence
$$
0 \to i_*\mathcal{H}_Z(\mathcal{I}) \to \mathcal{I}
\to j_*(\mathcal{I}|_U) \to 0
$$
This follows from Lemma \ref{lemma-injective-restriction-surjective}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-sections-support-in-closed-disjoint-open}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $Z \subset X$
be a closed subset. Let $j : U \to X$ be the inclusion of
an open subset with $U \cap Z = \emptyset$. Then
$R\mathcal{H}_Z(Rj_*K) = 0$ for all $K$ in $D(\mathcal{O}_U)$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$ of $\mathcal{O}_U$-modules
representing $K$. Then $j_*\mathcal{I}^\bullet$ represents $Rj_*K$. By
Lemma \ref{lemma-K-injective-flat} the complex $j_*\mathcal{I}^\bullet$ is a
K-injective complex of $\mathcal{O}_X$-modules. Hence
$\mathcal{H}_Z(j_*\mathcal{I}^\bullet)$ represents $R\mathcal{H}_Z(Rj_*K)$.
Thus it suffices to show that $\mathcal{H}_Z(j_*\mathcal{G}) = 0$
for any abelian sheaf $\mathcal{G}$ on $U$. Thus we have to show that
a section $s$ of $j_*\mathcal{G}$ over some open $W$ which is supported
on $W \cap Z$ is zero. The support condition means that
$s|_{W \setminus W \cap Z} = 0$. Since $j_*\mathcal{G}(W) =
\mathcal{G}(U \cap W) = j_*\mathcal{G}(W \setminus W \cap Z)$
this implies that $s$ is zero as desired.
\end{proof}

\begin{lemma}
\label{lemma-sections-support-abelian-unbounded}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $Z \subset X$
be a closed subset. Let $K$ be an object of $D(\mathcal{O}_X)$
and denote $K_{ab}$ its image in $D(\underline{\mathbf{Z}}_X)$.
\begin{enumerate}
\item There is a canonical map $R\Gamma_Z(X, K) \to R\Gamma_Z(X, K_{ab})$
which is an isomorphism in $D(\textit{Ab})$.
\item There is a canonical map
$R\mathcal{H}_Z(K) \to R\mathcal{H}_Z(K_{ab})$
which is an isomorphism in $D(\underline{\mathbf{Z}}_Z)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). The map is constructed as follows. Choose a K-injective complex
of $\mathcal{O}_X$-modules $\mathcal{I}^\bullet$ representing $K$.
Choose a quasi-isomorpism
$\mathcal{I}^\bullet \to \mathcal{J}^\bullet$ where $\mathcal{J}^\bullet$
is a K-injective complex of abelian groups. Then the map in (1)
is given by
$$
\Gamma_Z(X, \mathcal{I}^\bullet) \to \Gamma_Z(X, \mathcal{J}^\bullet)
$$
determined by the fact that $\Gamma_Z$ is a functor on abelian sheaves.
An easy check shows that the resulting map combined with the canonical
maps of Lemma \ref{lemma-modules-abelian-unbounded}
fit into a morphism of distinguished triangles
$$
\xymatrix{
R\Gamma_Z(X, K) \ar[r] \ar[d] &
R\Gamma(X, K) \ar[r] \ar[d] &
R\Gamma(U, K) \ar[d] \\
R\Gamma_Z(X, K_{ab}) \ar[r] &
R\Gamma(X, K_{ab}) \ar[r] &
R\Gamma(U, K_{ab})
}
$$
of Lemma \ref{lemma-triangle-sections-with-support}.
Since two of the three arrows are isomorphisms by the lemma cited,
we conclude by Derived Categories, Lemma
\ref{derived-lemma-third-isomorphism-triangle}.

\medskip\noindent
The proof of (2) is omitted. Hint: use the same argument with
Lemma \ref{lemma-triangle-sections-with-support-sheaves}
for the distinguished triangle.
\end{proof}

\begin{remark}
\label{remark-support-cup-product}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $i : Z \to X$
be the inclusion of a closed subset. Given $K$ and $M$ in
$D(\mathcal{O}_X)$ there is a canonical map
$$
K|_Z \otimes_{\mathcal{O}_X|_Z}^\mathbf{L} R\mathcal{H}_Z(M)
\longrightarrow
R\mathcal{H}_Z(K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
in $D(\mathcal{O}_X|_Z)$. Here $K|_Z = i^{-1}K$ is the restriction of
$K$ to $Z$ viewed as an object of $D(\mathcal{O}_X|_Z)$. By adjointness
of $i_*$ and $R\mathcal{H}_Z$ of
Lemma \ref{lemma-cohomology-with-support-sheaf-on-support} to construct this
map it suffices to produce a canonical map
$$
i_*\left(K|_Z \otimes_{\mathcal{O}_X|_Z}^\mathbf{L} R\mathcal{H}_Z(M)\right)
\longrightarrow
K \otimes_{\mathcal{O}_X}^\mathbf{L} M
$$
To construct this map, we choose a K-injective complex $\mathcal{I}^\bullet$
of $\mathcal{O}_X$-modules representing $M$ and a K-flat complex
$\mathcal{K}^\bullet$ of $\mathcal{O}_X$-modules representing $K$.
Observe that $\mathcal{K}^\bullet|_Z$ is a K-flat complex of
$\mathcal{O}_X|_Z$-modules representing $K|_Z$, see
Lemma \ref{lemma-pullback-K-flat}. Hence we need to produce a map
of complexes
$$
i_*\text{Tot}\left(
\mathcal{K}^\bullet|_Z \otimes_{\mathcal{O}_X|_Z}
\mathcal{H}_Z(\mathcal{I}^\bullet)\right)
\longrightarrow
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{I}^\bullet)
$$
of $\mathcal{O}_X$-modules. For this it suffices to produce maps
$$
i_*(\mathcal{K}^a|_Z \otimes_{\mathcal{O}_X|_Z}
\mathcal{H}_Z(\mathcal{I}^b))
\longrightarrow
\mathcal{K}^a \otimes_{\mathcal{O}_X} \mathcal{I}^b
$$
Looking at stalks (for example), we see that the left hand side of this
formula is equal to
$\mathcal{K}^a \otimes_{\mathcal{O}_X} i_*\mathcal{H}_Z(\mathcal{I}^b)$
and we can use the inclusion
$\mathcal{H}_Z(\mathcal{I}^b) \to \mathcal{I}^b$ to get our map.
\end{remark}

\begin{remark}
\label{remark-support-cup-product-global}
With notation as in Remark \ref{remark-support-cup-product}
we obtain a canonical cup product
\begin{align*}
H^a(X, K) \times H^b_Z(X, M)
& =
H^a(X, K) \times H^b(Z, R\mathcal{H}_Z(M)) \\
& \to
H^a(Z, K|_Z) \times H^b(Z, R\mathcal{H}_Z(M)) \\
& \to
H^{a + b}(Z, K|_Z \otimes_{\mathcal{O}_X|_Z}^\mathbf{L} R\mathcal{H}_Z(M)) \\
& \to
H^{a + b}(Z, R\mathcal{H}_Z(K \otimes_{\mathcal{O}_X}^\mathbf{L} M)) \\
& =
H^{a + b}_Z(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
\end{align*}
Here the equal signs are given by
Lemma \ref{lemma-local-to-global-sections-with-support},
the first arrow is restriction to $Z$, the second
arrow is the cup product (Section \ref{section-cup-product}),
and the third arrow is the map from Remark \ref{remark-support-cup-product}.
\end{remark}

\begin{lemma}
\label{lemma-support-cup-product}
With notation as in Remark \ref{remark-support-cup-product} the diagram
$$
\xymatrix{
H^i(X, K) \times H^j_Z(X, M) \ar[r] \ar[d] &
H^{i + j}_Z(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M) \ar[d] \\
H^i(X, K) \times H^j(X, M) \ar[r] &
H^{i + j}(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} M)
}
$$
commutes where the top horizontal arrow is the cup product of
Remark \ref{remark-support-cup-product-global}.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{remark}
\label{remark-support-functorial}
Let $f : (X', \mathcal{O}_{X'}) \to (X, \mathcal{O}_X)$ be a morphism
of ringed spaces. Let $Z \subset X$ be a closed subset and $Z' = f^{-1}(Z)$.
Denote $f|_{Z'} : (Z', \mathcal{O}_{X'}|_{Z'}) \to (Z, \mathcal{O}_X|Z)$ be the
induced morphism of ringed spaces. For any $K$ in $D(\mathcal{O}_X)$ there
is a canonical map
$$
L(f|_{Z'})^*R\mathcal{H}_Z(K) \longrightarrow R\mathcal{H}_{Z'}(Lf^*K)
$$
in $D(\mathcal{O}_{X'}|_{Z'})$. Denote $i : Z \to X$ and $i' : Z' \to X'$
the inclusion maps. By
Lemma \ref{lemma-complexes-with-support-on-closed} part (2)
applied to $i'$ it is the same thing to give a map
$$
i'_* L(f|_{Z'})^* R\mathcal{H}_Z(K)
\longrightarrow
i'_*R\mathcal{H}_{Z'}(Lf^*K)
$$
in $D_{Z'}(\mathcal{O}_{X'})$. The map of functors
$Lf^* \circ i_* \to i'_* \circ L(f|_{Z'})^*$ of
Remark \ref{remark-base-change} is an isomorphism in this case
(follows by checking what happens on stalks using that $i_*$ and $i'_*$
are exact and that $\mathcal{O}_{Z, z} = \mathcal{O}_{X, z}$
and similarly for $Z'$). Hence it suffices to construct a the top
horizonal arrow in the following diagram
$$
\xymatrix{
Lf^* i_* R\mathcal{H}_Z(K) \ar[rr] \ar[rd] & &
i'_* R\mathcal{H}_{Z'}(Lf^*K) \ar[ld] \\
& Lf^*K
}
$$
The complex $Lf^* i_* R\mathcal{H}_Z(K)$ is supported on $Z'$. The south-east
arrow comes from the adjunction mapping $i_*R\mathcal{H}_Z(K) \to K$
(Lemma \ref{lemma-cohomology-with-support-sheaf-on-support}). Since the
adjunction mapping $i'_* R\mathcal{H}_{Z'}(Lf^*K) \to Lf^*K$ is universal by
Lemma \ref{lemma-complexes-with-support-on-closed} part (3), we find that
the south-east arrow factors uniquely over the south-west arrow and
we obtain the desired arrow.
\end{remark}

\begin{lemma}
\label{lemma-support-functorial}
With notation and assumptions as in Remark \ref{remark-support-functorial}
the diagram
$$
\xymatrix{
H^p_Z(X, K) \ar[r] \ar[d] & H^p_{Z'}(X, Lf^*K) \ar[d] \\
H^p(X, K) \ar[r] & H^p(X', Lf^*K)
}
$$
commutes. Here the top horizontal arrow comes from the identifications
$H^p_Z(X, K) = H^p(Z, R\mathcal{H}_Z(K))$ and
$H^p_{Z'}(X', Lf^*K) = H^p(Z', R\mathcal{H}_{Z'}(K'))$,
the pullback map
$H^p(Z, R\mathcal{H}_Z(K)) \to H^p(Z', L(f|_{Z'})^*R\mathcal{H}_Z(K))$,
and the map constructed in Remark \ref{remark-support-functorial}.
\end{lemma}

\begin{proof}
Omitted. Hints:
Using that $H^p(Z, R\mathcal{H}_Z(K)) = H^p(X, i_*R\mathcal{H}_Z(K))$
and similarly for $R\mathcal{H}_{Z'}(Lf^*K)$ this follows from
the functoriality of the pullback maps and the commutative diagram
used to define the map of Remark \ref{remark-support-functorial}.
\end{proof}






\section{Inverse systems and cohomology}
\label{section-inverse-systems}

\noindent
We prove some results on inverse systems of sheaves of modules.

\begin{lemma}
\label{lemma-ML-general}
Let $I$ be an ideal of a ring $A$. Let $X$ be a topological space.
Let
$$
\ldots \to \mathcal{F}_3 \to \mathcal{F}_2 \to \mathcal{F}_1
$$
be an inverse system of sheaves of $A$-modules on $X$
such that $\mathcal{F}_n = \mathcal{F}_{n + 1}/I^n\mathcal{F}_{n + 1}$.
Let $p \geq 0$. Assume
$$
\bigoplus\nolimits_{n \geq 0} H^{p + 1}(X, I^n\mathcal{F}_{n + 1})
$$
satisfies the ascending chain condition as a graded
$\bigoplus_{n \geq 0} I^n/I^{n + 1}$-module.
Then the inverse system $M_n = H^p(X, \mathcal{F}_n)$ satisfies the
Mittag-Leffler condition\footnote{In fact, there exists
a $c \geq 0$ such that $\Im(M_n \to M_{n - c})$ is the stable image
for all $n \geq c$.}.
\end{lemma}

\begin{proof}
Set $N_n = H^{p + 1}(X, I^n\mathcal{F}_{n + 1})$ and let
$\delta_n : M_n \to N_n$ be the boundary map on cohomology
coming from the short exact sequence
$0 \to I^n\mathcal{F}_{n + 1} \to \mathcal{F}_{n + 1} \to \mathcal{F}_n \to 0$.
Then $\bigoplus \Im(\delta_n) \subset \bigoplus N_n$ is a graded submodule.
Namely, if $s \in M_n$ and $f \in I^m$, then we have a commutative diagram
$$
\xymatrix{
0 \ar[r] &
I^n\mathcal{F}_{n + 1} \ar[d]_f \ar[r] &
\mathcal{F}_{n + 1} \ar[d]_f \ar[r] &
\mathcal{F}_n \ar[d]_f \ar[r] & 0 \\
0 \ar[r] &
I^{n + m}\mathcal{F}_{n + m + 1} \ar[r] &
\mathcal{F}_{n + m + 1} \ar[r] &
\mathcal{F}_{n + m} \ar[r] & 0
}
$$
The middle vertical map is given by lifting a local section of
$\mathcal{F}_{n + 1}$ to a section of $\mathcal{F}_{n + m + 1}$
and then multiplying by $f$; similarly for the other vertical arrows.
We conclude that $\delta_{n + m}(fs) = f \delta_n(s)$.
By assumption we can find $s_j \in M_{n_j}$, $j = 1, \ldots, N$
such that $\delta_{n_j}(s_j)$
generate $\bigoplus \Im(\delta_n)$ as a graded module. Let $n > c = \max(n_j)$.
Let $s \in M_n$. Then we can find $f_j \in I^{n - n_j}$ such that
$\delta_n(s) = \sum f_j \delta_{n_j}(s_j)$. We conclude that
$\delta(s - \sum f_j s_j) = 0$, i.e., we can find $s' \in M_{n + 1}$
mapping to $s - \sum f_js_j$ in $M_n$. It follows that
$$
\Im(M_{n + 1} \to M_{n - c}) = \Im(M_n \to M_{n - c})
$$
Namely, the elements $f_js_j$ map to zero in $M_{n - c}$.
This proves the lemma.
\end{proof}

\begin{lemma}
\label{lemma-ML-general-better}
Let $I$ be an ideal of a ring $A$. Let $X$ be a topological space. Let
$$
\ldots \to \mathcal{F}_3 \to \mathcal{F}_2 \to \mathcal{F}_1
$$
be an inverse system of $A$-modules on $X$
such that $\mathcal{F}_n = \mathcal{F}_{n + 1}/I^n\mathcal{F}_{n + 1}$.
Let $p \geq 0$. Given $n$ define
$$
N_n =
\bigcap\nolimits_{m \geq n}
\Im\left(
H^{p + 1}(X, I^n\mathcal{F}_{m + 1}) \to H^{p + 1}(X, I^n\mathcal{F}_{n + 1})
\right)
$$
If $\bigoplus N_n$ satisfies the ascending chain condition as a graded
$\bigoplus_{n \geq 0} I^n/I^{n + 1}$-module, then the inverse system
$M_n = H^p(X, \mathcal{F}_n)$ satisfies the Mittag-Leffler
condition\footnote{In fact, there exists
a $c \geq 0$ such that $\Im(M_n \to M_{n - c})$ is the stable image
for all $n \geq c$.}.
\end{lemma}

\begin{proof}
The proof is exactly the same as the proof of Lemma \ref{lemma-ML-general}.
In fact, the result will follow from the arguments given there
as soon as we show that
$\bigoplus N_n$ is a graded $\bigoplus_{n \geq 0} I^n/I^{n + 1}$-submodule
of $\bigoplus H^{p + 1}(X, I^n\mathcal{F}_{n + 1})$
and that the boundary maps
$\delta_n : M_n \to H^{p + 1}(X, I^n\mathcal{F}_{n + 1})$
have image contained in $N_n$.

\medskip\noindent
Suppose that $\xi \in N_n$ and $f \in I^k$.
Choose $m \gg n + k$. Choose
$\xi' \in H^{p + 1}(X, I^n\mathcal{F}_{m + 1})$ lifting
$\xi$. We consider the diagram
$$
\xymatrix{
0 \ar[r] &
I^n\mathcal{F}_{m + 1} \ar[d]_f \ar[r] &
\mathcal{F}_{m + 1} \ar[d]_f \ar[r] &
\mathcal{F}_n \ar[d]_f \ar[r] & 0 \\
0 \ar[r] &
I^{n + k}\mathcal{F}_{m + 1} \ar[r] &
\mathcal{F}_{m + 1} \ar[r] &
\mathcal{F}_{n + k} \ar[r] & 0
}
$$
constructed as in the proof of Lemma \ref{lemma-ML-general}.
We get an induced map on cohomology and we see that
$f \xi' \in H^{p + 1}(X, I^{n + k}\mathcal{F}_{m + 1})$
maps to $f \xi$. Since this is true for all $m \gg n + k$
we see that $f\xi$ is in $N_{n + k}$ as desired.

\medskip\noindent
To see the boundary maps $\delta_n$ have image contained in $N_n$
we consider the diagrams
$$
\xymatrix{
0 \ar[r] &
I^n\mathcal{F}_{m + 1} \ar[d] \ar[r] &
\mathcal{F}_{m + 1} \ar[d] \ar[r] &
\mathcal{F}_n \ar[d] \ar[r] & 0 \\
0 \ar[r] &
I^n\mathcal{F}_{n + 1} \ar[r] &
\mathcal{F}_{n + 1} \ar[r] &
\mathcal{F}_n \ar[r] & 0
}
$$
for $m \geq n$. Looking at the induced maps on cohomology we conclude.
\end{proof}

\begin{lemma}
\label{lemma-topology-I-adic-general}
Let $I$ be an ideal of a ring $A$. Let $X$ be a topological space. Let
$$
\ldots \to \mathcal{F}_3 \to \mathcal{F}_2 \to \mathcal{F}_1
$$
be an inverse system of sheaves of $A$-modules on $X$ such that
$\mathcal{F}_n = \mathcal{F}_{n + 1}/I^n\mathcal{F}_{n + 1}$.
Let $p \geq 0$. Assume
$$
\bigoplus\nolimits_{n \geq 0} H^p(X, I^n\mathcal{F}_{n + 1})
$$
satisfies the ascending chain condition as a graded
$\bigoplus_{n \geq 0} I^n/I^{n + 1}$-module.
Then the limit topology on $M = \lim H^p(X, \mathcal{F}_n)$
is the $I$-adic topology.
\end{lemma}

\begin{proof}
Set $F^n = \Ker(M \to H^p(X, \mathcal{F}_n))$ for $n \geq 1$ and $F^0 = M$.
Observe that $I F^n \subset F^{n + 1}$. In particular $I^n M \subset F^n$.
Hence the $I$-adic topology is finer than the limit topology. For
the converse, we will show that given $n$
there exists an $m \geq n$ such that $F^m \subset I^nM$\footnote{In fact,
there exist a $c \geq 0$ such that $F^{n + c} \subset I^nM$ for all $n$.}.
We have injective maps
$$
F^n/F^{n + 1} \longrightarrow H^p(X, \mathcal{F}_{n + 1})
$$
whose image is contained in the image of
$H^p(X, I^n\mathcal{F}_{n + 1}) \to H^p(X, \mathcal{F}_{n + 1})$.
Denote
$$
E_n \subset H^p(X, I^n\mathcal{F}_{n + 1})
$$
the inverse image of $F^n/F^{n + 1}$. Then $\bigoplus E_n$ is
a graded $\bigoplus I^n/I^{n + 1}$-submodule of
$\bigoplus H^p(X, I^n\mathcal{F}_{n + 1})$ and
$\bigoplus E_n \to \bigoplus F^n/F^{n + 1}$ is a homomorphism of graded
modules; details omitted. By assumption $\bigoplus E_n$ is generated by
finitely many homogeneous elements over $\bigoplus I^n/I^{n + 1}$.
Since $E_n \to F^n/F^{n + 1}$ is surjective, we see that
the same thing is true of $\bigoplus F^n/F^{n + 1}$.
Hence we can find $r$ and $c_1, \ldots, c_r \geq 0$ and
$a_i \in F^{c_i}$ whose images in $\bigoplus F^n/F^{n + 1}$ generate.
Set $c = \max(c_i)$.

\medskip\noindent
For $n \geq c$ we claim that $I F^n = F^{n + 1}$. The claim shows that
$F^{n + c} = I^nF^c \subset I^nM$ as desired. To prove the claim
suppose $a \in F^{n + 1}$. The image of
$a$ in $F^{n + 1}/F^{n + 2}$ is a linear combination
of our $a_i$. Therefore $a  - \sum f_i a_i \in F^{n + 2}$
for some $f_i \in I^{n + 1 - c_i}$. Since
$I^{n + 1 - c_i} = I \cdot I^{n - c_i}$ as $n \geq c_i$ we can write
$f_i = \sum g_{i, j} h_{i, j}$ with $g_{i, j} \in I$
and $h_{i, j}a_i \in F^n$. Thus we see that
$F^{n + 1} = F^{n + 2} + IF^n$.
A simple induction argument gives $F^{n + 1} = F^{n + e} + IF^n$
for all $e > 0$. It follows that $IF^n$ is dense in $F^{n + 1}$.
Choose generators $k_1, \ldots, k_r$ of $I$ and consider
the continuous map
$$
u : (F^n)^{\oplus r} \longrightarrow F^{n + 1},\quad
(x_1, \ldots, x_r) \mapsto \sum k_i x_i
$$
(in the limit topology).
By the above the image of $(F^m)^{\oplus r}$ under $u$ is dense in
$F^{m + 1}$ for all $m \geq n$. By the open mapping lemma
(More on Algebra, Lemma \ref{more-algebra-lemma-open-mapping}) we find
that $u$ is open. Hence $u$ is surjective. Hence $IF^n = F^{n + 1}$
for $n \geq c$. This concludes the proof.
\end{proof}

\begin{lemma}
\label{lemma-topology-I-adic-general-better}
Let $I$ be an ideal of a ring $A$. Let $X$ be a topological space. Let
$$
\ldots \to \mathcal{F}_3 \to \mathcal{F}_2 \to \mathcal{F}_1
$$
be an inverse system of sheaves of $A$-modules on $X$ such that
$\mathcal{F}_n = \mathcal{F}_{n + 1}/I^n\mathcal{F}_{n + 1}$.
Let $p \geq 0$. Given $n$ define
$$
N_n =
\bigcap\nolimits_{m \geq n}
\Im\left(
H^p(X, I^n\mathcal{F}_{m + 1}) \to H^p(X, I^n\mathcal{F}_{n + 1})
\right)
$$
If $\bigoplus N_n$ satisfies the ascending chain condition as a graded
$\bigoplus_{n \geq 0} I^n/I^{n + 1}$-module, then
the limit topology on $M = \lim H^p(X, \mathcal{F}_n)$
is the $I$-adic topology.
\end{lemma}

\begin{proof}
The proof is exactly the same as the proof of
Lemma \ref{lemma-topology-I-adic-general}.
In fact, the result will follow from the arguments given there
as soon as we show that
$\bigoplus N_n$ is a graded $\bigoplus_{n \geq 0} I^n/I^{n + 1}$-submodule
of $\bigoplus H^{p + 1}(X, I^n\mathcal{F}_{n + 1})$
and that $F^n/F^{n + 1} \subset H^p(X, \mathcal{F}_{n + 1})$
is contained in the image of $N_n \to H^p(X, \mathcal{F}_{n + 1})$.
In the proof of Lemma \ref{lemma-ML-general-better}
we have seen the statement on the module structure.

\medskip\noindent
Let $t \in F^n$. Choose an element $s \in H^p(X, I^n\mathcal{F}_{n + 1})$
which maps to the image of $t$ in $H^p(X, \mathcal{F}_{n + 1})$. We have
to show that $s$ is in $N_n$. Now $F^n$ is the kernel of the map from
$M \to H^p(X, \mathcal{F}_n)$ hence for all $m \geq n$ we can map $t$
to an element $t_m \in H^p(X, \mathcal{F}_{m + 1})$ which maps to zero
in $H^p(X, \mathcal{F}_n)$. Consider the cohomology sequence
$$
H^{p - 1}(X, \mathcal{F}_n) \to
H^p(X, I^n\mathcal{F}_{m + 1}) \to
H^p(X, \mathcal{F}_{m + 1}) \to
H^p(X, \mathcal{F}_n)
$$
coming from the short exact sequence
$0 \to I^n\mathcal{F}_{m + 1} \to \mathcal{F}_{m + 1} \to \mathcal{F}_n \to 0$.
We can choose $s_m \in H^p(X, I^n\mathcal{F}_{m + 1})$ mapping to $t_m$.
Comparing the sequence above with the one for $m = n$ we see that
$s_m$ maps to $s$ up to an element in the image of
$H^{p - 1}(X, \mathcal{F}_n) \to H^p(X, I^n\mathcal{F}_{n + 1})$.
However, this map factors through the map
$H^p(X, I^n\mathcal{F}_{m + 1}) \to H^p(X, I^n\mathcal{F}_{n + 1})$
and we see that $s$ is in the image as desired.
\end{proof}







\section{Derived limits}
\label{section-derived-limits}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Since the triangulated category
$D(\mathcal{O}_X)$ has products
(Injectives, Lemma \ref{injectives-lemma-derived-products})
it follows that $D(\mathcal{O}_X)$ has derived limits, see
Derived Categories, Definition \ref{derived-definition-derived-limit}.
If $(K_n)$ is an inverse system in $D(\mathcal{O}_X)$ then we
denote $R\lim K_n$ the derived limit.

\begin{lemma}
\label{lemma-RGamma-commutes-with-Rlim}
Let $(X, \mathcal{O}_X)$ be a ringed space. For $U \subset X$ open the
functor $R\Gamma(U, -)$ commutes with $R\lim$. Moreover, there are
short exact sequences
$$
0 \to
R^1\lim H^{m - 1}(U, K_n) \to H^m(U, R\lim K_n) \to
\lim H^m(U, K_n) \to 0
$$
for any inverse system $(K_n)$ in $D(\mathcal{O}_X)$ and any $m \in \mathbf{Z}$.
\end{lemma}

\begin{proof}
The first statement follows from
Injectives, Lemma \ref{injectives-lemma-RF-commutes-with-Rlim}.
Then we may apply 
More on Algebra, Remark \ref{more-algebra-remark-compare-derived-limit}
to $R\lim R\Gamma(U, K_n) = R\Gamma(U, R\lim K_n)$ to get the short
exact sequences.
\end{proof}

\begin{lemma}
\label{lemma-Rf-commutes-with-Rlim}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of ringed
spaces. Then $Rf_*$ commutes with $R\lim$, i.e., $Rf_*$ commutes with
derived limits.
\end{lemma}

\begin{proof}
Let $(K_n)$ be an inverse system in $D(\mathcal{O}_X)$. Consider the defining
distinguished triangle
$$
R\lim K_n \to \prod K_n \to \prod K_n
$$
in $D(\mathcal{O}_X)$. Applying the exact functor $Rf_*$ we obtain
the distinguished triangle
$$
Rf_*(R\lim K_n) \to Rf_*\left(\prod K_n\right) \to Rf_*\left(\prod K_n\right)
$$
in $D(\mathcal{O}_Y)$. Thus we see that it suffices to prove that
$Rf_*$ commutes with products in the derived category (which are not just
given by products of complexes, see
Injectives, Lemma \ref{injectives-lemma-derived-products}).
However, since $Rf_*$ is a right adjoint by Lemma \ref{lemma-adjoint}
this follows formally (see
Categories, Lemma \ref{categories-lemma-adjoint-exact}).
Caution: Note that we cannot apply
Categories, Lemma \ref{categories-lemma-adjoint-exact}
directly as $R\lim K_n$ is not a limit in $D(\mathcal{O}_X)$.
\end{proof}

\begin{remark}
\label{remark-discuss-derived-limit}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(K_n)$ be an inverse
system in $D(\mathcal{O}_X)$. Set $K = R\lim K_n$. For each $n$ and $m$
let $\mathcal{H}^m_n = H^m(K_n)$ be the $m$th cohomology sheaf of
$K_n$ and similarly set $\mathcal{H}^m = H^m(K)$. Let us denote
$\underline{\mathcal{H}}^m_n$ the presheaf
$$
U \longmapsto \underline{\mathcal{H}}^m_n(U) = H^m(U, K_n)
$$
Similarly we set $\underline{\mathcal{H}}^m(U) = H^m(U, K)$.
By Lemma \ref{lemma-sheafification-cohomology} we see that
$\mathcal{H}^m_n$ is the sheafification of
$\underline{\mathcal{H}}^m_n$ and $\mathcal{H}^m$ is the
sheafification of $\underline{\mathcal{H}}^m$.
Here is a diagram
$$
\xymatrix{
K \ar@{=}[d] &
\underline{\mathcal{H}}^m \ar[d] \ar[r] & 
\mathcal{H}^m \ar[d] \\
R\lim K_n &
\lim \underline{\mathcal{H}}^m_n \ar[r] & 
\lim \mathcal{H}^m_n
}
$$
In general it may not be the case that
$\lim \mathcal{H}^m_n$ is the sheafification of
$\lim \underline{\mathcal{H}}^m_n$.
If $U \subset X$ is an open, then we have short exact
sequences
\begin{equation}
\label{equation-ses-Rlim-over-U}
0 \to
R^1\lim \underline{\mathcal{H}}^{m - 1}_n(U) \to
\underline{\mathcal{H}}^m(U) \to
\lim \underline{\mathcal{H}}^m_n(U) \to 0
\end{equation}
by Lemma \ref{lemma-RGamma-commutes-with-Rlim}.
\end{remark}

\noindent
The following lemma applies to an inverse system of quasi-coherent
modules with surjective transition maps on a scheme.

\begin{lemma}
\label{lemma-inverse-limit-is-derived-limit}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(\mathcal{F}_n)$ be an
inverse system of $\mathcal{O}_X$-modules. Let $\mathcal{B}$ be a set
of opens of $X$. Assume
\begin{enumerate}
\item every open of $X$ has a covering whose members are elements of
$\mathcal{B}$,
\item $H^p(U, \mathcal{F}_n) = 0$ for $p > 0$ and $U \in \mathcal{B}$,
\item the inverse system $\mathcal{F}_n(U)$ has vanishing $R^1\lim$
for $U \in \mathcal{B}$.
\end{enumerate}
Then $R\lim \mathcal{F}_n = \lim \mathcal{F}_n$ and we have
$H^p(U, \lim \mathcal{F}_n) = 0$ for $p > 0$ and $U \in \mathcal{B}$.
\end{lemma}

\begin{proof}
Set $K_n = \mathcal{F}_n$ and $K = R\lim \mathcal{F}_n$. Using the notation
of Remark \ref{remark-discuss-derived-limit} and assumption (2) we see that for
$U \in \mathcal{B}$ we have $\underline{\mathcal{H}}_n^m(U) = 0$
when $m \not = 0$ and $\underline{\mathcal{H}}_n^0(U) = \mathcal{F}_n(U)$.
From Equation (\ref{equation-ses-Rlim-over-U}) and assumption (3)
we see that $\underline{\mathcal{H}}^m(U) = 0$
when $m \not = 0$ and equal to $\lim \mathcal{F}_n(U)$
when $m = 0$. Sheafifying using (1) we find that
$\mathcal{H}^m = 0$ when $m \not = 0$ and equal to
$\lim \mathcal{F}_n$ when $m = 0$. Hence $K = \lim \mathcal{F}_n$.
Since $H^m(U, K) = \underline{\mathcal{H}}^m(U) = 0$ for $m > 0$
(see above) we see that the second assertion holds.
\end{proof}

\begin{lemma}
\label{lemma-cohomology-derived-limit-injective}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(K_n)$ be an
inverse system in $D(\mathcal{O}_X)$. Let $x \in X$ and $m \in \mathbf{Z}$.
Assume there exist an integer $n(x)$ and a fundamental system $\mathfrak{U}_x$
of open neighbourhoods of $x$ such that for $U \in \mathfrak{U}_x$
\begin{enumerate}
\item $R^1\lim H^{m - 1}(U, K_n) = 0$, and
\item $H^m(U, K_n) \to H^m(U, K_{n(x)})$ is injective
for $n \geq n(x)$.
\end{enumerate}
Then the map on stalks $H^m(R\lim K_n)_x \to H^m(K_{n(x)})_x$ is injective.
\end{lemma}

\begin{proof}
Let $\gamma$ be an element of $H^m(R\lim K_n)_x$ which maps to zero
in $H^m(K_{n(x)})_x$. Since $H^m(R\lim K_n)$ is the sheafification
of $U \mapsto H^m(U, R\lim K_n)$
(by Lemma \ref{lemma-sheafification-cohomology})
we can choose $U \in \mathfrak{U}_x$
and an element $\tilde \gamma \in H^m(U, R\lim K_n)$ mapping to $\gamma$.
Then $\tilde\gamma$ maps to $\tilde\gamma_{n(x)} \in H^m(U, K_{n(x)})$.
Using that $H^m(K_{n(x)})$ is the sheafification of
$U \mapsto H^m(U, K_{n(x)})$
(by Lemma \ref{lemma-sheafification-cohomology} again)
we see that after shrinking $U$ we may assume that $\tilde\gamma_{n(x)} = 0$.
For this $U$ we consider the short exact sequence
$$
0 \to
R^1\lim H^{m - 1}(U, K_n) \to H^m(U, R\lim K_n) \to
\lim H^m(U, K_n) \to 0
$$
of Lemma \ref{lemma-RGamma-commutes-with-Rlim}.
By assumption (1) the group on the left is zero and by
assumption (2) the group on the right maps injectively
into $H^m(U, K_{n(x)})$. We conclude $\tilde\gamma = 0$
and hence $\gamma = 0$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-is-limit-per-point}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $E \in D(\mathcal{O}_X)$.
Assume that for every $x \in X$ there exist
a function $p(x, -) : \mathbf{Z} \to \mathbf{Z}$ and
a fundamental system $\mathfrak{U}_x$ of open neighbourhoods of $x$
such that
$$
H^p(U, H^{m - p}(E)) = 0 \text{ for }
U \in \mathfrak{U}_x \text{ and } p > p(x, m)
$$
Then the canonical map $E \to R\lim \tau_{\geq -n} E$
is an isomorphism in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Set $K_n = \tau_{\geq -n}E$ and $K = R\lim K_n$.
The canonical map $E \to K$
comes from the canonical maps $E \to K_n = \tau_{\geq -n}E$.
We have to show that $E \to K$ induces an isomorphism
$H^m(E) \to H^m(K)$ of cohomology sheaves. In the rest of the
proof we fix $m$. If $n \geq -m$, then
the map $E \to \tau_{\geq -n}E = K_n$ induces an isomorphism
$H^m(E) \to H^m(K_n)$.
To finish the proof it suffices to show that for every $x \in X$
there exists an integer $n(x) \geq -m$ such that the map
$H^m(K)_x \to H^m(K_{n(x)})_x$ is injective. Namely, then
the composition
$$
H^m(E)_x \to H^m(K)_x \to H^m(K_{n(x)})_x
$$
is a bijection and the second arrow is injective, hence the
first arrow is bijective. Set
$$
n(x) = 1 + \max\{-m, p(x, m - 1) - m, -1 + p(x, m) - m, -2 + p(x, m + 1) - m\}.
$$
so that in any case $n(x) \geq -m$. Claim: the maps
$$
H^{m - 1}(U, K_{n + 1}) \to H^{m - 1}(U, K_n)
\quad\text{and}\quad
H^m(U, K_{n + 1}) \to H^m(U, K_n)
$$
are isomorphisms for $n \geq n(x)$ and $U \in \mathfrak{U}_x$.
The claim implies conditions
(1) and (2) of Lemma \ref{lemma-cohomology-derived-limit-injective}
are satisfied and hence implies the desired injectivity.
Recall (Derived Categories, Remark
\ref{derived-remark-truncation-distinguished-triangle})
that we have distinguished triangles
$$
H^{-n - 1}(E)[n + 1] \to
K_{n + 1} \to K_n \to H^{-n - 1}(E)[n + 2]
$$
Looking at the asssociated long exact cohomology sequence the claim follows if
$$
H^{m + n}(U, H^{-n - 1}(E)),\quad
H^{m + n + 1}(U, H^{-n - 1}(E)),\quad
H^{m + n + 2}(U, H^{-n - 1}(E))
$$
are zero for $n \geq n(x)$ and $U \in \mathfrak{U}_x$.
This follows from our choice of $n(x)$
and the assumption in the lemma.
\end{proof}

\begin{lemma}
\label{lemma-is-limit-spaltenstein}
\begin{reference}
\cite[Proposition 3.13]{Spaltenstein}
\end{reference}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $E \in D(\mathcal{O}_X)$.
Assume that for every $x \in X$ there exist an integer $d_x \geq 0$ and
a fundamental system $\mathfrak{U}_x$ of open neighbourhoods of $x$
such that
$$
H^p(U, H^q(E)) = 0 \text{ for }
U \in \mathfrak{U}_x,\ p > d_x, \text{ and }q < 0
$$
Then the canonical map $E \to R\lim \tau_{\geq -n} E$
is an isomorphism in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This follows from Lemma \ref{lemma-is-limit-per-point}
with $p(x, m) = d_x + \max(0, m)$.
\end{proof}

\begin{lemma}
\label{lemma-is-limit}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $E \in D(\mathcal{O}_X)$.
Assume there exist a function $p(-) : \mathbf{Z} \to \mathbf{Z}$
and a set $\mathcal{B}$ of opens of $X$ such that
\begin{enumerate}
\item every open in $X$ has a covering whose members are
elements of $\mathcal{B}$, and
\item $H^p(U, H^{m - p}(E)) = 0$ for $p > p(m)$ and $U \in \mathcal{B}$.
\end{enumerate}
Then the canonical map $E \to R\lim \tau_{\geq -n} E$
is an isomorphism in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Apply Lemma \ref{lemma-is-limit-per-point}
with $p(x, m) = p(m)$ and
$\mathfrak{U}_x = \{U \in \mathcal{B} \mid x \in U\}$.
\end{proof}

\begin{lemma}
\label{lemma-is-limit-dimension}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $E \in D(\mathcal{O}_X)$.
Assume there exist an integer $d \geq 0$ and a basis $\mathcal{B}$ for the
topology of $X$ such that
$$
H^p(U, H^q(E)) = 0 \text{ for }
U \in \mathcal{B},\ p > d, \text{ and }q < 0
$$
Then the canonical map $E \to R\lim \tau_{\geq -n} E$
is an isomorphism in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Apply Lemma \ref{lemma-is-limit-spaltenstein} with $d_x = d$
and $\mathfrak{U}_x = \{U \in \mathcal{B} \mid x \in U\}$.
\end{proof}

\noindent
The lemmas above can be used to compute cohomology
in certain situations.

\begin{lemma}
\label{lemma-cohomology-over-U-trivial}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K$
be an object of $D(\mathcal{O}_X)$.
Let $\mathcal{B}$ be a set of opens of $X$. Assume
\begin{enumerate}
\item every open of $X$ has a covering whose members are
elements of $\mathcal{B}$,
\item $H^p(U, H^q(K)) = 0$ for all $p > 0$, $q \in \mathbf{Z}$, and
$U \in \mathcal{B}$.
\end{enumerate}
Then $H^q(U, K) = H^0(U, H^q(K))$ for $q \in \mathbf{Z}$
and $U \in \mathcal{B}$.
\end{lemma}

\begin{proof}
Observe that $K = R\lim \tau_{\geq -n} K$ by
Lemma \ref{lemma-is-limit-dimension} with $d = 0$.
Let $U \in \mathcal{B}$. By Equation (\ref{equation-ses-Rlim-over-U})
we get a short exact sequence
$$
0 \to R^1\lim H^{q - 1}(U, \tau_{\geq -n}K) \to
H^q(U, K) \to \lim H^q(U, \tau_{\geq -n}K) \to 0
$$
Condition (2) implies
$H^q(U, \tau_{\geq -n} K) = H^0(U, H^q(\tau_{\geq -n} K))$
for all $q$ by using the spectral sequence of
Example \ref{example-spectral-sequence}.
The spectral sequence converges because $\tau_{\geq -n}K$ is bounded
below. If $n > -q$ then we have $H^q(\tau_{\geq -n}K) = H^q(K)$.
Thus the systems on the left and the right of the displayed
short exact sequence are eventually constant with values
$H^0(U, H^{q - 1}(K))$ and $H^0(U, H^q(K))$. The lemma follows.
\end{proof}

\noindent
Here is another case where we can describe the derived limit.

\begin{lemma}
\label{lemma-derived-limit-suitable-system}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(K_n)$
be an inverse system of objects of $D(\mathcal{O}_X)$.
Let $\mathcal{B}$ be a set of opens of $X$. Assume
\begin{enumerate}
\item every open of $X$ has a covering whose members are
elements of $\mathcal{B}$,
\item for all $U \in \mathcal{B}$ and all $q \in \mathbf{Z}$ we have
\begin{enumerate}
\item $H^p(U, H^q(K_n)) = 0$ for $p > 0$,
\item the inverse system $H^0(U, H^q(K_n))$ has vanishing $R^1\lim$.
\end{enumerate}
\end{enumerate}
Then $H^q(R\lim K_n) = \lim H^q(K_n)$ for $q \in \mathbf{Z}$.
\end{lemma}

\begin{proof}
Set $K = R\lim K_n$. We will use notation as in
Remark \ref{remark-discuss-derived-limit}. Let $U \in \mathcal{B}$.
By Lemma \ref{lemma-cohomology-over-U-trivial} and (2)(a)
we have $H^q(U, K_n) = H^0(U, H^q(K_n))$.
Using that the functor $R\Gamma(U, -)$ commutes with
derived limits we have
$$
H^q(U, K) = H^q(R\lim R\Gamma(U, K_n)) = \lim H^0(U, H^q(K_n))
$$
where the final equality follows from
More on Algebra, Remark \ref{more-algebra-remark-compare-derived-limit}
and assumption (2)(b). Thus $H^q(U, K)$ is the inverse limit
the sections of the sheaves $H^q(K_n)$ over $U$. Since
$\lim H^q(K_n)$ is a sheaf we find using assumption (1) that $H^q(K)$,
which is the sheafification of the presheaf $U \mapsto H^q(U, K)$,
is equal to $\lim H^q(K_n)$. This proves the lemma.
\end{proof}








\section{Producing K-injective resolutions}
\label{section-K-injective}


\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{F}^\bullet$ be a complex of $\mathcal{O}_X$-modules.
The category $\textit{Mod}(\mathcal{O}_X)$ has enough injectives, hence
we can use
Derived Categories, Lemma \ref{derived-lemma-special-inverse-system}
produce a diagram
$$
\xymatrix{
\ldots \ar[r] &
\tau_{\geq -2}\mathcal{F}^\bullet \ar[r] \ar[d] &
\tau_{\geq -1}\mathcal{F}^\bullet \ar[d] \\
\ldots \ar[r] & \mathcal{I}_2^\bullet \ar[r] & \mathcal{I}_1^\bullet
}
$$
in the category of complexes of $\mathcal{O}_X$-modules such that
\begin{enumerate}
\item the vertical arrows are quasi-isomorphisms,
\item $\mathcal{I}_n^\bullet$ is a bounded below complex of injectives,
\item the arrows $\mathcal{I}_{n + 1}^\bullet \to \mathcal{I}_n^\bullet$
are termwise split surjections.
\end{enumerate}
The category of $\mathcal{O}_X$-modules has limits (they are computed
on the level of presheaves), hence we can form the termwise limit
$\mathcal{I}^\bullet = \lim_n \mathcal{I}_n^\bullet$. By
Derived Categories, Lemmas
\ref{derived-lemma-bounded-below-injectives-K-injective} and
\ref{derived-lemma-limit-K-injectives}
this is a K-injective complex. In general the canonical map
\begin{equation}
\label{equation-into-candidate-K-injective}
\mathcal{F}^\bullet \to \mathcal{I}^\bullet
\end{equation}
may not be a quasi-isomorphism. In the following lemma we describe some
conditions under which it is.

\begin{lemma}
\label{lemma-K-injective}
In the situation described above.
Denote $\mathcal{H}^m = H^m(\mathcal{F}^\bullet)$ the $m$th cohomology sheaf.
Let $\mathcal{B}$ be a set of open subsets of $X$.
Let $d \in \mathbf{N}$.
Assume
\begin{enumerate}
\item every open in $X$ has a covering whose members are
elements of $\mathcal{B}$,
\item for every $U \in \mathcal{B}$ we have $H^p(U, \mathcal{H}^q) = 0$
for $p > d$ and $q < 0$\footnote{It suffices if
$\forall m$, $\exists p(m)$, $H^p(U. \mathcal{H}^{m - p}) = 0$ for
$p > p(m)$, see Lemma \ref{lemma-is-limit}.}.
\end{enumerate}
Then (\ref{equation-into-candidate-K-injective}) is a quasi-isomorphism.
\end{lemma}

\begin{proof}
By Derived Categories, Lemma \ref{derived-lemma-difficulty-K-injectives}
it suffices to show that the canonical map
$\mathcal{F}^\bullet \to R\lim \tau_{\geq -n} \mathcal{F}^\bullet$
is an isomorphism. This is Lemma \ref{lemma-is-limit-dimension}.
\end{proof}

\noindent
Here is a technical lemma about the cohomology sheaves of the inverse
limit of a system of complexes of sheaves. In some sense this lemma
is the wrong thing to try to prove as one should take derived
limits and not actual inverse limits.

\begin{lemma}
\label{lemma-inverse-limit-complexes}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(\mathcal{F}_n^\bullet)$
be an inverse system of complexes of $\mathcal{O}_X$-modules.
Let $m \in \mathbf{Z}$. Assume there exist a set $\mathcal{B}$
of open subsets of $X$ and an integer $n_0$ such that
\begin{enumerate}
\item every open in $X$ has a covering whose members are
elements of $\mathcal{B}$,
\item for every $U \in \mathcal{B}$
\begin{enumerate}
\item the systems of abelian groups
$\mathcal{F}_n^{m - 2}(U)$ and $\mathcal{F}_n^{m - 1}(U)$
have vanishing $R^1\lim$ (for example these have the Mittag-Leffler
condition),
\item the system of abelian groups $H^{m - 1}(\mathcal{F}_n^\bullet(U))$
has vanishing $R^1\lim$ (for example it has the Mittag-Leffler condition), and
\item we have
$H^m(\mathcal{F}_n^\bullet(U)) = H^m(\mathcal{F}_{n_0}^\bullet(U))$
for all $n \geq n_0$.
\end{enumerate}
\end{enumerate}
Then the maps
$H^m(\mathcal{F}^\bullet) \to \lim H^m(\mathcal{F}_n^\bullet) \to
H^m(\mathcal{F}_{n_0}^\bullet)$
are isomorphisms of sheaves where
$\mathcal{F}^\bullet = \lim \mathcal{F}_n^\bullet$ is the termwise
inverse limit.
\end{lemma}

\begin{proof}
Let $U \in \mathcal{B}$. Note that $H^m(\mathcal{F}^\bullet(U))$ is the
cohomology of
$$
\lim_n \mathcal{F}_n^{m - 2}(U) \to
\lim_n \mathcal{F}_n^{m - 1}(U) \to
\lim_n \mathcal{F}_n^m(U) \to
\lim_n \mathcal{F}_n^{m + 1}(U)
$$
in the third spot from the left. By assumptions (2)(a) and (2)(b)
we may apply
More on Algebra, Lemma \ref{more-algebra-lemma-apply-Mittag-Leffler-again}
to conclude that
$$
H^m(\mathcal{F}^\bullet(U)) = \lim H^m(\mathcal{F}_n^\bullet(U))
$$
By assumption (2)(c) we conclude
$$
H^m(\mathcal{F}^\bullet(U)) = H^m(\mathcal{F}_n^\bullet(U))
$$
for all $n \geq n_0$. By assumption (1) we conclude that the sheafification of
$U \mapsto H^m(\mathcal{F}^\bullet(U))$ is equal to the sheafification
of $U \mapsto H^m(\mathcal{F}_n^\bullet(U))$ for all $n \geq n_0$.
Thus the inverse system of sheaves $H^m(\mathcal{F}_n^\bullet)$ is
constant for $n \geq n_0$ with value $H^m(\mathcal{F}^\bullet)$ which
proves the lemma.
\end{proof}











\section{{\v C}ech cohomology of unbounded complexes}
\label{section-cech-cohomology-of-unbounded-complexes}

\noindent
The construction of Section \ref{section-cech-cohomology-of-complexes}
isn't the ``correct'' one for unbounded complexes. The problem is that
in the Stacks project we use direct sums in the totalization of a
double complex and we would have to replace this by a product. Instead
of doing so in this section we assume the covering is finite and
we use the alternating {\v C}ech complex.

\medskip\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let ${\mathcal F}^\bullet$ be a complex of presheaves of
$\mathcal{O}_X$-modules. Let ${\mathcal U} : X = \bigcup_{i \in I} U_i$
be a {\bf finite} open covering of $X$. Since the alternating
{\v C}ech complex
$\check{\mathcal{C}}_{alt}^\bullet(\mathcal{U}, \mathcal{F})$
(Section \ref{section-alternating-cech})
is functorial in the presheaf $\mathcal{F}$ we obtain a double complex
$\check{\mathcal{C}}^\bullet_{alt}(\mathcal{U}, \mathcal{F}^\bullet)$.
In this section we work with the associated total complex.
The construction of
$\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}({\mathcal U},
{\mathcal F}^\bullet))$
is functorial in ${\mathcal F}^\bullet$. As well there is a functorial
transformation
\begin{equation}
\label{equation-global-sections-to-alternating-cech}
\Gamma(X, {\mathcal F}^\bullet)
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}({\mathcal U},
{\mathcal F}^\bullet))
\end{equation}
of complexes defined by the following rule: The section
$s\in \Gamma(X, {\mathcal F}^n)$
is mapped to the element $\alpha = \{\alpha_{i_0\ldots i_p}\}$
with $\alpha_{i_0} = s|_{U_{i_0}}$ and $\alpha_{i_0\ldots i_p} = 0$
for $p > 0$.

\begin{lemma}
\label{lemma-alternating-cech-complex-complex}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{U} : X = \bigcup_{i \in I} U_i$ be
a finite open covering. For a complex $\mathcal{F}^\bullet$
of $\mathcal{O}_X$-modules there is a canonical map
$$
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}(\mathcal{U}, \mathcal{F}^\bullet))
\longrightarrow
R\Gamma(X, \mathcal{F}^\bullet)
$$
functorial in $\mathcal{F}^\bullet$ and compatible with
(\ref{equation-global-sections-to-alternating-cech}).
\end{lemma}

\begin{proof}
Let ${\mathcal I}^\bullet$ be a K-injective complex whose terms
are injective $\mathcal{O}_X$-modules.
The map (\ref{equation-global-sections-to-alternating-cech}) for
$\mathcal{I}^\bullet$ is a map
$\Gamma(X, {\mathcal I}^\bullet) \to
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}({\mathcal U},
{\mathcal I}^\bullet))$.
This is a quasi-isomorphism of complexes of abelian groups
as follows from
Homology, Lemma \ref{homology-lemma-double-complex-gives-resolution}
applied to the double complex
$\check{\mathcal{C}}^\bullet_{alt}({\mathcal U},
{\mathcal I}^\bullet)$ using
Lemmas \ref{lemma-injective-trivial-cech} and \ref{lemma-alternating-usual}.
Suppose ${\mathcal F}^\bullet \to {\mathcal I}^\bullet$ is a quasi-isomorphism
of ${\mathcal F}^\bullet$ into a K-injective complex whose terms
are injectives (Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}).
Since $R\Gamma(X, {\mathcal F}^\bullet)$ is represented by the complex
$\Gamma(X, {\mathcal I}^\bullet)$ we obtain the map of the lemma
using
$$
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}({\mathcal U},
{\mathcal F}^\bullet))
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}({\mathcal U},
{\mathcal I}^\bullet)).
$$
We omit the verification of functoriality and compatibilities.
\end{proof}

\begin{lemma}
\label{lemma-alternating-cech-complex-complex-ss}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{U} : X = \bigcup_{i \in I} U_i$ be a finite open covering. Let
$\mathcal{F}^\bullet$ be a complex of $\mathcal{O}_X$-modules.
Let $\mathcal{B}$ be a set of open subsets of $X$. Assume
\begin{enumerate}
\item every open in $X$ has a covering whose members are
elements of $\mathcal{B}$,
\item we have $U_{i_0\ldots i_p} \in \mathcal{B}$ for all
$i_0, \ldots, i_p \in I$,
\item for every $U \in \mathcal{B}$ and $p > 0$ we have
\begin{enumerate}
\item $H^p(U, \mathcal{F}^q) = 0$,
\item $H^p(U, \Coker(\mathcal{F}^{q - 1} \to \mathcal{F}^q)) = 0$, and
\item $H^p(U, H^q(\mathcal{F})) = 0$.
\end{enumerate}
\end{enumerate}
Then the map
$$
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}(\mathcal{U}, \mathcal{F}^\bullet))
\longrightarrow
R\Gamma(X, \mathcal{F}^\bullet)
$$
of Lemma \ref{lemma-alternating-cech-complex-complex}
is an isomorphism in $D(\textit{Ab})$.
\end{lemma}

\begin{proof}
First assume $\mathcal{F}^\bullet$ is bounded below. In this case the map
$$
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}(\mathcal{U}, \mathcal{F}^\bullet))
\longrightarrow
\text{Tot}(\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet))
$$
is a quasi-isomorphism by Lemma \ref{lemma-alternating-usual}.
Namely, the map of double complexes
$\check{\mathcal{C}}^\bullet_{alt}(\mathcal{U}, \mathcal{F}^\bullet) \to
\check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{F}^\bullet)$
induces an isomorphism between the first pages of the second spectral sequences
associated to these complexes
(by Homology, Lemma \ref{homology-lemma-ss-double-complex})
and these spectral sequences converge
(Homology, Lemma \ref{homology-lemma-first-quadrant-ss}).
Thus the conclusion in this case by
Lemma \ref{lemma-cech-complex-complex-computes} and assumption (3)(a).

\medskip\noindent
In general, by assumption (3)(c) we may choose a resolution
$\mathcal{F}^\bullet \to \mathcal{I}^\bullet = \lim \mathcal{I}_n^\bullet$
as in Lemma \ref{lemma-K-injective}.
Then the map of the lemma becomes
$$
\lim_n 
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}(\mathcal{U},
\tau_{\geq -n}\mathcal{F}^\bullet))
\longrightarrow
\Gamma(X, \mathcal{I}^\bullet) =
\lim_n \Gamma(X, \mathcal{I}_n^\bullet)
$$
Here the arrow is in the derived category, but the equality on the
right holds on the level of complexes.
Note that (3)(b) shows that $\tau_{\geq -n}\mathcal{F}^\bullet$
is a bounded below complex satisfying the hypothesis of the lemma.
Thus the case of bounded below complexes shows each of the maps
$$
\text{Tot}(\check{\mathcal{C}}^\bullet_{alt}(\mathcal{U},
\tau_{\geq -n}\mathcal{F}^\bullet))
\longrightarrow
\Gamma(X, \mathcal{I}_n^\bullet)
$$
is a quasi-isomorphism. The cohomologies of the complexes on the left
hand side in given degree are eventually
constant (as the alternating {\v C}ech complex is finite).
Hence the same is true on the right hand side.
Thus the cohomology of the limit on the right hand side is
this constant value by
Homology, Lemma \ref{homology-lemma-apply-Mittag-Leffler-again}
(or the stronger More on Algebra, Lemma
\ref{more-algebra-lemma-apply-Mittag-Leffler-again})
and we win.
\end{proof}






\section{Hom complexes}
\label{section-hom-complexes}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{L}^\bullet$ and $\mathcal{M}^\bullet$ be two complexes
of $\mathcal{O}_X$-modules. We construct a complex
of $\mathcal{O}_X$-modules
$\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{M}^\bullet)$.
Namely, for each $n$ we set
$$
\SheafHom^n(\mathcal{L}^\bullet, \mathcal{M}^\bullet) =
\prod\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{L}^{-q}, \mathcal{M}^p)
$$
It is a good idea to think of $\SheafHom^n$ as the
sheaf of $\mathcal{O}_X$-modules of all $\mathcal{O}_X$-linear
maps from $\mathcal{L}^\bullet$ to $\mathcal{M}^\bullet$
(viewed as graded $\mathcal{O}_X$-modules) which are homogenous
of degree $n$. In this terminology, we define the differential by the rule
$$
\text{d}(f) =
\text{d}_\mathcal{M} \circ f - (-1)^n f \circ \text{d}_\mathcal{L}
$$
for
$f \in \SheafHom^n_{\mathcal{O}_X}(\mathcal{L}^\bullet, \mathcal{M}^\bullet)$.
We omit the verification that $\text{d}^2 = 0$.
This construction is a special case of
Differential Graded Algebra, Example \ref{dga-example-category-complexes}.
It follows immediately from the construction that we have
\begin{equation}
\label{equation-cohomology-hom-complex}
H^n(\Gamma(U, \SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{M}^\bullet))) =
\Hom_{K(\mathcal{O}_U)}(\mathcal{L}^\bullet, \mathcal{M}^\bullet[n])
\end{equation}
for all $n \in \mathbf{Z}$ and every open $U \subset X$.

\begin{lemma}
\label{lemma-compose}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Given complexes $\mathcal{K}^\bullet, \mathcal{L}^\bullet, \mathcal{M}^\bullet$
of $\mathcal{O}_X$-modules there is an isomorphism
$$
\SheafHom^\bullet(\mathcal{K}^\bullet,
\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{M}^\bullet))
=
\SheafHom^\bullet(\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}
\mathcal{L}^\bullet), \mathcal{M}^\bullet)
$$
of complexes of $\mathcal{O}_X$-modules functorial in
$\mathcal{K}^\bullet, \mathcal{L}^\bullet, \mathcal{M}^\bullet$.
\end{lemma}

\begin{proof}
Omitted. Hint: This is proved in exactly the same way as
More on Algebra, Lemma \ref{more-algebra-lemma-compose}.
\end{proof}

\begin{lemma}
\label{lemma-composition}
Let $(X, \mathcal{O}_X)$ be a ringed space. Given complexes
$\mathcal{K}^\bullet, \mathcal{L}^\bullet, \mathcal{M}^\bullet$
of $\mathcal{O}_X$-modules there is a canonical morphism
$$
\text{Tot}\left(
\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{M}^\bullet)
\otimes_{\mathcal{O}_X}
\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{L}^\bullet)
\right)
\longrightarrow
\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{M}^\bullet)
$$
of complexes of $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
Omitted. Hint: This is proved in exactly the same way as
More on Algebra, Lemma \ref{more-algebra-lemma-composition}.
\end{proof}

\begin{lemma}
\label{lemma-diagonal-better}
Let $(X, \mathcal{O}_X)$ be a ringed space. Given complexes
$\mathcal{K}^\bullet, \mathcal{L}^\bullet, \mathcal{M}^\bullet$
of $\mathcal{O}_X$-modules there is a canonical morphism
$$
\text{Tot}\left(
\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}
\SheafHom^\bullet(\mathcal{M}^\bullet, \mathcal{L}^\bullet)
\right)
\longrightarrow
\SheafHom^\bullet(\mathcal{M}^\bullet,
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet))
$$
of complexes of $\mathcal{O}_X$-modules functorial in all three complexes.
\end{lemma}

\begin{proof}
Omitted. Hint: This is proved in exactly the same way as
More on Algebra, Lemma \ref{more-algebra-lemma-diagonal-better}.
\end{proof}

\begin{lemma}
\label{lemma-diagonal}
Let $(X, \mathcal{O}_X)$ be a ringed space. Given complexes
$\mathcal{K}^\bullet, \mathcal{L}^\bullet$
of $\mathcal{O}_X$-modules there is a canonical morphism
$$
\mathcal{K}^\bullet
\longrightarrow
\SheafHom^\bullet(\mathcal{L}^\bullet,
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet))
$$
of complexes of $\mathcal{O}_X$-modules functorial in both complexes.
\end{lemma}

\begin{proof}
Omitted. Hint: This is proved in exactly the same way as
More on Algebra, Lemma \ref{more-algebra-lemma-diagonal}.
\end{proof}

\begin{lemma}
\label{lemma-evaluate-and-more}
Let $(X, \mathcal{O}_X)$ be a ringed space. Given complexes
$\mathcal{K}^\bullet, \mathcal{L}^\bullet, \mathcal{M}^\bullet$
of $\mathcal{O}_X$-modules there is a canonical morphism
$$
\text{Tot}(\SheafHom^\bullet(\mathcal{L}^\bullet,
\mathcal{M}^\bullet) \otimes_{\mathcal{O}_X} \mathcal{K}^\bullet)
\longrightarrow
\SheafHom^\bullet(\SheafHom^\bullet(\mathcal{K}^\bullet,
\mathcal{L}^\bullet), \mathcal{M}^\bullet)
$$
of complexes of $\mathcal{O}_X$-modules functorial in all three complexes.
\end{lemma}

\begin{proof}
Omitted. Hint: This is proved in exactly the same way as
More on Algebra, Lemma \ref{more-algebra-lemma-evaluate-and-more}.
\end{proof}

\begin{lemma}
\label{lemma-RHom-into-K-injective}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{I}^\bullet$
be a K-injective complex of $\mathcal{O}_X$-modules. Let
$\mathcal{L}^\bullet$ be a complex of $\mathcal{O}_X$-modules.
Then
$$
H^0(\Gamma(U, \SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet))) =
\Hom_{D(\mathcal{O}_U)}(L|_U, M|_U)
$$
for all $U \subset X$ open.
\end{lemma}

\begin{proof}
We have
\begin{align*}
H^0(\Gamma(U, \SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet)))
& =
\Hom_{K(\mathcal{O}_U)}(L|_U, M|_U) \\
& =
\Hom_{D(\mathcal{O}_U)}(L|_U, M|_U)
\end{align*}
The first equality is (\ref{equation-cohomology-hom-complex}).
The second equality is true because $\mathcal{I}^\bullet|_U$
is K-injective by Lemma \ref{lemma-restrict-K-injective-to-open}.
\end{proof}

\begin{lemma}
\label{lemma-RHom-well-defined}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$(\mathcal{I}')^\bullet \to \mathcal{I}^\bullet$
be a quasi-isomorphism of K-injective complexes of $\mathcal{O}_X$-modules.
Let $(\mathcal{L}')^\bullet \to \mathcal{L}^\bullet$
be a quasi-isomorphism of complexes of $\mathcal{O}_X$-modules.
Then
$$
\SheafHom^\bullet(\mathcal{L}^\bullet, (\mathcal{I}')^\bullet)
\longrightarrow
\SheafHom^\bullet((\mathcal{L}')^\bullet, \mathcal{I}^\bullet)
$$
is a quasi-isomorphism.
\end{lemma}

\begin{proof}
Let $M$ be the object of $D(\mathcal{O}_X)$ represented by
$\mathcal{I}^\bullet$ and $(\mathcal{I}')^\bullet$.
Let $L$ be the object of $D(\mathcal{O}_X)$ represented by
$\mathcal{L}^\bullet$ and $(\mathcal{L}')^\bullet$.
By Lemma \ref{lemma-RHom-into-K-injective}
we see that the sheaves
$$
H^0(\SheafHom^\bullet(\mathcal{L}^\bullet, (\mathcal{I}')^\bullet))
\quad\text{and}\quad
H^0(\SheafHom^\bullet((\mathcal{L}')^\bullet, \mathcal{I}^\bullet))
$$
are both equal to the sheaf associated to the presheaf
$$
U \longmapsto \Hom_{D(\mathcal{O}_U)}(L|_U, M|_U)
$$
Thus the map is a quasi-isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-RHom-from-K-flat-into-K-injective}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{I}^\bullet$
be a K-injective complex of $\mathcal{O}_X$-modules. Let
$\mathcal{L}^\bullet$ be a K-flat complex of $\mathcal{O}_X$-modules.
Then $\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet)$
is a K-injective complex of $\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
Namely, if $\mathcal{K}^\bullet$ is an acyclic complex of
$\mathcal{O}_X$-modules, then
\begin{align*}
\Hom_{K(\mathcal{O}_X)}(\mathcal{K}^\bullet,
\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet))
& =
H^0(\Gamma(X,
\SheafHom^\bullet(\mathcal{K}^\bullet,
\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet)))) \\
& =
H^0(\Gamma(X, \SheafHom^\bullet(\text{Tot}(
\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet),
\mathcal{I}^\bullet))) \\
& =
\Hom_{K(\mathcal{O}_X)}(
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet),
\mathcal{I}^\bullet) \\
& =
0
\end{align*}
The first equality by (\ref{equation-cohomology-hom-complex}).
The second equality by Lemma \ref{lemma-compose}.
The third equality by (\ref{equation-cohomology-hom-complex}).
The final equality because
$\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet)$
is acyclic because $\mathcal{L}^\bullet$ is K-flat
(Definition \ref{definition-K-flat}) and because $\mathcal{I}^\bullet$
is K-injective.
\end{proof}








\section{Internal hom in the derived category}
\label{section-internal-hom}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $L, M$ be objects
of $D(\mathcal{O}_X)$. We would like to construct an object
$R\SheafHom(L, M)$ of $D(\mathcal{O}_X)$ such that for every third
object $K$ of $D(\mathcal{O}_X)$ there exists a canonical bijection
\begin{equation}
\label{equation-internal-hom}
\Hom_{D(\mathcal{O}_X)}(K, R\SheafHom(L, M))
=
\Hom_{D(\mathcal{O}_X)}(K \otimes_{\mathcal{O}_X}^\mathbf{L} L, M)
\end{equation}
Observe that this formula defines $R\SheafHom(L, M)$ up to unique
isomorphism by the Yoneda lemma
(Categories, Lemma \ref{categories-lemma-yoneda}).

\medskip\noindent
To construct such an object, choose a K-injective complex
$\mathcal{I}^\bullet$ representing $M$ and any complex of
$\mathcal{O}_X$-modules $\mathcal{L}^\bullet$ representing $L$.
Then we set
$$
R\SheafHom(L, M) = \SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet)
$$
where the right hand side is the complex of $\mathcal{O}_X$-modules
constructed in Section \ref{section-hom-complexes}.
This is well defined by Lemma \ref{lemma-RHom-well-defined}.
We get a functor
$$
D(\mathcal{O}_X)^{opp} \times D(\mathcal{O}_X) \longrightarrow D(\mathcal{O}_X),
\quad
(K, L) \longmapsto R\SheafHom(K, L)
$$
As a prelude to proving (\ref{equation-internal-hom})
we compute the cohomology groups of $R\SheafHom(K, L)$.

\begin{lemma}
\label{lemma-section-RHom-over-U}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $L, M$ be objects
of $D(\mathcal{O}_X)$. For every open $U$ we have
$$
H^0(U, R\SheafHom(L, M)) =
\Hom_{D(\mathcal{O}_U)}(L|_U, M|_U)
$$
and in particular $H^0(X, R\SheafHom(L, M)) = \Hom_{D(\mathcal{O}_X)}(L, M)$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$ of
$\mathcal{O}_X$-modules representing $M$ and a K-flat complex
$\mathcal{L}^\bullet$ representing $L$. Then
$\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet)$
is K-injective by Lemma \ref{lemma-RHom-from-K-flat-into-K-injective}.
Hence we can compute cohomology over $U$ by simply taking sections over $U$
and the result follows from Lemma \ref{lemma-RHom-into-K-injective}.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L, M$ be objects
of $D(\mathcal{O}_X)$. With the construction as described above
there is a canonical isomorphism
$$
R\SheafHom(K, R\SheafHom(L, M)) =
R\SheafHom(K \otimes_{\mathcal{O}_X}^\mathbf{L} L, M)
$$
in $D(\mathcal{O}_X)$ functorial in $K, L, M$
which recovers (\ref{equation-internal-hom}) by taking $H^0(X, -)$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$ representing
$M$ and a K-flat complex of $\mathcal{O}_X$-modules $\mathcal{L}^\bullet$
representing $L$. Let $\mathcal{K}^\bullet$ be any complex of
$\mathcal{O}_X$-modules representing $K$. Then
we have
$$
\SheafHom^\bullet(\mathcal{K}^\bullet,
\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{I}^\bullet))
=
\SheafHom^\bullet(
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet),
\mathcal{I}^\bullet)
$$
by Lemma \ref{lemma-compose}.
Note that the left hand side represents
$R\SheafHom(K, R\SheafHom(L, M))$ (use
Lemma \ref{lemma-RHom-from-K-flat-into-K-injective})
and that the right hand side represents
$R\SheafHom(K \otimes_{\mathcal{O}_X}^\mathbf{L} L, M)$.
This proves the displayed formula of the lemma.
Taking global sections and using Lemma \ref{lemma-section-RHom-over-U}
we obtain (\ref{equation-internal-hom}).
\end{proof}

\begin{lemma}
\label{lemma-restriction-RHom-to-U}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L$ be objects
of $D(\mathcal{O}_X)$. The construction of $R\SheafHom(K, L)$
commutes with restrictions to opens, i.e.,
for every open $U$ we have
$R\SheafHom(K|_U, L|_U) = R\SheafHom(K, L)|_U$.
\end{lemma}

\begin{proof}
This is clear from the construction and
Lemma \ref{lemma-restrict-K-injective-to-open}.
\end{proof}

\begin{lemma}
\label{lemma-RHom-triangulated}
Let $(X, \mathcal{O}_X)$ be a ringed space. The bifunctor $R\SheafHom(- , -)$
transforms distinguished triangles into distinguished triangles in both
variables.
\end{lemma}

\begin{proof}
This follows from the observation that the assignment
$$
(\mathcal{L}^\bullet, \mathcal{M}^\bullet) \longmapsto
\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{M}^\bullet)
$$
transforms a termwise split short exact sequences of complexes in either
variable into a termwise split short exact sequence. Details omitted.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-composition}
Let $(X, \mathcal{O}_X)$ be a ringed space. Given $K, L, M$ in
$D(\mathcal{O}_X)$ there is a canonical morphism
$$
R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} R\SheafHom(K, L)
\longrightarrow R\SheafHom(K, M)
$$
in $D(\mathcal{O}_X)$ functorial in $K, L, M$.
\end{lemma}

\begin{proof}
Choose a K-injective complex $\mathcal{I}^\bullet$ representing $M$,
a K-injective complex $\mathcal{J}^\bullet$ representing $L$, and
any complex of $\mathcal{O}_X$-modules $\mathcal{K}^\bullet$ representing $K$.
By Lemma \ref{lemma-composition} there is a map of complexes
$$
\text{Tot}\left(
\SheafHom^\bullet(\mathcal{J}^\bullet, \mathcal{I}^\bullet)
\otimes_{\mathcal{O}_X}
\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{J}^\bullet)
\right)
\longrightarrow
\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{I}^\bullet)
$$
The complexes of $\mathcal{O}_X$-modules
$\SheafHom^\bullet(\mathcal{J}^\bullet, \mathcal{I}^\bullet)$,
$\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{J}^\bullet)$, and
$\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{I}^\bullet)$
represent $R\SheafHom(L, M)$, $R\SheafHom(K, L)$, and $R\SheafHom(K, M)$.
If we choose a K-flat complex $\mathcal{H}^\bullet$ and a quasi-isomorphism
$\mathcal{H}^\bullet \to
\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{J}^\bullet)$,
then there is a map
$$
\text{Tot}\left(
\SheafHom^\bullet(\mathcal{J}^\bullet, \mathcal{I}^\bullet)
\otimes_{\mathcal{O}_X} \mathcal{H}^\bullet
\right)
\longrightarrow
\text{Tot}\left(
\SheafHom^\bullet(\mathcal{J}^\bullet, \mathcal{I}^\bullet)
\otimes_{\mathcal{O}_X}
\SheafHom^\bullet(\mathcal{K}^\bullet, \mathcal{J}^\bullet)
\right)
$$
whose source represents
$R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} R\SheafHom(K, L)$.
Composing the two displayed arrows gives the desired map. We omit the
proof that the construction is functorial.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-diagonal-better}
Let $(X, \mathcal{O}_X)$ be a ringed space. Given $K, L, M$
in $D(\mathcal{O}_X)$ there is a canonical morphism
$$
K \otimes_{\mathcal{O}_X}^\mathbf{L} R\SheafHom(M, L)
\longrightarrow
R\SheafHom(M, K \otimes_{\mathcal{O}_X}^\mathbf{L} L)
$$
in $D(\mathcal{O}_X)$ functorial in $K, L, M$.
\end{lemma}

\begin{proof}
Choose a K-flat complex $\mathcal{K}^\bullet$ representing $K$,
and a K-injective complex $\mathcal{I}^\bullet$ representing $L$, and
choose any complex of $\mathcal{O}_X$-modules $\mathcal{M}^\bullet$
representing $M$. Choose a quasi-isomorphism
$\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{I}^\bullet)
\to \mathcal{J}^\bullet$
where $\mathcal{J}^\bullet$ is K-injective. Then we use the map
$$
\text{Tot}\left(
\mathcal{K}^\bullet \otimes_{\mathcal{O}_X}
\SheafHom^\bullet(\mathcal{M}^\bullet, \mathcal{I}^\bullet)
\right)
\to
\SheafHom^\bullet(\mathcal{M}^\bullet,
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{I}^\bullet))
\to
\SheafHom^\bullet(\mathcal{M}^\bullet, \mathcal{J}^\bullet)
$$
where the first map is the map from Lemma \ref{lemma-diagonal-better}.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-diagonal}
Let $(X, \mathcal{O}_X)$ be a ringed space. Given $K, L$ in $D(\mathcal{O}_X)$
there is a canonical morphism
$$
K \longrightarrow R\SheafHom(L, K \otimes_{\mathcal{O}_X}^\mathbf{L} L)
$$
in $D(\mathcal{O}_X)$ functorial in both $K$ and $L$.
\end{lemma}

\begin{proof}
Choose a K-flat complex $\mathcal{K}^\bullet$ representing $K$
and any complex of $\mathcal{O}_X$-modules $\mathcal{L}^\bullet$
representing $L$. Choose a K-injective complex $\mathcal{J}^\bullet$
and a quasi-isomorphism
$\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet)
\to \mathcal{J}^\bullet$. Then we use
$$
\mathcal{K}^\bullet \to
\SheafHom^\bullet(\mathcal{L}^\bullet,
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet))
\to
\SheafHom^\bullet(\mathcal{L}^\bullet, \mathcal{J}^\bullet)
$$
where the first map comes from Lemma \ref{lemma-diagonal}.
\end{proof}

\begin{lemma}
\label{lemma-dual}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $L$ be an
object of $D(\mathcal{O}_X)$. Set $L^\vee = R\SheafHom(L, \mathcal{O}_X)$.
For $M$ in $D(\mathcal{O}_X)$ there is a canonical map
\begin{equation}
\label{equation-eval}
M \otimes^\mathbf{L}_{\mathcal{O}_X} L^\vee
\longrightarrow
R\SheafHom(L, M)
\end{equation}
which induces a canonical map
$$
H^0(X, M \otimes^\mathbf{L}_{\mathcal{O}_X} L^\vee)
\longrightarrow
\Hom_{D(\mathcal{O}_X)}(L, M)
$$
functorial in $M$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
The map (\ref{equation-eval}) is a special case of
Lemma \ref{lemma-internal-hom-composition}
using the identification $M = R\SheafHom(\mathcal{O}_X, M)$.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-evaluate}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L, M$ be objects of
$D(\mathcal{O}_X)$. There is a canonical morphism
$$
R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} K
\longrightarrow
R\SheafHom(R\SheafHom(K, L), M)
$$
in $D(\mathcal{O}_X)$ functorial in $K, L, M$.
\end{lemma}

\begin{proof}
Choose
a K-injective complex $\mathcal{I}^\bullet$ representing $M$,
a K-injective complex $\mathcal{J}^\bullet$ representing $L$, and
a K-flat complex $\mathcal{K}^\bullet$ representing $K$.
The map is defined using the map
$$
\text{Tot}(\SheafHom^\bullet(\mathcal{J}^\bullet,
\mathcal{I}^\bullet) \otimes_{\mathcal{O}_X} \mathcal{K}^\bullet)
\longrightarrow
\SheafHom^\bullet(\SheafHom^\bullet(\mathcal{K}^\bullet,
\mathcal{J}^\bullet), \mathcal{I}^\bullet)
$$
of Lemma \ref{lemma-evaluate-and-more}. By our particular
choice of complexes the left hand side represents
$R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} K$
and the right hand side represents
$R\SheafHom(R\SheafHom(K, L), M)$. We omit the proof that
this is functorial in all three objects of $D(\mathcal{O}_X)$.
\end{proof}

\begin{remark}
\label{remark-tensor-internal-hom}
Let $(X, \mathcal{O}_X)$ be a ringed space. For $K, K', M, M'$ in
$D(\mathcal{O}_X)$ there is a canonical map
$$
R\SheafHom(K, K') \otimes_{\mathcal{O}_X}^\mathbf{L}
R\SheafHom(M, M')
\longrightarrow
R\SheafHom(K \otimes_{\mathcal{O}_X}^\mathbf{L} M,
K' \otimes_{\mathcal{O}_X}^\mathbf{L} M')
$$
Namely, by (\ref{equation-internal-hom}) is the same thing as a map
$$
R\SheafHom(K, K') \otimes_{\mathcal{O}_X}^\mathbf{L}
R\SheafHom(M, M') \otimes_{\mathcal{O}_X}^\mathbf{L}
K \otimes_{\mathcal{O}_X}^\mathbf{L} M
\longrightarrow
K' \otimes_{\mathcal{O}_X}^\mathbf{L} M'
$$
For this we can first flip the middle two factors
(with sign rules as in More on Algebra, Section
\ref{more-algebra-section-sign-rules})
and use the maps
$$
R\SheafHom(K, K') \otimes_{\mathcal{O}_X}^\mathbf{L} K \to K'
\quad\text{and}\quad
R\SheafHom(M, M') \otimes_{\mathcal{O}_X}^\mathbf{L} M \to M'
$$
from Lemma \ref{lemma-internal-hom-composition} when thinking
of $K = R\SheafHom(\mathcal{O}_X, K)$ and similarly for
$K'$, $M$, and $M'$.
\end{remark}

\begin{remark}
\label{remark-projection-formula-for-internal-hom}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $K, L$ be objects of $D(\mathcal{O}_X)$. We claim there is a canonical map
$$
Rf_*R\SheafHom(L, K) \longrightarrow R\SheafHom(Rf_*L, Rf_*K)
$$
Namely, by (\ref{equation-internal-hom}) this is the same thing
as a map
$Rf_*R\SheafHom(L, K) \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*L \to Rf_*K$.
For this we can use the composition
$$
Rf_*R\SheafHom(L, K) \otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*L \to
Rf_*(R\SheafHom(L, K) \otimes_{\mathcal{O}_X}^\mathbf{L} L) \to
Rf_*K
$$
where the first arrow is the relative cup product
(Remark \ref{remark-cup-product}) and the second arrow is $Rf_*$ applied
to the canonical map
$R\SheafHom(L, K) \otimes_{\mathcal{O}_X}^\mathbf{L} L \to K$
coming from Lemma \ref{lemma-internal-hom-composition}
(with $\mathcal{O}_X$ in one of the spots).
\end{remark}

\begin{remark}
\label{remark-relative-cup-and-composition}
Let $h : X \to Y$ be a morphism of ringed spaces.
Let $K, L, M$ be objects of $D(\mathcal{O}_Y)$.
The diagram
$$
\xymatrix{
Rf_*R\SheafHom_{\mathcal{O}_X}(K, M)
\otimes_{\mathcal{O}_Y}^\mathbf{L} Rf_*M
\ar[r] \ar[d] &
Rf_*\left(R\SheafHom_{\mathcal{O}_X}(K, M)
\otimes_{\mathcal{O}_X}^\mathbf{L} M\right)
\ar[d] \\
R\SheafHom_{\mathcal{O}_Y}(Rf_*K, Rf_*M) \otimes_{\mathcal{O}_Y}^\mathbf{L}
Rf_*M \ar[r] &
Rf_*M
}
$$
is commutative. Here the left vertical arrow comes from
Remark \ref{remark-projection-formula-for-internal-hom}.
The top horizontal arrow is Remark \ref{remark-cup-product}.
The other two arrows are instances of the map in
Lemma \ref{lemma-internal-hom-composition} (with one of the entries
replaced with $\mathcal{O}_X$ or $\mathcal{O}_Y$).
\end{remark}

\begin{remark}
\label{remark-prepare-fancy-base-change}
Let $h : X \to Y$ be a morphism of ringed spaces.
Let $K, L$ be objects of $D(\mathcal{O}_Y)$. We claim there is a
canonical map
$$
Lh^*R\SheafHom(K, L) \longrightarrow R\SheafHom(Lh^*K, Lh^*L)
$$
in $D(\mathcal{O}_X)$. Namely, by (\ref{equation-internal-hom})
proved in Lemma \ref{lemma-internal-hom}
such a map is the same thing as a map
$$
Lh^*R\SheafHom(K, L) \otimes^\mathbf{L} Lh^*K \longrightarrow Lh^*L
$$
The source of this arrow is $Lh^*(\SheafHom(K, L) \otimes^\mathbf{L} K)$
by Lemma \ref{lemma-pullback-tensor-product}
hence it suffices to construct a canonical map
$$
R\SheafHom(K, L) \otimes^\mathbf{L} K \longrightarrow L.
$$
For this we take the arrow corresponding to
$$
\text{id} :
R\SheafHom(K, L)
\longrightarrow
R\SheafHom(K, L)
$$
via (\ref{equation-internal-hom}).
\end{remark}

\begin{remark}
\label{remark-fancy-base-change}
Suppose that
$$
\xymatrix{
X' \ar[r]_h \ar[d]_{f'} &
X \ar[d]^f \\
S' \ar[r]^g &
S
}
$$
is a commutative diagram of ringed spaces. Let $K, L$ be objects
of $D(\mathcal{O}_X)$. We claim there exists a canonical base change
map
$$
Lg^*Rf_*R\SheafHom(K, L)
\longrightarrow
R(f')_*R\SheafHom(Lh^*K, Lh^*L)
$$
in $D(\mathcal{O}_{S'})$. Namely, we take the map adjoint to
the composition
\begin{align*}
L(f')^*Lg^*Rf_*R\SheafHom(K, L)
& =
Lh^*Lf^*Rf_*R\SheafHom(K, L) \\
& \to
Lh^*R\SheafHom(K, L) \\
& \to
R\SheafHom(Lh^*K, Lh^*L)
\end{align*}
where the first arrow uses the adjunction mapping
$Lf^*Rf_* \to \text{id}$ and the second arrow is the canonical map
constructed in Remark \ref{remark-prepare-fancy-base-change}.
\end{remark}





\section{Ext sheaves}
\label{section-ext}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L \in D(\mathcal{O}_X)$.
Using the construction of the internal hom in the derived category we
obtain a well defined sheaves of $\mathcal{O}_X$-modules
$$
\SheafExt^n(K, L) = H^n(R\SheafHom(K, L))
$$
by taking the $n$th cohomology sheaf of the object $R\SheafHom(K, L)$
of $D(\mathcal{O}_X)$. We will sometimes write
$\SheafExt^n_{\mathcal{O}_X}(K, L)$ for this object.
By Lemma \ref{lemma-section-RHom-over-U}
we see that this $\SheafExt^n$-sheaf
is the sheafification of the rule
$$
U \longmapsto \Ext^n_{D(\mathcal{O}_U)}(K|_U, L|_U)
$$
By Example \ref{example-spectral-sequence} there is always a spectral
sequence
$$
E_2^{p, q} = H^p(X, \SheafExt^q(K, L))
$$
converging to $\Ext^{p + q}_{D(\mathcal{O}_X)}(K, L)$
in favorable situations (for example if $L$ is bounded below and
$K$ is bounded above).





\section{Global derived hom}
\label{section-global-RHom}

\noindent
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L \in D(\mathcal{O}_X)$.
Using the construction of the internal hom in the derived category we
obtain a well defined object
$$
R\Hom_X(K, L) = R\Gamma(X, R\SheafHom(K, L))
$$
in $D(\Gamma(X, \mathcal{O}_X))$. We will sometimes write
$R\Hom_{\mathcal{O}_X}(K, L)$ for this object.
By Lemma \ref{lemma-section-RHom-over-U}
we have
$$
H^0(R\Hom_X(K, L)) = \Hom_{D(\mathcal{O}_X)}(K, L),
\quad
H^p(R\Hom_X(K, L)) = \Ext_{D(\mathcal{O}_X)}^p(K, L)
$$
If $f : Y \to X$ is a morphism of ringed spaces, then there is
a canonical map
$$
R\Hom_X(K, L) \longrightarrow R\Hom_Y(Lf^*K, Lf^*L)
$$
in $D(\Gamma(X, \mathcal{O}_X))$ by taking global sections of the map
defined in Remark \ref{remark-prepare-fancy-base-change}.








\section{Glueing complexes}
\label{section-glueing-complexes}

\noindent
We can glue complexes! More precisely, in certain circumstances we can
glue locally given objects of the derived category to a global object.
We first prove some easy cases and then we'll prove the very general
\cite[Theorem 3.2.4]{BBD}
in the setting of topological spaces and open coverings.

\begin{lemma}
\label{lemma-glue}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $X = U \cup V$ be
the union of two open subspaces of $X$. Suppose given
\begin{enumerate}
\item an object $A$ of $D(\mathcal{O}_U)$,
\item an object $B$ of $D(\mathcal{O}_V)$, and
\item an isomorphism $c : A|_{U \cap V} \to B|_{U \cap V}$.
\end{enumerate}
Then there exists an object $F$ of $D(\mathcal{O}_X)$
and isomorphisms $f : F|_U \to A$, $g : F|_V \to B$ such
that $c = g|_{U \cap V} \circ f^{-1}|_{U \cap V}$.
Moreover, given
\begin{enumerate}
\item an object $E$ of $D(\mathcal{O}_X)$,
\item a morphism $a : A \to E|_U$ of $D(\mathcal{O}_U)$,
\item a morphism $b : B \to E|_V$ of $D(\mathcal{O}_V)$, 
\end{enumerate}
such that
$$
a|_{U \cap V}  = b|_{U \cap V} \circ c.
$$
Then there exists a morphism $F \to E$ in $D(\mathcal{O}_X)$
whose restriction to $U$ is $a \circ f$
and whose restriction to $V$ is $b \circ g$.
\end{lemma}

\begin{proof}
Denote $j_U$, $j_V$, $j_{U \cap V}$ the corresponding open immersions.
Choose a distinguished triangle
$$
F \to Rj_{U, *}A \oplus Rj_{V, *}B \to Rj_{U \cap V, *}(B|_{U \cap V})
\to F[1]
$$
where the map $Rj_{V, *}B \to Rj_{U \cap V, *}(B|_{U \cap V})$ is the
obvious one and where
$Rj_{U, *}A \to Rj_{U \cap V, *}(B|_{U \cap V})$
is the composition of
$Rj_{U, *}A \to Rj_{U \cap V, *}(A|_{U \cap V})$
with $Rj_{U \cap V, *}c$. Restricting to $U$ we obtain
$$
F|_U \to A \oplus (Rj_{V, *}B)|_U \to (Rj_{U \cap V, *}(B|_{U \cap V}))|_U
\to F|_U[1]
$$
Denote $j : U \cap V \to U$. Compatibility of restriction to opens and
cohomology shows that both
$(Rj_{V, *}B)|_U$ and $(Rj_{U \cap V, *}(B|_{U \cap V}))|_U$
are canonically isomorphic to $Rj_*(B|_{U \cap V})$.
Hence the second arrow of the last displayed diagram has
a section, and we conclude that the morphism $F|_U \to A$ is
an isomorphism. Similarly, the morphism $F|_V \to B$ is an
isomorphism. The existence of the morphism $F \to E$ follows
from the Mayer-Vietoris sequence for $\Hom$, see
Lemma \ref{lemma-mayer-vietoris-hom}.
\end{proof}

\begin{lemma}
\label{lemma-vanishing-and-glueing}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism
of ringed spaces. Let $\mathcal{B}$ be a basis for the topology on $Y$.
\begin{enumerate}
\item Assume $K$ is in $D(\mathcal{O}_X)$ such that
for $V \in \mathcal{B}$ we have $H^i(f^{-1}(V), K) = 0$ for $i < 0$.
Then $Rf_*K$ has vanishing cohomology sheaves in negative degrees,
$H^i(f^{-1}(V), K) = 0$ for $i < 0$ for all opens $V \subset Y$, and
the rule $V \mapsto H^0(f^{-1}V, K)$ is a sheaf on $Y$.
\item Assume $K, L$ are in $D(\mathcal{O}_X)$ such that
for $V \in \mathcal{B}$ we have
$\Ext^i(K|_{f^{-1}V}, L|_{f^{-1}V}) = 0$ for $i < 0$.
Then $\Ext^i(K|_{f^{-1}V}, L|_{f^{-1}V}) = 0$ for $i < 0$
for all opens $V \subset Y$ and
the rule $V \mapsto \Hom(K|_{f^{-1}V}, L|_{f^{-1}V})$ is a sheaf on $Y$.
\end{enumerate}
\end{lemma}

\begin{proof}
Lemma \ref{lemma-unbounded-describe-higher-direct-images} tells us
$H^i(Rf_*K)$ is the sheaf associated to the presheaf
$V \mapsto H^i(f^{-1}(V), K) = H^i(V, Rf_*K)$.
The assumptions in (1) imply that $Rf_*K$ has vanishing cohomology
sheaves in degrees $< 0$. We conclude that for any open $V \subset Y$
the cohomology group $H^i(V, Rf_*K)$ is zero for $i < 0$ and is equal to
$H^0(V, H^0(Rf_*K))$ for $i = 0$. This proves (1).

\medskip\noindent
To prove (2) apply (1) to the complex $R\SheafHom(K, L)$ using
Lemma \ref{lemma-section-RHom-over-U} to do the translation.
\end{proof}

\begin{situation}
\label{situation-locally-given}
Let $(X, \mathcal{O}_X)$ be a ringed space. We are given
\begin{enumerate}
\item a collection of opens $\mathcal{B}$ of $X$,
\item for $U \in \mathcal{B}$ an object $K_U$ in $D(\mathcal{O}_U)$,
\item for $V \subset U$ with $V, U \in \mathcal{B}$ an isomorphism
$\rho^U_V : K_U|_V \to K_V$ in $D(\mathcal{O}_V)$,
\end{enumerate}
such that whenever we have $W \subset V \subset U$ with $U, V, W$ in
$\mathcal{B}$, then $\rho^U_W = \rho^V_W \circ \rho ^U_V|_W$.
\end{situation}

\noindent
We won't be able to prove anything about this without making more
assumptions. An interesting case is where $\mathcal{B}$ is a basis
for the topology on $X$. Another is the case where we have a morphism
$f : X \to Y$ of topological spaces and the elements of $\mathcal{B}$
are the inverse images of the elements of a basis for the topology of $Y$.

\medskip\noindent
In Situation \ref{situation-locally-given} a {\it solution}
will be a pair $(K, \rho_U)$ where $K$ is an object of $D(\mathcal{O}_X)$
and $\rho_U : K|_U \to K_U$, $U \in \mathcal{B}$
are isomorphisms such that
we have $\rho^U_V \circ \rho_U|_V = \rho_V$ for all $V \subset U$,
$U, V \in \mathcal{B}$. In certain cases solutions are unique.

\begin{lemma}
\label{lemma-uniqueness}
In Situation \ref{situation-locally-given} assume
\begin{enumerate}
\item $X = \bigcup_{U \in \mathcal{B}} U$ and
for $U, V \in \mathcal{B}$ we have
$U \cap V = \bigcup_{W \in \mathcal{B}, W \subset U \cap V} W$,
\item for any $U \in \mathcal{B}$ we have $\Ext^i(K_U, K_U) = 0$
for $i < 0$.
\end{enumerate}
If a solution $(K, \rho_U)$ exists, then it is unique up to unique isomorphism
and moreover $\Ext^i(K, K) = 0$ for $i < 0$.
\end{lemma}

\begin{proof}
Let $(K, \rho_U)$ and $(K', \rho'_U)$ be a pair of solutions.
Let $f : X \to Y$ be the continuous map constructed
in Topology, Lemma \ref{topology-lemma-create-map-from-subcollection}.
Set $\mathcal{O}_Y = f_*\mathcal{O}_X$.
Then $K, K'$ and $\mathcal{B}$ are as in
Lemma \ref{lemma-vanishing-and-glueing} part (2).
Hence we obtain the vanishing of negative exts for $K$ and we see that
the rule
$$
V \longmapsto \Hom(K|_{f^{-1}V}, K'|_{f^{-1}V})
$$
is a sheaf on $Y$. As both $(K, \rho_U)$ and $(K', \rho'_U)$ are solutions
the maps
$$
(\rho'_U)^{-1} \circ \rho_U : K|_U \longrightarrow K'|_U
$$
over $U = f^{-1}(f(U))$ agree on overlaps. Hence we get a unique global
section of the sheaf above which defines the desired isomorphism
$K \to K'$ compatible with all structure available.
\end{proof}

\begin{remark}
\label{remark-uniqueness}
With notation and assumptions as in Lemma \ref{lemma-uniqueness}.
Suppose that $U, V \in \mathcal{B}$. Let $\mathcal{B}'$ be the set of
elements of $\mathcal{B}$ contained in $U \cap V$. Then
$$
(\{K_{U'}\}_{U' \in \mathcal{B}'},
\{\rho_{V'}^{U'}\}_{V' \subset U'\text{ with }U', V' \in \mathcal{B}'})
$$
is a system on the ringed space $U \cap V$
satisfying the assumptions of Lemma \ref{lemma-uniqueness}.
Moreover, both $(K_U|_{U \cap V}, \rho^U_{U'})$ and
$(K_V|_{U \cap V}, \rho^V_{U'})$ are solutions to this system.
By the lemma we find a unique isomorphism
$$
\rho_{U, V} : K_U|_{U \cap V} \longrightarrow K_V|_{U \cap V}
$$
such that for every $U' \subset U \cap V$, $U' \in \mathcal{B}$ the
diagram
$$
\xymatrix{
K_U|_{U'} \ar[rr]_{\rho_{U, V}|_{U'}} \ar[rd]_{\rho^U_{U'}} & &
K_V|_{U'} \ar[ld]^{\rho^V_{U'}} \\
& K_{U'}
}
$$
commutes. Pick a third element $W \in \mathcal{B}$. We obtain isomorphisms
$\rho_{U, W} : K_U|_{U \cap W} \to K_W|_{U \cap W}$ and
$\rho_{V, W} : K_U|_{V \cap W} \to K_W|_{V \cap W}$ satisfying
similar properties to those of $\rho_{U, V}$. Finally,
we have
$$
\rho_{U, W}|_{U \cap V \cap W} =
\rho_{V, W}|_{U \cap V \cap W} \circ \rho_{U, V}|_{U \cap V \cap W}
$$
This is true by the uniqueness in the lemma
because both sides of the equality are the unique isomorphism
compatible with the maps $\rho^U_{U''}$ and $\rho^W_{U''}$
for $U'' \subset U \cap V \cap W$, $U'' \in \mathcal{B}$.
Some minor details omitted.
The collection $(K_U, \rho_{U, V})$ is a descent datum
in the derived category for the open covering
$\mathcal{U} : X = \bigcup_{U \in \mathcal{B}} U$ of $X$.
In this language we are looking for ``effectiveness of the descent datum''
when we look for the existence of a solution.
\end{remark}

\begin{lemma}
\label{lemma-solution-in-finite-case}
In Situation \ref{situation-locally-given} assume
\begin{enumerate}
\item $X = U_1 \cup \ldots \cup U_n$ with $U_i \in \mathcal{B}$,
\item for $U, V \in \mathcal{B}$ we have
$U \cap V = \bigcup_{W \in \mathcal{B}, W \subset U \cap V} W$,
\item for any $U \in \mathcal{B}$ we have $\Ext^i(K_U, K_U) = 0$
for $i < 0$.
\end{enumerate}
Then a solution exists and is unique up to unique isomorphism.
\end{lemma}

\begin{proof}
Uniqueness was seen in Lemma \ref{lemma-uniqueness}. We may prove the lemma
by induction on $n$. The case $n = 1$ is immediate.

\medskip\noindent
The case $n = 2$.
Consider the isomorphism
$\rho_{U_1, U_2} : K_{U_1}|_{U_1 \cap U_2} \to K_{U_2}|_{U_1 \cap U_2}$
constructed in Remark \ref{remark-uniqueness}.
By Lemma \ref{lemma-glue} we obtain an object $K$ in $D(\mathcal{O}_X)$
and isomorphisms $\rho_{U_1} : K|_{U_1} \to K_{U_1}$ and
$\rho_{U_2} : K|_{U_2} \to K_{U_2}$ compatible with $\rho_{U_1, U_2}$.
Take $U \in \mathcal{B}$. We will construct an isomorphism
$\rho_U : K|_U \to K_U$ and we will leave it to the reader to verify
that $(K, \rho_U)$ is a solution. Consider the set $\mathcal{B}'$
of elements of $\mathcal{B}$ contained in either $U \cap U_1$ or contained in
$U \cap U_2$. Then $(K_U, \rho^U_{U'})$ is a solution for the system
$(\{K_{U'}\}_{U' \in \mathcal{B}'},
\{\rho_{V'}^{U'}\}_{V' \subset U'\text{ with }U', V' \in \mathcal{B}'})$
on the ringed space $U$.
We claim that $(K|_U, \tau_{U'})$ is another solution where
$\tau_{U'}$ for $U' \in \mathcal{B}'$ is chosen as follows:
if $U' \subset U_1$ then we take the composition
$$
K|_{U'} \xrightarrow{\rho_{U_1}|_{U'}}
K_{U_1}|_{U'} \xrightarrow{\rho^{U_1}_{U'}}
K_{U'}
$$
and if $U' \subset U_2$ then we take the composition
$$
K|_{U'} \xrightarrow{\rho_{U_2}|_{U'}}
K_{U_2}|_{U'} \xrightarrow{\rho^{U_2}_{U'}}
K_{U'}.
$$
To verify this is a solution use the property of the map $\rho_{U_1, U_2}$
described in Remark \ref{remark-uniqueness} and the compatibility of
$\rho_{U_1}$ and $\rho_{U_2}$ with $\rho_{U_1, U_2}$. Having said this
we apply Lemma \ref{lemma-uniqueness} to see that we obtain a unique
isomorphism $K|_{U'} \to K_{U'}$ compatible with the maps $\tau_{U'}$ and
$\rho^U_{U'}$ for $U' \in \mathcal{B}'$.

\medskip\noindent
The case $n > 2$. Consider the open subspace
$X' = U_1 \cup \ldots \cup U_{n - 1}$ and let $\mathcal{B}'$ be the set of
elements of $\mathcal{B}$ contained in $X'$. Then we find a system
$(\{K_U\}_{U \in \mathcal{B}'}, \{\rho_V^U\}_{U, V \in \mathcal{B}'})$
on the ringed space $X'$ to which we may apply our induction hypothesis.
We find a solution $(K_{X'}, \rho^{X'}_U)$.
Then we can consider the collection
$\mathcal{B}^* = \mathcal{B} \cup \{X'\}$ of opens of $X$ and we see that
we obtain a system
$(\{K_U\}_{U \in \mathcal{B}^*},
\{\rho_V^U\}_{V \subset U\text{ with }U, V \in \mathcal{B}^*})$.
Note that this new system also satisfies condition (3)
by Lemma \ref{lemma-uniqueness} applied to the solution $K_{X'}$.
For this system we have $X = X' \cup U_n$.
This reduces us to the case $n = 2$ we worked out above.
\end{proof}

\begin{lemma}
\label{lemma-glueing-increasing-union}
Let $X$ be a ringed space. Let $E$ be a well ordered set and let
$$
X = \bigcup\nolimits_{\alpha \in E} W_\alpha
$$
be an open covering with $W_\alpha \subset W_{\alpha + 1}$
and $W_\alpha = \bigcup_{\beta < \alpha} W_\beta$ if $\alpha$ is not
a successor. Let $K_\alpha$ be an object of $D(\mathcal{O}_{W_\alpha})$
with $\Ext^i(K_\alpha, K_\alpha) = 0$ for $i < 0$.
Assume given isomorphisms
$\rho_\beta^\alpha :  K_\alpha|_{W_\beta} \to K_\beta$ in
$D(\mathcal{O}_{W_\beta})$ for all $\beta < \alpha$ with
$\rho_\gamma^\alpha = \rho_\gamma^\beta \circ \rho^\alpha_\beta|_{W_\gamma}$
for $\gamma < \beta < \alpha$.
Then there exists an object
$K$ in $D(\mathcal{O}_X)$ and isomorphisms
$K|_{W_\alpha} \to K_\alpha$ for $\alpha \in E$
compatible with the isomorphisms $\rho_\beta^\alpha$.
\end{lemma}

\begin{proof}
In this proof $\alpha, \beta, \gamma, \ldots$ represent elements of $E$.
Choose a K-injective complex
$I_\alpha^\bullet$ on $W_\alpha$ representing $K_\alpha$.
For $\beta < \alpha$ denote $j_{\beta, \alpha} : W_\beta \to W_\alpha$
the inclusion morphism. Using transfinite recursion we will construct for all
$\beta < \alpha$ a map of complexes
$$
\tau_{\beta, \alpha} :
(j_{\beta, \alpha})_!I_\beta^\bullet
\longrightarrow
I_\alpha^\bullet
$$
representing the adjoint to the inverse of the isomorphism
$\rho^\alpha_\beta : K_\alpha|_{W_\beta} \to K_\beta$.
Moreover, we will do this in such that for
$\gamma < \beta < \alpha$ we have
$$
\tau_{\gamma, \alpha} = \tau_{\beta, \alpha} \circ
(j_{\beta, \alpha})_!\tau_{\gamma, \beta}
$$
as maps of complexes. Namely, suppose already given $\tau_{\gamma, \beta}$
composing correctly for all $\gamma < \beta < \alpha$.
If $\alpha = \alpha' + 1$ is a successor, then we choose any map of complexes
$$
(j_{\alpha', \alpha})_!I_{\alpha'}^\bullet \to I_\alpha^\bullet
$$
which is adjoint to the inverse of the isomorphism
$\rho^\alpha_{\alpha'} : K_\alpha|_{W_{\alpha'}} \to K_{\alpha'}$
(possible because $I_\alpha^\bullet$ is K-injective)
and for any $\beta < \alpha'$ we set
$$
\tau_{\beta, \alpha} = \tau_{\alpha', \alpha} \circ
(j_{\alpha', \alpha})_!\tau_{\beta, \alpha'}
$$
If $\alpha$ is not a successor, then
we can consider the complex on $W_\alpha$ given by
$$
C^\bullet = \colim_{\beta < \alpha} (j_{\beta, \alpha})_!I_\beta^\bullet
$$
(termwise colimit) where the transition maps of the sequence
are given by the maps $\tau_{\beta', \beta}$ for
$\beta' < \beta < \alpha$. We claim that $C^\bullet$
represents $K_\alpha$. Namely, for $\beta < \alpha$ the restriction
of the coprojection $(j_{\beta, \alpha})_!I_\beta^\bullet \to C^\bullet$
gives a map
$$
\sigma_\beta : I_\beta^\bullet \longrightarrow C^\bullet|_{W_\beta}
$$
which is a quasi-isomorphism: if $x \in W_\beta$ then looking
at stalks we get
$$
(C^\bullet)_x =
\colim_{\beta' < \alpha}
\left((j_{\beta', \alpha})_!I_{\beta'}^\bullet\right)_x =
\colim_{\beta \leq \beta' < \alpha} (I_{\beta'}^\bullet)_x
\longleftarrow
(I_\beta^\bullet)_x
$$
which is a quasi-isomorphism. Here we used that taking stalks
commutes with colimits, that filtered colimits are exact, and
that the maps $(I_\beta^\bullet)_x \to (I_{\beta'}^\bullet)_x$
are quasi-isomorphisms for $\beta \leq \beta' < \alpha$.
Hence $(C^\bullet, \sigma_\beta^{-1})$ is a solution to the
system $(\{K_\beta\}_{\beta < \alpha},
\{\rho^\beta_{\beta'}\}_{\beta' < \beta < \alpha})$.
Since $(K_\alpha, \rho^\alpha_\beta)$ is another solution
we obtain a unique isomorphism $\sigma : K_\alpha \to C^\bullet$
in $D(\mathcal{O}_{W_\alpha})$ compatible with all our maps, see
Lemma \ref{lemma-solution-in-finite-case}
(this is where we use the vanishing of negative ext groups).
Choose a morphism $\tau : C^\bullet \to I_\alpha^\bullet$
of complexes representing $\sigma$. Then we set
$$
\tau_{\beta, \alpha} = \tau|_{W_\beta} \circ \sigma_\beta
$$
to get the desired maps. Finally, we take $K$ to be the object of the derived
category represented by the complex
$$
K^\bullet = \colim_{\alpha \in E} (W_\alpha \to X)_!I_\alpha^\bullet
$$
where the transition maps are given by our carefully constructed
maps $\tau_{\beta, \alpha}$ for $\beta < \alpha$.
Arguing exactly as above we see that for all $\alpha$
the restriction of the coprojection determines an isomorphism
$$
K|_{W_\alpha} \longrightarrow K_\alpha
$$
compatible with the given maps $\rho^\alpha_\beta$.
\end{proof}

\noindent
Using transfinite induction we can prove the result in the general case.

\begin{theorem}[BBD gluing lemma]
\label{theorem-glueing-bbd-general}
\begin{reference}
Special case of \cite[Theorem 3.2.4]{BBD}
without boundedness assumption.
\end{reference}
In Situation \ref{situation-locally-given} assume
\begin{enumerate}
\item $X = \bigcup_{U \in \mathcal{B}} U$,
\item for $U, V \in \mathcal{B}$ we have
$U \cap V = \bigcup_{W \in \mathcal{B}, W \subset U \cap V} W$,
\item for any $U \in \mathcal{B}$ we have $\Ext^i(K_U, K_U) = 0$
for $i < 0$.
\end{enumerate}
Then there exists an object $K$ of $D(\mathcal{O}_X)$
and isomorphisms $\rho_U : K|_U \to K_U$ in $D(\mathcal{O}_U)$ for
$U \in \mathcal{B}$ such that $\rho^U_V \circ \rho_U|_V = \rho_V$
for all $V \subset U$ with $U, V \in \mathcal{B}$.
The pair $(K, \rho_U)$ is unique up to unique isomorphism.
\end{theorem}

\begin{proof}
A pair $(K, \rho_U)$ is called a solution in the text above.
The uniqueness follows from Lemma \ref{lemma-uniqueness}.
If $X$ has a finite covering by elements of $\mathcal{B}$
(for example if $X$ is quasi-compact), then the theorem
is a consequence of Lemma \ref{lemma-solution-in-finite-case}.
In the general case we argue in exactly the same manner,
using transfinite induction and
Lemma \ref{lemma-glueing-increasing-union}.

\medskip\noindent
First we use transfinite recursion to choose opens $W_\alpha \subset X$
for any ordinal $\alpha$. Namely, we set $W_0 = \emptyset$.
If $\alpha = \beta + 1$ is a successor, then either $W_\beta = X$
and we set $W_\alpha = X$ or $W_\beta \not = X$ and we set
$W_\alpha = W_\beta \cup U_\alpha$ where
$U_\alpha \in \mathcal{B}$ is not contained in $W_\beta$.
If $\alpha$ is a limit ordinal we set
$W_\alpha = \bigcup_{\beta < \alpha} W_\beta$.
Then for large enough $\alpha$ we have $W_\alpha = X$.
Observe that for every $\alpha$ the open $W_\alpha$ is
a union of elements of $\mathcal{B}$. Hence if
$\mathcal{B}_\alpha = \{U \in \mathcal{B}, U \subset W_\alpha\}$, then
$$
S_\alpha = (\{K_U\}_{U \in \mathcal{B}_\alpha},
\{\rho_V^U\}_{V \subset U\text{ with }U, V \in \mathcal{B}_\alpha})
$$
is a system as in Lemma \ref{lemma-uniqueness} on the ringed space $W_\alpha$.

\medskip\noindent
We will show by transfinite induction that for every $\alpha$
the system $S_\alpha$ has a solution. This will prove the theorem
as this system is the system given in the theorem for large $\alpha$.

\medskip\noindent
The case where $\alpha = \beta + 1$ is a successor ordinal.
(This case was already treated in the proof of the lemma above
but for clarity we repeat the argument.)
Recall that $W_\alpha = W_\beta \cup U_\alpha$ for some
$U_\alpha \in \mathcal{B}$ in this case.
By induction hypothesis we have a solution
$(K_{W_\beta}, \{\rho^{W_\beta}_U\}_{U \in \mathcal{B}_\beta})$
for the system $S_\beta$.
Then we can consider the collection
$\mathcal{B}_\alpha^* = \mathcal{B}_\alpha \cup \{W_\beta\}$
of opens of $W_\alpha$ and we see that we obtain a system
$(\{K_U\}_{U \in \mathcal{B}_\alpha^*},
\{\rho_V^U\}_{V \subset U\text{ with }U, V \in \mathcal{B}_\alpha^*})$.
Note that this new system also satisfies condition (3)
by Lemma \ref{lemma-uniqueness} applied to the solution $K_{W_\beta}$.
For this system we have $W_\alpha = W_\beta \cup U_\alpha$.
This reduces us to the case handled in
Lemma \ref{lemma-solution-in-finite-case}.

\medskip\noindent
The case where $\alpha$ is a limit ordinal. Recall that
$W_\alpha = \bigcup_{\beta < \alpha} W_\beta$ in this case.
For $\beta < \alpha$ let
$(K_{W_\beta}, \{\rho^{W_\beta}_U\}_{U \in \mathcal{B}_\beta})$
be the solution for $S_\beta$.
For $\gamma < \beta < \alpha$ the restriction
$K_{W_\beta}|_{W_\gamma}$ endowed with the maps
$\rho^{W_\beta}_U$, $U \in \mathcal{B}_\gamma$
is a solution for $S_\gamma$. By uniqueness we get unique isomorphisms
$\rho_{W_\gamma}^{W_\beta} : K_{W_\beta}|_{W_\gamma} \to K_{W_\gamma}$
compatible with the maps $\rho^{W_\beta}_U$ and $\rho^{W_\gamma}_U$
for $U \in \mathcal{B}_\gamma$. These maps compose in the correct manner,
i.e., $\rho_{W_\delta}^{W_\gamma} \circ \rho_{W_\gamma}^{W_\beta}|_{W_\delta}
= \rho^{W_\delta}_{W_\beta}$ for $\delta < \gamma < \beta < \alpha$.
Thus we may apply Lemma \ref{lemma-glueing-increasing-union}
(note that the vanishing of negative exts is true for
$K_{W_\beta}$ by Lemma \ref{lemma-uniqueness} applied
to the solution $K_{W_\beta}$)
to obtain $K_{W_\alpha}$ and isomorphisms
$$
\rho_{W_\beta}^{W_\alpha} :
K_{W_\alpha}|_{W_\beta}
\longrightarrow
K_{W_\beta}
$$
compatible with the maps $\rho_{W_\gamma}^{W_\beta}$ for
$\gamma < \beta < \alpha$.

\medskip\noindent
To show that $K_{W_\alpha}$ is a solution we still need to construct the
isomorphisms $\rho_U^{W_\alpha} : K_{W_\alpha}|_U \to K_U$ for
$U \in \mathcal{B}_\alpha$ satisfying certain compatibilities.
We choose $\rho_U^{W_\alpha}$ to be the unique map such that
for any $\beta < \alpha$ and any $V \in \mathcal{B}_\beta$
with $V \subset U$ the diagram
$$
\xymatrix{
K_{W_\alpha}|_V \ar[r]_{\rho_U^{W_\alpha}|_V}
\ar[d]_{\rho_{W_\beta}^{W_\alpha}|_V}
& K_U|_V \ar[d]^{\rho_U^V} \\
K_{W_\beta} \ar[r]^{\rho_V^{W_\beta}}
& K_V
}
$$
commutes. This makes sense because
$$
(\{K_V\}_{V \subset U, V \in \mathcal{B}_\beta\text{ for some }\beta < \alpha},
\{\rho_V^{V'}\}_{V \subset V'\text{ with }V, V' \subset U
\text{ and }V, V' \in \mathcal{B}_\beta\text{ for some }\beta < \alpha})
$$
is a system as in Lemma \ref{lemma-uniqueness} on the ringed space $U$
and because $(K_U, \rho^U_V)$ and
$(K_{W_\alpha}|_U,  \rho_V^{W_\beta}\circ \rho_{W_\beta}^{W_\alpha}|_V)$
are both solutions for this system. This gives existence and uniqueness.
We omit the proof that these
maps satisfy the desired compatibilities (it is just bookkeeping).
\end{proof}



\section{Strictly perfect complexes}
\label{section-strictly-perfect}

\noindent
Strictly perfect complexes of modules are used to define the notions
of pseudo-coherent and perfect complexes later on. They are defined
as follows.

\begin{definition}
\label{definition-strictly-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{E}^\bullet$ be a complex of $\mathcal{O}_X$-modules.
We say $\mathcal{E}^\bullet$ is {\it strictly perfect}
if $\mathcal{E}^i$ is zero for all but finitely many $i$ and
$\mathcal{E}^i$ is a direct summand of a finite free
$\mathcal{O}_X$-module for all $i$.
\end{definition}

\noindent
Warning: Since we do not assume that $X$ is a locally ringed space,
it may not be true that a direct summand of a finite free
$\mathcal{O}_X$-module is finite locally free.

\begin{lemma}
\label{lemma-cone}
The cone on a morphism of strictly perfect complexes is
strictly perfect.
\end{lemma}

\begin{proof}
This is immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-tensor}
The total complex associated to the tensor product of two
strictly perfect complexes is strictly perfect.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-strictly-perfect-pullback}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. If $\mathcal{F}^\bullet$ is a strictly
perfect complex of $\mathcal{O}_Y$-modules, then
$f^*\mathcal{F}^\bullet$ is a strictly perfect complex of
$\mathcal{O}_X$-modules.
\end{lemma}

\begin{proof}
The pullback of a finite free module is finite free. The functor
$f^*$ is additive functor hence preserves direct summands. The lemma follows.
\end{proof}

\begin{lemma}
\label{lemma-local-lift-map}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Given a solid diagram of $\mathcal{O}_X$-modules
$$
\xymatrix{
\mathcal{E} \ar@{..>}[dr] \ar[r] & \mathcal{F} \\
& \mathcal{G} \ar[u]_p
}
$$
with $\mathcal{E}$ a direct summand of a finite free
$\mathcal{O}_X$-module and $p$ surjective, then a dotted arrow
making the diagram commute exists locally on $X$.
\end{lemma}

\begin{proof}
We may assume $\mathcal{E} = \mathcal{O}_X^{\oplus n}$ for some $n$.
In this case finding the dotted arrow is equivalent to lifting the
images of the basis elements in $\Gamma(X, \mathcal{F})$. This is
locally possible by the characterization of surjective maps of
sheaves (Sheaves, Section \ref{sheaves-section-exactness-points}).
\end{proof}

\begin{lemma}
\label{lemma-local-homotopy}
Let $(X, \mathcal{O}_X)$ be a ringed space.
\begin{enumerate}
\item Let $\alpha : \mathcal{E}^\bullet \to \mathcal{F}^\bullet$
be a morphism of complexes of $\mathcal{O}_X$-modules
with $\mathcal{E}^\bullet$ strictly perfect and $\mathcal{F}^\bullet$
acyclic. Then $\alpha$ is locally on $X$ homotopic to zero.
\item Let $\alpha : \mathcal{E}^\bullet \to \mathcal{F}^\bullet$
be a morphism of complexes of $\mathcal{O}_X$-modules
with $\mathcal{E}^\bullet$ strictly perfect, $\mathcal{E}^i = 0$
for $i < a$, and $H^i(\mathcal{F}^\bullet) = 0$ for $i \geq a$.
Then $\alpha$ is locally on $X$ homotopic to zero.
\end{enumerate}
\end{lemma}

\begin{proof}
The first statement follows from the second, hence we only prove (2).
We will prove this by induction on the length of the complex
$\mathcal{E}^\bullet$. If $\mathcal{E}^\bullet \cong \mathcal{E}[-n]$
for some direct summand $\mathcal{E}$ of a finite free
$\mathcal{O}_X$-module and integer $n \geq a$, then the result follows from
Lemma \ref{lemma-local-lift-map} and the fact that
$\mathcal{F}^{n - 1} \to \Ker(\mathcal{F}^n \to \mathcal{F}^{n + 1})$
is surjective by the assumed vanishing of $H^n(\mathcal{F}^\bullet)$.
If $\mathcal{E}^i$ is zero except for $i \in [a, b]$, then we have a
split exact sequence of complexes
$$
0 \to \mathcal{E}^b[-b] \to \mathcal{E}^\bullet \to
\sigma_{\leq b - 1}\mathcal{E}^\bullet \to 0
$$
which determines a distinguished triangle in
$K(\mathcal{O}_X)$. Hence an exact sequence
$$
\Hom_{K(\mathcal{O}_X)}(
\sigma_{\leq b - 1}\mathcal{E}^\bullet, \mathcal{F}^\bullet)
\to
\Hom_{K(\mathcal{O}_X)}(\mathcal{E}^\bullet, \mathcal{F}^\bullet)
\to
\Hom_{K(\mathcal{O}_X)}(\mathcal{E}^b[-b], \mathcal{F}^\bullet)
$$
by the axioms of triangulated categories. The composition
$\mathcal{E}^b[-b] \to \mathcal{F}^\bullet$ is locally homotopic to
zero, whence we may assume our map comes from an element in the
left hand side of the displayed exact sequence above. This element
is locally zero by induction hypothesis.
\end{proof}

\begin{lemma}
\label{lemma-lift-through-quasi-isomorphism}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Given a solid diagram of complexes of $\mathcal{O}_X$-modules
$$
\xymatrix{
\mathcal{E}^\bullet \ar@{..>}[dr] \ar[r]_\alpha & \mathcal{F}^\bullet \\
& \mathcal{G}^\bullet \ar[u]_f
}
$$
with $\mathcal{E}^\bullet$ strictly perfect, $\mathcal{E}^j = 0$ for
$j < a$ and $H^j(f)$ an isomorphism for $j > a$ and surjective for $j = a$,
then a dotted arrow making the diagram commute up to homotopy
exists locally on $X$.
\end{lemma}

\begin{proof}
Our assumptions on $f$ imply the cone $C(f)^\bullet$ has vanishing
cohomology sheaves in degrees $\geq a$.
Hence Lemma \ref{lemma-local-homotopy} guarantees there is an open
covering $X = \bigcup U_i$ such that the composition
$\mathcal{E}^\bullet \to \mathcal{F}^\bullet \to C(f)^\bullet$
is homotopic to zero over $U_i$. Since
$$
\mathcal{G}^\bullet \to \mathcal{F}^\bullet \to C(f)^\bullet \to
\mathcal{G}^\bullet[1]
$$
restricts to a distinguished triangle in $K(\mathcal{O}_{U_i})$
we see that we can lift $\alpha|_{U_i}$ up to homotopy to a map
$\alpha_i : \mathcal{E}^\bullet|_{U_i} \to \mathcal{G}^\bullet|_{U_i}$
as desired.
\end{proof}

\begin{lemma}
\label{lemma-local-actual}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{E}^\bullet$, $\mathcal{F}^\bullet$ be complexes
of $\mathcal{O}_X$-modules with $\mathcal{E}^\bullet$ strictly perfect.
\begin{enumerate}
\item For any element
$\alpha \in \Hom_{D(\mathcal{O}_X)}(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$
there exists an open covering $X = \bigcup U_i$ such that
$\alpha|_{U_i}$ is given by a morphism of complexes
$\alpha_i : \mathcal{E}^\bullet|_{U_i} \to \mathcal{F}^\bullet|_{U_i}$.
\item Given a morphism of complexes
$\alpha : \mathcal{E}^\bullet \to \mathcal{F}^\bullet$
whose image in the group
$\Hom_{D(\mathcal{O}_X)}(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$
is zero, there exists an open covering $X = \bigcup U_i$ such that
$\alpha|_{U_i}$ is homotopic to zero.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1).
By the construction of the derived category we can find a quasi-isomorphism
$f : \mathcal{F}^\bullet \to \mathcal{G}^\bullet$ and a map of complexes
$\beta : \mathcal{E}^\bullet \to \mathcal{G}^\bullet$ such that
$\alpha = f^{-1}\beta$. Thus the result follows from
Lemma \ref{lemma-lift-through-quasi-isomorphism}.
We omit the proof of (2).
\end{proof}

\begin{lemma}
\label{lemma-Rhom-strictly-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{E}^\bullet$, $\mathcal{F}^\bullet$ be complexes
of $\mathcal{O}_X$-modules with $\mathcal{E}^\bullet$ strictly perfect.
Then the internal hom $R\SheafHom(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$
is represented by the complex $\mathcal{H}^\bullet$ with terms
$$
\mathcal{H}^n =
\bigoplus\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{F}^p)
$$
and differential as described in Section \ref{section-hom-complexes}.
\end{lemma}

\begin{proof}
Choose a quasi-isomorphism $\mathcal{F}^\bullet \to \mathcal{I}^\bullet$
into a K-injective complex. Let $(\mathcal{H}')^\bullet$ be the
complex with terms
$$
(\mathcal{H}')^n =
\prod\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{I}^p)
$$
which represents $R\SheafHom(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$
by the construction in Section \ref{section-internal-hom}. It suffices
to show that the map
$$
\mathcal{H}^\bullet \longrightarrow (\mathcal{H}')^\bullet
$$
is a quasi-isomorphism. Given an open $U \subset X$ we have
by inspection
$$
H^0(\mathcal{H}^\bullet(U)) =
\Hom_{K(\mathcal{O}_U)}(\mathcal{E}^\bullet|_U, \mathcal{K}^\bullet|_U)
\to
H^0((\mathcal{H}')^\bullet(U)) =
\Hom_{D(\mathcal{O}_U)}(\mathcal{E}^\bullet|_U, \mathcal{K}^\bullet|_U)
$$
By Lemma \ref{lemma-local-actual} the sheafification of
$U \mapsto H^0(\mathcal{H}^\bullet(U))$
is equal to the sheafification of
$U \mapsto H^0((\mathcal{H}')^\bullet(U))$. A similar argument can be
given for the other cohomology sheaves. Thus $\mathcal{H}^\bullet$
is quasi-isomorphic to $(\mathcal{H}')^\bullet$ which proves the lemma.
\end{proof}

\begin{lemma}
\label{lemma-Rhom-strictly-perfect-K-flat}
In the situation of Lemma \ref{lemma-Rhom-strictly-perfect}
if $\mathcal{F}^\bullet$ is K-flat, then $\mathcal{H}^\bullet$ is K-flat.
\end{lemma}

\begin{proof}
Observe that $\mathcal{H}^\bullet$ is simply the hom complex
$\SheafHom^\bullet(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$
since the boundedness of the strictly prefect complex
$\mathcal{E}^\bullet$ insures that the products in the definition
of the hom complex turn into direct sums.
Let $\mathcal{K}^\bullet$ be an acyclic complex of
$\mathcal{O}_X$-modules. Consider the map
$$
\gamma :
\text{Tot}(\mathcal{K}^\bullet \otimes
\SheafHom^\bullet(\mathcal{E}^\bullet, \mathcal{F}^\bullet))
\longrightarrow
\SheafHom^\bullet(\mathcal{E}^\bullet,
\text{Tot}(\mathcal{K}^\bullet \otimes \mathcal{F}^\bullet))
$$
of Lemma \ref{lemma-diagonal-better}. Since $\mathcal{F}^\bullet$ is K-flat,
the complex $\text{Tot}(\mathcal{K}^\bullet \otimes \mathcal{F}^\bullet)$
is acyclic, and hence by Lemma \ref{lemma-local-actual}
(or Lemma \ref{lemma-Rhom-strictly-perfect} if you like)
the target of $\gamma$ is acyclic too. Hence to prove the lemma it suffices to
show that $\gamma$ is an isomorphism of complexes. To see this, we may argue
by induction on the length of the complex $\mathcal{E}^\bullet$.
If the length is $\leq 1$ then the $\mathcal{E}^\bullet$
is a direct summand of $\mathcal{O}_X^{\oplus n}[k]$ for some
$n \geq 0$ and $k \in \mathbf{Z}$ and in this case the result
follows by inspection. If the length is $> 1$, then we reduce
to smaller length by considering the termwise split short exact
sequence of complexes
$$
0 \to \sigma_{\geq a + 1} \mathcal{E}^\bullet \to
\mathcal{E}^\bullet \to
\sigma_{\leq a} \mathcal{E}^\bullet \to 0
$$
for a suitable $a \in \mathbf{Z}$, see
Homology, Section \ref{homology-section-truncations}.
Then $\gamma$ fits into a morphism of termwise split
short exact sequences of complexes.
By induction $\gamma$ is an isomorphism for
$\sigma_{\geq a + 1} \mathcal{E}^\bullet$
and $\sigma_{\leq a} \mathcal{E}^\bullet$ and hence the result for
$\mathcal{E}^\bullet$ follows. Some details omitted.
\end{proof}

\begin{lemma}
\label{lemma-Rhom-complex-of-direct-summands-finite-free}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{E}^\bullet$, $\mathcal{F}^\bullet$ be complexes
of $\mathcal{O}_X$-modules with
\begin{enumerate}
\item $\mathcal{F}^n = 0$ for $n \ll 0$,
\item $\mathcal{E}^n = 0$ for $n \gg 0$, and
\item $\mathcal{E}^n$ isomorphic to a direct summand of a finite
free $\mathcal{O}_X$-module.
\end{enumerate}
Then the internal hom $R\SheafHom(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$
is represented by the complex $\mathcal{H}^\bullet$ with terms
$$
\mathcal{H}^n =
\bigoplus\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{F}^p)
$$
and differential as described in Section \ref{section-internal-hom}.
\end{lemma}

\begin{proof}
Choose a quasi-isomorphism $\mathcal{F}^\bullet \to \mathcal{I}^\bullet$
where $\mathcal{I}^\bullet$ is a bounded below complex of injectives.
Note that $\mathcal{I}^\bullet$ is K-injective
(Derived Categories, Lemma
\ref{derived-lemma-bounded-below-injectives-K-injective}).
Hence the construction in Section \ref{section-internal-hom}
shows that
$R\SheafHom(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$ is 
represented by the complex $(\mathcal{H}')^\bullet$ with terms
$$
(\mathcal{H}')^n =
\prod\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{I}^p) =
\bigoplus\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{I}^p)
$$
(equality because there are only finitely many nonzero terms).
Note that $\mathcal{H}^\bullet$ is the total complex associated to
the double complex with terms
$\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{F}^p)$
and similarly for $(\mathcal{H}')^\bullet$.
The natural map $(\mathcal{H}')^\bullet \to \mathcal{H}^\bullet$
comes from a map of double complexes.
Thus to show this map is a quasi-isomorphism, we may use the spectral
sequence of a double complex
(Homology, Lemma \ref{homology-lemma-first-quadrant-ss})
$$
{}'E_1^{p, q} =
H^p(\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{F}^\bullet))
$$
converging to $H^{p + q}(\mathcal{H}^\bullet)$ and similarly for
$(\mathcal{H}')^\bullet$. To finish the proof of the lemma it
suffices to show that $\mathcal{F}^\bullet \to \mathcal{I}^\bullet$
induces an isomorphism
$$
H^p(\SheafHom_{\mathcal{O}_X}(\mathcal{E}, \mathcal{F}^\bullet))
\longrightarrow
H^p(\SheafHom_{\mathcal{O}_X}(\mathcal{E}, \mathcal{I}^\bullet))
$$
on cohomology sheaves whenever $\mathcal{E}$ is a direct summand of a
finite free $\mathcal{O}_X$-module. Since this is clear when $\mathcal{E}$
is finite free the result follows.
\end{proof}





\section{Pseudo-coherent modules}
\label{section-pseudo-coherent}

\noindent
In this section we discuss pseudo-coherent complexes.

\begin{definition}
\label{definition-pseudo-coherent}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{E}^\bullet$
be a complex of $\mathcal{O}_X$-modules. Let $m \in \mathbf{Z}$.
\begin{enumerate}
\item We say $\mathcal{E}^\bullet$ is {\it $m$-pseudo-coherent}
if there exists an open covering $X = \bigcup U_i$ and for each $i$
a morphism of complexes
$\alpha_i : \mathcal{E}_i^\bullet \to \mathcal{E}^\bullet|_{U_i}$
where $\mathcal{E}_i$ is strictly perfect on $U_i$ and
$H^j(\alpha_i)$ is an isomorphism for $j > m$ and $H^m(\alpha_i)$
is surjective.
\item We say $\mathcal{E}^\bullet$ is {\it pseudo-coherent}
if it is $m$-pseudo-coherent for all $m$.
\item We say an object $E$ of $D(\mathcal{O}_X)$ is
{\it $m$-pseudo-coherent} (resp.\ {\it pseudo-coherent})
if and only if it can be represented by a $m$-pseudo-coherent
(resp.\ pseudo-coherent) complex of $\mathcal{O}_X$-modules.
\end{enumerate}
\end{definition}

\noindent
If $X$ is quasi-compact, then an $m$-pseudo-coherent object
of $D(\mathcal{O}_X)$ is in $D^-(\mathcal{O}_X)$. But this need
not be the case if $X$ is not quasi-compact.

\begin{lemma}
\label{lemma-pseudo-coherent-independent-representative}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $E$ be an object
of $D(\mathcal{O}_X)$.
\begin{enumerate}
\item If there exists an open covering $X = \bigcup U_i$,
strictly perfect complexes $\mathcal{E}_i^\bullet$ on $U_i$, and
maps $\alpha_i : \mathcal{E}_i^\bullet \to E|_{U_i}$ in
$D(\mathcal{O}_{U_i})$ with $H^j(\alpha_i)$ an isomorphism for $j > m$
and $H^m(\alpha_i)$ surjective, then $E$ is $m$-pseudo-coherent.
\item If $E$ is $m$-pseudo-coherent, then any complex representing
$E$ is $m$-pseudo-coherent.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $\mathcal{F}^\bullet$ be any complex representing $E$
and let $X = \bigcup U_i$ and
$\alpha_i : \mathcal{E}_i^\bullet \to E|_{U_i}$ be as in (1).
We will show that $\mathcal{F}^\bullet$ is $m$-pseudo-coherent
as a complex, which will prove (1) and (2) simultaneously.
By Lemma \ref{lemma-local-actual}
we can after refining the open covering $X = \bigcup U_i$
represent the maps $\alpha_i$ by maps of complexes
$\alpha_i : \mathcal{E}_i^\bullet \to \mathcal{F}^\bullet|_{U_i}$.
By assumption
$H^j(\alpha_i)$ are isomorphisms for $j > m$, and $H^m(\alpha_i)$
is surjective whence $\mathcal{F}^\bullet$ is
$m$-pseudo-coherent.
\end{proof}

\begin{lemma}
\label{lemma-pseudo-coherent-pullback}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$
be a morphism of ringed spaces. Let $E$ be an object of
$D(\mathcal{O}_Y)$. If $E$ is $m$-pseudo-coherent,
then $Lf^*E$ is $m$-pseudo-coherent.
\end{lemma}

\begin{proof}
Represent $E$ by a complex $\mathcal{E}^\bullet$ of $\mathcal{O}_Y$-modules
and choose an open covering $Y = \bigcup V_i$ and
$\alpha_i : \mathcal{E}_i^\bullet \to \mathcal{E}^\bullet|_{V_i}$
as in Definition \ref{definition-pseudo-coherent}.
Set $U_i = f^{-1}(V_i)$.
By Lemma \ref{lemma-pseudo-coherent-independent-representative}
it suffices to show that $Lf^*\mathcal{E}^\bullet|_{U_i}$ is
$m$-pseudo-coherent.
Choose a distinguished triangle
$$
\mathcal{E}_i^\bullet \to
\mathcal{E}^\bullet|_{V_i} \to
C \to
\mathcal{E}_i^\bullet[1]
$$
The assumption on $\alpha_i$ means exactly that the cohomology sheaves
$H^j(C)$ are zero for all $j \geq m$. Denote $f_i : U_i \to V_i$
the restriction of $f$. Note that $Lf^*\mathcal{E}^\bullet|_{U_i} = 
Lf_i^*(\mathcal{E}|_{V_i})$. Applying $Lf_i^*$ we obtain
the distinguished triangle
$$
Lf_i^*\mathcal{E}_i^\bullet \to
Lf_i^*\mathcal{E}|_{V_i} \to
Lf_i^*C \to
Lf_i^*\mathcal{E}_i^\bullet[1]
$$
By the construction of $Lf_i^*$ as a left derived functor we see that
$H^j(Lf_i^*C) = 0$ for $j \geq m$ (by the dual of Derived Categories, Lemma
\ref{derived-lemma-negative-vanishing}). Hence $H^j(Lf_i^*\alpha_i)$ is an
isomorphism for $j > m$ and $H^m(Lf^*\alpha_i)$ is surjective.
On the other hand,
$Lf_i^*\mathcal{E}_i^\bullet = f_i^*\mathcal{E}_i^\bullet$.
is strictly perfect by Lemma \ref{lemma-strictly-perfect-pullback}.
Thus we conclude.
\end{proof}

\begin{lemma}
\label{lemma-cone-pseudo-coherent}
Let $(X, \mathcal{O}_X)$ be a ringed space and $m \in \mathbf{Z}$.
Let $(K, L, M, f, g, h)$ be a distinguished triangle in $D(\mathcal{O}_X)$.
\begin{enumerate}
\item If $K$ is $(m + 1)$-pseudo-coherent and $L$ is $m$-pseudo-coherent
then $M$ is $m$-pseudo-coherent.
\item If $K$ and $M$ are $m$-pseudo-coherent, then $L$ is $m$-pseudo-coherent.
\item If $L$ is $(m + 1)$-pseudo-coherent and $M$
is $m$-pseudo-coherent, then $K$ is $(m + 1)$-pseudo-coherent.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). Choose an open covering $X = \bigcup U_i$ and
maps $\alpha_i : \mathcal{K}_i^\bullet \to K|_{U_i}$ in $D(\mathcal{O}_{U_i})$
with $\mathcal{K}_i^\bullet$ strictly perfect and $H^j(\alpha_i)$
isomorphisms for $j > m + 1$ and surjective for $j = m + 1$.
We may replace $\mathcal{K}_i^\bullet$ by
$\sigma_{\geq m + 1}\mathcal{K}_i^\bullet$
and hence we may assume that $\mathcal{K}_i^j = 0$
for $j < m + 1$. After refining the open covering we may choose
maps $\beta_i : \mathcal{L}_i^\bullet \to L|_{U_i}$ in $D(\mathcal{O}_{U_i})$
with $\mathcal{L}_i^\bullet$ strictly perfect such that
$H^j(\beta)$ is an isomorphism for $j > m$ and
surjective for $j = m$. By
Lemma \ref{lemma-lift-through-quasi-isomorphism}
we can, after refining the covering, find maps of complexes
$\gamma_i : \mathcal{K}^\bullet \to \mathcal{L}^\bullet$
such that the diagrams
$$
\xymatrix{
K|_{U_i} \ar[r] & L|_{U_i} \\
\mathcal{K}_i^\bullet \ar[u]^{\alpha_i} \ar[r]^{\gamma_i} &
\mathcal{L}_i^\bullet \ar[u]_{\beta_i}
}
$$
are commutative in $D(\mathcal{O}_{U_i})$ (this requires representing the
maps $\alpha_i$, $\beta_i$ and $K|_{U_i} \to L|_{U_i}$
by actual maps of complexes; some details omitted).
The cone $C(\gamma_i)^\bullet$ is strictly perfect (Lemma \ref{lemma-cone}).
The commutativity of the diagram implies that there exists a morphism
of distinguished triangles
$$
(\mathcal{K}_i^\bullet, \mathcal{L}_i^\bullet, C(\gamma_i)^\bullet)
\longrightarrow
(K|_{U_i}, L|_{U_i}, M|_{U_i}).
$$
It follows from the induced map on long exact cohomology sequences and
Homology, Lemmas \ref{homology-lemma-four-lemma} and
\ref{homology-lemma-five-lemma}
that $C(\gamma_i)^\bullet \to M|_{U_i}$ induces an isomorphism
on cohomology in degrees $> m$ and a surjection in degree $m$.
Hence $M$ is $m$-pseudo-coherent by
Lemma \ref{lemma-pseudo-coherent-independent-representative}.

\medskip\noindent
Assertions (2) and (3) follow from (1) by rotating the distinguished
triangle.
\end{proof}

\begin{lemma}
\label{lemma-tensor-pseudo-coherent}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L$ be objects
of $D(\mathcal{O}_X)$.
\begin{enumerate}
\item If $K$ is $n$-pseudo-coherent and $H^i(K) = 0$ for $i > a$
and $L$ is $m$-pseudo-coherent and $H^j(L) = 0$ for $j > b$, then
$K \otimes_{\mathcal{O}_X}^\mathbf{L} L$ is $t$-pseudo-coherent
with $t = \max(m + a, n + b)$.
\item If $K$ and $L$ are pseudo-coherent, then
$K \otimes_{\mathcal{O}_X}^\mathbf{L} L$ is pseudo-coherent.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). By replacing $X$ by the members of an open covering
we may assume there exist strictly perfect complexes $\mathcal{K}^\bullet$
and $\mathcal{L}^\bullet$ and maps
$\alpha : \mathcal{K}^\bullet \to K$ and
$\beta : \mathcal{L}^\bullet \to L$ with $H^i(\alpha)$ and isomorphism
for $i > n$ and surjective for $i = n$ and with
$H^i(\beta)$ and isomorphism for $i > m$ and surjective for $i = m$.
Then the map
$$
\alpha \otimes^\mathbf{L} \beta :
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{L}^\bullet)
\to K \otimes_{\mathcal{O}_X}^\mathbf{L} L
$$
induces isomorphisms on cohomology sheaves in degree $i$ for
$i > t$ and a surjection for $i = t$. This follows from the
spectral sequence of tors (details omitted).

\medskip\noindent
Proof of (2). We may first replace $X$ by the members of an open
covering to reduce to the case that $K$ and $L$ are bounded above.
Then the statement follows immediately from case (1).
\end{proof}

\begin{lemma}
\label{lemma-summands-pseudo-coherent}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $m \in \mathbf{Z}$.
If $K \oplus L$ is $m$-pseudo-coherent (resp.\ pseudo-coherent)
in $D(\mathcal{O}_X)$ so are $K$ and $L$.
\end{lemma}

\begin{proof}
Assume that $K \oplus L$ is $m$-pseudo-coherent.
After replacing $X$ by the members of an open covering we may
assume $K \oplus L \in D^-(\mathcal{O}_X)$, hence
$L \in D^-(\mathcal{O}_X)$.
Note that there is a distinguished triangle
$$
(K \oplus L, K \oplus L, L \oplus L[1]) =
(K, K, 0) \oplus (L, L, L \oplus L[1])
$$
see
Derived Categories, Lemma \ref{derived-lemma-direct-sum-triangles}.
By
Lemma \ref{lemma-cone-pseudo-coherent}
we see that $L \oplus L[1]$ is $m$-pseudo-coherent.
Hence also $L[1] \oplus L[2]$ is $m$-pseudo-coherent.
By induction $L[n] \oplus L[n + 1]$ is $m$-pseudo-coherent.
Since $L$ is bounded above we see that $L[n]$ is $m$-pseudo-coherent
for large $n$. Hence working backwards, using the distinguished triangles
$$
(L[n], L[n] \oplus L[n - 1], L[n - 1])
$$
we conclude that $L[n - 1], L[n - 2], \ldots, L$ are $m$-pseudo-coherent
as desired.
\end{proof}

\begin{lemma}
\label{lemma-complex-pseudo-coherent-modules}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $m \in \mathbf{Z}$. Let $\mathcal{F}^\bullet$ be a (locally) bounded
above complex of $\mathcal{O}_X$-modules such that
$\mathcal{F}^i$ is $(m - i)$-pseudo-coherent for all $i$.
Then $\mathcal{F}^\bullet$ is $m$-pseudo-coherent.
\end{lemma}

\begin{proof}
Omitted. Hint: use Lemma \ref{lemma-cone-pseudo-coherent} and truncations
as in the proof of
More on Algebra, Lemma \ref{more-algebra-lemma-complex-pseudo-coherent-modules}.
\end{proof}

\begin{lemma}
\label{lemma-cohomology-pseudo-coherent}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $m \in \mathbf{Z}$. Let
$E$ be an object of $D(\mathcal{O}_X)$. If $E$ is (locally) bounded above
and $H^i(E)$ is $(m - i)$-pseudo-coherent for all $i$, then
$E$ is $m$-pseudo-coherent.
\end{lemma}

\begin{proof}
Omitted. Hint: use Lemma \ref{lemma-cone-pseudo-coherent} and truncations
as in the proof of
More on Algebra, Lemma \ref{more-algebra-lemma-cohomology-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-finite-cohomology}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $K$ be an object of $D(\mathcal{O}_X)$.
Let $m \in \mathbf{Z}$.
\begin{enumerate}
\item If $K$ is $m$-pseudo-coherent and $H^i(K) = 0$
for $i > m$, then $H^m(K)$ is a finite type $\mathcal{O}_X$-module.
\item If $K$ is $m$-pseudo-coherent and $H^i(K) = 0$
for $i > m + 1$, then $H^{m + 1}(K)$ is a finitely presented
$\mathcal{O}_X$-module.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). We may work locally on $X$. Hence we may assume there exists
a strictly perfect complex $\mathcal{E}^\bullet$ and a map
$\alpha : \mathcal{E}^\bullet \to K$ which induces
an isomorphism on cohomology in degrees $> m$ and a surjection in degree $m$.
It suffices to prove the result for $\mathcal{E}^\bullet$.
Let $n$ be the largest integer such that $\mathcal{E}^n \not = 0$.
If $n = m$, then $H^m(\mathcal{E}^\bullet)$ is a quotient of
$\mathcal{E}^n$ and the result is clear.
If $n > m$, then $\mathcal{E}^{n - 1} \to \mathcal{E}^n$ is surjective as
$H^n(E^\bullet) = 0$. By Lemma \ref{lemma-local-lift-map}
we can locally find a section of this surjection and write
$\mathcal{E}^{n - 1} = \mathcal{E}' \oplus \mathcal{E}^n$.
Hence it suffices to prove the result for the complex
$(\mathcal{E}')^\bullet$ which is the same as $\mathcal{E}^\bullet$
except has $\mathcal{E}'$ in degree $n - 1$ and $0$ in degree $n$.
We win by induction on $n$.

\medskip\noindent
Proof of (2). We may work locally on $X$. Hence we may assume there exists
a strictly perfect complex $\mathcal{E}^\bullet$ and a map
$\alpha : \mathcal{E}^\bullet \to K$ which induces
an isomorphism on cohomology in degrees $> m$ and a surjection in degree $m$.
As in the proof of (1) we can reduce to the case that $\mathcal{E}^i = 0$
for $i > m + 1$. Then we see that
$H^{m + 1}(K) \cong H^{m + 1}(\mathcal{E}^\bullet) =
\Coker(\mathcal{E}^m \to \mathcal{E}^{m + 1})$
which is of finite presentation.
\end{proof}

\begin{lemma}
\label{lemma-n-pseudo-module}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}$ be a sheaf
of $\mathcal{O}_X$-modules.
\begin{enumerate}
\item $\mathcal{F}$ viewed as an object of $D(\mathcal{O}_X)$ is
$0$-pseudo-coherent if and only if $\mathcal{F}$ is a finite type
$\mathcal{O}_X$-module, and
\item $\mathcal{F}$ viewed as an object of $D(\mathcal{O}_X)$ is
$(-1)$-pseudo-coherent if and only if $\mathcal{F}$ is an
$\mathcal{O}_X$-module of finite presentation.
\end{enumerate}
\end{lemma}

\begin{proof}
Use Lemma \ref{lemma-finite-cohomology}
to prove the implications in one direction and
Lemma \ref{lemma-cohomology-pseudo-coherent} for the other.
\end{proof}





\section{Tor dimension}
\label{section-tor}

\noindent
In this section we take a closer look at resolutions by flat modules.

\begin{definition}
\label{definition-tor-amplitude}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $E$ be an object of $D(\mathcal{O}_X)$.
Let $a, b \in \mathbf{Z}$ with $a \leq b$.
\begin{enumerate}
\item We say $E$ has {\it tor-amplitude in $[a, b]$}
if $H^i(E \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{F}) = 0$
for all $\mathcal{O}_X$-modules $\mathcal{F}$ and all $i \not \in [a, b]$.
\item We say $E$ has {\it finite tor dimension}
if it has tor-amplitude in $[a, b]$ for some $a, b$.
\item We say $E$ {\it locally has finite tor dimension}
if there exists an open covering $X = \bigcup U_i$ such that
$E|_{U_i}$ has finite tor dimension for all $i$.
\end{enumerate}
An $\mathcal{O}_X$-module $\mathcal{F}$ has {\it tor dimension $\leq d$}
if $\mathcal{F}[0]$ viewed as an object of $D(\mathcal{O}_X)$ has
tor-amplitude in $[-d, 0]$.
\end{definition}

\noindent
Note that if $E$ as in the definition
has finite tor dimension, then $E$ is an object of
$D^b(\mathcal{O}_X)$ as can be seen by taking $\mathcal{F} = \mathcal{O}_X$
in the definition above.

\begin{lemma}
\label{lemma-last-one-flat}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{E}^\bullet$ be a bounded above complex of flat
$\mathcal{O}_X$-modules with tor-amplitude in $[a, b]$.
Then $\Coker(d_{\mathcal{E}^\bullet}^{a - 1})$ is a flat
$\mathcal{O}_X$-module.
\end{lemma}

\begin{proof}
As $\mathcal{E}^\bullet$ is a bounded above complex of flat modules we see that
$\mathcal{E}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F} =
\mathcal{E}^\bullet \otimes_{\mathcal{O}_X}^{\mathbf{L}} \mathcal{F}$
for any $\mathcal{O}_X$-module $\mathcal{F}$.
Hence for every $\mathcal{O}_X$-module $\mathcal{F}$ the sequence
$$
\mathcal{E}^{a - 2} \otimes_{\mathcal{O}_X} \mathcal{F} \to
\mathcal{E}^{a - 1} \otimes_{\mathcal{O}_X} \mathcal{F} \to
\mathcal{E}^a \otimes_{\mathcal{O}_X} \mathcal{F}
$$
is exact in the middle. Since
$\mathcal{E}^{a - 2} \to \mathcal{E}^{a - 1} \to \mathcal{E}^a \to
\Coker(d^{a - 1}) \to 0$
is a flat resolution this implies that
$\text{Tor}_1^{\mathcal{O}_X}(\Coker(d^{a - 1}), \mathcal{F}) = 0$
for all $\mathcal{O}_X$-modules $\mathcal{F}$. This means that
$\Coker(d^{a - 1})$ is flat, see Lemma \ref{lemma-flat-tor-zero}.
\end{proof}

\begin{lemma}
\label{lemma-tor-amplitude}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $E$ be an object of $D(\mathcal{O}_X)$.
Let $a, b \in \mathbf{Z}$ with $a \leq b$. The following are equivalent
\begin{enumerate}
\item $E$ has tor-amplitude in $[a, b]$.
\item $E$ is represented by a complex
$\mathcal{E}^\bullet$ of flat $\mathcal{O}_X$-modules with
$\mathcal{E}^i = 0$ for $i \not \in [a, b]$.
\end{enumerate}
\end{lemma}

\begin{proof}
If (2) holds, then we may compute
$E \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{F} =
\mathcal{E}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}$
and it is clear that (1) holds.

\medskip\noindent
Assume that (1) holds. We may represent $E$ by a bounded above complex
of flat $\mathcal{O}_X$-modules $\mathcal{K}^\bullet$, see
Section \ref{section-flat}.
Let $n$ be the largest integer such that $\mathcal{K}^n \not = 0$.
If $n > b$, then $\mathcal{K}^{n - 1} \to \mathcal{K}^n$ is surjective as
$H^n(\mathcal{K}^\bullet) = 0$. As $\mathcal{K}^n$ is flat we see that
$\Ker(\mathcal{K}^{n - 1} \to \mathcal{K}^n)$ is flat
(Modules, Lemma \ref{modules-lemma-flat-ses}).
Hence we may replace $\mathcal{K}^\bullet$ by
$\tau_{\leq n - 1}\mathcal{K}^\bullet$. Thus, by induction on $n$, we
reduce to the case that $K^\bullet$ is a complex of flat
$\mathcal{O}_X$-modules with $\mathcal{K}^i = 0$ for $i > b$.

\medskip\noindent
Set $\mathcal{E}^\bullet = \tau_{\geq a}\mathcal{K}^\bullet$.
Everything is clear except that $\mathcal{E}^a$ is flat
which follows immediately from Lemma \ref{lemma-last-one-flat}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-tor-amplitude-pullback}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of ringed
spaces. Let $E$ be an object of $D(\mathcal{O}_Y)$.
If $E$ has tor amplitude in $[a, b]$, then $Lf^*E$ has tor amplitude in
$[a, b]$.
\end{lemma}

\begin{proof}
Assume $E$ has tor amplitude in $[a, b]$. By
Lemma \ref{lemma-tor-amplitude}
we can represent $E$ by a complex of
$\mathcal{E}^\bullet$ of flat $\mathcal{O}$-modules with
$\mathcal{E}^i = 0$ for $i \not \in [a, b]$. Then
$Lf^*E$ is represented by $f^*\mathcal{E}^\bullet$.
By Modules, Lemma \ref{modules-lemma-pullback-flat}
the modules $f^*\mathcal{E}^i$ are flat.
Thus by Lemma \ref{lemma-tor-amplitude}
we conclude that $Lf^*E$ has tor amplitude in $[a, b]$.
\end{proof}

\begin{lemma}
\label{lemma-tor-amplitude-stalk}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $E$ be an object of $D(\mathcal{O}_X)$.
Let $a, b \in \mathbf{Z}$ with $a \leq b$. The following are equivalent
\begin{enumerate}
\item $E$ has tor-amplitude in $[a, b]$.
\item for every $x \in X$ the object $E_x$ of $D(\mathcal{O}_{X, x})$
has tor-amplitude in $[a, b]$.
\end{enumerate}
\end{lemma}

\begin{proof}
Taking stalks at $x$ is the same thing as pulling back by the
morphism of ringed spaces $(x, \mathcal{O}_{X, x}) \to (X, \mathcal{O}_X)$.
Hence the implication (1) $\Rightarrow$ (2) follows from
Lemma \ref{lemma-tor-amplitude-pullback}.
For the converse, note that taking stalks commutes with tensor
products (Modules, Lemma \ref{modules-lemma-stalk-tensor-product}).
Hence
$$
(E \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{F})_x =
E_x \otimes_{\mathcal{O}_{X, x}}^\mathbf{L} \mathcal{F}_x
$$
On the other hand, taking stalks is exact, so
$$
H^i(E \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{F})_x =
H^i((E \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{F})_x) =
H^i(E_x \otimes_{\mathcal{O}_{X, x}}^\mathbf{L} \mathcal{F}_x)
$$
and we can check whether
$H^i(E \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{F})$ is zero
by checking whether all of its stalks are zero
(Modules, Lemma \ref{modules-lemma-abelian}). Thus (2) implies (1).
\end{proof}

\begin{lemma}
\label{lemma-cone-tor-amplitude}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $(K, L, M, f, g, h)$ be a distinguished
triangle in $D(\mathcal{O}_X)$. Let $a, b \in \mathbf{Z}$.
\begin{enumerate}
\item If $K$ has tor-amplitude in $[a + 1, b + 1]$ and
$L$ has tor-amplitude in $[a, b]$ then $M$ has
tor-amplitude in $[a, b]$.
\item If $K$ and $M$ have tor-amplitude in $[a, b]$, then
$L$ has tor-amplitude in $[a, b]$.
\item If $L$ has tor-amplitude in $[a + 1, b + 1]$
and $M$ has tor-amplitude in $[a, b]$, then
$K$ has tor-amplitude in $[a + 1, b + 1]$.
\end{enumerate}
\end{lemma}

\begin{proof}
Omitted. Hint: This just follows from the long exact cohomology sequence
associated to a distinguished triangle and the fact that
$- \otimes_{\mathcal{O}_X}^{\mathbf{L}} \mathcal{F}$
preserves distinguished triangles.
The easiest one to prove is (2) and the others follow from it by
translation.
\end{proof}

\begin{lemma}
\label{lemma-tensor-tor-amplitude}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L$ be objects of
$D(\mathcal{O}_X)$. If $K$ has tor-amplitude in $[a, b]$ and
$L$ has tor-amplitude in $[c, d]$ then $K \otimes_{\mathcal{O}_X}^\mathbf{L} L$
has tor amplitude in $[a + c, b + d]$.
\end{lemma}

\begin{proof}
Omitted. Hint: use the spectral sequence for tors.
\end{proof}

\begin{lemma}
\label{lemma-summands-tor-amplitude}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $a, b \in \mathbf{Z}$.
For $K$, $L$ objects of $D(\mathcal{O}_X)$ if $K \oplus L$ has tor
amplitude in $[a, b]$ so do $K$ and $L$.
\end{lemma}

\begin{proof}
Clear from the fact that the Tor functors are additive.
\end{proof}






\section{Perfect complexes}
\label{section-perfect}

\noindent
In this section we discuss properties of perfect complexes on
ringed spaces.

\begin{definition}
\label{definition-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $\mathcal{E}^\bullet$ be a complex of $\mathcal{O}_X$-modules.
We say $\mathcal{E}^\bullet$ is {\it perfect} if there exists
an open covering $X = \bigcup U_i$ such that for each $i$
there exists a morphism of complexes
$\mathcal{E}_i^\bullet \to \mathcal{E}^\bullet|_{U_i}$
which is a quasi-isomorphism with $\mathcal{E}_i^\bullet$
a strictly perfect complex of $\mathcal{O}_{U_i}$-modules.
An object $E$ of $D(\mathcal{O}_X)$ is {\it perfect}
if it can be represented by a perfect complex of $\mathcal{O}_X$-modules.
\end{definition}

\begin{lemma}
\label{lemma-perfect-independent-representative}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $E$ be an object of $D(\mathcal{O}_X)$.
\begin{enumerate}
\item If there exists an open covering $X = \bigcup U_i$ and
strictly perfect complexes $\mathcal{E}_i^\bullet$ on $U_i$
such that $\mathcal{E}_i^\bullet$ represents $E|_{U_i}$ in
$D(\mathcal{O}_{U_i})$, then $E$ is perfect.
\item If $E$ is perfect, then any complex representing $E$ is perfect.
\end{enumerate}
\end{lemma}

\begin{proof}
Identical to the proof of
Lemma \ref{lemma-pseudo-coherent-independent-representative}.
\end{proof}

\begin{lemma}
\label{lemma-perfect-on-locally-ringed}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $E$ be an object of
$D(\mathcal{O}_X)$. Assume that all stalks $\mathcal{O}_{X, x}$
are local rings. Then the following are equivalent
\begin{enumerate}
\item $E$ is perfect,
\item there exists an open covering $X = \bigcup U_i$ such that
$E|_{U_i}$ can be represented by a finite complex of finite locally
free $\mathcal{O}_{U_i}$-modules, and
\item there exists an open covering $X = \bigcup U_i$ such that
$E|_{U_i}$ can be represented by a finite complex of finite
free $\mathcal{O}_{U_i}$-modules.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows from Lemma \ref{lemma-perfect-independent-representative}
and the fact that on $X$ every direct summand of a finite free module
is finite locally free. See Modules, Lemma
\ref{modules-lemma-direct-summand-of-locally-free-is-locally-free}.
\end{proof}

\begin{lemma}
\label{lemma-perfect-precise}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $E$ be an object of $D(\mathcal{O}_X)$.
Let $a \leq b$ be integers. If $E$ has tor amplitude in $[a, b]$
and is $(a - 1)$-pseudo-coherent, then $E$ is perfect.
\end{lemma}

\begin{proof}
After replacing $X$ by the members of an open covering we may assume there
exists a strictly perfect complex $\mathcal{E}^\bullet$ and a map
$\alpha : \mathcal{E}^\bullet \to E$ such that $H^i(\alpha)$ is an isomorphism
for $i \geq a$. We may and do replace $\mathcal{E}^\bullet$ by
$\sigma_{\geq a - 1}\mathcal{E}^\bullet$. Choose a distinguished triangle
$$
\mathcal{E}^\bullet \to E \to C \to \mathcal{E}^\bullet[1]
$$
From the vanishing of cohomology sheaves of $E$ and $\mathcal{E}^\bullet$
and the assumption on $\alpha$ we obtain $C \cong \mathcal{K}[a - 2]$ with
$\mathcal{K} = \Ker(\mathcal{E}^{a - 1} \to \mathcal{E}^a)$.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
Applying $- \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{F}$
the assumption that $E$ has tor amplitude in $[a, b]$
implies $\mathcal{K} \otimes_{\mathcal{O}_X} \mathcal{F} \to
\mathcal{E}^{a - 1} \otimes_{\mathcal{O}_X} \mathcal{F}$ has image
$\Ker(\mathcal{E}^{a - 1} \otimes_{\mathcal{O}_X} \mathcal{F}
\to \mathcal{E}^a \otimes_{\mathcal{O}_X} \mathcal{F})$.
It follows that $\text{Tor}_1^{\mathcal{O}_X}(\mathcal{E}', \mathcal{F}) = 0$
where $\mathcal{E}' = \Coker(\mathcal{E}^{a - 1} \to \mathcal{E}^a)$.
Hence $\mathcal{E}'$ is flat (Lemma \ref{lemma-flat-tor-zero}).
Thus $\mathcal{E}'$ is locally a direct summand of a finite free module by
Modules, Lemma \ref{modules-lemma-flat-locally-finite-presentation}.
Thus locally the complex
$$
\mathcal{E}' \to \mathcal{E}^{a - 1} \to \ldots \to \mathcal{E}^b
$$
is quasi-isomorphic to $E$ and $E$ is perfect.
\end{proof}

\begin{lemma}
\label{lemma-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Let $E$ be an object of $D(\mathcal{O}_X)$.
The following are equivalent
\begin{enumerate}
\item $E$ is perfect, and
\item $E$ is pseudo-coherent and locally has finite tor dimension.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1). By definition this means there exists an open covering
$X = \bigcup U_i$ such that $E|_{U_i}$ is represented by a
strictly perfect complex. Thus $E$ is pseudo-coherent (i.e.,
$m$-pseudo-coherent for all $m$) by
Lemma \ref{lemma-pseudo-coherent-independent-representative}.
Moreover, a direct summand of a finite free module is flat, hence
$E|_{U_i}$ has finite Tor dimension by
Lemma \ref{lemma-tor-amplitude}. Thus (2) holds.

\medskip\noindent
Assume (2). After replacing $X$ by the members of an open covering
we may assume there exist integers $a \leq b$ such that $E$
has tor amplitude in $[a, b]$. Since $E$ is $m$-pseudo-coherent
for all $m$ we conclude using Lemma \ref{lemma-perfect-precise}.
\end{proof}

\begin{lemma}
\label{lemma-perfect-pullback}
Let $f : (X, \mathcal{O}_X) \to (Y, \mathcal{O}_Y)$ be a morphism of ringed
spaces. Let $E$ be an object of $D(\mathcal{O}_Y)$. If $E$ is perfect in
$D(\mathcal{O}_Y)$, then $Lf^*E$ is perfect in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This follows from Lemma \ref{lemma-perfect},
\ref{lemma-tor-amplitude-pullback}, and
\ref{lemma-pseudo-coherent-pullback}.
(An alternative proof is to copy the proof of
Lemma \ref{lemma-pseudo-coherent-pullback}.)
\end{proof}

\begin{lemma}
\label{lemma-two-out-of-three-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(K, L, M, f, g, h)$
be a distinguished triangle in $D(\mathcal{O}_X)$. If two out of three of
$K, L, M$ are perfect then the third is also perfect.
\end{lemma}

\begin{proof}
First proof: Combine
Lemmas \ref{lemma-perfect}, \ref{lemma-cone-pseudo-coherent}, and
\ref{lemma-cone-tor-amplitude}.
Second proof (sketch): Say $K$ and $L$ are perfect. After replacing
$X$ by the members of an open covering we may assume that $K$ and $L$
are represented by strictly perfect complexes $\mathcal{K}^\bullet$
and $\mathcal{L}^\bullet$. After replacing $X$ by the members
of an open covering we may assume the map $K \to L$ is given by
a map of complexes $\alpha : \mathcal{K}^\bullet \to \mathcal{L}^\bullet$,
see Lemma \ref{lemma-local-actual}.
Then $M$ is isomorphic to the cone of $\alpha$ which is strictly
perfect by Lemma \ref{lemma-cone}.
\end{proof}

\begin{lemma}
\label{lemma-tensor-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space.
If $K, L$ are perfect objects of $D(\mathcal{O}_X)$, then
so is $K \otimes_{\mathcal{O}_X}^\mathbf{L} L$.
\end{lemma}

\begin{proof}
Follows from
Lemmas \ref{lemma-perfect}, \ref{lemma-tensor-pseudo-coherent}, and
\ref{lemma-tensor-tor-amplitude}.
\end{proof}

\begin{lemma}
\label{lemma-summands-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space.
If $K \oplus L$ is a perfect object of $D(\mathcal{O}_X)$, then
so are $K$ and $L$.
\end{lemma}

\begin{proof}
Follows from
Lemmas \ref{lemma-perfect}, \ref{lemma-summands-pseudo-coherent}, and
\ref{lemma-summands-tor-amplitude}.
\end{proof}

\begin{lemma}
\label{lemma-pushforward-perfect}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $j : U \to X$ be an
open subspace. Let $E$ be a perfect object of $D(\mathcal{O}_U)$
whose cohomology
sheaves are supported on a closed subset $T \subset U$ with $j(T)$
closed in $X$. Then $Rj_*E$ is a perfect object of $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Being a perfect complex is local on $X$. Thus it suffices to check that
$Rj_*E$ is perfect when restricted to $U$ and $V = X \setminus j(T)$.
We have $Rj_*E|_U = E$ which is perfect. We have
 $Rj_*E|_V = 0$ because $E|_{U \setminus T} = 0$.
\end{proof}

\begin{lemma}
\label{lemma-perfect-max-open-coh-loc-free}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $E$ in $D(\mathcal{O}_X)$
be perfect. Assume that all stalks $\mathcal{O}_{X, x}$ are local rings.
Then the set
$$
U =
\{x \in X \mid
H^i(E)_x\text{ is a finite free }
\mathcal{O}_{X, x}\text{-module for all }i\in \mathbf{Z}\}
$$
is open in $X$ and is the maximal open set $U \subset X$ such that
$H^i(E)|_U$ is finite locally free for all $i \in \mathbf{Z}$.
\end{lemma}

\begin{proof}
Note that if $V \subset X$ is some open such that $H^i(E)|_V$
is finite locally free for all $i \in \mathbf{Z}$ then $V \subset U$. 
Let $x \in U$. We will show that an open neighbourhood of $x$
is contained in $U$ and that $H^i(E)$ is finite locally free
on this neighbourhood for all $i$. This will finish the proof.
During the proof we may (finitely many times) replace
$X$ by an open neighbourhood of $x$.
Hence we may assume $E$ is represented
by a strictly perfect complex $\mathcal{E}^\bullet$. Say
$\mathcal{E}^i = 0$ for $i \not \in [a, b]$. We will
prove the result by induction on $b - a$. The module
$H^b(E) = \Coker(d^{b - 1} : \mathcal{E}^{b - 1} \to \mathcal{E}^b)$
is of finite presentation. Since $H^b(E)_x$ is finite free,
we conclude $H^b(E)$ is finite free in an open neighbourhood of $x$ by
Modules, Lemma \ref{modules-lemma-finite-presentation-stalk-free}.
Thus after replacing $X$ by a (possibly smaller) open
neighbourhood we may assume we have a direct sum decomposition
$\mathcal{E}^b = \Im(d^{b - 1}) \oplus H^b(E)$ and
$H^b(E)$ is finite free, see Lemma \ref{lemma-local-lift-map}.
Doing the same argument again, we see that we may
assume $\mathcal{E}^{b - 1} = \Ker(d^{b - 1}) \oplus \Im(d^{b - 1})$.
The complex
$\mathcal{E}^a \to \ldots \to \mathcal{E}^{b - 2} \to \Ker(d^{b - 1})$
is a strictly perfect complex representing a perfect
object $E'$ with $H^i(E) = H^i(E')$ for $i \not = b$.
Hence we conclude by our induction hypothesis.
\end{proof}






\section{Duals}
\label{section-duals}

\noindent
In this section we characterize the dualizable objects of
the category of complexes and of the derived category.
In particular, we will see that an object of $D(\mathcal{O}_X)$
has a dual if and only if it is perfect (this follows from
Example \ref{example-dual-derived} and
Lemma \ref{lemma-left-dual-derived}).

\begin{lemma}
\label{lemma-symmetric-monoidal-cat-complexes}
Let $(X, \mathcal{O}_X)$ be a ringed space. The category of complexes
of $\mathcal{O}_X$-modules with tensor product defined by
$\mathcal{F}^\bullet \otimes \mathcal{G}^\bullet =
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{G}^\bullet)$
is a symmetric monoidal category (for sign rules, see
More on Algebra, Section \ref{more-algebra-section-sign-rules}).
\end{lemma}

\begin{proof}
Omitted. Hints: as unit $\mathbf{1}$ we take the complex having
$\mathcal{O}_X$ in degree $0$ and zero in other degrees with
obvious isomorphisms
$\text{Tot}(\mathbf{1} \otimes_{\mathcal{O}_X} \mathcal{G}^\bullet) =
\mathcal{G}^\bullet$ and
$\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathbf{1}) =
\mathcal{F}^\bullet$.
to prove the lemma you have to check the commutativity
of various diagrams, see Categories, Definitions
\ref{categories-definition-monoidal-category} and
\ref{categories-definition-symmetric-monoidal-category}.
The verifications are straightforward in each case.
\end{proof}

\begin{example}
\label{example-dual}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}^\bullet$
be a locally bounded complex of $\mathcal{O}_X$-modules such that each
$\mathcal{F}^n$ is locally a direct summand of a finite
free $\mathcal{O}_X$-module. In other words, there is an open covering
$X = \bigcup U_i$ such that $\mathcal{F}^\bullet|_{U_i}$ is a strictly
perfect complex. Consider the complex
$$
\mathcal{G}^\bullet = \SheafHom^\bullet(\mathcal{F}^\bullet, \mathcal{O}_X)
$$
as in Section \ref{section-hom-complexes}. Let
$$
\eta :
\mathcal{O}_X
\to
\text{Tot}(\mathcal{F}^\bullet \otimes_{\mathcal{O}_X} \mathcal{G}^\bullet)
\quad\text{and}\quad
\epsilon :
\text{Tot}(\mathcal{G}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}^\bullet)
\to
\mathcal{O}_X
$$
be $\eta = \sum \eta_n$ and $\epsilon = \sum \epsilon_n$
where $\eta_n : \mathcal{O}_X \to
\mathcal{F}^n \otimes_{\mathcal{O}_X} \mathcal{G}^{-n}$
and
$\epsilon_n : \mathcal{G}^{-n} \otimes_{\mathcal{O}_X} \mathcal{F}^n
\to \mathcal{O}_X$ are as in Modules, Example \ref{modules-example-dual}.
Then $\mathcal{G}^\bullet, \eta, \epsilon$
is a left dual for $\mathcal{F}^\bullet$ as in
Categories, Definition \ref{categories-definition-dual}.
We omit the verification that
$(1 \otimes \epsilon) \circ (\eta \otimes 1) = \text{id}_{\mathcal{F}^\bullet}$
and
$(\epsilon \otimes 1) \circ (1 \otimes \eta) =
\text{id}_{\mathcal{G}^\bullet}$. Please compare with
More on Algebra, Lemma \ref{more-algebra-lemma-left-dual-complex}.
\end{example}

\begin{lemma}
\label{lemma-left-dual-complex}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $\mathcal{F}^\bullet$
be a complex of $\mathcal{O}_X$-modules. If $\mathcal{F}^\bullet$
has a left dual in the monoidal category of complexes of
$\mathcal{O}_X$-modules
(Categories, Definition \ref{categories-definition-dual})
then $\mathcal{F}^\bullet$ is a locally bounded complex whose terms are
locally direct summands of finite free $\mathcal{O}_X$-modules
and the left dual is as constructed in Example \ref{example-dual}.
\end{lemma}

\begin{proof}
By uniqueness of left duals
(Categories, Remark \ref{categories-remark-left-dual-adjoint})
we get the final statement provided we show that $\mathcal{F}^\bullet$
is as stated. Let $\mathcal{G}^\bullet, \eta, \epsilon$ be a left dual.
Write $\eta = \sum \eta_n$ and $\epsilon = \sum \epsilon_n$
where $\eta_n : \mathcal{O}_X \to
\mathcal{F}^n \otimes_{\mathcal{O}_X} \mathcal{G}^{-n}$
and
$\epsilon_n : \mathcal{G}^{-n} \otimes_{\mathcal{O}_X} \mathcal{F}^n
\to \mathcal{O}_X$. Since
$(1 \otimes \epsilon) \circ (\eta \otimes 1) = \text{id}_{\mathcal{F}^\bullet}$
and
$(\epsilon \otimes 1) \circ (1 \otimes \eta) = \text{id}_{\mathcal{G}^\bullet}$
by Categories, Definition \ref{categories-definition-dual} we see immediately
that we have
$(1 \otimes \epsilon_n) \circ (\eta_n \otimes 1) = \text{id}_{\mathcal{F}^n}$
and
$(\epsilon_n \otimes 1) \circ (1 \otimes \eta_n) =
\text{id}_{\mathcal{G}^{-n}}$.
Hence we see that $\mathcal{F}^n$ is locally a direct summand of a finite
free $\mathcal{O}_X$-module by
Modules, Lemma \ref{modules-lemma-left-dual-module}.
Since the sum $\eta = \sum \eta_n$ is locally finite, we conclude that
$\mathcal{F}^\bullet$ is locally bounded.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-evaluate-isom}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K, L, M \in D(\mathcal{O}_X)$.
If $K$ is perfect, then the map
$$
R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} K
\longrightarrow
R\SheafHom(R\SheafHom(K, L), M)
$$
of Lemma \ref{lemma-internal-hom-evaluate} is an isomorphism.
\end{lemma}

\begin{proof}
Since the map is globally defined and since formation of the right and
left hand side commute with localization
(see Lemma \ref{lemma-restriction-RHom-to-U}), to prove this we may work
locally on $X$. Thus we may assume $K$ is represented by a strictly
perfect complex $\mathcal{E}^\bullet$.

\medskip\noindent
If $K_1 \to K_2 \to K_3$ is a distinguished triangle in $D(\mathcal{O}_X)$,
then we get distinguished triangles
$$
R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} K_1 \to
R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} K_2 \to
R\SheafHom(L, M) \otimes_{\mathcal{O}_X}^\mathbf{L} K_3
$$
and
$$
R\SheafHom(R\SheafHom(K_1, L), M) \to
R\SheafHom(R\SheafHom(K_2, L), M)
R\SheafHom(R\SheafHom(K_3, L), M)
$$
See Section \ref{section-flat} and
Lemma \ref{lemma-RHom-triangulated}.
The arrow of Lemma \ref{lemma-internal-hom-evaluate} is functorial in $K$
hence we get a morphism between these distinguished triangles.
Thus, if the result holds for $K_1$ and $K_3$, then the result holds for
$K_2$ by Derived Categories, Lemma
\ref{derived-lemma-third-isomorphism-triangle}.

\medskip\noindent
Combining the remarks above with the distinguished triangles
$$
\sigma_{\geq n}\mathcal{E}^\bullet \to \mathcal{E}^\bullet \to
\sigma_{\leq n - 1}\mathcal{E}^\bullet
$$
of stupid trunctions, we reduce to the case where $K$ consists
of a direct summand of a finite free $\mathcal{O}_X$-module placed
in some degree. By an obvious compatibility of the problem with direct sums
(similar to what was said above) and shifts this reduces us to the case
where $K = \mathcal{O}_X^{\oplus n}$ for some integer $n$.
This case is clear.
\end{proof}

\begin{lemma}
\label{lemma-dual-perfect-complex}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K$ be a perfect object of
$D(\mathcal{O}_X)$. Then $K^\vee = R\SheafHom(K, \mathcal{O}_X)$ is a
perfect object too and $(K^\vee)^\vee \cong K$. There are
functorial isomorphisms
$$
M \otimes^\mathbf{L}_{\mathcal{O}_X} K^\vee = R\SheafHom(K, M)
$$
and
$$
H^0(X, M \otimes^\mathbf{L}_{\mathcal{O}_X} K^\vee) =
\Hom_{D(\mathcal{O}_X)}(K, M)
$$
for $M$ in $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-internal-hom-evaluate} there is a canonical map
$$
K = R\SheafHom(\mathcal{O}_X, \mathcal{O}_X)
\otimes_{\mathcal{O}_X}^\mathbf{L} K \longrightarrow
R\SheafHom(R\SheafHom(K, \mathcal{O}_X), \mathcal{O}_X) =
(K^\vee)^\vee
$$
which is an isomorphism by Lemma \ref{lemma-internal-hom-evaluate-isom}.
To check the other statements we will use without further mention that
formation of internal hom commutes with restriction to opens
(Lemma \ref{lemma-restriction-RHom-to-U}).
We may check $K^\vee$ is perfect locally on $X$.
By Lemma \ref{lemma-dual}
to see the final statement it suffices to check that the map
(\ref{equation-eval})
$$
M \otimes^\mathbf{L}_{\mathcal{O}_X} K^\vee
\longrightarrow
R\SheafHom(K, M)
$$
is an isomorphism. This is local on $X$ as well.
Hence it suffices to prove these two statements $K$ is represented
by a strictly perfect complex.

\medskip\noindent
Assume $K$ is represented by the strictly perfect complex
$\mathcal{E}^\bullet$. Then it follows from
Lemma \ref{lemma-Rhom-strictly-perfect}
that $K^\vee$ is represented by the complex whose terms are
$(\mathcal{E}^{-n})^\vee =
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-n}, \mathcal{O}_X)$
in degree $n$. Since $\mathcal{E}^{-n}$ is a direct summand of a finite
free $\mathcal{O}_X$-module, so is $(\mathcal{E}^{-n})^\vee$.
Hence $K^\vee$ is represented by a strictly perfect complex too
and we see that $K^\vee$ is perfect.
To see that (\ref{equation-eval}) is an isomorphism, represent
$M$ by a complex $\mathcal{F}^\bullet$.
By Lemma \ref{lemma-Rhom-strictly-perfect} the complex
$R\SheafHom(K, M)$ is represented by the complex with terms
$$
\bigoplus\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{F}^p)
$$
On the other hand, the object $M \otimes^\mathbf{L}_{\mathcal{O}_X} K^\vee$
is represented by the complex with terms
$$
\bigoplus\nolimits_{n = p + q}
\mathcal{F}^p \otimes_{\mathcal{O}_X} (\mathcal{E}^{-q})^\vee
$$
Thus the assertion that (\ref{equation-eval}) is an isomorphism
reduces to the assertion that the canonical map
$$
\mathcal{F}
\otimes_{\mathcal{O}_X}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}, \mathcal{O}_X)
\longrightarrow
\SheafHom_{\mathcal{O}_X}(\mathcal{E}, \mathcal{F})
$$
is an isomorphism when $\mathcal{E}$ is a direct summand of a finite
free $\mathcal{O}_X$-module and $\mathcal{F}$ is any $\mathcal{O}_X$-module.
This follows immediately from the corresponding statement when
$\mathcal{E}$ is finite free.
\end{proof}

\begin{lemma}
\label{lemma-symmetric-monoidal-derived}
Let $(X, \mathcal{O}_X)$ be a ringed space. The derived category
$D(\mathcal{O}_X)$ is a symmetric monoidal category with tensor product
given by derived tensor product with usual associativity and
commutativity constraints (for sign rules, see
More on Algebra, Section \ref{more-algebra-section-sign-rules}).
\end{lemma}

\begin{proof}
Omitted. Compare with Lemma \ref{lemma-symmetric-monoidal-cat-complexes}.
\end{proof}

\begin{example}
\label{example-dual-derived}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K$ be a perfect object
of $D(\mathcal{O}_X)$. Set $K^\vee = R\SheafHom(K, \mathcal{O}_X)$
as in Lemma \ref{lemma-dual-perfect-complex}.
Then the map
$$
K \otimes_{\mathcal{O}_X}^\mathbf{L} K^\vee \longrightarrow R\SheafHom(K, K)
$$
is an isomorphism (by the lemma). Denote
$$
\eta :
\mathcal{O}_X
\longrightarrow
K \otimes_{\mathcal{O}_X}^\mathbf{L} K^\vee
$$
the map sending $1$ to the section corresponding to
$\text{id}_K$ under the isomorphism above.
Denote
$$
\epsilon : 
K^\vee
\otimes_{\mathcal{O}_X}^\mathbf{L} K
\longrightarrow
\mathcal{O}_X
$$
the evaluation map (to construct it you can use
Lemma \ref{lemma-internal-hom-composition} for example). Then
$K^\vee, \eta, \epsilon$ is a left dual for $K$ as in
Categories, Definition \ref{categories-definition-dual}.
We omit the verification that
$(1 \otimes \epsilon) \circ (\eta \otimes 1) = \text{id}_K$
and
$(\epsilon \otimes 1) \circ (1 \otimes \eta) =
\text{id}_{K^\vee}$.
\end{example}

\begin{lemma}
\label{lemma-left-dual-derived}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $M$ be an object
of $D(\mathcal{O}_X)$. If $M$ has a left dual in the monoidal category
$D(\mathcal{O}_X)$ (Categories, Definition \ref{categories-definition-dual})
then $M$ is perfect and the left dual is as constructed in
Example \ref{example-dual-derived}.
\end{lemma}

\begin{proof}
Let $x \in X$. It suffices to find an open neighbourhood $U$ of $x$
such that $M$ restricts to a perfect complex over $U$. Hence during the
proof we can (finitely often) replace $X$ by an open neighbourhood of $x$.
Let $N, \eta, \epsilon$ be a left dual.

\medskip\noindent
We are going to use the following argument several times. Choose any
complex $\mathcal{M}^\bullet$
of $\mathcal{O}_X$-modules representing $M$. Choose a K-flat complex
$\mathcal{N}^\bullet$ representing $N$ whose terms are flat
$\mathcal{O}_X$-modules, see Lemma \ref{lemma-K-flat-resolution}.
Consider the map
$$
\eta : \mathcal{O}_X \to
\text{Tot}(\mathcal{M}^\bullet \otimes_{\mathcal{O}_X} \mathcal{N}^\bullet)
$$
After shrinking $X$ we can find an integer $N$ and for
$i = 1, \ldots, N$ integers $n_i \in \mathbf{Z}$ and sections
$f_i$ and $g_i$ of $\mathcal{M}^{n_i}$ and $\mathcal{N}^{-n_i}$
such that
$$
\eta(1) = \sum\nolimits_i f_i \otimes g_i
$$
Let $\mathcal{K}^\bullet \subset \mathcal{M}^\bullet$ be any subcomplex
of $\mathcal{O}_X$-modules containing the sections $f_i$
for $i = 1, \ldots, N$.
Since
$\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{N}^\bullet)
\subset
\text{Tot}(\mathcal{M}^\bullet \otimes_{\mathcal{O}_X} \mathcal{N}^\bullet)$
by flatness of the modules $\mathcal{N}^n$, we see that $\eta$ factors through
$$
\tilde \eta :
\mathcal{O}_X \to
\text{Tot}(\mathcal{K}^\bullet \otimes_{\mathcal{O}_X} \mathcal{N}^\bullet)
$$
Denoting $K$ the object of $D(\mathcal{O}_X)$ represented by
$\mathcal{K}^\bullet$ we find a commutative diagram
$$
\xymatrix{
M \ar[rr]_-{\eta \otimes 1} \ar[rrd]_{\tilde \eta \otimes 1} & &
M \otimes^\mathbf{L} N \otimes^\mathbf{L} M
\ar[r]_-{1 \otimes \epsilon} &
M \\
& &
K \otimes^\mathbf{L} N \otimes^\mathbf{L} M
\ar[u] \ar[r]^-{1 \otimes \epsilon} &
K \ar[u]
}
$$
Since the composition of the upper row is the identity on $M$
we conclude that $M$ is a direct summand of $K$ in $D(\mathcal{O}_X)$.

\medskip\noindent
As a first use of the argument above, we can choose the subcomplex
$\mathcal{K}^\bullet = \sigma_{\geq a} \tau_{\leq b}\mathcal{M}^\bullet$
with $a < n_i < b$ for $i = 1, \ldots, N$. Thus $M$ is a direct
summand in $D(\mathcal{O}_X)$ of a bounded complex and we conclude
we may assume $M$ is in $D^b(\mathcal{O}_X)$. (Recall that the process
above involves shrinking $X$.)

\medskip\noindent
Since $M$ is in $D^b(\mathcal{O}_X)$ we may choose
$\mathcal{M}^\bullet$ to be a bounded above complex of
flat modules (by Modules, Lemma \ref{modules-lemma-module-quotient-flat} and
Derived Categories, Lemma \ref{derived-lemma-subcategory-left-resolution}).
Then we can choose $\mathcal{K}^\bullet = \sigma_{\geq a}\mathcal{M}^\bullet$
with $a < n_i$ for $i = 1, \ldots, N$ in the argument above.
Thus we find that we may assume $M$ is a direct summand in
$D(\mathcal{O}_X)$ of a bounded complex of flat modules.
In particular,  $M$ has finite tor amplitude.

\medskip\noindent
Say $M$ has tor amplitude in $[a, b]$. Assuming $M$ is $m$-pseudo-coherent
we are going to show that (after shrinking $X$) we may assume $M$
is $(m - 1)$-pseudo-coherent. This will finish the proof by
Lemma \ref{lemma-perfect-precise} and the fact that
$M$ is $(b + 1)$-pseudo-coherent in any case.
After shrinking $X$ we may assume there exists a strictly perfect
complex $\mathcal{E}^\bullet$ and a map $\alpha : \mathcal{E}^\bullet \to M$
in $D(\mathcal{O}_X)$ such that $H^i(\alpha)$ is an isomorphism for
$i > m$ and surjective for $i = m$. We may and do assume
that $\mathcal{E}^i = 0$ for $i < m$. Choose a distinguished triangle
$$
\mathcal{E}^\bullet \to M \to L \to \mathcal{E}^\bullet[1]
$$
Observe that $H^i(L) = 0$ for $i \geq m$. Thus we may represent
$L$ by a complex $\mathcal{L}^\bullet$ with $\mathcal{L}^i = 0$
for $i \geq m$. The map $L \to \mathcal{E}^\bullet[1]$
is given by a map of complexes
$\mathcal{L}^\bullet \to \mathcal{E}^\bullet[1]$
which is zero in all degrees except in degree $m - 1$
where we obtain a map $\mathcal{L}^{m - 1} \to \mathcal{E}^m$, see
Derived Categories, Lemma \ref{derived-lemma-negative-exts}.
Then $M$ is represented by the complex
$$
\mathcal{M}^\bullet :
\ldots \to
\mathcal{L}^{m - 2} \to
\mathcal{L}^{m - 1} \to
\mathcal{E}^m \to
\mathcal{E}^{m + 1} \to \ldots
$$
Apply the discussion in the second paragraph to this complex to get
sections $f_i$ of $\mathcal{M}^{n_i}$ for $i = 1, \ldots, N$.
For $n < m$ let $\mathcal{K}^n \subset \mathcal{L}^n$
be the $\mathcal{O}_X$-submodule generated by the sections
$f_i$ for $n_i = n$ and $d(f_i)$ for $n_i = n - 1$.
For $n \geq m$ set $\mathcal{K}^n = \mathcal{E}^n$.
Clearly, we have a morphism of
distinguished triangles
$$
\xymatrix{
\mathcal{E}^\bullet \ar[r] &
\mathcal{M}^\bullet \ar[r] &
\mathcal{L}^\bullet \ar[r] &
\mathcal{E}^\bullet[1] \\
\mathcal{E}^\bullet \ar[r] \ar[u] &
\mathcal{K}^\bullet \ar[r] \ar[u] &
\sigma_{\leq m - 1}\mathcal{K}^\bullet \ar[r] \ar[u] &
\mathcal{E}^\bullet[1] \ar[u]
}
$$
where all the morphisms are as indicated above.
Denote $K$ the object of $D(\mathcal{O}_X)$ corresponding to the complex
$\mathcal{K}^\bullet$.
By the arguments in the second paragraph of the proof we obtain
a morphism $s : M \to K$ in $D(\mathcal{O}_X)$ such that the composition
$M \to K \to M$ is the identity on $M$. We don't know that the
diagram
$$
\xymatrix{
\mathcal{E}^\bullet \ar[r] &
\mathcal{K}^\bullet \ar@{=}[r] &
K \\
\mathcal{E}^\bullet \ar[u]^{\text{id}} \ar[r]^i &
\mathcal{M}^\bullet \ar@{=}[r] &
M \ar[u]_s
}
$$
commutes, but we do know it commutes after composing with the
map $K \to M$. By Lemma \ref{lemma-local-actual} after shrinking $X$ we may
assume that $s \circ i$ is given by a map of complexes
$\sigma : \mathcal{E}^\bullet \to \mathcal{K}^\bullet$.
By the same lemma we may assume the composition of $\sigma$
with the inclusion $\mathcal{K}^\bullet \subset \mathcal{M}^\bullet$
is homotopic to zero by some homotopy
$\{h^i : \mathcal{E}^i \to \mathcal{M}^{i - 1}\}$.
Thus, after replacing $\mathcal{K}^{m - 1}$ by
$\mathcal{K}^{m - 1} + \Im(h^m)$ (note that after doing this
it is still the case that $\mathcal{K}^{m - 1}$ is generated
by finitely many global sections), we see that
$\sigma$ itself is homotopic to zero!
This means that we have a commutative solid diagram
$$
\xymatrix{
\mathcal{E}^\bullet \ar[r] &
M \ar[r] &
\mathcal{L}^\bullet \ar[r] &
\mathcal{E}^\bullet[1] \\
\mathcal{E}^\bullet \ar[r] \ar[u] &
K \ar[r] \ar[u] &
\sigma_{\leq m - 1}\mathcal{K}^\bullet \ar[r] \ar[u] &
\mathcal{E}^\bullet[1] \ar[u] \\
\mathcal{E}^\bullet \ar[r] \ar[u] &
M \ar[r] \ar[u]^s &
\mathcal{L}^\bullet \ar[r] \ar@{..>}[u] &
\mathcal{E}^\bullet[1] \ar[u]
}
$$
By the axioms of triangulated categories we obtain a dotted
arrow fitting into the diagram.
Looking at cohomology sheaves in degree $m - 1$ we see that we obtain
$$
\xymatrix{
H^{m - 1}(M) \ar[r] &
H^{m - 1}(\mathcal{L}^\bullet) \ar[r] &
H^m(\mathcal{E}^\bullet) \\
H^{m - 1}(K) \ar[r] \ar[u] &
H^{m - 1}(\sigma_{\leq m - 1}\mathcal{K}^\bullet) \ar[r] \ar[u] &
H^m(\mathcal{E}^\bullet) \ar[u] \\
H^{m - 1}(M) \ar[r] \ar[u] &
H^{m - 1}(\mathcal{L}^\bullet) \ar[r] \ar[u] &
H^m(\mathcal{E}^\bullet) \ar[u]
}
$$
Since the vertical compositions are the identity in both the
left and right column, we conclude the vertical composition
$H^{m - 1}(\mathcal{L}^\bullet) \to
H^{m - 1}(\sigma_{\leq m - 1}\mathcal{K}^\bullet) \to
H^{m - 1}(\mathcal{L}^\bullet)$ in the middle is surjective!
In particular $H^{m - 1}(\sigma_{\leq m - 1}\mathcal{K}^\bullet) \to
H^{m - 1}(\mathcal{L}^\bullet)$ is surjective.
Using the induced map of long exact sequences of cohomology
sheaves from the morphism of triangles above, a diagram chase
shows this implies $H^i(K) \to H^i(M)$ is an isomorphism
for $i \geq m$ and surjective for $i = m - 1$.
By construction we can choose an $r \geq 0$ and a surjection
$\mathcal{O}_X^{\oplus r} \to \mathcal{K}^{m - 1}$. Then the
composition
$$
(\mathcal{O}_X^{\oplus r} \to \mathcal{E}^m \to
\mathcal{E}^{m + 1} \to \ldots ) \longrightarrow
K \longrightarrow M
$$
induces an isomorphism on cohomology sheaves in degrees $\geq m$ and
a surjection in degree $m - 1$ and the proof is complete.
\end{proof}





\section{Miscellany}
\label{section-misc}

\noindent
Some results which do not fit anywhere else.

\begin{lemma}
\label{lemma-colim-and-lim-of-duals}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$(K_n)_{n \in \mathbf{N}}$ be a system of perfect objects of $D(\mathcal{O}_X)$.
Let $K = \text{hocolim} K_n$ be the derived colimit
(Derived Categories, Definition \ref{derived-definition-derived-colimit}).
Then for any object $E$ of $D(\mathcal{O}_X)$ we have
$$
R\SheafHom(K, E) = R\lim E \otimes^\mathbf{L}_{\mathcal{O}_X} K_n^\vee
$$
where $(K_n^\vee)$ is the inverse system of dual perfect complexes.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-dual-perfect-complex} we have
$R\lim E \otimes^\mathbf{L}_{\mathcal{O}_X} K_n^\vee =
R\lim R\SheafHom(K_n, E)$
which fits into the distinguished triangle
$$
R\lim R\SheafHom(K_n, E) \to
\prod R\SheafHom(K_n, E) \to
\prod R\SheafHom(K_n, E)
$$
Because $K$ similarly fits into the distinguished triangle
$\bigoplus K_n \to \bigoplus K_n \to K$ it suffices to show that
$\prod R\SheafHom(K_n, E) = R\SheafHom(\bigoplus K_n, E)$.
This is a formal consequence of (\ref{equation-internal-hom})
and the fact that derived tensor product commutes with direct sums.
\end{proof}

\begin{lemma}
\label{lemma-ext-composition-is-cup}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $K$ and $E$ be objects
of $D(\mathcal{O}_X)$ with $E$ perfect. The diagram
$$
\xymatrix{
H^0(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} E^\vee) \times H^0(X, E)
\ar[r] \ar[d] &
H^0(X, K \otimes_{\mathcal{O}_X}^\mathbf{L} E^\vee
\otimes_{\mathcal{O}_X}^\mathbf{L} E) \ar[d] \\
\Hom_X(E, K) \times H^0(X, E) \ar[r] &
H^0(X, K)
}
$$
commutes where the top horizontal arrow is the cup product, the
right vertical arrow uses
$\epsilon : E^\vee \otimes_{\mathcal{O}_X}^\mathbf{L} E \to \mathcal{O}_X$
(Example \ref{example-dual-derived}), the left vertical arrow uses
Lemma \ref{lemma-dual-perfect-complex}, and the bottom horizontal
arrow is the obvious one.
\end{lemma}

\begin{proof}
We will abbreviate $\otimes = \otimes_{\mathcal{O}_X}^\mathbf{L}$
and $\mathcal{O} = \mathcal{O}_X$. We will identify $E$ and $K$
with $R\SheafHom(\mathcal{O}, E)$ and $R\SheafHom(\mathcal{O}, K)$
and we will identify $E^\vee$ with $R\SheafHom(E, \mathcal{O})$.

\medskip\noindent
Let $\xi \in H^0(X, K \otimes E^\vee)$ and $\eta \in H^0(X, E)$.
Denote $\tilde \xi : \mathcal{O} \to K \otimes E^\vee$ and
$\tilde \eta : \mathcal{O} \to E$ the corresponding maps in
$D(\mathcal{O})$. By Lemma \ref{lemma-second-cup-equals-first}
the cup product $\xi \cup \eta$ corresponds to
$\tilde \xi \otimes \tilde \eta : \mathcal{O} \to
K \otimes E^\vee \otimes E$.

\medskip\noindent
We claim the map $\xi' : E \to K$ corresponding to $\xi$ by
Lemma \ref{lemma-dual-perfect-complex} is the composition
$$
E = \mathcal{O} \otimes E
\xrightarrow{\tilde \xi \otimes 1_E}
K \otimes E^\vee \otimes E
\xrightarrow{1_K \otimes \epsilon}
K
$$
The construction in Lemma \ref{lemma-dual-perfect-complex}
uses the evaluation map (\ref{equation-eval}) which in turn
is constructed using the identification of $E$ with
$R\SheafHom(\mathcal{O}, E)$ and the composition
$\underline{\circ}$ constructed
in Lemma \ref{lemma-internal-hom-composition}.
Hence $\xi'$ is the composition
\begin{align*}
E = \mathcal{O} \otimes
R\SheafHom(\mathcal{O}, E)
& \xrightarrow{\tilde \xi \otimes 1}
R\SheafHom(\mathcal{O}, K) \otimes
R\SheafHom(E, \mathcal{O}) \otimes
R\SheafHom(\mathcal{O}, E) \\
& \xrightarrow{\underline{\circ} \otimes 1}
R\SheafHom(E, K) \otimes R\SheafHom(\mathcal{O}, E) \\
& \xrightarrow{\underline{\circ}}
R\SheafHom(\mathcal{O}, K) = K
\end{align*}
The claim follows immediately from this and the fact that
the composition $\underline{\circ}$ constructed in
Lemma \ref{lemma-internal-hom-composition} is associative
(insert future reference here) and the fact that $\epsilon$
is defined as the composition
$\underline{\circ} : E^\vee \otimes E \to \mathcal{O}$ in
Example \ref{example-dual-derived}.

\medskip\noindent
Using the results from the previous two paragraphs, we find
the statement of the lemma is that
$(1_K \otimes \epsilon) \circ (\tilde \xi \otimes \tilde \eta)$
is equal to
$(1_K \otimes \epsilon) \circ (\tilde \xi \otimes 1_E)
\circ (1_\mathcal{O} \otimes \tilde \eta)$
which is immediate.
\end{proof}

\begin{lemma}
\label{lemma-pullback-internal-hom}
Let $h : X \to Y$ be a morphism of ringed spaces.
Let $K, M$ be objects of $D(\mathcal{O}_Y)$. The
canonical map
$$
Lh^*R\SheafHom(K, M) \longrightarrow R\SheafHom(Lh^*K, Lh^*M)
$$
of Remark \ref{remark-prepare-fancy-base-change}
is an isomorphism in the following cases
\begin{enumerate}
\item $K$ is perfect,
\item $h$ is flat, $K$ is pseudo-coherent, and $M$ is (locally) bounded below,
\item $\mathcal{O}_X$ has finite tor dimension over $h^{-1}\mathcal{O}_Y$,
$K$ is pseudo-coherent, and $M$ is (locally) bounded below,
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). The question is local on $Y$, hence we may assume that
$K$ is represented by a strictly perfect complex
$\mathcal{E}^\bullet$, see Section \ref{section-perfect}.
Choose a K-flat complex $\mathcal{F}^\bullet$ representing $M$.
Apply Lemma \ref{lemma-Rhom-strictly-perfect} to see that
$R\SheafHom(K, L)$ is represented by the complex
$\mathcal{H}^\bullet =
\SheafHom^\bullet(\mathcal{E}^\bullet, \mathcal{F}^\bullet)$
with terms $\mathcal{H}^n = \bigoplus\nolimits_{n = p + q}
\SheafHom_{\mathcal{O}_X}(\mathcal{E}^{-q}, \mathcal{F}^p)$.
By the construction of $Lh^*$ in Section \ref{section-derived-pullback}
we see that $Lh^*K$ is represented by the strictly perfect complex
$h^*\mathcal{E}^\bullet$ (Lemma \ref{lemma-strictly-perfect-pullback}).
Similarly, the object $Lh^*M$ is represented by
the complex $h^*\mathcal{F}^\bullet$.
Finally, the object $Lh^*R\SheafHom(K, M)$
is represented by $h^*\mathcal{H}^\bullet$ as
$\mathcal{H}^\bullet$ is K-flat by
Lemma \ref{lemma-Rhom-strictly-perfect-K-flat}.
Thus to finish the proof it suffices to show that
$h^*\mathcal{H}^\bullet =
\SheafHom^\bullet(h^*\mathcal{E}^\bullet, h^*\mathcal{F}^\bullet)$.
For this it suffices to note that
$h^*\SheafHom(\mathcal{E}, \mathcal{F}) =
\SheafHom(h^*\mathcal{E}, \mathcal{F})$
whenever $\mathcal{E}$ is a direct summand of a finite free
$\mathcal{O}_X$-module.

\medskip\noindent
Proof of (2). Since $h$ is flat, we can compute $Lh^*$
by simply using $h^*$ on any complex of $\mathcal{O}_Y$-modules.
In particular we have $H^i(Lh^*K) = h^*H^i(K)$ for all $i \in \mathbf{Z}$.
Say $H^i(M) = 0$ for $i < a$. Let $K' \to K$ be a morphism
of $D(\mathcal{O}_Y)$ which defines an isomorphism
$H^i(K') \to H^i(K)$ for all $i \geq b$. Then the corresponding maps
$$
R\SheafHom(K, M) \to R\SheafHom(K', M)
$$
and
$$
R\SheafHom(Lh^*K, Lh^*M) \to R\SheafHom(Lh^*K', Lh^*M)
$$
are isomorphisms on cohomology sheaves in degrees $< a - b$ (details omitted).
Thus to prove the map in the statement of the lemma induces an
isomorphism on cohomology sheaves in degrees $< a - b$ it suffices to
prove the result for $K'$ in those degrees. Also, as in the proof
of part (1) the question is local on $Y$. Thus we may assume $K$ is
represented by a strictly perfect complex, see
Section \ref{section-pseudo-coherent}. This reduces us to case (1).

\medskip\noindent
Proof of (3). The proof is the same as the proof of (2) except one
uses that $Lh^*$ has bounded cohomological dimension to get the
desired vanishing. We omit the details.
\end{proof}

\begin{lemma}
\label{lemma-stalk-internal-hom}
Let $X$ be a ringed space. Let $K, M$ be objects of $D(\mathcal{O}_X)$.
Let $x \in X$. The canonical map
$$
R\SheafHom(K, M)_x \longrightarrow
R\Hom_{\mathcal{O}_{X, x}}(K_x, M_x)
$$
is an isomorphism in the following cases
\begin{enumerate}
\item $K$ is perfect,
\item $K$ is pseudo-coherent and $M$ is (locally) bounded below.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $Y = \{x\}$ be the singleton ringed space with structure sheaf
given by $\mathcal{O}_{X, x}$. Then apply
Lemma \ref{lemma-pullback-internal-hom}
to the flat inclusion morphism $Y \to X$.
\end{proof}







\section{Invertible objects in the derived category}
\label{section-invertible-D-or-R}

\noindent
We characterize invertible objects in the derived category of
a ringed space (both in the case where the stalks of the
structure sheaf are local and where not).

\begin{lemma}
\label{lemma-category-summands-finite-free}
Let $(X, \mathcal{O}_X)$ be a ringed space.
Set $R = \Gamma(X, \mathcal{O}_X)$. The category of
$\mathcal{O}_X$-modules which are summands of finite free
$\mathcal{O}_X$-modules is equivalent to the category of
finite projective $R$-modules.
\end{lemma}

\begin{proof}
Observe that a finite projective $R$-module is the same thing
as a summand of a finite free $R$-module.
The equivalence is given by the functor $\mathcal{E} \mapsto
\Gamma(X, \mathcal{E})$. The inverse functor is given by the construction of
Modules, Lemma \ref{modules-lemma-construct-quasi-coherent-sheaves}.
\end{proof}

\begin{lemma}
\label{lemma-invertible-derived}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let $M$ be an object
of $D(\mathcal{O}_X)$. The following are equivalent
\begin{enumerate}
\item $M$ is invertible in $D(\mathcal{O}_X)$, see
Categories, Definition \ref{categories-definition-invertible}, and
\item there is a locally finite direct product decomposition
$$
\mathcal{O}_X = \prod\nolimits_{n \in \mathbf{Z}} \mathcal{O}_n
$$
and for each $n$ there is an invertible $\mathcal{O}_n$-module
$\mathcal{H}^n$ (Modules, Definition \ref{modules-definition-invertible})
and $M = \bigoplus \mathcal{H}^n[-n]$ in $D(\mathcal{O}_X)$.
\end{enumerate}
If (1) and (2) hold, then $M$ is a perfect object of $D(\mathcal{O}_X)$. If
$\mathcal{O}_{X, x}$ is a local ring for all $x \in X$ these condition
are also equivalent to
\begin{enumerate}
\item[(3)] there exists an open covering $X = \bigcup U_i$
and for each $i$ an integer $n_i$ such that $M|_{U_i}$
is represented by an invertible $\mathcal{O}_{U_i}$-module
placed in degree $n_i$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (2). Consider the object $R\SheafHom(M, \mathcal{O}_X)$
and the composition map
$$
R\SheafHom(M, \mathcal{O}_X) \otimes_{\mathcal{O}_X}^\mathbf{L} M \to
\mathcal{O}_X
$$
To prove this is an isomorphism, we may work locally. Thus we may
assume $\mathcal{O}_X = \prod_{a \leq n \leq b} \mathcal{O}_n$
and $M = \bigoplus_{a \leq n \leq b} \mathcal{H}^n[-n]$.
Then it suffices to show that
$$
R\SheafHom(\mathcal{H}^m, \mathcal{O}_X)
\otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{H}^n
$$
is zero if $n \not = m$ and equal to $\mathcal{O}_n$ if $n = m$.
The case $n \not = m$ follows from the fact that $\mathcal{O}_n$ and
$\mathcal{O}_m$ are flat $\mathcal{O}_X$-algebras with
$\mathcal{O}_n \otimes_{\mathcal{O}_X} \mathcal{O}_m = 0$.
Using the local structure of invertible $\mathcal{O}_X$-modules
(Modules, Lemma \ref{modules-lemma-invertible}) and working locally
the isomorphism in case $n = m$ follows in a straightforward manner;
we omit the details. Because $D(\mathcal{O}_X)$ is symmetric monoidal,
we conclude that $M$ is invertible.

\medskip\noindent
Assume (1). The description in (2) shows that we have a candidate
for $\mathcal{O}_n$, namely,
$\SheafHom_{\mathcal{O}_X}(H^n(M), H^n(M))$.
If this is a locally finite family of sheaves of rings
and if $\mathcal{O}_X = \prod \mathcal{O}_n$, then we immediately
obtain the direct sum decomposition $M = \bigoplus H^n(M)[-n]$
using the idempotents in $\mathcal{O}_X$ coming from the product
decomposition.
This shows that in order to prove (2) we may work locally on $X$.

\medskip\noindent
Choose an object $N$ of $D(\mathcal{O}_X)$
and an isomorphism
$M \otimes_{\mathcal{O}_X}^\mathbf{L} N \cong \mathcal{O}_X$.
Let $x \in X$.
Then $N$ is a left dual for $M$ in the monoidal category
$D(\mathcal{O}_X)$ and we conclude that $M$ is perfect by
Lemma \ref{lemma-left-dual-derived}. By symmetry we see that
$N$ is perfect. After replacing $X$ by an open neighbourhood of $x$,
we may assume $M$ and $N$ are represented by a strictly perfect
complexes $\mathcal{E}^\bullet$ and $\mathcal{F}^\bullet$.
Then $M \otimes_{\mathcal{O}_X}^\mathbf{L} N$ is represented by
$\text{Tot}(\mathcal{E}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}^\bullet)$.
After another shinking of $X$ we may assume the mutually inverse
isomorphisms
$\mathcal{O}_X \to M \otimes_{\mathcal{O}_X}^\mathbf{L} N$ and
$M \otimes_{\mathcal{O}_X}^\mathbf{L} N \to \mathcal{O}_X$
are given by maps of complexes
$$
\alpha : \mathcal{O}_X \to
\text{Tot}(\mathcal{E}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}^\bullet)
\quad\text{and}\quad
\beta :
\text{Tot}(\mathcal{E}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}^\bullet)
\to \mathcal{O}_X
$$
See Lemma \ref{lemma-local-actual}. Then $\beta \circ \alpha = 1$
as maps of complexes and $\alpha \circ \beta = 1$ as a morphism
in $D(\mathcal{O}_X)$. After shrinking $X$
we may assume the composition $\alpha \circ \beta$ is homotopic to $1$
by some homotopy $\theta$ with components
$$
\theta^n :
\text{Tot}^n(\mathcal{E}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}^\bullet)
\to
\text{Tot}^{n - 1}(
\mathcal{E}^\bullet \otimes_{\mathcal{O}_X} \mathcal{F}^\bullet)
$$
by the same lemma as before. Set $R = \Gamma(X, \mathcal{O}_X)$. By
Lemma \ref{lemma-category-summands-finite-free}
we find that we obtain
\begin{enumerate}
\item $M^\bullet = \Gamma(X, \mathcal{E}^\bullet)$ is a bounded complex
of finite projective $R$-modules,
\item $N^\bullet = \Gamma(X, \mathcal{F}^\bullet)$ is a bounded complex
of finite projective $R$-modules,
\item $\alpha$ and $\beta$ correspond to maps of complexes
$a : R \to \text{Tot}(M^\bullet \otimes_R N^\bullet)$ and
$b : \text{Tot}(M^\bullet \otimes_R N^\bullet) \to R$,
\item $\theta^n$ corresponds to a map
$h^n : \text{Tot}^n(M^\bullet \otimes_R N^\bullet) \to
\text{Tot}^{n - 1}(M^\bullet \otimes_R N^\bullet)$, and
\item $b \circ a = 1$ and $b \circ a - 1 = dh + hd$,
\end{enumerate}
It follows that $M^\bullet$ and $N^\bullet$ define
mutually inverse objects of $D(R)$. By
More on Algebra, Lemma \ref{more-algebra-lemma-invertible-derived}
we find a product decomposition $R = \prod_{a \leq n \leq b} R_n$
and invertible $R_n$-modules $H^n$ such
that $M^\bullet \cong \bigoplus_{a \leq n \leq b} H^n[-n]$.
This isomorphism in $D(R)$ can be lifted to an morphism
$$
\bigoplus H^n[-n] \longrightarrow M^\bullet
$$
of complexes because each $H^n$ is projective as an $R$-module.
Correspondingly, using Lemma \ref{lemma-category-summands-finite-free} again,
we obtain an morphism
$$
\bigoplus H^n \otimes_R \mathcal{O}_X[-n] \to \mathcal{E}^\bullet
$$
which is an isomorphism in $D(\mathcal{O}_X)$. Setting
$\mathcal{O}_n = R_n \otimes_R \mathcal{O}_X$ we conclude (2) is true.

\medskip\noindent
If all stalks of $\mathcal{O}_X$ are local, then it is straightforward
to prove the equivalence of (2) and (3). We omit the details.
\end{proof}






\section{Compact objects}
\label{section-compact}

\noindent
In this section we study compact objects in the derived category of modules
on a ringed space. We recall that compact objects are defined in
Derived Categories, Definition \ref{derived-definition-compact-object}.
On suitable ringed spaces the perfect objects are compact.

\begin{lemma}
\label{lemma-when-jshriek-compact}
Let $X$ be a ringed space. Let $j : U \to X$ be the
inclusion of an open. The $\mathcal{O}_X$-module $j_!\mathcal{O}_U$ is a
compact object of $D(\mathcal{O}_X)$ if there exists an integer $d$ such that
\begin{enumerate}
\item $H^p(U, \mathcal{F}) = 0$ for all $p > d$, and
\item the functors $\mathcal{F} \mapsto H^p(U, \mathcal{F})$
commute with direct sums.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1) and (2). Since
$\Hom(j_!\mathcal{O}_U, \mathcal{F}) = \mathcal{F}(U)$
by Sheaves, Lemma \ref{sheaves-lemma-j-shriek-modules}
we have $\Hom(j_!\mathcal{O}_U, K) = R\Gamma(U, K)$ for
$K$ in $D(\mathcal{O}_X)$. Thus we have to show that $R\Gamma(U, -)$
commutes with direct sums. The first assumption means that the functor
$F = H^0(U, -)$ has finite cohomological dimension. Moreover, the second
assumption implies any direct sum of injective modules is acyclic for $F$.
Let $K_i$ be a family of objects of $D(\mathcal{O}_X)$.
Choose K-injective representatives $I_i^\bullet$ with injective terms
representing $K_i$, see Injectives, Theorem
\ref{injectives-theorem-K-injective-embedding-grothendieck}.
Since we may compute $RF$ by applying $F$ to any complex of acyclics
(Derived Categories, Lemma \ref{derived-lemma-unbounded-right-derived})
and since $\bigoplus K_i$ is represented by $\bigoplus I_i^\bullet$
(Injectives, Lemma \ref{injectives-lemma-derived-products})
we conclude that $R\Gamma(U, \bigoplus K_i)$ is represented by
$\bigoplus H^0(U, I_i^\bullet)$. Hence $R\Gamma(U, -)$ commutes
with direct sums as desired.
\end{proof}

\begin{lemma}
\label{lemma-perfect-is-compact}
Let $X$ be a ringed space. Assume that the underlying topological space
of $X$ has the following properties:
\begin{enumerate}
\item $X$ is quasi-compact,
\item there exists a basis of quasi-compact open subsets, and
\item the intersection of any two quasi-compact opens is quasi-compact.
\end{enumerate}
Let $K$ be a perfect object of $D(\mathcal{O}_X)$. Then
\begin{enumerate}
\item[(a)] $K$ is a compact object of $D^+(\mathcal{O}_X)$
in the following sense: if $M = \bigoplus_{i \in I} M_i$ is
bounded below, then $\Hom(K, M) = \bigoplus_{i \in I} \Hom(K, M_i)$.
\item[(b)] If $X$ has finite cohomological dimension, i.e., if there exists
a $d$ such that $H^i(X, \mathcal{F}) = 0$ for $i > d$, then
$K$ is a compact object of $D(\mathcal{O}_X)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $K^\vee$ be the dual of $K$, see
Lemma \ref{lemma-dual-perfect-complex}. Then we have
$$
\Hom_{D(\mathcal{O}_X)}(K, M) =
H^0(X, K^\vee \otimes_{\mathcal{O}_X}^\mathbf{L} M)
$$
functorially in $M$ in $D(\mathcal{O}_X)$.
Since $K^\vee \otimes_{\mathcal{O}_X}^\mathbf{L} -$ commutes with
direct sums it suffices
to show that $R\Gamma(X, -)$ commutes with the relevant direct sums.

\medskip\noindent
Proof of (b). Since $R\Gamma(X, K) = R\Hom(\mathcal{O}_X, K)$
and since $H^p(X, -)$ commutes with direct sums by
Lemma \ref{lemma-quasi-separated-cohomology-colimit}
this is a special case of
Lemma \ref{lemma-when-jshriek-compact}

\medskip\noindent
Proof of (a). Let $\mathcal{I}_i$, $i \in I$ be a collection of injective
$\mathcal{O}_X$-modules. By Lemma \ref{lemma-quasi-separated-cohomology-colimit}
we see that
$$
H^p(X, \bigoplus\nolimits_{i \in I} \mathcal{I}_i) =
\bigoplus\nolimits_{i \in I} H^p(X, \mathcal{I}_i) = 0
$$
for all $p$. Now if $M = \bigoplus M_i$ is as in (a), then we
see that there exists an $a \in \mathbf{Z}$ such that $H^n(M_i) = 0$
for $n < a$. Thus we can choose complexes of injective $\mathcal{O}_X$-modules
$\mathcal{I}_i^\bullet$ representing $M_i$
with $\mathcal{I}_i^n = 0$ for $n < a$, see
Derived Categories, Lemma \ref{derived-lemma-injective-resolutions-exist}.
By Injectives, Lemma \ref{injectives-lemma-derived-products}
we see that the direct sum complex $\bigoplus \mathcal{I}_i^\bullet$
represents $M$. By Leray acyclicity
(Derived Categories, Lemma \ref{derived-lemma-leray-acyclicity})
we see that
$$
R\Gamma(X, M) = \Gamma(X, \bigoplus \mathcal{I}_i^\bullet) =
\bigoplus \Gamma(X, \bigoplus \mathcal{I}_i^\bullet) =
\bigoplus R\Gamma(X, M_i)
$$
as desired.
\end{proof}


















\section{Projection formula}
\label{section-projection-formula}

\noindent
In this section we collect variants of the projection formula.
The most basic version is Lemma \ref{lemma-projection-formula}.
After we state and prove it, we discuss a more general version
involving perfect complexes.

\begin{lemma}
\label{lemma-injective-tensor-finite-locally-free}
Let $X$ be a ringed space.
Let $\mathcal{I}$ be an injective $\mathcal{O}_X$-module.
Let $\mathcal{E}$ be an $\mathcal{O}_X$-module.
Assume $\mathcal{E}$ is finite locally free on $X$, see
Modules, Definition \ref{modules-definition-locally-free}.
Then $\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{I}$ is
an injective $\mathcal{O}_X$-module.
\end{lemma}

\begin{proof}
This is true because under the assumptions of the lemma we have
$$
\Hom_{\mathcal{O}_X}(\mathcal{F},
\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{I})
=
\Hom_{\mathcal{O}_X}(
\mathcal{F} \otimes_{\mathcal{O}_X} \mathcal{E}^\vee, \mathcal{I})
$$
where
$\mathcal{E}^\vee = \SheafHom_{\mathcal{O}_X}(\mathcal{E}, \mathcal{O}_X)$
is the dual of $\mathcal{E}$ which is finite locally free also. Since tensoring
with a finite locally free sheaf is an exact functor we win by
Homology, Lemma \ref{homology-lemma-characterize-injectives}.
\end{proof}

\begin{lemma}
\label{lemma-projection-formula}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
Let $\mathcal{E}$ be an $\mathcal{O}_Y$-module.
Assume $\mathcal{E}$ is finite locally free on $Y$, see
Modules, Definition \ref{modules-definition-locally-free}.
Then there exist isomorphisms
$$
\mathcal{E} \otimes_{\mathcal{O}_Y} R^qf_*\mathcal{F}
\longrightarrow
R^qf_*(f^*\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{F})
$$
for all $q \geq 0$. In fact there exists an isomorphism
$$
\mathcal{E} \otimes_{\mathcal{O}_Y} Rf_*\mathcal{F}
\longrightarrow
Rf_*(f^*\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{F})
$$
in $D^{+}(Y)$ functorial in $\mathcal{F}$.
\end{lemma}

\begin{proof}
Choose an injective resolution $\mathcal{F} \to \mathcal{I}^\bullet$
on $X$. Note that $f^*\mathcal{E}$ is finite locally free also, hence
we get a resolution
$$
f^*\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{F}
\longrightarrow
f^*\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{I}^\bullet
$$
which is an injective resolution by
Lemma \ref{lemma-injective-tensor-finite-locally-free}.
Apply $f_*$ to see that
$$
Rf_*(f^*\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{F})
=
f_*(f^*\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{I}^\bullet).
$$
Hence the lemma follows if we can show that
$f_*(f^*\mathcal{E} \otimes_{\mathcal{O}_X} \mathcal{F}) =
\mathcal{E} \otimes_{\mathcal{O}_Y} f_*(\mathcal{F})$ functorially
in the $\mathcal{O}_X$-module $\mathcal{F}$. This is clear when
$\mathcal{E} = \mathcal{O}_Y^{\oplus n}$, and follows in general
by working locally on $Y$. Details omitted.
\end{proof}

\noindent
Let $f : X \to Y$ be a morphism of ringed spaces. 
Let $E \in D(\mathcal{O}_X)$ and $K \in D(\mathcal{O}_Y)$.
Without any further assumptions there is a map
\begin{equation}
\label{equation-projection-formula-map}
Rf_*E \otimes^\mathbf{L}_{\mathcal{O}_Y} K
\longrightarrow
Rf_*(E \otimes^\mathbf{L}_{\mathcal{O}_X} Lf^*K)
\end{equation}
Namely, it is the adjoint to the canonical map
$$
Lf^*(Rf_*E \otimes^\mathbf{L}_{\mathcal{O}_Y} K) =
Lf^*Rf_*E \otimes^\mathbf{L}_{\mathcal{O}_X} Lf^*K
\longrightarrow
E \otimes^\mathbf{L}_{\mathcal{O}_X} Lf^*K
$$
coming from the map $Lf^*Rf_*E \to E$ and Lemmas
\ref{lemma-pullback-tensor-product} and \ref{lemma-adjoint}.
A reasonably general version of the projection formula is the following.

\begin{lemma}
\label{lemma-projection-formula-perfect}
Let $f : X \to Y$ be a morphism of ringed spaces.
Let $E \in D(\mathcal{O}_X)$ and $K \in D(\mathcal{O}_Y)$.
If $K$ is perfect, then
$$
Rf_*E \otimes^\mathbf{L}_{\mathcal{O}_Y} K =
Rf_*(E \otimes^\mathbf{L}_{\mathcal{O}_X} Lf^*K)
$$
in $D(\mathcal{O}_Y)$.
\end{lemma}

\begin{proof}
To check (\ref{equation-projection-formula-map}) is an isomorphism
we may work locally on $Y$, i.e., we have to find a covering $\{V_j \to Y\}$
such that the map restricts to an isomorphism on $V_j$. By definition
of perfect objects, this means we may assume $K$ is represented by
a strictly perfect complex of $\mathcal{O}_Y$-modules.
Note that, completely generally, the statement is true for
$K = K_1 \oplus K_2$, if and only if the statement is true for
$K_1$ and $K_2$. Hence we may assume $K$ is a finite
complex of finite free $\mathcal{O}_Y$-modules.
In this case a simple argument involving stupid truncations reduces
the statement to the case where $K$ is represented by a finite
free $\mathcal{O}_Y$-module. Since the statement is invariant
under finite direct summands in the $K$ variable, we conclude
it suffices to prove it for $K = \mathcal{O}_Y[n]$
in which case it is trivial.
\end{proof}

\noindent
Here is a case where the projection formula is true in complete
generality.

\begin{lemma}
\label{lemma-projection-formula-closed-immersion}
Let $f : X \to Y$ be a morphism of ringed spaces such that $f$ is a
homeomorphism onto a closed subset. Then
(\ref{equation-projection-formula-map}) is an isomorphism always.
\end{lemma}

\begin{proof}
Since $f$ is a homeomorphism onto a closed subset, the functor $f_*$
is exact (Modules, Lemma \ref{modules-lemma-i-star-exact}). Hence
$Rf_*$ is computed by applying $f_*$ to any representative complex.
Choose a K-flat complex $\mathcal{K}^\bullet$ of $\mathcal{O}_Y$-modules
representing $K$ and choose any complex $\mathcal{E}^\bullet$
of $\mathcal{O}_X$-modules representing $E$. Then
$Lf^*K$ is represented by $f^*\mathcal{K}^\bullet$ which is
a K-flat complex of $\mathcal{O}_X$-modules
(Lemma \ref{lemma-pullback-K-flat}). Thus the right hand side of
(\ref{equation-projection-formula-map}) is represented by
$$
f_*\text{Tot}(\mathcal{E}^\bullet
\otimes_{\mathcal{O}_X} f^*\mathcal{K}^\bullet)
$$
By the same reasoning we see that the left hand side is represented by
$$
\text{Tot}(f_*\mathcal{E}^\bullet \otimes_{\mathcal{O}_Y} \mathcal{K}^\bullet)
$$
Since $f_*$ commutes with direct sums
(Modules, Lemma \ref{modules-lemma-i-star-right-adjoint})
it suffices to show that
$$
f_*(\mathcal{E} \otimes_{\mathcal{O}_X} f^*\mathcal{K}) =
f_*\mathcal{E} \otimes_{\mathcal{O}_Y} \mathcal{K}
$$
for any $\mathcal{O}_X$-module $\mathcal{E}$ and $\mathcal{O}_Y$-module
$\mathcal{K}$. We will check this by checking on stalks.
Let $y \in Y$. If $y \not \in f(X)$, then the stalks
of both sides are zero. If $y = f(x)$, then we see that we have to show
$$
\mathcal{E}_x \otimes_{\mathcal{O}_{X, x}}
(\mathcal{O}_{X, x} \otimes_{\mathcal{O}_{Y, y}} \mathcal{F}_y) =
\mathcal{E}_x \otimes_{\mathcal{O}_{Y, y}} \mathcal{F}_y
$$
(using Sheaves, Lemma \ref{sheaves-lemma-stalks-closed-pushforward}
and Lemma \ref{sheaves-lemma-stalk-pullback-modules}).
This equality holds and therefore the lemma has been proved.
\end{proof}

\begin{remark}
\label{remark-compatible-with-diagram}
The map (\ref{equation-projection-formula-map}) is compatible with the
base change map of Remark \ref{remark-base-change} in the following sense.
Namely, suppose that
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} &
X \ar[d]^f \\
Y' \ar[r]^g &
Y
}
$$
is a commutative diagram of ringed spaces. 
Let $E \in D(\mathcal{O}_X)$ and $K \in D(\mathcal{O}_Y)$.
Then the diagram
$$
\xymatrix{
Lg^*(Rf_*E \otimes^\mathbf{L}_{\mathcal{O}_Y} K) \ar[r]_p \ar[d]_t &
Lg^*Rf_*(E \otimes^\mathbf{L}_{\mathcal{O}_X} Lf^*K) \ar[d]_b \\
Lg^*Rf_*E \otimes^\mathbf{L}_{\mathcal{O}_{Y'}} Lg^*K \ar[d]_b &
Rf'_*L(g')^*(E \otimes^\mathbf{L}_{\mathcal{O}_X} Lf^*K) \ar[d]_t \\
Rf'_*L(g')^*E \otimes^\mathbf{L}_{\mathcal{O}_{Y'}} Lg^*K \ar[rd]_p &
Rf'_*(L(g')^*E \otimes^\mathbf{L}_{\mathcal{O}_{Y'}} L(g')^*Lf^*K) \ar[d]_c \\
& Rf'_*(L(g')^*E \otimes^\mathbf{L}_{\mathcal{O}_{Y'}} L(f')^*Lg^*K)
}
$$
is commutative. Here arrows labeled $t$ are gotten by an application of
Lemma \ref{lemma-pullback-tensor-product}, arrows labeled $b$ by an
application of Remark \ref{remark-base-change}, arrows labeled $p$
by an application of (\ref{equation-projection-formula-map}), and
$c$ comes from $L(g')^* \circ Lf^* = L(f')^* \circ Lg^*$.
We omit the verification.
\end{remark}















\section{An operator introduced by Berthelot and Ogus}
\label{section-eta}

\noindent
This section continuous the discussion started in
More on Algebra, Section \ref{more-algebra-section-eta}.
We strongly encourage the reader to read that section first.

\begin{lemma}
\label{lemma-invertible-ideal-sheaf}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{I} \subset \mathcal{O}_X$ be a sheaf of ideals.
Consider the following two conditions
\begin{enumerate}
\item for every $x \in X$ there exists an open neighbourhood
$U \subset X$ of $x$ and $f \in \mathcal{I}(U)$ such that
$\mathcal{I}|_U = \mathcal{O}_U \cdot f$ and
$f : \mathcal{O}_U \to \mathcal{O}_U$ is injective, and
\item $\mathcal{I}$ is invertible as an $\mathcal{O}_X$-module.
\end{enumerate}
Then (1) implies (2) and the converse is true if all stalks
$\mathcal{O}_{X, x}$ of the structure sheaf are local rings.
\end{lemma}

\begin{proof}
Omitted. Hint: Use Modules, Lemma
\ref{modules-lemma-invertible-is-locally-free-rank-1}.
\end{proof}

\begin{situation}
\label{situation-eta}
Let $(X, \mathcal{O}_X)$ be a ringed space. Let
$\mathcal{I} \subset \mathcal{O}_X$ be a sheaf of ideals
satisfying condition (1) of
Lemma \ref{lemma-invertible-ideal-sheaf}\footnote{The discussion
in this section can be generalized to the case where all we
require is that $\mathcal{I}$ is an invertible $\mathcal{O}_X$-module
as defined in Modules, Section \ref{modules-section-invertible}.}.
\end{situation}

\begin{lemma}
\label{lemma-I-torsion-free}
In Situation \ref{situation-eta}
let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
The following are equivalent
\begin{enumerate}
\item the subsheaf $\mathcal{F}[\mathcal{I}] \subset \mathcal{F}$
of sections annihilated by $\mathcal{I}$ is zero,
\item the subsheaf $\mathcal{F}[\mathcal{I}^n]$ is zero for all $n \geq 1$,
\item the multiplication map
$\mathcal{I} \otimes_{\mathcal{O}_X} \mathcal{F} \to \mathcal{F}$
is injective,
\item for every open $U \subset X$ such that
$\mathcal{I}|_U = \mathcal{O}_U \cdot f$
for some $f \in \mathcal{I}(U)$
the map $f : \mathcal{F}|_U \to \mathcal{F}|_U$ is injective,
\item for every $x \in X$ and generator $f$ of the ideal
$\mathcal{I}_x \subset \mathcal{O}_{X, x}$ the element $f$
is a nonzerodivisor on the stalk $\mathcal{F}_x$.
\end{enumerate}
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\noindent
In Situation \ref{situation-eta}
let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
If the equivalent conditions of Lemma \ref{lemma-I-torsion-free} hold,
then we will say that $\mathcal{F}$ is {\it $\mathcal{I}$-torsion free}.
If so, then for any $i \in \mathbf{Z}$ we will denote
$$
\mathcal{I}^i\mathcal{F} =
\mathcal{I}^{\otimes i} \otimes_{\mathcal{O}_X} \mathcal{F}
$$
so that we have inclusions
$$
\ldots \subset
\mathcal{I}^{i + 1}\mathcal{F} \subset
\mathcal{I}^i\mathcal{F} \subset
\mathcal{I}^{i - 1}\mathcal{F} \subset \ldots
$$
The modules $\mathcal{I}^i\mathcal{F}$ are locally isomorphic to
$\mathcal{F}$ as $\mathcal{O}_X$-modules, but not globally.

\medskip\noindent
Let $\mathcal{F}^\bullet$ be a complex of $\mathcal{I}$-torsion free
$\mathcal{O}_X$-modules with
differentials $d^i : \mathcal{F}^i \to \mathcal{F}^{i + 1}$.
In this case we define $\eta_\mathcal{I}\mathcal{F}^\bullet$
to be the complex with terms
\begin{align*}
(\eta_\mathcal{I}\mathcal{F})^i
& =
\Ker\left(
d^i, -1 :
\mathcal{I}^i\mathcal{F}^i \oplus \mathcal{I}^{i + 1}\mathcal{F}^{i + 1}
\to
\mathcal{I}^i\mathcal{F}^{i + 1}
\right) \\
& =
\Ker\left(d^i :
\mathcal{I}^i\mathcal{F}^i
\to
\mathcal{I}^i\mathcal{F}^{i + 1}/
\mathcal{I}^{i + 1}\mathcal{F}^{i + 1}
\right)
\end{align*}
and differential induced by $d^i$. In other words, a local section
$s$ of $(\eta_\mathcal{I}\mathcal{F})^i$ is the same thing as a local section
$s$ of $\mathcal{I}^i\mathcal{F}^i$ such that its image $d^i(s)$
in $\mathcal{I}^i\mathcal{F}^{i + 1}$ is in the subsheaf
$\mathcal{I}^{i + 1}\mathcal{F}^{i + 1}$.
Observe that $\eta_\mathcal{I}\mathcal{F}^\bullet$
is another complex of $\mathcal{I}$-torsion free modules.

\medskip\noindent
Let $a^\bullet : \mathcal{F}^\bullet \to \mathcal{G}^\bullet$ be a map of
complexes of $\mathcal{I}$-torsion free $\mathcal{O}_X$-modules.
Then we obtain a map of complexes
$$
\eta_\mathcal{I} a^\bullet :
\eta_\mathcal{I}\mathcal{F}^\bullet
\longrightarrow
\eta_\mathcal{I}\mathcal{G}^\bullet
$$
induced by the maps
$\mathcal{I}^i\mathcal{F}^i \to \mathcal{I}^i\mathcal{G}^i$.
The reader checks that we obtain
an endo-functor on the category of complexes of
$\mathcal{I}$-torsion free $\mathcal{O}_X$-modules.

\medskip\noindent
If $a^\bullet, b^\bullet : \mathcal{F}^\bullet \to \mathcal{G}^\bullet$
are two maps of
complexes of $\mathcal{I}$-torsion free $\mathcal{O}_X$-modules
and $h = \{h^i : \mathcal{F}^i \to \mathcal{G}^{i - 1}\}$ is a homotopy
between $a^\bullet$ and $b^\bullet$, then we define
$\eta_\mathcal{I}h$ to be the family of maps
$(\eta_\mathcal{I}h)^i : (\eta_\mathcal{I}\mathcal{F})^i \to
(\eta_\mathcal{I}\mathcal{G})^{i - 1}$
which sends $x$ to $h^i(x)$; this makes sense as
$x$ a local section of $\mathcal{I}^i\mathcal{F}^i$
implies $h^i(x)$ is a local section of $\mathcal{I}^i\mathcal{G}^{i - 1}$
which is certainly contained in $(\eta_\mathcal{I}\mathcal{G})^{i - 1}$.
The reader checks that $\eta_\mathcal{I}h$ is a homotopy
between $\eta_\mathcal{I}a^\bullet$ and $\eta_\mathcal{I}b^\bullet$.
All in all we see that we obtain a functor
$$
\eta_f :
K(\mathcal{I}\text{-torsion free }\mathcal{O}_X\text{-modules})
\longrightarrow
K(\mathcal{I}\text{-torsion free }\mathcal{O}_X\text{-modules})
$$
on the homotopy category
(Derived Categories, Section \ref{derived-section-homotopy})
of the additive category of $\mathcal{I}$-torsion free
$\mathcal{O}_X$-modules.
There is no sense in which $\eta_\mathcal{I}$ is an exact functor of
triangulated categories; compare with More on Algebra,
Example \ref{more-algebra-example-eta-not-distinguished}.

\begin{lemma}
\label{lemma-eta-stalks}
In Situation \ref{situation-eta}
let $\mathcal{F}^\bullet$ be a complex of $\mathcal{I}$-torsion free
$\mathcal{O}_X$-modules.
For $x \in X$ choose a generator $f \in \mathcal{I}_x$. Then
the stalk $(\eta_\mathcal{I}\mathcal{F}^\bullet)_x$ is canonically
isomorphic to the complex $\eta_f\mathcal{F}^\bullet_x$ constructed
in More on Algebra, Section \ref{more-algebra-section-eta}.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-eta-first-property}
In Situation \ref{situation-eta}
let $\mathcal{F}^\bullet$ be a complex of $\mathcal{I}$-torsion free
$\mathcal{O}_X$-modules. There is a canonical isomorphism
$$
\mathcal{I}^{\otimes i} \otimes_{\mathcal{O}_X}
\left(
H^i(\mathcal{F}^\bullet)/H^i(\mathcal{F}^\bullet)[\mathcal{I}]
\right)
\longrightarrow H^i(\eta_\mathcal{I}\mathcal{F}^\bullet)
$$
of cohomology sheaves.
\end{lemma}

\begin{proof}
We define a map
$$
\mathcal{I}^{\otimes i} \otimes_{\mathcal{O}_X} H^i(\mathcal{F}^\bullet)
\longrightarrow
H^i(\eta_\mathcal{I}\mathcal{F}^\bullet)
$$
as follows. Let $g$ be a local section of $\mathcal{I}^{\otimes i}$
and let $\overline{s}$ be a local section of $H^i(\mathcal{F}^\bullet)$.
Then $\overline{s}$ is (locally) the class of a local section $s$ of
$\Ker(d^i : \mathcal{F}^i \to \mathcal{F}^{i + 1})$.
Then we send $g \otimes \overline{s}$ to the local section
$gs$ of $(\eta_\mathcal{I}\mathcal{F})^i \subset \mathcal{I}^i\mathcal{F}$.
Of course $gs$ is in the kernel of $d^i$ on
$\eta_\mathcal{I}\mathcal{F}^\bullet$ and hence defines a local
section of $H^i(\eta_\mathcal{I}\mathcal{F}^\bullet)$.
Checking that this is well defined is without problems.
We claim that this map factors through an isomorphism
as given in the lemma. This we my check on stalks and hence
via Lemma \ref{lemma-eta-stalks} this translates into the result of
More on Algebra, Lemma \ref{more-algebra-lemma-eta-first-property}.
\end{proof}

\begin{lemma}
\label{lemma-eta-qis}
In Situation \ref{situation-eta}
let $\mathcal{F}^\bullet \to \mathcal{G}^\bullet$ be a map of
complexes of $\mathcal{I}$-torsion free $\mathcal{O}_X$-modules.
Then the induced map
$\eta_\mathcal{I}\mathcal{F}^\bullet \to \eta_\mathcal{I}\mathcal{G}^\bullet$
is a quasi-isomorphism too.
\end{lemma}

\begin{proof}
This is true because the isomorphisms of Lemma \ref{lemma-eta-first-property}
are compatible with maps of complexes.
\end{proof}

\begin{lemma}
\label{lemma-Leta}
In Situation \ref{situation-eta} there is an additive
functor\footnote{Beware that this functor isn't exact, i.e.,
does not transform distinguished triangles into distinguished triangles.}
$L\eta_\mathcal{I} : D(\mathcal{O}_X) \to D(\mathcal{O}_X)$
such that if $M$ in $D(\mathcal{O}_X)$ is represented by a complex
$\mathcal{F}^\bullet$ of $\mathcal{I}$-torsion free $\mathcal{O}_X$-modules,
then $L\eta_\mathcal{I}M = \eta_\mathcal{I}\mathcal{F}^\bullet$.
Similarly for morphisms.
\end{lemma}

\begin{proof}
Denote $\mathcal{T} \subset \textit{Mod}(\mathcal{O}_X)$ the full subcategory
of $\mathcal{I}$-torsion free $\mathcal{O}_X$-modules.
We have a corresponding inclusion
$$
K(\mathcal{T})
\quad\subset\quad
K(\textit{Mod}(\mathcal{O}_X)) = K(\mathcal{O}_X)
$$
of $K(\mathcal{T})$ as a full triangulated subcategory of $K(\mathcal{O}_X)$.
Let $S \subset \text{Arrows}(K(\mathcal{T}))$ be the quasi-isomorphisms.
We will apply
Derived Categories, Lemma \ref{derived-lemma-localization-subcategory}
to show that the map
$$
S^{-1}K(\mathcal{T}) \longrightarrow D(\mathcal{O}_X)
$$
is an equivalence of triangulated categories. The lemma shows that
it suffices to prove: given a complex $\mathcal{G}^\bullet$ of
$\mathcal{O}_X$-modules,
there exists a quasi-isomorphism $\mathcal{F}^\bullet \to \mathcal{G}^\bullet$
with $\mathcal{F}^\bullet$
a complex of $\mathcal{I}$-torsion free $\mathcal{O}_X$-modules.
By Lemma \ref{lemma-K-flat-resolution} we can find a quasi-isomorphism
$\mathcal{F}^\bullet \to \mathcal{G}^\bullet$ such that the complex
$\mathcal{F}^\bullet$ is K-flat (we won't use this) and
consists of flat $\mathcal{O}_X$-modules $\mathcal{F}^i$.
By the third characterization of Lemma \ref{lemma-I-torsion-free}
we see that a flat $\mathcal{O}_X$-module is an
$\mathcal{I}$-torsion free $\mathcal{O}_X$-module
and we are done.

\medskip\noindent
With these preliminaries out of the way we can define $L\eta_f$.
Namely, by the discussion following Lemma \ref{lemma-I-torsion-free}
this section we have already a well defined functor
$$
K(\mathcal{T}) \xrightarrow{\eta_f} K(\mathcal{T}) \to
K(\mathcal{O}_X) \to D(\mathcal{O}_X)
$$
which according to Lemma \ref{lemma-eta-qis} sends quasi-isomorphisms
to quasi-isomorphisms. Hence this functor factors over
$S^{-1}K(\mathcal{T}) = D(\mathcal{O}_X)$ by 
Categories, Lemma \ref{categories-lemma-properties-left-localization}.
\end{proof}

\noindent
In Situation \ref{situation-eta} let us construct the Bockstein operators.
First we observe that there is a commutative diagram
$$
\xymatrix{
0 \ar[r] &
\mathcal{I}^{i + 1} \ar[r] \ar[d] &
\mathcal{I}^i \ar[r] \ar[d] &
\mathcal{I}^i/\mathcal{I}^{i + 1}
\ar[r] \ar@{=}[d] &
0 \\
0 \ar[r] &
\mathcal{I}^{i + 1}/\mathcal{I}^{i + 2} \ar[r] &
\mathcal{I}^i/\mathcal{I}^{i + 2} \ar[r] &
\mathcal{I}^i/\mathcal{I}^{i + 1} \ar[r] &
0
}
$$
whose rows are short exact sequences of $\mathcal{O}_X$-modules.
Let $M$ be an object of $D(\mathcal{O}_X)$.
Tensoring the above diagram with $M$ gives a morphism
$$
\xymatrix{
M \otimes^\mathbf{L} \mathcal{I}^{i + 1} \ar[r] \ar[d] &
M \otimes^\mathbf{L} \mathcal{I}^i \ar[r] \ar[d] &
M \otimes^\mathbf{L} \mathcal{I}^i/\mathcal{I}^{i + 1} \ar[d]^{\text{id}} \\
M \otimes^\mathbf{L} \mathcal{I}^{i + 1}/\mathcal{I}^{i + 2} \ar[r] &
M \otimes^\mathbf{L} \mathcal{I}^i/\mathcal{I}^{i + 2} \ar[r] &
M \otimes^\mathbf{L} \mathcal{I}^i/\mathcal{I}^{i + 1}
}
$$
of distinguished triangles. The long exact sequence of
cohomology sheaves associated
the bottom triangle in particular determines the
{\it Bockstein operator}
$$
\beta = \beta^i :
H^i(M \otimes^\mathbf{L} \mathcal{I}^i/\mathcal{I}^{i + 1})
\longrightarrow
H^{i + 1}(M \otimes^\mathbf{L} \mathcal{I}^{i + 1}/\mathcal{I}^{i + 2})
$$
for all $i \in \mathbf{Z}$. For later use we record here that by
the commutative diagram above there is a factorization
\begin{equation}
\label{equation-factorization-bockstein}
\vcenter{
\xymatrix{
H^i(M \otimes^\mathbf{L} \mathcal{I}^i/\mathcal{I}^{i + 1})
\ar[r]_\delta \ar[rd]_\beta &
H^{i + 1}(M \otimes^\mathbf{L} \mathcal{I}^{i + 1}) \ar[d] \\
&
H^{i + 1}(M \otimes^\mathbf{L} \mathcal{I}^{i + 1}/\mathcal{I}^{i + 2})
}
}
\end{equation}
of the Bockstein operator where $\delta$ is the boundary operator
coming from the top distinguished triangle in the commutative diagram above.
We obtain a complex
\begin{equation}
\label{equation-complex-bocksteins}
H^\bullet(M/\mathcal{I}) =
\left[
\begin{matrix}
\ldots \\
\downarrow \\
H^{i - 1}(M \otimes^\mathbf{L} \mathcal{I}^{i - 1}/\mathcal{I}^i) \\
\downarrow \beta \\
H^i(M \otimes^\mathbf{L} \mathcal{I}^i/\mathcal{I}^{i + 1}) \\
\downarrow \beta \\
H^{i + 1}(M \otimes^\mathbf{L} \mathcal{I}^{i + 1}/\mathcal{I}^{i + 2}) \\
\downarrow \\
\ldots
\end{matrix}
\right]
\end{equation}
i.e., that $\beta \circ \beta = 0$. Namely, we can check this on stalks
and in this case we can deduce it from the corresponding result in algebra
shown in More on Algebra, Section \ref{more-algebra-section-eta}.
Alternative proof: the short exact sequences
$0 \to \mathcal{I}^{i + 1}/\mathcal{I}^{i + 2}
\to \mathcal{I}^i/\mathcal{I}^{i + 2}
\to \mathcal{I}^i/\mathcal{I}^{i + 1} \to 0$
define maps
$b^i : \mathcal{I}^i/\mathcal{I}^{i + 1} \to
(\mathcal{I}^{i + 1}/\mathcal{I}^{i + 2})[1]$
in $D(\mathcal{O}_X)$
which induce the maps $\beta$ above by tensoring with $M$
and taking cohomology sheaves.
Then one shows that the composition
$b^{i + 1}[1] \circ b^i : \mathcal{I}^i/\mathcal{I}^{i + 1} \to
(\mathcal{I}^{i + 1}/\mathcal{I}^{i + 2})[1] \to
(\mathcal{I}^{i + 2}/\mathcal{I}^{i + 3})[2]$
is zero in $D(\mathcal{O}_X)$ by using the criterion in
Derived Categories, Lemma \ref{derived-lemma-cup-ext-1-zero}
using that the module $\mathcal{I}^i/\mathcal{I}^{i + 3}$
is an extension of $\mathcal{I}^{i + 1}/\mathcal{I}^{i + 3}$
by $\mathcal{I}^i/\mathcal{I}^{i + 1}$.

\begin{lemma}
\label{lemma-eta-second-property}
In Situation \ref{situation-eta} let $M$ be an object of
$D(\mathcal{O}_X)$. There is a canonical isomorphism
$$
L\eta_\mathcal{I}M \otimes^\mathbf{L} \mathcal{O}_X/\mathcal{I}
\longrightarrow
H^\bullet(M/\mathcal{I})
$$
in $D(\mathcal{O}_X)$ where the right hand side is the complex
(\ref{equation-complex-bocksteins}).
\end{lemma}

\begin{proof}
By the construction of $L\eta_\mathcal{I}$ in Lemma \ref{lemma-eta-qis}
we may assume $M$ is represented by a complex of $\mathcal{I}$-torsion
free $\mathcal{O}_X$-modules $\mathcal{F}^\bullet$. Then
$L\eta_\mathcal{I}M$ is represented by the complex
$\eta_\mathcal{I}\mathcal{F}^\bullet$ which is a 
complex of $\mathcal{I}$-torsion free $\mathcal{O}_X$-modules as well.
Thus $L\eta_\mathcal{I}M \otimes^\mathbf{L} \mathcal{O}_X/\mathcal{I}$
is represented by the complex
$\eta_\mathcal{I}\mathcal{F}^\bullet \otimes \mathcal{O}_X/\mathcal{I}$.
Similarly, the complex $H^\bullet(M/\mathcal{I})$ has terms
$H^i(\mathcal{F}^\bullet \otimes \mathcal{I}^i/\mathcal{I}^{i + 1})$.

\medskip\noindent
Let $f$ be a local generator for $\mathcal{I}$.
Let $s$ be a local section of $(\eta_\mathcal{I}\mathcal{F})^i$.
Then we can write $s = f^is'$ for a local section $s'$ of
$\mathcal{F}^i$ and similarly $d^i(s) = f^{i + 1}t$ for a local
section $t$ of $\mathcal{F}^{i + 1}$. Thus $d^i$ maps $f^is'$
to zero in $\mathcal{F}^{i + 1} \otimes \mathcal{I}^i/\mathcal{I}^{i + 1}$.
Hence we may map $s$ to the class of $f^is'$ in
$H^i(\mathcal{F}^\bullet \otimes \mathcal{I}^i/\mathcal{I}^{i + 1})$.
This rule defines a map
$$
(\eta_\mathcal{I}\mathcal{F})^i \otimes \mathcal{O}_X/\mathcal{I}
\longrightarrow
H^i(\mathcal{F}^\bullet \otimes \mathcal{I}^i/\mathcal{I}^{i + 1})
$$
of $\mathcal{O}_X$-modules. A calculation shows that these maps
are compatible with differentials (essentially because $\beta$
sends the class of $f^is'$ to the class of $f^{i + 1}t$), whence
a map of complexes representing the arrow in the statement of the lemma.

\medskip\noindent
To finish the proof, we observe that the construction given
in the previous paragraph agrees on stalks with the maps
constructed in More on Algebra, Lemma
\ref{more-algebra-lemma-eta-second-property}
hence we conclude.
\end{proof}

\begin{lemma}
\label{lemma-eta-tensor-invertible}
In Situation \ref{situation-eta}
let $\mathcal{F}^\bullet$ be a complex of
$\mathcal{I}$-torsion free $\mathcal{O}_X$-modules.
Let $\mathcal{L}$ be an invertible $\mathcal{O}_X$-module.
Then $\eta_\mathcal{I}(\mathcal{F}^\bullet \otimes \mathcal{L}) =
(\eta_\mathcal{I}\mathcal{F}^\bullet) \otimes \mathcal{L}$.
\end{lemma}

\begin{proof}
Immediate from the construction.
\end{proof}

\begin{lemma}
\label{lemma-eta-cohomology-locally-free}
In Situation \ref{situation-eta} let $M$ be an object of $D(\mathcal{O}_X)$.
Let $x \in X$ with $\mathcal{O}_{X, x}$ nonzero. If $H^i(M)_x$
is finite free over $\mathcal{O}_{X, x}$, then $H^i(L\eta_\mathcal{I}M)_x$
is finite free over $\mathcal{O}_{X, x}$ of the same rank.
\end{lemma}

\begin{proof}
Namely, say $f \in \mathcal{O}_{X, x}$ generates the stalk $\mathcal{I}_x$.
Then $f$ is a nonzerodivisor in $\mathcal{O}_{X, x}$ and hence
$H^i(M)_x[f] = 0$. Thus by
Lemma \ref{lemma-eta-first-property}
we see that $H^i(L\eta_\mathcal{I}M)_x$
is isomorphic to
$\mathcal{I}^i_x \otimes_{\mathcal{O}_{X, x}} H^i(M)_x$
which is free of the same rank as desired.
\end{proof}









\input{chapters}

\bibliography{my}
\bibliographystyle{amsalpha}

\end{document}
