A question about continuity in topology Munkres' "Topology" states that 

The map $f:X\to Y$ is continuous if $X$ can be written as the union of open sets $U_\alpha$ such that $f|U_\alpha$ is continuous for each $\alpha$. 

The proof says

Let $V$ be an open set in $Y$. Then $f^{-1}(V)\cap U_\alpha=(f|U_\alpha)^{-1}(V)$ is an open set. 

What if $V$ is not (completely) in any $f(U_\alpha)$? Why would $f^{-1}(V)\cap U_\alpha$ be open then? Remember that we don't know if $f$ is continuous or not as of now. All we know is that $f|U_\alpha$ is continuous for every $U_\alpha$. 
 A: Suppose $f: X \rightarrow Y$ is a function (no other assumptions) and $A \subset X, B \subset Y$. Then $f|A : A \rightarrow Y$ is always defined in the obvious way and $(f|A)^{-1}[B]$ is well-defined and equals (by definition) all points of $A$ that have values in $B$. This of course equals $f^{-1}[B] \cap A$: having values in $B$ means being in the first set, being in $A$ in the second. So always, without any other knowledge, we have: $(f|A)^{-1}[B] = f^{-1}[B] \cap A$.
Now we return to the situation from the question. We know that each $f|U_{\alpha}$ is continuous and each $U_{\alpha}$ is open in $X$. This means that if $V \subset Y$ is open, by definition of continuity of $f|U_{\alpha}: U_\alpha \rightarrow Y$, $(f|U_{\alpha})^{-1}[V]$ is open in $U_\alpha$. So for some open set $O_\alpha \subset X$ we know that $O_\alpha \cap U_\alpha = (f|U_\alpha)^{-1}[V]$, by the definition of a subspace topology. The left hand side of this consists of two open sets of $X$, intersected, so is also open in $X$. Hence the right hand set $(f|U_\alpha)^{-1}[V]$ is open in $X$ (and not just in $U_\alpha$). I have in fact reproven a simple fact: a relatively open set of an open subspace is open in the whole space as well (and the same holds replacing open by closed here), for the special case at hand.
Now we know that all sets $(f|U_\alpha)^{-1}[V]$ are open in $X$, by the equality from the first paragraph. And as $f^{-1}[V] = \bigcup_\alpha (f|U_\alpha)^{-1}[V]$, we know that $f^{-1}[V]$ is open in $X$ as well, which is what one had to show. 
