In mathematics, a **compact space** is a space that resembles a closed and bounded subset of Euclidean space **R**^{n} in that it is "small" in a certain sense and "contains all its limit points". The modern general definition calls a topological space *compact* if every open cover of it has a finite subcover. That is, any collection of open sets whose union is the whole space has a finite subcollection whose union is still the whole space. Some authors use the term 'quasicompact' instead and reserve the term 'compact' for compact Hausdorff spaces, but Wikipedia follows the usual current practice of allowing compact spaces to be non-Hausdorff.

- Suppose
*X*is a Hausdorff space, and we have a point*x*in*X*and a finite subset*A*of*X*not containing*x*. Then we can separate*x*and*A*by neighbourhoodss: for each*a*in*A*, let*U*(*a*) and*V*(*a*) be disjoint neighbourhoods containing*x*and*a*, respectively. Then the intersection of all the*U*(*a*) and the union of all the*V*(*a*) are the required neighbourhoods of*x*and*A*.

An equivalent definition of compact spaces, sometimes useful, is based on the finite intersection property. This definition says that X is compact if and only if for every collection of closed sets which has the finite intersection property, the intersection over this collection is also nonempty. In other words, if all finite subsets of a collection of closed sets have nonempty intersection, so must the entire collection. For example, (0,1] is not compact, since the sequence (0,1/n] of closed sets (in (0,1]) is nested, and so clearly has the finite intersection property, but has empty intersection. This definition is used in some proofs of Tychonoff's theorem and the uncountability of the real numbers.

For any subset of Euclidean space **R**^{n}, the following three conditions are equivalent:

- Every open cover has a finite subcover. This is the definition most commonly used, as stated above.
- Every sequence in the set has a convergent subsequence.
- Every infinite subset of the set has an accumulation point in the set.
- The set is closed and bounded. This is the condition that is easiest to verify, for example a closed interval or closed
*n*-ball.

- The closed unit interval [0,1] is compact. (But not the half-open interval [0,1)).
- For every natural number
*n*, the*n*-sphere is compact. - The Cantor set is compact. (Since the
*p*-adic integers are homeomorphic to the Cantor set, they also form a compact set.) - Any finite topological space is compact.
- Any space carrying the cofinite topology is compact. (In the cofinite topology, a set is open iff it is empty or its complement is finite.)
- Consider the set 2
^{N}of all infinite sequences with entries in {0,1}. This is a metric space if we define*d*((*x*),(_{n}*y*)) = 1/_{n}*k*, where*k*is the smallest index such that*x*≠_{k}*y*. (If there is no such index, then the two sequences are the same, and we define their distance to be zero). Then 2_{k}^{N}is a compact space; this is a consequence of Tychonoff's theorem mentioned below. This construction can be performed for any finite set, not just {0,1}. - The spectrum of any continuous linear operator on a Hilbert space is a compact subset of
**C**. - The spectrum of any commutative ring or Boolean algebra is compact.
- The Hilbert cube is compact.
- The right order topology or left order topology on any bounded totally ordered set is compact. In particular, Sierpinski space is compact.
- The Stone-Čech compactification of any Tychonoff space is a compact Hausdorff space.
- The Alexandroff one-point compactification of any space is compact.

Some theorems related to compactness (see the Topology Glossary for the definitions):

- A continuous image of a compact space is compact.
- A closed subset of a compact space is compact.
- A compact subset of a Hausdorff space is closed.
- A nonempty compact subset of the real numbers has a greatest element and a least element.
- A subset of Euclidean
*n*-space is compact if and only if it is closed and bounded. (Heine-Borel theorem) - A metric space (or uniform space) is compact if and only if it is complete and totally bounded.
- The product of any collection of compact spaces is compact. (Tychonoff's theorem -- this is equivalent to the axiom of choice)
- A compact Hausdorff space is normal.
- Every continuous bijective map from a compact space to a Hausdorff space is a homeomorphism.
- A metric space is compact if and only if every sequence in the space has a convergent subsequence.
- A topological space is compact if and only if every net on the space has a convergent subnet.
- A topological space is compact if and only if every filter on the space has a convergent refinement.
- A topological space is compact if and only if every ultrafilter on the space is convergent.
- A topological space can be embedded in a compact Hausdorff space if and only if it is a Tychonoff space.
- Every topological space
*X*is a dense subspace of a compact space which has at most one point more than*X*. (Alexandroff one-point compactification) - A metric space
*X*is compact if and only if every metric space homeomorphic to*X*is complete. - If the metric space
*X*is compact and an open cover of*X*is given, then there exists a number δ > 0 such that every subset of*X*of diameter < δ is contained in some member of the cover. (Lebesgue's number lemma) - If a topological space has a sub-base such that every cover of the space by members of the sub-base has a finite subcover, then the space is compact. (Alexander's Sub-base Theorem)
- Two compact Hausdorff spaces
*X*_{1}and*X*_{2}are homeomorphic if and only if their rings of continuous real-valued functions C(*X*_{1}) and C(*X*_{2}) are isomorphic.

There are a number of topological properties which are equivalent to compactness in metric spaces, but are inequivalent in general topological spaces. These include the following.

- Sequentially compact: Every sequence has a convergent subsequence.
- Countably compact: Every countable open cover has a finite subcover. (Or, equivalently, every infinite subset has an ω-accumulation point.)
- Pseudocompact: Every real-valued continuous function on the space is bounded.
- Weakly countably compact (or limit point compact): Every infinite subset has an accumulation point.

Compact spaces are countably compact. Sequentially compact spaces are countably compact. Countably compact spaces are pseudocompact and weakly countably compact.

Another related notion that is usually strictly weaker than compactness is local compactness.

It has been recognized for a long time that a property like compactness was needed to prove many useful results. At one time, when primarily metric spaces were studied, compact was taken to mean the weaker sequentially compact, that every sequence has a convergent subsequence. The definition based on open coverings has surpassed it by allowing many useful results that could be proven about metric spaces using the old definition to be proven in general.