What's wrong with defining the rank of a finitely generated module over any (commutative) ring to be just the smallest number of generators? All books I know define rank only locally this way. But why not define it globally?



Rank of a module
Since your profile says you are interested in Algebraic Geometry, here are geometric considerations that might appeal to you.


Consider a projective module $P$ of finite type over a commutative ring $A$. It corresponds to a locally free sheaf $\mathcal F $ over $X=Spec(A)$. The rank of $\mathcal F $ at the prime ideal $\mathfrak p$ is that of the *free* $A\_{\mathfrak p}$-module $\mathcal F\_{\mathfrak p}$.
The rank is then a locally constant function on $X$ and if $X$ is connected (this means that the only idempotents in $A$ are $0$ and $1$) it may be seen as an integer. 


If $A$ is a domain, then $X$ is certainly connected and has a generic point $\eta$ whose local ring is the field of fractions $\mathcal O\_\eta=K=Frac(A)$. The rank of $\mathcal F $ or of $P$ is then simply the dimension of the $K$ vector space $P\otimes\_A K$. 


Actually, if $A$ is a domain, this formula can be used to define the rank of any $A$-module $M$ (projective or not, finitely generated or not) : $rank(M)=dim\_K ( M\otimes\_A K) $ .  

This is the definition given by Matsumura in his book *Commutative Rings*, page 84.  

 It corresponds to the **maximum** number of elements of $M$ which are linearly independent over $A$. 


The **minimum** number of generators of $M$ (which started this discussion) is quite a different, but interesting invariant, which has been studied by Forster, Swan, Eisenbud, Evans,...  

Geometrically it corresponds to the minimum numbers of global sections of $\tilde{M}$ which generate this sheaf at each point of $Spec(A)$.  

**Elementary example:** Every non-zero ideal of a Dedekind domain is of rank one, can be generated by at most two elements and can be generated by one element iff it is principal.
If the Dedekind domain is not a PID there always exist non free ideals which thus cannot be generated by less than two elements.


**Bibliography**  

 Ischebeck and Rao have published a [monograph](http://books.google.fr/books?id=P82xkbGioL8C&pg=PA205&lpg=PA205&dq=projective+modules+over+dedekind+rings&source=bl&ots=4ydpUikP4b&sig=XepMnxgKJcTr5xzGEpJEr-Y5_aM&hl=fr&ei=8CwrTMPMFNmXOLaRucgD&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBcQ6AEwADgK#v=onepage&q=projective%20modules%20over%20dedekind%20rings&f=false) *Ideals and reality: projective modules and number of generators of ideals* on exactly this theme


