# Connected spaces minus proper subspaces is connected

So, I have a topology problem here. It goes like this. We have X, Y conected topological spaces and A, B proper subspaces of X and Y respectively. I have to show that $X \times Y - A \times B$ is connected.

I have considered using subspaces like $\{x\} \times Y \cup X \times \{y\}$ where $(x,y) \in X \times Y$, but I don't quite get to the proof...

Let $f \colon X \times Y - A \times B \to \{0,1\}$ be continuous. It is enough to show that $f$ is constant. Let $x_0 \in X - A$ and $y_0 \in Y - B$ be fixed, and let $(x,y) \in X \times Y - A \times B$. We will show that $f(x,y) = f(x_0,y_0)$.
Either $x \not\in A$ or $y \not \in B$. Without loss of generality, we may assume it is the former. The restriction of $f$ to $\{x\} \times Y$, which is connected, is continuous. Therefore this restriction is constant. hence $f(x,y) = f(x,y_0)$.
Applying the same argument to $X \times \{y_0\}$, we conclude that $f(x,y_0) = f(x_0,y_0)$, completing the proof.
• Why is enough to show that $f$ is constant? – sinbadh Feb 3 '16 at 10:04
• @sinbadh There is a well-known characterization of connected spaces. A space $X$ is connected if and only if every continuous function $f \colon X \to \{0,1\}$ is constant. This criterion is an immediate consequence of the definition of connectedness; the existence of a non-constant continuous $f$ is equivalent to the existence of a partition of $X$ into two disjoint nonempty open subsets. – David Feb 3 '16 at 10:06