Let $R$ be a commutative ring with $1$. Let $n$ and $k$ be nonnegative integers, and let $A\in\mathrm{M}\_n\left(R\right)$ be a matrix such that $A\cdot R^n\cong R^k$ as $R$-modules. Assume that $A^2=\lambda A$ for some $\lambda\in R$. Do we have $\mathrm{Tr}A=\lambda k$ ?


**Motivation:** This holds for $R$ a field, in both $\lambda=0$ and $\lambda$ invertible cases. But the proofs for these cases are different. I am wondering whether they can be unified - if it works over arbitrary commutative rings, for example, it could.


Oh, and if it holds, it gives a kind of generalization of the Molien series to representations over arbitrary rings, provided the invariant spaces of their symmetric powers are free modules.



Pseudo-idempotent matrix generating a free module
$\DeclareMathOperator{\Tr}{Tr}$This is true. Here is an elementary proof: Let  

$$ \phi\colon A\cdot R^n \to R^k \quad \text{and}\quad \psi\colon R^k\to A\cdot R^n $$
mutually inverse isomorphisms. Let $X$ be the matrix of the map $R^n\ni v\mapsto \phi(Av)\in R^k$, and $Y$ the matrix of $\psi$ as map from $R^k\to R^n$ (with respect to the canonical bases). Since $\psi(\phi(Av))=Av$, it follows $YX=A$. Thus $$\Tr(A)= \Tr(YX)=\Tr(XY).$$ But $XY$ is the matrix of the map $R^k\ni w \mapsto \phi(A\psi(w))\in R^k$. Since $\psi(w)\in A\cdot R^n$, there is $v\in R^n$ with $\psi(w)=Av$. Thus 
$$XYw= \phi(A\psi(w))=\phi(A\cdot Av) = \phi(\lambda Av)= \lambda \phi(\psi(w)) = \lambda w,$$
that is, $XY = \lambda I\_k$. Therefore $\Tr(A)=\Tr(XY)=\lambda k$.


