Lean library · module TopologyByExample.Slices.S2

The second study: compactness and its variants

Source file

The study compactness (content/slices/compactness.md, Lean name S2) has seven properties, in this order:

index property Mathlib
0 compact CompactSpace
1 σ-compact SigmaCompactSpace
2 Lindelöf LindelofSpace
3 countably compact CountablyCompactSpace
4 sequentially compact SeqCompactSpace
5 weakly locally compact WeaklyLocallyCompactSpace
6 Hausdorff T2Space

Its theory is seven Horn clauses (S2.data.clauses), and its base library has eight spaces, in the order of the content's base_spaces:

index row base space here
0 1111111 one-point space Unit
1 1111110 Sierpiński space Prop
2 0010001 Sorgenfrey line field sorgenfreyLine
3 0110001 rational numbers ℚ
4 0001101 countable power of ω₁ field omegaOnePower
5 0110011 countably infinite discrete space ℕ
6 1111011 Stone–Čech compactification of ℕ Ultrafilter ℕ
7 0001111 first uncountable ordinal ω₁ field omegaOne

The data here is checked against content/ by the generated file TopologyByExample.Generated.SliceCheck, which also checks that S2.data.solve agrees with the Python implementation of the algorithm on all 128 rows.

Main statements

  • S2.valid, S2.sumConjunctive, S2.covers: the three hypotheses of the general theorems. All seven clauses and all seven sum lemmas are proved.
  • S2.not_realises_of_solve_eq_refuted: no space, in any universe, realises a refuted row.
  • S2.solve_correct and S2.exists_realises_iff_consistent: correctness and completeness of the algorithm for any base library S2.BaseSpaces. Five of its eight spaces are filled in here; the Sorgenfrey line, ω₁ and ω₁^ℕ are fields, supplied (through realises_sorgenfreyLine, realises_omegaOnePower and realises_omegaOne) in TopologyByExample.Slices.S2.Complete, which states both results unconditionally.

