hcju/stacksqa huggingface dataset:
By induction on $\dim(R)$. The case $\dim(R) = 0$ is trivial, because then $R$ is a field. Assume $\dim(R) > 0$. By (3) this implies that $\dim(S) > 0$. Let $\mathfrak q_1, \ldots, \mathfrak q_r$ be the minimal primes of $S$. Note that $\mathfrak q_i \not \supset \mathfrak m_R S$ since $$ \dim(S/\mathfrak q_i) = \dim(S) > \dim(S/\mathfrak m_R S) $$ the first equality by Lemma \ref{lemma-maximal-chain-CM} and the inequality by (3). Thus $\mathfrak p_i = R \cap \mathfrak q_i$ is not equal to $\mathfrak m_R$. Pick $x \in \mathfrak m$, $x \not \in \mathfrak m^2$, and $x \not \in \mathfrak p_i$, see Lemma \ref{lemma-silly}. Hence we see that $x$ is not contained in any of the minimal primes of $S$. Hence $x$ is a nonzerodivisor on $S$ by (2), see Lemma \ref{lemma-reformulate-CM} and $S/xS$ is Cohen-Macaulay with $\dim(S/xS) = \dim(S) - 1$. By (1) and Lemma \ref{lemma-regular-ring-CM} the ring $R/xR$ is regular with $\dim(R/xR) = \dim(R) - 1$. By induction we see that $R/xR \to S/xS$ is flat. Hence we conclude by Lemma \ref{lemma-variant-local-criterion-flatness} and the remark following it.
Suppose that $x_1, \ldots, x_d$ are a system of parameters of $R$ which map to a regular sequence in $S$. Note that $S/(x_1, \ldots, x_d)S$ is flat over $R/(x_1, \ldots, x_d)$ as the latter is a field. Then $x_d$ is a nonzerodivisor in $S/(x_1, \ldots, x_{d - 1})S$ hence $S/(x_1, \ldots, x_{d - 1})S$ is flat over $R/(x_1, \ldots, x_{d - 1})$ by the local criterion of flatness (see Lemma \ref{lemma-variant-local-criterion-flatness} and remarks following). Then $x_{d - 1}$ is a nonzerodivisor in $S/(x_1, \ldots, x_{d - 2})S$ hence $S/(x_1, \ldots, x_{d - 2})S$ is flat over $R/(x_1, \ldots, x_{d - 2})$ by the local criterion of flatness (see Lemma \ref{lemma-variant-local-criterion-flatness} and remarks following). Continue till one reaches the conclusion that $S$ is flat over $R$.
Pick some $\lambda \in \Lambda$ and consider $$ \text{Tor}_1^{R_\lambda}(M_\lambda, R_\lambda/\mathfrak m_\lambda) = \Ker(\mathfrak m_\lambda \otimes_{R_\lambda} M_\lambda \to M_\lambda). $$ See Remark \ref{remark-Tor-ring-mod-ideal}. The right hand side shows that this is a finitely generated $S_\lambda$-module (because $S_\lambda$ is Noetherian and the modules in question are finite). Let $\xi_1, \ldots, \xi_n$ be generators. Because $M$ is flat over $R$ we have that $0 = \Ker(\mathfrak m_\lambda R \otimes_R M \to M)$. Since $\otimes$ commutes with colimits we see there exists a $\lambda' \geq \lambda$ such that each $\xi_i$ maps to zero in $\mathfrak m_{\lambda}R_{\lambda'} \otimes_{R_{\lambda'}} M_{\lambda'}$. Hence we see that $$ \text{Tor}_1^{R_\lambda}(M_\lambda, R_\lambda/\mathfrak m_\lambda) \longrightarrow \text{Tor}_1^{R_{\lambda'}}(M_{\lambda'}, R_{\lambda'}/\mathfrak m_{\lambda}R_{\lambda'}) $$ is zero. Note that $M_\lambda \otimes_{R_\lambda} R_\lambda/\mathfrak m_\lambda$ is flat over $R_\lambda/\mathfrak m_\lambda$ because this last ring is a field. Hence we may apply Lemma \ref{lemma-another-variant-local-criterion-flatness} to get that $M_{\lambda'}$ is flat over $R_{\lambda'}$.
Let $\Lambda$, $R_\lambda \to S_\lambda$, $M_\lambda$ be as in Lemma \ref{lemma-limit-module-essentially-finite-presentation}. Denote $I_\lambda \subset R_\lambda$ the inverse image of $I$. In this case the system $R/I \to S/IS$, $M/IM$, $R_\lambda \to S_\lambda/I_\lambda S_\lambda$, and $M_\lambda/I_\lambda M_\lambda$ satisfies the conclusions of Lemma \ref{lemma-limit-module-essentially-finite-presentation} as well. Hence by Lemma \ref{lemma-colimit-eventually-flat} we may assume (after shrinking the index set $\Lambda$) that $M_\lambda/I_\lambda M_\lambda$ is flat for all $\lambda$. Pick some $\lambda$ and consider $$ \text{Tor}_1^{R_\lambda}(M_\lambda, R_\lambda/I_\lambda) = \Ker(I_\lambda \otimes_{R_\lambda} M_\lambda \to M_\lambda). $$ See Remark \ref{remark-Tor-ring-mod-ideal}. The right hand side shows that this is a finitely generated $S_\lambda$-module (because $S_\lambda$ is Noetherian and the modules in question are finite). Let $\xi_1, \ldots, \xi_n$ be generators. Because $\text{Tor}_1^R(M, R/I) = 0$ and since $\otimes$ commutes with colimits we see there exists a $\lambda' \geq \lambda$ such that each $\xi_i$ maps to zero in $\text{Tor}_1^{R_{\lambda'}}(M_{\lambda'}, R_{\lambda'}/I_{\lambda'})$. The composition of the maps $$ \xymatrix{ R_{\lambda'} \otimes_{R_\lambda} \text{Tor}_1^{R_\lambda}(M_\lambda, R_\lambda/I_\lambda) \ar[d]^{\text{surjective by Lemma \ref{lemma-surjective-on-tor-one}}} \\ \text{Tor}_1^{R_\lambda}(M_\lambda, R_{\lambda'}/I_\lambda R_{\lambda'}) \ar[d]^{\text{surjective up to localization by Lemma \ref{lemma-surjective-on-tor-one-trivial}}} \\ \text{Tor}_1^{R_{\lambda'}}(M_{\lambda'}, R_{\lambda'}/I_\lambda R_{\lambda'}) \ar[d]^{\text{surjective by Lemma \ref{lemma-surjective-on-tor-one}}} \\ \text{Tor}_1^{R_{\lambda'}}(M_{\lambda'}, R_{\lambda'}/I_{\lambda'}). } $$ is surjective up to a localization by the reasons indicated. The localization is necessary since $M_{\lambda'}$ is not equal to $M_\lambda \otimes_{R_\lambda} R_{\lambda'}$. Namely, it is equal to $M_\lambda \otimes_{S_\lambda} S_{\lambda'}$ and $S_{\lambda'}$ is the localization of $S_{\lambda} \otimes_{R_\lambda} R_{\lambda'}$ whence the statement up to a localization (or tensoring with $S_{\lambda'}$). Note that Lemma \ref{lemma-surjective-on-tor-one} applies to the first and third arrows because $M_\lambda/I_\lambda M_\lambda$ is flat over $R_\lambda/I_\lambda$ and because $M_{\lambda'}/I_\lambda M_{\lambda'}$ is flat over $R_{\lambda'}/I_\lambda R_{\lambda'}$ as it is a base change of the flat module $M_\lambda/I_\lambda M_\lambda$. The composition maps the generators $\xi_i$ to zero as we explained above. We finally conclude that $\text{Tor}_1^{R_{\lambda'}}(M_{\lambda'}, R_{\lambda'}/I_{\lambda'})$ is zero. This implies that $M_{\lambda'}$ is flat over $R_{\lambda'}$ by Lemma \ref{lemma-variant-local-criterion-flatness}.
As $S$ is essentially of finite presentation over $R$ we can write $S = C_{\overline{\mathfrak q}}$ for some finite type $R$-algebra $C$. Write $C = R[x_1, \ldots, x_n]/I$. Denote $\mathfrak q \subset R[x_1, \ldots, x_n]$ be the prime ideal corresponding to $\overline{\mathfrak q}$. Then we see that $S = B/J$ where $B = R[x_1, \ldots, x_n]_{\mathfrak q}$ is essentially of finite presentation over $R$ and $J = IB$. We can find $f_1, \ldots, f_k \in J$ such that the images $\overline{f}_i \in B/\mathfrak mB$ generate the image $\overline{J}$ of $J$ in the Noetherian ring $B/\mathfrak mB$. Hence there exist finitely generated ideals $J' \subset J$ such that $B/J' \to B/J$ induces an isomorphism $$ (B/J') \otimes_R R/\mathfrak m \longrightarrow B/J \otimes_R R/\mathfrak m = S/\mathfrak mS. $$ For any $J'$ as above we see that Lemma \ref{lemma-criterion-flatness-fibre} applies to the ring maps $$ R \longrightarrow B/J' \longrightarrow S' $$ and the module $M$. Hence we conclude that $B/J'$ is flat over $R$ for any choice $J'$ as above. Now, if $J' \subset J' \subset J$ are two finitely generated ideals as above, then we conclude that $B/J' \to B/J''$ is a surjective map between flat $R$-algebras which are essentially of finite presentation which is an isomorphism modulo $\mathfrak m$. Hence Lemma \ref{lemma-mod-injective-general} implies that $B/J' = B/J''$, i.e., $J' = J''$. Clearly this means that $J$ is finitely generated, i.e., $S$ is essentially of finite presentation over $R$. Thus we may apply Lemma \ref{lemma-criterion-flatness-fibre} to $R \to S \to S'$ and we win.
If $M \otimes_S \kappa(\mathfrak q)$ is nonzero, then $S' \otimes_S \kappa(\mathfrak q)$ is nonzero and hence there exists a prime $\mathfrak q' \subset S'$ lying over $\mathfrak q$ (Lemma \ref{lemma-in-image}). Let $\mathfrak p \subset R$ be the image of $\mathfrak q$ in $\Spec(R)$. Then $I \subset \mathfrak p$ as $I$ is locally nilpotent hence $M/\mathfrak p M$ is flat over $S/\mathfrak pS$. Hence we may apply Lemma \ref{lemma-criterion-flatness-fibre-fp-over-ft} to $R_\mathfrak p \to S_\mathfrak q \to S'_{\mathfrak q'}$ and $M_{\mathfrak q'}$. We conclude that $M_{\mathfrak q'}$ is flat over $S$ and $S_\mathfrak q$ is flat and essentially of finite presentation over $R$. Since $\mathfrak q'$ was an arbitrary prime of $S'$ we also see that $M$ is flat over $S$ (Lemma \ref{lemma-flat-localization}).
If $S$ is Cohen-Macaulay and equidimensional of dimension $d$, then we have $\dim(S_{\mathfrak m}) = d$ for all maximal ideals $\mathfrak m$ of $S$, see Lemma \ref{lemma-disjoint-decomposition-CM-algebra}. By Proposition \ref{proposition-CM-module} we see that for all maximal ideals $\mathfrak m \in V(f_1, \ldots, f_i)$ the sequence is a regular sequence in $S_{\mathfrak m}$ and the local ring $S_{\mathfrak m}/(f_1, \ldots, f_i)$ is Cohen-Macaulay of dimension $d - i$. This actually means that $S/(f_1, \ldots, f_i)$ is Cohen-Macaulay and equidimensional of dimension $d - i$.
Write $\overline{S} = S/(f_1, \ldots, f_i)$. Suppose $\mathfrak q$ is an element of the set defined in the lemma, and $\mathfrak p$ is the corresponding prime of $R$. We will use relative dimension as defined in Definition \ref{definition-relative-dimension}. First, note that $d = \dim_{\mathfrak q}(S/R) = \dim(S_{\mathfrak q}/\mathfrak pS_{\mathfrak q}) + \text{trdeg}_{\kappa(\mathfrak p)}\ \kappa(\mathfrak q)$ by Lemma \ref{lemma-dimension-at-a-point-finite-type-field}. Since $f_1, \ldots, f_i$ form a regular sequence in the Noetherian local ring $S_{\mathfrak q}/\mathfrak pS_{\mathfrak q}$ general dimension theory tells us that $\dim(\overline{S}_{\mathfrak q}/\mathfrak p\overline{S}_{\mathfrak q}) = \dim(S_{\mathfrak q}/\mathfrak pS_{\mathfrak q}) - i$. By the same Lemma \ref{lemma-dimension-at-a-point-finite-type-field} we then conclude that $\dim_{\mathfrak q}(\overline{S}/R) = \dim(\overline{S}_{\mathfrak q}/\mathfrak p\overline{S}_{\mathfrak q}) + \text{trdeg}_{\kappa(\mathfrak p)}\ \kappa(\mathfrak q) = d - i$. By Lemma \ref{lemma-dimension-fibres-bounded-open-upstairs} we have $\dim_{\mathfrak q'}(\overline{S}/R) \leq d - i$ for all $\mathfrak q' \in V(f_1, \ldots, f_i) = \Spec(\overline{S})$ in a neighbourhood of $\mathfrak q$. Thus after replacing $S$ by $S_g$ for some $g \in S$, $g \not \in \mathfrak q$ we may assume that the inequality holds for all $\mathfrak q'$. The result follows from Lemma \ref{lemma-CM-dim-finite-type}.
Let $\mathfrak q$ be an element of the set defined in the lemma. We are going to use Proposition \ref{proposition-what-exact} to show there exists a $g \in S$, $g \not \in \mathfrak q$ such that $D(g)$ is contained in the set defined in the lemma. In other words, we are going to show that after replacing $S$ by $S_g$, the set of the lemma is all of $\Spec(S)$. Thus during the proof we will, finitely often, replace $S$ by such a localization. Recall that Proposition \ref{proposition-what-exact} characterizes exactness of complexes in terms of ranks of the maps $\varphi_i$ and the ideals $I(\varphi_i)$, in case the ring is local. We first address the rank condition. Set $r_i = n_i - n_{i + 1} + \ldots + (-1)^{e - i} n_e$. Note that $r_i + r_{i + 1} = n_i$ and note that $r_i$ is the expected rank of $\varphi_i$ (in the exact case). \medskip\noindent By Lemma \ref{lemma-complex-exact-mod} we see that if $\overline{F}_{\bullet, \mathfrak q}$ is exact, then the localization $F_{\bullet, \mathfrak q}$ is exact. In particular the complex $F_\bullet$ becomes exact after localizing by an element $g \in S$, $g \not \in \mathfrak q$. In this case Proposition \ref{proposition-what-exact} applied to all localizations of $S$ at prime ideals implies that all $(r_i + 1) \times (r_i + 1)$-minors of $\varphi_i$ are zero. Thus we see that the rank of $\varphi_i$ is at most $r_i$. \medskip\noindent Let $I_i \subset S$ denote the ideal generated by the $r_i \times r_i$-minors of the matrix of $\varphi_i$. By Proposition \ref{proposition-what-exact} the complex $\overline{F}_{\bullet, \mathfrak q}$ is exact if and only if for every $1 \leq i \leq e$ we have either $(I_i)_{\mathfrak q} = S_{\mathfrak q}$ or $(I_i)_{\mathfrak q}$ contains a $S_{\mathfrak q}/\mathfrak p S_{\mathfrak q}$-regular sequence of length $i$. Namely, by our choice of $r_i$ above and by the bound on the ranks of the $\varphi_i$ this is the only way the conditions of Proposition \ref{proposition-what-exact} can be satisfied. \medskip\noindent If $(I_i)_{\mathfrak q} = S_{\mathfrak q}$, then after localizing $S$ at some element $g \not\in \mathfrak q$ we may assume that $I_i = S$. Clearly, this is an open condition. \medskip\noindent If $(I_i)_{\mathfrak q} \not = S_{\mathfrak q}$, then we have a sequence $f_1, \ldots, f_i \in (I_i)_{\mathfrak q}$ which form a regular sequence in $S_{\mathfrak q}/\mathfrak pS_{\mathfrak q}$. Note that for any prime $\mathfrak q' \subset S$ such that $(f_1, \ldots, f_i) \not \subset \mathfrak q'$ we have $(I_i)_{\mathfrak q'} = S_{\mathfrak q'}$. Thus the result follows from Lemma \ref{lemma-open-regular-sequence}.
Let $\mathfrak q \subset S$ be a prime. Denote $\mathfrak p = k[y_1, \ldots, y_d] \cap \mathfrak q$. Note that always $\dim(S_{\mathfrak q}) \leq \dim(k[y_1, \ldots, y_d]_{\mathfrak p})$ by Lemma \ref{lemma-dimension-inequality-quasi-finite} for example. Moreover, the field extension $\kappa(\mathfrak p) \subset \kappa(\mathfrak q)$ is finite and hence $\text{trdeg}_k(\kappa(\mathfrak p)) = \text{trdeg}_k(\kappa(\mathfrak q))$. \medskip\noindent Let $\mathfrak q$ be an element of the left hand side. Then Lemma \ref{lemma-finite-flat-over-regular-CM} applies and we conclude that $S_{\mathfrak q}$ is Cohen-Macaulay and $\dim(S_{\mathfrak q}) = \dim(k[y_1, \ldots, y_d]_{\mathfrak p})$. Combined with the equality of transcendence degrees above and Lemma \ref{lemma-dimension-at-a-point-finite-type-field} this implies that $\dim_{\mathfrak q}(S/k) = d$. Hence $\mathfrak q$ is an element of the right hand side. \medskip\noindent Let $\mathfrak q$ be an element of the right hand side. By the equality of transcendence degrees above, the assumption that $\dim_{\mathfrak q}(S/k) = d$ and Lemma \ref{lemma-dimension-at-a-point-finite-type-field} we conclude that $\dim(S_{\mathfrak q}) = \dim(k[y_1, \ldots, y_d]_{\mathfrak p})$. Hence Lemma \ref{lemma-CM-over-regular-flat} applies and we see that $\mathfrak q$ is an element of the left hand side.
Let $\mathfrak q \subset S$ be a prime such that $S_{\mathfrak q}$ is Cohen-Macaulay. We have to show there exists a $g \in S$, $g \not \in \mathfrak q$ such that the ring $S_g$ is Cohen-Macaulay. For any $g \in S$, $g \not \in \mathfrak q$ we may replace $S$ by $S_g$ and $\mathfrak q$ by $\mathfrak qS_g$. Combining this with Lemmas \ref{lemma-Noether-normalization-at-point} and \ref{lemma-dimension-at-a-point-finite-type-field} we may assume that there exists a finite injective ring map $k[y_1, \ldots, y_d] \to S$ with $d = \dim(S_{\mathfrak q}) + \text{trdeg}_k(\kappa(\mathfrak q))$. Set $\mathfrak p = k[y_1, \ldots, y_d] \cap \mathfrak q$. By construction we see that $\mathfrak q$ is an element of the right hand side of the displayed equality of Lemma \ref{lemma-where-CM}. Hence it is also an element of the left hand side. \medskip\noindent By Theorem \ref{theorem-openness-flatness} we see that for some $g \in S$, $g \not \in \mathfrak q$ the ring $S_g$ is flat over $k[y_1, \ldots, y_d]$. Hence by the equality of Lemma \ref{lemma-where-CM} again we conclude that all local rings of $S_g$ are Cohen-Macaulay as desired.
Let $I \subset S$ be the radical ideal such that $V(I) \subset \Spec(S)$ is the set of primes $\mathfrak q \subset S$ with $S_\mathfrak q$ not Cohen-Macaulay. See Lemma \ref{lemma-generic-CM} which also tells us that $V(I)$ is nowhere dense in $\Spec(S)$. Let $\mathfrak m \subset S$ be a maximal ideal such that $\dim(S_\mathfrak m) > 0$ and $\mathfrak m \not \in V(I)$. Such a maximal ideal exists as $\dim(S) > 0$ using the Hilbert Nullstellensatz (Theorem \ref{theorem-nullstellensatz}) and Lemma \ref{lemma-dimension-at-a-point-finite-type-over-field} which implies that any dense open of $\Spec(S)$ has the same dimension as $\Spec(S)$. Finally, let $\mathfrak q_1, \ldots, \mathfrak q_m$ be the minimal primes of $S$. Choose $f \in S$ with $$ f \equiv 1 \bmod I,\quad f \in \mathfrak m,\quad f \not \in \bigcup \mathfrak q_i $$ This is possible by Lemma \ref{lemma-silly-silly}. Namely, we have $S/(I \cap \mathfrak m) = S/I \times S/\mathfrak m$ by Lemma \ref{lemma-chinese-remainder}. Thus we can first choose $g \in S$ such that $g \equiv 1 \bmod I$ and $g \in \mathfrak m$. Then $g + (I \cap \mathfrak m) \not \subset \mathfrak q_i$ since $V(I \cap \mathfrak m) \not \supset V(\mathfrak q_i)$. Hence the lemma applies. Clearly $f$ is not a unit. To show that $f$ is a nonzerodivisor, it suffices to prove that $f : S_\mathfrak q \to S_\mathfrak q$ is injective for every prime ideal $\mathfrak q \subset S$. If $S_\mathfrak q$ is not Cohen-Macaulay, then $\mathfrak q \in V(I)$ and $f$ maps to a unit of $S_\mathfrak q$. On the other hand, if $S_\mathfrak q$ is Cohen-Macaulay, then we use that $\dim(S_\mathfrak q/fS_\mathfrak q) < \dim(S_\mathfrak q)$ by the requirement $f \not \in \mathfrak q_i$ and we conclude that $f$ is a nonzerodivisor in $S_\mathfrak q$ by Lemma \ref{lemma-reformulate-CM}.
Let $\mathfrak q$ be an element of the set indicated, with $\mathfrak p$ the corresponding prime of $R$. We have to find a $g \in S$, $g \not \in \mathfrak q$ such that all fibre rings of $R \to S_g$ are Cohen-Macaulay. During the course of the proof we may (finitely many times) replace $S$ by $S_g$ for a $g \in S$, $g \not \in \mathfrak q$. Thus by Lemma \ref{lemma-quasi-finite-over-polynomial-algebra} we may assume there is a quasi-finite ring map $R[t_1, \ldots, t_d] \to S$ with $d = \dim_{\mathfrak q}(S/R)$. Let $\mathfrak q' = R[t_1, \ldots, t_d] \cap \mathfrak q$. By Lemma \ref{lemma-where-CM} we see that the ring map $$ R[t_1, \ldots, t_d]_{\mathfrak q'} / \mathfrak p R[t_1, \ldots, t_d]_{\mathfrak q'} \longrightarrow S_{\mathfrak q}/\mathfrak p S_{\mathfrak q} $$ is flat. Hence by the crit\`ere de platitude par fibres Lemma \ref{lemma-criterion-flatness-fibre} we see that $R[t_1, \ldots, t_d]_{\mathfrak q'} \to S_{\mathfrak q}$ is flat. Hence by Theorem \ref{theorem-openness-flatness} we see that for some $g \in S$, $g \not \in \mathfrak q$ the ring map $R[t_1, \ldots, t_d] \to S_g$ is flat. Replacing $S$ by $S_g$ we see that for every prime $\mathfrak r \subset S$, setting $\mathfrak r' = R[t_1, \ldots, t_d] \cap \mathfrak r$ and $\mathfrak p' = R \cap \mathfrak r$ the local ring map $R[t_1, \ldots, t_d]_{\mathfrak r'} \to S_{\mathfrak r}$ is flat. Hence also the base change $$ R[t_1, \ldots, t_d]_{\mathfrak r'} / \mathfrak p' R[t_1, \ldots, t_d]_{\mathfrak r'} \longrightarrow S_{\mathfrak r}/\mathfrak p' S_{\mathfrak r} $$ is flat. Hence by Lemma \ref{lemma-where-CM} applied with $k = \kappa(\mathfrak p')$ we see $\mathfrak r$ is in the set of the lemma as desired.
During the course of the proof we may (finitely many times) replace $S$ by $S_g$ for any $g \in S$, $g \not \in \mathfrak q$. Hence using Lemma \ref{lemma-Noether-normalization-at-point} we may assume that $\dim(S) = \dim_{\mathfrak q}(S/k) =: d$ and find a finite injective map $k[x_1, \ldots, x_d] \to S$. Note that this also induces a finite injective map $K[x_1, \ldots, x_d] \to S_K$ by base change. By Lemma \ref{lemma-dimension-at-a-point-preserved-field-extension} we have $\dim_{\mathfrak q_K}(S_K/K) = d$. Set $\mathfrak p = k[x_1, \ldots, x_d] \cap \mathfrak q$ and $\mathfrak p_K = K[x_1, \ldots, x_d] \cap \mathfrak q_K$. Consider the following commutative diagram of Noetherian local rings $$ \xymatrix{ S_{\mathfrak q} \ar[r] & (S_K)_{\mathfrak q_K} \\ k[x_1, \ldots, x_d]_{\mathfrak p} \ar[r] \ar[u] & K[x_1, \ldots, x_d]_{\mathfrak p_K} \ar[u] } $$ By Lemma \ref{lemma-where-CM} we have to show that the left vertical arrow is flat if and only if the right vertical arrow is flat. Because the bottom arrow is flat this equivalence holds by Lemma \ref{lemma-base-change-flat-up-down}.
For each integer $d$ denote $W_d \subset \Spec(S)$ the set defined in Lemma \ref{lemma-finite-presentation-flat-CM-locus-open}. Clearly we have $\Spec(S) = \coprod W_d$, and each $W_d$ is open by the lemma we just quoted. Hence the result follows from Lemma \ref{lemma-disjoint-implies-product}.
We get a diagram (\ref{equation-functorial-omega}) by putting $R = A$, $S = C$, $R' = B$, and $S' = C$. By Lemma \ref{lemma-differential-surjective} the map $\Omega_{C/A} \to \Omega_{C/B}$ is surjective, and the kernel is generated by the elements $\text{d}(c)$, where $c \in C$ is in the image of $B \to C$. The lemma follows.
The middle term is $\Omega_{S/R} \otimes_S S/I$. For $f \in I$ denote $\overline{f}$ the image of $f$ in $I/I^2$. To show that the map $\overline{f} \mapsto \text{d}f \otimes 1$ is well defined we just have to check that $\text{d} f_1f_2 \otimes 1 = 0$ if $f_1, f_2 \in I$. And this is clear from the Leibniz rule $\text{d} f_1f_2 \otimes 1 = (f_1 \text{d}f_2 + f_2 \text{d} f_1 )\otimes 1 = \text{d}f_2 \otimes f_1 + \text{d}f_1 \otimes f_2 = 0$. A similar computation show this map is $S' = S/I$-linear. \medskip\noindent The map $\Omega_{S/R} \otimes_S S' \to \Omega_{S'/R}$ is the canonical $S'$-linear map associated to the $S$-linear map $\Omega_{S/R} \to \Omega_{S'/R}$. It is surjective because $\Omega_{S/R} \to \Omega_{S'/R}$ is surjective by Lemma \ref{lemma-differential-surjective}. \medskip\noindent The composite of the two maps is zero because $\text{d}f$ maps to zero in $\Omega_{S'/R}$ for $f \in I$. Note that exactness just says that the kernel of $\Omega_{S/R} \to \Omega_{S'/R}$ is generated as an $S$-submodule by the submodule $I\Omega_{S/R}$ together with the elements $\text{d}f$, with $f \in I$. We know by Lemma \ref{lemma-differential-surjective} that this kernel is generated by the elements $\text{d}(a)$ where $\varphi(a) = \beta(r)$ for some $r \in R$. But then $a = \alpha(r) + a - \alpha(r)$, so $\text{d}(a) = \text{d}(a - \alpha(r))$. And $a - \alpha(r) \in I$ since $\varphi(a - \alpha(r)) = \varphi(a) - \varphi(\alpha(r)) = \beta(r) - \beta(r) = 0$. We conclude the elements $\text{d}f$ with $f \in I$ already generate the kernel as an $S$-module, as desired.
[First proof] Apply Lemma \ref{lemma-differential-seq-split} to the commutative diagram $$ \xymatrix{ S \otimes_R S \ar[r] & S \\ S \ar[r] \ar[u] & S \ar[u] } $$ where the left vertical arrow is $a \mapsto a \otimes 1$. We get the exact sequence $0 \to J/J^2 \to \Omega_{S \otimes_R S/S} \otimes_{S \otimes_R S} S \to \Omega_{S/S} \to 0$. By Lemma \ref{lemma-trivial-differential-surjective} the term $\Omega_{S/S}$ is $0$, and we obtain an isomorphism between the other two terms. We have $\Omega_{S \otimes_R S/S} = \Omega_{S/R} \otimes_S (S \otimes_R S)$ by Lemma \ref{lemma-differentials-base-change} as $S \to S \otimes_R S$ is the base change of $R \to S$ and hence $$ \Omega_{S \otimes_R S/S} \otimes_{S \otimes_R S} S = \Omega_{S/R} \otimes_S (S \otimes_R S) \otimes_{S \otimes_R S} S = \Omega_{S/R} $$ We omit the verification that the map is given by the rule of the lemma.
Write $S = R[x_1, \ldots, x_n]/(f_1, \ldots, f_m)$. Write $I = (f_1, \ldots, f_m)$. According to Lemma \ref{lemma-differential-seq} there is an exact sequence of $S$-modules $$ I/I^2 \to \Omega_{R[x_1, \ldots, x_n]/R} \otimes_{R[x_1, \ldots, x_n]} S \to \Omega_{S/R} \to 0 $$ The result follows from the fact that $I/I^2$ is a finite $S$-module (generated by the images of the $f_i$), and that the middle term is finite free by Lemma \ref{lemma-differentials-polynomial-ring}.