  By a {\em Riemann function} we mean a function $f\colon{\mathbb
Z}^n\to{\mathbb Z}$ such that $f({\bf d})=f(d_1,\ldots,d_n)$ is equals $0$ for
${\rm deg}({\bf d})=d_1+\cdots+d_n$ sufficiently small, and equals
$d_1+\cdots+d_n+C$ for a constant, $C$ -- the {\em offset of $f$} -- for ${\rm
deg}({\bf d})$ sufficiently large. By adding $1$ to the Baker-Norine rank
function of a graph, one gets an equivalent Riemann function, and similarly for
related rank functions. For such an $f$, for any ${\bf K}\in{\mathbb Z}^n$
there is a unique Riemann function $f^\wedge_{\bf K}$ such that for all ${\bf
d}\in{\mathbb Z}^n$ we have $$ f({\bf d}) - f^\wedge_{\bf K}({\bf K}-{\bf d}) =
{\rm deg}({\bf d})+C $$ which we call a {\em generalized Riemann-Roch formula}.
We show that any such equation can be viewed as an Euler charactersitic
equation of sheaves of a particular simple type that we call {\em diagrams}.
  This article does not assume any prior knowledge of sheaf theory.
  To certain Riemann functions $f\colon{\mathbb Z}^2\to{\mathbb Z}$ there is a
simple family of diagrams $\{{\mathcal{M}}_{W,{\bf d}}\}_{{\bf d}\in{\mathbb
Z}^2}$ such that $f({\bf d})=b^0({\mathcal{M}}_{W,{\bf d}})$ and
$f^\wedge_{{\bf K}}({\bf K}-{\bf d})=b^1({\mathcal{M}}_{W,{\bf d}})$.
Furthermore we give a canonical isomorphism $$ H^1({\mathcal{M}}_{W,{\bf d}})^*
\to H^0({\mathcal{M}}_{W',{\bf K}-{\bf d}}) $$ where $W'$ is the weight of
$f^\wedge_{\bf K}$.
  General Riemann functions $f\colon{\mathbb Z}^2\to{\mathbb Z}$ are similarly
modeled with formal differences of diagrams. Riemann functions ${\mathbb
Z}^n\to{\mathbb Z}$ are modeled using their restrictions to two of their
variables. These constructions involve some ad hoc choices, although the
equivalence class of virtual diagram obtained is independent of the ad hoc
choices.
