hcju/stacksqa huggingface dataset:
(This proof is the same as the proof of Lemma \ref{lemma-scheme-theoretically-dense-generic-fibre}. We urge the reader to read that proof first.) Since the statement is about fibres it is clear that we may replace $Y$ by its reduction. Hence we may assume that $Y$ is integral, see Properties, Lemma \ref{properties-lemma-characterize-integral}. We may also assume that $Y = \Spec(A)$ is affine. Then $A$ is a domain with fraction field $K$. \medskip\noindent As $f$ is of finite type we see that $X$ is quasi-compact. Write $X = X_1 \cup \ldots \cup X_n$ for some affine opens $X_i$ and set $\mathcal{F}_i = \mathcal{F}|_{X_i}$. By assumption the generic fibre of $U_i = X_i \cap U$ contains $\text{Ass}_{X_{i, \eta}}(\mathcal{F}_{i, \eta})$. Thus it suffices to prove the result for the triples $(X_i, \mathcal{F}_i, U_i)$, in other words we may assume that $X$ is affine. \medskip\noindent Write $X = \Spec(B)$. Let $N$ be a finite $B$-module such that $\mathcal{F} = \widetilde{N}$. Note that $B_K$ is Noetherian as it is a finite type $K$-algebra. Hence $U_\eta$ is quasi-compact. Thus we can find finitely many $g_1, \ldots, g_m \in B$ such that $D(g_j) \subset U$ and such that $U_\eta = D(g_1)_\eta \cup \ldots \cup D(g_m)_\eta$. Since $\text{Ass}_{X_\eta}(\mathcal{F}_\eta) \subset U_\eta$ we see that $N_K \to \bigoplus_j (N_K)_{g_j}$ is injective. By Algebra, Lemma \ref{algebra-lemma-when-injective-covering} this is equivalent to the injectivity of $N_K \to \bigoplus\nolimits_{j = 1, \ldots, m} N_K$, $n \mapsto (g_1n, \ldots, g_mn)$. Let $I$ and $M$ be the kernel and cokernel of this map over $A$, i.e., such that we have an exact sequence $$ 0 \to I \to N \xrightarrow{(g_1, \ldots, g_m)} \bigoplus\nolimits_{j = 1, \ldots, m} N \to M \to 0 $$ After replacing $A$ by $A_h$ for some nonzero $h$ we may assume that $B$ is a flat, finitely presented $A$-algebra and that both $M$ and $N$ are flat over $A$, see Algebra, Lemma \ref{algebra-lemma-generic-flatness}. The flatness of $N$ over $A$ implies that $N$ is torsion free as an $A$-module, see More on Algebra, Lemma \ref{more-algebra-lemma-flat-torsion-free}. Hence $N \subset N_K$. By construction $I_K = 0$ which implies that $I = 0$ (as $I \subset N \subset N_K$ is a subset of $I_K$). Hence now we have a short exact sequence $$ 0 \to N \xrightarrow{(g_1, \ldots, g_m)} \bigoplus\nolimits_{j = 1, \ldots, m} N \to M \to 0 $$ with $M$ flat over $A$. Hence for every homomorphism $A \to \kappa$ where $\kappa$ is a field, we obtain a short exact sequence $$ 0 \to N \otimes_A \kappa \xrightarrow{(g_1 \otimes 1, \ldots, g_m \otimes 1)} \bigoplus\nolimits_{j = 1, \ldots, m} N \otimes_A \kappa \to M \otimes_A \kappa \to 0 $$ see Algebra, Lemma \ref{algebra-lemma-flat-tor-zero}. Reversing the arguments above this means that $\bigcup D(g_j \otimes 1)$ contains $\text{Ass}_{B \otimes_A \kappa}(N \otimes_A \kappa)$. As $\bigcup D(g_j \otimes 1) = \bigcup D(g_j)_\kappa \subset U_\kappa$ we obtain that $U_\kappa$ contains $\text{Ass}_{X \otimes \kappa}(\mathcal{F} \otimes \kappa)$ which is what we wanted to prove.
Let $y \in Y$. We have to show that there exists an open neighbourhood $V$ of $y$ in $Y$ such that $E \cap V$ is constructible in $V$. Thus we may assume that $Y$ is affine. Write $Y = \Spec(A)$ and $A = \colim A_i$ as a directed limit of finite type $\mathbf{Z}$-algebras. By Limits, Lemma \ref{limits-lemma-descend-finite-presentation} we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of finite presentation whose base change to $Y$ recovers $f$. After possibly increasing $i$ we may assume there exists a quasi-coherent $\mathcal{O}_{X_i}$-module $\mathcal{F}_i$ of finite presentation whose pullback to $X$ is isomorphic to $\mathcal{F}$, see Limits, Lemma \ref{limits-lemma-descend-modules-finite-presentation}. After possibly increasing $i$ one more time we may assume there exists an open subscheme $U_i \subset X_i$ whose inverse image in $X$ is $U$, see Limits, Lemma \ref{limits-lemma-descend-opens}. By Lemma \ref{lemma-base-change-assassin-in-U} it suffices to prove the lemma for $f_i$. Thus we reduce to the case where $Y$ is the spectrum of a Noetherian ring. \medskip\noindent We will use the criterion of Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian} to prove that $E$ is constructible in case $Y$ is a Noetherian scheme. To see this let $Z \subset Y$ be an irreducible closed subscheme. We have to show that $E \cap Z$ either contains a nonempty open subset or is not dense in $Z$. This follows from Lemmas \ref{lemma-bad-case} and \ref{lemma-good-case} applied to the base change $(X, \mathcal{F}, U) \times_Y Z$ over $Z$.
Let $Y' \subset Y$ be the reduction of $Y$. Let $X' \to Y'$ be the base change of $f$. Note that $Y' \to Y$ induces a bijection on points and that $X' \to X$ identifies fibres. Hence we may assume that $Y'$ is reduced, i.e., integral, see Properties, Lemma \ref{properties-lemma-characterize-integral}. We may also replace $Y$ by an affine open. Hence we may assume that $Y = \Spec(A)$ with $A$ a domain. Denote $K$ the fraction field of $A$. Pick an affine open $\Spec(B) = U \subset X$ and a section $h_\eta \in \Gamma(U_\eta, \mathcal{O}_{U_\eta}) = B_K$ which is nonzero and nilpotent. After shrinking $Y$ we may assume that $h$ comes from $h \in \Gamma(U, \mathcal{O}_U) = B$. After shrinking $Y$ a bit more we may assume that $h$ is nilpotent. Let $I = \{b \in B \mid hb = 0\}$ be the annihilator of $h$. Then $C = B/I$ is a finite type $A$-algebra whose generic fiber $(B/I)_K$ is nonzero (as $h_\eta \not = 0$). We apply generic flatness to $A \to C$ and $A \to B/hB$, see Algebra, Lemma \ref{algebra-lemma-generic-flatness}, and we obtain a $g \in A$, $g \not = 0$ such that $C_g$ is free as an $A_g$-module and $(B/hB)_g$ is flat as an $A_g$-module. Replace $Y$ by $D(g) \subset Y$. Now we have the short exact sequence $$ 0 \to C \to B \to B/hB \to 0. $$ with $B/hB$ flat over $A$ and with $C$ nonzero free as an $A$-module. It follows that for any homomorphism $A \to \kappa$ to a field the ring $C \otimes_A \kappa$ is nonzero and the sequence $$ 0 \to C \otimes_A \kappa \to B \otimes_A \kappa \to B/hB \otimes_A \kappa \to 0 $$ is exact, see Algebra, Lemma \ref{algebra-lemma-flat-tor-zero}. Note that $B/hB \otimes_A \kappa = (B \otimes_A \kappa) / h(B \otimes_A \kappa)$ by right exactness of tensor product. Thus we conclude that multiplication by $h$ is not zero on $B \otimes_A \kappa$. This clearly means that for any point $y \in Y$ the element $h$ restricts to a nonzero element of $U_y$, whence $X_y$ is nonreduced.
This comes down to the statement that for $y' \in Y'$ with image $y \in Y$ the fibre $X'_{y'} = X_y \times_y y'$ is geometrically reduced over $\kappa(y')$ if and only if $X_y$ is geometrically reduced over $\kappa(y)$. This follows from Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-upstairs}.
Apply Lemma \ref{lemma-make-generic-fibre-geometrically-reduced} to get $$ \xymatrix{ X' \ar[d]_{f'} \ar[r]_{g'} & X_V \ar[r] \ar[d] & X \ar[d]^f \\ Y' \ar[r]^g & V \ar[r] & Y } $$ with all the properties mentioned in that lemma. Let $\eta'$ be the generic point of $Y'$. Consider the morphism $X' \to X_{Y'}$ (which is the reduction morphism) and the resulting morphism of generic fibres $X'_{\eta'} \to X_{\eta'}$. Since $X'_{\eta'}$ is geometrically reduced, and $X_\eta$ is not this cannot be an isomorphism, see Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-upstairs}. Hence $X_{\eta'}$ is nonreduced. Hence by Lemma \ref{lemma-nonreduced-in-neighbourhood} the fibres of $X_{Y'} \to Y'$ are nonreduced at all points $y' \in V'$ of a nonempty open $V' \subset Y'$. Since $g : Y' \to V$ is a homeomorphism Lemma \ref{lemma-base-change-fibres-geometrically-reduced} proves that $g(V')$ is the open we are looking for.
Let $Y' \subset Y$ be the reduction of $Y$. Let $X' \to Y'$ be the base change of $f$. Note that $Y' \to Y$ induces a bijection on points and that $X' \to X$ identifies fibres. Hence we may assume that $Y'$ is reduced, i.e., integral, see Properties, Lemma \ref{properties-lemma-characterize-integral}. We may also replace $Y$ by an affine open. Hence we may assume that $Y = \Spec(A)$ with $A$ a domain. Denote $K$ the fraction field of $A$. After shrinking $Y$ a bit we may also assume that $X \to Y$ is flat and of finite presentation, see Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}. \medskip\noindent As $X_\eta$ is geometrically reduced there exists an open dense subset $V \subset X_\eta$ such that $V \to \Spec(K)$ is smooth, see Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-dense-smooth-open}. Let $U \subset X$ be the set of points where $f$ is smooth. By Morphisms, Lemma \ref{morphisms-lemma-set-points-where-fibres-smooth} we see that $V \subset U_\eta$. Thus the generic fibre of $U$ is dense in the generic fibre of $X$. Since $X_\eta$ is reduced, it follows that $U_\eta$ is scheme theoretically dense in $X_\eta$, see Morphisms, Lemma \ref{morphisms-lemma-reduced-scheme-theoretically-dense}. We note that as $U \to Y$ is smooth all the fibres of $U \to Y$ are geometrically reduced. Thus it suffices to show that, after shrinking $Y$, for all $y \in Y$ the scheme $U_y$ is scheme theoretically dense in $X_y$, see Morphisms, Lemma \ref{morphisms-lemma-reduced-subscheme-closure}. This follows from Lemma \ref{lemma-scheme-theoretically-dense-generic-fibre}.
Let $y \in Y$. We have to show that there exists an open neighbourhood $V$ of $y$ in $Y$ such that $E \cap V$ is constructible in $V$. Thus we may assume that $Y$ is affine. Then $X$ is quasi-compact. Choose a finite affine open covering $X = U_1 \cup \ldots \cup U_n$. Then the fibres of $U_i \to Y$ at $y$ form an affine open covering of the fibre of $X \to Y$ at $y$. Hence we may assume $X$ is affine as well.  Write $Y = \Spec(A)$. Write $A = \colim A_i$ as a directed limit of finite type $\mathbf{Z}$-algebras. By Limits, Lemma \ref{limits-lemma-descend-finite-presentation} we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of finite presentation whose base change to $Y$ recovers $f$. By Lemma \ref{lemma-base-change-fibres-geometrically-reduced} it suffices to prove the lemma for $f_i$. Thus we reduce to the case where $Y$ is the spectrum of a Noetherian ring. \medskip\noindent We will use the criterion of Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian} to prove that $E$ is constructible in case $Y$ is a Noetherian scheme. To see this let $Z \subset Y$ be an irreducible closed subscheme. We have to show that $E \cap Z$ either contains a nonempty open subset or is not dense in $Z$. If $X_\xi$ is geometrically reduced, then Lemma \ref{lemma-geometrically-reduced-generic-fibre} (applied to the morphism $X_Z \to Z$) implies that all fibres $X_y$ are geometrically reduced for a nonempty open $V \subset Z$. If $X_\xi$ is not geometrically reduced, then Lemma \ref{lemma-not-geometrically-reduced-in-neighbourhood} (applied to the morphism $X_Z \to Z$) implies that all fibres $X_y$ are geometrically reduced for a nonempty open $V \subset Z$. Thus we win.
Let $x \in X$ be a point in the generic fibre $X_\eta$ such that $\mathcal{O}_{X_\eta}$ is nonreduced. Then $\mathcal{O}_{X, x}$ is nonreduced. Let $x \leadsto x'$ be a specialization with $x'$ in the special fibre; such a specialization exists as a proper morphism is closed. Consider the local ring $A = \mathcal{O}_{X, x'}$. Let $\pi \in R$ be a uniformizer. If $a \in A$ then there exists an $n \geq 0$ and an element $a' \in A$ such that $a = \pi^n a'$ and $a' \not \in \pi A$. This follows from Krull intersection theorem (Algebra, Lemma \ref{algebra-lemma-intersect-powers-ideal-module-zero}). If $a$ is nilpotent, so is $a'$, because $\pi$ is a nonzerodivisor by flatness of $A$ over $R$. But $a'$ maps to a nonzero element of the reduced ring $A/\pi A = \mathcal{O}_{X_s, x'}$. This is a contradiction unless $A$ is reduced, which is what we wanted to show.
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, Lemma \ref{limits-lemma-descend-finite-presentation}, \ref{limits-lemma-descend-flat-finite-presentation}, and \ref{limits-lemma-eventually-proper}. Since the formation of the set of points where the fibres are geometrically reduced commutes with base change (Lemma \ref{lemma-base-change-fibres-geometrically-reduced}), 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 Varieties, Lemma \ref{varieties-lemma-geometrically-reduced}. 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}.
As the question is purely topological we may replace $X$ and $Y$ by their reductions. In particular this implies that $Y$ is integral, see Properties, Lemma \ref{properties-lemma-characterize-integral}. Let $X_\eta = X_{1, \eta} \cup \ldots \cup X_{n, \eta}$ be the decomposition of $X_\eta$ into irreducible components. Let $X_i \subset X$ be the reduced closed subscheme whose generic fibre is $X_{i, \eta}$. Note that $Z_{i, j} = X_i \cap X_j$ is a closed subset of $X_i$ whose generic fibre $Z_{i, j, \eta}$ is nowhere dense in $X_{i, \eta}$. Hence after shrinking $Y$ we may assume that $Z_{i, j, y}$ is nowhere dense in $X_{i, y}$ for every $y \in Y$, see Lemma \ref{lemma-nowhere-dense-generic-fibre}. After shrinking $Y$ some more we may assume that $X_y = \bigcup X_{i, y}$ for $y \in Y$, see Lemma \ref{lemma-cover-generic-fibre-neighbourhood}. Moreover, after shrinking $Y$ we may assume that each $X_i \to Y$ is flat and of finite presentation, see Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}. The morphisms $X_i \to Y$ are open, see Morphisms, Lemma \ref{morphisms-lemma-fppf-open}. Thus there exists an open neighbourhood $V$ of $\eta$ which is contained in $f(X_i)$ for each $i$. For each $y \in V$ the schemes $X_{i, y}$ are nonempty closed subsets of $X_y$, we have $X_y = \bigcup X_{i, y}$ and the intersections $Z_{i, j, y} = X_{i, y} \cap X_{j, y}$ are not dense in $X_{i, y}$. Clearly this implies that $X_y$ has at least $n$ irreducible components.
This comes down to the statement that for $y' \in Y'$ with image $y \in Y$ the fibre $X'_{y'} = X_y \times_y y'$ is geometrically irreducible over $\kappa(y')$ if and only if $X_y$ is geometrically irreducible over $\kappa(y)$. This follows from Varieties, Lemma \ref{varieties-lemma-geometrically-irreducible-check-after-extension}.
Suppose that $y' \in Y'$ has image $y \in Y$. Suppose $K \supset \kappa(y)$ and $K' \supset \kappa(y')$ are separably closed extensions. Then we may choose a commutative diagram $$ \xymatrix{ K \ar[r] & K'' & K' \ar[l] \\ \kappa(y) \ar[u] \ar[rr] & & \kappa(y') \ar[u] } $$ of fields. The result follows as the morphisms of schemes $$ \xymatrix{ (X'_{y'})_{K'} & (X'_{y'})_{K''} = (X_y)_{K''} \ar[l] \ar[r] & (X_y)_K } $$ induce bijections between irreducible components, see Varieties, Lemma \ref{varieties-lemma-separably-closed-field-irreducible-components}.
There exists an automorphism $\Psi$ of $A[x_1, \ldots, x_n]$ over $A$ such that $\Psi(P) = ax_n^d +$ lower order terms in $x_n$ with $a \not = 0$, see Algebra, Lemma \ref{algebra-lemma-helper-polynomial}. We may replace $P$ by $\Psi(P)$ and we may replace $A$ by $A_a$. Thus we may assume that $P$ is monic in $x_n$ of degree $d > 0$. For $i = 1, \ldots, n - 1$ let $d_i$ be the degree of $P$ in $x_i$. Note that this implies that $P^\varphi$ is monic of degree $d$ in $x_n$ and has degree $\leq d_i$ in $x_i$ for every homomorphism $\varphi : A \to \kappa$ where $\kappa$ is a field. Thus if $P^\varphi$ is reducible, then we can write $$ P^\varphi = Q_1 Q_2 $$ with $Q_1, Q_2$ monic of degree $e_1, e_2 \geq 0$ in $x_n$ with $e_1 + e_2 = d$ and having degree $\leq d_i$ in $x_i$ for $i = 1, \ldots, n - 1$. In other words we can write \begin{equation} \label{equation-factors} Q_j = x_n^{e_j} + \sum\nolimits_{0 \leq l < e_j} \left( \sum\nolimits_{L \in \mathcal{L}} a_{j, l, L} x^L \right) x_n^l \end{equation} where the sum is over the set $\mathcal{L}$ of multi-indices $L$ of the form $L = (l_1, \ldots, l_{n - 1})$ with $0 \leq l_i \leq d_i$. For any $e_1, e_2 \geq 0$ with $e_1 + e_2 = d$ we consider the $A$-algebra $$ B_{e_1, e_2} = A[\{a_{1, l, L}\}_{0 \leq l < e_1, L \in \mathcal{L}}, \{a_{2, l, L}\}_{0 \leq l < e_2, L \in \mathcal{L}}]/(\text{relations}) $$ where the $(\text{relations})$ is the ideal generated by the coefficients of the polynomial $$ P - Q_1Q_2 \in A[\{a_{1, l, L}\}_{0 \leq l < e_1, L \in \mathcal{L}}, \{a_{2, l, L}\}_{0 \leq l < e_2, L \in \mathcal{L}}][x_1, \ldots, x_n] $$ with $Q_1$ and $Q_2$ defined as in (\ref{equation-factors}). OK, and the assumption that $P$ is irreducible over $\overline{K}$ implies that there does not exist any $A$-algebra homomorphism $B_{e_1, e_2} \to \overline{K}$. By the Hilbert Nullstellensatz, see Algebra, Theorem \ref{algebra-theorem-nullstellensatz} this means that $B_{e_1, e_2} \otimes_A K = 0$. As $B_{e_1, e_2}$ is a finitely generated $A$-algebra this signifies that we can find an $f_{e_1, e_2} \in A$ such that $(B_{e_1, e_2})_{f_{e_1, e_2}} = 0$. By construction this means that if $\varphi : A_{f_{e_1, e_2}} \to \kappa$ is a homomorphism to a field, then $P^\varphi$ does not have a factorization $P^\varphi = Q_1 Q_2$ with $Q_1$ of degree $e_1$ in $x_n$ and $Q_2$ of degree $e_2$ in $x_n$. Thus taking $f = \prod_{e1, e_2 \geq 0, e_1 + e_2 = d} f_{e_1, e_2}$ we win.
[First proof of Lemma \ref{lemma-geom-irreducible-generic-fibre}] We give two proofs of the lemma. These are essentially equivalent; the second is more self contained but a bit longer. Choose a diagram $$ \xymatrix{ X' \ar[d]_{f'} \ar[r]_{g'} & X_V \ar[r] \ar[d] & X \ar[d]^f \\ Y' \ar[r]^g & V \ar[r] & Y } $$ as in Lemma \ref{lemma-make-generic-fibre-geometrically-reduced}. Note that the generic fibre of $f'$ is the reduction of the generic fibre of $f$ (see Lemma \ref{lemma-reduction-generic-fibre}) and hence is geometrically irreducible. Suppose that the lemma holds for the morphism $f'$. Then after shrinking $V$ all the fibres of $f'$ are geometrically irreducible. As $X' = (Y' \times_V X_V)_{red}$ this implies that all the fibres of $Y' \times_V X_V$ are geometrically irreducible. Hence by Lemma \ref{lemma-base-change-fibres-geometrically-irreducible} all the fibres of $X_V \to V$ are geometrically irreducible and we win. In this way we see that we may assume that the generic fibre is geometrically reduced as well as geometrically irreducible and we may assume $Y = \Spec(A)$ with $A$ a domain. \medskip\noindent Let $x \in X_\eta$ be the generic point. As $X_\eta$ is geometrically irreducible and reduced we see that $L = \kappa(x)$ is a finitely generated extension of $K = \kappa(\eta)$ which is geometrically reduced and geometrically irreducible, see Varieties, Lemmas \ref{varieties-lemma-geometrically-reduced-at-point} and \ref{varieties-lemma-geometrically-irreducible-function-field}. In particular the field extension $K \subset L$ is separable, see Algebra, Lemma \ref{algebra-lemma-characterize-separable-field-extensions}. Hence we can find $x_1, \ldots, x_{r + 1} \in L$ which generate $L$ over $K$ and such that $x_1, \ldots, x_r$ is a transcendence basis for $L$ over $K$, see Algebra, Lemma \ref{algebra-lemma-generating-finitely-generated-separable-field-extensions}. Let $P \in K(x_1, \ldots, x_r)[T]$ be the minimal polynomial for $x_{r + 1}$. Clearing denominators we may assume that $P$ has coefficients in $A[x_1, \ldots, x_r]$. Note that as $L$ is geometrically reduced and geometrically irreducible over $K$, the polynomial $P$ is irreducible in $\overline{K}[x_1, \ldots, x_r, T]$ where $\overline{K}$ is the algebraic closure of $K$. Denote $$ B' = A[x_1, \ldots, x_{r + 1}]/(P(x_{r + 1})) $$ and set $X' = \Spec(B')$. By construction the fraction field of $B'$ is isomorphic to $L = \kappa(x)$ as $K$-extensions. Hence there exists an open $U \subset X$, and open $U' \subset X'$ and a $Y$-isomorphism $U \to U'$, see Morphisms, Lemma \ref{morphisms-lemma-common-open}. Here is a diagram: $$ \xymatrix{ X \ar[rd] & U \ar[l] \ar@{=}[r] \ar[d] & U' \ar[r] \ar[d] & X' \ar[ld] \ar@{=}[r] & \Spec(B') \\ & Y \ar@{=}[r] & Y & } $$ Note that $U_\eta \subset X_\eta$ and $U'_\eta \subset X'_\eta$ are dense opens. Thus after shrinking $Y$ by applying Lemma \ref{lemma-nowhere-dense-generic-fibre} we obtain that $U_y$ is dense in $X_y$ and $U'_y$ is dense in $X'_y$ for all $y \in Y$. Thus it suffices to prove the lemma for $X' \to Y$ which is the content of Lemma \ref{lemma-irreducible-polynomial-over-domain}.
Let $Z$ be the reduced induced scheme structure on $\overline{\{y\}}$. Let $f_Z : X_Z \to Z$ be the base change of $f$. Clearly it suffices to prove the lemma for $f_Z$ and the generic point of $Z$. Hence we may assume that $Y$ is an integral scheme, see Properties, Lemma \ref{properties-lemma-characterize-integral}. Our goal in this case is to produce a nonempty open $V \subset Y$ such that $n_{X/Y}|_V$ is constant. \medskip\noindent We apply Lemma \ref{lemma-make-components-generic-fibre-geometrically-irreducible} to $f : X \to Y$ and we get $g : Y' \to V \subset Y$. As $g : Y' \to V$ is surjective finite \'etale, in particular open (see Morphisms, Lemma \ref{morphisms-lemma-etale-open}), it suffices to prove that there exists an open $V' \subset Y'$ such that $n_{X'/Y'}|_{V'}$ is constant, see Lemma \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components}. Thus we see that we may assume that all irreducible components of the generic fibre $X_\eta$ are geometrically irreducible over $\kappa(\eta)$. \medskip\noindent At this point suppose that $X_\eta = X_{1, \eta} \bigcup \ldots \bigcup X_{n, \eta}$ is the decomposition of the generic fibre into (geometrically) irreducible components. In particular $n_{X/Y}(\eta) = n$. Let $X_i$ be the closure of $X_{i, \eta}$ in $X$. After shrinking $Y$ we may assume that $X = \bigcup X_i$, see Lemma \ref{lemma-cover-generic-fibre-neighbourhood}. After shrinking $Y$ some more we see that each fibre of $f$ has at least $n$ irreducible components, see Lemma \ref{lemma-irreducible-components-in-neighbourhood}. Hence $n_{X/Y}(y) \geq n$ for all $y \in Y$. After shrinking $Y$ some more we obtain that $X_{i, y}$ is geometrically irreducible for each $i$ and all $y \in Y$, see Lemma \ref{lemma-geom-irreducible-generic-fibre}. Since $X_y = \bigcup X_{i, y}$ this shows that $n_{X/Y}(y) \leq n$ and finishes the proof.