Lean library · module TopologyByExample.Theorems.LocallyConnectedPaths

Small connected chains in locally connected metric spaces

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 {X : Type*} [MetricSpace X] [LocallyConnectedSpace X]

theorem exists_small_neighbourhood

TopologyByExample.LocallyConnectedPaths.exists_small_neighbourhood

Local connectedness supplies connected neighbourhoods of small diameter.

theorem exists_small_neighbourhood (x : X) {ε : ℝ} (hε : 0 < ε) :
    ∃ V : Set X, IsOpen V ∧ IsConnected V ∧ x ∈ V ∧
      ∀ u ∈ V, ∀ v ∈ V, dist u v < ε
Proof
:= by
  obtain ⟨V, ⟨hVo, hxV, hVc⟩, hV⟩ :=
    (LocallyConnectedSpace.open_connected_basis x).mem_iff.mp
      (ball_mem_nhds x (half_pos hε))
  refine ⟨V, hVo, hVc, hxV, fun u hu v hv ↦ ?_⟩
  have hu' : dist u x < ε / 2 := hV hu
  have hv' : dist v x < ε / 2 := hV hv
  calc
    dist u v ≤ dist u x + dist x v := dist_triangle _ _ _
    _ < ε := by rw [dist_comm x v]; linarith

definition SmallLinkWithin

TopologyByExample.LocallyConnectedPaths.SmallLinkWithin

A small link whose witnessing neighbourhood lies in a prescribed set.

def SmallLinkWithin (ε : ℝ) (U : Set X) (x y : X) : Prop
:=
  ∃ V : Set X, V ⊆ U ∧ IsOpen V ∧ IsConnected V ∧ x ∈ V ∧ y ∈ V ∧
    ∀ u ∈ V, ∀ v ∈ V, dist u v < ε

theorem finite_chain

TopologyByExample.LocallyConnectedPaths.finite_chain

A reflexive transitive relation witness gives a finite sequence of links.

theorem finite_chain {α : Type*} {r : α → α → Prop} {a b : α}
    (h : Relation.ReflTransGen r a b) :
    ∃ n : ℕ, ∃ f : ℕ → α, f 0 = a ∧ f n = b ∧ ∀ i < n, r (f i) (f (i + 1))
Proof
:= by
  classical
  induction h with
  | refl => exact ⟨0, fun _ ↦ a, rfl, rfl, fun i hi ↦ (Nat.not_lt_zero i hi).elim⟩
  | @tail b c hab hbc ih =>
    obtain ⟨n, f, hf0, hfn, hf⟩ := ih
    refine ⟨n + 1, Function.update f (n + 1) c, ?_, by simp, fun i hi ↦ ?_⟩
    · simpa using hf0
    · by_cases hin : i = n
      · subst i
        simpa [Function.update_of_ne (show n ≠ n + 1 by omega), hfn] using hbc
      · have hil : i < n := by omega
        simpa [Function.update_of_ne (show i ≠ n + 1 by omega),
          Function.update_of_ne (show i + 1 ≠ n + 1 by omega)] using hf i hil

theorem finite_small_chain_within

TopologyByExample.LocallyConnectedPaths.finite_small_chain_within

A connected open set admits finite refinements by small connected open sets.

theorem finite_small_chain_within {U : Set X} (hU : IsOpen U) (hUc : IsPreconnected U)
    {ε : ℝ} (hε : 0 < ε) {x y : X} (hx : x ∈ U) (hy : y ∈ U) :
    ∃ n : ℕ, ∃ f : ℕ → X, f 0 = x ∧ f n = y ∧
      ∀ i < n, SmallLinkWithin ε U (f i) (f (i + 1))
Proof
:=
  finite_chain (smallLink_chain_within hU hUc hε hx hy)