hcju/stacksqa huggingface dataset:
Assume $X$ is universally closed and $f$ surjective. Denote $p : X \to S$, $q : Y \to S$ the structure morphisms. Let $S' \to S$ be a morphism of schemes. The base change $f' : X_{S'} \to Y_{S'}$ is surjective (Lemma \ref{lemma-base-change-surjective}), and the base change $p' : X_{S'} \to S'$ is closed. If $T \subset Y_{S'}$ is closed, then $(f')^{-1}(T) \subset X_{S'}$ is closed, hence $p'((f')^{-1}(T)) = q'(T)$ is closed. So $q'$ is closed. This proves the first statement. Thus $Y \to S$ is quasi-compact by Lemma \ref{lemma-universally-closed-quasi-compact} and hence $Y \to S$ is proper by definition if in addition $Y \to S$ is locally of finite type and separated.
The scheme theoretic image of $h$ is constructed in Section \ref{section-scheme-theoretic-image}. Since $f$ is quasi-compact (Lemma \ref{lemma-universally-closed-quasi-compact}) we find that $h$ is quasi-compact (Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}). Hence $h(X) \subset Z$ is dense (Lemma \ref{lemma-quasi-compact-scheme-theoretic-image}). On the other hand $h(X)$ is closed in $Y$ (Lemma \ref{lemma-image-proper-scheme-closed}) hence $X \to Z$ is surjective. Thus $Z \to S$ is a proper (Lemma \ref{lemma-image-proper-is-proper}).
Parts (1) and (2) are a consequence of (3) and (4) for $S = \Spec(\mathbf{Z})$ (see Schemes, Definition \ref{schemes-definition-separated}). Consider the commutative diagram $$ \xymatrix{ X \ar[d] \ar[rr]_{\Delta_{X/S}} & & X \times_S X \ar[d] \\ Y \ar[rr]^{\Delta_{Y/S}} & & Y \times_S Y } $$ The left vertical arrow is surjective (i.e., universally surjective). The right vertical arrow is universally closed as a composition of the universally closed morphisms $X \times_S X \to X \times_S Y \to Y \times_S Y$. Hence it is also quasi-compact, see Lemma \ref{lemma-universally-closed-quasi-compact}. \medskip\noindent Assume $X$ is quasi-separated over $S$, i.e.,  $\Delta_{X/S}$ is quasi-compact. If $V \subset Y \times_S Y$ is a quasi-compact open, then $V \times_{Y \times_S Y} X \to \Delta_{Y/S}^{-1}(V)$ is surjective and $V \times_{Y \times_S Y} X$ is quasi-compact by our remarks above. We conclude that $\Delta_{Y/S}$ is quasi-compact, i.e., $Y$ is quasi-separated over $S$. \medskip\noindent Assume $X$ is separated over $S$, i.e., $\Delta_{X/S}$ is a closed immersion. Then $X \to Y \times_S Y$ is closed as a composition of closed morphisms. Since $X \to Y$ is surjective, it follows that $\Delta_{Y/S}(Y)$ is closed in $Y \times_S Y$. Hence $Y$ is separated over $S$ by the discussion following Schemes, Definition \ref{schemes-definition-separated}.
Proof of (1). We may replace $X$, $Y$, $S$ by suitable affine open neighbourhoods of $x$, $y$, $s$ and reduce to the following algebra problem: given a ring $R$, two $R$-algebra maps $\varphi, \psi : B \to A$ such that \begin{enumerate} \item $R \to B$ is of finite type, or $A$ is a domain, or $A$ is Noetherian, or $A$ is reduced and has finitely many minimal primes, \item the two maps $B \to A_\mathfrak p$ are the same for some prime $\mathfrak p \subset A$, \end{enumerate} show that $\varphi, \psi$ define the same map $B \to A_g$ for a suitable $g \in A$, $g \not \in \mathfrak p$. If $R \to B$ is of finite type, let $t_1, \ldots, t_m \in B$ be generators of $B$ as an $R$-algebra. For each $j$ we can find $g_j \in A$, $g_j \not \in \mathfrak p$ such that $\varphi(t_j)$ and $\psi(t_j)$ have the same image in $A_{g_j}$. Then we set $g = \prod g_j$. In the other cases (if $A$ is a domain, Noetherian, or reduced with finitely many minimal primes), we can find a $g \in A$, $g \not \in \mathfrak p$ such that $A_g \subset A_\mathfrak p$. See Algebra, Lemma \ref{algebra-lemma-subring-of-local-ring}. Thus the maps $B \to A_g$ are equal as desired. \medskip\noindent Proof of (2). To do this we may replace $X$, $Y$, and $S$ by suitable affine opens. Say $X = \Spec(A)$, $Y = \Spec(B)$, and $S = \Spec(R)$. Let $\mathfrak p \subset A$ be the prime ideal corresponding to $x$. Let $\mathfrak q \subset B$ be the prime corresponding to $y$. Then $\varphi$ is a local $R$-algebra map $\varphi : B_\mathfrak q \to A_\mathfrak p$. If $R \to B$ is a ring map of finite presentation, then there exists a $g \in A \setminus \mathfrak p$ and an $R$-algebra map $B \to A_g$ such that $$ \xymatrix{ B_\mathfrak q \ar[r]_\varphi & A_\mathfrak p \\ B \ar[u] \ar[r] & A_g \ar[u] } $$ commutes, see Algebra, Lemmas \ref{algebra-lemma-characterize-finite-presentation} and \ref{algebra-lemma-localization-colimit}. The induced morphism $\Spec(A_g) \to \Spec(B)$ works. If $B$ is of finite type over $R$, let $t_1, \ldots, t_m \in B$ be generators of $B$ as an $R$-algebra. Then we can choose $g_j \in A$, $g_j \not \in \mathfrak p$ such that $\varphi(t_j) \in \Im(A_{g_j} \to A_\mathfrak p)$. Thus after replacing $A$ by $A[1/\prod g_j]$ we may assume that $B$ maps into the image of $A \to A_\mathfrak p$. If we can find a $g \in A$, $g \not \in \mathfrak p$ such that $A_g \to A_\mathfrak p$ is injective, then we'll get the desired $R$-algebra map $B \to A_g$. Thus the proof is finished by another application of See Algebra, Lemma \ref{algebra-lemma-subring-of-local-ring}.
It is harmless to replace $X$ by an open neighbourhood of $x$ in $X$ (small detail omitted). By Properties, Lemma \ref{properties-lemma-ring-affine-open-injective-local-ring} we may assume $X$ is affine with $\Gamma(X, \mathcal{O}_X) \subset \mathcal{O}_{X, x}$. In particular $X$ is integral with a unique generic point $\xi$ whose residue field is the fraction field $K$ of the valuation ring $\mathcal{O}_{X, x}$. Since $x$ is in the closure of $U$ we see that $U$ is not empty, hence $U$ contains $\xi$. Thus by the valuative criterion of properness (Lemma \ref{lemma-characterize-proper}) there is a morphism $t : \Spec(\mathcal{O}_{X, x}) \to Y$ fitting into a commutative diagram $$ \xymatrix{ \Spec(K) \ar[d]_\xi \ar[r] & \Spec(\mathcal{O}_{X, x}) \ar[d]_t \\ U \ar[r]^f & Y } $$ of morphisms of schemes over $S$. Applying Lemma \ref{lemma-morphism-defined-local-ring} with $y = t(x)$ and $\varphi = t^\sharp_x$ we obtain an open neighbourhood $V \subset X$ of $x$ and a morphism $g : V \to Y$ over $S$ which sends $x$ to $y$ and such that $g^\sharp_x = t^\sharp_x$. As $Y \to S$ is separated, the equalizer $E$ of $f|_{U \cap V}$ and $g|_{U \cap V}$ is a closed subscheme of $U \cap V$, see Schemes, Lemma \ref{schemes-lemma-where-are-they-equal}. Since $f$ and $g$ determine the same morphism $\Spec(K) \to Y$ by construction we see that $E$ contains the generic point of the integral scheme $U \cap V$. Hence $E = U \cap V$ and we conclude that $f$ and $g$ glue to a morphism $U' = U \cup V \to Y$ as desired.
By Lemma \ref{lemma-H-projective} we see that (2) implies (1). Assume (1). For every point $s \in S$ we can find $\Spec(R) = U \subset S$ an affine open neighbourhood of $s$ such that $X_U$ is isomorphic to a closed subscheme of $\mathbf{P}(\mathcal{E})$ for some finite type, quasi-coherent sheaf of $\mathcal{O}_U$-modules $\mathcal{E}$. Write $\mathcal{E} = \widetilde{M}$ for some finite type $R$-module $M$ (see Properties, Lemma \ref{properties-lemma-finite-type-module}). Choose generators $x_0, \ldots, x_n \in M$ of $M$ as an $R$-module. Consider the surjective graded $R$-algebra map $$ R[X_0, \ldots, X_n] \longrightarrow \text{Sym}_R(M). $$ According to Constructions, Lemma \ref{constructions-lemma-surjective-graded-rings-map-proj} the corresponding morphism $$ \mathbf{P}(\mathcal{E}) \to \mathbf{P}^n_R $$ is a closed immersion. Hence we conclude that $f^{-1}(U)$ is isomorphic to a closed subscheme of $\mathbf{P}^n_U$ (as a scheme over $U$). In other words: (2) holds.
Let $f : X \to S$ be locally projective. In order to show that $f$ is proper we may work locally on the base, see Lemma \ref{lemma-proper-local-on-the-base}. Hence, by Lemma \ref{lemma-characterize-locally-projective} above we may assume there exists a closed immersion $X \to \mathbf{P}^n_S$. By Lemmas \ref{lemma-composition-proper} and \ref{lemma-closed-immersion-proper} it suffices to prove that $\mathbf{P}^n_S \to S$ is proper. Since $\mathbf{P}^n_S \to S$ is the base change of $\mathbf{P}^n_{\mathbf{Z}} \to \Spec(\mathbf{Z})$ it suffices to show that $\mathbf{P}^n_{\mathbf{Z}} \to \Spec(\mathbf{Z})$ is proper, see Lemma \ref{lemma-base-change-proper}. By Constructions, Lemma \ref{constructions-lemma-proj-separated} the scheme $\mathbf{P}^n_{\mathbf{Z}}$ is separated. By Constructions, Lemma \ref{constructions-lemma-proj-quasi-compact} the scheme $\mathbf{P}^n_{\mathbf{Z}}$ is quasi-compact. It is clear that $\mathbf{P}^n_{\mathbf{Z}} \to \Spec(\mathbf{Z})$ is locally of finite type since $\mathbf{P}^n_{\mathbf{Z}}$ is covered by the affine opens $D_{+}(X_i)$ each of which is the spectrum of the finite type $\mathbf{Z}$-algebra $$ \mathbf{Z}[X_0/X_i, \ldots, X_n/X_i]. $$ Finally, we have to show that $\mathbf{P}^n_{\mathbf{Z}} \to \Spec(\mathbf{Z})$ is universally closed. This follows from Constructions, Lemma \ref{constructions-lemma-proj-valuative-criterion} and the valuative criterion (see Schemes, Proposition \ref{schemes-proposition-characterize-universally-closed}).
If there exists an $f$-ample invertible sheaf, then we can locally on $S$ find an immersion $i : X \to \mathbf{P}^n_S$, see Lemma \ref{lemma-finite-type-over-affine-ample-very-ample}. Since $X \to S$ is proper the morphism $i$ is a closed immersion, see Lemma \ref{lemma-image-proper-scheme-closed}.
Suppose $X \to Y$ and $Y \to Z$ are H-projective. Then there exist closed immersions $X \to \mathbf{P}^n_Y$ over $Y$, and $Y \to \mathbf{P}^m_Z$ over $Z$. Consider the following diagram $$ \xymatrix{ X \ar[r] \ar[d] & \mathbf{P}^n_Y \ar[r] \ar[dl] & \mathbf{P}^n_{\mathbf{P}^m_Z} \ar[dl] \ar@{=}[r] & \mathbf{P}^n_Z \times_Z \mathbf{P}^m_Z \ar[r] & \mathbf{P}^{nm + n + m}_Z \ar[ddllll] \\ Y \ar[r] \ar[d] & \mathbf{P}^m_Z \ar[dl] & \\ Z & & } $$ Here the rightmost top horizontal arrow is the Segre embedding, see Constructions, Lemma \ref{constructions-lemma-segre-embedding}. The diagram identifies $X$ as a closed subscheme of $\mathbf{P}^{nm + n + m}_Z$ as desired.
This is true because the base change of a projective bundle over a scheme is a projective bundle, the pullback of a finite type $\mathcal{O}$-module is of finite type (Modules, Lemma \ref{modules-lemma-pullback-finite-type}) and the fact that the base change of a closed immersion is a closed immersion, see Schemes, Lemma \ref{schemes-lemma-base-change-immersion}. Some details omitted.
Let $f : X \to S$ be a projective morphism. Choose a closed immersion $i : X \to \mathbf{P}(\mathcal{E})$ where $\mathcal{E}$ is a quasi-coherent, finite type $\mathcal{O}_S$-module. Then $\mathcal{L} = i^*\mathcal{O}_{\mathbf{P}(\mathcal{E})}(1)$ is $f$-very ample. Since $f$ is proper (Lemma \ref{lemma-locally-projective-proper}) it is quasi-compact. Hence Lemma \ref{lemma-ample-very-ample} implies that $\mathcal{L}$ is $f$-ample. Since $f$ is proper it is of finite type. Thus we've checked all the defining properties of quasi-projective holds and we win.
By definition we can factor $f$ as a quasi-compact immersion $i : X \to \mathbf{P}^n_S$ followed by the projection $\mathbf{P}^n_S \to S$. By Lemma \ref{lemma-quasi-compact-immersion} there exists a closed subscheme $X' \subset \mathbf{P}^n_S$ such that $i$ factors through an open immersion $X \to X'$. The lemma follows.
Let $\mathcal{L}$ be $f$-ample. Since $f$ is of finite type and $S$ is quasi-compact $\mathcal{L}^{\otimes n}$ is $f$-very ample for some $n > 0$, see Lemma \ref{lemma-finite-type-ample-very-ample}. Replace $\mathcal{L}$ by $\mathcal{L}^{\otimes n}$. Write $\mathcal{F} = f_*\mathcal{L}$. This is a quasi-coherent $\mathcal{O}_S$-module by  Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent} (quasi-projective morphisms are quasi-compact and separated, see Lemma \ref{lemma-quasi-projective-properties}). By Properties, Lemma \ref{properties-lemma-directed-colimit-finite-presentation} we can find a directed set $I$ and a system of finite type quasi-coherent $\mathcal{O}_S$-modules $\mathcal{E}_i$ over $I$ such that $\mathcal{F} = \colim \mathcal{E}_i$. Consider the compositions $\psi_i : f^*\mathcal{E}_i \to f^*\mathcal{F} \to \mathcal{L}$. Choose a finite affine open covering $S = \bigcup_{j = 1, \ldots, m} V_j$. For each $j$ we can choose sections $$ s_{j, 0}, \ldots, s_{j, n_j} \in \Gamma(f^{-1}(V_j), \mathcal{L}) = f_*\mathcal{L}(V_j) = \mathcal{F}(V_j) $$ which generate $\mathcal{L}$ over $f^{-1}V_j$ and define an immersion $$ f^{-1}V_j \longrightarrow \mathbf{P}^{n_j}_{V_j}, $$ see Lemma \ref{lemma-very-ample-finite-type-over-affine}. Choose $i$ such that there exist sections $e_{j, t} \in \mathcal{E}_i(V_j)$ mapping to $s_{j, t}$ in $\mathcal{F}$ for all $j = 1, \ldots, m$ and $t = 1, \ldots, n_j$. Then the map $\psi_i$ is surjective as the sections $f^*e_{j, t}$ have the same image as the sections $s_{j, t}$ which generate $\mathcal{L}|_{f^{-1}V_j}$. Whence we obtain a morphism $$ r_{\mathcal{L}, \psi_i} : X \longrightarrow \mathbf{P}(\mathcal{E}_i) $$ over $S$ such that over $V_j$ we have a factorization $$ f^{-1}V_j \to \mathbf{P}(\mathcal{E}_i)|_{V_j} \to \mathbf{P}^{n_j}_{V_j} $$ of the immersion given above. It follows that $r_{\mathcal{L}, \psi_i}|_{V_j}$ is an immersion, see Lemma \ref{lemma-immersion-permanence}. Since $S = \bigcup V_j$ we conclude that $r_{\mathcal{L}, \psi_i}$ is an immersion. Note that $r_{\mathcal{L}, \psi_i}$ is quasi-compact as $X \to S$ is quasi-compact and $\mathbf{P}(\mathcal{E}_i) \to S$ is separated (see Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}). By Lemma \ref{lemma-quasi-compact-immersion} there exists a closed subscheme $X' \subset \mathbf{P}(\mathcal{E}_i)$ such that $i$ factors through an open immersion $X \to X'$. Then $X' \to S$ is projective by definition and we win.
If $f$ is projective, then $f$ is quasi-projective by Lemma \ref{lemma-projective-quasi-projective} and proper by Lemma \ref{lemma-locally-projective-proper}. Conversely, if $X \to S$ is quasi-projective and proper, then we can choose an open immersion $X \to X'$ with $X' \to S$ projective by Lemma \ref{lemma-quasi-projective-open-projective}. Since $X \to S$ is proper, we see that $X$ is closed in $X'$ (Lemma \ref{lemma-image-proper-scheme-closed}), i.e., $X \to X'$ is a (open and) closed immersion. Since $X'$ is isomorphic to a closed subscheme of a projective bundle over $S$ (Definition \ref{definition-projective}) we see that the same thing is true for $X$, i.e., $X \to S$ is a projective morphism. This proves (1). The proof of (2) is the same, except it uses Lemmas \ref{lemma-H-projective} and \ref{lemma-H-quasi-projective-open-H-projective}.
By Lemmas \ref{lemma-projective-quasi-projective} and \ref{lemma-locally-projective-proper} we see that $f$ and $g$ are quasi-projective and proper. By Lemmas \ref{lemma-composition-proper} and \ref{lemma-composition-quasi-projective} we see that $g \circ f$ is proper and quasi-projective. Thus $g \circ f$ is projective by Lemma \ref{lemma-projective-is-quasi-projective-proper}.
Choose a closed immersion $X \to \mathbf{P}(\mathcal{E})$ where $\mathcal{E}$ is a quasi-coherent, finite type $\mathcal{O}_S$-module. Then we get a morphism $X \to \mathbf{P}(\mathcal{E}) \times_S Y$. This morphism is a closed immersion because it is the composition $$ X \to X \times_S Y \to \mathbf{P}(\mathcal{E}) \times_S Y $$ where the first morphism is a closed immersion by Schemes, Lemma \ref{schemes-lemma-semi-diagonal} (and the fact that $g$ is separated) and the second as the base change of a closed immersion. Finally, the fibre product $\mathbf{P}(\mathcal{E}) \times_S Y$ is isomorphic to $\mathbf{P}(g^*\mathcal{E})$ and pullback preserves quasi-coherent, finite type modules.
The assumptions on $S$ imply that $S$ is quasi-compact and separated, see Properties, Definition \ref{properties-definition-ample} and Lemma \ref{properties-lemma-ample-immersion-into-proj} and Constructions, Lemma \ref{constructions-lemma-proj-separated}. Hence Lemma \ref{lemma-quasi-projective-open-projective} applies and we see that (1) implies (2). Let $\mathcal{E}$ be a finite type quasi-coherent $\mathcal{O}_S$-module. By our definition of projective morphisms it suffices to show that $\mathbf{P}(\mathcal{E}) \to S$ is H-projective. If $\mathcal{E}$ is generated by finitely many global sections, then the corresponding surjection $\mathcal{O}_S^{\oplus n} \to \mathcal{E}$ induces a closed immersion $$ \mathbf{P}(\mathcal{E}) \longrightarrow \mathbf{P}(\mathcal{O}_S^{\oplus n}) = \mathbf{P}^n_S $$ as desired. In general, let $\mathcal{L}$ be an invertible sheaf on $S$. By Properties, Proposition \ref{properties-proposition-characterize-ample} there exists an integer $n$ such that $\mathcal{E} \otimes_{\mathcal{O}_S} \mathcal{L}^{\otimes n}$ is globally generated by finitely many sections. Since $\mathbf{P}(\mathcal{E}) = \mathbf{P}(\mathcal{E} \otimes_{\mathcal{O}_S} \mathcal{L}^{\otimes n})$ by Constructions, Lemma \ref{constructions-lemma-twisting-and-proj} this finishes the proof.
Observe that $f$ is quasi-compact because the existence of an $f$-ample invertible module forces $f$ to be quasi-compact. By the lemma cited the morphism $r$ is an open immersion. On the other hand, the image of $r$ is closed by Lemma \ref{lemma-image-proper-scheme-closed} (the target of $r$ is separated over $S$ by Constructions, Lemma \ref{constructions-lemma-relative-proj-separated}). Finally, the image of $r$ is dense by Properties, Lemma \ref{properties-lemma-ample-immersion-into-proj} (here we also use that it was shown in the proof of Lemma \ref{lemma-characterize-relatively-ample} that the morphism $r$ over affine opens of $S$ is given by the canonical morphism of Properties, Lemma \ref{properties-lemma-map-into-proj}). Thus we conclude that $r$ is a surjective open immersion, i.e., an isomorphism.
The question is local on $S$ (Lemma \ref{lemma-characterize-affine}) hence we may assume $S$ is affine. By Lemma \ref{lemma-proper-ample-is-proj} we can write $X = \text{Proj}(A)$ where $A$ is a graded ring and $s$ corresponds to $f \in A_1$ and $X_s = D_+(f)$ (Properties, Lemma \ref{properties-lemma-map-into-proj}) which proves the lemma by construction of $\text{Proj}(A)$, see Constructions, Section \ref{constructions-section-proj}.
Assume (1). An integral morphism is affine by definition. A base change of an integral morphism is integral so in order to prove (2) it suffices to show that an integral morphism is closed. This follows from Algebra, Lemmas \ref{algebra-lemma-integral-going-up} and \ref{algebra-lemma-going-up-closed}. \medskip\noindent Assume (2). We may assume $f$ is the morphism $f : \Spec(A) \to \Spec(R)$ coming from a ring map $R \to A$. Let $a$ be an element of $A$. We have to show that $a$ is integral over $R$, i.e. that in the kernel $I$ of the map $R[x] \to A$ sending $x$ to $a$ there is a monic polynomial. Consider the ring $B = A[x]/(ax -1)$ and let $J$ be the kernel of the composition $R[x]\to A[x] \to B$. If $f\in J$ there exists $q\in A[x]$ such that $f = (ax-1)q$ in $A[x]$ so if $f = \sum_i f_ix^i$ and $q = \sum_iq_ix^i$, for all $i \geq 0$ we have $f_i = aq_{i-1} - q_i$. For $n \geq \deg q + 1$ the polynomial $$ \sum\nolimits_{i \geq 0} f_i x^{n - i} = \sum\nolimits_{i \geq 0} (a q_{i - 1} - q_i) x^{n - i} = (a - x) \sum\nolimits_{i \geq 0} q_i x^{n - i - 1} $$ is clearly in $I$; if $f_0 = 1$ this polynomial is also monic, so we are reduced to prove that $J$ contains a polynomial with constant term $1$. We do it by proving $\Spec(R[x]/(J + (x))$ is empty. \medskip\noindent Since $f$ is universally closed the base change $\Spec(A[x]) \to \Spec(R[x])$ is closed. Hence the image of the closed subset $\Spec(B) \subset \Spec(A[x])$ is the closed subset $\Spec(R[x]/J) \subset \Spec(R[x])$, see Example \ref{example-scheme-theoretic-image} and Lemma \ref{lemma-quasi-compact-scheme-theoretic-image}. In particular $\Spec(B) \to \Spec(R[x]/J)$ is surjective. Consider the following diagram where every square is a pullback: $$ \xymatrix{ \Spec(B) \ar@{->>}[r]^g & \Spec(R[x]/J)  \ar[r] & \Spec(R[x])\\ \emptyset \ar[u] \ar[r] & \Spec(R[x]/(J + (x)))\ar[u] \ar[r] & \Spec(R) \ar[u]^0 } $$ The bottom left corner is empty because it is the spectrum of $R\otimes_{R[x]} B$ where the map $R[x]\to B$ sends $x$ to an invertible element and $R[x]\to R$ sends $x$ to $0$. Since $g$ is surjective this implies $\Spec(R[x]/(J + (x)))$ is empty, as we wanted to show.
Since the dimension of $X$ and $Y$ is the supremum of the dimensions of the members of an affine open covering, we may assume $Y$ and $X$ are affine. The inequality follows from Algebra, Lemma \ref{algebra-lemma-integral-dim-up}. The equality then follows from Algebra, Lemmas \ref{algebra-lemma-dimension-going-up} and \ref{algebra-lemma-integral-going-up}.
This is implied by Algebra, Lemma \ref{algebra-lemma-quasi-finite} and Lemma \ref{lemma-quasi-finite-locally-quasi-compact}. Alternatively, all points in fibres are closed points by Lemma \ref{lemma-integral-fibres} (and the fact that a finite morphism is integral) and use Lemma \ref{lemma-quasi-finite-at-point-characterize} (3) to see that $f$ is quasi-finite at $x$ for all $x \in X$.
Assume $g \circ f$ is finite (resp.\ integral) and $g$ separated. The base change $X \times_Z Y \to Y$ is finite (resp.\ integral) by Lemma \ref{lemma-base-change-finite}. The morphism $X \to X \times_Z Y$ is a closed immersion as $Y \to Z$ is separated, see Schemes, Lemma \ref{schemes-lemma-section-immersion}. A closed immersion is finite (resp.\ integral), see Lemma \ref{lemma-closed-immersion-finite}. The composition of finite (resp.\ integral) morphisms is finite (resp.\ integral), see Lemma \ref{lemma-composition-finite}. Thus we win.
Let $f : X \to S$ be a finite morphism. Then $f_*\mathcal{O}_X$ is a quasi-coherent $\mathcal{O}_S$-module (Lemma \ref{lemma-affine-equivalence-algebras}) of finite type (by our definition of finite morphisms and Properties, Lemma \ref{properties-lemma-finite-type-module}). We claim there is a closed immersion $$ \sigma : X \longrightarrow \mathbf{P}(f_*\mathcal{O}_X) = \underline{\text{Proj}}_S(\text{Sym}^*_{\mathcal{O}_S}(f_*\mathcal{O}_X)) $$ over $S$, which finishes the proof. Namely, we let $\sigma$ be the morphism which corresponds (via Constructions, Lemma \ref{constructions-lemma-apply-relative}) to the surjection $$ f^*f_*\mathcal{O}_X \longrightarrow \mathcal{O}_X $$ coming from the adjunction map $f^*f_* \to \text{id}$. Then $\sigma$ is a closed immersion by Schemes, Lemma \ref{schemes-lemma-semi-diagonal} and Constructions, Lemma \ref{constructions-lemma-projective-bundle-separated}.
Let $y \in Y$ be a point. If $y \not \in f(X)$, then there exists an affine neighbourhood of $y$ which is disjoint from $f(X)$. If $y \in f(X)$, let $x \in X$ be the unique point of $X$ mapping to $y$. Let $y \in V$ be an affine open neighbourhood. Let $U \subset X$ be an affine open neighbourhood of $x$ which maps into $V$. Since $f(U) \subset V \cap f(X)$ is open in the induced topology by our assumption on $f$ we may choose a $h \in \Gamma(V, \mathcal{O}_Y)$ such that $y \in D(h)$ and $D(h) \cap f(X) \subset f(U)$. Denote $h' \in \Gamma(U, \mathcal{O}_X)$ the restriction of $f^\sharp(h)$ to $U$. Then we see that $D(h') \subset U$ is equal to $f^{-1}(D(h))$. In other words, every point of $Y$ has an open neighbourhood whose inverse image is affine. Thus $f$ is affine, see Lemma \ref{lemma-characterize-affine}.
Assume $f$ is a universal homeomorphism. By Lemma \ref{lemma-homeomorphism-affine} we see that $f$ is affine. Since $f$ is clearly universally closed we see that $f$ is integral by Lemma \ref{lemma-integral-universally-closed}. It is also clear that $f$ is universally injective and surjective. \medskip\noindent Assume $f$ is integral, universally injective and surjective. By Lemma \ref{lemma-integral-universally-closed} $f$ is universally closed. Since it is also universally bijective (see Lemma \ref{lemma-base-change-surjective}) we see that it is a universal homeomorphism.