hcju/stacksqa huggingface dataset:
The spectrum of $A$ has finitely many primes $\mathfrak p_1, \ldots, \mathfrak p_n$ besides $\mathfrak m$ and these are all minimal, see Algebra, Lemma \ref{algebra-lemma-Noetherian-irreducible-components}. Then the equivalence of (1) and (2) follows from Algebra, Lemma \ref{algebra-lemma-Zariski-topology}. Clearly, (3) implies (2). Conversely, if (2) is true, then the spectrum of $A_f$ is the subset $\{\mathfrak p_1, \ldots, \mathfrak p_n\}$ of $\Spec(A)$ with induced topology, see Algebra, Lemma \ref{algebra-lemma-spec-localization}. This is a finite discrete topological space. Hence $A_f = \prod_{\mathfrak p\text{ minimal}} A_\mathfrak p$ by Algebra, Proposition \ref{algebra-proposition-dimension-zero-ring}. The existence of an $f$ is asserted in Algebra, Lemma \ref{algebra-lemma-height-1}. \medskip\noindent Assume $A$ has depth $1$. (This is the maximum by Algebra, Lemma \ref{algebra-lemma-bound-depth} and holds if $A$ is reduced by Algebra, Lemma \ref{algebra-lemma-criterion-reduced}.) Then $\mathfrak m$ is not an associated prime of $A$. Every minimal prime of $A$ is an associated prime (Algebra, Proposition \ref{algebra-proposition-minimal-primes-associated-primes}). Hence the set of nonzerodivisors of $A$ is exactly the set of elements not contained in any of the minimal primes by Algebra, Lemma \ref{algebra-lemma-ass-zero-divisors}. Thus (4) is equivalent to (2). Part (5) is equivalent to (3) by Algebra, Lemma \ref{algebra-lemma-total-ring-fractions-no-embedded-points}. \medskip\noindent Then $A_\mathfrak p$ is a field for $\mathfrak p \subset A$ minimal, see Algebra, Lemma \ref{algebra-lemma-minimal-prime-reduced-ring}. Hence (3) is equivalent ot (6).
The total ring of fractions is essentially of finite type over $A$ hence $A \to A'$ is finite because $A$ is Nagata, see Algebra, Lemma \ref{algebra-lemma-nagata-in-reduced-finite-type-finite-integral-closure}. The ring $A'$ is normal for example by Algebra, Lemma \ref{algebra-lemma-characterize-reduced-ring-normal} and \ref{algebra-lemma-Noetherian-irreducible-components}. The ring $A'$ is Nagata for example by Algebra, Lemma \ref{algebra-lemma-quasi-finite-over-nagata}. Choose $f \in \mathfrak m$ as in Lemma \ref{lemma-pre-pre-delta-invariant}. As $A' \subset A_f$ it is clear that $A_f = A'_f$. Hence the support of the finite $A$-module $A'/A$ is contained in $\{\mathfrak m\}$. It follows that it has finite length by Algebra, Lemma \ref{algebra-lemma-support-point}.
If $A$ is a discrete valuation ring, then $A$ is normal and the ring $A'$ is equal to $A$. Conversely, if the $\delta$-invariant of $A$ is $0$, then $A$ is integrally closed in its total ring of fractions which implies that $A$ is normal (Algebra, Lemma \ref{algebra-lemma-characterize-reduced-ring-normal}) and this forces $A$ to be a discrete valuation ring by Algebra, Lemma \ref{algebra-lemma-characterize-dvr}.
Observe that $A^\wedge$ is reduced, see More on Algebra, Lemma \ref{more-algebra-lemma-completion-reduced}. The rings $A^h$ and $A^{sh}$ are reduced by More on Algebra, Lemma \ref{more-algebra-lemma-henselization-reduced}. The dimensions of $A$, $A^h$, $A^{sh}$, and $A^\wedge$ are the same by More on Algebra, Lemmas \ref{more-algebra-lemma-completion-dimension} and \ref{more-algebra-lemma-henselization-dimension}. \medskip\noindent Recall that a Noetherian local ring is Nagata if and only if the formal fibres of $A$ are geometrically reduced, see More on Algebra, Lemma \ref{more-algebra-lemma-Nagata-local-ring}. This property is inherited by $A^h$ and $A^{sh}$, see the material in More on Algebra, Section \ref{more-algebra-section-properties-formal-fibres} and especially Lemma \ref{more-algebra-lemma-henselization-P-ring}. The completion is Nagata by Algebra, Lemma \ref{algebra-lemma-Noetherian-complete-local-Nagata}. \medskip\noindent Now we come to the statement on integral closures. Before continuing let us pick $f \in \mathfrak m$ as in Lemma \ref{lemma-pre-pre-delta-invariant}. Then the image of $f$ in $A^h$, $A^{sh}$, and $A^\wedge$ clearly is an element satisfying properties (1) -- (6) in that ring. \medskip\noindent Since $A \to A'$ is finite we see that $A' \otimes_A A^h$ and $A' \otimes_A A^{sh}$ is the product of henselian local rings finite over $A^h$ and $A^{sh}$, see Algebra, Lemma \ref{algebra-lemma-finite-over-henselian}. Each of these local rings is the henselization of $A'$ at a maximal ideal $\mathfrak m' \subset A'$ lying over $\mathfrak m$, see Algebra, Lemma \ref{algebra-lemma-quasi-finite-henselization} or \ref{algebra-lemma-quasi-finite-strict-henselization}. Hence these local rings are normal domains by More on Algebra, Lemma \ref{more-algebra-lemma-henselization-normal}. It follows that $A' \otimes_A A^h$ and $A' \otimes_A A^{sh}$ are normal rings. Since $A^h \to A' \otimes_A A^h$ and $A^{sh} \to A' \otimes_A A^{sh}$ are finite (hence integral) and since $A' \otimes_A A^h \subset (A^h)_f = Q(A^h)$ and $A' \otimes_A A^{sh} \subset (A^{sh})_f = Q(A^{sh})$ we conclude that $A' \otimes_A A^h$ and $A' \otimes_A A^{sh}$ are the desired integral closures. \medskip\noindent For the completion we argue in entirely the same manner. First, by Algebra, Lemma \ref{algebra-lemma-completion-finite-extension} we have $$ A' \otimes_A A^\wedge = (A')^\wedge = \prod\nolimits (A'_{\mathfrak m'})^\wedge $$ The local rings $A'_{\mathfrak m'}$ are normal and have dimension $1$ (by Algebra, Lemma \ref{algebra-lemma-finite-in-codim-1} for example or the discussion in Algebra, Section \ref{algebra-section-homomorphism-dimension}). Thus $A'_{\mathfrak m'}$ is a discrete valuation ring, see Algebra, Lemma \ref{algebra-lemma-characterize-dvr}. Hence $(A'_{\mathfrak m'})^\wedge$ is a discrete valuation ring by More on Algebra, Lemma \ref{more-algebra-lemma-completion-dvr}. It follows that $A' \otimes_A A^\wedge$ is a normal ring and we can conclude in exactly the same manner as before.
Let us do this in case of the completion $B = A^\wedge$; the other cases are proved in exactly the same manner. Let $A'$, resp.\ $B'$ be the integral closure of $A$, resp.\ $B$ in its total ring of fractions. Then $B' = A' \otimes_A B$ by Lemma \ref{lemma-normalization-same-after-completion}. Hence $B'/B = A'/A \otimes_A B$. The equality now follows from Algebra, Lemma \ref{algebra-lemma-pullback-module} and the fact that $B \otimes_A \kappa_A = \kappa_B$.
Set $A = \mathcal{O}_{X, x}$ and $B = \mathcal{O}_{Y, y}$. By Lemma \ref{lemma-geometrically-reduced-at-point} we see that $A$ is geometrically reduced. Hence $B$ is a localization of $A \otimes_k K$. Let $A \to A'$ be as in Lemma \ref{lemma-pre-delta-invariant}. Then $$ B' = B \otimes_{(A \otimes_k K)} (A' \otimes_k K) $$ is finite over $B$ and $B \to B'$ induces an isomorphism on total rings of fractions. Namely, pick $f \in \mathfrak m_A$ satisfying (1) -- (6) of Lemma \ref{lemma-pre-pre-delta-invariant}; since $\dim(B) = 1$ we see that $f \in \mathfrak m_B$ playes the same role for $B$ and we see that $B_f = B'_f$ because $A_f = A'_f$. Let $B''$ be the integral closure of $B$ in its total ring of fractions as in Lemma \ref{lemma-pre-delta-invariant}. Then $B' \subset B''$. Thus the $\delta$-invariant of $Y$ at $y$ is $\text{length}_B(B''/B)$ and \begin{align*} \text{length}_B(B''/B) & \geq \text{length}_B(B'/B) \\ & = \text{length}_B((A'/A) \otimes_A B) \\ & = \text{length}_B(B/\mathfrak m_A B) \text{length}_A(A'/A) \end{align*} by Algebra, Lemma \ref{algebra-lemma-pullback-module} since $A \to B$ is flat (as a localization of $A \to A \otimes_k K$). Since $\text{length}_A(A'/A)$ is the $\delta$-invariant of $X$ at $x$ and since $\text{length}_B(B/\mathfrak m_A B) \geq 1$ the lemma is proved.
Set $A = \mathcal{O}_{X, x}$ and $B = \mathcal{O}_{Y, y}$. By Lemma \ref{lemma-geometrically-normal-in-codim-1} we see that $A$ is geometrically reduced. Hence $B$ is a localization of $A \otimes_k K$. Let $A \to A'$ be as in Lemma \ref{lemma-pre-delta-invariant}. By Lemma \ref{lemma-geometrically-normal-in-codim-1} we see that $A' \otimes_k K$ is normal. Hence $$ B' = B \otimes_{(A \otimes_k K)} (A' \otimes_k K) $$ is normal, finite over $B$, and $B \to B'$ induces an isomorphism on total rings of fractions. Namely, pick $f \in \mathfrak m_A$ satisfying (1) -- (6) of Lemma \ref{lemma-pre-pre-delta-invariant}; since $\dim(B) = 1$ we see that $f \in \mathfrak m_B$ playes the same role for $B$ and we see that $B_f = B'_f$ because $A_f = A'_f$. It follows that $B \to B'$ is as in Lemma \ref{lemma-pre-delta-invariant} for $B$. Thus we have to show that $\text{length}_A(A'/A) = \text{length}_B(B'/B) = \text{length}_B((A'/A) \otimes_A B)$. Since $A \to B$ is flat (as a localization of $A \to A \otimes_k K$) and since $\mathfrak m_B = \mathfrak m_A B$ (because $B/\mathfrak m_A B$ is zero dimensional by the remarks above and a localization of $K \otimes_k \kappa(x)$ which is reduced as $\kappa(x)$ is separable over $k$) we conclude by Algebra, Lemma \ref{algebra-lemma-pullback-module}.
First note that the assumption on $X$ exactly means that the normalization is defined, see Morphisms, Definition \ref{morphisms-definition-normalization}. Then the stalk $A' = (\nu_*\mathcal{O}_{X^\nu})_x$ is the integral closure of $A = \mathcal{O}_{X, x}$ in the total ring of fractions of $A_{red}$, see Morphisms, Lemma \ref{morphisms-lemma-stalk-normalization}. Since $\nu$ is an integral morphism, we see that the points of $X^\nu$ lying over $x$ correspond to the primes of $A'$ lying over the maximal ideal $\mathfrak m$ of $A$. As $A \to A'$ is integral, this is the same thing as the maximal ideals of $A'$ (Algebra, Lemmas \ref{algebra-lemma-integral-no-inclusion} and \ref{algebra-lemma-integral-going-up}). Thus the lemma now follows from its algebraic counterpart: More on Algebra, Lemma \ref{more-algebra-lemma-number-of-branches-1}.
Write $Y = X_K$ and let $X^\nu$, resp.\ $Y^\nu$ be the normalization of $X$, resp.\ $Y$. Consider the commutative diagram $$ \xymatrix{ Y^\nu \ar[r] \ar[d] & X^\nu_K \ar[r] \ar[d]_{\nu_K} & X^\nu \ar[d]_\nu \\ Y \ar@{=}[r] & Y \ar[r] & X } $$ By Lemma \ref{lemma-normalization-and-change-of-fields} we see that the left top horizontal arrow is a universal homeomorphism. Hence it induces purely inseparable residue field extensions, see Morphisms, Lemmas \ref{morphisms-lemma-universal-homeomorphism} and \ref{morphisms-lemma-universally-injective}. Thus the number of geometric branches of $Y$ at $y$ is $\sum_{\nu_K(y') = y} [\kappa(y') : \kappa(y)]_s$ by Lemma \ref{lemma-number-of-branches}. Similarly $\sum_{\nu(x') = x} [\kappa(x') : \kappa(x)]_s$ is the number of geometric branches of $X$ at $x$. Using Schemes, Lemma \ref{schemes-lemma-points-fibre-product} our statement follows from the following algebra fact: given a field extension $l/\kappa$ and an algebraic field extension $m/\kappa$, then $$ \sum\nolimits_{m \otimes_\kappa l \to m'} [m' : l']_s = [m : \kappa]_s $$ where the sum is over the quotient fields of $m \otimes_\kappa l$. One can prove this in an elementary way, or one can use Lemma \ref{lemma-separably-closed-field-connected-components} applied to $$ \Spec(m \otimes_\kappa l) \times_{\Spec(l)} \Spec(\overline{l}) = \Spec(m) \otimes_{\Spec(\kappa)} \Spec(\overline{l}) \longrightarrow \Spec(m) \times_{\Spec(\kappa)} \Spec(\overline{\kappa}) $$ because one can interpret $[m : \kappa]_s$ as the number of connected components of the right hand side and the sum $\sum_{m \otimes_\kappa l \to m'} [m' : l']_s$ as the number of connected components of the left hand side.
The number of geometric branches is equal to the number of branches of $A$ (immediate from More on Algebra, Definition \ref{more-algebra-definition-number-of-branches}). Let $A \to A'$ be as in Lemma \ref{lemma-pre-delta-invariant}. Observe that the number of branches of $A$ is the number of maximal ideals of $A'$, see More on Algebra, Lemma \ref{more-algebra-lemma-number-of-branches-1}. There is a surjection $$ A'/A \longrightarrow \left(\prod\nolimits_{\mathfrak m'} \kappa(\mathfrak m')\right)/ \kappa(\mathfrak m) $$ Since $\dim_{\kappa(\mathfrak m)} \prod \kappa(\mathfrak m')$ is $\geq$ the number of branches, the inequality is obvious. \medskip\noindent If equality holds, then $\kappa(\mathfrak m') = \kappa(\mathfrak m)$ for all $\mathfrak m' \subset A'$ and the displayed arrow above is an isomorphism. Since $A$ is henselian and $A \to A'$ is finite, we see that $A'$ is a product of local henselian rings, see Algebra, Lemma \ref{algebra-lemma-finite-over-henselian}. The factors are the local rings $A'_{\mathfrak m'}$ and as $A'$ is normal, these factors are discrete valuation rings (Algebra, Lemma \ref{algebra-lemma-characterize-dvr}). Since the displayed arrow is an isomorphism we see that $A$ is indeed the wedge of these local rings.
We may replace $A$ by the strict henselization of $A$ without changing the $\delta$-invariant (Lemma \ref{lemma-delta-same-after-completion}) and without changing the number of geometric branches of $A$ (this is immediate from the definition, see More on Algebra, Definition \ref{more-algebra-definition-number-of-branches}). Thus we may assume $A$ is strictly henselian and we may apply Lemma \ref{lemma-delta-number-branches-inequality-sh}.
Many of the results are in fact general properties of the normalization morphism, see Morphisms, Lemmas \ref{morphisms-lemma-normalization-reduced}, \ref{morphisms-lemma-stalk-normalization}, \ref{morphisms-lemma-normalization-normal}, and \ref{morphisms-lemma-normalization-birational}. What is not clear is that the fibres are finite, that the induced residue field extensions are finite, and that $X^\nu$ locally looks like the spectrum of a Dedekind domain (and hence is Noetherian). To see this we may assume that $X = \Spec(A)$ is affine, Noetherian, dimension $1$, and that $A$ is reduced. Then we may use the description in Morphisms, Lemma \ref{morphisms-lemma-description-normalization} to reduce to the case where $A$ is a Noetherian domain of dimension $1$. In this case the desired properties follow from Krull-Akizuki in the form stated in Algebra, Lemma \ref{algebra-lemma-integral-closure-Dedekind}.
We may and will use all the results of Lemma \ref{lemma-normalize-noetherian-dim-1}. Finiteness of $\nu$ follows from Morphisms, Lemma \ref{morphisms-lemma-nagata-normalization}. Since $X$ is reduced, Nagata, of dimension $1$, we see that the regular locus is a dense open $U \subset X$ by More on Algebra, Proposition \ref{more-algebra-proposition-ubiquity-J-2}. Since a regular scheme is normal, this shows that $\nu$ is an isomorphism over $U$. Since $\dim(X) \leq 1$ this implies that $\nu$ is not an isomorphism over a discrete set of closed points $x \in X$. In particular we see that we have a short exact sequence $$ 0 \to \mathcal{O}_X \to \nu_*\mathcal{O}_{X^\nu} \to \bigoplus\nolimits_{x \in X \setminus U} \mathcal{Q}_x \to 0 $$ As we have the description of the stalks of $\nu_*\mathcal{O}_{X^\nu}$ by Lemma \ref{lemma-normalize-noetherian-dim-1}, we conclude that $Q_x = A'/A$ indeed has length equal to the $\delta$-invariant of $X$ at $x$. Note that $Q_x \not = 0$ exactly when $x$ is a singular point for example by Lemma \ref{lemma-delta-invariant-is-zero}. The description of $A'$ as a product of semi-local Dedekind domains follows from Lemma \ref{lemma-normalize-noetherian-dim-1} as well. The relationship between $A$, $A'$, and $(A')^\wedge$ we have see in Lemma \ref{lemma-normalization-same-after-completion} (and its proof).
Using Limits, Proposition \ref{limits-proposition-affine} there is an immediate reduction to the case where $X$ and $T$ are reduced. Details omitted. \medskip\noindent Assume $X$ and $T$ are reduced. We may write $T = \lim_{i \in I} T_i$ as a directed limit of schemes of finite presentation over $X$ with affine transition morphisms, see Limits, Lemma \ref{limits-lemma-relative-approximation}. Pick $i \in I$ such that $T_i$ is affine, see Limits, Lemma \ref{limits-lemma-limit-affine}. Say $T_i = \Spec(R_i)$ and $T = \Spec(R)$. Let $R' \subset R$ be the image of $R_i \to R$. Then $T' = \Spec(R')$ is affine, reduced, of finite type over $X$, and $T \to T'$ dominant. For $j = 1, \ldots, r$ let $t'_j \in T'$ be the image of $t_j$. Consider the local ring maps $$ \mathcal{O}_{X, x_j} \to \mathcal{O}_{T', t'_j} \to \mathcal{O}_{T, t_j} $$ Denote $(T')^0$ the set of generic points of irreducible components of $T'$. Let $\xi \leadsto t'_j$ be a specialization with $\xi \in (T')^0$. As $T \to T'$ is dominant we can choose $\eta \in T^0$  mapping to $\xi$ (warning: a priori we do not know that $\eta$ specializes to $t_j$). Assumption (3) applied to $\eta$ tells us that the image $\theta$ of $\xi$ in $X$ corresponds to a minimal prime of $\mathcal{O}_{X, x_j}$. Lifting $\xi$ via the isomorphism of (5) we obtain a specialization $\eta' \leadsto t_j$ with $\eta' \in T^0$ mapping to $\theta \leadsto x_j$. The injectivity of (4) shows that $\eta = \eta'$. Thus every minimal prime of $\mathcal{O}_{T', t'_j}$ lies below a minimal prime of $\mathcal{O}_{T, t_j}$. We conclude that $\mathcal{O}_{T', t'_j} \to \mathcal{O}_{T, t_j}$ is injective, hence both maps above are isomorphisms. \medskip\noindent By Lemma \ref{lemma-local-isomorphism} there exists an open $U \subset T'$ containing all the points $t'_j$ such that $U \to X$ is a local isomorphism as in Lemma \ref{lemma-characterize-open-immersion}. By that lemma we see that $U \to X$ is an open immersion. Finally, by Properties, Lemma \ref{properties-lemma-ample-finite-set-in-affine} we can find an open $W \subset U \subset T'$ containing all the $t'_j$. The image of $W$ in $X$ is the desired affine open.
Let $K$ be the field of rational functions of $X$. Set $A_i = \mathcal{O}_{X, x_i}$. Then $A_i \subset K$ and $K$ is the fraction field of $A_i$. Since $X$ is separated, and $x_i \not = x_j$ there cannot be a valuation ring $\mathcal{O} \subset K$ dominating both $A_i$ and $A_j$. Namely, considering the diagram $$ \xymatrix{ \Spec(\mathcal{O}) \ar[r] \ar[d] & \Spec(A_1) \ar[d] \\ \Spec(A_2) \ar[r] & X } $$ and applying the valuative criterion of separatedness (Schemes, Lemma \ref{schemes-lemma-separated-implies-valuative}) we would get $x_i = x_j$. Thus we see by Lemma \ref{lemma-glue-separated} that $A_i \otimes A_j \to K$ is surjective for all $i \not = j$. By Lemma \ref{lemma-glue-a-bunch-of-local-rings} we see that $A = A_1 \cap \ldots \cap A_r$ is a Noetherian semi-local ring with exactly $r$ maximal ideals $\mathfrak m_1, \ldots, \mathfrak m_r$ such that $A_i = A_{\mathfrak m_i}$. Moreover, $$ \Spec(A) = \Spec(A_1) \cup \ldots \cup \Spec(A_r) $$ is an open covering and the intersection of any two pieces of this covering is $\Spec(K)$. Thus the given morphisms $\Spec(A_i) \to X$ glue to a morphism of schemes $$ \Spec(A) \longrightarrow X $$ mapping $\mathfrak m_i$ to $x_i$ and inducing isomorphisms of local rings. Thus the result follows from Lemma \ref{lemma-points-in-affine}.
We may assume there are no inclusion relations among the $\mathfrak p_i$ (by removing the smaller primes). First pick any $f \in A$ lifting $\overline{f}$. Let $S$ be the set $s \in \{1, \ldots, r\}$ such that $f \in \mathfrak p_s$. If $S$ is empty we are done. If not, consider the ideal $J = I \prod_{i \not \in S} \mathfrak p_i$. Note that $J$ is not contained in $\mathfrak p_s$ for $s \in S$ because there are no inclusions among the $\mathfrak p_i$ and because $I$ is not contained in any $\mathfrak p_i$. Hence we can choose $g \in J$, $g \not \in \mathfrak p_s$ for $s \in S$ by Algebra, Lemma \ref{algebra-lemma-silly}. Then $f + g$ is a solution to the problem posed by the lemma.
Using Limits, Proposition \ref{limits-proposition-affine} there is an immediate reduction to the case where $X$ is reduced. Details omitted. In the rest of the proof we endow every closed subset of $X$ with the induced reduced closed subscheme structure. \medskip\noindent We argue by induction that we can find an affine open $U \subset Z_1 \cup \ldots \cup Z_r$ containing $T \cap (Z_1 \cup \ldots \cup Z_r)$. For $r = 1$ this holds by assumption. Say $r > 1$ and let $U \subset Z_1 \cup \ldots \cup Z_{r -  1}$ be an affine open containing $T \cap (Z_1 \cup \ldots \cup Z_{r - 1})$. Let $V \subset X_r$ be an affine open containing $T \cap Z_r$ (exists by assumption). Then $U \cap V$ contains $T \cap ( Z_1 \cup \ldots \cup Z_{r - 1} ) \cap Z_r$. Hence $$ \Delta = (U \cap Z_r) \setminus (U \cap V) $$ does not contain any element of $T$. Note that $\Delta$ is a closed subset of $U$. By prime avoidance (Algebra, Lemma \ref{algebra-lemma-silly}), we can find a standard open $U'$ of $U$ containing $T \cap U$ and avoiding $\Delta$, i.e., $U' \cap Z_r \subset U \cap V$. After replacing $U$ by $U'$ we may assume that $U \cap V$ is closed in $U$. \medskip\noindent Using that by the same arguments as above also the set $\Delta' = (U \cap (Z_1 \cup \ldots \cup Z_{r - 1})) \setminus (U \cap V)$ does not contain any element of $T$ we find a $h \in \mathcal{O}(V)$ such that $D(h) \subset V$ contains $T \cap V$ and such that $U \cap D(h) \subset U \cap V$. Using that $U \cap V$ is closed in $U$ we can use Lemma \ref{lemma-extra-silly} to find an element $g \in \mathcal{O}(U)$ whose restriction to $U \cap V$ equals the restriction of $h$ to $U \cap V$ and such that $T \cap U \subset D(g)$. Then we can replace $U$ by $D(g)$ and $V$ by $D(h)$ to reach the situation where $U \cap V$ is closed in both $U$ and $V$. In this case the scheme $U \cup V$ is affine by Limits, Lemma \ref{limits-lemma-affines-glued-in-closed-affine}. This proves the induction step and thereby the lemma.
Namely, choose a specialization $x' \leadsto x$ with $x' \not = x$ (for example take $x'$ to be the generic point). By Schemes, Lemma \ref{schemes-lemma-points-specialize} there exists a morphism $a : \Spec(A) \to X$ where $A$ is a valuation ring with fraction field $K$ such that the generic point of $\Spec(A)$ maps to $x'$ and the closed point of $\Spec(A)$ maps to $x$. The morphism $\Spec(K) \to X \setminus \{x\}$ does not extend to a morphism $b : \Spec(A) \to X \setminus \{x\}$ since by the uniqueness in Schemes, Lemma \ref{schemes-lemma-separated-implies-valuative} we would have $a = b$ as morphisms into $X$ which is absurd. Hence the valuative criterion (Schemes, Proposition \ref{schemes-proposition-characterize-universally-closed}) shows that $X \setminus \{x\} \to \Spec(k)$ is not universally closed, hence not proper.
By Proposition \ref{proposition-dim-1-noetherian-separated-has-ample} the scheme $X$ has an ample invertible sheaf $\mathcal{L}$. By Morphisms, Lemma \ref{morphisms-lemma-quasi-projective-finite-type-over-S} we see that $X$ is isomorphic to a locally closed subscheme of $\mathbf{P}^n_k$ over $\Spec(k)$. This is the definition of being H-quasi-projective over $k$, see Morphisms, Definition \ref{morphisms-definition-quasi-projective}.
By Lemma \ref{lemma-dim-1-quasi-projective} we see that $X$ is a locally closed subscheme of $\mathbf{P}^n_k$ for some field $k$. Since $X$ is proper over $k$ it follows that $X$ is a closed subscheme of $\mathbf{P}^n_k$ (Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}).
By Lemma \ref{lemma-dim-1-quasi-projective} we may assume $X$ is a locally closed subscheme of $\mathbf{P}^d_k$ for some $d$. Let $\overline{X} \subset \mathbf{P}^d_k$ be the scheme theoretic image of $X \to \mathbf{P}^d_k$, see Morphisms, Definition \ref{morphisms-definition-scheme-theoretic-image}. The description in Morphisms, Lemma \ref{morphisms-lemma-quasi-compact-immersion} gives properties (1) and (2). Then $\dim(X) = 1 \Rightarrow \dim(\overline{X}) = 1$ for example by looking at generic points, see Lemma \ref{lemma-dimension-locally-algebraic}. As $\overline{X}$ is Noetherian, it then follows that $\overline{X} \setminus X = \{x_1, \ldots, x_n\}$ is a finite set of closed points.