How can a set be closed and bounded but not compact? In Rudin's Principles of Mathematical Analysis(3E), Chapter 2, Exercise 16 says let E be the set $ E = \{ p \in\Bbb Q \mid 2 < p^2 <3\} $, where $\Bbb Q$ is the set of all rationals as a metric space with $d(p,q) = |p -q|$.
You are asked to show that $E$ is closed and bounded in $\Bbb Q$ but that $E$ is not compact? But is not the definition of compact that the set is closed and bounded? 
You are also asked to show the set is open in $\Bbb Q$, when you have just showed it is closed in $\Bbb Q$?
I am not asking how to do this problem, I am just asking how this problem is even a question when it seems it is contradicting itself. Is there a loophole I am not seeing?
 A: There are two major misconceptions in your question:


*

*You are assuming that a closed and bounded set is compact by definition.  In fact, this is not the definition of a compact set.  In the most general setting, a compact set is one such that every open cover has a finite subcover (this is a moderately technical topological definition, which depends on what you mean by an "open set," a "cover," and a "subcover").  If you don't want to get into the nitty-gritty of topology, you can define compact sets in metric spaces in terms of sequential compactness.  A set is sequentially compact if every sequence in that space has a convergent subsequence.  In metric spaces, it turns out that compactness and sequential compactness are equivalent.
On the other hand, what you assert as the definition of a compact set is, in fact, a theorem which can be proved under certain hypotheses.  For example, in real analysis you have the Heine-Borel Theorem, which states that in $\mathbb{R}^n$, a set is compact if and only if it is closed and bounded.  If you are taking a course in real analysis, you might see this given as the definition of compactness in order to avoid topological or sequential technicalities, however it is important to note that this is not a definition which works in all metric spaces.  Indeed, Rudin almost certainly gives this exercise in order to demostrate the importance of the completeness of $\mathbb{R}$ for analysis.
More generally, the Heine-Borel Theorem gives us a way of describing some of the things that can go wrong.  A metric space is said to have the Heine-Borel Property if every closed, bounded set is compact.  Incomplete metric spaces fail to have the Heine-Borel property–essentially, if you can find a Cauchy sequence which fails to converge, then you can cover that sequence with balls in such a way that no finite subcover exists.  There are also more interesting examples–for example, the Hilbert space of square integrable functions over $\mathbb{R}$ fails to have the Heine-Borel Property, despite being a complete metric space.

*Open and closed are not opposites.  I don't remember how deep Rudin goes into the topology of $\mathbb{R}$, but a standard approach in real analysis classes is, essentially, as follows:


*

*A set $U$ in a metric space $(X,d)$ is said to be open if for every $x \in U$ there exists some $r > 0$ such that $B(x,r) \subseteq U$, where
$$ B(x,r) = \{ y \in X : d(x,y) < r \} $$
denotes the open ball of radius $r$ centered at $x$.  That is, by choosing a radius small enough, we can find a ball entirely contained in $U$ which contains $x$.

*A set $K \subseteq (X,d)$ is closed if its complement $K^\complement = X \setminus K$ is open.
It may look like these are complete opposites, but they aren't quite.  For example, the sets $\emptyset$ and $\mathbb{R}$ are both open and closed subsets of $\mathbb{R}$ (Exercise:  convince yourself that this is true).  Such sets are sometimes called "clopen" sets.
More generally, in a discrete metric space, all sets are clopen.  To see this, recall that the discrete metric is given by
$$ d(x,y) = \begin{cases} 0 & \text{if $x=y$, and} \\ 1 & \text{otherwise.} \end{cases} $$
But then $B(x,1/2) = \{ x \}$, which implies that if $x \in A$ for any set $A$, then $B(x,1/2) \subseteq A$.  Thus every set $A$ is open.  But if every set is open, then $A^\complement$ is also open, which means that $(A^\complement)^\complement = A$ is closed.  Therefore $A$ is clopen.
In short, contrary to your intuition, "closed" does not imply "not open".  That is, a subset of $\mathbb{Q}$ can be open, even if it is closed.  There is a video out there called "Hitler Learns Topology" which may be moderately enlightening and, hopefully, more than moderately entertaining.
