When is an element of a free module over a principal ideal domain contained in a basis?
I'm trying to show the following:
Let $R$ be a principal ideal domain and let $M$ be free $R$-module of rank $n$. Let $Y=\{y_1,\ldots,y_n\}$ be a basis of $M$ and $x\in M$ with $x=y_1a_1+\cdots+y_na_n$. Then $x$ is contained in a base of $M$ if and only if $\gcd(a_1,\ldots,a_n)=1$.
I have shown that if $x$ belongs to a basis of $M$, then $\gcd(a_1,\ldots,a_n)=1$.
This is my idea for the other direction:
If $n=1$, then $a_1\in R^*$, and we are done. Now suppose $n\geq 2$. Since $\gcd(a_1,\ldots,a_n)=1$, there are $s_1,\ldots,s_n\in R$ such that $a_1s_1+\cdots+a_ns_n=1$, then using this equality I tried to get some non-zero $y\in M$ such that $\langle x\rangle\cap \langle y\rangle=0$. Supposing the existence of such $y$, using Zorn's lemma you can get a maximal nonzero submodule $N$ such that $\langle x\rangle\cap N=0$, then I showed that $\langle x\rangle\oplus N=M$, and since $M$ is free and $R$ a principal ideal domain $N$ is free and has a basis $\{x_1,\ldots,x_m\}$, and thus $\{x,x_1,\ldots,x_m\}$ would be a basis of $M$.
My question is: is there such an $y$? Also, I would like to know whether this idea is too complicated, and if so, I want to know alternative approaches to it.
Thanks
Let $R$ be a PID $M$ a free $R$-module of finite rank $n$. Let $\{x_1,\dots,x_k\}$ be $k\leq n$ elements in $M$, and denote $N$ their $R$-span in $M$. Then the claim is that the $k$-ple $\{x_1,\dots,x_k\}$ can be completed to a basis of $M$ over $R$ if and only if $$ rk(N)=k\qquad\text{and}\qquad\text{$M/N$ is torsion-free.} $$ Indeed, if $\{x_1,\dots,x_k,x_{k+1},\dots,x_n\}$ is an $R$-basis for $M$, then $M=N\oplus N^\prime$ where $N^\prime$ is the submodule of $M$ generated by$\{x_{k+1},\dots,x_n\}$ and $M/N\simeq N^\prime$. Thus $rk(N)=k$ because $rk(N^\prime)\leq n-k$ and $rk(N)+rk(N^\prime)=n$, and $M/N$ is free because it is isomorphic to a submodule of a free module.
Viceversa, consider the quotient map $$ \pi:M\longrightarrow M/N. $$ Let $\{z_1,\dots,z_r\}$ be a basis of $M/N$. Choose $y_i\in M$ such that $\pi(y_i)=z_i$ and let $N^\prime\subset M$ the submodule generated by the $y_i$'s. Since the $z_i$ are $R$-linearly independent so are the $y_i$, i.e. they form a basis of $N^\prime$. For any $m\in M$ write $$ \pi(m)=a_1z_1+\cdots+a_rz_r,\qquad a_i\in R. $$ Then $m-\sum_{i=1}^ra_iy_i\in\ker(\pi)=N$, from which follows readily that $M=N\oplus N^\prime$ and thus $\{x_1,\dots,x_k,y_1,\dots,y_r\}$ is a basis for $M$ containing $\{x_1,\dots,x_k\}$. The claim is proved.
Now, let $x\in M$, $x\neq0$, and let $\{y_1,..,y_n\}$ be a basis of $M$. Then $x=a_1y_1+\dots+a_ny_n$ for some $a_i\in R$. Let $d=\operatorname{gcd}(a_1,\dots,a_n)$.
If $d\neq1$, the element $y=\frac1dx\in M$ gives a torsion element in $M/Rx$. On the other hand, suppose that $d=1$ and $z\in M/Rx$ is such that $rz=0$ for some non-zero $r\in R$. Choose $y\in M$ such that $\pi(y)=z$ and write $y=\sum_{i=1}^nb_iy_i$. Then $ry=sx$ for some $s\in R$, i.e. $$ rb_i=sa_i,\qquad\text{for all $i=1,\dots,n$} $$ Thus $r\operatorname{gcd}(b_i)=s$, i.e. $r$ divides $s$ in $R$. Therefore $y=\frac sr x\in Rx$ and $\pi(y)=z=0$, thus proving that $M/Rx$ is torsion-free.
Let $R$ be a PID and $M$ a free $R$-module of any rank, finite or infinite. Then $x\in M$ belongs to some basis of $M$ iff there exists a linear functional $g\colon M\to R$ such that $g(x)=1$. Moreover, let $(e_t\mid t\in T)$ be a basis of $M$, and $x=\sum_{t\in T}\xi_t e_t$ (where $\xi_t\neq 0$ for only finitely many $t\in T$); then $x$ belongs to some basis of $M$ iff $\gcd\{\xi_t\mid t\in T\}=1$.
Proof. Necessity. Suppose there is a basis $(e_t\mid t\in T)$ of $M$ such that $x=e_s$ for some $s\in T$. For each $t\in T$ choose an $\alpha_t\in R$, taking care to choose $\alpha_s=1$. There exists a unique linear functional $g$ on $M$ such that $g(e_t)=\alpha_t$ for every $t\in T$. Since $g(x)=g(e_s)=1$, we have a linear functional $g$ as required.
Sufficiency. Let $g$ be a linear functional on $M$ so that $g(x)=1$. We claim that $M=Rx\oplus\ker(g)$. If $y\in M$, then $g(y-g(y)x)=0$, thus $y-g(y)x\in\ker(g)$; this shows that $M=Rx+\ker(g)$. If $\xi x+z=0$ for some $\xi\in R$ and $z\in\ker(g)$, then $\xi=g(\xi x+z)=0$, thus also $z=0$; this shows that the sum $Rx+\ker(g)$ is direct. Now $\ker(g)$, as a submodule of a free module over a PID, is free, so we can extend $x$ to a basis of $M$ by any basis of $\ker(g)$.
The reformulation in terms of the coordinates $\xi_t$ of $x$ with respect to a basis $(e_t\mid t\in T)$.
Every linear functional $g$ on $M$ is uniquely determined by the values $\alpha_t=g(e_t)\in R$, $t\in T$, which can be chosen arbitrarily. The value of $g$ on $x$ is $g(x)=\sum_{t\in T}\alpha_t\xi_t$ (a finite linear combination). Since every linear combination of $\xi_t$'s is divisible by $d=\gcd\{\xi_t\mid t\in T\}$, which is itself a linear combination of $\xi_t$'s (because $R$ is a PID), it is clear that there exists a linear functional $g$ such that $g(x)=1$ iff $d=1$. Done.
You may enjoy proving the following generalization.
Let $R$ and $M$ be as above, and $x_1,\ldots,x_n\in M$. Then $(x_1,\ldots,x_n)$ can be extended to a basis of $M$ iff there exists a linear map $h\colon M\to R^n$ such that $h(x_1)=e_1$, $\ldots$, $h(x_n)=e_n$, where $(e_1,\ldots,e_n)$ is the standard basis of $R^n$. Moreover, let $(u_t\mid t\in T)$ be a basis of $M$, and $x_i=\sum_{t\in T}\xi_{it} u_t$ for $1\leq i\leq n$ and $t\in T$. Then $(x_1,\ldots,x_n)$ can be extended to a basis of $M$ iff the $\gcd$ of the determinants of all $n\!\times\! n$ submatrices of the $\{1,\ldots,n\}\!\times\! T$-matrix $[\xi_{it}]$ is $1$. (Since there exists a finite subset $S$ of $T$ such that $\xi_{it}=0$ for $1\leq i\leq n$ and $t\in T\setminus S$, the condition in fact involves only finitely many $n\!\times\! n$ matrices.)