hcju/stacksqa huggingface dataset:
Affineness is Lemma \ref{lemma-complement-locally-principal-closed-subscheme}. The density question is local on $S$, see Morphisms, Lemma \ref{morphisms-lemma-characterize-scheme-theoretically-dense}. Thus we may assume $S = \Spec(A)$ and $D$ corresponding to the nonzerodivisor $f \in A$, see Lemma \ref{lemma-characterize-effective-Cartier-divisor}. Thus $A \subset A_f$ which implies that $U \subset S$ is scheme theoretically dense, see Morphisms, Example \ref{morphisms-example-scheme-theoretic-closure}.
Assume $\dim_s(S) < \infty$. Let $U = \Spec(A) \subset S$ be an affine open neighbourhood of $s$ such that $\dim(U) = \dim_s(S)$ and such that $D = V(f)$ for some nonzerodivisor $f \in A$ (see Lemma \ref{lemma-characterize-effective-Cartier-divisor}). Recall that $\dim(U)$ is the Krull dimension of the ring $A$ and that $\dim(U \cap D)$ is the Krull dimension of the ring $A/(f)$. Then $f$ is not contained in any minimal prime of $A$. Hence any maximal chain of primes in $A/(f)$, viewed as a chain of primes in $A$, can be extended by adding a minimal prime.
See Morphisms, Definition \ref{morphisms-definition-scheme-theoretic-intersection-union} for the definition of scheme theoretic intersection and union. To prove the lemma working locally (using Lemma \ref{lemma-characterize-effective-Cartier-divisor}) we obtain the following algebra problem: Given a ring $A$ and nonzerodivisors $f_1, f_2 \in A$ such that $f_1$ maps to a nonzerodivisor in $A/f_2A$, show that $f_1A \cap f_2A = f_1f_2A$. We omit the straightforward argument.
The question is local on $X$, and hence we reduce to the case where $X = \Spec(A)$, $Y = \Spec(R)$, $f$ is given by $\varphi : R \to A$ and $D = \Spec(R/(t))$ where $t \in R$ is a nonzerodivisor. The goal in each case is to show that $\varphi(t) \in A$ is a nonzerodivisor. \medskip\noindent In case (1) this follows from Algebra, Lemma \ref{algebra-lemma-weakly-ass-zero-divisors}. Case (4) is a special case of (1) by Lemma \ref{lemma-ass-weakly-ass}. Case (5) follows from (4) and the definitions. Case (3) is a special case of (1) by Lemma \ref{lemma-weakass-reduced}. Case (2) is a special case of (3). If $R \to A$ is flat, then $t : R \to R$ being injective shows that $t : A \to A$ is injective. This proves (6).
In the statement of the lemma and in the proof we use the equivalence of Morphisms, Lemma \ref{morphisms-lemma-i-star-equivalence} to think of quasi-coherent modules on closed subschemes of $X$ as quasi-coherent modules on $X$. Let $\mathcal{I}$ be the ideal sheaf of $D$ in $D'$. Then there is a short exact sequence $$ 0 \to \mathcal{I} \to \mathcal{O}_{D'} \to \mathcal{O}_D \to 0 $$ because $D \to D'$ is a closed immersion. There is a canonical surjection $\mathcal{I} \to \mathcal{I}/\mathcal{I}^2 = \mathcal{C}_{D/D'}$. We have $\mathcal{C}_{D/X} = \mathcal{O}_X(-D)|_D$ by Lemma \ref{lemma-conormal-effective-Cartier-divisor} and there is a canonical surjective map $$ \mathcal{C}_{D/X} \longrightarrow \mathcal{C}_{D/D'} $$ see Morphisms, Lemmas \ref{morphisms-lemma-conormal-functorial} and \ref{morphisms-lemma-conormal-functorial-flat}. Thus it suffices to show: (a) $\mathcal{I}^2 = 0$ and (b) $\mathcal{I}$ is an invertible $\mathcal{O}_C$-module. Both (a) and (b) can be checked locally, hence we may assume $X = \Spec(A)$, $D = \Spec(A/fA)$ and $C = \Spec(A/gA)$ where $f, g \in A$ are nonzerodivisors (Lemma \ref{lemma-characterize-effective-Cartier-divisor}). Since $C \subset D$ we see that $f \in gA$. Then $I = fA/fgA$ has square zero and is invertible as an $A/gA$-module as desired.
Let $\Spec(A)$ be an affine neighbourhood of a point $x \in D$. Let $\mathfrak p \subset A$ be the prime corresponding to $x$. Let $I \subset A$ be the ideal defining the trace of $D$ on $\Spec(A)$. Since $A$ is Noetherian (as $X$ is Noetherian) the ideal $I$ is generated by finitely many elements, say $I = (f_1, \ldots, f_r)$. Under the assumption of (1) we have $I_\mathfrak p = (f)$ for some $f \in A_\mathfrak p$. Then $f_i = g_i f$ for some $g_i \in A_\mathfrak p$. Write $g_i = a_i/h_i$ and $f = f'/h$ for some $a_i, h_i, f', h \in A$, $h_i, h \not \in \mathfrak p$. Then $I_{h_1 \ldots h_r h} \subset A_{h_1 \ldots h_r h}$ is principal, because it is generated by $f'$. This proves (1). For (2) we may assume $I = (f)$. The assumption implies that the image of $f$ in $A_\mathfrak p$ is a nonzerodivisor. Then $f$ is a nonzerodivisor on a neighbourhood of $x$ by Algebra, Lemma \ref{algebra-lemma-regular-sequence-in-neighbourhood}. This proves (2).
Proof of (1). By assumption we may assume $X = \Spec(A)$ and $D = \Spec(A/(f))$ where $A$ is a Noetherian ring and $f \in A$. Let $\xi$ correspond to the prime ideal $\mathfrak p \subset A$. The assumption that $\xi$ is a generic point of an irreducible component of $D$ signifies $\mathfrak p$ is minimal over $(f)$. Thus $\dim(A_\mathfrak p) \leq 1$ by Algebra, Lemma \ref{algebra-lemma-minimal-over-1}. \medskip\noindent Proof of (2). By part (1) we see that $\dim(\mathcal{O}_{X, \xi}) \leq 1$. On the other hand, the local equation $f$ is a nonzerodivisor in $A_\mathfrak p$ by Lemma \ref{lemma-characterize-effective-Cartier-divisor} which implies the dimension is at least $1$ (because there must be a prime in $A_\mathfrak p$ not containing $f$ by the elementary Algebra, Lemma \ref{algebra-lemma-Zariski-topology}).
By Lemma \ref{lemma-characterize-effective-Cartier-divisor} we may assume $X = \Spec(A)$ and $D = \Spec(A/(f))$ where $A$ is a Noetherian ring and $f \in A$ is a nonzerodivisor. The assumption that $D$ is integral signifies that $(f)$ is prime. Hence the local ring of $X$ at the generic point is $A_{(f)}$ which is a Noetherian local ring whose maximal ideal is generated by a nonzerodivisor. Thus it is a discrete valuation ring by Algebra, Lemma \ref{algebra-lemma-characterize-dvr}.
Let $x \in D$. Then $\mathcal{O}_{D, x} = \mathcal{O}_{X, x}/(f)$ where $f \in \mathcal{O}_{X, x}$ is a nonzerodivisor. By assumption we have $\text{depth}(\mathcal{O}_{X, x}) \geq \min(\dim(\mathcal{O}_{X, x}), k)$. By Algebra, Lemma \ref{algebra-lemma-depth-drops-by-one} we have $\text{depth}(\mathcal{O}_{D, x}) = \text{depth}(\mathcal{O}_{X, x}) - 1$ and by Algebra, Lemma \ref{algebra-lemma-one-equation} $\dim(\mathcal{O}_{D, x}) = \dim(\mathcal{O}_{X, x}) - 1$. It follows that $\text{depth}(\mathcal{O}_{D, x}) \geq \min(\dim(\mathcal{O}_{D, x}), k - 1)$ as desired.
Let $x \in D$ and set $A = \mathcal{O}_{X, x}$. Let $\mathfrak p \subset A$ correspond to the generic point of $D$. Then $A_\mathfrak p$ has dimension $1$ by assumption (1). Thus $\mathfrak p$ is a prime ideal of height $1$. Since $A$ is a UFD this implies that $\mathfrak p = (f)$ for some $f \in A$. Of course $f$ is a nonzerodivisor and we conclude by Lemma \ref{lemma-effective-Cartier-in-points}.
Let $\xi_i \in D_i$ be the generic point and let $\mathcal{O}_i = \mathcal{O}_{X, \xi_i}$ be the local ring which is a discrete valuation ring by Lemma \ref{lemma-integral-effective-Cartier-divisor-dvr}. Let $a_i \geq 0$ be the minimal valuation of an element of $\mathcal{I}_{Z, \xi_i} \subset \mathcal{O}_i$. We claim that the effective Cartier divisor $D = \sum a_i D_i$ works. \medskip\noindent Namely, suppose that $x \in X$. Let $A = \mathcal{O}_{X, x}$. Let $f_i \in A$ be a local equation for $D_i$; we only consider those $i$ such that $x \in D_i$. Then $f_i$ is a prime element of $A$ and $\mathcal{O}_i = A_{(f_i)}$. Let $I = \mathcal{I}_{Z, x} \subset A$. By our choice of $a_i$ we have $I A_{(f_i)} = f_i^{a_i}A_{(f_i)}$. It follows that $I \subset (\prod f_i^{a_i})$ because the $f_i$ are prime elements of $A$. This proves that $\mathcal{I}_Z \subset \mathcal{I}_D$, i.e., that $D \subset Z$. Moreover, we also see that $D$ and $Z$ agree at the $\xi_i$, which proves the final assertion. \medskip\noindent To see the final statements we argue as follows. A regular local ring is a UFD (More on Algebra, Lemma \ref{more-algebra-lemma-regular-local-UFD}) hence it suffices to argue in the UFD case. In that case, let $D_i$ be the irreducible components of $Z$ which have codimension $1$ in $X$. By Lemma \ref{lemma-weil-divisor-is-cartier-UFD} each $D_i$ is an effective Cartier divisor.
Let $D = \sum a_i D_i$ be as in Lemma \ref{lemma-codim-1-part} where $D_i \subset Z$ are the irreducible components of $Z$. If $D \to Z$ is not an isomorphism, then $\mathcal{O}_Z \to \mathcal{O}_D$ has a nonzero kernel sitting in codimension $\geq 2$. This would mean that $Z$ has embedded points, which is forbidden by assumption (1). Hence $D \cong Z$ as desired.
Choose $a_i$ as in Lemma \ref{lemma-codim-1-part} and set $D' = \sum a_i D_i$. Then $D' \to D$ is an inclusion of effective Cartier divisors which is an isomorphism away from codimension $2$ on $X$. Pick $x \in X$. Set $A = \mathcal{O}_{X, x}$ and let $f, f' \in A$ be the nonzerodivisor generating the ideal of $D, D'$ in $A$. Then $f = gf'$ for some $g \in A$. Moreover, for every prime $\mathfrak p$ of height $\leq 1$ of $A$ we see that $g$ maps to a unit of $A_\mathfrak p$. This implies that $g$ is a unit because the minimal primes over $(g)$ have height $1$ (Algebra, Lemma \ref{algebra-lemma-minimal-over-1}).
Let $x_1, \ldots, x_n$ be the associated points of $X$ (Lemma \ref{lemma-finite-ass}). \medskip\noindent If $X$ is quasi-affine and $\mathcal{N}$ is any invertible $\mathcal{O}_X$-module, then we can pick a section $t$ of $\mathcal{N}$ which does not vanish at any of the points of $E \cup \{x_1, \ldots, x_n\}$, see Properties, Lemma \ref{properties-lemma-quasi-affine-invertible-nonvanishing-section}. Then $t$ is a regular section of $\mathcal{N}$ by Lemma \ref{lemma-regular-section-associated-points}. Hence $\mathcal{N} \cong \mathcal{O}_X(D)$ where $D = Z(t)$ is the effective Cartier divisor corresponding to $t$, see Lemma \ref{lemma-characterize-OD}. Since $E \cap D = \emptyset$ by construction we are done in this case. \medskip\noindent Returning to the general case, let $\mathcal{L}$ be an ample invertible sheaf on $X$. There exists an $n > 0$ and a section $s \in \Gamma(X, \mathcal{L}^{\otimes n})$ such that $X_s$ is affine and such that $E \cup \{x_1, \ldots, x_n\} \subset X_s$ (Properties, Lemma \ref{properties-lemma-ample-finite-set-in-principal-affine}). \medskip\noindent Let $\mathcal{N}$ be an arbitrary invertible $\mathcal{O}_X$-module. By the quasi-affine case, we can find a section $t \in \mathcal{N}(X_s)$ which does not vanish at any point of $E \cup \{x_1, \ldots, x_n\}$. By Properties, Lemma \ref{properties-lemma-invert-s-sections} we see that for some $e \geq 0$ the section $s^e|_{X_s} t$ extends to a global section $\tau$ of $\mathcal{L}^{\otimes e} \otimes \mathcal{N}$. Thus both $\mathcal{L}^{\otimes e} \otimes \mathcal{N}$ and $\mathcal{L}^{\otimes e}$ are invertible sheaves which have global sections which do not vanish at any point of $E \cup \{x_1, \ldots, x_n\}$. Thus these are regular sections by Lemma \ref{lemma-regular-section-associated-points}. Hence $\mathcal{L}^{\otimes e} \otimes \mathcal{N} \cong \mathcal{O}_X(D)$ and $\mathcal{L}^{\otimes e} \cong \mathcal{O}_X(D')$ for some effective Cartier divisors $D$ and $D'$, see Lemma \ref{lemma-characterize-OD}. By construction $E \cap D = \emptyset$ and $E \cap D' = \emptyset$ and the proof is complete.
The first statement follows from Lemma \ref{lemma-reflexive-over-regular-dim-2} as assumption (1) implies that $\mathcal{L}$ and $\mathcal{L}'$ have rank $1$. Taking $\wedge^r$ and double duals are functors, hence we obtain a canonical map $\sigma : \mathcal{L} \to \mathcal{L}'$ which is an isomorphism over the nonempty open of (1), hence nonzero. To finish the proof, it suffices to see that $\sigma$ viewed as a global section of $\mathcal{L}' \otimes \mathcal{L}^{\otimes -1}$ does not vanish at any codimension point of $X$, except at the generic point of $D$ and there with vanishing order at most $\min(s, r)$. \medskip\noindent Translated into algebra, we arrive at the following problem: Let $(A, \mathfrak m, \kappa)$ be a discrete valuation ring with fraction field $K$. Let $M \to M' \to N \to 0$ be an exact sequence of finite $A$-modules with $\dim_K(M \otimes K) = \dim_K(M' \otimes K) = r$ and with $N \cong \kappa^{\oplus s}$. Show that the induced map $L = \wedge^r(M)^{**} \to L' = \wedge^r(M')^{**}$ vanishes to order at most $\min(s, r)$. We will use the structure theorem for modules over $A$, see More on Algebra, Lemma \ref{more-algebra-lemma-generalized-valuation-ring-modules} or \ref{more-algebra-lemma-modules-PID}. Dividing out a finite $A$-module by a torsion submodule does not change the double dual. Thus we may replace $M$ by $M/M_{tors}$ and $M'$ by $M'/\Im(M_{tors} \to M')$ and assume that $M$ is torsion free. Then $M \to M'$ is injective and $M'_{tors} \to N$ is injective. Hence we may replace $M'$ by $M'/M'_{tors}$ and $N$ by $N/M'_{tors}$. Thus we reduce to the case where $M$ and $M'$ are free of rank $r$ and $N \cong \kappa^{\oplus s}$. In this case $\sigma$ is the determinant of $M \to M'$ and vanishes to order $s$ for example by Algebra, Lemma \ref{algebra-lemma-order-vanishing-determinant}.
If $\dim(A) = 0$, then $U$ is empty hence affine (equal to the spectrum of the $0$ ring). If $\dim(A) = 1$, then we can choose an element $f \in \mathfrak m$ not contained in any of the finite number of minimal primes of $A$ (Algebra, Lemmas \ref{algebra-lemma-Noetherian-irreducible-components} and \ref{algebra-lemma-silly}). Then $U = \Spec(A_f)$ is affine. \medskip\noindent The converse is more interesting. We will give a somewhat nonstandard proof and discuss the standard argument in a remark below. Assume $U = \Spec(B)$ is affine. Since affineness and dimension are not affecting by going to the reduction we may replace $A$ by the quotient by its ideal of nilpotent elements and assume $A$ is reduced. Set $Q = B/A$ viewed as an $A$-module. The support of $Q$ is $\{\mathfrak m\}$ as $A_\mathfrak p = B_\mathfrak p$ for all nonmaximal primes $\mathfrak p$ of $A$. We may assume $\dim(A) \geq 1$, hence as above we can pick $f \in \mathfrak m$ not contained in any of the minimal ideals of $A$. Since $A$ is reduced this implies that $f$ is a nonzerodivisor. In particular $\dim(A/fA) = \dim(A) - 1$, see Algebra, Lemma \ref{algebra-lemma-one-equation}. Applying the snake lemma to multiplication by $f$ on the short exact sequence $0 \to A \to B \to Q \to 0$ we obtain $$ 0 \to Q[f] \to A/fA \to B/fB \to Q/fQ \to 0 $$ where $Q[f] = \Ker(f : Q \to Q)$. This implies that $Q[f]$ is a finite $A$-module. Since the support of $Q[f]$ is $\{\mathfrak m\}$ we see $l = \text{length}_A(Q[f]) < \infty$ (Algebra, Lemma \ref{algebra-lemma-support-point}). Set $l_n = \text{length}_A(Q[f^n])$. The exact sequence $$ 0 \to Q[f^n] \to Q[f^{n + 1}] \xrightarrow{f^n} Q[f] $$ shows inductively that $l_n < \infty$ and that $l_n \leq l_{n + 1}$. Considering the exact sequence $$ 0 \to Q[f] \to Q[f^{n + 1}] \xrightarrow{f} Q[f^n] \to Q/fQ $$ and we see that the image of $Q[f^n]$ in $Q/fQ$ has length $l_n - l_{n + 1} + l \leq l$. Since $Q = \bigcup Q[f^n]$ we find that the length of $Q/fQ$ is at most $l$, i.e., bounded. Thus $Q/fQ$ is a finite $A$-module. Hence $A/fA \to B/fB$ is a finite ring map, in particular induces a closed map on spectra (Algebra, Lemmas \ref{algebra-lemma-integral-going-up} and \ref{algebra-lemma-going-up-closed}). On the other hand $\Spec(B/fB)$ is the punctured spectrum of $\Spec(A/fA)$. This is a contradiction unless $\Spec(B/fB) = \emptyset$ which means that $\dim(A/fA) = 0$ as desired.
Since $\xi$ is a generic point of $X \setminus U$, we see that $$ U_\xi = U \times_X \Spec(\mathcal{O}_{X, \xi}) \subset \Spec(\mathcal{O}_{X, \xi}) $$ is the punctured spectrum of $\mathcal{O}_{X, \xi}$ (hint: use Schemes, Lemma \ref{schemes-lemma-specialize-points}). As $U \to X$ is affine, we see that $U_\xi \to \Spec(\mathcal{O}_{X, \xi})$ is affine (Morphisms, Lemma \ref{morphisms-lemma-base-change-affine}) and we conclude that $U_\xi$ is affine. Hence $\dim(\mathcal{O}_{X, \xi}) \leq 1$ by Lemma \ref{lemma-affine-punctured-spec}. If $\xi \in \overline{U}$, then there is a specialization $\eta \to \xi$ where $\eta \in U$ (just take $\eta$ a generic point of an irreducible component of $\overline{U}$ which contains $\xi$; since $\overline{U}$ is locally Noetherian, hence locally has finitely many irreducible components, we see that $\eta \in U$). Then $\eta \in \Spec(\mathcal{O}_{X, \xi})$ and we see that the dimension cannot be $0$.
Since $X$ is Noetherian, the complement $X \setminus U$ has finitely many irreducible components $D_1, \ldots, D_r$ (Properties, Lemma \ref{properties-lemma-Noetherian-irreducible-components} applied to the reduced induced subscheme structure on $X \setminus U$). Each $D_i \subset X$ has codimension $1$ by Lemma \ref{lemma-complement-affine-open} (and Properties, Lemma \ref{properties-lemma-codimension-local-ring}). Thus $D_i$ is an effective Cartier divisor by Lemma \ref{lemma-weil-divisor-is-cartier-UFD}. Hence we can take $D = D_1 + \ldots + D_r$.
Since $X$ is Noetherian, the complement $X \setminus U$ has finitely many irreducible components $D_1, \ldots, D_r$ (Properties, Lemma \ref{properties-lemma-Noetherian-irreducible-components} applied to the reduced induced subscheme structure on $X \setminus U$). We view $D_i$ as a reduced closed subscheme of $X$. Let $X = \bigcup_{j \in J} X_j$ be an affine open covering of $X$. For all $j$ in $J$, set $U_j = U \cap X_j$. Since $X$ has affine diagonal, the scheme $$ U_j = X \times_{(X \times X)} (U \times X_j) $$ is affine. Therefore, as $X_j$ is separated, it follows from Lemma \ref{lemma-complement-open-affine-effective-cartier-divisor} and its proof that for all $j \in J$ and $1 \leq i \leq r$ the intersection $D_i \cap X_j$ is either empty or an effective Cartier divisor in $X_j$. Thus $D_i \subset X$ is an effective Cartier divisor (as this is a local property). Hence we can take $D = D_1 + \ldots + D_r$.
Clearly we may assume $Y$ and hence $X$ affine. Since $\pi$ is finite the fibre $\pi^{-1}(\{y\})$ over $y$ is finite. Since $X$ is affine, we can pick $s \in \Gamma(X, \mathcal{L})$ not vanishing in any point of $\pi^{-1}(\{y\})$. This follows from Properties, Lemma \ref{properties-lemma-quasi-affine-invertible-nonvanishing-section} but we also give a direct argument. Namely, we can pick a finite set $E \subset X$ of closed points such that every $x \in \pi^{-1}(\{y\})$ specializes to some point of $E$. For $x \in E$ denote $i_x : x \to X$ the closed immersion. Then $\mathcal{L} \to \bigoplus_{x \in E} i_{x, *}i_x^*\mathcal{L}$ is a surjective map of quasi-coherent $\mathcal{O}_X$-modules, and hence the map $$ \Gamma(X, \mathcal{L}) \to \bigoplus\nolimits_{x \in E} \mathcal{L}_x/\mathfrak m_x\mathcal{L}_x $$ is surjective (as taking global sections is an exact functor on the category of quasi-coherent $\mathcal{O}_X$-modules, see Schemes, Lemma \ref{schemes-lemma-equivalence-quasi-coherent}). Thus we can find an $s \in \Gamma(X, \mathcal{L})$ not vanishing at any point specializing to a point of $E$. Then $X_s \subset X$ is an open neighbourhood of $\pi^{-1}(\{y\})$. Since $\pi$ is finite, hence closed, we conclude that there is an open neighbourhood $V \subset Y$ of $y$ whose inverse image is contained in $X_s$ as desired.
We will use the correspondence between isomorphism classes of invertible $\mathcal{O}_X$-modules and elements of $H^1(X, \mathcal{O}_X^*)$ given in Cohomology, Lemma \ref{cohomology-lemma-h1-invertible} without further mention. We explain how to take the norm of an invertible $\mathcal{O}_X$-module $\mathcal{L}$. Namely, by Lemma \ref{lemma-finite-trivialize-invertible-upstairs} there exists an open covering $Y = \bigcup V_j$ such that $\mathcal{L}|_{\pi^{-1}V_j}$ is trivial. Choose a generating section $s_j \in \mathcal{L}(\pi^{-1}V_j)$ for each $j$. On the overlaps $\pi^{-1}V_j \cap \pi^{-1}V_{j'}$ we can write $$ s_j = u_{jj'} s_{j'} $$ for a unique $u_{jj'} \in \mathcal{O}^*_X(\pi^{-1}V_j \cap \pi^{-1}V_{j'})$. Thus we can consider the elements $$ v_{jj'} = \text{Norm}_\pi(u_{jj'}) \in \mathcal{O}_Y^*(V_j \cap V_{j'}) $$ These elements satisfy the cocycle condition (because the $u_{jj'}$ do and $\text{Norm}_\pi$ is multiplicative) and therefore define an invertible $\mathcal{O}_Y$-module. We omit the verification that: this is well defined, additive on Picard groups, and satisfies the property $\text{Norm}_\pi(\pi^*\mathcal{N}) \cong \mathcal{N}^{\otimes d}$ for all invertible $\mathcal{O}_Y$-modules $\mathcal{N}$.
We choose an open covering $Y = \bigcup V_j$ such that $\mathcal{L}$ and $\mathcal{L}'$ are trivial over the opens $\pi^{-1}V_j$. This is possible by Lemma \ref{lemma-finite-trivialize-invertible-upstairs}. Choose generating sections $s_j$ and $s'_j$ of $\mathcal{L}$ and $\mathcal{L}'$ over the opens $\pi^{-1}V_j$. Then $\varphi(s_j) = f_js'_j$ for some $f_j \in \mathcal{O}_X(\pi^{-1}V_j)$. Define $\text{Norm}_\pi(\varphi)$ to be multiplication by $\text{Norm}_\pi(f_j)$ on $V_j$. An simple calculation involving the cocycles used to construct $\text{Norm}_\pi(\mathcal{L})$, $\text{Norm}_\pi(\mathcal{L}')$ in the proof of Lemma \ref{lemma-norm-invertible} shows that this defines a map as stated in the lemma. The final statement follows from condition (2) in the definition of a norm map of degree $d$. Some details omitted.
Let $\mathcal{L}$ be the ample invertible sheaf on $X$ given to us by assumption. We will prove that $\mathcal{N} = \text{Norm}_\pi(\mathcal{L})$ is ample on $Y$. \medskip\noindent Since $X$ is quasi-compact (Properties, Definition \ref{properties-definition-ample}) and $X \to Y$ surjective (by the existence of $\text{Norm}_\pi$) we see that $Y$ is quasi-compact. Let $y \in Y$ be a point. To finish the proof we will show that there exists a section $t$ of some positive tensor power of $\mathcal{N}$ which does not vanish at $y$ such that $Y_t$ is affine. To do this, choose an affine open neighbourhood $V \subset Y$ of $y$. Choose $n \gg 0$ and a section $s \in \Gamma(X, \mathcal{L}^{\otimes n})$ such that $$ \pi^{-1}(\{y\}) \subset X_s \subset \pi^{-1}V $$ by Properties, Lemma \ref{properties-lemma-ample-finite-set-in-principal-affine}. Then $t = \text{Norm}_\pi(s)$ is a section of $\mathcal{N}^{\otimes n}$ which does not vanish at $x$ and with $Y_t \subset V$, see Lemma \ref{lemma-norm-map-invertible}. Then $Y_t$ is affine by Properties, Lemma \ref{properties-lemma-affine-cap-s-open}.
By Properties, Lemma \ref{properties-lemma-quasi-affine-O-ample} we see that $\mathcal{O}_X$ is an ample invertible sheaf on $X$. The proof of Lemma \ref{lemma-norm-ample} shows that $\text{Norm}_\pi(\mathcal{O}_X) = \mathcal{O}_Y$ is an ample invertible $\mathcal{O}_Y$-module. Hence Properties, Lemma \ref{properties-lemma-quasi-affine-O-ample} shows that $Y$ is quasi-affine.
Let $\Spec(B) \subset Y$ be an affine open subset and let $\Spec(A) \subset X$ be its inverse image. Then $A$ and $B$ are domains. Let $K$ be the fraction field of $A$ and $L$ the fraction field of $B$. Picture: $$ \xymatrix{ L \ar[r] & K \\ B \ar[u] \ar[r] & A \ar[u] } $$ Since $K/L$ is a finite extension, there is a norm map $\text{Norm}_{K/L} : K^* \to L^*$ of degree $d = [K : L]$; this is given by mapping $f \in K$ to $\det_L(f : K \to K)$ as in the proof of Lemma \ref{lemma-finite-locally-free-has-norm}. Observe that the characteristic polynomial of $f : K \to K$ is a power of the minimal polynomial of $f$ over $L$; in particular $\text{Norm}_{K/L}(f)$ is a power of the constant coefficient of the minimal polynomial of $f$ over $L$. Hence by Algebra, Lemma \ref{algebra-lemma-minimal-polynomial-normal-domain} $\text{Norm}_{K/L}$ maps $A$ into $B$. This determines a compatible system of maps on sections over affines and hence a global norm map $\text{Norm}_\pi$ of degree $d$. \medskip\noindent Property (1) is immediate from the construction. To see property (2) let $f \in A$ be contained in the prime ideal $\mathfrak p \subset A$. Let $f^m + b_1 f^{m - 1} + \ldots + b_m$ be the minimal polynomial of $f$ over $L$. By Algebra, Lemma \ref{algebra-lemma-minimal-polynomial-normal-domain} we have $b_i \in B$. Hence $b_0 \in B \cap \mathfrak p$. Since $\text{Norm}_{K/L}(f) = b_0^{d/m}$ (see above) we conclude that the norm vanishes in the image point of $\mathfrak p$.