Flatness is all about avoiding an annoying property of the tensor product: it does not preserve submodules.

Fix a commutative ring {R}. We say that an {R}-module {M} is flat if the functor {Mod(R) \rightarrow Mod(R), N \rightarrow M \otimes_R N}, is exact; it is always right-exact. It is sufficient to show that for any injection 

\displaystyle 0 \rightarrow N' \rightarrow N  

the tensored sequence is exact, i.e. 

\displaystyle 0 \rightarrow N' \otimes M \rightarrow N \otimes M.  

It is immediate that the direct sum or tensor product of flat modules is flat, and that a direct summand in a flat module is flat. Also, the module {R} itself is clearly flat. So any free module is flat, and thus so is any projective module.   In the local case, we’ll see that the converse is true at least if we stick to finitely generated modules over a noetherian ring (more generally, for finitely presented modules over any ring). 

Since completion preserves exactness, {\hat{R}} is a flat {R}-module where {\hat{R}} is an {I}-adic completion of {R} for {R} noetherian. Localization does to, so any localization is flat.   So many common examples are flat.  But because of the above injectivity characterization, a nonzerodivisor in R must act by a nonzerodivisor on any flat module.  Thus for instance, \mathbb{Z}/2\mathbb{Z} is not flat over \mathbb{Z} 

Interpretation via Tor  

Recall that the derived functors of the tensor product functor are denoted by {\mathrm{Tor} _R^i, i \geq 0}. So {\mathrm{Tor} _R^0(M,N) = M \otimes N}. These functors are symmetric in both variables, and given an exact sequence 

\displaystyle 0 \rightarrow N' \rightarrow N \rightarrow N'' \rightarrow 0  

we have a long exact sequence 

\displaystyle \mathrm{Tor} ^i(N',M) \rightarrow \mathrm{Tor} ^i(N,M) \rightarrow \mathrm{Tor} ^i(N'',M ) \rightarrow \mathrm{Tor} ^{i-1}(N',M) \rightarrow \dots  

For this, cf. books on homological algebra. 

One of the basic applications of this is that for a flat module {M}, the tor-functors vanish for {i \geq 1} (whatever be {N}). Indeed, recall that {\mathrm{Tor} (M,N)} is computed by taking a projective resolution of {N}

\displaystyle \dots \rightarrow P_2 \rightarrow P_1 \rightarrow P_0 \rightarrow M \rightarrow 0  

tensoring with {M}, and taking the homology. But tensoring with {M} is exact if we have flatness, so the higher {\mathrm{Tor} } modules vanish. 

Conversely, suppose {\mathrm{Tor} ^i(M,N) = 0} for all {N} and {i>0}. Then given an exact sequence, 

\displaystyle 0 \rightarrow N' \rightarrow N \rightarrow N'' \rightarrow 0  

we get exactness of 

\displaystyle \mathrm{Tor} _1(N'',M) \rightarrow N' \otimes M \rightarrow N \otimes M \rightarrow N'' \otimes M \rightarrow 0  

so the {\mathrm{Tor} }-vanishing (as we saw, we only needed it for {i=1}) gives flatness. By taking direct (filtered) limits, which preserve exactness, we can reduce to the case of checking that {\mathrm{Tor} ^1(M,N) = 0} for {N} finitely generated. By using a filtration on {N} whose quotients are of the form {R/I} for {I \subset R} an ideal, we find that: 

Proposition 1 {M} is flat iff {\mathrm{Tor} ^1(M,R/I)=0} for all finitely generated ideals {I \subset R}.

 

Note that there is an exact sequence {0 \rightarrow I \rightarrow R \rightarrow R/I \rightarrow 0} and so 

\displaystyle \mathrm{Tor} _1(M,R)=0 \rightarrow \mathrm{Tor} _1(M,R/I) \rightarrow I \otimes M \rightarrow M  

is exact, and it suffices to show that 

\displaystyle I \otimes M \rightarrow M  

is injective for all {I}

Theorem 2 If {R} is noetherian local and {M} finitely generated and flat, then {M} is free.

 

Indeed, let {\mathfrak{m} \subset R} be the maximal ideal and {k} the residue field. Now {M/\mathfrak{m} M} is a finitely generated {k}-vector space; choose a basis. This induces an isomorphism 

\displaystyle k^n \rightarrow M/\mathfrak{m} M  

which we can lift to a map 

\displaystyle R^n \rightarrow M , 

which is surjective by Nakayama’s lemma, and which becomes an isomorphism upon being tensored with {k}. Let {Q} be the kernel: 

\displaystyle 0 \rightarrow Q \rightarrow R^n \rightarrow M \rightarrow 0; 

then we have an exact sequence 

\displaystyle \mathrm{Tor} ^1(k,M)=0 \rightarrow Q \otimes k \rightarrow k^n \rightarrow M/\mathfrak{m} M \rightarrow 0. 

