hcju/stacksqa huggingface dataset:
Exactly as in the proof of Lemma \ref{lemma-noether-pairing-flat-quasi-finite} this reduces to the case of a finite free map $A \to B$. In this case $\tau_{B/A} = \text{Trace}_{B/A}$. Choose a basis $b_1, \ldots, b_n$ of $B$ as an $A$-module. Let $\xi = \sum b_i \otimes c_i \in J$. Then $\mu(\xi) = \sum b_i c_i$. On the other hand, the image of $\xi$ in $\Hom_B(\omega_{B/A}, B)$ sends $\text{Trace}_{B/A}$ to $\sum \text{Trace}_{B/A}(b_i)c_i$. Thus we have to show $$ \sum b_ic_i = \sum \text{Trace}_{B/A}(b_i)c_i $$ when $\xi = \sum b_i \otimes c_i \in J$. Write $b_i b_j = \sum_k a_{ij}^k b_k$ for some $a_{ij}^k \in A$. Then the right hand side is $\sum_{i, j} a_{ij}^j c_i$. On the other hand, $\xi \in J$ implies $$ (b_j \otimes 1)(\sum\nolimits_i b_i \otimes c_i) = (1 \otimes b_j)(\sum\nolimits_i b_i \otimes c_i) $$ which implies that $b_j c_i = \sum_k a_{jk}^i c_k$. Thus the left hand side is $\sum_{i, j} a_{ij}^i c_j$. Since $a_{ij}^k = a_{ji}^k$ the equality holds.
Assume $A \to B$ is unramified at $\mathfrak q$. After replacing $B$ by $B_g$ for some $g \in B$, $g \not \in \mathfrak q$ we may assume $A \to B$ is unramified (Algebra, Definition \ref{algebra-definition-unramified} and Lemma \ref{lemma-noether-different-localization}). In this case $\Omega_{B/A} = 0$. Hence if $I = \Ker(B \otimes_A B \to B)$, then $I/I^2 = 0$ by Algebra, Lemma \ref{algebra-lemma-differentials-diagonal}. Since $A \to B$ is of finite type, we see that $I$ is finitely generated. Hence by Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK}) there exists an element of the form $1 + i$ annihilating $I$. It follows that $\mathfrak{D} = B$. \medskip\noindent Conversely, assume that $\mathfrak{D} \not \subset \mathfrak q$. Then after replacing $B$ by a principal localization as above we may assume $\mathfrak{D} = B$. This means there exists an element of the form $1 + i$ in the annihilator of $I$. Conversely this implies that $I/I^2 = \Omega_{B/A}$ is zero and we conclude.
This is true because $\Omega_{B/A}$ has a presentation $$ \bigoplus\nolimits_{i = 1, \ldots, n} B f_i \xrightarrow{\text{d}} \bigoplus\nolimits_{j = 1, \ldots, n} B \text{d}x_j \rightarrow \Omega_{B/A} \rightarrow 0 $$ by Algebra, Lemma \ref{algebra-lemma-differential-seq}.
The equivalence of (3) and (4) and the implication (4) $\Rightarrow$ (5) are immediate. \medskip\noindent If $A \to B$ is flat, then we see that $\text{Trace}_{B/A} : B \to A$ is defined and that $\text{Trace}_{L/K}$ is the base change. Hence (3) holds. \medskip\noindent If $A$ is normal, then $A$ is a finite product of normal domains, hence we reduce to the case of a normal domain. Then $K$ is the fraction field of $A$ and $L = \prod L_i$ is a finite product of finite separable field extensions of $K$. Then $\text{Trace}_{L/K}(b) = \sum \text{Trace}_{L_i/K}(b_i)$ where $b_i \in L_i$ is the image of $b$. Since $b$ is integral over $A$ as $B$ is finite over $A$, these traces are in $A$. This is true because the minimal polynomial of $b_i$ over $K$ has coefficients in $A$ (Algebra, Lemma \ref{algebra-lemma-minimal-polynomial-normal-domain}) and because $\text{Trace}_{L_i/K}(b_i)$ is an integer multiple of one of these coefficients (Fields, Lemma \ref{fields-lemma-trace-and-norm-from-minimal-polynomial}).
Recall that $\omega_{B/A} = \Hom_A(B, A)$ as $A \to B$ is finite. We send $x \in \mathcal{L}_{B/A}$ to the map $b \mapsto \text{Trace}_{L/K}(bx)$. Conversely, given an $A$-linear map $\varphi : B \to A$ we obtain a $K$-linear map $\varphi_K : L \to K$. Since $K \to L$ is finite \'etale, we see that the trace pairing is nondegenerate (Lemma \ref{lemma-discriminant}) and hence there exists a $x \in L$ such that $\varphi_K(y) = \text{Trace}_{L/K}(xy)$ for all $y \in L$. Then $x \in \mathcal{L}_{B/A}$ maps to $\varphi$ in $\omega_{B/A}$.
Consider the map $$ \SheafHom_{\mathcal{O}_Y}(\omega_{Y/X}, \mathcal{O}_Y) \longrightarrow \mathcal{O}_Y,\quad \varphi \longmapsto \varphi(\tau_{Y/X}) $$ The image of this map corresponds to the Noether different on affine opens, see Lemma \ref{lemma-noether-different-flat-quasi-finite}. Hence the result follows from the elementary fact that given an invertible module $\omega$ and a global section $\tau$ the image of $\tau : \SheafHom(\omega, \mathcal{O}) = \omega^{\otimes -1} \to \mathcal{O}$ is the same as the annihilator of $\Coker(\tau : \mathcal{O} \to \omega)$.
There is an immediate reduction to the case where $X$, $X'$, $Y$, $Y'$ are affine. In other words, we have a cocartesian diagram of Noetherian rings $$ \xymatrix{ B' & B \ar[l] \\ A' \ar[u] & A \ar[l] \ar[u] } $$ with $A \to B$ flat and quasi-finite. The base change map $\omega_{B/A} \otimes_B B' \to \omega_{B'/A'}$ is an isomorphism (Lemma \ref{lemma-dualizing-base-change-of-flat}) and maps the trace element $\tau_{B/A}$ to the trace element $\tau_{B'/A'}$ (Lemma \ref{lemma-trace-base-change}). Hence the finite $B$-module $Q = \Coker(\tau_{B/A} : B \to \omega_{B/A})$ satisfies $Q \otimes_B B' = \Coker(\tau_{B'/A'} : B' \to \omega_{B'/A'})$. Thus $\mathfrak{D}_{B/A}B' \subset \mathfrak{D}_{B'/A'}$ which means we obtain the closed immersion $R' \to R \times_Y Y'$. Since $R = \text{Supp}(Q)$ and $R' = \text{Supp}(Q \otimes_B B')$ (Algebra, Lemma \ref{algebra-lemma-support-closed}) we see that $R' \to R \times_Y Y'$ is bijective by Algebra, Lemma \ref{algebra-lemma-support-base-change}. The equality $\mathfrak{D}_{B/A}B' = \mathfrak{D}_{B'/A'}$ holds if $B \to B'$ is flat, e.g., if $A \to A'$ is flat, see Algebra, Lemma \ref{algebra-lemma-annihilator-flat-base-change}. Finally, if $\omega_{B/A}$ is invertible, then we can localize and assume $\omega_{B/A} = B \lambda$. Writing $\tau_{B/A} = b\lambda$ we see that $Q = B/bB$ and $\mathfrak{D}_{B/A} = bB$. The same reasoning over $B'$ gives $\mathfrak{D}_{B'/A'} = bB'$ and the lemma is proved.
The norm map is constructed in Divisors, Lemma \ref{divisors-lemma-finite-locally-free-has-norm} and the discriminant of $f$ in Section \ref{section-discriminant}. The question is affine local, hence we may assume $X = \Spec(A)$, $Y = \Spec(B)$ and $f$ given by a finite locally free ring map $A \to B$. Localizing further we may assume $B$ is finite free as an $A$-module. Choose a basis $b_1, \ldots, b_n \in B$ for $B$ as an $A$-module. Denote $b_1^\vee, \ldots, b_n^\vee$ the dual basis of $\omega_{B/A} = \Hom_A(B, A)$ as an $A$-module. Since the norm of $b$ is the determinant of $b : B \to B$ as an $A$-linear map, we see that $\text{Norm}_{B/A}(b) = \det(b_i^\vee(bb_j))$. The discriminant is the principal closed subscheme of $\Spec(A)$ defined by $\det(\text{Trace}_{B/A}(b_ib_j))$. If $b \in \mathfrak{D}_{B/A}$ then there exist $c_i \in B$ such that $b \cdot b_i^\vee = c_i \cdot \text{Trace}_{B/A}$ where we use a dot to indicate the $B$-module structure on $\omega_{B/A}$. Write $c_i = \sum a_{il} b_l$. We have \begin{align*} \text{Norm}_{B/A}(b) & = \det(b_i^\vee(bb_j)) \\ & = \det( (b \cdot b_i^\vee)(b_j)) \\ & = \det((c_i \cdot \text{Trace}_{B/A})(b_j)) \\ & = \det(\text{Trace}_{B/A}(c_ib_j)) \\ & = \det(a_{il}) \det(\text{Trace}_{B/A}(b_l b_j)) \end{align*} which proves the lemma.
Since $f$ is of finite presentation and flat, we see that it is \'etale at a point if and only if it is unramified at that point. Moreover, the formation of the locus of ramified points commutes with base change. See Morphisms, Section \ref{morphisms-section-etale} and especially Morphisms, Lemma \ref{morphisms-lemma-set-points-where-fibres-etale}. By Lemma \ref{lemma-base-change-different} the formation of $R$ commutes set theoretically with base change. Hence it suffices to prove the lemma when $X$ is the spectrum of a field. On the other hand, the construction of $(\omega_{Y/X}, \tau_{Y/X})$ is local on $Y$. Since $Y$ is a finite discrete space (being quasi-finite over a field), we may assume $Y$ has a unique point. \medskip\noindent Say $X = \Spec(k)$ and $Y = \Spec(B)$ where $k$ is a field and $B$ is a finite local $k$-algebra. If $Y \to X$ is \'etale, then $B$ is a finite separable extension of $k$, and the trace element $\text{Trace}_{B/k}$ is a basis element of $\omega_{B/k}$ by Fields, Lemma \ref{fields-lemma-separable-trace-pairing}. Thus $\mathfrak{D}_{B/k} = B$ in this case. Conversely, if $\mathfrak{D}_{B/k} = B$, then we see from Lemma \ref{lemma-norm-different-in-discriminant} and the fact that the norm of $1$ equals $1$ that the discriminant is empty. Hence $Y \to X$ is \'etale by Lemma \ref{lemma-discriminant}.
Proof of (1). We may work locally on $Y$, hence we may assume $\omega_{Y/X}$ is free of rank $1$. Say $\omega_{Y/X} = \mathcal{O}_Y\lambda$. Then we can write $\tau_{Y/X} = h \lambda$ and then we see that $R$ is defined by $h$, i.e., $R$ is locally principal. \medskip\noindent Proof of (2). We may assume $Y \to X$ is given by a finite free ring map $A \to B$ and that $\omega_{B/A}$ is free of rank $1$ as $B$-module. Choose a $B$-basis element $\lambda$ for $\omega_{B/A}$ and write $\text{Trace}_{B/A} = b \cdot \lambda$ for some $b \in B$. Then $\mathfrak{D}_{B/A} = (b)$ and $D_f$ is cut out by $\det(\text{Trace}_{B/A}(b_ib_j))$ where $b_1, \ldots, b_n$ is a basis of $B$ as an $A$-module. Let $b_1^\vee, \ldots, b_n^\vee$ be the dual basis. Writing $b_i^\vee = c_i \cdot \lambda$ we see that $c_1, \ldots, c_n$ is a basis of $B$ as well. Hence with $c_i = \sum a_{il}b_l$ we see that $\det(a_{il})$ is a unit in $A$. Clearly, $b \cdot b_i^\vee = c_i \cdot \text{Trace}_{B/A}$ hence we conclude from the computation in the proof of Lemma \ref{lemma-norm-different-in-discriminant} that $\text{Norm}_{B/A}(b)$ is a unit times $\det(\text{Trace}_{B/A}(b_ib_j))$. \medskip\noindent Proof of (3). In the notation above we see from Lemma \ref{lemma-different-ramification} and the assumption that $h$ does not vanish in the associated points of $Y$, which implies that $h$ is a nonzerodivisor. The canonical isomorphism sends $1$ to $\tau_{Y/X}$, see Divisors, Lemma \ref{divisors-lemma-characterize-OD}.
The equivalence of (1) and (2) is More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-lci}. The equivalence of (1) and (3) is  Morphisms, Lemma \ref{morphisms-lemma-syntomic-flat-fibres}. \medskip\noindent If $A \to B$ is as in (4), then $B = A[x, x_1, \ldots, x_n]/(xh - 1, f_1, \ldots, f_n]$ is a relative global complete intersection by see Algebra, Definition \ref{algebra-definition-relative-global-complete-intersection}. Thus (4) implies (5). It is clear that (5) implies (4). \medskip\noindent Condition (5) implies (1): by Algebra, Lemma \ref{algebra-lemma-relative-global-complete-intersection} a relative global complete intersection is syntomic and the definition of a relative global complete intersection guarantees that a relative global complete intersection on $n$ variables with $n$ equations is quasi-finite, see Algebra, Definition \ref{algebra-definition-relative-global-complete-intersection} and Lemma \ref{algebra-lemma-isolated-point-fibre}. \medskip\noindent Either Algebra, Lemma \ref{algebra-lemma-syntomic} or Morphisms, Lemma \ref{morphisms-lemma-syntomic-locally-standard-syntomic} shows that (1) implies (5). \medskip\noindent More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-fp-NL-lci} shows that (6) is equivalent to (1). If the equivalent conditions (1) -- (6) hold, then we see that affine locally $Y \to X$ is given by a relative global complete intersection $B = A[x_1, \ldots, x_n]/(f_1, \ldots, f_n)$ with the same number of variables as the number of equations. Using this presentation we see that $$ \NL_{B/A} =\left( (f_1, \ldots, f_n)/(f_1, \ldots, f_n)^2 \longrightarrow \bigoplus\nolimits_{i = 1, \ldots, n} B \text{d} x_i\right) $$ By Algebra, Lemma \ref{algebra-lemma-relative-global-complete-intersection-conormal} the module $(f_1, \ldots, f_n)/(f_1, \ldots, f_n)^2$ is free with generators the congruence classes of the elements $f_1, \ldots, f_n$. Thus $\NL_{B/A}$ has rank $0$ and so does $\NL_{Y/X}$. In this way we see that (1) -- (6) imply (7). \medskip\noindent Finally, assume (7). By More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-fp-NL-lci} we see that $f$ is syntomic. Thus on suitable affine opens $f$ is given by a relative global complete intersection $A \to B = A[x_1, \ldots, x_n]/(f_1, \ldots, f_m)$, see Morphisms, Lemma \ref{morphisms-lemma-syntomic-locally-standard-syntomic}. Exactly as above we see that $\NL_{B/A}$ is a perfect complex of rank $n - m$. Thus $n = m$ and we see that (5) holds. This finishes the proof.
Proof of (1). As $A \to B$ is flat, the module $\omega_{B/A}$ is $A$-flat, see Lemma \ref{lemma-dualizing-base-flat-flat}. Thus $\omega_{B/A}$ is an invertible $B$-module if and only if $\omega_{B/A} \otimes_A \kappa(\mathfrak p)$ is an invertible $B \otimes_A \kappa(\mathfrak p)$-module for every prime $\mathfrak p \subset A$, see More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-and-free-at-point-fibre}. Still using that $A \to B$ is flat, we have that formation of $\omega_{B/A}$ commutes with base change, see Lemma \ref{lemma-dualizing-base-change-of-flat}. Thus we see that invertibility of the relative dualizing module, in the presence of flatness, is equivalent to invertibility of the relative dualizing module for the maps $\kappa(\mathfrak p) \to B \otimes_A \kappa(\mathfrak p)$. \medskip\noindent Part (2) follows from (1) and the fact that affine locally the dualizing modules are given by their algebraic counterparts, see Remark \ref{remark-relative-dualizing-for-quasi-finite}.
By Noether normalization, see Algebra, Lemma \ref{algebra-lemma-Noether-normalization} we see that there exists a finite injection $k \to B$, i.e., $\dim_k(B) < \infty$. Hence $\omega_{B/k} = \Hom_k(B, k)$ as a $B$-module. By Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing-finite} we see that $R\Hom(B, k)$ is a dualizing complex for $B$ and by Dualizing Complexes, Lemma \ref{dualizing-lemma-RHom-ext} we see that $R\Hom(B, k)$ is equal to $\omega_{B/k}$ placed in degree $0$. Thus it suffices to show that $B$ is Gorenstein (Dualizing Complexes, Lemma \ref{dualizing-lemma-gorenstein}). This is true by Dualizing Complexes, Lemma \ref{dualizing-lemma-gorenstein-lci}.
We may assume $A \to B$ is a relative global complete intersection of the form $B = A[x_1, \ldots, x_n]/(f_1, \ldots, f_n)$ and we have to show $\omega_{B/A}$ is invertible. This follows in combining Lemmas \ref{lemma-characterize-invertible} and \ref{lemma-dim-zero-global-complete-intersection-over-field}.
The scheme $X_{n, d}$ is the spectrum of the polynomial ring $A$. Hence $X_{n, d}$ is regular and irreducible. Since we can write $$ f_i = a_{i, (0, \ldots, 0)} + \sum\nolimits_{E \in T, E \not = (0, \ldots, 0)} a_{i, E} x^E $$ we see that the ring $B$ is isomorphic to the polynomial ring on $x_1, \ldots, x_n$ and the elements $a_{i, E}$ with $E \not = (0, \ldots, 0)$. Hence $\Spec(B)$ is an irreducible and regular scheme and so is the open $Y_{n, d}$. The morphism $Y_{n, d} \to X_{n, d}$ is locally quasi-finite and syntomic by Lemma \ref{lemma-syntomic-quasi-finite}. To find $V$ it suffices to find a single point where $Y_{n, d} \to X_{n, d}$ is \'etale (the locus of points where a morphism is \'etale is open by definition). Thus it suffices to find a point of $X_{n, d}$ where the fibre of $Y_{n, d} \to X_{n, d}$ is nonempty and \'etale, see Morphisms, Lemma \ref{morphisms-lemma-etale-at-point}. We choose the point corresponding to the ring map $\chi : A \to \mathbf{Q}$ sending $f_i$ to $1 + x_i^d$. Then $$ B \otimes_{A, \chi} \mathbf{Q} = \mathbf{Q}[x_1, \ldots, x_n]/(x_1^d - 1, \ldots, x_n^d - 1) $$ which is a nonzero \'etale algebra over $\mathbf{Q}$.
By Lemma \ref{lemma-syntomic-quasi-finite} we can choose $U$ and $V$ affine so that $U = \Spec(R)$ and $V = \Spec(S)$ with $S = R[y_1, \ldots, y_n]/(g_1, \ldots, g_n)$. With notation as in Example \ref{example-universal-quasi-finite-syntomic} if we pick $d$ large enough, then we can write each $g_i$ as $g_i = \sum_{E \in T} g_{i, E}y^E$ with $g_{i, E} \in R$. Then the map $A \to R$ sending $a_{i, E}$ to $g_{i, E}$ and the map $B \to S$ sending $x_i \to y_i$ give a cocartesian diagram of rings $$ \xymatrix{ S & B \ar[l] \\ R \ar[u] & A \ar[l] \ar[u] } $$ which proves the lemma.
The equivalence of (1), (2), (3), (5), and (6) and the implication (4) $\Rightarrow$ (1) follow immediately from Lemma \ref{lemma-syntomic-quasi-finite}. Assume the equivalent conditions (1), (2), (3), (5), (6) hold. Choose a point $x \in X$ and an affine open $U = \Spec(A)$ of $x$ in $X$ and say $x$ corresponds to the prime ideal $\mathfrak p \subset A$. Write $f^{-1}(U) = \Spec(B)$. Write $B = A[x_1, \ldots, x_n]/I$. Since $\NL_{B/A}$ is perfect of tor-amplitude in $[-1, 0]$ by (6) we see that $I/I^2$ is a finite locally free $B$-module of rank $n$. Since $B_\mathfrak p$ is semi-local we see that $(I/I^2)_\mathfrak p$ is free of rank $n$, see Algebra, Lemma \ref{algebra-lemma-locally-free-semi-local-free}. Thus after replacing $A$ by a principal localization at an element not in $\mathfrak p$ we may assume $I/I^2$ is a free $B$-module of rank $n$. Thus by Algebra, Lemma \ref{algebra-lemma-huber} we can find a presentation of $B$ over $A$ with the same number of variables as equations. In other words, we may assume $B = A[x_1, \ldots, x_n]/(f_1, \ldots, f_n)$. This proves (4).
Recall that being syntomic is the same thing as being flat and a local complete intersection morphism, see More on Morphisms, Lemma \ref{more-morphisms-lemma-flat-lci}. The set $W_d \subset Y_d$ of points where $\pi_d$ is Koszul is open in $Y_d$ and its formation commutes with arbitrary base change, see More on Morphisms, Lemma \ref{more-morphisms-lemma-base-change-lci-fibres}. Since $\pi_d$ is finite and hence closed, we see that $Z = \pi_d(Y_d \setminus W_d)$ is closed. Since clearly $U_d = X_d \setminus Z$ and since its formation commutes with base change we find that the lemma is true.
Let us use More on Morphisms, Lemma \ref{more-morphisms-lemma-lifting-along-artinian-at-point} to show that $U_d \to \Spec(\mathbf{Z})$ is smooth. Namely, suppose that $\Spec(A) \to U_d$ is a morphism and $A' \to A$ is a small extension. Then $B = A \otimes_{A_d} B_d$ is a finite free $A$-algebra which is syntomic over $A$ (by construction of $U_d$). By Smoothing Ring Maps, Proposition \ref{smoothing-proposition-lift-smooth} there exists a syntomic ring map $A' \to B'$ such that $B \cong B' \otimes_{A'} A$. Set $e'_1 = 1 \in B'$. For $1 < i \leq d$ choose lifts $e'_i \in B'$ of the elements $1 \otimes e_i \in A \otimes_{A_d} B_d = B$. Then $e'_1, \ldots, e'_d$ is a basis for $B'$ over $A'$ (for example see Algebra, Lemma \ref{algebra-lemma-local-artinian-basis-when-flat}). Thus we can write $e'_i e'_j = \sum \alpha_{ij}^l e'_l$ for unique elements $\alpha_{ij}^l \in A'$ which satisfy the relations $\sum_l \alpha_{ij}^l \alpha_{lk}^m = \sum_l \alpha_{il}^m \alpha _{jk}^l$ and $\alpha_{ij}^k = \alpha_{ji}^k$ and $\alpha_{i1}^j - \delta_{ij}$ in $A'$. This determines a morphism $\Spec(A') \to X_d$ by sending $a_{ij}^l \in A_d$ to $\alpha_{ij}^l \in A'$. This morphism agrees with the given morphism $\Spec(A) \to U_d$. Since $\Spec(A')$ and $\Spec(A)$ have the same underlying topological space, we see that we obtain the desired lift $\Spec(A') \to U_d$ and we conclude that $U_d$ is smooth over $\mathbf{Z}$.
By exactly the same reasoning as in the proof of Lemma \ref{lemma-universal-finite-syntomic}, using Morphisms, Lemma \ref{morphisms-lemma-set-points-where-fibres-etale}, there is a maximal open $U'_d \subset X_d$ over which $\pi_d$ is \'etale. Moreover, since an \'etale morphism is syntomic, we see that $U'_d \subset U_d$. To finish the proof we have to show that $U'_d \subset U_d$ is dense. Let $u : \Spec(k) \to U_d$ be a morphism where $k$ is a field. Let $B = k \otimes_{A_d} B_d$ as in the proof of Lemma \ref{lemma-universal-finite-syntomic-smooth}. We will show there is a local domain $A'$ with residue field $k$ and a finite syntomic $A'$ algebra $B'$ with $B = k \otimes_{A'} B'$ whose generic fibre is \'etale. Exactly as in the previous paragraph this will determine a morphism $\Spec(A') \to U_d$ which will map the generic point into $U'_d$ and the closed point to $u$, thereby finishing the proof. \medskip\noindent By Lemma \ref{lemma-syntomic-finite} part (4) we can choose a presentation $B = k[x_1, \ldots, x_n]/(f_1, \ldots, f_n)$. Let $d'$ be the maximum total degree of the polynomials $f_1, \ldots, f_n$. Let $Y_{n, d'} \to X_{n, d'}$ be as in Example \ref{example-universal-quasi-finite-syntomic}. By construction there is a morphism $u' : \Spec(k) \to X_{n, d'}$ such that $$ \Spec(B) \cong Y_{n, d'} \times_{X_{n, d'}, u'} \Spec(k) $$ Denote $A = \mathcal{O}_{X_{n, d'}, u'}^h$ the henselization of the local ring of $X_{n, d'}$ at the image of $u'$. Then we can write $$ Y_{n, d'} \times_{X_{n, d'}} \Spec(A) = Z \amalg W $$ with $Z \to \Spec(A)$ finite and $W \to \Spec(A)$ having empty closed fibre, see Algebra, Lemma \ref{algebra-lemma-characterize-henselian} part (13) or the discussion in More on Morphisms, Section \ref{more-morphisms-section-etale-localization}. By Lemma \ref{lemma-universal-quasi-finite-syntomic-etale} the local ring $A$ is regular (here we also use More on Algebra, Lemma \ref{more-algebra-lemma-henselization-regular}) and the morphism $Z \to \Spec(A)$ is \'etale over the generic point of $\Spec(A)$ (because it is mapped to the generic point of $X_{d, n'}$). By construction $Z \times_{\Spec(A)} \Spec(k) \cong \Spec(B)$. This proves what we want except that the map from residue field of $A$ to $k$ may not be an isomorphism. By Algebra, Lemma \ref{algebra-lemma-flat-local-given-residue-field} there exists a flat local ring map $A \to A'$ such that the residue field of $A'$ is $k$. If $A'$ isn't a domain, then we choose a minimal prime $\mathfrak p \subset A'$ (which lies over the unique minimal prime of $A$ by flatness) and we replace $A'$ by $A'/\mathfrak p$. Set $B'$ equal to the unique $A'$-algebra such that $Z \times_{\Spec(A)} \Spec(A') = \Spec(B')$. This finishes the proof.
The Koszul complex $K_\bullet = K(P, f_1, \ldots, f_n)$ is a resolution of $B$ by finite free $P$-modules. The Koszul complex $M_\bullet = K(P \otimes_A B, g_1, \ldots, g_n)$ is a resolution of $B$ by finite free $P \otimes_A B$-modules. There is a map of complexes $$ K_\bullet \longrightarrow M_\bullet $$ which in degree $1$ is given by the matrix $(g_{ij})$ and in degree $n$ by $\det(g_{ij})$. See More on Algebra, Lemma \ref{more-algebra-lemma-functorial}. As $B$ is a flat $A$-module, we can view $M_\bullet$ as a complex of flat $P$-modules (via $P \to P \otimes_A B$, $p \mapsto p \otimes 1$). Thus we may use both complexes to compute $\text{Tor}_*^P(B, B)$ and it follows that the displayed map defines a quasi-isomorphism after tensoring with $B$. It is clear that $H_n(K_\bullet \otimes_P B) = B$. On the other hand, $H_n(M_\bullet \otimes_P B)$ is the kernel of $$ B \otimes_A B \xrightarrow{g_1, \ldots, g_n} (B \otimes_A B)^{\oplus n} $$ Since $g_1, \ldots, g_n$ generate the kernel of $B \otimes_A B \to B$ this proves the lemma.
By Lemmas \ref{lemma-flat-gorenstein-agree-noether} and \ref{lemma-dualizing-syntomic-quasi-finite} the different of $f$ affine locally is the same as the Noether different. Then the lemma follows from the computation of the Noether different and the K\"ahler different on standard affine pieces done in Lemmas \ref{lemma-kahler-different-complete-intersection} and \ref{lemma-quasi-finite-complete-intersection}.
Let $J$ be the annihilator of $\Ker(B \otimes_A B \to B)$. By Lemma \ref{lemma-quasi-finite-complete-intersection} the map $A \to B$ is flat and $J$ is a free $B$-module with generator $\xi$ mapping to $\det(\partial f_i/\partial x_j)$ in $B$. Thus the lemma follows from Lemma \ref{lemma-noether-different-flat-quasi-finite} and the fact (Lemma \ref{lemma-dualizing-syntomic-quasi-finite}) that $\omega_{B/A}$ is an invertible $B$-module. (Warning: it is necessary to prove $\omega_{B/A}$ is invertible because a finite $B$-module $M$ such that $\Hom_B(M, B) \cong B$ need not be free.)