Rank of projective module We define the rank of free module as the number of elements on the basis of free module. It may be infinity. How do we define the rank of projective module?

The rank of a projective module $M$ over $R$ is the function $\mathrm{rk} : \mathrm{Spec}(R) \to \mathrm{Card}$, $\mathfrak{p} \mapsto \mathrm{dim}_{\mathrm{Quot}(R/\mathfrak{p})}(M \otimes_R \mathrm{Quot}(R/\mathfrak{p}))$. This is the dimension of the fiber of $\tilde{M}$ at $\mathfrak{p}$. One can show that if $M$ is finitely generated, then this rank function is locally constant (without any finiteness condition this may fail). In fact, then $\tilde{M}$ is locally free of finite rank. In particular, if $\mathrm{Spec}(R)$ is connected ($\Leftrightarrow$ $R$ has only the trivial idempotents $0,1$), this function is constant. Then you have just one rank $\mathrm{rk}(M)\in \mathbb{N}$. In particular, when $R$ is an integral domain, we have $\mathrm{rk}(M) = \mathrm{dim}_K(M \otimes_R K)$, where $K=\mathrm{Quot}(R)$.
