File size: 7,929 Bytes
59d1c80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Geometry.IsometricImmersion.Metric
import Mathlib.Analysis.SpecialFunctions.SmoothTransition
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Tactic.FunProp
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Ring

namespace OAI

noncomputable section
open Set Filter
open scoped ContDiff Topology

namespace SmoothLocal.Model
open SmoothLocal.Geometry

def squareTransition (t : ℝ) : ℝ := Real.smoothTransition (4 * t - 1)

theorem squareTransition_contDiff : ContDiff ℝ ∞ squareTransition :=
  Real.smoothTransition.contDiff.comp ((contDiff_const.mul contDiff_id).sub contDiff_const)

theorem squareTransition_range (t : ℝ) :
    0 ≤ squareTransition t ∧ squareTransition t ≤ 1 :=
  ⟨Real.smoothTransition.nonneg _, Real.smoothTransition.le_one _⟩

theorem squareTransition_zero {t : ℝ} (ht : t ≤ 1 / 4) : squareTransition t = 0 :=
  Real.smoothTransition.zero_of_nonpos (by linarith)

theorem squareTransition_one {t : ℝ} (ht : 1 / 2 ≤ t) : squareTransition t = 1 :=
  Real.smoothTransition.one_of_one_le (by linarith)

theorem squareTransition_monotone : Monotone squareTransition := by
  intro x y hxy
  exact Real.smoothTransition.monotone (by linarith)

theorem squareTransition_deriv_nonneg (t : ℝ) : 0 ≤ deriv squareTransition t :=
  squareTransition_monotone.deriv_nonneg

def modelProfile (y : ℝ) : ℝ := 1 - y ^ 2 * squareTransition (y ^ 2)

theorem modelProfile_contDiff : ContDiff ℝ ∞ modelProfile :=
  contDiff_const.sub ((contDiff_id.pow 2).mul
    (squareTransition_contDiff.comp (contDiff_id.pow 2)))

theorem modelProfile_even : Function.Even modelProfile := by
  intro y
  simp [modelProfile]

theorem modelProfile_plateau {y : ℝ} (hy : y ∈ Icc (-(1 / 2 : ℝ)) (1 / 2)) :
    modelProfile y = 1 := by
  have hs : y ^ 2 ≤ (1 / 2 : ℝ) ^ 2 := sq_le_sq' hy.1 hy.2
  have hz := squareTransition_zero (t := y ^ 2) (by nlinarith)
  simp [modelProfile, hz]

theorem modelProfile_bounds (y : ℝ) : 1 - y ^ 2 ≤ modelProfile y ∧ modelProfile y ≤ 1 := by
  have hh := squareTransition_range (y ^ 2)
  have hprod := mul_le_mul_of_nonneg_left hh.2 (sq_nonneg y)
  have hprod0 := mul_nonneg (sq_nonneg y) hh.1
  unfold modelProfile
  constructor <;> nlinarith

theorem modelProfile_pos_inside {y : ℝ} (hy : |y| < 1) : 0 < modelProfile y := by
  have hs : y ^ 2 < 1 := (sq_lt_one_iff_abs_lt_one y).mpr hy
  linarith [(modelProfile_bounds y).1]

theorem modelProfile_eq_one_sub_sq {y : ℝ} (hy : 1 / 2 ≤ y ^ 2) :
    modelProfile y = 1 - y ^ 2 := by
  simp [modelProfile, squareTransition_one hy]

theorem modelProfile_neg_outside {y : ℝ} (hy : 1 < |y|) : modelProfile y < 0 := by
  have hs : 1 < y ^ 2 := (one_lt_sq_iff_one_lt_abs y).mpr hy
  rw [modelProfile_eq_one_sub_sq (by linarith : 1 / 2 ≤ y ^ 2)]
  linarith

theorem modelProfile_one : modelProfile 1 = 0 := by
  rw [modelProfile_eq_one_sub_sq (by norm_num : (1 / 2 : ℝ) ≤ (1 : ℝ) ^ 2)]
  norm_num

theorem modelProfile_hasDerivAt (y : ℝ) :
    HasDerivAt modelProfile
      (-2 * y * squareTransition (y ^ 2) - 2 * y ^ 3 * deriv squareTransition (y ^ 2)) y := by
  have hsq : HasDerivAt (fun t : ℝ => t ^ 2) (2 * y) y := by
    convert (hasDerivAt_id y).pow 2 using 1 <;> first | rfl | simp
  have hcut := ((squareTransition_contDiff.differentiable (by simp)) (y ^ 2)).hasDerivAt.comp y hsq
  have hp := (hsq.mul hcut).const_sub 1
  convert hp using 1 <;> first | rfl | (dsimp only [Function.comp_def]; ring)

theorem modelProfile_deriv (y : ℝ) :
    deriv modelProfile y =
      -2 * y * squareTransition (y ^ 2) - 2 * y ^ 3 * deriv squareTransition (y ^ 2) :=
  (modelProfile_hasDerivAt y).deriv

theorem modelProfile_deriv_nonpos {y : ℝ} (hy : 0 ≤ y) : deriv modelProfile y ≤ 0 := by
  rw [modelProfile_deriv]
  have hfirst : 0 ≤ 2 * y * squareTransition (y ^ 2) :=
    mul_nonneg (mul_nonneg (by norm_num) hy) (squareTransition_range _).1
  have hsecond : 0 ≤ 2 * y ^ 3 * deriv squareTransition (y ^ 2) :=
    mul_nonneg (mul_nonneg (by norm_num) (pow_nonneg hy _)) (squareTransition_deriv_nonneg _)
  linarith

