Download data/lean/OAI/Combinatorics/MatchingCount/Graphs/RatWeight.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 19.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/RatWeight.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Graphs/RatWeight.lean
-
curl -L -o RatWeight.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/RatWeight.lean
19.1 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Graphs.EnlargementRun | |
| namespace OAI | |
| namespace MatchingFPRAS.StageAnalysis | |
| open Finset MatchingFPRAS.Switching MatchingFPRAS.Initializer | |
| variable {V : Type*} [Fintype V] [LinearOrder V] | |
| noncomputable def ratWeight (w : V β V β β) (m : Mate V) : β := | |
| β x, if x < m.val x then w x (m.val x) else 1 | |
| noncomputable def ratPartition (w : V β V β β) (R : Finset V) : β := | |
| β m β matchings R,ratWeight w m | |
| lemma ratWeight_cast (w : V β V β β) (m : Mate V) : | |
| (ratWeight w m:β)=weight (fun x y => (w x y:β)) m := by | |
| unfold ratWeight weight | |
| push_cast | |
| apply prod_congr rfl | |
| intro x _ | |
| split_ifs <;> simp | |
| lemma ratPartition_cast (w : V β V β β) (R : Finset V) : | |
| (ratPartition w R:β)=partition (fun x y => (w x y:β)) R := by | |
| unfold ratPartition partition | |
| push_cast | |
| exact sum_congr rfl fun m _ => ratWeight_cast w m | |
| lemma partition_pos_of_even (w : V β V β β) (hw : β x y,0 < w x y) | |
| (R : Finset V) (he : Even (Fintype.card V-R.card)) : 0 < partition w R := by | |
| have hm : 0 < (matchings R).card := by rw [matchings_card]; exact pairingCount_pos_of_even _ he | |
| apply Finset.sum_pos | |
| Β· intro m _ | |
| unfold weight | |
| apply Finset.prod_pos | |
| intro x _ | |
| split_ifs <;> first | exact hw _ _ | norm_num | |
| Β· exact Finset.card_pos.mp hm | |
| lemma selected_card (m : Mate V) (R : Finset V) (hm : HasHoles m R) : | |
| (univ.filter fun x => x < m.val x).card=(Fintype.card V-R.card)/2 := by | |
| have hh : HasHoles m RαΆαΆ := by simpa using hm | |
| have hc := mate_edge_count m RαΆ hh | |
| rw [Finset.card_compl] at hc | |
| omega | |
| lemma weight_factor (t : β) (w : V β V β β) (m : Mate V) (R : Finset V) (hm : HasHoles m R) : | |
| weight (fun x y => t*w x y) m=t^((Fintype.card V-R.card)/2)*weight w m := by | |
| unfold weight | |
| rw [βprod_filter (fun x => x < m.val x) (fun x => t*w x (m.val x)), | |
| βprod_filter (fun x => x < m.val x) (fun x => w x (m.val x)), | |
| prod_mul_distrib,prod_const,selected_card m R hm] | |
| lemma weight_mono (w wβ : V β V β β) (hw : β x y,0 β€ w x y) | |
| (hle : β x y,xβ y β w x y β€ wβ x y) (m : Mate V) : weight w m β€ weight wβ m := by | |
| apply Finset.prod_le_prodβ | |
| Β· intro x _ | |
| split_ifs <;> first | exact hw _ _ | norm_num | |
| Β· intro x _ | |
| split_ifs with h | |
| Β· exact hle _ _ h.ne | |
| Β· rfl | |
| theorem partition_reweight (w wβ : V β V β β) (hw : β x y,0 β€ w x y) | |
| (t : β) (ht : 0 β€ t) (ht1 : t β€ 1) | |
| (hlo : β x y,xβ y β t*w x y β€ wβ x y) | |
| (hhi : β x y,xβ y β wβ x y β€ w x y) (R : Finset V) : | |
| t^(Fintype.card V/2)*partition w R β€ partition wβ R β§ | |
| partition wβ R β€ partition w R := by | |
| have hwβ : β m : Mate V,0 β€ weight wβ m := by | |
| intro m | |
| unfold weight | |
| apply prod_nonneg | |
| intro x _ | |
| split_ifs with h | |
| Β· exact (mul_nonneg ht (hw _ _)).trans (hlo _ _ h.ne) | |
| Β· norm_num | |
| constructor | |
| Β· rw [partition,mul_sum] | |
| apply sum_le_sum | |
| intro m hm | |
| have hcard : (Fintype.card V-R.card)/2 β€ Fintype.card V/2 := Nat.div_le_div_right (Nat.sub_le _ _) | |
| calc | |
| _ β€ t^((Fintype.card V-R.card)/2)*weight w m := | |
| mul_le_mul_of_nonneg_right (pow_le_pow_of_le_one ht ht1 hcard) (weight_nonneg w hw m) | |
| _ = weight (fun x y => t*w x y) m := (weight_factor t w m R ((mem_matchings _ _).mp hm)).symm | |
| _ β€ weight wβ m := weight_mono _ _ (fun x y => mul_nonneg ht (hw x y)) hlo m | |
| Β· apply sum_le_sum | |
| intro m _ | |
| apply Finset.prod_le_prodβ | |
| Β· intro x _ | |
| split_ifs with h | |
| Β· exact (mul_nonneg ht (hw _ _)).trans (hlo _ _ h.ne) | |
| Β· norm_num | |
| Β· intro x _ | |
| split_ifs with h | |
| Β· exact hhi _ _ h.ne | |
| Β· rfl | |
| lemma cooling_half (n : β) (hn : 2 β€ n) : | |
| (1:β)/2 β€ ((1+1/(n:β))β»ΒΉ)^(n/2) := by | |
| have hnp : (0:β)<n := by exact_mod_cast (show 0<n by omega) | |
| have hb : 0 < 1+1/(n:β) := by positivity | |
| have hp : (1+1/(n:β))^(n/2) β€ Real.exp ((n/2:β)/n) := by | |
| have h := pow_le_pow_leftβ hb.le (by simpa [add_comm] using Real.add_one_le_exp (1/(n:β))) (n/2) | |
| simpa only [βReal.exp_nat_mul,div_eq_mul_inv,one_mul] using h | |
| have he : ((n/2:β):β)/(n:β) β€ 1/2 := by | |
| apply (div_le_iffβ hnp).mpr | |
| have h : (n/2)*2 β€ n := Nat.div_mul_le_self n 2 | |
| have h' : ((n/2:β):β)*2 β€ n := by exact_mod_cast h | |
| linarith | |
| have hexp : Real.exp (1/2:β)<2 := by | |
| have hs : (Real.exp (1/2:β))^2=Real.exp 1 := by rw [βReal.exp_nat_mul]; norm_num | |
| have h := Real.exp_one_lt_three | |
| have hpos := Real.exp_pos (1/2:β) | |
| nlinarith | |
| rw [inv_pow] | |
| exact (le_inv_commβ (by norm_num) (pow_pos hb _)).mpr (by | |
| norm_num | |
| simpa only [one_div] using hp.trans ((Real.exp_le_exp.mpr he).trans hexp.le)) | |
| theorem partition_cooling (hn : 2 β€ Fintype.card V) | |
| (w wβ : V β V β β) (hw : β x y,0 β€ w x y) | |
| (hlo : β x y,xβ y β (1+1/(Fintype.card V:β))β»ΒΉ*w x y β€ wβ x y) | |
| (hhi : β x y,xβ y β wβ x y β€ w x y) (R : Finset V) : | |
| partition w R/2 β€ partition wβ R β§ partition wβ R β€ partition w R := by | |
| have ht : 0 β€ (1+1/(Fintype.card V:β))β»ΒΉ := by positivity | |
| have ht1 : (1+1/(Fintype.card V:β))β»ΒΉ β€ 1 := inv_le_one_of_one_leβ (by | |
| have h : 0 β€ 1/(Fintype.card V:β) := by positivity | |
| linarith) | |
| have h := partition_reweight w wβ hw _ ht ht1 hlo hhi R | |
| refine β¨?_,h.2β© | |
| have hh := mul_le_mul_of_nonneg_right (cooling_half _ hn) (partition_nonneg w hw R) | |
| linarith | |
| theorem holeRatio_cooling (w wβ : V β V β β) | |
| (hw : β x y,0 β€ w x y) (hz : 0 < partition w β ) | |
| (h : β R,partition w R/2 β€ partition wβ R β§ partition wβ R β€ partition w R) | |
| (R : Finset V) : Switching.holeRatio w R/2 β€ Switching.holeRatio wβ R β§ Switching.holeRatio wβ R β€ 2*Switching.holeRatio w R := by | |
| have hzβ : 0 < partition wβ β := lt_of_lt_of_le (half_pos hz) (h β ).1 | |
| have hR := partition_nonneg w hw R | |
| have hRβ : 0 β€ partition wβ R := (by positivity : 0 β€ partition w R/2).trans (h R).1 | |
| unfold Switching.holeRatio | |
| constructor | |
| Β· apply (le_div_iffβ hzβ).mpr | |
| have hd : partition w R/partition w β /2*partition wβ β β€ partition w R/2 := by | |
| calc | |
| _ β€ partition w R/partition w β /2*partition w β := | |
| mul_le_mul_of_nonneg_left (h β ).2 (by positivity) | |
| _ = _ := by field_simp [hz.ne'] | |
| exact hd.trans (h R).1 | |
| Β· apply (div_le_iffβ hzβ).mpr | |
| have hd : partition w R β€ (2*(partition w R/partition w β ))*partition wβ β := by | |
| calc | |
| _ = (2*(partition w R/partition w β ))*(partition w β /2) := by field_simp [hz.ne'] | |
| _ β€ _ := mul_le_mul_of_nonneg_left (h β ).1 (by positivity) | |
| exact (h R).2.trans hd | |
| open Finset MatchingFPRAS.Switching | |
| variable {V : Type*} [Fintype V] [LinearOrder V] | |
| lemma mate_vertex_product (s : V β β) (m : Mate V) (R : Finset V) (hm : HasHoles m R) : | |
| (β x β univ.filter (fun x => x < m.val x),s x*s (m.val x))=β x β RαΆ,s x := by | |
| let L := univ.filter fun x => x < m.val x | |
| let H := univ.filter fun x => m.val x < x | |
| have himg : L.image m.val=H := by | |
| ext x | |
| simp only [L,H,mem_image,mem_filter,mem_univ,true_and] | |
| constructor | |
| Β· rintro β¨a,ha,rflβ© | |
| simpa using ha | |
| Β· intro hx | |
| exact β¨m.val x,by simpa using hx,mate_mate m xβ© | |
| have hdis : Disjoint L H := by | |
| apply disjoint_left.mpr | |
| intro x hx hy | |
| exact lt_asymm (mem_filter.mp hx).2 (mem_filter.mp hy).2 | |
| have hunion : LβͺH=RαΆ := by | |
| ext x | |
| simp only [L,H,mem_union,mem_filter,mem_univ,true_and,mem_compl] | |
| rw [βne_iff_lt_or_gt] | |
| simpa only [ne_eq,eq_comm] using not_congr (hm x) | |
| have hp : (β x β L,s (m.val x))=β x β H,s x := by | |
| rw [βhimg] | |
| exact (prod_image m.property.injective.injOn).symm | |
| change (β x β L,s x*s (m.val x))=_ | |
| rw [prod_mul_distrib,hp,βprod_union hdis,hunion] | |
| theorem weight_vertex_scaling (w : V β V β β) (s : V β β) | |
| (m : Mate V) (R : Finset V) (hm : HasHoles m R) : | |
| weight (fun x y => w x y*s x*s y) m=weight w m*(β x β RαΆ,s x) := by | |
| unfold weight | |
| rw [βprod_filter (fun x => x < m.val x) (fun x => w x (m.val x)*s x*s (m.val x)), | |
| βprod_filter (fun x => x < m.val x) (fun x => w x (m.val x))] | |
| calc | |
| _ = (β x β univ.filter (fun x => x < m.val x),w x (m.val x)*(s x*s (m.val x))) := by | |
| apply prod_congr rfl | |
| intro x _ | |
| ring | |
| _ = _ := by rw [prod_mul_distrib,mate_vertex_product s m R hm] | |
| theorem partition_vertex_scaling (w : V β V β β) (s : V β β) (R : Finset V) : | |
| partition (fun x y => w x y*s x*s y) R=partition w R*(β x β RαΆ,s x) := by | |
| unfold partition | |
| rw [sum_mul] | |
| exact sum_congr rfl fun m hm => weight_vertex_scaling w s m R ((mem_matchings _ _).mp hm) | |
| theorem holeRatio_vertex_scaling (w : V β V β β) (s : V β β) (hs : β x,0 < s x) (R : Finset V) : | |
| Switching.holeRatio (fun x y => w x y*s x*s y) R=Switching.holeRatio w R/(β x β R,s x) := by | |
| have hp : (β x : V,s x)β 0 := prod_ne_zero_iff.mpr (fun x _ => (hs x).ne') | |
| have hR : (β x β R,s x)β 0 := prod_ne_zero_iff.mpr (fun x _ => (hs x).ne') | |
| have hc : (β x β RαΆ,s x)β 0 := prod_ne_zero_iff.mpr (fun x _ => (hs x).ne') | |
| have he : (β x β R,s x)*(β x β RαΆ,s x)=β x,s x := prod_mul_prod_compl R s | |
| unfold Switching.holeRatio | |
| rw [partition_vertex_scaling,partition_vertex_scaling,compl_empty] | |
| by_cases hz : partition w β =0 | |
| Β· simp [hz] | |
| Β· rw [βhe] | |
| field_simp | |
| end MatchingFPRAS.StageAnalysis | |
| namespace MatchingFPRAS.Enlargement | |
| open MatchingFPRAS.Switching MatchingFPRAS.Subdivision MatchingFPRAS.RealGeometry | |
| open MatchingFPRAS.Hierarchy MatchingFPRAS.Transport MatchingFPRAS.StageAnalysis Finset | |
| 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 _ | |
| open scoped Classical | |
| lemma sourceBagZ_pos (w : V β V β β) (hw : β x y,0 < w x y) | |
| (hz : 0 < partition w β ) (K D : β) : 0 < sourceBagZ w K D := by | |
| apply (sourceRealPortion_full_pos w hz K).trans_le | |
| apply partitionWeight_mono BagEdge.Incident _ _ (sourceRealPortion_nonneg w hw K) | |
| intro e | |
| exact le_add_of_nonneg_right (div_nonneg (bagHeight_pos w K _).le (Nat.cast_nonneg D)) | |
| lemma sourceBagZ_bounds (hn : 2 β€ Fintype.card V) (w : V β V β β) | |
| (hw : β x y,0 < w x y) (hz : 0 < partition w β ) | |
| (hrlo : β x,(1:β)/4 β€ rowMax hn w x) (hrhi : β x,rowMax hn w x β€ 1) | |
| (K : β) (hK : β x y,xβ y β edgeActivity w x y β€ (4:β)^K) : | |
| sourceC w K*partition w β β€ sourceBagZ w K (sourceD (V:=V) K) β§ | |
| sourceBagZ w K (sourceD (V:=V) K) β€ 2*(sourceC w K*partition w β ) := by | |
| have h := source_bag_inflation hn w hw hz hrlo hrhi K hK | |
| change 1 β€ _ / _ β§ _ / _ β€ 2 at h | |
| have he : partitionWeight BagEdge.Incident (sourceRealPortion w K) univ=sourceC w K*partition w β := | |
| sourceRealPortion_full w hz K | |
| have hb : sourceBagZ w K (sourceD (V:=V) K)= | |
| partitionWeight BagEdge.Incident (fun e : BagEdge (sourceBags w K) => | |
| sourceRealPortion w K e+(2:β)^e.val.val.2.1.val/inflationScale (V:=SourceVertex V K) (holeScale V)) univ := by | |
| unfold sourceBagZ sourceBagWeight bagHeight | |
| rw [sourceD_cast] | |
| rw [βhb,he] at h | |
| have hp := mul_pos (sourceC_pos w K) hz | |
| exact β¨by simpa using (le_div_iffβ hp).mp h.1,(div_le_iffβ hp).mp h.2β© | |
| theorem source_observable_means (hn : 2 β€ Fintype.card V) (w wβ : V β V β β) | |
| (hw : β x y,0 < w x y) (hz : 0 < partition w β ) | |
| (hrlo : β x,(1:β)/4 β€ rowMax hn w x) (hrhi : β x,rowMax hn w x β€ 1) | |
| (hlo : β x y,xβ y β (1+1/(Fintype.card V:β))β»ΒΉ*w x y β€ wβ x y) | |
| (hhi : β x y,xβ y β wβ x y β€ w x y) | |
| (K : β) (hK : β x y,xβ y β edgeActivity w x y β€ (4:β)^K) : | |
| let D := sourceD (V:=V) K | |
| let a := β q : SourceMarked w K,sourceLaw w K D q*observableA w K q | |
| let d := β q : SourceMarked w K,sourceLaw w K D q*observableD w wβ K q | |
| (β q : SourceMarked w K,sourceLaw w K D q)=1 β§ | |
| (β q : SourceMarked w K,0 β€ sourceLaw w K D q) β§ | |
| (1:β)/2 β€ a β§ (1:β)/4 β€ d β§ | |
| d/a=partition wβ β /partition w β β§ (1:β)/2 β€ d/a β§ d/a β€ 1 β§ | |
| (β e : LogicalEdge V, | |
| (D:β)*(β q : SourceMarked w K,sourceLaw w K D q*observableProbe w wβ K e q)/d= | |
| Switching.holeRatio wβ {source e,target e}) := by | |
| dsimp only | |
| let D := sourceD (V:=V) K | |
| have hp := sourceBagZ_pos w hw hz K D | |
| have hb := sourceBagZ_bounds hn w hw hz hrlo hrhi K hK | |
| have hc := partition_cooling hn w wβ (fun x y => (hw x y).le) hlo hhi β | |
| have hzβ : 0 < partition wβ β := (half_pos hz).trans_le hc.1 | |
| have hC := sourceC_pos w K | |
| have hDn : (D:β)β 0 := by exact_mod_cast (Nat.ne_of_gt (sourceD_one (V:=V) K)) | |
| refine β¨sourceLaw_sum w K D hp.ne',sourceLaw_nonneg w hw K D hp.le,?_,?_,?_,?_,?_,?_β© | |
| Β· rw [observableA_mean w hz] | |
| apply (le_div_iffβ hp).mpr | |
| nlinarith [hb.2] | |
| Β· rw [observableD_mean w wβ hw hzβ] | |
| apply (le_div_iffβ hp).mpr | |
| nlinarith [mul_le_mul_of_nonneg_left hc.1 hC.le,hb.2] | |
| Β· rw [observableD_mean w wβ hw hzβ,observableA_mean w hz] | |
| field_simp [hC.ne',hz.ne',hp.ne'] | |
| simpa only [D] using div_self hp.ne' | |
| Β· rw [observableD_mean w wβ hw hzβ,observableA_mean w hz] | |
| have he : (sourceC w K*partition wβ β /sourceBagZ w K D)/ | |
| (sourceC w K*partition w β /sourceBagZ w K D)=partition wβ β /partition w β := by | |
| field_simp [hC.ne',hz.ne',hp.ne'] | |
| rw [he] | |
| exact (le_div_iffβ hz).mpr (by linarith) | |
| Β· rw [observableD_mean w wβ hw hzβ,observableA_mean w hz] | |
| have he : (sourceC w K*partition wβ β /sourceBagZ w K D)/ | |
| (sourceC w K*partition w β /sourceBagZ w K D)=partition wβ β /partition w β := by | |
| field_simp [hC.ne',hz.ne',hp.ne'] | |
| rw [he] | |
| exact (div_le_one hz).mpr hc.2 | |
| Β· intro e | |
| rw [observableProbe_mean w wβ hw,observableD_mean w wβ hw hzβ] | |
| unfold Switching.holeRatio | |
| dsimp only [D] at hDn hp β’ | |
| field_simp [hC.ne',hzβ.ne',hp.ne',hDn] | |
| end MatchingFPRAS.Enlargement | |
| noncomputable section | |
| namespace MatchingFPRAS.RealStage | |
| open Finset | |
| abbrev alpha : β := 1/100000 | |
| lemma others_nonempty {n : β} (hn : 2 β€ n) (i : Fin n) : (univ.erase i).Nonempty := by | |
| let j : Fin n := β¨if i.val=0 then 1 else 0, by split_ifs <;> omegaβ© | |
| refine β¨j,mem_erase.mpr β¨?_,mem_univ _β©β© | |
| apply Fin.ne_of_val_ne | |
| dsimp [j]; split_ifs <;> omega | |
| def rowMaximum {n : β} (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) (i : Fin n) : β := | |
| (univ.erase i).sup' (others_nonempty hn i) (fun j => G i j / v j) | |
| def scaleUpdate {n : β} (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) (i : Fin n) : Fin n β β := | |
| Function.update v i (rowMaximum hn G v i) | |
| def scalingTrace {n : β} (hn : 2 β€ n) (G : Fin n β Fin n β β) : β β Fin n β β | |
| | 0 => fun _ => 2 | |
| | k+1 => if hk : k<n then scaleUpdate hn G (scalingTrace hn G k) β¨k,hkβ© else scalingTrace hn G k | |
| open Finset | |
| variable {n : β} | |
| structure ScaleInvariant (G : Fin n β Fin n β β) (v : Fin n β β) : Prop where | |
| lower : β i, alpha/2 β€ v i | |
| upper : β i, v i β€ 2 | |
| feasible : β i j, iβ j β G i j β€ v i*v j | |
| lemma ScaleInvariant.pos {G : Fin n β Fin n β β} {v : Fin n β β} | |
| (hv : ScaleInvariant G v) (i) : 0 < v i := lt_of_lt_of_le (by norm_num [alpha]) (hv.lower i) | |
| lemma rowMaximum_le (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) | |
| (hv : ScaleInvariant G v) (i) : rowMaximum hn G v i β€ v i := by | |
| apply Finset.sup'_le | |
| intro j hj | |
| exact (div_le_iffβ (hv.pos j)).mpr (hv.feasible i j (mem_erase.mp hj).1.symm) | |
| lemma ratio_le_rowMaximum (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) | |
| (i j) (hji : jβ i) : G i j/v j β€ rowMaximum hn G v i := | |
| Finset.le_sup' (fun j => G i j/v j) (mem_erase.mpr β¨hji,mem_univ _β©) | |
| lemma rowMaximum_lower (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) | |
| (hG : β i j, iβ j β alpha β€ G i j) (hv : ScaleInvariant G v) (i) : | |
| alpha/2 β€ rowMaximum hn G v i := by | |
| obtain β¨j,hjβ© := others_nonempty hn i | |
| have hji := (mem_erase.mp hj).1 | |
| apply le_trans _ (ratio_le_rowMaximum hn G v i j hji) | |
| apply (le_div_iffβ (hv.pos j)).mpr | |
| have hGi := hG i j hji.symm | |
| have hvi := hv.upper j | |
| norm_num [alpha] at * | |
| linarith | |
| lemma scaleUpdate_le (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) | |
| (hv : ScaleInvariant G v) (i j) : scaleUpdate hn G v i j β€ v j := by | |
| by_cases hji : j=i | |
| Β· subst j; simpa [scaleUpdate] using rowMaximum_le hn G v hv i | |
| Β· simp [scaleUpdate,Function.update_of_ne hji] | |
| lemma scaleUpdate_invariant (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) | |
| (hsym : β i j, G i j=G j i) (hG : β i j, iβ j β alpha β€ G i j) | |
| (hv : ScaleInvariant G v) (i) : ScaleInvariant G (scaleUpdate hn G v i) := by | |
| constructor | |
| Β· intro j | |
| by_cases hji : j=i | |
| Β· subst j; simpa [scaleUpdate] using rowMaximum_lower hn G v hG hv i | |
| Β· simpa [scaleUpdate,Function.update_of_ne hji] using hv.lower j | |
| Β· intro j; exact (scaleUpdate_le hn G v hv i j).trans (hv.upper j) | |
| Β· intro a b hab | |
| by_cases hai : a=i | |
| Β· subst a | |
| have hb := (div_le_iffβ (hv.pos b)).mp (ratio_le_rowMaximum hn G v i b hab.symm) | |
| simpa [scaleUpdate,Function.update_of_ne hab.symm] using hb | |
| Β· by_cases hbi : b=i | |
| Β· subst b | |
| have ha := (div_le_iffβ (hv.pos a)).mp (ratio_le_rowMaximum hn G v i a hai) | |
| simpa [scaleUpdate,Function.update_of_ne hai,hsym i a,mul_comm] using ha | |
| Β· simpa [scaleUpdate,Function.update_of_ne hai,Function.update_of_ne hbi] using hv.feasible a b hab | |
| lemma scaleUpdate_tight (hn : 2 β€ n) (G : Fin n β Fin n β β) (v : Fin n β β) | |
| (hv : ScaleInvariant G v) (i) : | |
| β j, jβ i β§ scaleUpdate hn G v i i*scaleUpdate hn G v i j=G i j := by | |
| obtain β¨j,hj,heqβ© := Finset.exists_mem_eq_sup' (others_nonempty hn i) (fun j => G i j/v j) | |
| have hji := (mem_erase.mp hj).1 | |
| refine β¨j,hji,?_β© | |
| change rowMaximum hn G v i = G i j/v j at heq | |
| simp only [scaleUpdate,Function.update_self,Function.update_of_ne hji] | |
| rw [heq] | |
| exact div_mul_cancelβ _ (hv.pos j).ne' | |
| lemma tight_persists (G : Fin n β Fin n β β) (v v' : Fin n β β) | |
| (hv : ScaleInvariant G v) (hv' : ScaleInvariant G v') (hdown : β i, v' i β€ v i) | |
| (i j) (hji : jβ i) (hij : v i*v j=G i j) : v' i*v' j=G i j := by | |
| apply le_antisymm | |
| Β· calc | |
| _ β€ v i*v j := mul_le_mul (hdown i) (hdown j) (hv'.pos j).le (hv.pos i).le | |
| _ = _ := hij | |
| Β· exact hv'.feasible i j hji.symm | |
| end MatchingFPRAS.RealStage | |
| end | |
| end OAI | |