I'm reviewing some module theory before I take an algebra prelim at my university, and I came across a question that I do not know how to start.
"Let $R$ be a PID and let $M$ be an $R$-module. If $f:M\rightarrow R$ is a module homomorphism, show there exists a submodule $N$ of $M$ such that $M=N\oplus \ker(f)$."
My background with modules is limited. How can I approach this proof?
First note that the image of $M$ under $f$ is an ideal of $R$; since $R$ is PID, this ideal is principal generated by an (assume non-zero) element $a\in R$. Thus we get a surjective $R$-module homomorphism $f:M\to aR$. Since $aR\cong R$ is a (free, hence) projective $R$-module, the exact sequence $$\{0\}\to\operatorname{Ker}f\hookrightarrow M\xrightarrow f aR\to\{0\}$$ splits. Consequently, $\operatorname{Ker}f$ is a direct summand of $M$.
More explicity, let $x_0\in M$ such that $f(x_0)=a$ and $N=x_0R\subseteq M$. Then clearly $N\cap\operatorname{Ker}f=\{0\}$ and for every $x\in M$ we have $$x=\underbrace{x_0\frac{f(x)}a}_{\in N}+\underbrace{\left(x-x_0\frac{f(x)}a\right)}_{\in\operatorname{Ker}f}$$ thus proving $M=N+\operatorname{Ker}f$ and hence $M=N\oplus\operatorname{Ker}f$ as internal direct sum.
Alternatively, \begin{align} N\times\operatorname{Ker}f&\to M& (x,y)&\mapsto x+y\\ M&\to N\times\operatorname{Ker}f& x&\mapsto\left(x_0\frac{f(x)}a,x-x_0\frac{f(x)}a\right) \end{align} are inverse each other isomorphisms.