This file was written by Claude (Anthropic's AI model) working under the direction of David R. MacIver, who reviews it and is responsible for it.

Imports

The properties

definition compact

TopologyByExample.Slices.S2.compact

Compactness (CompactSpace).

def compact : SpaceProperty.{u}
:= ⟨fun X _ ↦ CompactSpace X⟩

definition sigmaCompact

TopologyByExample.Slices.S2.sigmaCompact

σ-compactness (SigmaCompactSpace).

def sigmaCompact : SpaceProperty.{u}
:= ⟨fun X _ ↦ SigmaCompactSpace X⟩

definition lindelof

TopologyByExample.Slices.S2.lindelof

The Lindelöf property (LindelofSpace).

def lindelof : SpaceProperty.{u}
:= ⟨fun X _ ↦ LindelofSpace X⟩

definition countablyCompact

TopologyByExample.Slices.S2.countablyCompact

Countable compactness (CountablyCompactSpace).

def countablyCompact : SpaceProperty.{u}
:= ⟨fun X _ ↦ CountablyCompactSpace X⟩

definition seqCompact

TopologyByExample.Slices.S2.seqCompact

Sequential compactness (SeqCompactSpace).

def seqCompact : SpaceProperty.{u}
:= ⟨fun X _ ↦ SeqCompactSpace X⟩

definition weaklyLocallyCompact

TopologyByExample.Slices.S2.weaklyLocallyCompact

Weak local compactness (WeaklyLocallyCompactSpace).

def weaklyLocallyCompact : SpaceProperty.{u}
:= ⟨fun X _ ↦ WeaklyLocallyCompactSpace X⟩

definition t2

TopologyByExample.Slices.S2.t2

The Hausdorff property (T2Space).

def t2 : SpaceProperty.{u}
:= ⟨fun X _ ↦ T2Space X⟩

definition prop

TopologyByExample.Slices.S2.prop

The properties of S2, in study order.

def prop : Fin 7 → SpaceProperty.{u}
:=
  ![compact, sigmaCompact, lindelof, countablyCompact, seqCompact, weaklyLocallyCompact, t2]

definition Realises

TopologyByExample.Slices.S2.Realises

The space X realises the row r of S2.

abbrev Realises (X : Type u) [TopologicalSpace X] (r : Row 7) : Prop
:=
  Slices.Realises prop X r

theorem sumConjunctive

TopologyByExample.Slices.S2.sumConjunctive

Every S2 property is sum-conjunctive.

theorem sumConjunctive : ∀ i, (prop.{u} i).SumConjunctive
Proof
:= by
  intro i
  fin_cases i <;> intro X Y _ _
  exacts [compactSpace_sum_iff, sigmaCompactSpace_sum_iff, lindelofSpace_sum_iff,
    countablyCompactSpace_sum_iff, seqCompactSpace_sum_iff, weaklyLocallyCompactSpace_sum_iff,
    t2Space_sum_iff]

theorem holds_of_homeomorph

TopologyByExample.Slices.S2.holds_of_homeomorph

The S2 properties are invariant under homeomorphisms, also between universes.

theorem holds_of_homeomorph {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y]
    (e : X ≃ₜ Y) (i : Fin 7) (h : (prop.{u} i).Holds X) : (prop.{v} i).Holds Y
Proof
:= by
  fin_cases i
  · have : CompactSpace X := h
    exact e.symm.isClosedEmbedding.compactSpace
  · have : SigmaCompactSpace X := h
    exact e.symm.isClosedEmbedding.sigmaCompactSpace
  · have : LindelofSpace X := h
    exact e.symm.isClosedEmbedding.LindelofSpace
  · have : CountablyCompactSpace X := h
    exact e.symm.isClosedEmbedding.countablyCompactSpace
  · have : SeqCompactSpace X := h
    exact e.symm.isClosedEmbedding.seqCompactSpace
  · have : WeaklyLocallyCompactSpace X := h
    exact e.symm.isClosedEmbedding.weaklyLocallyCompactSpace
  · have : T2Space X := h
    exact e.symm.isEmbedding.t2Space

theorem of_homeomorph

TopologyByExample.Slices.S2.Realises.of_homeomorph

Homeomorphic spaces, possibly in different universes, realise the same S2 rows.

theorem Realises.of_homeomorph {X : Type u} {Y : Type v} [TopologicalSpace X]
    [TopologicalSpace Y] (e : X ≃ₜ Y) {r : Row 7} (h : Realises X r) : Realises Y r
Proof
:=
  fun i ↦ ⟨fun hY ↦ (h i).1 (holds_of_homeomorph e.symm i hY),
    fun hr ↦ holds_of_homeomorph e i ((h i).2 hr)⟩

The combinatorial data

definition data

TopologyByExample.Slices.S2.data

The combinatorial data of S2. The clauses are listed in the order in which the content's algorithm prefers them (fewest literals, then theorem id):

  1. compact-implies-countably-compact
  2. compact-implies-sigma-compact
  3. compact-implies-weakly-locally-compact
  4. sequentially-compact-implies-countably-compact
  5. sigma-compact-implies-lindelof
  6. lindelof-countably-compact-implies-compact
  7. lindelof-weakly-locally-compact-implies-sigma-compact

The base rows are those of the base spaces in the content's order, and the top space is the one-point space.

def data : SliceData 7 8
Definition
where
  clauses :=
    [⟨[0], some 3⟩, ⟨[0], some 1⟩, ⟨[0], some 5⟩, ⟨[4], some 3⟩, ⟨[1], some 2⟩,
      ⟨[2, 3], some 0⟩, ⟨[2, 5], some 1⟩]
  baseRow :=
    ![![true, true, true, true, true, true, true],
      ![true, true, true, true, true, true, false],
      ![false, false, true, false, false, false, true],
      ![false, true, true, false, false, false, true],
      ![false, false, false, true, true, false, true],
      ![false, true, true, false, false, true, true],
      ![true, true, true, true, false, true, true],
      ![false, false, false, true, true, true, true]]
  top := 0

theorem valid

TopologyByExample.Slices.S2.valid

The S2 clauses are theorems, for spaces in every universe.

theorem valid : data.Valid prop.{u}
Proof
:= by
  intro c hc X _ h
  simp only [data, List.mem_cons, List.not_mem_nil, or_false] at hc
  rcases hc with rfl | rfl | rfl | rfl | rfl | rfl | rfl
  · have : CompactSpace X := h 0 (by simp)
    exact (inferInstance : CountablyCompactSpace X)
  · have : CompactSpace X := h 0 (by simp)
    exact (inferInstance : SigmaCompactSpace X)
  · have : CompactSpace X := h 0 (by simp)
    exact (inferInstance : WeaklyLocallyCompactSpace X)
  · have : SeqCompactSpace X := h 4 (by simp)
    exact (inferInstance : CountablyCompactSpace X)
  · have : SigmaCompactSpace X := h 1 (by simp)
    exact (inferInstance : LindelofSpace X)
  · have : LindelofSpace X := h 2 (by simp)
    have : CountablyCompactSpace X := h 3 (by simp)
    exact LindelofSpace.compactSpace
  · have : LindelofSpace X := h 2 (by simp)
    have : WeaklyLocallyCompactSpace X := h 5 (by simp)
    exact sigmaCompactSpace_of_lindelofSpace_of_weaklyLocallyCompactSpace

theorem covers

TopologyByExample.Slices.S2.covers

Every consistent row of S2 is the row of its witness expression: the meet of the base rows above it. Checked by kernel evaluation over all 128 rows.

theorem covers : data.Covers
Proof
:= by decide

theorem card_consistent

TopologyByExample.Slices.S2.card_consistent

Exactly 22 of the 128 rows of S2 are consistent.

theorem card_consistent :
    ((Row.all 7).filter fun r ↦ decide (data.Consistent r)).length = 22
Proof
:= by
  decide

Completing the base rows

For each base row, a few values determine the rest of the row through the clauses.

variable {X : Type u} [TopologicalSpace X]

theorem realises_onePointSpace

TopologyByExample.Slices.S2.realises_onePointSpace

A compact, sequentially compact Hausdorff space has the row 1111111.

theorem realises_onePointSpace [CompactSpace X] [SeqCompactSpace X] [T2Space X] :
    Realises X (data.baseRow 0)
Proof
:=
  data.realises_of_determines valid (cells := [(0, true), (4, true), (6, true)])
    ⟨iff_of_true ‹CompactSpace X› rfl, iff_of_true ‹SeqCompactSpace X› rfl,
      iff_of_true ‹T2Space X› rfl⟩
    (by decide)

theorem realises_sierpinskiSpace

TopologyByExample.Slices.S2.realises_sierpinskiSpace

A compact, sequentially compact, non-Hausdorff space has the row 1111110.

theorem realises_sierpinskiSpace [CompactSpace X] [SeqCompactSpace X] (h : ¬T2Space X) :
    Realises X (data.baseRow 1)
Proof
:=
  data.realises_of_determines valid (cells := [(0, true), (4, true), (6, false)])
    ⟨iff_of_true ‹CompactSpace X› rfl, iff_of_true ‹SeqCompactSpace X› rfl,
      iff_of_false h Bool.false_ne_true⟩
    (by decide)

theorem realises_sorgenfreyLine

TopologyByExample.Slices.S2.realises_sorgenfreyLine

A Lindelöf Hausdorff space that is not σ-compact has the row 0010001.

theorem realises_sorgenfreyLine [LindelofSpace X] [T2Space X] (h : ¬SigmaCompactSpace X) :
    Realises X (data.baseRow 2)
Proof
:=
  data.realises_of_determines valid (cells := [(1, false), (2, true), (6, true)])
    ⟨iff_of_false h Bool.false_ne_true, iff_of_true ‹LindelofSpace X› rfl,
      iff_of_true ‹T2Space X› rfl⟩
    (by decide)

theorem realises_rationals

TopologyByExample.Slices.S2.realises_rationals

A σ-compact Hausdorff space that is not weakly locally compact has the row 0110001.

theorem realises_rationals [SigmaCompactSpace X] [T2Space X] (h : ¬WeaklyLocallyCompactSpace X) :
    Realises X (data.baseRow 3)
Proof
:=
  data.realises_of_determines valid (cells := [(1, true), (5, false), (6, true)])
    ⟨iff_of_true ‹SigmaCompactSpace X› rfl, iff_of_false h Bool.false_ne_true,
      iff_of_true ‹T2Space X› rfl⟩
    (by decide)

theorem realises_omegaOnePower

TopologyByExample.Slices.S2.realises_omegaOnePower

A sequentially compact Hausdorff space that is neither Lindelöf nor weakly locally compact has the row 0001101.

theorem realises_omegaOnePower [SeqCompactSpace X] [T2Space X] (hl : ¬LindelofSpace X)
    (hw : ¬WeaklyLocallyCompactSpace X) : Realises X (data.baseRow 4)
Proof
:=
  data.realises_of_determines valid (cells := [(2, false), (4, true), (5, false), (6, true)])
    ⟨iff_of_false hl Bool.false_ne_true, iff_of_true ‹SeqCompactSpace X› rfl,
      iff_of_false hw Bool.false_ne_true, iff_of_true ‹T2Space X› rfl⟩
    (by decide)

theorem realises_discreteNaturals

TopologyByExample.Slices.S2.realises_discreteNaturals

A σ-compact, weakly locally compact Hausdorff space that is not compact has the row 0110011.

theorem realises_discreteNaturals [SigmaCompactSpace X] [WeaklyLocallyCompactSpace X] [T2Space X]
    (h : ¬CompactSpace X) : Realises X (data.baseRow 5)
Proof
:=
  data.realises_of_determines valid (cells := [(0, false), (1, true), (5, true), (6, true)])
    ⟨iff_of_false h Bool.false_ne_true, iff_of_true ‹SigmaCompactSpace X› rfl,
      iff_of_true ‹WeaklyLocallyCompactSpace X› rfl, iff_of_true ‹T2Space X› rfl⟩
    (by decide)

theorem realises_stoneCechNaturals

TopologyByExample.Slices.S2.realises_stoneCechNaturals

A compact Hausdorff space that is not sequentially compact has the row 1111011.

theorem realises_stoneCechNaturals [CompactSpace X] [T2Space X] (h : ¬SeqCompactSpace X) :
    Realises X (data.baseRow 6)
Proof
:=
  data.realises_of_determines valid (cells := [(0, true), (4, false), (6, true)])
    ⟨iff_of_true ‹CompactSpace X› rfl, iff_of_false h Bool.false_ne_true,
      iff_of_true ‹T2Space X› rfl⟩
    (by decide)

theorem realises_omegaOne

TopologyByExample.Slices.S2.realises_omegaOne

A sequentially compact, weakly locally compact Hausdorff space that is not Lindelöf has the row 0001111.

theorem realises_omegaOne [SeqCompactSpace X] [WeaklyLocallyCompactSpace X] [T2Space X]
    (h : ¬LindelofSpace X) : Realises X (data.baseRow 7)
Proof
:=
  data.realises_of_determines valid (cells := [(2, false), (4, true), (5, true), (6, true)])
    ⟨iff_of_false h Bool.false_ne_true, iff_of_true ‹SeqCompactSpace X› rfl,
      iff_of_true ‹WeaklyLocallyCompactSpace X› rfl, iff_of_true ‹T2Space X› rfl⟩
    (by decide)

theorem realises_unit

TopologyByExample.Slices.S2.realises_unit

The one-point space Unit realises the row 1111111.

theorem realises_unit : Realises (TopCat.of Unit) (data.baseRow 0)
Proof
:=
  realises_onePointSpace (X := Unit)

theorem realises_prop

TopologyByExample.Slices.S2.realises_prop

The Sierpiński space Prop realises the row 1111110.

theorem realises_prop : Realises (TopCat.of Prop) (data.baseRow 1)
Proof
:=
  realises_sierpinskiSpace (X := Prop) Sierpinski.not_t2Space

theorem realises_rat

TopologyByExample.Slices.S2.realises_rat

The rational numbers realise the row 0110001.

theorem realises_rat : Realises (TopCat.of ℚ) (data.baseRow 3)
Proof
:=
  have : SigmaCompactSpace ℚ := sigmaCompactSpace_of_countable
  realises_rationals (X := ℚ) Rationals.not_weaklyLocallyCompactSpace

theorem realises_nat

TopologyByExample.Slices.S2.realises_nat

The countably infinite discrete space ℕ realises the row 0110011.

theorem realises_nat : Realises (TopCat.of ℕ) (data.baseRow 5)
Proof
:=
  have : SigmaCompactSpace ℕ := sigmaCompactSpace_of_countable
  realises_discreteNaturals (X := ℕ) fun _ ↦
    Infinite.not_finite (finite_of_compact_of_discrete (X := ℕ))

theorem realises_ultrafilter_nat

TopologyByExample.Slices.S2.realises_ultrafilter_nat

The space of ultrafilters on ℕ realises the row 1111011.

theorem realises_ultrafilter_nat : Realises (TopCat.of (Ultrafilter ℕ)) (data.baseRow 6)
Proof
:=
  realises_stoneCechNaturals (X := Ultrafilter ℕ) StoneCechNaturals.not_seqCompactSpace

The base library and the main theorems

structure BaseSpaces

TopologyByExample.Slices.S2.BaseSpaces

The base library of S2: a space in Type realising each base row. Five spaces are filled in by default; the Sorgenfrey line, ω₁ and ω₁^ℕ are supplied by S2.baseSpaces in TopologyByExample.Slices.S2.Complete.

structure BaseSpaces : Type 1 where
  /-- The one-point space (row `1111111`). -/
  onePointSpace : TopCat.{0} := TopCat.of Unit
  onePointSpace_realises : Realises onePointSpace (data.baseRow 0) := by
    exact TopologyByExample.Slices.S2.realises_unit
  /-- The Sierpiński space (row `1111110`). -/
  sierpinskiSpace : TopCat.{0} := TopCat.of Prop
  sierpinskiSpace_realises : Realises sierpinskiSpace (data.baseRow 1) := by
    exact TopologyByExample.Slices.S2.realises_prop
  /-- The Sorgenfrey line (row `0010001`). -/
  sorgenfreyLine : TopCat.{0}
  sorgenfreyLine_realises : Realises sorgenfreyLine (data.baseRow 2)
  /-- The rational numbers (row `0110001`). -/
  rationals : TopCat.{0} := TopCat.of ℚ
  rationals_realises : Realises rationals (data.baseRow 3) := by
    exact TopologyByExample.Slices.S2.realises_rat
  /-- The countable power of the first uncountable ordinal (row `0001101`). -/
  omegaOnePower : TopCat.{0}
  omegaOnePower_realises : Realises omegaOnePower (data.baseRow 4)
  /-- The countably infinite discrete space (row `0110011`). -/
  discreteNaturals : TopCat.{0} := TopCat.of ℕ
  discreteNaturals_realises : Realises discreteNaturals (data.baseRow 5) := by
    exact TopologyByExample.Slices.S2.realises_nat
  /-- The Stone–Čech compactification of the natural numbers (row `1111011`). -/
  stoneCechNaturals : TopCat.{0} := TopCat.of (Ultrafilter ℕ)
  stoneCechNaturals_realises : Realises stoneCechNaturals (data.baseRow 6) := by
    exact TopologyByExample.Slices.S2.realises_ultrafilter_nat
  /-- The first uncountable ordinal (row `0001111`). -/
  omegaOne : TopCat.{0}
  omegaOne_realises : Realises omegaOne (data.baseRow 7)

definition library

TopologyByExample.Slices.S2.BaseSpaces.library

The base library as a SliceData.Library, indexed in the content's order.

def BaseSpaces.library (B : BaseSpaces) : data.Library prop.{0}
Definition
where
  space := ![B.onePointSpace, B.sierpinskiSpace, B.sorgenfreyLine, B.rationals, B.omegaOnePower,
    B.discreteNaturals, B.stoneCechNaturals, B.omegaOne]
  realises b := by
    fin_cases b
    exacts [B.onePointSpace_realises, B.sierpinskiSpace_realises, B.sorgenfreyLine_realises,
      B.rationals_realises, B.omegaOnePower_realises, B.discreteNaturals_realises,
      B.stoneCechNaturals_realises, B.omegaOne_realises]

theorem not_realises_of_solve_eq_refuted

TopologyByExample.Slices.S2.not_realises_of_solve_eq_refuted

Soundness of S2 refutations. If the algorithm refutes a row, by a clause of S2 the row violates, then no topological space, in any universe, realises the row.

theorem not_realises_of_solve_eq_refuted {r : Row 7} {c : Clause 7}
    (h : data.solve r = .refuted c) (X : Type u) [TopologicalSpace X] : ¬Realises X r
Proof
:=
  data.not_realises_of_solve_eq_refuted valid h X

theorem solve_correct

TopologyByExample.Slices.S2.solve_correct

Correctness of the S2 algorithm, for any base library.

theorem solve_correct (B : BaseSpaces) (r : Row 7) :
    (data.solve r).Correct data prop B.library.space r
Proof
:=
  data.solve_correct valid sumConjunctive B.library covers r

theorem exists_realises_iff_consistent

TopologyByExample.Slices.S2.exists_realises_iff_consistent

Completeness of S2, for any base library: a row is realised by some topological space (in any given universe) if and only if it satisfies the seven clauses.

theorem exists_realises_iff_consistent (B : BaseSpaces) (r : Row 7) :
    (∃ X : TopCat.{u}, Realises X r) ↔ data.Consistent r
Proof
:= by
  refine ⟨fun ⟨X, hX⟩ ↦ valid.consistent hX, fun hr ↦ ?_⟩
  obtain ⟨X, hX⟩ :=
    (data.exists_realises_iff_consistent valid sumConjunctive B.library covers r).2 hr
  exact ⟨TopCat.of (ULift.{u} X), Realises.of_homeomorph Homeomorph.ulift.symm hX⟩