You can compute the Smith normal form $B$ of the matrix with rows $a_1,\dots,a_n$. The rows generate $\mathbb{Z}^k$ if and only if the main diagonal entries of $B$ are $\pm 1$. (SNF over $\mathbb{Z}$ is determined only up to multiplication of the diagonal entries by $\pm 1$, and conventionally they are chosen to be 1.)
Richard Stanley
- 50.8k
- 14
- 155
- 279