As $B$ is essentially of finite type over $A$, so is $B \otimes_A B$ and in particular $B \otimes_A B$ is Noetherian. Hence the quotient $B$ of $B \otimes_A B$ is pseudo-coherent over $B \otimes_A B$ (More on Algebra, Lemma \ref{more-algebra-lemma-Noetherian-pseudo-coherent}) which explains why perfectness of the ring map (More on Algebra, Definition \ref{more-algebra-definition-pseudo-coherent-perfect}) agrees with the condition of finite tor dimension. \medskip\noindent We may write $B = R/K$ where $R$ is the localization of $A[x_1, \ldots, x_n]$ at a prime ideal and $K \subset R$ is an ideal. Denote $\mathfrak m \subset R \otimes_A R$ the maximal ideal which is the inverse image of the maximal ideal of $B$ via the surjection $R \otimes_A R \to B \otimes_A B \to B$. Then we have surjections $$ (R \otimes_A R)_\mathfrak m \to (B \otimes_A B)_\mathfrak m \to B $$ and hence ideals $I \subset J \subset (R \otimes_A R)_\mathfrak m$ as in Lemma \ref{lemma-injective}. We conclude that $I/\mathfrak m I \to J/\mathfrak m J$ is injective. \medskip\noindent Let $K = (f_1, \ldots, f_r)$ with $r$ minimal. We may and do assume that $f_i \in R$ is the image of an element of $A[x_1, \ldots, x_n]$ which we also denote $f_i$. Observe that $I$ is generated by $f_1 \otimes 1, \ldots, f_r \otimes 1$ and $1 \otimes f_1, \ldots, 1 \otimes f_r$. We claim that this is a minimal set of generators of $I$. Namely, if $\kappa$ is the common residue field of $R$, $B$, $(R \otimes_A R)_\mathfrak m$, and $(B \otimes_A B)_\mathfrak m$ then we have a map $R \otimes_A R \to R \otimes_A \kappa \oplus \kappa \otimes_A R$ which factors through $(R \otimes_A R)_\mathfrak m$. Since $B$ is flat over $A$ and since we have the short exact sequence $0 \to K \to R \to B \to 0$ we see that $K \otimes_A \kappa \subset R \otimes_A \kappa$, see Algebra, Lemma \ref{algebra-lemma-flat-tor-zero}. Thus restricting the map $(R \otimes_A R)_\mathfrak m \to R \otimes_A \kappa \oplus \kappa \otimes_A R$ to $I$ we obtain a map $$ I \to K \otimes_A \kappa \oplus \kappa \otimes_A K \to K \otimes_B \kappa \oplus \kappa \otimes_B K. $$ The elements $f_1 \otimes 1, \ldots, f_r \otimes 1, 1 \otimes f_1, \ldots, 1 \otimes f_r$ map to a basis of the target of this map, since by Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK}) $f_1, \ldots, f_r$ map to a basis of $K \otimes_B \kappa$. This proves our claim. \medskip\noindent The ideal $J$ is generated by $f_1 \otimes 1, \ldots, f_r \otimes 1$ and the elements $x_1 \otimes 1 - 1 \otimes x_1, \ldots, x_n \otimes 1 - 1 \otimes x_n$ (for the proof it suffices to see that these elements are contained in the ideal $J$). Now we can write $$ f_i \otimes 1 - 1 \otimes f_i = \sum g_{ij} (x_j \otimes 1 - 1 \otimes x_j) $$ for some $g_{ij}$ in $(R \otimes_A R)_\mathfrak m$. This is a general fact about elements of $A[x_1, \ldots, x_n]$ whose proof we omit. Denote $a_{ij} \in \kappa$ the image of $g_{ij}$. Another computation shows that $a_{ij}$ is the image of $\partial f_i / \partial x_j$ in $\kappa$. The injectivity of $I/\mathfrak m I \to J/\mathfrak m J$ and the remarks made above forces the matrix $(a_{ij})$ to have maximal rank $r$. Set $$ C = A[x_1, \ldots, x_n]/(f_1, \ldots, f_r) $$ and consider the naive cotangent complex $\NL_{C/A} \cong (C^{\oplus r} \to C^{\oplus n})$ where the map is given by the matrix of partial derivatives. Thus $\NL_{C/A} \otimes_A B$ is isomorphic to a free $B$-module of rank $n - r$ placed in degree $0$. Hence $C_g$ is smooth over $A$ for some $g \in C$ mapping to a unit in $B$, see Algebra, Lemma \ref{algebra-lemma-smooth-at-point}. This finishes the proof.