Lean library · module TopologyByExample.Theorems.ConnectedPolygonLimit

Limits of connected polygon refinements

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]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]

theorem exists_path_in_closure

TopologyByExample.LocallyConnectedPaths.exists_path_in_closure

Successively refined polygons converge to a path in the closure of the embedded open set.

theorem exists_path_in_closure {e : X → E} (he : Isometry e)
    {U : Set X} (hU : IsOpen U) (hUc : IsPreconnected U) {x y : X}
    (hx : x ∈ U) (hy : y ∈ U) :
    ∃ p : Path (e x) (e y), range p ⊆ closure (e '' U)
Proof
:= by
  classical
  let A (n : ℕ) := {p : Polygon X x y // p.Small dist ((1 / 2 : ℝ) ^ n) ∧ p.Within U}
  obtain ⟨p₀, hp₀, hp₀U⟩ := exists_small_polygon hU hUc (show (0 : ℝ) < 1 by norm_num) hx hy
  have step (n : ℕ) (p : A n) : ∃ q : A (n + 1),
      ∀ t, dist (Polygon.path e q.val t) (Polygon.path e p.val t) ≤ 2 * (1 / 2 : ℝ) ^ n := by
    obtain ⟨q, hq, hqin, hdist⟩ := exists_polygon_refinement he
      (show 0 < (1 / 2 : ℝ) ^ (n + 1) by positivity) p.val p.property.1
    exact ⟨⟨q, hq, hqin U p.property.2⟩, hdist⟩
  choose next hnext using step
  let p : (n : ℕ) → A n := Nat.rec ⟨p₀, by simpa using hp₀, hp₀U⟩ next
  let f : ℕ → C(unitInterval, E) := fun n ↦ (Polygon.path e (p n).val).toContinuousMap
  have hcauchy : CauchySeq f := by
    apply cauchySeq_of_le_geometric (1 / 2 : ℝ) 2 (by norm_num)
    intro n
    apply (ContinuousMap.dist_le (by positivity)).mpr
    intro t
    rw [dist_comm]
    exact hnext n (p n) t
  obtain ⟨g, hg⟩ := cauchySeq_tendsto_of_complete hcauchy
  have heval (t : unitInterval) : Tendsto (fun n ↦ f n t) atTop (𝓝 (g t)) :=
    ((continuous_eval_const t).tendsto g).comp hg
  have h0 : g 0 = e x := by
    have h : e x = g 0 := by simpa [f] using heval 0
    exact h.symm
  have h1 : g 1 = e y := by
    have h : e y = g 1 := by simpa [f] using heval 1
    exact h.symm
  refine ⟨{ toContinuousMap := g, source' := h0, target' := h1 }, ?_⟩
  rintro _ ⟨t, rfl⟩
  change g t ∈ closure (e '' U)
  apply Metric.mem_closure_iff.mpr
  intro ε hε
  have hpow : ∀ᶠ n : ℕ in atTop, (1 / 2 : ℝ) ^ n < ε / 2 :=
    (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : ℝ) ≤ 1 / 2)
      (by norm_num : (1 / 2 : ℝ) < 1)).eventually (gt_mem_nhds (half_pos hε))
  have hclose : ∀ᶠ n : ℕ in atTop, dist (f n t) (g t) < ε / 2 :=
    (tendsto_iff_dist_tendsto_zero.mp (heval t)).eventually (gt_mem_nhds (half_pos hε))
  obtain ⟨n, hn, hn'⟩ := (hpow.and hclose).exists
  obtain ⟨z, hz, hzd⟩ := polygon_near_vertex he (p n).val (p n).property.1 (p n).property.2 t
  refine ⟨e z, ⟨z, hz, rfl⟩, ?_⟩
  have hb : dist (g t) (e z) < ε := by
    have ht := dist_triangle (g t) (f n t) (e z)
    have hzd' : dist (f n t) (e z) ≤ (1 / 2 : ℝ) ^ n := hzd
    have hn'' : dist (g t) (f n t) < ε / 2 := by simpa only [dist_comm] using hn'
    linarith
  simpa [dist_comm] using hb