Lean library · module TopologyByExample.Theorems.PathLoopErasure

Closed domains for path loop erasure

Source file

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

Imports
variable {L X : Type*} [LinearOrder L]

definition EqualGapEnds

TopologyByExample.PathLoopErasure.EqualGapEnds

Endpoints of every gap in a domain have the same image.

def EqualGapEnds (f : L → X) (K : Set L) : Prop
:=
  ∀ a ∈ K, ∀ b ∈ K, a ≤ b → (∀ t ∈ K, a < t → t < b → False) → f a = f b

theorem equalGapEnds_univ

TopologyByExample.PathLoopErasure.equalGapEnds_univ

On a densely ordered domain, there are no nontrivial gaps in the whole space.

theorem equalGapEnds_univ [DenselyOrdered L] (f : L → X) : EqualGapEnds f univ
Proof
:= by
  intro a _ b _ hab hgap
  have he : a = b := le_antisymm hab (le_of_not_gt (by
    intro hab'
    obtain ⟨t, hat, htb⟩ := exists_between hab'
    exact hgap t (mem_univ t) hat htb))
  exact congrArg f he

theorem erase

TopologyByExample.PathLoopErasure.EqualGapEnds.erase

Deleting the interior of a loop preserves equality at gap endpoints.

theorem EqualGapEnds.erase {f : L → X} {K : Set L} (hK : EqualGapEnds f K)
    {a b : L} (ha : a ∈ K) (hb : b ∈ K) (hab : a ≤ b) (he : f a = f b) :
    EqualGapEnds f (K \ Ioo a b)
Proof
:= by
  intro u hu v hv huv hgap
  by_cases hua : u ≤ a
  · by_cases hva : v ≤ a
    · apply hK u hu.1 v hv.1 huv
      intro t ht hut htv
      exact hgap t ⟨ht, fun h ↦ (not_lt_of_ge (le_trans (le_of_lt htv) hva)) h.1⟩ hut htv
    · have hav : a < v := lt_of_not_ge hva
      have hbv : b ≤ v := le_of_not_gt (fun hvb ↦ hv.2 ⟨hav, hvb⟩)
      have huaeq : f u = f a := hK u hu.1 a ha hua (by
        intro t ht hut hta
        exact hgap t ⟨ht, fun h ↦ (not_lt_of_ge (le_of_lt hta)) h.1⟩ hut
          (lt_trans hta hav))
      have hbveq : f b = f v := hK b hb v hv.1 hbv (by
        intro t ht hbt htv
        exact hgap t ⟨ht, fun h ↦ (not_lt_of_ge (le_of_lt hbt)) h.2⟩
          (lt_of_le_of_lt (le_trans hua hab) hbt) htv)
      exact huaeq.trans (he.trans hbveq)
  · have hau : a < u := lt_of_not_ge hua
    have hbu : b ≤ u := le_of_not_gt (fun hub ↦ hu.2 ⟨hau, hub⟩)
    apply hK u hu.1 v hv.1 huv
    intro t ht hut htv
    exact hgap t ⟨ht, fun h ↦ (not_lt_of_ge (le_trans hbu (le_of_lt hut))) h.2⟩ hut htv

theorem exists_gap_around_interval

TopologyByExample.PathLoopErasure.exists_gap_around_interval

A missing closed interval in a compact domain lies between consecutive domain points.

theorem exists_gap_around_interval [TopologicalSpace L] [OrderClosedTopology L]
    {K : Set L} (hK : IsCompact K) {a b c d : L}
    (ha : a ∈ K) (hb : b ∈ K) (hac : a ≤ c) (_hcd : c < d) (hdb : d ≤ b)
    (hmiss : ∀ t ∈ K, c ≤ t → t ≤ d → False) :
    ∃ u ∈ K, ∃ v ∈ K, a ≤ u ∧ u ≤ c ∧ d ≤ v ∧ v ≤ b ∧
      ∀ t ∈ K, u < t → t < v → False
