# Flatness from constancy of dimension of fibers

Let $M$ be a finitely presented module over the ring $R$. Suppose that for all primes $P\subset R$ the $k(P)$ vector space $M\otimes _Rk(P)$ has a dimension $d(P)$ independent of $P$.
Can I conclude that $M$ is flat over $R$?
I am asking because I want to better understand the criterion for a family of projective schemes to be flat over some base in terms of invariance of their Hilbert polynomial.
I checked some examples. For example let $M$ be the ideal of a point $P$ of an affine curve $C$.
Here $d(P)$ is the dimension of the Zariski tangent space of $C$at $P$ so that the proposed criterion for flatness holds.

• In general equi-dimensionality of the fibres is necessary, but not sufficient in order to guarantee flatness. However, it is also sufficient when $R$ is regular of dimension $1$, or when $R$ is regular of arbitrary dimension and $M$ is Cohen-Macaulay. See S. Kovacs' answer to the following MO question: mathoverflow.net/questions/75317/… – Francesco Polizzi Jan 14 '17 at 9:59
• Ah, sorry, I slightly misread the question. You are asking about flatness of a (finitely presented) module over the ring $R$, so in geometric terms you want to know about the flatness of a coherent sheaf over an affine scheme (and not about the flatness of a morphism of schemes). Then the correct answer is given by abx in his comment: in the case where the fibres are of constant dimension, flatness occurs whenever $R$ is without nilpotents. – Francesco Polizzi Jan 14 '17 at 10:22

Yes if $R$ is reduced (no nilpotent elements). This is (for instance) Lemma 1 p. 51 in Mumford's Abelian Varieties (2nd edition). No in general: just take $R=k[\varepsilon ]/(\varepsilon ^2)$, $M=k$.