Download data/lean/OAI/Combinatorics/MatchingCount/Graphs/RowPeak.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 21.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/RowPeak.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Graphs/RowPeak.lean
-
curl -L -o RowPeak.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Graphs/RowPeak.lean
21.3 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Graphs.RatWeight | |
| namespace OAI | |
| noncomputable section | |
| namespace MatchingFPRAS.RealStage | |
| open Finset | |
| variable {n : β} | |
| lemma scalingTrace_invariant (hn : 2 β€ n) (G : Fin n β Fin n β β) | |
| (hsym : β i j, G i j=G j i) (hG : β i j, iβ j β alpha β€ G i j β§ G i j β€ 3) | |
| (k : β) : ScaleInvariant G (scalingTrace hn G k) β§ | |
| β i, i.val<k β β j, jβ i β§ scalingTrace hn G k i*scalingTrace hn G k j=G i j := by | |
| induction k with | |
| | zero => | |
| constructor | |
| Β· constructor | |
| Β· intro i; norm_num [scalingTrace,alpha] | |
| Β· intro i; simp [scalingTrace] | |
| Β· intro i j h; have := (hG i j h).2; simp only [scalingTrace]; linarith | |
| Β· intro i hi; omega | |
| | succ k ih => | |
| by_cases hk : k<n | |
| Β· let i : Fin n := β¨k,hkβ© | |
| have hinv := scaleUpdate_invariant hn G (scalingTrace hn G k) hsym (fun i j h => (hG i j h).1) ih.1 i | |
| have htrace : scalingTrace hn G (k+1)=scaleUpdate hn G (scalingTrace hn G k) i := by | |
| simp [scalingTrace,hk,i] | |
| rw [htrace] | |
| refine β¨hinv,?_β© | |
| intro a ha | |
| by_cases hak : a.val<k | |
| Β· obtain β¨j,hj,heβ© := ih.2 a hak | |
| refine β¨j,hj,?_β© | |
| exact tight_persists G _ _ ih.1 hinv (scaleUpdate_le hn G _ ih.1 i) a j hj he | |
| Β· have hai : a=i := Fin.ext (by dsimp [i]; omega) | |
| subst a | |
| exact scaleUpdate_tight hn G _ ih.1 i | |
| Β· have htrace : scalingTrace hn G (k+1)=scalingTrace hn G k := by simp [scalingTrace,hk] | |
| rw [htrace] | |
| refine β¨ih.1,?_β© | |
| intro i _ | |
| exact ih.2 i (by have := i.isLt; omega) | |
| open Finset | |
| theorem one_pass_scaling {n : β} (hn : 2 β€ n) (G : Fin n β Fin n β β) | |
| (hsym : β i j, G i j=G j i) (hG : β i j, iβ j β alpha β€ G i j β§ G i j β€ 3) : | |
| (β k i, scalingTrace hn G (k+1) i β€ scalingTrace hn G k i) β§ | |
| (β i, alpha/2 β€ scalingTrace hn G n i β§ scalingTrace hn G n i β€ 2) β§ | |
| (β i j, iβ j β G i j β€ scalingTrace hn G n i * scalingTrace hn G n j) β§ | |
| (β i, β j, jβ i β§ scalingTrace hn G n i * scalingTrace hn G n j=G i j) := by | |
| have htrace := scalingTrace_invariant hn G hsym hG | |
| refine β¨?_,(htrace n).1.lower |> fun h => ?_β© | |
| Β· intro k i | |
| by_cases hk : k<n | |
| Β· change (if h : k<n then scaleUpdate hn G (scalingTrace hn G k) β¨k,hβ© else scalingTrace hn G k) i β€ _ | |
| rw [dite_eq_left hk] | |
| exact scaleUpdate_le hn G _ (htrace k).1 β¨k,hkβ© i | |
| Β· simp [scalingTrace,hk] | |
| Β· refine β¨fun i => β¨h i,(htrace n).1.upper iβ©,(htrace n).1.feasible,?_β© | |
| intro i | |
| exact (htrace n).2 i i.isLt | |
| def rowPeak {n : β} (hn : 2 β€ n) (g : Fin n β Fin n β β) (i : Fin n) : β := | |
| (univ.erase i).sup' (others_nonempty hn i) (g i) | |
| def scaledHoleMatrix {n : β} (g : Fin n β Fin n β β) (v : Fin n β β) (i j : Fin n) : β := | |
| g i j/(v i*v j) | |
| def BalancedRows {n : β} (hn : 2 β€ n) (g : Fin n β Fin n β β) : Prop := | |
| β i, (1:β)/4 β€ rowPeak hn g i β§ rowPeak hn g i β€ 1 | |
| theorem one_pass_restores_balance {n : β} (hn : 2 β€ n) (g G : Fin n β Fin n β β) | |
| (hGsym : β i j, G i j=G j i) | |
| (hG : β i j, iβ j β alpha β€ G i j β§ G i j β€ 3) | |
| (hpre : β i, (1:β)/8 β€ rowPeak hn g i) | |
| (haccuracy : β i j, iβ j β g i j β€ G i j β§ G i j β€ g i j+2*alpha) : | |
| (β i, (1:β)/16 β€ scalingTrace hn G n i) β§ | |
| BalancedRows hn (scaledHoleMatrix g (scalingTrace hn G n)) := by | |
| let v := scalingTrace hn G n | |
| have hv := (scalingTrace_invariant hn G hGsym hG n).1 | |
| have hlow (i : Fin n) : (1:β)/16 β€ v i := by | |
| obtain β¨j,hj,heqβ© := Finset.exists_mem_eq_sup' (others_nonempty hn i) (g i) | |
| have hji := (mem_erase.mp hj).1 | |
| change rowPeak hn g i=g i j at heq | |
| have hgij : (1:β)/8 β€ g i j := by rw [β heq]; exact hpre i | |
| have hGi := (haccuracy i j hji.symm).1 | |
| have hfeas := hv.feasible i j hji.symm | |
| have hup := mul_le_mul_of_nonneg_left (hv.upper j) (hv.pos i).le | |
| dsimp [v] | |
| linarith | |
| refine β¨hlow,?_β© | |
| intro i | |
| constructor | |
| Β· obtain β¨j,hji,heqβ© := (one_pass_scaling hn G hGsym hG).2.2.2 i | |
| have hprod : (1:β)/256 β€ v i*v j := by | |
| calc | |
| (1:β)/256 = ((1:β)/16)*((1:β)/16) := by norm_num | |
| _ β€ v i*v j := mul_le_mul (hlow i) (hlow j) (by norm_num) (hv.pos i).le | |
| have hacc := (haccuracy i j hji.symm).2 | |
| have hg : (1:β)/4 β€ scaledHoleMatrix g v i j := by | |
| apply (le_div_iffβ (mul_pos (hv.pos i) (hv.pos j))).mpr | |
| change v i*v j=G i j at heq | |
| norm_num [alpha] at hacc | |
| nlinarith | |
| apply hg.trans | |
| exact Finset.le_sup' (scaledHoleMatrix g v i) (mem_erase.mpr β¨hji,mem_univ _β©) | |
| Β· apply Finset.sup'_le | |
| intro j hj | |
| have hji := (mem_erase.mp hj).1 | |
| apply (div_le_one (mul_pos (hv.pos i) (hv.pos j))).mpr | |
| exact ((haccuracy i j hji.symm).1).trans (hv.feasible i j hji.symm) | |
| def sigma (D K : β) (epsilon : β) : β := min (alpha/(100*D)) (epsilon/(1000*K)) | |
| def ratioEstimate (abar dbar : β) : β := if 0<abar then dbar/abar else 1 | |
| def upperEstimate (D : β) (dbar zbar : β) : β := | |
| if 0<dbar then max alpha (min 3 ((D:β)*zbar/dbar+alpha)) else 1 | |
| lemma sigma_nonneg (D K : β) (epsilon : β) (he : 0 β€ epsilon) : 0 β€ sigma D K epsilon := by | |
| unfold sigma alpha; positivity | |
| lemma sigma_small (D K : β) (hD : 1 β€ D) (epsilon : β) : sigma D K epsilon β€ (1:β)/10000000 := by | |
| have hDr : (1:β) β€ D := by exact_mod_cast hD | |
| apply (min_le_left _ _).trans | |
| apply (div_le_iffβ (by positivity : 0 < (100:β)*D)).mpr | |
| norm_num [alpha] | |
| linarith | |
| lemma sigma_times_D (D K : β) (hD : 1 β€ D) (epsilon : β) : (D:β)*sigma D K epsilon β€ alpha/100 := by | |
| have hDr : (1:β) β€ D := by exact_mod_cast hD | |
| have hs : sigma D K epsilon β€ alpha/(100*D) := min_le_left _ _ | |
| have hm := (le_div_iffβ (by positivity : 0 < (100:β)*D)).mp hs | |
| norm_num [alpha] at hm β’ | |
| nlinarith only [hm] | |
| lemma sigma_relative (D K : β) (epsilon : β) : 10*sigma D K epsilon β€ epsilon/(100*K) := by | |
| have h : sigma D K epsilon β€ epsilon/(1000*K) := min_le_right _ _ | |
| calc | |
| _ β€ 10*(epsilon/(1000*K)) := mul_le_mul_of_nonneg_left h (by norm_num) | |
| _ = _ := by ring | |
| lemma ratio_error (s a d abar dbar : β) (hs : 0 β€ s) (hs1 : s β€ (1:β)/100) | |
| (ha : (1:β)/2 β€ a) (hR : (1:β)/2 β€ d/a β§ d/a β€ 1) | |
| (haerr : |abar-a| β€ s) (hderr : |dbar-d| β€ s) : | |
| |ratioEstimate abar dbar/(d/a)-1| β€ 10*s := by | |
| have hab := abs_le.mp haerr | |
| have hdb := abs_le.mp hderr | |
| have hap : 0 < a := by linarith | |
| have habp : 0 < abar := by linarith | |
| have hRp : 0 < d/a := by linarith [hR.1] | |
| have hden : (1:β)/5 β€ (d/a)*abar := by | |
| have hbar : (1:β)/2-s β€ abar := by linarith | |
| have hm := mul_le_mul hR.1 hbar (by linarith : 0 β€ (1:β)/2-s) hRp.le | |
| nlinarith | |
| have hnum : |dbar-(d/a)*abar| β€ 2*s := by | |
| have hid : dbar-(d/a)*abar=(dbar-d)+(d/a)*(a-abar) := by | |
| have hm : (d/a)*a=d := div_mul_cancelβ d hap.ne' | |
| nlinarith | |
| rw [hid] | |
| calc | |
| _ β€ |dbar-d|+|(d/a)*(a-abar)| := abs_add_le _ _ | |
| _ = |dbar-d|+(d/a)*|abar-a| := by rw [abs_mul,abs_of_pos hRp,abs_sub_comm a abar] | |
| _ β€ s+(d/a)*s := add_le_add hderr (mul_le_mul_of_nonneg_left haerr hRp.le) | |
| _ β€ 2*s := by nlinarith [mul_le_mul_of_nonneg_right hR.2 hs] | |
| have hid : ratioEstimate abar dbar/(d/a)-1=(dbar-(d/a)*abar)/((d/a)*abar) := by | |
| simp only [ratioEstimate, ite_eq_left habp] | |
| have hdne : d β 0 := by intro hh; simp [hh] at hRp | |
| field_simp [hap.ne', habp.ne', hdne] | |
| rw [hid,abs_div,abs_of_pos (mul_pos hRp habp)] | |
| apply (div_le_iffβ (mul_pos hRp habp)).mpr | |
| nlinarith [mul_le_mul_of_nonneg_right hden (show 0 β€ 10*s by positivity)] | |
| lemma upper_error (D : β) (hD : 1 β€ D) (s d z dbar zbar : β) | |
| (hs : 0 β€ s) (hs1 : s β€ (1:β)/100) | |
| (hDs : (D:β)*s β€ alpha/100) (hd : (1:β)/4 β€ d) | |
| (hg : 0 β€ (D:β)*z/d β§ (D:β)*z/d β€ 2) | |
| (hderr : |dbar-d| β€ s) (hzerr : |zbar-z| β€ s) : | |
| alpha β€ upperEstimate D dbar zbar β§ upperEstimate D dbar zbar β€ 3 β§ | |
| (D:β)*z/d β€ upperEstimate D dbar zbar β§ | |
| upperEstimate D dbar zbar β€ (D:β)*z/d+2*alpha := by | |
| have hDr : (1:β) β€ D := by exact_mod_cast hD | |
| have hdp : 0 < d := by linarith | |
| have hdb := abs_le.mp hderr | |
| have hbar : (1:β)/5 β€ dbar := by linarith | |
| have hbarp : 0 < dbar := by linarith | |
| let g := (D:β)*z/d | |
| have hg0 : 0 β€ g := hg.1 | |
| have hg2 : g β€ 2 := hg.2 | |
| have hnum : |(D:β)*(zbar-z)+g*(d-dbar)| β€ ((D:β)+2)*s := by | |
| calc | |
| _ β€ |(D:β)*(zbar-z)|+|g*(d-dbar)| := abs_add_le _ _ | |
| _ = (D:β)*|zbar-z|+g*|dbar-d| := by | |
| rw [abs_mul, abs_mul, abs_of_nonneg (Nat.cast_nonneg D), abs_of_nonneg hg0, | |
| abs_sub_comm d dbar] | |
| _ β€ (D:β)*s+g*s := add_le_add (mul_le_mul_of_nonneg_left hzerr (Nat.cast_nonneg D)) | |
| (mul_le_mul_of_nonneg_left hderr hg0) | |
| _ β€ ((D:β)+2)*s := by nlinarith [mul_le_mul_of_nonneg_right hg2 hs] | |
| have hid : (D:β)*zbar/dbar-g=((D:β)*(zbar-z)+g*(d-dbar))/dbar := by | |
| dsimp [g] | |
| field_simp [hdp.ne', hbarp.ne'] | |
| ring | |
| have hraw : |(D:β)*zbar/dbar-g| β€ alpha := by | |
| rw [hid, abs_div, abs_of_pos hbarp] | |
| apply (div_le_iffβ hbarp).mpr | |
| have hsm : s β€ (D:β)*s := by nlinarith [mul_le_mul_of_nonneg_right hDr hs] | |
| have ha : 0 < alpha := by norm_num [alpha] | |
| have hm := mul_le_mul_of_nonneg_left hbar ha.le | |
| norm_num [alpha] at hDs hm β’ | |
| nlinarith only [hDs, hm, hnum, hsm] | |
| have hbounds := abs_le.mp hraw | |
| unfold upperEstimate | |
| rw [ite_eq_left hbarp] | |
| refine β¨le_max_left _ _, ?_, ?_, ?_β© | |
| Β· apply max_le | |
| Β· norm_num [alpha] | |
| Β· exact min_le_left _ _ | |
| Β· apply le_max_of_le_right | |
| exact le_min (by linarith) (by linarith) | |
| Β· apply max_le | |
| Β· have ha : 0 β€ alpha := by norm_num [alpha] | |
| linarith | |
| Β· exact (min_le_right _ _).trans (by linarith) | |
| theorem successful_stage_estimates (D K : β) (hD : 1 β€ D) (_hK : 1 β€ K) | |
| (epsilon : β) (he : 0<epsilon) (he1 : epsilon<1) | |
| (a d z abar dbar zbar : β) (ha : (1:β)/2 β€ a) (hd : (1:β)/4 β€ d) | |
| (hR : (1:β)/2 β€ d/a β§ d/a β€ 1) | |
| (hg : 0 β€ (D:β)*z/d β§ (D:β)*z/d β€ 2) | |
| (haerr : |abar-a| β€ sigma D K epsilon) | |
| (hderr : |dbar-d| β€ sigma D K epsilon) | |
| (hzerr : |zbar-z| β€ sigma D K epsilon) : | |
| 0<abar β§ 0<dbar β§ | |
| |ratioEstimate abar dbar/(d/a)-1| β€ 10*sigma D K epsilon β§ | |
| 10*sigma D K epsilon β€ epsilon/(100*K) β§ | |
| alpha β€ upperEstimate D dbar zbar β§ upperEstimate D dbar zbar β€ 3 β§ | |
| (D:β)*z/d β€ upperEstimate D dbar zbar β§ | |
| upperEstimate D dbar zbar β€ (D:β)*z/d+2*alpha := by | |
| have hs := sigma_nonneg D K epsilon he.le | |
| have hs1 : sigma D K epsilon β€ (1:β)/100 := | |
| (sigma_small D K hD epsilon).trans (by norm_num) | |
| have hab := abs_le.mp haerr | |
| have hdb := abs_le.mp hderr | |
| refine β¨by linarith, by linarith, ?_, sigma_relative D K epsilon, ?_β© | |
| Β· exact ratio_error _ _ _ _ _ hs hs1 ha hR haerr hderr | |
| Β· exact upper_error D hD _ _ _ _ _ hs hs1 (sigma_times_D D K hD epsilon) hd hg hderr hzerr | |
| end MatchingFPRAS.RealStage | |
| end | |
| namespace MatchingFPRAS.Enlargement | |
| open MatchingFPRAS.Switching MatchingFPRAS.Subdivision MatchingFPRAS.RealGeometry | |
| open MatchingFPRAS.Hierarchy MatchingFPRAS.Transport MatchingFPRAS.StageAnalysis Finset | |
| open scoped Classical | |
| variable {V : Type*} [Fintype V] [LinearOrder V] | |
| def pairEdge (i j : V) (hij : iβ j) : LogicalEdge V := | |
| β¨(min i j,max i j),min_lt_max.mpr hijβ© | |
| omit [Fintype V] in | |
| lemma pairEdge_swap (i j : V) (hij : iβ j) : pairEdge i j hij=pairEdge j i hij.symm := by | |
| apply Subtype.ext | |
| simp [pairEdge,min_comm,max_comm] | |
| omit [Fintype V] in | |
| lemma pairEdge_holes (i j : V) (hij : iβ j) : | |
| ({source (pairEdge i j hij),target (pairEdge i j hij)} : Finset V)={i,j} := by | |
| rcases le_total i j with h|h | |
| Β· simp [pairEdge,source,target,min_eq_left h,max_eq_right h] | |
| Β· simp [pairEdge,source,target,min_eq_right h,max_eq_left h,Finset.pair_comm] | |
| noncomputable def probeMatrix (z : LogicalEdge V β β) (i j : V) : β := | |
| if hij : i=j then 0 else z (pairEdge i j hij) | |
| omit [Fintype V] in | |
| lemma probeMatrix_off (z : LogicalEdge V β β) (i j : V) (hij : iβ j) : | |
| probeMatrix z i j=z (pairEdge i j hij) := dite_eq_right hij | |
| omit [Fintype V] in | |
| lemma probeMatrix_symm (z : LogicalEdge V β β) (i j : V) : probeMatrix z i j=probeMatrix z j i := by | |
| by_cases hij : i=j | |
| Β· subst j; rfl | |
| Β· rw [probeMatrix_off _ _ _ hij,probeMatrix_off _ _ _ (Ne.symm hij),pairEdge_swap] | |
| noncomputable def estimateMatrix (D : β) (dbar : β) (zbar : LogicalEdge V β β) (i j : V) : β := | |
| RealStage.upperEstimate D dbar (probeMatrix zbar i j) | |
| omit [Fintype V] in | |
| lemma estimateMatrix_symm (D : β) (dbar : β) (zbar : LogicalEdge V β β) (i j : V) : | |
| estimateMatrix D dbar zbar i j=estimateMatrix D dbar zbar j i := by | |
| rw [estimateMatrix,estimateMatrix,probeMatrix_symm] | |
| lemma rowMax_cooling_lower (hn : 2 β€ Fintype.card V) (w wβ : V β V β β) | |
| (hw : β x y,0 β€ w x y) (hz : 0 < partition w β ) | |
| (hr : β i,(1:β)/4 β€ rowMax hn w i) | |
| (hc : β R,partition w R/2 β€ partition wβ R β§ partition wβ R β€ partition w R) (i : V) : | |
| (1:β)/8 β€ rowMax hn wβ i := by | |
| obtain β¨j,hji,hjβ© := rowMax_attained hn w i | |
| have h := (holeRatio_cooling w wβ hw hz hc {i,j}).1 | |
| have hu := holeRatio_le_rowMax hn wβ i j hji.symm | |
| rw [hj] at h | |
| linarith [hr i] | |
| variable [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 _ | |
| noncomputable def meanA (w : V β V β β) (K : β) : β := | |
| β q : SourceMarked w K,sourceLaw w K (sourceD (V:=V) K) q*observableA w K q | |
| noncomputable def meanD (w wβ : V β V β β) (K : β) : β := | |
| β q : SourceMarked w K,sourceLaw w K (sourceD (V:=V) K) q*observableD w wβ K q | |
| noncomputable def meanProbe (w wβ : V β V β β) (K : β) (e : LogicalEdge (V)) : β := | |
| β q : SourceMarked w K,sourceLaw w K (sourceD (V:=V) K) q*observableProbe w wβ K e q | |
| variable {n : β} [Nontrivial (Fin n)] | |
| noncomputable local instance (w : Fin n β Fin n β β) (K : β) : DecidableEq (SourceLabel w K) := Classical.decEq _ | |
| noncomputable local instance (w : Fin n β Fin n β β) (K : β) : Fintype (BagEdge (sourceBags w K)) := Fintype.ofFinite _ | |
| omit [Nontrivial (Fin n)] in | |
| lemma rowPeak_holeMatrix (hn : 2 β€ n) (w : Fin n β Fin n β β) (i : Fin n) : | |
| RealStage.rowPeak hn (fun i j => Switching.holeRatio w {i,j}) i= | |
| rowMax (by simpa using hn) w i := rfl | |
| structure StageData (n K T : β) where | |
| hn : 2 β€ n | |
| w : Fin n β Fin n β β | |
| next : Fin n β Fin n β β | |
| positive : β i j,0 < w i j | |
| next_positive : β i j,0 < next i j | |
| partition_positive : 0 < partition w β | |
| lower : β i,(1:β)/4 β€ rowMax (by simpa using hn) w i | |
| upper : β i,rowMax (by simpa using hn) w i β€ 1 | |
| cool_lower : β i j,iβ j β (1+1/(n:β))β»ΒΉ*w i j β€ next i j | |
| cool_upper : β i j,iβ j β next i j β€ w i j | |
| cap : β i j,iβ j β edgeActivity w i j β€ (4:β)^K | |
| stages : 1 β€ T | |
| epsilon : β | |
| epsilon_positive : 0 < epsilon | |
| epsilon_lt_one : epsilon < 1 | |
| variable {K T : β} | |
| structure EmpiricalData (c : StageData n K T) where | |
| abar : β | |
| dbar : β | |
| zbar : LogicalEdge (Fin n) β β | |
| errorA : |abar-meanA c.w K| β€ RealStage.sigma (sourceD (V:=Fin n) K) T c.epsilon | |
| errorD : |dbar-meanD c.w c.next K| β€ RealStage.sigma (sourceD (V:=Fin n) K) T c.epsilon | |
| errorProbe : β e,|zbar e-meanProbe c.w c.next K e| β€ RealStage.sigma (sourceD (V:=Fin n) K) T c.epsilon | |
| omit [Nontrivial (Fin n)] in | |
| lemma StageData.cooling (c : StageData n K T) (R : Finset (Fin n)) : | |
| partition c.w R/2 β€ partition c.next R β§ partition c.next R β€ partition c.w R := by | |
| apply partition_cooling (by simpa using c.hn) c.w c.next (fun i j => (c.positive i j).le) | |
| Β· simpa using c.cool_lower | |
| Β· exact c.cool_upper | |
| lemma StageData.mean_bounds (c : StageData n K T) : | |
| (1:β)/2 β€ meanA c.w K β§ (1:β)/4 β€ meanD c.w c.next K β§ | |
| meanD c.w c.next K/meanA c.w K=partition c.next β /partition c.w β β§ | |
| (1:β)/2 β€ meanD c.w c.next K/meanA c.w K β§ meanD c.w c.next K/meanA c.w K β€ 1 β§ | |
| (β e,(sourceD (V:=Fin n) K:β)*meanProbe c.w c.next K e/meanD c.w c.next K= | |
| Switching.holeRatio c.next {source e,target e}) := by | |
| have h := source_observable_means (V:=Fin n) (by simpa using c.hn) c.w c.next c.positive c.partition_positive | |
| c.lower c.upper (by simpa using c.cool_lower) c.cool_upper K c.cap | |
| unfold meanA meanD meanProbe | |
| exact h.2.2 | |
| omit [Nontrivial (Fin n)] in | |
| lemma StageData.hole_upper (c : StageData n K T) (i j : Fin n) (hij : iβ j) : | |
| Switching.holeRatio c.next {i,j} β€ 2 := by | |
| have h := (holeRatio_cooling c.w c.next (fun i j => (c.positive i j).le) | |
| c.partition_positive c.cooling {i,j}).2 | |
| have hr := (holeRatio_le_rowMax (by simpa using c.hn) c.w i j hij).trans (c.upper i) | |
| linarith | |
| theorem actual_stage_statistics (c : StageData n K T) (b : EmpiricalData c) (i j : Fin n) (hij : iβ j) : | |
| let G := estimateMatrix (sourceD (V:=Fin n) K) b.dbar b.zbar | |
| 0 < b.abar β§ 0 < b.dbar β§ | |
| |RealStage.ratioEstimate b.abar b.dbar/(partition c.next β /partition c.w β )-1| β€ c.epsilon/(100*T) β§ | |
| RealStage.alpha β€ G i j β§ G i j β€ 3 β§ | |
| Switching.holeRatio c.next {i,j} β€ G i j β§ | |
| G i j β€ Switching.holeRatio c.next {i,j}+2*RealStage.alpha := by | |
| dsimp only | |
| have hm := c.mean_bounds | |
| have hem := hm.2.2.2.2.2 (pairEdge i j hij) | |
| rw [pairEdge_holes] at hem | |
| have hg0 := holeRatio_nonneg c.next (fun x y => (c.next_positive x y).le) {i,j} | |
| have h := RealStage.successful_stage_estimates (sourceD (V:=Fin n) K) T (sourceD_one K) | |
| c.stages c.epsilon c.epsilon_positive c.epsilon_lt_one | |
| (meanA c.w K) (meanD c.w c.next K) (meanProbe c.w c.next K (pairEdge i j hij)) | |
| b.abar b.dbar (b.zbar (pairEdge i j hij)) hm.1 hm.2.1 | |
| β¨hm.2.2.2.1,hm.2.2.2.2.1β© | |
| β¨by rw [hem]; exact hg0,by rw [hem]; exact c.hole_upper i j hijβ© | |
| b.errorA b.errorD (b.errorProbe _) | |
| refine β¨h.1,h.2.1,?_,?_β© | |
| Β· have he := h.2.2.1.trans h.2.2.2.1 | |
| rwa [hm.2.2.1] at he | |
| Β· simpa only [estimateMatrix,probeMatrix_off _ _ _ hij,hem] using h.2.2.2.2 | |
| theorem actual_successful_stage (c : StageData n K T) (b : EmpiricalData c) : | |
| let G := estimateMatrix (sourceD (V:=Fin n) K) b.dbar b.zbar | |
| let v := RealStage.scalingTrace c.hn G n | |
| (β i,(1:β)/16 β€ v i β§ v i β€ 2) β§ | |
| (β i,(1:β)/4 β€ rowMax (by simpa using c.hn) (fun x y => c.next x y*v x*v y) i β§ | |
| rowMax (by simpa using c.hn) (fun x y => c.next x y*v x*v y) i β€ 1) β§ | |
| |RealStage.ratioEstimate b.abar b.dbar/(partition c.next β /partition c.w β )-1| β€ c.epsilon/(100*T) := by | |
| dsimp only | |
| let G := estimateMatrix (sourceD (V:=Fin n) K) b.dbar b.zbar | |
| let g := fun i j => Switching.holeRatio c.next {i,j} | |
| have hest := actual_stage_statistics c b | |
| have hGs := estimateMatrix_symm (sourceD (V:=Fin n) K) b.dbar b.zbar | |
| have hGb : β i j,iβ j β RealStage.alpha β€ G i j β§ G i j β€ 3 := by | |
| intro i j hij | |
| exact β¨(hest i j hij).2.2.2.1,(hest i j hij).2.2.2.2.1β© | |
| have hGa : β i j,iβ j β g i j β€ G i j β§ G i j β€ g i j+2*RealStage.alpha := by | |
| intro i j hij | |
| exact (hest i j hij).2.2.2.2.2 | |
| have hpre : β i,(1:β)/8 β€ RealStage.rowPeak c.hn g i := by | |
| intro i | |
| rw [show g=(fun i j => Switching.holeRatio c.next {i,j}) from rfl,rowPeak_holeMatrix] | |
| exact rowMax_cooling_lower (by simpa using c.hn) c.w c.next (fun x y => (c.positive x y).le) | |
| c.partition_positive c.lower c.cooling i | |
| have hb := RealStage.one_pass_restores_balance c.hn g G hGs hGb hpre hGa | |
| let v := RealStage.scalingTrace c.hn G n | |
| have hv := (RealStage.scalingTrace_invariant c.hn G hGs hGb n).1 | |
| have heq (i j : Fin n) (hij : iβ j) : | |
| Switching.holeRatio (fun x y => c.next x y*v x*v y) {i,j}=RealStage.scaledHoleMatrix g v i j := by | |
| rw [holeRatio_vertex_scaling c.next v (fun x => hv.pos x),Finset.prod_pair hij] | |
| rfl | |
| have hb' (i : Fin n) : (1:β)/4 β€ rowMax (by simpa using c.hn) (fun x y => c.next x y*v x*v y) i β§ | |
| rowMax (by simpa using c.hn) (fun x y => c.next x y*v x*v y) i β€ 1 := by | |
| have he : rowMax (by simpa using c.hn) (fun x y => c.next x y*v x*v y) i= | |
| RealStage.rowPeak c.hn (RealStage.scaledHoleMatrix g v) i := by | |
| unfold rowMax RealStage.rowPeak | |
| apply Finset.sup'_congr _ rfl | |
| intro j hj | |
| exact heq i j (Finset.mem_erase.mp hj).1.symm | |
| rw [he] | |
| exact hb.2 i | |
| refine β¨fun i => β¨hb.1 i,hv.upper iβ©,hb',?_β© | |
| let i : Fin n := β¨0,by have := c.hn; omegaβ© | |
| let j : Fin n := β¨1,by have := c.hn; omegaβ© | |
| have hij : iβ j := by intro h; have := Fin.val_eq_of_eq h; dsimp [i,j] at this; omega | |
| exact (hest i j hij).2.2.1 | |
| end MatchingFPRAS.Enlargement | |
| end OAI | |