As a result {Q \otimes k = Q/\mathfrak{m} Q = 0}, which implies {Q=0} by Nakayama, so {R^n \rightarrow M} is an isomorphism, q.e.d. 

The local criterion of flatness  

In Proposition 1 above, the need to check all ideals is potentially burdensome, so the following is nice. 

Let {R} be a noetherian local ring with maximal ideal {\mathfrak{m}} and residue field {k}, {S} be a local finitely generated {R}-algebra with {\mathfrak{m}S \subset \mathfrak{n}} for {\mathfrak{n}} the maximal ideal of {S}, and {M} a finitely generated {S}-module. 

Theorem 3 {M} is flat over {R} iff\displaystyle \mathrm{Tor} ^1_R( k, M) = 0.  

 

Necessity is immediate. What we have to prove is sufficiency. 

First, I make the following claim. If {N} is an {R}-module of finite length, then 

\displaystyle \mathrm{Tor} ^1_R( N, M)=0. 

This is because {N} has by devissage a filtration {N_i} whose quotients are of the form {R/\mathfrak{p}} for {\mathfrak{p}} prime and (by finite length hypothesis) {\mathfrak{p}= \mathfrak{m}}. Then the result is true {N_0=0 \subset N} trivially. We climb up the filtration piece by piece inductively; if {\mathrm{Tor} ^1_R(N_i, M)=0}, then the exact sequence 

\displaystyle 0 \rightarrow N_i \rightarrow N_{i+1} \rightarrow k \rightarrow 0  

yields 

\displaystyle \mathrm{Tor} ^1_R(N_i, M) \rightarrow \mathrm{Tor} ^1_R(N_{i+1}, M) \rightarrow 0  

from the long exact sequence of {\mathrm{Tor} } and the hypothesis on {M}. The claim is proved. 

The idea behind this proof is to show that {I \otimes_RM \rightarrow M} is injective for any {I \subset R}. We will use some diagram chasing and the Krull intersection theorem on the kernel {K} of this map, to interpolate between it and various quotients by powers of {\mathfrak{m}}. First we write some exact sequences. 

We have an exact sequence 

\displaystyle 0 \rightarrow \mathfrak{m}^t \cap I \rightarrow I \rightarrow I/I \cap \mathfrak{m}^t \rightarrow 0 

which we tensor with {M}

\displaystyle \mathfrak{m}^t \cap I \otimes M \rightarrow I \otimes M \rightarrow I/I \cap \mathfrak{m}^t \otimes M \rightarrow 0. 

The sequence 

\displaystyle 0 \rightarrow I/I \cap \mathfrak{m}^t \rightarrow R/\mathfrak{m}^t \rightarrow R/(I+\mathfrak{m}^t) \rightarrow 0 

is also exact, and tensoring with {M} yields an exact sequence: 

\displaystyle 0 \rightarrow I/I \cap \mathfrak{m}^t \otimes M \rightarrow M/\mathfrak{m}^tM \rightarrow M/(\mathfrak{m}^t + I) M \rightarrow 0 

because {\mathrm{Tor} ^1_R(M, R/(I+\mathfrak{m}^t))=0} (finite length hypothesis. 

Let us draw the following commutative diagram:
 

 

where the column and the row are exact. As a result, if an element in {I \otimes M} goes to zero in {M} (a fortiori in {M/\mathfrak{m}^tM}) it must come from {\mathfrak{m}^t \cap I \otimes M} for all {t}. Thus it belongs to {\mathfrak{m}^t(I \otimes M)} for all {t}, and the Krull intersection theorem (applied to {S}, since {\mathfrak{m}S \subset \mathfrak{n}}) implies it is zero. 

The infinitesimal criterion

Theorem 4 Let {M} be a module over a noetherian local ring {R}. Then {M} is flat iff {M/\mathfrak{m}^tM} is flat over {R/\mathfrak{m}^t} for all {t>0}.

 

One direction is easy, because if {M} is a flat {R}-module and {S} an {R}-algebra, then {M \otimes_R S} is flat over {S}. For the other direction, take the same commutative diagram as before:
 

 

The horizontal sequence was always exact. The vertical sequence can be argued to be exact by tensoring the exact sequence\displaystyle 0 \rightarrow I/I \cap \mathfrak{m}^t \rightarrow R/\mathfrak{m}^t \rightarrow R/(I+\mathfrak{m}^t) \rightarrow 0  

of {R/\mathfrak{m}^t}-modules with {M/\mathfrak{m}^tM}, and using flatness. Thus we get flatness of {M} as before. 

Incidentally, if we combine the local and infinitesimal criteria fo flatness, we get a little more.   Moreover, the same reasoning shows that we only need the hypothesis of the theorem for sufficiencly large t>0, or even arbitrarily large.