File size: 5,056 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
102
103
104
105
106
107
108
109
110
111
import OAI.Probability.LatticePassage.LocalPassage
import Mathlib.Algebra.Order.BigOperators.Ring.Finset

namespace OAI

namespace CompanionFPP
open Finset

lemma trailCost_eq_sum (Ο‰ : Environment) {x y : Vertex} (p : lattice.Walk x y)
    (hp : p.IsTrail) : pathCost Ο‰ p = βˆ‘ e ∈ (pathEdges p).toFinset, Ο‰ e := by
  classical
  rw [pathCost_eq_edgeList_sum]
  exact (List.sum_toFinset _ (pathEdges_nodup hp)).symm

theorem trailCost_one_edge_change (Ο‰ Ο‰' : Environment) (e : Edge)
    (h : βˆ€ f, f β‰  e β†’ Ο‰' f = Ο‰ f) {x y : Vertex}
    (p : lattice.Walk x y) (hp : p.IsTrail) :
    pathCost Ο‰' p - pathCost Ο‰ p =
      if e ∈ pathEdges p then Ο‰' e - Ο‰ e else 0 := by
  classical
  rw [trailCost_eq_sum Ο‰' p hp, trailCost_eq_sum Ο‰ p hp, ← sum_sub_distrib]
  by_cases he : e ∈ pathEdges p
  Β· rw [ite_eq_left he]
    apply sum_eq_single_of_mem e (List.mem_toFinset.mpr he)
    intro f _ hfe
    rw [h f hfe, sub_self]
  Β· rw [ite_eq_right he]
    apply sum_eq_zero
    intro f hf
    have hfe : f β‰  e := by
      intro hfe
      exact he (hfe β–Έ List.mem_toFinset.mp hf)
    rw [h f hfe, sub_self]

theorem localPassageTime_one_edge_upper (Ο‰ Ο‰' : Environment) (e : Edge)
    (h : βˆ€ f, f β‰  e β†’ Ο‰' f = Ο‰ f) {x y : Vertex} {R : β„•}
    (p : lattice.Walk x y) (hp : p.IsPath) (hl : p.length < R)
    (hm : pathCost Ο‰ p = localPassageTime Ο‰ x y R) :
    localPassageTime Ο‰' x y R - localPassageTime Ο‰ x y R ≀
      if e ∈ pathEdges p then Ο‰' e - Ο‰ e else 0 := by
  classical
  have hc : localPassageTime Ο‰' x y R ≀ pathCost Ο‰' p :=
    csInf_le (local_costs_finite Ο‰' x y R).bddBelow ⟨p,hp,hl,rfl⟩
  rw [← trailCost_one_edge_change Ο‰ Ο‰' e h p hp.isTrail, ← hm]
  linarith

theorem localPassageTime_one_edge_bound (Ο‰ Ο‰' : Environment) (e : Edge)
    (h : βˆ€ f, f β‰  e β†’ Ο‰' f = Ο‰ f) (x y : Vertex) (R : β„•)
    (hR : latticeDistance x y < R) :
    localPassageTime Ο‰' x y R - localPassageTime Ο‰ x y R ≀ max (Ο‰' e - Ο‰ e) 0 := by
  obtain ⟨p,hp,hl,hm⟩ := local_geodesic_exists Ο‰ x y R hR
  apply (localPassageTime_one_edge_upper Ο‰ Ο‰' e h p hp hl hm).trans
  split_ifs
  Β· exact le_max_left _ _
  Β· exact le_max_right _ _

theorem localPassageTime_one_edge_lipschitz (Ο‰ Ο‰' : Environment) (e : Edge)
    (h : βˆ€ f, f β‰  e β†’ Ο‰' f = Ο‰ f) (x y : Vertex) (R : β„•)
    (hR : latticeDistance x y < R) :
    |localPassageTime Ο‰' x y R - localPassageTime Ο‰ x y R| ≀ |Ο‰' e - Ο‰ e| := by
  have h₁ := localPassageTime_one_edge_bound Ο‰ Ο‰' e h x y R hR
  have hβ‚‚ := localPassageTime_one_edge_bound Ο‰' Ο‰ e (fun f hf => (h f hf).symm) x y R hR
  have ha : max (Ο‰' e - Ο‰ e) 0 ≀ |Ο‰' e - Ο‰ e| := max_le (le_abs_self _) (abs_nonneg _)
  have hb : max (Ο‰ e - Ο‰' e) 0 ≀ |Ο‰' e - Ο‰ e| := by
    rw [abs_sub_comm]
    exact max_le (le_abs_self _) (abs_nonneg _)
  exact abs_le.mpr ⟨by linarith, h₁.trans ha⟩

theorem local_pathCost_change_squared (Ο‰ Ο‰' : Environment) {x y : Vertex} {R : β„•}
    (p : lattice.Walk x y) (hp : p.IsPath) (hl : p.length < R) :
    (pathCost Ο‰' p - pathCost Ο‰ p)^2 ≀
      (R : ℝ) * βˆ‘ e ∈ localEdges x R, (Ο‰' e - Ο‰ e)^2 := by
  classical
  let s := (pathEdges p).toFinset
  have hc : s.card = p.length := by
    rw [List.toFinset_card_of_nodup (pathEdges_nodup hp.isTrail), pathEdges_length]
  have hsub : s βŠ† localEdges x R := by
    intro e he
    exact mem_biUnion.mpr ⟨⟨y,p⟩,mem_localCandidates p hp hl,he⟩
  have hsum : (βˆ‘ e ∈ s, (Ο‰' e-Ο‰ e)^2) ≀ βˆ‘ e ∈ localEdges x R, (Ο‰' e-Ο‰ e)^2 :=
    sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => sq_nonneg _)
  have hcs := sum_mul_sq_le_sq_mul_sq s (fun _ => (1 : ℝ)) (fun e => Ο‰' e-Ο‰ e)
  simp only [one_mul, one_pow, sum_const, nsmul_eq_mul, mul_one, hc] at hcs
  rw [trailCost_eq_sum Ο‰' p hp.isTrail, trailCost_eq_sum Ο‰ p hp.isTrail, ← sum_sub_distrib]
  apply hcs.trans
  gcongr

private lemma localPassageTime_change_squared_of_le (Ο‰ Ο‰' : Environment)
    (x y : Vertex) (R : β„•) (hR : latticeDistance x y < R)
    (hle : localPassageTime Ο‰ x y R ≀ localPassageTime Ο‰' x y R) :
    (localPassageTime Ο‰' x y R - localPassageTime Ο‰ x y R)^2 ≀
      (R : ℝ) * βˆ‘ e ∈ localEdges x R, (Ο‰' e - Ο‰ e)^2 := by
  obtain ⟨p,hp,hl,hm⟩ := local_geodesic_exists Ο‰ x y R hR
  have hc : localPassageTime Ο‰' x y R ≀ pathCost Ο‰' p :=
    csInf_le (local_costs_finite Ο‰' x y R).bddBelow ⟨p,hp,hl,rfl⟩
  have hs := local_pathCost_change_squared Ο‰ Ο‰' p hp hl
  rw [hm] at hs
  nlinarith

theorem localPassageTime_change_squared (Ο‰ Ο‰' : Environment)
    (x y : Vertex) (R : β„•) (hR : latticeDistance x y < R) :
    (localPassageTime Ο‰' x y R - localPassageTime Ο‰ x y R)^2 ≀
      (R : ℝ) * βˆ‘ e ∈ localEdges x R, (Ο‰' e - Ο‰ e)^2 := by
  rcases le_total (localPassageTime Ο‰ x y R) (localPassageTime Ο‰' x y R) with h | h
  Β· exact localPassageTime_change_squared_of_le Ο‰ Ο‰' x y R hR h
  Β· simpa only [sub_sq_comm] using localPassageTime_change_squared_of_le Ο‰' Ο‰ x y R hR h

end CompanionFPP

end OAI