# The Stacks Project

## Tag 02LQ

### 36.38. Zariski's Main Theorem

In this section we prove Zariski's main theorem as reformulated by Grothendieck. Often when we say ''Zariski's main theorem'' in this content we mean either of Lemma 36.38.1, Lemma 36.38.2, or Lemma 36.38.3. In most texts people refer to the last of these as Zariski's main theorem. These lemmas have many consequences some of which the reader can find in this section.

We have already proved the algebraic version in Algebra, Theorem 10.122.13 and we have already restated this algebraic version in the language of schemes, see Morphisms, Theorem 28.52.1. The version in this section is more subtle; to get the full result we use the étale localization techniques of Section 36.36 to reduce to the algebraic case.

Lemma 36.38.1. Let $f : X \to S$ be a morphism of schemes. Assume $f$ is of finite type and separated. Let $S'$ be the normalization of $S$ in $X$, see Morphisms, Definition 28.50.3. Picture: $$\xymatrix{ X \ar[rd]_f \ar[rr]_{f'} & & S' \ar[ld]^\nu \\ & S & }$$ Then there exists an open subscheme $U' \subset S'$ such that

1. $(f')^{-1}(U') \to U'$ is an isomorphism, and
2. $(f')^{-1}(U') \subset X$ is the set of points at which $f$ is quasi-finite.

Proof. By Morphisms, Lemma 28.52.2 the subset $U \subset X$ of points where $f$ is quasi-finite is open. The lemma is equivalent to

