TITLE: Does $R$ have to be a PID in order for all f.g. torsion-free $R$-modules to be free?
QUESTION [9 upvotes]: I was just going through a proof of the following fact from a textbook. Generally $M$ is an $R$-module. 
$\textbf{Theorem.}$ A finitely generated torsion-free module over a PID is free.
$\textbf{Proof.}$ The proof given in the book is as follows. Let $M$ be a torsion-free non-zero module, generated by $X=\{x_{1},\dots,x_{m}\}$.  By reordering if necessary, we may assume that, $\mathscr{B} =\{x_{1},x_{2},\dots,x_{m}\}$ is a maximal linearly independent subset of $X$. Let $F=\text{span}\:\mathscr{B}$. Since $M$ is non-zero and torsion-free, we have $m \geq 1$. For each $i$, there are scalars, $a_{i},a_{ij}$ not all zero such that $$a_{i}x_{i} + \sum\limits_{j=1}^{m} a_{ij}x_{j}=0.\qquad\qquad\qquad\qquad (\star)$$ Since $\mathscr{B}$ is linearly independent, it is clear that $a_{i} \neq 0$, for all $i$. Let $a=a_{1}a_{2}\cdots a_{n}$ so that $a_{n} \neq 0$.  For $(\star)$, $a_{i}x_{i} \in F$ and so $ax_{i} \in F$, for all $i$, i.e. $aM \subseteq F$. Now the map $\nu:M \to F$, $x \to ax$, is $R$-linear and a monomorphism since $M$ is torsion-free. Hence $M \cong \nu(M)$ which is submodule of the free module $F$ and so $\nu(M)$ is free by $\textbf{Theorem A}$ (see below), i.e. $M$ is free as required. 

$\textbf{Theorem A.}$ Let $F$ be a free $R$-module and $M$ a submodule of $F$. Then $M$ is also free and $\dim_RM \leq \dim_RF$.

I would like to know in the proof of the above theorem, where have we assumed any facts about $\textbf{PID}$. It seems as if this theorem is true for a torsion-free module over a general ring as well (which I know is not true).

REPLY [11 votes]: Here are two facts which are (I believe) relevant to your question.
1: For a commutative integral domain $R$, the following are equivalent:
(i) Every submodule of a free $R$-module is free, and of equal or smaller rank.
(ii) Every submodule of a finitely generated free $R$-module is free.
(iii) $R$ is a principal ideal domain.
Proof: 
(i) $\implies$ (ii) is immediate.
(ii) $\implies$ (iii): $R = (1)$ is a finitely generated free $R$-module, and the $R$-submodules of $R$ are precisely the ideals.  It is easy to see that an ideal is free as an $R$-module iff it is free of rank $1$ iff it is principal.
(iii) $\implies$ (i): This is your Theorem A.  For a proof using methods from commutative algebra -- and valid for not necessarily finitely generated modules -- see $\S 3.9$ of my commutative algebra notes.
2: For a commutative integral domain $R$, the following are equivalent:
(i) Every finitely generated torsionfree $R$-module is free.
(ii) $R$ is a Bezout domain, that is, every finitely generated ideal is principal.
Proof: (i) $\implies$ (ii): A finitely generated ideal $I$ of $R$ is a finitely generated torsionfree $R$-module, so by hypothesis $I$ is a free $R$-module.  As above, this implies that $I$ is principal.
(ii) $\implies$ (i): An integral domain $R$ has the property that every finitely generated torsionfree $R$-module is projective iff $R$ is a Prüfer domain: every finitely generated ideal is invertible.  Since principal ideals are invertible, this property holds for Bezout domains.  Moreover, it is a theorem of Albrecht that every finitely generated projective module over a Bezout domain is free.  Proofs of both of these facts can be found in Chapter 2 of T.Y. Lam's Lectures on Modules and Rings.  (Probably they will be in my commutative algebra notes eventually, but they are not there at present.)
Added: I have recently added proofs of the above results to my commutative algebra notes.  Please see $\S 3.9.2$: hereditary and semihereditary rings.