Let $R$ be a commutative (noetherian, if needed) ring, let $f\_1，\ldots，f\_r\in R[x\_1，\ldots，x\_n]$ and $A=R[x\_1，…，x\_n]/(f\_1，\ldots，f\_r)$, when is $A$ flat over $R$?


I found a nice answer for the case $n=r=1$ [here](https://math.stackexchange.com/a/3667137/95662), but I don't know how to formulate a characterisation in general, or if it is solved. Any idea or reference is welcome.



Flatness of finitely presented algebras
There is a nice criterion that is usually applied in this situation.


A is flat over $R$ if the Krull dimension of the fiber ring $A\_{\mathfrak{P}}/\mathfrak{P}$ for all prime ideals $\mathfrak{P} \subset R$ is $n-r$ (or the fiber is empty). In scheme theoretic language, the fibers either have the expected dimension (are complete intersections) or are empty. This is what is called a relative global complete intersection here <https://stacks.math.columbia.edu/tag/00SK>. Flatness follows from <https://stacks.math.columbia.edu/tag/00SW>.


This is a generalization of the criterion you cited when $r=1$. In that case the fibers of $Spec(R[x\_1, \ldots, x\_n]) \to Spec(R)$ are affine spaces over a field (so integral) and the condition ensures that the restriction of the polynomial $f$ to every fiber over some closed and open subset $U \subset Spec(R)$ is nonzero, so it must cut a closed subset of the fiber of dimension $n-1$ (or empty if it restricts to a constant). The idempotent comes from the fact that if $Spec(R)$ is not connected, then we can allow the preimage over the complement of this open and closed to be just isomorphic to the whole affine space $\mathbb{A}^n\_{Spec(R) \setminus U}$, ($f$ is allowed to be identically $0$ on $Spec(R) \setminus U$).


