Download data/lean/OAI/Combinatorics/CliqueFree/Projection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.66 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/CliqueFree/Projection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/CliqueFree/Projection.lean
-
curl -L -o Projection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/CliqueFree/Projection.lean
5.66 kB
| import OAI.Combinatorics.CliqueFree.TriangleState | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators | |
| open Finset | |
| attribute [local instance] Classical.propDecidable | |
| namespace CliqueFreeIndependence.WeightedGraph | |
| universe u v | |
| variable {V : Type u} [Fintype V] | |
| attribute [local instance 10000] edgeStateDecEq | |
| variable {U : Type v} [Fintype U] | |
| lemma sum_injective_le {I : Type u} {J : Type v} [Fintype I] [Fintype J] | |
| (f : I β J) (hf : Function.Injective f) (g : J β β) (hg : β j, 0 β€ g j) : | |
| (β i, g (f i)) β€ β j, g j := by | |
| classical | |
| calc | |
| _ = β j β univ.image f, g j := (sum_image (fun _ _ _ _ h β¦ hf h)).symm | |
| _ β€ _ := sum_le_univ_sum_of_nonneg hg | |
| /-- A weight-preserving, directed-edge-injective projection. -/ | |
| structure EdgeProjection (H : SimpleGraph U) (G : SimpleGraph V) (Ο : U β V) : Prop where | |
| map_adj : β a b, H.Adj a b β G.Adj (Ο a) (Ο b) | |
| inj : β a b c d, H.Adj a b β H.Adj c d β Ο a = Ο c β Ο b = Ο d β a = c β§ b = d | |
| namespace EdgeProjection | |
| variable {H : SimpleGraph U} {G : SimpleGraph V} {Ο : U β V} | |
| def edgeMap (h : EdgeProjection H G Ο) (e : EdgeState H) : EdgeState G := | |
| β¨(Ο e.src, Ο e.dst), h.map_adj _ _ e.adjβ© | |
| omit [Fintype V] [Fintype U] in | |
| lemma edgeMap_injective (h : EdgeProjection H G Ο) : Function.Injective h.edgeMap := by | |
| intro e f hef | |
| have heq := congrArg Subtype.val hef | |
| have hpair := h.inj e.src e.dst f.src f.dst e.adj f.adj | |
| (congrArg Prod.fst heq) (congrArg Prod.snd heq) | |
| exact Subtype.ext (Prod.ext hpair.1 hpair.2) | |
| omit [Fintype V] [Fintype U] in | |
| lemma mass_image_le {w : V β β} (hw : β v, 0 β€ w v) (A : Finset U) : | |
| mass w (A.image Ο) β€ mass (w β Ο) A := by | |
| classical | |
| exact sum_image_le_of_nonneg (fun _ _ β¦ hw _) | |
| lemma crossMass_edge_sum (H : SimpleGraph U) (w : U β β) (A B : Finset U) : | |
| crossMass H w A B = | |
| β e : EdgeState H, if e.src β A β§ e.dst β B then w e.src * w e.dst else 0 := by | |
| classical | |
| rw [EdgeState.sum_eq (fun a b β¦ if a β A β§ b β B then w a * w b else 0)] | |
| have heq : (β a, β b β neighbors H a, if a β A β§ b β B then w a * w b else 0) = | |
| β a, if a β A then (β b, if b β B then if H.Adj a b then w a * w b else 0 else 0) else 0 := by | |
| apply sum_congr rfl | |
| intro a _ | |
| by_cases ha : a β A | |
| Β· simp only [ha, true_and, βreduceIte, neighbors, sum_filter] | |
| apply sum_congr rfl | |
| intro b _ | |
| by_cases hb : b β B <;> simp [hb] | |
| Β· simp [ha] | |
| rw [heq] | |
| simp [crossMass] | |
| lemma crossMass_le (h : EdgeProjection H G Ο) {w : V β β} (hw : β v, 0 β€ w v) | |
| (A B : Finset U) : | |
| crossMass H (w β Ο) A B β€ crossMass G w (A.image Ο) (B.image Ο) := by | |
| classical | |
| rw [crossMass_edge_sum, crossMass_edge_sum] | |
| calc | |
| _ β€ β e : EdgeState H, | |
| if (h.edgeMap e).src β A.image Ο β§ (h.edgeMap e).dst β B.image Ο | |
| then w (h.edgeMap e).src * w (h.edgeMap e).dst else 0 := by | |
| apply sum_le_sum | |
| intro e _ | |
| by_cases he : e.src β A β§ e.dst β B | |
| Β· have hi : (h.edgeMap e).src β A.image Ο β§ (h.edgeMap e).dst β B.image Ο := | |
| β¨mem_image.2 β¨e.src, he.1, rflβ©, mem_image.2 β¨e.dst, he.2, rflβ©β© | |
| simp only [he, hi] | |
| exact le_rfl | |
| Β· simp only [he, βreduceIte] | |
| split_ifs | |
| Β· exact mul_nonneg (hw _) (hw _) | |
| Β· exact le_rfl | |
| _ β€ _ := sum_injective_le h.edgeMap h.edgeMap_injective | |
| (fun e β¦ if e.src β A.image Ο β§ e.dst β B.image Ο then w e.src * w e.dst else 0) | |
| (fun e β¦ by split_ifs; exact mul_nonneg (hw _) (hw _); exact le_rfl) | |
| lemma crossBound (h : EdgeProjection H G Ο) {w : V β β} (hw : β v, 0 β€ w v) | |
| {C : β} (hC : 0 β€ C) (hc : CrossBound G w C) : CrossBound H (w β Ο) C := by | |
| classical | |
| intro x hx A B hA hB | |
| have hAi := mass_image_le (Ο := Ο) hw A | |
| have hBi := mass_image_le (Ο := Ο) hw B | |
| exact (h.crossMass_le hw A B).trans ((hc x hx _ _ (hAi.trans hA) (hBi.trans hB)).trans | |
| (mul_le_mul_of_nonneg_left (growth_mono hx (mass_nonneg hw _) (mass_nonneg (fun u β¦ hw (Ο u)) _) hAi) hC)) | |
| lemma edgeMass_le (h : EdgeProjection H G Ο) {w : V β β} (hw : β v, 0 β€ w v) : | |
| edgeMass H (w β Ο) β€ edgeMass G w := by | |
| classical | |
| have hsum : (β e : EdgeState H, w (Ο e.src) * w (Ο e.dst)) β€ | |
| β e : EdgeState G, w e.src * w e.dst := | |
| sum_injective_le h.edgeMap h.edgeMap_injective (fun e β¦ w e.src * w e.dst) | |
| (fun e β¦ mul_nonneg (hw _) (hw _)) | |
| unfold edgeMass | |
| rw [crossMass_edge_sum, crossMass_edge_sum] | |
| simpa only [mem_univ, true_and, βreduceIte, Function.comp_apply] using | |
| div_le_div_of_nonneg_right hsum (by norm_num : (0 : β) β€ 2) | |
| omit [Fintype V] in | |
| lemma neighbor_injective (h : EdgeProjection H G Ο) (a : U) : | |
| Set.InjOn Ο (neighbors H a) := by | |
| intro b hb c hc heq | |
| exact (h.inj a b a c ((mem_neighbors _ _ _).1 hb) ((mem_neighbors _ _ _).1 hc) rfl heq).2 | |
| lemma neighborhood_image (h : EdgeProjection H G Ο) (a : U) : | |
| (neighbors H a).image Ο β neighbors G (Ο a) := by | |
| intro b hb | |
| obtain β¨c, hc, rflβ© := mem_image.1 hb | |
| exact (mem_neighbors _ _ _).2 (h.map_adj _ _ ((mem_neighbors _ _ _).1 hc)) | |
| lemma neighborMass_le (h : EdgeProjection H G Ο) {w : V β β} (hw : β v, 0 β€ w v) (a : U) : | |
| neighborMass H (w β Ο) a β€ neighborMass G w (Ο a) := by | |
| classical | |
| calc | |
| _ = mass w ((neighbors H a).image Ο) := (sum_image (h.neighbor_injective a)).symm | |
| _ β€ _ := mass_mono hw (h.neighborhood_image a) | |
| end EdgeProjection | |
| end CliqueFreeIndependence.WeightedGraph | |
| end | |
| end OAI | |