File size: 12,300 Bytes
785c727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
import OAI.Geometry.CylinderCovering.Caps.FiniteDefinitions
import OAI.Geometry.CylinderCovering.Footprints.Shapes
import OAI.Geometry.CylinderCovering.Radial.Riemann

namespace OAI

open Set
open scoped InnerProductSpace
noncomputable section
namespace CylinderCovering.HalfheightFinite.Shape

lemma height_pos : 0 < height := by unfold height; positivity

lemma foot_eq_affine (δ : ℝ) (R : ℝ → ℝ) (N : ℕ) (i : Fin N) :
    foot δ R N i = Footprints.affineFootprint (midpoint N i) (maxCap R N i)
      (2 * halfwidth N) (δ / 4) (δ / 4) := by
  ext p
  simp only [foot, RadialFootprints.halfheightFootprint,
    Footprints.affineFootprint, mem_ofPred_eq, mem_Icc, collar]
  have h₁ : -(δ * halfwidth N / 2) = -(δ / 4) * (2 * halfwidth N) := by ring
  have h₂ : δ * halfwidth N / 2 = δ / 4 * (2 * halfwidth N) := by ring
  have h₃ : halfwidth N * (p.1 + 2 * (δ * halfwidth N / 2)) =
      2 * halfwidth N / 2 * p.1 + δ / 4 * (2 * halfwidth N)^2 := by ring
  rw [h₃, h₁, h₂]
  tauto

def firstFootLinear : (ℝ × ℝ) →ₗ[ℝ] Space where
  toFun := firstFoot
  map_add' p q := by ext i; fin_cases i <;> simp [firstFoot] <;> ring
  map_smul' c p := by ext i; fin_cases i <;> simp [firstFoot] <;> ring

def secondFootLinear : (ℝ × ℝ) →ₗ[ℝ] Space where
  toFun p := !₂[p.2/2,0,-height*p.1]
  map_add' p q := by ext i; fin_cases i <;> simp <;> ring
  map_smul' c p := by ext i; fin_cases i <;> simp <;> ring

def secondFootAffine : (ℝ × ℝ) →ᵃ[ℝ] Space where
  toFun := secondFoot
  linear := secondFootLinear
  map_vadd' p q := by
    ext i
    fin_cases i <;> simp [secondFoot, secondFootLinear] <;> ring

def projectionLinear (u : Space) : Space →ₗ[ℝ] Space :=
  LinearMap.id - (innerₛₗ ℝ u).smulRight u

lemma projectionLinear_apply (u z : Space) :
    projectionLinear u z = TriangularCovering.projection u z := rfl

def firstProjectedAffine (δ r : ℝ) : (ℝ × ℝ) →ᵃ[ℝ] Space :=
  (projectionLinear (firstAxis δ r)).toAffineMap.comp firstFootLinear.toAffineMap

def secondProjectedAffine (δ r : ℝ) : (ℝ × ℝ) →ᵃ[ℝ] Space :=
  (projectionLinear (secondAxis δ r)).toAffineMap.comp secondFootAffine

lemma firstRaw_ne_zero (δ r : ℝ) : firstRaw δ r ≠ 0 := by
  intro h
  have h₀ := congrArg (fun z : Space => z 0) h
  norm_num [firstRaw] at h₀

lemma secondRaw_ne_zero (δ r : ℝ) : secondRaw δ r ≠ 0 := by
  intro h
  have h₁ := congrArg (fun z : Space => z 1) h
  norm_num [secondRaw] at h₁

lemma firstAxis_zero_ne (δ r : ℝ) : firstAxis δ r 0 ≠ 0 := by
  simp [firstAxis, firstRaw]

lemma secondAxis_one_ne (δ r : ℝ) : secondAxis δ r 1 ≠ 0 := by
  simp [secondAxis, secondRaw]

lemma projection_injective_on_coordinate_plane {u p q : Space} {i : Fin 3}
    (hu : u i ≠ 0) (hp : p i = 0) (hq : q i = 0)
    (heq : TriangularCovering.projection u p = TriangularCovering.projection u q) : p = q := by
  have hi := congrArg (fun z : Space => z i) heq
  simp only [TriangularCovering.projection, PiLp.sub_apply, PiLp.smul_apply,
    smul_eq_mul, hp, hq, zero_sub] at hi
  have hin : inner ℝ u p = inner ℝ u q := mul_right_cancel₀ hu (neg_inj.mp hi)
  simpa only [TriangularCovering.projection, hin, sub_left_inj] using heq

