hcju/stacksqa huggingface dataset:
Let $x_1, x_2, \ldots$ be a countable set of generators for $M$.  For each $x_n$ choose $i \in I$ such that $x_n$ is in the image of the canonical map $f_i: M_i \to M$; let $I'_{0} \subset I$ be the set of all these $i$.  Now since $M$ is Mittag-Leffler, for each $i \in I'_{0}$ we can choose $j \in I$ such that $j \geq i$ and $f_{ij}: M_i \to M_j$ factors through $f_{ik}: M_i \to M_k$ for all $k \geq i$  (condition (3) of Proposition \ref{proposition-ML-characterization}); let $I'_1$ be the union of $I'_0$ with all of these $j$.  Since $I'_1$ is a countable, we can enlarge it to a countable directed set $I'_{2} \subset I$.  Now we can apply the same procedure to $I'_{2}$ as we did to $I'_{0}$ to get a new countable set $I'_{3} \subset I$.  Then we enlarge $I'_{3}$ to a countable directed set $I'_{4}$.  Continuing in this way---adding in a $j$ as in Proposition \ref{proposition-ML-characterization} (3) for each $ i \in I'_{\ell}$ if $\ell$ is odd and enlarging $I'_{\ell}$ to a directed set if $\ell$ is even---we get a sequence of subsets $I'_{\ell} \subset I$ for $\ell \geq 0$.  The union $I' = \bigcup I'_{\ell}$ satisfies: \begin{enumerate} \item $I'$ is countable and directed; \item each $x_n$ is in the image of $f_i: M_i \to M$ for some $i \in I'$; \item if $i \in I'$, then there is $j \in I'$ such that $j \geq i$ and $f_{ij}: M_i \to M_j$ factors through $f_{ik}: M_i \to M_k$ for all $k \in I$ with $k \geq i$.  In particular $\Ker(f_{ik}) \subset \Ker(f_{ij})$ for $k \geq i$. \end{enumerate} We claim that the canonical map $\colim_{i \in I'} M_i \to \colim_{i \in I} M_i = M$ is an isomorphism.  By (2) it is surjective.  For injectivity, suppose $x \in \colim_{i \in I'} M_i$ maps to $0$ in $\colim_{i \in I} M_i$. Representing $x$ by an element $\tilde{x} \in M_i$ for some $i \in I'$, this means that $f_{ik}(\tilde{x}) = 0$ for some $k \in I, k \geq i$.  But then by (3) there is $j \in I', j \geq i,$ such that $f_{ij}(\tilde{x}) = 0$.  Hence $x = 0$ in $\colim_{i \in I'} M_i$.
Write $M = \colim_{i \in I} M_i$ as a directed colimit of finitely presented $R$-modules with $I$ countable, see Lemma \ref{lemma-ML-countable-colimit}. The transition maps are denoted $f_{ij}$ and we use $f_i : M_i \to M$ to denote the canonical maps into $M$. Set $N = \prod_{s \in I} M_s$. Denote $$ M_i^* = \Hom_R(M_i, N) = \prod\nolimits_{s \in I} \Hom_R(M_i, M_s) $$ so that $(M_i^*)$ is an inverse system of $R$-modules over $I$. Note that $\Hom_R(M, N) = \lim M_i^*$. As $M$ is Mittag-Leffler, we find for every $i \in I$ an index $k(i) \geq i$ such that $$ E_i := \bigcap\nolimits_{i' \geq i} \Im(M_{i'}^* \to M_i^*) = \Im(M_{k(i)}^* \to M_i^*) $$ Choose and fix $j \in I$ such that $\Im(P \to M) \subset \Im(M_j \to M)$. This is possible as $P$ is finitely generated. Set $k = k(j)$. Let $x = (0, \ldots, 0, \text{id}_{M_k}, 0, \ldots, 0) \in M_k^*$ and note that this maps to $y = (0, \ldots, 0, f_{jk}, 0, \ldots, 0) \in M_j^*$. By our choice of $k$ we see that $y \in E_j$. By Example \ref{example-ML-surjective-maps} the transition maps $E_i \to E_j$ are surjective for each $i \geq j$ and $\lim E_i = \lim M_i^* = \Hom_R(M, N)$. Hence Lemma \ref{lemma-ML-limit-nonempty} guarantees there exists an element $z \in \Hom_R(M, N)$ which maps to $y$ in $E_j \subset M_j^*$. Let $z_k$ be the $k$th component of $z$. Then $z_k : M \to M_k$ is a homomorphism such that $$ \xymatrix{ M \ar[r]_{z_k} & M_k \\ M_j \ar[ru]_{f_{jk}} \ar[u]^{f_j} } $$ commutes. Let $\alpha : M \to M$ be the composition $f_k \circ z_k : M \to M_k \to M$. Then $\alpha$ factors through a finitely presented module by construction and $\alpha \circ f_j = f_j$. Since the image of $f$ is contained in the image of $f_j$ this also implies that $\alpha \circ f = f$.
By Lazard's theorem (Theorem \ref{theorem-lazard}), we can write $M = \colim_{i \in I} M_i$ for a directed system of finite free $R$-modules $(M_i, f_{ij})$ indexed by a set $I$.  By Lemma \ref{lemma-ML-countable-colimit}, we may assume $I$ is countable.  Now let $$ 0 \to N_1 \to N_2 \to N_3 \to 0 $$ be an exact sequence of $R$-modules.  We must show that applying $\Hom_R(M, -)$ preserves exactness.  Since $M_i$ is finite free, $$ 0 \to \Hom_R(M_i, N_1) \to \Hom_R(M_i, N_2) \to \Hom_R(M_i, N_3) \to 0 $$ is exact for each $i$.  Since $M$ is Mittag-Leffler, $(\Hom_R(M_i, N_{1}))$ is a Mittag-Leffler inverse system.  So by Lemma \ref{lemma-ML-exact-sequence}, $$ 0 \to \lim_{i \in I} \Hom_R(M_i, N_1) \to \lim_{i \in I} \Hom_R(M_i, N_2) \to \lim_{i \in I} \Hom_R(M_i, N_3) \to 0 $$ is exact.  But for any $R$-module $N$ there is a functorial isomorphism $\Hom_R(M, N) \cong \lim_{i \in I} \Hom_R(M_i, N)$, so $$ 0 \to \Hom_R(M, N_1) \to \Hom_R(M, N_2) \to \Hom_R(M, N_3) \to 0 $$ is exact.
Write $M = \colim_{i\in I} M_i$ as a directed colimit of finitely presented $R$-modules $M_i$. Using Proposition \ref{proposition-ML-characterization}, we see that we have to prove that for each $i \in I$ there exists $i \leq j$, $j\in I$ such that $M_i\rightarrow M_j$ dominates $M_i\rightarrow M$. \medskip\noindent Take $N$ the pushout $$ \xymatrix{ M_i  \ar[r] \ar[d] & M_j \ar[d] \\ M \ar[r] & N } $$ Then the lemma is equivalent to the existence of $j$ such that $M_j\rightarrow N$ is universally injective, see Lemma \ref{lemma-domination-universally-injective}. Observe that the tensorization by $S$ $$ \xymatrix{ M_i\otimes_R S  \ar[r] \ar[d] & M_j\otimes_R S \ar[d] \\ M\otimes_R S \ar[r] & N\otimes_R S } $$ Is a pushout diagram.  So because $M \otimes_R S = \colim_{i\in I} M_i \otimes_R S$ expresses $M\otimes_R S$ as a colimit of $S$-modules of finite presentation, and $M\otimes_R S$ is Mittag-Leffler, there exists $j \geq i$ such that $M_j\otimes_R S\rightarrow N\otimes_R S$ is universally injective. So using that $R\rightarrow S$ is faithfully flat we conclude that $M_j\rightarrow N$ is universally injective too.
Let $N'_0 = N$.  We construct by induction an increasing sequence of countably generated submodules $N'_{\ell} \subset M$ for $\ell = 0, 1, 2, \ldots$ such that: if $I'_{\ell}$ is the set of $i \in I$ such that the projection of $\Im(N'_{\ell} \otimes_R S \to M \otimes_R S)$ onto $Q_i$ is nonzero, then $\Im(N'_{\ell + 1} \otimes_R S \to M \otimes_R S)$ contains $Q_i$ for all $i \in I'_{\ell}$.  To construct $N'_{\ell + 1}$ from $N'_\ell$, let $Q$ be the sum of (the countably many) $Q_i$ for $i \in I'_{\ell}$, choose $P$ as in Lemma \ref{lemma-lift-countably-generated-submodule}, and then let $N'_{\ell + 1} = N'_{\ell} + P$.  Having constructed the $N'_{\ell}$, just take $N' = \bigcup_{\ell} N'_{\ell}$ and $I' = \bigcup_{\ell} I'_{\ell}$.
Assume $M/IM \to N/IN$ is surjective. Then the map $M/I^nM \to N/I^nN$ is surjective for each $n \geq 1$ by Nakayama's lemma. More precisely, apply Lemma \ref{lemma-NAK} part (11) to the map $M/I^nM \to N/I^nN$ over the ring $R/I^n$ and the nilpotent ideal $I/I^n$ to see this. Set $K_n = \{x \in M \mid \varphi(x) \in I^nN\}$. Thus we get short exact sequences $$ 0 \to K_n/I^nM \to M/I^nM \to N/I^nN \to 0 $$ We claim that the canonical map $K_{n + 1}/I^{n + 1}M \to K_n/I^nM$ is surjective. Namely, if $x \in K_n$ write $\varphi(x) = \sum z_j n_j$ with $z_j \in I^n$, $n_j \in N$. By assumption we can write $n_j = \varphi(m_j) + \sum z_{jk}n_{jk}$ with $m_j \in M$, $z_{jk} \in I$ and $n_{jk} \in N$. Hence $$ \varphi(x - \sum z_j m_j) = \sum z_jz_{jk} n_{jk}. $$ This means that $x' = x - \sum z_j m_j \in K_{n + 1}$ maps to $x$ which proves the claim. Now we may apply Lemma \ref{lemma-Mittag-Leffler} to the inverse system of short exact sequences above to see (1). Part (2) is a special case of (1). If the assumptions of (3) hold, then for each $n$ the sequence $$ 0 \to K/I^nK \to M/I^nM \to N/I^nN \to 0 $$ is short exact by Lemma \ref{lemma-flat-tor-zero}. Hence we can directly apply Lemma \ref{lemma-Mittag-Leffler} to conclude (3) is true. To see (4) choose generators $x_i \in M$, $i = 1, \ldots, n$. Then the map $R^{\oplus n} \to M$, $(a_1, \ldots, a_n) \mapsto \sum a_ix_i$ is surjective. Hence by (2) we see $(R^\wedge)^{\oplus n} \to M^\wedge$, $(a_1, \ldots, a_n) \mapsto \sum a_ix_i$ is surjective. Assertion (4) follows from this.
Since $I$ is finitely generated, $I^n$ is finitely generated, say by $f_1, \ldots, f_r$. Applying Lemma \ref{lemma-completion-generalities} part (2) to the surjection $(f_1, \ldots, f_r) : M^{\oplus r} \to I^n M$ yields a surjection $$ (M^\wedge)^{\oplus r} \xrightarrow{(f_1, \ldots, f_r)} (I^n M)^\wedge = \lim_{m \geq n} I^n M/I^m M = \Ker(M^\wedge \to M/I^n M). $$ On the other hand, the image of $(f_1, \ldots, f_r) : (M^\wedge)^{\oplus r} \to M^\wedge$ is $I^n M^\wedge$. Thus $M^\wedge / I^n M^\wedge \simeq M/I^n M$. Taking inverse limits yields $(M^\wedge)^\wedge \simeq M^\wedge$; that is, $M^\wedge$ is $I$-adically complete.
Say $I^c Q = 0$. Then $Q/I^nQ = Q$ for $n \geq c$. On the other hand, it is clear that $I^nM \subset M \cap I^nN \subset I^{n - c}M$ for $n \geq c$. Thus $M^\wedge = \lim M/(M \cap I^n N)$. Apply Lemma \ref{lemma-Mittag-Leffler} to the system of exact sequences $$ 0 \to M/(M \cap I^n N) \to N/I^n N \to Q \to 0 $$ for $n \geq c$ to conclude.
The module $I^n M^\wedge$ is contained in $K_n$. Thus for each $n \geq 1$ there is a canonical exact sequence $$ 0 \to K_n/I^nM^\wedge \to M^\wedge/I^nM^\wedge \to M/I^nM \to 0. $$ As $I^nM^\wedge$ maps onto $I^nM/I^{n + 1}M$ we see that $K_{n + 1} + I^n M^\wedge = K_n$. Thus the inverse system $\{K_n/I^n M^\wedge\}_{n \geq 1}$ has surjective transition maps. By Lemma \ref{lemma-Mittag-Leffler} we see that there is a short exact sequence $$ 0 \to \lim_n K_n/I^n M^\wedge \to (M^\wedge)^\wedge \to M^\wedge \to 0 $$ Hence $M^\wedge$ is complete if and only if $K_n/I^n M^\wedge = 0$ for all $n \geq 1$.
Let $x \in R^\wedge$ map to a unit $x_1$ in $R/I$. Then $x$ maps to a unit $x_n$ in $R/I^n$ for every $n$ by Lemma \ref{lemma-locally-nilpotent-unit}. Hence $y = (x_n^{-1}) \in \lim R/I^n = R^\wedge$ is an inverse to $x$. Parts (2) and (3) follow immediately from (1). Part (4) follows from (1) and Lemma \ref{lemma-contained-in-radical}.
Assume $M$ is $J$-adically complete and $I$ is finitely generated. We have $\bigcap I^nM = 0$ because $\bigcap J^nM = 0$. By Lemma \ref{lemma-when-surjective-to-completion} it suffices to prove the surjectivity of $M \to \lim M/I^nM$ in case $I$ is generated by a single element. Say $I = (f)$. Let $x_n \in M$ with $x_{n + 1} - x_n \in f^nM$. We have to show there exists an $x \in M$ such that $x_n - x \in f^nM$ for all $n$. As $x_{n + 1} - x_n \in J^nM$ and as $M$ is $J$-adically complete, there exists an element $x \in M$ such that $x_n - x \in J^nM$. Replacing $x_n$ by $x_n - x$ we may assume that $x_n \in J^nM$. To finish the proof we will show that this implies $x_n \in I^nM$. Namely, write $x_n - x_{n + 1} = f^nz_n$. Then $$ x_n = f^n(z_n + fz_{n + 1} + f^2z_{n + 2} + \ldots) $$ The sum $z_n + fz_{n + 1} + f^2z_{n + 2} + \ldots$ converges in $M$ as $f^c \in J^c$. The sum $f^n(z_n + fz_{n + 1} + f^2z_{n + 2} + \ldots)$ converges in $M$ to $x_n$ because the partial sums equal $x_n - x_{n + c}$ and $x_{n + c} \in J^{n + c}M$.
Let $x_1, \ldots, x_n \in M$ be elements whose images in $M/IM$ generate $M/IM$ as a $R/I$-module. Denote $M' \subset M$ the $R$-submodule generated by $x_1, \ldots, x_n$. By Lemma \ref{lemma-completion-generalities} the map $(M')^\wedge \to M^\wedge$ is surjective. Since $\bigcap I^nM = 0$ we see in particular that $\bigcap I^nM' = (0)$. Hence by Lemma \ref{lemma-when-finite-module-complete-over-complete-ring} we see that $M'$ is complete, and we conclude that $M' \to M^\wedge$ is surjective. Finally, the kernel of $M \to M^\wedge$ is zero since it is equal to $\bigcap I^nM = (0)$. Hence we conclude that $M \cong M' \cong M^\wedge$ is finitely generated.
Setting $M = N/K$ we find that part (1) follows from part (2). Let $0 \to K \to N \to M \to 0$ be as in (2). For each $n$ we get the short exact sequence $$ 0 \to K/(I^nN \cap K) \to N/I^nN \to M/I^nM \to 0. $$ By Lemma \ref{lemma-Mittag-Leffler} we obtain the exact sequence $$ 0 \to \lim K/(I^nN \cap K) \to N^\wedge \to M^\wedge \to 0. $$ By the Artin-Rees Lemma \ref{lemma-Artin-Rees} we may choose $c$ such that $I^nK \subset I^n N \cap K \subset I^{n-c} K$ for $n \geq c$. Hence $K^\wedge = \lim K/I^nK = \lim K/(I^nN \cap K)$ and we conclude that (2) is true. \medskip\noindent Let $M$ be as in (3) and let $0 \to K \to R^{\oplus t} \to M \to 0$ be a presentation of $M$. We get a commutative diagram $$ \xymatrix{ & K \otimes_R R^\wedge \ar[r] \ar[d] & R^{\oplus t} \otimes_R R^\wedge \ar[r] \ar[d] & M \otimes_R R^\wedge \ar[r] \ar[d] & 0 \\ 0 \ar[r] & K^\wedge \ar[r] & (R^{\oplus t})^\wedge \ar[r] & M^\wedge \ar[r] & 0 } $$ The top row is exact, see Section \ref{section-flat}. The bottom row is exact by part (2). By Lemma \ref{lemma-completion-generalities} the vertical arrows are surjective. The middle vertical arrow is an isomorphism. We conclude (3) holds by the Snake Lemma \ref{lemma-snake}.
Consider $J \otimes_R R^\wedge \to R \otimes_R R^\wedge = R^\wedge$ where $J$ is an arbitrary ideal of $R$. According to Lemma \ref{lemma-completion-tensor} this is identified with $J^\wedge \to R^\wedge$ and $J^\wedge \to R^\wedge$ is injective. Part (1) follows from Lemma \ref{lemma-flat}. Part (2) is a reformulation of Lemma \ref{lemma-completion-tensor} part (2).
By Lemma \ref{lemma-completion-flat} it is flat. The composition $R \to R^\wedge \to R/\mathfrak m$ where the last map is the projection map $R^\wedge \to R/I$ combined with $R/I \to R/\mathfrak m$ shows that $\mathfrak m$ is in the image of $\Spec(R^\wedge) \to \Spec(R)$. Hence the map is faithfully flat by Lemma \ref{lemma-ff}.
By Lemma \ref{lemma-hathat-finitely-generated} we see that $R^\wedge$ is $I$-adically complete. Hence it is also $IR^\wedge$-adically complete. Since $R^\wedge/IR^\wedge = R/I$ is Noetherian we see that after replacing $R$ by $R^\wedge$ we may in addition to assumptions (1) and (2) assume that also $R$ is $I$-adically complete. \medskip\noindent Let $f_1, \ldots, f_t$ be generators of $I$. Then there is a surjection of rings $R/I[T_1, \ldots, T_t] \to \bigoplus I^n/I^{n + 1}$ mapping $T_i$ to the element $\overline{f}_i \in I/I^2$. Hence $\bigoplus I^n/I^{n + 1}$ is a Noetherian ring. Let $J \subset R$ be an ideal. Consider the ideal $$ \bigoplus J \cap I^n/J \cap I^{n + 1} \subset \bigoplus I^n/I^{n + 1}. $$ Let $\overline{g}_1, \ldots, \overline{g}_m$ be generators of this ideal. We may choose $\overline{g}_j$ to be a homogeneous element of degree $d_j$ and we may pick $g_j \in J \cap I^{d_j}$ mapping to $\overline{g}_j \in J \cap I^{d_j}/J \cap I^{d_j + 1}$. We claim that $g_1, \ldots, g_m$ generate $J$. \medskip\noindent Let $x \in J \cap I^n$. There exist $a_j \in I^{\max(0, n - d_j)}$ such that $x - \sum a_j g_j \in J \cap I^{n + 1}$. The reason is that $J \cap I^n/J \cap I^{n + 1}$ is equal to $\sum \overline{g}_j I^{n - d_j}/I^{n - d_j + 1}$ by our choice of $g_1, \ldots, g_m$. Hence starting with $x \in J$ we can find a sequence of vectors $(a_{1, n}, \ldots, a_{m, n})_{n \geq 0}$ with $a_{j, n} \in I^{\max(0, n - d_j)}$ such that $$ x = \sum\nolimits_{n = 0, \ldots, N} \sum\nolimits_{j = 1, \ldots, m} a_{j, n} g_j \bmod I^{N + 1} $$ Setting $A_j = \sum_{n \geq 0} a_{j, n}$ we see that $x = \sum A_j g_j$ as $R$ is complete. Hence $J$ is finitely generated and we win.
This is a consequence of Lemma \ref{lemma-completion-Noetherian}. It can also be seen directly as follows. Choose generators $f_1, \ldots, f_n$ of $I$. Consider the map $$ R[[x_1, \ldots, x_n]] \longrightarrow R^\wedge, \quad x_i \longmapsto f_i. $$ This is a well defined and surjective ring map (details omitted). Since $R[[x_1, \ldots, x_n]]$ is Noetherian (see Lemma \ref{lemma-Noetherian-power-series}) we win.
We have $\mathfrak mS \subset \mathfrak n$ because $R \to S$ is a local ring map. The assumption $\dim_{\kappa(\mathfrak m)} S/\mathfrak mS < \infty$ implies that $S/\mathfrak mS$ is an Artinian ring, see Lemma \ref{lemma-finite-dimensional-algebra}. Hence has dimension $0$, see Lemma \ref{lemma-Noetherian-dimension-0}, hence $\mathfrak n = \sqrt{\mathfrak mS}$. This and the fact that $\mathfrak n$ is finitely generated implies that $\mathfrak n^t \subset \mathfrak mS$ for some $t \geq 1$. By Lemma \ref{lemma-change-ideal-completion} we see that $S^\wedge$ can be identified with the $\mathfrak m$-adic completion of $S$. As $\mathfrak m$ is finitely generated we see from Lemma \ref{lemma-hathat-finitely-generated} that $S^\wedge$ and $R^\wedge$ are $\mathfrak m$-adically complete. At this point we may apply Lemma \ref{lemma-finite-over-complete-ring} to $S^\wedge$ as an $R^\wedge$-module to conclude.
The first equality follows from Lemma \ref{lemma-completion-tensor}. We may replace $R$ by the localization $R_\mathfrak p$ and $S$ by $S_\mathfrak p = S \otimes_R R_\mathfrak p$. Hence we may assume that $R$ is a local Noetherian ring and that $\mathfrak p = \mathfrak m$ is its maximal ideal. The $\mathfrak q_iS_{\mathfrak q_i}$-adic completion $S_{\mathfrak q_i}^\wedge$ is equal to the $\mathfrak m$-adic completion by Lemma \ref{lemma-finite-after-completion}. For every $n \geq 1$ prime ideals of $S/\mathfrak m^nS$ are in 1-to-1 correspondence with the maximal ideals $\mathfrak q_1, \ldots, \mathfrak q_m$ of $S$ (by going up for $S$ over $R$, see Lemma \ref{lemma-integral-going-up}). Hence $S/\mathfrak m^nS = \prod S_{\mathfrak q_i}/\mathfrak m^nS_{\mathfrak q_i}$ by Lemma \ref{lemma-artinian-finite-length} (using for example Proposition \ref{proposition-dimension-zero-ring} to see that $S/\mathfrak m^nS$ is Artinian). Hence the $\mathfrak m$-adic completion $S^\wedge$ of $S$ is equal to $\prod S_{\mathfrak q_i}^\wedge$. Finally, we have $R^\wedge \otimes_R S = S^\wedge$ by Lemma \ref{lemma-completion-tensor}.
As $M$ is flat, each of the sequences $$ 0 \to K/I^nK \to P/I^nP \to M/I^nM \to 0 $$ is short exact, see Lemma \ref{lemma-flat-tor-zero} and the sequence $0 \to K^\wedge \to P^\wedge \to M^\wedge \to 0$ is a short exact sequence, see Lemma \ref{lemma-completion-generalities}. It suffices to show that we can find splittings $s_n : M/I^nM \to P/I^nP$ such that $s_{n + 1} \bmod I^n = s_n$. We will construct these $s_n$ by induction on $n$. Pick any splitting $s_1$, which exists as $M/IM$ is a projective $R/I$-module. Assume given $s_n$ for some $n > 0$. Set $P_{n + 1} = \{x \in P \mid x \bmod I^nP \in \Im(s_n)\}$. The map $\pi : P_{n + 1}/I^{n + 1}P_{n + 1} \to M/I^{n + 1}M$ is surjective (details omitted). As $M/I^{n + 1}M$ is projective as a $R/I^{n + 1}$-module by Lemma \ref{lemma-lift-projective} we may choose a section $t : M/I^{n + 1}M \to P_{n + 1}/I^{n + 1}P_{n + 1}$ of $\pi$. Setting $s_{n + 1}$ equal to the composition of $t$ with the canonical map $P_{n + 1}/I^{n + 1}P_{n + 1} \to P/I^{n + 1}P$ works.
Let $B$ be the $(I + J)$-adic completion of $A$. By Lemma \ref{lemma-completion-flat} $B/IB$ is the $J$-adic completion of $A/I$ hence isomorphic to $A/I$ by assumption. Moreover $B$ is $I$-adically complete by Lemma \ref{lemma-complete-by-sub}. Hence $B$ is a finite $A$-module by Lemma \ref{lemma-finite-over-complete-ring}. By Nakayama's lemma (Lemma \ref{lemma-NAK} using $I$ is in the Jacobson radical of $A$ by Lemma \ref{lemma-radical-completion}) we find that $A \to B$ is surjective. The map $A \to B$ is flat by Lemma \ref{lemma-completion-flat}. The image of $\Spec(B) \to \Spec(A)$ contains $V(I)$ and as $I$ is contained in the Jacobson radical of $A$ we find $A \to B$ is faithfully flat (Lemma \ref{lemma-ff-rings}). Thus $A \to B$ is injective. Thus $A$ is complete with respect to $I + J$, hence a fortiori complete with respect to $J$.
By Lemma \ref{lemma-limit-complete-pre} we see that $M$ is $I$-adically complete. Since the transition maps are surjective, the maps $M \to M_n$ are surjective. Consider the inverse system of short exact sequences $$ 0 \to N_n \to M \to M_n \to 0 $$ defining $N_n$. Since $M_n = M_{n + 1}/I^nM_{n + 1}$ the map $N_{n + 1} + I^nM \to N_n$ is surjective. Hence $N_{n + 1}/(N_{n + 1} \cap I^{n + 1}M) \to N_n/(N_n \cap I^nM)$ is surjective. Taking the inverse limit of the short exact sequences $$ 0 \to N_n/(N_n \cap I^nM) \to M/I^nM \to M_n \to 0 $$ we obtain an exact sequence $$ 0 \to \lim N_n/(N_n \cap I^nM) \to M^\wedge \to M $$ Since $M$ is $I$-adically complete we conclude that $\lim N_n/(N_n \cap I^nM) = 0$ and hence by the surjectivity of the transition maps we get $N_n/(N_n \cap I^nM) = 0$ for all $n$. Thus $M_n = M/I^nM$ as desired.
Pick $r$ and homogeneous elements $x_{1, 1}, \ldots, x_{1, r} \in N_1$ of degrees $d_1, \ldots, d_r$ generating $N_1$. Since the transition maps are surjective, we can pick a compatible system of homogeneous elements $x_{n, i} \in N_n$ lifting $x_{1, i}$. By the graded Nakayama lemma (Lemma \ref{lemma-graded-NAK}) we see that $N_n$ is generated by the elements $x_{n, 1}, \ldots, x_{n, r}$ sitting in degrees $d_1, \ldots, d_r$. Thus for $m \leq n$ we see that $N_n \to N_n/I^m N_n$ is an isomorphism in degrees $< \min(d_i) + m$ (as $I^mN_n$ is zero in those degrees). Thus the inverse system of degree $d$ parts $$ \ldots = N_{2 + d - \min(d_i), d} = N_{1 + d - \min(d_i), d} = N_{d - \min(d_i), d} \to N_{-1 + d - \min(d_i), d} \to \ldots $$ stabilizes as indicated. Let $N$ be the graded $A$-module whose $d$th graded part is this stabilization. In particular, we have the elements $x_i = \lim x_{n, i}$ in $N$. We claim the $x_i$ generate $N$: any $x \in N_d$ is a linear combination of $x_1, \ldots, x_r$ because we can check this in $N_{d - \min(d_i), d}$ where it holds as $x_{d - \min(d_i), i}$ generate $N_{d - \min(d_i)}$. Finally, the reader checks that the surjective map $N/I^nN \to N_n$ is an isomorphism by checking to see what happens in each degree as before. Details omitted.
First we claim that $u_n : N/{\mathfrak m}^nN \to M/{\mathfrak m}^nM$ is injective for all $n \geq 1$. We proceed by induction, the base case is that $\overline{u} = u_1$ is injective. By our assumption that $M$ is flat over $R$ we have  a short exact sequence $0 \to M \otimes_R {\mathfrak m}^n/{\mathfrak m}^{n + 1} \to M/{\mathfrak m}^{n + 1}M \to M/{\mathfrak m}^n M \to 0$. Also, $M \otimes_R {\mathfrak m}^n/{\mathfrak m}^{n + 1} = M/{\mathfrak m}M \otimes_{R/{\mathfrak m}} {\mathfrak m}^n/{\mathfrak m}^{n + 1}$. We have a similar exact sequence $N \otimes_R {\mathfrak m}^n/{\mathfrak m}^{n + 1} \to N/{\mathfrak m}^{n + 1}N \to N/{\mathfrak m}^n N \to 0$ for $N$ except we do not have the zero on the left. We also have $N \otimes_R {\mathfrak m}^n/{\mathfrak m}^{n + 1} = N/{\mathfrak m}N \otimes_{R/{\mathfrak m}} {\mathfrak m}^n/{\mathfrak m}^{n + 1}$. Thus the map $u_{n + 1}$ is injective as both $u_n$ and the map $\overline{u} \otimes \text{id}_{{\mathfrak m}^n/{\mathfrak m}^{n + 1}}$ are. \medskip\noindent By Krull's intersection theorem (Lemma \ref{lemma-intersect-powers-ideal-module-zero}) applied to $N$ over the ring $S$ and the ideal $\mathfrak mS$ we have $\bigcap \mathfrak m^nN = 0$. Thus the injectivity of $u_n$ for all $n$ implies $u$ is injective. \medskip\noindent To show that $M/u(N)$ is flat over $R$, it suffices to show that $I \otimes_R M/u(N) \to M/u(N)$ is injective for every ideal $I \subset R$, see Lemma \ref{lemma-flat}. Consider the diagram $$ \begin{matrix} & & 0 & & 0 & & 0 & & \\ & & \uparrow & & \uparrow & & \uparrow & & \\ & & N/IN & \to & M/IM & \to & M/(IM + u(N)) & \to & 0 \\ & & \uparrow & & \uparrow & & \uparrow & & \\ 0 & \to & N & \to & M & \to & M/u(N) & \to & 0 \\ & & \uparrow & & \uparrow & & \uparrow & & \\ & & N \otimes_R I & \to & M \otimes_R I & \to & M/u(N)\otimes_R I & \to & 0 \end{matrix} $$ The arrow $M \otimes_R I \to M$ is injective. By the snake lemma (Lemma \ref{lemma-snake}) we see that it suffices to prove that $N/IN$ injects into $M/IM$. Note that $R/I \to S/IS$ is a local homomorphism of Noetherian local rings, $N/IN \to M/IM$ is a map of $R/I$-modules, $N/IN$ is finite over $S/IS$, and $M/IM$ is flat over $R/I$ and $u \bmod I : N/IN \to M/IM$ is injective modulo $\mathfrak m$. Thus we may apply the first part of the proof to $u \bmod I$ and we conclude.