hcju/stacksqa huggingface dataset:
By Lemma \ref{lemma-essential-extension} the inclusion $R/\mathfrak p \subset \kappa(\mathfrak p)$ is an essential extension. Then Lemma \ref{lemma-injective-hull-unique} shows (2) holds. For $f \in R$, $f \not \in \mathfrak p$ the map $f : \kappa(\mathfrak p) \to \kappa(\mathfrak p)$ is an isomorphism hence the map $f : E \to E$ is an isomorphism, see Lemma \ref{lemma-injective-hull-unique}. Thus $E$ is an $R_\mathfrak p$-module. It is injective as an $R_\mathfrak p$-module by Lemma \ref{lemma-injective-epimorphism}. Finally, let $E' \subset E$ be a nonzero injective $R$-submodule. Then $J = (R/\mathfrak p) \cap E'$ is nonzero. After shrinking $E'$ we may assume that $E'$ is the injective hull of $J$ (see Lemma \ref{lemma-injective-hull-unique} for example). Observe that $R/\mathfrak p$ is an essential extension of $J$ for example by Lemma \ref{lemma-essential-extension}. Hence $E' \to E$ is an isomorphism by Lemma \ref{lemma-injective-hull-unique} part (3). Hence $E$ is indecomposable.
Let $\mathfrak p$ be the prime ideal found in Lemma \ref{lemma-indecomposable-injective}. Say $\mathfrak p = (f_1, \ldots, f_r)$. Pick a nonzero element $x \in \bigcap \Ker(f_i : E \to E)$, see Lemma \ref{lemma-indecomposable-injective}. Then $(R_\mathfrak p)x$ is a module isomorphic to $\kappa(\mathfrak p)$ inside $E$. We conclude by Lemma \ref{lemma-indecomposable-injective}.
Observe that the displayed arrow is injective. Namely, if $x \in M$ is a nonzero element, then there is a nonzero map $Rx \to \kappa$ which we can extend to a map $\varphi : M \to E$ that doesn't vanish on $x$. Since the source and target of the arrow have the same length by Lemma \ref{lemma-finite} we conclude it is an isomorphism. The final statement follows on taking $M = R$.
Observe that $E[I] = \Hom_R(S, E)$ as $S = R/I$. Hence $E[I]$ is an injective $S$-module by Lemma \ref{lemma-hom-injective}. Since $E$ is an essential extension of $\kappa = R/\mathfrak m_R$ it follows that $E[I]$ is an essential extension of $\kappa$ as well. The result follows.
Observe that $E^{\oplus n}$ is the injective hull of $\kappa^{\oplus n} = M[\mathfrak m]$. Thus there is an $R$-module map $M \to E^{\oplus n}$ which is injective on $M[\mathfrak m]$. Since $M$ is $\mathfrak m$-power torsion the inclusion $M[\mathfrak m] \subset M$ is an essential extension (for example by Lemma \ref{lemma-essential-extension}) we conclude that the kernel of $M \to E^{\oplus n}$ is zero.
We have $E_n = E[\mathfrak m^n]$ by Lemma \ref{lemma-quotient}. We have $E = \bigcup E_n$ because $\bigcup E_n = E[\mathfrak m^\infty]$ is an injective $R$-submodule which contains $\kappa$, see Lemma \ref{lemma-injective-module-divide}.
Set $\kappa = R/\mathfrak m_R = S/\mathfrak m_S$. Let $E_R$ be the injective hull of $\kappa$ over $R$. Let $E_S$ be the injective hull of $\kappa$ over $S$. Observe that $E_S$ is an injective $R$-module by Lemma \ref{lemma-injective-flat}. Choose an extension $E_R \to E_S$ of the identification of residue fields. This map is an isomorphism by Lemma \ref{lemma-union-artinian} because $R \to S$ induces an isomorphism $R/\mathfrak m_R^n \to S/\mathfrak m_S^n$ for all $n$.
Write $E = \bigcup E_n$ with $E_n = E[\mathfrak m^n]$ as in Lemma \ref{lemma-union-artinian}. Any endomorphism of $E$ preserves this filtration. Hence $$ \Hom_R(E, E) = \lim \Hom_R(E_n, E_n) $$ The lemma follows as $\Hom_R(E_n, E_n) = \Hom_{R/\mathfrak m^n}(E_n, E_n) = R/\mathfrak m^n$ by Lemma \ref{lemma-evaluate}.
If $E \supset M_1 \supset M_2 \supset \ldots$ is a sequence of submodules, then $$ \Hom_R(E, E) \to \Hom_R(M_1, E) \to \Hom_R(M_2, E) \to \ldots $$ is sequence of surjections. By Lemma \ref{lemma-endos} each of these is a module over the completion $R^\wedge = \Hom_R(E, E)$. Since $R^\wedge$ is Noetherian (Algebra, Lemma \ref{algebra-lemma-completion-Noetherian-Noetherian}) the sequence stabilizes: $\Hom_R(M_n, E) = \Hom_R(M_{n + 1}, E) = \ldots$. Since $E$ is injective, this can only happen if $\Hom_R(M_n/M_{n + 1}, E)$ is zero. However, if $M_n/M_{n + 1}$ is nonzero, then it contains a nonzero element annihilated by $\mathfrak m$, because $E$ is $\mathfrak m$-power torsion by Lemma \ref{lemma-union-artinian}. In this case $M_n/M_{n + 1}$ has a nonzero map into $E$, contradicting the assumed vanishing. This finishes the proof.
We omit the proof of (1). \medskip\noindent Let $M$ be an $R$-module with the descending chain condition. Let $x \in M$. Then $\mathfrak m^n x$ is a descending chain of submodules, hence stabilizes. Thus $\mathfrak m^nx = \mathfrak m^{n + 1}x$ for some $n$. By Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK}) this implies $\mathfrak m^n x = 0$, i.e., $x$ is $\mathfrak m$-power torsion. Since $M[\mathfrak m]$ is a vector space over $\kappa$ it has to be finite dimensional in order to have the descending chain condition. \medskip\noindent Assume that $M$ is $\mathfrak m$-power torsion and has a finite dimensional $\mathfrak m$-torsion submodule $M[\mathfrak m]$. By Lemma \ref{lemma-torsion-submodule-sum-injective-hulls} we see that $M$ is a submodule of $E^{\oplus n}$ for some $n$. Consider the quotient $N = E^{\oplus n}/M$. By Lemma \ref{lemma-injective-hull-has-dcc} the module $E$ has the descending chain condition hence so do $E^{\oplus n}$ and $N$. Therefore $N$ satisfies (2)(a) which implies $N$ satisfies (2)(b) by the second paragraph of the proof. Thus by Lemma \ref{lemma-torsion-submodule-sum-injective-hulls} again we see that $N$ is a submodule of $E^{\oplus m}$ for some $m$. Thus we have a short exact sequence $0 \to M \to E^{\oplus n} \to E^{\oplus m}$. \medskip\noindent Assume we have a short exact sequence $0 \to M \to E^{\oplus n} \to E^{\oplus m}$. Since $E$ satisfies the descending chain condition by Lemma \ref{lemma-injective-hull-has-dcc} so does $M$.
Let $J^\bullet$ be a K-injective complex representing $K$. Then $$ R\Gamma_I(K) = J^\bullet[I^\infty] = \colim J^\bullet[I^n] = \colim \Hom_A(A/I^n, J^\bullet) $$ The first equality is the definition. By Derived Categories, Lemma \ref{derived-lemma-colim-hocolim} we obtain the second equality. The third equality is clear because $H^q(\Hom_A(A/I^n, J^\bullet)) = \Ext^q_A(A/I^n, K)$ and because filtered colimits are exact in the category of abelian groups.
Say $I = (f_1, \ldots, f_r)$ is an ideal. Let $K^\bullet$ be a complex of $A$-modules. There is a canonical map of complexes $$ (A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to \prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to \ldots \to A_{f_1\ldots f_r}) \longrightarrow A. $$ from the extended {\v C}ech complex to $A$. Tensoring with $K^\bullet$, taking associated total complex, we get a map $$ \text{Tot}\left( K^\bullet \otimes_A (A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to \prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to \ldots \to A_{f_1\ldots f_r})\right) \longrightarrow K^\bullet $$ in $D(A)$. We claim the cohomology modules of the complex on the left are $I$-power torsion, i.e., the LHS is an object of $D_{I^\infty\text{-torsion}}(A)$. Namely, we have $$ (A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to \prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to \ldots \to A_{f_1\ldots f_r}) = \colim K(A, f_1^n, \ldots, f_r^n) $$ by More on Algebra, Lemma \ref{more-algebra-lemma-extended-alternating-Cech-is-colimit-koszul}. Moreover, multiplication by $f_i^n$ on the complex $K(A, f_1^n, \ldots, f_r^n)$ is homotopic to zero by More on Algebra, Lemma \ref{more-algebra-lemma-homotopy-koszul}. Since $$ H^q\left( LHS \right) = \colim H^q(\text{Tot}(K^\bullet \otimes_A K(A, f_1^n, \ldots, f_r^n))) $$ we obtain our claim. On the other hand, if $K^\bullet$ is an object of $D_{I^\infty\text{-torsion}}(A)$, then the complexes $K^\bullet \otimes_A A_{f_{i_0} \ldots f_{i_p}}$ have vanishing cohomology. Hence in this case the map $LHS \to K^\bullet$ is an isomorphism in $D(A)$. The construction $$ R\Gamma_Z(K^\bullet) = \text{Tot}\left( K^\bullet \otimes_A (A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to \prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to \ldots \to A_{f_1\ldots f_r})\right) $$ is functorial in $K^\bullet$ and defines an exact functor $D(A) \to D_{I^\infty\text{-torsion}}(A)$ between triangulated categories. It follows formally from the existence of the natural transformation $R\Gamma_Z \to \text{id}$ given above and the fact that this evaluates to an isomorphism on $K^\bullet$ in the subcategory, that $R\Gamma_Z$ is the desired right adjoint.
This follows from uniqueness of adjoint functors as both $R\Gamma_Z((-)_A)$ and $R\Gamma_Y(-)_A$ are right adjoint to the functor $D_{I^\infty\text{-torsion}}(A) \to D(B)$, $K \mapsto K \otimes_A^\mathbf{L} B$. Alternatively, one can use the description of $R\Gamma_Z$ and $R\Gamma_Y$ in terms of alternating {\v C}ech complexes (Lemma \ref{lemma-local-cohomology-adjoint}). Namely, if $I = (f_1, \ldots, f_r)$ then $J$ is generated by the images $g_1, \ldots, g_r \in B$ of $f_1, \ldots, f_r$. Then the statement of the lemma follows from the existence of a canonical isomorphism \begin{align*} & M_A \otimes_A (A \to \prod\nolimits_{i_0} A_{f_{i_0}} \to \prod\nolimits_{i_0 < i_1} A_{f_{i_0}f_{i_1}} \to \ldots \to A_{f_1\ldots f_r}) \\ & =  M \otimes_B (B \to \prod\nolimits_{i_0} B_{g_{i_0}} \to \prod\nolimits_{i_0 < i_1} B_{g_{i_0}g_{i_1}} \to \ldots \to B_{g_1\ldots g_r}) \end{align*} for any $B$-module $M$.
Write $I = (f_1, \ldots, f_r)$. Then $J$ is generated by the images $g_1, \ldots, g_r \in B$ of $f_1, \ldots, f_r$. Then we have $$ (A \to \prod A_{f_{i_0}} \to \ldots \to A_{f_1\ldots f_r}) \otimes_A B = (B \to \prod B_{g_{i_0}} \to \ldots \to B_{g_1\ldots g_r}) $$ as complexes of $B$-modules. Represent $K$ by a K-flat complex $K^\bullet$ of $A$-modules. Since the total complexes associated to $$ K^\bullet \otimes_A (A \to \prod A_{f_{i_0}} \to \ldots \to A_{f_1\ldots f_r}) \otimes_A B $$ and $$ K^\bullet \otimes_A B \otimes_B (B \to \prod B_{g_{i_0}} \to \ldots \to B_{g_1\ldots g_r}) $$ represent the left and right hand side of the displayed formula of the lemma (see Lemma \ref{lemma-local-cohomology-adjoint}) we conclude.
By Lemma \ref{lemma-local-cohomology-adjoint} we know that $R\Gamma_Z$ is given by $C \otimes^\mathbf{L} -$ for some $C \in D(A)$. Hence, for $K, L \in D(A)$ general we have $$ R\Gamma_Z(K \otimes_A^\mathbf{L} L) = K \otimes^\mathbf{L} L \otimes_A^\mathbf{L} C = K \otimes_A^\mathbf{L} R\Gamma_Z(L) $$ The other equalities follow formally from this one. This also implies the last statement of the lemma.
There is a bit of abuse of notation in the lemma as strictly speaking we cannot compose $R\Gamma_Y$ and $R\Gamma_Z$. The meaning of the statement is simply that we are composing $R\Gamma_Z$ with the inclusion $D_{I^\infty\text{-torsion}}(A) \to D(A)$ and then with $R\Gamma_Y$. Then the equality $R\Gamma_Y \circ R\Gamma_Z = R\Gamma_{Y \cap Z}$ follows from the fact that $$ D_{I^\infty\text{-torsion}}(A) \to D(A) \xrightarrow{R\Gamma_Y} D_{(I + J)^\infty\text{-torsion}}(A) $$ is right adjoint to the inclusion $D_{(I + J)^\infty\text{-torsion}}(A) \to D_{I^\infty\text{-torsion}}(A)$. Alternatively one can prove the formula using Lemma \ref{lemma-local-cohomology-adjoint} and the fact that the tensor product of extended {\v C}ech complexes on $f_1, \ldots, f_r$ and $g_1, \ldots, g_m$ is the extended {\v C}ech complex on $f_1, \ldots, f_n. g_1, \ldots, g_m$. The final assertion follows from this and the cited lemma.
More precisely the functors are $K \mapsto K \otimes_A^\mathbf{L} B$ for $K$ in $D_{I^\infty\text{-torsion}}(A)$ and $M \mapsto M_A$ for $M$ in $D_{(IB)^\infty\text{-torsion}}(B)$. The reason this works is that $H^i(K \otimes_A^\mathbf{L} B) = H^i(K) \otimes_A B = H^i(K)$. The first equality holds as $A \to B$ is flat and the second by More on Algebra, Lemma \ref{more-algebra-lemma-neighbourhood-isomorphism}.
Let $Z = V(I) \subset \Spec(A)$ and $Y = V(IB) \subset \Spec(B)$. Since the cohomology modules of $K$ are $I$ power torsion, the canonical map $R\Gamma_Z(L) \to L$ induces an isomorphism $$ R\Hom_A(K, R\Gamma_Z(L)) \to R\Hom_A(K, L) $$ in $D(A)$. Similarly, the cohomology modules of $K \otimes_A B$ are $IB$ power torsion and we have an isomorphism $$ R\Hom_B(K \otimes_A B, R\Gamma_Y(L \otimes_A B)) \to  R\Hom_B(K \otimes_A B, L \otimes_A B) $$ in $D(B)$. By Lemma \ref{lemma-torsion-change-rings} we have $R\Gamma_Z(L) \otimes_A B = R\Gamma_Y(L \otimes_A B)$. Hence it suffices to show that the map $$ R\Hom_A(K, R\Gamma_Z(L)) \to R\Hom_B(K \otimes_A B, R\Gamma_Z(L) \otimes_A B) $$ is a quasi-isomorphism. This follows from Lemma \ref{lemma-torsion-flat-change-rings}.
A formal argument, which we omit, shows that it suffices to prove (1). \medskip\noindent Let $M$ be an $I$-power torsion $A$-module. Choose an embedding $M \to J$ into an injective $A$-module. Then $J[I^\infty]$ is an injective $A$-module, see Lemma \ref{lemma-injective-module-divide}, and we obtain an embedding $M \to J[I^\infty]$. Thus every $I$-power torsion module has an injective resolution $M \to J^\bullet$ with $J^n$ also $I$-power torsion. It follows that $R\Gamma_I(M) = M$ (this is not a triviality and this is not true in general if $A$ is not Noetherian). Next, suppose that $K \in D_{I^\infty\text{-torsion}}^+(A)$. Then the spectral sequence $$ R^q\Gamma_I(H^p(K)) \Rightarrow R^{p + q}\Gamma_I(K) $$ (Derived Categories, Lemma \ref{derived-lemma-two-ss-complex-functor}) converges and above we have seen that only the terms with $q = 0$ are nonzero. Thus we see that $R\Gamma_I(K) \to K$ is an isomorphism. \medskip\noindent Suppose $K$ is an arbitrary object of $D_{I^\infty\text{-torsion}}(A)$. We have $$ R^q\Gamma_I(K) = \colim \Ext^q_A(A/I^n, K) $$ by Lemma \ref{lemma-local-cohomology-ext}. Choose $f_1, \ldots, f_r \in A$ generating $I$. Let $K_n^\bullet = K(A, f_1^n, \ldots, f_r^n)$ be the Koszul complex with terms in degrees $-r, \ldots, 0$. Since the pro-objects $\{A/I^n\}$ and $\{K_n^\bullet\}$ in $D(A)$ are the same by More on Algebra, Lemma \ref{more-algebra-lemma-sequence-Koszul-complexes}, we see that $$ R^q\Gamma_I(K) = \colim \Ext^q_A(K_n^\bullet, K) $$ Pick any complex $K^\bullet$ of $A$-modules representing $K$. Since $K_n^\bullet$ is a finite complex of finite free modules we see that $$ \Ext^q_A(K_n, K) = H^q(\text{Tot}((K_n^\bullet)^\vee \otimes_A K^\bullet)) $$ where $(K_n^\bullet)^\vee$ is the dual of the complex $K_n^\bullet$. See More on Algebra, Lemma \ref{more-algebra-lemma-RHom-out-of-projective}. As $(K_n^\bullet)^\vee$ is a complex of finite free $A$-modules sitting in degrees $0, \ldots, r$ we see that the terms of the complex $\text{Tot}((K_n^\bullet)^\vee \otimes_A K^\bullet)$ are the same as the terms of the complex $\text{Tot}((K_n^\bullet)^\vee \otimes_A \tau_{\geq q - r - 2} K^\bullet)$ in degrees $q - 1$ and higher. Hence we see that $$ \Ext^q_A(K_n, K) = \text{Ext}^q_A(K_n, \tau_{\geq q - r - 2}K) $$ for all $n$. It follows that $$ R^q\Gamma_I(K) = R^q\Gamma_I(\tau_{\geq q - r - 2}K) = H^q(\tau_{\geq q - r - 2}K) = H^q(K) $$ Thus we see that the map $R\Gamma_I(K) \to K$ is an isomorphism.
We prove the equality of (1) and (2) by induction on $\text{depth}_I(M)$ which is allowed by Algebra, Lemma \ref{algebra-lemma-depth-finite-noetherian}. \medskip\noindent Base case. If $\text{depth}_I(M) = 0$, then $I$ is contained in the union of the associated primes of $M$ (Algebra, Lemma \ref{algebra-lemma-ass-zero-divisors}). By prime avoidance (Algebra, Lemma \ref{algebra-lemma-silly}) we see that $I \subset \mathfrak p$ for some associated prime $\mathfrak p$. Hence $\Hom_A(A/I, M)$ is nonzero. Thus equality holds in this case. \medskip\noindent Assume that $\text{depth}_I(M) > 0$. Let $f \in I$ be a nonzerodivisor on $M$ such that $\text{depth}_I(M/fM) = \text{depth}_I(M) - 1$. Consider the short exact sequence $$ 0 \to M \to M \to M/fM \to 0 $$ and the associated long exact sequence for $\Ext^*_A(A/I, -)$. Note that $\Ext^i_A(A/I, M)$ is a finite $A/I$-module (Algebra, Lemmas \ref{algebra-lemma-ext-noetherian} and \ref{algebra-lemma-annihilate-ext}). Hence we obtain $$ \Hom_A(A/I, M/fM) = \Ext^1_A(A/I, M) $$ and short exact sequences $$ 0 \to \Ext^i_A(A/I, M) \to \text{Ext}^i_A(A/I, M/fM) \to \Ext^{i + 1}_A(A/I, M) \to 0 $$ Thus the equality of (1) and (2) by induction. \medskip\noindent Observe that $\text{depth}_I(M) = \text{depth}_{I^n}(M)$ for all $n \geq 1$ for example by Algebra, Lemma \ref{algebra-lemma-regular-sequence-powers}. Hence by the equality of (1) and (2) we see that $\Ext^i_A(A/I^n, M) = 0$ for all $n$ and $i < \text{depth}_I(M)$. Let $N$ be a finite $A$-module annihilated by a power of $I$. Then we can choose a short exact sequence $$ 0 \to N' \to (A/I^n)^{\oplus m} \to N \to 0 $$ for some $n, m \geq 0$. Then $\Hom_A(N, M) \subset \Hom_A((A/I^n)^{\oplus m}, M)$ and $\Ext^i_A(N, M) \subset \text{Ext}^{i - 1}_A(N', M)$ for $i < \text{depth}_I(M)$. Thus a simply induction argument shows that the final statement of the lemma holds. \medskip\noindent Finally, we prove that (3) is equal to (1) and (2). We have $H^p_I(M) = \colim \Ext^p_A(A/I^n, M)$ by Lemma \ref{lemma-local-cohomology-ext}. Thus we see that $H^i_I(M) = 0$ for $i < \text{depth}_I(M)$. For $i = \text{depth}_I(M)$, using the vanishing of $\Ext_A^{i - 1}(I/I^n, M)$ we see that the map $\Ext_A^i(A/I, M) \to H_I^i(M)$ is injective which proves nonvanishing in the correct degree.
Assume $IN \not = N$, $IN' \not = N'$, and $IN'' \not = N''$. Then we can use the characterization of depth using the Ext groups $\Ext^i(A/I, N)$, see Lemma \ref{lemma-depth}, and use the long exact cohomology sequence $$ \begin{matrix} 0 \to \Hom_A(A/I, N') \to \Hom_A(A/I, N) \to \Hom_A(A/I, N'') \\ \phantom{0\ } \to \Ext^1_A(A/I, N') \to \Ext^1_A(A/I, N) \to \Ext^1_A(A/I, N'') \to \ldots \end{matrix} $$ from Algebra, Lemma \ref{algebra-lemma-long-exact-seq-ext}. This argument also works if $IN = N$ because in this case $\Ext^i_A(A/I, N) = 0$ for all $i$. Similarly in case $IN' \not = N'$ and/or $IN'' \not = N''$.
Part (2) is a formal consequence of part (1). Let $x \in I$ be as in (1). By the short exact sequence $0 \to M \to M \to M/xM \to 0$ and Lemma \ref{lemma-depth-in-ses} we see that $\text{depth}_I(M/xM) \geq \text{depth}_I(M) - 1$. On the other hand, if $x_1, \ldots, x_r \in I$ is a regular sequence for $M/xM$, then $x, x_1, \ldots, x_r$ is a regular sequence for $M$. Hence (1) holds.
We will prove this by induction on $\text{depth}_I(M)$. \medskip\noindent If $\text{depth}_I(M) = 0$, then $I$ is contained in one of the associated primes $\mathfrak p$ of $M$ (Algebra, Lemma \ref{algebra-lemma-ideal-nonzerodivisor}). Then $\mathfrak p \in \text{Supp}(M/IM)$, hence $\dim(\text{Supp}(M/IM)) \geq \dim(R/\mathfrak p) = \dim(\text{Supp}(M))$ where equality holds by Algebra, Lemma \ref{algebra-lemma-CM-ass-minimal-support}. Thus the lemma holds in this case. \medskip\noindent If $\text{depth}_I(M) > 0$, we pick $x \in I$ which is a nonzerodivisor on $M$. Note that $(M/xM)/I(M/xM) = M/IM$. On the other hand we have $\text{depth}_I(M/xM) = \text{depth}_I(M) - 1$ by Lemma \ref{lemma-depth-drops-by-one} and $\dim(\text{Supp}(M/xM)) = \dim(\text{Supp}(M)) -  1$ by Algebra, Lemma \ref{algebra-lemma-one-equation-module}. Thus the result by induction hypothesis.
By definition $H^0_I(M) = M[I^\infty]$ is $I$-power torsion. By Lemma \ref{lemma-local-cohomology-adjoint} we see that $$ H^0_Z(M) = \Ker(M \longrightarrow M_{f_1} \times \ldots \times M_{f_r}) $$ if $I = (f_1, \ldots, f_r)$. Thus $H^0_I(M) \subset H^0_Z(M)$ and conversely, if $x \in H^0_Z(M)$, then it is annihilated by a $f_i^{e_i}$ for some $e_i \geq 1$ hence annihilated by some power of $I$. This proves the first equality and moreover $N$ is $I$-power torsion. By Lemma \ref{lemma-adjoint} we see that $R\Gamma_I(N) = N$. By Lemma \ref{lemma-local-cohomology-adjoint} we see that $R\Gamma_Z(N) = N$. This proves the higher vanishing of $H^p_I(N)$ and $H^p_Z(N)$ in (1) and (2). The vanishing of $H^0_I(M')$ and $H^0_Z(M')$ follow from the preceding remarks and the fact that $M'$ is $I$-power torsion free by More on Algebra, Lemma \ref{more-algebra-lemma-divide-by-torsion}. The equality of higher cohomologies for $M$ and $M'$ follow immediately from the long exact cohomology sequence.
Choose $f_1, \ldots, f_r \in A$ generating $I$. Recall that $$ K^\wedge = R\Hom_A\left((A \to \prod A_{f_{i_0}} \to \prod A_{f_{i_0i_1}} \to \ldots \to A_{f_1 \ldots f_r}), K\right) $$ by More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion}. Hence the cone $C = \text{Cone}(K \to K^\wedge)$ is given by $$ R\Hom_A\left((\prod A_{f_{i_0}} \to \prod A_{f_{i_0i_1}} \to \ldots \to A_{f_1 \ldots f_r}), K\right) $$ which can be represented by a complex endowed with a finite filtration whose successive quotients are isomorphic to $$ R\Hom_A(A_{f_{i_0} \ldots f_{i_p}}, K), \quad p > 0 $$ These complexes vanish on applying $R\Gamma_Z$, see Lemma \ref{lemma-local-cohomology-vanishes}. Applying $R\Gamma_Z$ to the distinguished triangle $K \to K^\wedge \to C \to K[1]$ we see that the first formula of the lemma is correct. \medskip\noindent Recall that $$ R\Gamma_Z(K) = K \otimes^\mathbf{L} (A \to \prod A_{f_{i_0}} \to \prod A_{f_{i_0i_1}} \to \ldots \to A_{f_1 \ldots f_r}) $$ by Lemma \ref{lemma-local-cohomology-adjoint}. Hence the cone $C = \text{Cone}(R\Gamma_Z(K) \to K)$ can be represented by a complex endowed with a finite filtration whose successive quotients are isomorphic to $$ K \otimes_A A_{f_{i_0} \ldots f_{i_p}}, \quad p > 0 $$ These complexes vanish on applying ${\ }^\wedge$, see More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion-vanishes}. Applying derived completion to the distinguished triangle $R\Gamma_Z(K) \to K \to C \to R\Gamma_Z(K)[1]$ we see that the second formula of the lemma is correct.
Say $I = (f_1, \ldots, f_r)$. Denote $C = (A \to \prod A_{f_i} \to \ldots \to A_{f_1 \ldots f_r})$ the alternating {\v C}ech complex. Then derived completion is given by $R\Hom_A(C, -)$ (More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion}) and local cohomology by $C \otimes^\mathbf{L} -$ (Lemma \ref{lemma-local-cohomology-adjoint}). Combining the isomorphism $$ R\Hom_A(K \otimes^\mathbf{L} C, L \otimes^\mathbf{L} C) = R\Hom_A(K, R\Hom_A(C,  L \otimes^\mathbf{L} C)) $$ (More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom}) and the map $$ L \to R\Hom_A(C,  L \otimes^\mathbf{L} C) $$ (More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom-diagonal}) we obtain a map $$ \gamma : R\Hom_A(K, L) \longrightarrow R\Hom_A(K \otimes^\mathbf{L} C, L \otimes^\mathbf{L} C) $$ On the other hand, the right hand side is derived complete as it is equal to $$ R\Hom_A(C, R\Hom_A(K, L \otimes^\mathbf{L} C)). $$ Thus $\gamma$ factors through the derived completion of $R\Hom_A(K, L)$ by the universal property of derived completion. However, the derived completion goes inside the $R\Hom_A$ by More on Algebra, Lemma \ref{more-algebra-lemma-completion-RHom} and we obtain the desired map. \medskip\noindent To show that the map of the lemma is an isomorphism we may assume that $K$ and $L$ are derived complete, i.e., $K = K^\wedge$ and $L = L^\wedge$. In this case we are looking at the map $$ \gamma : R\Hom_A(K, L) \longrightarrow R\Hom_A(R\Gamma_Z(K), R\Gamma_Z(L)) $$ By Proposition \ref{proposition-torsion-complete} we know that the cohomology groups of the left and the right hand side coincide. In other words, we have to check that the map $\gamma$ sends a morphism $\alpha : K \to L$ in $D(A)$ to the morphism $R\Gamma_Z(\alpha) : R\Gamma_Z(K) \to R\Gamma_Z(L)$. We omit the verification (hint: note that $R\Gamma_Z(\alpha)$ is just the map $\alpha \otimes \text{id}_C : K \otimes^\mathbf{L} C \to L \otimes^\mathbf{L} C$ which is almost the same as the construction of the map in More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom-diagonal}).