When is a function who is defined on two disjoint sets are continuous? Okay so let $f$ be a function, $A$ and $B$ two sets that are disjoint.
$f$ is continuous on $A$
$f$ is continuous on $B$.
My teacher told me that $f$ is continuous on these two disjoint sets if and only if they are mutually separated, meaning no one contains the boundary of the other.
I couldn't understand the reason behind this. Could someone help out?
 A: That's not actually completely true.
Suppose that $f$ is the constant function $f(x)=1$ on both $A$ and $B$. Then $f$ is going to $A\cup B$-continuous no matter what happens with $A$ and $B$.
The following two things are true however:

If $f:X\rightarrow Y$ is continuous on  $A$ and $B$ and $\overline A\cap \overline B=\varnothing$ the $f$ is continuous on $A$ and $B$.
The proof of this is going to be different depending on whether you are working on metric spaces or topological spaces. 
Proof for topological spaces: 
Every $A$-open set is also $A\cup B$-open. To see this take an $A$-open set  $U$, notice that $U=U'\cap A$ for some open set $U'$. Notice that $U=(U'\cap (X\setminus \overline B) ) \cap (A\cup B)$. And so $U$ is $AB$-open.
Proving that $f$ is $AB$-continuous is now easy, given an open $V\subseteq Y$ that $f^{-1}(V)\cap A$ is $A$-open and $f^{-1}(V)\cap B$ is $B$-open, so by hypothesis both are $AB$-open and so their union is $AB$-open, and their union is precisely $f^{-1}(V)\cap (A\cup B)$. So $f$ is  $A\cup B$-continuous.

If $\overline A \cap \overline B\neq \varnothing$ then there exists a function $f:X\rightarrow Y$ that is continuous on $A$ and $B$ but not on $A\cup B$.
Proof: I suffices to take the function $f(x)=1$ if $x\in A$ and $f(x)=0$ otherwise.
Pick a point $x$ such that $x\in \overline A \cap \overline B$. Notice that every open set $U$ containing $x$ satisfies that $\{0,1\}\subseteq f(U)$. This is a contradiction, since we can find an open set $V$ containing $f(x)$ such that at least one of $0$ and $1$ is not in $V$.
A: The "only if" direction does not hold.
If the domain of $f$ is the union of two separated sets, it is disconnected. Let $(X,\tau)$ be a disconnected topological space and $(Y,\upsilon)$ another topological space. Suppose that $f:X \to Y$ is continuous on $U$ and $V$ where $U,V$ are disjoint open subsets of $X$ whose union is $X$. We can separate $f$ into two mappings: $\phi = f\restriction_U, \psi = f\restriction_V$. Then $\phi \in C(U,Y),\psi \in C(V,Y)$. If $W \subseteq Y$ is open, then $f^{-1}[W] = \phi^{-1}[W] \cup \psi^{-1}[W]$ is the union of two open sets, and thus open. This shows that $f$ is continuous.
A: Definitely false: an easy general method for making counterexamples is take $A$ and $B$ as disjoint subsets of some larger topological space $X$. Then take a function $f^*:X\rightarrow Y$ that is continuous, and restrict its domain to $A\cup B$ to get a new function $f:A\cup B\rightarrow Y$. This function is continuous because $f^*$ was. To make it a counterexample to your teacher's claim, all that you require is that $\overline{A}\cap\overline{B}\neq\emptyset$ (they are not separated).
