TITLE: Why is this statement about generators of groups true?
QUESTION [9 upvotes]: Let $G$ be free abelian of rank $n$ and $H \subseteq G$ a subgroup also of rank $n$. It is known that $G/H$ is finite, in fact a direct sum of at most $n$ cyclic groups. Thus we can write $$G/H = \langle x_1,\ldots,x_n | d_1x_1 = \cdots =d_nx_n = 0\rangle,$$ where the $d_i$'s are the orders of those cyclic groups. From here why does it follow that there is a basis $\beta_1,\ldots,\beta_n$ of $G$ such that $d_1\beta_1,\ldots ,d_n\beta_n$ is a basis for $H$? 
Thanks!

REPLY [2 votes]: Suppose that $G/H\simeq \mathbb Z_{d_1}\oplus\cdots\oplus\mathbb Z_{d_n}$. (Note that some of $d_i$'s can be equal to $1$.) 
Set $D=\operatorname{diag}(d_1,\dots,d_n)$. This matrix is equivalent to a matrix $C=\operatorname{diag}(c_1,\dots,c_n)$ (called the Smith Normal Form of $D$) with $c_1\mid\cdots\mid c_n$, that is, there are $U,V\in\mathrm{GL}_n(\mathbb Z)$ such that $UDV=C$. One knows that there exists a basis $g_1,\dots,g_n$ in $G$ such that $c_1g_1,\dots,c_ng_n$ is a basis of $H$. Note that $(c_1g_1,\dots,c_ng_n)^T=C(g_1,\dots,g_n)^T$. Since $C=UDV$ we get that $UDV(g_1,\dots,g_n)^T$ is a basis of $H$. But $U$ is invertible, so $DV(g_1,\dots,g_n)^T$ is also a basis of $H$. On the other side, since $V$ is invertible it follows that $(x_1,\dots,x_n)^T:=V(g_1,\dots,g_n)^T$ is a basis of $G$. Finally we get that $D(x_1,\dots,x_n)^T$ is a basis of $H$, i.e. $d_1x_1,\dots,d_nx_n$ is a basis of $H$.