Download data/lean/OAI/Combinatorics/MatchingEntropy/Face.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/Face.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingEntropy/Face.lean
-
curl -L -o Face.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/Face.lean
14.4 kB
| import OAI.Combinatorics.MatchingEntropy.Polytope | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators Topology | |
| open Filter | |
| universe uV uE uI uJ uA uB uC uW uF uD uΞΉ | |
| namespace MatchingEntropyBounds.LooplessGraph | |
| variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] | |
| def positiveExtension (x : E β β) : ({e // 0<x e} β β) ββ[β] (E β β) := by | |
| classical | |
| exact { | |
| toFun := fun u e => if h : 0<x e then u β¨e,hβ© else 0 | |
| map_add' := by intro u v; ext e; by_cases h : 0<x e <;> simp [h] | |
| map_smul' := by intro a u; ext e; by_cases h : 0<x e <;> simp [h] } | |
| omit [Fintype E] [DecidableEq E] in | |
| @[simp] theorem positiveExtension_pos (x : E β β) (u : {e // 0<x e} β β) | |
| (e : {e // 0<x e}) : positiveExtension x u e.val=u e := by | |
| simp [positiveExtension,e.property] | |
| omit [Fintype E] [DecidableEq E] in | |
| @[simp] theorem positiveExtension_zero (x : E β β) (u : {e // 0<x e} β β) | |
| {e : E} (he : x e=0) : positiveExtension x u e=0 := by | |
| simp [positiveExtension,he] | |
| def degreeLinear (G : LooplessGraph V E) : (E β β) ββ[β] (V β β) where | |
| toFun := G.degree | |
| map_add' := by | |
| intro u v | |
| ext w | |
| simpa using G.degree_linear u v 1 1 w | |
| map_smul' := by | |
| intro a u | |
| ext w | |
| simp only [degree,Pi.smul_apply,smul_eq_mul,RingHom.id_apply,Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro e _ | |
| split <;> simp | |
| def cutLinear (G : LooplessGraph V E) (S : Finset V) : (E β β) ββ[β] β where | |
| toFun := fun u => G.cutMass u S | |
| map_add' := by intro u v; simpa using G.cutMass_linear u v 1 1 S | |
| map_smul' := by intro a u; simp [cutMass,Finset.mul_sum] | |
| def faceSpace (G : LooplessGraph V E) (x : E β β) : Submodule β ({e // 0<x e} β β) where | |
| carrier := {u | G.degreeLinear (positiveExtension x u)=0 β§ | |
| β S : Finset V, Odd S.card β G.cutMass x S=1 β G.cutLinear S (positiveExtension x u)=0} | |
| zero_mem' := by simp | |
| add_mem' := by | |
| intro u v hu hv | |
| refine β¨by simp only [map_add,hu.1,hv.1,add_zero],?_β© | |
| intro S hS ht | |
| simp only [map_add,hu.2 S hS ht,hv.2 S hS ht,add_zero] | |
| smul_mem' := by | |
| intro a u hu | |
| refine β¨by simp only [map_smul,hu.1,smul_zero],?_β© | |
| intro S hS ht | |
| simp only [map_smul,hu.2 S hS ht,smul_zero] | |
| def faceCodimension (G : LooplessGraph V E) (x : E β β) : β := | |
| Module.finrank β (({e // 0<x e} β β) β§Έ G.faceSpace x) | |
| omit [DecidableEq E] in | |
| theorem faceCodimension_no_tight (G : LooplessGraph V E) {x : E β β} | |
| (heven : Even (Fintype.card V)) | |
| (hnt : Β¬β S : Finset V, Odd S.card β§ 3β€S.card β§ 3β€SαΆ.card β§ G.cutMass x S=1) : | |
| G.faceCodimension x β€ Fintype.card V := by | |
| classical | |
| let F := G.degreeLinear.comp (positiveExtension x) | |
| have hk : F.ker β€ G.faceSpace x := by | |
| intro u hu | |
| have hd : G.degreeLinear (positiveExtension x u)=0 := hu | |
| refine β¨hd,?_β© | |
| exact G.trivial_tight_cut_preserved heven hnt _ (congrFun hd) | |
| simpa [faceCodimension] using quotient_finrank_le_of_ker_le (G.faceSpace x) F hk | |
| omit [DecidableEq E] in | |
| theorem faceSpace_eventually_line (G : LooplessGraph V E) {x : E β β} | |
| (hx : x β G.constraintPolytope) {u : {e // 0<x e} β β} (hu : u β G.faceSpace x) : | |
| βαΆ t : β in π 0, x+t β’ positiveExtension x u β G.constraintPolytope := by | |
| exact G.constraint_eventually_line hx _ (fun e he => positiveExtension_zero x u he) | |
| (congrFun hu.1) hu.2 | |
| omit [Fintype V] [DecidableEq E] in | |
| theorem faceSpace_of_eventually_line (G : LooplessGraph V E) {x : E β β} | |
| (hx : x β G.constraintPolytope) {u : {e // 0<x e} β β} | |
| (hu : βαΆ t : β in π 0, x+t β’ positiveExtension x u β G.constraintPolytope) : | |
| u β G.faceSpace x := by | |
| have hu' : βαΆ t : β in π 0, x+(-t) β’ positiveExtension x u β G.constraintPolytope := by | |
| have hc : Tendsto (fun t : β => -t) (π 0) (π 0) := by simpa using continuous_neg.tendsto (0:β) | |
| exact hc.eventually hu | |
| have hh : βαΆ t : β in π[>] 0, | |
| (x+t β’ positiveExtension x u β G.constraintPolytope β§ | |
| x+(-t) β’ positiveExtension x u β G.constraintPolytope) β§ 0<t := | |
| ((hu.and hu').filter_mono nhdsWithin_le_nhds).and eventually_mem_nhdsWithin | |
| obtain β¨a,β¨ha,hnaβ©,ha0β© := hh.exists | |
| refine β¨?_,?_β© | |
| Β· ext v | |
| have he := G.degree_linear x (positiveExtension x u) 1 a v | |
| simp only [one_smul,one_mul,hx.2.1,ha.2.1] at he | |
| change G.degree (positiveExtension x u) v=0 | |
| nlinarith | |
| Β· intro S hS ht | |
| have he := G.cutMass_linear x (positiveExtension x u) 1 a S | |
| have he' := G.cutMass_linear x (positiveExtension x u) 1 (-a) S | |
| simp only [one_smul,one_mul,ht] at he he' | |
| have hp := ha.2.2 S hS | |
| have hn := hna.2.2 S hS | |
| change G.cutMass (positiveExtension x u) S=0 | |
| nlinarith | |
| abbrev sideMarginal (G : LooplessGraph V E) (x : E β β) (S : Finset V) : | |
| {e // G.left e β S β¨ G.right e β S} β β := fun e => x e.val | |
| def sideRestriction (G : LooplessGraph V E) (x : E β β) (S : Finset V) : | |
| ({e // 0<x e} β β) ββ[β] ({e // 0<G.sideMarginal x S e} β β) where | |
| toFun := fun u e => u β¨e.val.val,e.propertyβ© | |
| map_add' := by intros; rfl | |
| map_smul' := by intros; rfl | |
| omit [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] in | |
| theorem positiveExtension_side (G : LooplessGraph V E) (x : E β β) (S : Finset V) | |
| (u : {e // 0<x e} β β) (e : {e // G.left e β S β¨ G.right e β S}) : | |
| positiveExtension (G.sideMarginal x S) (G.sideRestriction x S u) e = | |
| positiveExtension x u e.val := by | |
| rfl | |
| omit [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] in | |
| theorem sideMarginal_line (G : LooplessGraph V E) (x : E β β) (S : Finset V) | |
| (u : {e // 0<x e} β β) (t : β) : | |
| G.sideMarginal (x+t β’ positiveExtension x u) S = G.sideMarginal x S + | |
| t β’ positiveExtension (G.sideMarginal x S) (G.sideRestriction x S u) := by | |
| rfl | |
| theorem faceSpace_of_side_spaces (G : LooplessGraph V E) {x : E β β} | |
| (heven : Even (Fintype.card V)) (hx : x β G.constraintPolytope) | |
| (S : Finset V) (hS : Odd S.card) (ht : G.cutMass x S=1) | |
| {u : {e // 0<x e} β β} | |
| (h1 : G.sideRestriction x S u β (G.onSide S).faceSpace (G.sideMarginal x S)) | |
| (h2 : G.sideRestriction x SαΆ u β (G.onSide SαΆ).faceSpace (G.sideMarginal x SαΆ)) : | |
| u β G.faceSpace x := by | |
| have hc := odd_compl_of_even heven hS | |
| have htc : G.cutMass x SαΆ=1 := by simpa only [cutMass,cut_compl] using ht | |
| have hx1 := G.restriction_mem_constraints hx S hS ht | |
| have hx2 := G.restriction_mem_constraints hx SαΆ hc htc | |
| have hv1 : Even (Fintype.card (Option {v // v β S})) := by | |
| simpa only [Fintype.card_option,Fintype.card_coe] using hS.add_odd odd_one | |
| have hv2 : Even (Fintype.card (Option {v // v β SαΆ})) := by | |
| simpa only [Fintype.card_option,Fintype.card_coe] using hc.add_odd odd_one | |
| apply G.faceSpace_of_eventually_line hx | |
| filter_upwards [(G.onSide S).faceSpace_eventually_line hx1 h1, | |
| (G.onSide SαΆ).faceSpace_eventually_line hx2 h2] with t ht1 ht2 | |
| rw [β G.sideMarginal_line x S u t] at ht1 | |
| rw [β G.sideMarginal_line x SαΆ u t] at ht2 | |
| have hp1 : G.sideMarginal (x+t β’ positiveExtension x u) S β (G.onSide S).polytope := by | |
| rwa [(G.onSide S).polytope_eq_constraints hv1] | |
| have hp2 : G.sideMarginal (x+t β’ positiveExtension x u) SαΆ β (G.onSide SαΆ).polytope := by | |
| rwa [(G.onSide SαΆ).polytope_eq_constraints hv2] | |
| obtain β¨p,hp,hpxβ© := ((G.onSide S).mem_polytope_iff _).mp hp1 | |
| obtain β¨q,hq,hqxβ© := ((G.onSide SαΆ).mem_polytope_iff _).mp hp2 | |
| have hp := (G.mem_polytope_iff _).mpr (G.couple_laws S _ hp hq (congrFun hpx) (congrFun hqx)) | |
| exact G.polytope_subset_constraintPolytope hp | |
| theorem faceCodimension_le_sides (G : LooplessGraph V E) {x : E β β} | |
| (heven : Even (Fintype.card V)) (hx : x β G.constraintPolytope) | |
| (S : Finset V) (hS : Odd S.card) (ht : G.cutMass x S=1) : | |
| G.faceCodimension x β€ (G.onSide S).faceCodimension (G.sideMarginal x S) + | |
| (G.onSide SαΆ).faceCodimension (G.sideMarginal x SαΆ) := by | |
| classical | |
| exact quotient_finrank_le_pair (G.faceSpace x) ((G.onSide S).faceSpace (G.sideMarginal x S)) | |
| ((G.onSide SαΆ).faceSpace (G.sideMarginal x SαΆ)) | |
| (G.sideRestriction x S) (G.sideRestriction x SαΆ) | |
| (fun _ => G.faceSpace_of_side_spaces heven hx S hS ht) | |
| theorem faceCodimension_strong_aux (n : β) : | |
| β {W : Type uW} {F : Type uF} [Fintype W] [Fintype F] [DecidableEq W] [DecidableEq F] | |
| (G : LooplessGraph W F), Fintype.card W=n β Even n β 4β€n β | |
| β x β G.constraintPolytope, G.faceCodimension x β€ 2*(n-2) := by | |
| induction n using Nat.strong_induction_on with | |
| | h n ih => | |
| intro W F _ _ _ _ G hcard heven hfour x hx | |
| have heven' : Even (Fintype.card W) := hcard βΈ heven | |
| by_cases hcut : β S : Finset W, Odd S.card β§ 3β€S.card β§ 3β€SαΆ.card β§ G.cutMass x S=1 | |
| Β· obtain β¨S,hS,hlo,hhi,htβ© := hcut | |
| have hc := odd_compl_of_even heven' hS | |
| have hlt1 : Fintype.card (Option {v // v β S}) < n := by | |
| simp only [Fintype.card_option,Fintype.card_coe] | |
| have hco := Finset.card_compl S | |
| omega | |
| have hlt2 : Fintype.card (Option {v // v β SαΆ}) < n := by | |
| simp only [Fintype.card_option,Fintype.card_coe] | |
| have hco := Finset.card_compl S | |
| have hle := Finset.card_le_univ S | |
| omega | |
| have hv1 : Even (Fintype.card (Option {v // v β S})) := by | |
| simpa only [Fintype.card_option,Fintype.card_coe] using hS.add_odd odd_one | |
| have hv2 : Even (Fintype.card (Option {v // v β SαΆ})) := by | |
| simpa only [Fintype.card_option,Fintype.card_coe] using hc.add_odd odd_one | |
| have hn1 : 4β€Fintype.card (Option {v // v β S}) := by | |
| simp only [Fintype.card_option,Fintype.card_coe]; omega | |
| have hn2 : 4β€Fintype.card (Option {v // v β SαΆ}) := by | |
| simp only [Fintype.card_option,Fintype.card_coe]; omega | |
| have hx1 := G.restriction_mem_constraints hx S hS ht | |
| have htc : G.cutMass x SαΆ=1 := by simpa only [cutMass,cut_compl] using ht | |
| have hx2 := G.restriction_mem_constraints hx SαΆ hc htc | |
| have hb1 := ih _ hlt1 (G.onSide S) rfl hv1 hn1 _ hx1 | |
| have hb2 := ih _ hlt2 (G.onSide SαΆ) rfl hv2 hn2 _ hx2 | |
| have hb := G.faceCodimension_le_sides heven' hx S hS ht | |
| have hsum : Fintype.card (Option {v // v β S}) + Fintype.card (Option {v // v β SαΆ})=n+2 := by | |
| simp only [Fintype.card_option,Fintype.card_coe] | |
| have hh := Finset.card_compl_add_card S | |
| omega | |
| change (G.onSide S).faceCodimension (G.sideMarginal x S) β€ _ at hb1 | |
| change (G.onSide SαΆ).faceCodimension (G.sideMarginal x SαΆ) β€ _ at hb2 | |
| omega | |
| Β· have hb := G.faceCodimension_no_tight heven' hcut | |
| omega | |
| theorem faceCodimension_bound (G : LooplessGraph V E) {x : E β β} | |
| (heven : Even (Fintype.card V)) (hx : x β G.polytope) : | |
| G.faceCodimension x β€ 2*Fintype.card V := by | |
| by_cases hn : 4β€Fintype.card V | |
| Β· have hb := faceCodimension_strong_aux (Fintype.card V) G rfl heven hn x | |
| (G.polytope_subset_constraintPolytope hx) | |
| omega | |
| Β· have hnt : Β¬ β S : Finset V, Odd S.card β§ 3β€S.card β§ 3β€SαΆ.card β§ G.cutMass x S=1 := by | |
| rintro β¨S,_,hlo,hhi,_β© | |
| have hh := Finset.card_compl_add_card S | |
| omega | |
| have hb := G.faceCodimension_no_tight heven hnt | |
| omega | |
| omit [Fintype V] [DecidableEq E] in | |
| theorem degree_add_smul (G : LooplessGraph V E) (x u : E β β) (t : β) (v : V) : | |
| G.degree (x+t β’ u) v=G.degree x v+t*G.degree u v := by | |
| simpa using G.degree_linear x u 1 t v | |
| omit [Fintype V] [DecidableEq E] in | |
| theorem cutMass_add_smul (G : LooplessGraph V E) (x u : E β β) (t : β) (S : Finset V) : | |
| G.cutMass (x+t β’ u) S=G.cutMass x S+t*G.cutMass u S := by | |
| simpa using G.cutMass_linear x u 1 t S | |
| omit [DecidableEq E] in | |
| theorem constraint_eventually_expand (G : LooplessGraph V E) {x : E β β} | |
| (hx : x β G.constraintPolytope) {t : β} (ht : 0<t) : | |
| βαΆ y in π[G.constraintPolytope] x, x+tβ»ΒΉ β’ (y-x) β G.constraintPolytope := by | |
| have hn : βαΆ y in π[G.constraintPolytope] x, β e, 0β€(x+tβ»ΒΉ β’ (y-x)) e := by | |
| apply Filter.eventually_all.mpr | |
| intro e | |
| by_cases he : x e=0 | |
| Β· filter_upwards [eventually_mem_nhdsWithin] with y hy | |
| simpa [he] using mul_nonneg (inv_nonneg.mpr ht.le) (hy.1 e) | |
| Β· have hp : 0<x e := lt_of_le_of_ne (hx.1 e) (Ne.symm he) | |
| have hc : Continuous (fun y : E β β => (x+tβ»ΒΉ β’ (y-x)) e) := by fun_prop | |
| have hh : βαΆ y : E β β in π x, 0<(x+tβ»ΒΉ β’ (y-x)) e := | |
| (isOpen_lt continuous_const hc).mem_nhds (by simpa using hp) | |
| exact (hh.filter_mono nhdsWithin_le_nhds).mono fun y hy => hy.le | |
| have hodd : βαΆ y in π[G.constraintPolytope] x, | |
| β S : Finset V, Odd S.card β 1β€G.cutMass (x+tβ»ΒΉ β’ (y-x)) S := by | |
| apply Filter.eventually_all.mpr | |
| intro S | |
| by_cases hS : Odd S.card | |
| Β· by_cases hs : G.cutMass x S=1 | |
| Β· filter_upwards [eventually_mem_nhdsWithin] with y hy _ | |
| rw [cutMass_add_smul,cutMass_sub,hs] | |
| have hh := mul_nonneg (inv_nonneg.mpr ht.le) (sub_nonneg.mpr (hy.2.2 S hS)) | |
| linarith | |
| Β· have hp : 1<G.cutMass x S := lt_of_le_of_ne (hx.2.2 S hS) (Ne.symm hs) | |
| have hc : Continuous (fun y : E β β => G.cutMass (x+tβ»ΒΉ β’ (y-x)) S) := | |
| (G.continuous_cutMass S).comp (by fun_prop) | |
| have hh : βαΆ y : E β β in π x, 1<G.cutMass (x+tβ»ΒΉ β’ (y-x)) S := | |
| (isOpen_lt continuous_const hc).mem_nhds (by simpa using hp) | |
| exact (hh.filter_mono nhdsWithin_le_nhds).mono fun y hy _ => hy.le | |
| Β· exact Filter.Eventually.of_forall fun _ h => (hS h).elim | |
| filter_upwards [hn,hodd,eventually_mem_nhdsWithin] with y hn hodd hy | |
| refine β¨hn,?_,hoddβ© | |
| intro v | |
| rw [degree_add_smul,degree_sub,hx.2.1,hy.2.1] | |
| ring | |
| theorem polytope_eventually_expand (G : LooplessGraph V E) {x : E β β} | |
| (heven : Even (Fintype.card V)) (hx : x β G.polytope) {t : β} (ht : 0<t) : | |
| βαΆ y in π[G.polytope] x, x+tβ»ΒΉ β’ (y-x) β G.polytope := by | |
| rw [G.polytope_eq_constraints heven] at hx β’ | |
| exact G.constraint_eventually_expand hx ht | |
| end MatchingEntropyBounds.LooplessGraph | |
| end | |
| end OAI | |