hcju/stacksqa huggingface dataset:
We have seen this in Schemes, Lemma \ref{schemes-lemma-composition-immersion}, but here is another proof. Namely, it follows from the characterization (3) of closed immersions in Lemma \ref{lemma-closed-immersion}. Since if $I \subset R$ is an ideal, and $\overline{J} \subset R/I$ is an ideal, then $\overline{J} = J/I$ for some ideal $J \subset R$ which contains $I$ and $(R/I)/\overline{J} = R/J$.
In each case the proof is to contemplate the commutative diagram $$ \xymatrix{ Z \ar[r] \ar[rd] & Y \times_X Z \ar[r] \ar[d] & Z \ar[d] \\ & Y \ar[r] & X } $$ where the composition of the top horizontal arrows is the identity. Let us prove (1). The first horizontal arrow is a section of $Y \times_X Z \to Z$, whence an immersion by Schemes, Lemma \ref{schemes-lemma-section-immersion}. The arrow $Y \times_X Z \to Y$ is a base change of $Z \to X$ hence an immersion (Schemes, Lemma \ref{schemes-lemma-base-change-immersion}). Finally, a composition of immersions is an immersion (Schemes, Lemma \ref{schemes-lemma-composition-immersion}). This proves (1). The other two results are proved in exactly the same manner.
Note that $h$ is quasi-compact and quasi-separated (see Schemes, Lemma \ref{schemes-lemma-immersions-monomorphisms}). Hence $h_*\mathcal{O}_Z$ is a quasi-coherent sheaf of $\mathcal{O}_X$-modules by Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent}. This implies that $\mathcal{I} = \Ker(\mathcal{O}_X \to h_*\mathcal{O}_Z)$ is a quasi-coherent sheaf of ideals, see Schemes, Section \ref{schemes-section-quasi-coherent}. Let $\overline{Z} \subset X$ be the closed subscheme corresponding to $\mathcal{I}$, see Lemma \ref{lemma-closed-immersion-bijection-ideals}. By Schemes, Lemma \ref{schemes-lemma-characterize-closed-subspace} the morphism $h$ factors as $h = i \circ j$ where $i : \overline{Z} \to X$ is the inclusion morphism. To see that $j$ is an open immersion, choose an open subscheme $U \subset X$ such that $h$ induces a closed immersion of $Z$ into $U$. Then it is clear that $\mathcal{I}|_U$ is the sheaf of ideals corresponding to the closed immersion $Z \to U$. Hence we see that $Z = \overline{Z} \cap U$.
Let $\overline{Z} \subset X$ be the closure of $h(Z)$ with the reduced induced closed subscheme structure, see Schemes, Definition \ref{schemes-definition-reduced-induced-scheme}. By Schemes, Lemma \ref{schemes-lemma-map-into-reduction} the morphism $h$ factors as $h = i \circ j$ with $i : \overline{Z} \to X$ the inclusion morphism and $j : Z \to \overline{Z}$. From the definition of an immersion we see there exists an open subscheme $U \subset X$ such that $h$ factors through a closed immersion into $U$. Hence $\overline{Z} \cap U$ and $h(Z)$ are reduced closed subschemes of $U$ with the same underlying closed set. Hence by the uniqueness in Schemes, Lemma \ref{schemes-lemma-reduced-closed-subscheme} we see that $h(Z) \cong \overline{Z} \cap U$. So $j$ induces an isomorphism of $Z$ with $\overline{Z} \cap U$. In other words $j$ is an open immersion.
This statement follows readily from the discussion of closed subschemes at the end of Schemes, Section \ref{schemes-section-immersions} but we will also give a detailed proof. Let $Z \subset X$ be the closure of $f(X)$. Since taking closures commutes with restricting to opens, we see from the assumption that $f(Y) \subset Z$ is open. Hence $Z' = Z \setminus f(Y)$ is closed. Hence $X' = X \setminus Z'$ is an open subscheme of $X$ and $f$ factors as $f : Y \to X'$ followed by the inclusion. If $y \in Y$ and $U \subset X$ is as in the statement of the lemma, then $U' = X' \cap U$ is an open neighbourhood of $f'(y)$ such that $(f')^{-1}(U') \to U'$ is an immersion (Lemma \ref{lemma-immersion-permanence}) with closed image. Hence it is a closed immersion, see Schemes, Lemma \ref{schemes-lemma-immersion-when-closed}. Since being a closed immersion is local on the target (for example by Lemma \ref{lemma-closed-immersion}) we conclude that $f'$ is a closed immersion as desired.
A closed immersion is quasi-compact and separated, see Lemmas \ref{lemma-closed-immersion-quasi-compact} and \ref{lemma-closed-immersion-separated}. Hence Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent} applies and the pushforward of a quasi-coherent sheaf on $Z$ is indeed a quasi-coherent sheaf on $X$. \medskip\noindent By Modules, Lemma \ref{modules-lemma-i-star-equivalence} the functor $i_*$ is fully faithful. \medskip\noindent Now we turn to the description of the essential image of the functor $i_*$. We have $\mathcal{I}(i_*\mathcal{F}) = 0$ for any quasi-coherent $\mathcal{O}_Z$-module, for example by Modules, Lemma \ref{modules-lemma-i-star-equivalence}. Next, suppose that $\mathcal{G}$ is any quasi-coherent $\mathcal{O}_X$-module such that $\mathcal{I}\mathcal{G} = 0$. It suffices to show that the canonical map $$ \mathcal{G} \longrightarrow i_* i^*\mathcal{G} $$ is an isomorphism\footnote{This was proved in a more general situation in the proof of  Modules, Lemma \ref{modules-lemma-i-star-equivalence}.}. In the case of schemes and quasi-coherent modules, working affine locally on $X$ and using Lemma \ref{lemma-closed-immersion} and Schemes, Lemma \ref{schemes-lemma-widetilde-pullback} it suffices to prove the following algebraic statement: Given a ring $R$, an ideal $I$ and an $R$-module $N$ such that $IN = 0$ the canonical map $$ N \longrightarrow N \otimes_R R/I,\quad n \longmapsto n \otimes 1 $$ is an isomorphism of $R$-modules. Proof of this easy algebra fact is omitted.
The morphisms $Z \cap Y \to Z$ and $Z \cap Y \to Y$ are closed immersions by Lemma \ref{lemma-closed-immersion-ideals}. Let $U = \Spec(A)$ be an affine open of $X$ and let $Z \cap U$ and $Y \cap U$ correspond to the ideals $I \subset A$ and $J \subset A$. Then $Z \cap Y \cap U$ corresponds to $I + J \subset A$. Since $A/I \otimes_A A/J = A/(I + J)$ we see that the diagram is cartesian by our description of fibre products of schemes in Schemes, Section \ref{schemes-section-fibre-products}.
The morphisms $X \to X \cup Y$ and $Y \to X \cup Y$ are closed immersions by Lemma \ref{lemma-closed-immersion-ideals}. In the short exact sequence we use the equivalence of Lemma \ref{lemma-i-star-equivalence} to think of quasi-coherent modules on closed subschemes of $S$ as quasi-coherent modules on $S$. For the first map in the sequence we use the canonical maps $\mathcal{O}_{X \cup Y} \to \mathcal{O}_X$ and $\mathcal{O}_{X \cup Y} \to \mathcal{O}_Y$ and for the second map we use the canonical map $\mathcal{O}_X \to \mathcal{O}_{X \cap Y}$ and the negative of the canonical map $\mathcal{O}_Y \to \mathcal{O}_{X \cap Y}$. Then to check exactness we may work affine locally. Let $U = \Spec(A)$ be an affine open of $S$ and let $X \cap U$ and $Y \cap U$ correspond to the ideals $I \subset A$ and $J \subset A$. Then $(X \cup Y) \cap U$ corresponds to $I \cap J \subset A$ and $X \cap Y \cap U$ corresponds to $I + J \subset A$. Thus exactness follows from the exactness of $$ 0 \to A/I \cap J \to A/I \times A/J \to A/(I + J) \to 0 $$ To show the diagram is cocartesian, suppose we are given a scheme $T$ and morphisms of schemes $f : X \to T$, $g : Y \to T$ agreeing as morphisms $X \cap Y \to T$. Goal: Show there exists a unique morphism $h : X \cup Y \to T$ agreeing with $f$ and $g$. To construct $h$ we may work affine locally on $X \cup Y$, see Schemes, Section \ref{schemes-section-glueing-schemes}. If $s \in X$, $s \not \in Y$, then $X \to X \cup Y$ is an isomorphism in a neighbourhood of $s$ and it is clear how to construct $h$. Similarly for $s \in Y$, $s \not \in X$. For $s \in X \cap Y$ we can pick an affine open $V = \Spec(B) \subset T$ containing $f(s) = g(s)$. Then we can choose an affine open $U = \Spec(A) \subset S$ containing $s$ such that $f(X \cap U)$ and $g(Y \cap U)$ are contained in $V$. The morphisms $f|_{X \cap U}$ and $g|_{Y \cap V}$ into $V$ correspond to ring maps $$ B \to A/I \quad\text{and}\quad B \to A/J $$ which agree as maps into $A/(I + J)$. By the short exact sequence displayed above there is a unique lift of these ring homomorphism to a ring map $B \to A/I \cap J$ as desired.
Part (1) is a reformulation of Modules, Lemma \ref{modules-lemma-support-finite-type-closed}. You can also combine Lemma \ref{lemma-support-affine-open}, Properties, Lemma \ref{properties-lemma-finite-type-module}, and Algebra, Lemma \ref{algebra-lemma-support-closed} to see this. The first equivalence in (2) is the definition of support, and the second equivalence follows from Nakayama's lemma, see Algebra, Lemma \ref{algebra-lemma-NAK}. Let $f : Y \to X$ be a morphism of schemes. Note that $f^*\mathcal{F}$ is of finite type by Modules, Lemma \ref{modules-lemma-pullback-finite-type}. For the final assertion, let $y \in Y$ with image $x \in X$. Recall that $$ (f^*\mathcal{F})_y = \mathcal{F}_x \otimes_{\mathcal{O}_{X, x}} \mathcal{O}_{Y, y}, $$ see Sheaves, Lemma \ref{sheaves-lemma-stalk-pullback-modules}. Hence $(f^*\mathcal{F})_y \otimes \kappa(y)$ is nonzero if and only if $\mathcal{F}_x \otimes \kappa(x)$ is nonzero. By (2) this implies $x \in \text{Supp}(\mathcal{F})$ if and only if $y \in \text{Supp}(f^*\mathcal{F})$, which is the content of assertion (3).
Suppose that $i' : Z' \to X$ is a closed subscheme which satisfies the description on open affines from the lemma. Then by Lemma \ref{lemma-i-star-equivalence} we see that $\mathcal{F} \cong i'_*\mathcal{G}'$ for some unique quasi-coherent sheaf $\mathcal{G}'$ on $Z'$. Furthermore, it is clear that $Z'$ is the smallest closed subscheme with this property (by the same lemma). Finally, using Properties, Lemma \ref{properties-lemma-finite-type-module} and Algebra, Lemma \ref{algebra-lemma-finite-over-subring} it follows that $\mathcal{G}'$ is of finite type. We have $\text{Supp}(\mathcal{G}') = Z$ by Algebra, Lemma \ref{algebra-lemma-support-closed}. Hence, in order to prove the lemma it suffices to show that the characterization in (1) actually does define a closed subscheme. And, in order to do this it suffices to prove that the given rule produces a quasi-coherent sheaf of ideals, see Lemma \ref{lemma-closed-immersion-bijection-ideals}. This comes down to the following algebra fact: If $A$ is a ring, $f \in A$, and $M$ is a finite $A$-module, then $\text{Ann}_A(M)_f = \text{Ann}_{A_f}(M_f)$. We omit the proof.
Let $\mathcal{I} = \Ker(\mathcal{O}_Y \to f_*\mathcal{O}_X)$. If $\mathcal{I}$ is quasi-coherent then we just take $Z$ to be the closed subscheme determined by $\mathcal{I}$, see Lemma \ref{lemma-closed-immersion-bijection-ideals}. This works by Schemes, Lemma \ref{schemes-lemma-characterize-closed-subspace}. In general the same lemma requires us to show that there exists a largest quasi-coherent sheaf of ideals $\mathcal{I}'$ contained in $\mathcal{I}$. This follows from Lemma \ref{lemma-largest-quasi-coherent-subsheaf}.
Part (4) follows from part (3). To show (3) it suffices to prove (1) since the formation of $\mathcal{I}$ commutes with restriction to open subschemes of $Y$. And if (1) holds then in the proof of Lemma \ref{lemma-scheme-theoretic-image} we showed (2). Thus it suffices to prove that $\mathcal{I}$ is quasi-coherent. Since the property of being quasi-coherent is local we may assume $Y$ is affine. As $f$ is quasi-compact, we can find a finite affine open covering $X = \bigcup_{i = 1, \ldots, n} U_i$. Denote $f'$ the composition $$ X' = \coprod U_i \longrightarrow X \longrightarrow Y. $$ Then $f_*\mathcal{O}_X$ is a subsheaf of $f'_*\mathcal{O}_{X'}$, and hence $\mathcal{I} = \Ker(\mathcal{O}_Y \to f'_*\mathcal{O}_{X'})$. By Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent} the sheaf $f'_*\mathcal{O}_{X'}$ is quasi-coherent on $Y$. Hence we win.
Let $z \in \Spec(R) = V \subset Y$ be an affine open neighbourhood of $z$. By Lemma \ref{lemma-quasi-compact-scheme-theoretic-image} the intersection $Z \cap V$ is the scheme theoretic image of $f^{-1}(V) \to V$. Hence we may replace $Y$ by $V$ and assume $Y = \Spec(R)$ is affine. In this case $X$ is quasi-compact as $f$ is quasi-compact. Say $X = U_1 \cup \ldots \cup U_n$ is a finite affine open covering. Write $U_i = \Spec(A_i)$. Let $I = \Ker(R \to A_1 \times \ldots \times A_n)$. By Lemma \ref{lemma-quasi-compact-scheme-theoretic-image} again we see that $Z$ corresponds to the closed subscheme $\Spec(R/I)$ of $Y$. If $\mathfrak p \subset R$ is the prime corresponding to $z$, then we see that $I_{\mathfrak p} \subset R_{\mathfrak p}$ is not an equality. Hence (as localization is exact, see Algebra, Proposition \ref{algebra-proposition-localization-exact}) we see that $R_{\mathfrak p} \to (A_1)_{\mathfrak p} \times \ldots \times (A_n)_{\mathfrak p}$ is not zero. Hence one of the rings $(A_i)_{\mathfrak p}$ is not zero. Hence there exists an $i$ and a prime $\mathfrak q_i \subset A_i$ lying over a prime $\mathfrak p_i \subset \mathfrak p$. By Algebra, Lemma \ref{algebra-lemma-dominate} we can choose a valuation ring $A \subset K = \kappa(\mathfrak q_i)$ dominating the local ring $R_{\mathfrak p}/\mathfrak p_iR_{\mathfrak p} \subset \kappa(\mathfrak q_i)$. This gives the desired diagram. Some details omitted.
The assumption that $V$ is retrocompact in $Y$ (Topology, Definition \ref{topology-definition-quasi-compact}) means that $V \to Y$ is a quasi-compact morphism. By Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence} the morphism $s : V \to X$ is quasi-compact. Hence the construction of the scheme theoretic image $Y'$ of $s$ commutes with restriction to opens by Lemma \ref{lemma-quasi-compact-scheme-theoretic-image}. In particular, we see that $Y' \cap f^{-1}(V)$ is the scheme theoretic image of a section of the separated morphism $f^{-1}(V) \to V$. Since a section of a separated morphism is a closed immersion (Schemes, Lemma \ref{schemes-lemma-section-immersion}), we conclude that $Y' \cap f^{-1}(V) \to V$ is an isomorphism as desired.
If $\mathcal{O}_X \to j_*\mathcal{O}_U$ is injective, then the same is true when restricted to any open $V$ of $X$. Hence the scheme theoretic closure of $U \cap V$ in $V$ is equal to $V$, see proof of Lemma \ref{lemma-scheme-theoretic-image}. Conversely, suppose that the scheme theoretic closure of $U \cap V$ is equal to $V$ for all opens $V$. Suppose that $\mathcal{O}_X \to j_*\mathcal{O}_U$ is not injective. Then we can find an affine open, say $\Spec(A) = V \subset X$ and a nonzero element $f \in A$ such that $f$ maps to zero in $\Gamma(V \cap U, \mathcal{O}_X)$. In this case the scheme theoretic closure of $V \cap U$ in $V$ is clearly contained in $\Spec(A/(f))$ a contradiction.
Let $W \subset X$ be any open. Consider the map $\mathcal{O}_X(W) \to \mathcal{O}_X(W \cap V) \to \mathcal{O}_X(W \cap V \cap U)$. By Lemma \ref{lemma-characterize-scheme-theoretically-dense} both maps are injective. Hence the composite is injective. Hence by Lemma \ref{lemma-characterize-scheme-theoretically-dense} $U \cap V$ is scheme theoretically dense in $X$.
By Lemma \ref{lemma-factor-quasi-compact-immersion} or Lemma \ref{lemma-factor-reduced-immersion} we can factor $Z \to X$ as $Z \to \overline{Z}_1 \to X$ with $Z \to \overline{Z}_1$ open and $\overline{Z}_1 \to X$ closed. On the other hand, let $Z \to \overline{Z} \subset X$ be the scheme theoretic closure of $Z \to X$. We conclude that $\overline{Z} \subset \overline{Z}_1$. Since $Z$ is an open subscheme of $\overline{Z}_1$ it follows that $Z$ is an open subscheme of $\overline{Z}$ as well. In the case that $Z$ is reduced we know that $Z \subset \overline{Z}_1$ is topologically dense by the construction of $\overline{Z}_1$ in the proof of Lemma \ref{lemma-factor-reduced-immersion}. Hence $\overline{Z}_1$ and $\overline{Z}$ have the same underlying topological spaces. Thus $\overline{Z} \subset \overline{Z}_1$ is a closed immersion into a reduced scheme which induces a bijection on underlying topological spaces, and hence it is an isomorphism. In the case that $Z \to X$ is quasi-compact we argue as follows: The assertion that $Z$ is scheme theoretically dense in $\overline{Z}$ follows from Lemma \ref{lemma-quasi-compact-scheme-theoretic-image} part (3). The last assertion follows from Lemma \ref{lemma-quasi-compact-scheme-theoretic-image} part (4).
Let $V \subset S$ be an affine open. Because $f$ is quasi-compact we may choose finitely many affine opens $U_i \subset f^{-1}(V)$, $i = 1, \ldots, n$ covering $f^{-1}(V)$. Consider the morphism of affines $$ f' : \coprod\nolimits_{i = 1, \ldots, n} U_i \longrightarrow V. $$ A disjoint union of affines is affine, see Schemes, Lemma \ref{schemes-lemma-disjoint-union-affines}. Generic points of irreducible components of $V$ are exactly the generic points of the irreducible components of $S$ that meet $V$. Also, $f$ is dominant if and only if $f'$ is dominant no matter what choices of $V, n, U_i$ we make above. Thus we have reduced the lemma to the case of a morphism of affine schemes. The affine case is Algebra, Lemma \ref{algebra-lemma-image-dense-generic-points}.
Let $Z \subset S$ be the scheme theoretic image of $f$. We have to show that $\eta \not \in Z$. This follows from Lemma \ref{lemma-reach-points-scheme-theoretic-image} but can also be seen as follows. By Lemma \ref{lemma-quasi-compact-scheme-theoretic-image} the morphism $X \to Z$ is dominant, which by Lemma \ref{lemma-quasi-compact-dominant} means all the generic points of all irreducible components of $Z$ are in the image of $X \to Z$. By assumption we see that $\eta \not \in Z$ since $\eta$ would be the generic point of some irreducible component of $Z$ if it were in $Z$.
The equivalence of (1) and (2) follows from Lemma \ref{lemma-dominant-finite-number-irreducible-components}. Let $U \subset X$ and $V \subset Y$ be nonempty affine opens with $f(U) \subset V$. Recall that the rings $A = \mathcal{O}_X(U)$ and $B = \mathcal{O}_Y(V)$ are integral domains. The morphism $f|_U : U \to V$ corresponds to a ring map $\varphi : B \to A$. The generic points of $X$ and $Y$ correspond to the prime ideals $(0) \subset A$ and $(0) \subset B$. Thus (2) is equivalent to the condition $(0) = \varphi^{-1}((0))$, i.e., to the condition that $\varphi$ is injective. In this way we see that (2), (3), and (4) are equivalent. Similarly, given $x$ and $y$ as in (5) the local rings $\mathcal{O}_{X, x}$ and $\mathcal{O}_{Y, y}$ are domains and the prime ideals $(0) \subset \mathcal{O}_{X, x}$ and $(0) \subset \mathcal{O}_{Y, y}$ correspond to the generic points of $X$ and $Y$ (via the identification of the spectrum of the local ring at $x$ with the set of points specializing to $x$, see Schemes, Lemma \ref{schemes-lemma-specialize-points}). Thus we can argue in the exact same manner as above to see that (2), (5), and (6) are equivalent.
Let $f: X \to Y$ be a morphism of schemes over a base scheme $S$. If $S' \to S$ is a morphism of schemes, let $p: X_{S'} \to X$ and $q: Y_{S'} \to Y$ be the canonical projections.  The commutative square $$ \xymatrix{ X_{S'} \ar[d]_{f_{S'}} \ar[r]_p & X \ar[d]^{f} \\ Y_{S'} \ar[r]^{q} & Y. } $$ identifies $X_{S'}$ as a fibre product of $X \to Y$ and $Y_{S'} \to Y$.  Let $Z$ be a subset of the underlying topological space of $X$.  Then $q^{-1}(f(Z)) = f_{S'}(p^{-1}(Z))$, because $y' \in q^{-1}(f(Z))$ if and only if $q(y') = f(x)$ for some $x \in Z$, if and only if, by Lemma \ref{lemma-when-point-maps-to-pair}, there exists $x' \in X_{S'}$ such that $f_{S'}(x') = y'$ and $p(x') = x$.  In particular taking $Z = X$ we see that if $f$ is surjective so is the base change $f_{S'}: X_{S'} \to Y_{S'}$.
Let $K$ be a field, and let $s : \Spec(K) \to S$ be a morphism. Giving a morphism $x : \Spec(K) \to X$ such that $f \circ x = s$ is the same as giving a section of the projection $X_K = \Spec(K) \times_S X \to \Spec(K)$, which in turn is the same as giving a point $x \in X_K$ whose residue field is $K$. Hence we see that (2) implies (1). \medskip\noindent Conversely, suppose that (1) holds. Assume that $x, x' \in X_{S'}$ map to the same point $s' \in S'$. Choose a commutative diagram $$ \xymatrix{ K & \kappa(x) \ar[l] \\ \kappa(x') \ar[u] & \kappa(s') \ar[l] \ar[u] } $$ of fields. By Schemes, Lemma \ref{schemes-lemma-characterize-points} we get two morphisms $a, a' : \Spec(K) \to X_{S'}$. One corresponding to the point $x$ and the embedding $\kappa(x) \subset K$ and the other corresponding to the  point $x'$ and the embedding $\kappa(x') \subset K$. Also we have $f' \circ a = f' \circ a'$. Condition (1) now implies that the compositions of $a$ and $a'$ with $X_{S'} \to X$ are equal. Since $X_{S'}$ is the fibre product of $S'$ and $X$ over $S$ we see that $a = a'$. Hence $x = x'$. Thus (1) implies (2). \medskip\noindent If there are two different points $x, x' \in X$ mapping to the same point of $s$ then (2) is violated. If for some $s = f(x)$, $x \in X$ the field extension $\kappa(s) \subset \kappa(x)$ is not purely inseparable, then we may find a field extension $\kappa(s) \subset K$ such that $\kappa(x)$ has two $\kappa(s)$-homomorphisms into $K$. By Schemes, Lemma \ref{schemes-lemma-characterize-points} this implies that the map $\Mor(\Spec(K), X) \to \Mor(\Spec(K), S)$ is not injective, and hence (1) is violated. Thus we see that the equivalent conditions (1) and (2) imply $f$ is radicial, i.e., they imply (3). \medskip\noindent Assume (3). By Schemes, Lemma \ref{schemes-lemma-characterize-points} a morphism $\Spec(K) \to X$ is given by a pair $(x, \kappa(x) \to K)$. Property (3) says exactly that associating to the pair $(x, \kappa(x) \to K)$ the pair $(s, \kappa(s) \to \kappa(x) \to K)$ is injective. In other words (1) holds. At this point we know that (1), (2) and (3) are all equivalent. \medskip\noindent Finally, we prove the equivalence of (4) with (1), (2) and (3). A point of $X \times_S X$ is given by a quadruple $(x_1, x_2, s, \mathfrak p)$, where $x_1, x_2 \in X$, $f(x_1) = f(x_2) = s$ and $\mathfrak p \subset \kappa(x_1) \otimes_{\kappa(s)} \kappa(x_2)$ is a prime ideal, see Schemes, Lemma \ref{schemes-lemma-points-fibre-product}. If $f$ is universally injective, then by taking $S'=X$ in the definition of universally injective, $\Delta_{X/S}$ must be surjective since it is a section of the injective morphism $X \times_S X  \longrightarrow X$. Conversely, if $\Delta_{X/S}$ is surjective, then always $x_1 = x_2 = x$ and there is exactly one such prime ideal $\mathfrak p$, which means that $\kappa(s) \subset \kappa(x)$ is purely inseparable. Hence $f$ is radicial. Alternatively, if $\Delta_{X/S}$ is surjective, then for any $S' \to S$ the base change $\Delta_{X_{S'}/S'}$ is surjective which implies that $f$ is universally injective. This finishes the proof of the lemma.
Let $f : X \to S$ be affine. Quasi-compactness is immediate from Schemes, Lemma \ref{schemes-lemma-quasi-compact-affine}. We will show $f$ is separated using Schemes, Lemma \ref{schemes-lemma-characterize-separated}. Let $x_1, x_2 \in X$ be points of $X$ which map to the same point $s \in S$. Choose any affine open $W \subset S$ containing $s$. By assumption $f^{-1}(W)$ is affine. Apply the lemma cited with $U = V = f^{-1}(W)$.
It is obvious that (1) implies (2). \medskip\noindent Assume $S = \bigcup_{j \in J} W_j$ is an affine open covering such that each $f^{-1}(W_j)$ is affine. By Schemes, Lemma \ref{schemes-lemma-quasi-compact-affine} we see that $f$ is quasi-compact. By Schemes, Lemma \ref{schemes-lemma-characterize-quasi-separated} we see the morphism $f$ is quasi-separated. Hence by Schemes, Lemma \ref{schemes-lemma-push-forward-quasi-coherent} the sheaf $\mathcal{A} = f_*\mathcal{O}_X$ is a quasi-coherent sheaf of $\mathcal{O}_X$-algebras. Thus we have the scheme $g : Y = \underline{\Spec}_S(\mathcal{A}) \to S$ over $S$. The identity map $\text{id} : \mathcal{A} = f_*\mathcal{O}_X \to f_*\mathcal{O}_X$ provides, via the definition of the relative spectrum, a morphism $can : X \to Y$ over $S$, see Constructions, Lemma \ref{constructions-lemma-canonical-morphism}. By assumption and the lemma just cited the restriction $can|_{f^{-1}(W_j)} : f^{-1}(W_j) \to g^{-1}(W_j)$ is an isomorphism. Thus $can$ is an isomorphism. We have shown that (2) implies (3). \medskip\noindent Assume (3). By Constructions, Lemma \ref{constructions-lemma-spec-properties} we see that the inverse image of every affine open is affine, and hence the morphism is affine by definition.