TITLE: When is an element of a free module over a principal ideal domain contained in a basis?
QUESTION [10 upvotes]: 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

REPLY [2 votes]: 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.)