# “Numerical Criterion” for Flatness

Let $R$ be a Dedekind ring, let $S = \mathrm{Spec} R$, and let us suppose that $f: X \to S$ is a finite morphism. Note that $X$ is not required to be connected. Does there exist a "numerical criterion" that will produce a closed subscheme $S_0 \subset S$ such that $f$ is flat when restricted to $f^{-1}(S - S_0)$?

Consider the following non-example: Let $F \in \mathbb{Z}[T]$ be a non-constant monic polynomial, and set $X = \mathrm{Spec} \mathbb{Z}[T] / (F(T)), \qquad f: X \to \mathrm{Spec} \mathbb{Z}.$ The structure morphism $f \$ is finite and flat. A prime $p$ occurs as a factor of the discriminant $\Delta(F)$ if and only if the fiber of $f$ over $p$ contains a non-smooth point. So the discriminant can be viewed as a numerical criterion for detecting (non-)smoothness. All of the data needed to determine smoothness is contained in the discriminant. Does there exist a similar one-step gadget for detecting (non-)flatness? (I say "one-step" to mean that the vanishing of infinitely many Tor groups is not an adequate solution. Is there a single Tor group that captures what I'm after?)

-
Your criterion for a map to $Spec~\mathbb{Z}$ is essentially a criterion for torsion-freeness. It so happens that over $\mathbb{Z}$ this is the the same thing as flatness. What is your $X$ a finite group scheme over? – Keerthi Madapusi Pera Dec 7 '11 at 2:55
I think you just need to check that the dimension of the quotient by each maximal ideal is constant. Reason: If the morphism was projective than one would just have to use the Hilbert polynomial, but the Hilbert polynomial would always be constant and equal to the dimension. – Will Sawin Dec 7 '11 at 3:09
In your example $X = \mathop{\mathrm{Spec}} \mathbb{Z}[T] / (F(T))$, if $F$ is not monic the map is not finite, but it may still happen to be flat (for example, take $F(T) = 2T+1$). If $f\colon X \to Y$ is a finite morphism, $Y$ is locally noetherian, you only need to check that the length of the fibers is locally constant. – Angelo Dec 7 '11 at 6:16
@Keerthi - $X$ is a finite group scheme over the ring of S-integers in a number field. @Will and Angelo - It's true that one can check that the length of the fibers is locally constant, but that's not a "one-step" solution. I want an effective procedure for searching for bad fibers. @Angelo - Ack! You're right! That botches my example, but not my question thankfully. Good catch. – Xander Faber Dec 7 '11 at 6:33
I suppose you could find the primes over which the map is not smooth, and then compare the length of the fiber over each of this prime with the generic one. – Angelo Dec 7 '11 at 6:49

Take a free resolution of $X$ as an $S$-module, or, more importantly, the first two steps. Look at the map between them, which is given by a matrix over $S$. You need to compute how the rank of this matrix varies across various prime ideals, since this is a constant minus the dimension of the cokernel.
To compute the rank of a matrix, one of course uses the vanishing or nonvanishing of various determinants of $n$ by $n$ minors. These seem to be the kind of numerical criteria you are looking for.