Suppose that $M=R^n$, where $n\geq 1$ and $R$ is a PID and suppose $N\leq M$. A \emph{complement} of $N$ in $M$ is a submodule $P$ of $M$ so that $M=N\oplus P$ (internal). If $A\in M_{n\times n}(R)$, the \emph{nullspace} of $A$ is the submodule $\{x\in M\mid Ax=0\}$. Show that $$N\text{ has a complement in }M\Leftrightarrow N\text{ is the null space of some }A\in M_{n\times n}(R).$$ Do all submodules of $M$ have a complement in $M$?
From the RHS to the LHS, I know that $N$ is a free module. And I try to expand the basis of $N$ to the basis of $M$ but I don't know whether I can do this. From the LFS to the RHS, I think should I give out an $A$ whose solution space is generated by the basis of $N$?
Can anyone help? Thanks!