# If a nonempty set of real numbers is open and closed, is it $\mathbb{R}$? Why/Why not?

In other words, are $\emptyset$ and $\mathbb{R}$ the only open and closed sets in $\mathbb{R}$? Why/Why not?

I tried by assuming a set is equal to its interior points and contains its limit points.

A bounded set will not do since stuff like $[1,4]$ and $\{5\}$ will not work, though that is not really proof. Help please?

Anyway, it must then be unbounded.

If $a$ is a real number then $(a,\infty)$, $(-\infty,a)$, $[a,\infty)$ and $(-\infty,a]$ don't seem to cut it so it must be $\mathbb{R}$.

• A closed set contains all of its border. An open set contains none of its border. What do you conclude about the border of a set that is both open and closed? Commented Apr 13, 2014 at 14:49
• There was a hint that somehow vanished that suggested to think about connectedness. Commented Apr 13, 2014 at 14:53
• The border obviously cannot contain elements outside of $\mathbb R$ because we are talking about the topology of $\mathbb R$. Commented Apr 13, 2014 at 14:57
• More exactly, its border is the empty set (the border as set of all border points is always defined, but the clopen set has no border points, and thus the border is empty). Commented Apr 13, 2014 at 15:13
• Well, showing that is showing that $\mathbb R$ is connected. Commented Apr 13, 2014 at 15:47

Suppose $X \subset \mathbb{R}$ is nonempty, open and closed. Let $x_0 \in X$. Finally suppose that $X \neq \mathbb{R}$; then there is some $y \not\in X$; WLOG we can assume that $y > x_0$.

Then the set $Z = \{ x \in \mathbb{R} : x > x_0, x \not\in X \}$ is bounded below (by $x_0$) and nonempty ($y \in Z$). Therefore $\inf Z = z$ exists.

• Suppose $z \in X$. Then since $X$ is open, it contains an open neighborhood $(z - \epsilon, z + \epsilon)$. This contradicts the definition of $z = \inf Z$, because there would be a sequence $z_n > z$, $|z - z_n| < \frac{1}{n}$, $z_n \in Z \Rightarrow z_n \not \in X$. This is not possible, because $[z, z + \epsilon) \subset X$.

• Suppose $z \not \in X$. Then since $X$ is closed, its complement is open, therefore there is an open neighborhood $(z - \epsilon, z + \epsilon)$ contained in $\mathbb{R} \setminus X$. Then $z - \frac{\epsilon}{2}$ contradicts the $\inf$ definition of $z$.

It follows that $X = \mathbb{R}$.

• why would $z-\frac{\epsilon}{2}$ immediately yield a contradiction? Commented Jun 7, 2017 at 11:43
• @user162089 Because $z - \epsilon/2$ is in $\mathbb{R} \setminus X$. Furthermore so is all of $[z-\epsilon/2, z]$, thus $x_0 \not \in [z-\epsilon/2,z]$. However by definition $z$ is the inf of $\mathbb{R} \setminus X \cap (x_0,+\infty]$, therefore $z \le z - \epsilon/2$, a contradiction. Commented Jun 7, 2017 at 11:47
• How do you obtain $z\leq z-\epsilon/2$ from $z$ being the infimum of the set $Z$? I can't see why the jump holds. Commented Jun 7, 2017 at 12:01
• @user162089 No, it is not a result of infimum, it is a result of $z-\frac{\epsilon}{2}\in Z$. Now, $z$ is the infimum. Hence, it is a lower bound of the set $Z$. $z-\frac{\epsilon}{2}$ is a member of the $Z$, so it should be greater than or equal to the lower bound, which is $z$. Commented May 21, 2021 at 1:24
• "WLOG we can assume that $x_0<y$" - Why can we assume that WLOG? We can not assume that such a $y$ always exists, can we? Do you simply mean that we can write a similar proof for the case $y<x_0$? Commented Aug 6, 2023 at 6:13

You're trying to prove that $\mathbb{R}$ is connected. You can do as follow : if a set $\mathbf{A}$ is both open and closed, then you can check that $\mathbb{1}_\mathbf{A}$ (the characteristic function of $\mathbf{A}$) is continuous, because $\mathbb{1}_\mathbf{A}^{-1}(O)$ where O is open is either $A$, its complement, the empty set or $R$ depending on $1$ and/or $0$ being in $O$, and all these set are open.

