Formalising Mathematics with Lean

3.1.Β Topological spacesπŸ”—

Definition 3.1 (Topological space)πŸ”—

Let X be a set and \mathcal{T} a collection of subsets of X such that

  1. The sets \emptyset and X belong to \mathcal{T}.

  2. Any finite intersection of elements of \mathcal{T} belongs to \mathcal{T}.

  3. Any arbitrary union of elements of \mathcal{T} belongs to \mathcal{T}.

Then we will say that \mathcal{T} is a topology on X, that (X, \mathcal{T}) is a topological space and that the elements of \mathcal{T} are open in this space.

In Lean, this definition is written as a structure consisting of four elements:

class TopologicalSpace (X : Type u) where IsOpen : Set X β†’ Prop isOpen_univ : IsOpen Set.univ isOpen_inter : βˆ€ s t, IsOpen s β†’ IsOpen t β†’ IsOpen (s ∩ t) isOpen_sUnion : βˆ€ s, (βˆ€ t ∈ s, IsOpen t) β†’ IsOpen (⋃₀ s)

The first element, IsOpen, is a function taking each set of X to a proposition, that is, it is a description of the elements of \mathcal{T} as the set {U ∈ Set (X) | IsOpen U}. The other three elements are proofs of the properties in the definition.

Let us look at some examples and their proofs in Lean.

Example 3.1πŸ”—

Let X be any set. Consider the collection of all subsets of X, \mathcal{T} = \mathcal{P}(X). Then \mathcal{T} is a topology on X, which we call the discrete topology.

Proof. We can describe \mathcal T as {U ∈ Set (X) | true}, because IsOpen is true for any U.

def DiscreteTopo (X : Type) : TopologicalSpace X where IsOpen (_ : Set X) := true

Now, proving the remaining properties is easy:

isOpen_univ := X:Type⊒ true = true

Applying the function fun x ↦ true to any set always returns true, so it suffices to use trivial.

@[reducible] def DiscreteTopo (X : Type) : TopologicalSpace X where IsOpen (_ : Set X) := true isOpen_univ := X:Type⊒ true = true All goals completed! πŸ™ isOpen_inter := X:Type⊒ βˆ€ (s t : Set X), true = true β†’ true = true β†’ true = true X:Types✝:Set Xt✝:Set Xa✝¹:true = truea✝:true = true⊒ true = true All goals completed! πŸ™ isOpen_sUnion := X:Type⊒ βˆ€ (s : Set (Set X)), (βˆ€ t ∈ s, true = true) β†’ true = true X:Types✝:Set (Set X)a✝:βˆ€ t ∈ s✝, true = true⊒ true = true All goals completed! πŸ™

∎

Example 3.2πŸ”—

Let X be any set. Consider the collection \mathcal{T}=\{\emptyset, X\}. Then \mathcal{T} is a topology on X, which we call the trivial topology.

Proof. We can describe \mathcal{T} as {U ∈ Set (X) | U = X ∨ U = βˆ…}.

@[reducible] def TrivialTopology (X : Type) : TopologicalSpace X where IsOpen (s : Set X) := s = Set.univ ∨ s = βˆ…

The first condition holds trivially: we want to see X = X \lor X = \emptyset.

isOpen_univ := X:Type⊒ Set.univ = Set.univ ∨ Set.univ = βˆ… X:Type⊒ Set.univ = Set.univ All goals completed! πŸ™

Let us now consider two open sets (intro). We distinguish cases:

isOpen_inter := X:Type⊒ βˆ€ (s t : Set X), s = Set.univ ∨ s = βˆ… β†’ t = Set.univ ∨ t = βˆ… β†’ s ∩ t = Set.univ ∨ s ∩ t = βˆ… intro s X:Types:Set Xt:Set X⊒ s = Set.univ ∨ s = βˆ… β†’ t = Set.univ ∨ t = βˆ… β†’ s ∩ t = Set.univ ∨ s ∩ t = βˆ… X:Types:Set Xt:Set Xhs:s = Set.univ ∨ s = βˆ…βŠ’ t = Set.univ ∨ t = βˆ… β†’ s ∩ t = Set.univ ∨ s ∩ t = βˆ… X:Types:Set Xt:Set Xhs:s = Set.univ ∨ s = βˆ…ht:t = Set.univ ∨ t = βˆ…βŠ’ s ∩ t = Set.univ ∨ s ∩ t = βˆ… X:Types:Set Xt:Set Xht:t = Set.univ ∨ t = βˆ…hs_univ:s = Set.univ⊒ s ∩ t = Set.univ ∨ s ∩ t = βˆ…X:Types:Set Xt:Set Xht:t = Set.univ ∨ t = βˆ…hs_empty:s = βˆ…βŠ’ s ∩ t = Set.univ ∨ s ∩ t = βˆ… X:Types:Set Xt:Set Xhs_univ:s = Set.univht_univ:t = Set.univ⊒ s ∩ t = Set.univ ∨ s ∩ t = βˆ…X:Types:Set Xt:Set Xhs_univ:s = Set.univht_empty:t = βˆ…βŠ’ s ∩ t = Set.univ ∨ s ∩ t = βˆ…X:Types:Set Xt:Set Xht:t = Set.univ ∨ t = βˆ…hs_empty:s = βˆ…βŠ’ s ∩ t = Set.univ ∨ s ∩ t = βˆ…

If both are X, the intersection will be X and therefore open. If one of the two is empty, then the intersection is empty, also open.