1. (a)    $U' = f'(U) \subset S'$ is open,
2. (b)    $U = f^{-1}(U')$, and
3. (c)    $U \to U'$ is an isomorphism.

Let $x \in U$ be arbitrary. We claim there exists an open neighbourhood $f'(x) \in V \subset S'$ such that $(f')^{-1}V \to V$ is an isomorphism. We first prove the claim implies the lemma. Namely, then $(f')^{-1}V \cong V$ is both locally of finite type over $S$ (as an open subscheme of $X$) and for $v \in V$ the residue field extension $\kappa(v) \supset \kappa(\nu(v))$ is algebraic (as $V \subset S'$ and $S'$ is integral over $S$). Hence the fibres of $V \to S$ are discrete (Morphisms, Lemma 28.19.2) and $(f')^{-1}V \to S$ is locally quasi-finite (Morphisms, Lemma 28.19.8). This implies $(f')^{-1}V \subset U$ and $V \subset U'$. Since $x$ was arbitrary we see that (a), (b), and (c) are true.

Let $s = f(x)$. Let $(T, t) \to (S, s)$ be an elementary étale neighbourhood. Denote by a subscript ${}_T$ the base change to $T$. Let $y = (x, t) \in X_T$ be the unique point in the fibre $X_t$ lying over $x$. Note that $U_T \subset X_T$ is the set of points where $f_T$ is quasi-finite, see Morphisms, Lemma 28.19.13. Note that $$X_T \xrightarrow{f'_T} S'_T \xrightarrow{\nu_T} T$$ is the normalization of $T$ in $X_T$, see Lemma 36.17.2. Suppose that the claim holds for $y \in U_T \subset X_T \to S'_T \to T$, i.e., suppose that we can find an open neighbourhood $f'_T(y) \in V' \subset S'_T$ such that $(f'_T)^{-1}V' \to V'$ is an isomorphism. The morphism $S'_T \to S'$ is étale hence the image $V \subset S'$ of $V'$ is open. Observe that $f'(x) \in V$ as $f'_T(y) \in V'$. Observe that $$\xymatrix{ (f'_T)^{-1}V' \ar[r] \ar[d] & (f')^{-1}(V) \ar[d] \\ V' \ar[r] & V }$$ is a fibre square (as $S'_T \times_{S'} X = X_T$). Since the left vertical arrow is an isomorphism and $\{V' \to V\}$ is a étale covering, we conclude that the right vertical arrow is an isomorphism by Descent, Lemma 34.20.17. In other words, the claim holds for $x \in U \subset X \to S' \to S$.

By the result of the previous paragraph we may replace $S$ by an elementary étale neighbourhood of $s = f(x)$ in order to prove the claim. Thus we may assume there is a decomposition $$X = V \amalg W$$ into open and closed subschemes where $V \to S$ is finite and $x \in V$, see Lemma 36.36.4. Since $X$ is a disjoint union of $V$ and $W$ over $S$ and since $V \to S$ is finite we see that the normalization of $S$ in $X$ is the morphism $$X = V \amalg W \longrightarrow V \amalg W' \longrightarrow S$$ where $W'$ is the normalization of $S$ in $W$, see Morphisms, Lemmas 28.50.10, 28.42.4, and 28.50.12. The claim follows and we win. $\square$

Lemma 36.38.2. Let $f : X \to S$ be a morphism of schemes. Assume $f$ is quasi-finite and separated. Let $S'$ be the normalization of $S$ in $X$, see Morphisms, Definition 28.50.3. Picture: $$\xymatrix{ X \ar[rd]_f \ar[rr]_{f'} & & S' \ar[ld]^\nu \\ & S & }$$ Then $f'$ is a quasi-compact open immersion and $\nu$ is integral. In particular $f$ is quasi-affine.

Proof. This follows from Lemma 36.38.1. Namely, by that lemma there exists an open subscheme $U' \subset S'$ 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 : S' \to S$ is separated (Schemes, Lemma 25.21.15). It follows that $f$ is quasi-affine by Morphisms, Lemma 28.12.3. $\square$

Lemma 36.38.3 (Zariski's Main Theorem). Let $f : X \to S$ be a morphism of schemes. Assume $f$ is quasi-finite and separated and assume that $S$ is quasi-compact and quasi-separated. Then there exists a factorization $$\xymatrix{ X \ar[rd]_f \ar[rr]_j & & T \ar[ld]^\pi \\ & S & }$$ where $j$ is a quasi-compact open immersion and $\pi$ is finite.

Proof. Let $X \to S' \to S$ be as in the conclusion of Lemma 36.38.2. By Properties, Lemma 27.22.13 we can write $\nu_*\mathcal{O}_{S'} = \mathop{\rm colim}\nolimits_{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}_{S'}$. Then $\pi_i : T_i = \underline{\mathop{\rm Spec}}_S(\mathcal{A}_i) \to S$ is a finite morphism for each $i$. Note that the transition morphisms $T_{i'} \to T_i$ are affine and that $S' = \mathop{\rm lim}\nolimits T_i$.

By Limits, Lemma 31.4.11 there exists an $i$ and a quasi-compact open $U_i \subset T_i$ whose inverse image in $S'$ 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) = \mathop{\rm lim}\nolimits_{i' \geq i} U_{i'}$, see Limits, Lemma 31.2.2. By Limits, Lemma 31.4.16 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, Lemma 28.3.2 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. $\square$

Lemma 36.38.4. Let $f : X \to S$ be a morphism of schemes. The following are equivalent:

1. $f$ is finite,
2. $f$ is proper with finite fibres,
3. $f$ is proper and locally quasi-finite,
4. $f$ is universally closed, separated, locally of finite type and has finite fibres.

Proof. We have (1) implies (2) by Morphisms, Lemmas 28.42.10, 28.19.10, and 28.42.9. We have (2) implies (3) by Morphisms, Lemma 28.19.7. We have (3) implies (4) by the definition of proper morphisms and Morphisms, Lemmas 28.19.9 and 28.19.10.

Assume (3). Pick $s \in S$. By Morphisms, Lemma 28.19.7 we see that all the finitely many points of $X_s$ are isolated in $X_s$. Choose an elementary étale neighbourhood $(U, u) \to (S, s)$ and decomposition $X_U = V \amalg W$ as in Lemma 36.36.6. Note that $W_u = \emptyset$ because all points of $X_s$ are isolated. 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 $s \in S$ was arbitrary this means there exists a family $\{U_i \to S\}$ of étale morphisms whose images cover $S$ such that the base changes $X_{U_i} \to U_i$ are finite. Note that $\{U_i \to S\}$ is an étale covering, see Topologies, Definition 33.4.1. Hence it is an fpqc covering, see Topologies, Lemma 33.9.6. Hence we conclude $f$ is finite by Descent, Lemma 34.20.23. $\square$

As a consequence we have the following useful results.

Lemma 36.38.5. Let $f : X \to S$ be a morphism of schemes. Let $s \in S$. Assume that $f$ is proper and $f^{-1}(\{s\})$ is a finite set. Then there exists an open neighbourhood $V \subset S$ of $s$ such that $f|_{f^{-1}(V)} : f^{-1}(V) \to V$ is finite.

Proof. The morphism $f$ is quasi-finite at all the points of $f^{-1}(\{s\})$ by Morphisms, Lemma 28.19.7. By Morphisms, Lemma 28.52.2 the set of points at which $f$ is quasi-finite is an open $U \subset X$. Let $Z = X \setminus U$. Then $s \not \in f(Z)$. Since $f$ is proper the set $f(Z) \subset S$ is closed. Choose any open neighbourhood $V \subset S$ of $s$ with $Z \cap V = \emptyset$. Then $f^{-1}(V) \to V$ is locally quasi-finite and proper. Hence it is quasi-finite (Morphisms, Lemma 28.19.9), hence has finite fibres (Morphisms, Lemma 28.19.10), hence is finite by Lemma 36.38.4. $\square$

Lemma 36.38.6. Consider a commutative diagram of schemes $$\xymatrix{ X \ar[rr]_h \ar[rd]_f & & Y \ar[ld]^g \\ & S }$$ Let $s \in S$. Assume

1. $X \to S$ is a proper morphism,
2. $Y \to S$ is separated and locally of finite type, and
3. the image of $X_s \to Y_s$ is finite.

Then there is an open subspace $U \subset S$ containing $s$ such that $X_U \to Y_U$ factors through a closed subscheme $Z \subset Y_U$ finite over $U$.

Proof. Let $Z \subset Y$ be the scheme theoretic image of $h$, see Morphisms, Section 28.6. By Morphisms, Lemma 28.39.9 the morphism $X \to Z$ is surjective and $Z \to S$ is proper. Thus $X_s \to Z_s$ is surjective. We see that either (3) implies $Z_s$ is finite. Hence $Z \to S$ is finite in an open neighbourhood of $s$ by Lemma 36.38.5. $\square$

Lemma 36.38.7. Let $f : Y \to X$ be a quasi-finite morphism. There exists a dense open $U \subset X$ such that $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite.

Proof. If $U_i \subset X$, $i \in I$ is a collection of opens such that the restrictions $f|_{f^{-1}(U_i)} : f^{-1}(U_i) \to U_i$ are finite, then with $U = \bigcup U_i$ the restriction $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite, see Morphisms, Lemma 28.42.3. Thus the problem is local on $X$ and we may assume that $X$ is affine.

Assume $X$ is affine. Write $Y = \bigcup_{j = 1, \ldots, m} V_j$ with $V_j$ affine. This is possible since $f$ is quasi-finite and hence in particular quasi-compact. Each $V_j \to X$ is quasi-finite and separated. Let $\eta \in X$ be a generic point of an irreducible component of $X$. We see from Morphisms, Lemmas 28.19.10 and 28.48.1 that there exists an open neighbourhood $\eta \in U_\eta$ such that $f^{-1}(U_\eta) \cap V_j \to U_\eta$ is finite. We may choose $U_\eta$ such that it works for each $j = 1, \ldots, m$. Note that the collection of generic points of $X$ is dense in $X$. Thus we see there exists a dense open $W = \bigcup_\eta U_\eta$ such that each $f^{-1}(W) \cap V_j \to W$ is finite. It suffices to show that there exists a dense open $U \subset W$ such that $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite. Thus we may replace $X$ by an affine open subscheme of $W$ and assume that each $V_j \to X$ is finite.

Assume $X$ is affine, $Y = \bigcup_{j = 1, \ldots, m} V_j$ with $V_j$ affine, and the restrictions $f|_{V_j} : V_j \to X$ are finite. Set $$\Delta_{ij} = \Big(\overline{V_i \cap V_j} \setminus V_i \cap V_j\Big) \cap V_j.$$ This is a nowhere dense closed subset of $V_j$ because it is the boundary of the open subset $V_i \cap V_j$ in $V_j$. By Morphisms, Lemma 28.45.7 the image $f(\Delta_{ij})$ is a nowhere dense closed subset of $X$. By Topology, Lemma 5.21.2 the union $T = \bigcup f(\Delta_{ij})$ is a nowhere dense closed subset of $X$. Thus $U = X \setminus T$ is a dense open subset of $X$. We claim that $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite. To see this let $U' \subset U$ be an affine open. Set $Y' = f^{-1}(U') = U' \times_X Y$, $V_j' = Y' \cap V_j = U' \times_X V_j$. Consider the restriction $$f' = f|_{Y'} : Y' \longrightarrow U'$$ of $f$. This morphism now has the property that $Y' = \bigcup_{j = 1, \ldots, m} V'_j$ is an affine open covering, each $V'_j \to U'$ is finite, and $V_i' \cap V_j'$ is (open and) closed both in $V'_i$ and $V'_j$. Hence $V_i' \cap V_j'$ is affine, and the map $$\mathcal{O}(V'_i) \otimes_{\mathbf{Z}} \mathcal{O}(V'_j) \longrightarrow \mathcal{O}(V'_i \cap V'_j)$$ is surjective. This implies that $Y'$ is separated, see Schemes, Lemma 25.21.8. Finally, consider the commutative diagram $$\xymatrix{ \coprod_{j = 1, \ldots, m} V'_j \ar[rd] \ar[rr] & & Y' \ar[ld] \\ & U' & }$$ The south-east arrow is finite, hence proper, the horizontal arrow is surjective, and the south-west arrow is separated. Hence by Morphisms, Lemma 28.39.8 we conclude that $Y' \to U'$ is proper. Since it is also quasi-finite, we see that it is finite by Lemma 36.38.4, and we win. $\square$

Lemma 36.38.8. Let $f : X \to S$ be flat, locally of finite presentation, separated, locally quasi-finite with universally bounded fibres. Then there exist closed subsets $$\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset \ldots \subset Z_n = S$$ such that with $S_r = Z_r \setminus Z_{r - 1}$ the stratification $S = \coprod_{r = 0, \ldots, n} S_r$ is characterized by the following universal property: Given $g : T \to S$ the projection $X \times_S T \to T$ is finite locally free of degree $r$ if and only if $g(T) \subset S_r$ (set theoretically).

Proof. Let $n$ be an integer bounding the degree of the fibres of $X \to S$. By Morphisms, Lemma 28.53.6 we see that any base change has degrees of fibres bounded by $n$ also. In particular, all the integers $r$ that occur in the statement of the lemma will be $\leq n$. We will prove the lemma by induction on $n$. The base case is $n = 0$ which is obvious.

We claim the set of points $s \in S$ with $\deg_{\kappa(s)}(X_s) = n$ is an open subset $S_n \subset S$ and that $X \times_S S_n \to S_n$ is finite locally free of degree $n$. Namely, suppose that $s \in S$ is such a point. Choose an elementary étale morphism $(U, u) \to (S, s)$ and a decomposition $U \times_S X = W \amalg V$ as in Lemma 36.36.6. Since $V \to U$ is finite, flat, and locally of finite presentation, we see that $V \to U$ is finite locally free, see Morphisms, Lemma 28.45.2. After shrinking $U$ to a smaller neighbourhood of $u$ we may assume $V \to U$ is finite locally free of some degree $d$, see Morphisms, Lemma 28.45.5. As $u \mapsto s$ and $W_u = \emptyset$ we see that $d = n$. Since $n$ is the maximum degree of a fibre we see that $W = \emptyset$! Thus $U \times_S X \to U$ is finite locally free of degree $n$. By Descent, Lemma 34.20.30 we conclude that $X \to S$ is finite locally free of degree $n$ over $\mathop{\rm Im}(U \to S)$ which is an open neighbourhood of $s$ (Morphisms, Lemma 28.34.13). This proves the claim.

Let $S' = S \setminus S_n$ endowed with the reduced induced scheme structure and set $X' = X \times_S S'$. Note that the degrees of fibres of $X' \to S'$ are universally bounded by $n - 1$. By induction we find a stratification $S' = S_0 \amalg \ldots \amalg S_{n - 1}$ adapted to the morphism $X' \to S'$. We claim that $S = \coprod_{r = 0, \ldots, n} S_r$ works for the morphism $X \to S$. Let $g : T \to S$ be a morphism of schemes and assume that $X \times_S T \to T$ is finite locally free of degree $r$. As remarked above this implies that $r \leq n$. If $r = n$, then it is clear that $T \to S$ factors through $S_n$. If $r < n$, then $g(T) \subset S' = S \setminus S_d$ (set theoretically) hence $T_{red} \to S$ factors through $S'$, see Schemes, Lemma 25.12.6. Note that $X \times_S T_{red} \to T_{red}$ is also finite locally free of degree $r$ as a base change. By the universal property of the stratification $S' = \coprod_{r = 0, \ldots, n - 1} S_r$ we see that $g(T) = g(T_{red})$ is contained in $S_r$. Conversely, suppose that we have $g : T \to S$ such that $g(T) \subset S_r$ (set theoretically). If $r = n$, then $g$ factors through $S_n$ and it is clear that $X \times_S T \to T$ is finite locally free of degree $n$ as a base change. If $r < n$, then $X \times_S T \to T$ is a morphism which is separated, flat, and locally of finite presentation, such that the restriction to $T_{red}$ is finite locally free of degree $r$. Since $T_{red} \to T$ is a universal homeomorphism, we conclude that $X \times_S T_{red} \to X \times_S T$ is a universal homeomorphism too and hence $X \times_S T \to T$ is universally closed (as this is true for the finite morphism $X \times_S T_{red} \to T_{red}$). It follows that $X \times_S T \to T$ is finite, for example by Lemma 36.38.4. Then we can use Morphisms, Lemma 28.45.2 to see that $X \times_S T \to T$ is finite locally free. Finally, the degree is $r$ as all the fibres have degree $r$. $\square$

Lemma 36.38.9. Let $f : X \to S$ be a morphism of schemes which is flat, locally of finite presentation, separated, and quasi-finite. Then there exist closed subsets $$\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset \ldots \subset S$$ such that with $S_r = Z_r \setminus Z_{r - 1}$ the stratification $S = \coprod S_r$ is characterized by the following universal property: Given a morphism $g : T \to S$ the projection $X \times_S T \to T$ is finite locally free of degree $r$ if and only if $g(T) \subset S_r$ (set theoretically). Moreover, the inclusion maps $S_r \to S$ are quasi-compact.

Proof. The question is local on $S$, hence we may assume that $S$ is affine. By Morphisms, Lemma 28.53.10 the fibres of $f$ are universally bounded in this case. Hence the existence of the stratification follows from Lemma 36.38.8.

We will show that $U_r = S \setminus Z_r \to S$ is quasi-compact for each $r \geq 0$. This will prove the final statement by elementary topology. Since a composition of quasi-compact maps is quasi-compact it suffices to prove that $U_r \to U_{r - 1}$ is quasi-compact. Choose an affine open $W \subset U_{r - 1}$. Write $W = \mathop{\rm Spec}(A)$. Then $Z_r \cap W = V(I)$ for some ideal $I \subset A$ and $X \times_S \mathop{\rm Spec}(A/I) \to \mathop{\rm Spec}(A/I)$ is finite locally free of degree $r$. Note that $A/I = \mathop{\rm colim}\nolimits A/I_i$ where $I_i \subset I$ runs through the finitely generated ideals. By Limits, Lemma 31.8.8 we see that $X \times_S \mathop{\rm Spec}(A/I_i) \to \mathop{\rm Spec}(A/I_i)$ is finite locally free of degree $r$ for some $i$. (This uses that $X \to S$ is of finite presentation, as it is locally of finite presentation, separated, and quasi-compact.) Hence $\mathop{\rm Spec}(A/I_i) \to \mathop{\rm Spec}(A) = W$ factors (set theoretically) through $Z_r \cap W$. It follows that $Z_r \cap W = V(I_i)$ is the zero set of a finite subset of elements of $A$. This means that $W \setminus Z_r$ is a finite union of standard opens, hence quasi-compact, as desired. $\square$

Lemma 36.38.10. Let $f : X \to S$ be a flat, locally of finite presentation, separated, and locally quasi-finite morphism of schemes. Then there exist open subschemes $$S = U_0 \supset U_1 \supset U_2 \supset \ldots$$ such that a morphism $\mathop{\rm Spec}(k) \to S$ factors through $U_d$ if and only if $X \times_S \mathop{\rm Spec}(k)$ has degree $\geq d$ over $k$.

Proof. The statement simply means that the collection of points where the degree of the fibre is $\geq d$ is open. Thus we can work locally on $S$ and assume $S$ is affine. In this case, for every $W \subset X$ quasi-compact open, the set of points $U_d(W)$ where the fibres of $W \to S$ have degree $\geq d$ is open by Lemma 36.38.9. Since $U_d = \bigcup_W U_d(W)$ the result follows. $\square$

Lemma 36.38.11. Let $f : X \to S$ be a morphism of schemes which is flat, locally of finite presentation, and locally quasi-finite. Let $g \in \Gamma(X, \mathcal{O}_X)$ nonzero. Then there exist an open $V \subset X$ such that $g|_V \not = 0$, an open $U \subset S$ fitting into a commutative diagram $$\xymatrix{ V \ar[r] \ar[d]_\pi & X \ar[d]^f \\ U \ar[r] & S, }$$ a quasi-coherent subsheaf $\mathcal{F} \subset \mathcal{O}_U$, an integer $r > 0$, and an injective $\mathcal{O}_U$-module map $\mathcal{F}^{\oplus r} \to \pi_*\mathcal{O}_V$ whose image contains $g|_V$.

Proof. We may assume $X$ and $S$ affine. We obtain a filtration $\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset \ldots \subset Z_n = S$ as in Lemmas 36.38.8 and 36.38.9. Let $T \subset X$ be the scheme theoretic support of the finite $\mathcal{O}_X$-module $\mathop{\rm Im}(g : \mathcal{O}_X \to \mathcal{O}_X)$. Note that $T$ is the support of $g$ as a section of $\mathcal{O}_X$ (Modules, Definition 17.5.1) and for any open $V \subset X$ we have $g|_V \not = 0$ if and only if $V \cap T \not = \emptyset$. Let $r$ be the smallest integer such that $f(T) \subset Z_r$ set theoretically. Let $\xi \in T$ be a generic point of an irreducible component of $T$ such that $f(\xi) \not \in Z_{r - 1}$ (and hence $f(\xi) \in Z_r$). We may replace $S$ by an affine neighbourhood of $f(\xi)$ contained in $S \setminus Z_{r - 1}$. Write $S = \mathop{\rm Spec}(A)$ and let $I = (a_1, \ldots, a_m) \subset A$ be a finitely generated ideal such that $V(I) = Z_r$ (set theoretically, see Algebra, Lemma 10.28.1). Since the support of $g$ is contained in $f^{-1}V(I)$ by our choice of $r$ we see that there exists an integer $N$ such that $a_j^N g = 0$ for $j = 1, \ldots, m$. Replacing $a_j$ by $a_j^r$ we may assume that $Ig = 0$. For any $A$-module $M$ write $M[I]$ for the $I$-torsion of $M$, i.e., $M[I] = \{m \in M \mid Im = 0\}$. Write $X = \mathop{\rm Spec}(B)$, so $g \in B[I]$. Since $A \to B$ is flat we see that $$B[I] = A[I] \otimes_A B \cong A[I] \otimes_{A/I} B/IB$$ By our choice of $Z_r$, the $A/I$-module $B/IB$ is finite locally free of rank $r$. Hence after replacing $S$ by a smaller affine open neighbourhood of $f(\xi)$ we may assume that $B/IB \cong (A/IA)^{\oplus r}$ as $A/I$-modules. Choose a map $\psi : A^{\oplus r} \to B$ which reduces modulo $I$ to the isomorphism of the previous sentence. Then we see that the induced map $$A[I]^{\oplus r} \longrightarrow B[I]$$ is an isomorphism. The lemma follows by taking $\mathcal{F}$ the quasi-coherent sheaf associated to the $A$-module $A[I]$ and the map $\mathcal{F}^{\oplus r} \to \pi_*\mathcal{O}_V$ the one corresponding to $A[I]^{\oplus r} \subset A^{\oplus r} \to B$. $\square$

Lemma 36.38.12. Let $f : X \to Y$ be a separated, locally quasi-finite morphism with $Y$ affine. Then every finite set of points of $X$ is contained in an open affine of $X$.

Proof. Let $x_1, \ldots, x_n \in X$. Choose a quasi-compact open $U \subset X$ with $x_i \in U$. Then $U \to Y$ is quasi-affine by Lemma 36.38.2. Hence there exists an affine open $V \subset U$ containing $x_1, \ldots, x_n$ by Properties, Lemma 27.29.5. $\square$

Lemma 36.38.13. Let $U \to X$ be a surjective étale morphism of schemes. Assume $X$ is quasi-compact and quasi-separated. Then there exists a surjective integral morphism $Y \to X$, such that for every $y \in Y$ there is an open neighbourhood $V \subset Y$ such that $V \to X$ factors through $U$. In fact, we may assume $Y \to X$ is finite and of finite presentation.

Proof. Since $X$ is quasi-compact, there exist finitely many affine opens $U_i \subset U$ such that $U' = \coprod U_i \to X$ is surjective. After replacing $U$ by $U'$, we see that we may assume $U$ is affine. Then there exists an integer $d$ bounding the degree of the geometric fibres of $U \to X$ (see Morphisms, Lemma 28.53.10). We will prove the lemma by induction on $d$ for all quasi-compact and separated schemes $U$ mapping surjective and étale onto $X$. If $d = 1$, then $U = X$ and the result holds with $Y = U$. Assume $d > 1$.

We apply Lemma 36.38.2 and we obtain a factorization $$\xymatrix{ U \ar[rr]_j \ar[rd] & & Y \ar[ld]^\pi \\ & X }$$ with $\pi$ integral and $j$ a quasi-compact open immersion. We may and do assume that $j(U)$ is scheme theoretically dense in $Y$. Note that $$U \times_X Y = U \amalg W$$ where the first summand is the image of $U \to U \times_X Y$ (which is closed by Schemes, Lemma 25.21.11 and open because it is étale as a morphism between schemes étale over $Y$) and the second summand is the (open and closed) complement. The image $V \subset Y$ of $W$ is an open subscheme containing $Y \setminus U$.

The étale morphism $W \to Y$ has geometric fibres of cardinality $< d$. Namely, this is clear for geometric points of $U \subset Y$ by inspection. Since $U \subset Y$ is dense, it holds for all geometric points of $Y$ for example by Lemma 36.38.8 (the degree of the fibres of a quasi-compact étale morphism does not go up under specialization). Thus we may apply the induction hypothesis to $W \to V$ and find a surjective integral morphism $Z \to V$ with $Z$ a scheme, which Zariski locally factors through $W$. Choose a factorization $Z \to Z' \to Y$ with $Z' \to Y$ integral and $Z \to Z'$ open immersion (Lemma 36.38.2). After replacing $Z'$ by the scheme theoretic closure of $Z$ in $Z'$ we may assume that $Z$ is scheme theoretically dense in $Z'$. After doing this we have $Z' \times_Y V = Z$. Finally, let $T \subset Y$ be the induced reduced closed subscheme structure on $Y \setminus V$. Consider the morphism $$Z' \amalg T \longrightarrow X$$ This is a surjective integral morphism by construction. Since $T \subset U$ it is clear that the morphism $T \to X$ factors through $U$. On the other hand, let $z \in Z'$ be a point. If $z \not \in Z$, then $z$ maps to a point of $Y \setminus V \subset U$ and we find a neighbourhood of $z$ on which the morphism factors through $U$. If $z \in Z$, then we have a neighbourhood $V \subset Z$ which factors through $W \subset U \times_X Y$ and hence through $U$. This proves existence.

Assume we have found $Y \to X$ integral and surjective which Zariski locally factors through $U$. Choose a finite affine open covering $Y = \bigcup V_j$ such that $V_j \to X$ factors through $U$. We can write $Y = \mathop{\rm lim}\nolimits Y_i$ with $Y_i \to X$ finite and of finite presentation, see Limits, Lemma 31.7.2. For large enough $i$ we can find affine opens $V_{i, j} \subset Y_i$ whose inverse image in $Y$ recovers $V_j$, see Limits, Lemma 31.4.11. For even larger $i$ the morphisms $V_j \to U$ over $X$ come from morphisms $V_{i, j} \to U$ over $X$, see Limits, Proposition 31.6.1. This finishes the proof. $\square$

The code snippet corresponding to this tag is a part of the file more-morphisms.tex and is located in lines 10724–11440 (see updates for more information).

\section{Zariski's Main Theorem}
\label{section-application-etale-neighbourhoods}

\noindent
In this section we prove Zariski's main theorem as reformulated by Grothendieck.
Often when we say Zariski's main theorem'' in this content we mean either of
Lemma \ref{lemma-finite-type-separated},
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}, or
Lemma \ref{lemma-quasi-finite-separated-pass-through-finite}.
In most texts people refer to the last of these as
Zariski's main theorem. These lemmas have many consequences
some of which the reader can find in this section.

\medskip\noindent
We have already proved the algebraic version in
Algebra, Theorem \ref{algebra-theorem-main-theorem}
and we have already restated this algebraic version
in the language of schemes, see
Morphisms, Theorem \ref{morphisms-theorem-main-theorem}.
The version in this section is more subtle; to get the full
result we use the \'etale localization techniques
of Section \ref{section-etale-localization} to reduce to
the algebraic case.

\begin{lemma}
\label{lemma-finite-type-separated}
Let $f : X \to S$ be a morphism of schemes.
Assume $f$ is of finite type and separated.
Let $S'$ be the normalization of $S$ in $X$, see
Morphisms, Definition \ref{morphisms-definition-normalization-X-in-Y}.
Picture:
$$\xymatrix{ X \ar[rd]_f \ar[rr]_{f'} & & S' \ar[ld]^\nu \\ & S & }$$
Then there exists an open subscheme $U' \subset S'$ such that
\begin{enumerate}
\item $(f')^{-1}(U') \to U'$ is an isomorphism, and
\item $(f')^{-1}(U') \subset X$ is the set of points at which
$f$ is quasi-finite.
\end{enumerate}
\end{lemma}

\begin{proof}
By Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-points-open}
the subset $U \subset X$ of points where $f$ is quasi-finite is open.
The lemma is equivalent to
\begin{enumerate}
\item[(a)] $U' = f'(U) \subset S'$ is open,
\item[(b)] $U = f^{-1}(U')$, and
\item[(c)] $U \to U'$ is an isomorphism.
\end{enumerate}
Let $x \in U$ be arbitrary. We claim there exists an open
neighbourhood $f'(x) \in V \subset S'$ such that $(f')^{-1}V \to V$ is an
isomorphism. We first prove the claim implies the lemma.
Namely, then $(f')^{-1}V \cong V$ is both locally of finite
type over $S$ (as an open subscheme of $X$) and for $v \in V$ the residue
field extension $\kappa(v) \supset \kappa(\nu(v))$ is algebraic (as
$V \subset S'$ and $S'$ is integral over $S$). Hence the fibres
of $V \to S$ are discrete (Morphisms, Lemma
\ref{morphisms-lemma-algebraic-residue-field-extension-closed-point-fibre})
and $(f')^{-1}V \to S$ is locally quasi-finite
(Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-fibres}).
This implies $(f')^{-1}V \subset U$ and $V \subset U'$. Since $x$ was
arbitrary we see that (a), (b), and (c) are true.

\medskip\noindent
Let $s = f(x)$. Let $(T, t) \to (S, s)$ be an elementary \'etale
neighbourhood. Denote by a subscript ${}_T$ the base change to $T$.
Let $y = (x, t) \in X_T$ be the unique point in
the fibre $X_t$ lying over $x$. Note that $U_T \subset X_T$
is the set of points where $f_T$ is quasi-finite, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-quasi-finite}.
Note that
$$X_T \xrightarrow{f'_T} S'_T \xrightarrow{\nu_T} T$$
is the normalization of $T$ in $X_T$, see
Lemma \ref{lemma-normalization-smooth-localization}.
Suppose that the claim holds for $y \in U_T \subset X_T \to S'_T \to T$, i.e.,
suppose that we can find an open neighbourhood
$f'_T(y) \in V' \subset S'_T$ such that $(f'_T)^{-1}V' \to V'$ is an
isomorphism. The morphism $S'_T \to S'$ is \'etale hence the image
$V \subset S'$ of $V'$ is open. Observe that $f'(x) \in V$ as $f'_T(y) \in V'$.
Observe that
$$\xymatrix{ (f'_T)^{-1}V' \ar[r] \ar[d] & (f')^{-1}(V) \ar[d] \\ V' \ar[r] & V }$$
is a fibre square (as $S'_T \times_{S'} X = X_T$).
Since the left vertical arrow is an isomorphism
and $\{V' \to V\}$ is a \'etale covering, we conclude that the right vertical
arrow is an isomorphism by
Descent, Lemma \ref{descent-lemma-descending-property-isomorphism}.
In other words, the claim holds for $x \in U \subset X \to S' \to S$.

\medskip\noindent
By the result of the previous paragraph we may replace $S$ by an
elementary \'etale neighbourhood of $s = f(x)$ in order to prove the claim.
Thus we may assume there is a decomposition
$$X = V \amalg W$$
into open and closed subschemes where $V \to S$ is finite and $x \in V$,
see Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical}.
Since $X$ is a disjoint union of $V$ and $W$ over $S$ and since
$V \to S$ is finite we see that the
normalization of $S$ in $X$ is the morphism
$$X = V \amalg W \longrightarrow V \amalg W' \longrightarrow S$$
where $W'$ is the normalization of $S$ in $W$, see
Morphisms, Lemmas \ref{morphisms-lemma-normalization-in-disjoint-union},
\ref{morphisms-lemma-finite-integral}, and
\ref{morphisms-lemma-normalization-in-integral}.
The claim follows and we win.
\end{proof}

\begin{lemma}
\label{lemma-quasi-finite-separated-quasi-affine}
Let $f : X \to S$ be a morphism of schemes.
Assume $f$ is quasi-finite and separated.
Let $S'$ be the normalization of $S$ in $X$, see
Morphisms, Definition \ref{morphisms-definition-normalization-X-in-Y}.
Picture:
$$\xymatrix{ X \ar[rd]_f \ar[rr]_{f'} & & S' \ar[ld]^\nu \\ & S & }$$
Then $f'$ is a quasi-compact open immersion and $\nu$ is integral.
In particular $f$ is quasi-affine.
\end{lemma}

\begin{proof}
This follows from Lemma \ref{lemma-finite-type-separated}. Namely, by
that lemma there exists an open subscheme $U' \subset S'$ 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 : S' \to S$ is separated
(Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}).
It follows that $f$ is quasi-affine by
Morphisms, Lemma \ref{morphisms-lemma-characterize-quasi-affine}.
\end{proof}

\begin{lemma}[Zariski's Main Theorem]
\label{lemma-quasi-finite-separated-pass-through-finite}
Let $f : X \to S$ be a morphism of schemes.
Assume $f$ is quasi-finite and separated and assume that
$S$ is quasi-compact and quasi-separated. Then there exists
a factorization
$$\xymatrix{ X \ar[rd]_f \ar[rr]_j & & T \ar[ld]^\pi \\ & S & }$$
where $j$ is a quasi-compact open immersion and $\pi$ is finite.
\end{lemma}

\begin{proof}
Let $X \to S' \to S$ be as in the conclusion of
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}.
By
Properties, Lemma
\ref{properties-lemma-integral-algebra-directed-colimit-finite}
we can write
$\nu_*\mathcal{O}_{S'} = \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}_{S'}$. Then
$\pi_i : T_i = \underline{\Spec}_S(\mathcal{A}_i) \to S$
is a finite morphism for each $i$.
Note that the transition morphisms $T_{i'} \to T_i$ are affine
and that $S' = \lim T_i$.

\medskip\noindent
By Limits, Lemma \ref{limits-lemma-descend-opens}
there exists an $i$ and a quasi-compact open
$U_i \subset T_i$ whose inverse image in $S'$ 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, Lemma \ref{limits-lemma-directed-inverse-system-has-limit}.
By Limits, Lemma \ref{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, Lemma \ref{morphisms-lemma-factor-quasi-compact-immersion}
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.
\end{proof}

\begin{lemma}
\label{lemma-characterize-finite}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent:
\begin{enumerate}
\item $f$ is finite,
\item $f$ is proper with finite fibres,
\item $f$ is proper and locally quasi-finite,
\item $f$ is universally closed, separated, locally of finite type
and has finite fibres.
\end{enumerate}
\end{lemma}

\begin{proof}
We have (1) implies (2) by
Morphisms, Lemmas \ref{morphisms-lemma-finite-proper},
\ref{morphisms-lemma-quasi-finite},
and \ref{morphisms-lemma-finite-quasi-finite}.
We have (2) implies (3) by Morphisms, Lemma \ref{morphisms-lemma-finite-fibre}.
We have (3) implies (4) by the definition of proper morphisms and
Morphisms, Lemmas \ref{morphisms-lemma-quasi-finite-locally-quasi-compact} and
\ref{morphisms-lemma-quasi-finite}.

\medskip\noindent
Assume (3). Pick $s \in S$. By
Morphisms, Lemma \ref{morphisms-lemma-finite-fibre} we
see that all the finitely many points of $X_s$ are isolated in $X_s$.
Choose an elementary \'etale neighbourhood $(U, u) \to (S, s)$
and decomposition $X_U = V \amalg W$ as in
Lemma \ref{lemma-etale-splits-off-quasi-finite-part}.
Note that $W_u = \emptyset$ because all points of $X_s$ are isolated.
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 $s \in S$ was arbitrary
this means there exists a family $\{U_i \to S\}$
of \'etale morphisms whose images cover $S$ such that
the base changes $X_{U_i} \to U_i$ are finite.
Note that $\{U_i \to S\}$ is an \'etale covering,
see Topologies, Definition \ref{topologies-definition-etale-covering}.
Hence it is an fpqc covering, see
Topologies,
Lemma \ref{topologies-lemma-zariski-etale-smooth-syntomic-fppf-fpqc}.
Hence we conclude $f$ is finite by
Descent, Lemma \ref{descent-lemma-descending-property-finite}.
\end{proof}

\noindent
As a consequence we have the following useful results.

\begin{lemma}
\label{lemma-proper-finite-fibre-finite-in-neighbourhood}
Let $f : X \to S$ be a morphism of schemes.
Let $s \in S$.
Assume that $f$ is proper and $f^{-1}(\{s\})$ is a finite set.
Then there exists an open neighbourhood $V \subset S$ of $s$
such that $f|_{f^{-1}(V)} : f^{-1}(V) \to V$ is finite.
\end{lemma}

\begin{proof}
The morphism $f$ is quasi-finite at all the points of $f^{-1}(\{s\})$
by Morphisms, Lemma \ref{morphisms-lemma-finite-fibre}.
By Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-points-open} the
set of points at which $f$ is quasi-finite is an open $U \subset X$.
Let $Z = X \setminus U$. Then $s \not \in f(Z)$. Since $f$ is proper
the set $f(Z) \subset S$ is closed. Choose any open neighbourhood
$V \subset S$ of $s$ with $Z \cap V = \emptyset$. Then
$f^{-1}(V) \to V$ is locally quasi-finite and proper.
Hence it is quasi-finite
(Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-locally-quasi-compact}),
hence has finite fibres
(Morphisms, Lemma \ref{morphisms-lemma-quasi-finite}), hence
is finite by Lemma \ref{lemma-characterize-finite}.
\end{proof}

\begin{lemma}
\label{lemma-flat-proper-family-cannot-collapse-fibre}
Consider a commutative diagram of schemes
$$\xymatrix{ X \ar[rr]_h \ar[rd]_f & & Y \ar[ld]^g \\ & S }$$
Let $s \in S$. Assume
\begin{enumerate}
\item $X \to S$ is a proper morphism,
\item $Y \to S$ is separated and locally of finite type, and
\item the image of $X_s \to Y_s$ is finite.
\end{enumerate}
Then there is an open
subspace $U \subset S$ containing $s$ such that $X_U \to Y_U$
factors through a closed subscheme $Z \subset Y_U$ finite over $U$.
\end{lemma}

\begin{proof}
Let $Z \subset Y$ be the scheme theoretic image of $h$, see
Morphisms, Section \ref{morphisms-section-scheme-theoretic-image}.
By Morphisms, Lemma \ref{morphisms-lemma-scheme-theoretic-image-is-proper}
the morphism $X \to Z$ is surjective and $Z \to S$ is proper.
Thus $X_s \to Z_s$ is surjective. We see that either
(3) implies $Z_s$ is finite.
Hence $Z \to S$ is finite in an open neighbourhood of $s$ by
Lemma \ref{lemma-proper-finite-fibre-finite-in-neighbourhood}.
\end{proof}

\begin{lemma}
\label{lemma-quasi-finite-finite-over-dense-open}
Let $f : Y \to X$ be a quasi-finite morphism.
There exists a dense open $U \subset X$ such that
$f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite.
\end{lemma}

\begin{proof}
If $U_i \subset X$, $i \in I$ is a collection of opens such that the
restrictions $f|_{f^{-1}(U_i)} : f^{-1}(U_i) \to U_i$ are finite,
then with $U = \bigcup U_i$ the restriction $f|_{f^{-1}(U)} : f^{-1}(U) \to U$
is finite, see
Morphisms, Lemma \ref{morphisms-lemma-finite-local}.
Thus the problem is local on $X$ and we may assume that $X$ is affine.

\medskip\noindent
Assume $X$ is affine.
Write $Y = \bigcup_{j = 1, \ldots, m} V_j$ with $V_j$ affine.
This is possible since $f$ is quasi-finite and hence
in particular quasi-compact. Each $V_j \to X$ is quasi-finite
and separated. Let $\eta \in X$ be a generic point of an irreducible
component of $X$. We see from
Morphisms, Lemmas
\ref{morphisms-lemma-quasi-finite} and \ref{morphisms-lemma-generically-finite}
that there exists an open neighbourhood $\eta \in U_\eta$ such that
$f^{-1}(U_\eta) \cap V_j \to U_\eta$ is finite. We may choose $U_\eta$ such
that it works for each $j = 1, \ldots, m$.
Note that the collection of generic points of $X$ is dense in $X$.
Thus we see there exists a dense open $W = \bigcup_\eta U_\eta$
such that each $f^{-1}(W) \cap V_j \to W$ is finite.
It suffices to show that there exists a dense open $U \subset W$
such that $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite.
Thus we may replace $X$ by an affine open subscheme of $W$ and
assume that each $V_j \to X$ is finite.

\medskip\noindent
Assume $X$ is affine, $Y = \bigcup_{j = 1, \ldots, m} V_j$ with $V_j$ affine,
and the restrictions $f|_{V_j} : V_j \to X$ are finite.
Set
$$\Delta_{ij} = \Big(\overline{V_i \cap V_j} \setminus V_i \cap V_j\Big) \cap V_j.$$
This is a nowhere dense closed subset of $V_j$ because it is the boundary
of the open subset $V_i \cap V_j$ in $V_j$. By
Morphisms, Lemma \ref{morphisms-lemma-image-nowhere-dense-finite}
the image $f(\Delta_{ij})$ is a nowhere dense closed subset of $X$. By
Topology, Lemma \ref{topology-lemma-nowhere-dense}
the union $T = \bigcup f(\Delta_{ij})$ is a nowhere dense closed
subset of $X$. Thus $U = X \setminus T$ is a dense open subset of $X$.
We claim that $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite.
To see this let $U' \subset U$ be an affine open.
Set $Y' = f^{-1}(U') = U' \times_X Y$,
$V_j' = Y' \cap V_j = U' \times_X V_j$. Consider the restriction
$$f' = f|_{Y'} : Y' \longrightarrow U'$$
of $f$. This morphism now has the property that
$Y' = \bigcup_{j = 1, \ldots, m} V'_j$ is an affine open covering,
each $V'_j \to U'$ is finite, and $V_i' \cap V_j'$ is (open and) closed
both in $V'_i$ and $V'_j$. Hence $V_i' \cap V_j'$ is affine, and the map
$$\mathcal{O}(V'_i) \otimes_{\mathbf{Z}} \mathcal{O}(V'_j) \longrightarrow \mathcal{O}(V'_i \cap V'_j)$$
is surjective. This implies that $Y'$ is separated, see
Schemes, Lemma \ref{schemes-lemma-characterize-separated}.
Finally, consider the commutative diagram
$$\xymatrix{ \coprod_{j = 1, \ldots, m} V'_j \ar[rd] \ar[rr] & & Y' \ar[ld] \\ & U' & }$$
The south-east arrow is finite, hence proper, the horizontal arrow is
surjective, and the south-west arrow is separated. Hence by
Morphisms, Lemma \ref{morphisms-lemma-image-proper-is-proper}
we conclude that $Y' \to U'$ is proper. Since it is also quasi-finite,
we see that it is finite by Lemma \ref{lemma-characterize-finite},
and we win.
\end{proof}

\begin{lemma}
\label{lemma-stratify-flat-fp-lqf-universally-bounded}
Let $f : X \to S$ be flat, locally of finite presentation, separated,
locally quasi-finite with universally bounded fibres. Then there exist
closed subsets
$$\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset \ldots \subset Z_n = S$$
such that with $S_r = Z_r \setminus Z_{r - 1}$ the stratification
$S = \coprod_{r = 0, \ldots, n} S_r$ is characterized by the following
universal property: Given $g : T \to S$ the projection
$X \times_S T \to T$ is finite locally
free of degree $r$ if and only if $g(T) \subset S_r$ (set theoretically).
\end{lemma}

\begin{proof}
Let $n$ be an integer bounding the degree of the fibres of $X \to S$.
By Morphisms, Lemma \ref{morphisms-lemma-base-change-universally-bounded}
we see that any base change has degrees of fibres bounded by $n$ also.
In particular, all the integers $r$ that occur in the statement of the lemma
will be $\leq n$. We will prove the lemma by induction on $n$. The base
case is $n = 0$ which is obvious.

\medskip\noindent
We claim the set of points $s \in S$
with $\deg_{\kappa(s)}(X_s) = n$ is an open subset $S_n \subset S$
and that $X \times_S S_n \to S_n$ is finite locally free of degree $n$.
Namely, suppose that $s \in S$ is such a point. Choose an elementary
\'etale morphism $(U, u) \to (S, s)$ and a decomposition
$U \times_S X = W \amalg V$ as in
Lemma \ref{lemma-etale-splits-off-quasi-finite-part}.
Since $V \to U$ is finite, flat, and locally of finite presentation,
we see that $V \to U$ is finite locally free, see
Morphisms, Lemma \ref{morphisms-lemma-finite-flat}.
After shrinking $U$ to a smaller neighbourhood of $u$
we may assume $V \to U$ is finite locally free of some degree $d$, see
Morphisms, Lemma \ref{morphisms-lemma-finite-locally-free}.
As $u \mapsto s$ and $W_u = \emptyset$ we see that $d = n$. Since $n$
is the maximum degree of a fibre we see that $W = \emptyset$!
Thus $U \times_S X \to U$ is finite locally free of degree $n$.
By Descent, Lemma \ref{descent-lemma-descending-property-finite-locally-free}
we conclude that $X \to S$ is finite locally free of degree $n$
over $\Im(U \to S)$ which is an open neighbourhood of $s$
(Morphisms, Lemma \ref{morphisms-lemma-etale-open}).
This proves the claim.

\medskip\noindent
Let $S' = S \setminus S_n$ endowed with the reduced induced scheme
structure and set $X' = X \times_S S'$. Note that the degrees of fibres
of $X' \to S'$ are universally bounded by $n - 1$. By induction we find a
stratification $S' = S_0 \amalg \ldots \amalg S_{n - 1}$ adapted
to the morphism $X' \to S'$. We claim that $S = \coprod_{r = 0, \ldots, n} S_r$
works for the morphism $X \to S$. Let $g : T \to S$ be a morphism of schemes
and assume that $X \times_S T \to T$ is finite locally free of degree $r$.
As remarked above this implies that $r \leq n$. If $r = n$, then it is
clear that $T \to S$ factors through $S_n$. If $r < n$, then
$g(T) \subset S' = S \setminus S_d$ (set theoretically) hence
$T_{red} \to S$ factors through $S'$, see
Schemes, Lemma \ref{schemes-lemma-map-into-reduction}.
Note that $X \times_S T_{red} \to T_{red}$ is also
finite locally free of degree $r$ as a base change.
By the universal property of the stratification
$S' = \coprod_{r = 0, \ldots, n - 1} S_r$ we see that $g(T) = g(T_{red})$
is contained in $S_r$.
Conversely, suppose that we have $g : T \to S$ such that
$g(T) \subset S_r$ (set theoretically).
If $r = n$, then $g$ factors through $S_n$ and
it is clear that $X \times_S T \to T$
is finite locally free of degree $n$ as a base change.
If $r < n$, then $X \times_S T \to T$ is a morphism which is
separated, flat, and locally of finite presentation, such that
the restriction to $T_{red}$ is finite locally free of degree $r$.
Since $T_{red} \to T$ is a universal homeomorphism, we conclude
that $X \times_S T_{red} \to X \times_S T$ is a universal homeomorphism
too and hence $X \times_S T \to T$ is universally closed (as this
is true for the finite morphism $X \times_S T_{red} \to T_{red}$).
It follows that $X \times_S T \to T$ is finite, for example by
Lemma \ref{lemma-characterize-finite}. Then we can use
Morphisms, Lemma \ref{morphisms-lemma-finite-flat}
to see that $X \times_S T \to T$ is finite locally free.
Finally, the degree is $r$ as all the fibres have degree $r$.
\end{proof}

\begin{lemma}
\label{lemma-stratify-flat-fp-qf}
Let $f : X \to S$ be a morphism of schemes which is flat, locally of
finite presentation, separated, and quasi-finite. Then there exist
closed subsets
$$\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset \ldots \subset S$$
such that with $S_r = Z_r \setminus Z_{r - 1}$ the stratification
$S = \coprod S_r$ is characterized by the following universal property:
Given a morphism $g : T \to S$ the projection $X \times_S T \to T$ is
finite locally free of degree $r$ if and only if $g(T) \subset S_r$
(set theoretically). Moreover, the inclusion maps $S_r \to S$ are
quasi-compact.
\end{lemma}

\begin{proof}
The question is local on $S$, hence we may assume that $S$ is affine.
By Morphisms, Lemma
\ref{morphisms-lemma-locally-quasi-finite-qc-source-universally-bounded}
the fibres of $f$ are universally bounded in this case.
Hence the existence of the stratification follows from
Lemma \ref{lemma-stratify-flat-fp-lqf-universally-bounded}.

\medskip\noindent
We will show that $U_r = S \setminus Z_r \to S$ is quasi-compact for
each $r \geq 0$. This will prove the final statement by elementary topology.
Since a composition of quasi-compact maps is quasi-compact
it suffices to prove that $U_r \to U_{r - 1}$ is quasi-compact.
Choose an affine open $W \subset U_{r - 1}$. Write $W = \Spec(A)$.
Then $Z_r \cap W = V(I)$ for some ideal $I \subset A$
and $X \times_S \Spec(A/I) \to \Spec(A/I)$ is finite locally
free of degree $r$. Note that $A/I = \colim A/I_i$ where $I_i \subset I$
runs through the finitely generated ideals. By
Limits, Lemma \ref{limits-lemma-descend-finite-locally-free}
we see that $X \times_S \Spec(A/I_i) \to \Spec(A/I_i)$
is finite locally free of degree $r$ for some $i$. (This uses
that $X \to S$ is of finite presentation, as it is locally of finite
presentation, separated, and quasi-compact.)
Hence $\Spec(A/I_i) \to \Spec(A) = W$ factors (set theoretically)
through $Z_r \cap W$. It follows that $Z_r \cap W = V(I_i)$ is the zero
set of a finite subset of elements of $A$. This means that
$W \setminus Z_r$ is a finite union of standard opens, hence quasi-compact,
as desired.
\end{proof}

\begin{lemma}
\label{lemma-stratify-flat-fp-lqf}
Let $f : X \to S$ be a flat, locally of finite presentation, separated, and
locally quasi-finite morphism of schemes. Then there
exist open subschemes
$$S = U_0 \supset U_1 \supset U_2 \supset \ldots$$
such that a morphism $\Spec(k) \to S$ factors through $U_d$ if and
only if $X \times_S \Spec(k)$ has degree $\geq d$ over $k$.
\end{lemma}

\begin{proof}
The statement simply means that the collection of points where the degree
of the fibre is $\geq d$ is open. Thus we can work locally on $S$ and
assume $S$ is affine. In this case, for every $W \subset X$ quasi-compact
open, the set of points $U_d(W)$ where the fibres of $W \to S$ have
degree $\geq d$ is open by Lemma \ref{lemma-stratify-flat-fp-qf}.
Since $U_d = \bigcup_W U_d(W)$ the result follows.
\end{proof}

\begin{lemma}
\label{lemma-go-down-with-annihilators}
Let $f : X \to S$ be a morphism of schemes which is flat, locally of
finite presentation, and locally quasi-finite. Let
$g \in \Gamma(X, \mathcal{O}_X)$ nonzero. Then there exist
an open $V \subset X$ such that $g|_V \not = 0$, an open
$U \subset S$ fitting into a commutative diagram
$$\xymatrix{ V \ar[r] \ar[d]_\pi & X \ar[d]^f \\ U \ar[r] & S, }$$
a quasi-coherent subsheaf $\mathcal{F} \subset \mathcal{O}_U$, an integer
$r > 0$, and an injective $\mathcal{O}_U$-module map
$\mathcal{F}^{\oplus r} \to \pi_*\mathcal{O}_V$
whose image contains $g|_V$.
\end{lemma}

\begin{proof}
We may assume $X$ and $S$ affine. We obtain a filtration
$\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset \ldots \subset Z_n = S$ as in
Lemmas \ref{lemma-stratify-flat-fp-lqf-universally-bounded} and
\ref{lemma-stratify-flat-fp-qf}.
Let $T \subset X$ be the scheme theoretic support of the finite
$\mathcal{O}_X$-module $\Im(g : \mathcal{O}_X \to \mathcal{O}_X)$.
Note that $T$ is the support of $g$ as a section of $\mathcal{O}_X$
(Modules, Definition \ref{modules-definition-support}) and
for any open $V \subset X$ we have $g|_V \not = 0$ if and only if
$V \cap T \not = \emptyset$.
Let $r$ be the smallest integer such that $f(T) \subset Z_r$
set theoretically. Let $\xi \in T$ be a generic point of an irreducible
component of $T$ such that $f(\xi) \not \in Z_{r - 1}$ (and hence
$f(\xi) \in Z_r$). We may replace $S$ by an affine neighbourhood of
$f(\xi)$ contained in $S \setminus Z_{r - 1}$. Write $S = \Spec(A)$
and let $I = (a_1, \ldots, a_m) \subset A$ be a finitely generated ideal
such that $V(I) = Z_r$ (set theoretically, see
Algebra, Lemma \ref{algebra-lemma-qc-open}).
Since the support of $g$ is contained in $f^{-1}V(I)$ by our choice of $r$
we see that there exists an integer $N$ such that
$a_j^N g = 0$ for $j = 1, \ldots, m$. Replacing $a_j$ by $a_j^r$
we may assume that $Ig = 0$. For any $A$-module $M$ write
$M[I]$ for the $I$-torsion of $M$, i.e., $M[I] = \{m \in M \mid Im = 0\}$.
Write $X = \Spec(B)$, so $g \in B[I]$. Since $A \to B$ is flat we
see that
$$B[I] = A[I] \otimes_A B \cong A[I] \otimes_{A/I} B/IB$$
By our choice of $Z_r$, the $A/I$-module $B/IB$ is
finite locally free of rank $r$. Hence after replacing $S$ by
a smaller affine open neighbourhood of $f(\xi)$ we may assume
that $B/IB \cong (A/IA)^{\oplus r}$ as $A/I$-modules.
Choose a map $\psi : A^{\oplus r} \to B$ which reduces modulo $I$ to the
isomorphism of the previous sentence. Then we see that
the induced map
$$A[I]^{\oplus r} \longrightarrow B[I]$$
is an isomorphism. The lemma follows by taking $\mathcal{F}$ the
quasi-coherent sheaf associated to the $A$-module $A[I]$ and
the map $\mathcal{F}^{\oplus r} \to \pi_*\mathcal{O}_V$ the
one corresponding to $A[I]^{\oplus r} \subset A^{\oplus r} \to B$.
\end{proof}

\begin{lemma}
\label{lemma-separated-locally-quasi-finite-over-affine}
Let $f : X \to Y$ be a separated, locally quasi-finite morphism
with $Y$ affine. Then every finite set of points of $X$ is contained
in an open affine of $X$.
\end{lemma}

\begin{proof}
Let $x_1, \ldots, x_n \in X$. Choose a quasi-compact open
$U \subset X$ with $x_i \in U$. Then $U \to Y$ is quasi-affine by
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}.
Hence there exists an affine open $V \subset U$ containing
$x_1, \ldots, x_n$ by
Properties, Lemma \ref{properties-lemma-ample-finite-set-in-affine}.
\end{proof}

\begin{lemma}
\label{lemma-there-is-a-scheme-integral-over}
Let $U \to X$ be a surjective \'etale morphism of schemes. Assume $X$
is quasi-compact and quasi-separated. Then there exists a surjective
integral morphism $Y \to X$, such that for
every $y \in Y$ there is an open neighbourhood $V \subset Y$
such that $V \to X$ factors through $U$. In fact, we may assume
$Y \to X$ is finite and of finite presentation.
\end{lemma}

\begin{proof}
Since $X$ is quasi-compact, there exist finitely many affine opens
$U_i \subset U$ such that $U' = \coprod U_i \to X$ is surjective.
After replacing $U$ by $U'$, we see that we may assume $U$ is affine.
Then there exists an integer $d$ bounding the degree of the geometric
fibres of $U \to X$ (see Morphisms, Lemma
\ref{morphisms-lemma-locally-quasi-finite-qc-source-universally-bounded}).
We will prove the lemma by induction on $d$ for all quasi-compact
and separated schemes $U$ mapping surjective and \'etale onto $X$.
If $d = 1$, then $U = X$ and the result holds with $Y = U$.
Assume $d > 1$.

\medskip\noindent
We apply Lemma \ref{lemma-quasi-finite-separated-quasi-affine}
and we obtain a factorization
$$\xymatrix{ U \ar[rr]_j \ar[rd] & & Y \ar[ld]^\pi \\ & X }$$
with $\pi$ integral and $j$ a quasi-compact open immersion. We may and do
assume that $j(U)$ is scheme theoretically dense in $Y$. Note that
$$U \times_X Y = U \amalg W$$
where the first summand is the image of $U \to U \times_X Y$
(which is closed by
Schemes, Lemma \ref{schemes-lemma-semi-diagonal}
and open because it is \'etale as a morphism between schemes \'etale over $Y$)
and the second summand is the (open and closed) complement.
The image $V \subset Y$ of $W$ is an open subscheme containing
$Y \setminus U$.

\medskip\noindent
The \'etale morphism $W \to Y$ has geometric fibres of cardinality $< d$.
Namely, this is clear for geometric points of $U \subset Y$ by inspection.
Since $U \subset Y$ is dense, it holds for all geometric points of $Y$
for example by Lemma
\ref{lemma-stratify-flat-fp-lqf-universally-bounded}
(the degree of the fibres of a quasi-compact \'etale morphism
does not go up under specialization). Thus we may apply the induction
hypothesis to $W \to V$ and find a surjective integral morphism
$Z \to V$ with $Z$ a scheme, which Zariski locally factors through $W$.
Choose a factorization $Z \to Z' \to Y$ with $Z' \to Y$ integral and
$Z \to Z'$ open immersion
(Lemma \ref{lemma-quasi-finite-separated-quasi-affine}).
After replacing $Z'$ by the scheme theoretic closure of $Z$ in $Z'$
we may assume that $Z$ is scheme theoretically dense in $Z'$.
After doing this we have $Z' \times_Y V = Z$. Finally,
let $T \subset Y$ be the induced reduced closed subscheme structure
on $Y \setminus V$. Consider the morphism
$$Z' \amalg T \longrightarrow X$$
This is a surjective integral morphism by construction.
Since $T \subset U$ it is clear that the morphism $T \to X$
factors through $U$. On the other hand, let $z \in Z'$
be a point. If $z \not \in Z$, then $z$ maps to a point of
$Y \setminus V \subset U$ and we find a neighbourhood of $z$
on which the morphism factors through $U$.
If $z \in Z$, then we have a neighbourhood $V \subset Z$
which factors through $W \subset U \times_X Y$ and hence through $U$.
This proves existence.

\medskip\noindent
Assume we have found $Y \to X$ integral and surjective which Zariski
locally factors through $U$. Choose a finite affine open covering
$Y = \bigcup V_j$ such that $V_j \to X$ factors through $U$. We can
write $Y = \lim Y_i$ with $Y_i \to X$ finite and of finite
presentation, see Limits, Lemma
\ref{limits-lemma-integral-limit-finite-and-finite-presentation}.
For large enough $i$ we can find affine opens $V_{i, j} \subset Y_i$
whose inverse image in $Y$ recovers $V_j$, see
Limits, Lemma \ref{limits-lemma-descend-opens}.
For even larger $i$ the morphisms $V_j \to U$ over $X$ come
from morphisms $V_{i, j} \to U$ over $X$, see
Limits, Proposition
\ref{limits-proposition-characterize-locally-finite-presentation}.
This finishes the proof.
\end{proof}

Comment #1594 by kollar on August 5, 2015 a 6:31 pm UTC

I think it could be useful to tell the reader which of the 12 lemmas you consider to be "zariski's main thm"

## Add a comment on tag 02LQ

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the lower-right corner).