File size: 2,639 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 | import Mathlib
namespace OAI
noncomputable section
open scoped BigOperators
namespace SparsePaths
attribute [local instance] Classical.propDecidable
lemma walk_sum_abs {W : Type*} (G : SimpleGraph W) (h : W β β)
{x y : W} (p : G.Walk x y) :
|h x-h y| β€ (p.darts.map (fun e => |h e.fst-h e.snd|)).sum := by
induction p with
| nil => simp
| @cons x y z hxy p ih =>
simpa only [SimpleGraph.Walk.darts_cons,List.map_cons,List.sum_cons] using
(abs_sub_le (h x) (h y) (h z)).trans (add_le_add le_rfl ih)
def dartsMap {W E : Type*} {G : SimpleGraph W} (v : W β E) (e : G.Dart) : E Γ E :=
(v e.fst, v e.snd)
lemma dartsMap_injective {W E : Type*} {G : SimpleGraph W} (v : W β E)
(hv : Function.Injective v) : Function.Injective (dartsMap (G := G) v) := by
intro e f hef
apply SimpleGraph.Dart.ext
exact Prod.ext (hv (congrArg Prod.fst hef)) (hv (congrArg Prod.snd hef))
def edges {W E : Type*} [DecidableEq E] {G : SimpleGraph W} (v : W β E)
{x y : W} (p : G.Walk x y) : Finset (E Γ E) :=
(p.darts.map (dartsMap v)).toFinset
lemma card_edges {W E : Type*} [DecidableEq E] {G : SimpleGraph W}
(v : W β E) (hv : Function.Injective v) {x y : W}
(p : G.Walk x y) (hp : p.IsPath) : (edges v p).card = p.length := by
rw [edges,List.toFinset_card_of_nodup]
Β· simp
Β· exact (p.darts_nodup_of_support_nodup hp.support_nodup).map (dartsMap_injective v hv)
lemma sum_edges {W E : Type*} [DecidableEq E] {G : SimpleGraph W}
(v : W β E) (hv : Function.Injective v) {x y : W}
(p : G.Walk x y) (hp : p.IsPath) (h : E β β) :
|h (v x)-h (v y)| β€ β e β edges v p, |h e.1-h e.2| := by
have hn := (p.darts_nodup_of_support_nodup hp.support_nodup).map (dartsMap_injective v hv)
rw [edges,List.sum_toFinset _ hn]
simpa only [List.map_map,Function.comp_def,dartsMap] using walk_sum_abs G (h β v) p
lemma cap_count {E : Type*} [DecidableEq E] (F : Finset E) (a : E β β)
(Ξ΅ : β) (hΞ΅ : 0 < Ξ΅) (ha : β e β F, a e β€ 1)
(hbad : (1-Ξ΅/2)*(F.card : β) < β e β F, a e) :
(F.card : β)/2 β€ ((F.filter (fun e => 1-Ξ΅ β€ a e)).card : β) := by
have hup : β e β F, a e β€ (1-Ξ΅)*(F.card : β) +
Ξ΅*((F.filter (fun e => 1-Ξ΅ β€ a e)).card : β) := by
calc
_ β€ β e β F, ((1-Ξ΅) + if 1-Ξ΅ β€ a e then Ξ΅ else 0) := by
apply Finset.sum_le_sum
intro e he
split_ifs with hh
Β· linarith [ha e he]
Β· linarith
_ = _ := by
simp [Finset.sum_add_distrib,Finset.sum_ite,Finset.sum_const,mul_comm]
ring
nlinarith
end SparsePaths
end
end OAI
|