X:Types:Set Xt:Set Xhs_univ:s = Set.univht_univ:t = Set.univ⊒ s ∩ t = Set.univ ∨ s ∩ t = βˆ… X:Types:Set Xt:Set Xhs_univ:s = Set.univht_univ:t = Set.univ⊒ s ∩ t = Set.univ -- 1. both are univ X:Types:Set Xt:Set Xhs_univ:s = Set.univht_univ:t = Set.univ⊒ Set.univ ∩ Set.univ = Set.univ All goals completed! πŸ™ X:Types:Set Xt:Set Xhs_univ:s = Set.univht_empty:t = βˆ…βŠ’ s ∩ t = Set.univ ∨ s ∩ t = βˆ… X:Types:Set Xt:Set Xhs_univ:s = Set.univht_empty:t = βˆ…βŠ’ s ∩ t = βˆ… -- 2. t is empty X:Types:Set Xt:Set Xhs_univ:s = Set.univht_empty:t = βˆ…βŠ’ s ∩ βˆ… = βˆ… All goals completed! πŸ™ X:Types:Set Xt:Set Xht:t = Set.univ ∨ t = βˆ…hs_empty:s = βˆ…βŠ’ s ∩ t = Set.univ ∨ s ∩ t = βˆ… X:Types:Set Xt:Set Xht:t = Set.univ ∨ t = βˆ…hs_empty:s = βˆ…βŠ’ s ∩ t = βˆ… -- 3. s is empty X:Types:Set Xt:Set Xht:t = Set.univ ∨ t = βˆ…hs_empty:s = βˆ…βŠ’ βˆ… ∩ t = βˆ… All goals completed! πŸ™

Finally, consider an arbitrary collection S of open sets. To see whether the union is open, we consider two different cases: either X is in S, in which case the union is X, or it is not, in which case all the sets in S are the empty set and so is the union.

isOpen_sUnion := X:Type⊒ βˆ€ (s : Set (Set X)), (βˆ€ t ∈ s, t = Set.univ ∨ t = βˆ…) β†’ ⋃₀ s = Set.univ ∨ ⋃₀ s = βˆ… intro S X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…βŠ’ ⋃₀ S = Set.univ ∨ ⋃₀ S = βˆ… X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ S⊒ ⋃₀ S = Set.univ ∨ ⋃₀ S = βˆ…X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h2:Set.univ βˆ‰ S⊒ ⋃₀ S = Set.univ ∨ ⋃₀ S = βˆ… -- h1 : Set.univ ∈ S -- h2 : Set.univ βˆ‰ S X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ S⊒ ⋃₀ S = Set.univ ∨ ⋃₀ S = βˆ… X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ S⊒ ⋃₀ S = Set.univ X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:X⊒ s ∈ ⋃₀ S ↔ s ∈ Set.univ X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:X⊒ s ∈ ⋃₀ S β†’ s ∈ Set.univX:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:X⊒ s ∈ Set.univ β†’ s ∈ ⋃₀ S X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:X⊒ s ∈ ⋃₀ S β†’ s ∈ Set.univX:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:X⊒ s ∈ Set.univ β†’ s ∈ ⋃₀ S X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:Xhs:s ∈ Set.univ⊒ s ∈ ⋃₀ S X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:Xhs:s ∈ ⋃₀ S⊒ s ∈ Set.univ All goals completed! πŸ™ X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h1:Set.univ ∈ Ss:Xhs:s ∈ Set.univ⊒ s ∈ ⋃₀ S All goals completed! πŸ™ -- uses h1 implicitly to close the goal X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h2:Set.univ βˆ‰ S⊒ ⋃₀ S = Set.univ ∨ ⋃₀ S = βˆ… X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h2:Set.univ βˆ‰ S⊒ ⋃₀ S = βˆ… X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h2:Set.univ βˆ‰ S⊒ βˆ€ s ∈ S, s = βˆ… intro s X:TypeS:Set (Set X)hS:βˆ€ t ∈ S, t = Set.univ ∨ t = βˆ…h2:Set.univ βˆ‰ Ss:Set Xhs:s ∈ S⊒ s = βˆ… X:TypeS:Set (Set X)h2:Set.univ βˆ‰ Ss:Set Xhs:s ∈ ShS:s = Set.univ ∨ s = βˆ…βŠ’ s = βˆ… X:TypeS:Set (Set X)h2:Set.univ βˆ‰ Ss:Set Xhs:s ∈ ShS:s = Set.univ⊒ s = βˆ…X:TypeS:Set (Set X)h2:Set.univ βˆ‰ Ss:Set Xhs:s ∈ ShS:s = βˆ…βŠ’ s = βˆ… X:TypeS:Set (Set X)h2:Set.univ βˆ‰ Ss:Set Xhs:s ∈ ShS:s = Set.univ⊒ s = βˆ… X:TypeS:Set (Set X)h2:Set.univ βˆ‰ Ss:Set Xhs:s ∈ ShS:s = Set.univthis:Β¬s = βˆ…βŠ’ False X:TypeS:Set (Set X)h2:Set.univ βˆ‰ Ss:Set Xhs:Set.univ ∈ ShS:s = Set.univthis:Β¬s = βˆ…βŠ’ False All goals completed! πŸ™ X:TypeS:Set (Set X)h2:Set.univ βˆ‰ Ss:Set Xhs:s ∈ ShS:s = βˆ…βŠ’ s = βˆ… All goals completed! πŸ™

∎

Example 3.3πŸ”—

Consider the real line and the usual definition of an open set in \mathbb{R}, that is, A \subseteq \mathbb{R} is open if and only if for each point x \in A there exists an open ball centred at x entirely contained in A. Let \mathcal{T} be the collection of these open sets. Then \mathcal{T} is a topology on \mathbb{R}, which we call the usual topology.

Proof. In Lean, we can describe this topological space by giving its elements in the following way, where each object is defined beforehand.

