If $R$ is a ring and $J\subset R$ is an ideal, can $R/J$ ever be a flat $R$-module? For algebraic geometers, the question is "can a closed immersion ever be flat?"


The answer is yes: take $J=0$. For a less trivial example, take $R=R\_1\oplus R\_2$ and $J=R\_1$, then $R/J$ is flat over $R$. Geometrically, this is the inclusion of a connected component, which is kind of cheating. If I add the hypotheses that $R$ has no idempotents (i.e. $\operatorname{Spec}(R)$ is connected) and $J\neq 0$, can $R/J$ ever be flat over $R$?


I think the answer is no, but I don't know how to prove it. Here's a failed attempt. Consider the exact sequence $0 \to J\to R\to R/J\to 0$. When you tensor with $R/J$, you get



> 
> $$
> 0 \to J/J^2 \to R/J \to R/J \to 0
> $$
> 
> 
> 


where the map $R/J\to R/J$ is the identity map. If $J\neq J^2$, this sequence is not exact, contradicting flatness of $R/J$.


But sometimes it happens that $J=J^2$, like the case of the maximal ideal of the ring $k[t^q| q\in\mathbf Q\_{>0}]$. I can show that the quotient is not flat in that case (see [this answer](https://mathoverflow.net/questions/195/is-there-an-example-of-a-formally-smooth-morphism-which-is-not-smooth/200#200)), but I had to do something clever.


I usually think about commutative rings, but if you have a non-commutative example, I'd love to see it.



Can a quotient ring R/J ever be flat over R?
1. If $A$ is arbitrary and $I$ is an ideal *of finite type* such that $A/I$ is a flat $A$-module, then $V(I)$ is open and closed. In fact, $A/I$ is a *finitely presented* $A$-algebra and thus $\operatorname{Spec}(A/I) \to \operatorname{Spec}(A)$ is a flat monomorphism of finite presentation, hence an étale monomorphism, i.e., an open immersion (cf. EGA IV 17.9.1).
2. If $A$ is a *noetherian* ring then $A/I$ is flat if and only if $V(I)$ is open and closed (every ideal is of finite type).
3. If $A$ is not noetherian but *has a finite number of minimal prime ideals* (i.e., the spectrum has a finite number of irreducible components), then it still holds that $A/I$ is flat iff $\operatorname{Spec}(A/I) \to \operatorname{Spec}(A)$ is open and closed. Indeed, there is a result due to Lazard [Laz, Cor. 5.9] which states that the flatness of $A/I$ implies that $I$ is of finite type in this case.
4. If $A$ has an *infinite number of minimal prime ideals*, then it can happen that a flat closed immersion is not open. For example, let $A$ be an absolutely flat ring with an infinite number of points (e.g. let $A$ be the product of an infinite number of fields). Then $A$ is zero-dimensional and every local ring is a field. However, there are non-open points (otherwise $\operatorname{Spec}(A)$ would be discrete and hence not quasi-compact). The inclusion of any such non-open point is a closed non-open immersion which is flat.


The example in 4) is totally disconnected, but there is also a connected example:


5. There exists a *connected* affine scheme $\operatorname{Spec}(A)$, with an infinite number of irreducible components, and an ideal $I$ such that $A/I$ is flat but $V(I)$ is not open. This follows from [Laz, 7.2 and 5.4].


[Laz] [Disconnexités des spectres d'anneaux et des préschémas (Bull SMF 95, 1967)](https://doi.org/10.24033/bsmf.1649)


**Edit**: Corrected proof of 1). An open closed immersion is not necessarily an open immersion! (e.g. $X\_{red} \to X$ is a closed immersion which is open but not an open immersion.)


**Edit**: Raynaud-Gruson only shows that flat+finite type => finite presentation when the spectrum has a finite number of *associated* points. Lazard proves that it is enough that the spectrum has a finite number of irreducible components. Added example 5).


