hcju/stacksqa huggingface dataset:
By Lemma \ref{lemma-base-change-fibres-geometrically-reduced} formation of $E$ commutes with base change. To check a subset of $|Y|$ is open, we may replace $Y$ by the members of an \'etale covering. Thus we may assume $Y$ is affine. Then $Y$ is a cofiltered limit of affine schemes of finite type over $\mathbf{Z}$. Hence we can assume $X \to Y$ is the base change of $X_0 \to Y_0$ where $Y_0$ is the spectrum of a finite type $\mathbf{Z}$-algebra and $X_0 \to Y_0$ is flat and proper. See Limits of Spaces, Lemma \ref{spaces-limits-lemma-descend-finite-presentation}, \ref{spaces-limits-lemma-descend-flat}, and \ref{spaces-limits-lemma-eventually-proper}. Since the formation of $E$ commutes with base change (see above), we may assume the base is Noetherian. \medskip\noindent Assume $Y$ is Noetherian. The set is constructible by Lemma \ref{lemma-geometrically-reduced-constructible}. Hence it suffices to show the set is stable under generalization (Topology, Lemma \ref{topology-lemma-characterize-closed-Noetherian}). By Properties, Lemma \ref{properties-lemma-locally-Noetherian-specialization-dvr} we reduce to the case where $Y = \Spec(R)$, $R$ is a discrete valuation ring, and the closed fibre $X_y$ is geometrically reduced. To show: the generic fibre $X_\eta$ is geometrically reduced. \medskip\noindent If not then there exists a finite extension $L$ of the fraction field of $R$ such that $X_L$ is not reduced, see Spaces over Fields, Lemmas \ref{spaces-over-fields-lemma-perfect-reduced} (characteristic zero) and \ref{spaces-over-fields-lemma-geometrically-reduced-positive-characteristic} (positive characteristic). There exists a discrete valuation ring $R' \subset L$ with fraction field $L$ dominating $R$, see Algebra, Lemma \ref{algebra-lemma-integral-closure-Dedekind}. After replacing $R$ by $R'$ we reduce to Lemma \ref{lemma-proper-flat-over-dvr-reduced-fibre}.
Suppose that $y' \in Y'$ has image $y \in Y$. Let $\Spec(k') \to Y'$ be in the equivalence class of $y'$ with $k'$ algebraically closed. Then we can choose a commutative diagram $$ \xymatrix{ \Spec(K) \ar[r] \ar[rd] & \Spec(k') \ar[r] & Y' \ar[d] \\ & \Spec(k) \ar[r] & Y } $$ where $K$ is an algebraically closed field. The result follows as the morphisms of schemes $$ \xymatrix{ X'_{k'} & (X'_{k'})_K = (X_k)_K \ar[l] \ar[r] & X_k } $$ induce bijections between connected components, see Spaces over Fields, Lemma \ref{spaces-over-fields-lemma-separably-closed-field-connected-components}. To use this to prove the function is well defined take $Y' = Y$.
To parse this one has to consult Morphisms of Spaces, Definition \ref{spaces-morphisms-definition-dimension-fibre}, Properties of Spaces, Definition \ref{spaces-properties-definition-dimension}, Properties of Spaces, Definition \ref{spaces-properties-definition-dimension-at-point}. We will show that the numbers in (1) and (2) are equal for a fixed morphism $\Spec(k) \to Y$. Choose an \'etale morphism $V \to Y$ where $V$ is an affine scheme and a point $v \in V$ mapping to $y$. Since $V \times_Y \Spec(k) \to \Spec(k)$ is surjective \'etale (by Properties of Spaces, Lemma \ref{spaces-properties-lemma-points-cartesian}) we can find a finite separable extension $k'/k$ (by Morphisms, Lemma \ref{morphisms-lemma-etale-over-field}) and a commutative diagram $$ \xymatrix{ \Spec(k') \ar[r] \ar[d] & V \ar[d] \\ \Spec(k) \ar[r] & Y } $$ We may replace $X \to Y$ by $V \times_Y X \to V$ and $X_k$ by $X_{k'} = \Spec(k') \times_V (V \times_Y X)$ because this does not change the dimensions in question by Properties of Spaces, Lemma \ref{spaces-properties-lemma-dimension-decent-invariant-under-etale} and Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-dimension-fibre-after-base-change}. Thus we may assume that $Y$ is an affine scheme. In this case we may assume that $k = \kappa(y)$ because the dimension of $X_{\kappa(y)}$ and $X_k$ are the same by the aforementioned Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-dimension-fibre-after-base-change} and the fact that for an algebraic space $Z$ over a field $K$ the relative dimension of $Z$ at a point $z \in |Z|$ is the same as $\dim_z(Z)$ by definition. Assume $Y$ is affine and $k = \kappa(y)$. Then $X$ is quasi-compact we can choose an affine scheme $U$ and an surjective \'etale morphism $U \to X$. Then $\dim(X_k) = \dim(U_k) = \max \dim_u(U_k)$ is equal to the number given in (1) by definition.
Let $V \to Y$ be a surjective \'etale morphism where $V$ is a scheme. If we can show that the composition $n_{X/Y} \circ |g|$ is lower semi-continuous, then the lemma follows as $|g|$ is open. Hence we may assume $Y$ is a scheme. Working locally we may assume $V$ is an affine scheme. Then we can choose an affine scheme $U$ and a surjective \'etale morphism $U \to X$. Then $n_{X/Y} = n_{U/Y}$. Hence we may assume $X$ and $Y$ are both schemes. In this case the lemma follows from More on Morphisms, Lemma \ref{more-morphisms-lemma-dimension-fibres-flat}.
Let $Z_d = \{x \in |X| : \text{the fibre of }f\text{ at }x\text{ has dimension }> d\}$. Then $Z_d$ is a closed subset of $|X|$ by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-openness-bounded-dimension-fibres}. Since $f$ is proper $f(Z_d)$ is closed in $|Y|$. Since $y \in f(Z_d) \Leftrightarrow n_{X/Y}(y) > d$ we see that the lemma is true.
By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-pushforward} the sheaves $f_*\mathcal{O}_X$, $(X_y \to Y)_*\mathcal{O}_{X_y}$, and $y_*\mathcal{O}_{\Spec(k)}$ are quasi-coherent sheaves of $\mathcal{O}_Y$-algebras. Consider the maps $$ f_*\mathcal{O}_Y \longrightarrow (X_y \to Y)_*\mathcal{O}_{X_y} \longleftarrow y_*\mathcal{O}_{\Spec(k)} $$ The fibre product is a quasi-coherent sheaf of $\mathcal{O}_Y$-algebras $\mathcal{A}'$ and we can define $X' \to Y$ as the relative spectrum of $\mathcal{A}'$ over $Y$, see Morphisms, Lemma \ref{morphisms-lemma-affine-equivalence-algebras}. This construction commutes with arbitrary change of base. In particular, it is clear that over the open subspace $|Y| \setminus \{y\}$ the morphism $X \to X'$ is an isomorphism and over $|Y| \setminus \{y\}$ the morphism $X' \to Y$ is integral. It remains to prove the statements in a small neighbourhood of $y$. Choose an affine scheme $V = \Spec(R)$ and an \'etale morphism $\varphi : V \to Y$ such that $y$ is in the image of $\varphi$. Then $V_y$ is a closed subscheme of $V$ \'etale over $k$, whence consists of finitely many points each with residue field separable over $k$ (see Decent Spaces, Remark \ref{decent-spaces-remark-recall}). After shrinking $V$ we may assume there is a unique closed point $v = \Spec(l) \to V$ mapping to $y$ with $l/k$ finite separable. We may write $V \times_Y X = \Spec(C)$ with $R \to C$ an integral ring map. The stated compatibility with base change gives us that $U \times_X Y' = \Spec(C')$ where $$ C' = C \times_{C \otimes_R l} l $$ Since $R \to l$ is surjective, also $C \to C \otimes_R l$ is surjective and we see that this is a fibre product of the kind studied in More on Algebra, Situation \ref{more-algebra-situation-module-over-fibre-product} (with $A, A', B, B'$ corresponding to $C \otimes_R l, C, l, C'$). Observe that $C'$ is an $R$-subalgebra of $C$ and hence is integral over $R$; this proves (1). Finally, More on Algebra, Lemma \ref{more-algebra-lemma-points-of-fibre-product} shows that $V \times_X Y' = \Spec(C')$ has a unique point $y''$ lying over $v$ with residue $l$ (this corresponds with the obvious surjective map $C' \to l$). Thus $X_y \times_{\Spec(k)} \Spec(l)$ has a unique point with residue field $l$. Since $l/k$ is finite separable, this implies $X'_y$ has a unique point with residue field $k$, i.e., (3) holds. \medskip\noindent To prove the final statement, observe that if $Y$ is locally Noetherian, then $R$ is a Noetherian ring and if $f$ is finite, then $R \to C$ is finite. Then $C'$ is a finite type $R$-algebra by More on Algebra, Lemma \ref{more-algebra-lemma-fibre-product-finite-type}. This proves that $X' \to Y$ is finite.
Let $(U, u) \to (Y, y)$ be an \'etale morphism of algebraic spaces and consider the set of  $w \in |U \times_Y X|$ mapping to $u \in |U|$ and one of the $x_i \in |X|$. By Decent Spaces, Lemma \ref{decent-spaces-lemma-qf-and-qc-finite-fibre} (if $f$ is of finite type) or Decent Spaces, Lemma \ref{decent-spaces-lemma-decent-finite-fibre} (if $Y$ is decent) this set is finite. It follows that we may replace $f$ by the base change $U \times_Y X \to U$ and $x_1, \ldots, x_n$ by the set of these $w$. In particular we may and do assume that $Y$ is an affine scheme, whence $X$ is a separated algebraic space. \medskip\noindent Choose an affine scheme $Z$ and an \'etale morphism $Z \to X$ such that $x_1, \ldots, x_n$ are in the image of $|Z| \to |X|$. The fibres of $|Z| \to |X|$ are finite, see Properties of Spaces, Lemma \ref{spaces-properties-lemma-finite-fibres-presentation} (or the more general discussion in Decent Spaces, Section \ref{decent-spaces-section-reasonable-decent}). Let $\{z_1, \ldots, z_m\} \subset |Z|$ be the preimage of $\{x_1, \ldots, x_n\}$. By More on Morphisms, Lemma \ref{more-morphisms-lemma-etale-splits-off-quasi-finite-part-technical} there exists an \'etale morphism $(U, u) \to (Y, y)$ such that $U \times_Y Z = Z_1 \amalg Z_2$ with $Z_1 \to U$ finite and $(Z_1)_y = \{z_1, \ldots, z_m\}$. We may assume that $U$ is affine and hence $Z_1$ is affine too. \medskip\noindent Since $f$ is separated, the image $V$ of $Z_1 \to X$ is both open and closed (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-universally-closed-permanence}). Set $W = X \setminus V$ to get a decomposition as in the lemma. To finish the proof we have to show that $V \to U$ is finite. As $Z_1 \to V$ is surjective and \'etale, $V$ is the quotient of $Z_1$ by the \'etale equivalence relation $R = Z_1 \times_V Z_1$, see Spaces, Lemma \ref{spaces-lemma-space-presentation}. Since $f$ is separated, $V \to U$ is separated and $R$ is closed in $Z_1 \times_U Z_1$. Since $Z_1 \to U$ is finite, the projections $s, t : R \to Z_1$ are finite. Thus $V$ is an affine scheme by Groupoids, Proposition \ref{groupoids-proposition-finite-flat-equivalence}. By Morphisms, Lemma \ref{morphisms-lemma-image-proper-is-proper} we conclude that $V \to U$ is proper and by Morphisms, Lemma \ref{morphisms-lemma-finite-proper} we conclude that $V \to U$ is finite, thereby finishing the proof.
Pick a scheme $U$, a point $u \in U$, and an \'etale morphism $U \to Y$ mapping $u$ to $y$. There exists a point $x' \in |U \times_Y X|$ mapping to $x$ in $|X|$ and $u$ in $|U|$ (Properties of Spaces, Lemma \ref{spaces-properties-lemma-points-cartesian}). To finish, apply Lemma \ref{lemma-etale-splits-off-quasi-finite-part} to the morphism $U \times_Y X \to U$ and the point $x'$. It applies because $U$ is a scheme and hence $u$ comes from the monomorphism $\Spec(\kappa(u)) \to U$.
This follows from Lemma \ref{lemma-finite-type-separated}. Namely, by that lemma there exists an open subspace $U' \subset Y'$ such that $(f')^{-1}(U') = X$ (!) and $X \to U'$ is an isomorphism! In other words, $f'$ is an open immersion. Note that $f'$ is quasi-compact as $f$ is quasi-compact and $\nu : Y' \to Y$ is separated (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-quasi-compact-permanence}). Hence for every affine scheme $Z$ and morphism $Z \to Y$ the fibre product $Z \times_Y X$ is a quasi-compact open subscheme of the affine scheme $Z \times_Y Y'$. Hence $f$ is quasi-affine by definition.
Let $X \to Y' \to Y$ be as in the conclusion of Lemma \ref{lemma-quasi-finite-separated-quasi-affine}. By Limits of Spaces, Lemma \ref{spaces-limits-lemma-integral-algebra-directed-colimit-finite} we can write $\nu_*\mathcal{O}_{Y'} = \colim_{i \in I} \mathcal{A}_i$ as a directed colimit of finite quasi-coherent $\mathcal{O}_X$-algebras $\mathcal{A}_i \subset \nu_*\mathcal{O}_{Y'}$. Then $\pi_i : T_i = \underline{\Spec}_Y(\mathcal{A}_i) \to Y$ is a finite morphism for each $i$. Note that the transition morphisms $T_{i'} \to T_i$ are affine and that $Y' = \lim T_i$. \medskip\noindent By Limits of Spaces, Lemma \ref{spaces-limits-lemma-descend-opens} there exists an $i$ and a quasi-compact open $U_i \subset T_i$ whose inverse image in $Y'$ equals $f'(X)$. For $i' \geq i$ let $U_{i'}$ be the inverse image of $U_i$ in $T_{i'}$. Then $X \cong f'(X) = \lim_{i' \geq i} U_{i'}$, see Limits of Spaces, Lemma \ref{spaces-limits-lemma-directed-inverse-system-has-limit}. By Limits of Spaces, Lemma \ref{spaces-limits-lemma-finite-type-eventually-closed} we see that $X \to U_{i'}$ is a closed immersion for some $i' \geq i$. (In fact $X \cong U_{i'}$ for sufficiently large $i'$ but we don't need this.) Hence $X \to T_{i'}$ is an immersion. By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-factor-the-other-way} we can factor this as $X \to T \to T_{i'}$ where the first arrow is an open immersion and the second a closed immersion. Thus we win.
By Limits of Spaces, Lemma \ref{spaces-limits-lemma-finite-in-finite-and-finite-presentation} we can write $T = \lim T_i$ where all $T_i$ are finite and of finite presentation over $Y$ and the transition morphisms $T_{i'} \to T_i$ are closed immersions. By Limits of Spaces, Lemma \ref{spaces-limits-lemma-descend-opens} there exists an $i$ and an open subscheme $U_i \subset T_i$ whose inverse image in $T$ is $X$. By Limits of Spaces, Lemma \ref{spaces-limits-lemma-finite-type-eventually-closed} we see that $X \cong U_i$ for large enough $i$. Replacing $T$ by $T_i$ finishes the proof.
We have (1) $\Rightarrow$ (2) by Morphisms of Spaces, Lemmas \ref{spaces-morphisms-lemma-finite-proper}, \ref{spaces-morphisms-lemma-finite-quasi-finite}. We have (2) $\Rightarrow$ (3) by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-locally-quasi-finite}. By definition (3) implies (4). \medskip\noindent Assume (4). Since $f$ is universally closed it is quasi-compact (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-universally-closed-quasi-compact}). Pick a point $y$ of $|Y|$. We represent $y$ by a morphism $\Spec(k) \to Y$. Note that $|X_k|$ is finite discrete as a quasi-compact discrete space. The map $|X_k| \to |X|$ surjects onto the fibre of $|X| \to |Y|$ over $y$ (Properties of Spaces, Lemma \ref{spaces-properties-lemma-points-cartesian}). By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-quasi-finite-at-point} we see that $X \to Y$ is quasi-finite at all the points of the fibre of $|X| \to |Y|$ over $y$. Choose an elementary \'etale neighbourhood $(U, u) \to (Y, y)$ and decomposition $X_U = V \amalg W$ as in Lemma \ref{lemma-etale-splits-off-quasi-finite-part} adapted to all the points of $|X|$ lying over $y$. Note that $W_u = \emptyset$ because we used all the points in the fibre of $|X| \to |Y|$ over $y$. Since $f$ is universally closed we see that the image of $|W|$ in $|U|$ is a closed set not containing $u$. After shrinking $U$ we may assume that $W = \emptyset$. In other words we see that $X_U = V$ is finite over $U$. Since $y \in |Y|$ was arbitrary this means there exists a family $\{U_i \to Y\}$ of \'etale morphisms whose images cover $Y$ such that the base changes $X_{U_i} \to U_i$ are finite. We conclude that $f$ is finite by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-integral-local}.
By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-locally-finite-type-quasi-finite-part} the set of points at which $f$ is quasi-finite is an open $U \subset X$. Let $Z = X \setminus U$. Then $y \not \in f(Z)$. Since $f$ is proper the set $f(Z) \subset Y$ is closed. Choose any open neighbourhood $V \subset Y$ of $y$ with $Z \cap V = \emptyset$. Then $f^{-1}(V) \to V$ is locally quasi-finite and proper. Hence $f^{-1}(V) \to V$ is finite by Lemma \ref{lemma-characterize-finite}.
Let $Z \subset Y$ be the scheme theoretic image of $h$, see Morphisms of Spaces, Section \ref{spaces-morphisms-section-scheme-theoretic-image}. By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-scheme-theoretic-image-is-proper} the morphism $X \to Z$ is surjective and $Z \to B$ is proper. Thus $$ \{x \in |X|\text{ lying over }b\} \to \{z \in |Z|\text{ lying over }b\} $$ and $|X_k| \to |Z_k|$ are surjective. We see that either (3)(a) or (3)(b) imply that $Z \to B$ is quasi-finite all points of $|Z|$ lying over $b$ by Decent Spaces, Lemma \ref{decent-spaces-lemma-conditions-on-fibre-and-qf}. Hence $Z \to B$ is finite in an open neighbourhood of $b$ by Lemma \ref{lemma-proper-finite-fibre-finite-in-neighbourhood}.
By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-universally-closed-quasi-compact} the morphism $f$ is quasi-compact. We just define $Y'$ as the normalization of $Y$ in $X$, so (5) and (2) hold automatically. By Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-normalization-in-universally-closed} we see that (4) holds. The morphism $f'$ is universally closed by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-universally-closed-permanence}. It is quasi-compact by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-quasi-compact-permanence} and quasi-separated by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-compose-after-separated}. \medskip\noindent To show the remaining statements we may assume the base $Y$ is affine (as taking normalization commutes with \'etale localization). Say $Y = \Spec(R)$. Then $Y' = \Spec(A)$ with $A = \Gamma(X, \mathcal{O}_X)$ an integral $R$-algebra. Thus it is clear that $f'_*\mathcal{O}_X$ is $\mathcal{O}_{Y'}$ (because $f'_*\mathcal{O}_X$ is quasi-coherent, by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-pushforward}, and hence equal to $\widetilde{A}$). This proves (3). \medskip\noindent Let us show that $f'$ is surjective. As $f'$ is universally closed (see above) the image of $f'$ is a closed subset $V(I) \subset Y' = \Spec(A)$. Pick $h \in I$. Then $h|_X = f^\sharp(h)$ is a global section of the structure sheaf of $X$ which vanishes at every point. As $X$ is quasi-compact this means that $h|_X$ is a nilpotent section, i.e., $h^n|X = 0$ for some $n > 0$. But $A = \Gamma(X, \mathcal{O}_X)$, hence $h^n = 0$. In other words $I$ is contained in the Jacobson radical of $A$ and we conclude that $V(I) = Y'$ as desired.
Recall that there are no specializations among the points of $\pi^{-1}(\{y\})$, see Algebra, Lemma \ref{algebra-lemma-integral-no-inclusion}. As $f'$ is surjective, we find that $|X_y| \to \pi^{-1}(\{y\})$ is surjective. Observe that $X_y$ is a quasi-separated algebraic space of finite type over a field (quasi-compactness was shown in the proof of the referenced lemma). Thus $|X_y|$ is a Noetherian topological space (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-finite-presentation-noetherian}). A topological argument (omitted) now shows that $\pi^{-1}(\{y\})$ is finite. For each $i$ we can pick a finite type point $x_i \in |X_y|$ mapping to $y_i$ (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-enough-finite-type-points}). We conclude that $\kappa(y_i)/\kappa(y)$ is finite: $x_i$ can be represented by a morphism $\Spec(k_i) \to X_y$ of finite type (by our definition of finite type points) and hence $\Spec(k_i) \to y = \Spec(\kappa(y))$ is of finite type (as a composition of finite type morphisms), hence $k_i/\kappa(y)$ is finite (Morphisms, Lemma \ref{morphisms-lemma-point-finite-type}).
Since the category of \'etale neighbourhoods of $\overline{y}$ is cofiltered and contains a cofinal collection of schemes (Properties of Spaces, Lemma \ref{spaces-properties-lemma-cofinal-etale}) we may replace $Y$ by one of these neighbourhoods and assume that $Y$ is a scheme. Let $y \in Y$ be the point corresponding to $\overline{y}$. Then $X_y$ is geometrically connected over $\kappa(y)$ if and only if $X_{\overline{y}}$ is connected and if and only if $(X_y)_{k'}$ is connected for every finite separable extension $k'$ of $\kappa(y)$. See Spaces over Fields, Section \ref{spaces-over-fields-section-geometrically-connected} and especially Lemma \ref{spaces-over-fields-lemma-characterize-geometrically-disconnected}. By More on Morphisms, Lemma \ref{more-morphisms-lemma-realize-prescribed-residue-field-extension-etale} there exists an affine \'etale neighbourhood $(V, v) \to (Y, y)$ such that $\kappa(s) \subset \kappa(u)$ is identified with $\kappa(s) \subset k'$ any given finite separable extension. The lemma follows.
Apply Theorem \ref{theorem-stein-factorization-general} to get a factorization $X \to Y' \to Y$. It is enough to show that $Y' = Y$. It suffices to show that $Y' \times_Y V \to V$ is an isomorphism, where $V \to Y$ is an \'etale morphism and $V$ an affine integral scheme, see Spaces over Fields, Lemma \ref{spaces-over-fields-lemma-normal-integral-cover-by-affines}. The formation of $Y'$ commutes with \'etale base change, see Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-properties-normalization}. The generic points of $X \times_Y V$ lie over the generic points of $X$ (Decent Spaces, Lemma \ref{decent-spaces-lemma-decent-generic-points}) hence map to the generic point of $V$ by assumption (5). Moreover, condition (6) is preserved under the base change by $V \to Y$, for example by flat base change (Cohomology of Spaces, Lemma \ref{spaces-cohomology-lemma-flat-base-change-cohomology}). Thus it suffices to prove the lemma in case $Y$ is a normal integral affine scheme. \medskip\noindent Assume $Y$ is a normal integral affine scheme. We will show $Y' \to Y$ is an isomorphism by an application of Morphisms, Lemma \ref{morphisms-lemma-finite-birational-over-normal}. Namely, $Y'$ is reduced because $X$ is reduced (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-normalization-in-reduced}). The morphism $Y' \to Y$ is integral by the theorem cited above. Since $Y$ is decent and $X \to Y$ is separated, we see that $X$ is decent too; to see this use Decent Spaces, Lemmas \ref{decent-spaces-lemma-properties-trivial-implications} and \ref{decent-spaces-lemma-property-over-property}. By assumption (5), Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-normalization-generic}, and Decent Spaces, Lemma \ref{decent-spaces-lemma-decent-generic-points} we see that every generic point of an irreducible component of $|Y'|$ maps to $\xi$. On the other hand, since $Y'$ is the relative spectrum of $f_*\mathcal{O}_X$ we see that the scheme theoretic fibre $Y'_\xi$ is the spectrum of $H^0(X_\xi, \mathcal{O})$ which is equal to $\kappa(\xi)$ by assumption. Hence $Y'$ is an integral scheme with function field equal to the function field of $Y$. This finishes the proof.
The question is \'etale local on $Y$, hence we may and do assume $Y$ is an affine scheme. Let $y \in Y$. Set $n = n_{X/S}(y)$. Note that $n < \infty$ as the geometric fibre of $X \to Y$ at $y$ is a proper algebraic space over a field, hence Noetherian, hence has a finite number of connected components. We have to find an open neighbourhood $V$ of $y$ such that $n_{X/S}|_V \geq n$. Let $X \to Y' \to Y$ be the Stein factorization as in Theorem \ref{theorem-stein-factorization-general}. By Lemma \ref{lemma-stein-universally-closed-residue-fields} there are finitely many points $y'_1, \ldots, y'_m \in Y'$ lying over $y$ and the extensions $\kappa(y'_i)/\kappa(y)$ are finite. More on Morphisms, Lemma \ref{more-morphisms-lemma-etale-makes-integral-split} tells us that after replacing $Y$ by an \'etale neighbourhood of $y$ we may assume $Y' = V_1 \amalg \ldots \amalg V_m$ as a scheme with $y'_i \in V_i$ and $\kappa(y'_i)/\kappa(y)$ purely inseparable. Then the algebraic spaces $X_{y_i'}$ are geometrically connected over $\kappa(y)$, hence $m = n$. The algebraic spaces $X_i = (f')^{-1}(V_i)$, $i = 1, \ldots, n$ are flat and of finite presentation over $Y$. Hence the image of $X_i \to Y$ is open (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-fppf-open}). Thus in a neighbourhood of $y$ we see that $n_{X/Y}$ is at least $n$.