Definition `UsualTopology` of class type must be marked with `@[reducible]` or `@[implicit_reducible]`def UsualTopology : TopologicalSpace ℝ where IsOpen := Real.IsOpen isOpen_univ := Real.isOpen_univ isOpen_inter := Real.isOpen_inter isOpen_sUnion := Real.isOpen_sUnion

The definition of an open set can be written like this:

def Real.IsOpen (s : Set ℝ) : Prop := βˆ€ x ∈ s, βˆƒ Ξ΄ > 0, βˆ€ y : ℝ, x - Ξ΄ < y ∧ y < x + Ξ΄ β†’ y ∈ s

We give the proof for the finite intersection. The others use similar mechanisms.

Let, therefore, s and t be two subsets of \mathcal{T}. Let x \in t \cap s; we want to see that there exists an open ball centred at x and contained in t \cap s.

lemma Real.isOpen_inter (s t : Set ℝ) (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ∩ t) := s:Set ℝt:Set ℝhs:IsOpen sht:IsOpen t⊒ IsOpen (s ∩ t) intro x s:Set ℝt:Set ℝhs:IsOpen sht:IsOpen tx:ℝhx:x ∈ s ∩ t⊒ βˆƒ Ξ΄ > 0, βˆ€ (y : ℝ), x - Ξ΄ < y ∧ y < x + Ξ΄ β†’ y ∈ s ∩ t

Since x \in s, there exists a \delta_1>0 (hΞ΄1) such that B_{\delta_1}(x) \subseteq s (hs). Analogously, there exists a \delta_2>0 (hΞ΄2) such that B_{\delta_2}(x) \subseteq t (ht). It suffices to take \delta = \min \{\delta_1, \delta_2\}.

s:Set ℝt:Set ℝhs✝:IsOpen sht:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ s⊒ βˆƒ Ξ΄ > 0, βˆ€ (y : ℝ), x - Ξ΄ < y ∧ y < x + Ξ΄ β†’ y ∈ s ∩ t s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ t⊒ βˆƒ Ξ΄ > 0, βˆ€ (y : ℝ), x - Ξ΄ < y ∧ y < x + Ξ΄ β†’ y ∈ s ∩ t s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ t⊒ min Ξ΄1 Ξ΄2 > 0 ∧ βˆ€ (y : ℝ), x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2 β†’ y ∈ s ∩ t

Trivially \delta > 0.

s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ t⊒ min Ξ΄1 Ξ΄2 > 0s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ t⊒ βˆ€ (y : ℝ), x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2 β†’ y ∈ s ∩ t s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ t⊒ min Ξ΄1 Ξ΄2 > 0 All goals completed! πŸ™

To see that B_\delta (x) \subseteq s \cap t, we consider y \in B_\delta(x) and want to see that y \in s and that y \in t. To see y \in s, since B_{\delta_1}(x) \subseteq s (hs), it suffices to see y \in B_{\delta_1}(x).

s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ t⊒ βˆ€ (y : ℝ), x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2 β†’ y ∈ s ∩ t intro y s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2⊒ y ∈ s ∩ t s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2⊒ y ∈ ss:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2⊒ y ∈ t s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2⊒ y ∈ s s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2⊒ x - Ξ΄1 < y ∧ y < x + Ξ΄1

Actually, this condition reduces to two inequalities, which are easy to prove given that \delta \leq \delta_1 (hΞ΄).

s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2hΞ΄:min Ξ΄1 Ξ΄2 ≀ Ξ΄1⊒ x - Ξ΄1 < y ∧ y < x + Ξ΄1 s:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2hΞ΄:min Ξ΄1 Ξ΄2 ≀ Ξ΄1⊒ x - Ξ΄1 < ys:Set ℝt:Set ℝhs✝:IsOpen sht✝:IsOpen tx:ℝhx:x ∈ s ∩ tΞ΄1:ℝhΞ΄1:Ξ΄1 > 0hs:βˆ€ (y : ℝ), x - Ξ΄1 < y ∧ y < x + Ξ΄1 β†’ y ∈ sΞ΄2:ℝhΞ΄2:Ξ΄2 > 0ht:βˆ€ (y : ℝ), x - Ξ΄2 < y ∧ y < x + Ξ΄2 β†’ y ∈ ty:ℝhy:x - min Ξ΄1 Ξ΄2 < y ∧ y < x + min Ξ΄1 Ξ΄2hΞ΄:min Ξ΄1 Ξ΄2 ≀ Ξ΄1⊒ y < x + Ξ΄1 all_goals All goals completed! πŸ™

Proving that y \in t is analogous. ∎

3.1.1.Β Open setsπŸ”—

As we have said, the open sets in a topological space are the elements of the topology. In Lean, it is a function TopologicalSpace.IsOpen of type Set X β†’ Prop. We can use this definition directly to prove that an open set is indeed open.

Example 3.4πŸ”—

By definition, the universe, X, is always open. Indeed:

example (X : Type) [T : TopologicalSpace X] : T.IsOpen Set.univ := X:TypeT:TopologicalSpace X⊒ TopologicalSpace.IsOpen Set.univ All goals completed! πŸ™

Example 3.5πŸ”—

In Definition 3.1, we had the condition \emptyset \in \mathcal{T}, a condition that does not appear in the Mathlib definition.

It can be proved that the empty set is open from the remaining conditions: we can write \emptyset as \emptyset = \bigcup_{x \in \emptyset} \{x\}. Applying that the arbitrary union of open sets is open, it would suffice to see that \forall x \in \emptyset, \{x\} is an open set. Which is trivial.

