Let $M$ be a finitely generated module over PID $R$, and $M$ is generated by $x_1, x_2, \dots, x_n$. Let $y_1=a_1\cdot x_1+\dots +a_n\cdot x_n$, and $\gcd(a_1, \dots , a_n)=1.$ Prove that there exist $y_2, \dots, y_n$ such that $y_1, \dots, y_n$ generate $M$.
Since $R$ is PID, there exist $u_1, \dots , u_n \in R$ such that $u_1a_1+ \dots +u_na_n=1$. I want to use this equation to prove it, but I have trouble constructing $y_2, \dots, y_n$. Any hint would be helpful!
For convenience, I'll reword the problem as follows . . .
Let $M$ be an $R$-module where $R$ is a PID, let $x_1,...,x_n\in M$ with $n\ge 2$, and let $y_1=a_1x_1+\cdots+a_nx_n$ where $a_1,...,a_n\in R$ are such that $\text{gcd}(a_1,...,a_n)=1$.
Claim:$\;$There exist $y_2,...,y_n\in \langle{x_1,...,x_n}\rangle$ such that $\langle{y_1,...,y_n}\rangle=\langle{x_1,...,x_n}\rangle$.
Proof:
First suppose $n = 2$.
Let $a_1,a_2\in R$ be such that $\text{gcd}(a_1,a_2)=1$, and let $y_1=a_1x_1+a_2x_2$.
Since $\text{gcd}(a_1,a_2)=1$, there exist $u_1,u_2\in R$ such that $u_1a_1+u_2a_2=1$.
Let $y_2=-u_2x_1+u_1x_2$.
It's clear that $y_1,y_2\in \langle{x_1,x_2}\rangle$.
But identically we have $$ \left\lbrace \begin{align*} u_1y_1-a_2y_2 &= u_1(a_1x_1+a_2x_2)-a_2(-u_2x_1+u_1x_2) \\[4pt] &= (u_1a_1+u_2a_2)x_1+(u_1a_2-u_1a_2)x_2 \\[4pt] &= (1)(x_1)+(0)(x_2) \\[4pt] &= x_1 \\[10pt] u_2y_1+a_1y_2 &= u_2(a_1x_1+a_2x_2)+a_1(-u_2x_1+u_1x_2) \\[4pt] &= (u_2a_1-u_2a_1)x_1+(u_1a_1+u_2a_2)x_2 \\[4pt] &= (0)(x_1)+(1)(x_2) \\[4pt] &= x_2 \\[4pt] \end{align*} \right. $$ hence $x_1,x_2\in \langle{y_1,y_2}\rangle$.
Thus $\langle{y_1,y_2}\rangle=\langle{x_1,x_2}\rangle$, so the claim holds for $n=2$.
Before continuing, we prove a simple lemma . . .
Lemma:
If $R$ is a UFD and $r_1,r_2\in R$, there exist $s_1,s_2\in R$ with $\text{gcd}(s_1,s_2)=1$ such that $r_1s_1+r_2s_2=0$.
Proof of the lemma:
If $r_1=0$ then letting $s_1=1$ and $s_2=0$ we have $\text{gcd}(s_1,s_2)=1$ and $$ r_1s_1+r_2s_2 = (0)(1)+(r_2)(0) = 0+0 = 0 $$ Next suppose $r_1\ne 0$ and let $$ \left\lbrace \begin{align*} s_1&=\frac{r_2}{d}\\[4pt] s_2&=-\frac{r_1}{d}\\[4pt] \end{align*} \right. $$ where $d=\text{gcd}(r_1,r_2)$.
Then we have $\text{gcd}(s_1,s_2)=1$ and $$ r_1s_1+r_2s_2 = (r_1)\left(\frac{r_2}{d}\right)+(r_2)\left(-\frac{r_1}{d}\right) = \frac{r_1r_2-r_1r_2}{d} = \frac{0}{d} = 0 $$ which completes the proof of the lemma.
Returning to the proof of the main claim . . .
Proceeding by induction on $n$, let $n\ge 3$ and assume the claim holds for the case $n-1$.
Let $a_1,...,a_n\in R$ be such that $\text{gcd}(a_1,...,a_n)=1$, and let $y_1=\sum_{k=1}^na_kx_k$.
Since $\text{gcd}(a_1,...,a_n)=1$, at least one of $a_1,...,a_n$ must be nonzero.
Relabeling if necessary, assume $a_1\ne 0$.
Let $g=\text{gcd}(a_1,...,a_{n-1})$.
Let $r_1,...,r_{n-1}\in R$ be such that $\sum_{k=1}^{n-1}r_ka_k=g$ and $\text{gcd}(r_1,...,r_{n-1})=1$.
Applying the lemma, let $s_1,s_2\in R$ be such that $\text{gcd}(s_1,s_2)=1$ and $r_1s_1+r_2s_2=0$.
Then letting $s_k=0$ for $3\le k\le n-1$, it follows that $\text{gcd}(s_1,...,s_{n-1})=1$ and $\sum_{k=1}^{n-1}r_ks_k=0$.
Let $y_n=x_n+\sum_{k=1}^{n-1}s_kx_k$ and let $y_1'=y_1-a_ny_n$.
Then $y_1'=\sum_{k=1}^{n-1}b_kx_k$ where $b_k=a_k-s_ka_n$.
Suppose $f\in R$ is a common divisor of $b_1,...,b_{n-1}$.
Identically we have \begin{align*} \sum_{k=1}^{n-1}r_kb_k &= \sum_{k=1}^{n-1}r_k(a_k-s_ka_n) \\[4pt] &= \sum_{k=1}^{n-1}r_ka_k-a_n\sum_{k=1}^{n-1}r_ks_k \\[4pt] &= g-(a_n)(0) \\[4pt] &= g \\[4pt] \end{align*} hence $f{\,\mid\,}g$.
Then $f{\,\mid\,}a_k$ for all $k\in\{1,...,n-1\}$ and $\text{gcd}(f,a_n)=1$.
Then for all $k\in\{1,...,n-1\}$ \begin{align*} & f{\,\mid\,}b_k \\[4pt] \implies & f{\,\mid\,}a_k-s_ka_n \\[4pt] \implies & f{\,\mid\,}s_ka_n \\[4pt] \implies & f{\,\mid\,}s_k \\[4pt] \end{align*} hence, since $\text{gcd}(s_1,...,s_{n-1})=1$, it follows that $f$ is a unit of $R$.
Thus we have $\text{gcd}(b_1,...,b_{n-1})=1$.
Applying the inductive hypothesis, there exist $y_2,...,y_{n-1}\in \langle{x_1,...,x_{n-1}}\rangle$ such that $\langle{y_1',y_2,...,y_{n-1}}\rangle=\langle{x_1,...,x_{n-1}}\rangle$.
Now consider $\langle{y_1,...,y_n}\rangle$.
It's clear that $y_1,...,y_n\in\langle{x_1,...,x_n}\rangle$.
From $y_1'=y_1-a_ny_n$, we get $y_1'\in \langle{y_1,...,y_n}\rangle$.
Hence from $\langle{y_1',y_2,...,y_{n-1}}\rangle=\langle{x_1,...,x_{n-1}}\rangle$, we get $x_1,...,x_{n-1}\in \langle{y_1,...,y_n}\rangle$.
And then from $y_n=x_n-\sum_{k=1}^{n-1}s_kx_k$, we get $x_n\in \langle{y_1,...,y_n}\rangle$.
Thus $x_1,...x_n\in \langle{y_1,...,y_n}\rangle$, hence $\langle{y_1,...,y_n}\rangle=\langle{x_1,...,x_n}\rangle$, which completes the induction, and thus completes the proof.