hcju/stacksqa huggingface dataset:
Let $U \to X$ be an \'etale morphism such that $U \to S$ factors as $U \to V \to S$ with $V \to S$ \'etale and $U \to V$ quasi-compact with geometrically connected fibres. Observe that $U \to V$ is flat (More on Flatness, Lemma \ref{flat-lemma-etale-flat-up-down}). We claim that \begin{align*} f^{-1}g_*\mathcal{F}(U) & = g_*\mathcal{F}(V) \\ & = \mathcal{F}(V \times_S T) \\ & = e^{-1}\mathcal{F}(U \times_X Y) \\ & = h_*e^{-1}\mathcal{F}(U) \end{align*} Namely, thinking of $U$ as an object of $X_\etale$ and $V$ as an object of $S_\etale$ we see that the first equality follows from Lemma \ref{lemma-sections-upstairs}\footnote{Strictly speaking, we are also using that the restriction of $f^{-1}g_*\mathcal{F}$ to $U_\etale$ is the pullback via $U \to V$ of the restriction of $g_*\mathcal{F}$ to $V_\etale$. See Sites, Lemma \ref{sites-lemma-localize-morphism-strong}.}. Thinking of $V \times_S T$ as an object of $T_\etale$ the second equality follows from the definition of $g_*$. Observe that $U \times_X Y = U \times_S T$ (because $Y = X \times_S T$) and hence $U \times_X Y \to V \times_S T$ has geometrically connected fibres as a base change of $U \to V$. Thinking of $U \times_X Y$ as an object of $Y_\etale$, we see that the third equality  follows from Lemma \ref{lemma-sections-upstairs} as before. Finally, the fourth equality follows from the definition of $h_*$. \medskip\noindent Since by assumption every object of $X_\etale$ has an \'etale covering to which the argument of the previous paragraph applies we see that the lemma is true.
We may work locally on $X$. Hence we may assume $X$ is affine. Then we can write $X$ as a cofiltered limit of affine schemes of finite type over $S$. By Lemma \ref{lemma-base-change-Rf-star-colim} we may assume that $X$ is of finite type over $S$. Then Lemma \ref{lemma-base-change-f-star-general} applies because any scheme of finite type over a separably closed field is a finite disjoint union of connected and geometrically connected schemes (see Varieties, Lemma \ref{varieties-lemma-separably-closed-field-connected-components}).
Let $I$ be a set and let $\mathcal{G}_i$ be a sheaf on $S_\etale$ for $i \in I$. Let $U \to X$ be an \'etale morphism such that $U \to S$ factors as $U \to V \to S$ with $V \to S$ \'etale and $U \to V$ flat of finite presentation with geometrically connected fibres. Then we have \begin{align*} f^{-1}(\prod \mathcal{G}_i)(U) & = (\prod \mathcal{G}_i)(V) \\ & = \prod \mathcal{G}_i(V) \\ & = \prod f^{-1}\mathcal{G}_i(U) \\ & = (\prod f^{-1}\mathcal{G}_i)(U) \end{align*} where we have used Lemma \ref{lemma-sections-upstairs} in the first and third equality (we are also using that the restriction of $f^{-1}\mathcal{G}$ to $U_\etale$ is the pullback via $U \to V$ of the restriction of $\mathcal{G}$ to $V_\etale$, see Sites, Lemma \ref{sites-lemma-localize-morphism-strong}). By More on Morphisms, Lemma \ref{more-morphisms-lemma-cover-by-geometrically-connected} every object $U$ of $X_\etale$ has an \'etale covering $\{U_i \to U\}$ such that the discussion in the previous paragraph applies to $U_i$. The lemma follows.
It suffices to check equality on stalks, see Theorem \ref{theorem-exactness-stalks}. By Theorem \ref{theorem-higher-direct-images} we have $$ (h_*e^{-1}\mathcal{F})_{\overline{x}} = \Gamma(\Spec(\mathcal{O}_{X, \overline{x}}^{sh}) \times_X Y, e^{-1}\mathcal{F}) $$ and we have similarly $$ (f^{-1}g_*^{-1}\mathcal{F})_{\overline{x}} = (g_*^{-1}\mathcal{F})_{f(\overline{x})} = \Gamma(\Spec(\mathcal{O}_{S, f(\overline{x})}^{sh}) \times_S T, \mathcal{F}) $$ These sets are equal by an application of Lemma \ref{lemma-sections-upstairs} to the morphism $$ \Spec(\mathcal{O}_{X, \overline{x}}^{sh}) \times_X Y \longrightarrow \Spec(\mathcal{O}_{S, f(\overline{x})}^{sh}) \times_S T $$ which is a base change of $\Spec(\mathcal{O}_{X, \overline{x}}^{sh}) \to \Spec(\mathcal{O}_{S, f(\overline{x})}^{sh})$ because $Y = X \times_S T$.
Observe that $\mathcal{F} \to \pi_*\pi^{-1}\mathcal{F}'$ is injective as $\pi$ is surjective (check on stalks). Thus by Lemma \ref{lemma-base-change-q-injective} we see that it suffices to show that the base change map $$ (f')^{-1}R^qg_*\pi_*\mathcal{F}' \longrightarrow R^qh_*e^{-1}\pi_*\mathcal{F}' $$ is an isomorphism. This follows from the assumption because we have $R^qg_*\pi_*\mathcal{F}' = R^qg'_*\mathcal{F}'$, we have $e^{-1}\pi_*\mathcal{F}' =\pi'_*(e')^{-1}\mathcal{F}'$, and we have $R^qh_*\pi'_*(e')^{-1}\mathcal{F}' = R^qh'_*(e')^{-1}\mathcal{F}'$. This follows from Lemmas \ref{lemma-integral-pushforward-commutes-with-base-change} and \ref{lemma-what-integral} and the relative leray spectral sequence (Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-relative-Leray}).
Since $\pi$ and $\pi'$ are integral we have $R\pi_* = \pi_*$ and $R\pi'_* = \pi'_*$, see Lemma \ref{lemma-what-integral}. We also have $(f')^{-1}\pi_* = \pi'_*(f'')^{-1}$. Thus we see that $\pi'_*(f'')^{-1}R^qg'_*\mathcal{F} = (f')^{-1}R^qg_*\mathcal{F}$ and $\pi'_*R^qh'_*e^{-1}\mathcal{F} = R^qh_*e^{-1}\mathcal{F}$. Thus the assumption means that our map becomes an isomorphism after applying the functor $\pi'_*$. Hence we see that it is an isomorphism by Lemma \ref{lemma-what-integral}.
First choose a diagram and $\mathcal{F}$ as in Lemma \ref{lemma-base-change-does-not-hold-pre}. We may and do assume $S'$ is affine (this is obvious, but see proof of the lemma in case of doubt). By Lemma \ref{lemma-base-change-q-integral-top} we may assume $K$ is algebraically closed. Then $\mathcal{F}$ corresponds to a $\mathbf{Z}/n\mathbf{Z}$-module. Such a modules is a direct sum of copies of $\mathbf{Z}/d\mathbf{Z}$ for varying $d | n$ hence we may assume $\mathcal{F}$ is constant with value $\mathbf{Z}/d\mathbf{Z}$. By Lemma \ref{lemma-base-change-q-integral-bottom} we may replace $S'$ by the normalization of $S'$ in $\Spec(K)$ which finishes the proof.
Consider the spectral sequences $$ E_2^{p, q} = R^pf_*H^q(E) \quad\text{and}\quad {E'}_2^{p, q} = R^pf'_*H^q((g')^{-1}E) = R^pf'_*(g')^{-1}H^q(E) $$ converging to $R^nf_*E$ and $R^nf'_*(g')^{-1}E$. These spectral sequences are constructed in Derived Categories, Lemma \ref{derived-lemma-two-ss-complex-functor}. Combining the smooth base change theorem (Theorem \ref{theorem-smooth-base-change}) with Lemma \ref{lemma-base-change-Rf-star-colim} we see that $$ g^{-1}R^pf_*H^q(E) = R^p(f')_*(g')^{-1}H^q(E) $$ Combining all of the above we get the lemma.
If $L/K$ is separable, then $L$ is a filtered colimit of smooth $K$-algebras, see Algebra, Lemma \ref{algebra-lemma-colimit-syntomic}. Thus the lemma in this case follows immediately from Lemma \ref{lemma-smooth-base-change-general}. In the general case, let $K'$ and $L'$ be the perfect closures (Algebra, Definition \ref{algebra-definition-perfection}) of $K$ and $L$. Then $\Spec(K') \to \Spec(K)$ and $\Spec(L') \to \Spec(L)$ are universal homeomorphisms as $K'/K$ and $L'/L$ are purely inseparable (see Algebra, Lemma \ref{algebra-lemma-p-ring-map}). Thus we have $(T_{K'})_\etale = T_\etale$, $(S_{K'})_\etale = S_\etale$, $(T_{L'})_\etale = (T_L)\etale$, and $(S_{L'})_\etale = (S_L)_\etale$ by the topological invariance of \'etale cohomology, see Proposition \ref{proposition-topological-invariance}. This reduces the lemma to the case of the field extension $L'/K'$ which is separable (by definition of perfect fields, see Algebra, Definition \ref{algebra-definition-perfect}).
Proof of (1). First let $\overline{k}$ and $\overline{K}$ be the algebraic closures of $k$ and $K$. The morphisms $\Spec(\overline{k}) \to \Spec(k)$ and $\Spec(\overline{K}) \to \Spec(K)$ are universal homeomorphisms as $\overline{k}/k$ and $\overline{K}/K$ are purely inseparable (see Algebra, Lemma \ref{algebra-lemma-p-ring-map}). Thus $H^q_\etale(X, \mathcal{F}) = H^q_\etale(X_{\overline{k}}, \mathcal{F}_{X_{\overline{k}}})$ by the topological invariance of \'etale cohomology, see Proposition \ref{proposition-topological-invariance}. Similarly for $X_K$ and $X_{\overline{K}}$. Thus we may assume $k$ and $K$ are algebraically closed. In this case $K$ is a limit of smooth $k$-algebras, see Algebra, Lemma \ref{algebra-lemma-colimit-syntomic}. We conclude our lemma is a special case of Theorem \ref{theorem-smooth-base-change} as reformulated in Lemma \ref{lemma-smooth-base-change-general}. \medskip\noindent Proof of (2). For any quasi-compact and quasi-separated $U$ in $X_\etale$ the above shows that the restriction of the map $E \to R(X_K \to X)_*E|_{X_K}$ determines an isomorphism on cohomology. Since every object of $X_\etale$ has an \'etale covering by such $U$ this proves the desired statement.
First choose a diagram and $\mathcal{F}$ as in Lemma \ref{lemma-base-change-does-not-hold}. We may and do assume $S'$ is affine (this is obvious, but see proof of the lemma in case of doubt). Let $K'$ be the function field of $S'$ and let $Y' = X' \times_{S'} \Spec(K')$ to get the diagram $$ \xymatrix{ X \ar[d]_f & X' \ar[d] \ar[l] & Y' \ar[l]^{h'} \ar[d] & Y \ar[l] \ar[d] \\ S & S' \ar[l] & \Spec(K') \ar[l] & \Spec(K) \ar[l] } $$ By Lemma \ref{lemma-smooth-base-change-separably-closed} the total direct image $R(Y \to Y')_*\mathbf{Z}/d\mathbf{Z}$ is isomorphic to $\mathbf{Z}/d\mathbf{Z}$ in $D(Y'_\etale)$; here we use that $n$ is invertible on $S$. Thus $Rh'_*\mathbf{Z}/d\mathbf{Z} = Rh_*\mathbf{Z}/d\mathbf{Z}$ by the relative Leray spectral sequence. This finishes the proof.
We will use Lemma \ref{lemma-h0-topological} to prove this. First observe that the underlying topological space of $X$ is spectral by Properties, Lemma \ref{properties-lemma-quasi-compact-quasi-separated-spectral}. Let $Y \subset X$ be an irreducible closed subscheme. To finish the proof we show that $Y \cap Z = Y \times_{\Spec(A)} \Spec(A/I)$ is connected. Replacing $X$ by $Y$ we may assume that $X$ is irreducible and we have to show that $Z$ is connected. Let $X \to \Spec(B) \to \Spec(A)$ be the Stein factorization of $f$ (More on Morphisms, Theorem \ref{more-morphisms-theorem-stein-factorization-general}). Then $A \to B$ is integral and $(B, IB)$ is a henselian pair (More on Algebra, Lemma \ref{more-algebra-lemma-integral-over-henselian-pair}). Thus we may assume the fibres of $X \to \Spec(A)$ are geometrically connected. On the other hand, the image $T \subset \Spec(A)$ of $f$ is irreducible and closed as $X$ is proper over $A$. Hence $T \cap V(I)$ is connected by More on Algebra, Lemma \ref{more-algebra-lemma-irreducible-henselian-pair-connected}. Now $Y \times_{\Spec(A)} \Spec(A/I) \to T \cap V(I)$ is a surjective closed map with connected fibres. The result now follows from Topology, Lemma \ref{topology-lemma-connected-fibres-quotient-topology-connected-components}.
By Theorem \ref{theorem-higher-direct-images} (for sheaves of sets) we have $$ (f_*\mathcal{F})_{\overline{s}} = \Gamma(X \times_S \Spec(\mathcal{O}_{S, \overline{s}}^{sh}), p_{small}^{-1}\mathcal{F}) $$ where $p : X \times_S \Spec(\mathcal{O}_{S, \overline{s}}^{sh}) \to X$ is the projection. Since the residue field of the strictly henselian local ring $\mathcal{O}_{S, \overline{s}}^{sh}$ is $\kappa(s)^{sep}$ we conclude from the discussion above the lemma and Lemma \ref{lemma-h0-proper-over-henselian-local}.
There is a canonical map $g^{-1}f_*\mathcal{F} \to f'_*(g')^{-1}\mathcal{F}$. Namely, it is adjoint to the map $$ f_*\mathcal{F} \longrightarrow g_*f'_*(g')^{-1}\mathcal{F} = f_*g'_*(g')^{-1}\mathcal{F} $$ which is $f_*$ applied to the canonical map $\mathcal{F} \to g'_*(g')^{-1}\mathcal{F}$. To check this map is an isomorphism we can compute what happens on stalks. Let $y' : \Spec(k) \to Y'$ be a geometric point with image $y$ in $Y$. By Lemma \ref{lemma-proper-pushforward-stalk} the stalks are $\Gamma(X'_{y'}, \mathcal{F}_{y'})$ and $\Gamma(X_y, \mathcal{F}_y)$ respectively. Here the sheaves $\mathcal{F}_y$ and $\mathcal{F}_{y'}$ are the pullbacks of $\mathcal{F}$ by the projections $X_y \to X$ and $X'_{y'} \to X$. Thus we see that the groups agree by Lemma \ref{lemma-sections-base-field-extension}. We omit the verification that this isomorphism is compatible with our map.
It is clear that (1) implies (2). Conversely, assume (2) and let $\mathcal{F}$ be a torsion abelian sheaf on $X_\etale$. Let $Y' \to Y$ be a morphism of schemes and let $X' = Y' \times_Y X$ with projections $g' : X' \to X$ and $f' : X' \to Y'$ as in diagram (\ref{equation-base-change-diagram}). We want to show the maps of sheaves $$ g^{-1}R^qf_*\mathcal{F} \longrightarrow R^qf'_*(g')^{-1}\mathcal{F} $$ are isomorphisms for all $q \geq 0$. \medskip\noindent For every $n \geq 1$, let $\mathcal{F}[n]$ be the subsheaf of sections of $\mathcal{F}$ annihilated by $n$. Then $\mathcal{F} = \colim \mathcal{F}[n]$. The functors $g^{-1}$ and $(g')^{-1}$ commute with arbitrary colimits (as left adjoints). Taking higher direct images along $f$ or $f'$ commutes with filtered colimits by Lemma \ref{lemma-relative-colimit}. Hence we see that $$ g^{-1}R^qf_*\mathcal{F} = \colim g^{-1}R^qf_*\mathcal{F}[n] \quad\text{and}\quad R^qf'_*(g')^{-1}\mathcal{F} = \colim R^qf'_*(g')^{-1}\mathcal{F}[n] $$ Thus it suffices to prove the result in case $\mathcal{F}$ is annihilated by a positive integer $n$. \medskip\noindent If $n = \ell n'$ for some prime number $\ell$, then we obtain a short exact sequence $$ 0 \to \mathcal{F}[\ell] \to \mathcal{F} \to \mathcal{F}/\mathcal{F}[\ell] \to 0 $$ Observe that $\mathcal{F}/\mathcal{F}[\ell]$ is annihilated by $n'$. Moreover, if the result holds for both $\mathcal{F}[\ell]$ and $\mathcal{F}/\mathcal{F}[\ell]$, then the result holds by the long exact sequence of higher direct images (and the $5$ lemma). In this way we reduce to the case that $\mathcal{F}$ is annihilated by a prime number $\ell$. \medskip\noindent Assume $\mathcal{F}$ is annihilated by a prime number $\ell$. Choose an injective resolution $\mathcal{F} \to \mathcal{I}^\bullet$ in $D(X_\etale, \mathbf{Z}/\ell\mathbf{Z})$. Applying assumption (2) and Leray's acyclicity lemma (Derived Categories, Lemma \ref{derived-lemma-leray-acyclicity}) we see that $$ f'_*(g')^{-1}\mathcal{I}^\bullet $$ computes $Rf'_*(g')^{-1}\mathcal{F}$. We conclude by applying Lemma \ref{lemma-proper-base-change-f-star}.
We will use the equivalence of Lemma \ref{lemma-proper-base-change-in-terms-of-injectives} without further mention. Let $\ell$ be a prime number. Let $\mathcal{I}$ be an injective sheaf of $\mathbf{Z}/\ell\mathbf{Z}$-modules on $Y_\etale$. Choose an injective map of sheaves $f^{-1}\mathcal{I} \to \mathcal{J}$ where $\mathcal{J}$ is an injective sheaf of $\mathbf{Z}/\ell\mathbf{Z}$-modules on $Z_\etale$. Since $f$ is surjective the map $\mathcal{I} \to f_*\mathcal{J}$ is injective (look at stalks in geometric points). Since $\mathcal{I}$ is injective we see that $\mathcal{I}$ is a direct summand of $f_*\mathcal{J}$. Thus it suffices to prove the desired vanishing for $f_*\mathcal{J}$. \medskip\noindent Let $Z' \to Z$ be a morphism of schemes and set $Y' = Z' \times_Z Y$ and $X' = Z' \times_Z X = Y' \times_ Y X$. Denote $a : X' \to X$, $b : Y' \to Y$, and $c : Z' \to Z$ the projections. Similarly for $f' : X' \to Y'$ and $g' : Y' \to Z'$. By Lemma \ref{lemma-proper-base-change-f-star} we have $b^{-1}f_*\mathcal{J} = f'_*a^{-1}\mathcal{J}$. On the other hand, we know that $R^qf'_*a^{-1}\mathcal{J}$ and $R^q(g' \circ f')_*a^{-1}\mathcal{J}$ are zero for $q > 0$. Using the spectral sequence (Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-relative-Leray}) $$ R^pg'_* R^qf'_* a^{-1}\mathcal{J} \Rightarrow R^{p + q}(g' \circ f')_* a^{-1}\mathcal{J} $$ we conclude that $ R^pg'_*(b^{-1}f_*\mathcal{J}) = R^pg'_*(f'_*a^{-1}\mathcal{J}) = 0$ for $p > 0$ as desired.
We will use the equivalence of Lemma \ref{lemma-proper-base-change-in-terms-of-injectives} without further mention. Let $\ell$ be a prime number. Let $\mathcal{I}$ be an injective sheaf of $\mathbf{Z}/\ell\mathbf{Z}$-modules on $X_\etale$. Then $f_*\mathcal{I}$ is an injective sheaf of $\mathbf{Z}/\ell\mathbf{Z}$-modules on $Y_\etale$ (Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-pushforward-injective-flat}). The result follows formally from this, but we will also spell it out. \medskip\noindent Let $Z' \to Z$ be a morphism of schemes and set $Y' = Z' \times_Z Y$ and $X' = Z' \times_Z X = Y' \times_ Y X$. Denote $a : X' \to X$, $b : Y' \to Y$, and $c : Z' \to Z$ the projections. Similarly for $f' : X' \to Y'$ and $g' : Y' \to Z'$. By Lemma \ref{lemma-proper-base-change-f-star} we have $b^{-1}f_*\mathcal{I} = f'_*a^{-1}\mathcal{I}$. On the other hand, we know that $R^qf'_*a^{-1}\mathcal{I}$ and $R^q(g')_*b^{-1}f_*\mathcal{I}$ are zero for $q > 0$. Using the spectral sequence (Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-relative-Leray}) $$ R^pg'_* R^qf'_* a^{-1}\mathcal{I} \Rightarrow R^{p + q}(g' \circ f')_* a^{-1}\mathcal{I} $$ we conclude that $R^p(g' \circ f')_*a^{-1}\mathcal{I} = 0$ for $p > 0$ as desired.
Observe that a finite morphism is proper, see Morphisms, Lemma \ref{morphisms-lemma-finite-proper}. Moreover, the base change of a finite morphism is finite, see Morphisms, Lemma \ref{morphisms-lemma-base-change-finite}. Thus the result follows from Lemma \ref{lemma-proper-base-change-in-terms-of-injectives} combined with Proposition \ref{proposition-finite-higher-direct-image-zero}.
Let $f : X \to Y$ be a proper morphism of schemes. Let $Y = \bigcup Y_i$ be an affine open covering and set $X_i = f^{-1}(Y_i)$. If we can prove cohomology commutes with base change for $X_i \to Y_i$, then cohomology commutes with base change for $f$. Namely, the formation of the higher direct images commutes with Zariski (and even \'etale) localization on the base, see Lemma \ref{lemma-higher-direct-images}. Thus we may assume $Y$ is affine. \medskip\noindent Let $Y$ be an affine scheme and let $X \to Y$ be a proper morphism. By Chow's lemma there exists a commutative diagram $$ \xymatrix{ X \ar[rd] & X' \ar[d] \ar[l]^\pi \ar[r] & \mathbf{P}^n_Y \ar[dl] \\ & Y & } $$ where $X' \to \mathbf{P}^n_Y$ is an immersion, and $\pi : X' \to X$ is proper and surjective, see Limits, Lemma \ref{limits-lemma-chow-finite-type}. Since $X \to Y$ is proper, we find that $X' \to Y$ is proper (Morphisms, Lemma \ref{morphisms-lemma-composition-proper}). Hence $X' \to \mathbf{P}^n_Y$ is a closed immersion (Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}). It follows that $X' \to X \times_Y \mathbf{P}^n_Y = \mathbf{P}^n_X$ is a closed immersion (as an immersion with closed image). \medskip\noindent By Lemma \ref{lemma-sandwich} it suffices to prove cohomology commutes with base change for $\pi$ and $X' \to Y$. These morphisms both factor as a closed immersion followed by a projection $\mathbf{P}^n_S \to S$ (for some $S$). By Lemma \ref{lemma-finite} the result holds for closed immersions (as closed immersions are finite). By Lemma \ref{lemma-composition} it suffices to prove the result for projections $\mathbf{P}^n_S \to S$. \medskip\noindent For every $n \geq 1$ there is a finite surjective morphism $$ \mathbf{P}^1_S \times_S \ldots \times_S \mathbf{P}^1_S \longrightarrow \mathbf{P}^n_S $$ given on coordinates by $$ ((x_1 : y_1), (x_2 : y_2), \ldots, (x_n : y_n)) \longmapsto (F_0 : \ldots : F_n) $$ where $F_0, \ldots, F_n$ in $x_1, \ldots, y_n$ are the polynomials with integer coefficients such that $$ \prod (x_i t + y_i) = F_0 t^n + F_1 t^{n - 1} + \ldots + F_n $$ Applying Lemmas \ref{lemma-sandwich}, \ref{lemma-finite}, and \ref{lemma-composition} one more time we conclude that the lemma is true.
In the statement, $\mathcal{F}_{\overline{y}}$ denotes the pullback of $\mathcal{F}$ to the scheme theoretic fibre $X_{\overline{y}} = \overline{y} \times_Y X$. Since pulling back by $\overline{y} \to Y$ produces the stalk of $\mathcal{F}$, the first statement of the lemma is a special case of Theorem \ref{theorem-proper-base-change}. The second one is a special case of Lemma \ref{lemma-proper-base-change}.
It is enough to prove this when $Y$ and $Y'$ are quasi-compact. By Morphisms, Lemma \ref{morphisms-lemma-morphism-finite-type-bounded-dimension} we see that the dimension of the fibres of $f : X \to Y$ and $f' : X' \to Y'$ are bounded. Thus Lemma \ref{lemma-cohomological-dimension-proper} implies that $$ f_* : \textit{Mod}(X_\etale, \mathbf{Z}/n\mathbf{Z}) \longrightarrow \textit{Mod}(Y_\etale, \mathbf{Z}/n\mathbf{Z}) $$ and $$ f'_* : \textit{Mod}(X'_\etale, \mathbf{Z}/n\mathbf{Z}) \longrightarrow \textit{Mod}(Y'_\etale, \mathbf{Z}/n\mathbf{Z}) $$ have finite cohomological dimension in the sense of Derived Categories, Lemma \ref{derived-lemma-unbounded-right-derived}. Choose a K-injective complex $\mathcal{I}^\bullet$ of $\mathbf{Z}/n\mathbf{Z}$-modules each of whose terms $\mathcal{I}^n$ is an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules representing $E$. See Injectives, Theorem \ref{injectives-theorem-K-injective-embedding-grothendieck}. By the usual proper base change theorem we find that $R^qf'_*(g')^{-1}\mathcal{I}^n = 0$ for $q > 0$, see Theorem \ref{theorem-proper-base-change}. Hence we conclude by  Derived Categories, Lemma \ref{derived-lemma-unbounded-right-derived} that we may compute $Rf'_*(g')^{-1}E$ by the complex $f'_*(g')^{-1}\mathcal{I}^\bullet$. Another application of the usual proper base change theorem shows that this is equal to $g^{-1}f_*\mathcal{I}^\bullet$ as desired.
Say $H^i(E) = 0$ for $i \geq a$ and $H^j(K) = 0$ for $j \geq b$. We may represent $K$ by a bounded below complex $K^\bullet$ of torsion free $\mathbf{Z}$-modules. (Choose a K-flat complex $L^\bullet$ representing $K$ and then take $K^\bullet = \tau_{\geq b - 1}L^\bullet$. This works because $\mathbf{Z}$ has global dimension $1$. See More on Algebra, Lemma \ref{more-algebra-lemma-last-one-flat}.) We may represent $E$ by a bounded below complex $\mathcal{E}^\bullet$. Then $E \otimes_\mathbf{Z}^\mathbf{L} \underline{K}$ is represented by $$ \text{Tot}(\mathcal{E}^\bullet \otimes_\mathbf{Z} \underline{K}^\bullet) $$ Using distinguished triangles $$ \sigma_{\geq -b + n + 1}K^\bullet \to K^\bullet \to \sigma_{\leq -b + n}K^\bullet $$ and the trivial vanishing $$ H^n(X, \text{Tot}(\mathcal{E}^\bullet \otimes_\mathbf{Z} \sigma_{\geq -a + n + 1}\underline{K}^\bullet) = 0 $$ and $$ H^n(R\Gamma(X, E) \otimes_\mathbf{Z}^\mathbf{L} \sigma_{\geq -a + n + 1}K^\bullet) = 0 $$ we reduce to the case where $K^\bullet$ is a bounded complex of flat $\mathbf{Z}$-modules. Repeating the argument we reduce to the case where $K^\bullet$ is equal to a single flat $\mathbf{Z}$-module sitting in some degree. Next, using the stupid trunctions for $\mathcal{E}^\bullet$ we reduce in exactly the same manner to the case where $\mathcal{E}^\bullet$ is a single abelian sheaf sitting in some degree. Thus it suffices to show that $$ H^n(X, \mathcal{E} \otimes_\mathbf{Z} \underline{M}) = H^n(X, \mathcal{E}) \otimes_\mathbf{Z} M $$ when $M$ is a flat $\mathbf{Z}$-module and $\mathcal{E}$ is an abelian sheaf on $X$. In this case we write $M$ is a filtered colimit of finite free $\mathbf{Z}$-modules (Lazard's theorem, see Algebra, Theorem \ref{algebra-theorem-lazard}). By Theorem \ref{theorem-colimit} this reduces us to the case of finite free $\mathbf{Z}$-module $M$ in which case the result is trivially true.