# Prove that $A\cup B$ is connected.

Let $$A$$, $$B$$ $$\subseteq \mathbb{R^n}$$ be connected sets and suppose that $$\overline{A} \cap B \ne \emptyset$$. Prove that $$A\cup B$$ is connected.

My attempt: I've tried a proof by contradiction.

Suppose that $$A\cup B$$ is disconnected, e.g. $$A\cup B = X\cup Y$$, where $$X, Y$$ are disjoint, nonempty, and open in $$A\cup B$$.

Besides that, we have $$A\cap X$$ and $$Y\cap A$$ open in $$A$$, and that they cover A. But since A is connected by hypotesis, then we can suppose that $$A\cap X= \emptyset$$. And that implies that $$A \subseteq Y$$.

So far, so good... but where do I get the contradiction? Where do I use that $$\overline{A} \cap B \ne \emptyset$$? Any help to finish this proof would be appreciated!

You are on the right track. Continuing from your argument: in a similar fashion we see that $$B$$ must be contained in the other open, so $$B \subseteq X$$. Now we can use that $$\bar{A} \cap B \neq \emptyset$$, because that means there is a point $$b \in B$$ that is also in the closure of $$A$$. So every open containing $$b$$ must intersect $$A$$. In particular $$X$$ must intersect $$A$$, and now we have our contradiction.

Note that this argument works for any topological space, not just $$\mathbb{R}^n$$.

I once gave an answer to this question that is pretty similar (modulo notation) but you can also use the fact that

$$X$$ is connected iff every continuous $$f:X \to \{0,1\}$$ (the latter in the discrete topology) is constant.

So take $$f: A \cup B \to \{0,1\}$$ and assume it's continuous. Then by connectedness of $$A$$, $$f\restriction_A$$ is constant (say with value $$a \in \{0,1\}$$) and likewise $$f\restriction_B$$ is constant with value $$b \in \{0,1\}$$. By continuity of $$f$$ we know:

$$f[\overline{A}] \subseteq \overline{f[A]} = \{a\}$$

while of course $$f[B]=\{b\}$$. But as $$\overline{A} \cap B \neq \emptyset$$ it follows that $$a=b$$ and $$f$$ is constant and thus $$A \cup B$$ is connected.