Let $M$ be a finitely generated $R$-module. suppose $m_i, ..., m_k$ and $p_i, ..., p_n$ are elements in $M$ so that ${m_i, ..., m_k}$ is linearly independent over ring $R$, and ${p_i, ..., p_n}$ is a set of generators of $M$. then $k\le n$. furthermore, if $k=n$ then ${p_i, ..., p_n}$ is a free $R$-module basis of $M$.
The proof from my textbook is in the image description below. I do not understand why they use a quotient ring to prove the second point, that is if $k=n$ then ${p_i, ..., p_n}$ is a free $R$-module basis of $M$. Can you please help me to explain? Thank you.