example (X : Type) [TopologicalSpace X] : IsOpen (βˆ… : Set X) := X:Typeinst✝:TopologicalSpace X⊒ IsOpen βˆ… X:Typeinst✝:TopologicalSpace X⊒ βˆ… = ⋃₀ βˆ…X:Typeinst✝:TopologicalSpace Xh1:βˆ… = ⋃₀ βˆ…βŠ’ IsOpen βˆ… X:Typeinst✝:TopologicalSpace Xh1:βˆ… = ⋃₀ βˆ…βŠ’ IsOpen βˆ… X:Typeinst✝:TopologicalSpace Xh1:βˆ… = ⋃₀ βˆ…βŠ’ IsOpen (⋃₀ βˆ…) X:Typeinst✝:TopologicalSpace Xh1:βˆ… = ⋃₀ βˆ…βŠ’ βˆ€ t ∈ βˆ…, IsOpen t intro t X:Typeinst✝:TopologicalSpace Xh1:βˆ… = ⋃₀ βˆ…t:Set Xht:t ∈ βˆ…βŠ’ IsOpen t X:Typeinst✝:TopologicalSpace Xh1:βˆ… = ⋃₀ βˆ…t:Set Xht:t ∈ βˆ…this:Β¬IsOpen t⊒ False All goals completed! πŸ™

Example 3.6πŸ”—

In the usual topology, (\mathbb{R}, \mathcal{T}_u), the open intervals I = (a, b) with a < b are open sets of the topology.

Proof. Consider an interval of the form (a, b); we want to see that it is open. To do so, let x \in (a, b), and let us see that there exists a \delta >0 such that \forall y \in \mathbb{R}, if y \in B_\delta(x) then y \in (a, b).

lemma ioo_open_in_R (a b : ℝ) : UsualTopology.IsOpen ((Set.Ioo a b) : Set ℝ) := a:ℝb:β„βŠ’ TopologicalSpace.IsOpen (Set.Ioo a b) a:ℝb:β„βŠ’ TopologicalSpace.IsOpen (Set.Ioo a b) intro x a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a b⊒ βˆƒ Ξ΄ > 0, βˆ€ (y : ℝ), x - Ξ΄ < y ∧ y < x + Ξ΄ β†’ y ∈ Set.Ioo a b

We take \delta = min \{x-a, b-x\}. Obviously \delta >0 since a < x < b.

a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a b⊒ min (x - a) (b - x) > 0 ∧ βˆ€ (y : ℝ), x - min (x - a) (b - x) < y ∧ y < x + min (x - a) (b - x) β†’ y ∈ Set.Ioo a b -- nuestro Ξ΄ a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a b⊒ min (x - a) (b - x) > 0a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a b⊒ βˆ€ (y : ℝ), x - min (x - a) (b - x) < y ∧ y < x + min (x - a) (b - x) β†’ y ∈ Set.Ioo a b a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a b⊒ min (x - a) (b - x) > 0 -- Ξ΄ > 0 ? a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a b⊒ 0 < x - a ∧ 0 < b - x All goals completed! πŸ™

Let now y \in B_\delta(x); we want to see that y \in (a, b). There are two possible cases, depending on the value \delta takes. If \delta = x-a, that is, x-a < b -x, then we have y \in B_\delta(x) \implies x - (x - a) < y < x + (x - a) < x + (b - x) \implies a < y < b, hence y \in (a, b). The case \delta = b -x is analogous.

a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a b⊒ βˆ€ (y : ℝ), x - min (x - a) (b - x) < y ∧ y < x + min (x - a) (b - x) β†’ y ∈ Set.Ioo a b -- (x - Ξ΄, x + Ξ΄) βŠ† (a, b) ? -- hay que diferenciar cuando Ξ΄ = x-a y Ξ΄ = b-x intro y a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝhy:x - min (x - a) (b - x) < y ∧ y < x + min (x - a) (b - x)⊒ y ∈ Set.Ioo a b a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝhy:x - min (x - a) (b - x) < y ∧ y < x + min (x - a) (b - x)cases:x - a < b - x ∨ b - x ≀ x - a⊒ y ∈ Set.Ioo a b a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝhy:x - min (x - a) (b - x) < y ∧ y < x + min (x - a) (b - x)h:x - a < b - x⊒ y ∈ Set.Ioo a ba:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝhy:x - min (x - a) (b - x) < y ∧ y < x + min (x - a) (b - x)h:b - x ≀ x - a⊒ y ∈ Set.Ioo a b all_goals try a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝhy:x - (x - a) < y ∧ y < x + (x - a)h:x - a < b - x⊒ y ∈ Set.Ioo a b try a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝhy:x - (b - x) < y ∧ y < x + (b - x)h:b - x ≀ x - a⊒ y ∈ Set.Ioo a b a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝh:b - x ≀ x - ahy:x - (b - x) < y ∧ y < b⊒ y ∈ Set.Ioo a b a:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝh:b - x ≀ x - ahy:x - (b - x) < y ∧ y < b⊒ a < ya:ℝb:ℝx:ℝhx:x ∈ Set.Ioo a by:ℝh:b - x ≀ x - ahy:x - (b - x) < y ∧ y < b⊒ y < b all_goals All goals completed! πŸ™

∎

Definition 3.2 (Open neighbourhood)πŸ”—

Let (X, \mathcal{T}) be a topological space and x \in X. An open neighbourhood of x in X is an open set U \in \mathcal{T} such that x \in U.

def OpenNeighbourhood {X : Type} [TopologicalSpace X] (U : Set X) (x : X) : Prop := x ∈ U ∧ IsOpen U

Example 3.7πŸ”—

The universe, X, is an open neighbourhood of any point x \in X. Indeed:

