Is the restriction of a flat morphism flat?

Let $X$ be a projective scheme, $X_1, X_2$ be closed subschemes of $X$. Let $f:X \to S$ be a flat morphism for some scheme $S$. Denote by $i_1$ and $i_2$ the natural inclusion maps from $X_1$ and $X_2$, respectively to $X$. Assume that the composition maps $f \circ i_1$ and $f \circ i_2$ are flat. Is it then true that the fiber product $X_1 \times_X X_2$ is flat over $S$ under the natural maps $f \circ i_1 \circ pr_1$ or $f \circ i_2 \circ pr_2$, where $pr_i$ is the natural projection morphism from $X_1 \times_X X_2$ onto its $i$-th coordinate?

• Dear @Cantlog, I have taken the liberty of adding a few details to your answer :-) – Georges Elencwajg Sep 14 '13 at 9:03
• Dear @GeorgesElencwajg: Sure. But I don't want to bother answering questions of someone who does not make effort to understand answers he/she got previously. – Cantlog Sep 14 '13 at 9:41
• Dear @Cantlog, I understand your point of view but have a different philosophy on the questions I choose to answer. In a nutshell, I always give answers if they involve computations or examples that are not in books. It is not my role (in my opinion) to paternalistically decide what is good for the student. – Georges Elencwajg Sep 14 '13 at 11:14
• Dear @Cantlog, thanks for the kind words: I understand what you mean. I'm getting annoyed by some users on this site who couldn't answer a question at the level of chapter 0 of the most elementary book on algebraic geometry, who have only ever given utmost banal,insightless answers on other subjects, and who come pontificating , demanding that the OP do this and that, and try to close questions. Needless to say my bad mood is not in the least directed at you: I am very glad of your presence here, which is certainly a bonus for this site, both on a human and on a mathematical level. – Georges Elencwajg Sep 14 '13 at 14:21
• Also, I'm on edge because I realize that some of the best contributors have left this site, the most recent case being that remarkable mathematician Qing Liu, a master for us all. I can't get over this dreadful loss and I can't get rid of the suspicion that the humourless, snarky behaviour of some users might have played a role in his sad decision. – Georges Elencwajg Sep 14 '13 at 14:27

No, the fiber product is not always flat over $S$:

Let $k$ be a field of characteristic $\neq 2$ and take for $f$ the first projection $f:X=\mathbb A^2_k=\operatorname {Spec}k[x,y]\to S=\mathbb A^1_k=\operatorname {Spec} k[x]$, for $i_1$ the closed immersion of $X_1=V(x-y^2)$ into $X$ and for $i_2$ the closed immersion of $X_2=V(x+y^2)$ into $X$.
The fiber product $X=X_1\times_X X_2$ is then the same as the scheme theoretic intersection intersection $X_1\cap X_2=V((x-y^2,x+y^2))=V(x,y^2)$, a double point.
This fiber product is thus certainly not flat $(\bigstar)$ over $S=\mathbb A^1_k$, although $X,X_1$ and $X_2$ are $(\bigstar \bigstar)$.

$(\bigstar)$ Since it corresponds to the ring morphism $k[x]\to k[x,y]/(x,y^2)=k[y]/(y^2):x\mapsto 0$
$(\bigstar \bigstar)$ Recall that a morphism from an integral reduced scheme to a nonsingular curve is flat iff it is dominant (Hartshorne, III 9.7, page 257), which shows that $X,X_1$ and $X_2$ are flat over $S$.

• @Martin Brandenburg: of course $X$ is flat over $S$. Beware that your wish to criticize my answer will lead you to making egregious mistakes on very elementary mathematics. – Georges Elencwajg Sep 14 '13 at 11:25
• I hadn't noticed $X$ was supposed to be projective. As @Martin Brandenburg remarks , a trivial modification (taking projective closure) will yield a projective counterexample. – Georges Elencwajg Sep 14 '13 at 11:26
• Sorry I was thinking of $f$ in the wrong direction. Anyway, $X,X_1,X_2$ are flat over $S$ because the corresponding algebras are just free as modules. No need to cite some deep theorem. – Martin Brandenburg Sep 14 '13 at 11:57
• @Martin. I'm happy you realized your mistake. As to using deep results: I sometimes think it useful for didactical purposes to surreptitiously draw the reader's attention to a general (maybe deep) result which may be good to know, as is definitely the case here for the flatness criterion I quote. – Georges Elencwajg Sep 14 '13 at 12:15

In the spirit of Georges's philosophy of recording useful (counter)examples, let me offer another:

Consider the projection $X = \mathbb A^2 \to S = \mathbb A^1$ given by $(x,y) \mapsto x$.

Now let $X_1$ be the line $y = 0$ and $X_2$ be the line $x + y = 0$. Both map isomorphically to $\mathbb A^1$ (and an isomorphism is flat!). However there intersection is the single point $(0,0)$, which does not map flatly to $\mathbb A^1$.

(Note: as with Georges's answer, my varieties are not projective, because it is easier to write formulas in the affine setting. It is an exercise to "complete" the above example to give an analogous example with projective varieties.)

General remark: As Georges pointed out in his answer, and as I used above, the fibre product over $X$ of two closed subschemes of $X$ is just their (scheme-theoretic) intersection. So the map you are asking about, namely $X_1\times_X X_2 \to S$, factors as the closed immersion $X_1\times X_2 \to X_1$, followed by the flat map $X_1 \to S$. Since closed immersions are never flat unless they are isomorphisms, there is no reason at all to think that the answer to your question would be yes, and of course it was easy for Georges and me to come up with counterexamples, just by thinking of examples of non-trivial (and hence non-flat) closed immersions.