hcju/stacksqa huggingface dataset:
Let $\overline{x}_1, \ldots, \overline{x}_n$ be a basis for the free module $M/\mathfrak mM$. Choose $x_1, \ldots, x_n \in M$ with $x_i$ mapping to $\overline{x}_i$. Let $u : S^{\oplus n} \to M$ be the map which maps the $i$th standard basis vector to $x_i$. By Lemma \ref{lemma-mod-injective} we see that $u$ is injective. On the other hand, by Nakayama's Lemma \ref{lemma-NAK} the map is surjective. The lemma follows.
By induction on $e$. If $e = 1$, then this is exactly Lemma \ref{lemma-mod-injective}. If $e > 1$, we see by Lemma \ref{lemma-mod-injective} that $F_e \to F_{e-1}$ is injective and that $C = \Coker(F_e \to F_{e-1})$ is a finite $S$-module flat over $R$. Hence we can apply the induction hypothesis to the complex $0 \to C \to F_{e-2} \to \ldots \to F_0$. We deduce that $C \to F_{e-2}$ is injective and the exactness of the complex follows, as well as the flatness of the cokernel of $F_1 \to F_0$.
By descending induction on the length of $N$. If the length of $N$ is $1$, then $N \cong \kappa$ and we are done. If the length of $N$ is more than $1$, then we can fit $N$ into a short exact sequence $0 \to N' \to N \to N'' \to 0$ where $N'$, $N''$ are finite length $R$-modules of smaller length. The vanishing of $\text{Tor}_1^R(N, M)$ follows from the vanishing of $\text{Tor}_1^R(N', M)$ and $\text{Tor}_1^R(N'', M)$ (induction hypothesis) and the long exact sequence of Tor groups, see Lemma \ref{lemma-long-exact-sequence-tor}.
Let $I \subset R$ be an ideal. By Lemma \ref{lemma-flat} it suffices to show that $I \otimes_R M \to M$ is injective. By Remark \ref{remark-Tor-ring-mod-ideal} we see that this kernel is equal to $\text{Tor}_1^R(M, R/I)$. By Lemma \ref{lemma-prepare-local-criterion-flatness} we see that $J \otimes_R M \to M$ is injective for all ideals of finite colength. \medskip\noindent Choose $n >> 0$ and consider the following short exact sequence $$ 0 \to I \cap \mathfrak m^n \to I \oplus \mathfrak m^n \to I + \mathfrak m^n \to 0 $$ This is a sub sequence of the short exact sequence $0 \to R \to R^{\oplus 2} \to R \to 0$. Thus we get the diagram $$ \xymatrix{ (I\cap \mathfrak m^n) \otimes_R M \ar[r] \ar[d] & I \otimes_R M \oplus \mathfrak m^n \otimes_R M \ar[r] \ar[d] & (I + \mathfrak m^n) \otimes_R M \ar[d] \\ M \ar[r] & M \oplus M \ar[r] & M } $$ Note that $I + \mathfrak m^n$ and $\mathfrak m^n$ are ideals of finite colength. Thus a diagram chase shows that $\Ker((I \cap \mathfrak m^n)\otimes_R M \to M) \to \Ker(I \otimes_R M \to M)$ is surjective. We conclude in particular that $K = \Ker(I \otimes_R M \to M)$ is contained in the image of $(I \cap \mathfrak m^n) \otimes_R M$ in $I \otimes_R M$. By Artin-Rees, Lemma \ref{lemma-Artin-Rees} we see that $K$ is contained in $\mathfrak m^{n-c}(I \otimes_R M)$ for some $c > 0$ and all $n >> 0$. Since $I \otimes_R M$ is a finite $S$-module (!) and since $S$ is Noetherian, we see that this implies $K = 0$. Namely, the above implies $K$ maps to zero in the $\mathfrak mS$-adic completion of $I \otimes_R M$. But the map from $S$ to its $\mathfrak mS$-adic completion is faithfully flat by Lemma \ref{lemma-completion-faithfully-flat}. Hence $K = 0$, as desired.
Assume $M/IM$ is flat over $R/I$ and $\text{Tor}_1^R(R/I, M) = 0$. Let $N$ be an $R/I$-module. Choose a short exact sequence $$ 0 \to K \to \bigoplus\nolimits_{i \in I} R/I \to N \to 0 $$ By the long exact sequence of $\text{Tor}$ and the vanishing of $\text{Tor}_1^R(R/I, M)$ we get $$ 0 \to \text{Tor}_1^R(N, M) \to K \otimes_R M \to (\bigoplus\nolimits_{i \in I} R/I) \otimes_R M \to N \otimes_R M \to 0 $$ But since $K$, $\bigoplus_{i \in I} R/I$, and $N$ are all annihilated by $I$ we see that \begin{align*} K \otimes_R M & = K \otimes_{R/I} M/IM, \\ (\bigoplus\nolimits_{i \in I} R/I) \otimes_R M & = (\bigoplus\nolimits_{i \in I} R/I) \otimes_{R/I} M/IM, \\ N \otimes_R M & = N \otimes_{R/I} M/IM. \end{align*} As $M/IM$ is flat over $R/I$ we conclude that $$ 0 \to K \otimes_{R/I} M/IM \to (\bigoplus\nolimits_{i \in I} R/I) \otimes_{R/I} M/IM \to N \otimes_{R/} M/IM \to 0 $$ is exact. Combining this with the above we conclude that $\text{Tor}_1^R(N, M) = 0$ for any $R$-module $N$ annihilated by $I$. \medskip\noindent In particular, if we apply this to the module $I/I^2$, then we conclude that the sequence $$ 0 \to I^2 \otimes_R M \to I \otimes_R M  \to I/I^2 \otimes_R M \to 0 $$ is short exact. This implies that $I^2 \otimes_R M \to M$ is injective and it implies that $I/I^2 \otimes_{R/I} M/IM = IM/I^2M$. \medskip\noindent Let us prove that $M/I^2M$ is flat over $R/I^2$. Let $I^2 \subset J$ be an ideal. We have to show that $J/I^2 \otimes_{R/I^2} M/I^2M \to M/I^2M$ is injective, see Lemma \ref{lemma-flat}. As $M/IM$ is flat over $R/I$ we know that the map $(I + J)/I \otimes_{R/I} M/IM \to M/IM$ is injective. The sequence $$ (I \cap J)/I^2 \otimes_{R/I^2} M/I^2M \to J/I^2 \otimes_{R/I^2} M/I^2M \to (I + J)/I \otimes_{R/I} M/IM \to 0 $$ is exact, as you get it by tensoring the exact sequence $0 \to (I \cap J) \to J \to (I + J)/I \to 0$ by $M/I^2M$. Hence suffices to prove the injectivity of the map $(I \cap J)/I^2 \otimes_{R/I} M/IM \to IM/I^2M$. However, the map $(I \cap J)/I^2 \to I/I^2$ is injective and as $M/IM$ is flat over $R/I$ the map $(I \cap J)/I^2 \otimes_{R/I} M/IM \to I/I^2 \otimes_{R/I} M/IM$ is injective. Since we have previously seen that $I/I^2 \otimes_{R/I} M/IM = IM/I^2M$ we obtain the desired injectivity. \medskip\noindent Hence we have proven that the assumptions imply: (a) $\text{Tor}_1^R(N, M) = 0$ for all $N$ annihilated by $I$, (b) $I^2 \otimes_R M \to M$ is injective, and (c) $M/I^2M$ is flat over $R/I^2$. Thus we can continue by induction to get the same results for $I^n$ for all $n \geq 1$.
The first statement is a consequence of Lemma \ref{lemma-what-does-it-mean} applied with $R$ replaced by $R/I^2$ and $M$ replaced by $M/I^2M$ using that $$ \text{Tor}_1^{R/I^2}(M/I^2M, R/I) = \Ker(M \otimes_R I/I^2 \to IM/I^2M), $$ see Remark \ref{remark-Tor-ring-mod-ideal}. The second statement follows in the same manner using induction on $n$ to show that $M/I^{n + 1}M$ is flat over $R/I^{n + 1}$ for $n = 1, \ldots, k$. Here we use that $$ \text{Tor}_1^{R/I^{n + 1}}(M/I^{n + 1}M, R/I) = \Ker(M \otimes_R I^n/I^{n + 1} \to I^nM/I^{n + 1}M) $$ for every $n$.
First proof: By Lemma \ref{lemma-what-does-it-mean} we see that $\text{Tor}_1^R(\kappa, M)$ is zero where $\kappa$ is the residue field of $R$. Hence we see that $M$ is flat over $R$ by Lemma \ref{lemma-local-criterion-flatness}. \medskip\noindent Second proof: Let $\mathfrak m$ be the maximal ideal of $R$. We will show that $\mathfrak m \otimes_R M \to M$ is injective, and then apply Lemma \ref{lemma-local-criterion-flatness}. Suppose that $\sum f_i \otimes x_i \in \mathfrak m \otimes_R M$ and that $\sum f_i x_i = 0$ in $M$. By the equational criterion for flatness Lemma \ref{lemma-flat-eq} applied to $M/IM$ over $R/I$ we see there exist $\overline{a}_{ij} \in R/I$ and $\overline{y}_j \in M/IM$ such that $x_i \bmod IM = \sum_j \overline{a}_{ij} \overline{y}_j $ and $0 = \sum_i (f_i \bmod I) \overline{a}_{ij}$. Let $a_{ij} \in R$ be a lift of $\overline{a}_{ij}$ and similarly let $y_j \in M$ be a lift of $\overline{y}_j$. Then we see that \begin{eqnarray*} \sum f_i \otimes x_i & = & \sum f_i \otimes x_i + \sum f_ia_{ij} \otimes y_j - \sum f_i \otimes a_{ij} y_j \\ & = & \sum f_i \otimes (x_i - \sum a_{ij} y_j) + \sum (\sum f_i a_{ij}) \otimes y_j \end{eqnarray*} Since $x_i - \sum a_{ij} y_j \in IM$ and $\sum f_i a_{ij} \in I$ we see that there exists an element in $I \otimes_R M$ which maps to our given element $\sum f_i \otimes x_i$ in $\mathfrak m \otimes_R M$. But $I \otimes_R M \to M$ is injective by assumption (see Remark \ref{remark-Tor-ring-mod-ideal}) and we win.
We are going to use Lemma \ref{lemma-variant-local-criterion-flatness}. By assumption $M/IM$ is flat over $R/I$. Hence it suffices to check that $\text{Tor}_1^R(M, R/I)$ is zero on localization at $\mathfrak q$. By Remark \ref{remark-Tor-ring-mod-ideal} this Tor group is equal to $K = \Ker(I \otimes_R M \to M)$. We know for each $n \geq 1$ that the kernel $\Ker(I/I^n \otimes_{R/I^n} M/I^nM \to M/I^nM)$ is zero. Since there is a module map $I/I^n \otimes_{R/I^n} M/I^nM \to (I \otimes_R M)/I^{n - 1}(I \otimes_R M)$ we conclude that $K \subset I^{n - 1}(I \otimes_R M)$ for each $n$. By the Artin-Rees lemma, and more precisely Lemma \ref{lemma-intersection-powers-ideal-module} we conclude that $K_{\mathfrak q} = 0$, as desired.
Since $S'$ is a localization of $S \otimes_R R'$ we see that $M'$ is a localization of $M \otimes_R R'$. Note that by Lemma \ref{lemma-flat-base-change} the module $M/IM \otimes_{R/I} R'/I' = M \otimes_R R' /I'(M \otimes_R R')$ is flat over $R'/I'$. Hence also $M'/I'M'$ is flat over $R'/I'$ as the localization of a flat module is flat. By Lemma \ref{lemma-variant-local-criterion-flatness} it suffices to show that $\text{Tor}_1^{R'}(M', R'/I')$ is zero. Since $M'$ is a localization of $M \otimes_R R'$, the last assumption implies that it suffices to show that $\text{Tor}_1^R(M, R/I) \otimes_R R' \to \text{Tor}_1^{R'}(M \otimes_R R', R'/I')$ is surjective. \medskip\noindent By Lemma \ref{lemma-surjective-on-tor-one-trivial} we see that $\text{Tor}_1^R(M, R'/I') \to \text{Tor}_1^{R'}(M \otimes_R R', R'/I')$ is surjective. So now it suffices to show that $\text{Tor}_1^R(M, R/I) \otimes_R R' \to \text{Tor}_1^R(M, R'/I')$ is surjective. This follows from Lemma \ref{lemma-surjective-on-tor-one} by looking at the ring maps $R \to R/I \to R'/I'$ and the module $M$.
Set $I = \mathfrak mS \subset S$. Then we see that $M/IM$ is a flat $S/I$-module because of (3). Since $\mathfrak m \otimes_R S' \to I \otimes_S S'$ is surjective we see that also $\mathfrak m \otimes_R M \to I \otimes_S M$ is surjective. Consider $$ \mathfrak m \otimes_R M \to I \otimes_S M \to M. $$ As $M$ is flat over $R$ the composition is injective and so both arrows are injective. In particular $\text{Tor}_1^S(S/I, M) = 0$ see Remark \ref{remark-Tor-ring-mod-ideal}. By Lemma \ref{lemma-variant-local-criterion-flatness} we conclude that $M$ is flat over $S$. Note that since $M/\mathfrak m_{S'}M$ is not zero by Nakayama's Lemma \ref{lemma-NAK} we see that actually $M$ is faithfully flat over $S$ by Lemma \ref{lemma-ff} (since it forces $M/\mathfrak m_SM \not = 0$). \medskip\noindent Consider the exact sequence $0 \to \mathfrak m \to R \to \kappa \to 0$. This gives an exact sequence $0 \to \text{Tor}_1^R(\kappa, S) \to \mathfrak m \otimes_R S \to I \to 0$. Since $M$ is flat over $S$ this gives an exact sequence $0 \to \text{Tor}_1^R(\kappa, S)\otimes_S M \to \mathfrak m \otimes_R M \to I \otimes_S M \to 0$. By the above this implies that $\text{Tor}_1^R(\kappa, S)\otimes_S M = 0$. Since $M$ is faithfully flat over $S$ this implies that $\text{Tor}_1^R(\kappa, S) = 0$ and we conclude that $S$ is flat over $R$ by Lemma \ref{lemma-local-criterion-flatness}.
Proof of (1). If $M$ is flat over $R$, then $M \otimes_R R'$ is flat over $R'$ by Lemma \ref{lemma-flat-base-change}. If $W \subset S \otimes_R R'$ is the multiplicative subset such that $W^{-1}(S \otimes_R R') = S'$ then $M' = W^{-1}(M \otimes_R R')$. Hence $M'$ is flat over $R'$ as the localization of a flat module, see Lemma \ref{lemma-flat-localization} part (5). This proves (1) and in particular, we see that (3) holds. \medskip\noindent Proof of (2). Suppose that $M'$ is flat over $R'$ and $R \to R'$ is flat. By (3) applied to the diagram reflected in the northwest diagonal we see that $S \to S'$ is flat. Thus $S \to S'$ is faithfully flat by Lemma \ref{lemma-local-flat-ff}. We are going to use the criterion of Lemma \ref{lemma-flat} (\ref{item-f-ideal}) to show that $M$ is flat. Let $I \subset R$ be an ideal. If $I \otimes_R M \to M$ has a kernel, so does $(I \otimes_R M) \otimes_S S' \to M \otimes_S S' = M'$. Note that $I \otimes_R R' = IR'$ as $R \to R'$ is flat, and that $$ (I \otimes_R M) \otimes_S S' = (I \otimes_R R') \otimes_{R'} (M \otimes_S S') = IR' \otimes_{R'} M'. $$ From flatness of $M'$ over $R'$ we conclude that this maps injectively into $M'$. This concludes the proof of (2), and hence (4) is true as well.
Since $\mathfrak m_R \subset R$ and $R \to R'$ is flat, we get $\mathfrak m_R \otimes_R R' = \mathfrak m_R R' = \mathfrak m_{R'}$ by assumption (3). Observe that $M'$ is a finite $S'$-module which is flat over $R$ by Lemma \ref{lemma-flatness-descends-more-general}. Thus $\mathfrak m_R \otimes_R M' \to M'$ is injective. Then we get $$ \mathfrak m_R \otimes_R M' = \mathfrak m_R \otimes_R R' \otimes_{R'} M' = \mathfrak m_{R'} \otimes_{R'} M' $$ Thus $\mathfrak m_{R'} \otimes_{R'} M' \to M'$ is injective. This shows that $\text{Tor}_1^{R'}(\kappa_{R'}, M') = 0$ (Remark \ref{remark-Tor-ring-mod-ideal}). Thus $M'$ is flat over $R'$ by Lemma \ref{lemma-local-criterion-flatness}.
The implication (2) $\Rightarrow$ (1) is immediate. Assume (1). By Nakayama's Lemma \ref{lemma-NAK} the elements $x_\alpha$ generate $M$. Then one gets a short exact sequence $$ 0 \to K \to \bigoplus\nolimits_{\alpha \in A} R \to M \to 0 $$ Tensoring with $R/\mathfrak m$ and using Lemma \ref{lemma-flat-tor-zero} we obtain $K/\mathfrak mK = 0$. By Nakayama's Lemma \ref{lemma-NAK} we conclude $K = 0$.
Since any projective module is flat (as a direct summand of a free module) and every free module is projective, it suffices to prove that a flat module is free. Let $M$ be a flat module. Let $A$ be a set and let $x_\alpha \in M$, $\alpha \in A$ be elements such that $\overline{x_\alpha} \in M/\mathfrak m M$ forms a basis over the residue field of $R$. By Lemma \ref{lemma-local-artinian-basis-when-flat} the $x_\alpha$ are a basis for $M$ over $R$ and we win.
Let $R$, $I$, $M$, $\{x_\alpha\}_{\alpha \in A}$ be as in the lemma and satisfy assumptions (1), (2), and (3). By Nakayama's Lemma \ref{lemma-NAK} the elements $x_\alpha$ generate $M$ over $R$. The assumption $\text{Tor}_1^R(R/I, M) = 0$ implies that we have a short exact sequence $$ 0 \to I \otimes_R M \to M \to M/IM \to 0. $$ Let $\sum f_\alpha x_\alpha = 0$ be a relation in $M$. By choice of $x_\alpha$ we see that $f_\alpha \in I$. Hence we conclude that $\sum f_\alpha \otimes x_\alpha = 0$ in $I \otimes_R M$. The map $I \otimes_R M \to I/I^2 \otimes_{R/I} M/IM$ and the fact that $\{x_\alpha\}_{\alpha \in A}$ forms a basis for $M/IM$ implies that $f_\alpha \in I^2$! Hence we conclude that there are no relations among the images of the $x_\alpha$ in $M/I^2M$. In other words, we see that $M/I^2M$ is free with basis the images of the $x_\alpha$. Using the map $I \otimes_R M \to I/I^3 \otimes_{R/I^2} M/I^2M$ we then conclude that $f_\alpha \in I^3$! And so on. Since $I^n = 0$ for some $n$ by assumption (1) we win.
We may replace $R$, $M$, and $R'$ by $R/I_2$, $M/I_2M$, and $R'/\varphi(I)^2R'$. Then $I^2 = 0$ and $\varphi$ is injective. By Lemma \ref{lemma-what-does-it-mean} and the fact that $I^2 = 0$ it suffices to prove that $\text{Tor}^R_1(R/I, M) = K = \Ker(I \otimes_R M \to M)$ is zero. Set $M' = M \otimes_R R'$ and $I' = IR'$. By assumption the map $I' \otimes_{R'} M' \to M'$ is injective. Hence $K$ maps to zero in $$ I' \otimes_{R'} M' = I' \otimes_R M = I' \otimes_{R/I} M/IM. $$ Then $I \to I'$ is an injective map of $R/I$-modules. Since $M/IM$ is flat over $R/I$ the map $$ I \otimes_{R/I} M/IM \longrightarrow I' \otimes_{R/I} M/IM $$ is injective. This implies that $K$ is zero in $I \otimes_R M = I \otimes_{R/I} M/IM$ as desired.
Define inductively $I_1 = I$ and $I_{n + 1} = \varphi^{-1}(\varphi(I_n)^2R')$ for $n \geq 1$. Note that by Lemma \ref{lemma-prepare-lift-flatness} we find that $M/I_nM$ is flat over $R/I_n$ for each $n \geq 1$. It is clear that $\varphi(I_n) \subset \varphi(I)^{2^n}R'$. Since $I$ is nilpotent we see that $\varphi(I_n) = 0$ for some $n$. As $\varphi$ is injective we conclude that $I_n = 0$ for some $n$ and we win.
The implication (1) $\Rightarrow$ (2) follows immediately from the definitions. Assume $M/IM$ is flat over $R/I$ and $\text{Tor}_1^R(R/I, M) = 0$. By Lemma \ref{lemma-local-artinian-characterize-flat} this implies that $M/IM$ is free over $R/I$. Pick a set $A$ and elements $x_\alpha \in M$ such that the images in $M/IM$ form a basis. By Lemma \ref{lemma-lift-basis} we conclude that $M$ is free and in particular flat.
First proof: Let $I \subset R$ be the Jacobson radical of $R$. Then $I$ is nilpotent and $M/IM$ is flat over $R/I$ as $R/I$ is a product of fields, see Section \ref{section-artinian}. Hence $M$ is flat by an application of Lemma \ref{lemma-lift-flatness}. \medskip\noindent Second proof: By Lemma \ref{lemma-artinian-finite-length} we may write $R = \prod R_i$ as a finite product of local Artinian rings. This induces similar product decompositions for both $R$ and $S$. Hence we reduce to the case where $R$ is local Artinian (details omitted). \medskip\noindent Assume that $R \to S$, $M$ are as in the lemma satisfying (1), (2), and (3) and in addition that $R$ is local with maximal ideal $\mathfrak m$. Let $A$ be a set and $x_\alpha \in A$ be elements such that $\overline{x}_\alpha$ forms a basis for $M/\mathfrak mM$ over $R/\mathfrak m$. By Nakayama's Lemma \ref{lemma-NAK} we see that the elements $x_\alpha$ generate $M$ as an $R$-module. Set $N = S \otimes_R M$ and $I = \mathfrak mS$. Then $\{1 \otimes x_\alpha\}_{\alpha \in A}$ is a family of elements of $N$ which form a basis for $N/IN$. Moreover, since $N$ is flat over $S$ we have $\text{Tor}_1^S(S/I, N) = 0$. Thus we conclude from Lemma \ref{lemma-lift-basis} that $N$ is free on $\{1 \otimes x_\alpha\}_{\alpha \in A}$. The injectivity of $R \to S$ then guarantees that there cannot be a nontrivial relation among the $x_\alpha$ with coefficients in $R$.
As $M$ is flat over $R$ tensoring with the short exact sequence $0 \to I \to R \to R/I \to 0$ gives a short exact sequence $$ 0 \to I \otimes_R M \to M \to M/IM \to 0. $$ Note that $I \otimes_R M \to IS \otimes_S M$ is surjective. Combined with the above this means both maps in $$ I \otimes_R M \to IS \otimes_S M \to M $$ are injective. Hence $\text{Tor}_1^S(IS, M) = 0$ (see Remark \ref{remark-Tor-ring-mod-ideal}) and we conclude that $M$ is a flat $S$-module by Lemma \ref{lemma-what-does-it-mean}. To finish we need to show that $S_{\mathfrak q}$ is flat over $R$ for any prime $\mathfrak q \subset S$ such that $M \otimes_S \kappa(\mathfrak q)$ is nonzero. This follows from Lemma \ref{lemma-ff} and \ref{lemma-flat-permanence}.
Pick $x \in R$, $x \not = 0$, with $\mathfrak m x = 0$. Let $i$ be the biggest index such that $n_i > 0$. If $i = 0$, then the statement is true. If $i > 0$ denote $f_1$ the first basis vector of $R^{n_i}$. Since $xf_1$ is not mapped to zero by exactness of the complex we deduce that some matrix coefficient of the map $R^{n_i} \to R^{n_{i - 1}}$ is not in $\mathfrak m$. Lemma \ref{lemma-add-trivial-complex} then allows us to decrease $n_e + \ldots + n_1$. Induction finishes the proof.
Let $H = \Ker(M_i \to M_{i-1})/\Im(M_{i + 1} \to M_i)$ be the cohomology group in question. We may break the complex into short exact sequences $0 \to M_e \to M_{e-1} \to K_{e-2} \to 0$, $0 \to K_j \to M_j \to K_{j-1} \to 0$, for $i + 2 \leq j \leq e-2 $, $0 \to K_{i + 1} \to M_{i + 1} \to B_i \to 0$, $0 \to K_i \to M_i \to M_{i-1}$, and $0 \to B_i \to K_i \to H \to 0$. We proceed up through these complexes to prove the statements about depths, repeatedly using Lemma \ref{lemma-depth-in-ses}. First of all, since $\text{depth}(M_e) \geq e$, and $\text{depth}(M_{e-1}) \geq e-1$ we deduce that $\text{depth}(K_{e-2}) \geq e - 1$. At this point the sequences $0 \to K_j \to M_j \to K_{j-1} \to 0$ for $i + 2 \leq j \leq e-2 $ imply similarly that $\text{depth}(K_{j-1}) \geq j$ for $i + 2 \leq j \leq e-2$. The sequence $0 \to K_{i + 1} \to M_{i + 1} \to B_i \to 0$ then shows that $\text{depth}(B_i) \geq i + 1$. The sequence $0 \to K_i \to M_i \to M_{i-1}$ shows that $\text{depth}(K_i) \geq 1$ since $M_i$ has depth $\geq i \geq 1$ by assumption. The sequence $0 \to B_i \to K_i \to H \to 0$ then implies the result.
We prove the lemma by induction on $d$. If $d = 0$, then $M$ is finite and there is no case to which the lemma applies. If $d = 1$, then we have to show that $g : M \to M$ is injective. The kernel $K$ has support $\{\mathfrak m\}$ because by assumption $\dim \text{Supp}(M) \cap V(g) = 0$. Hence $K$ has finite length. Hence $f_1 : K \to K$ injective implies the length of the image is the length of $K$, and hence $f_1 K = K$, which by Nakayama's Lemma \ref{lemma-NAK} implies $K = 0$. Also, $\dim \text{Supp}(M/gM) = 0$ and so $M/gM$ is Cohen-Macaulay of depth $0$. \medskip\noindent Assume $d > 1$. Observe that $g$ is good for $(M/f_1M, f_2, \ldots, f_d)$, as is easily seen from the definition. By induction, we have that (a) $g$ is a nonzerodivisor on $M/f_1M$ and (b) $M/(g, f_1)M$ is Cohen-Macaulay with maximal regular sequence $f_2, \ldots, f_{d - 1}$. By Lemma \ref{lemma-permute-xi} we see that $g, f_1$ is an $M$-regular sequence. Hence $g$ is a nonzerodivisor on $M$ and $f_1, \ldots, f_{d - 1}$ is an $M/gM$-regular sequence.
Choose a $M$-regular sequence $f_1, \ldots, f_d$ with $d = \dim(\text{Supp}(M))$. If $g$ is good with respect to $(M, f_1, \ldots, f_d)$ we win by Lemma \ref{lemma-good-element}. In particular the lemma holds if $d = 1$. (The case $d = 0$ does not occur.) Assume $d > 1$. Choose an element $h \in R$ such that (\romannumeral1) $h$ is good with respect to $(M, f_1, \ldots, f_d)$, and (\romannumeral2) $\dim(\text{Supp}(M) \cap V(h, g)) = d - 2$. To see $h$ exists, let $\{\mathfrak q_j\}$ be the (finite) set of minimal primes of the closed sets $\text{Supp}(M)$, $\text{Supp}(M)\cap V(f_1, \ldots, f_i)$, $i = 1, \ldots, d - 1$, and $\text{Supp}(M) \cap V(g)$. None of these $\mathfrak q_j$ is equal to $\mathfrak m$ and hence we may find $h \in \mathfrak m$, $h \not \in \mathfrak q_j$ by Lemma \ref{lemma-silly}. It is clear that $h$ satisfies (\romannumeral1) and (\romannumeral2). From Lemma \ref{lemma-good-element} we conclude that $M/hM$ is Cohen-Macaulay. By (\romannumeral2) we see that the pair $(M/hM, g)$ satisfies the induction hypothesis. Hence $M/(h, g)M$ is Cohen-Macaulay and $g : M/hM \to M/hM$ is injective. By Lemma \ref{lemma-permute-xi} we see that $g : M \to M$ and $h : M/gM \to M/gM$ are injective. Combined with the fact that $M/(g, h)M$ is Cohen-Macaulay this finishes the proof.
By Lemma \ref{lemma-depth-dim-associated-primes} we have $\text{depth}(M) \leq \dim(R/\mathfrak p)$. Of course $\dim(R/\mathfrak p) \leq \dim(\text{Supp}(M))$ as $\mathfrak p \in \text{Supp}(M)$ (Lemma \ref{lemma-ass-support}). Thus we have equality in both inequalities as $M$ is Cohen-Macaulay. Then $\mathfrak p$ must be minimal in $\text{Supp}(M)$ otherwise we would have $\dim(R/\mathfrak p) < \dim(\text{Supp}(M))$. Finally, minimal primes in the support of $M$ are equal to the minimal elements of $\text{Ass}(M)$ (Proposition \ref{proposition-minimal-primes-associated-primes}) hence $M$ has no embedded associated primes (Definition \ref{definition-embedded-primes}).
We will prove this by induction on $\dim(R)$. If $\dim(R) = 0$, then the statement is clear. Assume $\dim(R) > 0$. Then $n > 0$. Choose an element $x \in \mathfrak p_1$, with $x$ not in any of the minimal primes of $R$, and in particular $x \not \in \mathfrak p_0$. (See Lemma \ref{lemma-silly}.) Then $\dim(R/xR) = \dim(R) - 1$ by Lemma \ref{lemma-one-equation}. The module $M/xM$ is Cohen-Macaulay over $R/xR$ by Proposition \ref{proposition-CM-module} and Lemma \ref{lemma-CM-over-quotient}. The support of $M/xM$ is $\Spec(R/xR)$ by Lemma \ref{lemma-support-quotient}. After replacing $x$ by $x^n$ for some $n$, we may assume that $\mathfrak p_1$ is an associated prime of $M/xM$, see Lemma \ref{lemma-inherit-minimal-primes}. By Lemma \ref{lemma-CM-ass-minimal-support} we conclude that $\mathfrak p_1/(x)$ is a minimal prime of $R/xR$. It follows that  the chain $\mathfrak p_1/(x) \subset \ldots \subset \mathfrak p_n/(x)$ is a maximal chain of primes in $R/xR$. By induction we find that this chain has length $\dim(R/xR) = \dim(R) - 1$ as desired.