Does $\text{rank}(M/M')=\text{rank}(M)-\text{rank}(M')$ hold for a free module over a PID? Let $M$ be a free module over a PID, $\text{rank}(M)<\infty$, $M'$ submodule of $M$, then  $\text{rank}(M/M')=\text{rank}(M)-\text{rank}(M')$?
 A: The answer is yes, as $M'$ and $M$ are both free the inclusion map $M' \to M$ is given by a matrix and this matrix can be put into Smith Normal Form which is a matrix of the form
$$\begin{bmatrix}a_1 \\ & a_2 \\ && \ddots \\ &&& a_n \\ &&& \mbox{} \\ &&& \mbox{} \\ &&& \mbox{} \end{bmatrix}$$
(entries only on the diagonal, even though the matrix need not be square) with $a_i \neq 0$.
We know there are no zeros on the diagonal because the matrix is injective.  If this is an $s \times t$ matrix then the ranks of $M'$ and $M$ are $t$ and $s$ respectively (with $t \leq s$, hence the depiction of the matrix as being tall).
The cokernel of this matrix is isomorphic to $M/M'$ and you can see it is exactly $R/(a_1) \oplus \cdots \oplus R/(a_n) \oplus R^{s - t}$, so $M/M'$ has rank $s - t$.
A: Since any finitely generated module $M$ over a PID $R$ can be decomposed as $F\oplus T$, where $F$ is free and $T$ is torsion, it follows that
$$
\operatorname{rank}M=\dim M\otimes_R Q
$$
where $Q$ is the field of fractions of $R$ and $M\otimes_RQ$ is considered as $Q$-vector space in the obvious way. Note that $T\otimes_RQ=0$, if $T$ is torsion.
Since $Q$ is flat as $R$-module, from the exact sequence
$$
0\to M'\to M\to M/M'\to0
$$
we get the exact sequence
$$
0\to M'\otimes_RQ\to M\otimes_RQ\to(M/M')\otimes_RQ\to0
$$
and the rank-nullity theorem gives you the required identity
$$
\operatorname{rank}M/M'=\operatorname{rank}M-\operatorname{rank}M'.
$$
