Let $A$ be a commutative ring with unit and $P$ an $A$-module, I know that if $A^n\cong A^m\implies n=m$, then this number $n$ is well defined. I would like to prove that if $P\oplus A^m\cong A^n$, this number $n-m$ is well defined also. I'm trying to use the fact I've said above to prove this, am I on the right way? What is the standard proof of this fact?
Thanks
Let $p$ be a prime ideal and define a functor $F_p(M)=M\otimes A_p/p$, and let $r_p(M)=\dim F_p(M)$. Then $n-m=r_p(P)$. So not only is the difference well defined, but there is a rank which can by computed at any prime ideal for arbitrary finitely generated projective modules (and not just stably free ones).