Using Smith Normal Form to understand cokernel of a map between $\mathbb{Z}$-modules I want to explicitly understand the $\mathbb{Z}$-module I constructed as $M = \mathbb{Z}^4/\mathrm{im}(A)$, where $A\colon \mathbb{Z}^6 \to \mathbb{Z}^4$ is represented by the matrix
$$
    A = 
    \begin{pmatrix}
    1 & -1 &  0 & 1 &  0 & 0 \\
    1 &  0 & -1 & 0 &  1 & 0 \\
    0 &  1 &  -1 & 0 &  0 & 1 \\
    0 &  0 &  0 & 1 & -1 & 1 
    \end{pmatrix}    
.$$
In order to do so, I have computed the Smith Normal Form of A as
$$PAQ = 
\begin{pmatrix}
1 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 
\end{pmatrix}
,$$
where
$$
P = 
\begin{pmatrix}
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 \\
-1 & 1 & -1 & 1
\end{pmatrix} 
\text{ and }
Q = 
\begin{pmatrix}
1 & 0 & 0 & 0 & 1 & -1 \\
0 & 1 & 0 & -1 & 0 & -1 \\
0 & 0 & 0 & 0 & 0 & -1 \\
0 & 0 & 1 & -1 & -1 & 0 \\
0 & 0 & 0 & 0 & -1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0
\end{pmatrix}
$$
As I understand it, this tells me that the image of $A$ is isomorphic to $\mathbb{Z}^3 \oplus \{0\}$, and so $M \cong \mathbb{Z}$. However, knowing this in the abstract isn’t enough for my purposes, I need to explicitly know the map $\mathbb{Z}^4 \to M \to \mathbb{Z}$, where the first arrow is the projection $v \mapsto v + \mathrm{im}(A)$ and the second is an isomorphism. I suspect that this map can be constructed somehow via the matrix $P$, but I must admit I don’t understand the Smith Normal Form well enough to see how.
 A: Ended up being able to work out the answer myself:
Since $Q$ is a change of basis matrix of $\mathbb{Z}^6$, we have $\mathrm{im}(A) = \mathrm{im}(AQ)$, which is the column space of
$$
AQ = 
\begin{pmatrix}
    1 & -1 & 1 & 0 & 0 & 0 \\
    1 &  0 & 0 & 0 & 0 & 0 \\
    0 &  1 & 0 & 0 & 0 & 0 \\
    0 &  0 & 1 & 0 & 0 & 0
\end{pmatrix},    
$$
i.e. $\left\{\begin{pmatrix}  a-b+c & a & b & c \end{pmatrix}^T\ \middle|\ a,b,c \in \mathbb{Z}\right\}$.
Set $f_1, \dots, f_4$ to be the columns of
$$
    P^{-1} = 
    \begin{pmatrix}
        1 &-1 & 1 &-1 \\
        1 & 0 & 0 & 0 \\
        0 & 1 & 0 & 0 \\
        0 & 0 & 1 & 0
    \end{pmatrix}.
$$
Then we see that $\mathbb{Z}^4 / \mathrm{im}(A) = \frac{\mathbb{Z} f_1 \oplus \mathbb{Z} f_2 \oplus \mathbb{Z} f_3 \oplus \mathbb{Z} f_4}{\mathbb{Z} f_1 \oplus \mathbb{Z} f_2 \oplus \mathbb{Z} f_3} \cong \mathbb{Z} f_4$. The canonical dual basis $\{\phi^i\}$ of the $f_i$ is given by (left-multiplication with) the rows of $P$. In particular, the map $\phi^4 \colon \mathbb{Z}^4 \to \mathbb{Z}$ given by $\begin{pmatrix} a & b & c & d \end{pmatrix}^T \mapsto (-a+b-c+d)$ induces the desired isomorphism $\mathcal{M} \to \mathbb{Z}$.
