hcju/stacksqa huggingface dataset:
Observe that $n > 1$ for example by Lemma \ref{lemma-irreducible} and hence $n' \geq 1$. We check conditions (1) -- (5) of Definition \ref{definition-type} for $n', m'_i, a'_{ij}, w'_i, g'_i$. \medskip\noindent Condition (1) is immediate. \medskip\noindent Condition (2). Symmetry of $A' = (a'_{ij})$ is immediate and since $a_{nn} < 0$ by Lemma \ref{lemma-diagonal-negative} we see that $a'_{ij} \geq a_{ij} \geq 0$ if $i \not = j$. \medskip\noindent Condition (3). Suppose that $I \subset \{1, \ldots, n - 1\}$ such that $a'_{ii'} = 0$ for $i \in I$ and $i' \in \{1, \ldots, n - 1\} \setminus I$. Then we see that for each $i \in I$ and $i' \in I'$ we have $a_{in}a_{i'n} = 0$. Thus either $a_{in} = 0$ for all $i \in I$ and $I \subset \{1, \ldots, n\}$ is a contradiction for property (3) for $T$, or $a_{i'n} = 0$ for all $i' \in \{1, \ldots, n - 1\} \setminus I$ and $I \cup \{n\} \subset \{1, \ldots, n\}$ is a contradiction for property (3) of $T$. Hence (3) holds for $T'$. \medskip\noindent Condition (4). We compute $$ \sum\nolimits_{j = 1}^{n - 1} a'_{ij}m_j = \sum\nolimits_{j = 1}^{n - 1} (a_{ij}m_j - \frac{a_{in}a_{jn}m_j}{a_{nn}}) = - a_{in}m_n - \frac{a_{in}}{a_{nn}}(-a_{nn}m_n) = 0 $$ as desired. \medskip\noindent Condition (5). We have to show that $w'_i$ divides $a_{in}a_{jn}/a_{nn}$. This is clear because $a_{nn} = -w_n$ and $w_n | a_{jn}$ and $w_i | a_{in}$. \medskip\noindent To show that $g = g'$ we first write \begin{align*} g & = 1 + \sum\nolimits_{i = 1}^n m_i(w_i(g_i - 1) - \frac{1}{2}a_{ii}) \\ & = 1 + \sum\nolimits_{i = 1}^{n - 1} m_i(w_i(g_i - 1) - \frac{1}{2}a_{ii}) -\frac{1}{2}m_nw_n \\ & = 1 +  \sum\nolimits_{i = 1}^{n - 1} m_i(w_i(g_i - 1) - \frac{1}{2}a_{ii} - \frac{1}{2}a_{in}) \end{align*} Comparing with the expression for $g'$ we see that it suffices if $$ w'_i(g'_i - 1) - \frac{1}{2}a'_{ii} = w_i(g_i - 1) - \frac{1}{2}a_{in} - \frac{1}{2}a_{ii} $$ for $i \leq n - 1$. In other words, we have $$ g'_i = \frac{2w_i(g_i - 1) - a_{in} - a_{ii} + a'_{ii} + 2w'_i}{2w'_i} = \frac{w_i}{w'_i}(g_i - 1) + 1 + \frac{a_{in}^2 - w_na_{in}}{2w'_iw_n} $$ It is elementary to check that this is an integer $\geq 0$ if we choose $w'_i$ as in (4).
If $n = 1$, then $A = (a_{ij})$ is the zero matrix and the result is clear. For $n > 1$ the matrix $A$ has rank $n - 1$ by either Lemma \ref{lemma-recurring-real} or Lemma \ref{lemma-recurring-symmetric-real}. Of course the rank is not affected by scaling the rows by $1/w_i$. This proves the lemma.
By induction on $n$. If $n = 1$, then the assertion is clear. If $n > 1$, then $T$ is not minimal by Lemma \ref{lemma-non-irreducible-minimal-type-genus-at-least-one}. After replacing $T$ by an equivalent type we may assume $n$ is a $(-1)$-index. By Lemma \ref{lemma-contract-picard-group} we find $\Pic(T) \subset \Pic(T')$. By Lemma \ref{lemma-contract} we see that the genus of $T'$ is equal to the genus of $T$ and we conclude by induction.
Recall that $g = 1 + \sum m_j(w_j(g_j - 1) - \frac{1}{2} a_{jj})$. For $j \in J$ the contribution $m_j(w_j(g_j - 1) - \frac{1}{2} a_{jj})$ to the genus $g$ is $> 0$ and hence $\geq 1/2$. This uses Lemma \ref{lemma-minus-one}, Definition \ref{definition-type-minus-one}, Definition \ref{definition-type-minimal}, Lemma \ref{lemma-minus-two}, and Definition \ref{definition-type-minus-two}; we will use these results without further mention in the following. Thus $J$ has at most $2(g - 1)$ elements. This proves (1). \medskip\noindent Recall that $-a_{ii} > 0$ for all $i$ by Lemma \ref{lemma-diagonal-negative}. Hence for $j \in J$ the contribution $m_j(w_j(g_j - 1) - \frac{1}{2} a_{jj})$ to the genus $g$ is $> m_jw_j(g_j - 1)$. Thus $$ g - 1 > m_jw_j(g_j - 1) \Rightarrow g_j < (g - 1)/m_jw_j + 1 $$ This indeed implies $g_j < g$ which proves (2). \medskip\noindent For $j \in J$ if $g_j > 0$, then the contribution $m_j(w_j(g_j - 1) - \frac{1}{2} a_{jj})$ to the genus $g$ is $\geq -\frac{1}{2}m_ja_{jj}$ and we immediately conclude that $m_j|a_{jj}| \leq 2(g - 1)$. Otherwise $a_{jj} = -kw_j$ for some integer $k \geq 3$ (because $j \in J$) and we get $$ m_jw_j(-1 + \frac{k}{2}) \leq g - 1 \Rightarrow m_jw_j \leq \frac{2(g - 1)}{k - 2} $$ Plugging this back into $a_{jj} = -km_jw_j$ we obtain $$ m_j|a_{jj}| \leq 2(g - 1) \frac{k}{k - 2} \leq 6(g - 1) $$ This proves (3). \medskip\noindent Part (4) follows from Lemma \ref{lemma-bound-neighbours} and (3).
Using Morphisms, Lemma \ref{morphisms-lemma-quasi-compact-scheme-theoretic-image} and Example \ref{morphisms-example-scheme-theoretic-image} this boils down to the following algebra statement. Let $A_1$ be a finite type $R$-algebra flat over $R$. Let $A_1 \otimes_R K \to B_2$ be a surjection. Then $A_2 = A_1 / \Ker(A_1 \to B_2)$ is a finite type $R$-algebra flat over $R$ such that $B_2 = A_2 \otimes_R K$. We omit the detailed proof; use More on Algebra, Lemma \ref{more-algebra-lemma-dedekind-torsion-free-flat} to prove that $A_2$ is flat.
Observe that $R^\wedge$ is a discrete valuation ring (More on Algebra, Lemma \ref{more-algebra-lemma-completion-dvr}). Set $Y = X \times_{\Spec(R)} \Spec(R^\wedge)$. Since $R^\wedge$ is a discrete valuation ring, we see that $$ Y \setminus Y_k = Y \times_{\Spec(R^\wedge)} \Spec(K^\wedge) = V \times_{\Spec(K)} \Spec(K^\wedge) $$ where $K^\wedge$ is the fraction field of $R^\wedge$. Since $V$ is geometrically normal, we find that this is a normal scheme. Hence the first part of the lemma follows from Resolution of Surfaces, Lemma \ref{resolve-lemma-normalization-completion}. \medskip\noindent To prove the second part we may assume $X$ and $Y$ are normal (by the first part). If $x$ is in the generic fibre, then $\mathcal{O}_{X, x} = \mathcal{O}_{V, x}$ is a normal local ring essentially of finite type over a field. Such a ring is excellent (More on Algebra, Proposition \ref{more-algebra-proposition-ubiquity-excellent}). If $x$ is a point of the special fibre with image $y \in Y$, then $\mathcal{O}_{X, x}^\wedge = \mathcal{O}_{Y, y}^\wedge$ by Resolution of Surfaces, Lemma \ref{resolve-lemma-iso-completions}. In this case $\mathcal{O}_{Y, y}$ is a excellent normal local domain by the same reference as before as $R^\wedge$ is excellent. If $B$ is a excellent local normal domain, then the completion $B^\wedge$ is normal (as $B \to B^\wedge$ is regular and More on Algebra, Lemma \ref{more-algebra-lemma-normal-goes-up} applies). This finishes the proof.
We check condition (4) of Lipman's theorem (Resolution of Surfaces, Theorem \ref{resolve-theorem-resolve}) hold. This is clear from Lemma \ref{lemma-normalization} except for the statement that $X^\nu$ has finitely many singular points. To see this we can use that $R$ is J-2 by More on Algebra, Proposition \ref{more-algebra-proposition-ubiquity-J-2} and hence the nonsingular locus is open in $X^\nu$. Since $X^\nu$ is normal of dimension $\leq 2$, the singular points are closed, hence closedness of the singular locus means there are finitely many of them (as $X$ is quasi-compact). Observe that any resolution of $X$ is a modification of $X$ (Resolution of Surfaces, Definition \ref{resolve-definition-resolution}). This will be an isomorphism over the normal locus of $X$ by Varieties, Lemma \ref{varieties-lemma-modification-normal-iso-over-codimension-1}. Since the set of normal points includes $C = X_K$ we conclude any resolution is a model of $C$.
By Resolution of Surfaces, Lemma \ref{resolve-lemma-regular-dim-2-projective} we see that $X$ is projective over $R$. Hence $X$ has an ample invertible sheaf by More on Morphisms, Lemma \ref{more-morphisms-lemma-projective} (we will use this below). Let $E \subset X$ be an exceptional curve of the first kind. See Resolution of Surfaces, Section \ref{resolve-section-minus-one}. By Resolution of Surfaces, Lemma \ref{resolve-lemma-contract-ample} we can contract $E$ by a morphism $X \to X'$ such that $X'$ is regular and is projective over $R$. Clearly, the number of irreducible components of $X'_k$ is exactly one less than the number of irreducible components of $X_k$. Thus we can only perform a finite number of these contractions until we obtain a minimal model.
Recall that $R$ is a discrete valuation ring with uniformizer $\pi$ and residue field $k = R/(\pi)$. Because $X \to \Spec(R)$ is flat, the element $\pi$ is a nonzerodivisor affine locally on $X$ (see More on Algebra, Lemma \ref{more-algebra-lemma-dedekind-torsion-free-flat}). Thus if $U = \Spec(A) \subset X$ is an affine open, then $$ X_K \cap U = U_k = \Spec(A \otimes_R k) = \Spec(A/\pi A) $$ and $\pi$ is a nonzerodivisor in $A$. Hence $X_k = V(\pi)$ is an effective Cartier divisor by Divisors, Lemma \ref{divisors-lemma-characterize-effective-Cartier-divisor}. Hence (1) is true. \medskip\noindent The discussion above shows that the pair $(\mathcal{O}_X(X_k), 1)$ is isomorphic to the pair $(\mathcal{O}_X, \pi)$ which proves (4). \medskip\noindent By Divisors, Lemma \ref{divisors-lemma-effective-Cartier-divisor-is-a-sum} there exist pairwise distinct integral effective Cartier divisors $D_i \subset X$ and integers $a_i \geq 0$ such that $X_k = \sum a_i D_i$. We can throw out those divisors $D_i$ such that $a_i = 0$. Then it is clear (from the definition of addition of effective Cartier divisors) that $X_k = \bigcup D_i$ set theoretically. Thus $C_i = D_i$ are the irreducible components of $X_k$ which proves (2). Let $\xi_i$ be the generic point of $C_i$. Then $\mathcal{O}_{X, \xi_i}$ is a discrete valuation ring (Divisors, Lemma \ref{divisors-lemma-integral-effective-Cartier-divisor-dvr}). The uniformizer $\pi_i \in \mathcal{O}_{X, \xi_i}$ is a local equation for $C_i$ and the image of $\pi$ is a local equation for $X_k$. Since $X_k = \sum a_i C_i$ we see that $\pi$ and $\pi_i^{a_i}$ generate the same ideal in $\mathcal{O}_{X, \xi_i}$. On the other hand, the multiplicity of $C_i$ in $X_k$ is $$ m_i = \text{length}_{\mathcal{O}_{C_i, \xi_i}} \mathcal{O}_{X_k, \xi_i} = \text{length}_{\mathcal{O}_{C_i, \xi_i}} \mathcal{O}_{X, \xi_i}/(\pi) = \text{length}_{\mathcal{O}_{C_i, \xi_i}} \mathcal{O}_{X, \xi_i}/(\pi_i^{a_i}) = a_i $$ See Chow Homology, Definition \ref{chow-definition-cycle-associated-to-closed-subscheme}. Thus $a_i = m_i$ and (3) is proved.
Since $X \to \Spec(R)$ is flat, to prove (1) it suffices to show that the fibres are Gorenstein (Duality for Schemes, Lemma \ref{duality-lemma-gorenstein-morphism}). The generic fibre is a smooth curve, which is regular and hence Gorenstein (Duality for Schemes, Lemma \ref{duality-lemma-regular-gorenstein}). For the special fibre $X_k$ we use that it is an effective Cartier divisor on a regular (hence Gorenstein) scheme and hence Gorenstein for example by Dualizing Complexes, Lemma \ref{dualizing-lemma-gorenstein-divide-by-nonzerodivisor}. The curves $C_i$ are Gorenstein by the same argument.
Observe that $C \subset X$ is an open subscheme. The restriction map $\Pic(X) \to \Pic(C)$ is surjective by Divisors, Lemma \ref{divisors-lemma-extend-invertible-module}. Let $\mathcal{L}$ be an invertible $\mathcal{O}_X$-module such that there is an isomorphism $s : \mathcal{O}_C \to \mathcal{L}|_C$. Then $s$ is a regular meromorphic section of $\mathcal{L}$ and we see that $\text{div}_\mathcal{L}(s) = \sum a_i C_i$ for some $a_i \in \mathbf{Z}$ (Divisors, Definition \ref{divisors-definition-divisor-invertible-sheaf}). By Divisors, Lemma \ref{divisors-lemma-normal-c1-injective} (and the fact that $X$ is normal) we conclude that $\mathcal{L} = \mathcal{O}_X(\sum a_iC_i)$. Finally, suppose that $\mathcal{O}_X(\sum a_i C_i) \cong \mathcal{O}_X$. Then there exists an element $g$ of the function field of $X$ with $\text{div}_X(g) = \sum a_i C_i$. In particular the rational function $g$ has no zeros or poles on the generic fibre $C$ of $X$. Since $C$ is a normal scheme this implies $g \in H^0(C, \mathcal{O}_C) = K$. Thus $g = \pi^a u$ for some $a \in \mathbf{Z}$ and $u \in R^*$. We conclude that $\text{div}_X(g) = a \sum m_i C_i$ and the proof is complete.
Bilinearity is immediate from the definition and Varieties, Lemma \ref{varieties-lemma-degree-tensor-product}. To prove symmetry it suffices to assume $a$ and $b$ are standard basis vectors in $\mathbf{Z}^{\oplus n}$. Hence it suffices to prove that $$ \deg(\mathcal{O}_X(C_j)|_{C_i}) = \deg(\mathcal{O}_X(C_i)|_{C_j}) $$ for all $1 \leq i, j \leq n$. If $i = j$ there is nothing to prove. If $i \not = j$, then the canonical section $1$ of $\mathcal{O}_X(C_j)$ restricts to a nonzero (hence regular) section of $\mathcal{O}_X(C_j)|_{C_i}$ whose zero scheme is exactly $C_i \cap C_j$ (scheme theoretic intersection). In other words, $C_i \cap C_j$ is an effective Cartier divisor on $C_i$ and $$ \deg(\mathcal{O}_X(C_j)|_{C_i}) = \deg(C_i \cap C_j) $$ by Varieties, Lemma \ref{varieties-lemma-degree-effective-Cartier-divisor}. By symmetry we obtain the same (!) formula for the other side and the proof is complete.
In the proof of Lemma \ref{lemma-intersection-pairing} we saw that $(C_i \cdot C_j) = \deg(C_i \cap C_j)$ if $i \not = j$. This is $\geq 0$ and $> 0 $ if and only if $C_i \cap C_j \not = \emptyset$. This proves (1). \medskip\noindent Proof of (2). This is true because by Lemma \ref{lemma-divisor-special-fiber} the invertible sheaf associated to $\sum m_i C_i$ is trivial and the trivial sheaf has degree zero. \medskip\noindent Proof of (3). This is expressing the fact that $X_k$ is connected (Lemma \ref{lemma-regular-model-connected}) via the description of the intersection products given in the proof of (1). \medskip\noindent Part (4) follows from (1), (2), and (3) by Lemma \ref{lemma-recurring-symmetric-real}.
We have $$ \mathcal{O}_X(D)^{\otimes d} = \mathcal{O}_X(dD) = \mathcal{O}_X(X_k) = \mathcal{O}_X $$ by Lemma \ref{lemma-divisor-special-fiber}. We conclude as $\mathcal{C}_{D/X}$ is the pullback of $\mathcal{O}_X(-D)$.
The reduction $D_{red} = (X_k)_{red} = \sum C_i$ is connected (Lemma \ref{lemma-regular-model-connected}) and proper over $k$. Hence $H^0(D_{red}, \mathcal{O})$ is a field and a finite extension of $k$ by Varieties, Lemma \ref{varieties-lemma-proper-geometrically-reduced-global-sections}. Thus the result for $Z_0 = D_{red} = (X_k)_{red}$ is true. Suppose that we have already constructed $$ (X_k)_{red} = Z_0 \subset Z_1 \subset \ldots \subset Z_t \subset D $$ with $Z_j = Z_{j - 1} + C_{i_j}$ for some $i_j \in \{1, \ldots, n\}$ for $j = 1, \ldots, t$ and such that $H^0(Z_j, \mathcal{O}_{Z_j})$ is a field finite over $k$ for $j = 0, \ldots, t$. Write $Z_t = \sum a_i C_i$ with $1 \leq a_i \leq m_i/d$. If $a_i = m_i/d$ for all $i$, then $Z_t = D$ and the lemma is proved. If not, then $a_i < m_i/d$ for some $i$ and it follows that $(Z_t \cdot Z_t) < 0$ by Lemma \ref{lemma-properties-form}. This means that $(D - Z_t \cdot Z_t) > 0$ because $(D \cdot Z_t) = 0$ by the lemma. Thus we can find an $i$ with $a_i < m_i/d$ such that $(C_i \cdot Z_t) > 0$. Set $Z_{t + 1} = Z_t + C_i$ and $i_{t + 1} = i$. Consider the short exact sequence $$ 0 \to \mathcal{O}_X(-Z_t)|_{C_i} \to \mathcal{O}_{Z_{t + 1}} \to \mathcal{O}_{Z_t} \to 0 $$ of Divisors, Lemma \ref{divisors-lemma-ses-add-divisor}. By our choice of $i$ we see that $\mathcal{O}_X(-Z_t)|_{C_i}$ is an invertible sheaf of negative degree on the proper curve $C_i$, hence it has no nonzero global sections (Varieties, Lemma \ref{varieties-lemma-check-invertible-sheaf-trivial}). We conclude that $H^0(\mathcal{O}_{Z_{t + 1}}) \subset H^0(\mathcal{O}_{Z_t})$ is a field (this is clear but also follows from Algebra, Lemma \ref{algebra-lemma-integral-under-field}) and a finite extension of $k$. Thus we have extended the sequence. Since the process must stop, for example because $t \leq \sum (m_i/d - 1)$, this finishes the proof.
By Lemma \ref{lemma-regular-model-field} we see that $\kappa$ is a field and a finite extension of $k$. Since also $H^0(C, \mathcal{O}_C) = K$ we see that the genus of $C$ and $D$ are defined (see Algebraic Curves, Definition \ref{curves-definition-genus}) and we have $g_C = \dim_K H^1(C, \mathcal{O}_C)$ and $g_D = \dim_\kappa H^1(D, \mathcal{O}_D)$. By Derived Categories of Schemes, Lemma \ref{perfect-lemma-chi-locally-constant-geometric} we have $$ 1 - g_C = \chi(C, \mathcal{O}_C) = \chi(X_k, \mathcal{O}_{X_k}) = \dim_k H^0(X_k, \mathcal{O}_{X_k}) - \dim_k H^1(X_k, \mathcal{O}_{X_k}) $$ We claim that $$ \chi(X_k, \mathcal{O}_{X_k}) = d \chi(D, \mathcal{O}_D) $$ This will prove the lemma because $$ \chi(D, \mathcal{O}_D) = \dim_k H^0(D, \mathcal{O}_D) - \dim_k H^1(D, \mathcal{O}_D) = [\kappa : k](1 - g_D) $$ Observe that $X_k = dD$ as an effective Cartier divisor. To prove the claim we prove by induction on $1 \leq r \leq d$ that $\chi(rD, \mathcal{O}_{rD}) = r \chi(D, \mathcal{O}_D)$. The base case $r = 1$ is trivial. If $1 \leq r < d$, then we consider the short exact sequence $$ 0 \to \mathcal{O}_X(rD)|_D \to \mathcal{O}_{(r + 1)D} \to \mathcal{O}_{rD} \to 0 $$ of Divisors, Lemma \ref{divisors-lemma-ses-add-divisor}. By additivity of Euler characteristics (Varieties, Lemma \ref{varieties-lemma-euler-characteristic-additive}) it suffices to prove that $\chi(D, \mathcal{O}_X(rD)|_D) = \chi(D, \mathcal{O}_D)$. This is true because $\mathcal{O}_X(rD)|_D$ is a torsion element of $\Pic(D)$ (Lemma \ref{lemma-multiple-fibre-normal-bundle}) and because the degree of a line bundle is additive (Varieties, Lemma \ref{varieties-lemma-degree-tensor-product}) hence zero for torsion invertible sheaves.
Choose isomorphisms $C_i = \mathbf{P}^1_{\kappa_i}$ and $C_j = \mathbf{P}^1_{\kappa_j}$. The scheme $C_i \cap C_j$ is a nonempty effective Cartier divisor in both $C_i$ and $C_j$. Hence $$ (C_i \cdot C_j) = \deg(C_i \cap C_j) \geq \max([\kappa_i: k], [\kappa_j : k]) $$ The first equality was shown in the proof of Lemma \ref{lemma-intersection-pairing}. On the other hand, the self intersection $(C_i \cdot C_i)$ is equal to the degree of $\mathcal{O}_X(C_i)$ on $C_i$ which is $-[\kappa_i : k]$ as $C_i$ is an exceptional curve of the first kind. Similarly for $C_j$. By Lemma \ref{lemma-properties-form} $$ 0 \geq (C_i + C_j)^2 = -[\kappa_i : k] + 2(C_i \cdot C_j) - [\kappa_j : k] $$ This implies that $[\kappa_i : k] = \deg(C_i \cap C_j) = [\kappa_j : k]$ and that we have $(C_i + C_j)^2 = 0$. Looking at the lemma again we conclude that $n = 2$, $\{1, 2\} = \{i, j\}$, and $m_1 = m_2$. Moreover, the scheme theoretic intersection $C_i \cap C_j$ consists of a single point $p$ with residue field $\kappa$ and $\kappa_i \to \kappa \leftarrow \kappa_j$ are isomorphisms. Let $D = C_1 + C_2$ as effective Cartier divisor on $X$. Observe that $D$ is the scheme theoretic union of $C_1$ and $C_2$ (Divisors, Lemma \ref{divisors-lemma-sum-effective-Cartier-divisors-union}) hence we have a short exact sequence $$ 0 \to \mathcal{O}_D \to \mathcal{O}_{C_1} \oplus \mathcal{O}_{C_2} \to \mathcal{O}_p \to 0 $$ by Morphisms, Lemma \ref{morphisms-lemma-scheme-theoretic-union}. Since we know the cohomology of $C_i \cong \mathbf{P}^1_\kappa$ (Cohomology of Schemes, Lemma \ref{coherent-lemma-cohomology-projective-space-over-ring}) we conclude from the long exact cohomology sequence that $H^0(D, \mathcal{O}_D) = \kappa$ and $H^1(D, \mathcal{O}_D) = 0$. By Lemma \ref{lemma-regular-model-genus} we conclude $$ 1 - g_C = d[\kappa : k](1 - 0) $$ where $d = m_1 = m_2$. It follows that $g_C = 0$ and $d = m_1 = m_2 = 1$ and $\kappa = k$.
We have already proven the hard part of the lemma which is the existence of a minimal model (whose proof relies on resolution of surface singularities), see Proposition \ref{proposition-exists-minimal-model}. To prove uniqueness, suppose that $X$ and $Y$ are two minimal models. By Resolution of Surfaces, Lemma \ref{resolve-lemma-birational-regular-surfaces} there exists a diagram of $S$-morphisms $$ X = X_0 \leftarrow X_1 \leftarrow \ldots \leftarrow X_n = Y_m \to \ldots \to Y_1 \to Y_0 = Y $$ where each morphism is a blowup in a closed point. The exceptional fibre of the morphism $X_n \to X_{n - 1}$ is an exceptional curve of the first kind $E$. We claim that $E$ is contracted to a point under the morphism $X_n = Y_m \to Y$. If this is true, then $X_n \to Y$ factors through $X_{n - 1}$ by Resolution of Surfaces, Lemma \ref{resolve-lemma-factor-through-contraction}. In this case the morphism $X_{n - 1} \to Y$ is still a sequence of contractions of exceptional curves by Resolution of Surfaces, Lemma \ref{resolve-lemma-proper-birational-regular-surfaces}. Hence by induction on $n$ we conclude. (The base case $n = 0$ means that there is a sequence of contractions $X = Y_m \to \ldots \to Y_1 \to Y_0 = Y$ ending with $Y$. However as $X$ is a minimal model it contains no exceptional curves of the first kind, hence $m = 0$ and $X = Y$.) \medskip\noindent Proof of the claim. We will show by induction on $m$ that any exceptional curve of the first kind $E \subset Y_m$ is mapped to a point by the morphism $Y_m \to Y$. If $m = 0$ this is clear because $Y$ is a minimal model. If $m > 0$, then either $Y_m \to Y_{m - 1}$ contracts $E$ (and we're done) or the exceptional fibre $E' \subset Y_m$ of $Y_m \to Y_{m - 1}$ is a second exceptional curve of the first kind. Since both $E$ and $E'$ are irreducible components of the special fibre and since $g_C > 0$ by assumption, we conclude that $E \cap E' = \emptyset$ by Lemma \ref{lemma-exceptional-curves-dont-meet}. Then the image of $E$ in $Y_{m - 1}$ is an exceptional curve of the first kind (this is clear because the morphism $Y_m \to Y_{m - 1}$ is an isomorphism in a neighbourhood of $E$). By induction we see that $Y_{m - 1} \to Y$ contracts this curve and the proof is complete.
The second equality follows from the definition of the bilinear form $(\ \cdot\ )$ in (\ref{equation-form}) and Lemma \ref{lemma-intersection-pairing}. To see the first equality we distinguish two cases. Namely, if $C_i \not \subset D$, then $D'$ is the scheme theoretic union of $D$ and $C_i$ (by Divisors, Lemma \ref{divisors-lemma-sum-effective-Cartier-divisors-union}) and we get a short exact sequence $$ 0 \to \mathcal{O}_{D'} \to \mathcal{O}_D \times \mathcal{O}_{C_i} \to \mathcal{O}_{D \cap C_i} \to 0 $$ by Morphisms, Lemma \ref{morphisms-lemma-scheme-theoretic-union}. Since we also have an exact sequence $$ 0 \to \mathcal{O}_X(-D)|_{C_i} \to \mathcal{O}_{C_i} \to \mathcal{O}_{D \cap C_i} \to 0 $$ (Divisors, Remark \ref{divisors-remark-ses-regular-section}) we conclude that the claim holds by additivity of euler characteristics (Varieties, Lemma \ref{varieties-lemma-euler-characteristic-additive}). On the other hand, if $C_i \subset D$ then we get an exact sequence $$ 0 \to \mathcal{O}_X(-D)|_{C_i} \to \mathcal{O}_{D'} \to \mathcal{O}_D \to 0 $$ by Divisors, Lemma \ref{divisors-lemma-ses-add-divisor} and we immediately see the lemma holds.