# Exact sequence of four sheaves in Beauville: associated l.e.s.?

This question is about an exact sequence of four sheaves on a smooth projective surface $S$ over $k=\mathbb{C}$, to be found in Beauville: complex algebraic surfaces, theorem I.4, page 3 (second edition).

It comes down to this: Denote the exact sequence by $$0 \rightarrow A \rightarrow B \rightarrow C \rightarrow D \rightarrow 0$$ then Beauville concludes $$\chi(A)-\chi(B)+\chi(C)-\chi(D) = 0$$ where $\chi(A) = \sum(-1)^{i}h^i(S,A)$ where $S$ is the surface.

How does he come to this conclusion? Of course an exact sequence of three sheaves yields a l.e.s. in cohomology, from which a similar result follows, but how to proceed with four sheaves as above? It might be easy, but i know just the basics of sheaf cohomology.

(Also see Exact sequence in Beauville's "Complex Algebraic Surfaces" for an earlier question about the same sequence)

If necessary i can provide the exact sheaves used in the sequence, but i hope that there's a general solution. Also i have an exam coming up, so prefer to save time (btw this is not homework). The sequence is also to be found in the link i provided.

As usual, the trick is to break up an exact sequence into short exact sequences. First, consider a general short exact sequence of f.g. abelian groups $$0 \longrightarrow K \longrightarrow M \longrightarrow Q \longrightarrow 0$$ The rank–nullity theorem from linear algebra implies $$\operatorname{rank} K - \operatorname{rank} M + \operatorname{rank} Q = 0$$ and so by induction, if we have any long exact sequence of f.g. abelian groups $$0 \longrightarrow M^0 \longrightarrow M^1 \longrightarrow \cdots \longrightarrow M^r \longrightarrow 0$$ we must have $$\sum_{i=0}^{r} (-1)^i \operatorname{rank} M^r = 0$$ which is a baby version of the result you want.
Now, let $A^\bullet$ be a bounded-below cochain complex in an abelian category $\mathcal{A}$, and suppose $$A^{n-1} \longrightarrow A^n \longrightarrow A^{n+1}$$ is exact for every integer $n$; if we define $Z^n = \operatorname{ker}(A^n \to A^{n+1})$, that means we have a short exact sequence $$0 \longrightarrow Z^n \longrightarrow A^n \longrightarrow Z^{n+1} \longrightarrow 0$$ for each integer $n$. Now, suppose $H^\bullet : \mathcal{A} \to \textbf{Ab}$ is any cohomological $\delta$-functor (this just means we get long exact cohomology sequences); then we get an exact sequence $$\cdots \longrightarrow H^p (A^q) \longrightarrow H^p (Z^{q+1}) \longrightarrow H^{p+1} (Z^q) \longrightarrow H^{p+1} (A^q) \longrightarrow \cdots$$ for each natural number $p$ and each integer $q$. Let us write $h^p (M)$ for $\operatorname{rank} H^p(M)$. Assuming that all the sequences in question vanish in sufficiently high degree and all the groups are f.g., our previous calculation says $$\sum_p (-1)^p h^p(A^q) = \sum_p (-1)^p h^p (Z^{q+1}) + \sum_p (-1)^p h^p (Z^q)$$ and so $$\sum_{p, q} (-1)^{p+q} h^p (A^q) = \sum_{p, q} (-1)^{p+q+1} h^p (Z^q) + \sum_{p,q} (-1)^{p+q} h^p (Z^q) = 0$$ so if we define $\chi (A^q) = \sum_p (-1)^p h^p (A^q)$, it follows that $$\sum_{q} (-1)^q \chi (A^q) = 0$$ as required.