lemma firstProjectedAffine_injective (δ r : ℝ) :
    Function.Injective (firstProjectedAffine δ r) := by
  intro p q h
  have hpq : firstFoot p = firstFoot q :=
    projection_injective_on_coordinate_plane (firstAxis_zero_ne δ r) (by simp [firstFoot])
      (by simp [firstFoot]) h
  have h₁ := congrArg (fun z : Space => z 1) hpq
  have h₂ := congrArg (fun z : Space => z 2) hpq
  change p.2 / 2 = q.2 / 2 at h₁
  change height * p.1 = height * q.1 at h₂
  apply Prod.ext
  · exact mul_left_cancel₀ (ne_of_gt height_pos) h₂
  · linarith

lemma secondProjectedAffine_injective (δ r : ℝ) :
    Function.Injective (secondProjectedAffine δ r) := by
  intro p q h
  have hpq : secondFoot p = secondFoot q :=
    projection_injective_on_coordinate_plane (secondAxis_one_ne δ r) (by simp [secondFoot])
      (by simp [secondFoot]) h
  have h₀ := congrArg (fun z : Space => z 0) hpq
  have h₂ := congrArg (fun z : Space => z 2) hpq
  change p.2 / 2 = q.2 / 2 at h₀
  change height * (1-p.1) = height * (1-q.1) at h₂
  apply Prod.ext
  · have := mul_left_cancel₀ (ne_of_gt height_pos) h₂
    linarith
  · linarith

lemma firstBase_eq_image (δ : ℝ) (R : ℝ → ℝ) (N : ℕ) (i : Fin N) :
    firstBase δ R N i = firstProjectedAffine δ (midpoint N i) '' foot δ R N i := by
  rw [firstBase, image_image]
  rfl

lemma secondBase_eq_image (δ : ℝ) (R : ℝ → ℝ) (N : ℕ) (i : Fin N) :
    secondBase δ R N i = secondProjectedAffine δ (midpoint N i) '' foot δ R N i := by
  rw [secondBase, image_image]
  rfl

def coordinateVertices (δ : ℝ) (R : ℝ → ℝ) (N : ℕ) (i : Fin N) : Fin 4 → ℝ × ℝ :=
  Footprints.trapezoidVertices (midpoint N i) (maxCap R N i)
    (2 * halfwidth N) (δ / 4) (δ / 4)

def firstVertices (δ : ℝ) (R : ℝ → ℝ) (N : ℕ) (i : Fin N) : Fin 4 → Space :=
  firstProjectedAffine δ (midpoint N i) ∘ coordinateVertices δ R N i

def secondVertices (δ : ℝ) (R : ℝ → ℝ) (N : ℕ) (i : Fin N) : Fin 4 → Space :=
  secondProjectedAffine δ (midpoint N i) ∘ coordinateVertices δ R N i

lemma halfwidth_pos {N : ℕ} (hN : 0 < N) : 0 < halfwidth N := by
  unfold halfwidth
  positivity

lemma radial_length_pos {δ M : ℝ} {N : ℕ} (hδ : 0 < δ) (hM : 0 ≤ M)
    (hN : 0 < N) : 0 < M + 2 * (δ / 4) * (2 * halfwidth N) := by
  have := halfwidth_pos hN
  positivity

lemma coordinate_shape {δ : ℝ} {R : ℝ → ℝ} {N : ℕ} (i : Fin N)
    (hδ : 0 < δ) (hM : 0 ≤ maxCap R N i) :
    foot δ R N i = convexHull ℝ (range (coordinateVertices δ R N i)) ∧
      Function.Injective (coordinateVertices δ R N i) := by
  have hN : 0 < N := Nat.zero_lt_of_lt i.isLt
  have hd : 0 < 2 * halfwidth N := mul_pos (by norm_num) (halfwidth_pos hN)
  have hpad : δ / 4 / 2 < δ / 4 := by linarith
  have hlen := radial_length_pos hδ hM hN
  rw [foot_eq_affine]
  exact ⟨Footprints.affineFootprint_eq_convexHull_trapezoid hd hpad hlen,
    Footprints.trapezoidVertices_injective hd hpad hlen⟩

