Pseudo-idempotent matrix generating a free module 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.
 A: $\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$.
A: Yes. If $R$ is an integral domain. Just embedd everything inside the quotient field of $R$, and use the result your result over  fields (i believe you that it holds).
Yes. If $R$ is reduced and noetherian. By the previous parts the satement holds for $R/p$, 
where $p$ is a minimal prime ideal. Hence $Tr A$ is equal $\lambda$ mod $p$, for all minimal primes. Since $R$ is reduced the natural $R\rightarrow \prod_p R/p$ is injective, where the product is taken over the minimal primes.    
I believe it should fail if $R$ is not reduced, and i guess the example should exist over $R=k[x]/(x^2)$.
Edit: I dont belive the last statement anymore. The image of $A$ is projective, hence we may split it off. The point is that the statement holds when $n=k$, since then $A$ is invertible. The only  thing that worries me slightly is that the kernel might not be free, but maybe everything is ok after passing to a covering, where the Kernel is free.
Edit 2: Sorry for being incomprehensible yesterday. I believe the result is true, at least if $R$ is noetherian. Let me assume that $R$ is noetherian, this makes me feel better.
Then $R$ injects into $\prod_p R_p$, where the product is taken over minimal primes of $R$. It is enough to show the statement for $R_p$. Now, $R_p$ is a local ring with a nilpotent maximal ideal.
So assume (as we may) $R$ is local with a nilpotent maximal idela $\mathfrak m$. Consider 
the exact sequence $0\rightarrow Ker A \rightarrow R^n\rightarrow Im A\rightarrow 0$. Since $Im A$ is free, it is projective, hence the sequence slits. Thus $Ker A$ is projective (since a direct summand of a free). Since $R$ is local, $Ker A$ is free.
Case 1. $\lambda\not\in \mathfrak m$. Then $\lambda$ is a unit in $R$. Thus the intersection of $Ker A$ and $Ker(A-\lambda)$ is zero. Now $A^2=\lambda A$ implies 
that $R^n= Ker A\oplus Ker(A-\lambda)$, and we are done. 
Case 2. $\lambda\in \mathfrak m$. Choose a basis for $Ker A$, $v_1, \ldots, v_{n-k}$ and extend it to a basis of $R^n$, $w_1, \ldots w_{k}$. The images of $Aw_1,.., A w_k$ mod $\mathfrak m$ are linearly independent and contained in $Ker A$ mod $\mathfrak m$. We may assume that $Aw_i = v_i$ mod $\mathfrak m$. Wrt this basis, $A$ looks like a block matrix 
$(0 B//0  D)$, where the  top $k\times k$ square of $B$ is congruent to $1$ mod $\mathfrak m$ ( i hope i got this right), hence this top right corner is invertible. By plugging in the relation $A^2=\lambda A$ and looking at the top right $k\times k$ corner, we get $D=\lambda \times (identity)$, which implies the claim. 
