hcju/stacksqa huggingface dataset:
Assume (1). Then $R \to S$ is flat by definition. By Algebra, Lemma \ref{algebra-lemma-syntomic} and Lemma \ref{lemma-lci-local} we see that it suffices to show a relative global complete intersection is a local complete intersection homomorphism which is Lemma \ref{lemma-relative-global-complete-intersection-koszul}. \medskip\noindent Assume (2). A local complete intersection is of finite presentation because a Koszul-regular ideal is finitely generated. Let $R \to k$ be a map to a field. It suffices to show that $S' = S \otimes_R k$ is a local complete intersection over $k$, see Algebra, Definition \ref{algebra-definition-lci-field}. Choose a prime $\mathfrak q' \subset S'$. Write $S = R[x_1, \ldots, x_n]/I$. Then $S' = k[x_1, \ldots, x_n]/I'$ where $I' \subset k[x_1, \ldots, x_n]$ is the image of $I$. Let $\mathfrak p' \subset k[x_1, \ldots, x_n]$, $\mathfrak q \subset S$, and $\mathfrak p \subset R[x_1, \ldots, x_n]$ be the corresponding primes. By Definition \ref{definition-regular-ideal} exists an $g \in R[x_1, \ldots, x_n]$, $g \not \in \mathfrak p$ and $f_1, \ldots, f_r \in R[x_1, \ldots, x_n]_g$ which form a Koszul-regular sequence generating $I_g$. Since $S$ and hence $S_g$ is flat over $R$ we see that the images $f'_1, \ldots, f'_r$ in $k[x_1, \ldots, x_n]_g$ form a $H_1$-regular sequence generating $I'_g$, see Lemma \ref{lemma-relative-regular-immersion-algebra}. Thus $f'_1, \ldots, f'_r$ map to a regular sequence in $k[x_1, \ldots, x_n]_{\mathfrak p'}$ generating $I'_{\mathfrak p'}$ by Lemma \ref{lemma-noetherian-finite-all-equivalent}. Applying Algebra, Lemma \ref{algebra-lemma-lci} we conclude $S'_{gg'}$ for some $g' \in S$, $g' \not \in \mathfrak q'$ is a global complete intersection over $k$ as desired.
The only thing to prove is the injectivity of the map $I/I^2 \otimes C \to K/K^2$. By assumption the ideal $J$ is Koszul-regular. Hence we have $IA[x_s, y_j] \cap K^2 = IK$ by Lemma \ref{lemma-conormal-sequence-H1-regular-ideal}. This means that the kernel of $K/K^2 \to J/J^2$ is isomorphic to $IA[x_s, y_j]/IK$. Since $I/I^2 \otimes_A C = IA[x_s, y_j]/IK$ by right exactness of tensor product, this provides us with the desired injectivity of $I/I^2 \otimes_A C \to K/K^2$.
Since $A^h$ is a filtered colimit of \'etale algebras over $A$ we see that $\NL_{A^h/A}$ is an acyclic complex by Algebra, Lemma \ref{algebra-lemma-colimits-NL} and Algebra, Definition \ref{algebra-definition-etale}. The same is true for $B^h/B$. Using the Jacobi-Zariski sequence (Algebra, Lemma \ref{algebra-lemma-exact-sequence-NL}) for $A \to A^h \to B^h$ we find that $\NL_{B^h/A} \to \NL_{B^h/A^h}$ induces isomorphisms on cohomology groups. Moreover, an \'etale ring map is a local complete intersection as it is even a global complete intersection, see Algebra, Lemma \ref{algebra-lemma-etale-standard-smooth}. By Lemma \ref{lemma-transitive-colimit-lci-at-end} we get a six term exact Jacobi-Zariski sequence associated to $A \to B \to B^h$ which proves that $\NL_{B/A} \otimes_B B^h \to \NL_{B^h/A}$ induces isomorphisms on cohomology groups. This finishes the proof in the case of the map on henselizations. The case of strict henselization is proved in exactly the same manner.
We can find a global complete intersection $A = k[x_1, \ldots, x_n]/(f_1, \ldots, f_c)$ over $k$ such that $K$ is isomorphic to the fraction field of $A$, see Algebra, Lemma \ref{algebra-lemma-colimit-syntomic} and its proof. In this case we see that $\NL_{K/k}$ is homotopy equivalent to the complex $$ \bigoplus\nolimits_{j = 1, \ldots, c} K \longrightarrow \bigoplus\nolimits_{i = 1, \ldots, n} K\text{d}x_i $$ by Algebra, Lemmas \ref{algebra-lemma-NL-homotopy} and \ref{algebra-lemma-localize-NL}. The transcendence degree of $K$ over $k$ is the dimension of $A$ (by Algebra, Lemma \ref{algebra-lemma-dimension-prime-polynomial-ring}) which is $n - c$ and we win.
The Jacobi-Zariski sequences for $k \subset k' \subset K'$ and $k \subset K \subset K'$ are $$ 0 \to H_1(L_{k'/k}) \otimes K'  \to H_1(L_{K'/k}) \to H_1(L_{K'/k'}) \to \Omega_{k'/k} \otimes K' \to \Omega_{K'/k} \to \Omega_{K'/k} \to 0 $$ and $$ 0 \to H_1(L_{K/k}) \otimes K' \to H_1(L_{K'/k}) \to H_1(L_{K'/K}) \to \Omega_{K/k} \otimes K' \to \Omega_{K'/k} \to \Omega_{K'/K} \to 0 $$ By Lemma \ref{lemma-cartier-equality} the vector spaces $\Omega_{k'/k}$, $\Omega_{K'/K}$, $H_1(L_{K'/K})$, and $H_1(L_{k'/k})$ are finite dimensional and the alternating sum of their dimensions is $\text{trdeg}_k(k') - \text{trdeg}_K(K')$. The lemma follows.
Set $A_0 = k[y_1, \ldots, y_m]_\mathfrak p$ with maximal ideal $\mathfrak m_0$ and residue field $K_0$. Note that $\Omega_{A_0/k}$ is free of rank $m$ and $\Omega_{A_0/k} \otimes K_0 \to \Omega_{K_0/k}$ is an isomorphism. It is clear that $A_0$ is geometrically regular over $k$. Hence $H_1(L_{K_0/k}) \to \mathfrak m_0/\mathfrak m_0^2$ is an isomorphism, see Proposition \ref{proposition-characterization-geometrically-regular}. Now consider $$ \xymatrix{ H_1(L_{K_0/k}) \otimes K \ar[d] \ar[r] & \mathfrak m_0/\mathfrak m_0^2 \otimes K \ar[d] \\ H_1(L_{K/k}) \ar[r] & \mathfrak m/\mathfrak m^2 } $$ Since the left vertical arrow is injective by Lemma \ref{lemma-transitivity-gamma} and the lower horizontal by Proposition \ref{proposition-characterization-geometrically-regular} we conclude that the right vertical one is too. Hence a regular system of parameters in $A_0$ maps to part of a regular system of parameters in $A$. We win by Algebra, Lemmas \ref{algebra-lemma-flat-over-regular} and \ref{algebra-lemma-regular-ring-CM}.
Assume $R \to S$ is formally smooth in the sense of Algebra, Definition \ref{algebra-definition-formally-smooth}. If $S$ has a pre-adic topology, then there exists an ideal $\mathfrak n \subset S$ such that $S$ has the $\mathfrak n$-adic topology. Suppose given a solid commutative diagram as in Definition \ref{definition-formally-smooth}. Continuity of $S \to A/J$ means that $\mathfrak n^k$ maps to zero in $A/J$ for some $k \geq 1$, see Lemma \ref{lemma-continuous}. We obtain a ring map $\psi : S \to A$ from the assumed formal smoothness of $S$ over $R$. Then $\psi(\mathfrak n^k) \subset J$ hence $\psi(\mathfrak n^{2k}) = 0$ as $J^2 = 0$. Hence $\psi$ is continuous by Lemma \ref{lemma-continuous}. This proves (1). \medskip\noindent The proof of (2)(b) $\Rightarrow$ (2)(a) is the same as the proof of (1). Assume (2)(a). Suppose given a solid commutative diagram as in Definition \ref{definition-formally-smooth} where we use the discrete topology on $R$. Since $\varphi$ is continuous we see that $\varphi(\mathfrak m^n) \subset \mathfrak n$ for some $m \geq 1$. As $S \to A/J$ is continuous we see that $\mathfrak n^k$ maps to zero in $A/J$ for some $k \geq 1$. Hence $\mathfrak m^{nk}$ maps into $J$ under the map $R \to A$. Thus $\mathfrak m^{2nk}$ maps to zero in $A$ and we see that $R \to A$ is continuous in the $\mathfrak m$-adic topology. Thus (2)(a) gives a dotted arrow as desired.
The assumption that $\mathfrak m$ is finitely generated implies that $R^\wedge$ is $\mathfrak mR^\wedge$-adically complete, that $\mathfrak mR^\wedge = \mathfrak m^\wedge$ and that $R^\wedge/\mathfrak m^nR^\wedge = R/\mathfrak m^n$, see Algebra, Lemma \ref{algebra-lemma-hathat-finitely-generated} and its proof. Similarly for $(S, \mathfrak n)$. Thus it is clear that diagrams as in Definition \ref{definition-formally-smooth} for the cases (1), (2), and (3) are in 1-to-1 correspondence.
Let $I \subset A$ be an ideal of definition so that $I \supset J^t$ for some $n$. Then $A = \lim A/I^n$ and $A/J = \lim A/J + I^n$ because $J$ is assumed closed. Consider the following diagram of discrete $R$ algebras $A_{n, m} = A/J^n + I^m$: $$ \xymatrix{ A/J^3 + I^3 \ar[r] \ar[d] & A/J^2 + I^3 \ar[r] \ar[d] & A/J + I^3 \ar[d] \\ A/J^3 + I^2 \ar[r] \ar[d] & A/J^2 + I^2 \ar[r] \ar[d] & A/J + I^2 \ar[d] \\ A/J^3 + I \ar[r] & A/J^2 + I \ar[r] & A/J + I } $$ Note that each of the commutative squares defines a surjection $$ A_{n + 1, m + 1} \longrightarrow A_{n + 1, m} \times_{A_{n, m}} A_{n, m + 1} $$ of $R$-algebras whose kernel has square zero. We will inductively construct $R$-algebra maps $\varphi_{n, m} : S \to A_{n, m}$. Namely, we have the maps $\varphi_{1, m} = \psi \bmod J + I^m$. Note that each of these maps is continuous as $\psi$ is. We can inductively choose the maps $\varphi_{n, 1}$ by starting with our choice of $\varphi_{1, 1}$ and lifting up, using the formal smoothness of $S$ over $R$, along the right column of the diagram above. We construct the remaining maps $\varphi_{n, m}$ by induction on $n + m$. Namely, we choose $\varphi_{n + 1, m + 1}$ by lifting the pair $(\varphi_{n + 1, m}, \varphi_{n, m + 1})$ along the displayed surjection above (again using the formal smoothness of $S$ over $R$). In this way all of the maps $\varphi_{n, m}$ are compatible with the transition maps of the system. As $J^t \subset I$ we see that for example $\varphi_n = \varphi_{nt, n} \bmod I^n$ induces a map $S \to A/I^n$. Taking the limit $\varphi = \lim \varphi_n$ we obtain a map $S \to A = \lim A/I^n$. The composition into $A/J$ agrees with $\psi$ as we have seen that $A/J = \lim A/J + I^n$. Finally we show that $\varphi$ is continuous. Namely, we know that $\psi(\mathfrak n^r) \subset J + I^r/J$ for some $r$ by our assumption that $\psi$ is a morphism of topological rings, see Lemma \ref{lemma-continuous}. Hence $\varphi(\mathfrak n^r) \subset J + I$ hence $\varphi(\mathfrak n^{rt}) \subset I$ as desired.
Let a solid diagram $$ \xymatrix{ S \ar[r] \ar@{-->}[rrd] & S' \ar[r] \ar@{-->}[rd] & A/J \\ R  \ar[u] \ar[r] & R' \ar[r] \ar[u] & A \ar[u] } $$ as in Definition \ref{definition-formally-smooth} be given. Then the composition $S \to S' \to A/J$ is continuous. By assumption the longer dotted arrow exists. By the universal property of tensor product we obtain the shorter dotted arrow.
Let a solid diagram $$ \xymatrix{ S \ar[r] & A/J \\ R \ar[u] \ar[r] & A \ar[u] } $$ as in Definition \ref{definition-formally-smooth} be given. Set $A' = A \otimes_R R'$ and $J' = \Im(J \otimes_R R' \to A')$. The base change of the diagram above is the diagram $$ \xymatrix{ S' \ar[r] \ar@{-->}[rd]^{\psi'} & A'/J' \\ R' \ar[u] \ar[r] & A' \ar[u] } $$ with continuous arrows. By condition (2) we obtain the dotted arrow $\psi' : S' \to A'$. Using condition (1) choose a direct summand decomposition $R' = R \oplus C$ as $R$-modules. (Warning: $C$ isn't an ideal in $R'$.) Then $A' = A \oplus A \otimes_R C$. Set $$ J'' = \Im(J \otimes_R C \to A \otimes_R C) \subset J' \subset A'. $$ Then $J' = J \oplus J''$ as $A$-modules. The image of the composition $\psi : S \to A'$ of $\psi'$ with $S \to S'$ is contained in $A + J' = A \oplus J''$. However, in the ring $A + J' = A \oplus J''$ the $A$-submodule $J''$ is an ideal! (Use that $J^2 = 0$.) Hence the composition $S \to A + J' \to (A + J')/J'' = A$ is the arrow we were looking for.
The implication (1) $\Rightarrow$ (2) follows from the definitions. Consider a diagram $$ \xymatrix{ S \ar[r] \ar@{-->}[rd] & A/J \\ R \ar[r] \ar[u] & A \ar[u] } $$ as in Definition \ref{definition-formally-smooth} for the $\mathfrak m$-adic topology on $R$ and the $\mathfrak n$-adic topology on $S$. Pick $m > 0$ with $\mathfrak n^m(A/J) = 0$ (possible by continuity of maps in diagram). Consider the subring $A'$ of $A$ which is the inverse image of the image of $S$ in $A/J$. Set $J' = J$ viewed as an ideal in $A'$. Then $J'$ is an ideal of square zero in $A'$ and $A'/J'$ is a quotient of $S/\mathfrak n^m$. Hence $A'$ is local and $\mathfrak m_{A'}^{2m} = 0$. Thus we get a diagram $$ \xymatrix{ S \ar[r] \ar@{-->}[rd] & A'/J' \\ R \ar[r] \ar[u] & A' \ar[u] } $$ as in (2). If we can construct the dotted arrow in this diagram, then we obtain the dotted arrow in the original one by composing with $A' \to A$. In this way we see that (2) implies (1). \medskip\noindent Assume $S$ Noetherian. The implication (1) $\Rightarrow$ (3) is immediate. Assume (3) and suppose a diagram as in (2) is given. Then $\mathfrak m_A^n J = 0$ for some $n > 0$. Considering the maps $$ A \to A/\mathfrak m_A^{n - 1}J \to \ldots \to A/\mathfrak mJ \to A/J $$ we see that it suffices to produce the lifting if $\mathfrak m_A J = 0$. Assume $\mathfrak m_A J = 0$ and let $A' \subset A$ be the ring constructed above. Then $A'/J'$ is Artinian as a quotient of the Artinian local ring $S/\mathfrak n^m$. Thus it suffices to show that given property (3) we can find the dotted arrow in diagrams as in (2) with $A/J$ Artinian and $\mathfrak m_A J = 0$. Let $\kappa$ be the common residue field of $A$, $A/J$, and $S$. By (3), if $J_0 \subset J$ is an ideal with $\dim_\kappa(J/J_0) = 1$, then we can produce a dotted arrow $S \to A/J_0$. Taking the product we obtain $$ S \longrightarrow \prod\nolimits_{J_0 \text{ as above}} A/J_0 $$ Clearly the image of this arrow is contained in the sub $R$-algebra $A'$ of elements which map into the small diagonal $A/J \subset \prod_{J_0} A/J$. Let $J' \subset A'$ be the elements mapping to zero in $A/J$. Then $J'$ is an ideal of square zero and as $\kappa$-vector space equal to $$ J' = \prod\nolimits_{J_0 \text{ as above}} J/J_0 $$ Thus the map $J \to J'$ is injective. By the theory of vector spaces we can choose a splitting $J' = J \oplus M$. It follows that $$ A' = A \oplus M $$ as an $R$-algebra. Hence the map $S \to A'$ can be composed with the projection $A' \to A$ to give the desired dotted arrow thereby finishing the proof of the lemma.
Let $k_0 \subset k$ be the prime field. Then $k_0$ is perfect, hence $k / k_0$ is separable, hence formally smooth by Algebra, Lemma \ref{algebra-lemma-formally-smooth-extensions-easy}. By Lemmas \ref{lemma-formally-smooth} and \ref{lemma-compose-formally-smooth} we see that $k_0 \to A$ is formally smooth for the $\mathfrak m$-adic topology on $A$. Hence we may assume $k = \mathbf{Q}$ or $k = \mathbf{F}_p$. \medskip\noindent By Algebra, Lemmas \ref{algebra-lemma-completion-faithfully-flat} and \ref{algebra-lemma-flat-under-regular} it suffices to prove the completion $A^\wedge$ is regular. By Lemma \ref{lemma-formally-smooth-completion} we may replace $A$ by $A^\wedge$. Thus we may assume that $A$ is a Noetherian complete local ring. By the Cohen structure theorem (Algebra, Theorem \ref{algebra-theorem-cohen-structure-theorem}) there exist a map $K \to A$. As $k$ is the prime field we see that $K \to A$ is a $k$-algebra map. \medskip\noindent Let $x_1, \ldots, x_n \in \mathfrak m$ be elements whose images form a basis of $\mathfrak m/\mathfrak m^2$. Set $T = K[[X_1, \ldots, X_n]]$. Note that $$ A/\mathfrak m^2 \cong K[x_1, \ldots, x_n]/(x_ix_j) $$ and $$ T/\mathfrak m_T^2 \cong K[X_1, \ldots, X_n]/(X_iX_j). $$ Let $A/\mathfrak m^2 \to T/m_T^2$ be the local $K$-algebra isomorphism given by mapping the class of $x_i$ to the class of $X_i$. Denote $f_1 : A \to T/\mathfrak m_T^2$ the composition of this isomorphism with the quotient map $A \to A/\mathfrak m^2$. The assumption that $k \to A$ is formally smooth in the $\mathfrak m$-adic topology means we can lift $f_1$ to a map $f_2 : A \to T/\mathfrak{m}_T^3$, then to a map $f_3 : A \to T/\mathfrak{m}_T^4$, and so on, for all $n \geq 1$. Warning: the maps $f_n$ are continuous $k$-algebra maps and may not be $K$-algebra maps. We get an induced map $f : A \to T = \lim T/\mathfrak m_T^n$ of local $k$-algebras. By our choice of $f_1$, the map $f$ induces an isomorphism $\mathfrak m/\mathfrak m^2 \to \mathfrak m_T/\mathfrak m_T^2$ hence each $f_n$ is surjective and we conclude $f$ is surjective as $A$ is complete. This implies $\dim(A) \geq \dim(T) = n$. Hence $A$ is regular by definition. (It also follows that $f$ is an isomorphism.)
By Algebra, Proposition \ref{algebra-proposition-characterize-separable-field-extensions} the extension $\kappa/k$ is formally smooth. By Lemma \ref{lemma-formally-smooth} $k \to \kappa$ is formally smooth in the sense of Definition \ref{definition-formally-smooth}. Then we get $\kappa \to A$ from Lemma \ref{lemma-lift-continuous}.
It suffices to prove that the completion of $A$ is formally smooth over $k$, see Lemma \ref{lemma-formally-smooth-completion}. Hence we may assume that $A$ is a complete local regular $k$-algebra with residue field $K$ separable over $k$. By Lemma \ref{lemma-power-series-over-residue-field} we see that $A = K[[x_1, \ldots, x_n]]$. \medskip\noindent The power series ring $K[[x_1, \ldots, x_n]]$ is formally smooth over $k$. Namely, $K$ is formally smooth over $k$ and $K[x_1, \ldots, x_n]$ is formally smooth over $K$ as a polynomial algebra. Hence $K[x_1, \ldots, x_n]$ is formally smooth over $k$ by Algebra, Lemma \ref{algebra-lemma-compose-formally-smooth}. It follows that $k \to K[x_1, \ldots, x_n]$ is formally smooth for the $(x_1, \ldots, x_n)$-adic topology by Lemma \ref{lemma-formally-smooth}. Finally, it follows that $k \to K[[x_1, \ldots, x_n]]$ is formally smooth for the $(x_1, \ldots, x_n)$-adic topology by Lemma \ref{lemma-formally-smooth-completion}.
The implication (2) $\Rightarrow$ (1) follows from Algebra, Lemma \ref{algebra-lemma-smooth-test-artinian}. Conversely, if $A \to B$ is smooth at $\mathfrak q$, then $A \to B_g$ is smooth for some $g \in B$, $g \not \in \mathfrak q$. Then $A \to B_g$ is formally smooth by Algebra, Proposition \ref{algebra-proposition-smooth-formally-smooth}. Hence $A_\mathfrak p \to B_\mathfrak q$ is formally smooth as localization preserves formal smoothness (for example by the criterion of Algebra, Proposition \ref{algebra-proposition-characterize-formally-smooth} and the fact that the cotangent complex behaves well with respect to localization, see Algebra, Lemmas \ref{algebra-lemma-NL-localize-bottom} and \ref{algebra-lemma-localize-NL}). Finally, Lemma \ref{lemma-formally-smooth} implies that $A_\mathfrak p \to B_\mathfrak q$ is formally smooth in the $\mathfrak q$-adic topology.
By the universal property of power series rings it suffices to prove: \begin{enumerate} \item $\mathbf{Q} \to K$ is formally smooth. \item $\mathbf{F}_p \to L$ is formally smooth. \item $\mathbf{Z} \to \Lambda$ is formally smooth in the $\mathfrak m$-adic topology. \end{enumerate} The first two are Algebra, Proposition \ref{algebra-proposition-characterize-separable-field-extensions}. The third follows from Algebra, Lemma \ref{algebra-lemma-cohen-ring-formally-smooth} since for any test diagram as in Definition \ref{definition-formally-smooth} some power of $p$ will be zero in $A/J$ and hence some power of $p$ will be zero in $A$.
Use the Cohen structure theorem (Algebra, Theorem \ref{algebra-theorem-cohen-structure-theorem}) to choose a surjection $S \to B$ as in the statement of the lemma where we choose $S$ to be a power series over a Cohen ring if the residue characteristic is $p > 0$ and a power series over a field else. Let $J \subset S$ be the kernel of $S \to B$. Next, choose a surjection $R = \Lambda[[x_1, \ldots, x_n]] \to A$ where we choose $\Lambda$ to be a Cohen ring if the residue characteristic of $A$ is $p > 0$ and $\Lambda$ equal to the residue field of $A$ otherwise. We lift the composition $\Lambda[[x_1, \ldots, x_n]] \to A \to B$ to a map $\varphi : R \to S$. This is possible because $\Lambda[[x_1, \ldots, x_n]]$ is formally smooth over $\mathbf{Z}$ in the $\mathfrak m$-adic topology (see Lemma \ref{lemma-power-series-ring-over-Cohen-fs}) by an application of Lemma \ref{lemma-lift-continuous}. Finally, we replace $\varphi$ by the map $\varphi' : R = \Lambda[[x_1, \ldots, x_n]] \to S' = S[[y_1, \ldots, y_n]]$ with $\varphi'|_\Lambda = \varphi|_\Lambda$ and $\varphi'(x_i) = \varphi(x_i) + y_i$. We also replace $S \to B$ by the map $S' \to B$ which maps $y_i$ to zero. After this replacement it is clear that a regular system of parameters of $R$ maps to part of a regular sequence in $S'$ and we win.
Let $k$ be the residue field of $R$. If the characteristic of $k$ is $p > 0$, then we denote $\Lambda$ a Cohen ring (Algebra, Definition \ref{algebra-definition-cohen-ring}) with residue field $k$ (Algebra, Lemma \ref{algebra-lemma-cohen-rings-exist}). If the characteristic of $k$ is $0$ we set $\Lambda = k$. Choose a surjection $\Lambda[[x_1, \ldots, x_n]] \to R$ (as in the Cohen structure theorem, see Algebra, Theorem \ref{algebra-theorem-cohen-structure-theorem}) and lift this to maps $\Lambda[[x_1, \ldots, x_n]] \to S$ and $\varphi : \Lambda[[x_1, \ldots, x_n]] \to S$ and $\varphi' : \Lambda[[x_1, \ldots, x_n]] \to S'$ using Lemmas \ref{lemma-power-series-ring-over-Cohen-fs} and \ref{lemma-lift-continuous}. Next, choose $f_1, \ldots, f_m \in S$ generating the kernel of $S \to R$ and $f'_1, \ldots, f'_{m'} \in S'$ generating the kernel of $S' \to R$. Then the map $$ \Lambda[[x_1, \ldots, x_n, y_1, \ldots, y_m, z_1, \ldots, z_{m'}]] \longrightarrow S \times_R S, $$ which sends $x_i$ to $(\varphi(x_i), \varphi'(x_i))$ and $y_j$ to $(f_j, 0)$ and $z_{j'}$ to $(0, f'_j)$ is surjective. Thus $S \times_R S'$ is a quotient of a complete local ring, whence complete.
We may assume that $A$ and $B$ a Noetherian complete local rings by Lemma \ref{lemma-formally-smooth-completion} and Algebra, Lemma \ref{algebra-lemma-completion-Noetherian-Noetherian} (this also uses Algebra, Lemma \ref{algebra-lemma-flatness-descends-more-general} and \ref{algebra-lemma-completion-faithfully-flat} to see that flatness of the map on completions implies flatness of $A \to B$). Choose a commutative diagram $$ \xymatrix{ S \ar[r] & B \\ R \ar[u] \ar[r] & A \ar[u] } $$ as in Lemma \ref{lemma-embed-map-Noetherian-complete-local-rings} with $R \to S$ flat. Let $I \subset R$ be the kernel of $R \to A$. Because $B$ is formally smooth over $A$ we see that the $A$-algebra map $$ S/IS \longrightarrow B $$ has a section, see Lemma \ref{lemma-lift-continuous}. Hence $B$ is a direct summand of the flat $A$-module $S/IS$ (by base change of flatness, see Algebra, Lemma \ref{algebra-lemma-flat-base-change}), whence flat.
Observe that $\mathfrak m_B/\mathfrak m_B^2 = H_1(\NL_{K/B})$ by Algebra, Lemma \ref{algebra-lemma-NL-surjection}. By Algebra, Lemma \ref{algebra-lemma-exact-sequence-NL} it remains to show injectivity of $H_1(\NL_{K/A}) \to \mathfrak m_B/\mathfrak m_B^2$. With $k$ the residue field of $A$, the Jacobi-Zariski sequence for $A \to k \to K$ gives $\Omega_{K/A} = \Omega_{K/k}$ and an exact sequence $$ \mathfrak m_A/\mathfrak m_A^2 \otimes_k K \to H_1(\NL_{K/A}) \to H_1(\NL_{K/k}) \to 0 $$ Set $\overline{B} = B \otimes_A k$. Since $\overline{B}$ is regular the ideal $\mathfrak m_{\overline{B}}$ is generated by a regular sequence. Applying Lemmas \ref{lemma-conormal-sequence-H1-regular} and \ref{lemma-noetherian-finite-all-equivalent} to $\mathfrak m_A B \subset \mathfrak m_B$ we find $\mathfrak m_A B / (\mathfrak m_AB \cap \mathfrak m_B^2) = \mathfrak m_A B / \mathfrak m_A \mathfrak m_B$ which is equal to $\mathfrak m_A/\mathfrak m_A^2 \otimes_k K$ as $A \to B$ is flat by Lemma \ref{lemma-formally-smooth-flat}. Thus we obtain a short exact sequence $$ 0 \to \mathfrak m_A/\mathfrak m_A^2 \otimes_k K \to \mathfrak m_B/\mathfrak m_B^2 \to \mathfrak m_{\overline{B}}/\mathfrak m_{\overline{B}}^2 \to 0 $$ Functoriality of the Jacobi-Zariski sequences shows that we obtain a commutative diagram $$ \xymatrix{ & \mathfrak m_A/\mathfrak m_A^2 \otimes_k K \ar[d] \ar[r] & H_1(\NL_{K/A}) \ar[d] \ar[r] & H_1(\NL_{K/k}) \ar[d] \ar[r] & 0 \\ 0 \ar[r] & \mathfrak m_A/\mathfrak m_A^2 \otimes_k K \ar[r] & \mathfrak m_B/\mathfrak m_B^2 \ar[r] & \mathfrak m_{\overline{B}}/\mathfrak m_{\overline{B}}^2 \ar[r] & 0 } $$ The left vertical arrow is injective by Theorem \ref{theorem-regular-fs} as $k \to \overline{B}$ is formally smooth in the $\mathfrak m_{\overline{B}}$-adic topology by Lemma \ref{lemma-base-change-fs}. This finishes the proof by the snake lemma.