Problem: Let $R$ be a commutative ring, show that if $R^n \cong R^m$ then $n = m$.
I have an attempt which I think is alright, but I just want to double check that there are no issues in my attempt. It's a very basic from the definitions approach, and didn't see anything exactly like it on the site. I saw this but I haven't studied tensor products yet.
Attempt:We use exercise 10.2.12 from DF, if $R$ is a ring and $I$ is a left ideal of $R$, then $R^n/IR^n \cong \underbrace{R/IR \times \dots \times R/IR}_{n \text{ times}}$. Let $I$ be a maximal ideal of $R$, note that because $R$ is commutative, $I$ is a $2$-sided ideal. Because $R^n \cong R^m$ there is an $R$-module isomorphism $\varphi:R^n \rightarrow R^m$ which induces an isomorphism $\psi: R^n/IR^n \rightarrow R^m/IR^m$ defined by $r+IR^n \mapsto \varphi(r)+IR^m$. To see that this map is well-defined, let $r,r'$ be representatives of the same equivalence class, i.e $r+IR^n = r'+IR^n$. Then it follows that $r-r' \in IR^n$ so $r-r' = \sum_1^k a_im_i$ where $a_i \in I$ and $m_i \in R^n$. Then notice \begin{align*} \psi(r)-\psi(r') &= \varphi(r)+IR^m - \varphi(r')+IR^m \\ & = \varphi(r-r')+IR^m \\ & = \varphi \left( \sum_1^k a_i m_i \right) + IR^m \\ & = \sum_1^k a_i\varphi(m_i) + IR^m \\ &= IR^m \tag{$\varphi(m_i) \in R^m$ and $a_i \in I$} \end{align*} so $\psi(r)+IR^m = \psi(r')+IR^m$ and the map is well-defined. It follows from the fact that $\varphi$ is an isomorphism that $\psi$ is also an isomorphism. Therefore we can apply 10.2.12 from Dummit and Foote. We have that $R^n/IR^n \cong R^m/IR^m$ and so by 10.2.12 we have that $$ \underbrace{R/IR \times \dots \times R/IR}_{n \text{ times }} \cong \underbrace{R/IR \times \dots \times R/IR}_{m \text{ times}} $$ Since $R$ is commutative $I$ is two sided and it follows that $IR = I$; it's obvious that $I \subseteq IR$, if $\sum_1^ka_ir_i \in IR$ since $I$ is a two sided ideal $a_ir_i \in I$ for all $i$ so is an element of the ideal. Therefore This becomes $$ \underbrace{R/I \times \dots \times R/I}_{n \text{ times }} \cong \underbrace{R/I \times \dots \times R/I}_{m \text{ times}}. $$ Because $I$ was a maximal ideal we know that $R/I$ is a field and so this gives that $F^n \cong F^m$, but we know from vector space theory that these are isomorphic if and only if they have the same dimension, i.,e $n = m$.
Let me know if there are any missteps or places to trim the fat.