If $A$ is the ring of continuous functions on a genus $g$ surface, can the genus of $X$ be seen by simple algebra in $A$? I was describing to a friend the result that a compact Hausdorff space is determined up to homeomorphism up to by its ring of continuous functions, and he asked how one could see the genus of a surface algebraically. I think it's a good question, and I don't know the answer.
Two parts to this question:


*

*Suppose it is known that $A$ is the ring of continuous functions of a closed surface $X$ (topological manifold, real 2-dimensional) of genus $g$. Where in the algebraic structure of $A$ is the genus of $X$? (There are comments from other users about $K$-theory below... I want to emphasize that I am dreaming of a simple algebraic characterization, analogous to the relationship between idempotents and connected components.)

*Does the answer to 1 say something interesting for more general classes of rings (ex, those that are rings of continuous functions on a compact Hausdorff space, or more general rings...)
Any ideas? (Analogous to the idempotents / connected components dictionary.)
Here are some thoughts of my own: 


*

*Picking a smooth structure on $X$ amounts to passing to some subring of differentiable functions. In this setting, results about the existence of vector fields with zeros of prescribed index could be interpreted as the existence of derivations with some prescribed zeros (by choosing some arbitrary Riemannian metric and translating the results about vector fields) - though its not clear how to interpret the index of the zero algebraically, or how to describe these subrings. 

*Consider all ring homomorphisms to $C(X) \to C(S^1)$ up the homotopy relation induced by factoring through $C(S^1 \times I)$ in the right way. This crudely recaptures the fundamental group, but I don't see how to turn it into an algebraic condition.

*Vector bundles are the same as finite projective modules via Swan's theorem - so certain sections of the vector bundle are elements of the corresponding module? Maybe one could get at the Poincare-Hopf computation of the genus that way, but again I don't see how to compute the index. (Also as far as I know, one still needs a smooth structure to use Poincare-Hopf.)
I would be happy to just be able to distinguish $S^2$ and $T^2$ via their ring of continuous functions.
 A: I'll assume we're talking about complex functions; if real, tensor with $\mathbb{C}$. Now pass to the group of units. With the topology given by spectral radius (this is an algebraic description of the C-* topology), the group of connected components of the group of units is $H^1(X, \mathbb{Z})$ which of course knows the genus. 
If you really like idempotents then you should try learning about K-theory. There's a very concrete and elementary way to define $K^0$ in terms of idempotents in the matrix algebras $M_n(A)$. You don't need the C*-structure of $A$. But on the other hand $K^0$ doesn't know the genus of a surface. $K^1$ does but it's a bit trickier to define, I think. 
Edit: $H^1(X, \mathbb{Z})$ can be isolated a bit more algebraically too. To extract $H^1(X, \mathbb{Z})$ from the group of units it suffices to isolate the connected component of the identity. The elements in this connected component can be distinguished by the fact that they are divisible. 
Edit #2: So, purely for the sake of distinguishing $S^2$ and $T^2$, you can say the following: on $S^2$, every unit has a square root, but not on $T^2$. 
A: The torus has two functions $f$ and $g$ which are (1) relatively prime, (2) each have two square roots, and (3) whose product has $4$ square roots. For instance take two functions which vanish on disjoint loops which are not null-homologous. There sphere does not have two such functions because (1) implies that $V(f)$ and $V(g)$ are disjoint and (2) implies that the complement of $V(f)$ and $V(g)$ are connected, and (3) implies that the complement of $V(fg)$ is not connected. These conditions are impossible to all satisfy at once on the sphere.
