Lemma (gluing lemma)

Let $f: X\to Y$ be a function between topological spaces, and $A,B\subseteq X$ are subsets.

Suppose $A\cup B = X$ and $A,B$ are closed. Then $f$ is continuous iff both $f|_A$ and $f|_B$ are continuous.

Proof