theorem modelProfile_deriv_one_neg : deriv modelProfile 1 < 0 := by
  rw [modelProfile_deriv]
  have hc := squareTransition_one (t := 1) (by norm_num)
  have hd := squareTransition_deriv_nonneg 1
  norm_num only [one_pow]
  rw [hc]
  nlinarith only [hd]

theorem modelProfile_spec :
    ContDiff ℝ ∞ modelProfile ∧ Function.Even modelProfile ∧
    (∀ y ∈ Icc (-(1 / 2 : ℝ)) (1 / 2), modelProfile y = 1) ∧
    (∀ y ∈ Ici (0 : ℝ), deriv modelProfile y ≤ 0) ∧
    (∀ y ∈ Ioo (-1 : ℝ) 1, 0 < modelProfile y) ∧
    (∀ y : ℝ, 1 < |y| → modelProfile y < 0) ∧
    modelProfile 1 = 0 ∧ deriv modelProfile 1 < 0 :=
  ⟨modelProfile_contDiff, modelProfile_even, fun _ hy => modelProfile_plateau hy,
    fun _ hy => modelProfile_deriv_nonpos hy,
    fun _ hy => modelProfile_pos_inside (abs_lt.mpr hy),
    fun _ hy => modelProfile_neg_outside hy, modelProfile_one, modelProfile_deriv_one_neg⟩

def modelCurvature (kappa : ℝ) (p : Coord) : ℝ :=
  kappa * ((p 0) ^ 2 - modelProfile (p 1))

theorem modelCurvature_contDiff (kappa : ℝ) : ContDiff ℝ ∞ (modelCurvature kappa) :=
  contDiff_const.mul (((contDiff_apply ℝ ℝ 0).pow 2).sub
    (modelProfile_contDiff.comp (contDiff_apply ℝ ℝ 1)))

theorem modelCurvature_central_square {kappa : ℝ} (hkappa : 0 < kappa) {p : Coord}
    (hp : ∀ i : Fin 2, p i ∈ Icc (-(1 / 5 : ℝ)) (1 / 5)) :
    modelCurvature kappa p < -kappa / 2 := by
  have hplateau : modelProfile (p 1) = 1 := modelProfile_plateau
    ⟨by linarith [(hp 1).1], by linarith [(hp 1).2]⟩
  have hx : (p 0) ^ 2 ≤ (1 / 5 : ℝ) ^ 2 := sq_le_sq' (hp 0).1 (hp 0).2
  have hmul := mul_le_mul_of_nonneg_left hx hkappa.le
  unfold modelCurvature
  rw [hplateau]
  nlinarith

theorem modelCurvature_pos_lateral {kappa : ℝ} (hkappa : 0 < kappa) {p : Coord}
    (hp : 1 < |p 0|) : 0 < modelCurvature kappa p := by
  have hx : 1 < (p 0) ^ 2 := (one_lt_sq_iff_one_lt_abs _).mpr hp
  apply mul_pos hkappa
  linarith [(modelProfile_bounds (p 1)).2]

theorem modelCurvature_lateral_band_lower {kappa : ℝ} (hkappa : 0 < kappa) {p : Coord}
    (hp : 3 / 2 < |p 0|) : 5 / 4 * kappa < modelCurvature kappa p := by
  have hx : (3 / 2 : ℝ) ^ 2 < (p 0) ^ 2 := sq_lt_sq.mpr (by
    rw [abs_of_pos (by norm_num : (0 : ℝ) < 3 / 2)]
    exact hp)
  have hmul := mul_lt_mul_of_pos_left hx hkappa
  have hh := mul_le_mul_of_nonneg_left (modelProfile_bounds (p 1)).2 hkappa.le
  unfold modelCurvature
  nlinarith

theorem modelCurvature_pos_transverse {kappa : ℝ} (hkappa : 0 < kappa) {p : Coord}
    (hp : 1 < |p 1|) : 0 < modelCurvature kappa p := by
  have hh := modelProfile_neg_outside hp
  apply mul_pos hkappa
  linarith [sq_nonneg (p 0)]

theorem modelCurvature_pos_lower_flow_band {kappa y s t : ℝ} (hkappa : 0 < kappa)
    (hys : |y - s| ≤ 1 / 50) (hs : s < -3 / 2) :
    0 < modelCurvature kappa ![t, y] := by
  have hy : y < -1 := by linarith [(abs_le.mp hys).2]
  apply modelCurvature_pos_transverse hkappa
  simp only [Matrix.cons_val_one, Matrix.cons_val_zero]
  rw [abs_of_neg (by linarith : y < 0)]
  linarith

theorem modelCurvature_abs_le_model_square {kappa : ℝ} (hkappa : 0 ≤ kappa) {p : Coord}
    (hp : ∀ i : Fin 2, p i ∈ Icc (-3 : ℝ) 3) :
    |modelCurvature kappa p| ≤ 17 * kappa := by
  have hx : (p 0) ^ 2 ≤ (3 : ℝ) ^ 2 := sq_le_sq' (hp 0).1 (hp 0).2
  have hy : (p 1) ^ 2 ≤ (3 : ℝ) ^ 2 := sq_le_sq' (hp 1).1 (hp 1).2
  have hh := modelProfile_bounds (p 1)
  have habs : |(p 0) ^ 2 - modelProfile (p 1)| ≤ 17 := by
    apply abs_le.mpr
    constructor <;> nlinarith [sq_nonneg (p 0)]
  unfold modelCurvature
  rw [abs_mul, abs_of_nonneg hkappa]
  simpa only [mul_comm] using mul_le_mul_of_nonneg_left habs hkappa

end SmoothLocal.Model

end

end OAI