theorem projected_shape {δ : ℝ} {R : ℝ → ℝ} {N : ℕ} (i : Fin N)
    (hδ : 0 < δ) (hM : 0 ≤ maxCap R N i) :
    firstBase δ R N i = convexHull ℝ (range (firstVertices δ R N i)) ∧
    secondBase δ R N i = convexHull ℝ (range (secondVertices δ R N i)) ∧
    Function.Injective (firstVertices δ R N i) ∧
    Function.Injective (secondVertices δ R N i) := by
  obtain ⟨hfoot, hinj⟩ := coordinate_shape i hδ hM
  refine ⟨?_, ?_, (firstProjectedAffine_injective δ (midpoint N i)).comp hinj,
    (secondProjectedAffine_injective δ (midpoint N i)).comp hinj⟩
  · rw [firstBase_eq_image, hfoot, (firstProjectedAffine δ (midpoint N i)).image_convexHull,
      ← range_comp]
    rfl
  · rw [secondBase_eq_image, hfoot, (secondProjectedAffine δ (midpoint N i)).image_convexHull,
      ← range_comp]
    rfl

lemma vertical_triangle_independent {l r a b c : ℝ} (hlr : l < r) (hab : a < b) :
    AffineIndependent ℝ ![(l,a),(l,b),(r,c)] := by
  rw [affineIndependent_iff_of_fintype]
  intro w hw hv j
  rw [Finset.weightedVSub_eq_linear_combination _ hw] at hv
  have hx := congrArg (fun p : ℝ × ℝ => p.1) hv
  have hy := congrArg (fun p : ℝ × ℝ => p.2) hv
  simp [Fin.sum_univ_succ] at hw hx hy
  have hw₂' : (r-l) * w 2 = 0 := by linear_combination hx-l*hw
  have hw₂ : w 2 = 0 := (mul_eq_zero.mp hw₂').resolve_left (ne_of_gt (sub_pos.mpr hlr))
  have hw₁' : (b-a) * w 1 = 0 := by linear_combination hy-a*hw-(c-a)*hw₂
  have hw₁ : w 1 = 0 := (mul_eq_zero.mp hw₁').resolve_left (ne_of_gt (sub_pos.mpr hab))
  fin_cases j <;> simp_all

lemma coordinate_nondegenerate {δ : ℝ} {R : ℝ → ℝ} {N : ℕ} (i : Fin N)
    (hδ : 0 < δ) (hM : 0 ≤ maxCap R N i) :
    AffineIndependent ℝ ![coordinateVertices δ R N i 0,
      coordinateVertices δ R N i 1, coordinateVertices δ R N i 2] := by
  have hN : 0 < N := Nat.zero_lt_of_lt i.isLt
  have hd : 0 < 2 * halfwidth N := mul_pos (by norm_num) (halfwidth_pos hN)
  have hpad : δ / 4 / 2 < δ / 4 := by linarith
  have hlen := radial_length_pos hδ hM hN
  have hwidth := Footprints.affine_width_pos hd hpad (le_refl (-(δ/4)*(2*halfwidth N)))
  apply vertical_triangle_independent
  · linarith
  · linarith

theorem projected_nondegenerate {δ : ℝ} {R : ℝ → ℝ} {N : ℕ} (i : Fin N)
    (hδ : 0 < δ) (hM : 0 ≤ maxCap R N i) :
    AffineIndependent ℝ ![firstVertices δ R N i 0,
      firstVertices δ R N i 1, firstVertices δ R N i 2] ∧
    AffineIndependent ℝ ![secondVertices δ R N i 0,
      secondVertices δ R N i 1, secondVertices δ R N i 2] := by
  have h := coordinate_nondegenerate i hδ hM
  constructor
  · convert h.map' (firstProjectedAffine δ (midpoint N i))
      (firstProjectedAffine_injective δ (midpoint N i)) using 1
    ext j
    fin_cases j <;> rfl
  · convert h.map' (secondProjectedAffine δ (midpoint N i))
      (secondProjectedAffine_injective δ (midpoint N i)) using 1
    ext j
    fin_cases j <;> rfl

lemma coordinate_parallel_sides (δ : ℝ) (R : ℝ → ℝ) (N : ℕ) (i : Fin N) :
    coordinateVertices δ R N i 1 - coordinateVertices δ R N i 0 =
      (0, 2 * halfwidth N * collar δ N) ∧
    coordinateVertices δ R N i 3 - coordinateVertices δ R N i 2 =
      (0, 2 * halfwidth N * (maxCap R N i + 3 * collar δ N)) := by
  constructor <;> ext <;>
    simp [coordinateVertices, Footprints.trapezoidVertices, collar] <;> ring

private lemma affine_side (f : (ℝ × ℝ) →ᵃ[ℝ] Space) {p q : ℝ × ℝ} {a : ℝ}
    (h : p - q = (0,a)) : f p - f q = a • f.linear (0,1) := by
  calc
    f p - f q = f.linear (p-q) := (f.linearMap_vsub p q).symm
    _ = f.linear (a • (0,1)) := by rw [h]; congr 1; ext <;> simp
    _ = a • f.linear (0,1) := f.linear.map_smul a (0,1)

private lemma affine_vertical_ne_zero (f : (ℝ × ℝ) →ᵃ[ℝ] Space)
    (hf : Function.Injective f) : f.linear (0,1) ≠ 0 := by
  intro h
  have heq : f.linear (0,1) = f.linear (0,0) := by
    change f.linear (0,1) = f.linear 0
    rw [map_zero]
    exact h
  have := (f.linear_injective_iff.mpr hf) heq
  norm_num at this

theorem projected_parallel_sides {δ : ℝ} {R : ℝ → ℝ} {N : ℕ} (i : Fin N)
    (hδ : 0 < δ) (hM : 0 ≤ maxCap R N i) :
    0 < 2 * halfwidth N * collar δ N ∧
    0 < 2 * halfwidth N * (maxCap R N i + 3 * collar δ N) ∧
    ∃ vU vL : Space, vU ≠ 0 ∧ vL ≠ 0 ∧
      firstVertices δ R N i 1 - firstVertices δ R N i 0 =
        (2 * halfwidth N * collar δ N) • vU ∧
      firstVertices δ R N i 3 - firstVertices δ R N i 2 =
        (2 * halfwidth N * (maxCap R N i + 3 * collar δ N)) • vU ∧
      secondVertices δ R N i 1 - secondVertices δ R N i 0 =
        (2 * halfwidth N * collar δ N) • vL ∧
      secondVertices δ R N i 3 - secondVertices δ R N i 2 =
        (2 * halfwidth N * (maxCap R N i + 3 * collar δ N)) • vL := by
  have hρ := halfwidth_pos (Nat.zero_lt_of_lt i.isLt)
  have he : 0 < collar δ N := by unfold collar; positivity
  obtain ⟨hl,hr⟩ := coordinate_parallel_sides δ R N i
  refine ⟨by positivity, by positivity,
    (firstProjectedAffine δ (midpoint N i)).linear (0,1),
    (secondProjectedAffine δ (midpoint N i)).linear (0,1),
    affine_vertical_ne_zero _ (firstProjectedAffine_injective δ (midpoint N i)),
    affine_vertical_ne_zero _ (secondProjectedAffine_injective δ (midpoint N i)),
    affine_side _ hl, affine_side _ hr, affine_side _ hl, affine_side _ hr⟩

theorem family_shape {δ : ℝ} (hδ : 0 < δ) {R : ℝ → ℝ}
    (hR : ContinuousOn R (Icc (-1) 1)) (hR0 : ∀ r ∈ Icc (-1:ℝ) 1, 0 ≤ R r)
    {N : ℕ} (i : Fin N) :
    firstBase δ R N i = convexHull ℝ (range (firstVertices δ R N i)) ∧
    secondBase δ R N i = convexHull ℝ (range (secondVertices δ R N i)) ∧
    Function.Injective (firstVertices δ R N i) ∧
    Function.Injective (secondVertices δ R N i) := by
  apply projected_shape i hδ
  exact RadialRiemann.capMax_nonneg (by norm_num) hR hR0 i

end CylinderCovering.HalfheightFinite.Shape

end

end OAI