TL;DR
A set in a metric space is compact when every collection of open sets that covers has a finite part that still covers . The definition says nothing about size, but it forces a set to have no escape routes: it cannot be spread out endlessly or have a missing endpoint that a cover can slip past. Compactness is what guarantees that a continuous function on reaches a largest and a smallest value.
Builds on: Open Set, Bounded Set · Leads to: Universal Approximation Theorem, and the extreme value theorem for continuous functions
Where it's used
Choosing the best design. An engineer who tunes a process over a closed range of settings, say a mixing fraction between 0 and 1, wants a best setting to exist before searching for it. If the quality measure is continuous and the range is compact, the extreme value theorem guarantees a maximum and a minimum. The search can then be about finding them, not about whether they exist.
Neural networks. The universal approximation theorem for neural networks is usually stated for functions on a compact input set, such as a closed and bounded box of inputs. Compactness there gives the uniform control needed to approximate the function well everywhere on the box.
Checking compactness in . The Heine–Borel theorem says that in ordinary space , a set is compact exactly when it is closed and bounded. Most practical checks therefore reduce to two easy tests, instead of testing every possible cover.
How it works
Take the closed interval on the real line. A cover of is a family of sets whose union contains . Here is one cover by open intervals:
-
Check that it covers. Points from 0 up to 0.4 lie in , points from 0.3 to 0.7 lie in , and points from 0.6 to 1 lie in . Every point of is in at least one set. Check: 0.35 lies in and , so overlaps are allowed.
-
Start from one end. The point 0 lies in . The rightmost reach of is 0.4, which is not in itself, so the next set must cover 0.4. The point 0.4 lies in , since .
-
Keep going. reaches up to 0.7, which is not in . The point 0.7 lies in , since . Now reaches 1.1, which is past the end of .
-
Read off the finite subcover. The three sets , , together cover . Check: dropping would leave 0.5 uncovered, since stops at 0.4 and starts at 0.6. The subcover is finite, which is all the definition asks for.
flowchart LR
A["Any open cover of K"] --> B["Start at one end of K"]
B --> C["Pick a set that covers the current point"]
C --> D{"Does the chosen reach cover the end of K?"}
D -- no --> C
D -- yes --> E["A finite subcover: compact"]
This walkthrough checked one cover. Compactness needs every cover to pass, and the proof for does this for all covers at once.
The math
Let be a metric space and . A family of open sets is an open cover of when . The set is compact when every open cover of has a finite subfamily with .
Here means the set of all points that lie in at least one . A finite subfamily is a choice of finitely many of the sets, though the cover itself may be infinite.
Step 1 in symbols: the cover
For the example, and the cover is . Each is an open interval, hence an open set, and .
Step 2 in symbols: the finite subcover
The subfamily is finite and covers . Here no set can be removed, since removing leaves .
Step 3 in symbols: the Heine–Borel test
In , is compact exactly when is closed (it contains all its limit points) and bounded (it lies inside some ball of finite radius). The interval is closed and bounded, so it is compact.
Step 4 in symbols: the extreme value theorem
If is compact and is continuous, then attains a maximum and a minimum on . That is, there are points with for every . This is the reason compactness matters in optimisation.
Worked examples
Let in the real line, and take any open cover of .
- Some set in the cover contains 1. Pick one.
- Some set contains 2. Pick one.
- Some set contains 3. Pick one.
- The three chosen sets, , , , cover , and there are three of them.
Check: three is a finite number, so the cover has a finite subcover. Every finite set is compact by this argument.
Use the cover , , of from "How it works".
- Verify the cover: the three intervals together contain .
- Find the subcover by the walkthrough: start at 0, then 0.4, then 0.7. Three sets are used.
- Confirm it is finite: 3 sets, so it is finite.
- Confirm the Heine–Borel test agrees: is closed and bounded, so it is compact.
Check: the finite subcover exists, and the closed and bounded test gives the same answer.
A process has quality , where is the mixing fraction, and is only allowed to range over . Find the best setting.
- The set is closed and bounded, so it is compact.
- The function is a Polynomial, so it is continuous.
- Compactness and continuity guarantee a largest value of on . Find it.
- Differentiate: . On this is positive, so is still rising.
- Compare the endpoints: and .
- The largest value is 1, reached at . The best setting is therefore the full mixing fraction, , and no interior setting does better.
Try it: the function on has a maximum. Where is it, and what is its value?
Answer: is zero at , and . The endpoints give , so the maximum is , at .
Common mistakes and tradeoffs
It is tempting to think compact means small. In fact a compact set can be very large: is compact. Compactness is about covers, not size.
It is tempting to think bounded is enough. In fact the open interval is bounded but not compact. Take the open cover . Every finite part of it has the form for some , which misses the points between 0 and . So no finite subcover exists. The cover fails because the set has an endpoint, 0, that is not in it.
It is tempting to think one cover with a finite subcover proves compactness. In fact the definition asks for every open cover. The walkthrough above is an example, not a proof.
It is tempting to think closed and bounded is the definition. In fact that is only the Heine–Borel theorem in . In infinite-dimensional spaces a closed and bounded set need not be compact, so the general definition must be used there.
When to use it: when you need a maximum or minimum to exist, or a property to hold uniformly over a set. When not to use it: for small finite problems, where a direct check is simpler, and for spaces where the closed and bounded test fails and the cover definition is hard to verify. Alternative: in a metric space, compactness is equivalent to sequential compactness, where every sequence in has a subsequence converging inside . Proofs that work with sequences are often easier, and the Sequence lesson covers the tools.
History
Eduard Heine proved in 1872 that a continuous function on a closed interval is uniformly continuous. Émile Borel gave the covering statement for intervals in 1895, and the result is now named after Heine and Borel. Henri Lebesgue extended the covering idea in the early 1900s. In the 1920s Pavel Alexandroff and Paul Urysohn defined compact spaces in general topology, which made compactness a standard tool in analysis and geometry.
Recap
- A compact set is one where every open cover has a finite subcover, which is a property about covers, not size.
- Open intervals with endpoints missing, and unbounded sets, fail to be compact.
- In , compact means closed and bounded (Heine–Borel).
- A continuous function on a compact set attains a maximum and a minimum (extreme value theorem).
- Read next: Continuity for the functions this result applies to, and Universal Approximation Theorem for an application to neural networks.
Check yourself
QuestionIs the set compact? Explain in one sentence.Show answer
Yes. Any open cover has an open set containing each of its four points, so picking one set per point gives a finite subcover. A finite set is always compact.
QuestionCompute the largest value of on the closed interval , and say which theorem guarantees it exists.Show answer
The largest value is , since grows as grows and . The extreme value theorem guarantees it, because is closed and bounded, hence compact, and is continuous.
QuestionWhy does compactness fail for , even though the set is bounded?Show answer
Compactness needs every open cover to have a finite subcover. The cover has no finite subcover, because any finite part is for some . The point lies in but not in , so it is missed. The set has an endpoint, 0, that is not in it, so the cover can get arbitrarily close to 0 without ever containing it.
QuestionA researcher says the closed unit ball in must be compact because it is closed and bounded. Is the reasoning valid, and why?Show answer
Yes. In , the Heine–Borel theorem says a set is compact exactly when it is closed and bounded, so the closed unit ball in is compact. The same reasoning does not carry over to infinite-dimensional spaces, where closed and bounded sets need not be compact.