Download data/lean/OAI/Combinatorics/MatchingCount/Graphs/Related2.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 18.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/Related2.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Graphs/Related2.lean
-
curl -L -o Related2.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/Related2.lean
18.8 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Sampling.DiscreteLadderSteps | |
| namespace OAI | |
| namespace MatchingFPRAS.NumberedHierarchy | |
| open Finset | |
| variable {V : Type*} [Fintype V] [LinearOrder V] | |
| variable (B : V β V β β) | |
| def related (t : β) (x y : V) : Prop := x=y β¨ tβ€B x y | |
| instance relatedDec (t : β) (x y : V) : Decidable (related B t x y) := | |
| inferInstanceAs (Decidable (x=y β¨ tβ€B x y)) | |
| def component (t : β) (x : V) : Finset V := univ.filter (related B t x) | |
| lemma component_self (t : β) (x : V) : xβcomponent B t x := by simp [component,related] | |
| def root (t : β) (x : V) : V := (component B t x).min' β¨x,component_self B t xβ© | |
| lemma root_mem (t : β) (x : V) : root B t x β component B t x := min'_mem _ _ | |
| lemma related_root (t : β) (x : V) : related B t x (root B t x) := by | |
| simpa [component] using root_mem B t x | |
| omit [Fintype V] [LinearOrder V] in | |
| lemma cast_related [Fintype V] [LinearOrder V] (t : β) (x y : V) : | |
| related B t x y β Hierarchy.Related (fun x y=>(B x y:β)) (t:β) x y := by | |
| simp only [related,Hierarchy.Related,Rat.cast_le] | |
| variable (hsym : β x y,B x y=B y x) | |
| variable (htri : β x y z,xβ y β xβ z β yβ z β min (B x z) (B z y)β€B x y) | |
| include hsym in | |
| omit [Fintype V] [LinearOrder V] in | |
| lemma symmetric [Fintype V] [LinearOrder V] : β x y,(B x y:β)=(B y x:β) := by intro x y; rw [hsym] | |
| include htri in | |
| omit [Fintype V] [LinearOrder V] in | |
| lemma triangular [Fintype V] [LinearOrder V] : β x y z,xβ y β xβ z β yβ z β | |
| min (B x z:β) (B z y:β)β€(B x y:β) := by | |
| intro x y z hxy hxz hyz | |
| exact_mod_cast htri x y z hxy hxz hyz | |
| lemma related_trans (_hsym : β x y,B x y=B y x) | |
| (htri : β x y z,xβ y β xβ z β yβ z β min (B x z) (B z y)β€B x y) | |
| (t : β) {x y z : V} (hxy : related B t x y) (hyz : related B t y z) : | |
| related B t x z := by | |
| rw [cast_related] at * | |
| exact Hierarchy.related_trans _ (triangular B htri) _ hxy hyz | |
| include hsym in | |
| omit [Fintype V] [LinearOrder V] in | |
| lemma related_symm [Fintype V] [LinearOrder V] (t : β) {x y : V} | |
| (hxy : related B t x y) : related B t y x := by | |
| rcases hxy with rfl|h | |
| Β· exact Or.inl rfl | |
| Β· exact Or.inr (by rwa [hsym]) | |
| include hsym htri in | |
| lemma component_eq_iff (t : β) (x y : V) : component B t x=component B t y β related B t x y := by | |
| constructor | |
| Β· intro h | |
| have := component_self B t y | |
| rw [βh] at this | |
| simpa [component] using this | |
| Β· intro h | |
| ext z | |
| simp only [component,mem_filter,mem_univ,true_and] | |
| exact β¨fun hx=>related_trans B hsym htri t (related_symm B hsym t h) hx, | |
| fun hy=>related_trans B hsym htri t h hyβ© | |
| include hsym htri in | |
| lemma root_eq_iff (t : β) (x y : V) : root B t x=root B t y β related B t x y := by | |
| constructor | |
| Β· intro h | |
| have hx := related_root B t x | |
| rw [h] at hx | |
| exact related_trans B hsym htri t hx (related_symm B hsym t (related_root B t y)) | |
| Β· intro h | |
| unfold root | |
| congr 1 | |
| exact (component_eq_iff B hsym htri t x y).mpr h | |
| include hsym htri in | |
| lemma root_idem (t : β) (x : V) : root B t (root B t x)=root B t x := | |
| (root_eq_iff B hsym htri t _ _).mpr (related_symm B hsym t (related_root B t x)) | |
| abbrev NumberedComponent (t : β) := {x : V // root B t x=x} | |
| def classOf (t : β) (x : V) : NumberedComponent B t := β¨root B t x,root_idem B hsym htri t xβ© | |
| def quotientEquiv (t : β) : | |
| Hierarchy.Component (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri) (t:β) β | |
| NumberedComponent B t where | |
| toFun := Quotient.lift (classOf B hsym htri t) (by | |
| intro x y h | |
| apply Subtype.ext | |
| exact (root_eq_iff B hsym htri t x y).mpr ((cast_related B t x y).mpr h)) | |
| invFun x := Quotient.mk _ x.val | |
| left_inv := by | |
| intro x | |
| induction x using Quotient.inductionOn with | h x => | |
| apply Quotient.sound | |
| exact (cast_related B t _ _).mp (related_symm B hsym t (related_root B t x)) | |
| right_inv := by intro x; apply Subtype.ext; exact x.property | |
| def level (H : β) (x : β) : Fin (H+1) := | |
| β¨Nat.findGreatest (fun k => (2:β)^kβ€x) H,Nat.lt_succ_of_le (Nat.findGreatest_le H)β© | |
| lemma level_cast (H : β) (x : β) : level H x=Hierarchy.dyadicLevel H (x:β) := by | |
| apply Fin.ext | |
| change Nat.findGreatest (fun k => (2:β)^kβ€x) H = Nat.findGreatest (fun k => (2:β)^kβ€(x:β)) H | |
| have h : (fun k => (2:β)^kβ€x) = (fun k => (2:β)^kβ€(x:β)) := by | |
| funext k | |
| apply propext | |
| norm_cast | |
| simp only [h] | |
| abbrev Label (H : β) := (k : Fin (H+1)) Γ NumberedComponent B ((2:β)^k.val) | |
| def labelAt {H : β} (k : Fin (H+1)) (x : V) : Label B H := | |
| β¨k,classOf B hsym htri _ xβ© | |
| def member {H : β} (l : Label B H) (x : V) : Prop := root B ((2:β)^l.1.val) x=l.2.val | |
| instance memberDec {H : β} (l : Label B H) (x : V) : Decidable (member B l x) := | |
| inferInstanceAs (Decidable (root B _ x=l.2.val)) | |
| lemma member_self {H : β} (l : Label B H) : member B l l.2.val := l.2.property | |
| def parent {H : β} (l : Label B H) : Option (Label B H) := | |
| if h : 0<l.1.val then some (labelAt B hsym htri β¨l.1.val-1,by omegaβ© l.2.val) else none | |
| lemma parent_rank {H : β} {l p : Label B H} (h : parent B hsym htri l=some p) : p.1.val<l.1.val := by | |
| unfold parent at h | |
| split_ifs at h with hl | |
| Β· cases h | |
| simp only [labelAt] | |
| omega | |
| lemma label_card_bound (H : β) : Fintype.card (Label B H)β€(H+1)*Fintype.card V := by | |
| rw [Fintype.card_sigma] | |
| calc | |
| _ β€ β k : Fin (H+1),Fintype.card V := sum_le_sum (fun k _=>Fintype.card_subtype_le _) | |
| _ = _ := by simp | |
| def componentEquiv (k : β) : | |
| Hierarchy.Component (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri) ((2:β)^k) β | |
| NumberedComponent B ((2:β)^k) where | |
| toFun := Quotient.lift (classOf B hsym htri ((2:β)^k)) (by | |
| intro x y h | |
| apply Subtype.ext | |
| apply (root_eq_iff B hsym htri _ x y).mpr | |
| apply (cast_related B ((2:β)^k) x y).mpr | |
| change Hierarchy.Related (fun x y=>(B x y:β)) ((2:β)^k) x y at h | |
| simpa only [Rat.cast_pow,Rat.cast_ofNat] using h) | |
| invFun x := Quotient.mk _ x.val | |
| left_inv := by | |
| intro x | |
| induction x using Quotient.inductionOn with | h x => | |
| apply Quotient.sound | |
| change Hierarchy.Related (fun x y=>(B x y:β)) ((2:β)^k) (root B ((2:β)^k) x) x | |
| have h := (cast_related B ((2:β)^k) _ _).mp | |
| (related_symm B hsym ((2:β)^k) (related_root B ((2:β)^k) x)) | |
| simpa only [Rat.cast_pow,Rat.cast_ofNat] using h | |
| right_inv := by intro x; apply Subtype.ext; exact x.property | |
| def labelEquiv (H : β) : | |
| Hierarchy.Label (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri) H β Label B H := | |
| Equiv.sigmaCongrRight (fun k=>componentEquiv B hsym htri k.val) | |
| lemma componentEquiv_mk (k : β) (x : V) : | |
| componentEquiv B hsym htri k (Quotient.mk _ x)=classOf B hsym htri ((2:β)^k) x := by | |
| rfl | |
| lemma labelEquiv_at {H : β} (k : Fin (H+1)) (x : V) : | |
| labelEquiv B hsym htri H (Hierarchy.labelAt _ _ _ k x)=labelAt B hsym htri k x := by | |
| simp [labelEquiv,Hierarchy.labelAt,labelAt,componentEquiv_mk] | |
| lemma labelEquiv_level {H : β} (l : Hierarchy.Label (fun x y=>(B x y:β)) | |
| (symmetric B hsym) (triangular B htri) H) : | |
| (labelEquiv B hsym htri H l).1=l.1 := rfl | |
| lemma member_labelAt {H : β} (k : Fin (H+1)) (x y : V) : | |
| member B (labelAt B hsym htri k x) y β related B ((2:β)^k.val) y x := by | |
| exact root_eq_iff B hsym htri _ y x | |
| lemma member_equiv {H : β} (l : Hierarchy.Label (fun x y=>(B x y:β)) | |
| (symmetric B hsym) (triangular B htri) H) (x : V) : | |
| member B (labelEquiv B hsym htri H l) x β | |
| Hierarchy.Mem (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri) l x := by | |
| obtain β¨k,lβ©:=l | |
| induction l using Quotient.inductionOn with | h y => | |
| change member B (labelEquiv B hsym htri H (Hierarchy.labelAt _ _ _ k y)) x β _ | |
| rw [labelEquiv_at,member_labelAt] | |
| change related B ((2:β)^k.val) x y β Hierarchy.Mem _ _ _ (Hierarchy.labelAt _ _ _ k y) x | |
| rw [Hierarchy.mem_class_iff] | |
| simpa only [Rat.cast_pow,Rat.cast_ofNat] using cast_related B ((2:β)^k.val) x y | |
| lemma parent_iff {H : β} (l p : Label B H) : parent B hsym htri l=some p β | |
| p.1.val+1=l.1.val β§ member B p l.2.val := by | |
| obtain β¨k,lβ©:=l | |
| obtain β¨j,pβ©:=p | |
| unfold parent | |
| split_ifs with hl | |
| Β· change 0<k.val at hl | |
| constructor | |
| Β· intro h | |
| have he := Option.some.inj h | |
| have hk := congrArg (fun l : Label B H => l.1.val) he | |
| constructor | |
| Β· change j.val+1=k.val | |
| change k.val-1=j.val at hk | |
| omega | |
| Β· rw [βhe] | |
| rfl | |
| Β· rintro β¨hp,hmβ© | |
| change j.val+1=k.val at hp | |
| have hj : j=(β¨k.val-1,Nat.lt_of_le_of_lt (Nat.sub_le _ _) k.isLtβ© : Fin (H+1)) := by | |
| apply Fin.ext | |
| change j.val=k.val-1 | |
| omega | |
| cases hj | |
| congr 1 | |
| apply congrArg (Sigma.mk _) | |
| exact Subtype.ext hm | |
| Β· constructor | |
| Β· intro h; cases h | |
| Β· rintro β¨hp,_β© | |
| change j.val+1=k.val at hp | |
| change Β¬0<k.val at hl | |
| omega | |
| lemma parent_equiv_iff {H : β} | |
| (l p : Hierarchy.Label (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri) H) : | |
| parent B hsym htri (labelEquiv B hsym htri H l)=some (labelEquiv B hsym htri H p) β | |
| Hierarchy.Parent (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri) p l := by | |
| rw [parent_iff] | |
| change (p.1.val+1=l.1.val β§ _) β _ | |
| let v := (labelEquiv B hsym htri H l).2.val | |
| have hl : Hierarchy.Mem _ (symmetric B hsym) (triangular B htri) l v := | |
| (member_equiv B hsym htri l v).mp (member_self B _) | |
| constructor | |
| Β· rintro β¨hp,hmβ© | |
| exact β¨hp,v,(member_equiv B hsym htri p v).mp hm,hlβ© | |
| Β· intro h | |
| exact β¨h.1,(member_equiv B hsym htri p v).mpr (Hierarchy.parent_mem _ _ _ h hl)β© | |
| variable {E : Type*} [Fintype E] [DecidableEq E] (left right : E β V) | |
| def edgeLabel (H : β) (e : E) : Label B H := | |
| labelAt B hsym htri (level H (B (left e) (right e))) (left e) | |
| def bags (H : β) (x : V) : Finset (Label B H) := | |
| (univ.filter (fun e=>x=left e β¨ x=right e)).image (edgeLabel B hsym htri left right H) | |
| omit [Fintype E] [DecidableEq E] in | |
| lemma edgeLabel_equiv [Fintype E] [DecidableEq E] (H : β) (e : E) : | |
| labelEquiv B hsym htri H (Hierarchy.edgeLabel (fun x y=>(B x y:β)) | |
| (symmetric B hsym) (triangular B htri) left right H e)=edgeLabel B hsym htri left right H e := by | |
| unfold Hierarchy.edgeLabel edgeLabel | |
| rw [βlevel_cast] | |
| exact labelEquiv_at B hsym htri _ _ | |
| omit [DecidableEq E] in | |
| lemma mem_bags [DecidableEq E] (H : β) (x : V) (l : Label B H) : | |
| lβbags B hsym htri left right H x β | |
| β e,(x=left e β¨ x=right e) β§ edgeLabel B hsym htri left right H e=l := by | |
| simp [bags] | |
| lemma bags_equiv (H : β) (x : V) : | |
| (Hierarchy.memberships (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri) | |
| left right H x).image (labelEquiv B hsym htri H)=bags B hsym htri left right H x := by | |
| classical | |
| ext l | |
| simp only [mem_image,mem_bags,Hierarchy.mem_memberships,Hierarchy.Incident] | |
| constructor | |
| Β· rintro β¨a,β¨e,he,heaβ©,halβ© | |
| refine β¨e,he,?_β© | |
| rw [βedgeLabel_equiv,hea,hal] | |
| Β· rintro β¨e,he,helβ© | |
| refine β¨_,β¨e,he,rflβ©,?_β© | |
| rwa [edgeLabel_equiv] | |
| omit [DecidableEq E] in | |
| lemma bags_card_edges [DecidableEq E] (H : β) (x : V) : | |
| (bags B hsym htri left right H x).cardβ€Fintype.card E := by | |
| exact card_image_le.trans ((card_filter_le _ _).trans_eq (card_univ)) | |
| end MatchingFPRAS.NumberedHierarchy | |
| namespace MatchingFPRAS.RationalSource | |
| open MatchingFPRAS Switching Subdivision RealGeometry Enlargement Finset | |
| variable {V : Type*} [Fintype V] [LinearOrder V] [Nontrivial V] | |
| def logicalB (w : V β V β β) : V β V β β := | |
| BottleneckAlgorithm.close w (Fintype.card V) | |
| omit [Nontrivial V] in | |
| lemma logicalB_cast [Nontrivial V] (w : V β V β β) (x y : V) : | |
| (logicalB w x y:β)=bottleneck (fun x y=>(w x y:β)) x y := | |
| BottleneckAlgorithm.rational_close_eq w x y | |
| def height (w : V β V β β) (x : V) : β := | |
| (univ.erase x).sup' (row_nonempty x) (logicalB w x) | |
| lemma height_cast (w : V β V β β) (x : V) : | |
| (height w x:β)=sourceHeight (fun x y=>(w x y:β)) x := by | |
| unfold height sourceHeight | |
| rw [Finset.apply_sup'_eq_sup'_comp _ (fun x:β=>(x:β)) (by intro x y; exact Rat.cast_max x y)] | |
| apply Finset.sup'_congr _ rfl | |
| intro y _ | |
| exact logicalB_cast w x y | |
| def maxHeight (w : V β V β β) : β := univ.sup' univ_nonempty (height w) | |
| lemma maxHeight_cast (w : V β V β β) : | |
| (maxHeight w:β)=maxSourceHeight (fun x y=>(w x y:β)) := by | |
| unfold maxHeight maxSourceHeight | |
| rw [Finset.apply_sup'_eq_sup'_comp _ (fun x:β=>(x:β)) (by intro x y; exact Rat.cast_max x y)] | |
| apply Finset.sup'_congr _ rfl | |
| intro x _ | |
| exact height_cast w x | |
| def levels (w : V β V β β) (K : β) : β := | |
| (NumberedHierarchy.level (2*K) (maxHeight w)).val | |
| lemma levels_eq (w : V β V β β) (K : β) : | |
| levels w K=sourceLevels (fun x y=>(w x y:β)) K := by | |
| simp only [levels,NumberedHierarchy.level_cast,maxHeight_cast,sourceLevels] | |
| def profile (p : β) (B Hu Hv lam : β) (i : Fin (4*p+1)) : β := | |
| if i.val<2*p then max B (Hu/2^(i.val/2)) | |
| else if i.val=2*p then lam else max B (Hv/2^((4*p-i.val)/2)) | |
| lemma profile_cast (p : β) (B Hu Hv lam : β) (i : Fin (4*p+1)) : | |
| (profile p B Hu Hv lam i:β)=profileActivity p B Hu Hv lam i := by | |
| rcases lt_trichotomy i.val (2*p) with h|h|h | |
| Β· rw [profile,ite_eq_left h,profile_left _ _ _ _ _ _ h] | |
| norm_cast | |
| Β· have he : i=β¨2*p,by omegaβ©:=Fin.ext h | |
| rw [he] | |
| simp [profile] | |
| Β· rw [profile,ite_eq_right (by omega),ite_eq_right (by omega),profile_right _ _ _ _ _ _ h] | |
| norm_cast | |
| def pathActivity (w : V β V β β) (K : β) (e : LogicalEdge V) : Fin (4*(2*K+2)+1) β β := | |
| profile (2*K+2) (logicalB w (source e) (target e)) (height w (source e)) | |
| (height w (target e)) (BottleneckAlgorithm.edge w (source e) (target e)) | |
| lemma pathActivity_cast (w : V β V β β) (K : β) (e : LogicalEdge V) (i : Fin (4*(2*K+2)+1)) : | |
| (pathActivity w K e i:β) = Enlargement.pathActivity (2*K+2) | |
| (fun e=>bottleneck (fun x y=>(w x y:β)) (source e) (target e)) | |
| (fun e=>sourceHeight (fun x y=>(w x y:β)) (source e)) | |
| (fun e=>sourceHeight (fun x y=>(w x y:β)) (target e)) | |
| (logicalActivity (fun x y=>(w x y:β))) e i := by | |
| rw [pathActivity,profile_cast,logicalB_cast,height_cast,height_cast] | |
| congr 1 | |
| have he : source e<target e:=e.property | |
| simp [BottleneckAlgorithm.edge,logicalActivity,edgeActivity,he] | |
| def activity (w : V β V β β) (K : β) (x y : SourceVertex V K) : β := | |
| β q : SourceRealEdge V K, | |
| if RealGeometry.edge source target (4*(2*K+2)) q.1 q.2=s(x,y) | |
| then pathActivity w K q.1 q.2 else 0 | |
| lemma activity_cast (w : V β V β β) (K : β) (x y : SourceVertex V K) : | |
| (activity w K x y:β)=RealGeometry.activity source target (4*(2*K+2)) | |
| (Enlargement.pathActivity (2*K+2) | |
| (fun e=>bottleneck (fun x y=>(w x y:β)) (source e) (target e)) | |
| (fun e=>sourceHeight (fun x y=>(w x y:β)) (source e)) | |
| (fun e=>sourceHeight (fun x y=>(w x y:β)) (target e)) | |
| (logicalActivity (fun x y=>(w x y:β)))) x y := by | |
| unfold activity RealGeometry.activity | |
| push_cast | |
| apply sum_congr rfl | |
| intro q _ | |
| split_ifs | |
| Β· exact pathActivity_cast w K q.1 q.2 | |
| Β· norm_cast | |
| def realB (w : V β V β β) (K : β) : SourceVertex V K β SourceVertex V K β β := | |
| BottleneckAlgorithm.close (activity w K) (Fintype.card (SourceVertex V K)) | |
| lemma realB_cast (w : V β V β β) (K : β) (x y : SourceVertex V K) : | |
| (realB w K x y:β)=sourceRealB (fun x y=>(w x y:β)) K x y := by | |
| rw [realB,BottleneckAlgorithm.rational_close_eq] | |
| unfold sourceRealB realBottleneck | |
| congr 2 | |
| funext a b | |
| exact activity_cast w K a b | |
| lemma realB_symm (w : V β V β β) (K : β) (x y : SourceVertex V K) : | |
| realB w K x y=realB w K y x := by | |
| apply Rat.cast_injective (Ξ±:=β) | |
| simp only [realB_cast,sourceRealB_comm] | |
| lemma realB_tri (w : V β V β β) (K : β) (x y z : SourceVertex V K) | |
| (hxy : xβ y) (hxz : xβ z) (hyz : yβ z) : | |
| min (realB w K x z) (realB w K z y)β€realB w K x y := by | |
| apply (Rat.cast_le (K:=β)).mp | |
| simp only [Rat.cast_min,realB_cast] | |
| exact sourceRealB_tri _ _ _ _ _ hxy hxz hyz | |
| abbrev Label (w : V β V β β) (K : β) := NumberedHierarchy.Label (realB w K) (levels w K) | |
| def bags (w : V β V β β) (K : β) : SourceVertex V K β Finset (Label w K) := | |
| NumberedHierarchy.bags (realB w K) (realB_symm w K) (realB_tri w K) | |
| (realLeft K) (realRight K) (levels w K) | |
| theorem label_card (w : V β V β β) (K : β) : | |
| Fintype.card (Label w K)β€(2*K+1)*Fintype.card (SourceVertex V K) := by | |
| calc | |
| _ β€ (levels w K+1)*Fintype.card (SourceVertex V K) := by | |
| rw [Fintype.card_sigma] | |
| calc | |
| _ β€ β k : Fin (levels w K+1),Fintype.card (SourceVertex V K) := | |
| sum_le_sum (fun k _=>Fintype.card_subtype_le _) | |
| _ = _ := by simp | |
| _ β€ _ := by | |
| apply Nat.mul_le_mul_right | |
| rw [levels_eq] | |
| exact Nat.add_le_add_right (sourceLevels_le _ _) 1 | |
| noncomputable def sourceLabelsEquiv (w : V β V β β) (K : β) : | |
| SourceLabel (fun x y=>(w x y:β)) K β Label w K := by | |
| simpa only [SourceLabel,Label,realB_cast,levels_eq] using | |
| (NumberedHierarchy.labelEquiv (realB w K) (realB_symm w K) (realB_tri w K) (levels w K)) | |
| lemma bags_card_le_two (w : V β V β β) (K : β) | |
| (hw : β x y,xβ y β BottleneckAlgorithm.edge w x y β€ (4:β)^K) (x : SourceVertex V K) : | |
| (bags w K x).cardβ€2 := by | |
| have he := NumberedHierarchy.bags_equiv (realB w K) (realB_symm w K) (realB_tri w K) | |
| (realLeft K) (realRight K) (levels w K) x | |
| rw [bags,βhe] | |
| apply Finset.card_image_le.trans | |
| have hw' : β x y,xβ y β edgeActivity (fun x y=>(w x y:β)) x y β€ (4:β)^K := by | |
| intro a b hab | |
| have ha:=hw a b hab | |
| have hec : ((BottleneckAlgorithm.edge w a b:β):β)=edgeActivity (fun x y=>(w x y:β)) a b := by | |
| unfold BottleneckAlgorithm.edge edgeActivity | |
| split_ifs <;> norm_cast | |
| simpa only [hec,Rat.cast_pow,Rat.cast_ofNat] using (Rat.cast_le (K:=β)).mpr ha | |
| apply Hierarchy.membership_count | |
| Β· intro a b | |
| rw [realB_cast] | |
| exact sourceRealB_floor _ _ a b | |
| Β· intro e | |
| simpa only [realB_cast,levels_eq] using | |
| (source_strength_le_max (fun x y=>(w x y:β)) K hw' e).trans_lt | |
| (maxSourceHeight_lt (fun x y=>(w x y:β)) K hw') | |
| Β· intro a e f he hf | |
| simpa only [realB_cast] using source_strength_incident_near | |
| (fun x y=>(w x y:β)) K hw' a e f he hf | |
| end MatchingFPRAS.RationalSource | |
| end OAI | |