Clarification on Proof that any two bases for a free module over certain $R$ have same cardinality I've been looking for proofs of the following well-known theorem that don't appeal to linear-algebraic techniques (matrices/determinants): For $R$ commutative with $1$, any two bases for a free module $M$ over $R$ have equal cardinality.
I found one in Robert Ash's Basic Abstract Algebra, which I quote almost in full.

If $I$ is a maximal ideal of $R$,then $k=R/I$ is a field,and $V =M/IM$
  is a vector space over k. [By $IM$ we mean all finite sums  $a_ix_i$ with
  $ai \in I$ and $xi \in M$; thus $IM$ is a submodule of $M$. If $r+I
> \in k$ and $x+IM \in M/IM$, we take $(r+I)(x+IM)$ to be $rx + IM$]
Now if $(x_i)$ is a basis for $M$, let $\bar{x_i} = xi+IM$. Since the
  $x_i$ span $M$, the $\bar{x_i}$ span $M/IM$. If 
  $\sum\bar{a_i}\bar{x_i} = 0$, then  $a_ix_i \in IM$. Thus  $\sum
a_ix_i =  \sum b_jx_j$ with $b_j \in I$. Since the $x_i$ form a basis,
  we must have $a_i = b_j$ for some $j$. Consequently $a_i \in I$, so
  that $\bar{a_i} =0$ in $k$. We conclude that the $\bar{x_i}$ form a
  basis for $V$ over $k$, and since the dimension of $V$ over $k$
  depends only on $M, R$ and $I$, and not on a particular basis for $M$,
  the result follows.

The part in bold is confusing me. How exactly does the result follow from this?
 A: The definition of $V$ was given before introducing a basis $(x_i)$ of $M$. Therefore the dimension $d$ of $V$ is a well-defined number. Now if $(x_i)$ is any basis of $M$, then $(\overline{x_i})$ is a basis of $V$, hence has cardinality $d$. Therefore all bases $(x_i)$ of $M$ have the same cardinality $d$.
A: It should be noted that in fact $i\neq j \implies x_i+IM\neq x_j+IM$ is a special case of the linear independence of $\{x_i+IM\}_{i\in I}$. For convenience here is the same argument with a different packaging. The proof will be based on the special case of vector spaces:
Theorem: If $V$ is a $k$-vector space and $\mathcal{X},\mathcal{Y}$ are two $k$-bases of $V$, then $\operatorname{card}(\mathcal{X})=\operatorname{card}(\mathcal{Y})$.

For preliminaries we have the following:
Let $\operatorname{sca}:R\times M\to M$ define the $R$-module structure of $M$, and $I\in\mathcal{P}_{\unlhd}(R)$. Then


*

*$IM:=\bigcup_{n\geq1}\left\{\sum_{k=1}^n \operatorname{sca}(a_k,m_k)\vert a_k\in I,m_k\in M\right\}$ is a submodule of $M$ with $ \operatorname{sca}\vert_{R\times IM}$.

*That being the case the quotient group $M/IM$ too has an $R$-module structure, given by\begin{align}
\widetilde{\operatorname{sca}}:&R\times M/IM\to M/IM\\
&(a,m+IM)\mapsto \operatorname{sca}(a,m)+IM
\end{align}

*Finally (since $I\subseteq (M/IM)^\circ$) we have an $R/I$-module structure on $M/IM$ given by\begin{align}
\overline{\operatorname{sca}}:&R/I\times M/IM\to M/IM\\
&(a+I,m+IM)\mapsto \widetilde{\operatorname{sca}}(a,m)=\operatorname{sca}(a,m)+IM.
\end{align}

*In the case when $I$ is maximal $R/I$ is a field, hence $M/IM$ becomes an $R/I$-vector space with $\overline{\operatorname{sca}}$ as the scalar multiplication.


To make it less painful to read the actual proof I will not be using $\operatorname{sca}$ and its kin from now on, as is customary.

Claim: Let $R$ be a nonzero commutative ring and $M$ an $R$-module. Then any two $R$-bases of $M$ have the same cardinality.
Proof of Claim: Let $\mathcal{X}:=\{x_j\}_{j\in J}$ be an $R$-basis of $M$, $I\in\mathcal{P}_{\unlhd}(R)\setminus\{R\}$ be maximal. Set $\overline{\mathcal{X}}:=\mathcal{X}+IM=\{x_j+IM\}_{j\in J}$. Then $\overline{\mathcal{X}}$ is an $R/I$-basis of $M/IM$:


