TITLE: If union and intersection of two subsets are connected, are the subsets connected?
QUESTION [11 upvotes]: I'm starting with the basics of topology theory and I'm trying to show:

Let $A$ and $B$ be closed subsets of a topological space. If $A\cap B$ and $A\cup B$ are both connected, $A$ and $B$ are connected.

I've tried to prove it whit subsets operations and by contradiction, but I've failed with both strategies. Can you help me, please?

REPLY [19 votes]: Suppose for a contradiction that $A$ is disconnected. Then there are closed, disjoint, non-empty subsets $S, T$ of $A$ such that $A=S\cup T$.
Since $A\cap B$ is connected, one of $B\cap S$ and $B\cap T$ must be empty, otherwise $A\cap B=(B\cap S)\cup (B\cap T)$. WLOG assume $B\cap S=\emptyset$.
Now, since $S$ and $T$ are closed in $A$ and $A$ is closed in $X$, $S$ and $T$ are closed in $X$. Therefore, $B\cup T$ and $S$ are closed non-empty subsets of $A\cup B$. Obviously, $(B\cup T)\cap S=\emptyset$ and $A\cup B=(B\cup T)\cup S$, so $A\cup B$ is disconnected, contradiction.