Proof
:= by
  obtain ⟨u, hu⟩ := (hK.inter_right isClosed_Icc).exists_isGreatest
    (show (K ∩ Icc a c).Nonempty from ⟨a, ha, le_rfl, hac⟩)
  obtain ⟨v, hv⟩ := (hK.inter_right isClosed_Icc).exists_isLeast
    (show (K ∩ Icc d b).Nonempty from ⟨b, hb, hdb, le_rfl⟩)
  refine ⟨u, hu.1.1, v, hv.1.1, hu.1.2.1, hu.1.2.2, hv.1.2.1, hv.1.2.2, ?_⟩
  intro t ht hut htv
  by_cases htc : t ≤ c
  · exact (not_lt_of_ge (hu.2 ⟨ht, le_trans hu.1.2.1 (le_of_lt hut), htc⟩)) hut
  by_cases hdt : d ≤ t
  · exact (not_lt_of_ge (hv.2 ⟨ht, hdt, le_trans (le_of_lt htv) hv.1.2.2⟩)) htv
  exact hmiss t ht (le_of_not_ge htc) (le_of_not_ge hdt)

theorem iInter

TopologyByExample.PathLoopErasure.EqualGapEnds.iInter

Descending intersections of closed domains preserve equality at gap endpoints.

theorem EqualGapEnds.iInter [TopologicalSpace L] [OrderTopology L]
    [CompactSpace L] [DenselyOrdered L] [TopologicalSpace X] [T2Space X]
    {ι : Type*} [Nonempty ι] {K : ι → Set L} {f : L → X}
    (hf : Continuous f) (hclosed : ∀ i, IsClosed (K i))
    (hdir : Directed (· ⊇ ·) K) (hgap : ∀ i, EqualGapEnds f (K i)) :
    EqualGapEnds f (⋂ i, K i)
Proof
:= by
  intro a ha b hb hab hnone
  by_contra hne
  have hab' : a < b := lt_of_le_of_ne hab (fun h ↦ hne (congrArg f h))
  obtain ⟨U, V, hU, hV, haU, hbV, hUV⟩ := t2_separation hne
  obtain ⟨m, ham, hmb⟩ := exists_between hab'
  obtain ⟨r, har, hUr⟩ := exists_Ico_subset_of_mem_nhds'
    ((hU.preimage hf).mem_nhds haU) ham
  obtain ⟨c, hac, hcr⟩ := exists_between har.1
  obtain ⟨l, hlb, hVl⟩ := exists_Ioc_subset_of_mem_nhds'
    ((hV.preimage hf).mem_nhds hbV) hmb
  obtain ⟨d, hld, hdb⟩ := exists_between hlb.2
  have hcd : c < d := lt_trans (lt_of_lt_of_le hcr har.2)
    (lt_of_le_of_lt hlb.1 hld)
  have hdis : Disjoint (Icc c d) (⋂ i, K i) := by
    rw [Set.disjoint_left]
    intro t ht htK
    exact hnone t htK (lt_of_lt_of_le hac ht.1) (lt_of_le_of_lt ht.2 hdb)
  obtain ⟨i, hi⟩ := isClosed_Icc.isCompact.elim_directed_family_closed K hclosed hdis hdir
  obtain ⟨u, hu, v, hv, hau, huc, hdv, hvb, huv⟩ :=
    exists_gap_around_interval (hclosed i).isCompact (mem_iInter.mp ha i)
      (mem_iInter.mp hb i) hac.le hcd hdb.le (by
        intro t ht hct htd
        exact Set.disjoint_left.mp hi ⟨hct, htd⟩ ht)
  have he : f u = f v := hgap i u hu v hv (le_trans huc (le_trans hcd.le hdv)) huv
  have huU : f u ∈ U := hUr ⟨hau, lt_of_le_of_lt huc hcr⟩
  have hvV : f v ∈ V := hVl ⟨lt_of_lt_of_le hld hdv, hvb⟩
  exact Set.disjoint_left.mp hUV huU (he ▸ hvV)

theorem exists_minimal_domain

TopologyByExample.PathLoopErasure.exists_minimal_domain

A continuous map on a compact densely ordered interval has a minimal closed domain containing both endpoints and preserving equality at gap endpoints.

theorem exists_minimal_domain [TopologicalSpace L] [OrderTopology L]
    [CompactSpace L] [DenselyOrdered L] [OrderBot L] [OrderTop L]
    [TopologicalSpace X] [T2Space X] {f : L → X} (hf : Continuous f) :
    ∃ K : Set L, IsClosed K ∧ ⊥ ∈ K ∧ ⊤ ∈ K ∧ EqualGapEnds f K ∧
      ∀ S ⊆ K, IsClosed S → ⊥ ∈ S → ⊤ ∈ S → EqualGapEnds f S → K ⊆ S
