File size: 8,344 Bytes
8e4d533
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import Mathlib
import OAI.Geometry.Cannon.Energy.Square

namespace OAI

section
section
section
noncomputable section
section
section
section
section
section
open Set Topology
open Set Metric Topology
open Set Topology Filter Metric unitInterval
open scoped InnerProductSpace
open Set unitInterval

namespace CannonChart

variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]

def liftPath (e : X → Y) (he : IsEmbedding e) {a b : X}
    (p : Path (e a) (e b)) (hp : ∀ t, p t ∈ range e) : Path a b where
  toFun := fun t => he.toHomeomorph.symm ⟨p t,hp t⟩
  continuous_toFun := he.toHomeomorph.symm.continuous.comp (p.continuous.subtype_mk hp)
  source' := by
    apply he.toHomeomorph.injective
    simp
  target' := by
    apply he.toHomeomorph.injective
    simp

lemma liftPath_apply (e : X → Y) (he : IsEmbedding e) {a b : X}
    (p : Path (e a) (e b)) (hp : ∀ t, p t ∈ range e) (t : unitInterval) :
    e (liftPath e he p hp t) = p t := by
  have hh := he.toHomeomorph.apply_symm_apply ⟨p t,hp t⟩
  exact congrArg Subtype.val hh

lemma lift_joinedIn (e : X → Y) (he : IsEmbedding e) {a b : X} {S : Set Y}
    (hS : S ⊆ range e) (hp : JoinedIn S (e a) (e b)) :
    JoinedIn (e ⁻¹' S) a b := by
  obtain ⟨p,hp⟩ := hp
  let hpr : ∀ t, p t ∈ range e := fun t => hS (hp t)
  refine ⟨liftPath e he p hpr,fun t => ?_⟩
  change e (liftPath e he p hpr t) ∈ S
  rw [liftPath_apply e he p hpr]
  exact hp t

end CannonChart

namespace CannonLevel

open CannonPlanar CannonRegularization

instance : PathConnectedSpace Square :=
  pathConnectedSpace_iff_connectedSpace.mpr inferInstance

theorem regularized_values {f : Square → ℝ} {A B : Set Square}
    (hA : A.Nonempty) (hB : B.Nonempty)
    (hf0 : ∀ z, 0 ≤ f z) (hf1 : ∀ z, f z ≤ 1)
    (hAf : ∀ z ∈ A, f z = 0) (hBf : ∀ z ∈ B, f z = 1) :
    (∀ z, drain (flood f A) B z ∈ Icc (0 : ℝ) 1) ∧
    (∀ z ∈ A, drain (flood f A) B z = 0) ∧
    (∀ z ∈ B, drain (flood f A) B z = 1) := by
  have hF0 : ∀ z, 0 ≤ flood f A z := fun z => (hf0 z).trans (le_flood hA hf1 z)
  have hF1 := flood_le_upper hA hf1
  have hH0 := drain_lower hB hF0
  have hHF := drain_le hB hF0
  refine ⟨fun z => ⟨hH0 z, (hHF z).trans (hF1 z)⟩, ?_, ?_⟩
  · intro z hz
    apply le_antisymm _ (hH0 z)
    simpa [flood_eq_on_band hA hf1 hz, hAf z hz] using hHF z
  · intro z hz
    rw [drain_eq_on_band hB hF0 hz]
    apply le_antisymm (hF1 z)
    simpa [hBf z hz] using le_flood hA hf1 z

theorem separating_level {f : Square → ℝ} {A B : Set Square}
    (hA : IsPathConnected A) (hB : IsPathConnected B)
    (hAedge : ∀ s, (s,0) ∈ A) (hBedge : ∀ s, (s,1) ∈ B)
    (hf : Continuous f) (hf0 : ∀ z, 0 ≤ f z) (hf1 : ∀ z, f z ≤ 1)
    (hAf : ∀ z ∈ A, f z = 0) (hBf : ∀ z ∈ B, f z = 1)
    {t : ℝ} (ht0 : 0 < t) (ht1 : t < 1) :
    let H := drain (flood f A) B
    ∃ C : Set Square, IsCompact C ∧ IsConnected C ∧
      (∀ z ∈ C, H z = t) ∧ (∃ z ∈ C, z.1 = 0) ∧ (∃ z ∈ C, z.1 = 1) ∧
      (∀ {x y : Square} (p : Path x y), H x < t → t < H y →
        ∃ s, p s ∈ C) := by
  let F := flood f A
  let H := drain F B
  have hF0 : ∀ z, 0 ≤ F z := fun z => (hf0 z).trans (le_flood hA.nonempty hf1 z)
  have hFc : Continuous F := continuous_flood hA.nonempty hf hf1
  have hHc : Continuous H := continuous_drain hB.nonempty hFc hF0
  obtain ⟨hHr,hHA,hHB⟩ := regularized_values hA.nonempty hB.nonempty hf0 hf1 hAf hBf
  obtain ⟨C,hCc,hCn,hCH,⟨a,ha,ha0⟩,⟨b,hb,hb1⟩⟩ := level_continuum hHc
    (c := t) (fun s => by rw [show H (s,0) = 0 from hHA _ (hAedge s)]; exact ht0.le)
    (fun s => by rw [show H (s,1) = 1 from hHB _ (hBedge s)]; exact ht1.le)
  refine ⟨C,hCc,hCn,hCH,⟨a,ha,ha0⟩,⟨b,hb,hb1⟩,?_⟩
  intro x y p hx hy
  obtain ⟨u,hu,lo,hlo⟩ := regularized_low_side hA.nonempty hB.nonempty hf hf0 hf1 hAf ht0 hx
  obtain ⟨v,hv,hi,hhi⟩ := drain_strict_side hB.nonempty hF0 hy
  obtain ⟨qa,hqa⟩ := hA.joinedIn u hu (0,0) (hAedge 0)
  obtain ⟨qb,hqb⟩ := hB.joinedIn v hv (0,1) (hBedge 0)
  let low : Path x (0,0) := lo.trans qa
  let high : Path y (0,1) := hi.trans qb
  have hlow : ∀ s, H (low s) < t := by
    intro s
    have hs : low s ∈ range lo ∪ range qa := by rw [← Path.trans_range]; exact mem_range_self s
    rcases hs with ⟨r,hr⟩ | ⟨r,hr⟩
    · rw [← hr]; exact hlo r
    · rw [← hr, show H (qa r) = 0 from hHA _ (hqa r)]; exact ht0
  have hhigh : ∀ s, t < H (high s) := by
    intro s
    have hs : high s ∈ range hi ∪ range qb := by rw [← Path.trans_range]; exact mem_range_self s
    rcases hs with ⟨r,hr⟩ | ⟨r,hr⟩
    · rw [← hr]; exact hhi r
    · rw [← hr, show H (qb r) = 1 from hHB _ (hqb r)]; exact ht1
  let q := high.symm.trans (p.symm.trans low)
  obtain ⟨s,hs⟩ := continuum_crosses_path hCn.isPreconnected ha hb ha0 hb1 q.continuous
    (by simp [q]) (by simp [q])
  have hqs : q s ∈ range high.symm ∪ (range p.symm ∪ range low) := by
    rw [← Path.trans_range, ← Path.trans_range]
    exact mem_range_self s
  rcases hqs with ⟨r,hr⟩ | ⟨r,hr⟩ | ⟨r,hr⟩
  · have ht := hhigh (unitInterval.symm r)
    have he := hCH _ hs
    change H (high.symm r) > t at ht
    rw [hr,he] at ht
    exact False.elim (lt_irrefl _ ht)
  · exact ⟨unitInterval.symm r, hr.symm ▸ hs⟩
  · have ht := hlow r
    rw [hr,hCH _ hs] at ht
    exact False.elim (lt_irrefl _ ht)

lemma slab_pathConnected {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1) :
    IsPathConnected {z : Square | a ≤ (z.2 : ℝ) ∧ (z.2 : ℝ) ≤ b} := by
  let e : Square → ℝ × ℝ := Prod.map Subtype.val Subtype.val
  have he : Topology.IsInducing e := Topology.IsInducing.subtypeVal.prodMap
    Topology.IsInducing.subtypeVal
  rw [he.isPathConnected_iff]
  have himage : e '' {z : Square | a ≤ (z.2 : ℝ) ∧ (z.2 : ℝ) ≤ b} =
      Icc ((0 : ℝ),a) (1,b) := by
    ext z
    constructor
    · rintro ⟨w,hw,rfl⟩
      exact ⟨⟨w.1.property.1,hw.1⟩,⟨w.1.property.2,hw.2⟩⟩
    · intro hz
      refine ⟨(⟨z.1,hz.1.1,hz.2.1⟩,⟨z.2,ha.trans hz.1.2,hz.2.2.trans hb⟩), ?_, rfl⟩
      exact ⟨hz.1.2,hz.2.2⟩
  rw [himage]
  exact (convex_Icc _ _).isPathConnected ⟨(0,a),⟨le_rfl,⟨zero_le_one,hab⟩⟩⟩

def topBand : Set Square := {z | (z.2 : ℝ) ≤ 1 / 3}

def bottomBand : Set Square := {z | 2 / 3 ≤ (z.2 : ℝ)}

def centralRectangle : Set Square := {z | (z.2 : ℝ) ∈ Icc (1 / 3) (2 / 3)}

lemma topBand_pathConnected : IsPathConnected topBand := by
  convert slab_pathConnected (a := 0) (b := 1 / 3) (by norm_num) (by norm_num) (by norm_num) using 1
  ext z
  exact ⟨fun hz => ⟨z.2.property.1,hz⟩,fun hz => hz.2⟩

lemma bottomBand_pathConnected : IsPathConnected bottomBand := by
  convert slab_pathConnected (a := 2 / 3) (b := 1) (by norm_num) (by norm_num) (by norm_num) using 1
  ext z
  exact ⟨fun hz => ⟨hz,z.2.property.2⟩,fun hz => hz.1⟩

theorem rectangle_separating_level {f : Square → ℝ}
    (hf : Continuous f) (hf0 : ∀ z, 0 ≤ f z) (hf1 : ∀ z, f z ≤ 1)
    (hAf : ∀ z ∈ topBand, f z = 0) (hBf : ∀ z ∈ bottomBand, f z = 1)
    {t : ℝ} (ht0 : 0 < t) (ht1 : t < 1) :
    let H := drain (flood f topBand) bottomBand
    ∃ C : Set Square, IsCompact C ∧ IsConnected C ∧ C ⊆ centralRectangle ∧
      (∀ z ∈ C, H z = t) ∧ (∃ z ∈ C, z.1 = 0) ∧ (∃ z ∈ C, z.1 = 1) ∧
      (∀ {x y : Square} (p : Path x y), H x < t → t < H y → ∃ s, p s ∈ C) := by
  obtain ⟨C,hCc,hCn,hCH,hCl,hCr,hCs⟩ := separating_level topBand_pathConnected bottomBand_pathConnected
    (by intro s; change (0 : ℝ) ≤ 1 / 3; norm_num)
    (by intro s; change (2 : ℝ) / 3 ≤ 1; norm_num)
    hf hf0 hf1 hAf hBf ht0 ht1
  refine ⟨C,hCc,hCn,?_,hCH,hCl,hCr,hCs⟩
  obtain ⟨_,hHA,hHB⟩ := regularized_values topBand_pathConnected.nonempty
    bottomBand_pathConnected.nonempty hf0 hf1 hAf hBf
  intro z hz
  constructor
  · by_contra h
    have he := hHA z (show z ∈ topBand from (lt_of_not_ge h).le)
    rw [hCH z hz] at he
    exact (ne_of_gt ht0) he
  · by_contra h
    have he := hHB z (show z ∈ bottomBand from (lt_of_not_ge h).le)
    rw [hCH z hz] at he
    exact (ne_of_lt ht1) he

end CannonLevel

end
end
end
end
end
end
end
end
end

end OAI