lemma univ_is_OpenNeighb {X : Type} [TopologicalSpace X] (x : X) : OpenNeighbourhood Set.univ x := X:Typeinst✝:TopologicalSpace Xx:X⊒ OpenNeighbourhood Set.univ x X:Typeinst✝:TopologicalSpace Xx:X⊒ x ∈ Set.univX:Typeinst✝:TopologicalSpace Xx:X⊒ IsOpen Set.univ X:Typeinst✝:TopologicalSpace Xx:X⊒ x ∈ Set.univ All goals completed! πŸ™ X:Typeinst✝:TopologicalSpace Xx:X⊒ IsOpen Set.univ All goals completed! πŸ™

Definition 3.3 (Neighbourhood)πŸ”—

Let (X, \mathcal{T}) be a topological space and x \in X. A neighbourhood of x in X is a set V \subseteq X such that there exists an open neighbourhood of x, U \in \mathcal{T}, with U \subseteq V.

def Neighbourhood {X : Type} [TopologicalSpace X] (V : Set X) (x : X) : Prop := βˆƒ U : Set X, U βŠ† V ∧ OpenNeighbourhood U x

Example 3.8πŸ”—

An open neighbourhood is also a neighbourhood. Indeed:

lemma OpenNeighb_is_Neighb {X : Type} [TopologicalSpace X] (U : Set X) (x : X) : OpenNeighbourhood U x β†’ Neighbourhood U x := X:Typeinst✝:TopologicalSpace XU:Set Xx:X⊒ OpenNeighbourhood U x β†’ Neighbourhood U x X:Typeinst✝:TopologicalSpace XU:Set Xx:XhU:OpenNeighbourhood U x⊒ Neighbourhood U x All goals completed! πŸ™

Proposition 3.1 (Characterisation of open sets)πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq U any set. A is open if and only if it is a neighbourhood of all of its points.

lemma A_open_iff_neighbourhood_of_all {X : Type} [T : TopologicalSpace X] {A : Set X} : IsOpen A ↔ βˆ€ x ∈ A, Neighbourhood A x := X:TypeT:TopologicalSpace XA:Set X⊒ IsOpen A ↔ βˆ€ x ∈ A, Neighbourhood A x

Proof. We prove each implication separately.

X:TypeT:TopologicalSpace XA:Set X⊒ IsOpen A β†’ βˆ€ x ∈ A, Neighbourhood A xX:TypeT:TopologicalSpace XA:Set X⊒ (βˆ€ x ∈ A, Neighbourhood A x) β†’ IsOpen A all_goals X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A x⊒ IsOpen A

(\implies) The first implication is easy: if A is open, for each x \in A it suffices to take A as a neighbourhood of x.

X:TypeT:TopologicalSpace XA:Set Xh:IsOpen A⊒ βˆ€ x ∈ A, Neighbourhood A x -- β†’ intro x X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ Neighbourhood A x X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ A βŠ† A ∧ OpenNeighbourhood A x X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ A βŠ† AX:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ OpenNeighbourhood A x X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ A βŠ† A All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ OpenNeighbourhood A x X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ x ∈ AX:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ IsOpen A X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ x ∈ A All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Ax:Xhx:x ∈ A⊒ IsOpen A All goals completed! πŸ™

(\impliedby) The converse is more complicated. We know that for each a \in A there exists U_a, a neighbourhood of a. We will first prove that A = \bigcup_{a \in A} U_a

X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A x⊒ IsOpen A -- ← X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A x⊒ A = ⋃ a, Classical.choose β‹―X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xhUnion:A = ⋃ a, Classical.choose β‹―βŠ’ IsOpen A

To do so, we prove both inclusions. If x \in A, then by our hypothesis there exists a neighbourhood of x, U_x. And by the definition of neighbourhood, that means that x \in U_x. Hence x \in \bigcup_{a}U_a.

X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A x⊒ A = ⋃ a, Classical.choose β‹― X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:X⊒ x ∈ A ↔ x ∈ ⋃ a, Classical.choose β‹―; X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:X⊒ x ∈ A β†’ x ∈ ⋃ a, Classical.choose β‹―X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:X⊒ x ∈ ⋃ a, Classical.choose β‹― β†’ x ∈ A; all_goals X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xhx:x ∈ ⋃ a, Classical.choose β‹―βŠ’ x ∈ A X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xhx:x ∈ A⊒ x ∈ ⋃ a, Classical.choose β‹― X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xhx:x ∈ Aleft✝:Classical.choose β‹― βŠ† AhUx:OpenNeighbourhood (Classical.choose β‹―) x⊒ x ∈ ⋃ a, Classical.choose β‹― X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xhx:x ∈ Aleft✝:Classical.choose β‹― βŠ† AhUx:OpenNeighbourhood (Classical.choose β‹―) x⊒ βˆƒ i, βˆƒ (i_1 : i ∈ A), x ∈ Classical.choose β‹― X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xhx:x ∈ Aleft✝:Classical.choose β‹― βŠ† AhUx:OpenNeighbourhood (Classical.choose β‹―) x⊒ x ∈ Classical.choose β‹― All goals completed! πŸ™

Now, if x \in \bigcup_{a}U_a, then there exists an a \in A with x \in U_a and U_a an open neighbourhood of a with U_a \subseteq A. Hence x \in U_a \subseteq A.

X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xhx:x ∈ ⋃ a, Classical.choose β‹―βŠ’ x ∈ A X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xhx:βˆƒ i, βˆƒ (i_1 : i ∈ A), x ∈ Classical.choose β‹―βŠ’ x ∈ A X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xa:Xha:a ∈ Ahx:x ∈ Classical.choose β‹―βŠ’ x ∈ A X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xa:Xha:a ∈ Ahx:x ∈ Classical.choose β‹―ha':Classical.choose β‹― βŠ† Aright✝:OpenNeighbourhood (Classical.choose β‹―) a⊒ x ∈ A X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xx:Xa:Xha:a ∈ Ahx:x ∈ Classical.choose β‹―ha':Classical.choose β‹― βŠ† Aright✝:OpenNeighbourhood (Classical.choose β‹―) a⊒ x ∈ Classical.choose β‹― All goals completed! πŸ™

