Structure theorems for compact sets of rationals Everyone knows the Heine-Borel theorem characterizing compact subsets of Euclidean space. For any $n \in \mathbb N$ a set $A \subseteq \mathbb R^n$ is compact just in case it is closed and bounded (in the sense that it is contained in some large enough finite diameter ball).
There is a similar theorem for the irrationals, due to Rothberger. The irrationals are homeomorphic to the space $\mathbb N^\mathbb N$ of functions $f:\mathbb N \to \mathbb N$ topologized by the product topology of the discrete topology on $\mathbb N$. With this presentation a set $A \subseteq\mathbb N^\mathbb N$ is compact just in case it is closed and bounded where bounded means there is an $f:\mathbb N \to \mathbb N$ so that for all $g \in A$ we have $\forall n \, g(n) \leq f(n)$.
My question is whether there is a similar (or at least relatively neat) characterization of compact sets of rationals (with the subspace topology). Does some relatively simple (topological, geometric, combinatorial) property characterize when a closed $A \subseteq \mathbb Q$ is compact?
 A: The characterization of the compact subspaces of $\mathbb{R}^{n}$ as closed and bounded sets can be extended in a natural way to the much more general context of uniform spaces and subspaces of complete uniform spaces; a subset of a complete uniform space is compact if and only if it is closed and totally bounded, and $\mathbb{Q}$ can be made into a complete uniform space.
Observe that we cannot give $\mathbb{Q}$ a complete metric that is compatible with the topology on $\mathbb{Q}$ since the Baire category theorem applies to all complete metric spaces, but it does not apply to $\mathbb{Q}$, so we really need to go all the way to uniform spaces in order to say that $\mathbb{Q}$ is complete.
A separated uniform space is a pair $(X,\mathcal{U})$ where $X$ is a set and $\mathcal{U}$ is a filter on $X\times X$ that satisfies the following properties:

*

*$R\in\mathcal{U}\Rightarrow R^{-1}\in\mathcal{U}$


*$\bigcap\mathcal{U}=\{(x,x)\mid x\in X\}$


*$\forall R\in\mathcal{U}\exists S\in\mathcal{U}:S\circ S\subseteq R$
We shall assume all uniform spaces are separated. For example, every metric space $(X,d)$ is a uniform space where the uniformity $\mathcal{U}$ is the filter generated by the sets $R_{\delta}=\{(x,y)\in X^{2}\mid d(x,y)<\delta\}$ (in fact,every uniform space can be obtained in a similar manner if we use a collection of possibly uncountably many pseudometrics instead of metrics)
A uniform space $(X,\mathcal{U})$ is said to be totally bounded if for each $R\in\mathcal{U}$, there are $x_{1},\dots,x_{n}\in X$ with
$X=R[x_{1}]\cup\dots\cup R[x_{n}]$.
A uniform space $(X,\mathcal{U})$ is said to be complete if whenever
$e:(X,\mathcal{U})\rightarrow(Y,\mathcal{V})$ is an embedding of uniform spaces with $e[X]$ dense in $Y$, the mapping $e$ is already a uniform homeomorphism (alternatively, a uniform space is complete if and only if every Cauchy filter converges). A uniform space $(X,\mathcal{U})$ is said to be non-Archimedean if $\mathcal{U}$ is generated by equivalence relations.
Theorem: A uniform space $(X,\mathcal{U})$ is totally bounded if and only if its completion is compact.
Theorem: A uniform space $(X,\mathcal{U})$ is compact in the induced topology if and only if it is complete and totally bounded.
Corollary: A subset $A$ of a complete uniform space $(X,\mathcal{U})$ is compact if and only if it is closed and totally bounded.
A topological space is said to be realcompact if it can be embedded as a closed subspace of $\mathbb{R}^{I}$ for some $I$. A topological space is said to be $\mathbb{N}$-compact if it can be embedded as a closed subspace of $\mathbb{N}^{I}$ for some $I$. A Hausdorff space is said to be ultraparacompact if every open cover has a refinement that is a partition of the space into open sets. A Hausdorff space is said to be zero-dimensional if it has a basis of clopen sets.
Theorem: Suppose that $X$ is a completely regular space. Then each of the following statements implies the next one:

