hcju/stacksqa huggingface dataset:
Choose the presentation $R \to R[x] \to R[x]/(fx - 1) = R_f$ and observe that $fx - 1$ is a nonzerodivisor in $R[x]$. Thus we can apply using Lemma \ref{lemma-compute-for-effective-Cartier-algebraic} to compute the functor $\varphi^!$. Details omitted; note that the shift in the definition of $\varphi^!$ and in the lemma add up to zero. \medskip\noindent In the general case note that $R' \otimes_R R' = R'$. Hence the result follows from the base change results above. Either Lemma \ref{lemma-flat-bc} or Lemma \ref{lemma-bc} will do.
(The parenthetical statement follows from More on Algebra, Lemma \ref{more-algebra-lemma-flat-finite-presentation-perfect}.) We can choose a factorization $R \to P \to A$ where $P$ is a polynomial ring in $n$ variables over $R$ and then $A$ is a perfect $P$-module, see More on Algebra, Lemma \ref{more-algebra-lemma-perfect-ring-map}. Recall that $\varphi^!(K) = R\Hom(A, K \otimes_R^\mathbf{L} P[n])$. Thus the result follows from Lemma \ref{lemma-RHom-is-tensor-special} and More on Algebra, Lemma \ref{more-algebra-lemma-double-base-change}.
Observe that $\omega_B^\bullet$ is a dualizing complex for $B$ by Lemma \ref{lemma-shriek-dualizing-algebraic}. Let $A \to B \to C$ be finite type homomorphisms of Noetherian rings. If the lemma holds for $A \to B$ and $B \to C$, then the lemma holds for $A \to C$. This follows from Lemma \ref{lemma-composition-shriek-algebraic} and the fact that $D_B \circ D_B \cong \text{id}$ by Lemma \ref{lemma-dualizing}. Thus it suffices to prove the lemma in case $A \to B$ is a surjection and in the case where $B$ is a polynomial ring over $A$. \medskip\noindent Assume $B = A[x_1, \ldots, x_n]$. Since $D_A \circ D_A \cong \text{id}$, it suffices to prove $D_B(K \otimes_A B) \cong D_A(K) \otimes_A B[n]$ for $K$ in $D_{\textit{Coh}}(A)$. Choose a bounded complex $I^\bullet$ of injectives representing $\omega_A^\bullet$. Choose a quasi-isomorphism $I^\bullet \otimes_A B \to J^\bullet$ where $J^\bullet$ is a bounded complex of $B$-modules. Given a complex $K^\bullet$ of $A$-modules, consider the obvious map of complexes $$ \Hom^\bullet(K^\bullet, I^\bullet) \otimes_A B[n] \longrightarrow \Hom^\bullet(K^\bullet \otimes_A B, J^\bullet[n]) $$ The left hand side represents $D_A(K) \otimes_A B[n]$ and the right hand side represents $D_B(K \otimes_A B)$. Thus it suffices to prove this map is a quasi-isomorphism if the cohomology modules of $K^\bullet$ are finite $A$-modules. Observe that the cohomology of the complex in degree $r$ (on either side) only depends on finitely many of the $K^i$. Thus we may replace $K^\bullet$ by a truncation, i.e., we may assume $K^\bullet$ represents an object of $D^-_{\textit{Coh}}(A)$. Then $K^\bullet$ is quasi-isomorphic to a bounded above complex of finite free $A$-modules. Therefore we may assume $K^\bullet$ is a bounded above complex of finite free $A$-modules. In this case it is easy to that the displayed map is an isomorphism of complexes which finishes the proof in this case. \medskip\noindent Assume that $A \to B$ is surjective. Denote $i_* : D(B) \to D(A)$ the restriction functor and recall that $\varphi^!(-) = R\Hom(A, -)$ is a right adjoint to $i_*$ (Lemma \ref{lemma-right-adjoint}). For $F \in D(B)$ we have \begin{align*} \Hom_B(F, D_B(D_A(K) \otimes_A^\mathbf{L} B)) & = \Hom_B((D_A(K) \otimes_A^\mathbf{L} B) \otimes_B^\mathbf{L} F, \omega_B^\bullet) \\ & = \Hom_A(D_A(K) \otimes_A^\mathbf{L} i_*F, \omega_A^\bullet) \\ & = \Hom_A(i_*F, D_A(D_A(K))) \\ & = \Hom_A(i_*F, K) \\ & = \Hom_B(F, \varphi^!(K)) \end{align*} The first equality follows from More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom} and the definition of $D_B$. The second equality by the adjointness mentioned above and the equality $i_*((D_A(K) \otimes_A^\mathbf{L} B) \otimes_B^\mathbf{L} F) = D_A(K) \otimes_A^\mathbf{L} i_*F$ (More on Algebra, Lemma \ref{more-algebra-lemma-derived-base-change}). The third equality follows from More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom}. The fourth because $D_A \circ D_A = \text{id}$. The final equality by adjointness again. Thus the result holds by the Yoneda lemma.
Choose $R \to P \to A$ as in the definition of $\varphi^!$. Recall that $R \to A$ is a perfect ring map (More on Algebra, Lemma \ref{more-algebra-lemma-flat-finite-presentation-perfect}) and hence $A$ is perfect as a $P$-modue (More on Algebra, Lemma \ref{more-algebra-lemma-perfect-ring-map}). This shows that $\omega_{A/R}^\bullet$ is in $D^b_{\textit{Coh}}(A)$ by Lemma \ref{lemma-shriek-boundedness}. To show $\omega_{A/R}^\bullet$ is $R$-perfect it suffices to show it has finite tor dimension as a complex of $R$-modules. This is true because $\omega_{A/R}^\bullet = \varphi^!(R) = R\Hom(A, P)[n]$ maps to $R\Hom_P(A, P)[n]$ in $D(P)$, which is perfect in $D(P)$ (More on Algebra, Lemma \ref{more-algebra-lemma-dual-perfect-complex}), hence has finite tor dimension in $D(R)$ as $R \to P$ is flat. This proves (1). \medskip\noindent Proof of (2). The object $R\Hom_A(\omega_{A/R}^\bullet, \omega_{A/R}^\bullet)$ of $D(A)$ maps in $D(P)$ to \begin{align*} R\Hom_P(\omega_{A/R}^\bullet, R\Hom(A, P)[n]) & = R\Hom_P(R\Hom_P(A, P)[n], P)[n] \\ & = R\Hom_P(R\Hom_P(A, P), P) \end{align*} This is equal to $A$ by the already used More on Algebra, Lemma \ref{more-algebra-lemma-dual-perfect-complex}. \medskip\noindent Proof of (3). By Lemma \ref{lemma-base-change-relative-algebraic} there is an isomorphism $$ \omega_{A/R}^\bullet \otimes_A^\mathbf{L} (A \otimes_R k) \cong \omega^\bullet_{A \otimes_R k/k} $$ and the right hand side is a dualizing complex by Lemma \ref{lemma-shriek-dualizing-algebraic}.
By the uniqueness of dualizing complexes, it doesn't matter which dualizing complex we pick for $A$; we omit the detailed proof. Denote $\varphi : k \to A$ the algebra structure. We may take $\omega_A^\bullet = \varphi^!(k[0])$ by Lemma \ref{lemma-shriek-dualizing-algebraic}. We conclude by Lemma \ref{lemma-relative-dualizing-algebraic}.
Recall that a local complete intersection homomorphism is a perfect ring map by More on Algebra, Lemma \ref{more-algebra-lemma-lci-perfect}. Hence the final statement holds by Lemma \ref{lemma-upper-shriek-is-tensor-functor}. By More on Algebra, Definition \ref{more-algebra-definition-local-complete-intersection} we can write $A = R[x_1, \ldots, x_n]/I$ where $I$ is a Koszul-regular ideal. The construction of $\varphi^!$ in Section \ref{section-relative-dualizing-complex-algebraic} shows that it suffices to show the lemma in case $A = R/I$ where $I \subset R$ is a Koszul-regular ideal. Checking $\omega_{A/R}^\bullet$ is invertible in $D(A)$ is local on $\Spec(A)$ by More on Algebra, Lemma \ref{more-algebra-lemma-invertible-derived}. Moreover, formation of $\omega_{A/R}^\bullet$ commutes with localization on $R$ by Lemma \ref{lemma-flat-bc}. Combining More on Algebra, Definition \ref{more-algebra-definition-regular-ideal} and Lemma \ref{more-algebra-lemma-noetherian-finite-all-equivalent} and Algebra, Lemma \ref{algebra-lemma-regular-sequence-in-neighbourhood} we can find $g_1, \ldots, g_r \in R$ generating the unit ideal in $A$ such that $I_{g_j} \subset R_{g_j}$ is generated by a regular sequence. Thus we may assume $A = R/(f_1, \ldots, f_c)$ where $f_1, \ldots, f_c$ is a regular sequence in $R$. Then we consider the ring maps $$ R \to R/(f_1) \to R/(f_1, f_2) \to \ldots \to R/(f_1, \ldots, f_c) = A $$ and we use Lemma \ref{lemma-composition-shriek-algebraic} (and the final statement already proven) to see that it suffices to prove the lemma for each step. Finally, in case $A = R/(f)$ for some nonzerodivisor $f$ we see that the lemma is true since $\varphi^!(R) = R\Hom(A, R)$ is invertible by Lemma \ref{lemma-compute-for-effective-Cartier-algebraic}.
If (2) holds, then the fibre rings $A \otimes_R \kappa(\mathfrak p)$ have invertible dualizing complexes, and hence are Gorenstein. See Lemmas \ref{lemma-relative-dualizing-algebraic} and \ref{lemma-gorenstein}. \medskip\noindent For the converse, assume (1). Observe that $\omega_{A/R}^\bullet$ is in $D^b_{\textit{Coh}}(A)$ by Lemma \ref{lemma-shriek-boundedness} (since flat finite type homomorphisms of Noetherian rings are perfect, see  More on Algebra, Lemma \ref{more-algebra-lemma-flat-finite-presentation-perfect}). Take a prime $\mathfrak q \subset A$ lying over $\mathfrak p \subset R$. Then $$ \omega_{A/R}^\bullet \otimes_A^\mathbf{L} \kappa(\mathfrak q) = \omega_{A/R}^\bullet \otimes_A^\mathbf{L} (A \otimes_R \kappa(\mathfrak p)) \otimes_{(A \otimes_R \kappa(\mathfrak p))}^\mathbf{L} \kappa(\mathfrak q) $$ Applying Lemmas \ref{lemma-relative-dualizing-algebraic} and \ref{lemma-gorenstein} and assumption (1) we find that this complex has $1$ nonzero cohomology group which is a $1$-dimensional $\kappa(\mathfrak q)$-vector space. By More on Algebra, Lemma \ref{more-algebra-lemma-lift-bounded-pseudo-coherent-to-perfect} we conclude that $(\omega_{A/R}^\bullet)_f$ is an invertible object of $D(A_f)$ for some $f \in A$, $f \not \in \mathfrak q$. This proves (2) holds.
We already know that $\varphi^!(\omega_R^\bullet)$ is a dualizing complex for $A$, see Lemma \ref{lemma-shriek-dualizing-algebraic}. Choose a factorization $R \to P \to A$ with $P = R[x_1, \ldots, x_n]$ as in the construction of $\varphi^!$. If we can prove the lemma for $R \to P$ and the maximal ideal $\mathfrak m'$ of $P$ corresponding to $\mathfrak m$, then we obtain the result for $R \to A$ by applying Lemma \ref{lemma-normalized-quotient} to $P_{\mathfrak m'} \to A_\mathfrak m$ or by applying Lemma \ref{lemma-quotient-function} to $P \to A$. In the case $A = R[x_1, \ldots, x_n]$ we see that $\dim(A_\mathfrak m) = \dim(R) + n$ for example by Algebra, Lemma \ref{algebra-lemma-dimension-base-fibre-equals-total} (combined with Algebra, Lemma \ref{algebra-lemma-dim-affine-space} to compute the dimension of the fibre). The fact that $\omega_R^\bullet$ is normalized means that $i = -\dim(R)$ is the smallest index such that $H^i(\omega_R^\bullet)$ is nonzero (follows from Lemmas \ref{lemma-sitting-in-degrees} and \ref{lemma-nonvanishing-generically-local}). Then $\varphi^!(\omega_R^\bullet)_\mathfrak m = \omega_R^\bullet \otimes_R A_\mathfrak m[n]$ has its first nonzero cohomology module in degree $-\dim(R) - n$ and therefore is the normalized dualizing complex for $A_\mathfrak m$.
Choose a factorization $R \to P \to A$ with $P = R[x_1, \ldots, x_n]$ as in Section \ref{section-relative-dualizing-complex-algebraic} so that $\omega_{A/R}^\bullet = R\Hom(A, P)[n]$. We have to show that $R\Hom(A, P)_\mathfrak q$ has vanishing cohomology in degrees $< n - d$. By Lemma \ref{lemma-RHom-ext} this means we have to show that $\Ext_P^i(P/I, P)_{\mathfrak r} = 0$ for $i < n - d$ where $\mathfrak r \subset P$ is the prime corresponding to $\mathfrak q$ and $I$ is the kernel of $P \to A$. We may rewrite this as $\Ext_{P_\mathfrak r}^i(P_\mathfrak r/IP_\mathfrak r, P_\mathfrak r)$ by More on Algebra, Lemma \ref{more-algebra-lemma-pseudo-coherence-and-base-change-ext}. Thus we have to show $$ \text{depth}_{IP_\mathfrak r}(P_\mathfrak r) \geq n - d $$ by Lemma \ref{lemma-depth}. By Lemma \ref{lemma-depth-flat-CM} we have $$ \text{depth}_{IP_\mathfrak r}(P_\mathfrak r) \geq \dim((P \otimes_R \kappa(\mathfrak p))_\mathfrak r) - \dim((P/I \otimes_R \kappa(\mathfrak p))_\mathfrak r) $$ The two expressions on the right hand side agree by Algebra, Lemma \ref{algebra-lemma-codimension}.
The lower bound has been shown in Lemma \ref{lemma-relative-dualizing-trivial-vanishing}. Choose a factorization $R \to P \to A$ with $P = R[x_1, \ldots, x_n]$ as in Section \ref{section-relative-dualizing-complex-algebraic} so that $\omega_{A/R}^\bullet = R\Hom(A, P)[n]$. The upper bound means that $\Ext^i_P(A, P)$ is zero for $i > n$. This follows from More on Algebra, Lemma \ref{more-algebra-lemma-perfect-over-polynomial-ring} which shows that $A$ is a perfect $P$-module with tor amplitude in $[-n, 0]$. \medskip\noindent Proof of the final statement. Let $R \to R'$ be a ring homomorphism of Noetherian rings. Set $A' = A \otimes_R R'$. Then $$ \omega_{A'/R'}^\bullet = \omega_{A/R}^\bullet \otimes_A^\mathbf{L} A' = \omega_{A/R}^\bullet \otimes_R^\mathbf{L} R' $$ The first isomorphism by Lemma \ref{lemma-base-change-relative-algebraic} and the second, which takes place in $D(R')$, by More on Algebra, Lemma \ref{more-algebra-lemma-base-change-comparison}. By the first part of the proof (note that the fibres of $\Spec(A') \to \Spec(R')$ have dimension $\leq d$) we conclude that $\omega_{A/R}^\bullet \otimes_R^\mathbf{L} R'$ has cohomology only in degrees $[-d, 0]$. Taking $R' = R \oplus M$ to be the square zero thickening of $R$ by a finite $R$-module $M$, we see that $R\Hom(A, P) \otimes_R^\mathbf{L} M$ has cohomology only in the interval $[-d, 0]$ for any finite $R$-module $M$. Since any $R$-module is a filtered colimit of finite $R$-modules and since tensor products commute with colimits we conclude.
We may replace $R$ by $R_\mathfrak p$ by Lemma \ref{lemma-base-change-relative-algebraic}. Thus we may assume $R$ is a Cohen-Macaulay local ring and we have to show the assertions of the lemma for the $A$-modules $H^i(\omega_{A/R}^\bullet)$. \medskip\noindent Let $R^\wedge$ be the completion of $R$. The map $R \to R^\wedge$ is flat and $R^\wedge$ is Cohen-Macaulay (More on Algebra, Lemma \ref{more-algebra-lemma-completion-CM}). Observe that the minimal primes of $A \otimes_R R^\wedge$ lie over minimal primes of $A$ by the flatness of $A \to A \otimes_R R^\wedge$ (and going down for flatness, see Algebra, Lemma \ref{algebra-lemma-flat-going-down}). Thus condition (2) holds for the finite type ring map $R^\wedge \to A \otimes_R R^\wedge$ by Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-after-base-change}. Appealing to Lemma \ref{lemma-base-change-relative-algebraic} once again it suffices to prove the lemma for $R^\wedge \to A \otimes_R R^\wedge$. In this way, using Lemma \ref{lemma-ubiquity-dualizing}, we may assume $R$ is a Noetherian local Cohen-Macaulay ring which has a dualizing complex $\omega_R^\bullet$. \medskip\noindent Let $\mathfrak m \subset A$ be a maximal ideal. It suffices to show that the assertions of the lemma hold for $H^i(\omega_{A/R}^\bullet)_\mathfrak m$. If $\mathfrak m$ does not lie over the maximal ideal of $R$, then we replace $R$ by a localization to reduce to this case (small detail omitted).  \medskip\noindent We may assume $\omega_R^\bullet$ is normalized. Setting $d = \dim(R)$ we see that $\omega_R^\bullet = \omega_R[d]$ for some $R$-module $\omega_R$, see Lemma \ref{lemma-apply-CM}. Set $\omega_A^\bullet = \varphi^!(\omega_R^\bullet)$. By Lemma \ref{lemma-relative-dualizing-if-have-omega} we have $$ \omega_{A/R}^\bullet = R\Hom_A(\omega_R[d] \otimes_R^\mathbf{L} A, \omega_A^\bullet) $$ By the dimension formula we have $\dim(A_\mathfrak m) \leq d + r$, see Morphisms, Lemma \ref{morphisms-lemma-dimension-formula-general} and use that $\kappa(\mathfrak m)$ is finite over the residue field of $R$ by the Hilbert Nullstellensatz. By Lemma \ref{lemma-shriek-normalized} we see that $(\omega_A^\bullet)_\mathfrak m$ is a normalized dualizing complex for $A_\mathfrak m$. Hence $H^i((\omega_A^\bullet)_\mathfrak m)$ is nonzero only for $-d - r \leq i \leq 0$, see Lemma \ref{lemma-sitting-in-degrees}. Since $\omega_R[d] \otimes_R^\mathbf{L} A$ lives in degrees $\leq -d$ we conclude the vanishing holds. Finally, we also see that $$ H^{-r}(\omega_{A/R}^\bullet)_\mathfrak m = \Hom_A(\omega_R \otimes_R A, H^{-d - r}(\omega_A^\bullet))_\mathfrak m $$ Since $H^{-d - r}(\omega_A^\bullet)_\mathfrak m$ is $(S_2)$ by Lemma \ref{lemma-depth-dualizing-module} we find that the final statement is true by More on Algebra, Lemma \ref{more-algebra-lemma-hom-into-S2}.
Since $A \to B$ is flat we have $H^i(K) \otimes_A B = H^i(K \otimes_A^\mathbf{L} B)$. Since $K \otimes_A^\mathbf{L} B$ is in $D^b_{\textit{Coh}}(B)$ we first find that $K$ is in $D^b(A)$ and then we see that $H^i(K)$ is a finite $A$-module by Algebra, Lemma \ref{algebra-lemma-descend-properties-modules}. Let $M$ be a finite $A$-module. Then $$ R\Hom_A(M, K) \otimes_A B = R\Hom_B(M \otimes_A B, K \otimes_A^\mathbf{L} B) $$ by More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom}. Since $K \otimes_A^\mathbf{L} B$ has finite injective dimension, say injective-amplitude in $[a, b]$, we see that the right hand side has vanishing cohomology in degrees $> b$. Since $A \to B$ is faithfully flat, we find that $R\Hom_A(M, K)$ has vanishing cohomology in degrees $> b$. Thus $K$ has finite injective dimension by More on Algebra, Lemma \ref{more-algebra-lemma-injective-amplitude}. To finish the proof we have to show that the map $A \to R\Hom_A(K, K)$ is an isomorphism. For this we again use More on Algebra, Lemma \ref{more-algebra-lemma-base-change-RHom} and the fact that $B \to R\Hom_B(K \otimes_A^\mathbf{L} B, K \otimes_A^\mathbf{L} B)$ is an isomorphism.
Observe that $A \to B$ satisfies (1) if and only if $A \to B$ satisfies (2) by  More on Algebra, Lemma \ref{more-algebra-lemma-syntomic-lci}. Observe that in both (2) and (3) the relative dualzing complex $\varphi^!(A) = \omega_{B/A}^\bullet$ is an invertible object of $D(B)$, see Lemmas \ref{lemma-lci-shriek} and \ref{lemma-gorenstein-shriek}. Moreover we have $\varphi^!(K) = K \otimes_A^\mathbf{L} \omega_{B/A}^\bullet$ in both cases, see Lemma \ref{lemma-upper-shriek-is-tensor-functor} for case (3). Thus $\varphi^!(K)$ is the same as $K \otimes_A^\mathbf{L} B$ up to tensoring with an invertible object of $D(B)$. Hence $\varphi^!(K)$ is a dualizing complex for $B$ if and only if $K \otimes_A^\mathbf{L} B$ is (as being a dualizing complex is local and invariant under shifts). Thus we see that if $K$ is dualizing for $A$, then $K \otimes_A^\mathbf{L} B$ is dualizing for $B$ by Lemma \ref{lemma-shriek-dualizing-algebraic}. To descend the property, see Lemma \ref{lemma-descent}.
Write $E = \bigcup E_n$ as in Lemma \ref{lemma-union-artinian}. It suffices to show that $E_n \otimes_{A/\mathfrak m^n} B/\mathfrak n^n$ is the injective hull of $l$ over $B/\mathfrak n$. This reduces us to the case where $A$ and $B$ are Artinian local. Observe that $\text{length}_A(A) = \text{length}_B(B)$ and $\text{length}_A(E) = \text{length}_B(E \otimes_A B)$ by Algebra, Lemma \ref{algebra-lemma-pullback-module}. By Lemma \ref{lemma-finite} we have $\text{length}_A(E) = \text{length}_A(A)$ and $\text{length}_B(E') = \text{length}_B(B)$ where $E'$ is the injective hull of $l$ over $B$. We conclude $\text{length}_B(E') = \text{length}_B(E \otimes_A B)$. Observe that $$ \dim_l((E \otimes_A B)[\mathfrak n]) = \dim_l(E[\mathfrak m] \otimes_A B) = \dim_\kappa(E[\mathfrak m]) = 1 $$ where we have used flatness of $A \to B$ and $\mathfrak n = \mathfrak mB$. Thus there is an injective $B$-module map $E \otimes_A B \to E'$ by Lemma \ref{lemma-torsion-submodule-sum-injective-hulls}. By equality of lengths shown above this is an isomorphism.
\'Etale maps satisfy the assumption by Algebra, Lemma \ref{algebra-lemma-etale-at-prime}. By Lemma \ref{lemma-sum-injective-modules} and Proposition \ref{proposition-structure-injectives-noetherian} we may assume $I$ is the injective hull of $\kappa(\mathfrak p)$ for some prime $\mathfrak p \subset A$. Then $I$ is a module over $A_\mathfrak p$. It suffices to prove $I \otimes_A B = I \otimes_{A_\mathfrak p} B_\mathfrak p$ is injective as a $B_\mathfrak p$-module, see Lemma \ref{lemma-injective-flat}. Thus we may assume $(A, \mathfrak m, \kappa)$ is local Noetherian and $I = E$ is the injective hull of the residue field $\kappa$. Our assumption implies that the Noetherian ring $B/\mathfrak m B$ is a product of fields (details omitted). Thus there are finitely many prime ideals $\mathfrak m_1, \ldots, \mathfrak m_n$ in $B$ lying over $\mathfrak m$ and they are all maximal ideals. Write $E = \bigcup E_n$ as in Lemma \ref{lemma-union-artinian}. Then $E \otimes_A B = \bigcup E_n \otimes_A B$ and $E_n \otimes_A B$ is a finite $B$-module with support $\{\mathfrak m_1, \ldots, \mathfrak m_n\}$ hence decomposes as a product over the localizations at $\mathfrak m_i$. Thus $E \otimes_A B = \prod (E \otimes_A B)_{\mathfrak m_i}$. Since $(E \otimes_A B)_{\mathfrak m_i} = E \otimes_A B_{\mathfrak m_i}$ is the injective hull of the residue field of $\mathfrak m_i$ by Lemma \ref{lemma-injective-hull-goes-up} we conclude.
Let $K$ and $L$ be two relative dualizing complexes for $R \to A$. Denote $K_1 = K \otimes_A^\mathbf{L} (A \otimes_R A)$ and $L_2 = (A \otimes_R A) \otimes_A^\mathbf{L} L$ the derived base changes via the first and second coprojections $A \to A \otimes_R A$. By symmetry the assumption on $L_2$ implies that $R\Hom_{A \otimes_R A}(A, L_2)$ is isomorphic to $A$. By More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism} part (3) applied twice we have $$ A \otimes_{A \otimes_R A}^\mathbf{L} L_2 \cong R\Hom_{A \otimes_R A}(A, K_1 \otimes_{A \otimes_R A}^\mathbf{L} L_2) \cong A \otimes_{A \otimes_R A}^\mathbf{L} K_1 $$ Applying the restriction functor $D(A \otimes_R A) \to D(A)$ for either coprojection we obtain the desired result.
From Lemma \ref{lemma-relative-dualizing-algebraic} we see that $\varphi^!(R)$ is $R$-perfect. Denote $\delta : A \otimes_R A \to A$ the multiplication map and $p_1, p_2 : A \to A \otimes_R A$ the coprojections. Then $$ \varphi^!(R) \otimes_A^\mathbf{L} (A \otimes_R A) = \varphi^!(R) \otimes_{A, p_1}^\mathbf{L} (A \otimes_R A) = p_2^!(A) $$ by Lemma \ref{lemma-flat-bc}. Recall that $ R\Hom_{A \otimes_R A}(A, \varphi^!(R) \otimes_A^\mathbf{L} (A \otimes_R A)) $ is the image of $\delta^!(\varphi^!(R) \otimes_A^\mathbf{L} (A \otimes_R A))$ under the restriction map $\delta_* : D(A) \to D(A \otimes_R A)$. Use the definition of $\delta^!$ from Section \ref{section-relative-dualizing-complex-algebraic} and Lemma \ref{lemma-RHom-ext}. Since $\delta^!(p_2^!(A)) \cong A$ by Lemma \ref{lemma-composition-shriek-algebraic} we conclude.
By Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat} there exists a finite type $\mathbf{Z}$ subalgebra $R_0 \subset R$ and a flat finite type ring map $R_0 \to A_0$ such that $A = A_0 \otimes_{R_0} R$. By Lemmas \ref{lemma-uniqueness-relative-dualizing}, \ref{lemma-relative-dualizing-noetherian}, and \ref{lemma-base-change-relative-dualizing} there exists a relative dualizing complex $K_0 \in D(A_0)$ and its derived base change is $K$. This reduces us to the situation discussed in the next paragraph. \medskip\noindent Assume $R$ Noetherian and let $K$ be a relative dualizing complex for $R \to A$. Given a ring map $R \to R'$ set $A' = A \otimes_R R'$ and $K' = K \otimes_A^\mathbf{L} A'$. To finish the proof we show $R\Hom_{A'}(K', K') = A'$. By Lemma \ref{lemma-relative-dualizing-algebraic} we know this is true whenever $R'$ is Noetherian. Since a general $R'$ is a filtered colimit of Noetherian $R$-algebras, we find the result holds by More on Algebra, Lemma \ref{more-algebra-lemma-colimit-relatively-perfect}.
We will use reduction to the Noetherian case. Namely, by Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat} there exists a finite type $\mathbf{Z}$ subalgebra $R_0 \subset R$ and a flat finite type ring map $R_0 \to A_0$ such that $A = A_0 \otimes_{R_0} R$. After increasing $R_0$ and correspondingly replacing $A_0$ we may assume there is a flat finite type ring map $A_0 \to B_0$ such that $B = B_0 \otimes_{R_0} R$ (use the same lemma). If we prove the lemma for $R_0 \to A_0 \to B_0$, then the lemma follows by Lemmas \ref{lemma-uniqueness-relative-dualizing}, \ref{lemma-relative-dualizing-noetherian}, and \ref{lemma-base-change-relative-dualizing}. This reduces us to the situation discussed in the next paragraph. \medskip\noindent Assume $R$ is Noetherian and denote $\varphi : R \to A$ and $\psi : A \to B$ the given ring maps. Then $K_{A/R} \cong \varphi^!(R)$ and $K_{B/A} \cong \psi^!(A)$, see references given above. Then $$ K = K_{A/R} \otimes_A^\mathbf{L} K_{B/A} \cong \varphi^!(R) \otimes_A^\mathbf{L} \psi^!(A) \cong \psi^!(\varphi^!(R)) \cong (\psi \circ \varphi)^!(R) $$ by Lemmas \ref{lemma-upper-shriek-is-tensor-functor} and \ref{lemma-composition-shriek-algebraic}. Thus $K$ is a relative dualizing complex for $R \to B$.