Let $(X,\tau)$ be a topological space. We say that a subset $S\subset X$ is connected iff there does not exist a set $A\subset X$ that is both open and closed in the induced topology. I need to prove the following:
A subset $S \subset X$ is connected if and only if cannot be written as a union of two disjoint subsets $H,K$, such that $S=H \cup K$ with $\overline H \cap K= H \cap \overline K=\emptyset$
$(\implies)$ Suppose that there exist $H,K\subset S $ such that $S=H \cup K$ with $\overline H \cap K= H \cap \overline K=\emptyset$. Then $S\setminus \overline H$ is open because $\overline H$ is closed by definition. Since we know that $\overline H \cap K=\emptyset$ and $S=H \cup K$, clearly $S\setminus \overline H \subset K$. I would like to show that $\overline H$ is also open, but I don't know how to do it; I thought about showing that its complement $S\setminus \overline H$ is closed using that $H \cap \overline K$ is empty but I am not able to do it.
$(\impliedby)$ Suppose $S$ is not connected. Then there exists a set $H\subset S$ such that $H$ is both open and closed. Take $K=S\setminus H$ and we are done. In fact, $S=H\cup (S\setminus H)$ by definition. On the other hand, $\overline H=H$ since $H$ is closed, so $\overline H \cap K=\emptyset$. Since $H$ is open, $K$ is closed, hence $H \cap \overline K=\emptyset$.
How can I show the first implication to be true? It seems simple, but I feel like I am missing something.
I'll use the equivalent definition of connectedness: $A$ is disconnected iff there exist two closed disjoint subsets whose union is $A$. I'll also use subscripts to denote the space in which a closure is taken.
If $S$ is disconnected by $H$ and $K$, then $$\begin{align}H \cap \overline{K}_X &= (H \cap S) \cap \overline{K}_X \\&= H \cap (S \cap \overline{K}_X) \\ &= H \cap \overline K_S = \emptyset, \end{align}$$ and similarly for $\overline{H}_X \cap K$.
Conversely, if $H,K$ satisfy the criterion, then $$\begin{align}\overline H_S &= S \cap \overline{H}_X \\&=(H \cup K) \cap \overline H_X \\&= (H \cap \overline H_X) \cup (K \cap \overline H_X) = H \end{align}$$ and hence $H$ is closed in $S$. Similarly, $K$ is closed in $S$.