Lean library · module TopologyByExample.Theorems.PlaneSeparation

Preparatory separation lemmas for the plane

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

theorem exists_continuous_binary_on_compact

TopologyByExample.PlaneSeparation.exists_continuous_binary_on_compact

Urysohn separation can be chosen binary on a compact totally disconnected set.

theorem exists_continuous_binary_on_compact {X : Type*} [TopologicalSpace X]
    [T2Space X] [NormalSpace X] {K A B : Set X}
    (hK : IsCompact K) (ht : IsTotallyDisconnected K)
    (hA : IsClosed A) (hB : IsClosed B) (hd : Disjoint A B) :
    ∃ f : C(X, ℝ), EqOn f 0 A ∧ EqOn f 1 B ∧
      (∀ x ∈ K, f x = 0 ∨ f x = 1) ∧ ∀ x, f x ∈ Icc (0 : ℝ) 1
Proof
:= by
  let : CompactSpace K := isCompact_iff_compactSpace.mp hK
  let : TotallyDisconnectedSpace K := totallyDisconnectedSpace_subtype_iff.mpr ht
  obtain ⟨C, hC, hAC, hCB⟩ := exists_clopen_of_closed_subset_open
    (hA.preimage (continuous_subtypeVal : Continuous ((↑) : K → X)))
    ((hB.preimage (continuous_subtypeVal : Continuous ((↑) : K → X))).isOpen_compl)
    (by
      intro x hxA hxB
      exact Set.disjoint_left.mp hd hxA hxB)
  have hC0 : IsClosed (((↑) : K → X) '' C) :=
    hK.isClosed.isClosedEmbedding_subtypeVal.isClosed_iff_image_isClosed.mp hC.isClosed
  have hC1 : IsClosed (((↑) : K → X) '' Cᶜ) :=
    hK.isClosed.isClosedEmbedding_subtypeVal.isClosed_iff_image_isClosed.mp hC.compl.isClosed
  have hdisj : Disjoint (A ∪ ((↑) : K → X) '' C)
      (B ∪ ((↑) : K → X) '' Cᶜ) := by
    apply Set.disjoint_left.mpr
    intro x hx hy
    rcases hx with hxA | ⟨y, hyC, rfl⟩
    · rcases hy with hxB | ⟨y, hyC, rfl⟩
      · exact Set.disjoint_left.mp hd hxA hxB
      · exact hyC (hAC hxA)
    · rcases hy with hyB | ⟨z, hzC, he⟩
      · exact hCB hyC hyB
      · have he' : z = y := Subtype.ext he
        exact hzC (he' ▸ hyC)
  obtain ⟨f, hfA, hfB, hf⟩ := exists_continuous_zero_one_of_isClosed
    (hA.union hC0) (hB.union hC1) hdisj
  refine ⟨f, fun x hx ↦ hfA (Or.inl hx), fun x hx ↦ hfB (Or.inl hx), ?_, hf⟩
  intro x hx
  by_cases hxc : (⟨x, hx⟩ : K) ∈ C
  · exact Or.inl (hfA (Or.inr ⟨⟨x, hx⟩, hxc, rfl⟩))
  · exact Or.inr (hfB (Or.inr ⟨⟨x, hx⟩, hxc, rfl⟩))

theorem exists_continuous_nonzero_on_compact

TopologyByExample.PlaneSeparation.exists_continuous_nonzero_on_compact

Two closed sets can be separated by signs without a zero on a compact totally disconnected set.

theorem exists_continuous_nonzero_on_compact {X : Type*} [TopologicalSpace X]
    [T2Space X] [NormalSpace X] {K A B : Set X}
    (hK : IsCompact K) (ht : IsTotallyDisconnected K)
    (hA : IsClosed A) (hB : IsClosed B) (hd : Disjoint A B) :
    ∃ g : C(X, ℝ), EqOn g (fun _ ↦ -1) A ∧ EqOn g 1 B ∧
      ∀ x ∈ K, g x ≠ 0
Proof
:= by
  obtain ⟨f, hfA, hfB, hfK, _⟩ := exists_continuous_binary_on_compact hK ht hA hB hd
  let g : C(X, ℝ) := ⟨fun x ↦ 2 * f x - 1, by fun_prop⟩
  refine ⟨g, ?_, ?_, ?_⟩
  · intro x hx
    change 2 * f x - 1 = -1
    rw [hfA hx]
    norm_num
  · intro x hx
    change 2 * f x - 1 = 1
    rw [hfB hx]
    norm_num
  · intro x hx
    change 2 * f x - 1 ≠ 0
    rcases hfK x hx with h | h <;> rw [h] <;> norm_num

theorem exists_signed_separator

TopologyByExample.PlaneSeparation.exists_signed_separator

Disjoint nonempty open sets admit a continuous signed separator whose zero set is exactly the complement of their union.

theorem exists_signed_separator {X : Type*} [MetricSpace X] {U V : Set X}
    (hU : IsOpen U) (hV : IsOpen V) (hUn : U.Nonempty) (hVn : V.Nonempty)
    (hd : Disjoint U V) :
    ∃ f : C(X, ℝ), (∀ x ∈ U, 0 < f x) ∧ (∀ x ∈ V, f x < 0) ∧
      ∀ x, f x = 0 ↔ x ∉ U ∪ V
Proof
:= by
  have hUc : Uᶜ.Nonempty := by
    obtain ⟨x, hx⟩ := hVn
    exact ⟨x, fun hxU ↦ Set.disjoint_left.mp hd hxU hx⟩
  have hVc : Vᶜ.Nonempty := by
    obtain ⟨x, hx⟩ := hUn
    exact ⟨x, fun hxV ↦ Set.disjoint_left.mp hd hx hxV⟩
  let f : C(X, ℝ) := ⟨fun x ↦ Metric.infDist x Uᶜ - Metric.infDist x Vᶜ,
    (Metric.continuous_infDist_pt Uᶜ).sub (Metric.continuous_infDist_pt Vᶜ)⟩
  have hp : ∀ x ∈ U, 0 < f x := by
    intro x hx
    have hp := (hU.isClosed_compl.notMem_iff_infDist_pos hUc).mp (by simpa using hx)
    have hz := Metric.infDist_zero_of_mem
      (show x ∈ Vᶜ from fun hxV ↦ Set.disjoint_left.mp hd hx hxV)
    change 0 < Metric.infDist x Uᶜ - Metric.infDist x Vᶜ
    rwa [hz, sub_zero]
  have hn : ∀ x ∈ V, f x < 0 := by
    intro x hx
    have hp := (hV.isClosed_compl.notMem_iff_infDist_pos hVc).mp (by simpa using hx)
    have hz := Metric.infDist_zero_of_mem
      (show x ∈ Uᶜ from fun hxU ↦ Set.disjoint_left.mp hd hxU hx)
    change Metric.infDist x Uᶜ - Metric.infDist x Vᶜ < 0
    rw [hz]
    linarith
  refine ⟨f, hp, hn, fun x ↦ ⟨?_, ?_⟩⟩
  · intro he hx
    rcases hx with hx | hx
    · have := hp x hx
      linarith
    · have := hn x hx
      linarith
  · intro hx
    change Metric.infDist x Uᶜ - Metric.infDist x Vᶜ = 0
    rw [Metric.infDist_zero_of_mem (show x ∈ Uᶜ from fun h ↦ hx (Or.inl h)),
      Metric.infDist_zero_of_mem (show x ∈ Vᶜ from fun h ↦ hx (Or.inr h)), sub_self]