TITLE: The Gauss-Bonnet theorem for Sheaves
QUESTION [5 upvotes]: Euler Characteristic of Sheaves and the Generalized Gauss-Bonnet Theorem
Consider a sheaf $\mathscr{F}$ over a site $\mathscr{(C,J)}$, where $\mathscr{C}$ is a small category with a coverage $\mathscr{J}$. The Euler characteristic is defined as $\chi(\mathscr{F})=\sum_{i\in\mathbf{Z}_0^+}(-1)^i\dim_\mathbb F(H^i(\mathscr{C},\mathscr{F}))$.
The Euler characteristic satisfies, on a compact orientable $2n$-dimensional Riemannian manifold without boundary, the generalized Gauss-Bonnet theorem:
$$\int_M \mathrm{Pf}(\Omega)=(2\pi)^n\chi(M), \, $$
Here $\Omega$ is the curvature form of the Levi-Civita connection and the Pfaffian of $\Omega$ is $\mathrm{Pf}(\Omega)$.
The Question

Is there an analog of the Gauss-Bonnet theorem in algebraic geometry? Specifically, is it possible to define the "curvature form $\mathscr{O}$ of a (Levi-Civita) connection on the quasi-coherent sheaf $\mathscr{F}$ over the site $\mathscr{(C,J)}$ (this book, perhaps?)" and the "sheaf Pfaffian $\mathscr{Pf}$" to obtain something like the Gauss-Bonnet, e.g. $\int_\mathscr{F} \mathscr{Pf}(\mathscr{O})=(2\pi)^{\dim\mathscr{F}}\dim_\mathbb FH^0(\mathscr{C},\mathscr{F})$, with $\dim\mathscr{F}$ the (pure) dimension of $\mathscr{F}$? (What is the "integral" supposed to be?)

Thoughts
Note 1: As for what the integration might be, this answer, which links to this paper (I believe Theorem 3.2 of that paper) provides a possible answer. However, I'm not sure if that's the "integration" wanted in the conjectured Gauss-Bonnet for sheaves.
Note 2: For constructible sheaves on reductive groups, I found the following paper by V. Kiritchenko. I am interested in a generalization of this to sheaves over sites.

REPLY [9 votes]: There is an answer in the case of constructible sheaves. The whole story can be found in Kashiwara and Shapira's book "Sheaves on Manifolds" Chapters VIII and IX.
I will try to summarize this rather  long story.     First, a prototype for a constructible sheaf is a locally constant sheaf supported on a reasonable set, e.g., semialgebraic, or subanalytic subset of some  Euclidean space  $\newcommand{\bR}{\mathbb{R}}$ $\bR^n$.  For example the  constant sheaf with stalk $\bR$ defined on a compact  reasonable set is constructible. The Euler characteristic  of the cohomology of this sheaf is the Euler characteristic of that set.
In general, a constructible sheaf is really a complex of sheaves  whose  associated   cohomology sheaves are locally constant.
We  can form a $K$-theoretic group $K(\bR^n)$out of these   constructible sheaves   very much the way Grothendieck for coherent sheaves on algebraic manifolds. If $A, B,C$ are  constructible complexes of sheaves, then we have a $K$-theoretic equality  $B=A+C$  if   there exists a short exact  sequence  of complexes $0\to A\to B\to C\to 0$  (It is a bit more complicated than this but I want to avoid talking about triangulated categories.) The Euler characteristic of the (hyper)cohomology of a complex $A$ induces  a group morphism
$$\chi: K(\bR^n)\to \mathbb{Z}.$$ 
Kashiwara and Schapira have shown that the Abelian group  $K(\bR^n)$  is isomorphic to two groups that have simpler descriptions.
The first group is the group $\newcommand{\eC}{\mathscr{C}}$ $\eC(\bR^n)$ of constructible  functions. These  are functions $f:\bR^n\to \mathbb{Z}$ with finite range such that, for any $t\in\bR$ $f^{-1}(t)$ is a subanalytic set.    We obtain  an Euler characteristic morphism
$$\chi:\eC(\bR^n)\to\mathbb{Z}, $$
defined by
$$\chi (f) =\sum_{n\in\mathbb{Z}} n \chi\bigl(\;f^{-1}(n)\;\bigr). $$
The  second group is the group $\newcommand{\eL}{\mathscr{L}}$ $\eL(\bR^n)$ of  conical lagrangian cycles in $T^*\bR^n$.  These are cycles supported by   lagrangian  varieties in $T^*\bR^n$ which  are invariant under  the rescaling along the fibers of the cotangent bundle.
Joseph  Fu  has      given a very nice  geometric description of an isomorphism   $\eC(\bR^n)\to \eL(\bR^n)$. This isomorphism associates  to each constructible $f$ function a lagrangian cycle called the conormal cycle $C^f$  of   the constructible function $f$. For example, if  $f$ is the indicator function  of a compact, subanalytic submanifold $S\subset \bR^n$, then $C^f$  is the Lagrangian cycle  defined by the conormal bundle of $S$ which is a subbundle of $T^*\bR^n|_S$.
The normal cycle $N^f$ of a constructible  function $f$ is obtained by intersecting the conormal cycle $C^f$ with the unit sphere bundle of $T^*\bR^n$. Thus,  if  $f$ is the indicator function  of a compact, subanalytic submanifold $S\subset \bR^n$, then the normal cycle $N^f=N^S$ can be identified with the unit normal sphere bundle of the submanifold $S$. If $f$ is the characteristic function of a  compact domain $D$ with smooth boundary $\newcommand{\pa}{\partial}$ $\pa D$ then  the normal cycle is the graph of the  Gauss map
$$ n:\pa D \to S^{n-1}\subset \bR^n,\;\;p\mapsto n(p), $$
where $n(p)$ denotes the outer unit normal vector to $\pa D$ at $p$.$\newcommand{\bZ}{\mathbb{Z}}$
The Euler characteristic morphism $\chi: \eL(\bR^n)\to\bZ$  was given an explicit description by Fu.  More precisely there exists a universal form of degree $n-1$, $\omega\in \Omega^{n-1}(S^{n-1}\times \bR^n)$ such that, for any constructible function $f$, its Euler characteristic $\chi(f)$ is equal to the integral  of $\omega$ over  the normal cycle  $N^f$ which is naturally a   cycle in $S^{n-1}\times \bR^n$.  When $f$  is the indicator function of a submanifold, the above result is   none other that the usual Gauss-Bonnet.  When  $f$ is the indicator function of a compact  affine simplicial complex in $\bR^n$,  Fu's result   leads to the computation of the Euler characteristic of the complex   as an integral of a so called curvature measure.   You can learn more about  this at Fu's homepage.