Then we have proved that A can be expressed as a union of sets U_a. But we know that all these sets are open neighbourhoods, hence they are open. It suffices to apply that the union of open sets is open.

X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xhUnion:A = ⋃ a, Classical.choose β‹―βŠ’ IsOpen (⋃ a, Classical.choose β‹―) X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xhUnion:A = ⋃ a, Classical.choose β‹―βŠ’ βˆ€ (i : ↑A), IsOpen (Classical.choose β‹―) X:TypeT:TopologicalSpace XA:Set Xh:βˆ€ x ∈ A, Neighbourhood A xhUnion:A = ⋃ a, Classical.choose β‹―a:↑A⊒ IsOpen (Classical.choose β‹―) All goals completed! πŸ™

∎

Definition 3.4 (Interior)πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. We define the interior as the set \overset{\circ}{A} = \bigcup \left\{ U \subseteq X | U \text{ is open and } U \subseteq A \right\}

def interior (s : Set X) : Set X := ⋃₀ { t | IsOpen t ∧ t βŠ† s }

Let us look at several properties of the interior of a set.

Proposition 3.2πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. Then \overset{\circ}{A} \subseteq A

In Mathlib, this result goes by the name interior_subset.

Proof. Let a \in \overset{\circ}{A}. Then A is a neighbourhood of a and there exists an open set with a \in U \subseteq A. Hence a \in A.

example {X : Type} [T : TopologicalSpace X] (A : Set X) : interior A βŠ† A := X:TypeT:TopologicalSpace XA:Set X⊒ interior A βŠ† A intro a X:TypeT:TopologicalSpace XA:Set Xa:Xha:a ∈ interior A⊒ a ∈ A X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ a ∈ A X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ a ∈ U All goals completed! πŸ™

∎

Proposition 3.3πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. Then \overset{\circ}{A} is an open set.

In Mathlib, this result goes by the name isOpen_interior.

Proof. By the characterisation of open sets (3.1), it suffices to see that, given a \in \overset{\circ}{A}, \overset{\circ}{A} is a neighbourhood of a.

If a \in \overset{\circ}{A}, then there exists an open U with a \in U \subseteq A. We use this U to prove that \overset{\circ}{A} is a neighbourhood of a.

example {X : Type} [T : TopologicalSpace X] (A : Set X) : IsOpen (interior A) := X:TypeT:TopologicalSpace XA:Set X⊒ IsOpen (interior A) X:TypeT:TopologicalSpace XA:Set X⊒ βˆ€ x ∈ interior A, Neighbourhood (interior A) x intro a X:TypeT:TopologicalSpace XA:Set Xa:Xha:a ∈ interior A⊒ Neighbourhood (interior A) a X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ Neighbourhood (interior A) a X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ U βŠ† interior A ∧ OpenNeighbourhood U a X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ U βŠ† interior AX:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ OpenNeighbourhood U a X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ U βŠ† interior A intro x X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ Ux:Xhx:x ∈ U⊒ x ∈ interior A All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ OpenNeighbourhood U a X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ a ∈ UX:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ IsOpen U X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ a ∈ U All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xa:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† A}ha:a ∈ U⊒ IsOpen U All goals completed! πŸ™

∎

Proposition 3.4πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. Then A is open if and only if A is equal to its interior.

In Mathlib, this result goes by the name interior_eq_iff_isOpen.

Proof. The converse is trivial, since we have already seen that the interior of a set is open.

example {X : Type} [T : TopologicalSpace X] (A : Set X) : IsOpen A ↔ interior A = A:= X:TypeT:TopologicalSpace XA:Set X⊒ IsOpen A ↔ interior A = A X:TypeT:TopologicalSpace XA:Set X⊒ IsOpen A β†’ interior A = AX:TypeT:TopologicalSpace XA:Set X⊒ interior A = A β†’ IsOpen A; X:TypeT:TopologicalSpace XA:Set X⊒ interior A = A β†’ IsOpen AX:TypeT:TopologicalSpace XA:Set X⊒ IsOpen A β†’ interior A = A; all_goals X:TypeT:TopologicalSpace XA:Set Xh:IsOpen A⊒ interior A = A X:TypeT:TopologicalSpace XA:Set Xh:interior A = A⊒ IsOpen A X:TypeT:TopologicalSpace XA:Set Xh:interior A = A⊒ IsOpen (interior A) All goals completed! πŸ™

Now, suppose that A is open. We have already seen that \overset{\circ}{A} \subseteq A, so it suffices to see the other inclusion. Let a \in A. Since A is open, it is an open neighbourhood of a with A \subseteq A. Hence a \in \overset{\circ}{A}.

X:TypeT:TopologicalSpace XA:Set Xh:IsOpen A⊒ interior A = A X:TypeT:TopologicalSpace XA:Set Xh:IsOpen A⊒ interior A βŠ† AX:TypeT:TopologicalSpace XA:Set Xh:IsOpen A⊒ A βŠ† interior A X:TypeT:TopologicalSpace XA:Set Xh:IsOpen A⊒ interior A βŠ† A All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xh:IsOpen A⊒ A βŠ† interior A intro a X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Aa:Xha:a ∈ A⊒ a ∈ interior A X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Aa:Xha:a ∈ A⊒ A ∈ {t | IsOpen t ∧ t βŠ† A} ∧ a ∈ A X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Aa:Xha:a ∈ A⊒ A ∈ {t | IsOpen t ∧ t βŠ† A}X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Aa:Xha:a ∈ A⊒ a ∈ A X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Aa:Xha:a ∈ A⊒ A ∈ {t | IsOpen t ∧ t βŠ† A} X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Aa:Xha:a ∈ A⊒ IsOpen A All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xh:IsOpen Aa:Xha:a ∈ A⊒ a ∈ A All goals completed! πŸ™

