Given a valuation ring $A$ and an $A$-module $M$, I want to prove that $M$ is flat $\iff$ M is torsion free.
I already proved the implication '$\implies$' and I also know that $A$ is a local ring with maximal ideal $\mathfrak{m} = \{0\} \cup \{a \in A\setminus{\{0\}}\; :\; a^{-1} \notin A\}$. I was given a hint that it suffices to show that every finitely generated, torsion free $A$-module is free (and thus flat); that is, every minimal generating set is linearly independent. However, I don't quite understand why it suffices to consider finitely generated modules. Could someone explain this please?
Proving the claim for a finitely generated module $M$, let $<x_1,\dots , x_r>_A$ be a minimal generating set of $M$ and $\sum_{i=1}^r a_ix_i = 0$. Since $A$ is local, by Nakayama's Lemma we have that $<\bar{x_1},\dots ,\bar{x_r}>_{A/\mathfrak{m}}$ is a generating set of the $A/\mathfrak{m}$-vector space $M/\mathfrak{m}M$. Since $r$ is minimal, the set is also linearly independent and thus $\sum_{i=1} \bar{a_i}\bar{x_i} = 0 \implies \bar{a_i} = \bar{0}$ for all $i = 1, \dots , r$. That means $a_i \in \mathfrak{m}$. Now it remains to show that $a_i$ is invertible, but how exactly can we do this?
Any module is the filtered colimit of its finitely generated submodules. Also, submodules of torsionfree modules are torsionfree, and filtered colimits of flat modules are flat. This is why it suffices to prove that finitely generated torsionfree modules are flat, or even free.
So let $M$ be a finitely generated $A$-module, where $ A$ is a valuation ring. Choose $m_1,\dotsc,m_n \in M$ such that $[m_1],\dotsc,[m_n]$ is a $A/\mathfrak{m}$-basis of $M/\mathfrak{m}M$. By Nakayama's Lemma, $m_1,\dotsc,m_n$ is a generating set of $M$. We show that it is linearly independent. Assume $\sum_{i=1}^{n} a_i m_i = 0$ for some $a_1,\dotsc,a_n \in A$. Since $A$ is a valuation ring, some coefficient $ a_j$ divides all others. If $a_j=0$, we are done. Otherwise, the relation becomes $a_j \sum_{i=1}^{n} a_i/a_j \cdot m_i=0$, and since $M$ is torsionfree this implies $ \sum_{i=1}^{n} a_i/a_j \cdot m_i=0$. But since the $[m_1],\dotsc,[m_n]$ are linearly independent over $A/\mathfrak{m}$, we have $a_i/a_j \in \mathfrak{m}$ for all $i$, which fails for $i=j$.
A different proof, using the equational criterion of flatness, can be found in Stacks, Tag 0539.