Pasting Lemma

Theorem
Let $X$ and $Y$ be topological spaces.

Let $A$ and $B$ be open in $X$.

Let $f: A \to Y$ and $g: B \to Y$ be continuous mappings that agree on $A \cap B$.

Let $f \cup g$ be the union of the mappings $f$ and $g$:


 * $\forall x \in A \cup B: \map {f \cup g} x = \begin {cases} \map f x & : x \in A \\ \map g x & : x \in B \end {cases}$

Then the mapping $f \cup g : A \cup B \to Y$ is continuous.

Proof
First it is shown that $f \cup g$ is well-defined.

It is sufficient to check that $f \cup g$ maps any $x \in A \cap B$ to a single value in $Y$.

Let $x \in A \cap B$.

Because $x \in A$:
 * $\map {f \cup g} x = \map f x \in Y$

Because $x \in B$:
 * $\map {f \cup g} x = \map g x \in Y$

But by definition of agreement of mappings:
 * $\map f x = \map g x$

so $f \cup g$ maps $x$ to a unique value in $Y$, as was to be shown.

Next it is shown that $f \cup g$ is continuous:

We show that $\map {\paren {f \cup g}^{-1} } U$ is open in $A \cup B$ for every open $U$ in $Y$.

Observe first that $(f \cup g)^{-1}(U) = f^{-1}(U) \cup g^{-1}(U)$.

For if $x \in (f \cup g)^{-1}(U) \subseteq A \cup B$, then $(f \cup g)(x) \in U$; but if $x \in A$, then $f(x) = (f \cup g)(x) \in U$ i.e. $x \in f^{-1}(U)$ or if $x \in B$, then $g(x) = (f \cup g)(x) \in U$ i.e. $x \in g^{-1}(U)$. In both cases, $x \in f^{-1}(U) \cup g^{-1}(U)$. Conversely if $x \in f^{-1}(U) \cup g^{-1}(U)$, then without loss of generality consider the case of $x \in f^{-1}(U) \subseteq A$; in this case $(f \cup g)(x) = f(x) \in U$ so that $x \in (f \cup g)^{-1}(U)$.

Having established that $(f \cup g)^{-1}(U) = f^{-1}(U) \cup g^{-1}(U)$, note that by continuity of $f$ and $g$, we have that $f^{-1}(U)$ is open in $A$ and $g^{-1}(U)$ is open in $B$. So there are an open sets $P$ and $Q$ of $X$ such that $f^{-1}(U) = P \cap A$ and $g^{-1}(U) = Q \cap B$. Since $A$ and $B$ are open in $X$ and intersections of open sets are open, this implies that $f^{-1}(U)$ and $g^{-1}(U)$ are open in $X$. Furthermore, note that $P \cap A$ and $Q \cap B$ are both subsets of $A \cup B$. Hence, $f^{-1}(U) = f^{-1}(U) \cap (A \cup B)$ and $g^{-1}(U) = g^{-1}(U) \cap (A \cup B)$.

Thus:
 * $(f \cup g)^{-1}(U) = f^{-1}(U) \cup g^{-1}(U) = (f^{-1}(U) \cup g^{-1}(U)) \cap (A \cup B)$

demonstrating that $(f \cup g)^{-1}(U)$ is open in the subspace topology of $A \cup B$.