My question: How $K = d_1 \mathbb{Z} \times d_2 \mathbb{Z} \times \dots d_s \mathbb{Z}$ especially when ${\{x_1,x_2, \dots, x_n}\}$ is not a basis that we choose arbitrarilry, i.e. it is such a basis such that some basis of any subgroup of it to turn out to be of the form ${\{d_1 x_1,d_2 x_2, \dots, d_s x_s}\}$?
Please help. Thanks!
Added for clarity: I need rigorously prove $K = d_1 \mathbb{Z} \times d_2 \mathbb{Z} \times \dots d_s \mathbb{Z}$ which I can't.

$G$ is finitely generated by $n$ elements, say $\{a_1,a_2,...,a_n\}$. According to theorem $38.8$, the map $\phi : F\to G $ given by $\phi(h_1,\ldots,h_n) = h_1a_1+\ldots + h_na_n$ is a map which is onto $G$ (i.e. the image of $\phi$ is the whole of $G$) because $G$ is generated by the elements $a_1,\ldots , a_n$.
Now, according to the first isomorphism theorem Theorem $14.11$, $\frac{F}{\ker \phi} \cong G$, where $\ker \phi$ is the kernel of the map $\phi$.
All we are left to do then, is understand this kernel, and see if quotienting $F$ by it has any particular group structure. Of course $G$ has that same structure, and we are done.
This is in fact true, and is the content of Theorem 38.11. The remark before that is illuminating :
This clearly tells you that $\{x_1,\ldots,x_n\}$ and $\{d_1x_1,\ldots,d_nx_n\}$ are not arbitrarily chosen, but rather constructed so that this property holds.
Let us state Theorem $38.11$ then.
For this, we use the theorem $38.9$, which states in words that given a basis, if you change one element by adding a multiple of a different element then the new set remains a basis. The proof of that is elementary and I choose not to go over it.
I will instead go over the proof of theorem $38.11$, with more clarity on what is going on.
So what we do is to prove that $K$ has a basis of the desired form, that will tell you that it is free abelian of rank at most $n$.
The point is that our start itself is with a basis specifically chosen to minimize a certain constraint. Namely, because $K$ is a subset of $G$, given a basis, every element of $K$ can be written as a linear combination of elements of that basis. We have the coefficients of this linear combination, they will be integers, and at least one of them will be non-zero.
Let's do the specifics. Given a basis $B = \{y_1,...,y_n\}$, we define a number $k_B$, as follows : $$ k_B = min\{|l| > 0 : \text{there is a non-zero element $k \in K$}\\\text{ so that when $k$ is written in terms of the basis $B$, at least one of the coefficients equals $l$}\} $$
So basically, express every non-zero element of $k$ in terms of $B$. Pick the smallest ever non-zero coefficient (in absolute value) that you see in any of the expansions, and that is $k_B$.
A simple example : Take $G = \mathbb Z$ with the basis $B = \{1\}$. The subgroup $K = 10873 \mathbb Z$ of $\mathbb Z$ would have $k_B = 10873$, because if I express every non-zero element of $K$ in terms of the basis, the smallest such coefficient in absolute value is certainly $10873$, so that is $k_B$. (This is just to give you an idea that $k_B$ need not always be a small number.)
Now, a basis $B$ is chosen so that $k_B$ is as small as possible. Because $k_B$ is an integer, such a basis exists. That basis, we call as $B = \{y_1,y_2,...,y_n\}$.
Recall, $k_B$ is the smallest coefficient you see in any of the expansions, so it is a coefficient of one of $y_1,y_2,...,y_n$. "By renumbering, if necessary" basically permutes the $y_i$ (it still remains a basis, of course) so that the coefficient $k_B$ was in fact of $y_1$.
This coefficient $k_B$ would have come in the expansion of some non-zero element of $K$. We call that element as $w_1$. Now we call $k_B = d_1$. Note that $w_1 = d_1y_1 + k_2y_2 + k_3y_3 + \ldots + k_ny_n$ where $k_i$ are the other coefficients.
Finally , we run something similar to the Euclidean algorithm. Note that $d_1$ is the smallest coefficient , so we can express $k_i = q_id_1+r_i$, that is we have a quotient and remainder of the division of $k_i$ by $d_i$, which we call $q_i,r_i$ respectively. Remember that $0 \leq r_i \leq d_1$ for each $i$.
Now, we do something cheeky. We find a new basis whose $k_B$ is smaller than $d_1$. But then this basis was chosen to minimize that quantity, so something must give way.
How? Well, the rearrangement : $$ w_1 = d_1y_1 + k_2y_2 + \ldots + k_ny_n \\ = d_1y_1 + (q_2d_1+r_1)y_2 + \ldots + (qd_n+r_n)y_n \\ = d_1(y_1+q_2y_2 + \ldots + q_ny_n) + r_2y_2 + \ldots + r_ny_n \\ $$
along with setting $x_1 = (y_1 + q_2y_2 + \ldots + q_ny_n)$, tells you by Theorem $38.9$ (repeated applications : we are adding multiples of $y_2,...,y_n$ to $y_1$) that $x_1,y_2,...,y_n$ is also a basis. But then, $w_1$ written in this basis has coefficients which are smaller than $d_1$, namely the $r_i$. To uphold the condition we had, we must have each of the remainders $r_i$ as zero.
In other words, $d_1x_1 = w_1$.
Finally, we now "induct" this argument. Our first argument is to dispose of $x_1$. To do this, note that if any other element $w_2 \in K$ was written in terms of the basis $x_1,y_2,...,y_n$ then the coefficient of $x_1$ in $w_2$ must be a multiple of $d_1$. Why? If not then the coefficient leaves a non-zero remainder $R$ (and quotient $q$, say), but $w_2-qw_1$ would have $R$ as the coefficient of $x_1$ with $R < d_1$, contradicting the definition of $d_1$.
In other words, given any $w_2 \in K$, we have $w_2 = h_1x_1 + h_2y_2 + ... + h_ny_n$, now $h_1x_1$ is a multiple of $d_1x_1$ so belongs in $K$ hence $h_2y_2 + ... + h_ny_n$ belongs in $K$. This fact will be important.
We do exactly what we did earlier now. Consider all bases $B$ of $G$ which contain $x_1$. These are of the form $\{x_1,y_2,...,y_n\}$. We shall call these bases as $B_{x_1}$ bases, because they contain $x_1$.
Define for any $B_{x_1}$ basis : $$ c_B = min\{|l| > 0 : \text{there is a non-zero element $k \in K$}\\\text{so that when $k$ is written in terms of the basis $B$, at least one of the coefficients} \\ \text{of a basis element which is *not $x_1$* equals $l$}\} $$
So now we are looking at the smallest coefficient of any basis element in any expansion, ignoring the $x_1$ coefficient.
However, something else can happen here. It is possible that every element of $K$ is of the form $h_1x_1$. In that case, if we write any element of $K$ in terms of a basis, there won't be a coefficient to focus on other than that of $x_1$. In that case, we STOP, and proceed to the end step.
If the above doesn't happen then $c_B \neq 0$, and we can choose a $B_{x_1}$ basis $B$ which minimizes $c_B$ (which we call as $x_1,y_2,...,y_n$, but other than $x_1$, all the $y_i$s will have changed from the previous step because our choice of basis is fresh, so don't get confused), and again permute the elements of that basis so that for some element $w_2 \in K$, the expansion of $w_2$ in this basis has $y_2$ coefficient as $c_B$.
Finally, we call $d_2 = c_B$. Note that $w_2 = h_1x_1 + d_2y_2 + k_3y_3 + \ldots + k_ny_n$. However, using our fact earlier, the element $w'_2 = d_2y_2 + k_3y_3 + \ldots + k_ny_n$ also belongs in $K$.
Now, we may again express the division of each $k_3,k_4$ etc. by $d_2$ as a quotient/remainder , and do the same thing as earlier to conclude by minimality of $d_2$ that $d_2x_2 \in K$ for $x_2$ defined using the quotients and remainders obtained above(just like $x_1$, really), and $\{x_1,x_2,y_3,...,y_n\}$ is a basis for $G$.
Finally, one sees how $d_1,d_2,...$ are obtained. We just need to see that $d_1$ divides $d_2$ and so on, then we can go to the end step.
Why does $d_1$ divide $d_2$? We will use the minimality of $d_1$ and the same remainder technique. Well, the element $d_1x_1 + d_2x_2$ belongs in $K$ because each $d_ix_i$ does. But suppose that $d_2 = d_1q+r$ (for some quotient and remainder) then this element is $d_1(x_1 + qx_2) + rx_2$ as well, and noticing by Theorem $38.9$ that changing $x_1$ to $x_1+qx_2$ creates a new basis, and in this basis the above element has a coefficient $r < d_1$, tells you by minimality of $d_1$ that $r=0$ i.e. $d_1$ divides $d_2$.
Now we proceed to a third step, fourth and so on. Each time we fix a basis containing $x_1,x_2$ and look at the smallest coefficient of any other basis element in any expansion. Then we use a remainder argument to generate an $x_3$, whose $d_3$ is shown to be a multiple of $d_2$ using the minimality of $d_2$.
At some point, it must happen (because $K \leq G$) that all elements of $K$ can be written in terms of the $x_i$. We go to the end step.
The end step has a basis (which is the basis formed by the last coefficient minimizer with an $x_i$ replacing one of the $y_i$) which is $\{x_1,x_2,...,x_s,y_{s+1},...,y_n\}$. The set $\{d_1x_1,d_2x_2,...,d_sx_s\}$ is a basis of $K$ (because each of $d_1x_1,d_2x_2,...,d_sx_s$ can't be written as a linear combination in terms of the other elements, but all of them together cover $K$ : that's why we can stop in the last step) and the whole thing is a basis of $G$. Of course, the $d_i$ division condition is satisfied, and we are finally done with the proof of theorem $38.11$.
So it is clear that the basis of theorem $38.12$ is carefully chosen. However, once these are chosen, only the $d_i$ matter. We know that $d_1x_1,...,d_sx_s$ is a basis of $K$. Define the map from $K \to \mathbb d_1Z \times ... \times d_n \mathbb Z$ as $h_1x_1 + + ... + h_nx_n \to (h_1,...,h_n)$. It is clear from a sub-argument in the proof of Theorem $38.11$ that each $h_i$ is a multiple of $d_i$, so the map is well defined. It is a homomorphism for reasons similar to theorem $38.8$, and is in fact an isomorphism , because any $(h_1,...,h_n) \in \mathbb d_1Z \times ... \times d_n \mathbb Z$ is the image of $h_1x_1 + ... + h_nx_n$ (i.e. it is surjective) and if something maps to $(0,0,...,0)$ then that element must be $0x_1 + 0x_2 + ... + 0x_n = 0$ i.e. the zero element (so it is injective).
So $K \cong d_1\mathbb Z \times ... \times d_s \mathbb Z$. It is also isomorphic to $d_1 \mathbb Z \times ... \times d_s \mathbb Z \times \underbrace{\{0\} \times \{0\} \times ... \times \{0\}}_{\text{$n-s$ times}}$ from the map that just adds the extra $0$s to the right of any integer tuple.
Finally, $F/K$ is simplified using the product splitting over quotient rule
extended to multiple groups.
This completes the proof of the main theorem, and hopefully clarifies your doubts.