hcju/stacksqa huggingface dataset:
We will use the criterion of Topology, Lemma \ref{topology-lemma-characterize-limit}. We have seen that $S_{set} = \lim_i S_{i, set}$ in Lemma \ref{lemma-inverse-limit-sets}. The maps $f_i : S \to S_i$ are morphisms of schemes hence continuous. Thus $f_i^{-1}(U_i)$ is open for each open $U_i \subset S_i$. Finally,  let $s \in S$ and let $s \in V \subset S$ be an open neighbourhood. Choose $0 \in I$ and choose an affine open neighbourhood $U_0 \subset S_0$ of the image of $s$. Then $f_0^{-1}(U_0) = \lim_{i \geq 0} f_{i0}^{-1}(U_0)$, see Lemma \ref{lemma-directed-inverse-system-has-limit}. Then $f_0^{-1}(U_0)$ and $f_{i0}^{-1}(U_0)$ are affine and $$ \mathcal{O}_S(f_0^{-1}(U_0)) = \colim_{i \geq 0} \mathcal{O}_{S_i}(f_{i0}^{-1}(U_0)) $$ either by the proof of Lemma \ref{lemma-directed-inverse-system-has-limit} or by Lemma \ref{lemma-directed-inverse-system-affine-schemes-has-limit}. Choose $a \in \mathcal{O}_S(f_0^{-1}(U_0))$ such that $s \in D(a) \subset V$. This is possible because the principal opens form a basis for the topology on the affine scheme $f_0^{-1}(U_0)$. Then we can pick an $i \geq 0$ and $a_i \in \mathcal{O}_{S_i}(f_{i0}^{-1}(U_0))$ mapping to $a$. It follows that $D(a_i) \subset f_{i0}^{-1}(U_0) \subset S_i$ is an open subset whose inverse image in $S$ is $D(a)$. This finishes the proof.
Choose $0 \in I$ and an affine open covering $U_0 = \bigcup_{j \in J} U_{0, j}$. For $i \geq 0$ let $U_{i, j} = f_{i, 0}^{-1}(U_{0, j})$ and set $U_j = f_0^{-1}(U_{0, j})$. Here $f_{i'i} : S_{i'} \to S_i$ is the transtion morphism and $f_i : S \to S_i$ is the projection. For $j \in J$ the following are equivalent: (a) $s \in U_j$, (b) $s_0 \in U_{0, j}$, (c) $s_i \in U_{i, j}$ for all $i \geq 0$. Let $J' \subset J$ be the set of indices for which (a), (b), (c) are true. Then $\overline{\{s\}} = \bigcup_{j \in J'} (\overline{\{s\}} \cap U_j)$ and similarly for $\overline{\{s_i\}}$ for $i \geq 0$. Note that $\overline{\{s\}} \cap U_j$ is the closure of the set $\{s\}$ in the topological space $U_j$. Similarly for $\overline{\{s_i\}} \cap U_{i, j}$ for $i \geq 0$. Hence it suffices to prove the lemma in the case $S$ and $S_i$ affine for all $i$. This reduces us to the algebra question considered in the next paragraph. \medskip\noindent Suppose given a system of rings $(A_i, \varphi_{ii'})$ over $I$. Set $A = \colim_i A_i$ with canonical maps $\varphi_i : A_i \to A$. Let $\mathfrak p \subset A$ be a prime and set $\mathfrak p_i = \varphi_i^{-1}(\mathfrak p)$. Then $$ V(\mathfrak p) = \lim_i V(\mathfrak p_i) $$ This follows from Lemma \ref{lemma-inverse-limit-sets} because $A/\mathfrak p = \colim A_i/\mathfrak p_i$. This equality of rings also shows the final statement about reduced induced scheme structures holds true. The equality $\kappa(\mathfrak p) = \colim \kappa(\mathfrak p_i)$ follows from the statement as well.
Write $\mathcal{A}_j = f_{i0, *} \mathcal{O}_{S_i}$. This is a quasi-coherent sheaf of $\mathcal{O}_{S_0}$-algebras (see Morphisms, Lemma \ref{morphisms-lemma-affine-equivalence-algebras}) and $S_i$ is the relative spectrum of $\mathcal{A}_i$ over $S_0$. In the proof of Lemma \ref{lemma-directed-inverse-system-has-limit} we constructed $S$ as the relative spectrum of $\mathcal{A} = \colim_{i \geq 0} \mathcal{A}_i$ over $S_0$. Set $$ \mathcal{M}_i = \mathcal{F}_0 \otimes_{\mathcal{O}_{S_0}} \mathcal{A}_i $$ and $$ \mathcal{M} = \mathcal{F}_0 \otimes_{\mathcal{O}_{S_0}} \mathcal{A}. $$ Then we have $f_{i0, *} \mathcal{F}_i = \mathcal{M}_i$ and $f_{0, *}\mathcal{F} = \mathcal{M}$. Since $\mathcal{A}$ is the colimit of the sheaves $\mathcal{A}_i$ and since tensor product commutes with directed colimits, we conclude that $\mathcal{M} = \colim_{i \geq 0} \mathcal{M}_i$. Since $S_0$ is quasi-compact and quasi-separated we see that \begin{eqnarray*} \Gamma(S, \mathcal{F}) & = & \Gamma(S_0, \mathcal{M}) \\ & = & \Gamma(S_0, \colim_{i \geq 0} \mathcal{M}_i) \\ & = & \colim_{i \geq 0} \Gamma(S_0, \mathcal{M}_i) \\ & = & \colim_{i \geq 0} \Gamma(S_i, \mathcal{F}_i) \end{eqnarray*} see Sheaves, Lemma \ref{sheaves-lemma-directed-colimits-sections} and Topology, Lemma \ref{topology-lemma-topology-quasi-separated-scheme} for the middle equality.
Let $Z_i \subset S_i$ also denote the reduced closed subscheme associated to $Z_i$, see Schemes, Definition \ref{schemes-definition-reduced-induced-scheme}. A closed immersion is affine, and a composition of affine morphisms is affine (see Morphisms, Lemmas \ref{morphisms-lemma-closed-immersion-affine} and \ref{morphisms-lemma-composition-affine}), and hence $Z_i \to S_{i'}$ is affine when $i \geq i'$. We conclude that the morphism $f_{ii'} : Z_i \to Z_{i'}$ is affine by Morphisms, Lemma \ref{morphisms-lemma-affine-permanence}. Each of the schemes $Z_i$ is quasi-compact as a closed subscheme of a quasi-compact scheme. Hence we may apply Lemma \ref{lemma-limit-nonempty} to see that $Z = \lim_i Z_i$ is nonempty. Since there is a canonical morphism $Z \to S$ we win.
Writing $S_i$ as a finite union of open affine subschemes reduces the question to the case that $S_i$ is affine and $E$ is constructible, see Lemma \ref{lemma-directed-inverse-system-has-limit} and Properties, Lemma \ref{properties-lemma-locally-constructible}. In this case the complement $S_i \setminus E$ is constructible too. Hence there exists an affine scheme $T$ and a morphism $T \to S_i$ whose image is $S_i \setminus E$, see Algebra, Lemma \ref{algebra-lemma-constructible-is-image}. By Lemma \ref{lemma-limit-fibre-product-empty} we see that $T \times_{S_i} S_{i'}$ is empty for all sufficiently large $i'$, and hence $f_{i'i}(S_{i'}) \subset E$ for all sufficiently large $i'$.
Choose $i_0 \in I$. Note that $I$ is nonempty as the limit is directed. For convenience we write $S_0 = S_{i_0}$ and $i_0 = 0$. Let $s \in S$. We may choose an affine open $U_0 \subset S_0$ containing $f_0(s)$. Since $S$ is quasi-affine we may choose an element $a \in \Gamma(S, \mathcal{O}_S)$ such that $s \in D(a) \subset f_0^{-1}(U_0)$, and such that $D(a)$ is affine. By Lemma \ref{lemma-descend-section} there exists an $i \geq 0$ such that $a$ comes from an element $a_i \in \Gamma(S_i, \mathcal{O}_{S_i})$. For any index $j \geq i$ we denote $a_j$ the image of $a_i$ in the global sections of the structure sheaf of $S_j$. Consider the opens $D(a_j) \subset S_j$ and $U_j = f_{j0}^{-1}(U_0)$. Note that $U_j$ is affine and $D(a_j)$ is a quasi-compact open of $S_j$, see Properties, Lemma \ref{properties-lemma-affine-cap-s-open} for example. Hence we may apply Lemma \ref{lemma-descend-opens} to the opens $U_j$ and $U_j \cup D(a_j)$ to conclude that $D(a_j) \subset U_j$ for some  $j \geq i$. For such an index $j$ we see that $D(a_j) \subset S_j$ is an affine open (because $D(a_j)$ is a standard affine open of the affine open $U_j$) containing the image $f_j(s)$. \medskip\noindent We conclude that for every $s \in S$ there exist an index $i \in I$, and a global section $a \in \Gamma(S_i, \mathcal{O}_{S_i})$ such that $D(a) \subset S_i$ is an affine open containing $f_i(s)$. Because $S$ is quasi-compact we may choose a single index $i \in I$ and global sections $a_1, \ldots, a_m \in \Gamma(S_i, \mathcal{O}_{S_i})$ such that each $D(a_j) \subset S_i$ is affine open and such that $f_i : S \to S_i$ has image contained in the union $W_i = \bigcup_{j = 1, \ldots, m} D(a_j)$. For $i' \geq i$ set $W_{i'} = f_{i'i}^{-1}(W_i)$. Since $f_i^{-1}(W_i)$ is all of $S$ we see (by Lemma \ref{lemma-descend-opens} again) that for a suitable $i' \geq i$ we have $S_{i'} = W_{i'}$. Thus we may replace $i$ by $i'$ and assume that $S_i = \bigcup_{j = 1, \ldots, m} D(a_j)$. This implies that $\mathcal{O}_{S_i}$ is an ample invertible sheaf on $S_i$ (see Properties, Definition \ref{properties-definition-ample}) and hence that $S_i$ is quasi-affine, see Properties, Lemma \ref{properties-lemma-quasi-affine-O-ample}. Hence we win.
By Lemma \ref{lemma-limit-quasi-affine} we may assume that $S_0$ is quasi-affine for some $0 \in I$. Set $R_0 = \Gamma(S_0, \mathcal{O}_{S_0})$. Then $S_0$ is a quasi-compact open of $T_0 = \Spec(R_0)$. Denote $j_0 : S_0 \to T_0$ the corresponding quasi-compact open immersion. For $i \geq 0$ set $\mathcal{A}_i = f_{i0, *}\mathcal{O}_{S_i}$. Since $f_{i0}$ is affine we see that $S_i = \underline{\Spec}_{S_0}(\mathcal{A}_i)$. Set $T_i = \underline{\Spec}_{T_0}(j_{0, *}\mathcal{A}_i)$. Then $T_i \to T_0$ is affine, hence $T_i$ is affine. Thus $T_i$ is the spectrum of $$ R_i = \Gamma(T_0, j_{0, *}\mathcal{A}_i) = \Gamma(S_0, \mathcal{A}_i) = \Gamma(S_i, \mathcal{O}_{S_i}). $$ Write $S = \Spec(R)$. We have $R = \colim_i R_i$ by Lemma \ref{lemma-descend-section}. Hence also $S = \lim_i T_i$. As formation of the relative spectrum commutes with base change, the inverse image of the open $S_0 \subset T_0$ in $T_i$ is $S_i$. Let $Z_0 = T_0 \setminus S_0$ and let $Z_i \subset T_i$ be the inverse image of $Z_0$. As $S_i = T_i \setminus Z_i$, it suffices to show that $Z_i$ is empty for some $i$. Assume $Z_i$ is nonempty for all $i$ to get a contradiction. By Lemma \ref{lemma-limit-closed-nonempty} there exists a point $s$ of $S = \lim T_i$ which maps to a point of $Z_i$ for every $i$. But $S = \lim_i S_i$, and hence we arrive at a contradiction by Lemma \ref{lemma-topology-limit}.
Choose a finite affine open covering $S_0 = U_{0, 1} \cup \ldots \cup U_{0, m}$. Set $U_{i, j} \subset S_i$ and $U_j \subset S$ equal to the inverse image of $U_{0, j}$. Note that $U_{i, j}$ and $U_j$ are affine. As $S$ is separated the intersections $U_{j_1} \cap U_{j_2}$ are affine. Since $U_{j_1} \cap U_{j_2} = \lim_{i \geq 0} U_{i, j_1} \cap U_{i, j_2}$ we see that $U_{i, j_1} \cap U_{i, j_2}$ is affine for large $i$ by Lemma \ref{lemma-limit-affine}. To show that $S_i$ is separated for large $i$ it now suffices to show that $$ \mathcal{O}_{S_i}(U_{i, j_1}) \otimes_{\mathcal{O}_S(S)} \mathcal{O}_{S_i}(U_{i, j_2}) \longrightarrow \mathcal{O}_{S_i}(U_{i, j_1} \cap U_{i, j_2}) $$ is surjective for large $i$ (Schemes, Lemma \ref{schemes-lemma-characterize-separated}). \medskip\noindent To get rid of the annoying indices, assume we have affine opens $U, V \subset S_0$ such that $U \cap V$ is affine too. Let $U_i, V_i \subset S_i$, resp.\ $U, V \subset S$ be the inverse images. We have to show that $\mathcal{O}(U_i) \otimes \mathcal{O}(V_i) \to \mathcal{O}(U_i \cap V_i)$ is surjective for $i$ large enough and we know that $\mathcal{O}(U) \otimes \mathcal{O}(V) \to \mathcal{O}(U \cap V)$ is surjective. Note that $\mathcal{O}(U_0) \otimes \mathcal{O}(V_0) \to \mathcal{O}(U_0 \cap V_0)$ is of finite type, as the diagonal morphism $S_i \to S_i \times S_i$ is an immersion (Schemes, Lemma \ref{schemes-lemma-diagonal-immersion}) hence locally of finite type (Morphisms, Lemmas \ref{morphisms-lemma-locally-finite-type-characterize} and \ref{morphisms-lemma-immersion-locally-finite-type}). Thus we can choose elements $f_{0, 1}, \ldots, f_{0, n} \in \mathcal{O}(U_0 \cap V_0)$ which generate $\mathcal{O}(U_0 \cap V_0)$ over $\mathcal{O}(U_0) \otimes \mathcal{O}(V_0)$. Observe that for $i \geq 0$ the diagram of schemes $$ \xymatrix{ U_i \cap V_i \ar[r] \ar[d] & U_i \ar[d] \\ U_0 \cap V_0 \ar[r] & U_0 } $$ is cartesian. Thus we see that the images $f_{i, 1}, \ldots, f_{i, n} \in \mathcal{O}(U_i \cap V_i)$ generate $\mathcal{O}(U_i \cap V_i)$ over $\mathcal{O}(U_i) \otimes \mathcal{O}(V_0)$ and a fortiori over $\mathcal{O}(U_i) \otimes \mathcal{O}(V_i)$. By assumption the images $f_1, \ldots, f_n \in \mathcal{O}(U \otimes V)$ are in the image of the map $\mathcal{O}(U) \otimes \mathcal{O}(V) \to \mathcal{O}(U \cap V)$. Since $\mathcal{O}(U) \otimes \mathcal{O}(V) = \colim \mathcal{O}(U_i) \otimes \mathcal{O}(V_i)$ we see that they are in the image of the map at some finite level and the lemma is proved.
The assumption means there are finitely many sections $s_1, \ldots, s_m \in \Gamma(S, \mathcal{L})$ such that $S_{s_j}$ is affine and such that $S = \bigcup S_{s_j}$, see Properties, Definition \ref{properties-definition-ample}. By Lemma \ref{lemma-descend-section} we can find an $i \in I$ and sections $s_{i, j} \in \Gamma(S_i, \mathcal{L}_i)$ mapping to $s_j$. By Lemma \ref{lemma-limit-affine} we may, after increasing $i$, assume that $(S_i)_{s_{i, j}}$ is affine for $j = 1, \ldots, m$. By Lemma \ref{lemma-descend-opens} we may, after increasing $i$ a last time, assume that $S_i = \bigcup (S_i)_{s_{i, j}}$. Then $\mathcal{L}_i$ is ample by definition.
Proof of (1). Choose $0 \in I$ and a finite affine open covering $X_0 = U_{0, 1} \cup \ldots \cup U_{0, m}$ with the property that $U_{0, j}$ maps into an affine open $W_j \subset S$. Let $V_j \subset Y$, resp.\ $U_{i, j} \subset X_i$, $i \geq 0$, resp. $U_j \subset X$ be the inverse image of $U_{0, j}$. It suffices to prove that $V_j \to U_{i, j}$ is a closed immersion for $i$ sufficiently large and we know that $V_j \to U_j$ is a closed immersion. Thus we reduce to the following algebra fact: If $A = \colim A_i$ is a directed colimit of $R$-algebras, $A \to B$ is a surjection of $R$-algebras, and $B$ is a finitely generated $R$-algebra, then $A_i \to B$ is surjective for $i$ sufficiently large. \medskip\noindent Proof of (2). Choose $0 \in I$. Choose a quasi-compact open $X'_0 \subset X_0$ such that $Y \to X_0$ factors through $X'_0$. After replacing $X_i$ by the inverse image of $X'_0$ for $i \geq 0$ we may assume all $X_i'$ are quasi-compact and quasi-separated. Let $U \subset X$ be a quasi-compact open such that $Y \to X$ factors through a closed immersion $Y \to U$ ($U$ exists as $Y$ is quasi-compact). By Lemma \ref{lemma-descend-opens} we may assume that $U = \lim U_i$ with $U_i \subset X_i$ quasi-compact open. By part (1) we see that $Y \to U_i$ is a closed immersion for some $i$. Thus (2) holds. \medskip\noindent Proof of (3). Working affine locally on $X_0$ for some $0 \in I$ as in the proof of (1) we reduce to the following algebra fact: If $A = \lim A_i$ is a directed colimit of $R$-algebras with surjective transition maps and $A$ of finite presentation over $A_0$, then $A = A_i$ for some $i$. Namely, write $A = A_0/(f_1, \ldots, f_n)$. Pick $i$ such that $f_1, \ldots, f_n$ map to zero under the surjective map $A_0 \to A_i$.
Let $0 \in I$. Note that $I$ is nonempty as the limit is directed. As $X_0$ is quasi-compact we can find finitely many affine opens $U_1, \ldots, U_n \subset S$ such that $X_0 \to S$ maps into $U_1 \cup \ldots \cup U_n$. Denote $h_i : X_i \to S$ the structure morphism. It suffices to check that for some $i \geq 0$ the morphisms $h_i^{-1}(U_j) \to U_j$ are separated for $j = 1, \ldots,  n$. Since $S$ is quasi-separated the morphisms $U_j \to S$ are quasi-compact. Hence $h_i^{-1}(U_j)$ is quasi-compact and quasi-separated. In this way we reduce to the case $S$ affine. In this case we have to show that $X_i$ is separated and we know that $X$ is separated. Thus the lemma follows from Lemma \ref{lemma-limit-separated}.
Choose a finite affine open covering $S = \bigcup_{j = 1, \ldots, n} V_j$. Denote $f : X \to S$ and $f_i : X_i \to S$ the structure morphisms. For each $j$ the scheme $f^{-1}(V_j) = \lim_i f_i^{-1}(V_j)$ is affine (as a finite morphism is affine by definition). Hence by Lemma \ref{lemma-limit-affine} there exists an $i \in I$ such that each $f_i^{-1}(V_j)$ is affine. In other words, $f_i : X_i \to S$ is affine for $i$ large enough, see Morphisms, Lemma \ref{morphisms-lemma-characterize-affine}.
By Lemma \ref{lemma-eventually-affine} we may assume $X_i \to S$ is affine for all $i$. Choose a finite affine open covering $S = \bigcup_{j = 1, \ldots, n} V_j$. Denote $f : X \to S$ and $f_i : X_i \to S$ the structure morphisms. It suffices to show that there exists an $i$ such that $f_i^{-1}(V_j)$ is finite over $V_j$ for $j = 1, \ldots, m$ (Morphisms, Lemma \ref{morphisms-lemma-finite-local}). Namely, for $i' \geq i$ the composition $X_{i'} \to X_i \to S$ will be finite as a composition of finite morphisms (Morphisms, Lemma \ref{morphisms-lemma-composition-finite}). This reduces us to the affine case: Let $R$ be a ring and $A = \colim A_i$ with $R \to A$ integral and $A_i \to A_{i'}$ finite for all $i \leq i'$. Moreover $R \to A_i$ is of finite type for all $i$. Goal: Show that $A_i$ is finite over $R$ for some $i$. To prove this choose an $i \in I$ and pick generators $x_1, \ldots, x_m \in A_i$ of $A_i$ as an $R$-algebra. Since $A$ is integral over $R$ we can find monic polynomials $P_j \in R[T]$ such that $P_j(x_j) = 0$ in $A$. Thus there exists an $i' \geq i$ such that $P_j(x_j) = 0$ in $A_{i'}$ for $j = 1, \ldots, m$. Then the image $A'_i$ of $A_i$ in $A_{i'}$ is finite over $R$ by Algebra, Lemma \ref{algebra-lemma-characterize-finite-in-terms-of-integral}. Since $A'_i \subset A_{i'}$ is finite too we conclude that $A_{i'}$ is finite over $R$ by Algebra, Lemma \ref{algebra-lemma-finite-transitive}.
By Lemma \ref{lemma-eventually-affine} we may assume $X_i \to S$ is affine for all $i$. Choose a finite affine open covering $S = \bigcup_{j = 1, \ldots, n} V_j$. Denote $f : X \to S$ and $f_i : X_i \to S$ the structure morphisms. It suffices to show that there exists an $i$ such that $f_i^{-1}(V_j)$ is a closed subscheme of $V_j$ for $j = 1, \ldots, m$ (Morphisms, Lemma \ref{morphisms-lemma-closed-immersion}). This reduces us to the affine case: Let $R$ be a ring and $A = \colim A_i$ with $R \to A$ surjective and $A_i \to A_{i'}$ surjective for all $i \leq i'$. Moreover $R \to A_i$ is of finite type for all $i$. Goal: Show that $R \to A_i$ is surjective for some $i$. To prove this choose an $i \in I$ and pick generators $x_1, \ldots, x_m \in A_i$ of $A_i$ as an $R$-algebra. Since $R \to A$ is surjective we can find $r_j \in R$ such that $r_j$ maps to $x_j$ in $A$. Thus there exists an $i' \geq i$ such that $r_j$ maps to the image of $x_j$ in $A_{i'}$ for $j = 1, \ldots, m$. Since $A_i \to A_{i'}$ is surjective this implies that $R \to A_{i'}$ is surjective.
The proof is exactly the same as the proof of the implication ``(2) implies (1)'' in Proposition \ref{proposition-characterize-locally-finite-presentation}. Choose any affine opens $U \subset X$ and $V \subset S$ such that $f(U) \subset V$. We have to show that $\mathcal{O}_S(V) \to \mathcal{O}_X(U)$ is of finite presentation. Let $(A_i, \varphi_{ii'})$ be a directed system of $\mathcal{O}_S(V)$-algebras. Set $A = \colim_i A_i$. According to Algebra, Lemma \ref{algebra-lemma-characterize-finite-presentation} it suffices to show that $$ \colim_i \Hom_{\mathcal{O}_S(V)}(\mathcal{O}_X(U), A_i) \to \Hom_{\mathcal{O}_S(V)}(\mathcal{O}_X(U), A) $$ is surjective. Consider the schemes $T_i = \Spec(A_i)$. They form an inverse system of $V$-schemes over $I$ with transition morphisms $f_{ii'} : T_i \to T_{i'}$ induced by the $\mathcal{O}_S(V)$-algebra maps $\varphi_{i'i}$. Set $T := \Spec(A) = \lim_i T_i$. The formula above becomes in terms of morphism sets of schemes $$ \colim_i \Mor_V(T_i, U) \to \Mor_V(\lim_i T_i, U) $$ We first observe that $\Mor_V(T_i, U) = \Mor_S(T_i, U)$ and $\Mor_V(T, U) = \Mor_S(T, U)$. Hence we have to show that $$ \colim_i \Mor_S(T_i, U) \to \Mor_S(\lim_i T_i, U) $$ is surjective and we are given that $$ \colim_i \Mor_S(T_i, X) \to \Mor_S(\lim_i T_i, X) $$ is surjective. Hence it suffices to prove that given a morphism $g_i : T_i \to X$ over $S$ such that the composition $T \to T_i \to X$ ends up in $U$ there exists some $i' \geq i$ such that the composition $g_{i'} : T_{i'} \to T_i \to X$ ends up in $U$. Denote $Z_{i'} = g_{i'}^{-1}(X \setminus U)$. Assume each $Z_{i'}$ is nonempty to get a contradiction. By Lemma \ref{lemma-limit-closed-nonempty} there exists a point $t$ of $T$ which is mapped into $Z_{i'}$ for all $i' \geq i$. Such a point is not mapped into $U$. A contradiction.
Since $f(X)$ is quasi-compact we may replace $S$ by a quasi-compact open containing $f(X)$. Hence we may assume $S$ is quasi-compact as well. Write $X = \lim X_a$ and $S = \lim S_b$ as in Proposition \ref{proposition-approximate}, i.e., with $X_a$ and $S_b$ of finite type over $\mathbf{Z}$ and with affine transition morphisms. By Proposition \ref{proposition-characterize-locally-finite-presentation} we find that for each $b$ there exists an $a$ and a morphism $f_{a, b} : X_a \to S_b$ making the diagram $$ \xymatrix{ X \ar[d] \ar[r] & S \ar[d] \\ X_a \ar[r] & S_b } $$ commute. Moreover the same proposition implies that, given a second triple $(a', b', f_{a', b'})$, there exists an $a'' \geq a'$ such that the compositions $X_{a''} \to X_a \to S_b$ and $X_{a''} \to X_{a'} \to S_{b'} \to S_b$ are equal. Consider the set of triples $(a, b, f_{a, b})$ endowed with the preorder $$ (a, b, f_{a, b}) \geq (a', b', f_{a', b'}) \Leftrightarrow a \geq a',\ b' \geq b,\text{ and } f_{a', b'} \circ h_{a, a'} = g_{b', b} \circ f_{a, b} $$ where $h_{a, a'} : X_a \to X_{a'}$ and $g_{b', b} : S_{b'} \to S_b$ are the transition morphisms. The remarks above show that this system is directed. It follows formally from the equalities $X = \lim X_a$ and $S = \lim S_b$ that $$ X = \lim_{(a, b, f_{a, b})} X_a \times_{f_{a, b}, S_b} S. $$ where the limit is over our directed system above. The transition morphisms $X_a \times_{S_b} S \to X_{a'} \times_{S_{b'}} S$ are affine as the composition $$ X_a \times_{S_b} S \to X_a \times_{S_{b'}} S \to X_{a'} \times_{S_{b'}} S $$ where the first morphism is a closed immersion (by Schemes, Lemma \ref{schemes-lemma-fibre-product-after-map}) and the second is a base change of an affine morphism (Morphisms, Lemma \ref{morphisms-lemma-base-change-affine}) and the composition of affine morphisms is affine (Morphisms, Lemma \ref{morphisms-lemma-composition-affine}). The morphisms $f_{a, b}$ are of finite presentation (Morphisms, Lemmas \ref{morphisms-lemma-noetherian-finite-type-finite-presentation} and \ref{morphisms-lemma-finite-presentation-permanence}) and hence the base changes $X_a \times_{f_{a, b}, S_b} S \to S$ are of finite presentation (Morphisms, Lemma \ref{morphisms-lemma-base-change-finite-presentation}).
Consider the sheaf $\mathcal{A} = f_*\mathcal{O}_X$. This is a quasi-coherent sheaf of $\mathcal{O}_S$-algebras, see Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent}. Combining Properties, Lemma \ref{properties-lemma-integral-algebra-directed-colimit-finite} we can write $\mathcal{A} = \colim_i \mathcal{A}_i$ as a filtered colimit of finite and finitely presented $\mathcal{O}_S$-algebras. Then $$ X_i = \underline{\Spec}_S(\mathcal{A}_i) \longrightarrow S $$ is a finite and finitely presented morphism of schemes. By construction $X = \lim_i X_i$ which proves the lemma.
Let $Y_0 = \bigcup_{j = 1, \ldots, m} V_{j, 0}$ be a finite affine open covering. Set $U_{j, 0} = f_0^{-1}(V_{j, 0})$. For $i \geq 0$ we denote $V_{j, i}$ the inverse image of $V_{j, 0}$ in $Y_i$ and $U_{j, i} = f_i^{-1}(V_{j, i})$. Similarly we have $U_j = f^{-1}(V_j)$. Then $U_j = \lim_{i \geq 0} U_{j, i}$ (see Lemma \ref{lemma-directed-inverse-system-has-limit}). Since $U_j$ is affine by assumption we see that each $U_{j, i}$ is affine for $i$ large enough, see Lemma \ref{lemma-limit-affine}. As there are finitely many $j$ we can pick an $i$ which works for all $j$. Thus $f_i$ is affine for $i$ large enough, see Morphisms, Lemma \ref{morphisms-lemma-characterize-affine}.
A finite morphism is affine, see Morphisms, Definition \ref{morphisms-definition-integral}. 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 follows from Algebra, Lemma \ref{algebra-lemma-colimit-finite}.