TITLE: Fibers equal implies schemes equal in a neighborhood
QUESTION [6 upvotes]: Let $f:X \rightarrow Y $ be a morphism of locally Noetherian schemes. Let $Z$ be a closed subscheme of $X$ and suppose that there exists a point $y \in Y$ such that $Z_y=X_y$ as schemes. Show that if $Z$ is flat over $Y$ at $z \in X_y$ , then $Z$ is equal to $X$ in a open neighborhood of $z$.
The problem is from Liu's book and he tells me to use the following, but I can't seem to put it together
1. Use : Let $A \rightarrow B$ be a ring homomorphism and $J$ an ideal such that $B/J$ is flat over $A$. Then for any ideal $I$ of $A$, we have $IB \cap J = IJ$.
2. Use Nakayama's lemma.

REPLY [5 votes]: Take $A=O_{Y,y}$, $I$ the maximal ideal of $A$, $B=O_{X,z}$ and $J\subseteq B$ the image of the ideal defining the closed subscheme $Z$ in $X$. 
The hypothesis $X_y=Z_y$ in a neighborhood of $z$ means the canonical map 
$$B/IB=B\otimes_A A/I\to (B/J)\otimes_A A/I=B/(IB+J)$$
is an isomorphism. The kernel in general is $(IB+J)/IB\simeq J/(IB\cap J)$. So $J=IB\cap J$. By (1), this implies $J=IJ$. Applying Nakayama to the $B$-module $J$, we get $J=0$. Hence $Z=X$ in a neighborhood of $z$.