Download data/lean/OAI/Combinatorics/MatchingCount/Graphs/PM.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/PM.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Graphs/PM.lean
-
curl -L -o PM.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/PM.lean
14.1 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Sampling.LadderL | |
| import OAI.Combinatorics.MatchingCount.Graphs.MatchingMap | |
| namespace OAI | |
| namespace MatchingFPRAS.Enlargement | |
| open MatchingFPRAS.Switching MatchingFPRAS.Subdivision MatchingFPRAS.RealGeometry | |
| open MatchingFPRAS.Hierarchy MatchingFPRAS.Transport Finset | |
| open MatchingFPRAS.Replica MatchingFPRAS.Replica.Ladder | |
| variable {V : Type*} [Fintype V] [LinearOrder V] [Nontrivial V] | |
| noncomputable local instance (w : V β V β β) (K : β) : DecidableEq (SourceLabel w K) := Classical.decEq _ | |
| noncomputable local instance (w : V β V β β) (K : β) : Fintype (BagEdge (sourceBags w K)) := Fintype.ofFinite _ | |
| abbrev SourcePM (w : V β V β β) (K : β) := PM (BagEdge.Incident (bags:=sourceBags w K)) | |
| noncomputable local instance (w : V β V β β) (K : β) : DecidableEq (SourcePM w K) := Classical.decEq _ | |
| omit [Nontrivial V] in | |
| lemma sourceVertex_card_ge (K : β) : Fintype.card V β€ Fintype.card (SourceVertex V K) := by | |
| exact Fintype.card_le_of_injective (Sum.inl : V β SourceVertex V K) Sum.inl_injective | |
| theorem source_ladder_sampling (hn : 2 β€ Fintype.card V) | |
| (w : V β V β β) (hw : β x y, 0 < w x y) (K : β) | |
| (hK : β x y, x β y β edgeActivity w x y β€ (4:β)^K) | |
| (Mβ : SourcePM w K) (T : β) | |
| (z : Slot T (ladderQ (Fintype.card (SourceVertex V K)) (sourceD (V:=V) K)) β SourcePM w K) | |
| (ΞΎ : β) (hΞΎ : 0 < ΞΎ) (hΞΎ1 : ΞΎ < 1) : | |
| let D := sourceD (V:=V) K | |
| let N := Fintype.card (SourceVertex V K) | |
| let wt := sourceBagWeight w K D | |
| let Ξ½ := ladderLaw wt T (ladderQ N D) | |
| let C := ladderFlow (fun x a ha b hb => sourceBag_tree_adjacent w K hK x a b ha hb) (sourceTree_isTree w K).2 wt T (ladderQ N D) | |
| (β s, |MatchingFPRAS.FiniteChain.walk Ξ½ C z (ladderSteps N D K T ΞΎ) s-Ξ½ s|)/2 β€ ΞΎ := by | |
| classical | |
| dsimp only | |
| apply ideal_ladder_sampling (fun x a ha b hb => sourceBag_tree_adjacent w K hK x a b ha hb) (sourceTree_isTree w K).2 | |
| (bagHeight w K) (bagHeight_pos w K) (bagHeight_adjacent w K) | |
| (sourceD (V:=V) K) K (sourceD_one K) (hn.trans (sourceVertex_card_ge K)) | |
| (sourceBagWeight w K (sourceD (V:=V) K)) | |
| (sourceBagWeight_range w K _ (sourceD_one K) hw hK) | |
| (sourceBagWeight_global w K _ (sourceD_one K) hw hK) Mβ T z ΞΎ hΞΎ hΞΎ1 | |
| end MatchingFPRAS.Enlargement | |
| namespace MatchingFPRAS.Subdivision | |
| open Finset | |
| def probeHoles (p : β) (hp : 1β€p) : Finset (Fin (4*p)) := | |
| {β¨2*p-1,by omegaβ©,β¨2*p,by omegaβ©} | |
| def probeWord (p : β) : Selection (4*p) := | |
| fun i => if i.val=2*p then false else alternating true i.val | |
| lemma probeWord_valid (p : β) (hp : 1β€p) : Valid (probeHoles p hp) (probeWord p) := by | |
| intro i | |
| by_cases h : i.val=2*p-1 β¨ i.val=2*p | |
| Β· have hm : iβprobeHoles p hp := by simpa [probeHoles,Fin.ext_iff] using h | |
| rw [ite_eq_left hm] | |
| rcases h with h | h | |
| Β· have _hm : i.val%2=1 := by omega | |
| simp [probeWord,Fin.val_castSucc,Fin.val_succ,h,show 2*p-1+1=2*p by omega, | |
| alternating,show (2*p-1)%2=1 by omega,show 2*p-1β 2*p by omega] | |
| Β· simp [probeWord,Fin.val_castSucc,Fin.val_succ,h,alternating,Nat.add_mod] | |
| Β· have hm : iβprobeHoles p hp := by simpa [probeHoles,Fin.ext_iff] using h | |
| rw [ite_eq_right hm] | |
| have hβ : i.valβ 2*p := by omega | |
| have hβ : i.val+1β 2*p := by omega | |
| simp only [probeWord,Fin.val_castSucc,Fin.val_succ,ite_eq_right hβ,ite_eq_right hβ,alternating_succ] | |
| cases alternating true i.val <;> decide | |
| @[simp] lemma probeWord_first (p : β) (hp : 1β€p) : probeWord p 0=true := by | |
| simp [probeWord,show 0β 2*p by omega] | |
| @[simp] lemma probeWord_last (p : β) (hp : 1β€p) : probeWord p (Fin.last (4*p))=true := by | |
| simp [probeWord,show 4*pβ 2*p by omega,alternating,Nat.mul_mod] | |
| lemma probeHoles_nonempty (p : β) (hp : 1β€p) : (probeHoles p hp).Nonempty := by | |
| simp [probeHoles] | |
| lemma probeWord_unique (p : β) (hp : 1β€p) (b : Selection (4*p)) | |
| (hb : Valid (probeHoles p hp) b) : b=probeWord p := | |
| broken_unique (probeHoles_nonempty p hp) hb (probeWord_valid p hp) | |
| lemma probe_weight (p : β) (B Hu Hv lam : β) : | |
| selectedWeight (profileActivity p B Hu Hv lam) (probeWord p)= | |
| (β r : Fin p,max B (Hu/2^r.val))*(β r : Fin p,max B (Hv/2^r.val)) := by | |
| have he : selectedWeight (profileActivity p B Hu Hv lam) (probeWord p)= | |
| selectedWeight (profileActivity p B Hu Hv 1) (fun i => alternating true i.val) := by | |
| unfold selectedWeight | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| by_cases hi : i.val=2*p | |
| Β· have hfi : i=β¨2*p,by omegaβ© := Fin.ext hi | |
| rw [hfi] | |
| simp [probeWord,alternating] | |
| Β· simp only [probeWord,ite_eq_right hi] | |
| congr 1 | |
| rcases lt_or_gt_of_ne hi with h | h | |
| Β· rw [profile_left _ _ _ _ _ _ h,profile_left _ _ _ _ _ _ h] | |
| Β· rw [profile_right _ _ _ _ _ _ h,profile_right _ _ _ _ _ _ h] | |
| rw [he,exact_profile_weight] | |
| simp | |
| variable {V E : Type*} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] | |
| variable (u v : E β V) (p : β) (hp : 1β€p) (eβ : E) | |
| def singleProbeHoles (e : E) : Finset (Fin (4*p)) := | |
| if e=eβ then probeHoles p hp else β | |
| @[simp] lemma broken_singleProbe : broken (singleProbeHoles p hp eβ)={eβ} := by | |
| ext e | |
| by_cases he : e=eβ <;> simp [singleProbeHoles,he,probeHoles_nonempty] | |
| omit [Fintype V] [Fintype E] [DecidableEq V] in | |
| lemma singleProbe_word (b : E β Selection (4*p)) | |
| (hb : FamilyHoles u v (4*p) β (singleProbeHoles p hp eβ) b) : b eβ=probeWord p := by | |
| exact probeWord_unique p hp (b eβ) (by simpa [singleProbeHoles] using hb.1 eβ) | |
| lemma residual_singleProbe (b : E β Selection (4*p)) | |
| (hb : FamilyHoles u v (4*p) β (singleProbeHoles p hp eβ) b) : | |
| residualHoles u v β (singleProbeHoles p hp eβ) b={u eβ,v eβ} := by | |
| ext x | |
| simp only [mem_residualHoles,notMem_empty,broken_singleProbe,mem_singleton, | |
| exists_eq_left,false_or,Uses,singleProbe_word u v p hp eβ b hb, | |
| probeWord_first p hp,probeWord_last p hp,true_and,mem_insert,mem_singleton] | |
| exact or_congr eq_comm eq_comm | |
| def insertProbe (s : E β Bool) (e : E) : Selection (4*p) := | |
| if e=eβ then probeWord p else fun i => alternating (s e) i.val | |
| include hp in | |
| omit [Fintype V] [Fintype E] [DecidableEq V] in | |
| lemma insertProbe_uses (s : E β Bool) (e : E) (x : V) : | |
| Uses u v (insertProbe p eβ s) e x β | |
| if e=eβ then u eβ=x β¨ v eβ=x else s e=true β§ (u e=x β¨ v e=x) := by | |
| by_cases he : e=eβ | |
| Β· subst e; simp [Uses,insertProbe,probeWord_first p hp,probeWord_last p hp] | |
| Β· simp [Uses,insertProbe,he,alternating,and_or_left,Nat.mul_mod] | |
| omit [Fintype V] [Fintype E] in | |
| lemma insertProbe_family (_hne : u eββ v eβ) (s : E β Bool) | |
| (hs : LogicalHoles u v {u eβ,v eβ} {eβ} s) : | |
| FamilyHoles u v (4*p) β (singleProbeHoles p hp eβ) (insertProbe p eβ s) := by | |
| refine β¨?_,by simp,?_β© | |
| Β· intro e | |
| by_cases he : e=eβ | |
| Β· subst e; simpa [singleProbeHoles,insertProbe] using probeWord_valid p hp | |
| Β· simpa [singleProbeHoles,insertProbe,he] using alternating_valid (4*p) (s e) | |
| Β· intro x _ | |
| by_cases hx : xβ({u eβ,v eβ} : Finset V) | |
| Β· refine β¨eβ,?_,?_β© | |
| Β· change Uses u v (insertProbe p eβ s) eβ x | |
| rw [insertProbe_uses u v p hp eβ,ite_eq_left rfl] | |
| simpa only [mem_insert,mem_singleton,eq_comm] using hx | |
| Β· intro e he | |
| by_contra hen | |
| rw [insertProbe_uses u v p hp eβ,ite_eq_right hen] at he | |
| exact hs.2.1 x hx e he | |
| Β· obtain β¨e,he,huβ© := hs.2.2 x hx | |
| have heβ : eβ eβ := by | |
| intro h | |
| subst e | |
| exact (Bool.noConfusion (he.1.symm.trans (hs.1 eβ (mem_singleton_self _)))) | |
| refine β¨e,(insertProbe_uses u v p hp eβ s e x).mpr (by simpa [heβ] using he),?_β© | |
| intro f hf | |
| by_cases hfβ : f=eβ | |
| Β· subst f | |
| rw [insertProbe_uses u v p hp eβ,ite_eq_left rfl] at hf | |
| exact False.elim (hx (by simpa only [mem_insert,mem_singleton,eq_comm] using hf)) | |
| Β· rw [insertProbe_uses u v p hp eβ,ite_eq_right hfβ] at hf | |
| exact hu f hf | |
| omit [Fintype V] [DecidableEq V] in | |
| lemma singleProbe_deletionConstant (b : E β Selection (4*p)) | |
| (hb : FamilyHoles u v (4*p) β (singleProbeHoles p hp eβ) b) | |
| (B Hu Hv lam : E β β) : | |
| deletionConstant (singleProbeHoles p hp eβ) b | |
| (fun e => profileActivity p (B e) (Hu e) (Hv e) (lam e)) | |
| (fun e => (β r : Fin p,max (B e) (Hu e/2^r.val))*(β r : Fin p,max (B e) (Hv e/2^r.val))) = | |
| β e,(β r : Fin p,max (B e) (Hu e/2^r.val))*(β r : Fin p,max (B e) (Hv e/2^r.val)) := by | |
| unfold deletionConstant | |
| apply Finset.prod_congr rfl | |
| intro e _ | |
| by_cases he : e=eβ | |
| Β· subst e | |
| simp only [singleProbeHoles,probeHoles_nonempty,ite_true, | |
| singleProbe_word u v p hp eβ b hb,probe_weight] | |
| Β· simp [singleProbeHoles,he] | |
| theorem singleProbe_partition (hne : u eββ v eβ) (B Hu Hv lam : E β β) : | |
| realHolePartition u v (4*p) β (singleProbeHoles p hp eβ) | |
| (fun e => profileActivity p (B e) (Hu e) (Hv e) (lam e)) = | |
| (β e,(β r : Fin p,max (B e) (Hu e/2^r.val))*(β r : Fin p,max (B e) (Hv e/2^r.val))) * | |
| logicalHolePartition u v {u eβ,v eβ} {eβ} lam := by | |
| classical | |
| by_cases h : β b,FamilyHoles u v (4*p) β (singleProbeHoles p hp eβ) b | |
| Β· obtain β¨b,hbβ© := h | |
| have hid := deletion_partition_identity (show Even (4*p) from β¨2*p,by omegaβ©) | |
| u v β (singleProbeHoles p hp eβ) b hb | |
| (fun e => profileActivity p (B e) (Hu e) (Hv e) (lam e)) | |
| (fun e => List.ofFn fun r : Fin p => max (B e) (Hu e/2^r.val)) | |
| (fun e => (List.ofFn fun r : Fin p => max (B e) (Hv e/2^r.val)).reverse) lam | |
| (fun e => profileActivity_ofFn p (B e) (Hu e) (Hv e) (lam e)) | |
| simp only [List.prod_reverse,List.prod_ofFn] at hid | |
| rw [singleProbe_deletionConstant u v p hp eβ b hb,residual_singleProbe u v p hp eβ b hb, | |
| broken_singleProbe] at hid | |
| exact hid | |
| Β· have hl : Β¬β s,LogicalHoles u v {u eβ,v eβ} {eβ} s := by | |
| rintro β¨s,hsβ© | |
| exact h β¨insertProbe p eβ s,insertProbe_family u v p hp eβ hne s hsβ© | |
| have hz : realHolePartition u v (4*p) β (singleProbeHoles p hp eβ) | |
| (fun e => profileActivity p (B e) (Hu e) (Hv e) (lam e))=0 := by | |
| unfold realHolePartition | |
| apply Finset.sum_eq_zero | |
| intro b _ | |
| exact False.elim (h β¨b.val,b.propertyβ©) | |
| have hz' : logicalHolePartition u v {u eβ,v eβ} {eβ} lam=0 := by | |
| unfold logicalHolePartition | |
| apply Finset.sum_eq_zero | |
| intro s _ | |
| exact False.elim (hl β¨s.val,s.propertyβ©) | |
| rw [hz,hz',mul_zero] | |
| end MatchingFPRAS.Subdivision | |
| namespace MatchingFPRAS.Representation | |
| open MatchingFPRAS.Switching MatchingFPRAS.Subdivision MatchingFPRAS.Enlargement Finset | |
| variable {V : Type*} [Fintype V] [LinearOrder V] | |
| omit [Fintype V] in | |
| lemma forbidden_endpoint_redundant (R : Finset V) (eβ : LogicalEdge V) | |
| (he : source eββR) (s : LogicalEdge V β Bool) : | |
| LogicalHoles source target R {eβ} s β LogicalHoles source target R β s := by | |
| constructor | |
| Β· intro h; exact β¨by simp,h.2β© | |
| Β· intro h | |
| refine β¨?_,h.2β© | |
| intro e hem | |
| have heq : e=eβ := mem_singleton.mp hem | |
| subst e | |
| cases hs : s eβ with | |
| | false => rfl | |
| | true => exact False.elim (h.2.1 (source eβ) he eβ β¨hs,Or.inl rflβ©) | |
| lemma logical_partition_redundant (w : V β V β β) (R : Finset V) (eβ : LogicalEdge V) | |
| (he : source eββR) : | |
| logicalHolePartition source target R {eβ} (logicalActivity w)=partition w R := by | |
| classical | |
| let := Fintype.ofFinite {s : LogicalEdge V β Bool // LogicalHoles source target R {eβ} s} | |
| let := Fintype.ofFinite {s : LogicalEdge V β Bool // LogicalHoles source target R β s} | |
| rw [β logical_partition_eq] | |
| unfold logicalHolePartition | |
| apply Fintype.sum_equiv (Equiv.subtypeEquivRight (forbidden_endpoint_redundant R eβ he)) | |
| intro s | |
| rfl | |
| end MatchingFPRAS.Representation | |
| namespace MatchingFPRAS.Enlargement | |
| open MatchingFPRAS.Switching MatchingFPRAS.Subdivision MatchingFPRAS.RealGeometry | |
| open MatchingFPRAS.Transport MatchingFPRAS.Representation Finset | |
| variable {V : Type*} [Fintype V] [LinearOrder V] [Nontrivial V] | |
| noncomputable local instance (w : V β V β β) (K : β) : Fintype (BagEdge (sourceBags w K)) := Fintype.ofFinite _ | |
| theorem source_probe_partition (w : V β V β β) (K : β) (eβ : LogicalEdge V) : | |
| partitionWeight BagEdge.Incident (sourceRealPortion w K) | |
| (survivors (4*(2*K+2)) β (singleProbeHoles (2*K+2) (by omega) eβ)) = | |
| (β e, pathConstant (2*K+2) (bottleneck w (source e) (target e)) | |
| (sourceHeight w (source e)) (sourceHeight w (target e))) * | |
| partition w {source eβ,target eβ} := by | |
| rw [sourceRealPortion_partition] | |
| change realHolePartition source target (4*(2*K+2)) β | |
| (singleProbeHoles (2*K+2) (by omega) eβ) | |
| (fun e => profileActivity (2*K+2) (bottleneck w (source e) (target e)) | |
| (sourceHeight w (source e)) (sourceHeight w (target e)) (logicalActivity w e)) = _ | |
| rw [singleProbe_partition _ _ _ _ _ (source_ne_target eβ)] | |
| rw [logical_partition_redundant w _ eβ (by simp)] | |
| rfl | |
| theorem source_probe_ratio (w : V β V β β) (hz : 0<partition w β ) (K : β) | |
| (eβ : LogicalEdge V) (D I : β) : | |
| (partitionWeight BagEdge.Incident (sourceRealPortion w K) | |
| (survivors (4*(2*K+2)) β (singleProbeHoles (2*K+2) (by omega) eβ)) / D) / | |
| (I * partitionWeight BagEdge.Incident (sourceRealPortion w K) univ) = | |
| holeRatio w {source eβ,target eβ}/(D*I) := by | |
| rw [source_probe_partition,sourceRealPortion_full w hz] | |
| have hc : (β e : LogicalEdge V, pathConstant (2*K+2) (bottleneck w (source e) (target e)) | |
| (sourceHeight w (source e)) (sourceHeight w (target e)))β 0 := by | |
| exact ne_of_gt (prod_pos fun e _ => pathConstant_pos _ _ _ _ | |
| (zero_lt_one.trans_le (one_le_bottleneck w _ _))) | |
| unfold holeRatio | |
| field_simp | |
| end MatchingFPRAS.Enlargement | |
| end OAI | |