I read a book and I don't understand one transition:
$R$ is a PID. $M$ is a finitely generated module. Thus there exists a surjective $\varphi:R^n\to M$. $R$ is PID therefore $R$ is noetherian, thus $R^n$ is noetherian thus $\ker\varphi\subseteq R^n$ is finitely generated. Thus there exists $\psi :R^m\to R^n$ such that $\operatorname{Im} \psi=\ker\varphi$.
The transition that I don't understand is why is $M=\operatorname{coker} \psi$?
I know that $\operatorname{coker}\psi=R^n/\operatorname {Im}\psi=R^n/\ker\varphi$. I don't understand how does $M=\operatorname {coker}\psi$. Thanks.
We have $M = \text{im}(\varphi) \cong R^n/\text{ker}(\varphi) = R^n/\text{im}(\psi) = \text{coker}(\psi)$.