But $\mathbb{1}_\mathbf{A}$ only takes values $1$ or $0$, so it's easy to see that if it's continuous, then it's constant (if it is not, by the Intermediate Value Theorem, then it should also take all values between $0$ and $1$). Hence it's either always $1$ or $0$. And so $\mathbf{A}$ is either $\mathbb{R}$ or the empty set.

• Quite an elegant approach ! Commented Apr 21, 2014 at 18:11
• All you have proven is that a space $X$ is connected iff all functions $X \to \{0,1\}$ are constant. What you haven't proven (you just said "it's easy") is that all functions $\mathbb{R} \to \{0,1\}$ are constant. Commented Jul 12, 2016 at 9:56
• No, I claimed that all continuous functions $\mathbb{R} \to \{ 0, 1 \}$ are constant (of course it is false in general, e.g. $\mathbb{1}_\mathbb{Q}$ is not). I just added a short justification, but it's just a trivial application of the (well-known !) Intermediate Value Theorem.
– yago
Commented Jul 13, 2016 at 11:10
• Nice approach! If $\Bbb R$ were disconnected then there would exist a continuous $f:\Bbb R\to \Bbb R$ that does not have the IVP. Commented Aug 17, 2018 at 9:24

Because $\mathbb R$ is connected. Asume $U$ is a nonempty proper open and closed subset of $\mathbb R$, that is $V:=\mathbb R\setminus U$ is also nonempty and open. Let $u\in U$, $v\in V$. Wlog. $u<v$. Let $a=\sup([u,v]\cap U)$. As $[u,v]\cap U$ is a nonempty bounded closed set, $a\in([u,v]\cap U)$. Hence $u\le a<v$ (as $v\notin U$) and $U$ contains some $\epsilon$ neighbourhood of $a$. But then $\min\{a+\frac12\epsilon, v\}\in U\cap[u,v]$, contradiction to $a$ being the supremum.

Let $S$ be a nonempty subset of $\mathbb{R}$ that is both open and closed. Let's say that $S$ contains the element $s$. We want to show that no element of $\mathbb{R} - S$ can be bigger than or less than $s$, immediately implying that it is empty.

Suppose that there are elements of $\mathbb{R} - S$ bigger than $s$. We can construct the set $X$ of all such elements, and consider its infimum. Use the fact that $S$ is open and closed to derive a contradiction. A similar argument works to show there are no elements of $\mathbb{R} - S$ smaller than $s$.

Note: This argument crucially uses the structure of $\mathbb{R}$ in asserting the existence of infimums and supremums.

I think I have a simpler proof using the border of $$A$$:

Let $$A \subseteq R$$ nonempty, open and closed, and assume $$A \neq \mathbb{R}$$.

Then $$\partial A = \overline A \cap \overline{(\mathbb{R} \setminus A)} =$$ ($$A=\overline A$$ since $$A$$ closed, same for $$\overline{\mathbb{R} \setminus A}$$) $$= A \cap (\mathbb{R} \setminus A) = \emptyset$$ (the border is empty)

However $$x = \sup A(=\overline A) \in \partial A$$, a contradiction. $$(\forall r>0) \langle x-r, x+r \rangle$$ contains points both in $$A$$ and in $$A \setminus \mathbb{R}$$.

• This is the proof I came up with too. Just phrased differently. We have a = sup(A) $\in$ A since A is closed. Then since A is open, B(A, $\epsilon$) $\subseteq$ A. So $a + \frac{\epsilon}{2} \in$ A, and a < a + $\frac{\epsilon}{2}$, contradicting that a = sup(a) Commented Oct 28, 2019 at 20:55
• * Oops B(a, $\epsilon$) $\subseteq$ A Should be the point a, not the set A Commented Oct 28, 2019 at 21:01
• How do you know that the supremum is not $+\infty$? Commented Oct 7, 2020 at 10:38
– BCLC
Commented Apr 17, 2021 at 10:46
– BCLC
Commented Apr 17, 2021 at 10:46

A space $X$ is connected if the only subsets of $X$ with empty boundary are $X$ and the empty set. Alternatively, $X$ is connected if the only subsets of $X$ which are both open and closed are $X$ and the empty set. Therefore, your first question asks if there exists any subset of $\mathbb R$ that is connected. Indeed, yes, there is. An interval is connected. Your second question seems to ask if $\mathbb R$ is connected. Yes, it is. For a proof, see here.

Here's yet another proof, which works by constructing a border point if $A$ is clopen nonempty proper subset of $\mathbb{R}$:

