I am working through a set of lecture notes on abstract algebra, and I am trying to come up with an alternative proof for one of the theorems. However, I am unsure of how to finish it/if it's possible to finish it. Could any of you help me? Any help would be greatly appreciated!
Theorem. Let $R$ be a PID and let $M$ be a finitely generated $R$-module. Then, $$M\cong R^n\oplus_{j=1}^k R/(a_j)$$ for some elements $a_1,\ldots,a_k\in R$.
My (unfinished) proof. Let $G=\{m_1,\ldots,m_s\}$ be a minimal generating set for $M$ (since $M$ is finitely generated, there must exist some such set $G$). Then, $$M=\sum_{1\leq i\leq s} R\cdot m_i.$$ Let $n$ be the number of elements $m_i\in G$ that satisfy that $R\cdot m_i\cong R$. Rearranging if necessary, we may assume that $m_1,\ldots,m_n$ are all such elements. Let $k=s-n$, and consider the remaining generators $m_{n+1},\ldots,m_{n+k}$. For each $1\leq j\leq k$, we introduce the $R$-module homomorphism $$f_j:R\to R\cdot m_{n+j},\quad r\mapsto r\cdot m_{n+j}.$$ Since $R$ is a PID, we can pick some element $a_j\in R$ so that $\ker f_j=(a_j)$. Then, by the 1st isomorphism theorem, $$R\cdot m_{n+j}\cong R/(a_j).$$ Now, consider the map \begin{gather*} \phi:R^n\oplus_{j=1}^k R/(a_j)\to M,\\ (r_1,\ldots,r_n,r_{n+1}+(a_1),\ldots,r_{n+k}+(a_k))\mapsto\sum_{i=1}^{n+k}r_i\cdot m_i. \end{gather*} It is clear that $\phi$ is a surjective $R$-module homomorphism, so it remains to prove that $\phi$ is injective.
Here, I don't see how to continue. I think the problem is is that $G$ is not necessarily linearly independent (since $R$ does not necessarily admit multiplicative inverses). Is it possible to finish this proof? If not, is there any way to salvage it (for example by tweaking the definition of $\phi$)?
The injectivity statement is not true for an arbitrary minimal generating set. For instance, if $R=\mathbb{Z}$, $M=\mathbb{Z}\oplus \mathbb{Z}/2\mathbb{Z}$ with minimal generating set $\{(1,1),(1,0)\}$, then neither generator is torsion. So, they each generate a copy of $\mathbb{Z}$ in $M$. The associated homomorphism $\mathbb{Z}\oplus \mathbb{Z}\to \mathbb{Z}\oplus \mathbb{Z}/2\mathbb{Z}$ is not injective. For instance, $2(1,1)-2(1,0)=(0,0)$, so $(2,-2)$ is in the kernel.