topology question in Hartshorne's Algebraic Geometry

On page 15, in Lemma 3.1 it is claimed: "A subset Z of a topological space Y is closed if and only if Y can be covered by open subsets U such that Z $\cap$ U is closed in U for each U."

How do I prove this?

-

For the $(\Leftarrow)$ direction, let $Z$ be a subset of $Y$ and we will show that $V := Y \setminus Z$ is open. The given covering of $Y$ has the property that $V \cap U$ is open in $U$ for all $U$. But $U$ is open in $Y$, so $V \cap U$ is open in $Y$. And $V = \cup (V \cap U)$ since the $U$'s cover $Y$, so $V$ is open in $Y$, as desired.

-

For the first direction, if $Z$ is closed, then $Y$ is open and $\{Y\}$ is an open cover of $Y$ such that $Z\cap Y$ is closed in $Y$.

For the converse direction, if $Z$ is not closed, then there is some $z\in \partial Z \cap Z'$. Let $\{U\}$ be an open cover of $Y$ such that $Z\cap U$ is closed in each $U$. Consider $U_z \ni z$. Then in $U_z$, $z\in\partial (Z\cap U)$ but $z\notin (Z\cap U)$, so $Z\cap U$ cannot be closed in $U$ after all.

-

If $Z$ is closed, consider the points of $Y-Z$. For each such point, take an open set containing it disjoint of $Z$. Also, for each point of $Z$, consider any open set containing it. Then you'll have open sets covering $Y$ satisfying the conditions required on the intersections. This proves $(\Rightarrow)$.

-
For the $(\Rightarrow)$ direction, you can take the covering consisting of the single open set $Y$. –  Michael Joyce Oct 21 '12 at 15:55