Download data/lean/OAI/Combinatorics/MatchingCount/Graphs/LabelOrder.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 23.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/LabelOrder.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Graphs/LabelOrder.lean
-
curl -L -o LabelOrder.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/LabelOrder.lean
23.8 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Graphs.Related2 | |
| namespace OAI | |
| namespace MatchingFPRAS.NumberedHierarchy | |
| open Finset MatchingFPRAS.UnitRefresh | |
| variable {V : Type*} [Fintype V] [LinearOrder V] | |
| variable (B : V β V β β) (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) | |
| @[instance_reducible] def labelOrder (H : β) : LinearOrder (Label B H) := | |
| LinearOrder.lift' (fun l : Label B H=>toLex (l.1,l.2.val)) (by | |
| intro a b h | |
| have h' := toLex.injective h | |
| obtain β¨k,aβ©:=a | |
| obtain β¨j,bβ©:=b | |
| have hk : k=j:=congrArg Prod.fst h' | |
| cases hk | |
| exact congrArg (Sigma.mk k) (Subtype.ext (congrArg Prod.snd h'))) | |
| attribute [local instance] labelOrder | |
| noncomputable def abstractTree (H : β) : SimpleGraph (Label B H) := | |
| (Hierarchy.tree (fun x y=>(B x y:β)) (symmetric B hsym) (triangular B htri)).comap | |
| (labelEquiv B hsym htri H).symm | |
| lemma abstractTree_acyclic (H : β) : (abstractTree B hsym htri H).IsAcyclic := by | |
| exact SimpleGraph.IsAcyclic.of_comap (labelEquiv B hsym htri H).symm.toEmbedding | |
| (Hierarchy.tree_acyclic _ _ _ _) | |
| lemma abstractTree_adj (H : β) (a b : Label B H) : | |
| (abstractTree B hsym htri H).Adj a b β | |
| parent B hsym htri b=some a β¨ parent B hsym htri a=some b := by | |
| change (Hierarchy.Parent _ _ _ ((labelEquiv B hsym htri H).symm a) ((labelEquiv B hsym htri H).symm b) β¨ | |
| Hierarchy.Parent _ _ _ ((labelEquiv B hsym htri H).symm b) ((labelEquiv B hsym htri H).symm a)) β _ | |
| have ha:=parent_equiv_iff B hsym htri ((labelEquiv B hsym htri H).symm b) ((labelEquiv B hsym htri H).symm a) | |
| have hb:=parent_equiv_iff B hsym htri ((labelEquiv B hsym htri H).symm a) ((labelEquiv B hsym htri H).symm b) | |
| simpa only [Equiv.apply_symm_apply] using or_congr ha.symm hb.symm | |
| def tree (H : β) : SimpleGraph (Label B H) where | |
| Adj a b := parent B hsym htri b=some a β¨ parent B hsym htri a=some b | |
| symm := β¨fun _ _ h=>Or.symm hβ© | |
| loopless := β¨by intro a h; rcases h with h|h <;> exact (Nat.lt_irrefl _ (parent_rank B hsym htri h))β© | |
| instance treeDec (H : β) : DecidableRel (tree B hsym htri H).Adj := by | |
| intro a b | |
| exact inferInstanceAs (Decidable (parent B hsym htri b=some a β¨ parent B hsym htri a=some b)) | |
| lemma tree_adj (H : β) (a b : Label B H) : | |
| (tree B hsym htri H).Adj a b β | |
| parent B hsym htri b=some a β¨ parent B hsym htri a=some b := Iff.rfl | |
| lemma tree_eq (H : β) : tree B hsym htri H=abstractTree B hsym htri H := by | |
| ext a b | |
| exact (abstractTree_adj B hsym htri H a b).symm | |
| lemma tree_acyclic (H : β) : (tree B hsym htri H).IsAcyclic := by | |
| rw [tree_eq] | |
| exact abstractTree_acyclic B hsym htri H | |
| variable {E : Type*} [Fintype E] [DecidableEq E] (left right : E β V) | |
| lemma bags_nonempty (H : β) (hx : β x,β e,x=left e β¨ x=right e) (x : V) : | |
| (bags B hsym htri left right H x).Nonempty := by | |
| obtain β¨e,heβ©:=hx x | |
| exact β¨_,(mem_bags _ _ _ _ _ _ _ _).mpr β¨e,he,rflβ©β© | |
| lemma bags_adjacent (H : β) (hfloor : β x y,1β€B x y) | |
| (hmax : β e,B (left e) (right e)<(2:β)^(H+1)) | |
| (hnear : β x e f,Hierarchy.Incident left right e x β Hierarchy.Incident left right f x β | |
| B (left e) (right e)β€2*B (left f) (right f)) : | |
| β x a,aβbags B hsym htri left right H x β β bβbags B hsym htri left right H x, | |
| a=b β¨ (tree B hsym htri H).Adj a b := by | |
| intro x a ha b hb | |
| rw [βbags_equiv] at ha hb | |
| obtain β¨a',ha',rflβ©:=mem_image.mp ha | |
| obtain β¨b',hb',rflβ©:=mem_image.mp hb | |
| have hf : β x y,1β€(B x y:β) := by intro x y; exact_mod_cast hfloor x y | |
| have hm : β e,(B (left e) (right e):β)<(2:β)^(H+1) := by | |
| intro e; exact_mod_cast hmax e | |
| have hn : β x e f,Hierarchy.Incident left right e x β Hierarchy.Incident left right f x β | |
| (B (left e) (right e):β)β€2*(B (left f) (right f):β) := by | |
| intro x e f he hf; exact_mod_cast hnear x e f he hf | |
| have h:=Hierarchy.memberships_tree_bags (fun x y=>(B x y:β)) (symmetric B hsym) | |
| (triangular B htri) hf left right H hm hn x a' b' ha' hb' | |
| rcases h with h|h | |
| Β· exact Or.inl (congrArg _ h) | |
| Β· exact Or.inr (by simpa only [tree_eq,abstractTree,SimpleGraph.comap_adj,Equiv.symm_apply_apply] using h) | |
| lemma bags_ranked (H : β) (hfloor : β x y,1β€B x y) | |
| (hmax : β e,B (left e) (right e)<(2:β)^(H+1)) | |
| (hnear : β x e f,Hierarchy.Incident left right e x β Hierarchy.Incident left right f x β | |
| B (left e) (right e)β€2*B (left f) (right f)) : | |
| RankedBags (bags B hsym htri left right H) (fun l=>l.1.val) (parent B hsym htri) := by | |
| intro x a ha b hb hab | |
| rcases bags_adjacent B hsym htri left right H hfloor hmax hnear x a ha b hb with h|h | |
| Β· exact (hab h).elim | |
| Β· rcases (tree_adj B hsym htri H a b).mp h with h|h | |
| Β· exact Or.inl β¨parent_rank B hsym htri h,hβ© | |
| Β· exact Or.inr β¨parent_rank B hsym htri h,hβ© | |
| omit [Fintype E] [DecidableEq E] in | |
| lemma height_step (H : β) (a b : Label B H) (h : (tree B hsym htri H).Adj a b) : | |
| (2:β)^a.1.val β€ 2*(2:β)^b.1.val := by | |
| rcases (tree_adj B hsym htri H a b).mp h with h|h | |
| Β· have hh:=((parent_iff B hsym htri b a).mp h).1 | |
| rw [βhh,pow_succ] | |
| have hp : 0β€(2:β)^a.1.val := by positivity | |
| nlinarith | |
| Β· have hh:=((parent_iff B hsym htri a b).mp h).1 | |
| rw [βhh,pow_succ] | |
| ring_nf | |
| exact le_rfl | |
| end MatchingFPRAS.NumberedHierarchy | |
| namespace MatchingFPRAS.RationalSource | |
| open Finset MatchingFPRAS.Switching MatchingFPRAS.Subdivision MatchingFPRAS.RealGeometry | |
| open MatchingFPRAS.Hierarchy MatchingFPRAS.Transport MatchingFPRAS.Enlargement | |
| variable {V : Type*} [Fintype V] [LinearOrder V] [Nontrivial V] | |
| attribute [local instance] NumberedHierarchy.labelOrder sym2Order bagEdgeOrder bagEdgeFintype | |
| attribute [local instance] UnitRefresh.Computable.allowedDec | |
| def parent (w : V β V β β) (K : β) : Label w K β Option (Label w K) := | |
| NumberedHierarchy.parent (realB w K) (realB_symm w K) (realB_tri w K) | |
| def tree (w : V β V β β) (K : β) : SimpleGraph (Label w K) := | |
| NumberedHierarchy.tree (realB w K) (realB_symm w K) (realB_tri w K) (levels w K) | |
| lemma tree_acyclic (w : V β V β β) (K : β) : (tree w K).IsAcyclic := | |
| NumberedHierarchy.tree_acyclic _ _ _ _ | |
| lemma parent_rank (w : V β V β β) (K : β) (l p : Label w K) | |
| (h : parent w K l=some p) : p.1.val<l.1.val := | |
| NumberedHierarchy.parent_rank _ _ _ h | |
| omit [Fintype V] [Nontrivial V] in | |
| lemma raw_cast [Fintype V] [Nontrivial V] (w : V β V β β) (K : β) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) : | |
| β x y,xβ y β edgeActivity (fun x y=>(w x y:β)) x yβ€(4:β)^K := by | |
| intro x y hxy | |
| have he : ((BottleneckAlgorithm.edge w x y:β):β)=edgeActivity (fun x y=>(w x y:β)) x y := by | |
| unfold BottleneckAlgorithm.edge edgeActivity | |
| split_ifs <;> rfl | |
| simpa only [he,Rat.cast_pow,Rat.cast_ofNat] using (Rat.cast_le (K:=β)).mpr (h x y hxy) | |
| lemma realB_floor (w : V β V β β) (K : β) (x y : SourceVertex V K) : 1β€realB w K x y := by | |
| apply (Rat.cast_le (K:=β)).mp | |
| simpa only [Rat.cast_one,realB_cast] using sourceRealB_floor (fun x y=>(w x y:β)) K x y | |
| lemma realB_upper (w : V β V β β) (K : β) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) (e : SourceRealEdge V K) : | |
| realB w K (realLeft K e) (realRight K e)<(2:β)^(levels w K+1) := by | |
| apply (Rat.cast_lt (K:=β)).mp | |
| simpa only [realB_cast,levels_eq,Rat.cast_pow,Rat.cast_ofNat] using | |
| (source_strength_le_max (fun x y=>(w x y:β)) K (raw_cast w K h) e).trans_lt | |
| (maxSourceHeight_lt (fun x y=>(w x y:β)) K (raw_cast w K h)) | |
| lemma realB_near (w : V β V β β) (K : β) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (x : SourceVertex V K) (e f : SourceRealEdge V K) | |
| (he : Hierarchy.Incident (realLeft K) (realRight K) e x) | |
| (hf : Hierarchy.Incident (realLeft K) (realRight K) f x) : | |
| realB w K (realLeft K e) (realRight K e)β€2*realB w K (realLeft K f) (realRight K f) := by | |
| apply (Rat.cast_le (K:=β)).mp | |
| simpa only [realB_cast,Rat.cast_mul,Rat.cast_ofNat] using | |
| source_strength_incident_near (fun x y=>(w x y:β)) K (raw_cast w K h) x e f he hf | |
| lemma bags_adjacent (w : V β V β β) (K : β) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) : | |
| β x a,aβbags w K x β β bβbags w K x,a=b β¨ (tree w K).Adj a b := | |
| NumberedHierarchy.bags_adjacent _ _ _ _ _ _ (realB_floor w K) (realB_upper w K h) (realB_near w K h) | |
| lemma bags_ranked (w : V β V β β) (K : β) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) : | |
| UnitRefresh.RankedBags (bags w K) (fun l=>l.1.val) (parent w K) := | |
| NumberedHierarchy.bags_ranked _ _ _ _ _ _ (realB_floor w K) (realB_upper w K h) (realB_near w K h) | |
| omit [Fintype V] in | |
| lemma incident_exists [Fintype V] (K : β) (x : SourceVertex V K) : | |
| β e,Hierarchy.Incident (realLeft K) (realRight K) e x := by | |
| cases x with | |
| | inl x => | |
| obtain β¨y,hyβ© := exists_ne x | |
| rcases lt_or_gt_of_ne hy with h | h | |
| Β· let e : LogicalEdge V := β¨(y,x),hβ© | |
| refine β¨(e,Fin.last (4*(2*K+2))),Or.inr ?_β© | |
| simp [realRight,atVertex_last,target,e] | |
| Β· let e : LogicalEdge V := β¨(x,y),hβ© | |
| refine β¨(e,0),Or.inl ?_β© | |
| simp [realLeft,atVertex_zero,source,e] | |
| | inr q => | |
| obtain β¨e,iβ© := q | |
| refine β¨(e,i.castSucc),Or.inr ?_β© | |
| change Sum.inr (e,i)=atVertex source target _ e i.castSucc.succ | |
| have he : i.castSucc.succ=i.succ.castSucc := Fin.ext rfl | |
| rw [he,atVertex_internal] | |
| lemma bags_nonempty (w : V β V β β) (K : β) (x : SourceVertex V K) : | |
| (bags w K x).Nonempty := | |
| NumberedHierarchy.bags_nonempty _ _ _ _ _ _ (incident_exists K) x | |
| def realLabel (w : V β V β β) (K : β) (e : SourceRealEdge V K) : Label w K := | |
| NumberedHierarchy.edgeLabel (realB w K) (realB_symm w K) (realB_tri w K) | |
| (realLeft K) (realRight K) (levels w K) e | |
| omit [Nontrivial V] in | |
| lemma real_not_diag [Nontrivial V] (K : β) (e : SourceRealEdge V K) : | |
| Β¬(edge source target (4*(2*K+2)) e.1 e.2).IsDiag := by | |
| rw [edge,Sym2.mk_isDiag_iff] | |
| intro he | |
| have hi := atVertex_injective source target (4*(2*K+2)) e.1 (source_ne_target e.1) he | |
| have := congrArg Fin.val hi | |
| simp at this | |
| def coloredReal (w : V β V β β) (K : β) (e : SourceRealEdge V K) : BagEdge (bags w K) := | |
| β¨β¨(edge source target (4*(2*K+2)) e.1 e.2,realLabel w K e),real_not_diag K eβ©,by | |
| intro x hx | |
| apply (NumberedHierarchy.mem_bags _ _ _ (realLeft K) (realRight K) (levels w K) x _).mpr | |
| refine β¨e,?_,rflβ© | |
| simpa [ColoredEdge.Incident,realLeft,realRight,edge] using hxβ© | |
| lemma coloredReal_injective (w : V β V β β) (K : β) : Function.Injective (coloredReal w K) := by | |
| intro e f h | |
| apply edge_injective source target (4*(2*K+2)) (by omega) | |
| exact congrArg (fun q : BagEdge (bags w K)=>q.val.val.1) h | |
| def realPortion (w : V β V β β) (K : β) (e : BagEdge (bags w K)) : β := | |
| β q : SourceRealEdge V K,if coloredReal w K q=e then pathActivity w K q.1 q.2 else 0 | |
| lemma realPortion_on (w : V β V β β) (K : β) (q : SourceRealEdge V K) : | |
| realPortion w K (coloredReal w K q)=pathActivity w K q.1 q.2 := by | |
| simp only [realPortion,(coloredReal_injective w K).eq_iff,sum_ite_eq',mem_univ,ite_true] | |
| lemma realPortion_off (w : V β V β β) (K : β) (e : BagEdge (bags w K)) | |
| (he : Β¬β q,coloredReal w K q=e) : realPortion w K e=0 := by | |
| apply sum_eq_zero | |
| intro q _ | |
| exact ite_eq_right (fun h=>he β¨q,hβ©) | |
| lemma pathActivity_pos (w : V β V β β) (hw : β x y,0<w x y) (K : β) | |
| (e : LogicalEdge V) (i : Fin (4*(2*K+2)+1)) : 0<pathActivity w K e i := by | |
| have hb : 0<logicalB w (source e) (target e) := by | |
| have h : (1:β)β€(logicalB w (source e) (target e):β) := by | |
| rw [logicalB_cast]; exact one_le_bottleneck _ _ _ | |
| have : (1:β)β€logicalB w (source e) (target e) := by exact_mod_cast h | |
| linarith | |
| unfold pathActivity profile | |
| split_ifs | |
| Β· exact hb.trans_le (le_max_left _ _) | |
| Β· unfold BottleneckAlgorithm.edge | |
| split_ifs <;> exact hw _ _ | |
| Β· exact hb.trans_le (le_max_left _ _) | |
| lemma pathActivity_le_realB (w : V β V β β) (K : β) (e : SourceRealEdge V K) : | |
| pathActivity w K e.1 e.2β€realB w K (realLeft K e) (realRight K e) := by | |
| apply (Rat.cast_le (K:=β)).mp | |
| rw [pathActivity_cast,realB_cast] | |
| exact edge_activity_le_realBottleneck source target source_ne_target (2*K+2) (by omega) _ _ _ _ e.1 e.2 | |
| def bagHeight (w : V β V β β) (K : β) (l : Label w K) : β := 2^l.1.val | |
| lemma realPortion_nonneg (w : V β V β β) (hw : β x y,0<w x y) (K : β) | |
| (e : BagEdge (bags w K)) : 0β€realPortion w K e := by | |
| apply sum_nonneg | |
| intro q _ | |
| split_ifs | |
| Β· exact (pathActivity_pos w hw K q.1 q.2).le | |
| Β· exact le_rfl | |
| lemma realPortion_le_height (w : V β V β β) (K : β) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (e : BagEdge (bags w K)) : realPortion w K eβ€2*bagHeight w K e.color := by | |
| by_cases he : β q,coloredReal w K q=e | |
| Β· obtain β¨q,rflβ©:=he | |
| rw [realPortion_on] | |
| apply (pathActivity_le_realB w K q).trans | |
| apply (Rat.cast_le (K:=β)).mp | |
| have hu:=dyadic_upper_of_lt (levels w K) (realB w K (realLeft K q) (realRight K q):β) | |
| (by exact_mod_cast realB_upper w K h q) | |
| rw [βNumberedHierarchy.level_cast,pow_succ] at hu | |
| change (realB w K (realLeft K q) (realRight K q):β)β€((2*2^_ : β):β) | |
| push_cast | |
| simpa only [coloredReal,BagEdge.color,ColoredEdge.color,realLabel,NumberedHierarchy.edgeLabel,NumberedHierarchy.labelAt,mul_comm] using hu.le | |
| Β· rw [realPortion_off w K e he] | |
| dsimp [bagHeight] | |
| positivity | |
| def bagWeight (w : V β V β β) (K D : β) (e : BagEdge (bags w K)) : β := | |
| realPortion w K e+bagHeight w K e.color/D | |
| lemma bagWeight_range (w : V β V β β) (hw : β x y,0<w x y) (K D : β) (hD : 1β€D) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (e : BagEdge (bags w K)) : | |
| (bagHeight w K e.color:β)/Dβ€(bagWeight w K D e:β) β§ | |
| (bagWeight w K D e:β)β€3*(bagHeight w K e.color:β) := by | |
| have he:=realPortion_nonneg w hw K e | |
| have hu:=realPortion_le_height w K h e | |
| have hd : (1:β)β€D := by exact_mod_cast hD | |
| have hh : bagHeight w K e.color/(D:β)β€bagHeight w K e.color := | |
| div_le_self (by dsimp [bagHeight]; positivity) hd | |
| have hlo : bagHeight w K e.color / (D:β)β€bagWeight w K D e := by unfold bagWeight; linarith | |
| have hhi : bagWeight w K D eβ€3*bagHeight w K e.color := by unfold bagWeight; linarith | |
| constructor <;> exact_mod_cast (by assumption) | |
| lemma bagHeight_one (w : V β V β β) (K : β) (l : Label w K) : 1β€bagHeight w K l := by | |
| exact one_le_powβ (by norm_num) | |
| lemma bagHeight_le (w : V β V β β) (K : β) (l : Label w K) : bagHeight w K lβ€(4:β)^K := by | |
| have hl : l.1.valβ€2*K := (Nat.le_of_lt_succ l.1.isLt).trans (by rw [levels_eq]; exact sourceLevels_le _ _) | |
| calc | |
| _ β€ (2:β)^(2*K) := pow_le_pow_rightβ (by norm_num) hl | |
| _ = _ := by rw [pow_mul]; norm_num | |
| lemma bagHeight_step (w : V β V β β) (K : β) (a b : Label w K) (h : (tree w K).Adj a b) : | |
| (bagHeight w K a:β)β€2*(bagHeight w K b:β) := by | |
| simpa only [bagHeight,Rat.cast_pow,Rat.cast_ofNat] using | |
| NumberedHierarchy.height_step (realB w K) (realB_symm w K) (realB_tri w K) (levels w K) a b h | |
| lemma bagWeight_global (w : V β V β β) (hw : β x y,0<w x y) (K D : β) (hD : 1β€D) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (e : BagEdge (bags w K)) : | |
| (D:β)β»ΒΉβ€(bagWeight w K D e:β) β§ (bagWeight w K D e:β)β€3*4^K := by | |
| have hr:=bagWeight_range w hw K D hD h e | |
| have h1 : (1:β)β€(bagHeight w K e.color:β) := by exact_mod_cast bagHeight_one w K e.color | |
| have h4 : (bagHeight w K e.color:β)β€(4:β)^K := by exact_mod_cast bagHeight_le w K e.color | |
| constructor | |
| Β· calc | |
| (D:β)β»ΒΉ = 1/(D:β) := (one_div _).symm | |
| _ β€ (bagHeight w K e.color:β)/(D:β) := div_le_div_of_nonneg_right h1 (Nat.cast_nonneg D) | |
| _ β€ _ := hr.1 | |
| Β· exact hr.2.trans (mul_le_mul_of_nonneg_left h4 (by norm_num)) | |
| open MatchingFPRAS.Replica MatchingFPRAS.Replica.Ladder MatchingFPRAS.Variation | |
| attribute [local instance] prodOrder sumOrder | |
| noncomputable local instance (w : V β V β β) (K : β) : DecidableEq (BagPM (bags w K)) := Classical.decEq _ | |
| def sampler (w : V β V β β) (K D T m : β) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (hq : 0<ladderQ (Fintype.card (SourceVertex V K)) D) (M : BagPM (bags w K)) (Ξ· : β) | |
| (s : Slot T (ladderQ (Fintype.card (SourceVertex V K)) D) β BagPM (bags w K)) := | |
| finiteLadder (bags_adjacent w K h) (tree_acyclic w K) (fun l=>l.1.val) (parent w K) | |
| (bags_ranked w K h) (bags_nonempty w K) (parent_rank w K) D K T m hq (bagWeight w K D) M Ξ· s | |
| noncomputable local instance (w : V β V β β) (K : β) : Fintype (BagPM (bags w K)) := Fintype.ofFinite _ | |
| theorem sampler_tv (w : V β V β β) (hw : β x y,0<w x y) (K D T m : β) (hD : 1β€D) | |
| (hN : 2β€Fintype.card (SourceVertex V K)) (hm : 1 < m) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (hq : 0<ladderQ (Fintype.card (SourceVertex V K)) D) (M : BagPM (bags w K)) (Ξ· : β) (hΞ· : 0<Ξ·) | |
| (s : Slot T (ladderQ (Fintype.card (SourceVertex V K)) D) β BagPM (bags w K)) : | |
| tv (imageLaw (sampler w K D T m h hq M Ξ· s)) | |
| (ladderLaw (fun e=>(bagWeight w K D e:β)) T (ladderQ (Fintype.card (SourceVertex V K)) D))β€ | |
| (Ξ·:β)+(m:β)β»ΒΉ := by | |
| apply finiteLadder_tv (bags_adjacent w K h) (tree_acyclic w K) (fun l=>l.1.val) (parent w K) | |
| (bags_ranked w K h) (bags_nonempty w K) (parent_rank w K) (fun l=>(bagHeight w K l:β)) | |
| (fun l=>by have hh : (1:β)β€(bagHeight w K l:β) := by exact_mod_cast bagHeight_one w K l | |
| linarith) | |
| (bagHeight_step w K) D K hD hN (bagWeight w K D) (bagWeight_range w hw K D hD h) | |
| (bagWeight_global w hw K D hD h) M T m hm Ξ· hΞ· hq s | |
| end MatchingFPRAS.RationalSource | |
| namespace MatchingFPRAS.Transport | |
| open Finset MatchingFPRAS.Replica MatchingFPRAS.Replica.Ladder | |
| variable {V J : Type*} [Fintype V] [DecidableEq V] [Fintype J] [DecidableEq J] | |
| variable {bags : V β Finset J} | |
| noncomputable local instance : Fintype (BagEdge bags) := Fintype.ofFinite _ | |
| noncomputable local instance : DecidableEq (PM (BagEdge.Incident (bags := bags))) := Classical.decEq _ | |
| omit [DecidableEq V] in | |
| lemma gibbs_instances [DecidableEq V] {E : Type*} (Fβ Fβ : Fintype E) (inc : E β V β Prop) | |
| (w : E β β) : @gibbs V E _ inc Fβ w = @gibbs V E _ inc Fβ w := by | |
| cases Subsingleton.elim Fβ Fβ | |
| rfl | |
| omit [DecidableEq J] in | |
| lemma slotLaw_of_weight [DecidableEq J] {T q : β} (F : Fintype (BagEdge bags)) | |
| (w : BagEdge bags β β) (i : Slot T q) | |
| (he : slotWeight w i=w) : slotLaw w i=@gibbs V (BagEdge bags) _ BagEdge.Incident F w := by | |
| change @gibbs V (BagEdge bags) _ BagEdge.Incident (instFintypeBagEdge_5 (bags:=bags)) | |
| (slotWeight w i)=_ | |
| rw [he] | |
| exact gibbs_instances _ _ _ _ | |
| lemma top_marginal_tv {A : Type*} [Fintype A] {T q : β} (F : Fintype (BagEdge bags)) | |
| (hq : 0<q) (w : BagEdge bags β β) (M : PM (BagEdge.Incident (bags:=bags))) | |
| (f : A β Slot T q β PM (BagEdge.Incident (bags:=bags))) | |
| (he : slotWeight w (topSlot T q hq)=w) : | |
| Variation.tv (Variation.imageLaw (fun a=>f a (topSlot T q hq))) | |
| (@gibbs V (BagEdge bags) _ BagEdge.Incident F w)β€ | |
| Variation.tv (Variation.imageLaw f) (ladderLaw w T q) := by | |
| have ht:=Variation.push_contraction (Variation.imageLaw f) (ladderLaw w T q) | |
| (fun x=>x (topSlot T q hq)) | |
| rw [ladder_top_marginal w T q hq M,slotLaw_of_weight F _ _ he] at ht | |
| change Variation.tv (Variation.imageLaw ((fun x=>x (topSlot T q hq)) β f)) _β€_ | |
| rw [Variation.imageLaw_comp] | |
| exact ht | |
| open Finset Replica Replica.Ladder Variation | |
| def rationalBase (N : β) : β := 1+((N:β)^2)β»ΒΉ | |
| lemma rationalBase_cast (N : β) : (rationalBase N:β)=1+((N:β)^2)β»ΒΉ := by | |
| simp [rationalBase] | |
| private lemma reaches_cast (N D K t : β) : | |
| max (D:β) (3*4^K)β€(rationalBase N)^t β | |
| max (D:β) (3*4^K)β€(1+((N:β)^2)β»ΒΉ)^t := by | |
| rw [βrationalBase_cast] | |
| exact_mod_cast (Iff.rfl : max (D:β) (3*4^K)β€(rationalBase N)^t β _) | |
| def endpoint (N D K : β) (hN : 0<N) : β := | |
| ((range (tierBound N D K+1)).filter | |
| (fun t => max (D:β) (3*4^K)β€(rationalBase N)^t)).min' | |
| (by refine β¨tierBound N D K,mem_filter.mpr β¨mem_range.mpr (by omega),?_β©β© | |
| exact (reaches_cast _ _ _ _).mpr (tierBound_reaches N D K hN)) | |
| lemma endpoint_eq (N D K : β) (hN : 0<N) : endpoint N D K hN=ladderTier N D K hN := by | |
| apply Nat.le_antisymm | |
| Β· apply min'_le | |
| apply mem_filter.mpr | |
| exact β¨mem_range.mpr (by have := ladderTier_le N D K hN; omega), | |
| (reaches_cast _ _ _ _).mpr (ladderTier_spec N D K hN)β© | |
| Β· have he : max (D:β) (3*4^K)β€(1+((N:β)^2)β»ΒΉ)^(endpoint N D K hN) := by | |
| apply (reaches_cast _ _ _ _).mp | |
| unfold endpoint | |
| exact (mem_filter.mp (min'_mem ((range (tierBound N D K+1)).filter | |
| (fun t => max (D:β) (3*4^K)β€(rationalBase N)^t)) _)).2 | |
| unfold ladderTier | |
| exact Nat.find_min' _ he | |
| lemma endpoint_reaches (N D K : β) (hN : 0<N) : | |
| max (D:β) (3*4^K)β€(1+((N:β)^2)β»ΒΉ)^(endpoint N D K hN) := by | |
| rw [endpoint_eq]; exact ladderTier_spec N D K hN | |
| end MatchingFPRAS.Transport | |
| namespace MatchingFPRAS.RationalSource | |
| open Finset MatchingFPRAS.Switching MatchingFPRAS.Subdivision MatchingFPRAS.RealGeometry | |
| open MatchingFPRAS.Hierarchy MatchingFPRAS.Transport MatchingFPRAS.Enlargement | |
| open MatchingFPRAS.Replica MatchingFPRAS.Replica.Ladder MatchingFPRAS.Variation | |
| variable {V : Type*} [Fintype V] [LinearOrder V] [Nontrivial V] | |
| attribute [local instance] NumberedHierarchy.labelOrder sym2Order bagEdgeOrder bagEdgeFintype | |
| attribute [local instance] UnitRefresh.Computable.allowedDec prodOrder sumOrder | |
| noncomputable local instance (w : V β V β β) (K : β) : DecidableEq (BagPM (bags w K)) := Classical.decEq _ | |
| noncomputable local instance (w : V β V β β) (K : β) : Fintype (BagPM (bags w K)) := Fintype.ofFinite _ | |
| def topSampler (w : V β V β β) (K D m : β) (hN : 0<Fintype.card (SourceVertex V K)) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (hq : 0<ladderQ (Fintype.card (SourceVertex V K)) D) (M : BagPM (bags w K)) (Ξ· : β) := | |
| fun bits => sampler w K D (endpoint (Fintype.card (SourceVertex V K)) D K hN) m h hq M Ξ· | |
| (fun _=>M) bits (topSlot _ _ hq) | |
| theorem topSampler_tv (w : V β V β β) (hw : β x y,0<w x y) (K D m : β) (hD : 1β€D) | |
| (hN : 2β€Fintype.card (SourceVertex V K)) (hm : 1 < m) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (hq : 0<ladderQ (Fintype.card (SourceVertex V K)) D) (M : BagPM (bags w K)) (Ξ· : β) (hΞ· : 0<Ξ·) : | |
| tv (imageLaw (topSampler w K D m (by omega) h hq M Ξ·)) | |
| (gibbs (fun e=>(bagWeight w K D e:β)))β€(Ξ·:β)+(m:β)β»ΒΉ := by | |
| let T:=endpoint (Fintype.card (SourceVertex V K)) D K (by omega) | |
| have hs:=sampler_tv w hw K D T m hD hN hm h hq M Ξ· hΞ· (fun _=>M) | |
| have he:=slotWeight_top (fun e=>(bagWeight w K D e:β)) D K T _ (by omega) hq | |
| (bagWeight_global w hw K D hD h) (endpoint_reaches _ _ _ (by omega)) | |
| exact (top_marginal_tv (bagEdgeFintype (bags:=bags w K)) hq (fun e=>(bagWeight w K D e:β)) M | |
| (sampler w K D T m h hq M Ξ· (fun _=>M)) he).trans hs | |
| end MatchingFPRAS.RationalSource | |
| end OAI | |