hcju/stacksqa huggingface dataset:
Consider the two spectral sequences of Lemma \ref{lemma-formal-functions-general}. The first degenerates by More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion-pseudo-coherent}. We obtain $H^p(X, \mathcal{F})^\wedge$ in degree $p$. This is where we use the assumption that $H^p(X, \mathcal{F})$ is a finite $A$-module. The second degenerates because $$ \mathcal{F}^\wedge = \lim \mathcal{F}/I^n\mathcal{F} = R\lim \mathcal{F}/I^n\mathcal{F} $$ is a sheaf by Lemma \ref{lemma-derived-completion-pseudo-coherent}. We obtain $H^p(X, \lim \mathcal{F}/I^n\mathcal{F})$ in degree $p$. Since $R\Gamma(X, -)$ commutes with derived limits (Injectives, Lemma \ref{injectives-lemma-RF-commutes-with-Rlim}) we also get $$ R\Gamma(X, \lim \mathcal{F}/I^n\mathcal{F}) = R\Gamma(X, R\lim \mathcal{F}/I^n\mathcal{F}) = R\lim R\Gamma(X, \mathcal{F}/I^n\mathcal{F}) $$ By More on Algebra, Remark \ref{more-algebra-remark-how-unique} we obtain exact sequences $$ 0 \to R^1\lim H^{p - 1}(X, \mathcal{F}/I^n\mathcal{F}) \to H^p(X, \lim \mathcal{F}/I^n\mathcal{F}) \to \lim H^p(X, \mathcal{F}/I^n\mathcal{F}) \to 0 $$ of $A$-modules. Combining the above we get the first statement of the lemma. The vanishing of the $R^1\lim$ term follows from Cohomology of Schemes, Lemma \ref{coherent-lemma-ML-cohomology-powers-ideal}.
We will use that $R\Gamma_J = R\Gamma_{V(J)}$ and similarly for $I + J$, see Dualizing Complexes, Lemma \ref{dualizing-lemma-local-cohomology-noetherian}. Observe that $R\Gamma_J(M)^\wedge = R\Gamma_I(R\Gamma_J(M))^\wedge = R\Gamma_{I + J}(M)^\wedge$, see Dualizing Complexes, Lemmas \ref{dualizing-lemma-complete-and-local} and \ref{dualizing-lemma-local-cohomology-ss}. Thus we may replace $J$ by $I + J$ and assume $I \subset J$ and $\mathfrak p \not \in V(J)$. Recall that $$ R\Gamma_J(M)^\wedge = R\Hom_A(R\Gamma_I(A), R\Gamma_J(M)) $$ by the description of derived completion in More on Algebra, Lemma \ref{more-algebra-lemma-derived-completion} combined with the description of local cohomology in Dualizing Complexes, Lemma \ref{dualizing-lemma-compute-local-cohomology-noetherian}. Assumption (3) means that $R\Gamma_I(A)$ has nonzero cohomology only in degrees $\leq d$. Using the canonical truncations of $R\Gamma_I(A)$ we find it suffices to show that $$ \text{Ext}^i(N, R\Gamma_J(M)) $$ is annihilated by an $f \in A$, $f \not \in \mathfrak p$ for $i \leq s + d$ and any $A$-module $N$. In turn using the canonical truncations for $R\Gamma_J(M)$ we see that it suffices to show $H^i_J(M)$ is annihilated by an $f \in A$, $f \not \in \mathfrak p$ for $i \leq s + d$. This follows from Local Cohomology, Lemma \ref{local-cohomology-lemma-kill-local-cohomology-at-prime}.
Recall that $H^i_{J_0}(M) = H^i_T(M)$, see proof of Lemma \ref{lemma-kill-colimit-weak-general}. Thus it suffices to check that for $\mathfrak p \not \in T$ and $\mathfrak q \in T$ with $\mathfrak p \subset \mathfrak q$ we have $\text{depth}_{A_\mathfrak p}(M_\mathfrak p) + \dim((A/\mathfrak p)_\mathfrak q) > s$, see Local Cohomology, Proposition \ref{local-cohomology-proposition-finiteness}. Condition (2') tells us this is true for $\mathfrak p \in V(I)$. Since we know $H^i_T(M)$ is annihilated by a power of $IJ_0$ we know the condition holds if $\mathfrak p \not \in V(IJ_0)$ by Local Cohomology, Proposition \ref{local-cohomology-proposition-annihilator}. This covers all cases and the proof is complete.
Choose $\mathfrak p \in V(J)$ or $\mathfrak p \in V(J_0)$ but $\mathfrak p \not \in V(J + I) = V(J_0 + I)$. It suffices to show that $H^i_{\mathfrak pA_\mathfrak p}(M_\mathfrak p) = 0$ for $i \leq s$, see Local Cohomology, Lemma \ref{local-cohomology-lemma-isomorphism}. These groups vanish by condition (6) and Dualizing Complexes, Lemma \ref{dualizing-lemma-depth}. The final statement follows from Local Cohomology, Proposition \ref{local-cohomology-proposition-annihilator}.
According to Local Cohomology, Lemma \ref{local-cohomology-lemma-sitting-in-degrees} the function $$ \mathfrak p' \longmapsto \text{depth}_{A_{\mathfrak p'}}(M_{\mathfrak p'}) + \dim(A/\mathfrak p') $$ is lower semi-continuous on $\Spec(A)$. Thus the value of this function on $\mathfrak p' \subset \mathfrak p$ is $> s + d$. Thus our lemma is a special case of Lemma \ref{lemma-kill-completion-general} provided that $\mathfrak p \not = \mathfrak m$. If $\mathfrak p = \mathfrak m$, then we have $H^i_\mathfrak m(M) = 0$ for $i \leq s + d$ by the relationship between depth and local cohomology (Dualizing Complexes, Lemma \ref{dualizing-lemma-depth}). Thus the argument given in the proof of Lemma \ref{lemma-kill-completion-general} shows that $H^i(R\Gamma_\mathfrak m(M)^\wedge) = 0$ for $i \leq s$ in this (degenerate) case.
Choose $\mathfrak q' \in T$ with $\mathfrak p \subset \mathfrak q' \subset \mathfrak q$ such that there is no prime in $T$ strictly in between $\mathfrak p$ and $\mathfrak q'$. To prove the lemma we may and do replace $\mathfrak q$ by $\mathfrak q'$. Next, let $\mathfrak p' \subset A_\mathfrak q$ be the prime corresponding to $\mathfrak p$. After doing this we obtain that $V(\mathfrak p') \cap V(IA_\mathfrak q) = \{\mathfrak q A_\mathfrak q\}$ because of the nonexistence of a prime $\mathfrak r$ as in the lemma. Let $A', I', \mathfrak m', M'$ be the $I$-adic completions of $A_\mathfrak q, I_\mathfrak q, \mathfrak qA_\mathfrak q, M_\mathfrak q$. Since $A_\mathfrak q \to A'$ is faithfully flat (Algebra, Lemma \ref{algebra-lemma-completion-faithfully-flat}) we can choose $\mathfrak p'' \subset A'$ lying over $\mathfrak p'$ with $\dim(A'_{\mathfrak p''}/\mathfrak p' A'_{\mathfrak p''}) = 0$. Then we see that $$ \text{depth}(M'_{\mathfrak p''}) = \text{depth}((M_\mathfrak q \otimes_{A_\mathfrak q} A')_{\mathfrak p''}) = \text{depth}(M_\mathfrak p \otimes_{A_\mathfrak p} A'_{\mathfrak p''}) = \text{depth}(M_\mathfrak p) $$ by flatness of $A \to A'$ and our choice of $\mathfrak p''$, see Algebra, Lemma \ref{algebra-lemma-apply-grothendieck-module}. Since $\mathfrak p''$ lies over $\mathfrak p'$ we have $V(\mathfrak p'') \cap V(I') = \{\mathfrak m'\}$. Thus condition (6) in Situation \ref{situation-bootstrap} implies $\text{depth}(M'_{\mathfrak p''}) > s$ which finishes the proof.
Let $A', I', \mathfrak m', M'$ be the usual $I$-adic completions of $A, I, \mathfrak m, M$. Recall that we have $H^i_\mathfrak m(M) \otimes_A A' = H^i_{\mathfrak m'}(M')$ by flatness of $A \to A'$ and Dualizing Complexes, Lemma \ref{dualizing-lemma-torsion-change-rings}. Since $H^i_\mathfrak m(M)$ is $\mathfrak m$-power torsion we have $H^i_\mathfrak m(M) = H^i_\mathfrak m(M) \otimes_A A'$, see More on Algebra, Lemma \ref{more-algebra-lemma-neighbourhood-equivalence}. We conclude that $H^i_\mathfrak m(M) = H^i_{\mathfrak m'}(M')$. The exact same arguments will show that $H^i_\mathfrak m(M/I^nM) =  H^i_{\mathfrak m'}(M'/(I')^nM')$ for all $n$ and $i$. \medskip\noindent Lemmas \ref{lemma-algebraize-local-cohomology}, \ref{lemma-kill-colimit-weak}, and \ref{lemma-kill-colimit-support} apply to $A', \mathfrak m', I', M'$ by Lemma \ref{lemma-bootstrap-inherited} parts (C) and (D). Thus we get an isomorphism $$ H^i_{\mathfrak m'}(M') \longrightarrow H^i(R\Gamma_{\mathfrak m'}(M')^\wedge) $$ for $i \leq s$ where ${}^\wedge$ is derived $I'$-adic completion and these modules are annihilated by a power of $I'$. By Lemma \ref{lemma-local-cohomology-derived-completion} we obtain isomorphisms $$ H^i_{\mathfrak m'}(M') \longrightarrow \lim H^i_{\mathfrak m'}(M'/(I')^nM')) $$ for $i \leq s$. Combined with the already established comparison with local cohomology over $A$ we conclude the lemma is true.
We have to show that assumptions (1), (3), (4), and (6) of Situation \ref{situation-bootstrap} hold. It is clear that (a) $\Rightarrow$ (1), (b) $\Rightarrow$ (3), and (c) $\Rightarrow$ (4). To finish the proof in the next paragraph we show (6) holds. \medskip\noindent Let $\mathfrak q \in V(\mathfrak a)$. Denote $A', I', \mathfrak m', M'$ the $I$-adic completions of $A_\mathfrak q, I_\mathfrak q, \mathfrak qA_\mathfrak q, M_\mathfrak q$. Let $\mathfrak p' \subset A'$ be a nonmaximal prime with $V(\mathfrak p') \cap V(I') = \{\mathfrak m'\}$. Observe that this implies $\dim(A'/\mathfrak p') \leq d$ by Local Cohomology, Lemma \ref{local-cohomology-lemma-cd-bound-dim-local}. Denote $\mathfrak p \subset A$ the image of $\mathfrak p'$. We have $\text{depth}(M'_{\mathfrak p'}) \geq \text{depth}(M_\mathfrak p)$ and $\text{depth}(M'_{\mathfrak p'}) + \dim(A'/\mathfrak p') = \text{depth}(M_\mathfrak p) + \dim((A/\mathfrak p)_\mathfrak q)$ by Local Cohomology, Lemma \ref{local-cohomology-lemma-change-completion}. By assumption (c) either we have $\text{depth}(M'_{\mathfrak p'}) \geq \text{depth}(M_\mathfrak p) > s$ and we're done or we have $\text{depth}(M'_{\mathfrak p'}) + \dim(A'/\mathfrak p') > s + d$ which implies $\text{depth}(M'_{\mathfrak p'}) > s$ because of the already shown inequality $\dim(A'/\mathfrak p') \leq d$. In both cases we obtain what we want.
Consider the long exact sequences $$ 0 \to H^0_T(I^nM) \to H^0_T(M) \to H^0_T(M/I^nM) \to H^1_T(I^nM) \to H^1_T(M) \to \ldots $$ Parts (1) and (3) follows easily from this and Lemma \ref{lemma-bootstrap}. \medskip\noindent Let $m_0$ and $m'(-)$ be as in Lemma \ref{lemma-bootstrap}. For $m \geq m_0$ consider the long exact sequence $$ H^s_T(I^mM) \to H^s_T(I^{m_0}M) \to H^s_T(I^{m_0}M/I^mM) \to H^{s + 1}_T(I^mM) \to H^1_T(I^{m_0}M) $$ Then for $k \geq m'(m)$ the image of $H^{s + 1}_T(I^kM) \to H^{s + 1}_T(I^mM)$ maps injectively to $H^{s + 1}_T(I^{m_0}M)$. Hence the image of $H^s_T(I^{m_0}M/I^kM) \to H^s_T(I^{m_0}M/I^mM)$ maps to zero in $H^{s + 1}_T(I^mM)$ for all $k \geq m'(m)$. We conclude that (2) and (4) hold. \medskip\noindent Consider the short exact sequences $0 \to I^{m_0}M \to M \to M/I^{m_0} M \to 0$ and $0 \to I^{m_0}M/I^nM \to M/I^nM \to M/I^{m_0} M \to 0$. We obtain a diagram $$ \xymatrix{ H^{s - 1}_T(M/I^{m_0}M) \ar[r] & \lim H^s_T(I^{m_0}M/I^nM) \ar[r] & \lim H^s_T(M/I^nM) \ar[r] & H^s_T(M/I^{m_0}M) \\ H^{s - 1}_T(M/I^{m_0}M) \ar[r] \ar@{=}[u] & H^s_T(I^{m_0}M) \ar[r] \ar[u]_{\cong} & H^s_T(M) \ar[r] \ar[u] & H^s_T(M/I^{m_0}M) \ar@{=}[u] } $$ whose lower row is exact. The top row is also exact (at the middle two spots) by Homology, Lemma \ref{homology-lemma-apply-Mittag-Leffler}. Part (5) follows. \medskip\noindent Write $B_n = H^s_T(M/I^nM)$. Let $A_n \subset B_n$ be the image of $H^s_T(I^{m_0}M/I^nM) \to H^s_T(M/I^nM)$. Then $(A_n)$ satisfies the Mittag-Leffler condition by (2) and Homology, Lemma \ref{homology-lemma-Mittag-Leffler}. Also $C_n = B_n/A_n$ is killed by $I^{m_0}$. Thus $R^1\lim B_n \cong R^1\lim C_n$ is killed by $I^{m_0}$ and we get (6).
Namely, we have the existence of $J_0$ and the isomorphism $H^{s + 1}_J(M) = H^{s + 1}(R\Gamma_\mathfrak a(M)^\wedge)$ by Lemma \ref{lemma-algebraize-local-cohomology-general}, we have a short exact sequence $$ 0 \to R^1\lim H^s_\mathfrak a(M/I^nM) \to H^{s + 1}(R\Gamma_\mathfrak a(M)^\wedge) \to \lim H^{s + 1}_\mathfrak a(M/I^nM) \to 0 $$ by Dualizing Complexes, Lemma \ref{dualizing-lemma-completion-local}, and the module $R^1\lim H^s_\mathfrak a(M/I^nM)$ is zero because $\{H^s_\mathfrak a(M/I^nM)\}_{n \geq 0}$ has Mittag-Leffler by Theorem \ref{theorem-final-bootstrap}.
By Lemmas \ref{lemma-formal-functions-general} and \ref{lemma-derived-completion-pseudo-coherent} we have $$ R\Gamma(U, \mathcal{F})^\wedge = R\Gamma(U, \mathcal{F}^\wedge) = R\Gamma(U, R\lim \mathcal{F}/I^n\mathcal{F}) $$ Thus we obtain short exact sequences $$ 0 \to R^1\lim H^{i - 1}(U, \mathcal{F}/I^n\mathcal{F}) \to H^i(R\Gamma(U, \mathcal{F})^\wedge) \to \lim H^i(U, \mathcal{F}/I^n\mathcal{F}) \to 0 $$ by Cohomology, Lemma \ref{cohomology-lemma-RGamma-commutes-with-Rlim}. The $R^1\lim$ terms vanish because the inverse systems of groups $H^i(U, \mathcal{F}/I^n\mathcal{F})$ satisfy the Mittag-Leffler condition by Lemma \ref{lemma-ML-local}.
Choose a finite $A$-module $M$ such that $\mathcal{F}$ is the restriction to $U$ of the coherent module associated to $M$, see Local Cohomology, Lemma \ref{local-cohomology-lemma-finiteness-pushforwards-and-H1-local}. Set $d = \text{cd}(A, I)$. Let $\mathfrak p$ be a prime of $A$ not contained in $V(I)$ and let $\mathfrak q \in V(\mathfrak p) \cap V(\mathfrak a)$. Then either $\mathfrak p$ is not an associated prime of $M$ and hence $\text{depth}(M_\mathfrak p) \geq 1$ or we have $\dim((A/\mathfrak p)_\mathfrak q) > d + 1$ by (2). Thus the hypotheses of Lemma \ref{lemma-algebraize-local-cohomology-general} are satisfied for $s = 1$ and $d$; here we use condition (3). Thus we find there exists an ideal $J_0 \subset \mathfrak a$ with $V(J_0) \cap V(I) = V(\mathfrak a)$ such that for any $J \subset J_0$ with $V(J) \cap V(I) = V(\mathfrak a)$ the maps $$ H^i_J(M) \longrightarrow H^i(R\Gamma_\mathfrak a(M)^\wedge) $$ are isomorphisms for $i = 0, 1$. Consider the morphisms of exact triangles $$ \xymatrix{ R\Gamma_J(M)  \ar[d] \ar[r] & M \ar[r] \ar[d] & R\Gamma(V, \mathcal{F}) \ar[d] \ar[r] & R\Gamma_J(M)[1]  \ar[d] \\ R\Gamma_J(M)^\wedge \ar[r] & M \ar[r] & R\Gamma(V, \mathcal{F})^\wedge \ar[r] & R\Gamma_J(M)^\wedge[1] \\ R\Gamma_\mathfrak a(M)^\wedge \ar[r] \ar[u] & M \ar[r] \ar[u] & R\Gamma(U, \mathcal{F})^\wedge \ar[r] \ar[u] & R\Gamma_\mathfrak a(M)^\wedge[1] \ar[u] } $$ where $V = \Spec(A) \setminus V(J)$. Recall that $R\Gamma_\mathfrak a(M)^\wedge \to R\Gamma_J(M)^\wedge$ is an isomorphism (because $\mathfrak a$, $\mathfrak a + I$, and $J + I$ cut out the same closed subscheme, for example see proof of Lemma \ref{lemma-algebraize-local-cohomology-general}). Hence $R\Gamma(U, \mathcal{F})^\wedge = R\Gamma(V, \mathcal{F})^\wedge$. This produces a commutative diagram $$ \xymatrix{ 0 \ar[r] & H^0_J(M) \ar[r] \ar[d] & M \ar[r] \ar[d] \ar[r] & \Gamma(V, \mathcal{F}) \ar[d] \ar[r] & H^1_J(M) \ar[d] \ar[r] & 0 \\ 0 \ar[r] & H^0(R\Gamma_J(M)^\wedge) \ar[r] & M \ar[r] & H^0(R\Gamma(V, \mathcal{F})^\wedge) \ar[r] & H^1(R\Gamma_J(M)^\wedge) \ar[r] & 0 \\ 0 \ar[r] & H^0(R\Gamma_\mathfrak a(M)^\wedge) \ar[r] \ar[u] & M \ar[r] \ar[u] & H^0(R\Gamma(U, \mathcal{F})^\wedge) \ar[r] \ar[u] & H^1(R\Gamma_\mathfrak a(M)^\wedge) \ar[r] \ar[u] & 0 } $$ with exact rows and isomorphisms for the lower vertical arrows. Hence we obtain an isomorphism $\Gamma(V, \mathcal{F}) \to H^0(R\Gamma(U, \mathcal{F})^\wedge)$. By Lemmas \ref{lemma-formal-functions-general} and \ref{lemma-derived-completion-pseudo-coherent} we have $$ R\Gamma(U, \mathcal{F})^\wedge = R\Gamma(U, \mathcal{F}^\wedge) = R\Gamma(U, R\lim \mathcal{F}/I^n\mathcal{F}) $$ and we find $H^0(R\Gamma(U, \mathcal{F})^\wedge) = \lim H^0(U, \mathcal{F}/I^n\mathcal{F})$ by Cohomology, Lemma \ref{cohomology-lemma-RGamma-commutes-with-Rlim}.
Let $\hat s \in \lim H^0(U, \mathcal{F}/I^n\mathcal{F})$. By Proposition \ref{proposition-application-H0} we find that $\hat s$ is the image of an element $s \in \mathcal{F}(V)$ for some $V \subset U$ open containing $U \cap V(I)$. However, condition (3) shows that $\text{depth}(\mathcal{F}_x) \geq 2$ for all $x \in U \setminus V$ and hence we find that $\mathcal{F}(V) = \mathcal{F}(U)$ by Divisors, Lemma \ref{divisors-lemma-depth-2-hartog} and the proof is complete.
Set $\mathcal{F} = \widetilde{M}|_U$. The finiteness of $H^1_\mathfrak a(M/fM)$ implies that $H^0(U, \mathcal{F}/f\mathcal{F})$ is finite, see Local Cohomology, Lemma \ref{local-cohomology-lemma-finiteness-pushforwards-and-H1-local}. By Lemma \ref{lemma-limit-finite} (which applies as $f$ is a nonzerodivisor on $\mathcal{F}$) we see that $N = \lim H^0(U, \mathcal{F}/f^n\mathcal{F})$ is a finite $A$-module, is $f$-torsion free, and $N/fN \subset H^0(U, \mathcal{F}/f\mathcal{F})$. On the other hand, we have $M \to N$ and the map $$ M/fM \longrightarrow H^0(U, \mathcal{F}/f\mathcal{F}) $$ is an isomorphism upon localization at any prime $\mathfrak q$ in $U_0 = V(f) \setminus \{\mathfrak m\}$ (details omitted). Thus $M_\mathfrak q \to N_\mathfrak q$ induces an isomorphism $$ M_\mathfrak q/fM_\mathfrak q = (M/fM)_\mathfrak q \to (N/fN)_\mathfrak q = N_\mathfrak q/fN_\mathfrak q $$ Since $f$ is a nonzerodivisor on both $N$ and $M$ we conclude that $M_\mathfrak q \to N_\mathfrak q$ is an isomorphism (use Nakayama to see surjectivity). We conclude that $M$ and $N$ determine isomorphic coherent modules over an open $V$ as in the statement of the lemma. This finishes the proof.
We may apply Lemma \ref{lemma-formal-functions-principal} to $U$ and $\mathcal{F} = \widetilde{M}|_U$ because $\mathcal{F}$ is a Noetherian object in the category of coherent $\mathcal{O}_U$-modules. Since $H^1(U, \mathcal{F}) = H^2_\mathfrak a(M)$ (Local Cohomology, Lemma \ref{local-cohomology-lemma-finiteness-pushforwards-and-H1-local}) is annihilated by a power of $f$, we see that its $f$-adic Tate module is zero. Hence the lemma shows $\lim H^0(U, \mathcal{F}/f^n \mathcal{F})$ is the $0$th cohomology group of the derived $f$-adic completion of $H^0(U, \mathcal{F})$. Consider the exact sequence $$ 0 \to H^0_\mathfrak a(M) \to M \to \Gamma(U, \mathcal{F}) \to H^1_\mathfrak a(M) \to 0 $$ of Local Cohomology, Lemma \ref{local-cohomology-lemma-finiteness-pushforwards-and-H1-local}. Since $H^1_\mathfrak a(M)$ is annihilated by a power of $f$ it is derived complete with respect to $(f)$. Since $M$ and $H^0_\mathfrak a(M)$ are finite $A$-modules they are complete (Algebra, Lemma \ref{algebra-lemma-completion-tensor}) hence derived complete (More on Algebra, Proposition \ref{more-algebra-proposition-derived-complete-modules}). By More on Algebra, Lemma \ref{more-algebra-lemma-serre-subcategory} we conclude that $\Gamma(U, \mathcal{F})$ is derived complete as desired.
The proof is the same as the proof of Lemma \ref{lemma-alternative-H0}. We may apply Lemma \ref{lemma-formal-functions-principal} to $U$ and $\mathcal{F} = \widetilde{M}|_U$ because $\mathcal{F}$ is a Noetherian object in the category of coherent $\mathcal{O}_U$-modules. Since $H^i(U, \mathcal{F}) = H^{i + 1}_\mathfrak a(M)$ (Local Cohomology, Lemma \ref{local-cohomology-lemma-finiteness-pushforwards-and-H1-local}) is annihilated by a power of $f$ for $i \leq s$, we see that its $f$-adic Tate module is zero. Hence the lemma shows $\lim H^{i - 1}(U, \mathcal{F}/f^n \mathcal{F})$ is the $0$th cohomology group of the derived $f$-adic completion of $H^{i - 1}(U, \mathcal{F})$. However, if $s \geq i > 1$, then this equal to the $f$-power torsion module $H^i_\mathfrak a(M)$ and hence equal to its own (derived) completion. For $i = 0$, we refer to Lemma \ref{lemma-alternative-H0}.
Let us first prove the final assertion. As a first case, if the punctured spectrum of $A/I$ is empty, then Local Cohomology, Lemma \ref{local-cohomology-lemma-cd-bound-dim-local} shows every irreducible component of $X$ has dimension $\leq \text{cd}(A, I)$ and we get $\min(c, d - 1) - \text{cd}(A, I) < 0$ which implies the lemma holds in this case. Thus we may assume $U \cap Y$ is nonempty where $U = X \setminus \{\mathfrak m\}$ is the punctured spectrum of $A$. We may replace $A$ by its reduction. Observe that $A$ has a dualizing complex (Dualizing Complexes, Lemma \ref{dualizing-lemma-ubiquity-dualizing}) and that $A$ is complete with respect to $I$ (Algebra, Lemma \ref{algebra-lemma-complete-by-sub}). If we assume $d - 1 > \text{cd}(A, I)$, then we may apply Lemma \ref{lemma-application-theorem} to see that $$ \colim H^0(V, \mathcal{O}_V) \longrightarrow \lim H^0(U, \mathcal{O}_U/I^n\mathcal{O}_U) $$ is an isomorphism where the colimit is over opens $V \subset U$ containing $U \cap Y$. If $U \cap Y$ is disconnected, then its $n$th infinitesimal neighbourhood in $U$ is disconnected for all $n$ and we find the right hand side has a nontrivial idempotent (here we use that $U \cap Y$ is nonempty). Thus we can find a $V$ which is disconnected. Set $Z = X \setminus V$. By Local Cohomology, Lemma \ref{local-cohomology-lemma-cd-bound-dim-local} we see that every irreducible component of $Z$ has dimension $\leq \text{cd}(A, I)$. Hence $c \leq \text{cd}(A, I)$ and this indeed proves the final statement. \medskip\noindent We can deduce the statement of the lemma from what we just proved as follows. Suppose that $Z \subset Y$ closed and $Y \setminus Z$ is disconnected and $\dim(Z) = e$. Recall that a connected space is nonempty by convention. Hence we conclude either (a) $Y = Z$ or (b) $Y \setminus Z = W_1 \amalg W_2$ with $W_i$ nonempty, open, and closed in $Y \setminus Z$. In case (b) we may pick points $w_i \in W_i$ which are closed in $U$, see Morphisms, Lemma \ref{morphisms-lemma-ubiquity-Jacobson-schemes}. Then we can find $f_1, \ldots, f_e \in \mathfrak m$ such that $V(f_1, \ldots, f_e) \cap Z = \{\mathfrak m\}$ and in case (b) we may assume $w_i \in V(f_1, \ldots, f_e)$. Namely, we can inductively using prime avoidance choose $f_i$ such that $\dim V(f_1, \ldots, f_i) \cap Z = e - i$ and such that in case (b) we have $w_1, w_2 \in V(f_i)$. It follows that the punctured spectrum of $A/I + (f_1, \ldots, f_e)$ is disconnected (small detail omitted). Since $\text{cd}(A, I + (f_1, \ldots, f_e)) \leq \text{cd}(A, I) + e$ by Local Cohomology, Lemmas \ref{local-cohomology-lemma-cd-sum} and \ref{local-cohomology-lemma-bound-cd} we conclude that $$ \text{cd}(A, I) + e \geq \min(c, d - 1) $$ by the first part of the proof. This implies $e \geq \min(c, d - 1) - \text{cd}(A, I)$ which is what we had to show.
We may replace $A$ by its reduction. Then we have the inequality in (2) for all associated primes of $A$. By Proposition \ref{proposition-application-H0} we see that $$ \colim H^0(V, \mathcal{O}_V) = \lim H^0(T_n, \mathcal{O}_{T_n}) $$ where the colimit is over the opens $V$ as in (3) and $T_n$ is the $n$th infinitesimal neighbourhood of $T = V(I) \setminus V(\mathfrak a)$ in $U = \Spec(A) \setminus V(\mathfrak a)$. Thus $T$ is either empty or connected, since if not, then the right hand side would have a nontrivial idempotent and we've assumed the left hand side does not. Some details omitted.
Proof of (3) $\Rightarrow$ (4). If $\mathcal{F}$ and $\mathcal{G}$ are finite locally free on $X$, then considering $\mathcal{H} = \SheafHom_{\mathcal{O}_X}(\mathcal{G}, \mathcal{F})$ and using Cohomology of Schemes, Lemma \ref{coherent-lemma-completion-internal-hom} we see that (3) implies (4). \medskip\noindent Proof of (2) $\rightarrow$ (3). Namely, let $\mathcal{L}$ be ample on $X$ and suppose that $\mathcal{E}$ is a finite locally free $\mathcal{O}_X$-module. We claim we can find a universally exact sequence $$ 0 \to \mathcal{E} \to (\mathcal{L}^{\otimes p})^{\oplus r} \to (\mathcal{L}^{\otimes q})^{\oplus s} $$ for some $r, s \geq 0$ and $0 \ll p \ll q$. If this holds, then using the exact sequence $$ 0 \to \lim \Gamma(\mathcal{E}|_{Y_n}) \to \lim \Gamma((\mathcal{L}^{\otimes p})^{\oplus r}|_{Y_n}) \to \lim \Gamma((\mathcal{L}^{\otimes q})^{\oplus s}|_{Y_n}) $$ and the isomorphisms in (2) we get the isomorphism in (3). To prove the claim, consider the dual locally free module $\SheafHom_{\mathcal{O}_X}(\mathcal{E}, \mathcal{O}_X)$ and apply Properties, Proposition \ref{properties-proposition-characterize-ample} to find a surjection $$ (\mathcal{L}^{\otimes -p})^{\oplus r} \longrightarrow \SheafHom_{\mathcal{O}_X}(\mathcal{E}, \mathcal{O}_X) $$ Taking duals we obtain the first map in the exact sequence (it is universally injective because being a surjection is universal). Repeat with the cokernel to get the second. Some details omitted. \medskip\noindent Proof of (1) $\Rightarrow$ (2). This is true because if $X$ is quasi-affine then $\mathcal{O}_X$ is an ample invertible module, see Properties, Lemma \ref{properties-lemma-quasi-affine-O-ample}. \medskip\noindent We omit the proof of (4) $\Rightarrow$ (3).