TITLE: A map is continuous if and only if the restrictions are
QUESTION [7 upvotes]: I want to find out if the following statement is true or false, and prove why:

Let $X$ be a topological space. Suppose $X=A \cup B$ and $f:X \rightarrow Y$ is a map whose restrictions to $A$ and $B$ are $f_A:A \rightarrow Y$ and $f_B:B \rightarrow Y$. Then $f$ is continuous if and only if $f_A$ and $f_B$ are continuous. 

I'm not really sure where to start with a proof on this. What's a good way to prove a map is continuous in this context?

REPLY [4 votes]: Continuity of restrictions $f_A:A\to Y$ and $f_B:B\to Y$ does not justify the conclusion that $f$ is continuous. 
The extra condition needed for that is that $A$ and $B$ have the so-called gluing property.
Let $\tau$ be the topology on $X$ and let $A$ and $B$ both be equipped with the induced subspace topology.
Then there is a topology $\tau'$ on $X=A\cup B$ prescribed by the rule: $$V\in\tau'\iff [V\cap A\text{ is open in }A]\wedge [V\cap B\text{ is open in }B]$$or equivalently by the rule:$$F^{\complement}\in\tau'\iff [F\cap A\text{ is closed in }A]\wedge [F\cap B\text{ is closed in }B]\tag1$$
Then evidently $\tau\subseteq\tau'$. 
In the special case that $\tau'$ is not properly finer than $\tau$ (so $\tau'=\tau$) the sets $A$ and $B$ have the gluing property.
It is the special case in which the following diagram - where all arrows denote inclusions - is a pushout square.
$$\begin{array}{ccc}
A\cap B & \longrightarrow & A\\
\downarrow &  & \downarrow\\
B & \longrightarrow & A\cup B
\end{array}$$
If $A$ and $B$ are both closed (or are both open) then $(1)$ makes clear that $A$ and $B$ have the gluing property.