∎

3.1.2.Β Closed setsπŸ”—

Definition 3.5 (Closed set)πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. We say that A is closed in X if A^c is open in X.

class IsClosed (s : Set X) : Prop where isOpen_compl : IsOpen sᢜ

Example 3.9πŸ”—

The universe is closed, because the empty set is open. The empty set is closed, because the universe is closed.

example (X : Type) [TopologicalSpace X] : IsClosed (Set.univ : Set X) := X:Typeinst✝:TopologicalSpace X⊒ IsClosed Set.univ X:Typeinst✝:TopologicalSpace X⊒ IsOpen Set.univᢜ X:Typeinst✝:TopologicalSpace X⊒ IsOpen βˆ… All goals completed! πŸ™

Example 3.10πŸ”—

The arbitrary intersection of closed sets is closed. The finite union of closed sets is closed. Both follow easily from the definition of topological space and closed set.

example (X : Type) [TopologicalSpace X] (A B : Set X) (hA : IsClosed A) (hB : IsClosed B) : IsClosed (A βˆͺ B) := X:Typeinst✝:TopologicalSpace XA:Set XB:Set XhA:IsClosed AhB:IsClosed B⊒ IsClosed (A βˆͺ B) X:Typeinst✝:TopologicalSpace XA:Set XB:Set XhA:IsOpen AᢜhB:IsOpen Bᢜ⊒ IsOpen (A βˆͺ B)ᢜ X:Typeinst✝:TopologicalSpace XA:Set XB:Set XhA:IsOpen AᢜhB:IsOpen Bᢜ⊒ IsOpen (Aᢜ ∩ Bᢜ) X:Typeinst✝:TopologicalSpace XA:Set XB:Set XhA:IsOpen AᢜhB:IsOpen Bᢜ⊒ TopologicalSpace.IsOpen AᢜX:Typeinst✝:TopologicalSpace XA:Set XB:Set XhA:IsOpen AᢜhB:IsOpen Bᢜ⊒ TopologicalSpace.IsOpen Bᢜ X:Typeinst✝:TopologicalSpace XA:Set XB:Set XhA:IsOpen AᢜhB:IsOpen Bᢜ⊒ TopologicalSpace.IsOpen Bᢜ All goals completed! πŸ™

Definition 3.6 (Closure)πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. We define the closure of A as the set \overline{A} = \bigcap \{K \subseteq X | K \text{ is closed and } A \subseteq K\}

def closure (s : Set X) : Set X := β‹‚β‚€ { t | IsClosed t ∧ s βŠ† t }

Let us look at some properties of the closure of a set.

Proposition 3.5πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. Then A \subseteq \overline{A}

In Mathlib, this result goes by the name subset_closure.

Proof. Let a \in A; we want to see that a \in \overline{A}. Since \overline{A} is an intersection, this is equivalent to proving that for each closed K with A \subseteq K, x \in K. But this is trivial because, for each of those K, x \in A \subseteq K.

example {X : Type} [T : TopologicalSpace X] (A : Set X) : A βŠ† closure A := X:TypeT:TopologicalSpace XA:Set X⊒ A βŠ† closure A Try this: intro x hx K hKintro x X:TypeT:TopologicalSpace XA:Set Xx:Xhx:x ∈ A⊒ x ∈ closure A intro K X:TypeT:TopologicalSpace XA:Set Xx:Xhx:x ∈ AK:Set XhK:K ∈ {t | IsClosed t ∧ A βŠ† t}⊒ x ∈ K X:TypeT:TopologicalSpace XA:Set Xx:Xhx:x ∈ AK:Set XhK:K ∈ {t | IsClosed t ∧ A βŠ† t}⊒ x ∈ A All goals completed! πŸ™

∎

Proposition 3.6πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. Then (\overline{A})^c = \overset{\circ}{\overbrace{(A^c)}}

In Mathlib, this result goes by the name interior_compl.

Proof. Let us see both inclusions separately.

example {X : Type} [T : TopologicalSpace X] (A : Set X) : (closure A)ᢜ = interior (Aᢜ) := X:TypeT:TopologicalSpace XA:Set X⊒ (closure A)ᢜ = interior Aᢜ X:TypeT:TopologicalSpace XA:Set Xx:X⊒ x ∈ (closure A)ᢜ ↔ x ∈ interior Aᢜ; X:TypeT:TopologicalSpace XA:Set Xx:X⊒ x ∈ (closure A)ᢜ β†’ x ∈ interior AᢜX:TypeT:TopologicalSpace XA:Set Xx:X⊒ x ∈ interior Aᢜ β†’ x ∈ (closure A)ᢜ; all_goals X:TypeT:TopologicalSpace XA:Set Xx:Xhx:x ∈ interior Aᢜ⊒ x ∈ (closure A)ᢜ

(\subseteq) Suppose that x \in (\overline{A})^c, that is, x \notin \overline{A}. This means that there exists a closed K such that A \subseteq K and x \notin K.

X:TypeT:TopologicalSpace XA:Set Xx:Xhx:x ∈ (closure A)ᢜ⊒ x ∈ interior Aᢜ X:TypeT:TopologicalSpace XA:Set Xx:Xhx:βˆƒ x_1, IsClosed x_1 ∧ A βŠ† x_1 ∧ x βˆ‰ x_1⊒ x ∈ interior Aᢜ X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ x ∈ interior Aᢜ

To see that x is in the interior of A^c, we want to see that there exists an open set contained in A^c that contains x. Consider the open set K^c. Since A \subseteq K, we have K^c \subseteq A^c, and since x \notin K, we have x \in K^c.

