hcju/stacksqa huggingface dataset:
Choose a finite affine open covering $Y_0 = \bigcup_{j = 1, \ldots, m} Y_{j, 0}$ such that each $Y_{j, 0}$ maps into an affine open $S_{j, 0} \subset S_0$. For each $j$ let $f_0^{-1}Y_{j, 0} = \bigcup_{k = 1, \ldots, n_j} X_{k, 0}$ be a finite affine open covering. Since the property of being unramified is local we see that it suffices to prove the lemma for the morphisms of affines $X_{k, i} \to Y_{j, i} \to S_{j, i}$ which are the base changes of $X_{k, 0} \to Y_{j, 0} \to S_{j, 0}$ to $S_i$. Thus we reduce to the case that $X_0, Y_0, S_0$ are affine \medskip\noindent In the affine case we reduce to the following algebra result. Suppose that $R = \colim_{i \in I} R_i$. For some $0 \in I$ suppose given an $R_0$-algebra map $A_i \to B_i$ of finite type. If $R \otimes_{R_0} A_0 \to R \otimes_{R_0} B_0$ is unramified, then for some $i \geq 0$ the map $R_i \otimes_{R_0} A_0 \to R_i \otimes_{R_0} B_0$ is unramified. This follows from Algebra, Lemma \ref{algebra-lemma-colimit-unramified}.
A closed immersion is affine, see Morphisms, Lemma \ref{morphisms-lemma-closed-immersion-affine}. Hence by Lemma \ref{lemma-descend-affine-finite-presentation} above after increasing $0$ we may assume that $f_0$ is affine. By writing $Y_0$ as a finite union of affines we reduce to proving the result when $X_0$ and $Y_0$ are affine and map into a common affine $W \subset S_0$. The corresponding algebra statement is a consequence of Algebra, Lemma \ref{algebra-lemma-colimit-surjective}.
Apply Lemma \ref{lemma-descend-closed-immersion-finite-presentation} to the diagonal morphism $\Delta_{X_0/S_0} : X_0 \to X_0 \times_{S_0} X_0$. (This is permissible as diagonal morphisms are locally of finite type and the fibre product $X_0 \times_{S_0} X_0$ is quasi-compact and quasi-separated, see Schemes, Lemma \ref{schemes-lemma-diagonal-immersion}, Morphisms, Lemma \ref{morphisms-lemma-immersion-locally-finite-type}, and Schemes, Remark \ref{schemes-remark-quasi-compact-and-quasi-separated}.
Choose a finite affine open covering $Y_0 = \bigcup_{j = 1, \ldots, m} Y_{j, 0}$ such that each $Y_{j, 0}$ maps into an affine open $S_{j, 0} \subset S_0$. For each $j$ let $f_0^{-1}Y_{j, 0} = \bigcup_{k = 1, \ldots, n_j} X_{k, 0}$ be a finite affine open covering. Since the property of being flat is local we see that it suffices to prove the lemma for the morphisms of affines $X_{k, i} \to Y_{j, i} \to S_{j, i}$ which are the base changes of $X_{k, 0} \to Y_{j, 0} \to S_{j, 0}$ to $S_i$. Thus we reduce to the case that $X_0, Y_0, S_0$ are affine \medskip\noindent In the affine case we reduce to the following algebra result. Suppose that $R = \colim_{i \in I} R_i$. For some $0 \in I$ suppose given an $R_0$-algebra map $A_i \to B_i$ of finite presentation. If $R \otimes_{R_0} A_0 \to R \otimes_{R_0} B_0$ is flat, then for some $i \geq 0$ the map $R_i \otimes_{R_0} A_0 \to R_i \otimes_{R_0} B_0$ is flat. This follows from Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat} part (3).
By Lemmas \ref{lemma-descend-flat-finite-presentation} and \ref{lemma-descend-finite-finite-presentation} we find an $i$ such that $f_i$ is flat and finite. On the other hand, $f_i$ is locally of finite presentation. Hence $f_i$ is finite locally free by Morphisms, Lemma \ref{morphisms-lemma-finite-flat}. If moreover $f$ is finite locally free of degree $d$, then the image of $Y \to Y_i$ is contained in the open and closed locus $W_d \subset Y_i$ over which $f_i$ has degree $d$. By Lemma \ref{lemma-limit-contained-in-constructible} we see that for some $i' \geq i$ the image of $Y_{i'} \to Y_i$ is contained in $W_d$. Then $f_{i'}$ will be finite locally free of degree $d$.
By Lemmas \ref{lemma-descend-etale} and \ref{lemma-descend-closed-immersion-finite-presentation} we can find an $i$ such that $f_i$ is flat and a closed immersion. Then $f_i$ identifies $X_i$ with an open and closed subscheme of $Y_i$, see Morphisms, Lemma \ref{morphisms-lemma-flat-closed-immersions-finite-presentation}. By assumption the image of $Y \to Y_i$ maps into $f_i(X_i)$. Thus by Lemma \ref{lemma-limit-contained-in-constructible} we find that $Y_{i'}$ maps into $f_i(X_i)$ for some $i' \geq i$. It follows that $X_{i'} \to Y_{i'}$ is surjective and we win.
By Lemma \ref{lemma-descend-etale} we can find an $i$ such that $f_i$ is \'etale. Then $V_i = f_i(X_i)$ is a quasi-compact open subscheme of $Y_i$ (Morphisms, Lemma \ref{morphisms-lemma-etale-open}). let $V$ and $V_{i'}$ for $i' \geq i$ be the inverse image of $V_i$ in $Y$ and $Y_{i'}$. Then $f : X \to V$ is an isomorphism (namely it is a surjective open immersion). Hence by Lemma \ref{lemma-descend-isomorphism} we see that $X_{i'} \to V_{i'}$ is an isomorphism for some $i' \geq i$ as desired.
Recall that a morphism of schemes $V \to W$ is a monomorphism if and only if the diagonal $V \to V \times_W V$ is an isomorphism (Schemes, Lemma \ref{schemes-lemma-monomorphism}). The morphism $X_0 \to X_0 \times_{Y_0} X_0$ is locally of finite presentation by Morphisms, Lemma \ref{morphisms-lemma-diagonal-morphism-finite-type}. Since $X_0 \times_{Y_0} X_0$ is quasi-compact and quasi-separated (Schemes, Remark \ref{schemes-remark-quasi-compact-and-quasi-separated}) we conclude from Lemma \ref{lemma-descend-isomorphism} that $\Delta_i : X_i \to X_i \times_{Y_i} X_i$ is an isomorphism for some $i \geq 0$. For this $i$ the morphism $f_i$ is a monomorphism.
The morphism $f_0$ is of finite presentation. Hence $E = f_0(X_0)$ is a constructible subset of $Y_0$, see Morphisms, Lemma \ref{morphisms-lemma-chevalley}. Since $f_i$ is the base change of $f_0$ by $Y_i \to Y_0$ we see that the image of $f_i$ is the inverse image of $E$ in $Y_i$. Moreover, we know that $Y \to Y_0$ maps into $E$. Hence we win by Lemma \ref{lemma-limit-contained-in-constructible}.
Choose a finite affine open covering $Y_0 = \bigcup_{j = 1, \ldots, m} Y_{j, 0}$ such that each $Y_{j, 0}$ maps into an affine open $S_{j, 0} \subset S_0$. For each $j$ let $f_0^{-1}Y_{j, 0} = \bigcup_{k = 1, \ldots, n_j} X_{k, 0}$ be a finite affine open covering. Since the property of being syntomic is local we see that it suffices to prove the lemma for the morphisms of affines $X_{k, i} \to Y_{j, i} \to S_{j, i}$ which are the base changes of $X_{k, 0} \to Y_{j, 0} \to S_{j, 0}$ to $S_i$. Thus we reduce to the case that $X_0, Y_0, S_0$ are affine \medskip\noindent In the affine case we reduce to the following algebra result. Suppose that $R = \colim_{i \in I} R_i$. For some $0 \in I$ suppose given an $R_0$-algebra map $A_i \to B_i$ of finite presentation. If $R \otimes_{R_0} A_0 \to R \otimes_{R_0} B_0$ is syntomic, then for some $i \geq 0$ the map $R_i \otimes_{R_0} A_0 \to R_i \otimes_{R_0} B_0$ is syntomic. This follows from Algebra, Lemma \ref{algebra-lemma-colimit-syntomic}.
By Proposition \ref{proposition-approximate} we can write $X = \lim_i X_i$ with each $X_i$ of finite type over $\mathbf{Z}$ and with transition morphisms $f_{ii'} : X_i \to X_{i'}$ affine. Consider the commutative diagram $$ \xymatrix{ X \ar[r] \ar[rd] & X_{i, S} \ar[r] \ar[d] & X_i \ar[d] \\ & S \ar[r] & \Spec(\mathbf{Z}) } $$ Note that $X_i$ is of finite presentation over $\Spec(\mathbf{Z})$, see Morphisms, Lemma \ref{morphisms-lemma-noetherian-finite-type-finite-presentation}. Hence the base change $X_{i, S} \to S$ is of finite presentation by Morphisms, Lemma \ref{morphisms-lemma-base-change-finite-presentation}. Thus it suffices to show that the arrow $X \to X_{i, S}$ is an immersion for $i$ sufficiently large. \medskip\noindent To do this we choose a finite affine open covering $X = V_1 \cup \ldots \cup V_n$ such that $f$ maps each $V_j$ into an affine open $U_j \subset S$. Let $h_{j, a} \in \mathcal{O}_X(V_j)$ be a finite set of elements which generate $\mathcal{O}_X(V_j)$ as an $\mathcal{O}_S(U_j)$-algebra, see Morphisms, Lemma \ref{morphisms-lemma-locally-finite-type-characterize}. By Lemmas \ref{lemma-descend-opens} and \ref{lemma-limit-affine} (after possibly shrinking $I$) we may assume that there exist affine open coverings $X_i = V_{1, i} \cup \ldots \cup V_{n, i}$ compatible with transition maps such that $V_j = \lim_i V_{j, i}$. By Lemma \ref{lemma-descend-section} we can choose $i$ so large that each $h_{j, a}$ comes from an element $h_{j, a, i} \in \mathcal{O}_{X_i}(V_{j, i})$. Thus the arrow in $$ V_j \longrightarrow U_j \times_{\Spec(\mathbf{Z})} V_{j, i} = (V_{j, i})_{U_j} \subset (V_{j, i})_S \subset X_{i, S} $$ is a closed immersion. Since $\bigcup (V_{j, i})_{U_j}$ forms an open of $X_{i, S}$ and since the inverse image of $(V_{j, i})_{U_j}$ in $X$ is $V_j$ it follows that $X \to X_{i, S}$ is an immersion.
By Lemma \ref{lemma-locally-finite-type-in-finite-presentation} above there exists a morphism $Y \to S$ of finite presentation and an immersion $i : X \to Y$ of schemes over $S$. For every point $x \in X$, there exists an affine open $V_x \subset Y$ such that $i^{-1}(V_x) \to V_x$ is a closed immersion. Since $X$ is quasi-compact we can find finitely may affine opens $V_1, \ldots, V_n \subset Y$ such that $i(X) \subset V_1 \cup \ldots \cup V_n$ and $i^{-1}(V_j) \to V_j$ is a closed immersion. In other words such that $i : X \to X' = V_1 \cup \ldots \cup V_n$ is a closed immersion of schemes over $S$. Since $S$ is quasi-separated and $Y$ is quasi-separated over $S$ we deduce that $Y$ is quasi-separated, see Schemes, Lemma \ref{schemes-lemma-separated-permanence}. Hence the open immersion $X' = V_1 \cup \ldots \cup V_n \to Y$ is quasi-compact. This implies that $X' \to Y$ is of finite presentation, see Morphisms, Lemma \ref{morphisms-lemma-quasi-compact-open-immersion-finite-presentation}. We conclude since then $X' \to Y \to S$ is a composition of morphisms of finite presentation, and hence of finite presentation (see Morphisms, Lemma \ref{morphisms-lemma-composition-finite-presentation}).
Let $\mathcal{I} \subset \mathcal{O}_Y$ be the quasi-coherent sheaf of ideals defining $X$ as a closed subscheme of $Y$. By Properties, Lemma \ref{properties-lemma-quasi-coherent-colimit-finite-type} we can write $\mathcal{I}$ as a directed colimit $\mathcal{I} = \colim_{i \in I} \mathcal{I}_i$ of its quasi-coherent sheaves of ideals of finite type. Let $X_i \subset Y$ be the closed subscheme defined by $\mathcal{I}_i$. These form an inverse system of schemes indexed by $I$. The transition morphisms $X_i \to X_{i'}$ are affine because they are closed immersions. Each $X_i$ is quasi-compact and quasi-separated since it is a closed subscheme of $Y$ and $Y$ is quasi-compact and quasi-separated by our assumptions. We have $X = \lim_i X_i$ as follows directly from the fact that $\mathcal{I} = \colim_{i \in I} \mathcal{I}_a$. Each of the morphisms $X_i \to Y$ is of finite presentation, see Morphisms, Lemma \ref{morphisms-lemma-closed-immersion-finite-presentation}.
By Lemma \ref{lemma-finite-type-closed-in-finite-presentation} there is a closed immersion $X \to Y$ with $Y \to S$ of finite presentation. Then $Y$ is quasi-separated by Schemes, Lemma \ref{schemes-lemma-separated-permanence}. Since $X$ is quasi-compact, we may assume $Y$ is quasi-compact by replacing $Y$ with a quasi-compact open containing $X$. We see that $X = \lim X_i$ with $X_i \to Y$ a closed immersion of finite presentation by Lemma \ref{lemma-closed-is-limit-closed-and-finite-presentation}. The morphisms $X_i \to S$ are of finite presentation by Morphisms, Lemma \ref{morphisms-lemma-composition-finite-presentation}.
We sketch two proofs, but we omit the details. \medskip\noindent First proof. If $S$ and $S_i$ are affine schemes, then this lemma is equivalent to Algebra, Lemma \ref{algebra-lemma-colimit-category-fp-modules}. In the general case, use Zariski glueing to deduce it from the affine case. \medskip\noindent Second proof. We use \begin{enumerate} \item there is an equivalence of categories between quasi-coherent $\mathcal{O}_S$-modules and vector bundles over $S$, see Constructions, Section \ref{constructions-section-vector-bundle}, and \item a vector bundle $\mathbf{V}(\mathcal{F}) \to S$ is of finite presentation over $S$ if and only if $\mathcal{F}$ is an $\mathcal{O}_S$-module of finite presentation. \end{enumerate} Having said this, we can use Lemma \ref{lemma-descend-finite-presentation} to show that the category of vector bundles of finite presentation over $S$ is the colimit over $I$ of the categories of vector bundles over $S_i$.
Let $\mathcal{E}$ be a finite locally free $\mathcal{O}_S$-module. Since finite locally free modules are of finite presentation we can find an $i$ and an $\mathcal{O}_{S_i}$-module $\mathcal{E}_i$ of finite presentation such that $f_i^*\mathcal{E}_i \cong \mathcal{E}$, see Lemma \ref{lemma-descend-modules-finite-presentation}. After increasing $i$ we may assume $\mathcal{E}_i$ is a flat $\mathcal{O}_{S_i}$-module, see Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat}. (Using this lemma is not necessary, but it is convenient.) Then $\mathcal{E}_i$ is finite locally free by Algebra, Lemma \ref{algebra-lemma-finite-projective}. \medskip\noindent If $\mathcal{L}$ is an invertible $\mathcal{O}_S$-module, then by the above we can find an $i$ and finite locally free $\mathcal{O}_{S_i}$-modules $\mathcal{L}_i$ and $\mathcal{N}_i$ pulling back to $\mathcal{L}$ and $\mathcal{L}^{\otimes -1}$. After possible increasing $i$ we see that the map $\mathcal{L} \otimes_{\mathcal{O}_X} \mathcal{L}^{\otimes -1} \to \mathcal{O}_X$ descends to a map $\mathcal{L}_i \otimes_{\mathcal{O}_{S_i}} \mathcal{N}_i \to \mathcal{O}_{S_i}$. And after increasing $i$ further, we may assume it is an isomorphism. It follows that $\mathcal{L}_i$ is an invertible module (Modules, Lemma \ref{modules-lemma-invertible}) and the proof of (2) is complete. \medskip\noindent Given $\mathcal{I}$ as in (3) we see that $\mathcal{O}_S \to \mathcal{O}_S/\mathcal{I}$ is a map of finitely presented $\mathcal{O}_S$-modules. Hence by Lemma \ref{lemma-descend-modules-finite-presentation} this is the pullback of some map $\mathcal{O}_{S_i} \to \mathcal{F}_i$ of finitely presented $\mathcal{O}_{S_i}$-modules. After increasing $i$ we may assume this map is surjective (details omitted; hint: use Algebra, Lemma \ref{algebra-lemma-module-map-property-in-colimit} on affine open cover). Then the kernel of $\mathcal{O}_{S_i} \to \mathcal{F}_i$ is a finite type quasi-coherent ideal in $\mathcal{O}_{S_i}$ whose pullback gives $\mathcal{I}$.
(This lemma is the analogue of Lemma \ref{lemma-descend-flat-finite-presentation} for modules.) For $i' \geq i$ denote $X_{i'} = S_{i'} \times_{S_i} X_i$, $\mathcal{F}_{i'} = (X_{i'} \to X_i)^*\mathcal{F}_i$ and similarly for $Y_{i'}$. Denote $\varphi_{i'}$ the base change of $\varphi_i$ to $S_{i'}$. Also set $X = S \times_{S_i} X_i$, $Y =S \times_{S_i} X_i$, $\mathcal{F} = (X \to X_i)^*\mathcal{F}_i$ and $\varphi$ the base change of $\varphi_i$ to $S$. Let $Y_i = \bigcup_{j = 1, \ldots, m} V_{j, i}$ be a finite affine open covering such that each $V_{j, i}$ maps into some affine open of $S_i$. For each $j = 1, \ldots m$ let $\varphi_i^{-1}(V_{j, i}) = \bigcup_{k = 1, \ldots, m(j)} U_{k, j, i}$ be a finite affine open covering. For $i' \geq i$ we denote $V_{j, i'}$ the inverse image of $V_{j, i}$ in $Y_{i'}$ and $U_{k, j, i'}$ the inverse image of $U_{k, j, i}$ in $X_{i'}$. Similarly we have $U_{k, j} \subset X$ and $V_j \subset Y$. Then $U_{k, j} = \lim_{i' \geq i} U_{k, j, i'}$ and $V_j = \lim_{i' \geq i} V_j$ (see Lemma \ref{lemma-directed-inverse-system-has-limit}). Since $X_{i'} = \bigcup_{k, j} U_{k, j, i'}$ is a finite open covering it suffices to prove the lemma for each of the morphisms $U_{k, j, i} \to V_{j, i}$ and the sheaf $\mathcal{F}_i|_{U_{k, j, i}}$. Hence we see that the lemma reduces to the case that $X_i$ and $Y_i$ are affine and map into an affine open of $S_i$, i.e., we may also assume that $S$ is affine. \medskip\noindent In the affine case we reduce to the following algebra result. Suppose that $R = \colim_{i \in I} R_i$. For some $i \in I$ suppose given a map $A_i \to B_i$ of finitely presented $R_i$-algebras. Let $N_i$ be a finitely presented $B_i$-module. Then, if $R \otimes_{R_i} N_i$ is flat over $R \otimes_{R_i} A_i$, then for some $i' \geq i$ the module $R_{i'} \otimes_{R_i} N_i$ is flat over $R_{i'} \otimes_{R_i} A$. This is exactly the result proved in Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat} part (3).
Since $f$ is surjective and $X$ is quasi-compact we see that $S$ is quasi-compact. Since $X$ is separated and $f$ is surjective and universally closed (Morphisms, Lemma \ref{morphisms-lemma-integral-universally-closed}), we see that $S$ is separated (Morphisms, Lemma \ref{morphisms-lemma-image-universally-closed-separated}). \medskip\noindent By Lemma \ref{lemma-finite-in-finite-and-finite-presentation} we can write $X = \lim_a X_a$ with $X_a \to S$ finite and of finite presentation. By Lemma \ref{lemma-limit-affine} we see that $X_a$ is affine for some $a \in A$. Replacing $X$ by $X_a$ we may assume that $X \to S$ is surjective, finite, of finite presentation and that $X$ is affine. \medskip\noindent By Proposition \ref{proposition-approximate} we may write $S = \lim_{i \in I} S_i$ as a directed limits of schemes of finite type over $\mathbf{Z}$. By Lemma \ref{lemma-descend-finite-presentation} we can after shrinking $I$ assume there exist schemes $X_i \to S_i$ of finite presentation such that $X_{i'} = X_i \times_S S_{i'}$ for $i' \geq i$ and such that $X = \lim_i X_i$. By Lemma \ref{lemma-descend-finite-finite-presentation} we may assume that $X_i \to S_i$ is finite for all $i \in I$ as well. By Lemma \ref{lemma-limit-affine} once again we may assume that $X_i$ is affine for all $i \in I$. Hence the result follows from the Noetherian case, see Cohomology of Schemes, Lemma \ref{coherent-lemma-image-affine-finite-morphism-affine-Noetherian}.
If $\mathcal{L}$ is ample, then $i^*\mathcal{L}$ is ample for example by Morphisms, Lemma \ref{morphisms-lemma-pullback-ample-tensor-relatively-ample}. Assume $i^*\mathcal{L}$ is ample. Then $Z$ is quasi-compact (Properties, Definition \ref{properties-definition-ample}) and separated (Properties, Lemma \ref{properties-lemma-ample-separated}). Since $i$ is surjective, we see that $X$ is quasi-compact. Since $i$ is universally closed and surjective, we see that $X$ is separated (Morphisms, Lemma \ref{morphisms-lemma-image-universally-closed-separated}). \medskip\noindent By Proposition \ref{proposition-approximate} we can write $X = \lim X_i$ as a directed limit of finite type schemes over $\mathbf{Z}$ with affine transition morphisms. We can find an $i$ and an invertible sheaf $\mathcal{L}_i$ on $X_i$ whose pullback to $X$ is isomorphic to $\mathcal{L}$, see Lemma \ref{lemma-descend-modules-finite-presentation}. \medskip\noindent For each $i$ let $Z_i \subset X_i$ be the scheme theoretic image of the morphism $Z \to X$. If $\Spec(A_i) \subset X_i$ is an affine open subscheme with inverse image of $\Spec(A)$ in $X$ and if $Z \cap \Spec(A)$ is defined by the ideal $I \subset A$, then $Z_i \cap \Spec(A_i)$ is defined by the ideal $I_i \subset A_i$ which is the inverse image of $I$ in $A_i$ under the ring map $A_i \to A$, see Morphisms, Example \ref{morphisms-example-scheme-theoretic-image}. Since $\colim A_i/I_i = A/I$ it follows that $\lim Z_i = Z$. By Lemma \ref{lemma-limit-ample} we see that $\mathcal{L}_i|_{Z_i}$ is ample for some $i$. Since $Z$ and hence $X$ maps into $Z_i$ set theoretically, we see that $X_{i'} \to X_i$ maps into $Z_i$ set theoretically for some $i' \geq i$, see Lemma \ref{lemma-limit-contained-in-constructible}. (Observe that since $X_i$ is Noetherian, every closed subset of $X_i$ is constructible.) Let $T \subset X_{i'}$ be the scheme theoretic inverse image of $Z_i$ in $X_{i'}$. Observe that $\mathcal{L}_{i'}|_T$ is the pullback of $\mathcal{L}_i|_{Z_i}$ and hence ample by Morphisms, Lemma \ref{morphisms-lemma-pullback-ample-tensor-relatively-ample} and the fact that $T \to Z_i$ is an affine morphism. Thus we see that $\mathcal{L}_{i'}$ is ample on $X_{i'}$ by Cohomology of Schemes, Lemma \ref{coherent-lemma-ample-on-reduction}. Pulling back to $X$ (using the same lemma as above) we find that $\mathcal{L}$ is ample.
Since $\Spec(A)$ is quasi-compact, we may replace $W$ by a quasi-compact open still containing the image of $\Spec(A) \to X$. Recall that $X$ is quasi-separated and quasi-compact by dint of having an ample invertible sheaf, see Properties, Definition \ref{properties-definition-ample} and Lemma \ref{properties-lemma-affine-s-opens-cover-quasi-separated}. By Proposition \ref{proposition-approximate} we can write $X = \lim X_i$ as a limit of a directed system of schemes of finite type over $\mathbf{Z}$ with affine transition morphisms. For some $i$ the ample invertible sheaf $\mathcal{L}$ on $X$ descends to an ample invertible sheaf $\mathcal{L}_i$ on $X_i$ and the open $W$ is the inverse image of a quasi-compact open $W_i \subset X_i$, see Lemmas \ref{lemma-limit-ample}, \ref{lemma-descend-invertible-modules}, and \ref{lemma-descend-opens}. We may replace $X, W, \mathcal{L}$ by $X_i, W_i, \mathcal{L}_i$ and assume $X$ is of finite presentation over $\mathbf{Z}$. Write $A = \colim A_j$ as the colimit of its finite $k$-subalgebras. Then for some $j$ the morphism $\Spec(A) \to X$ factors through a morphism $\Spec(A_j) \to X$, see Proposition \ref{proposition-characterize-locally-finite-presentation}. Since $\Spec(A_j)$ is finite this reduces the lemma to Properties, Lemma \ref{properties-lemma-ample-finite-set-in-principal-affine}.
By Proposition \ref{proposition-separated-closed-in-finite-presentation} we can find a closed immersion $X \to Y$ where $Y$ is separated and of finite presentation over $S$. Clearly, if we prove the assertion for $Y$, then the result follows for $X$. Hence we may assume that $X$ is of finite presentation over $S$. \medskip\noindent Write $S = \lim_i S_i$ as a directed limit of Noetherian schemes, see Proposition \ref{proposition-approximate}. By Lemma \ref{lemma-descend-finite-presentation} we can find an index $i \in I$ and a scheme $X_i \to S_i$ of finite presentation so that $X = S \times_{S_i} X_i$. By Lemma \ref{lemma-descend-separated-finite-presentation} we may assume that $X_i \to S_i$ is separated. Clearly, if we prove the assertion for $X_i$ over $S_i$, then the assertion holds for $X$. The case $X_i \to S_i$ is treated by Cohomology of Schemes, Lemma \ref{coherent-lemma-chow-Noetherian}.
By Lemma \ref{lemma-descend-separated-finite-presentation} we see that $f_i$ is separated for some $i \geq 0$. Replacing $0$ by $i$ we may assume that $f_0$ is separated. Observe that $f_0$ is quasi-compact, see Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}. By Lemma \ref{lemma-chow-finite-type} we can choose a diagram $$ \xymatrix{ X_0 \ar[rd] & X_0' \ar[d] \ar[l]^\pi \ar[r] & \mathbf{P}^n_{Y_0} \ar[dl] \\ & Y_0 & } $$ where $X_0' \to \mathbf{P}^n_{Y_0}$ is an immersion, and $\pi : X_0' \to X_0$ is proper and surjective. Introduce $X' = X_0' \times_{Y_0} Y$ and $X_i' = X_0' \times_{Y_0} Y_i$. By Morphisms, Lemmas \ref{morphisms-lemma-composition-proper} and \ref{morphisms-lemma-base-change-proper} we see that $X' \to Y$ is proper. Hence $X' \to \mathbf{P}^n_Y$ is a closed immersion (Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}). By Morphisms, Lemma \ref{morphisms-lemma-image-proper-is-proper} it suffices to prove that $X'_i \to Y_i$ is proper for some $i$. By Lemma \ref{lemma-descend-closed-immersion-finite-presentation} we find that $X'_i \to \mathbf{P}^n_{Y_i}$ is a closed immersion for $i$ large enough. Then $X'_i \to Y_i$ is proper and we win.