# Pasting lemma

In topology, the pasting or gluing lemma, and sometimes the gluing rule, is an important result which says that two continuous functions can be "glued together" to create another continuous function. The lemma is implicit in the use of piecewise functions. For example, in the book Topology and Groupoids, where the condition given for the statement below is that ${\displaystyle A\setminus B\subseteq \operatorname {Int} A}$ and ${\displaystyle B\setminus A\subseteq \operatorname {Int} B}$.

The pasting (or gluing) lemma is crucial to the construction of the fundamental group or fundamental groupoid of a topological space; it allows one to concatenate continuous paths to create a new continuous path.

## Formal statement

Let ${\displaystyle X,Y}$ be both closed (or both open) subsets of a topological space A such that ${\displaystyle A=X\cup Y}$, and let B also be a topological space. If ${\displaystyle f:A\to B}$ is continuous when restricted to both X and Y, then f is continuous.

This result allows one to take two continuous functions defined on closed (or open) subsets of a topological space and create a new one.

Proof: if U is a closed subset of B, then ${\displaystyle f^{-1}(U)\cap X}$ and ${\displaystyle f^{-1}(U)\cap Y}$ are both closed since each is the preimage of f when restricted to X and Y respectively, which by assumption are continuous. Then their union, ${\displaystyle f^{-1}(U)}$ is also closed, being a finite union of closed sets.

A similar argument applies when X and Y are both open. ${\displaystyle \Box }$

The infinite analog of this result (where ${\displaystyle A=X_{1}\cup X_{2}\cup X_{3}\cup \cdots }$)is not true for closed ${\displaystyle X_{1},X_{2},X_{3}\ldots }$. For instance, the inclusion map ${\displaystyle \iota :Z\rightarrow R}$ from the integers to the real line (with the integers equipped with the cofinite topology) is continuous when restricted to an integer, but the inverse image of a bounded open set in the reals with this map is at most a finite number of points, so not open in Z.

It is, however, true if the ${\displaystyle X_{1},X_{2},X_{3}\ldots }$ are open; this follows from the fact that an arbitrary union of open sets is open.