Filling in the missing steps in a proof of the Funtamental Theorem of Finitely Generated Abelian Groups. I'm struggling to grasp this proof of the Fundamental Theorem of Finitely Generated Abelian Groups, particularly the first theorem, which states:
Theorem: Let $K\leq \mathbb{Z}^n$, then $K\cong d_1\mathbb{Z}\oplus \ldots \oplus d_r\mathbb{Z}$ and $\mathbb{Z}^n/K\cong \mathbb{Z}/d_1\mathbb{Z}\oplus \ldots \oplus \mathbb{Z}/d_r\mathbb{Z}$ for some $d_i|d_{i+1}$ bigger than zero.
My specific issue is that I do not understand how the matrix having a Smith Normal Form implies the result. Perhaps the idea is that the row vectors form a basis of $K$, but this isn't clear to me since column operations were applied.
I'd appreciate any help.
 A: You got a comment by @hunter explaining in a down to earth fashion what effect row and column operations have on the quotient $\mathbb Z^n / K$. I'll present here a bit of a different approach that doesn't touch on the specifics of row/column operations much but still follows the basic principle of the proof. It's more abstract and long, involving linear transformations and commutative diagrams, but I think the approach is quite elegant once you internalize the details. Please feel free to comment if you want some clarification.
Applying elementary row operations to a matrix $A$ can be interpreted as multiplying $A$ on the left by certain elementary matrices. For instance, there is the permutation matrix $P_{ij}$ which is the identity matrix after switching the $i^{th}$ and $j^{th}$ row. Then $P_{ij} A$ ends up being $A$ after switching the $i^{th}$ and $j^{th}$ rows. The same idea holds for column operations, where instead you multiply on the right. Point being, saying that $A$ is transformed to $S$ via elementary row and column operations tells us that $A = PSQ$ where $P, Q$ are invertible square matrices of the appropriate dimension.
In the specific case of the proof you cite, the row space of $A$ is precisely $K$, but in what I'm going to do I really want to image of $A$ to be $K$. The image of a matrix is just its column space, so I instead want to consider the transpose $A^t$, whose columns are given by generators $k_1, \dots, k_m \in K$.
Now, we can interpret the $n \times m$ matrix $B = A^t$ as a linear transformation $\mathbb Z^m \longrightarrow \mathbb Z^n$. The notable property of this linear transformation is that its image is $K$. Now, we can perform row and column operations on $B$ to find a matrix $D$ in Smith normal form. As discussed above, by keeping track of these operations we can write $D = PBQ$ for some invertible matrices $P \in GL_n(\mathbb Z)$ and $Q \in GL_m(\mathbb Z)$. If you're not familiar with this notation, it means that $P, Q$ are invertible integer matrices and that $P$ is $n \times n$ and $Q$ is $m \times m$. We can represent this data concisely with the following commutative diagram:
$$
\require{AMScd}
\begin{CD}
\mathbb Z^m @>B>> \mathbb Z^n \\
@AQAA @VVPV \\
\mathbb Z^m @>>D> \mathbb Z^n
\end{CD}
$$
Or alternatively, we can write it like this:
$$
\require{AMScd}
\begin{CD}
\mathbb Z^m @>B>> \mathbb Z^n \\
@VQ^{-1}VV @VVPV \\
\mathbb Z^m @>>D> \mathbb Z^n
\end{CD}
$$
Now, the quantity we are interested in understanding is $\mathbb Z^n / K = \mathbb Z^n / im(B)$ (by the way, this is called the cokernel of $B$). Since $P, Q$ are invertible matrices, the linear transformations they correspond to are isomorphisms. The above diagrams say that the maps $B, D: \mathbb Z^m \longrightarrow \mathbb Z^n$ are the same up to isomorphism, so we should expect the quantities $\mathbb Z^n/im(B)$ (the cokernel of $B$) and $\mathbb Z^n/im(D)$ (the cokernel of $D$) to be isomorphic as well.
To prove this, we need to define a map between them. Since $P: \mathbb Z^n \longrightarrow \mathbb Z^n$ is an isomorphism, we will try to reduce $P$ to the quotient $\mathbb Z^n / im(B) \longrightarrow \mathbb Z^n / im(D)$. Indeed, we have the composition $\mathbb Z^n \xrightarrow{P} \mathbb Z^n \rightarrow \mathbb Z^n / im(D)$ of $P$ with the quotient map. Its kernel is $P^{-1}[im(D)]$ because $P$ is an isomorphism. Hence, by the first isomorphism theorem, this yields an isomorphism $\mathbb Z^n / P^{-1}[im(D)] \longrightarrow \mathbb Z^n / im(D)$. Explicitly, this maps $a + P^{-1}[im(D)] \mapsto P(a) + im(D)$.
Now, we just need to show that $P^{-1}[im(D)] = im(B)$. This comes immediately from the equation $PB = D Q^{-1}$. Indeed, taking the image of both sides yields $im(PB) = im(D Q^{-1})$, so $P[im(B)] = D[im(Q^{-1})]$. $Q^{-1}$ is an isomorphism so the right hand side is just $im(D)$. Thus, $P[im(B)] = im(D)$ so $P^{-1}[im(D)] = im(B)$. This allows us to form the isomorphism $\mathbb Z^n / im(B) \longrightarrow \mathbb Z^n / im(D)$ via $a + im(B) \mapsto P(a) + im(D)$.
With all of this done, let's summarize the results, recalling that $im(B) = K$. We have found an isomorphism $P|_K: K \longrightarrow im(D)$ and concluded that $\mathbb Z^n / K \cong \mathbb Z^n / im(D)$. As $D$ was in Smith normal form, let's say its diagonal entries are $d_1 \mid \dots \mid d_r$. Then $im(D) = d_1 \mathbb Z \oplus \dots \oplus d_r \mathbb Z$ and the quotient $\mathbb Z^n / im(D) \cong \mathbb Z/d_1\mathbb Z \oplus \dots \oplus \mathbb Z/ d_r \mathbb Z \oplus \mathbb Z^{n - r}$. Hence, $K \cong d_1 \mathbb Z \oplus \dots \oplus d_r \mathbb Z$ and $\mathbb Z^n / K \cong \mathbb Z/d_1\mathbb Z \oplus \dots \oplus \mathbb Z/ d_r \mathbb Z \oplus \mathbb Z^{n - r}$ as desired.
Now, I know this is a very long response. That's mostly because I gave many details, but once you're used to these sorts of ideas, you can arrive at such proofs very quickly. For instance, when I saw this problem, my thought process went "$B$ is equivalent to a matrix in Smith normal form $D$ so their cokernels must agree, and it's easy to compute the image and cokernel in Smith normal form." That one sentence really is the content of the entire proof, the rest are details.
