hcju/stacksqa huggingface dataset:
(The parenthetical statement follows from More on Morphisms, Lemma \ref{more-morphisms-lemma-Noetherian-pseudo-coherent}.) By Lemma \ref{lemma-sheaf-with-exact-support-adjoint} the functor $R\SheafHom(\mathcal{O}_Z, -)$ is a right adjoint to $Ri_* : D(\mathcal{O}_Z) \to D(\mathcal{O}_X)$. Moreover, by Lemma \ref{lemma-sheaf-with-exact-support-quasi-coherent} and Lemma \ref{lemma-twisted-inverse-image-bounded-below} both $R\SheafHom(\mathcal{O}_Z, -)$ and $a$ map $D_\QCoh^+(\mathcal{O}_X)$ into $D_\QCoh^+(\mathcal{O}_Z)$. Hence we obtain the isomorphism by uniqueness of adjoint functors.
The statement makes sense because $\mathcal{O}_{Z'} = Lf^*\mathcal{O}_Z$ by the assumed tor independence. Since $i'_*$ is exact and faithful we see that it suffices to show the map (\ref{equation-base-change-exact-support}) is an isomorphism after applying $Ri'_*$. Since $Ri'_* \circ Lg^* = Lf^* \circ Ri_*$ by the assumed tor indepence and Derived Categories of Schemes, Lemma \ref{perfect-lemma-compare-base-change-closed-immersion} we obtain a map $$ Lf^*Ri_*R\SheafHom(\mathcal{O}_Z, K) \longrightarrow Ri'_*R\SheafHom(\mathcal{O}_{Z'}, Lf^*K) $$ whose source and target are as in the statement of the lemma by Lemma \ref{lemma-sheaf-with-exact-support-ext}. We omit the verification that this is the same map as the one constructed in Cohomology, Remark \ref{cohomology-remark-prepare-fancy-base-change}.
First proof. To prove this map is an isomorphism, we may work locally. Hence we may assume $X$, $X'$, $Z$, $Z'$ are affine, say corresponding to the rings $A$, $A'$, $B$, $B'$. Then $B$ and $A'$ are tor independent over $A$. By Lemma \ref{lemma-check-base-change-is-iso} it suffices to check that $$ R\Hom_A(B, K) \otimes_A^\mathbf{L} A' = R\Hom_{A'}(B', K \otimes_A^\mathbf{L} A') $$ in $D(A')$ for all $K \in D^+(A)$. Here we use Derived Categories of Schemes, Lemma \ref{perfect-lemma-quasi-coherence-internal-hom} and the fact that $B$, resp.\ $B'$ is pseudo-coherent as an $A$-module, resp.\ $A'$-module to compare derived hom on the level of rings and schemes. The displayed equality follows from More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism} part (3). See also the discussion in Dualizing Complexes, Section \ref{dualizing-section-base-change-trivial-duality}. \medskip\noindent Second proof\footnote{This proof shows it suffices to assume $K$ is in $D^+(\mathcal{O}_X)$.}. Let $z' \in Z'$ with image $z \in Z$. First show that (\ref{equation-base-change-exact-support}) on stalks at $z'$ induces the map $$ R\Hom(\mathcal{O}_{Z, z}, K_z) \otimes_{\mathcal{O}_{Z, x}}^\mathbf{L} \mathcal{O}_{Z', z'} \longrightarrow R\Hom(\mathcal{O}_{Z', z'}, K_z \otimes_{\mathcal{O}_{X, z}}^\mathbf{L} \mathcal{O}_{X', z'}) $$ from Dualizing Complexes, Equation (\ref{dualizing-equation-base-change}). Namely, the constructions of these maps are identical. Then apply Dualizing Complexes, Lemma \ref{dualizing-lemma-flat-bc-surjection}.
A map from LHS to RHS is the same thing as a map $$ Ri_*R\SheafHom(\mathcal{O}_Z, K) \otimes_{\mathcal{O}_X}^\mathbf{L} M \longrightarrow K \otimes_{\mathcal{O}_X}^\mathbf{L} M $$ by Lemmas \ref{lemma-sheaf-with-exact-support-adjoint} and \ref{lemma-sheaf-with-exact-support-ext}. For this map we take the counit $Ri_*R\SheafHom(\mathcal{O}_Z, K) \to K$ tensored with $\text{id}_M$. To see this map is an isomorphism under the hypotheses given, translate into algebra using Lemma \ref{lemma-sheaf-with-exact-support-quasi-coherent} and then for example use More on Algebra, Lemma \ref{more-algebra-lemma-internal-hom-evaluate-tensor-isomorphism} part (3). Instead of using Lemma \ref{lemma-sheaf-with-exact-support-quasi-coherent} you can look at stalks as in the second proof of Lemma \ref{lemma-flat-bc-sheaf-with-exact-support}.
Adjointness follows from Modules, Lemma \ref{modules-lemma-adjoint-tensor-restrict}. As $f$ is affine we see that $f_*\mathcal{O}_Y$ is the quasi-coherent sheaf corresponding to $B$ viewed as an $A$-module. Hence the description of sections over $U$ follows from Schemes, Lemma \ref{schemes-lemma-compare-constructions}.
(The parenthetical remark follows from More on Morphisms, Lemma \ref{more-morphisms-lemma-Noetherian-pseudo-coherent}.) Since $f$ is pseudo-coherent, the $\mathcal{O}_X$-module $f_*\mathcal{O}_Y$ is pseudo-coherent, see More on Morphisms, Lemma \ref{more-morphisms-lemma-finite-pseudo-coherent}. Thus $R\SheafHom(f_*\mathcal{O}_Y, -)$ maps $D_\QCoh^+(\mathcal{O}_X)$ into $D_\QCoh^+(f_*\mathcal{O}_Y)$, see Derived Categories of Schemes, Lemma \ref{perfect-lemma-quasi-coherence-internal-hom}. Then $\Phi \circ a$ and $R\SheafHom(f_*\mathcal{O}_Y, -)$ agree on $D_\QCoh^+(\mathcal{O}_X)$ because these functors are both right adjoint to the restriction functor $D_\QCoh^+(f_*\mathcal{O}_Y) \to D_\QCoh^+(\mathcal{O}_X)$. To see this use Lemmas \ref{lemma-twisted-inverse-image-bounded-below} and \ref{lemma-sheafhom-affine-adjoint}.
Let $P$ be a perfect object of $D(\mathcal{O}_X)$. By Derived Categories of Schemes, Lemma \ref{perfect-lemma-flat-proper-perfect-direct-image-general} the complex $Rf_*P$ is perfect on $Y$. Let $K_i$ be a family of objects of $D_\QCoh(\mathcal{O}_Y)$. Then \begin{align*} \Hom_{D(\mathcal{O}_X)}(P, a(\bigoplus K_i)) & = \Hom_{D(\mathcal{O}_Y)}(Rf_*P, \bigoplus K_i) \\ & = \bigoplus \Hom_{D(\mathcal{O}_Y)}(Rf_*P, K_i) \\ & = \bigoplus \Hom_{D(\mathcal{O}_X)}(P, a(K_i)) \end{align*} because a perfect object is compact (Derived Categories of Schemes, Proposition \ref{perfect-proposition-compact-is-perfect}). Since $D_\QCoh(\mathcal{O}_X)$ has a perfect generator (Derived Categories of Schemes, Theorem \ref{perfect-theorem-bondal-van-den-Bergh}) we conclude that the map $\bigoplus a(K_i) \to a(\bigoplus K_i)$ is an isomorphism, i.e., $a$ commutes with direct sums.
By Lemma \ref{lemma-proper-flat} we know that $a$ commutes with direct sums. Hence the collection of objects of $D_\QCoh(\mathcal{O}_Y)$ for which (\ref{equation-compare-with-pullback}) is an isomorphism is a strictly full, saturated, triangulated subcategory of $D_\QCoh(\mathcal{O}_Y)$ which is moreover preserved under taking direct sums. Since $D_\QCoh(\mathcal{O}_Y)$ is a module category (Derived Categories of Schemes, Theorem \ref{perfect-theorem-DQCoh-is-Ddga}) generated by a single perfect object (Derived Categories of Schemes, Theorem \ref{perfect-theorem-bondal-van-den-Bergh}) we can argue as in More on Algebra, Remark \ref{more-algebra-remark-P-resolution} to see that it suffices to prove (\ref{equation-compare-with-pullback}) is an isomorphism for a single perfect object. However, the result holds for perfect objects, see Lemma \ref{lemma-compare-with-pullback-perfect}.
By Lemma \ref{lemma-proper-flat-relative} formation of the functors $a$ and $a'$ commutes with restriction to opens of $Y$ and $Y'$. Hence we may assume $Y' \to Y$ is a morphism of affine schemes, see Remark \ref{remark-check-over-affines}. In this case the statement follows from Lemma \ref{lemma-more-base-change}.
Let $a$ be the right adjoint to $Rf_*$ as in Lemma \ref{lemma-twisted-inverse-image}. Consider the cartesian square $$ \xymatrix{ X \times_Y X \ar[r]_q \ar[d]_p & X \ar[d]_f \\ X \ar[r]^f & Y } $$ Let $b$ be the right adjoint for $p$ as in Lemma \ref{lemma-twisted-inverse-image}. Then \begin{align*} \omega_{X/Y}^\bullet & = c(b(\omega_{X/Y}^\bullet)) \\ & = c(Lp^*\omega_{X/Y}^\bullet \otimes_{\mathcal{O}_{X \times_Y X}}^\mathbf{L} b(\mathcal{O}_X)) \\ & = c(Lp^*\omega_{X/Y}^\bullet \otimes_{\mathcal{O}_{X \times_Y X}}^\mathbf{L} Lq^*a(\mathcal{O}_Y)) \\ & = c(Lp^*\omega_{X/Y}^\bullet \otimes_{\mathcal{O}_{X \times_Y X}}^\mathbf{L} Lq^*\omega_{X/Y}^\bullet) \end{align*} as in (\ref{equation-rigid}). Explanation as follows: \begin{enumerate} \item The first equality holds as $\text{id} = c \circ b$ because $\text{id}_X = p \circ \Delta$. \item The second equality holds by Lemma \ref{lemma-compare-with-pullback-flat-proper}. \item The third holds by Lemma \ref{lemma-proper-flat-base-change} and the fact that $\mathcal{O}_X = Lf^*\mathcal{O}_Y$. \item The fourth holds because $\omega_{X/Y}^\bullet = a(\mathcal{O}_Y)$. \end{enumerate} Equation (\ref{equation-pre-rigid}) is proved in exactly the same way.
Let $P$ be a perfect object of $D(\mathcal{O}_X)$. By More on Morphisms, Lemma \ref{more-morphisms-lemma-perfect-proper-perfect-direct-image} the complex $Rf_*P$ is perfect on $Y$. Let $K_i$ be a family of objects of $D_\QCoh(\mathcal{O}_Y)$. Then \begin{align*} \Hom_{D(\mathcal{O}_X)}(P, a(\bigoplus K_i)) & = \Hom_{D(\mathcal{O}_Y)}(Rf_*P, \bigoplus K_i) \\ & = \bigoplus \Hom_{D(\mathcal{O}_Y)}(Rf_*P, K_i) \\ & = \bigoplus \Hom_{D(\mathcal{O}_X)}(P, a(K_i)) \end{align*} because a perfect object is compact (Derived Categories of Schemes, Proposition \ref{perfect-proposition-compact-is-perfect}). Since $D_\QCoh(\mathcal{O}_X)$ has a perfect generator (Derived Categories of Schemes, Theorem \ref{perfect-theorem-bondal-van-den-Bergh}) we conclude that the map $\bigoplus a(K_i) \to a(\bigoplus K_i)$ is an isomorphism, i.e., $a$ commutes with direct sums.
By Lemma \ref{lemma-proper-flat-noetherian} we know that $a$ commutes with direct sums. Hence the collection of objects of $D_\QCoh(\mathcal{O}_Y)$ for which (\ref{equation-compare-with-pullback}) is an isomorphism is a strictly full, saturated, triangulated subcategory of $D_\QCoh(\mathcal{O}_Y)$ which is moreover preserved under taking direct sums. Since $D_\QCoh(\mathcal{O}_Y)$ is a module category (Derived Categories of Schemes, Theorem \ref{perfect-theorem-DQCoh-is-Ddga}) generated by a single perfect object (Derived Categories of Schemes, Theorem \ref{perfect-theorem-bondal-van-den-Bergh}) we can argue as in More on Algebra, Remark \ref{more-algebra-remark-P-resolution} to see that it suffices to prove (\ref{equation-compare-with-pullback}) is an isomorphism for a single perfect object. However, the result holds for perfect objects, see Lemma \ref{lemma-compare-with-pullback-perfect}.
By Lemma \ref{lemma-proper-flat-noetherian-relative} formation of the functors $a$ and $a'$ commutes with restriction to opens of $Y$ and $Y'$. Hence we may assume $Y' \to Y$ is a morphism of affine schemes, see Remark \ref{remark-check-over-affines}. In this case the statement follows from Lemma \ref{lemma-more-base-change}.
Equivalently, we are saying that $R\SheafHom(\mathcal{O}_D, \mathcal{O}_X)$ has a unique nonzero cohomology sheaf in degree $1$ and that this sheaf is isomorphic to $\mathcal{N}$. Since $i_*$ is exact and fully faithful, it suffices to prove that $i_*R\SheafHom(\mathcal{O}_D, \mathcal{O}_X)$ is isomorphic to $i_*\mathcal{N}[-1]$. We have $i_*R\SheafHom(\mathcal{O}_D, \mathcal{O}_X) = R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, \mathcal{O}_X)$ by Lemma \ref{lemma-sheaf-with-exact-support-ext}. We have a resolution $$ 0 \to \mathcal{I} \to \mathcal{O}_X \to i_*\mathcal{O}_D \to 0 $$ where $\mathcal{I}$ is the ideal sheaf of $D$ which we can use to compute. Since $R\SheafHom_{\mathcal{O}_X}(\mathcal{O}_X, \mathcal{O}_X) = \mathcal{O}_X$ and $R\SheafHom_{\mathcal{O}_X}(\mathcal{I}, \mathcal{O}_X) = \mathcal{O}_X(D)$ by a local computation, we see that $$ R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, \mathcal{O}_X) = (\mathcal{O}_X \to \mathcal{O}_X(D)) $$ where on the right hand side we have $\mathcal{O}_X$ in degree $0$ and $\mathcal{O}_X(D)$ in degree $1$. The result follows from the short exact sequence $$ 0 \to \mathcal{O}_X \to \mathcal{O}_X(D) \to i_*\mathcal{N} \to 0 $$ coming from the fact that $D$ is the zero scheme of the canonical section of $\mathcal{O}_X(D)$ and from the fact that $\mathcal{N} = i^*\mathcal{O}_X(D)$.
Since $i_*$ is exact and fully faithful on modules, to prove the map is an isomorphism, it suffices to show that it is an isomorphism after applying $i_*$. We will use the short exact sequences $0 \to \mathcal{I} \to \mathcal{O}_X \to i_*\mathcal{O}_D \to 0$ and $0 \to \mathcal{O}_X \to \mathcal{O}_X(D) \to i_*\mathcal{N} \to 0$ used in the proof of Lemma \ref{lemma-compute-for-effective-Cartier} without further mention. By Cohomology, Lemma \ref{cohomology-lemma-projection-formula-closed-immersion} which was used to define the map (\ref{equation-map-effective-Cartier}) the left hand side becomes $$ K \otimes_{\mathcal{O}_X}^\mathbf{L} i_*\mathcal{N}[-1] = K \otimes_{\mathcal{O}_X}^\mathbf{L} (\mathcal{O}_X \to \mathcal{O}_X(D)) $$ The right hand side becomes \begin{align*} R\SheafHom_{\mathcal{O}_X}(i_*\mathcal{O}_D, K) & = R\SheafHom_{\mathcal{O}_X}((\mathcal{I} \to \mathcal{O}_X), K) \\ & = R\SheafHom_{\mathcal{O}_X}((\mathcal{I} \to \mathcal{O}_X), \mathcal{O}_X) \otimes_{\mathcal{O}_X}^\mathbf{L} K \end{align*} the final equality by Cohomology, Lemma \ref{cohomology-lemma-dual-perfect-complex}. Since the map comes from the isomorphism $$ R\SheafHom_{\mathcal{O}_X}((\mathcal{I} \to \mathcal{O}_X), \mathcal{O}_X) = (\mathcal{O}_X \to \mathcal{O}_X(D)) $$ the lemma is clear.
In (the proof of) Cohomology of Schemes, Lemma \ref{coherent-lemma-cohomology-projective-bundle} we constructed a canonical isomorphism $$ R^nf_*(f^*\mathcal{L}(-n - 1)) \longrightarrow \mathcal{O}_Y $$ Moreover, $Rf_*(f^*\mathcal{L}(-n - 1))[n] = R^nf_*(f^*\mathcal{L}(-n - 1))$, i.e., the other higher direct images are zero. Thus we find an isomorphism $$ Rf_*(f^*\mathcal{L}(-n - 1)[n]) \longrightarrow \mathcal{O}_Y $$ This isomorphism determines $c$ as in the statement of the lemma because $a$ is the right adjoint of $Rf_*$. By Lemma \ref{lemma-proper-noetherian} construction of the $a$ is local on the base. In particular, to check that $c$ is an isomorphism, we may work locally on $Y$. In other words, we may assume $Y$ is affine and $\mathcal{E} = \mathcal{O}_Y^{\oplus n + 1}$. In this case the sheaves $\mathcal{O}_X, \mathcal{O}_X(-1), \ldots, \mathcal{O}_X(-n)$ generate $D_\QCoh(X)$, see Derived Categories of Schemes, Lemma \ref{perfect-lemma-generator-P1}. Hence it suffices to show that $c : \mathcal{O}_X(-n - 1)[n] \to a(\mathcal{O}_Y)$ is transformed into an isomorphism under the functors $$ F_{i, p}(-) = \Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X(i), (-)[p]) $$ for $i \in \{-n, \ldots, 0\}$ and $p \in \mathbf{Z}$. For $F_{0, p}$ this holds by construction of the arrow $c$! For $i \in \{-n, \ldots, -1\}$ we have $$ \Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X(i), \mathcal{O}_X(-n - 1)[n + p]) = H^p(X, \mathcal{O}_X(-n - 1 - i)) = 0 $$ by the computation of cohomology of projective space (Cohomology of Schemes, Lemma \ref{coherent-lemma-cohomology-projective-space-over-ring}) and we have $$ \Hom_{D(\mathcal{O}_X)}(\mathcal{O}_X(i), a(\mathcal{O}_Y)[p]) = \Hom_{D(\mathcal{O}_Y)}(Rf_*\mathcal{O}_X(i), \mathcal{O}_Y[p]) = 0 $$ because $Rf_*\mathcal{O}_X(i) = 0$ by the same lemma. Hence the source and the target of $F_{i, p}(c)$ vanish and $F_{i, p}(c)$ is necessarily an isomorphism. This finishes the proof.
Consider the canonical short exact sequence \begin{equation} \label{equation-second-order-thickening} 0 \to \mathcal{I}/\mathcal{I}^2 \to \mathcal{O}_Y/\mathcal{I}^2 \to \mathcal{O}_X \to 0 \end{equation} Let $U \subset X$ be open and let $s \in \mathcal{N}(U)$. Then we can pushout (\ref{equation-second-order-thickening}) via $s$ to get an extension $E_s$ of $\mathcal{O}_X|_U$ by $\mathcal{O}_X|_U$. This in turn defines a section $c(s)$ of $\SheafExt^1_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)$ over $U$. See Cohomology, Lemma \ref{cohomology-lemma-section-RHom-over-U} and Derived Categories, Lemma \ref{derived-lemma-ext-1}. Conversely, given an extension $$ 0 \to \mathcal{O}_X|_U \to \mathcal{E} \to \mathcal{O}_X|_U \to 0 $$ of $\mathcal{O}_U$-modules, we can find an open covering $U = \bigcup U_i$ and sections $e_i \in \mathcal{E}(U_i)$ mapping to $1 \in \mathcal{O}_X(U_i)$. Then $e_i$ defines a map $\mathcal{O}_Y|_{U_i} \to \mathcal{E}|_{U_i}$ whose kernel contains $\mathcal{I}^2$. In this way we see that $\mathcal{E}|_{U_i}$ comes from a pushout as above. This shows that $c$ is surjective. We omit the proof of injectivity.
We can use Lemmas \ref{lemma-ext} and \ref{lemma-regular-ideal-ext} to see that we have isomorphisms $\wedge^i\mathcal{N} \to \SheafExt^i_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X)$ for $i \geq 0$. Thus it suffices to show that the map $\mathcal{O}_Y \to \mathcal{O}_X$ induces an isomorphism $$ \SheafExt^r_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_Y) \longrightarrow \SheafExt^r_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_X) $$ and that $\SheafExt^i_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_Y)$ is zero for $i \not = r$. These statements are local on $Y$. Thus we may assume that we have global sections $f_1, \ldots, f_r$ of $\mathcal{O}_Y$ which generate $\mathcal{I}$ and which form a Koszul regular sequence. Let $\mathcal{A}^\bullet$ be the Koszul complex on $f_1, \ldots, f_r$ as introduced in the proof of Lemma \ref{lemma-regular-ideal-ext}. Then $$ R\SheafHom_{\mathcal{O}_Y}(\mathcal{O}_X, \mathcal{O}_Y) = \SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y) $$ by Cohomology, Lemma \ref{cohomology-lemma-Rhom-strictly-perfect}. Denote $1 \in H^0(\SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y))$ the identity map of $\mathcal{A}^0 = \mathcal{O}_Y \to \mathcal{O}_Y$. With $\delta_j$ as in the proof of Lemma \ref{lemma-regular-ideal-ext} we get an isomorphism of graded $\mathcal{O}_Y$-modules $$ \mathcal{O}_Y\langle \delta_1, \ldots, \delta_r\rangle \longrightarrow \SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y) $$ by mapping $\delta_{j_1} \ldots \delta_{j_i}$ to $1 \circ \delta_{j_1} \circ \ldots \circ \delta_{j_i}$ in degree $i$. Via this isomorphism the differential on the right hand side induces a differential $\text{d}$ on the left hand side. By our sign rules we have $\text{d}(1) = - \sum f_j \delta_j$. Since $\delta_j : \mathcal{A}^\bullet \to \mathcal{A}^\bullet[1]$ is a morphism of complexes, it follows that $$ \text{d}(\delta_{j_1} \ldots \delta_{j_i}) = (- \sum f_j \delta_j )\delta_{j_1} \ldots \delta_{j_i} $$ Observe that we have $\text{d} = \sum f_j \delta_j$ on the differential graded algebra $\mathcal{A}$. Therefore the map defined by the rule $$ 1 \circ \delta_{j_1} \ldots \delta_{j_i} \longmapsto (\delta_{j_1} \circ \ldots \circ \delta_{j_i})(\xi_1 \ldots \xi_r) $$ will define an isomorphism of complexes $$ \SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y) \longrightarrow \mathcal{A}^\bullet[-r] $$ if $r$ is odd and commuting with differentials up to sign if $r$ is even. In any case these complexes have isomorphic cohomology, which shows the desired vanishing. The isomorphism on cohomology in degree $r$ under the map $$ \SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_Y) \longrightarrow \SheafHom^\bullet(\mathcal{A}^\bullet, \mathcal{O}_X) $$ also follows in a straightforward manner from this. (We observe that our choice of conventions regarding Koszul complexes does intervene in the definition of the isomorphism $R\SheafHom_{\mathcal{O}_X}(\mathcal{O}_X, \mathcal{O}_Y) = \wedge^r \mathcal{N}[r]$.)
Recall, from Lemmas \ref{lemma-twisted-inverse-image-closed} and \ref{lemma-sheaf-with-exact-support-ext}, that $a(\mathcal{O}_Y)$ is an object of $D_\QCoh(\mathcal{O}_X)$ whose pushforward to $Y$ is $R\SheafHom_{\mathcal{O}_Y}(i_*\mathcal{O}_X, \mathcal{O}_Y)$. Thus the result follows from Lemma \ref{lemma-regular-immersion-ext}.
Set $\omega_{X/S}^\bullet = a(\mathcal{O}_S)$ as in Remark \ref{remark-relative-dualizing-complex}. Let $c$ be the right adjoint of Lemma \ref{lemma-twisted-inverse-image} for $\Delta : X \to X \times_S X$. Because $\Delta$ is the diagonal of a smooth morphism it is a Koszul-regular immersion, see Divisors, Lemma \ref{divisors-lemma-immersion-smooth-into-smooth-regular-immersion}. In particular, $\Delta$ is a perfect proper morphism (More on Morphisms, Lemma \ref{more-morphisms-lemma-regular-immersion-perfect}) and we obtain \begin{align*} \mathcal{O}_X & = c(L\text{pr}_1^*\omega_{X/S}^\bullet) \\ & = L\Delta^*(L\text{pr}_1^*\omega_{X/S}^\bullet) \otimes_{\mathcal{O}_X}^\mathbf{L} c(\mathcal{O}_{X \times_S X}) \\ & = \omega_{X/S}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} c(\mathcal{O}_{X \times_S X}) \\ & = \omega_{X/S}^\bullet \otimes_{\mathcal{O}_X}^\mathbf{L} \wedge^d(\mathcal{N}_\Delta)[-d] \end{align*} The first equality is (\ref{equation-pre-rigid}) because $\omega_{X/S}^\bullet = a(\mathcal{O}_S)$. The second equality by Lemma \ref{lemma-compare-with-pullback-flat-proper-noetherian}. The third equality because $p \circ \Delta = \text{id}_X$. The fourth equality by Lemma \ref{lemma-regular-immersion}. Observe that $\wedge^d(\mathcal{N}_\Delta)$ is an invertible $\mathcal{O}_X$-module. Hence $\wedge^d(\mathcal{N}_\Delta)[-d]$ is an invertible object of $D(\mathcal{O}_X)$ and we conclude that $a(\mathcal{O}_S) = \omega_{X/S}^\bullet = \wedge^d(\mathcal{C}_\Delta)[d]$. Since the conormal sheaf $\mathcal{C}_\Delta$ of $\Delta$ is $\Omega_{X/S}$ by Morphisms, Lemma \ref{morphisms-lemma-differentials-diagonal} the proof is complete.
To show this we have to prove given morphisms $f : X \to Y$, $g : Y \to Z$, $h : Z \to T$ that $$ \xymatrix{ (h \circ g \circ f)^! \ar[r]_{\gamma_{A + B}} \ar[d]_{\gamma_{B + C}} & f^! \circ (h \circ g)^! \ar[d]^{\gamma_C} \\ (g \circ f)^! \circ h^! \ar[r]^{\gamma_A} & f^! \circ g^! \circ h^! } $$ is commutative (for the meaning of the $\gamma$'s, see below). To do this we choose a compactification $\overline{Z}$ of $Z$ over $T$, then a compactification $\overline{Y}$ of $Y$ over $\overline{Z}$, and then a compactification $\overline{X}$ of $X$ over $\overline{Y}$. This uses More on Flatness, Theorem \ref{flat-theorem-nagata} and Lemma \ref{flat-lemma-compactifyable}. Let $W \subset \overline{Y}$ be the inverse image of $Z$ under $\overline{Y} \to \overline{Z}$ and let $U \subset V \subset \overline{X}$ be the inverse images of $Y \subset W$ under $\overline{X} \to \overline{Y}$. This produces the following diagram $$ \xymatrix{ X \ar[d]_f \ar[r] & U \ar[r] \ar[d] \ar@{}[dr]|A & V \ar[d] \ar[r] \ar@{}[rd]|B & \overline{X} \ar[d] \\ Y \ar[d]_g \ar[r] & Y \ar[r] \ar[d] & W \ar[r] \ar[d] \ar@{}[rd]|C & \overline{Y} \ar[d] \\ Z \ar[d]_h \ar[r] & Z \ar[d] \ar[r] & Z \ar[d] \ar[r] & \overline{Z} \ar[d] \\ T \ar[r] & T \ar[r] & T \ar[r] & T } $$ Without introducing tons of notation but arguing exactly as in the proof of Lemma \ref{lemma-upper-shriek-composition} we see that the maps in the first displayed diagram use the maps (\ref{equation-sheafy}) for the rectangles $A + B$, $B + C$, $A$, and $C$ as indicated. Since by Lemmas \ref{lemma-compose-base-change-maps} and \ref{lemma-compose-base-change-maps-horizontal} we have $\gamma_{A + B} = \gamma_A \circ \gamma_B$ and $\gamma_{B + C} = \gamma_C \circ \gamma_B$  we conclude that the desired equality holds provided $\gamma_A \circ \gamma_C = \gamma_C \circ \gamma_A$. This is true because the two squares $A$ and $C$ only intersect in one point (similar to the last argument in Remark \ref{remark-going-around}).
Let $h = f \circ j = j' \circ g$. By Lemma \ref{lemma-upper-shriek-composition} we have $h^! = j^! \circ f^! = g^! \circ (j')^!$. By Lemma \ref{lemma-shriek-open-immersion} we have $j^! = j^*$ and $(j')^! = (j')^*$.
Since $X = \mathbf{A}^1_Y \subset \mathbf{P}^1_Y$ and since $\mathcal{O}_{\mathbf{P}^1_Y}(-2)|_X \cong \mathcal{O}_X$ this follows from Lemmas \ref{lemma-upper-shriek-P1} and \ref{lemma-compare-with-pullback-flat-proper-noetherian}.
The question is local on $X$ hence we may assume that $X$ and $Y$ are affine schemes. In this case we can factor $f : X \to Y$ as $$ X \xrightarrow{i} \mathbf{A}^n_Y \to \mathbf{A}^{n - 1}_Y \to \ldots \to \mathbf{A}^1_Y \to Y $$ where $i$ is a closed immersion. The lemma follows from By Lemmas \ref{lemma-shriek-affine-line} and \ref{lemma-sheaf-with-exact-support-coherent} and Dualizing Complexes, Lemma \ref{dualizing-lemma-dualizing-polynomial-ring} and induction.