Given R, a PID, and two finitely generated R-modules A and B, suppose $\varphi: A \rightarrow B$ is a homomorphism.
If B is a free module, show that $A \cong \ker(\varphi) \oplus \mathrm{im}(\varphi)$.
I understand how to use the universal property of modules to do this if $\varphi$ was a surjective homomorphism, but I'm not sure how to do this without assuming that.
Assuming that by "free" you mean "free of finite rank": Consider following exact sequence $$0 \to \ker (\phi) \to A \to \mathrm{im}(\phi) \to 0.$$ Then note that, since $R$ is a PID, $\mathrm{im}(\phi)$ is also a free module.