rank function on Spec (help with definition) one definition of the line bundle over a ring is: a finitely generated projective A-module such that the rank function Spec A → N (positive integers) is constant with value 1. We call A itself the trivial line bundle.
so here i think that spec is equipped with zariski topology and N with the discrete one. Does this mean that in general the rank function is not continuous? Does one know about a basic example of non constant rank function to illustrate the peculiarities implied by the definition above?
Many thanks
 A: I am only going to talk about the case that $A$ is Noetherian. 
Here is part of Theorem A3.2 of Eisenbud's "commutative algebra with a view toward Algebraic geometry": a finitely generated module $M$ over a noetherian ring $A$ is projective if and only if there exists a finite set of elements $x_1,\ldots, x_r$ in $A$ that generates the unit ideal of $R$ such that $M[x_i^{-1}]$ is free over $A[x_i^{-1}]$ for each $i$.  
It follows that the rank is a locally constant function. So if $\mathrm{Spec}(A)$ is connected, then the rank has to be constant. 
I'll leave it to you to construct an example of a projective module with nonconstant rank. 
A: I'm not quite sure I understand the question:

Does this mean that in general the rank function is not continuous?

How general is "in general"?  Anyway, here are some facts which taken together may answer your question.

*

*A function $f$ from a topological space $X$ to a discrete space is continuous iff it is locally constant, i.e., for all $x \in X$ there exists a neighborhood $U$ of $x$ such that $f|_U$ is constant.  For whatever reason, it is more common to speak of "locally constant" rank functions than continuous ones.


*In order to have a rank function, an $R$-module $M$ must have the property that for all prime ideals $\mathfrak{p}$, the localization $M_{\mathfrak{p}}$ is finitely generated and free.
Certainly all the localizations will be finitely generated if $M$ itself is finitely generated (I'm blanking a little on conditions for the converse at the moment), so let's restrict to the case of finitely generated modules $M$.


*For a finitely generated module $M$ with a well-defined rank function -- i.e., such that $M_{\mathfrak{p}}$ is free for all prime ideals $\mathfrak{p}$, the following are equivalent:
(i) The rank function is locally constant (equivalently, continuous).
(ii) $M$ is projective.

This takes some work: see e.g. $\S 13.9$ of my commutative algebra notes.


*There are conditions on $R$ which force the rank function of any finitely generated locally free module to be constant: e.g. this holds if $R$ has a unique minimal prime ideal ($\S 13.9$), so in particular if $R$ is a domain.  It also holds if $R$ is Noetherian ($\S 7.8$).  However there are examples of finitely generated locally free modules with nonconstant rank function: see this MO question and its answer.

A: I've never seen this described this way, but here is why it is not "peculiar" to me. If you are thinking about Spec A as a topological space, then this A-module is sort of like a vector bundle on the space (but is allowed to be weirder since it is a module).
The rank function is saying look at the "fiber" of this bundle over a specific point. You get a free module isomorphic to $A^n$. Just as in the vector bundle case, the $n$ is the rank here. 
Now if your A-module is actually a vector bundle, then the rank is just constant of whatever the rank. Since you have specified that the module is finitely generated and projective it must be locally free (assuming A Noetherian). You can check that a locally free module will have constant rank (as long as the space is connected), and hence the rank function is continuous.
If you are asking for an arbitrary A-module that is not projective for which the rank function is not continuous, try a torsion module over $\mathbb{Z}$.
(Looks like someone beat me to the answer, but it seems we've given different interpretations of how to produce an example).
