TITLE: $R^n \cong R^m$ iff $n=m$
QUESTION [12 upvotes]: 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$.

REPLY [5 votes]: 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.