The exercise is as follows:
Supposing $A$ is a commutative ring with an identity, if $A \ne 0$ and $A^m \cong A^n$, then $m=n$.
I have some question with the proof. The proof is as follows:
Assume $k = A/\mathfrak{m}$ which $\mathfrak{m}$ is the maximal ideal in $A$.
If $\phi \colon A^m \rightarrow A^n$ is the $A$-module isomorphism, so I get $$\mathrm{id}_k \otimes \phi \colon k \otimes_A A^m \rightarrow k \otimes_A A^n$$ is the group isomorphism. $(*)$.
Because $$k_A \otimes_A A^m \cong \oplus_m (k_A \otimes_A A) \cong \oplus_m k \cong k^m, \quad k \otimes A^n \cong \oplus_n k \cong k^n, $$
$\mathrm{id}_k \otimes \phi$ is an isomorphism between vector spaces of dimensions $m$ and $n$ over the field $k$.
Thus $m = n$.
My question is:
From $(*)$, the isomorphism is a group isomorphism and how to get it is also a $k$-module isomorphism?
Is it simply by definition $l \times v_2 = (\mathrm{id}_k \otimes \phi)(l \times v_1)$ with $l \in k$, $v_2 = (\mathrm{id}_k \otimes \phi)(v_1)$, $v_1 \in k^m$, $v_2 \in k^n$?
Assume $\mathrm{id}_k \otimes \phi = f$, and $l, l_1 \in k$.
$l (v_2 + v_{2'}) = l (f(v_1 + v_{1'})) = f(l v_1 + l v_{1'}) = f(l v_1) + f(l v_{1'}) = l f(v_1) + l f(v_{1'})$.
$(l + l_1) v_2 = (l + l_1) f(v_1) = f(l v_1) + f(l_1 v_1) = lv_2 + l_1 v_2$.
$l (l_1 v_2) = l f(l_1 v_2) = f(l \cdot l_1 v_2)$.
$1 v_2 = f(1 v_1) = v_2$.
Using $f$ is the group isomorphism, I check it and I think it is true.
Thanks!