Foundations
Compactness and Heine-Borel
Sequential compactness, the Heine-Borel theorem in finite dimensions, the extreme value theorem, and why compactness is the key assumption in optimization.
Prerequisites
Why This Matters
Optimization problems in ML ask: does a minimum exist? Compactness is the standard tool for guaranteeing existence of minimizers. The extreme value theorem says a continuous function on a compact set attains its minimum. Without compactness, minima may not exist (the infimum is not achieved), and many proof strategies in learning theory break down.
Core Definitions
Open Cover
An open cover of a set is a collection of open sets such that . A subcover is a subcollection that still covers .
Compactness
A subset of a metric space is compact if every open cover of has a finite subcover. Compactness is a topological property: it does not depend on the particular metric, only on the topology.
Sequential Compactness
A set is sequentially compact if every sequence in has a subsequence that converges to a point in . In metric spaces, compactness and sequential compactness are equivalent.
Bounded Set
A subset of a metric space is bounded if there exist and such that for all . In , this means is contained in some ball of finite radius.
Main Theorems
Heine-Borel Theorem
Statement
A subset is compact if and only if is closed and bounded.
Intuition
Bounded means sequences cannot escape to infinity. Closed means limits of convergent subsequences stay in the set. Together, they guarantee every sequence has a convergent subsequence with limit in .
Proof Sketch
Compact implies closed and bounded: If is not bounded, the sequence with has no convergent subsequence in . If is not closed, there is a limit point ; a sequence converging to has no subsequence converging in . Closed and bounded implies compact: By Bolzano-Weierstrass, every bounded sequence in has a convergent subsequence. Since is closed, the limit is in .
Why It Matters
Heine-Borel makes compactness easy to check in : just verify closed and bounded. This is the standard way to establish that a constrained optimization problem has a solution.
Failure Mode
Heine-Borel fails in infinite-dimensional spaces. The closed unit ball in is closed and bounded but not compact (the standard basis vectors have no convergent subsequence). In infinite dimensions, compactness is a much stronger condition than closed-and-bounded.
Extreme Value Theorem
Statement
A continuous function on a nonempty compact set attains its maximum and minimum. There exist with:
Intuition
Compactness prevents the minimizing sequence from escaping (either to infinity or to a boundary point outside ). Continuity preserves convergence, so the limit of a minimizing sequence is a minimizer.
Proof Sketch
Let . Take a sequence with . By compactness, a subsequence . By continuity, . So the infimum is attained at . Same argument for the supremum.
Why It Matters
This theorem is invoked implicitly whenever you write for a continuous loss over a compact parameter set . Without compactness, you can only write , and the minimizer may not exist.
Failure Mode
Fails without compactness: on has but no minimizer. Fails without continuity: on achieves its infimum at any , but pathological discontinuous functions on compact sets can fail to have maxima.
Why Compactness Matters in ML
- Existence of minimizers: Regularized loss with bounded parameter space (e.g., ) satisfies EVT assumptions.
- Uniform convergence: Covering number arguments require compact hypothesis classes.
- Continuity arguments: Compactness lets you upgrade pointwise statements to uniform ones (e.g., Dini's theorem).
- Function approximation: The Arzela-Ascoli theorem characterizes compact subsets of , used in universal approximation results.
Common Confusions
Closed and bounded is not enough in infinite dimensions
A common mistake is applying Heine-Borel in function spaces. The closed unit ball in any infinite-dimensional normed space is never compact. This is why weak compactness and related notions are needed in functional analysis and measure-theoretic probability.
Compact subsets of R^n are always complete
Every compact metric space is complete (Cauchy sequences have convergent subsequences, whose limits are in the compact set). But completeness alone does not give compactness: is complete but not compact.
Exercises
Problem
Is the set compact? What about ?
Problem
Give an example of a continuous function on a closed (but unbounded) subset of that does not attain its infimum. Explain which hypothesis of the extreme value theorem fails.
References
Canonical:
- Rudin, Principles of Mathematical Analysis (1976), Chapter 2 (sections on compactness)
- Munkres, Topology (2000), Chapter 3
- Apostol, Mathematical Analysis (1974), Chapter 3 (compact subsets of R^n)
For ML context:
- Shalev-Shwartz & Ben-David, Understanding Machine Learning (2014), Chapter 27 (covering numbers and compactness)
- Folland, Real Analysis (1999), Section 4.4 (compactness in metric spaces and function spaces)
- Aliprantis & Border, Infinite Dimensional Analysis (2006), Chapters 2-3 (compactness in topological vector spaces)
Last reviewed: April 2026
Prerequisites
Foundations this topic depends on.