Decide whether a function is continuous if it's restrictions are. 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.
 A: *

*Note that you've gotten $f|_{F_i}^{-1}(A)$ is open in $F_i$. This does not mean that it's open in $X$.
In fact, the correct proof would go like:  


*

*Let $A$ be a closed subset of $Y$.  

*$f|_{F_i}^{-1}(A)$ is closed in $F_i$. Since each $F_i$ is closed in $X$, we get that $f|_{F_i}^{-1}(A)$ is closed in $X$.  

*Use the fact that finite unions of closed sets is closed.  

*Conclude that $f^{-1}(A)$ is closed for every closed subset $A$ of $Y$.  

*Conclude that $f$ is continuous.




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.



*The statement is false.
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.