X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ Kᢜ ∈ {t | IsOpen t ∧ t βŠ† Aᢜ} ∧ x ∈ Kᢜ X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ Kᢜ ∈ {t | IsOpen t ∧ t βŠ† Aᢜ}X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ x ∈ Kᢜ X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ Kᢜ ∈ {t | IsOpen t ∧ t βŠ† Aᢜ} X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ IsOpen KᢜX:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ Kᢜ βŠ† Aᢜ X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ IsOpen Kᢜ All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ Kᢜ βŠ† Aᢜ All goals completed! πŸ™ X:TypeT:TopologicalSpace XA:Set Xx:XK:Set XhKclosed:IsClosed KhKA:A βŠ† KhKx:x βˆ‰ K⊒ x ∈ Kᢜ All goals completed! πŸ™

(\supseteq) Let x be in the interior of A^c. Then there exists an open U with x \in U \subseteq A^c. To see that x is in the complement of \overline{A}, suppose, for contradiction, that x \in \overline{A}.

X:TypeT:TopologicalSpace XA:Set Xx:Xhx:x ∈ interior Aᢜ⊒ x ∈ (closure A)ᢜ X:TypeT:TopologicalSpace XA:Set Xx:XU:Set XhU:U ∈ {t | IsOpen t ∧ t βŠ† Aᢜ}hUx:x ∈ U⊒ x ∈ (closure A)ᢜ X:TypeT:TopologicalSpace XA:Set Xx:XU:Set XhUx:x ∈ UhUopen:IsOpen UhUA:U βŠ† Aᢜ⊒ x ∈ (closure A)ᢜ X:TypeT:TopologicalSpace XA:Set Xx:XU:Set XhUx:x ∈ UhUopen:IsOpen UhUA:U βŠ† Aᢜhx:x βˆ‰ (closure A)ᢜ⊒ False

In that case, for each closed K with A \subseteq K, we have x \in K. In particular, since U^c is closed because U is open, and A \subseteq U^c because U \subseteq A^c, we have that x \in U^c. But x \in U, which is a contradiction.

X:TypeT:TopologicalSpace XA:Set Xx:XU:Set XhUx:x ∈ UhUopen:IsOpen UhUA:U βŠ† Aᢜhx:βˆ€ (t : Set X), IsClosed t β†’ A βŠ† t β†’ x ∈ t⊒ False specialize hx Uᢜ (X:TypeT:TopologicalSpace XA:Set Xx:XU:Set XhUx:x ∈ UhUopen:IsOpen UhUA:U βŠ† Aᢜhx:βˆ€ (t : Set X), IsClosed t β†’ A βŠ† t β†’ x ∈ t⊒ IsClosed Uᢜ All goals completed! πŸ™) (X:TypeT:TopologicalSpace XA:Set Xx:XU:Set XhUx:x ∈ UhUopen:IsOpen UhUA:U βŠ† Aᢜhx:βˆ€ (t : Set X), IsClosed t β†’ A βŠ† t β†’ x ∈ t⊒ A βŠ† Uᢜ All goals completed! πŸ™) All goals completed! πŸ™

∎

Proposition 3.7πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. Then \overline{A} is a closed set.

In Mathlib, this result goes by the name isClosed_closure.

Proof. The proof is easy using the previous result: \overline{A} is closed if (\overline{A})^c is open. But we have seen that (\overline{A})^c = (A^c)^\circ, and the interior of any set is open.

example {X : Type} [T : TopologicalSpace X] (A : Set X) : IsClosed (closure A) := X:TypeT:TopologicalSpace XA:Set X⊒ IsClosed (closure A) X:TypeT:TopologicalSpace XA:Set X⊒ IsOpen (closure A)ᢜ X:TypeT:TopologicalSpace XA:Set X⊒ IsOpen (interior Aᢜ) All goals completed! πŸ™

∎

Proposition 3.8πŸ”—

Let (X, \mathcal{T}) be a topological space and A \subseteq X. Then A is closed if and only if it is equal to its closure.

Proof. The converse is trivial, since we have already seen that the closure of a set is closed.

example {X : Type} [T : TopologicalSpace X] (A : Set X) : IsClosed A ↔ closure A = A := X:TypeT:TopologicalSpace XA:Set X⊒ IsClosed A ↔ closure A = A X:TypeT:TopologicalSpace XA:Set X⊒ IsClosed A β†’ closure A = AX:TypeT:TopologicalSpace XA:Set X⊒ closure A = A β†’ IsClosed A; X:TypeT:TopologicalSpace XA:Set X⊒ closure A = A β†’ IsClosed AX:TypeT:TopologicalSpace XA:Set X⊒ IsClosed A β†’ closure A = A; all_goals X:TypeT:TopologicalSpace XA:Set Xh:IsClosed A⊒ closure A = A X:TypeT:TopologicalSpace XA:Set Xh:closure A = A⊒ IsClosed A X:TypeT:TopologicalSpace XA:Set Xh:closure A = A⊒ IsClosed (closure A) All goals completed! πŸ™

Now, suppose that A is closed. Then A^c is open, hence it is equal to its interior. But we have seen that the interior of A^c is (\overline{A})^c, hence A^c = (\overline{A})^c, from which we deduce A = \overline{A}.

X:TypeT:TopologicalSpace XA:Set Xh:IsClosed A⊒ closure A = A X:TypeT:TopologicalSpace XA:Set Xh:(closure A)ᢜ = Aᢜ⊒ closure A = A X:TypeT:TopologicalSpace XA:Set Xh:(closure A)ᢜ = Aᢜ⊒ closure (closure A) = closure A All goals completed! πŸ™

∎