Continuous maps between open/closed topological subspaces give a continuous map between topological spaces Let $A,B$ be topological spaces and $\phi:A\rightarrow B$ a map.
Let $A',A''\subseteq A$ with $A=A'\cup A''$ and the maps $\phi|_{A'}:A'\rightarrow B$ en $\phi|_{A''}:A''\rightarrow B$ are continuous.

How do I prove that $\phi$ is continuous if
  1. $A',A''$ are open?
  2. $A',A''$ are closed?

What I have done:
I know that for $\phi$ to be continuous we must have that $\phi^{-1}B\in\mathcal{T_A}$, but I'm not sure what to do with the information that is given.
 A: Hint: Let $U$ be an open set in $B$.
In the case where $A'$ and $A''$ are open (each of the following statements requires proof): 
1) 
$$\phi^{-1}U=\phi|_{A'}^{-1}(U)\cup\phi|_{A''}^{-1}(U)
$$
2) Since $\phi|_{A'}$ and $\phi|_{A''}$ are continuous (and assuming they are given the subspace topology), there are open sets $V'$ and $V''$ in $A$ so that
$$
\phi|_{A'}^{-1}(U)=V'\cap A'
$$
and
$$
\phi|_{A''}^{-1}(U)=V''\cap A''
$$
3) Then, $\phi^{-1}U=(V'\cap A')\cup (V''\cap A'')$, which is a finite union/intersection of open sets (and therefore is open).
For the case where $A'$ and $A''$ are closed, use the fact that the preimage of a closed set is closed is another definition of continuity.
A: Let $U$ be an open subset of $B$. Since $\phi_{A'}$ and $\phi_{A''}$ are continuous, $\phi_{A'}^{-1}(U)$ and $\phi_{A''}^{-1}(U)$ are open.
By definition $\phi_{A'}^{-1}(U) = \{x \in A' \mid \phi(x) \in U\}$ and
$\phi_{A''}^{-1}(U) = \{x \in A'' \mid \phi(x) \in U\}$. It follows that
$$
\phi_{A'}^{-1}(U) \cup \phi_{A''}^{-1}(U) = \{x \in A' \cup A'' \mid \phi(x) \in U\} = \phi^{-1}(U)
$$
and thus $\phi^{-1}(U)$ is open.
A: Let's assume that $A'$ and $A''$ are open and show that $\phi$ is continuous. Let $U\subset B$ an open set of $B$. We have to show that $\phi^{-1}(U)$ is open in $A$.
$\phi|_{A'}^{-1}(U)$ is open in $A'$, as $\phi|_{A'}$ is continuous. This means, using induced topology, that there exists $O_1$ open in $A$ such that $\phi|_{A'}^{-1}(U)=A'\cap O_1$.
We also have, for the same reasons, $\phi|_{A''}^{-1}(U)=A'\cap O_2$ with $O_2$ open in $A''$.
Thus, $\phi^{-1}(U)=\phi|_{A'}^{-1}(U)\cup \phi|_{A''}^{-1}(U)=(A'\cap O_1)\cup (A''\cap O_2)$.
If $A'$ and $A''$ are open, then $A'\cap O_1$ and $A''\cap O_2$ are open and $\phi^{-1}(U)$ too.
You can do the same kind of proof in the case where $A'$ and $A''$ are closed.
