hcju/stacksqa huggingface dataset:
Assume $X$ and $Y$ are birational. Let $f : U \to Y$ and $g : V \to X$ define inverse dominant rational maps from $X$ to $Y$ and from $Y$ to $X$. We may assume $V$ affine. We may replace $U$ by an affine open of $f^{-1}(V)$. As $g \circ f$ is the identity as a dominant rational map, we see that the composition $U \to V \to X$ is the identity on a dense open of $U$. Thus after replacing $U$ by a smaller affine open we may assume that $U \to V \to X$ is the inclusion of $U$ into $X$. It follows that $U \to V$ is an immersion (apply Schemes, Lemma \ref{schemes-lemma-section-immersion} to $U \to g^{-1}(U) \to U$). However, switching the roles of $U$ and $V$ and redoing the argument above, we see that there exists a nonempty affine open $V' \subset V$ such that the inclusion factors as $V' \to U \to V$. Then $V' \to U$ is necessarily an open immersion. Namely, $V' \to f^{-1}(V') \to V'$ are monomorphisms (Schemes, Lemma \ref{schemes-lemma-immersions-monomorphisms}) composing to the identity, hence isomorphisms. Thus $V'$ is isomorphic to an open of both $X$ and $Y$. In the $S$-rational maps case, the exact same argument works.
There is an immediate reduction to the case where $X$ and $Y$ are irreducible which we omit. Moreover, after shrinking further and we may assume $X$ and $Y$ are affine, say $X = \Spec(A)$ and $Y = \Spec(B)$. By assumption $A$, resp.\ $B$ has a unique minimal prime $\mathfrak p$, resp.\ $\mathfrak q$, the prime $\mathfrak p$ lies over $\mathfrak q$, and $B_\mathfrak q = A_\mathfrak p$. By Lemma \ref{lemma-birational-generic-fibres} we have $B_\mathfrak q = A_\mathfrak q = A_\mathfrak p$. \medskip\noindent Suppose $B \to A$ is of finite type, say $A = B[x_1, \ldots, x_n]$. There exist a $b_i \in B$ and $g_i \in B \setminus \mathfrak q$ such that $b_i/g_i$ maps to the image of $x_i$ in $A_\mathfrak q$. Hence $b_i  - g_ix_i$ maps to zero in $A_{g_i'}$ for some $g_i' \in B \setminus \mathfrak q$. Setting $g = \prod g_i g'_i$ we see that $B_g \to A_g$ is surjective. If moreover $Y$ is reduced, then the map $B_g \to B_\mathfrak q$ is injective and hence $B_g \to A_g$ is injective as well. This proves case (1). \medskip\noindent Proof of (2). By the argument given in the previous paragraph we may assume that $B \to A$ is surjective. As $f$ is locally of finite presentation the kernel $J \subset B$ is a finitely generated ideal. Say $J = (b_1, \ldots, b_r)$. Since $B_\mathfrak q = A_\mathfrak q$ there exist $g_i \in B \setminus \mathfrak q$ such that $g_i b_i = 0$. Setting $g = \prod g_i$ we see that $B_g \to A_g$ is an isomorphism.
We have seen the equivalence of (1) and (2) in Lemma \ref{lemma-birational-integral}. It is immediate that (2) implies (3). To finish we assume (3) holds and we prove (1). By Lemma \ref{lemma-rational-map-finite-presentation} there is a rational map $f : U \to Y$ which sends $x \in U$ to $y$ and induces the given isomorphism $\mathcal{O}_{Y, y} \cong \mathcal{O}_{X, x}$. Thus $f$ is a birational morphism and hence induces an isomorphism on nonempty opens by Lemma \ref{lemma-birational-birational}. This finishes the proof.
We have seen the equivalence of (1) and (2) in Lemma \ref{lemma-birational-integral}. It is immediate that (2) implies (3). To finish we assume (3) holds and we prove (1). Observe that $\mathcal{O}_{X, x} = \kappa(x)$ and $\mathcal{O}_{Y, y} = \kappa(y)$ by Algebra, Lemma \ref{algebra-lemma-minimal-prime-reduced-ring}. By Lemma \ref{lemma-rational-map-finite-presentation} there is a rational map $f : U \to Y$ which sends $x \in U$ to $y$ and induces the given isomorphism $\mathcal{O}_{Y, y} \cong \mathcal{O}_{X, x}$. Thus $f$ is a birational morphism and hence induces an isomorphism on nonempty opens by Lemma \ref{lemma-birational-birational}. This finishes the proof.
The question is local on the base. Hence we may replace $Y$ by an affine neighbourhood of $\eta$, and we may and do assume throughout the proof below that $Y$ is affine, say $Y = \Spec(R)$. \medskip\noindent It is clear that (2) implies (1). Assume that $f^{-1}(\{\eta\}) = \{\xi_1, \ldots, \xi_n\}$ is finite. Choose affine opens $U_i \subset X$ with $\xi_i \in U_i$. By Algebra, Lemma \ref{algebra-lemma-generically-finite} we see that after replacing $Y$ by a standard open in $Y$ each of the morphisms $U_i \to Y$ is finite. In other words (2) holds. \medskip\noindent It is clear that (3) implies (1). Assume $f$ is quasi-separated and (1). Write $f^{-1}(\{\eta\}) = \{\xi_1, \ldots, \xi_n\}$. There are no specializations among the $\xi_i$ by Lemma \ref{lemma-finite-fibre}. Since each $\xi_i$ maps to the generic point $\eta$ of an irreducible component of $Y$, there cannot be a nontrivial specialization $\xi \leadsto \xi_i$ in $X$ (since $\xi$ would map to $\eta$ as well). We conclude each $\xi_i$ is a generic point of an irreducible component of $X$. Since $Y$ is affine and $f$ quasi-separated we see $X$ is quasi-separated. By Properties, Lemma \ref{properties-lemma-maximal-points-affine} we can find an affine open $U \subset X$ containing each $\xi_i$. By Algebra, Lemma \ref{algebra-lemma-generically-finite} we see that after replacing $Y$ by a standard open in $Y$ the morphisms $U \to Y$ is finite. In other words (3) holds. \medskip\noindent It is clear that (4) implies all of (1) -- (3) with no further assumptions on $f$. Suppose that $f$ is quasi-compact and quasi-separated. We have to show that the equivalent conditions (1) -- (3) imply (4). Let $U$, $V$ be as in (3). Replace $Y$ by $V$. Since $f$ is quasi-compact and $Y$ is quasi-compact (being affine) we see that $X$ is quasi-compact. Hence $Z = X \setminus U$ is quasi-compact, hence the morphism $f|_Z : Z \to Y$ is quasi-compact. By construction of $Z$ we see that $\eta \not \in f(Z)$. Hence by Lemma \ref{lemma-quasi-compact-generic-point-not-in-image} we see that there exists an affine open neighbourhood $V'$ of $\eta$ in $Y$ such that $f^{-1}(V') \cap Z = \emptyset$. Then we have $f^{-1}(V') \subset U$ and this means that $f^{-1}(V') \to V'$ is finite.
Condition (1) implies there are no specializations among the points of the fibre $X_\eta$. Hence (2) holds by Lemma \ref{lemma-quasi-finite-at-point-characterize}. The implication (2) $\Rightarrow$ (3) is immediate. Since $\eta$ is a generic point of $Y$, the generic points of $X_\eta$ are generic points of $X$. Hence (3) and  Lemma \ref{lemma-quasi-finite-at-point-characterize} imply the generic points of $X_\eta$ are also closed. Thus all points of $X_\eta$ are generic and we see that (1) holds.
Since $Y$ has finitely many irreducible components, we can find a dense open which is a disjoint union of its irreducible components. Thus we may assume $Y$ is irreducible affine with generic point $\eta$. Then the fibre over $\eta$ is finite as $X^0$ is finite. \medskip\noindent Assume $f$ is separated and $Y$ irreducible affine. Choose $V \subset Y$ and $U \subset X$ as in Lemma \ref{lemma-generically-finite} part (3). Since $f|_U : U \to V$ is finite, we see that $U \subset f^{-1}(V)$ is closed as well as open (Lemmas \ref{lemma-image-proper-scheme-closed} and \ref{lemma-finite-proper}). Thus $f^{-1}(V) = U \amalg W$ for some open subscheme $W$ of $X$. However, since $U$ contains all the generic points of $X$ we conclude that $W = \emptyset$ as desired. \medskip\noindent Assume $f$ is quasi-compact and $Y$ irreducible affine. Then $X$ is quasi-compact, hence there exists a dense open subscheme $U \subset X$ which is separated (Properties, Lemma \ref{properties-lemma-quasi-compact-dense-open-separated}). Since the set of generic points $X^0$ is finite, we see that $X^0 \subset U$. Thus $\eta \not \in f(X \setminus U)$. Since $X \setminus U \to Y$ is quasi-compact, we conclude that there is a nonempty open $V \subset Y$ such that $f^{-1}(V) \subset U$, see Lemma \ref{lemma-quasi-compact-dominant}. After replacing $X$ by $f^{-1}(V)$ and $Y$ by $V$ we reduce to the separated case which we dealt with in the preceding paragraph.
By Lemma \ref{lemma-finite-over-dense-open} we may assume that $f$ is finite. Since $Y$ has finitely many irreducible components, we can find a dense open which is a disjoint union of its irreducible components. Thus we may assume $Y$ is irreducible. By Lemma \ref{lemma-birational-birational} we find a nonempty open $U \subset X$ such that $f|_U : U \to Y$ is an open immersion. After removing the closed (as $f$ finite) subset $f(X \setminus U)$ from $Y$ we see that $f$ is an isomorphism.
Choose any affine opens $\Spec(A) = U \subset X$ and $\Spec(R) = V \subset Y$ such that $f(U) \subset V$. Then $R$ and $A$ are domains by definition. The ring map $R \to A$ is of finite type (Lemma \ref{lemma-locally-finite-type-characterize}). By Lemma \ref{lemma-dominant-finite-number-irreducible-components} the generic point of $X$ maps to the generic point of $Y$ hence $R \to A$ is injective. Let $K = R(Y)$ be the fraction field of $R$ and $L = R(X)$ the fraction field of $A$. Then $K \subset L$ is a finitely generated field extension. Hence we see that (1) is equivalent to (2). \medskip\noindent Suppose (2) holds. Let $x_1, \ldots, x_n \in A$ be generators of $A$ over $R$. By assumption there exist nonzero polynomials $P_i(X) \in R[X]$ such that $P_i(x_i) = 0$. Let $f_i \in R$ be the leading coefficient of $P_i$. Then we conclude that $R_{f_1 \ldots f_n} \to A_{f_1 \ldots f_n}$ is finite, i.e., (3) holds. Note that (3) implies (2). So now we see that (1), (2) and (3) are all equivalent. \medskip\noindent Let $\eta$ be the generic point of $X$, and let $\eta' \in Y$ be the generic point of $Y$. Assume (4). Then $\dim_\eta(X_{\eta'}) = 0$ and we see that $R(X) = \kappa(\eta)$ has transcendence degree $0$ over $R(Y) = \kappa(\eta')$ by Lemma \ref{lemma-dimension-fibre-at-a-point}. In other words (1) holds. Assume the equivalent conditions (1), (2) and (3). Suppose that $x \in X$ is a point mapping to $\eta'$. As $x$ is a specialization of $\eta$, this gives inclusions $R(Y) \subset \mathcal{O}_{X, x} \subset R(X)$, which implies $\mathcal{O}_{X, x}$ is a field, see Algebra, Lemma \ref{algebra-lemma-integral-over-field}. Hence $x = \eta$. Thus we see that (1) -- (4) are all equivalent. \medskip\noindent It is clear that (5) implies (3) with no additional assumptions on $f$. What remains is to prove that if $f$ is either separated or quasi-compact, then the equivalent conditions (1) -- (4) imply (5). This follows from Lemma \ref{lemma-finite-over-dense-open}.
Let $X_1, \ldots, X_n$ be the irreducible components of $X$ containing $x$ endowed with their reduced induced scheme structure. These correspond to the minimal primes $\mathfrak q_i$ of $\mathcal{O}_{X, x}$ and hence there are finitely many of them (Schemes, Lemma \ref{schemes-lemma-specialize-points} and Algebra, Lemma \ref{algebra-lemma-Noetherian-irreducible-components}). Then $\dim(\mathcal{O}_{X, x}) = \max \dim(\mathcal{O}_{X, x}/\mathfrak q_i) = \max \dim(\mathcal{O}_{X_i, x})$. The $\xi$'s occurring in the definition of $E$ are exactly the generic points $\xi_i \in X_i$. Let $Z_i = \overline{\{f(\xi_i)\}} \subset S$ endowed with the reduced induced scheme structure. The composition $X_i \to X \to S$ factors through $Z_i$ (Schemes, Lemma \ref{schemes-lemma-map-into-reduction}). Thus we may apply the dimension formula (Lemma \ref{lemma-dimension-formula}) to see that $\dim(\mathcal{O}_{X_i, x}) \leq \dim(\mathcal{O}_{Z_i, x}) + \text{trdeg}_{\kappa(f(\xi))}(\kappa(\xi)) - \text{trdeg}_{\kappa(s)} \kappa(x)$. Putting everything together we obtain the lemma.
Let $f : X \to S$ be locally of finite type. Let $x \leadsto y$, $x \not = y$ be a specialization in $X$. We have to show that $\delta_{X/S}(x) > \delta_{X/S}(y)$ and that $\delta_{X/S}(x) = \delta_{X/S}(y) + 1$ if $y$ is an immediate specialization of $x$. \medskip\noindent Choose an affine open $V \subset S$ containing the image of $y$ and choose an affine open $U \subset X$ mapping into $V$ and containing $y$. We may clearly replace $X$ by $U$ and $S$ by $V$. Thus we may assume that $X = \Spec(A)$ and $S = \Spec(R)$ and that $f$ is given by a ring map $R \to A$. The ring $R$ is universally catenary (Lemma \ref{lemma-universally-catenary-local}) and the map $R \to A$ is of finite type (Lemma \ref{lemma-locally-finite-type-characterize}). \medskip\noindent Let $\mathfrak q \subset A$ be the prime ideal corresponding to the point $x$ and let $\mathfrak p \subset R$ be the prime ideal corresponding to $f(x)$. The restriction $\delta'$ of $\delta$ to $S' = \Spec(R/\mathfrak p) \subset S$ is a dimension function. The ring $R/\mathfrak p$ is universally catenary. The restriction of $\delta_{X/S}$ to $X' = \Spec(A/\mathfrak q)$ is clearly equal to the function $\delta_{X'/S'}$ constructed using the dimension function $\delta'$. Hence we may assume in addition to the above that $R \subset A$ are domains, in other words that $X$ and $S$ are integral schemes, and that $x$ is the generic point of $X$ and $f(x)$ is the generic point of $S$. \medskip\noindent Note that $\mathcal{O}_{X, x} = R(X)$ and that since $x \leadsto y$, $x \not = y$, the spectrum of $\mathcal{O}_{X, y}$ has at least two points (Schemes, Lemma \ref{schemes-lemma-specialize-points}) hence $\dim(\mathcal{O}_{X, y}) > 0$ . If $y$ is an immediate specialization of $x$, then $\Spec(\mathcal{O}_{X, y}) = \{x, y\}$ and $\dim(\mathcal{O}_{X, y}) = 1$. \medskip\noindent Write $s = f(x)$ and $t = f(y)$. We compute \begin{align*} \delta_{X/S}(x) - \delta_{X/S}(y) & = \delta(s) + \text{trdeg}_{\kappa(s)} \kappa(x) - \delta(t) - \text{trdeg}_{\kappa(t)} \kappa(y) \\ & = \delta(s) - \delta(t) + \text{trdeg}_{R(S)} R(X) - \text{trdeg}_{\kappa(t)} \kappa(y) \\ & = \delta(s) - \delta(t) + \dim(\mathcal{O}_{X, y}) - \dim(\mathcal{O}_{S, t}) \end{align*} where we use equality in (\ref{equation-dimension-formula}) in the last step. Since $\delta$ is a dimension function on the scheme $S$ and $s \in S$ is the generic point, the difference $\delta(s) - \delta(t)$ is equal to $\text{codim}(\overline{\{t\}}, S)$ by Topology, Lemma \ref{topology-lemma-dimension-function-catenary}. This is equal to $\dim(\mathcal{O}_{S, t})$ by Properties, Lemma \ref{properties-lemma-codimension-local-ring}. Hence we conclude that $$ \delta_{X/S}(x) - \delta_{X/S}(y) = \dim(\mathcal{O}_{X, y}) $$ and the lemma follows from what we said above about $\dim(\mathcal{O}_{X, y})$.
Let $f : X \to Y$ be as in the lemma. Let $\xi_0 \leadsto \xi_1 \leadsto \ldots \leadsto \xi_e$ be a sequence of specializations in $X$. Set $x = \xi_e$ and $y = f(x)$. Observe that $e \leq \dim(\mathcal{O}_{X, x})$ as the given specializations occur in the spectrum of $\mathcal{O}_{X, x}$, see Schemes, Lemma \ref{schemes-lemma-specialize-points}. By the dimension formula, Lemma \ref{lemma-dimension-formula}, we see that \begin{align*} e & \leq \dim(\mathcal{O}_{X, x}) \\ & \leq \dim(\mathcal{O}_{Y, y}) + \text{trdeg}_{R(Y)} R(X) - \text{trdeg}_{\kappa(y)} \kappa(x) \\ & \leq \dim(\mathcal{O}_{Y, y}) + \text{trdeg}_{R(Y)} R(X) \end{align*} Hence we conclude that $e \leq \dim(Y) + \text{trdeg}_{R(Y)} R(X)$ as desired. \medskip\noindent Next, assume $f$ is also closed. Say $\overline{\xi}_0 \leadsto \overline{\xi}_1 \leadsto \ldots \leadsto \overline{\xi}_d$ is a sequence of specializations in $Y$. We want to show that $\dim(X) \geq d + r$. We may assume that $\overline{\xi}_0 = \eta$ is the generic point of $Y$. The generic fibre $X_\eta$ is a scheme locally of finite type over $\kappa(\eta) = R(Y)$. It is nonempty as $f$ is dominant. Hence by Lemma \ref{lemma-ubiquity-Jacobson-schemes} it is a Jacobson scheme. Thus by Lemma \ref{lemma-jacobson-finite-type-points} we can find a closed point $\xi_0 \in X_\eta$ and the extension $\kappa(\eta) \subset \kappa(\xi_0)$ is a finite extension. Note that $\mathcal{O}_{X, \xi_0} = \mathcal{O}_{X_\eta, \xi_0}$ because $\eta$ is the generic point of $Y$. Hence we see that $\dim(\mathcal{O}_{X, \xi_0}) = r$ by Lemma \ref{lemma-dimension-formula} applied to the scheme $X_\eta$ over the universally catenary scheme $\Spec(\kappa(\eta))$ (see Lemma \ref{lemma-ubiquity-uc}) and the point $\xi_0$. This means that we can find $\xi_{-r} \leadsto \ldots \leadsto \xi_{-1} \leadsto \xi_0$ in $X$. On the other hand, as $f$ is closed specializations lift along $f$, see Topology, Lemma \ref{topology-lemma-closed-open-map-specialization}. Thus, as $\xi_0$ lies over $\eta = \overline{\xi}_0$ we can find specializations $\xi_0 \leadsto \xi_1 \leadsto \ldots \leadsto \xi_d$ lying over $\overline{\xi}_0 \leadsto \overline{\xi}_1 \leadsto \ldots \leadsto \overline{\xi}_d$. In other words we have $$ \xi_{-r} \leadsto \ldots \leadsto \xi_{-1} \leadsto \xi_0 \leadsto \xi_1 \leadsto \ldots \leadsto \xi_d $$ which means that $\dim(X) \geq d + r$ as desired.
This is a subsheaf by the local nature of the conditions. It is an $\mathcal{O}_X$-algebra by Algebra, Lemma \ref{algebra-lemma-integral-closure-is-ring}. Let $U \subset X$ be an affine open. Say $U = \Spec(R)$ and say $\mathcal{A}$ is the quasi-coherent sheaf associated to the $R$-algebra $A$. Then according to Algebra, Lemma \ref{algebra-lemma-integral-closure-stalks} the value of $\mathcal{A}'$ over $U$ is given by the integral closure $A'$ of $R$ in $A$. This proves the last assertion of the lemma. To prove that $\mathcal{A}'$ is quasi-coherent, it suffices to show that $\mathcal{A}'(D(f)) = A'_f$. This follows from the fact that integral closure and localization commute, see Algebra, Lemma \ref{algebra-lemma-integral-closure-localize}. The same fact shows that the stalks are as advertised.
Let $\mathcal{O}' \subset f_*\mathcal{O}_Y$ be the integral closure of $\mathcal{O}_X$ as in Definition \ref{definition-normalization-X-in-Y}. The morphism $\nu$ is integral by construction, which proves (1). Assume given a factorization $f = \pi \circ g$ with $\pi : Z \to X$ integral as in (2). By Definition \ref{definition-integral} $\pi$ is affine, and hence $Z$ is the relative spectrum of a quasi-coherent sheaf of $\mathcal{O}_X$-algebras $\mathcal{B}$. The morphism $g : Y \to Z$ corresponds to a map of $\mathcal{O}_X$-algebras $\chi : \mathcal{B} \to f_*\mathcal{O}_Y$. Since $\mathcal{B}(U)$ is integral over $\mathcal{O}_X(U)$ for every affine open $U \subset X$ (by Definition \ref{definition-integral}) we see from Lemma \ref{lemma-integral-closure} that $\chi(\mathcal{B}) \subset \mathcal{O}'$. By the functoriality of the relative spectrum Lemma \ref{lemma-affine-equivalence-algebras} this provides us with a unique morphism $h : X' \to Z$. We omit the verification that the diagram commutes. \medskip\noindent It is clear that (1) and (2) characterize the factorization $f = \nu \circ f'$ since it characterizes it as an initial object in a category. \medskip\noindent From the universal property in (2) we see that $f'$ does not factor through a proper closed subscheme of $X'$. Hence the scheme theoretic image of $f'$ is $X'$. Since $f'$ is quasi-compact (by Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence} and the fact that $\nu$ is separated as an affine morphism) we see that $f'(Y)$ is dense in $X'$. Hence $f'$ is dominant. \medskip\noindent The morphism $h$ in (2) is integral by Lemma \ref{lemma-finite-permanence}. Given a factorization $g = \pi' \circ g'$ with $\pi' : Z' \to Z$ integral, we get a factorization $f = (\pi \circ \pi') \circ g'$ and we get a morphism $h' : X' \to Z'$. Uniqueness implies that $\pi' \circ h' = h$. Hence the characterization (1), (2) applies to the morphism $h : X' \to Z$ which gives the last statement of the lemma.
By Lemmas \ref{lemma-characterize-normalization} (1) and \ref{lemma-base-change-finite} the base change $X_2 \times_{X_1} X'_1 \to X_2$ is integral. Note that $f_2$ factors through this morphism. Hence we get a unique morphism $X'_2 \to X_2 \times_{X_1} X'_1$ from Lemma \ref{lemma-characterize-normalization} (2). This gives the arrow $X'_2 \to X'_1$ fitting into the commutative diagram and uniqueness follows as well.
If $Y \to X'' \to X'$ is the normalization of $X'$ in $Y$, then we can apply Lemma \ref{lemma-characterize-normalization} to the composition $X'' \to X$ to get a canonical morphism $h : X' \to X''$ over $X$. We omit the verification that the morphisms $h$ and $X'' \to X'$ are mutually inverse (using uniqueness of the factorization in the lemma).
By Lemma \ref{lemma-normalization-localization} we may assume $X = \Spec(A)$ is affine. Choose a finite affine open covering $Y = \bigcup \Spec(B_i)$. Then $X' = \Spec(A')$ and the morphisms $\Spec(B_i) \to Y \to X'$ jointly define an injective $A$-algebra map $A' \to \prod B_i$. Thus the lemma follows from Algebra, Lemma \ref{algebra-lemma-injective-minimal-primes-in-image}.
The question is local on $S$, hence we may assume $S = \Spec(R)$ is affine. Let $h \in \Gamma(X, \mathcal{O}_X)$. We have to show that $h$ satisfies a monic equation over $R$. Think of $h$ as a morphism as in the following commutative diagram $$ \xymatrix{ X \ar[rr]_h \ar[rd]_f & & \mathbf{A}^1_S \ar[ld] \\ & S & } $$ Let $Z \subset \mathbf{A}^1_S$ be the scheme theoretic image of $h$, see Definition \ref{definition-scheme-theoretic-image}. The morphism $h$ is quasi-compact as $f$ is quasi-compact and $\mathbf{A}^1_S \to S$ is separated, see Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}. By Lemma \ref{lemma-quasi-compact-scheme-theoretic-image} the morphism $X \to Z$ is dominant. By Lemma \ref{lemma-image-proper-scheme-closed} the morphism $X \to Z$ is closed. Hence $h(X) = Z$ (set theoretically). Thus we can use Lemma \ref{lemma-image-proper-is-proper} to conclude that $Z \to S$ is universally closed (and even proper). Since $Z \subset \mathbf{A}^1_S$, we see that $Z \to S$ is affine and proper, hence integral by Lemma \ref{lemma-integral-universally-closed}. Writing $\mathbf{A}^1_S = \Spec(R[T])$ we conclude that the ideal $I \subset R[T]$ of $Z$ contains a monic polynomial $P(T) \in R[T]$. Hence $P(h) = 0$ and we win.
Let $U \subset X$ be an affine open. Consider the inverse image $U'$ of $U$ in $X'$. Set $V = f^{-1}(U)$. By Lemma \ref{lemma-normalization-localization} we $V \to U' \to U$ is the normalization of $U$ in $V$. Say $U = \Spec(A)$. Then $V$ is quasi-compact, and hence has a finite number of irreducible components by assumption. Hence $V = \coprod_{i = 1, \ldots n} V_i$ is a finite disjoint union of normal integral schemes by Properties, Lemma \ref{properties-lemma-normal-locally-finite-nr-irreducibles}. By Lemma \ref{lemma-normalization-in-disjoint-union} we see that $U' = \coprod_{i = 1, \ldots, n} U_i'$, where $U'_i$ is the normalization of $U$ in $V_i$. By Properties, Lemma \ref{properties-lemma-normal-integral-sections} we see that $B_i = \Gamma(V_i, \mathcal{O}_{V_i})$ is a normal domain. Note that $U_i' = \Spec(A_i')$, where $A_i' \subset B_i$ is the integral closure of $A$ in $B_i$, see Lemma \ref{lemma-integral-closure}. By Algebra, Lemma \ref{algebra-lemma-integral-closure-in-normal} we see that $A_i' \subset B_i$ is a normal domain. Hence $U' = \coprod U_i'$ is a finite union of normal integral schemes and hence is normal. \medskip\noindent As $X'$ has an open covering by the schemes $U'$ we conclude from Properties, Lemma \ref{properties-lemma-locally-normal} that $X'$ is normal. On the other hand, each $U'$ is a finite disjoint union of irreducible schemes, hence every quasi-compact open of $X'$ has finitely many irreducible components (by a topological argument which we omit). Thus $X'$ is a disjoint union of normal integral schemes by Properties, Lemma \ref{properties-lemma-normal-locally-finite-nr-irreducibles}. It is clear from the description of $X'$ above that $Y \to X'$ is dominant and induces a bijection on irreducible components $V \to U'$ for every affine open $U \subset X$. The bijection of irreducible components for the morphism $Y \to X'$ follows from this by a topological argument (omitted).