*

*To see that $\overline{\mathcal{X}}$ spans $M/IM$, let $m+IM\in M/IM,$ i.e. $m\in M$.


\begin{align}
&\implies \exists \mbox{ finite } J_0\subseteq J, \{a_j\}_{j\in J_0}\subseteq R: m=\sum_{j\in J_0}a_jx_j\\
&\implies m+IM=\left(\sum_{j\in J_0}a_jx_j\right)+IM=\sum_{j\in J_0}(a_j+I)(x_j+IM), \checkmark.
\end{align}


*

*Next we show that $\overline{\mathcal{X}}$ is $R/I$-linearly independent. Let $J_0\subseteq J$ be finite and  $\{a_j\}_{j\in J_0}\subseteq R: \sum_{j\in J_0}(a_j+I)(x_j+IM)=IM$.


\begin{align}
\implies \sum_{j\in J_0}a_jx_j\in IM \implies \exists \{b_k\}_{k=1}^n\subseteq I,\exists \{m_k\}_{k=1}^n\subseteq M:\sum_{j\in J_0}a_jx_j=\sum_{k=1}^n b_km_k.
\end{align}
Since $\mathcal{X}$ is an $R$-basis of $M$, $\forall k,\exists$ finite $J_k\subseteq J, \exists\{c_j^k\}_{j\in J_k}\subseteq R: m_k=\sum_{j\in J_k}c_j^kx_k$. Setting $J':=\bigcup_{k}J_k$, we have $\forall k:m_k=\sum_{j\in J'}c_j^k\chi_{J_k}(j)x_j$.
\begin{align}
&\implies \sum_{j\in J_0}a_jx_j=\sum_{k=1}^n b_km_k=\sum_{k=1}^nb_k\left(\sum_{j\in J'}c_j^k\chi_{J_k}(j)x_j\right)
= \sum_{j\in J'} \underbrace{\left(\sum_{k=1}^n b_kc_j^k\chi_{J_k}(j)\right)}_{=:d_j\in I} x_j \\
&\implies 0 = \sum_{j\in J_0\setminus J'}a_jx_j + \sum_{j\in J_0\cap J'}(a_j-d_j)x_j +\sum_{j\in J'\setminus J_0}(-d_j)x_j\\
&\implies \forall j\in J_0\setminus J': a_j=0\in I;\;\forall j\in J_0\cap J': a_j=d_j\in I;\;\forall j\in J'\setminus J_0:d_j=0\\
&\implies \forall j\in J_0: a_j\in I \implies \forall j\in J_0: a_j+I=I,\checkmark.
\end{align}
Next observe that $\operatorname{card}(\mathcal{X})=\operatorname{card}(\overline{\mathcal{X}})$:


*

*$\operatorname{card}(\mathcal{X})\geq\operatorname{card}(\overline{\mathcal{X}})$ by construction.

*If $x_i+IM=x_j+IM$ but $i\neq j$, then $x_i-x_j\in IM$, which implies by the above argument for $R/I$-linear independence that $1\in I$, but $I$ is maximal, $\unicode{x21af}$. Thus $\operatorname{card}(\mathcal{X})\leq\operatorname{card}(\overline{\mathcal{X}})$ as well.


Finally let $\mathcal{Y}$ be an arbitrary $R$-basis of $M$. Then we have
$$\operatorname{card}(\mathcal{Y})=\operatorname{card}(\overline{\mathcal{Y}})=\operatorname{card}(\overline{\mathcal{X}})=\operatorname{card}(\mathcal{X}),$$
where the second equality follows from the theorem that addresses the vector space case, which applies by 4 above.

Note: For future reference this is also Exercise III.2 from Lang's Algebra, 3e (p. 165) (where the context is to generalize the result from vector spaces to free modules over nonzero commutative rings, hence my argument).
Note 2: After all this maybe it's a good idea also to observe that the converse is not true, even in the case of vector spaces, e.g. considering $\Bbb{R}[X]$ as an $\Bbb{R}$-vector space, we have $\operatorname{card}(\{X^n\vert n\geq0\})=\operatorname{card}(\{X^n\vert n\geq1\})$.
