How to get from relation matrix in smith normal form to direct product of cyclic groups?

So...we have an abelian group $G$ with generating set {$g_1,\ldots,g_n$} the following homomorphism has been formed ($F$ is a free group generated by {$f_1,\ldots,f_n$}); \begin{align} \phi:F &\rightarrow G \newline k_1f_1+\ldots +k_nf_n &\mapsto k_1g_1+\ldots +k_ng_n \end{align} Using the first isomorphism theorem $G \cong F/K$ where $K = \operatorname{Ker}(\phi)$. It can be shown that since $K$ is a subgroup of $F$ that it is itself free and finitely generated by {$r_1,\ldots,r_m$}, where $m \leq n$. The generators of $K$ can be expressed as; $$\textbf{r} = A\textbf{f}$$ where $\textbf{r} = (r_1,\ldots,r_m)^T$, $\textbf{f} = (f_1,\ldots f_n)^T$ and $A = (a_{ij})$ is an $m \times n$ matrix. It can be shown that $P\textbf{r}=PA\textbf{f}$ also generates $K$, and also that $P\textbf{r} = PAQ(Q^{-1}\textbf{f})$ generates $K$. So choosing suitable matrices $P$ and $Q$ we can show that $K$ is generated by {$a_1f'_1,\ldots,a_nf'_n$} where $a_i \in \mathbb{N}$ for $i=1,\ldots,m$ and $a_i = 0$ for $i = m+1,\ldots,n$. Now this is where my difficulties begin, that is if what i've outlined up to now makes any sense, using $\phi$ we can investigate the orders of the generating set for $G$. An element $x = k_1g_1+\ldots +k_ng_n \in G$ is equal to the identity iff $k_1f'_1+\ldots +k_nf'_n \in K$ therefore $k_ig_i=e$ iff $k_if'_i \in K$ and $k_if'_i \in K$ iff $a_i |k_i$. So we conclude from this that $|g_i| = a_i$ for $i=1,\ldots ,m$ and $|g_i| = \infty$ for $i = m+1,\ldots,n$, and also that $\langle g_i \rangle \cong \mathbb{Z}/a_i\mathbb{Z}$ for $i=1,\ldots ,m$ and $\langle g_i \rangle \cong \mathbb{Z}$ for $i = m+1,\ldots,n$. Now I need to show that $G \cong \langle g_1 \rangle \oplus \ldots \oplus \langle g_m \rangle \oplus \mathbb{Z}^{n-m}$ but haven't got a clue how to go about it. I know i must show that the intersection $\langle g_i \rangle \cap \langle g_j \rangle=e$ for $i \not = j$ and that any $x \in G$ can be expressed as $k_1g_1+\ldots +k_ng_n$ (this follows from the fact that the set {$g_1,\ldots,g_n$} generates $G$ ?) and that $|G| =|g_i|\ldots|g_n|=a_1\ldots a_n$.

The question boils down to this - given an abelian group $G$ and two distinct elements $g_1,g_2 \in G$ is the intersection of the cyclic subgroups generated by $g_1$ and $g_2$ trivial?

-
Your final question has a trivial negative answer: the only groups where that holds are groups of exponent $2$. Otherwise, let $g_1$ be any element that is not equal to its own inverse, and take $g_2=g_1^{-1}$. –  Arturo Magidin Mar 28 '12 at 22:24

What you do before the horizontal line does not work: your map sends $k_1f_1+\cdots+k_nf_n$ to $k_1g_1+\cdots+k_ng_n$, but it does not necessarily send $k_1f'_1+\cdots k_nf'_n$ to $k_1g_1+\cdots+k_ng_n$; so your claim that $k_1g_1+\cdots+k_ng_n=0$ if and only if $k_1f'_1+\cdots+k_nf'_n\in K$ is incorrect. As to your final conclusion, you certainly cannot conclude that: start with $G=\mathbb{Z}/4\mathbb{Z}$, $g_1=\overline{1}$ and $g_2=\overline{2}$; you are claiming that $\mathbb{Z}/4\mathbb{Z}\cong\mathbb{Z}/4\mathbb{Z}\oplus\mathbb{Z}/2\mathbb{Z}$.

To see how you went wrong, let's go through your argument using that example above. $F=\mathbb{Z}\times\mathbb{Z}$, $G=\mathbb{Z}/4\mathbb{Z}$, $g_1=\overline{1}$, $g_2=\overline{2}$, $\phi(a,b) = \overline{a+2b}$. The kernel of $\phi$ is generated by $(4,0)$, $(0,2)$, and $(2,1)$. We can do a change of basis for $F$ to the basis $\mathbf{f}'_1=(1,0), \mathbf{f}'_2=(2,1)$; the kernel of $\phi$ is now generated by $4\mathbf{f}'_1$ and $\mathbf{f}'_2$. However, $\phi(a\mathbf{f}'_1+b\mathbf{f}'_2) = \phi(a+2b,b) = \overline{a+4b}\neq ag_1+bg_2$.

