Download data/lean/OAI/Probability/LatticePassage/EdgeInfluence.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.06 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LatticePassage/EdgeInfluence.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LatticePassage/EdgeInfluence.lean
-
curl -L -o EdgeInfluence.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LatticePassage/EdgeInfluence.lean
5.06 kB
| 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 | |