I wonder if the miracle flatness theorem [Generalizing miracle flatness (Matsumura 23.1) via finite Tor-dimension](https://mathoverflow.net/questions/7432/generalizing-miracle-flatness-matsumura-23-1-via-finite-tor-dimension)
still works if the rings involved are not local (and the dimension condition is deleted)?


In other words, is it true that $f: A \to B$, $A$ regular, $B$ Cohen-Macaulay,
implies that $f$ is flat? I guess the answer is no (maybe taking $A=k[x,y]$, $B=A/I$, with a right choice of an ideal $I$ of $A$ will serve as a counterexample? or maybe no).


But what if we further assume that: $f$ is injective, $A$ is Noetherian and $B$ is a finitely generated $A$-module? Is $f$ flat in this case?


I ask this question since I have seen here this claim as a fact
<https://math.stackexchange.com/questions/296971/what-has-projectiveness-to-do-with-cohen-macaulay-rings/297320#297320>, with reference to EGA IV 6.1.5, though it seems (I do not know French) that Grothendieck talks about the local case.



A generalization of miracle flatness theorem
The answer to your first question is obviously no, as you point out: the homomorphism $A\rightarrow A/I$ is essentially never flat. It is OK under your hypotheses ($f$ injective, $A$ noetherian, $B$ finitely generated) if you assume moreover that $B$ is a domain. A reference (in french, sorry) is Bourbaki, Algèbre Commutative X, §4, no. 3, Corollaire.


The hypothesis that $B$ is a domain is necessary for stupid reasons: just take $B=A\times A/I$ with $A/I$ Cohen-Macaulay, again this is not flat over $A$.


