hcju/stacksqa huggingface dataset:
Fix $n$. Let $y \in Y$. We have to show that there exists an open neighbourhood $V$ of $y$ in $Y$ such that $E_n \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$. By Lemma \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components} 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_n$ 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_n \cap Z$ either contains a nonempty open subset or is not dense in $Z$. Let $\xi \in Z$ be the generic point. Then Lemma \ref{lemma-nr-geom-irreducible-components-good} shows that $n_{X/Y}$ is constant in a neighbourhood of $\xi$ in $Z$. This clearly implies what we want.
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 connected 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$ whose generic fibre $Z_{i, j, \eta}$ is empty. Hence after shrinking $Y$ we may assume that $Z_{i, j} = \emptyset$, see Lemma \ref{lemma-empty-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 empty! Clearly this implies that $X_y$ has at least $n$ connected 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 connected over $\kappa(y')$ if and only if $X_y$ is geometrically connected over $\kappa(y)$. This follows from Varieties, Lemma \ref{varieties-lemma-geometrically-connected-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 connected components, see Varieties, Lemma \ref{varieties-lemma-separably-closed-field-connected-components}.
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)$. By Varieties, Lemma \ref{varieties-lemma-irreducible-components-geometrically-irreducible} this implies that also the connected components of $X_\eta$ are geometrically connected. \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) connected 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$ connected components, see Lemma \ref{lemma-connected-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 connected for each $i$ and all $y \in Y$, see Lemma \ref{lemma-geometrically-connected-generic-fibre}. Since $X_y = \bigcup X_{i, y}$ this shows that $n_{X/Y}(y) \leq n$ and finishes the proof.
Fix $n$. Let $y \in Y$. We have to show that there exists an open neighbourhood $V$ of $y$ in $Y$ such that $E_n \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$. By Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components} 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_n$ 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_n \cap Z$ either contains a nonempty open subset or is not dense in $Z$. Let $\xi \in Z$ be the generic point. Then Lemma \ref{lemma-nr-geom-connected-components-good} shows that $n_{X/Y}$ is constant in a neighbourhood of $\xi$ in $Z$. This clearly implies what we want.
Write $S = \Spec(R)$ and let $\pi \in R$ be a uniformizer. To get a contradiction assume that $X_\eta$ is disconnected. This means there exists a nontrivial idempotent $e \in \Gamma(X_\eta, \mathcal{O}_{X_\eta})$. Let $U = \Spec(A)$ be any affine open in $X$. Note that $\pi$ is a nonzerodivisor on $A$ as $A$ is flat over $R$, see More on Algebra, Lemma \ref{more-algebra-lemma-flat-torsion-free} for example. Then $e|_{U_\eta}$ corresponds to an element $e \in A[1/\pi]$. Let $z \in A$ be an element such that $e = z/\pi^n$ with $n \geq 0$ minimal. Note that $z^2 = \pi^nz$. This means that $z \bmod \pi A$ is nilpotent if $n > 0$. By assumption $A/\pi A$ is reduced, and hence minimality of $n$ implies $n = 0$. Thus we conclude that $e \in A$! In other words $e \in \Gamma(X, \mathcal{O}_X)$. As $X$ is connected it follows that $e$ is a trivial idempotent which is a contradiction.
Let $y' \in Y'$ with image $y \in Y$. We may think of $X^0_y$ as a closed subscheme of $X_y$, see for example Morphisms, Definition \ref{morphisms-definition-scheme-structure-connected-component}. As $s(y) \in X^0_y$ we conclude from Varieties, Lemma \ref{varieties-lemma-geometrically-connected-if-connected-and-point} that $X_y^0$ is a geometrically connected scheme over $\kappa(y)$. Hence $X_y^0 \times_y y' \to X'_{y'}$ is a connected closed subscheme which contains $s'(y')$. Thus $X_y^0 \times_y y' \subset (X'_{y'})^0$. The other inclusion $X_y^0 \times_y y' \supset (X'_{y'})^0$ is clear as the image of $(X'_{y'})^0$ in $X_y$ is a connected subset of $X_y$ which contains $s(y)$.
Let $Z \subset Y$ be the induced reduced closed subscheme structure on $\overline{\{y\}}$. Let $f_Z : X_Z \to Z$ and $s_Z : Z \to X_Z$ be the base changes of $f$ and $s$. By Lemma \ref{lemma-base-change-connected-along-section} we have $(X_Z)^0 = (X^0)_Z$. Hence it suffices to prove the lemma for the morphism $X_Z \to Z$ and the point $x \in X_Z$ which maps to the generic point of $Z$. In other words we have reduced the problem to the case where $Y$ is an integral scheme (see Properties, Lemma \ref{properties-lemma-characterize-integral}) with generic point $\eta$. Our goal is to show that after shrinking $Y$ the subset $X^0$ becomes an open and closed subset of $X$. \medskip\noindent Note that the scheme $X_\eta$ is of finite type over a field, hence Noetherian. Thus its connected components are open as well as closed. Hence we may write $X_\eta = X_\eta^0 \amalg T_\eta$ for some open and closed subset $T_\eta$ of $X_\eta$. Next, let $T \subset X$ be the closure of $T_\eta$ and let $X^{00} \subset X$ be the closure of $X_\eta^0$. Note that $T_\eta$, resp.\ $X^0_\eta$ is the generic fibre of $T$, resp.\ $X^{00}$, see discussion preceding Lemma \ref{lemma-cover-generic-fibre-neighbourhood}. Moreover, that lemma implies that after shrinking $Y$ we may assume that $X = X^{00} \cup T$ (set theoretically). Note that $(T \cap X^{00})_\eta = T_\eta \cap X^0_\eta = \emptyset$. Hence after shrinking $Y$ we may assume that $T \cap X^{00} = \emptyset$, see Lemma \ref{lemma-empty-generic-fibre}. In particular $X^{00}$ is open in $X$. Note that $X^0_\eta$ is connected and has a rational point, namely $s(\eta)$, hence it is geometrically connected, see Varieties, Lemma \ref{varieties-lemma-geometrically-connected-if-connected-and-point}. Thus after shrinking $Y$ we may assume that all fibres of $X^{00} \to Y$ are geometrically connected, see Lemma \ref{lemma-geometrically-connected-generic-fibre}. At this point it follows that the fibres $X^{00}_y$ are open, closed, and connected subsets of $X_y$ containing $\sigma(y)$. It follows that $X^0 = X^{00}$ and we win.
Let $x \in X$. We have to show that there exists an open neighbourhood $U$ of $x$ such that $X^0 \cap U$ is constructible in $U$. This reduces us to the case where $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, endowed with a section $s_i : \Spec(A_i) \to X_i$ whose base change to $Y$ recovers $f$ and the section $s$. By Lemma \ref{lemma-base-change-connected-along-section} it suffices to prove the lemma for $f_i, s_i$. Thus we reduce to the case where $Y$ is the spectrum of a Noetherian ring. \medskip\noindent Assume $Y$ is a Noetherian affine scheme. Since $f$ is of finite presentation, i.e., of finite type, we see that $X$ is a Noetherian scheme too, see Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}. In order to prove the lemma in this case it suffices to show that for every irreducible closed subset $Z \subset X$ the intersection $Z \cap X^0$ either contains a nonempty open of $Z$ or is not dense in $Z$, see Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian}. Let $x \in Z$ be the generic point, and let $y = f(x)$. By Lemma \ref{lemma-connected-along-section-good} there exists a nonempty open subset $V \subset \overline{\{y\}}$ such that $X^0 \cap X_V$ is open and closed in $X_V$. Since $f(Z) \subset \overline{\{y\}}$ and $f(x) = y \in V$ we see that $W = f^{-1}(V) \cap Z$ is a nonempty open subset of $Z$. It follows that $X^0 \cap W$ is open and closed in $W$. Since $W$ is irreducible we see that $X^0 \cap W$ is either empty or equal to $W$. This proves the lemma.
Let $Z = \{x \in X \mid \dim_x(X_{f(x)}) > n \}$. By Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres} this is a closed subset of $X$. By assumption $Z_\eta = \emptyset$. Hence by Lemma \ref{lemma-empty-generic-fibre} we may shrink $Y$ and assume that $Z = \emptyset$. Let $Z' = \{x \in X \mid \dim_x(X_{f(x)}) > n - 1 \} = \{x \in X \mid \dim_x(X_{f(x)}) = n\}$. As before this is a closed subset of $X$. By assumption we have $Z'_\eta \not = \emptyset$. Hence after shrinking $Y$ we may assume that $Z' \to Y$ is surjective, see Lemma \ref{lemma-nonempty-generic-fibre}. Hence we win.
Fix $n$. Let $y \in Y$. We have to show that there exists an open neighbourhood $V$ of $y$ in $Y$ such that $E_n \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$. By Lemma \ref{lemma-base-change-dimension-fibres} 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_n$ 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_n \cap Z$ either contains a nonempty open subset or is not dense in $Z$. Let $\xi \in Z$ be the generic point. Then Lemma \ref{lemma-dimension-in-neighbourhood} shows that $n_{X/Y}$ is constant in a neighbourhood of $\xi$ in $Z$. This implies what we want.
Let $W \subset X$, $W = \coprod_{d \geq 0} U_d$ be the open constructed in Lemmas \ref{lemma-flat-finite-presentation-CM-open} and \ref{lemma-flat-finite-presentation-CM-pieces}. Let $y \in Y$ be a point. If $n_{X/Y}(y) = \dim(X_y) = n$, then $y$ is in the image of $U_n \to Y$. By Morphisms, Lemma \ref{morphisms-lemma-fppf-open} we see that $f(U_n)$ is open in $Y$. Hence there is an open neighbourhoof of $y$ where $n_{X/Y}$ is $\geq n$.
Let $Z_d = \{x \in X \mid \dim_x(X_{f(x)}) > d\}$. Then $Z_d$ is a closed subset of $X$ by Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}. Since $f$ is proper $f(Z_d)$ is closed. Since $y \in f(Z_d) \Leftrightarrow n_{X/Y}(y) > d$ we see that the lemma is true.
The algebraic independence over $k$ means that the morphism $$ T = \Spec(A[x_1, \ldots, x_n]) \longrightarrow \Spec(k[x_1, \ldots, x_n, y, z]) = S $$ given by $y = \sum g_ix_i$ and $z = \sum c_ig_i$ is dominant. Set $d = \dim(A)$. If $T \to S$ is not dominant, then the image has dimension $< n + 2$ and hence every irreducible component of every fibre has dimension $> d + n - (n + 2) = d - 2$, see Varieties, Lemma \ref{varieties-lemma-dimension-fibres-locally-algebraic}. Choose a closed point $u \in V(g_1, g_2)$ contained in an irreducible component of dimension $d - 2$ and in no other component of $V(g_1, g_2)$. Consider the closed point $t = (u, 1, 0, \ldots 0)$ of $T$ lying over $u$. Set $(c_1, \ldots, c_n) = (0, 1, 0, \ldots, 0)$. Then $t$ maps to the point $s = (1, 0, \ldots, 0)$ of $S$. The fibre of $T \to S$ over $s$ is cut out by $$ x_1 - 1, x_2, \ldots, x_n, \sum x_ig_i, g_2 $$ and hence equivalently is cut out by $$ x_1 - 1, x_2, \ldots, x_n, g_1, g_2 $$ By our condition on $g_1, g_2$ this subscheme has an irreducible component of dimension $d - 2$.
Write $S = \Spec(A)$. We will first prove the lemma when $A$ is a discrete valuation ring (as this is the case most often used in practice). Let $\pi \in A$ be a uniformizer. Take a trivializing section $s \in \Gamma(X_\eta, \mathcal{L}_\eta)$. After replacing $s$ by $\pi^n s$ if necessary we can assume that $s \in \Gamma(X, \mathcal{L})$. If $s|_{X_0} = 0$, then we see that $s$ is divisible by $\pi$ (because $X_0$ is the scheme theoretic fibre and $X$ is flat over $A$). Thus we may assume that $s|_{X_0}$ is nonzero. Then the zero locus $Z(s)$ of $s$ is contained in $X_0$ but does not contain the generic point of $X_0$ (because $X_0$ is integral). This means that the $Z(s)$ has codimension $\geq 2$ in $X$ which contradicts Divisors, Lemma \ref{divisors-lemma-effective-Cartier-codimension-1} unless $Z(s) = \emptyset$ as desired. \medskip\noindent Proof in the general case. Since the valuation ring $A$ is coherent (Algebra, Example \ref{algebra-example-valuation-ring-coherent}) we see that $H^0(X, \mathcal{L})$ is a coherent $A$-module, see Derived Categories of Schemes, Lemma \ref{perfect-lemma-cohomology-over-coherent-ring}. Equivalently, $H^0(X, \mathcal{L})$ is a finitely presented $A$-module (Algebra, Lemma \ref{algebra-lemma-coherent-ring}). Since $H^0(X, \mathcal{L})$ is torsion free (by flatness of $X$ over $A$), we see from More on Algebra, Lemma \ref{more-algebra-lemma-generalized-valuation-ring-modules} that $H^0(X, \mathcal{L}) = A^{\oplus n}$ for some $n$. By flat base change (Cohomology of Schemes, Lemma \ref{coherent-lemma-flat-base-change-cohomology}) we have $$ K = H^0(X_\eta, \mathcal{O}_{X_\eta}) \cong H^0(X_\eta, \mathcal{L}_\eta) = H^0(X, \mathcal{L}) \otimes_A K $$ where $K$ is the fraction field of $A$. Thus $n = 1$. Pick a generator $s \in H^0(X, \mathcal{L})$. Let $\mathfrak m \subset A$ be the maximal ideal. Then $\kappa = A/\mathfrak m = \colim A/\pi$ where this is a filtered colimit over nonzero $\pi \in \mathfrak m$ (here we use that $A$ is a valuation ring). Thus $X_0 = \lim X \times_S \Spec(A/\pi)$. If $s|_{X_0}$ is zero, then for some $\pi$ we see that $s$ restricts to zero on $X \times_S \Spec(A/\pi)$, see Limits, Lemma \ref{limits-lemma-descend-section}. But if this happens, then $\pi^{-1} s$ is a global section of $\mathcal{L}$ which contradicts the fact that $s$ is a generator of $H^0(X, \mathcal{L})$. Thus $s|_{X_0}$ is not zero. Let $Z(s) \subset X$ be the zero scheme of $s$. Since $s|_{X_0}$ is not zero and since $X_0$ is integral, we see that $Z(s)_0 \subset X_0$ is an effective Cartier divisor. Since $f$ is proper and $S$ is local, every point of $Z(s)$ specializes to a point of $Z(s)_0$. Thus by Divisors, Lemma \ref{divisors-lemma-fibre-Cartier} part (3) we see that $Z(s)$ is a relative effective Cartier divisor, in particular $Z(s) \to S$ is flat. Hence if $Z(s)$ were nonemtpy, then $Z(s)_\eta$ would be nonempty which contradicts the fact that $s|_{X_\eta}$ is a trivialization of $\mathcal{L}_\eta$. Thus $Z(s) = \emptyset$ as desired.
Since $j : Z \to S$ is of finite presentation, it suffices to show: for any morphism $g : \Spec(A) \to S$ where $A$ is a valuation ring with fraction field $K$ such that $g(\Spec(K)) \in j(Z)$ we have $g(\Spec(A)) \subset j(Z)$. See Morphisms, Lemma \ref{morphisms-lemma-reach-points-scheme-theoretic-image}. This follows from Lemma \ref{lemma-triviality-generic-fibre-valuation-ring} and the characterization of $j : Z \to S$ in Lemma \ref{lemma-diagonal-picard-flat-proper}.
We may replace $S$ by $Z'$. After shrinking $S$ to an affine open neighbourhood of $s$ we may assume that $\mathcal{L}' = \mathcal{O}_{X'}$. Let $E = Rf_*\mathcal{L}$ and $E' = Rf'_*\mathcal{L}' = Rf'_*\mathcal{O}_{X'}$. These are perfect complexes whose formation commutes with arbitrary change of base (Derived Categories of Schemes, Lemma \ref{perfect-lemma-flat-proper-perfect-direct-image-general}). In particular we see that $$ E \otimes_{\mathcal{O}_S}^\mathbf{L} \kappa(s) = R\Gamma(X_s, \mathcal{L}_s) = R\Gamma(X_s, \mathcal{O}_{X_s}) $$ The second equality because $s \in Z$. Set $h_i = \dim_{\kappa(s)} H^i(X_s, \mathcal{O}_{X_s})$. After shrinking $S$ we can represent $E$ by a complex $$ \mathcal{O}_S \to \mathcal{O}_S^{\oplus h_1} \to \mathcal{O}_S^{\oplus h_2} \to \ldots $$ see More on Algebra, Lemma \ref{more-algebra-lemma-lift-perfect-from-residue-field} (strictly speaking this also uses Derived Categories of Schemes, Lemmas \ref{perfect-lemma-affine-compare-bounded} and \ref{perfect-lemma-perfect-affine}). Similarly, we may assume $E'$ is represented by a complex $$ \mathcal{O}_S \to \mathcal{O}_S^{\oplus h'_1} \to \mathcal{O}_S^{\oplus h'_2} \to \ldots $$ where $h'_i = \dim_{\kappa(s)} H^i(X'_s, \mathcal{O}_{X'_s})$. By functoriality of cohomology we have a map $$ E \longrightarrow E' $$ in $D(\mathcal{O}_S)$ whose formation commutes with change of base. Since the complex representing $E$ is a finite complex of finite free modules and since $S$ is affine, we can choose a map of complexes $$ \xymatrix{ \mathcal{O}_S \ar[r]_d \ar[d]_a & \mathcal{O}_S^{\oplus h_1} \ar[r] \ar[d]_b & \mathcal{O}_S^{\oplus h_2} \ar[r] \ar[d]_c & \ldots \\ \mathcal{O}_S \ar[r]^{d'} & \mathcal{O}_S^{\oplus h'_1} \ar[r] & \mathcal{O}_S^{\oplus h'_2} \ar[r] & \ldots } $$ representing the given map $E \to E'$. Since $s \in Z$ we see that the trivializing section of $\mathcal{L}_s$ pulls back to a trivializing section of $\mathcal{L}'_s = \mathcal{O}_{X'_s}$. Thus $a \otimes \kappa(s)$ is an isomorphism, hence after shrinking $S$ we see that $a$ is an isomorphism. Finally, we use the hypothesis that $H^1(X_s, \mathcal{O}) \to H^1(X'_s, \mathcal{O})$ is injective, to see that there exists a $h_1 \times h_1$ minor of the matrix defining $b$ which maps to a nonzero element in $\kappa(s)$. Hence after shrinking $S$ we may assume that $b$ is injective. However, since $\mathcal{L}' = \mathcal{O}_{X'}$ we see that $d' = 0$. It follows that $d = 0$. In this way we see that the trivializing section of $\mathcal{L}_s$ lifts to a section of $\mathcal{L}$ over $X$. A straightforward topological argument (omitted) shows that this means that $\mathcal{L}$ is trivial after possibly shrinking $S$ a bit further.
By K\"unneth (Varieties, Lemma \ref{varieties-lemma-kunneth}) the map $$ H^1(X_s \times_{\Spec(\kappa(s))} Y_s, \mathcal{O}) \to H^1(X_s, \mathcal{O}) \oplus H^1(Y_s, \mathcal{O}) $$ is injective. Thus we may apply Lemma \ref{lemma-H1-O-multiple-picard-flat-proper} to the two morphisms $$ 1 \times \tau : X \to X \times_S Y \quad\text{and}\quad \sigma \times 1 : Y \to X \times_S Y $$ to conclude.
Write $S = \Spec(A)$ and $X = \Spec(B)$. As $f$ is of finite presentation we see that $B$ is of finite presentation as an $A$-algebra, see Morphisms, Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}. Thus the lemma follows from Algebra, Lemma \ref{algebra-lemma-limit-module-finite-presentation}.
Write $S = \Spec(A)$, $X = \Spec(B)$, and $\mathcal{F} = \widetilde{M}$. As $f$ is of finite presentation we see that $B$ is of finite presentation as an $A$-algebra, see Morphisms, Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}. As $\mathcal{F}$ is of finite presentation over $\mathcal{O}_X$ we see that $M$ is of finite presentation as a $B$-module, see Properties, Lemma \ref{properties-lemma-finite-presentation-module}. Thus the lemma follows from Algebra, Lemma \ref{algebra-lemma-limit-module-finite-presentation}.
Write $S = \Spec(A)$, $X = \Spec(B)$, and $\mathcal{F} = \widetilde{M}$. As $f$ is of finite presentation we see that $B$ is of finite presentation as an $A$-algebra, see Morphisms, Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}. As $\mathcal{F}$ is of finite presentation over $\mathcal{O}_X$ we see that $M$ is of finite presentation as a $B$-module, see Properties, Lemma \ref{properties-lemma-finite-presentation-module}. As $\mathcal{F}$ is flat over $S$ we see that $M$ is flat over $A$, see Morphisms, Lemma \ref{morphisms-lemma-flat-module-characterize}. Thus the lemma follows from Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat}.