$R^n \cong R^m$ iff $n=m$ How can i show that two $R$-modules of finite rank are isomorphic if and only if they have the same rank, i.e., $R^n \cong R^m$ iff $n=m$. 
 A: A simple counterexample in the general case is the following.
Let $k$ be a field, and let $R$ be the quotient of the free algebra on letters $x_1$, $x_2$, $y_1$, $y_2$ by the ideal generated by the elements 
$$
x_1y_1+x_2y_2-1, \qquad y_1x_1-1, \qquad y_2x_1, \qquad
y_1x_2, \qquad y_2x_2-1.
$$
Then the free modules $R$ and $R^2$ are isomorphic. This follows at once, since the matrices $\begin{pmatrix}x_1&x_2\end{pmatrix}$ and $\begin{pmatrix}y_1\\y_2\end{pmatrix}$ are mutually inverse.
The difficulty here lies in showing that the ring $R$ is non-trivial.
A: This is true of rings that have the "IBN" (invariant basis number property). Among these are commutative rings--which is probably what you meant. 
Use Krull's theorem to find a maximal ideal $\mathfrak{m}$ of $R$ and use the fact that since $R^n\cong R^m$ as $R$-modules that $(R/\mathfrak{m})\otimes_R R^n\cong (R/\mathfrak{m})\otimes_R R^m$ as $R/\mathfrak{m}$-modules. But, from basic module theory this is just $(R/\mathfrak{m})^n\cong(R/\mathfrak{m})^m$ and so we've reduced the problem from general rings to fields--something you should be familiar with.
A: If localization is not your thing, there is a different elementary proof.
Just as in linear algebra, you can prove that the set of R linear transformations from $R^n\to R^m$ is isomorphic to the set of $n\times m$ matrices over R. An isomorphism would amount to an $n\times m$ matrix A and an $m\times n$ matrix B such that AB and BA are identity matrices.
Now pick a maximal ideal M of R, and apply the quotient map from R to the field R/M entry wise to the matrix. Now you have two matrices over a field which multiply to identities in either order, giving an isomorphism of vector spaces. Since we know two isomorphic vector spaces have equal dimension, m=n.
