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?)

`$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. $\endgroup$ – Angelo Dec 7 '11 at 6:16