What you need to do is that after you replace $f_1,\ldots,f_n$ with $f'_1,\ldots,f'_n$, then you need to replace $g_1,\ldots,g_n$ with $g'_i=\phi(f'_i)$ for $i=1,\ldots,n$. Then your conclusions hold, and the final step is easy: if $\alpha g'_i\in\langle g'_1,\ldots,g'_{i-1},g'_{i+1},\ldots,g'_n\rangle$, then we can express $g'_i$ as combination of the rest, which gives $$b_1g'_1+\cdots + b_{i-1}g'_{i-1}-\alpha g'_i+b_{i+1}g'_{i+1}+\cdots+b_ng_n = 0,$$ hence $$b_1f'_1+\cdots + b_{i-1}f'_{i-1} - \alpha f'_i + b_{i+1}f'_{i+1}+\cdots+b_nf'_n\in K$$ hence $a_i|\alpha$, so $\alpha g'_i=0$. So for each $i$ we have $$\langle g'_i\rangle\cap\langle g_j\mid j\neq i\rangle = \{0\},$$ so the subgroup generated by the $g'_i$ is isomorphic to the direct sum of the cyclic groups generated by the $g'_i$.

But you cannot use the original $g_i$ this way.

The final question, that was posted elsewhere and then closed, has a negative answer in most groups. In fact:

Theorem. Let $G$ be a group such that whenever $x\neq y$ we have $\langle x\rangle \cap \langle y\rangle = \{e\}$. Then $G$ is an abelian group and every element is its own inverse. Assuming the Axiom of Choice, this implies that $G$ is isomorphic to a (possibly infinite) direct sum of copies of the cyclic group of order $2$.

Proof. If $G$ has an element that is not equal to its own inverse, then $\langle x\rangle\cap\langle x^{-1}\rangle\neq\{e\}$, since the intersection contains $x$, and $x\neq e$. Thus, every element of $G$ is of exponent $2$; this is well-known to imply that $G$ is abelian. Hence $G$ is a vector space over $\mathbb{F}_2$; assuming the Axiom of Choice, a basis for $G$ affords a representation of $G$ as a direct sum of copies of the cyclic group of order $2$, as claimed. $\Box$

-
That has got me half way there, I can see that if you assume that some element $x$ from the cyclic subgroup generated by $g'_i$ is equal to a combination of all the other generators then that combination minus $x$ is equal to the identity...and so there is a corresponding element in $K$...i don't get the next part.. –  joshua Mar 28 '12 at 23:03
$\alpha g'_i \in \langle g'_i \rangle$, we also assume that $\alpha g'_i \in \langle g'_j \rangle$. If that is the case then $\alpha g'_i = kg'_j$ for some $k \in \mathbb{Z}$, this implies that $\alpha g'_i - kg'_j = 0$ and so there is a corresponding element $\alpha f'_i - kf'_j \in K$. This element is only in $K$ if $a_i | \alpha$ and $a_j | k$, $a_i | \alpha \implies \alpha g'_i = 0$. Therefore the only element that is in both $\langle g'_i \rangle$ and $\langle g'_j \rangle$ is the identity. –  joshua Mar 28 '12 at 23:20
@joshua: If $H_i$ are a nonempty family of subgroups of an abelian group $G$, then $G$ is the direct sum of the $H_i$ if and only if (i) $G=\langle H_i\rangle$; and (ii) $H_i\cap\langle H_j\mid j\neq i\rangle = \{0\}$. You don't just check the generators, you need to check the entire subgroup. In order to check the intersection of $\langle g'_i\rangle$ and $\langle g'_j|j\neq i\rangle$, any element of the intersection lies in $\langle g'_i\rangle$, hence can be written as $\alpha g'_i$ for some $\alpha$. (cont) –  Arturo Magidin Mar 29 '12 at 2:56
@joshua (cont) You cannot assume that it is merely equal to some $kg'_j$, because it is not enough to check $\langle g_i\rangle \cap \langle g_j\rangle = \{0\}$, you need to check that $\langle g_i\rangle$ intersects trivially with the subgroup generated by **all the other $g'_j$** (not just one). So you need to set it equal to some combination $$k_1g'_i + \cdots + k_{i-1}g'_{i-1}+k_{i+1}g'_{i+1}+\cdots+k_ng_n$$and not merely to a multiple of a single other generator. –  Arturo Magidin Mar 29 '12 at 2:58