Be $A\subset\mathbb R$ both open and closed, but neither empty nor $\mathbb R$. Then there exist points $a\in A$ and $b\in\mathbb R\setminus A$.

Now construct two sequences $(a_n)$ and $(b_n)$ as follows:

$a_0=a$, $b_0=b$. For any $n$, be $c_n=(a_n+b_n)/2$. If $c_n\in A$, then $a_{n+1}=c_n$, $b_{n+1}=b_n$, else $a_{n+1}=a_n$, $b_{n+1}=c_n$.

Quite obviously for all $n$, $a_n\in A$ and $b_n\notin A$. Also $\lim_{n\to\infty}\left|a_n-b_n\right| = \lim_{n\to\infty}2^{-n}\left|a-b\right| = 0$. Therefore there exists exactly one point $x$ so that $\min(a_n,b_n)\le x\le\max(a_n,b_n)$ for all $n$ (nested intervals).

Since $\lim_{n\to\infty}a_n=x$ and $\lim_{n\to\infty} b_n=x$, we have in every open neighbourhood of $x$ both points in $A$ (namely $a_n$ for sufficiently large $n$) and in the complement of $A$ (namely $b_n$ for sufficiently large $n$). Thus $x$ is a border point of $A$, in contradiction that $A$ is both open and closed, and thus cannot have any border points.

I don't know why the other proofs seem overcomplicated to me... maybe mine's wrong. But here it is anyways.

Proof. Suppose $$F$$ is open and not equal to $$\mathbb{R}$$. Then there exists some number in $$\mathbb{R}$$ that's not in $$F$$. Since $$F$$ is closed we are guaranteed that $$F$$ has closest point ($$F$$ contains all its points and limit points) to that number at distance equal to $$c$$. But that's not true because $$F$$ is open (it can't have an exact distance to any non members). Contradiction. $$F$$ must be $$\mathbb{R}$$.

• If you define the distance of a set to some other element by the infimum distance, we do not arrive at a contradiction. This is the notion of distance we have been taught. Essentially I'm saying that the set $(a,b)$ and $[a,b]$ have the same distance to a point $c \not \in [a,b]$, namely we define distance by: $$\text{dist}(X,c)= \inf_{x \in X}(|x-c|)$$
– user459879
Commented Jul 20, 2019 at 15:13
• Basically this tells us that for the distance of a set to a point, it's not important if we draw its boundary or not.
– user459879
Commented Jul 20, 2019 at 15:15
– BCLC
Commented Apr 17, 2021 at 10:46

For an open set

$$\overline{A} \setminus A = \text{bd}(A)$$

For a closed set

$$\text{bd}(A) \subseteq A$$

Therefore, for a clopen set,

$$\overline{A} \cap A^C = \overline{A} \setminus A \subseteq A$$

The last statement is false if $A$ is a proper subset of $\mathbb R$.

In re my other answer, this is aligned with Trench, Lay and Royden and Fitzpatrick but doesn't use ideas of intervals except possibly something about $A' = \overline{A}$, so I changed my answer from $A'$ to $\overline{A}$ (see previous revision).

If $$A$$ is open, $$A$$ is ($$\emptyset$$ or) a disjoint union of a countable collection of open intervals. If $$A$$ is the latter, then $$A$$ is closed if and only $$A=\mathbb R$$ because otherwise, $$A$$ would have nonempty border, violating the rule that Set is Clopen iff Boundary is Empty.

Note: This is more in line with my thinking that $$A$$ has something to do with intervals, but unfortunately the first sentence of this post was not proven (or stated) in one of my elementary real analysis textbooks, namely the one by Trench. Luckily: 1 - it is an exercise in the other textbook, namely the one by Lay. 2 - it is a proposition in my advanced real analysis textbook by Royden and Fitzpatrick.

• This is absolutely not folklore, for (1) people are not merely "pretty sure that the result is true", and (2) you have given a direct link to its proof. If you must have more academic hard copy sources, that page itself cites two places to find it (one of them seems to be an exercise; exercises are not folklore either) Commented Apr 17, 2021 at 8:00
• @CalvinKhor ok thanks edited. it's a folklore sort of from my point of view in that when i 1st learned it about clopen non-empty implies R, there wasn't any such rule. at least i recall lay, trench and royden & fitzpatrick didn't have those.
– BCLC
Commented Apr 17, 2021 at 10:44