hcju/stacksqa huggingface dataset:
We may replace $K$ by its sheafification and assume $K$ is a sheaf. Note that both $H^p(K, \mathcal{F})$ and $H^p(K, \mathcal{F}_{ab})$ depend only on the topos, not on the underlying site. Hence by Sites, Lemma \ref{sites-lemma-topos-good-site} we may replace $\mathcal{C}$ by a ``larger'' site such that $K = h_U$ for some object $U$ of $\mathcal{C}$. In this case the result follows from Lemma \ref{lemma-cohomology-modules-abelian-agree}.
Since sheafification is exact, we see that $(K_p')^\#$ is equal to $(K')^\# \times_{K^\#} \ldots \times_{K^\#} (K')^\#$ ($p + 1$-factors). Thus we may replace $K$ and $K'$ by their sheafifications and assume $K \to K'$ is a surjective map of sheaves. After replacing $\mathcal{C}$ by a ``larger'' site as in Sites, Lemma \ref{sites-lemma-topos-good-site}  we may assume that $K, K'$ are objects of $\mathcal{C}$ and that $\mathcal{U} = \{K' \to K\}$ is a covering. Then we have the {\v C}ech to cohomology spectral sequence of Lemma \ref{lemma-cech-spectral-sequence} whose $E_1$ page is as indicated in the statement of the lemma.
By assumption (1) we have $H^p(h_U^\#, g^{-1}\mathcal{I}) = 0$ for all $p > 0$ and all objects $U$ of $\mathcal{C}$. Note that if $K = \coprod K_i$ is a coproduct of sheaves of sets on $\mathcal{C}$ then $H^p(K, g^{-1}\mathcal{I}) = \prod H^p(K_i, g^{-1}\mathcal{I})$. For any sheaf of sets $K$ there exists a surjection $$ K' = \coprod h_{U_i}^\# \longrightarrow K $$ see Sites, Lemma \ref{sites-lemma-sheaf-coequalizer-representable}. Thus we conclude that: (*) for every sheaf of sets $K$ there exists a surjection $K' \to K$ of sheaves of sets such that $H^p(K', \mathcal{F}) = 0$ for $p > 0$. We claim that (*) and condition (2) imply that $\mathcal{F}$ is totally acyclic. Note that conditions (*) and (2) only depend on $\mathcal{F}$ as an object of the topos $\Sh(\mathcal{C})$ and not on the underlying site. (We will not use property (1) in the rest of the proof.) \medskip\noindent We are going to prove by induction on $n \geq 0$ that (*) and (2) imply the following induction hypothesis $IH_n$: $H^p(K, \mathcal{F}) = 0$ for all $0 < p \leq n$ and all sheaves of sets $K$. Note that $IH_0$ holds. Assume $IH_n$. Pick a sheaf of sets $K$. Pick a surjection $K' \to K$ such that $H^p(K', \mathcal{F}) = 0$ for all $p > 0$. We have a spectral sequence with $$ E_1^{p, q} = H^q(K'_p, \mathcal{F}) $$ covering to $H^{p + q}(K, \mathcal{F})$, see Lemma \ref{lemma-cech-to-cohomology-sheaf-sets}. By $IH_n$ we see that $E_1^{p, q} = 0$ for $0 < q \leq n$ and by assumption (2) we see that $E_2^{p, 0} = 0$ for $p > 0$. Finally, we have $E_1^{0, q} = 0$ for $q > 0$ because $H^q(K', \mathcal{F}) = 0$ by choice of $K'$. Hence we conclude that $H^{n + 1}(K, \mathcal{F}) = 0$ because all the terms $E_2^{p, q}$ with $p + q = n + 1$ are zero.
Let $K$ be a sheaf of sets on $\mathcal{D}$. By Modules on Sites, Lemma \ref{sites-modules-lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites} we may replace $\mathcal{C}$, $\mathcal{D}$ by ``larger'' sites such that $f$ comes from a morphism of ringed sites induced by a continuous functor $u : \mathcal{D} \to \mathcal{C}$ such that $K = h_V$ for some object $V$ of $\mathcal{D}$. \medskip\noindent Thus we have to show that $H^q(V, f_*\mathcal{I})$ is zero for $q > 0$ and all objects $V$ of $\mathcal{D}$ when $f$ is given by a morphism of ringed sites. Let $\mathcal{V} = \{V_j \to V\}$ be any covering of $\mathcal{D}$. Since $u$ is continuous we see that $\mathcal{U} = \{u(V_j) \to u(V)\}$ is a covering of $\mathcal{C}$. Then we have an equality of {\v C}ech complexes $$ \check{\mathcal{C}}^\bullet(\mathcal{V}, f_*\mathcal{I}) = \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{I}) $$ by the definition of $f_*$. By Lemma \ref{lemma-injective-module-trivial-cech} we see that the cohomology of this complex is zero in positive degrees. We win by Lemma \ref{lemma-cech-vanish-collection}.
Part (2) is the definition of a totally acyclic sheaf. Part (1) is a consequence of (2) as pointed out in the discussion following the definition of totally acyclic sheaves. Part (3) is a special case of (2) where $K = e$ is the final object of $\Sh(\mathcal{C})$. \medskip\noindent To prove (4) we may assume, by Modules on Sites, Lemma \ref{sites-modules-lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites} that $f$ is given by a morphism of sites. In this case we see that $R^if_*$, $i > 0$ of a totally acyclic sheaf are zero by the description of higher direct images in Lemma \ref{lemma-higher-direct-images}.
This is just the Grothendieck spectral sequence Derived Categories, Lemma \ref{derived-lemma-grothendieck-spectral-sequence} coming from the composition of functors $\Gamma(\mathcal{C}, -) = \Gamma(\mathcal{D}, -) \circ f_*$. To see that the assumptions of Derived Categories, Lemma \ref{derived-lemma-grothendieck-spectral-sequence} are satisfied, see Lemmas \ref{lemma-direct-image-injective-sheaf} and \ref{lemma-limp-acyclic}.
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 $\mathcal{D}$ 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.
To prove the lemma we will argue by induction on $p$. Note that we require in (1) the coverings $\mathcal{U} \in \text{Cov}$ to be finite, so that all the elements of $\mathcal{B}$ are quasi-compact. Hence (2) and (1) imply that any $U \in \mathcal{B}$ satisfies the hypothesis of Sites, Lemma \ref{sites-lemma-directed-colimits-sections} (4). Thus we see that the result holds for $p = 0$. Now we assume the lemma holds for $p$ and prove it for $p + 1$. \medskip\noindent Choose a filtered diagram $\mathcal{F} : \mathcal{I} \to \textit{Ab}(\mathcal{C})$, $i \mapsto \mathcal{F}_i$. Since $\textit{Ab}(\mathcal{C})$ has functorial injective embeddings, see Injectives, Theorem \ref{injectives-theorem-sheaves-injectives}, we can find a morphism of filtered diagrams $\mathcal{F} \to \mathcal{I}$ such that each $\mathcal{F}_i \to \mathcal{I}_i$ is an injective map of abelian sheaves into an injective abelian sheaf. 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. $$ Since colimits of sheaves are the sheafification of colimits on the level of presheaves, since sheafification is exact, and since filtered colimits of abelian groups are exact (see Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}), we see 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. We claim that $H^q(U, \colim_i \mathcal{I}_i) = 0$ for all $U \in \mathcal{B}$ and all $q \geq 1$. Accepting this claim for the moment consider the diagram $$ \xymatrix{ \colim_i H^p(U, \mathcal{I}_i) \ar[d] \ar[r] & \colim_i H^p(U, \mathcal{Q}_i) \ar[d] \ar[r] & \colim_i H^{p + 1}(U, \mathcal{F}_i) \ar[d] \ar[r] & 0 \ar[d] \\ H^p(U, \colim_i \mathcal{I}_i) \ar[r] & H^p(U, \colim_i \mathcal{Q}_i) \ar[r] & H^{p + 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 $p + 1$. \medskip\noindent It remains to show that the claim is true. We will use Lemma \ref{lemma-cech-vanish-collection}. By the result for $p = 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 $U_{j_0} \times_U \ldots \times_U U_{j_p}$ are in $\mathcal{B}$. 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-collection}. are satisfied and the claim follows.
For each $i$ we pick an injection $\mathcal{F}_i \to \mathcal{A}_i$ where $\mathcal{A}_i$ is an injective abelian sheaf on $\mathcal{C}_i$. Then we can consider the family of maps $$ \gamma_i : \mathcal{F}_i \longrightarrow \prod\nolimits_{b : k \to i} f_{b, *}\mathcal{A}_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{A}_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{A}_k \to f_{b, *}\mathcal{A}_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 $\mathcal{C}_i$, see Lemma \ref{lemma-pushforward-injective-flat} and Homology, Lemma \ref{homology-lemma-product-injectives}. This finishes the construction.
The case $p = 0$ is Sites, Lemma \ref{sites-lemma-colimit}. \medskip\noindent Choose $(\mathcal{F}_i, \varphi_a) \to (\mathcal{G}_i, \psi_a)$ as in Lemma \ref{lemma-colim-sites-injective}. Arguing exactly as in the proof of Lemma \ref{lemma-colim-works-over-collection} 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 object of $\mathcal{C}$ we show that the {\v C}ech cohomology of $\mathcal{G}$ for any covering $\mathcal{U}$ of $\mathcal{C}$ is zero (Lemma \ref{lemma-cech-vanish-collection}). The covering $\mathcal{U}$ comes from a covering $\mathcal{U}_i$ of $\mathcal{C}_i$ for some $i$. We have $$ \check{\mathcal{C}}^\bullet(\mathcal{U}, \mathcal{G}) = \colim_{a : j \to i} \check{\mathcal{C}}^\bullet(u_a(\mathcal{U}_i), \mathcal{G}_j) $$ by the case $p = 0$. The right hand side is acyclic in positive degrees as a filtered colimit of acyclic complexes by Lemma \ref{lemma-injective-trivial-cech}. See Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}.
Let $\mathcal{G}^\bullet$ be an exact complex of $\mathcal{O}_U$-modules. Since $j_{U!}$ is exact (Modules on Sites, Lemma \ref{sites-modules-lemma-extension-by-zero-exact}) and $\mathcal{K}^\bullet$ is a K-flat complex of $\mathcal{O}$-modules we see that the complex $$ j_{U!}(\text{Tot}(\mathcal{G}^\bullet \otimes_{\mathcal{O}_U} \mathcal{K}^\bullet|_U)) = \text{Tot}(j_{U!}\mathcal{G}^\bullet \otimes_\mathcal{O} \mathcal{K}^\bullet) $$ is exact. Here the equality comes from Modules on Sites, Lemma \ref{sites-modules-lemma-j-shriek-and-tensor} and the fact that $j_{U!}$ commutes with direct sums (as a left adjoint). We conclude because $j_{U!}$ reflects exactness by Modules on Sites, Lemma \ref{sites-modules-lemma-j-shriek-reflects-exactness}.
By Modules on Sites, Lemma \ref{sites-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} \mathcal{K}_1^\bullet) \to \text{Tot}(\mathcal{L}^\bullet \otimes_\mathcal{O} \mathcal{K}_1^\bullet) \to \text{Tot}(\mathcal{L}^\bullet \otimes_\mathcal{O} \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.
Let $\mathcal{K}^\bullet$ be a bounded above complex of flat $\mathcal{O}$-modules. Let $\mathcal{L}^\bullet$ be an acyclic complex of $\mathcal{O}$-modules. Note that $\mathcal{L}^\bullet = \colim_m \tau_{\leq m}\mathcal{L}^\bullet$ where we take termwise colimits. Hence also $$ \text{Tot}(\mathcal{K}^\bullet \otimes_\mathcal{O} \mathcal{L}^\bullet) = \colim_m \text{Tot}( \mathcal{K}^\bullet \otimes_\mathcal{O} \tau_{\leq m}\mathcal{L}^\bullet) $$ termwise. Hence to prove the complex on the left is acyclic it suffices to show each of the complexes on the right is acyclic. Since $\tau_{\leq m}\mathcal{L}^\bullet$ is acyclic this reduces us to the case where $\mathcal{L}^\bullet$ is bounded above. In this case the spectral sequence of Homology, Lemma \ref{homology-lemma-first-quadrant-ss} has $$ {}'E_1^{p, q} = H^p(\mathcal{L}^\bullet \otimes_R \mathcal{K}^q) $$ which is zero as $\mathcal{K}^q$ is flat and $\mathcal{L}^\bullet$ acyclic. Hence we win.
The existence of the diagram and properties (1), (2), (3) follows immediately from Modules on Sites, Lemma \ref{sites-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.
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 on Sites, Lemma \ref{sites-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.
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} \mathcal{P}^\bullet) \ar[r] \ar[d] & \text{Tot}(\mathcal{K}^\bullet \otimes_\mathcal{O} \mathcal{Q}^\bullet) \ar[d] \\ \text{Tot}(\mathcal{F}^\bullet \otimes_\mathcal{O} \mathcal{P}^\bullet) \ar[r] & \text{Tot}(\mathcal{F}^\bullet \otimes_\mathcal{O} \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.
Observe that $$ \ldots \to \mathcal{K}^{n - 2} \to \mathcal{K}^{n - 1} \to \mathcal{F} \to 0 $$ is a flat resolution of our module $\mathcal{F}$. Since a bounded above complex of flat modules is K-flat (Lemma \ref{lemma-bounded-flat-K-flat}) we may use this resolution to compute $\text{Tor}_i(\mathcal{F}, \mathcal{G})$ for any $\mathcal{O}$-module $\mathcal{G}$. On the one hand $\mathcal{K}^\bullet \otimes_\mathcal{O}^\mathbf{L} \mathcal{G}$ is zero in $D(\mathcal{O})$ because $\mathcal{K}^\bullet$ is acyclic and on the other hand it is represented by $\mathcal{K}^\bullet \otimes_\mathcal{O} \mathcal{G}$. Hence we see that $$ \mathcal{K}^{n - 3} \otimes_\mathcal{O} \mathcal{G} \to \mathcal{K}^{n - 2} \otimes_\mathcal{O} \mathcal{G} \to \mathcal{K}^{n - 1} \otimes_\mathcal{O} \mathcal{G} $$ is exact. Thus $\text{Tor}_1(\mathcal{F}, \mathcal{G}) = 0$ and we conclude by Lemma \ref{lemma-flat-tor-zero}.
We will use that the homotopy category $K(\textit{Mod}(\mathcal{O}))$ 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})$ 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.
The terms $f^*\mathcal{K}^n$ are flat $\mathcal{O}'$-modules by Modules on Sites, Lemma \ref{sites-modules-lemma-pullback-flat}. Choose a diagram $$ \xymatrix{ \mathcal{K}_1^\bullet \ar[d] \ar[r] & \mathcal{K}_2^\bullet \ar[d] \ar[r] & \ldots \\ \tau_{\leq 1}\mathcal{K}^\bullet \ar[r] & \tau_{\leq 2}\mathcal{K}^\bullet \ar[r] & \ldots } $$ as in Lemma \ref{lemma-resolution-by-direct-sums-extensions-by-zero}. We will use all of the properties stated in the lemma without further mention. Each $\mathcal{K}_n^\bullet$ is a bounded above complex of flat modules, see Modules on Sites, Lemma \ref{sites-modules-lemma-j-shriek-flat}. Consider the short exact sequence of complexes $$ 0 \to \mathcal{M}^\bullet \to \colim \mathcal{K}_n^\bullet \to \mathcal{K}^\bullet \to 0 $$ defining $\mathcal{M}^\bullet$. By Lemmas \ref{lemma-bounded-flat-K-flat} and \ref{lemma-colimit-K-flat} the complex $\colim \mathcal{K}_n^\bullet$ is K-flat and by Modules on Sites, Lemma \ref{sites-modules-lemma-colimits-flat} it has flat terms. By Modules on Sites, Lemma \ref{sites-modules-lemma-flat-ses} $\mathcal{M}^\bullet$ has flat terms, by Lemma \ref{lemma-K-flat-two-out-of-three-ses} $\mathcal{M}^\bullet$ is K-flat, and by the long exact cohomology sequence $\mathcal{M}^\bullet$ is acyclic (because the second arrow is a quasi-isomorphism). The pullback $f^*(\colim \mathcal{K}_n^\bullet) = \colim f^*\mathcal{K}_n^\bullet$ is a colimit of bounded below complexes of flat $\mathcal{O}'$-modules and hence is K-flat (by the same lemmas as above). The pullback of our short exact sequence $$ 0 \to f^*\mathcal{M}^\bullet \to f^*(\colim \mathcal{K}_n^\bullet) \to f^*\mathcal{K}^\bullet \to 0 $$ is a short exact sequence of complexes by Modules on Sites, Lemma \ref{sites-modules-lemma-pullback-ses}. Hence by Lemma \ref{lemma-K-flat-two-out-of-three-ses} it suffices to show that $f^*\mathcal{M}^\bullet$ is K-flat. This reduces us to the case discussed in the next paragraph. \medskip\noindent Assume $\mathcal{K}^\bullet$ is acyclic as well as K-flat and with flat terms. Then Lemma \ref{lemma-K-flat-flat-acyclic} guarantees that all terms of $\tau_{\leq n}\mathcal{K}^\bullet$ are flat $\mathcal{O}$-modules. We choose a diagram as above and we will use all the properties proven above for this diagram. Denote $\mathcal{M}_n^\bullet$ the kernel of the map of complexes $\mathcal{K}_n^\bullet \to \tau_{\leq n}\mathcal{K}^\bullet$ so that we have short exact sequences of complexes $$ 0 \to \mathcal{M}_n^\bullet \to \mathcal{K}_n^\bullet \to \tau_{\leq n}\mathcal{K}^\bullet \to 0 $$ By Modules on Sites, Lemma \ref{sites-modules-lemma-flat-ses} we see that the terms of the complex $\mathcal{M}_n^\bullet$ are flat. Hence we see that $\mathcal{M} = \colim \mathcal{M}_n^\bullet$ is a filtered colimit of bounded below complexes of flat modules in this case. Thus $f^*\mathcal{M}^\bullet$ is K-flat (same argument as above) and we win.
To see this we use the general theory developed in Derived Categories, Section \ref{derived-section-derived-functors}. Set $\mathcal{D} = K(\mathcal{O}')$ and $\mathcal{D}' = D(\mathcal{O})$. 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}')$. 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 $\mathcal{K}^\bullet$ with flat terms. Namely, (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 elements of $\mathcal{P}$ 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}'} \mathcal{O} \longrightarrow f^{-1}\mathcal{K}_2^\bullet \otimes_{f^{-1}\mathcal{O}'} \mathcal{O} $$ 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. The complexes $f^{-1}\mathcal{K}_1^\bullet$ and $f^{-1}\mathcal{K}_2^\bullet$ are K-flat complexes of $f^{-1}\mathcal{O}'$-modules by Lemma \ref{lemma-pullback-K-flat} because we can consider the morphism of ringed topoi $(\Sh(\mathcal{C}), f^{-1}\mathcal{O}') \to (\Sh(\mathcal{C}'), \mathcal{O}')$. 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}') = S^{-1}\mathcal{D} \longrightarrow \mathcal{D}' = D(\mathcal{O}) $$ 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 in $\mathcal{P}$. The proof is finished by observing that bounded above complexes of flat modules are in $\mathcal{P}$ by Lemma \ref{lemma-bounded-flat-K-flat}.
Let $E$ be an object of $D(\mathcal{O}_\mathcal{E})$. We may represent $E$ by a K-flat complex $\mathcal{K}^\bullet$ with flat terms, see Lemma \ref{lemma-K-flat-resolution}. By construction $Lg^*E$ is computed by $g^*\mathcal{K}^\bullet$, see Lemma \ref{lemma-derived-base-change}. By Lemma \ref{lemma-pullback-K-flat} the complex $g^*\mathcal{K}^\bullet$ is K-flat with flat terms. Hence $Lf^*Lg^*E$ is represented by $f^*g^*\mathcal{K}^\bullet$. Since also $L(g \circ f)^*E$ is represented by $(g \circ f)^*\mathcal{K}^\bullet = f^*g^*\mathcal{K}^\bullet$ we conclude.