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: 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.
A: 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.
A: 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}$.
A: 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.
A: 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}$.
A: 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.
A: 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.
A: 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}$.
A: 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.
A: 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).
