Riemann-Roch Theorem and Ideals of a Ring I found in some Math book a comment stating that the study of Ideals in ring theory à la Dedekind (all kinds of ideals? only one-sided ideals?) could be transferred to other areas (specifically, geometry and topology) via something the author referred to as Riemann-Roch Theorem. Could anyone explain a little bit about the theorem and about that alleged connection?
The comment goes as follows: 
"Hilbert then shows how one of Dedekind's notions of a prime factor or ideal (the different) corresponds to the Riemann-Roch theorem, a geometric and arithmetic fact concerning the topology of Riemann's surfaces"
 A: As suggested in the comments, I will try to write an answer (although I'm a little against this). 
First of all, I may accidentally forget to write the word "compact" in "compact Riemann surface". So I'm assuming that all Riemann surfaces are compact. Actually everything fails if it's not compact. For instance, the correspondence between curves and Riemann surfaces (that will be explained later) fails for the disk (actually, the disk is not even a complex affine curve).
Let $X$ be a Riemann surface. This means that $X$ is a complex manifold of dimension $1$. One can consider the field of meromorphic functions (or rational functions) on $X$, usually denoted by $\mathbb{C}(X)$,i.e, the field composed by the functions that have a power series expansion of the form $f(x) = \sum_{k = -n}^{\infty} c_k (x - p)^k$ around each point $p \in X$. 
It turns out that if $X$ is compact we can reconstruct $X$, by just using $\mathbb{C} (X)$. Actually given a finite extension $K/\mathbb{C}(x)$ (the field of rational polynomials), we can consider the set of valuations of $K$ that we will call $Y_{K}$ and put a topology on $Y$ minimal with the property that sets $V(f) = \{v \in Y; v(f)>0 \}$. Intuitively, this means that for each meromorphic function of an hypothetical space $Y$ we consider the zeroes of $f$ to be a closed set. 
For instance, if we let $K = \mathbb{C} (x) = \mathbb{C} (\mathbb{P}^1)$ (the meromorphic functions on the Riemann sphere), we get a point $v_p$ in $Y_{K}$ for each point of $\mathbb{P}^1$ together with a point  at infinity $v_{\infty}$ (the archimedean valuation). More precisely, $v_{p} (f) = -n$ if $f(x) = \sum_{k = -n}^m c_k (x - p)^k$ near the point $p$ and $v_{\infty} (f) = -deg(f)$. So, in this case, $v (f) > 0$ for $v= v_p, v_{\infty}$ precisely when $f$ is zero at the given point represented by the valuation. 
However, of course, the topology on $Y_{K}$ is coarser then the topology of $\mathbb{P}^1$. Nowadays, we now how to recover this topology entirely. This is done by using the GAGA correspond that will give as output the space $Y_{K}^{an}$ (the analytification of $Y_K$). Reciprocally, we can embed any Riemann surface $X$ in the projective space $\mathbb{P}^3(\mathbb{C})$ and use the Zariski topology to get back this coarse topology (defined early). So this is, in fact, a bijective correspondence. More precisely I'm saying that complex smooth projective curves are exactly Riemann surfaces. However, these smooth complex projective curves arises always as some $Y_K$ for some $K$ (as above). Hence we get the correspondence between compact Riemann surfaces and extensions of $\mathbb{C}(x)$.
Actually, given any two (complex) function fields $K$ and $L$ (i. e, finite extensions of $\mathbb{C}(x)$) together with maps $L \rightarrow K$ we get a ramified covering $Y_K \rightarrow Y_L$. Furthermore, this covering is Galois iff $K/L$ is Galois. So we can see a lot of analogies between certain fields and Riemann surfaces.
It turns out that all this procedure using valuations can be carried over to any global field (finite extensions of $k(t)$ or finite extensions of $\mathbb{Q}$) or, more generally, to any Dedekind domain (a Noetherian domain such that the localizations at primes are discrete valuation rings). It should be noted that this procedure using valuations is a little problematic in higher dimensions (when the transcendence degree $K$ over $\mathbb{C}$ is greater then one) and does not coincides with the usual nowadays scheme theory (this is because isomorphic fields of meromorphic functions, aka irrational varieties, does not yields isomorphic varieties in higher dimensions).
For instance, for the number field $\mathbb{Q}$, we have exactly one valuation for each prime $p$ given by $v_p(\frac{p^nm}{n}) = -n$ for $\frac{m}{n}$ cop rime to $p$ and one valuation at infinity $v_{\infty}(a) = \log (|a|)$ where $|-|$ is the usual norm in the reals. In this case, the algebraic integers of $\mathbb{Q}$ are the ordinary integers $\mathbb{Z}$. Furthermore we can complete the field at some $v$ (this is analogous to picking germs of holomorphic functions around the point corresponding to $v$) and we get the usuals $\mathbb{Q}_p$ for the valuations $v_p$ and $\mathbb{R}$ for the valuation $v_{\infty}$.
Again, as in the case of Riemann surfaces, extensions corresponds to ramified extensions of the corresponding curves. More precisely, given two number fields $L$ and $K$ together with a map $L \rightarrow K$ we get a finite ramified covering $Y_K \rightarrow Y_L$, where $Y_K$ denotes $\text{Proj} (\mathcal{O}_K) = \text{Spec} (\mathcal{O_K}) \cup \{\text{valuations at } \infty \}$ (which amounts to exactly the same construction done for Riemann surfaces earlier). In this case, the non-archimedean valuations (the non-infinity ones) corresponds exactly to the prime ideals in $\mathcal{O}_L$ and the ramification above a given point $\mathfrak{p}$ (prime ideal) means exactly that over the extension $K$, $\mathfrak{B}^{e}| \mathfrak{p}$ for some prime ideal $\mathfrak{B}$ and $e > 1$.
So this correspondence indeed makes sense. Actually, this correspondence has developed in a more general one called the function field analogy, but I will not write about this (you can check for instance http://www-math.mit.edu/~poonen/papers/curves.pdf around page 32).
Now let's go to the line bundles. A line bundle $\pi: L \rightarrow X$ over a Riemann surface $X$ is a complex vector bundle of dimension one, i.e, it's a complex manifold $L$ that looks like $X \times \mathbb{C}$ locally. We can pick the sections of this line bundle for each open set $U \subset X$, i.e, the functions $s: U \rightarrow L$ that such that $\pi s = 1_X$. This yields a module over the ring of homolorphic functions for each open set $U$ (this is what's called a sheaf of $\mathscr{O}_X$-modules). For the case of number fields we can do the same using $\mathcal{O}_K$ instead of the ring of holomorphic functions (look at the notational similarity). For this we need to tell what are the regular functions (an analogous to the holomorphic functions) on each open set $D(f)= \text{Spec} (\mathcal{O}_K) \setminus V(f)$. This is done by localizing (inverting) $f$ and we denote this by $A_{f}$ (I may $A$ instead of $\mathcal{O}_K$ if the procedure holds for any commutative ring with unity). It turns out that giving a line bundle over $\text{Spec} (A)$ is the same as giving an $A$-modules $M$ that satisfy $M \otimes_A \text{Hom}_A (M, A) \cong A$. In the case of a Dedekind domain and, in particular, the case of $\mathcal{O}_K$ this is exactly the same as giving a fractional ideal $I \subset K$. Actually for any integral domain $A$, line bundles corresponds to invertible fractional ideals of the field of fractions of $A$. 
The Riemann Roch theorem says that  for some line bundle $L$ and an special line bundle $K$ (the canonical bundle given by the 1-forms on the curve) on a smooth projective curve of genus $g$ the equality $$h^0 (X, L) - h^0 (X, L^{-1} \otimes K) = deg (L) + 1 -g$$ holds. The degree of a line bundle in the formula is described by the degree of the Weil divisor associated to $L$. Roughly speaking giving a line bundle over a smooth projective curve (a Riemann surface or the spectrum of any Dedekind domain) we can find the points where the line bundle fails to give an isomorphism $L \cong X \otimes \mathbb{C}$ (or $L \cong  \mathcal{O}_K$) together with the multiplicities of this failure in each point. The sum of these multiplicities is the degree. More precisely, there is a section defined except finitely many points that fail give the above isomorphism section because it's zero at some of these points and is infinity at these undefined points. The sum of the multiplicities of the zeros minus the multiplicities of the poles is exactly the degree $deg (L)$.
I don't have time to write more none. Maybe I will add more things later. If something is not clear, just ask me (I don't know how much knowledge about commutative algebra and differential geometry you have).
