Trace of the identity map in a projective module Let $A$ be a commutative algebra (over the complex numbers, with a unit) and let $M$ be a finitely generated projective $A$-module, and let $m_1,\ldots,m_n$ be a set of generators of $M$. The Dual Basis Theorem states that there exists $m_1^\ast,\ldots,m_n^\ast\in M^\ast$ such that $x=\sum m_i^\ast(x)m_i$ for all $x\in M$. This implies that one can write the identity map on $M$ as the tensor $\mathbf{1}=\sum m_i^\ast\otimes m_i$ and one defines $\operatorname{tr}\mathbf{1}=\sum m_i^\ast(m_i)$. What are the properties of $\operatorname{tr}\mathbf{1}$? Is there any relation to, for instance, the rank of $M$? When is it proportional to the unit element in $A$?
 A: More abstractly:  Let $A$ be a commutative unital ring and let $M$ be a f.g. projective $A$-module. The rank $rk_P(M)$ of $M$ at a prime ideal may be defined as the vector space dimension of $K\otimes_A M$ where $K$ is the residue field. Because projective modules of local rings are free, this is a locally constant function of the prime (so a constant if $A$ is a domain). The trace of the identity of $M$ is the unique element of $A$ such that in every local ring $A_P$ it goes to $rk_P(M)1$.
A: For any homomorphism $\varphi : A \to \mathbb C$, $\varphi({\rm tr}({\bf 1}))$ will be the corresponding trace for the finite-dimensional vector space $M \otimes_A \mathbb C$, and hence be equal to the rank of $M$ at $\varphi$. 
So, if $A$ is some algebra of continuous functions on a connected space, then the trace ${\rm tr}({\bf 1})$ is a constant function, equal to the rank of $M$. In general, ${\rm tr}({\bf 1})$ is integer-valued locally constant.
A: Let $A$ be the matrix with entries $m_i^*(m_j)$, and put $B(x)=xA+I-A$ and $f(x)=\det(B(x))$.  We find that $A^2=A$, and $B(xy)=B(x)B(y)$, and $f(xy)=f(x)f(y)\in R[x,y]$.  We also have $f(1)=1$.  It follows that $f(x)=\sum_{i=0}^ne_ix^i$ for some elements $e_i\in R$ which are orthogonal idempotents, ie $e_ie_j=\delta_{ij}e_i$ and $\sum_ie_i=1$.  If we put $R_i=R/(1-e_i)\simeq Re_i$ and $M=M/(1-e_i)M\simeq e_iM$ we see that $R=\prod_iR_i$ as rings and $M=\prod_iM_i$ as modules.  Moreover, $M_i$ is locally free of rank $i$ over $R_i$. 
We also have $\text{tr}(1)=\text{tr}(A)=f'(1)=\sum_iie_i$, so $\text{tr}(1)$ maps to $i$ in $R_i$.  It is cleaner to work with the elements $e_i$ because they distinguish the different $R_i$ even in a finite characteristic situation, which is not true for $\text{tr}(1)$.  
