Nearness without numbers
In real analysis you proved two theorems that calculus cannot live without. The intermediate value theorem: a continuous function on takes every value between and . The extreme value theorem: a continuous function on attains a maximum. Both proofs leaned on the completeness of . But look at what they actually used about . The first used that the interval is "in one piece"; the second that it is "finite in disguise": any way of covering it by small open pieces can be cut down to finitely many. Neither proof cared about the formula for distance.
Distances come in many flavours. A delivery cyclist in the grid of Barcelona's Eixample or the old chessboard streets of Kyoto measures the taxicab distance , not the straight-line one. A geneticist comparing two DNA strings of the same length counts the positions where they differ (the Hamming distance), and so does an engineer designing the error-correcting code in a QR code. A pilot flying from Nairobi to Lima follows a great circle on the sphere. An analyst asks how far apart two functions on are and answers . Each of these is a metric, and in each the same questions arise: which sequences converge, which maps are continuous, which sets are "in one piece"?
Point-set topology answers them once and for all, in two steps. First, it abstracts distance into a metric space (Fréchet, 1906). Second, it notices that most of the answers depend only on which sets are open, and abstracts again into a topological space (Hausdorff, 1914). The reward is a toolkit — compactness, connectedness, continuity, products and quotients — that the rest of geometry, topology and analysis is built on. It also answers questions like these: is a circle the same shape as an interval? Is a line the same as a plane? Your intuition says no. By the end of this lesson you will be able to prove it.
Wiggle room
Think of a set in the plane as open if every point of has some wiggle room: a small disc around it that stays inside . The open disc is open — a point near the edge has only a little room, but some. The closed disc is not: a point on the boundary circle has no room at all.
Now change how distance is measured. With the taxicab metric the "disc" of radius is a diamond; with the maximum metric it is a square. But every disc contains a smaller diamond and a smaller square around the same centre, and vice versa:
So "open" does not depend on which of these three metrics we use, even though the distances themselves differ. Topology is what survives when you forget the exact distances and keep only the open sets.
Three ideas carry the whole subject.
- Continuity becomes: the preimage of an open set is open. A continuous map may squash and stretch, but it cannot tear: if has wiggle room inside , then has wiggle room inside .
- Connectedness means: the space cannot be split into two disjoint non-empty open pieces.
- Compactness means: every cover of the space by open sets has a finite subcover. It is what turns local information (near each point, is bounded) into global information ( is bounded).
Metric spaces and topological spaces
Definition— metric space
A metric on a set is a function such that for all :
- if and only if ;
- (symmetry);
- (the triangle inequality).
The open ball of radius about is . A set is open if for every there is with .
Definition— topological space
A topology on a set is a collection of subsets of , called the open sets, such that
- and ;
- any union of members of (finite or infinite) is in ;
- the intersection of any two (hence any finitely many) members of is in .
A set is closed if its complement is open. An open neighbourhood of is an open set containing .
Closed sets therefore satisfy the "dual" axioms: and are closed, arbitrary intersections and finite unions of closed sets are closed. The finiteness in axiom 3 matters: in the open intervals intersect in , which is not open.
Definition— interior, closure, boundary
The interior of is the union of all open sets contained in ; the closure is the intersection of all closed sets containing ; the boundary is . A point lies in exactly when every open neighbourhood of meets . In a metric space this happens exactly when is the limit of a sequence of points of .
Definition— continuous map, homeomorphism
A map between topological spaces is continuous if is open in for every open . A homeomorphism is a continuous bijection whose inverse is also continuous; and are homeomorphic, , if there is one. A property preserved by homeomorphisms is a topological property.
Definition— subspace, product and quotient topologies
Let and be topological spaces.
- Subspace. For , the open sets of are the sets with open in .
- Product. The open sets of are the unions of boxes with open in and open in . For a product of any family, the open sets are unions of finite intersections of sets , open in : it is the coarsest topology making every projection continuous.
- Quotient. If is an equivalence relation on and sends to its class, a set is open when is open in : it is the finest topology making continuous.
Definition— compact, connected, path-connected
A space is compact if every open cover of (a family of open sets whose union is ) has a finite subcover. A subset is compact if it is compact in the subspace topology; equivalently, every cover of it by open sets of has a finite subcover.
is connected if it is not the union of two disjoint non-empty open sets; equivalently, its only clopen (closed and open) subsets are and . It is path-connected if any two points are joined by a continuous path with and .
Definition— separation axioms
is T₀ if for any two distinct points some open set contains one but not the other; T₁ if every one-point set is closed; and Hausdorff (or T₂) if any two distinct points have disjoint open neighbourhoods. Every metric space is Hausdorff: if , the balls and are disjoint by the triangle inequality.
Examples, non-examples and boundary cases
Example— Three metrics, one topology
On let be the Euclidean metric, and . For all ,
So a -ball of radius lies inside the -ball of radius , which lies inside the -ball of radius , which lies inside the -ball of radius . Hence the three metrics have the same open sets: the Euclidean topology. It is also the product topology on , because the -balls are exactly the open cubes, which are boxes.
Example— The discrete metric and the Hamming metric
On any set, for (and for ) is the discrete metric. Every ball is open, so every subset is open — and closed. On binary strings of length , the Hamming distance counts differing positions; the ball of radius about is . As a topology on a finite set it is again discrete, but the metric carries real information: a code whose codewords are at distance at least from each other can correct any single error.
Example— Topologies that come from no metric
- The indiscrete topology on a set with at least two points is not Hausdorff, so no metric produces it.
- The Sierpiński space with open sets : here is open but not closed and is closed but not open. It is T₀ but not T₁.
- The cofinite topology on an infinite set (open sets: and complements of finite sets) is T₁, not Hausdorff (any two non-empty open sets meet), and compact.
Example— Open, closed, both, neither
In : is open, and are closed, and are both, and and are neither. In the subspace of , the set is open and closed (its complement in is ), so is not connected. More surprisingly, in the set is clopen, because no rational squares to — so falls apart into pieces at every irrational number. This is proved in Lean below.
Example— Gluing: quotient spaces
Glue the ends of together: the quotient is homeomorphic to the circle , via . The same circle is , where when .
From the square we can make several famous spaces:
- glue : a cylinder ;
- glue : a Möbius band (one twist);
- glue and : the torus, homeomorphic to the product ;
- glue and : the Klein bottle.
Continuity: from ε–δ to open sets
Theorem— Proposition 1 (metric spaces are topological spaces)
In a metric space, every open ball is open, and the open sets form a topology.
Proof
Let and put . If then , so . Hence balls are open.
Clearly and are open. If lies in a union of open sets, it lies in one of them, , and a ball around inside lies inside the union. If with and , then .
∎
Theorem— Theorem 2 (ε–δ continuity is open-set continuity)
Let be a map between metric spaces. Then is continuous in the ε–δ sense — for every and there is with whenever — if and only if is open for every open .
Proof
() Let be open and . As is open there is with . Take the corresponding : if then . So , and is open.
() Let and . The ball is open (Proposition 1), so is an open set containing . It therefore contains some ball , which says precisely that implies .
∎
Two consequences show why the open-set definition is so convenient.
Theorem— Corollary 3
(a) The composite of continuous maps is continuous. (b) A map is continuous if and only if the preimage of every closed set is closed.
Proof
(a) If and are continuous and is open, then is open. (b) Preimages commute with complements: .
∎
Notice the direction: continuity pulls open sets back. It does not push them forward. The continuous map sends the open interval to , which is not open.
Connectedness
Theorem— Theorem 4 (the interval is connected)
The interval is connected.
Proof
Suppose with disjoint, non-empty and open in ; say . Let . It contains and is bounded by , so by completeness it has a supremum .
If : then , since . As is open in there is with . Since there is with . Then (as ) and , contradicting .
If : as is open in there is with . Pick with ; then and for , so . If then , contradicting . So and , which means and — a contradiction.
∎
Theorem— Theorem 5 (continuous images of connected spaces are connected)
If is connected and is continuous, then is connected.
Proof
Suppose with disjoint, non-empty and open in . Then and are open in (continuity, together with the definition of the subspace topology), disjoint, non-empty and cover — impossible, since is connected.
∎
Theorem— Corollary 6 (intermediate value theorem)
If is continuous and lies between and , then for some .
Proof
is homeomorphic to , so connected by Theorem 4, and is connected by Theorem 5. A connected subset is an interval: if , and , then and would split into two disjoint non-empty open pieces. So .
∎
A path-connected space is connected: if were a splitting and a path from a point of to a point of , then would split the connected interval . The converse fails: the topologist's sine curve, the closure of in , is connected but not path-connected.
Theorem— Corollary 7 (counting pieces tells spaces apart)
(a) is not homeomorphic to . (b) is not homeomorphic to the circle .
Proof
A homeomorphism restricts to a homeomorphism for every point .
(a) is not connected (it is split by and ), but minus any point is path-connected — go around the missing point — hence connected.
(b) is not connected, but minus any point is homeomorphic to an open interval, hence connected.
∎
Compactness and the Heine–Borel theorem
Theorem— Theorem 8 (continuous images of compact spaces are compact)
If is compact and is continuous, then is compact.
Proof
Let be a cover of by open sets of . The sets are open and cover , so finitely many of them, , already cover . Then cover .
∎
Before the extreme value theorem we need to know what compact sets look like.
Theorem— Lemma 9 (three facts about compact sets)
(a) A closed subset of a compact space is compact. (b) A compact subset of a Hausdorff space is closed. (c) A compact subset of a metric space is bounded.
Proof
(a) Let be closed and an open cover of . Then is an open cover of ; a finite subcover, with removed, covers .
(b) Let be compact in a Hausdorff space and . For each choose disjoint open sets and . Finitely many cover ; then is an open neighbourhood of missing . So is open.
(c) Fix . The balls , , cover the space, so finitely many cover , and for the largest used.
∎
Theorem— Corollary 10 (extreme value theorem)
A continuous function on a non-empty compact space attains a maximum and a minimum.
Proof
is compact (Theorem 8), hence bounded and closed in (Lemma 9). A non-empty bounded set has a supremum , which lies in the closure of the set, hence in itself. So for some . Apply this to for the minimum.
∎
Theorem— Theorem 11 (closed bounded intervals are compact)
Every interval is compact.
Proof
Suppose an open cover of has no finite subcover. Cut in half. If both halves had finite subcovers, so would ; so one half — call it — has none. Repeating, we get nested closed intervals , each with no finite subcover, with of length . By completeness (the nested interval property) they share a point . Now for some , and since is open, for some . Choose with : then , so the single set covers — a contradiction.
∎
The experiment in the computation section runs this proof as an algorithm.
Theorem— Lemma 12 (the tube lemma; products of two compact spaces)
If and are compact, so is .
Proof
Let be an open cover of . Each is a union of boxes, and if finitely many boxes cover , the finitely many sets of containing them do too. So we may assume consists of boxes .
Fix . For each choose a box containing . The open sets cover the compact space , so finitely many of them, , already do. Then is an open neighbourhood of , and the whole tube is covered by the boxes . The sets cover the compact space , so finitely many do; the corresponding finitely many boxes cover .
∎
Theorem— Theorem 13 (Heine–Borel)
A subset of is compact if and only if it is closed and bounded.
Proof
() is a metric space, hence Hausdorff; apply Lemma 9 (b) and (c).
() If is bounded, then for some . The cube is compact: is compact by Theorem 11, and products of finitely many compact spaces are compact by Lemma 12 and induction. (We use that the Euclidean topology of is the product topology — the first example above.) is closed in , hence closed in the cube, hence compact by Lemma 9 (a).
∎
Theorem— Theorem 14 (when a continuous bijection is a homeomorphism)
A continuous bijection from a compact space to a Hausdorff space is a homeomorphism.
Proof
We show that is continuous, i.e. that maps closed sets to closed sets (the preimage of under is ). If is closed, it is compact (Lemma 9a), so is compact (Theorem 8), so is closed in the Hausdorff space (Lemma 9b).
∎
Both hypotheses matter. The map from to is a continuous bijection, but its inverse jumps from near to at the point : points of just below go to numbers near . Here the domain is not compact. In fact no homeomorphism exists at all, since is compact (Heine–Borel) and is not (it is not closed in ).
Note
Heine–Borel is a theorem about , not about metric spaces. In the metric space , the set is closed and bounded but not compact: the open sets cover it (as ), with no finite subcover. In an infinite set with the discrete metric, the whole space is closed and bounded (diameter ) but the cover by one-point sets has no finite subcover. In a general metric space, compact is equivalent to complete and totally bounded, and also to sequentially compact (every sequence has a convergent subsequence); see Sutherland (2009) or Munkres (2000).
Theorem— Theorem 15 (Tychonoff; stated, not proved here)
Every product of compact spaces, with the product topology, is compact.
For finitely many factors this is Lemma 12. For infinitely many, the proof needs the axiom of choice (through Zorn's lemma or ultrafilters); see Munkres (2000), chapter 5. And it must: John Kelley showed in 1950 that Tychonoff's theorem, over the other axioms of ZF, implies the axiom of choice. The product topology is essential: with the "box topology", where all products of open sets are open, even fails to be compact.
Point-set topology in Lean and Mathlib
Mathlib builds topology exactly as this lesson does: a TopologicalSpace X is a family of sets called open, closed under unions and finite intersections, and a MetricSpace automatically carries the topology of its balls. Two design choices are worth knowing. Mathlib's IsCompact is defined with filters (every filter that lives on the set has a cluster point in it), but it proves the equivalence with the open-cover definition, which our proofs use. And IsPreconnected is "connected, but possibly empty"; IsConnected adds non-emptiness.
First, metric spaces. The proof that balls are open is the triangle-inequality argument of Proposition 1, as a calc chain:
/-- **Open balls are open.** If `y` lies in the ball `B(x, r)`, then the smaller ball of radius
`r - d(y, x)` around `y` stays inside `B(x, r)`: for `z` in it, the triangle inequality gives
`d(z, x) ≤ d(z, y) + d(y, x) < (r - d(y, x)) + d(y, x) = r`. -/
theorem ball_isOpen {X : Type*} [MetricSpace X] (x : X) (r : ℝ) :
IsOpen (Metric.ball x r) := by
rw [Metric.isOpen_iff]
intro y hy
have hy' : dist y x < r := hy
refine ⟨r - dist y x, sub_pos.mpr hy', fun z hz => ?_⟩
have hz' : dist z y < r - dist y x := hz
show dist z x < r
calc dist z x ≤ dist z y + dist y x := dist_triangle z y x
_ < (r - dist y x) + dist y x := by linarith
_ = r := by ringTheorem 2, proved from the definitions, alongside Mathlib's own version, which is a one-line citation:
/-- **ε–δ continuity is open-set continuity.** For a map between metric spaces, the ε–δ condition
at every point holds exactly when the preimage of every open set is open.
(⇒) If `U` is open and `f x ∈ U`, some ball `B(f x, ε)` lies in `U`; the δ for this ε gives a
ball `B(x, δ)` inside `f⁻¹(U)`. (⇐) The ball `B(f x, ε)` is open (`ball_isOpen`), so its preimage
is an open set containing `x`, hence contains some ball `B(x, δ)` — which is the ε–δ condition. -/
theorem eps_delta_iff_isOpen_preimage {X Y : Type*} [MetricSpace X] [MetricSpace Y] (f : X → Y) :
(∀ x, ∀ ε > 0, ∃ δ > 0, ∀ y, dist y x < δ → dist (f y) (f x) < ε) ↔
∀ U : Set Y, IsOpen U → IsOpen (f ⁻¹' U) := by
constructor
· intro h U hU
rw [Metric.isOpen_iff] at hU ⊢
intro x hx
obtain ⟨ε, hε, hball⟩ := hU (f x) hx
obtain ⟨δ, hδ, hfx⟩ := h x ε hε
exact ⟨δ, hδ, fun y hy => hball (hfx y hy)⟩
· intro h x ε hε
have hopen : IsOpen (f ⁻¹' Metric.ball (f x) ε) := h _ (ball_isOpen (f x) ε)
rw [Metric.isOpen_iff] at hopen
have hx : x ∈ f ⁻¹' Metric.ball (f x) ε := by
show dist (f x) (f x) < ε
rw [dist_self]
exact hε
obtain ⟨δ, hδ, hsub⟩ := hopen x hx
exact ⟨δ, hδ, fun y hy => hsub hy⟩/-- Mathlib's notion of continuity (preimages of open sets are open) agrees with the ε–δ
definition between metric spaces. This applies Mathlib's `Metric.continuous_iff`; compare
`eps_delta_iff_isOpen_preimage`, which proves the same equivalence from the definitions. -/
theorem continuous_iff_eps_delta {X Y : Type*} [MetricSpace X] [MetricSpace Y] (f : X → Y) :
Continuous f ↔ ∀ x, ∀ ε > 0, ∃ δ > 0, ∀ y, dist y x < δ → dist (f y) (f x) < ε :=
Metric.continuous_iffTheorems 5 and 8 — continuous images of connected and compact sets — are proved by pulling covers back along , exactly as on paper:
/-- **The continuous image of a compact set is compact.** Given an open cover `(Uᵢ)` of `f(K)`,
the preimages `f⁻¹(Uᵢ)` are open (continuity) and cover `K`; compactness of `K` picks finitely
many of them, and the corresponding `Uᵢ` cover `f(K)`. Compactness is used in the open-cover form
(`IsCompact.elim_finite_subcover`, `isCompact_of_finite_subcover`). -/
theorem isCompact_image {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]
{K : Set X} (hK : IsCompact K) {f : X → Y} (hf : Continuous f) : IsCompact (f '' K) := by
apply isCompact_of_finite_subcover
intro ι U hUo hcover
obtain ⟨t, ht⟩ := hK.elim_finite_subcover (fun i => f ⁻¹' U i)
(fun i => (hUo i).preimage hf)
(fun x hx => by simpa using hcover ⟨x, hx, rfl⟩)
refine ⟨t, ?_⟩
rintro _ ⟨x, hx, rfl⟩
simpa using ht hx/-- **The continuous image of a connected set is connected.** Mathlib's `IsPreconnected s` says:
whenever two open sets `u`, `v` together cover `s` and each meets `s`, they meet each other inside
`s`. If `u`, `v` split `f(s)` like this, then `f⁻¹(u)` and `f⁻¹(v)` are open, cover `s` and each
meets `s`; so some `z ∈ s` lies in both, and `f z` lies in `f(s) ∩ u ∩ v`. -/
theorem isPreconnected_image {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]
{s : Set X} (hs : IsPreconnected s) {f : X → Y} (hf : Continuous f) :
IsPreconnected (f '' s) := by
intro u v hu hv hcover ⟨_, ⟨x, hx, rfl⟩, hxu⟩ ⟨_, ⟨y, hy, rfl⟩, hyv⟩
obtain ⟨z, hzs, hzu, hzv⟩ := hs (f ⁻¹' u) (f ⁻¹' v) (hu.preimage hf) (hv.preimage hf)
(fun z hz => hcover ⟨z, hz, rfl⟩) ⟨x, hx, hxu⟩ ⟨y, hy, hyv⟩
exact ⟨f z, ⟨z, hzs, rfl⟩, hzu, hzv⟩The deeper facts that rest on the completeness of are cited from Mathlib: the connectedness of (Theorem 4), Heine–Borel (Theorem 13, for Euclidean space), the extreme value theorem (Corollary 10) and Tychonoff's theorem (Theorem 15), whose Mathlib proof uses ultrafilters.
/-- **The interval `[0, 1]` is connected.** This applies Mathlib's `isConnected_Icc`, whose proof
uses the completeness of `ℝ` (a least upper bound argument), as in the lesson. -/
theorem unitInterval_isConnected : IsConnected (Icc (0 : ℝ) 1) :=
isConnected_Icc zero_le_one/-- **Heine–Borel.** A subset of Euclidean space `ℝⁿ` is compact if and only if it is closed and
bounded. This applies Mathlib's `Metric.isCompact_iff_isClosed_bounded`, which holds in every
*proper* metric space (closed balls compact); `ℝⁿ` is proper because it is finite-dimensional. -/
theorem heine_borel {n : ℕ} (K : Set (EuclideanSpace ℝ (Fin n))) :
IsCompact K ↔ IsClosed K ∧ Bornology.IsBounded K :=
Metric.isCompact_iff_isClosed_bounded/-- **Extreme value theorem.** A continuous real-valued function on a non-empty compact set attains
a maximum. This applies Mathlib's `IsCompact.exists_isMaxOn`. -/
theorem exists_max_on_compact {X : Type*} [TopologicalSpace X] {K : Set X} (hK : IsCompact K)
(hne : K.Nonempty) {f : X → ℝ} (hf : ContinuousOn f K) :
∃ x ∈ K, ∀ y ∈ K, f y ≤ f x := by
obtain ⟨x, hx, hmax⟩ := hK.exists_isMaxOn hne hf
exact ⟨x, hx, fun y hy => isMaxOn_iff.mp hmax y hy⟩/-- **Tychonoff's theorem.** A product of compact sets — any number of them — is compact in the
product topology. This applies Mathlib's `isCompact_univ_pi`, which is proved with ultrafilters
(and so uses the axiom of choice, as it must). -/
theorem tychonoff {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)]
{K : ∀ i, Set (X i)} (hK : ∀ i, IsCompact (K i)) : IsCompact (Set.pi univ K) :=
isCompact_univ_pi hKNext, a clopen set in , and the conclusion that is disconnected. The only arithmetic input is the irrationality of :
/-- No rational number squares to `2`. If `x * x = 2` with `x ∈ ℚ`, then `√2 = |x|` would be
rational, contradicting Mathlib's `irrational_sqrt_two`. -/
theorem no_rat_sq_eq_two (x : ℚ) : x * x ≠ 2 := by
intro h
apply irrational_sqrt_two
refine ⟨|x|, ?_⟩
have hx : ((x : ℝ)) ^ 2 = 2 := by
have := congrArg (fun q : ℚ => (q : ℝ)) h
push_cast at this
nlinarith [this]
rw [Rat.cast_abs, ← hx, Real.sqrt_sq_eq_abs]/-- **A set that is both open and closed.** In `ℚ`, the set `S = {x | x² < 2}` is open (the
preimage of `(-∞, 2)` under the continuous map `x ↦ x²`) and also closed: since no rational
squares to `2`, `S = {x | x² ≤ 2}`, the preimage of the closed set `(-∞, 2]`. -/
theorem rat_clopen : IsClopen {x : ℚ | x * x < 2} := by
have hcont : Continuous fun x : ℚ => x * x := continuous_id.mul continuous_id
have hS : {x : ℚ | x * x < 2} = {x : ℚ | x * x ≤ 2} := by
ext x
show x * x < 2 ↔ x * x ≤ 2
exact ⟨le_of_lt, fun hle => lt_of_le_of_ne hle (no_rat_sq_eq_two x)⟩
refine ⟨?_, isOpen_lt hcont continuous_const⟩
rw [hS]
exact isClosed_le hcont continuous_const/-- **`ℚ` is not connected.** In a connected space the only clopen sets are `∅` and the whole
space (Mathlib's `isClopen_iff`). The clopen set `{x | x² < 2}` contains `0` but not `2`, so it is
neither. -/
theorem rat_not_preconnected : ¬ PreconnectedSpace ℚ := by
intro h
rcases isClopen_iff.mp rat_clopen with hempty | huniv
· have h0 : (0 : ℚ) ∈ {x : ℚ | x * x < 2} := by norm_num
rw [hempty] at h0
exact h0
· have h2 : (2 : ℚ) ∈ {x : ℚ | x * x < 2} := by rw [huniv]; trivial
norm_num at h2The misconception "a continuous bijection is a homeomorphism" fails for . Lean proves the stronger statement that no homeomorphism exists, by the compactness argument after Theorem 14 (IsEmpty of the type of homeomorphisms says there are none):
/-- **`[0, 1)` is not homeomorphic to the circle.** The circle (the unit sphere in `ℝ²`) is
compact (Heine–Borel), and a homeomorphism carries compact spaces to compact spaces; but `[0, 1)`
is not compact, because it is not closed in `ℝ` (Mathlib's `isCompact_Ico_iff`). In particular the
continuous bijection `t ↦ (cos 2πt, sin 2πt)` from `[0, 1)` onto the circle is not a
homeomorphism: its inverse is not continuous. -/
theorem ico_not_homeomorphic_circle :
IsEmpty (Ico (0 : ℝ) 1 ≃ₜ Metric.sphere (0 : EuclideanSpace ℝ (Fin 2)) 1) := by
refine ⟨fun h => ?_⟩
have : CompactSpace (Metric.sphere (0 : EuclideanSpace ℝ (Fin 2)) 1) :=
isCompact_iff_compactSpace.mp (isCompact_sphere 0 1)
have : CompactSpace (Ico (0 : ℝ) 1) := h.symm.compactSpace
have hK : IsCompact (Ico (0 : ℝ) 1) := isCompact_iff_compactSpace.mpr inferInstance
have := isCompact_Ico_iff.mp hK
norm_num at thisFinally, quotients. Maps out of a quotient are continuous as soon as their composite with the projection is — the universal property of the quotient topology — and Mathlib's circle (AddCircle 1) is compact:
/-- **The universal property of the quotient topology.** If `f : X → Y` is continuous and takes
equal values on equivalent points, the induced map on the quotient `X/∼` is continuous. (The
quotient topology is the finest topology making the projection `X → X/∼` continuous.) This
applies Mathlib's `Continuous.quotient_lift`. -/
theorem quotient_lift_continuous {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]
(s : Setoid X) {f : X → Y} (hf : Continuous f) (h : ∀ a b, a ≈ b → f a = f b) :
Continuous (Quotient.lift f h : Quotient s → Y) :=
hf.quotient_lift h/-- **The circle `ℝ/ℤ` is compact.** Mathlib's `AddCircle 1` is the quotient of `ℝ` by the
subgroup `ℤ`, with the quotient topology. It is compact because it is the image of the compact
interval `[0, 1]` under the continuous projection — the lesson's argument. This applies Mathlib's
instance `AddCircle.compactSpace`. -/
theorem addCircle_compact : CompactSpace (AddCircle (1 : ℝ)) := by
have : Fact ((0 : ℝ) < 1) := ⟨one_pos⟩
infer_instanceWhat is and is not formalised. Independent proofs: Proposition 1 (balls are open), Theorem 2 (both directions), Theorems 5 and 8, the clopen subset of , the disconnectedness of and the non-existence of a homeomorphism . Cited from Mathlib: Theorems 4, 13 and 15, Corollary 10, the universal property of quotients and the compactness of . Theorem 14 and Lemma 12 are in Mathlib (Continuous.homeoOfEquivCompactToT2, IsCompact.prod) but are not restated here, and Corollary 7 is not formalised.
Finite spaces and the bisection machine
On a finite set a topology is a finite object, so a computer can list them all. The program below tries every family of subsets of an -point set and keeps those that satisfy the axioms. It then sorts them by the separation axioms and by connectedness.
"""Every topology on a set with at most four points, found by exhaustive search.
A topology on a finite set X is a family of subsets containing the empty set
and X and closed under unions and intersections (for finite families,
closure under pairs suffices). Subsets of X are encoded as bit masks, so a
family of subsets is a set of integers. The search tries every family that
contains the empty set and X, keeps those satisfying the axioms, and sorts
the survivors by separation and connectedness properties. It also prints the
open, closed and clopen sets of the Sierpinski space. This is exact,
exhaustive evidence about finite spaces only; infinite spaces are not touched.
"""
from itertools import combinations
def is_topology(n, family):
"""Whether ``family`` (a set of bit masks) is a topology on {0, ..., n-1}."""
full = (1 << n) - 1
if 0 not in family or full not in family:
return False
members = sorted(family)
for i, a in enumerate(members):
for b in members[i + 1:]:
if (a | b) not in family or (a & b) not in family:
return False
return True
def topologies(n):
"""List every topology on an n-point set, each as a frozenset of masks."""
full = (1 << n) - 1
middle = [m for m in range(1, full)]
found = []
for k in range(len(middle) + 1):
for extra in combinations(middle, k):
family = frozenset({0, full, *extra})
if is_topology(n, family):
found.append(family)
return found
def closed_sets(n, family):
"""The closed sets: complements of the open sets."""
full = (1 << n) - 1
return frozenset(full ^ u for u in family)
def is_t0(n, family):
"""T0: any two distinct points are told apart by some open set."""
return all(
any(((u >> x) & 1) != ((u >> y) & 1) for u in family)
for x, y in combinations(range(n), 2)
)
def is_t1(n, family):
"""T1: every one-point set is closed."""
closed = closed_sets(n, family)
return all((1 << x) in closed for x in range(n))
def is_hausdorff(n, family):
"""Hausdorff: distinct points have disjoint open neighbourhoods."""
for x, y in combinations(range(n), 2):
if not any((u >> x) & 1 and (v >> y) & 1 and not u & v
for u in family for v in family):
return False
return True
def is_connected(n, family):
"""Connected: the only clopen sets are the empty set and the whole set."""
if n == 0:
return True
full = (1 << n) - 1
clopen = family & closed_sets(n, family)
return clopen == {0, full}
def census(n):
"""Counts (all, T0, T1, Hausdorff, connected) of topologies on n points."""
tops = topologies(n)
return (
len(tops),
sum(is_t0(n, t) for t in tops),
sum(is_t1(n, t) for t in tops),
sum(is_hausdorff(n, t) for t in tops),
sum(is_connected(n, t) for t in tops),
)
def show(mask, names="ab"):
"""Write a subset of a two-point set as {a}, {a, b}, ..."""
items = [names[i] for i in range(len(names)) if (mask >> i) & 1]
return "{" + ", ".join(items) + "}"
def main():
print("Topologies on an n-point set, found by trying every family:")
print(" n all T0 T1 Hausdorff connected")
for n in range(1, 5):
total, t0, t1, t2, conn = census(n)
print(f" {n} {total:5d} {t0:4d} {t1:4d} {t2:10d} {conn:10d}")
print()
sierpinski = frozenset({0b00, 0b01, 0b11})
opens = sorted(sierpinski)
closed = sorted(closed_sets(2, sierpinski))
print("Sierpinski space on {a, b} with open sets", ", ".join(map(show, opens)))
print(" closed sets:", ", ".join(map(show, closed)))
print(" {a} is open but not closed; {b} is closed but not open;")
print(" only {} and {a, b} are both. It is T0 but not T1, and connected.")
print()
print("On a finite set, T1 already forces the discrete topology, so the")
print("T1 and Hausdorff columns are all 1s: finite spaces with interesting")
print("topologies are never Hausdorff.")
print()
print("Epistemic status: exact and exhaustive for sets of one to four")
print("points (the totals 1, 4, 29, 355 agree with the known values, OEIS")
print("A000798). It proves nothing about infinite spaces, where the lesson's")
print("theorems live.")
if __name__ == "__main__":
main()The counts grow quickly; no simple formula for the number of topologies on points is known. Notice the T₁ column: a finite T₁ space is discrete (every set is a finite union of closed points, hence closed). So finite spaces — which turn up in combinatorics and in computer science, as models of digital images — are never Hausdorff unless they are discrete. This is exhaustive evidence about at most four points, and nothing more.
The second program runs the proof of Theorem 11 as an algorithm. It halves an interval until each piece lies inside a single set of the cover. On it stops. On , with the cover by the intervals , the piece next to is never covered, and the number of sets needed grows without bound.
"""The bisection proof of Heine-Borel, run as an algorithm.
To find a finite subcover of an open cover of [a, b], ask whether one set of
the cover contains the whole interval; if not, cut it in half and ask again
about each half. The proof of the Heine-Borel theorem shows that on a closed
bounded interval this always stops: an infinite chain of halvings would close
in on a point x, and the open set containing x would swallow every small
enough interval around x. We run the procedure with exact rational arithmetic
on two covers by the open intervals U_n = (1/n, 2): on [0, 1], with one extra
set around 0, it stops; on (0, 1] it never does, because the chain of
left-hand halves closes in on 0, which is not in the space. Evidence: exact
computation, and a counterexample to compactness of (0, 1].
"""
from fractions import Fraction
TENTH = Fraction(1, 10)
def smallest_index_above(lo):
"""Smallest n >= 1 with 1/n < lo, for lo > 0."""
if lo <= 0:
raise ValueError("lo must be positive")
return int(1 / lo) + 1
def cover_closed(lo, hi, left_open=False):
"""Cover of [0, 1]: U_0 = (-1/10, 1/10) and U_n = (1/n, 2), n >= 1.
Returns the index of one set containing [lo, hi], or None.
"""
if -TENTH < lo and hi < TENTH:
return 0
if lo > 0 and hi < 2:
return smallest_index_above(lo)
return None
def cover_half_open(lo, hi, left_open=False):
"""Cover of (0, 1] by U_n = (1/n, 2), n >= 1 (no set around 0).
``left_open`` marks the piece (lo, hi] with lo = 0, which no U_n contains.
"""
if left_open or lo <= 0 or hi >= 2:
return None
return smallest_index_above(lo)
def bisect_cover(find, lo, hi, max_depth, left_open=False):
"""Run the bisection argument on [lo, hi] (or (lo, hi] if ``left_open``).
Returns (sorted indices used, leftover pieces, deepest level reached).
"""
used, leftovers, deepest = set(), [], 0
stack = [(Fraction(lo), Fraction(hi), 0)]
while stack:
a, b, depth = stack.pop()
deepest = max(deepest, depth)
index = find(a, b, left_open and a == lo)
if index is not None:
used.add(index)
elif depth == max_depth:
leftovers.append((a, b))
else:
mid = (a + b) / 2
stack.extend([(a, mid, depth + 1), (mid, b, depth + 1)])
return sorted(used), leftovers, deepest
def main():
used, left, deepest = bisect_cover(cover_closed, 0, 1, 60)
print("Cover of [0, 1] by (-1/10, 1/10) and U_n = (1/n, 2), n >= 1:")
print(f" halted at depth {deepest} with no leftovers: {left == []}")
print(f" finite subcover: {len(used)} sets, indices {used}")
print()
print("Cover of (0, 1] by U_n = (1/n, 2) alone:")
print(" depth sets used largest index uncovered piece")
for depth in (4, 8, 16, 32):
used, left, _ = bisect_cover(cover_half_open, 0, 1, depth, True)
(a, b), = left
assert a == 0 and b == Fraction(1, 2**depth)
print(f" {depth:5d} {len(used):10d} {max(used):14d} (0, 2^-{depth}]")
print()
print("Every halving leaves the piece next to 0 uncovered, and covering")
print("[2^-d, 1] needs ever larger n. Indeed no finite subfamily covers")
print("(0, 1]: if N is its largest index, the points of (0, 1/N] are missed.")
print("The chain of left halves closes in on 0, a point missing from the")
print("space. On [0, 1] that point is present and lies in an open set of")
print("the cover, which is exactly why the procedure must halt.")
print()
print("Epistemic status: exact rational arithmetic on two specific covers.")
print("It illustrates the proof of Heine-Borel and gives a counterexample")
print("to compactness of (0, 1]; it does not prove that the procedure halts")
print("for every open cover of [0, 1] - the lesson's proof does that.")
if __name__ == "__main__":
main()This is a picture of the proof, not a proof. The procedure halts on these particular covers. The theorem says it halts on every open cover of — and its proof shows why. If it never halted, the chain of halvings would close in on a point, and some open set of the cover would swallow every small piece around that point.
Explore: continuity and gluing
First, continuity at a point in the ε–δ form of Theorem 2. Shrink ε and look for a δ that keeps the graph inside the band. Then switch to the function with a jump: there, no δ works for small ε, and in open-set language the preimage of a small open interval around is not open — it contains but no interval around it.
Continuity at a point: find δ for each ε
A limit is a promise: for every tolerance ε there is a δ. Choose δ and see whether the graph stays inside the band.
Claim: limx→1 (x²) = 1Your move: find δ > 0 so that every x with 0 < |x − a| < δ satisfies |f(x) − L| < ε.
- f(x) = x²
- ε-band L ± ε
- δ-window a ± δ
- graph outside the band
The challenge ε
Checked at 2,118 sample points: evidence, not a proof.
A discontinuity: no δ works
A limit is a promise: for every tolerance ε there is a δ. Choose δ and see whether the graph stays inside the band.
Claim: limx→0 (x/2 + sign(x)) = 1Your move: find δ > 0 so that every x with 0 < |x − a| < δ satisfies |f(x) − L| < ε.
- f(x) = x/2 + sign(x)
- ε-band L ± ε
- δ-window a ± δ
- graph outside the band
The challenge ε
Checked at 2,118 sample points: evidence, not a proof.
Next, quotient spaces. Each surface below is a square with its sides glued in pairs. Walk the little creature off one edge and watch where it comes back. In the torus and the sphere every crossing preserves the creature's orientation. In the Klein bottle and the projective plane, some crossings bring it back mirror-reversed.
Quotient spaces: squares with glued sides
Glue the sides of a square in pairs so that the arrows match. Walk a flatlander across a side and watch where — and how — it comes back.
Keys: ↑ forward, ↓ back, ← and → turn, Space walks or stops. You can also drag it.
- Orientable
- Yes
- Euler characteristic
- χ = 0
Gluing turns the 4 corners into V = 1, the 4 sides into E = 2 and the square into F = 1: V − E + F = 1 − 2 + 1 = 0
Same way round as at the start.
Sides crossed so far: 0
Opposite sides are glued with arrows pointing the same way. Walk off the right side and you come back on the left, the same way round. However it walks, the flatlander is never mirrored: the torus is orientable.
Exercises
1. Metric spaces and point-set topology
Warm-upHumanWhich of these formulas define a metric on ? (Choose all that apply.)
2. Metric spaces and point-set topology
Warm-upHumanWith the usual topology on , which of these sets are closed? (Choose all that apply.)
3. Metric spaces and point-set topology
Warm-upHumanHow many different topologies are there on the two-element set ?
4. Metric spaces and point-set topology
CoreHumanA student claims: a continuous map sends open sets to open sets. Which of these continuous maps are counterexamples? (Choose all that apply.)
5. Metric spaces and point-set topology
CoreHumanThe map from to the circle is a continuous bijection but not a homeomorphism. Theorem 14 says a continuous bijection from a compact space to a Hausdorff space is a homeomorphism. Which hypothesis of Theorem 14 fails here?
6. Metric spaces and point-set topology
CoreHumanIn which of these metric spaces is the given set closed and bounded but not compact? (Choose all that apply.)
7. Metric spaces and point-set topology
CoreHumanStart with the square and glue for every , and nothing else. What is the quotient space?
8. Metric spaces and point-set topology
CoreFormalWhich Lean statement says that the continuous image of a compact set is compact? (Here K : Set X and f : X → Y.)
9. Metric spaces and point-set topology
CoreComputationalWrite is_topology(points, opens) that returns True exactly when the set opens of frozensets is a topology on the finite set points (a frozenset). Check: every open set is a subset of points; the empty set and points are open; and the union and intersection of any two open sets are open. (Why is checking pairs enough for a finite family?)
10. Metric spaces and point-set topology
StretchHumanRemoving one point and counting connected pieces proves that which of these pairs are not homeomorphic? (Choose all that apply.)
Common misconceptions
Misconception
"Closed means not open." Open and closed are not opposites. In every space and are both; in the set is neither; in the set is both; in a discrete space every set is both. A space is connected exactly when and are its only clopen sets.
Misconception
"A continuous bijection is a homeomorphism." The map from onto is a continuous bijection whose inverse tears the circle open at . The identity map from a two-point set with the discrete topology to the same set with the indiscrete topology is another continuous bijection that is not a homeomorphism. Theorem 14 gives a sufficient condition: compact domain and Hausdorff target. The first example fails the first hypothesis, the second fails the second.
Misconception
"Closed and bounded implies compact, in every metric space." That is the Heine–Borel theorem for . It fails in , in infinite discrete spaces, and in infinite-dimensional spaces: in the space of square-summable sequences, the unit vectors lie in the closed unit ball but are at distance from each other, so no subsequence converges. Boundedness is not even a topological property: is bounded, is not, yet they are homeomorphic.
Misconception
"Continuous maps send open sets to open sets." Continuity pulls open sets back; it need not push them forward. A constant map sends to a point, and sends to . Maps that do send open sets to open sets are called open maps; projections are examples.
Misconception
"Connected and path-connected are the same." Path-connected implies connected, but the topologist's sine curve is connected and not path-connected: no path can reach the segment from the wiggling part. For open subsets of (and for manifolds) the two notions do coincide.
Many ways of seeing
Topology— Invariants that tell spaces apart
Compactness, connectedness and the number of pieces left after removing points are topological invariants: homeomorphic spaces share them. They already settle many "same shape?" questions. (via ), but neither is homeomorphic to , which is compact. The letters I, O and Y are pairwise non-homeomorphic: removing a suitable point leaves 2, 1 and 3 pieces respectively, and no point of O disconnects it.
Point-set invariants soon run out, though. and are both compact and connected, and both stay connected when one point is removed. Removing two points separates them: falls apart and does not. And to show that one needs a finer invariant. Removing a point from leaves loops that cannot be shrunk; in every loop can be shrunk. That is the fundamental group. That for all is Brouwer's invariance of domain, a theorem of algebraic topology.
Geometry— Metric versus topology
A geometer keeps the distances. An isometry preserves them; a homeomorphism only preserves open sets. So the circle of radius and the circle of radius are homeomorphic but not isometric, and the round sphere and the surface of a cube are homeomorphic — topologically the same — while their geometries differ completely. Between these two extremes lie bi-Lipschitz maps, which distort distances by at most a bounded factor; the three metrics on are bi-Lipschitz equivalent, which is why they have the same open sets.
Metric geometry can even put a metric on the collection of spaces themselves. The Hausdorff distance between compact subsets of a metric space is the least such that each lies in the -neighbourhood of the other. Gromov extended this to the Gromov–Hausdorff distance between abstract metric spaces. It is the setting for statements such as "the integer grid , viewed from farther and farther away, converges to the plane with the taxicab metric".
Analysis— Compactness is finiteness in disguise
For an analyst, compactness is the tool that turns pointwise statements into uniform ones. A continuous function on a compact metric space is uniformly continuous (Heine–Cantor): around each point there is a δ, and compactness lets one choose a single δ for all points. In metric spaces compactness is equivalent to sequential compactness (Bolzano–Weierstrass in disguise) and to "complete and totally bounded".
In infinite dimensions compactness becomes precious. In a normed space the closed unit ball is compact if and only if the space is finite-dimensional (F. Riesz's lemma). In the space with the metric , the Arzelà–Ascoli theorem characterises the compact sets: closed, bounded and equicontinuous. That theorem is behind Peano's existence theorem for differential equations. These ideas are developed in functional analysis.
Algebra— The Zariski topology: closed sets are solution sets
An algebraist builds topologies out of equations. On , declare a set closed if it is the set of common zeros of some family of polynomials. Finite unions and arbitrary intersections of such sets are again solution sets, so this is a topology: the Zariski topology. On a non-zero polynomial has finitely many roots, so the closed sets are exactly the finite sets and itself — the cofinite topology from the examples, which is compact and T₁ but not Hausdorff. Far from being a defect, this coarse topology is the foundation of algebraic geometry. Its non-Hausdorff behaviour is one reason sheaves enter the story.
Number theory— A metric in which powers of p shrink
Fix a prime . For a non-zero rational with not divisible by , set (and ). Then is a metric on satisfying the ultrametric inequality . In this metric , every triangle is isosceles, and every point of a ball is a centre of it. Balls are therefore clopen, so the completion is totally disconnected, and the -adic integers — the closed unit ball — are compact. Ostrowski's theorem (1916) says that every non-trivial absolute value on is equivalent to the usual one or to a -adic one. So topology sees the primes.
Logic— Compactness theorems and choice
The compactness theorem of first-order logic — a set of sentences has a model as soon as every finite subset does — takes its name from topology: it says that a certain space of complete theories (a Stone space) is compact. See completeness, compactness and Löwenheim–Skolem. Logic also measures the strength of topological theorems. Tychonoff's theorem is equivalent to the axiom of choice over ZF (Kelley, 1950). In reverse mathematics, the Heine–Borel theorem for countable covers of is equivalent, over the weak base system RCA₀, to the system WKL₀ ("weak König's lemma": every infinite binary tree has an infinite path). That is exactly the combinatorial heart of the bisection proof.
Category theory— Products and quotients by their maps
Topological spaces and continuous maps form a category . The product topology is the categorical product: a map is continuous exactly when each component is. The quotient topology has the dual property: a map is continuous exactly when its composite with is (formalised above as quotient_lift_continuous). These are universal properties, and they make "coarsest" and "finest" precise. The forgetful functor has a left adjoint (give a set the discrete topology) and a right adjoint (give it the indiscrete topology). That is why it preserves both limits and colimits: a product of spaces has the product set as its underlying set, and a quotient space has the quotient set.
History and global context
- Roots in analysis. Bernard Bolzano's 1817 proof of the intermediate value theorem and Karl Weierstrass's lectures in Berlin made limits and continuity rigorous; Georg Cantor's study of the sets on which Fourier series converge (1870s) introduced limit points and derived sets.
- Compactness of intervals. The theorem named after Eduard Heine and Émile Borel grew out of proofs of uniform continuity. Borel's 1895 thesis showed that a countable cover of a closed interval by open intervals has a finite subcover, and Henri Lebesgue and others removed the countability. Similar arguments appear earlier, in lectures of Dirichlet.
- Abstraction. Maurice Fréchet's 1906 thesis introduced abstract metric spaces (and the word "compact"). Frigyes Riesz proposed axioms for abstract spaces at the 1908 International Congress in Rome. Felix Hausdorff's Grundzüge der Mengenlehre (1914) defined topological spaces by neighbourhood axioms, with his separation axiom, and named metric spaces. Kazimierz Kuratowski (1922) gave the closure-operator axioms.
- Schools. In Warsaw, Wacław Sierpiński, Stefan Mazurkiewicz and Zygmunt Janiszewski founded Fundamenta Mathematicae in 1920, the first journal devoted to set theory and topology. In Moscow, Pavel Alexandrov and Pavel Urysohn developed the modern open-cover notion of compactness ("bicompactness") in the 1920s, and Urysohn proved his metrisation theorem. Andrey Tychonoff proved in 1930 that arbitrary products of closed intervals are compact; he stated the general product theorem in 1935, and the first published proof of it is in a 1937 paper of Eduard Čech. After the war, Jun-iti Nagata in Japan (1950) and Yuri Smirnov in the Soviet Union (1951) independently characterised the metrisable spaces.
- Foundations. John Kelley's 1950 proof that Tychonoff's theorem implies the axiom of choice tied the subject to set theory. His General Topology (1955) fixed much of the modern vocabulary.
Further reading
- James R. Munkres, Topology (2nd edition, 2000) — the standard textbook; chapters 2–5 cover this lesson, including Tychonoff's theorem.
- Wilson A. Sutherland, Introduction to Metric and Topological Spaces (2nd edition, 2009) — a gentle bridge from metric spaces to topology.
- Lynn Arthur Steen and J. Arthur Seebach Jr., Counterexamples in Topology (1970) — 143 spaces that show which hypotheses are necessary.
- John L. Kelley, General Topology (1955), and Ryszard Engelking, General Topology (revised edition, 1989) — comprehensive references.