Rank-nullity theorem for free $\mathbb Z$-modules
From linear algebra we know that given vector spaces $V$, $W$ over a field $k$ and a linear map $f\colon V\to W$ we have $$\dim V = \dim \operatorname{im} f + \dim \ker f.$$
Is this still true when we consider free $\mathbb Z$-modules (i.e. free abelian groups) instead of vector spaces? Given a homomorphism $f\colon G\to H$ between free $\mathbb Z$-modules, do we have $$\operatorname{rk}(G) = \operatorname{rk}\operatorname{im} f + \operatorname{rk}\ker f?$$
To provide some context: This question comes up when computing homology groups of free chain complexes, where we need to check if some generating set of a kernel is a basis. Using the rank nullity theorem for free $\mathbb Z$-modules is an appealing way to do this.
Solution 1:
Here is a proof that doesn't involve going through $\mathbb{Q}$ (and works for any PID):
The image of $f$ is a submodule of a free module, so it is itself free (since $\mathbb{Z}$ is a PID). Therefore the short exact sequence $0 \to \operatorname{ker} f \to G \to \operatorname{im} f \to 0$ is split, and therefore (general fact about split exact sequences of modules) $G \cong \operatorname{ker} f \oplus \operatorname{im} f$. The result about the ranks follows immediately.
Solution 2:
Yes, for morphisms between free Abelian groups this holds. Just interpret the matrix with respect to some basis as one with rational coefficients, and use its rank, and kernel dimension. Formally this means applying the functor of tensoring with the rational numbers.
Note however that much interesting things about Abelian groups involves torsion, which is ignored here because of the insistence upon free modules. Also note that a free module can have a proper submodule of the same rank as itself. In particular an endomorphism having kernel of rank$~0$ does not have to be an automorphism (it may fail to be surjective).