Showing that $\mathbb{R}$ is connected [duplicate]

So I know that $\mathbb{R}$ is both open and closed. But given a set, $X\subset \mathbb{R}$, $X\ne \emptyset $ that is both open and closed, how does one show that $X=\mathbb{R}$?

Here is my attempt: Using the definitions I was given, $X$ open implies that for every $x\in X$ there is a $\delta \gt 0$, $(x-\delta,~ x+\delta)\subset X$. Also, since $X$ is closed , $B=\mathbb{R}$\ $X$ is open.

However, I don't know how to proceed.
NB: This is not a homework problem.


Suppose that $X$ and $\mathbb{R}\setminus X$ are both open. Pick a point $a\in X$ and a point $b\in \mathbb{R}\setminus X$. There’s no harm in assuming that $a<b$. Let $A = \{x\in [a,b]:[a,x]\subseteq X\}$. $A$ is bounded, so it has a least upper bound $u$. Clearly $u\le b$.

Now let $\epsilon > 0$, and consider the interval $J=(u-\epsilon, u+\epsilon)$. Since $u$ is the least upper bound of $A$, $A \cap (u-\epsilon,u]\ne\varnothing$, and therefore certainly $J\cap A\ne \varnothing$. This shows that $u$ can’t be in $\mathbb{R}\setminus X$, since no open nbhd of $u$ is a subset of $\mathbb{R}\setminus X$, Thus, $u\in A$, and therefore $u<b$ (since $b\notin A$). Let $v=\min\{u+\epsilon,b\}$. Clearly $v \notin A$, so there is some $x\in [a,v)\setminus X$. since $[a,u]\subseteq X$, we must have $x\in [u,v)\subseteq [u,u+\epsilon)$. Thus, $J\setminus X\ne \varnothing$, and $J\nsubseteq X$. Thus, $u$ can’t be in $X$, either. Since $u$ has to be somewhere, this is a contradiction, showing that $X$ and $\mathbb{R}\setminus X$ can’t both be open.


Theorem. A compact interval $[a,b]$ is connected.

Suppose $[a,b]$ were disconnected. Then there would exist a continuous surjective function $f$ from $[a,b]$ onto the discrete space $\{0,1\}$. Said discrete space can also be considered as a subset of $\mathbb R$ with the subspace topology, so $f$ would be continuous as a function from $[a,b]$ to $\mathbb R$ as well. But by the intermediate value theorem, it would attain every value in the interval $[0,1]$ contradicting that it's a function onto $\{0,1\}$. Hence such a function cannot exist, and $[a,b]$ must be connected. $\square$

Theorem. If a space $X$ contains at least two points and any pair of distinct points of $X$ are contained in a connected subset, then $X$ is connected.

Proof. Suppose we have disjoint nonempty open sets $A,B \subset X$ with $A \cup B = X$, i.e. a disconnection of $X$. By the assumption there are $a \in A$ and $b \in B$ contained in a connected $S \subseteq X$. $S$ has the subspace topology, so $A \cap S$ and $B \cap S$ would then be disjoint nonempty open subsets of $S$ with $(A \cap S) \cup (B \cap S) = (A \cup B) \cap S = X \cap S = S$, yielding a disconnection of $S$, which is our desired contradiction. $\square$

Corollary. $\mathbb{R}$ is connected.


Hint: $X$ is clopen iff $\partial X = \partial X^c = \emptyset$


You can prove, as a previous exercise, that $x\in \partial(X)$ (boundary of $X$) if and only if there exist sequences $(x_n)$ in $X$ and $(y_n)$ in $\mathbb{R}\setminus X$ such that $x_n\to x$ and $y_n\to x$. After demonstrating this you can argue as follows:

Suppose that $X$ and $\mathbb{R}\setminus X$ are both closed. Take $x\in\partial(X)$. There exist $(x_n)$ in $X$ with $x_n\to x$. Since $X$ is closed, $x\in X$. In the same way you can prove that $x\in \mathbb{R}\setminus X$, and this is a contradiction. Therefore the boundary of $X$ is empty.

Now, since $X$ is open there exist a countable collection of open disjoint intervals $I_k=(a_k,b_k)$ such that $$X=\bigcup_{k\in\mathbb{N}} I_k.$$ Since $X\neq \emptyset$, at least an interval $I_r=(a_r,b_r)$ is not empty and is contained in $X$. Note that if $a_r=-\infty$ and $b_r=\infty$, then $\mathbb{R}\subseteq X$ and there is nothing to prove. Therefore we can assume that either $a_r$ or $b_r$ is finite, is a number. W. l. o. g. assume that $a_r$ is a number We have $a_r\not\in X$. Then since $\mathbb{R}\setminus X$ is also open, exist $\delta>0$ such that $(a_r-\delta,a_r+\delta)\subset \mathbb{R}\setminus X$. But since $a_r$ is in the boundary of $I_r$, $(a_r-\delta,a_r+\delta)\cap I_r\neq \emptyset$ and therefore $(a_r-\delta,a_r+\delta)\cap X\neq\emptyset$. Note that from here is possible to show that $a_r\in\partial(X)$, and this is an absurd.

Therefore such $X$ cannot be.