1-- Examples and constructions: the discrete and indiscrete topologies, the2-- subspace topology, and the Hausdorff separation property3-- Part of Cumulus, the Grace17 mathematics library.4-- Copyright (c) 2026 Grant Passmore.5-- Released under the Apache License 2.0. See LICENSE in the repository root.6-- Authors: Grant Passmore78module Grace.Cumulus.Topology.Subspace9import Compact1011theorem discreteTopology (X : Set)12shows IsTopology(X, 𝒫(X))13proof14constructor15 . exact Subset.reflexive at𝒫(X)16 . constructor17 . exact powerset.membership_iff.backward with (Subset.reflexive at X)18 . constructor19 . intros S hS20apply powerset.membership_iff.backward21apply union.subset22intros U hU23exact powerset.membership_iff.forward with (hS with U, hU)24 . intros U hU V hV25apply powerset.membership_iff.backward26have inside := powerset.membership_iff.forward with hU27exact Subset.transitive with (intersection.subset_left at U, V), inside2829theorem indiscreteTopology (X : Set)30shows IsTopology(X, {∅, X})31proof32constructor33 . intros U hU34havesplit:= pair.membership.forward with hU35apply powerset.membership_iff.backward36casessplitwith isEmpty | isWhole37 . rw isEmpty38exact empty.subset39 . rw isWhole40exact Subset.reflexive41 . constructor42 . apply pair.membership.backward43right44rfl45 . constructor46 . intros S hS47havesplit : X ∈ S ∨¬X ∈ S bytauto48casessplitwith inside | outside49 . have equal : ⋃(S) = X50apply Subset.antisymmetric51 . apply union.subset52intros U hU53havecases:= pair.membership.forward with (hS with U, hU)54casescaseswith isEmpty | isWhole55 . rw isEmpty56exact empty.subset57 . rw isWhole58exact Subset.reflexive59 . exact union.subset_of_member with inside60rw equal61apply pair.membership.backward62right63rfl64 . have equal : ⋃(S) =∅65apply Subset.antisymmetric66 . apply union.subset67intros U hU68havecases:= pair.membership.forward with (hS with U, hU)69casescaseswith isEmpty | isWhole70 . rw isEmpty71exact Subset.reflexive72 . exfalso73rw isWhole at hU74exact outside with hU75 . exact empty.subset at⋃(S)76rw equal77apply pair.membership.backward78left79rfl80 . intros U hU V hV81have splitU := pair.membership.forward with hU82cases splitU with emptyU | wholeU83 . rw [emptyU, intersection.left_empty]84apply pair.membership.backward85left86rfl87 . have splitV := pair.membership.forward with hV88cases splitV with emptyV | wholeV89 . rw [emptyV, intersection.right_empty]90apply pair.membership.backward91left92rfl93 . rw [wholeU, wholeV, intersection.idempotent]94apply pair.membership.backward95right96rfl9798-- The subspace topology on A ⊆ X: traces of the open sets of X.99def subspaceTopology (T A : Set) : Set:= { U ∩ A | U ∈ T }100def tracedBy (T A S : Set) : Set:= { U ∈ T | U ∩ A ∈ S }101102theorem subspaceTopology.topology (X T A : Set)103requires topology : IsTopology(X, T)104requires hA : A ⊆ X105shows IsTopology(A, subspaceTopology(T, A))106proof107constructor108 . intros V hV109obtain⟨U, hU, shape⟩:= subspaceTopology.membership.forward with hV110apply powerset.membership_iff.backward111rw← shape112exact intersection.subset_right113 . constructor114 . apply subspaceTopology.membership.backward115refine⟨X, (IsTopology.whole with topology), ?_⟩116exact intersection.eq_right_of_subset with hA117 . constructor118 . intros S hS119have tracedOpen : tracedBy(T, A, S) ⊆ T120intros U hU121have parts := tracedBy.membership.forward with hU122exact parts.left123have isOpen := IsTopology.union with topology, tracedOpen124apply subspaceTopology.membership.backward125refine⟨⋃(tracedBy(T, A, S)), isOpen, ?_⟩126ext x127constructor128 . intro hx129have parts := intersection.membership.forward with hx130obtain⟨U, hU, hxU⟩:= union.membership.forward with parts.left131have traced := tracedBy.membership.forward with hU132have inTrace : x ∈ U ∩ A := intersection.membership.backward with⟨hxU, parts.right⟩133exact union.contains with traced.right, inTrace134 . intro hx135obtain⟨V, hV, hxV⟩:= union.membership.forward with hx136obtain⟨U, hU, shape⟩:= subspaceTopology.membership.forward with (hS with V, hV)137rw← shape at hxV138have parts := intersection.membership.forward with hxV139have traced : U ∈ tracedBy(T, A, S)140apply tracedBy.membership.backward141rw shape142exact⟨hU, hV⟩143apply intersection.membership.backward144exact⟨(union.contains with traced, parts.left), parts.right⟩145 . intros V hV W hW146obtain⟨U, hU, shapeV⟩:= subspaceTopology.membership.forward with hV147obtain⟨U2, hU2, shapeW⟩:= subspaceTopology.membership.forward with hW148apply subspaceTopology.membership.backward149refine⟨U ∩ U2, (IsTopology.intersection2 with topology, hU, hU2), ?_⟩150rw [← shapeV, ← shapeW]151ext x152simp [intersection.membership]153154-- Hausdorff spaces: distinct points have disjoint open neighbourhoods.155predicate IsHausdorff (X T : Set) :=156∀ x ∈ X, ∀ y ∈ X, x ≠ y →∃ U ∈ T, ∃ V ∈ T, x ∈ U ∧ y ∈ V ∧ Disjoint(U, V)157158theorem IsHausdorff.discrete (X : Set)159shows IsHausdorff(X, 𝒫(X))160proof161intros x hx y hy distinct162have singletonX : {x} ⊆ X163intros z hz164have same := singleton.membership.forward with hz165 rwa same166have singletonY : {y} ⊆ X167intros z hz168have same := singleton.membership.forward with hz169 rwa same170refine⟨{x}, (powerset.membership_iff.backward with singletonX), {y}, (powerset.membership_iff.backward with singletonY), ?_, ?_, ?_⟩171 . simp [singleton.membership]172 . simp [singleton.membership]173 . apply Disjoint.iff.backward174intros z hz hz2175have sameX := singleton.membership.forward with hz176have sameY := singleton.membership.forward with hz2177apply distinct178rw [← sameX, ← sameY]179rfl180181def awayFrom (T x : Set) : Set:= { V ∈ T |¬x ∈ V }182183-- In a Hausdorff space every point is closed.184theorem IsHausdorff.singleton_closed (X T x : Set)185requires topology : IsTopology(X, T)186requires hausdorff : IsHausdorff(X, T)187requires hx : x ∈ X188shows IsClosed(X, T, {x})189proof190constructor191 . intros z hz192have same := singleton.membership.forward with hz193 rwa same194 . have awayOpen : awayFrom(T, x) ⊆ T195intros V hV196have parts := awayFrom.membership.forward with hV197exact parts.left198have isOpen := IsTopology.union with topology, awayOpen199have equal : complement(X, {x}) =⋃(awayFrom(T, x))200ext y201constructor202 . intro hy203have parts := complement.membership.forward with hy204have distinct : x ≠ y205intro same206apply parts.right207rw← same208simp [singleton.membership]209obtain⟨U, hU, V, hV, hxU, hyV, disjoint⟩:= hausdorff with x, hx, y, parts.left, distinct210have separated := Disjoint.iff.forward with disjoint211have away : V ∈ awayFrom(T, x)212apply awayFrom.membership.backward213refine⟨hV, ?_⟩214intro hxV215exact separated with x, hxU, hxV216exact union.contains with away, hyV217 . intro hy218obtain⟨V, hV, hyV⟩:= union.membership.forward with hy219have parts := awayFrom.membership.forward with hV220have inside := IsTopology.subset with topology, parts.left221have hyX := inside with y, hyV222apply complement.membership.backward223refine⟨hyX, ?_⟩224intro same225have equalXY := singleton.membership.forward with same226apply parts.right227 rwa ← equalXY228 rwa equal229