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



"Numerical Criterion" for Flatness
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.


