# Decomposition of Free Module over PID

Let $M$ be a free module with rank $2$ over the PID $R$ having basis $B=\{b_1,b_2\}$. I have a few questions regarding the submodule $Rm$, where $m$ is some element of our module $M$. Suppose $m$ is of the form $xb_1+xb_2$ for $x\in R$. How can we show that there is some submodule $T$ such that $M=Rm\oplus T$ if and only if $x$ has an inverse in $R$? C an we also show that if $m=xb_1+yb_2$, then there is $T$ s.t. $M=Rm\oplus T \iff$ the ideal generated by $x$ and $y$ gives the whole ring $R$?

I've given this some thought and have ideas to use a decomposition as done here, but I'm not really sure how to approach this. I'm also not sure how $x$ being invertible is relevant. Thanks in advance.

This is easiest to see working with $2\times2$-matrices over $R$: Let me show that if $m=xb_1 + yb_2$ then there exists $T\subseteq M$ such that $M = Rm \oplus T$ if and only if $Rx+Ry = R$.
First assume that $Rx+Ry=R$. Then there are $w,z\in R$ such that $wx - zy = 1$. Now define $t := zb_1 + wb_2\in M$ and $A := \begin{pmatrix}x & y\\ z & w\end{pmatrix}\in {\rm Mat}_{2\times 2}(R)$ is invertible (its inverse being $\begin{pmatrix}w & -y\\ -z & x\end{pmatrix}$). Thus, we have $$\begin{pmatrix} m\\ t\end{pmatrix} = \begin{pmatrix} x & y\\ z & w\end{pmatrix}\cdot \begin{pmatrix} b_1\\ b_2\end{pmatrix}.$$ Setting $T:= Rt$, it is clear that $M = Rm\oplus T$. For example linear independence of $m$, $t$: Let $\lambda,\mu\in R$ such that $0 = \lambda m + \mu t = \begin{pmatrix} \lambda & \mu\end{pmatrix}\cdot \begin{pmatrix} m\\ t\end{pmatrix}$. Then $$0 = \begin{pmatrix} \lambda & \mu\end{pmatrix}\cdot \begin{pmatrix} m\\ t\end{pmatrix} = \left(\begin{pmatrix} \lambda & \mu\end{pmatrix}\cdot \begin{pmatrix} x & y\\ z & w\end{pmatrix}\right)\cdot \begin{pmatrix} b_1\\ b_2\end{pmatrix}.$$ Since $b_1, b_2$ is a basis, we have $\begin{pmatrix} \lambda & \mu\end{pmatrix}\cdot \begin{pmatrix} x & y\\ z & w\end{pmatrix} = 0$ and hence $$0 = \begin{pmatrix} \lambda & \mu\end{pmatrix}\cdot \begin{pmatrix} x & y\\ z & w\end{pmatrix} \cdot \begin{pmatrix} w & -y\\ -z & x\end{pmatrix} = \begin{pmatrix} \lambda & \mu\end{pmatrix}\cdot \begin{pmatrix} 1 & 0\\ 0 & 1\end{pmatrix} = \begin{pmatrix} \lambda & \mu\end{pmatrix},$$ i. e. $\lambda = \mu = 0$.
Conversely, if there exists $T\subseteq M$ such that $M = Rm\oplus T$ then $T$ has to be free of rank $1$, generated by, say $t=zb_1 + wb_2\in M$. Since $m, t$ is also a basis of $M$, there exist $a,b,c,d\in R$ such that $b_1 = am + bt$ and $b_2 = cm +dt$. Hence $$\begin{pmatrix}m\\t\end{pmatrix} = \begin{pmatrix}x & y\\ z & w\end{pmatrix}\cdot \begin{pmatrix} b_1 \\ b_2\end{pmatrix} = \begin{pmatrix} x & y\\ z & w\end{pmatrix}\cdot \begin{pmatrix} a & b\\ c & d\end{pmatrix} \cdot \begin{pmatrix} m\\ t\end{pmatrix}.$$ Since $m,t$ are linearly independent, we conclude $\begin{pmatrix} x & y\\ z&w\end{pmatrix}\cdot \begin{pmatrix} a & b\\ c & d\end{pmatrix} = \begin{pmatrix} 1 & 0\\ 0&1\end{pmatrix}$. In particular, $ax + cy = 1\in R^\times$, i. e. $Rx + Ry = R$.