Let $(X,d),(Y,d')$ be metric spaces and let $f:X\to Y$ be a function.
Decide whether the following statements are true or false:
- If $X=\bigcup_{i=1}^nF_i$ where $F_i$ is closed and $f|_{F_i}$ is continuous for all $i$ $\implies$ $f$ is continuous.
- If $X=\bigcup_{i=1}^nX_i$ and $f|_{X_i}$ is continuous for all $i$ $\implies$ $f$ is continuous.
I thought I had managed to prove that 1. is true by first proving that $\bigcup\limits_{i=1}^n f|_{F_i}^{-1}(A)=f^{-1}(A)$ for all $A\subseteq Y$, then, by continuity, $f|_{F_i}^{-1}(A)$ is open for all open $A$ thus $f^{-1}(A)$ is open and then $f$ is continuous.
As I didn't use the $F_i$ is closed hypothesis this led me to believe that this is a proof for 2.
But I've come up with a counterexample for 2. so I know that there's something wrong with the proof.
In fact, the correct proof would go like:
Aside. Note that the above is not necessarily true if we had an infinite union.
Consider $X = [0, 1]$ and $F_i = \{i\}$ for each $i \in [0, 1] = I$.
Clearly, $X = \bigcup_{i \in I}F_i$ and each $F_i$ is closed. Moreover, given any $f:X\to Y$, $f|_{F_i}$ will be continuous.
However, not every function $f:X\to Y$ is continuous.
Let $X = Y = [0, 1]$. Consider $F_1 = \{1\}$ and $F_2 = [0, 1)$.
Define $f:X \to Y$ as $f(x) = x - \lfloor x\rfloor$.
I leave the verification that the above is a counterexample up to you.