[proofplan]
The proof is a single application of the Riemann-Roch theorem to the canonical divisor itself. The key inputs are: (i) the Riemann-Roch identity $\ell(D) - \ell(K_C - D) = \deg D - g + 1$; (ii) the genus is defined as $g = \ell(K_C)$, the dimension of the space of global regular differentials; (iii) the divisor $K_C - K_C = 0$ is the zero divisor, and $\ell(0) = 1$ because the only rational functions with no poles are the constants on a smooth projective curve over an algebraically closed field. Setting $D = K_C$ in Riemann-Roch and substituting these values yields a linear equation in $\deg K_C$ whose solution is $2g - 2$.
[/proofplan]
[step:Apply Riemann-Roch with $D = K_C$]
Apply the [Riemann-Roch Theorem](/theorems/2185) to the divisor $D := K_C$ on $C$. The theorem states that for any divisor $D \in \operatorname{Div}(C)$,
\begin{align*}
\ell(D) - \ell(K_C - D) = \deg D - g + 1,
\end{align*}
where $\ell(D) := \dim_k \mathcal{L}(D)$ and $K_C$ is a canonical divisor (any choice of canonical divisor gives the same identity, since the Riemann-Roch identity is preserved under linear equivalence of canonical divisors).
The hypotheses of Riemann-Roch — $C$ smooth projective irreducible curve over an algebraically closed field, $D \in \operatorname{Div}(C)$ — are met for $D = K_C$. Substituting $D = K_C$:
\begin{align*}
\ell(K_C) - \ell(K_C - K_C) = \deg K_C - g + 1.
\end{align*}
[/step]
[step:Evaluate $\ell(K_C) = g$ from the definition of the genus]
By definition, the genus $g$ of a smooth projective curve $C$ over an algebraically closed field is
\begin{align*}
g := \dim_k H^0(C, \Omega_C) = \dim_k \mathcal{L}(K_C) = \ell(K_C),
\end{align*}
where $H^0(C, \Omega_C)$ is the space of global regular differentials on $C$, and the second equality is the canonical identification $H^0(C, \Omega_C) \cong \mathcal{L}(K_C)$ given by the map $\omega \mapsto \omega/\omega_0$, where $\omega_0$ is a fixed nonzero rational differential representing $K_C = \operatorname{div}(\omega_0)$. Under this map, a regular differential $\omega \in H^0(C, \Omega_C)$ corresponds to the rational function $f := \omega/\omega_0 \in K(C)$, and the regularity condition $\operatorname{div}(\omega) \geq 0$ translates to $\operatorname{div}(f) + K_C = \operatorname{div}(\omega) \geq 0$, i.e., $f \in \mathcal{L}(K_C)$.
Hence $\ell(K_C) = g$.
[/step]
[step:Evaluate $\ell(0) = 1$ from the structure of regular functions on a projective curve]
The divisor $K_C - K_C$ is the zero divisor in $\operatorname{Div}(C)$:
\begin{align*}
K_C - K_C = \sum_{p \in C} 0 \cdot [p] = 0.
\end{align*}
We compute $\ell(0) = \dim_k \mathcal{L}(0)$ where
\begin{align*}
\mathcal{L}(0) = \{ f \in K(C)^\times : \operatorname{div}(f) \geq 0 \} \cup \{0\}.
\end{align*}
The condition $\operatorname{div}(f) \geq 0$ for $f \neq 0$ means $\operatorname{ord}_p(f) \geq 0$ for every closed point $p \in C$, i.e., $f$ is regular at every point of $C$. Equivalently, $f$ is a global section of the structure sheaf $\mathcal{O}_C$:
\begin{align*}
\mathcal{L}(0) = H^0(C, \mathcal{O}_C).
\end{align*}
For a smooth projective irreducible curve $C$ over an algebraically closed field $k$, the global sections of the structure sheaf are exactly the constants:
\begin{align*}
H^0(C, \mathcal{O}_C) = k.
\end{align*}
This holds because (i) every constant $c \in k$ defines a global regular function on $C$, giving $k \subseteq H^0(C, \mathcal{O}_C)$; and (ii) any $f \in H^0(C, \mathcal{O}_C)$ with $f \notin k$ would be a nonconstant regular morphism $f: C \to \mathbb{A}^1_k \subset \mathbb{P}^1_k$, hence (by [Rational Maps from Smooth Curves Are Morphisms](/theorems/2172) extended to a morphism $\bar{f}: C \to \mathbb{P}^1_k$) a nonconstant morphism from a projective curve to $\mathbb{P}^1_k$. Such a morphism is surjective onto $\mathbb{P}^1_k$ (its image is closed and irreducible of dimension $\geq 1$, hence equals $\mathbb{P}^1_k$). But surjectivity forces $f$ to take the value $\infty$ at some point, contradicting $f \in H^0(C, \mathcal{O}_C) \subset H^0(C, \mathcal{O}_{\mathbb{A}^1})$ being a global regular function (i.e., $f$ never takes the value $\infty$). Hence $f$ must be constant, $f \in k$.
(Alternatively: a nonconstant regular function $f$ on the projective curve $C$ would attain a maximum on the compact curve, contradicting $f$ being a non-constant holomorphic function — over $\mathbb{C}$ this is the classical maximum principle, and over a general algebraically closed field the analogous algebraic statement holds.)
Therefore $\ell(0) = \dim_k H^0(C, \mathcal{O}_C) = \dim_k k = 1$.
[guided]
We need $\ell(0) = 1$. The set $\mathcal{L}(0)$ consists of rational functions on $C$ with no poles at any closed point — i.e., functions regular on all of $C$. We claim these are exactly the constants.
\textbf{Why constants are in $\mathcal{L}(0)$.} Any $c \in k$ defines a constant function $c: C \to k$, which is regular everywhere (the principal divisor is $\operatorname{div}(c) = 0$ for $c \neq 0$, satisfying $\operatorname{div}(c) \geq 0$).
\textbf{Why nothing else is in $\mathcal{L}(0)$.} Suppose $f \in \mathcal{L}(0)$, $f \neq 0$. Then $f \in K(C)^\times$ is a global regular function on the smooth projective curve $C$. Consider its principal divisor $\operatorname{div}(f) \geq 0$. By [Principal Divisors Have Degree Zero](/theorems/2177), $\deg \operatorname{div}(f) = 0$. Combined with $\operatorname{div}(f) \geq 0$ (each coefficient non-negative), the only way the sum of non-negative coefficients can equal zero is if all coefficients are zero: $\operatorname{div}(f) = 0$. So $f$ has no zeros and no poles.
A regular function on a smooth projective curve over an algebraically closed field, with no zeros, must be a constant. Why? Consider $f - c$ for any $c \in k$. This is also a regular function on $C$. If $f$ is nonconstant, then $f$ takes infinitely many values (or at least more than one value), so for some $c \in k$, $f - c$ has a zero — but $f - c$ is regular (no poles), and by the same degree argument, if $f - c$ has a zero it has degree $\geq 1$ at that zero, summing to $\geq 1$. Yet $\operatorname{div}(f - c)$ has degree $0$. Contradiction. Hence $f$ takes a single value, i.e., $f \in k$.
(More directly: a nonconstant morphism $f: C \to \mathbb{P}^1_k$ from a smooth projective curve to $\mathbb{P}^1_k$ is surjective, so $f$ attains $\infty$ — but then $f$ has a pole, contradicting $f \in \mathcal{L}(0)$.)
\textbf{Conclusion.} $\mathcal{L}(0) = k$, so $\ell(0) = \dim_k k = 1$.
[/guided]
[/step]
[step:Solve for $\deg K_C$]
Substituting $\ell(K_C) = g$ (Step 2) and $\ell(K_C - K_C) = \ell(0) = 1$ (Step 3) into the Riemann-Roch identity from Step 1:
\begin{align*}
g - 1 = \deg K_C - g + 1.
\end{align*}
Solving for $\deg K_C$:
\begin{align*}
\deg K_C = 2g - 2.
\end{align*}
This completes the proof.
[/step]