Proof
:= by
  let A := {K : Set L | IsClosed K ∧ ⊥ ∈ K ∧ ⊤ ∈ K ∧ EqualGapEnds f K}
  have hA : univ ∈ A := ⟨isClosed_univ, mem_univ _, mem_univ _, equalGapEnds_univ f⟩
  have hbound : ∀ C ⊆ A, IsChain (· ⊆ ·) C → C.Nonempty →
      ∃ S ∈ A, ∀ T ∈ C, S ⊆ T := by
    intro C hCA hchain hne
    let : Nonempty C := hne.to_subtype
    let F : C → Set L := fun s ↦ s.val
    have hcl : ∀ i, IsClosed (F i) := fun i ↦ (hCA i.property).1
    have hdir : Directed (· ⊇ ·) F := by
      intro i j
      rcases hchain.total i.property j.property with hij | hji
      · exact ⟨i, Subset.rfl, hij⟩
      · exact ⟨j, hji, Subset.rfl⟩
    refine ⟨⋂ i, F i, ⟨isClosed_iInter hcl, ?_, ?_, ?_⟩, ?_⟩
    · exact mem_iInter.mpr (fun i ↦ (hCA i.property).2.1)
    · exact mem_iInter.mpr (fun i ↦ (hCA i.property).2.2.1)
    · exact EqualGapEnds.iInter hf hcl hdir (fun i ↦ (hCA i.property).2.2.2)
    · intro S hS
      exact iInter_subset F ⟨S, hS⟩
  obtain ⟨K, _, hK⟩ := zorn_superset_nonempty A hbound univ hA
  exact ⟨K, hK.prop.1, hK.prop.2.1, hK.prop.2.2.1, hK.prop.2.2.2,
    fun S hSK hS hbot htop hgap ↦ hK.le_of_le ⟨hS, hbot, htop, hgap⟩ hSK⟩

theorem no_interior_of_minimal

TopologyByExample.PathLoopErasure.no_interior_of_minimal

A minimal closed gap-preserving domain has no interior point between equal images.

theorem no_interior_of_minimal [TopologicalSpace L] [OrderClosedTopology L]
    [OrderBot L] [OrderTop L]
    {f : L → X} {K : Set L} (hclosed : IsClosed K) (hK : EqualGapEnds f K)
    (hbot : ⊥ ∈ K) (htop : ⊤ ∈ K)
    (hminimal : ∀ S ⊆ K, IsClosed S → ⊥ ∈ S → ⊤ ∈ S → EqualGapEnds f S → K ⊆ S)
    {a b : L} (ha : a ∈ K) (hb : b ∈ K) (hab : a ≤ b) (he : f a = f b) :
    ∀ t ∈ K, a < t → t < b → False
Proof
:= by
  have hsub := hminimal (K \ Ioo a b) sdiff_subset
    (hclosed.sdiff isOpen_Ioo)
    ⟨hbot, fun h ↦ (not_lt_of_ge bot_le) h.1⟩
    ⟨htop, fun h ↦ (not_lt_of_ge le_top) h.2⟩ (hK.erase ha hb hab he)
  intro t ht hat htb
  exact (hsub ht).2 ⟨hat, htb⟩

theorem exists_reduced_domain

TopologyByExample.PathLoopErasure.exists_reduced_domain

A continuous map has a closed endpoint-retaining domain whose only repeated values occur across gaps.

theorem exists_reduced_domain [TopologicalSpace L] [OrderTopology L]
    [CompactSpace L] [DenselyOrdered L] [OrderBot L] [OrderTop L]
    [TopologicalSpace X] [T2Space X] {f : L → X} (hf : Continuous f) :
    ∃ K : Set L, IsClosed K ∧ ⊥ ∈ K ∧ ⊤ ∈ K ∧ EqualGapEnds f K ∧
      ∀ a ∈ K, ∀ b ∈ K, a ≤ b → f a = f b →
        ∀ t ∈ K, a < t → t < b → False
Proof
:= by
  obtain ⟨K, hcl, hbot, htop, hgap, hmin⟩ := exists_minimal_domain hf
  exact ⟨K, hcl, hbot, htop, hgap,
    fun _ ha _ hb hab he ↦ no_interior_of_minimal hcl hgap hbot htop hmin ha hb hab he⟩