Proof of Pasting Lemma

I am trying to understand the proof of the Pasting Lemma. I have found several proofs but I am missing something from all of them. Wikipedia has:

Statement: Let $X,Y$ be both closed (or both open) subsets of a topological space $A$ such that $A = X \cup Y$, and let $B$ also be a topological space. If $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 $f^{-1}(U )\cap X$ and $f^{-1}(U )\cap Y$ are both closed since the intersection of two closed sets is closed, and f restricted to both X and Y is continuous. Therefore, their union, f^{-1}(U) is also closed. A similar argument applies when X and Y are both open. \Box

My main objection to this proof is that they say "$f^{-1}(U )\cap X$ and $f^{-1}(U )\cap Y$ are both closed since the intersection of two closed sets is closed." Which two closed sets are they referring to? It seems they have assumed that $f^{-1}(U )$ is closed to begin with.

I have attempted the proof myself but I can't convince myself that that line is true for other reasons.

If someone could simply present a detailed proof of the Pasting Lemma for a beginner to general topology I would be grateful. Thanks.


Solution 1:

The wikipedia proof could definitely use a fix. Munkres "Topology" gets this right.

Consider $U$ a closed subset of $B$. The set $(f | X)^{-1}(U)$ is closed in $X$ because $f | X$ is continuous, and therefore $(f | X)^{-1}(U)$ is closed in $A$, because a closed subset of the closed subset $X \subset A$ is a closed subset of $A$. Similarly $(f | Y)^{-1}(U)$ is a closed subset of $A$, using $f | Y$ is continuous. So the union $$f^{-1}(U) = (f | X)^{-1}(U) \cup (f | Y)^{-1}(U) $$ is a closed subset of $A$.

It works similarly for open subsets.