Proof that for an effective divisor $l(D)\leq \deg D +1$ In one of my recent questions I got this answer: https://math.stackexchange.com/a/4348876/645867. In particular, it is said that "for an effective divisor $l(D)\leq \deg D +1$ and equality holds iff $D=0$ or $g=0$".
Where can I find a proof of this fact?
 A: First, observe that we have equality when $D=0$ or $g=0$: $h^0(X,\mathcal{O}_X)=1$ for any smooth projective curve, while $h^0(\Bbb P^1,\mathcal{O}_{\Bbb P^1}(D))= h^0(\Bbb P^1,\mathcal{O}_{\Bbb P^1}(\deg D))=\deg D+1$ for any effective divisor on $\Bbb P^1$.
Next, we'll reuse some material from the proof of the Riemann-Roch theorem.
We have for any divisor $D$ and any point $P$ on a curve $X$ an exact sequence of sheaves $$0\to \mathcal{O}_X(D)\to\mathcal{O}_X(D+P)\to k(P)\to 0.$$
Taking global sections, we get that either $l(D+P)=l(D)$ or $l(D+P)=l(D)+1$.
Now write $D=\sum_{i=1}^d P_i$, let $D_j=\sum_{i=1}^j P_i$ and consider the sequence $\{l(D_j)\}_{0\leq j \leq d}$: this is a sequence which starts with $1$ and increases by at most 1 each time the index does.
So $l(D)=l(D_d)\leq d+1$, with equality implying $l(D_1)=2$.
But $l(D_1)=2$ means that there's a nonconstant meromorphic function on $X$ with a single pole at $P_1$, which implies that $X$ has a degree-one map to $\Bbb P^1$, or that $X\cong \Bbb P^1$.
So $l(D)\leq \deg D+1$, with equality iff $D=0$ or $g=0$.
A: HINT:
You don't need much knowledge to prove it. Assume that we have $l(D) \ge \deg D +2$, and get a linear combination of rational function without poles and non-constant, contradiction.
A: You can start considering the short exact sequence
$0\to \mathcal{O_C(-D)}\to\mathcal{O_C}\to \mathcal{O_D}\to 0$ and then tensoring by $\mathcal{O(K_C)}$ since it is a free sheaf you get the short exact sequence,
$$0\to \mathcal{O_C(K_C-D)}\to\mathcal{O_C(K_C)}\to \mathcal{O_D(K_C)}\to 0, $$
Now, by taking cohomology we obtain that
$0\to H^0(C,\mathcal{K_C-D})\to H^0(C,\mathcal{K_C})$ is exact, so
$h^0(C,\mathcal{K_C-D})\leq h^0(C,\mathcal{K_C})=g(C). $
On the other hand, using Riemann-Roch theorem we know that
$$l(D)\leq deg(D)+1-g+l(K_C-D),$$
but $-g+l(K_C-D)$ is positive, then $l(D)\leq deg(D)+1$.
If $l(D)=deg(D)+1$, then $l(K_C-D)=g$, which is true if $D=0$ by definition of genus or if $D\neq 0$, the genus $g$ must be zero by the last inequalities. The converse is clear,  since $g=0$ implies that $C\cong \mathbb{P^1}$, and if $D=0$ it is trivial.
