File size: 4,272 Bytes
4a56cd6 | 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 | import OAI.Probability.FirstPassage.RareFastGeometry
namespace OAI
namespace PlanarFPP
open Set Finset
noncomputable def trialSpacing (R s : β) : β := (R+1)*(βsββ : β)
noncomputable def trialWindow (M : β) (R s : β) : β := 100*M*trialSpacing R s
noncomputable def trialOffset (M : β) (R s : β) (j : Fin M) : β :=
(2*((j.val : β)+1)-(M : β)-1)*3*trialSpacing R s
noncomputable def trialTranslate (b : β) (X : β€) (Y : β)
(M : β) (R s : β) (j : Fin M) : Vertex :=
(X,βb*X+Y+trialOffset M R s j+1/2β)
theorem nearest_integer_error (t : β) : |(βt+1/2β : β)-t| β€ 1/2 := by
have hlo := Int.floor_le (t+1/2)
have hhi := Int.lt_floor_add_one (t+1/2)
apply abs_le.mpr
constructor <;> linarith
theorem trialTranslate_error (b : β) (X : β€) (Y : β)
(M : β) (R s : β) (j : Fin M) :
|transverse b (trialTranslate b X Y M R s j)-(Y+trialOffset M R s j)| β€ 1/2 := by
have hh := nearest_integer_error (b*X+Y+trialOffset M R s j)
convert hh using 1
simp [trialTranslate,transverse]
congr 1
ring
theorem trialSpacing_bounds (R s : β) (hR : 0 β€ R) (hs : 1 β€ s) :
1 β€ trialSpacing R s β§ R*s β€ trialSpacing R s := by
have hc := Nat.le_ceil s
have hn : (1 : β) β€ (βsββ : β) := by linarith
unfold trialSpacing
constructor
Β· nlinarith
Β· nlinarith
theorem trialOffset_bound (M : β) (R s : β) (j : Fin M)
(hR : 0 β€ R) (hs : 1 β€ s) :
|trialOffset M R s j| β€ 3*M*trialSpacing R s := by
have hB := (trialSpacing_bounds R s hR hs).1
have hj : (j.val : β)+1 β€ M := by exact_mod_cast j.isLt
have hj0 : (0 : β) β€ j.val := Nat.cast_nonneg _
have ha : |2*((j.val : β)+1)-(M : β)-1| β€ M := by
apply abs_le.mpr
constructor <;> linarith
unfold trialOffset
rw [abs_mul,abs_mul,abs_of_pos (by norm_num : (0 : β)<3),abs_of_nonneg (show 0 β€ trialSpacing R s by linarith)]
nlinarith
theorem trial_strip_in_window (b : β) (X : β€) (Y : β)
(M : β) (R s : β) (j : Fin M) (hR : 0 β€ R) (hs : 1 β€ s)
(p : Vertex) (hp : |transverse b p-transverse b (trialTranslate b X Y M R s j)| β€ R*s) :
|transverse b p-Y| β€ trialWindow M R s/4 := by
have he := trialTranslate_error b X Y M R s j
have ho := trialOffset_bound M R s j hR hs
have hB := trialSpacing_bounds R s hR hs
have hM : (1 : β) β€ M := by exact_mod_cast j.pos
have hh := abs_add_le
(transverse b (trialTranslate b X Y M R s j)-(Y+trialOffset M R s j))
(trialOffset M R s j)
have heq : transverse b (trialTranslate b X Y M R s j)-(Y+trialOffset M R s j)+
trialOffset M R s j = transverse b (trialTranslate b X Y M R s j)-Y := by ring
rw [heq] at hh
have ht := abs_add_le (transverse b p-transverse b (trialTranslate b X Y M R s j))
(transverse b (trialTranslate b X Y M R s j)-Y)
rw [sub_add_sub_cancel] at ht
unfold trialWindow
nlinarith [mul_le_mul_of_nonneg_right hM (by linarith : 0 β€ trialSpacing R s)]
theorem trial_centers_separated (b : β) (X : β€) (Y : β)
(M : β) (R s : β) (j l : Fin M) (hjl : j β l) (hR : 0 β€ R) (hs : 1 β€ s) :
2*R*s < |transverse b (trialTranslate b X Y M R s j)-
transverse b (trialTranslate b X Y M R s l)| := by
have hB := trialSpacing_bounds R s hR hs
have he := trialTranslate_error b X Y M R s j
have hf := trialTranslate_error b X Y M R s l
have he' := abs_le.mp he
have hf' := abs_le.mp hf
have hdiff : trialOffset M R s j-trialOffset M R s l =
6*((j.val : β)-(l.val : β))*trialSpacing R s := by unfold trialOffset; ring
have hne : j.val β l.val := fun hh => hjl (Fin.ext hh)
rcases lt_or_gt_of_ne hne with hlt | hgt
Β· have hn : (j.val : β)+1 β€ l.val := by exact_mod_cast hlt
have ha := neg_le_abs (transverse b (trialTranslate b X Y M R s j)-
transverse b (trialTranslate b X Y M R s l))
nlinarith [mul_le_mul_of_nonneg_right hn (by linarith : 0 β€ trialSpacing R s)]
Β· have hn : (l.val : β)+1 β€ j.val := by exact_mod_cast hgt
have ha := le_abs_self (transverse b (trialTranslate b X Y M R s j)-
transverse b (trialTranslate b X Y M R s l))
nlinarith [mul_le_mul_of_nonneg_right hn (by linarith : 0 β€ trialSpacing R s)]
end PlanarFPP
end OAI
|