*

*$X$ is second countable.


*$X$ is Lindelof and has cardinality below the first uncountable measurable cardinal.


*$X$ is paracompact and has cardinality below the first uncountable measurable cardinal.


*$X$ is realcompact.


*$X$ can be endowed with a compatible complete uniformity.
Theorem: Suppose that $X$ is a zero-dimensional space. Then each of the following statements implies the next one.

*

*$X$ is second countable.


*$X$ is Lindelof.


*$X$ is ultraparacompact and has cardinality below the first uncountable measurable cardinal.


*$X$ is $\mathbb{N}$-compact.


*$X$ can be endowed with a compatible complete non-Archimedean uniformity.


*$X$ can be written as an inverse limit of discrete spaces $(X_{d})_{d\in D}$ where all the transitional mappings and the mapping from $X$ to $X_{d}$ are surjective.
Therefore, the space $\mathbb{Q}$ can be endowed with a complete uniformity $\mathcal{U}$, so a subspace $A\subseteq\mathbb{Q}$ is compact if and only if it is closed in $A$ and totally bounded with respect to this uniformity.
Suppose that $X$ is an inverse limit of an inverse system $(X_{d})_{d\in D}$ of discrete spaces. Then we have a characterization of the compact subspaces of
$(X_{d})_{d\in D}$ that looks exactly like the characterization of the compact subsets of the irrational numbers. Here, we set $D$ to be downwards directed. If $d\leq e$, then let $\phi_{d,e}:X_{d}\rightarrow X_{e}$ be the transitional mapping, and let $\phi_{d}:X\rightarrow X_{d}$ is the canonical projection mapping. Suppose that each $\phi_{d,e},\phi_{d}$ is surjective. Then a closed subspace $C$ of $X$ is compact if and only if $\phi_{d}[C]$ is finite for each $d\in D$.
Let $\mathcal{K}$ denote the collection of all compact subsets of $X$, and let $\mathcal{J}$ denote the collection of all systems $(C_{d})_{d\in D}$ where
$C_{d}$ is a finite subset of $X_{d}$ for $d\in D$ and where $\phi_{d,e}[C_{d}]=C_{e}$ whenever $d\leq e$. Observe that if $C_{d}$ is a finite subset of $X_{d}$ for each $d\in D$, then $\bigcap_{d\in D}\phi^{-1}[C_{d}]$ is closed and totally bounded, so $\bigcap_{d\in D}\phi^{-1}[C_{d}]$ is compact. Define a mapping $L:\mathcal{K}\rightarrow\mathcal{J}$ by letting $L(C)=(\phi_{d}[C])_{d\in D}$ and define a mapping $M:\mathcal{J}\rightarrow\mathcal{K}$ by letting
$M((C_{d})_{d\in D})=\bigcap_{d\in D}\phi^{-1}_{d}[C_{d}]$. Observe that if $d\leq e$, then $\phi^{-1}_{d}[C_{d}]\subseteq\phi^{-1}_{e}[C_{e}]$, so the intersection
$\bigcap_{d\in D}\phi^{-1}_{d}[C_{d}]$ is downwards directed.
Theorem: The mappings $L,M$ are inverses.
Proof: Suppose that $C$ is a compact subspace of $X$. Then $L(C)=(\phi_{d}[C])_{d\in D}$, so
$M(L(C))=\bigcap_{c\in C}\phi_{d}^{-1}[\phi_{d}[C]]$. Since $C\subseteq\phi_{d}^{-1}[\phi_{d}[C]]$. On the other hand, if $x\in X\setminus C$, then since $C$ is closed, there is some $d\in D$ where $\phi_{d}(x)\not\in\phi_{d}[C]$. In this case,
$x\not\in\phi_{d}^{-1}[\phi_{d}[C]]$. Therefore, $M(L(C))=C$.
Now, suppose that $(C_{d})_{d\in D}\in\mathcal{J}$. Then
$M((C_{d})_{d\in D})=\bigcap_{d\in D}\phi_{d}^{-1}[C_{d}]$. Therefore, if
$L(M((C_{d})_{d\in D}))=(A_{d})_{d\in D}$, then
$$A_{d_{0}}=\phi_{d_{0}}[\bigcap_{d\in D}\phi_{d}^{-1}[C_{d}]]\subseteq\phi_{d_{0}}[\phi_{d_{0}}^{-1}[C_{d_{0}}]]\subseteq C_{d_{0}}.$$
On the other hand, if $c\in C_{d_{0}},$ then there is some $(c_{d})_{d\in D}\in\varprojlim_{d\in D}C_{d}$ with $c_{d_{0}}=c$ (this can be proven using Tychonoff's theorem and the fact that each $C_{d}$ is finite). In this case,
$(c_{d})_{d\in D}\in\bigcap_{d\in D}\phi_{d}^{-1}[C_{d}]$. Therefore, since
$c=\phi_{d_{0}}((c_{d})_{d\in D})$, we have $c\in\phi_{d_{0}}[\bigcap_{d\in D}\phi_{d}^{-1}[C_{d}]]$ as well. Therefore, $C_{d_{0}}\subseteq A_{c_{0}}$ as well, so $L(M((C_{d})_{d\in D}))=(A_{d})_{d\in D}=(C_{d})_{d\in D}.$ Q.E.D.
A: If we consider the ordering on $\mathbb{Q}$, then we obtain characterizations of the compact subsets of $\mathbb{Q}$ which give more information about these compact subsets than the homeomorphism type in Ville Salo's answer.
A linearly ordered set $X$ is said to be scattered if $X$ does not contain any order isomorphic copy of the rational numbers.
Let $\mathcal{A}_{\alpha}$ be the class of all totally ordered sets of the form
$\bigcup_{a\in A}X_{a}$ where

*

*$A$ is either well-ordered or dual-well ordered,


*if $a<b$ and $x\in X_{a},y\in X_{b}$, then $x<y$, and


*either $X_{a}\in\bigcup_{\beta<\alpha}\mathcal{A}_{\beta}$ or $\lvert X_{a}\rvert\leq 1$.
Let $\mathcal{A}_{\infty}=\bigcup_{\alpha}\mathcal{A}_{\alpha}$.
Theorem: A linearly ordered set $X$ is scattered if and only if $X\in\mathcal{A}_{\alpha}$ for some ordinal $\alpha$.
Proof outline: The direction $\leftarrow$ is proven using a standard transfinite induction. For $\rightarrow$, suppose that $X\notin\mathcal{A}_{\alpha}$ for all ordinals $\alpha$. Then one can show that there is some $x\in X$ where
$\{y\in X\mid y<x\}\notin\mathcal{A}_{\infty}$ and
$\{y\in X\mid y>x\}\notin\mathcal{A}_{\infty}$. Therefore, by recursion, one can construct a set $X_{\gamma}$ along with an element $x_{\gamma}$ for each binary string $\gamma$ where we set $X_{\epsilon}=X$ and where for each binary string $X_{\gamma}$, there is an element $x_{\gamma}$ where if $X_{\gamma 0}=\{y\in X_{\gamma}\mid y<x\}$ and
$X_{\gamma 1}=\{y\in X_{\gamma}\mid y>x\}$, then $X_{\gamma 0}\notin\mathcal{A}_{\infty}$ and $X_{\gamma 1}\notin\mathcal{A}_{\infty}$. In this case,
the set $\{x_{\gamma}\mid \gamma\}$ is order isomorphic to $\mathbb{Q}$.
Q.E.D.
Proposition: A linearly ordered set $X$ is compact in the order topology if and only if $X$ is complete as a lattice.
Suppose that $A$ is a subset of a linearly ordered set $X$. Then an element $a\in A$ is said to be a gap point if there exists some $x\in X$ where either

*

*$a<x<\{b\in A\mid b>a\}$ but where the set $\{b\in A\mid b>a\}$ has no minimal element or


*$\{b\in A\mid b<a\}<x<a$ but where the set $\{b\in A\mid b<a\}$ has no maximal element.
Proposition: Suppose that $A$ is a subset of a linearly ordered set $X$. Then every set that is open in the order topology on $A$ is also open in the subspace topology.
Proposition: Suppose that $A$ is a subset of a linearly ordered set $X$. Then the following are equivalent:

*

*the order topology on $A$ coincides with the subspace topology.


*$A$ has no gap points.


*if $R\subseteq A$ and $\bigvee^{A}R$ exists, then $\bigvee^{X}R$ exists and $\bigvee^{A}R=\bigvee^{X}R$, and if $R\subseteq A$ and $\bigwedge^{A}R$ exists, then $\bigwedge^{X}R$ exists and $\bigwedge^{A}R=\bigwedge^{X}R$.
Proposition: Suppose that $X$ is a set and $\mathcal{S}$, $\mathcal{T}$ are compact Hausdorff topologies on $X$ with $\mathcal{S}\subseteq\mathcal{T}$. Then $\mathcal{S}=\mathcal{T}$.
Proposition: Suppose that $A$ is a subset of a linearly ordered set $X$. Then the following are equivalent:

*

*$A$ is a complete sublattice of $X$ in the sense that if $R\subseteq A$, then
$\bigvee^{X}R,\bigwedge^{X}R$ exist and $\bigvee^{X}R,\bigwedge^{X}R\in A$.


*$A$ is compact in the subspace topology.


*$A$ is compact in the order topology, and the subspace topology on $A$ is the same as the order topology on $A$.
Let $X$ be a linearly ordered set. For each ordinal $\alpha$, let $\mathcal{C}_{\alpha,X}$ be the collection of all subsets $A\subseteq X$ where either

*

*there exists an ordinal $\delta$ and a continuous increasing function $f:\delta+1\rightarrow X$ where $f[\delta+1]\subseteq A$ and if $\gamma<\delta$, then
$A\cap[f(\gamma),f(\gamma+1)]\in\bigcap_{\beta<\alpha}\mathcal{C}_{\alpha,X}$ or
$\lvert A\cap[f(\gamma),f(\gamma+1)]\rvert=1$ and where $A\subseteq[f(0),f(\delta)]$, or


*there exists an ordinal $\delta$ and a continuous decreasing function $f:\delta+1\rightarrow X$ where $f[\delta+1]\subseteq A$, and if $\gamma<\delta$, then $A\cap[f(\gamma+1),f(\gamma)]\in\bigcap_{\beta<\alpha}\mathcal{C}_{\alpha,X}$ or
$\lvert A\cap[f(\gamma+1),f(\gamma)]\rvert=1$ and where $A\subseteq[f(\delta),f(0)]$.
Let $\mathcal{C}_{\infty,X}=\bigcup_{\alpha}\mathcal{C}_{\alpha,X}.$
Proposition: A subset $A$ of a linearly ordered set $X$ is compact in the subspace topology and scattered if and only if $A\in\mathcal{C}_{\alpha,X}$ for some ordinal $\alpha$.
Proof:
$\leftarrow$ Observe that if $A\in\mathcal{C}_{\alpha,X}$ for some $A$, then $A\in\mathcal{A}_{\alpha}$, so $A$ is scattered. Furthermore, by transfinite induction, each $A\in\mathcal{C}_{\alpha,X}$ is a complete sublattice of $X$, so $A\in\mathcal{C}_{\alpha,X}$ is compact in the subspace topology.
$\rightarrow$ Suppose that $A\notin \mathcal{C}_{\infty,X}$. Then I claim that either $A$ is not compact in the subspace topology or $A$ has an isomorphic copy of the linear order $\mathbb{Q}$. Suppose that $A$ is compact in the subspace topology.
Then let $P=\{a\in A\mid\{b\in A\mid b\leq a\}\in\mathcal{C}_{\infty,X}\}$. Then $P$ has a largest element which we shall call $p$.
Let $Q=\{a\in A\mid\{b\in A\mid b\geq a\}\in\mathcal{C}_{\infty,X}\}$. Then $Q$ has a least element which we shall call $q$. If $q\leq p$, then we can conclude that $A\in\mathcal{C}_{\infty,X}$ which is a contradiction. We therefore know that $p<q$ and that $[p,q]\cap A\notin\bigcup_{\alpha}\mathcal{C}_{\alpha,X}$. In particular, if $x\in (p,q)\cap A$, then $(-\infty,x]\cap A\notin \mathcal{C}_{\infty,X}$ and $[x,\infty)\cap A\notin \mathcal{C}_{\infty,X}$.
Let $A_{\epsilon}=A$. We construct a system of elements $(x_{\gamma})_{\gamma\in\{0,1\}^{*}}$ in $A$ along with a system of subsets $(A_{\gamma})_{\gamma\in\{0,1\}^{*}}$ of $A$ recursively. For each binary string $\gamma$, let $x_{\gamma}\in A_{\gamma}$ be an element such that $[x_{\gamma},\infty)\cap A_{\gamma}\notin\mathcal{C}_{\infty,X}$ and $(-\infty,x_{\gamma}]\notin\mathcal{C}_{\infty,X}$. Then let
$A_{\gamma 0}=(-\infty,x_{\gamma}]$ and let $A_{\gamma 1}=[x_{\gamma},\infty)$. Then $(x_{\gamma})_{\gamma\in\{0,1\}^{*}}$ is a subset of $A$ order isomorphic to
$\mathbb{Q}$. Therefore, $A$ is not scattered.
Q.E.D.
Corollary: Let $X$ be a totally ordered set of cardinality less than the continuum. Then a subset $A\subseteq X$ is compact in the subspace topology if and only if $A\in\mathcal{C}_{\infty,X}$.
The upper limit topology
There is a simpler characterization of the compact subsets of $\mathbb{Q}$ where the subsets are given the subspace topology and $\mathbb{Q}$ is given the upper limit topology. Observe that since the upper limit topology on $\mathbb{Q}$ is homeomorphic to the order topology, the case when $\mathbb{Q}$ has the upper limit topology is not any different than the case with the order topology.
Recall that the upper limit topology on a totally ordered set $X$ is the topology where if $x$ is the least element of $X$, then $x$ is isolated, and where the local basis around $x$ consists of the intervals of the form $(v,x]$ where $v<x$.
Theorem: Every countable first countable regular space without any isolated points is homeomorphic to $\mathbb{Q}$ with the order topology.
Corollary: The set $\mathbb{Q}$ with the upper limit topology is homeomorphic to $\mathbb{Q}$ with the order topology.
Proposition: Let $X$ be a totally ordered set. Then $X$ is compact in the upper limit topology if and only if $X$ is well-ordered and has a greatest element.
Proposition: Let $X$ be a totally ordered set with the upper limit topology. Let $A$ be a subset of $X$, and give $A$ the subspace topology. Then $A$ is compact if and only if there is some ordinal $\alpha$, and a continuous function $f:\alpha+1\rightarrow X$ where if $\beta<\gamma\leq\alpha$, then $f(\beta)<f(\gamma)$.
A: It is easy to describe these up to homeomorphism:

*

*Every countable compact Hausdorff space is homeomorphic to a countable successor ordinal, see Milliet - A remark on Cantor derivative.


*Conversely, it's easy to embed all countable limit ordinals in the rationals by transfinite induction, and successor ordinals will give you compact sets.
