File size: 6,184 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
import Mathlib

namespace OAI

namespace AngularCartesianValidation

theorem cartesian_failure_displacement
    {x y s τ η : ℝ} (hx : |x| ≤ 1) (hy : |y| ≤ 1)
    (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (hτ : 0 < τ) (hτ1 : τ ≤ 1)
    (hη : 0 ≤ η)
    (hfirst : 1 / 4 + τ * x * y +
      τ ^ 2 * ((y ^ 2 / 4 + y ^ 4) + η / 2 - x ^ 2 / 4) < s ^ 2)
    (hsecond : 1 / 4 - τ * x * y +
      τ ^ 2 * ((x ^ 2 / 4 + x ^ 4) + η / 2 - y ^ 2 / 4) < (1 - s) ^ 2) :
    |s - 1 / 2| ≤ 3 * τ ∧ |s - 1 / 2 - τ * x * y| ≤ 10 * τ ^ 2 := by
  let u := s - 1 / 2
  have hu0 : -(1 / 2 : ℝ) ≤ u := by dsimp [u]; linarith
  have hu1 : u ≤ (1 / 2 : ℝ) := by dsimp [u]; linarith
  have hx2 : x ^ 2 ≤ 1 := by
    nlinarith only [(abs_le.mp hx).1, (abs_le.mp hx).2]
  have hy2 : y ^ 2 ≤ 1 := by
    nlinarith only [(abs_le.mp hy).1, (abs_le.mp hy).2]
  have hxy : |x * y| ≤ 1 := by
    rw [abs_mul]
    nlinarith only [mul_le_mul hx hy (abs_nonneg y) (by norm_num : (0 : ℝ) ≤ 1)]
  have htxyl : -τ ≤ τ * x * y := by
    nlinarith only [mul_le_mul_of_nonneg_left (abs_le.mp hxy).1 hτ.le]
  have htxyr : τ * x * y ≤ τ := by
    nlinarith only [mul_le_mul_of_nonneg_left (abs_le.mp hxy).2 hτ.le]
  have hτsq : τ ^ 2 ≤ τ := by
    nlinarith only [mul_nonneg hτ.le (sub_nonneg.mpr hτ1)]
  have hA : -(1 / 4 : ℝ) ≤ (y ^ 2 / 4 + y ^ 4) + η / 2 - x ^ 2 / 4 := by
    nlinarith only [sq_nonneg y, sq_nonneg (y ^ 2), hx2, hη]
  have hB : -(1 / 4 : ℝ) ≤ (x ^ 2 / 4 + x ^ 4) + η / 2 - y ^ 2 / 4 := by
    nlinarith only [sq_nonneg x, sq_nonneg (x ^ 2), hy2, hη]
  have hfirst' : τ * x * y - τ ^ 2 / 4 < u + u ^ 2 := by
    dsimp [u]
    nlinarith only [hfirst, mul_le_mul_of_nonneg_left hA (sq_nonneg τ)]
  have hsecond' : -τ * x * y - τ ^ 2 / 4 < -u + u ^ 2 := by
    dsimp [u]
    nlinarith only [hsecond, mul_le_mul_of_nonneg_left hB (sq_nonneg τ)]
  have hul : -3 * τ ≤ u := by
    by_cases hu : 0 ≤ u
    · linarith
    · have hmul := mul_nonpos_of_nonpos_of_nonneg (le_of_not_ge hu)
        (show 0 ≤ u + 1 / 2 by linarith)
      nlinarith only [hmul, hfirst', htxyl, hτsq, hτ.le]
  have hur : u ≤ 3 * τ := by
    by_cases hu : u ≤ 0
    · linarith
    · have hmul := mul_nonpos_of_nonneg_of_nonpos (le_of_not_ge hu)
        (show u - 1 / 2 ≤ 0 by linarith)
      nlinarith only [hmul, hsecond', htxyr, hτsq, hτ.le]
  have hu2 : u ^ 2 ≤ 9 * τ ^ 2 := by
    nlinarith only [mul_nonneg (sub_nonneg.mpr hur)
      (show 0 ≤ u + 3 * τ by linarith only [hul])]
  constructor
  · exact abs_le.mpr ⟨by simpa only [neg_mul] using hul, hur⟩
  · change |u - τ * x * y| ≤ 10 * τ ^ 2
    apply abs_le.mpr
    constructor
    · nlinarith only [hfirst', hu2, sq_nonneg τ]
    · nlinarith only [hsecond', hu2, sq_nonneg τ]

theorem cartesian_squared_failures_impossible
    {x y s τ η : ℝ} (hx : |x| ≤ 1) (hy : |y| ≤ 1)
    (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (hτ : 0 < τ) (hτ1 : τ ≤ 1)
    (hη : 0 < η) (hsmall : τ ≤ η / 80)
    (hfirst : 1 / 4 + τ * x * y +
      τ ^ 2 * ((y ^ 2 / 4 + y ^ 4) + η / 2 - x ^ 2 / 4) < s ^ 2)
    (hsecond : 1 / 4 - τ * x * y +
      τ ^ 2 * ((x ^ 2 / 4 + x ^ 4) + η / 2 - y ^ 2 / 4) < (1 - s) ^ 2) :
    False := by
  obtain ⟨hu, herr⟩ := cartesian_failure_displacement hx hy hs0 hs1 hτ hτ1 hη.le
    hfirst hsecond
  let u := s - 1 / 2
  change |u| ≤ 3 * τ at hu
  change |u - τ * x * y| ≤ 10 * τ ^ 2 at herr
  have hxy : |x * y| ≤ 1 := by
    rw [abs_mul]
    nlinarith only [mul_le_mul hx hy (abs_nonneg y) (by norm_num : (0 : ℝ) ≤ 1)]
  have htx : |τ * x * y| ≤ τ := by
    calc
      |τ * x * y| = τ * |x * y| := by rw [mul_assoc, abs_mul, abs_of_pos hτ]
      _ ≤ τ * 1 := mul_le_mul_of_nonneg_left hxy hτ.le
      _ = τ := mul_one τ
  have hsum : |u + τ * x * y| ≤ 4 * τ := by
    exact (abs_add_le _ _).trans (by linarith)
  have hsq : |u ^ 2 - (τ * x * y) ^ 2| ≤ 40 * τ ^ 3 := by
    calc
      |u ^ 2 - (τ * x * y) ^ 2| = |u - τ * x * y| * |u + τ * x * y| := by
        rw [← abs_mul]
        congr 1
        ring
      _ ≤ (10 * τ ^ 2) * (4 * τ) :=
        mul_le_mul herr hsum (abs_nonneg _) (by positivity)
      _ = 40 * τ ^ 3 := by ring
  have hsumfail : τ ^ 2 * (x ^ 4 + y ^ 4 + η) < 2 * u ^ 2 := by
    dsimp [u]
    nlinarith only [hfirst, hsecond]
  have hquartic : 2 * x ^ 2 * y ^ 2 ≤ x ^ 4 + y ^ 4 := by
    nlinarith only [sq_nonneg (x ^ 2 - y ^ 2)]
  have hgap : η * τ ^ 2 < 2 * (u ^ 2 - (τ * x * y) ^ 2) := by
    nlinarith only [hsumfail, mul_le_mul_of_nonneg_left hquartic (sq_nonneg τ)]
  have hwindow : 80 * τ ^ 3 ≤ η * τ ^ 2 := by
    nlinarith only [mul_le_mul_of_nonneg_right hsmall (sq_nonneg τ)]
  nlinarith only [hgap, hwindow, (abs_le.mp hsq).2]

theorem cartesian_squared_lower_of_sqrt {Q τ c : ℝ} (hc : 0 ≤ c)
    (hroot : 1 / 2 + τ ^ 2 * c < Real.sqrt Q) :
    1 / 4 + τ ^ 2 * c < Q := by
  have hbase : 0 < 1 / 2 + τ ^ 2 * c := by positivity
  have hQ : 0 ≤ Q := (Real.sqrt_pos.mp (hbase.trans hroot)).le
  have hsq := mul_self_lt_mul_self hbase.le hroot
  rw [Real.mul_self_sqrt hQ] at hsq
  nlinarith only [hsq, sq_nonneg (τ ^ 2 * c)]

theorem cartesian_sqrt_failures_impossible
    {x y s τ η : ℝ} (hx : |x| ≤ 1) (hy : |y| ≤ 1)
    (hs0 : 0 ≤ s) (hs1 : s ≤ 1) (hτ : 0 < τ) (hτ1 : τ ≤ 1)
    (hη : 0 < η) (hsmall : τ ≤ η / 80)
    (hfirst : 1 / 2 + τ ^ 2 * ((y ^ 2 / 4 + y ^ 4) + η / 2) <
      Real.sqrt (s ^ 2 - τ * x * y + τ ^ 2 * x ^ 2 / 4))
    (hsecond : 1 / 2 + τ ^ 2 * ((x ^ 2 / 4 + x ^ 4) + η / 2) <
      Real.sqrt ((1 - s) ^ 2 + τ * x * y + τ ^ 2 * y ^ 2 / 4)) :
    False := by
  have hfirst' := cartesian_squared_lower_of_sqrt (by positivity) hfirst
  have hsecond' := cartesian_squared_lower_of_sqrt (by positivity) hsecond
  apply cartesian_squared_failures_impossible hx hy hs0 hs1 hτ hτ1 hη hsmall
  · nlinarith only [hfirst']
  · nlinarith only [hsecond']

theorem cartesian_edge_one_obstruction (ε x y : ℝ) :
    (ε / 2) ^ 2 * (((2 * x) ^ 2 - (2 * y) ^ 2) ^ 2 + 1 / 1000) =
      ε ^ 2 * (4 * (x ^ 2 - y ^ 2) ^ 2 + 1 / 4000) := by
  ring

end AngularCartesianValidation

end OAI