If $n$ elements generate a free module of rank $n$, are they necessarily linearly independent? Let $A$ be a nonzero commutative ring with $1$, and $n$ a positive integer. If $b_1,\ldots,b_n\in A^n$ generate $A^n$ as an $A$-module, is it true that $b_1,\ldots,b_n$ are linearly independent over $A$ (hence a basis)? I suspect this is true (It is true if $n=1$), but I can't seem to prove it.
I guess an equivalent way of asking this question is: if a linear map $A^n\to A^n$ is surjective, is it necessarily injective?
Any help is welcome!
 A: Yes. Let $B$ be the $n\times n$ matrix consisting of $b_1 \cdots b_n$ as its columns, and $e_1,\ldots,e_n\in A^n$ the standard basis. Since $b_1,\ldots,b_n$ generate $A^n$, there exist $c_{ij}\in A$ such that $e_i=c_{i1}b_1+\cdots+c_{in}b_n$ for each $i$. Let $C$ be the $n\times n$ matrix whose $ij$-th entry is $c_{ji}$. Then $BC=I$, where $I$ is the $n\times n$ identity matrix. This implies that $\det B\in A$ is a unit, hence the linear map $B:A^n\to A^n$ is injective.
A: A proof of the equivalent way :

If $\;u\colon A^n\longrightarrow A^n$ is surjective, $u$ is injective.

Indeed, consider the short exact sequence:
$$0\longrightarrow K \overset{i}\longrightarrow A^n\overset{u}\longrightarrow A^n\longrightarrow 0,$$
where $i$ is the canonical injection of $K=\ker u$. This is a split exact sequence, since the last term is free, so $i$ has a linear retraction, which is surjective. In other words, $K$ is a finitely generated submodule of $A^n$.
Tensoring with  each of the residual fields $\kappa(\mathfrak m)=A_\mathfrak m/\mathfrak mA_\mathfrak m$, $\;u\otimes_A\kappa(\mathfrak m)\colon\kappa(\mathfrak m)^n\longrightarrow \kappa(\mathfrak m)^n$ is an automorphism, hence the image of $K\otimes_A\kappa(\mathfrak m)$ in $\kappa(\mathfrak m)^n$ is $0$.
We conclude that $K_\mathfrak m=\{0\}$ for each maximal ideal, whence $K=\{0\}$ since $K$ is finitely generated.
