Download data/lean/OAI/Combinatorics/CycleDecomposition/ReservoirSampling.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 18.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/CycleDecomposition/ReservoirSampling.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/CycleDecomposition/ReservoirSampling.lean
-
curl -L -o ReservoirSampling.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/CycleDecomposition/ReservoirSampling.lean
18.7 kB
| import OAI.Combinatorics.CycleDecomposition.SamplingCuts | |
| namespace OAI | |
| universe cycleUniverse1 cycleUniverse2 cycleUniverse3 cycleUniverse4 | |
| section | |
| open Filter Asymptotics Real | |
| open scoped Topology | |
| noncomputable section | |
| namespace ErdosGallai.Sampling | |
| lemma eventually_monomial_lt (K c a b : β) (hc : 0 < c) (hab : a < b) : | |
| βαΆ D : β in atTop, K * D^a < c * D^b := by | |
| have ht : Tendsto (fun D : β => K * D^(a-b)) atTop (π 0) := by | |
| have hh := (tendsto_rpow_neg_atTop (sub_pos.mpr hab)).const_mul K | |
| simpa only [neg_sub, mul_zero] using hh | |
| filter_upwards [eventually_gt_atTop (0 : β), ht.eventually_lt_const hc] with D hD htD | |
| have hb : 0 < D^b := Real.rpow_pos_of_pos hD b | |
| have heq : D^a = D^(a-b) * D^b := by rw [β Real.rpow_add hD]; congr 1; ring | |
| rw [heq, β mul_assoc] | |
| exact mul_lt_mul_of_pos_right htD hb | |
| lemma tendsto_monomial_exp_neg_power (a b c : β) (hb : 0 < b) (hc : 0 < c) : | |
| Tendsto (fun D : β => D^a * exp (-c * D^b)) atTop (π 0) := by | |
| have ht := (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (a/b) c hc).comp | |
| (tendsto_rpow_atTop hb) | |
| apply ht.congr' | |
| filter_upwards [eventually_gt_atTop (0 : β)] with D hD | |
| dsimp only [Function.comp_def] | |
| rw [β Real.rpow_mul hD.le, mul_div_cancelβ _ hb.ne'] | |
| lemma eventually_log_le_small_power : βαΆ D : β in atTop, log D β€ D^(1/10 : β) := by | |
| filter_upwards [(isLittleO_log_rpow_atTop (show (0 : β) < 1/10 by norm_num)).eventuallyLE, | |
| eventually_ge_atTop (1 : β)] with D hD h1 | |
| simpa only [Real.norm_eq_abs, abs_of_nonneg (Real.log_nonneg h1), | |
| abs_of_nonneg (Real.rpow_nonneg (by linarith) _)] using hD | |
| def samplingScaleError (c p D : β) : β := | |
| exp (-p/3 * D^(9/10 : β)) + | |
| D^(51/50 : β) * exp (-(p*c/8) * D^(9/10 : β)) + | |
| (2*(4/c+2)) * (D^(23/20 : β) * exp (-(p^3*c^2/512) * D^(39/50 : β))) | |
| lemma samplingScaleError_tendsto (c p : β) (hc : 0 < c) (hp : 0 < p) : | |
| Tendsto (samplingScaleError c p) atTop (π 0) := by | |
| have h0 := tendsto_monomial_exp_neg_power 0 (9/10) (p/3) (by norm_num) (by positivity) | |
| have h1 := tendsto_monomial_exp_neg_power (51/50) (9/10) (p*c/8) (by norm_num) (by positivity) | |
| have h2 := (tendsto_monomial_exp_neg_power (23/20) (39/50) (p^3*c^2/512) | |
| (by norm_num) (by positivity)).const_mul (2*(4/c+2)) | |
| unfold samplingScaleError | |
| simpa [neg_div, Real.rpow_zero] using (h0.add h1).add h2 | |
| def SamplingScaleReady (c p D : β) (r : β) : Prop := | |
| let h := c*D^(9/10 : β) | |
| let Ο := D^(37/50 : β) | |
| let M := D^(1/100 : β) | |
| 2 β€ r β§ Ο < p*h/4 β§ M β€ h β§ (r : β)*exp (-p*M/4) < 1/2 β§ | |
| 4*Ο/(p*h)+4*Ο*M/h β€ 1/2 β§ | |
| Ο+r*(4*Ο/(p*h)+4*Ο*M/h) β€ p^2*h/8 β§ | |
| exp (-p*r/3) + r*exp (-p*h/8) + | |
| 2*r*((β4*r*M/hββ+1 : β) : β) * (r : β)^β4*r*M/hββ * | |
| exp (-p^3*h^2/(256*r)) β€ samplingScaleError c p D | |
| lemma sampling_witness_error_le (c p D : β) (r : β) (hc : 0 < c) (hp : 0 < p) | |
| (hD : 1 β€ D) (hrpos : 0 < (r : β)) (hrhi : (r : β) β€ D^(51/50 : β)) | |
| (hlog : log D β€ D^(1/10 : β)) | |
| (hcost : ((51/50)*(4/c+2))*D^(23/100 : β) β€ | |
| (p^3*c^2/512)*D^(39/50 : β)) : | |
| let h := c*D^(9/10 : β) | |
| let M := D^(1/100 : β) | |
| 2*r*((β4*r*M/hββ+1 : β) : β)*(r : β)^β4*r*M/hββ* | |
| exp (-p^3*h^2/(256*r)) β€ | |
| (2*(4/c+2))*(D^(23/20 : β)*exp (-(p^3*c^2/512)*D^(39/50 : β))) := by | |
| let h := c*D^(9/10 : β) | |
| let M := D^(1/100 : β) | |
| let K := 4/c+2 | |
| have hK : 0 < K := by dsimp [K]; positivity | |
| have hDpos : 0 < D := by linarith | |
| have hh : 0 < h := by dsimp [h]; positivity | |
| have hMpos : 0 < M := Real.rpow_pos_of_pos hDpos _ | |
| have hrNat : 0 < r := by exact_mod_cast hrpos | |
| have hs : ((β4*r*M/hββ+1 : β) : β) β€ K*D^(13/100 : β) := by | |
| have hnorm : 4*D^(51/50 : β)*M/h = (4/c)*D^(13/100 : β) := by | |
| dsimp [M,h] | |
| rw [show (13/100 : β) = (51/50+1/100)-9/10 by norm_num, | |
| Real.rpow_sub hDpos, Real.rpow_add hDpos] | |
| field_simp | |
| calc | |
| _ β€ 4*r*M/h+2 := by | |
| have hs := (Nat.ceil_lt_add_one (show 0 β€ 4*(r : β)*M/h by positivity)).le | |
| push_cast | |
| linarith | |
| _ β€ 4*D^(51/50 : β)*M/h+2 := by gcongr | |
| _ = (4/c)*D^(13/100 : β)+2 := by rw [hnorm] | |
| _ β€ K*D^(13/100 : β) := by | |
| have hd := Real.one_le_rpow hD (show (0 : β) β€ 13/100 by norm_num) | |
| dsimp [K] | |
| nlinarith | |
| have hln : log (r : β) β€ (51/50)*log D := by | |
| simpa only [Real.log_rpow hDpos] using Real.log_le_log hrpos hrhi | |
| have hecost : (β4*r*M/hββ : β)*log (r : β) β€ | |
| (p^3*c^2/512)*D^(39/50 : β) := by | |
| have hs' : (β4*r*M/hββ : β) β€ K*D^(13/100 : β) := by push_cast at hs; linarith | |
| calc | |
| _ β€ K*D^(13/100 : β)*((51/50)*log D) := by | |
| apply mul_le_mul hs' hln | |
| Β· exact Real.log_nonneg (by exact_mod_cast (show 1 β€ r by omega)) | |
| Β· positivity | |
| _ β€ K*D^(13/100 : β)*((51/50)*D^(1/10 : β)) := by gcongr | |
| _ = ((51/50)*K)*D^(23/100 : β) := by | |
| have he := Real.rpow_add hDpos (13/100 : β) (1/10) | |
| norm_num at he | |
| rw [he] | |
| ring | |
| _ β€ _ := hcost | |
| have hratio : c^2*D^(39/50 : β) β€ h^2/(r : β) := by | |
| have he : c^2*D^(39/50 : β) = h^2/D^(51/50 : β) := by | |
| dsimp [h] | |
| rw [show (39/50 : β) = (9/10)*2-51/50 by norm_num, | |
| Real.rpow_sub hDpos] | |
| have he2 := Real.rpow_mul_natCast hDpos.le (9/10 : β) 2 | |
| norm_num only [Nat.cast_ofNat] at he2 | |
| rw [show (9/10 : β)*2=9/5 by norm_num, he2] | |
| ring | |
| rw [he] | |
| exact div_le_div_of_nonneg_left (sq_nonneg h) hrpos hrhi | |
| have hexpcost : exp ((β4*r*M/hββ : β)*log (r : β) - p^3*h^2/(256*r)) β€ | |
| exp (-(p^3*c^2/512)*D^(39/50 : β)) := by | |
| apply Real.exp_le_exp.mpr | |
| have hn := mul_le_mul_of_nonneg_left hratio (show 0 β€ p^3/256 by positivity) | |
| have hid : (p^3/256)*(h^2/(r : β)) =p^3*h^2/(256*r) := by ring | |
| rw [hid] at hn | |
| nlinarith | |
| have hpoly : 2*(r : β)*((β4*r*M/hββ+1 : β) : β) β€ | |
| 2*K*D^(23/20 : β) := by | |
| calc | |
| _ β€ 2*D^(51/50 : β)*(K*D^(13/100 : β)) := by gcongr | |
| _ = _ := by | |
| have he := Real.rpow_add hDpos (51/50 : β) (13/100) | |
| norm_num at he | |
| rw [he] | |
| ring | |
| have hwitness : 2*r*((β4*r*M/hββ+1 : β) : β)*(r : β)^β4*r*M/hββ* | |
| exp (-p^3*h^2/(256*r)) β€ | |
| (2*K)*(D^(23/20 : β)*exp (-(p^3*c^2/512)*D^(39/50 : β))) := by | |
| have heq : (r : β)^β4*r*M/hββ*exp (-p^3*h^2/(256*r)) = | |
| exp ((β4*r*M/hββ : β)*log (r : β)-p^3*h^2/(256*r)) := by | |
| rw [Real.exp_sub, Real.exp_nat_mul, Real.exp_log hrpos] | |
| simp only [neg_mul, Real.exp_neg, div_eq_mul_inv] | |
| rw [mul_assoc (2*(r : β)*_) _ _, heq] | |
| exact (mul_le_mul hpoly hexpcost (exp_pos _).le (by positivity)).trans_eq (by ring) | |
| exact hwitness | |
| lemma eventually_samplingScaleReady (c p : β) (hc : 0 < c) (hp : 0 < p) : | |
| βαΆ D : β in atTop, β r : β, | |
| D^(9/10 : β) β€ r β (r : β) β€ D^(51/50 : β) β SamplingScaleReady c p D r := by | |
| let K := 4/c+2 | |
| have hK : 0 < K := by dsimp [K]; positivity | |
| have hmiss : Tendsto (fun D : β => D^(51/50 : β) * exp (-p/4*D^(1/100 : β))) | |
| atTop (π 0) := by | |
| convert tendsto_monomial_exp_neg_power (51/50) (1/100) (p/4) | |
| (by norm_num) (by positivity) using 1 ; simp [neg_div] | |
| filter_upwards [eventually_ge_atTop (1 : β), | |
| (tendsto_rpow_atTop (show (0 : β) < 9/10 by norm_num)).eventually_ge_atTop 2, | |
| eventually_monomial_lt 1 (p*c/4) (37/50) (9/10) (by positivity) (by norm_num), | |
| eventually_monomial_lt 1 c (1/100) (9/10) hc (by norm_num), | |
| hmiss.eventually_lt_const (show (0 : β) < 1/2 by norm_num), | |
| eventually_monomial_lt (4/(p*c)) (1/4) (-4/25) 0 (by norm_num) (by norm_num), | |
| eventually_monomial_lt (4/c) (1/4) (-3/20) 0 (by norm_num) (by norm_num), | |
| eventually_monomial_lt 1 (p^2*c/24) (37/50) (9/10) (by positivity) (by norm_num), | |
| eventually_monomial_lt (4/(p*c)) (p^2*c/24) (43/50) (9/10) (by positivity) (by norm_num), | |
| eventually_monomial_lt (4/c) (p^2*c/24) (87/100) (9/10) (by positivity) (by norm_num), | |
| eventually_log_le_small_power, | |
| eventually_monomial_lt ((51/50)*K) (p^3*c^2/512) (23/100) (39/50) | |
| (by positivity) (by norm_num)] with D hD h2 hΟ hM hm hΞ΅β hΞ΅β htβ htβ htβ hlog hcost | |
| intro r hrlo hrhi | |
| have hDpos : 0 < D := by linarith | |
| have hr2 : 2 β€ r := by exact_mod_cast h2.trans hrlo | |
| have hrpos : 0 < (r : β) := by exact_mod_cast (show 0 < r by omega) | |
| let h := c*D^(9/10 : β) | |
| let Ο := D^(37/50 : β) | |
| let M := D^(1/100 : β) | |
| have hh : 0 < h := by dsimp [h]; positivity | |
| have hΟpos : 0 < Ο := Real.rpow_pos_of_pos hDpos _ | |
| have hMpos : 0 < M := Real.rpow_pos_of_pos hDpos _ | |
| have heβ : 4*Ο/(p*h) = (4/(p*c))*D^(-4/25 : β) := by | |
| dsimp [Ο,h] | |
| rw [show (-4/25 : β) =37/50-9/10 by norm_num, Real.rpow_sub hDpos] | |
| field_simp | |
| have heβ : 4*Ο*M/h = (4/c)*D^(-3/20 : β) := by | |
| dsimp [Ο,M,h] | |
| rw [show (-3/20 : β) =(37/50+1/100)-9/10 by norm_num, | |
| Real.rpow_sub hDpos, Real.rpow_add hDpos] | |
| field_simp | |
| have hmβ : D^(51/50 : β)*((4/(p*c))*D^(-4/25 : β)) = | |
| (4/(p*c))*D^(43/50 : β) := by | |
| rw [mul_left_comm, β Real.rpow_add hDpos] | |
| norm_num | |
| have hmβ : D^(51/50 : β)*((4/c)*D^(-3/20 : β)) = | |
| (4/c)*D^(87/100 : β) := by | |
| rw [mul_left_comm, β Real.rpow_add hDpos] | |
| norm_num | |
| refine β¨hr2, ?_, (by simpa only [one_mul] using hM.le), ?_, ?_, ?_, ?_β© | |
| Β· change Ο < p*h/4 | |
| dsimp [Ο,h] | |
| simpa only [one_mul, div_mul_eq_mul_div, mul_assoc] using hΟ | |
| Β· change (r : β)*exp (-p*M/4) < 1/2 | |
| calc | |
| _ β€ D^(51/50 : β)*exp (-p*M/4) := mul_le_mul_of_nonneg_right hrhi (exp_pos _).le | |
| _ < _ := by simpa [M, div_mul_eq_mul_div] using hm | |
| Β· change 4*Ο/(p*h)+4*Ο*M/h β€ 1/2 | |
| rw [heβ, heβ] | |
| simp only [Real.rpow_zero, mul_one] at hΞ΅β hΞ΅β | |
| linarith | |
| Β· change Ο+(r : β)*(4*Ο/(p*h)+4*Ο*M/h) β€ p^2*h/8 | |
| rw [heβ,heβ] | |
| have ht : (r : β)*((4/(p*c))*D^(-4/25 : β)+(4/c)*D^(-3/20 : β)) β€ | |
| (4/(p*c))*D^(43/50 : β)+(4/c)*D^(87/100 : β) := by | |
| calc | |
| _ β€ D^(51/50 : β)*((4/(p*c))*D^(-4/25 : β)+(4/c)*D^(-3/20 : β)) := by | |
| apply mul_le_mul_of_nonneg_right hrhi; positivity | |
| _ = _ := by rw [mul_add, hmβ, hmβ] | |
| dsimp [Ο,h] | |
| nlinarith | |
| Β· change exp (-p*r/3)+r*exp (-p*h/8)+ | |
| 2*r*((β4*r*M/hββ+1 : β) : β)*(r : β)^β4*r*M/hββ* | |
| exp (-p^3*h^2/(256*r)) β€ samplingScaleError c p D | |
| have hwitness := sampling_witness_error_le c p D r hc hp hD hrpos hrhi hlog hcost.le | |
| have hsize : exp (-p*r/3) β€ exp (-p/3*D^(9/10 : β)) := by | |
| apply exp_le_exp.mpr | |
| have ht := mul_le_mul_of_nonneg_left hrlo hp.le | |
| nlinarith | |
| have hdegree : (r : β)*exp (-p*h/8) β€ | |
| D^(51/50 : β)*exp (-(p*c/8)*D^(9/10 : β)) := by | |
| have heq : -p*h/8=-(p*c/8)*D^(9/10 : β) := by dsimp [h]; ring | |
| rw [heq] | |
| exact mul_le_mul_of_nonneg_right hrhi (exp_pos _).le | |
| exact add_le_add (add_le_add hsize hdegree) hwitness | |
| end ErdosGallai.Sampling | |
| namespace ErdosGallai.Sampling | |
| open Filter MeasureTheory Real | |
| universe u | |
| theorem vertex_sampling_uniform (c : β) (hc : 0 < c) (p : unitInterval) | |
| (hp : 0 < (p : β)) (_hp1 : (p : β) < 1) (Ξ΅ : β) (hΞ΅ : 0 < Ξ΅) : | |
| β Dβ : β, β D : β, Dβ β€ D β β (V : Type u) [Fintype V] [DecidableEq V] | |
| (P : SimpleGraph V) [DecidableRel P.Adj], | |
| D^(9/10 : β) β€ (Fintype.card V : β) β | |
| (Fintype.card V : β) β€ D^(51/50 : β) β | |
| CutExpansion P (c*D^(9/10 : β)) β | |
| (sampleMeasure V p).real {Ο | Β¬SampleGood P (p : β) (c*D^(9/10 : β)) | |
| (D^(37/50 : β)) Ο} β€ Ξ΅ := by | |
| have hevent : βαΆ D : β in atTop, | |
| 1 β€ D β§ | |
| (β r : β, D^(9/10 : β) β€ r β (r : β) β€ D^(51/50 : β) β | |
| SamplingScaleReady c (p : β) D r) β§ | |
| samplingScaleError c (p : β) D β€ Ξ΅ := by | |
| filter_upwards [eventually_ge_atTop (1 : β), eventually_samplingScaleReady c (p : β) hc hp, | |
| (samplingScaleError_tendsto c (p : β) hc hp).eventually_le_const hΞ΅] with D h1 h2 h3 | |
| exact β¨h1,h2,h3β© | |
| obtain β¨Dβ,hDββ© := hevent.exists_forall_of_atTop | |
| refine β¨Dβ, ?_β© | |
| intro D hD V _ _ P _ hrlo hrhi hexp | |
| obtain β¨h1, hready, herrβ© := hDβ D hD | |
| have hDpos : 0 < D := by linarith | |
| obtain β¨hr,hΟ,hM,hmiss,he,hperturb,hboundβ© := hready (Fintype.card V) hrlo hrhi | |
| exact (vertex_sampling_failure_bound P p hp (by positivity) (by positivity) | |
| hΟ (by positivity) hM hr hmiss he hperturb hexp).trans (hbound.trans herr) | |
| end ErdosGallai.Sampling | |
| open MeasureTheory ProbabilityTheory Finset | |
| noncomputable section | |
| namespace ErdosGallai.Sampling | |
| def reservoirLabelPMF (p : unitInterval) (hp : 3*(p : β) β€ 1) : PMF (Fin 4) := | |
| PMF.ofFintype (fun i => ENNReal.ofReal (if i = 3 then 1-3*(p : β) else (p : β))) (by | |
| rw [Fin.sum_univ_four] | |
| simp only [show (0 : Fin 4) β 3 by decide, show (1 : Fin 4) β 3 by decide, | |
| show (2 : Fin 4) β 3 by decide, βreduceIte, ] | |
| rw [β ENNReal.ofReal_add p.property.1 p.property.1, | |
| β ENNReal.ofReal_add (by linarith [p.property.1]) p.property.1, | |
| β ENNReal.ofReal_add (by linarith [p.property.1]) (by linarith)] | |
| norm_num [show (p : β)+(p : β)+(p : β)+(1-3*(p : β)) = 1 by ring]) | |
| def labelIs (i : Fin 3) (j : Fin 4) : Bool := decide (j = i.castSucc) | |
| lemma ofReal_unitInterval (p : unitInterval) : | |
| ENNReal.ofReal (p : β) = (unitInterval.toNNReal p : ENNReal) := by | |
| unfold ENNReal.ofReal | |
| apply congrArg (fun x : NNReal => (x : ENNReal)) | |
| apply Subtype.ext | |
| exact Real.coe_toNNReal _ p.property.1 | |
| lemma labelIs_preserving (p : unitInterval) (hp : 3*(p : β) β€ 1) (i : Fin 3) : | |
| MeasurePreserving (labelIs i) (reservoirLabelPMF p hp).toMeasure | |
| (bernoulliMeasure true false p) := by | |
| have hnon : 0 β€ (p : β) := p.property.1 | |
| have hnon' : 0 β€ 1-3*(p : β) := by linarith | |
| refine β¨measurable_of_finite _, ?_β© | |
| apply Measure.ext_iff_singleton.mpr | |
| intro b | |
| rw [Measure.map_apply (measurable_of_finite _) (measurableSet_singleton _)] | |
| rw [PMF.toMeasure_apply_fintype] | |
| simp only [reservoirLabelPMF] | |
| cases b <;> fin_cases i <;> | |
| simp [labelIs, Fin.sum_univ_four, PMF.ofFintype_apply] | |
| all_goals | |
| first | |
| | exact ofReal_unitInterval p | |
| | rw [β ENNReal.ofReal_add hnon hnon, | |
| β ENNReal.ofReal_add (by linarith : 0 β€ (p : β)+(p : β)) hnon'] | |
| convert ofReal_unitInterval (unitInterval.symm p) using 1 | |
| congr 1 | |
| change (p : β)+(p : β)+(1-3*(p : β)) = 1-(p : β) | |
| ring | |
| end ErdosGallai.Sampling | |
| namespace ErdosGallai.Sampling | |
| open Finset MeasureTheory ProbabilityTheory | |
| noncomputable section | |
| variable {V : Type cycleUniverse1} [Fintype V] [DecidableEq V] | |
| def reservoirSample (i : Fin 3) (Ο : V β Fin 4) : V β Bool := fun v => labelIs i (Ο v) | |
| def reservoirMeasure (V : Type cycleUniverse2) [Fintype V] (p : unitInterval) (hp : 3*(p : β) β€ 1) : | |
| Measure (V β Fin 4) := Measure.pi (fun _ : V => (reservoirLabelPMF p hp).toMeasure) | |
| instance reservoirMeasure_probability (p : unitInterval) (hp : 3*(p : β) β€ 1) : | |
| IsProbabilityMeasure (reservoirMeasure V p hp) := by unfold reservoirMeasure; infer_instance | |
| lemma reservoirSample_preserving {V : Type cycleUniverse3} [_contextInstance1 : Fintype V] [_contextInstance2 : DecidableEq V] (p : unitInterval) (hp : 3*(p : β) β€ 1) (i : Fin 3) : | |
| MeasurePreserving (reservoirSample i) (reservoirMeasure V p hp) (sampleMeasure V p) := by | |
| exact measurePreserving_pi _ _ (fun _ => labelIs_preserving p hp i) | |
| lemma reservoirSamples_disjoint {V : Type cycleUniverse4} [_contextInstance1 : Fintype V] [_contextInstance2 : DecidableEq V] (Ο : V β Fin 4) (i j : Fin 3) (hij : i β j) : | |
| Disjoint (sampleVertices (reservoirSample i Ο)) (sampleVertices (reservoirSample j Ο)) := by | |
| apply Finset.disjoint_left.mpr | |
| intro v hi hj | |
| simp only [sampleVertices, Finset.mem_filter, Finset.mem_univ, true_and, | |
| reservoirSample, labelIs, decide_eq_true_eq] at hi hj | |
| exact hij (Fin.castSucc_injective 3 (hi.symm.trans hj)) | |
| universe u | |
| theorem three_reservoirs_uniform (c : β) (hc : 0 < c) (p : unitInterval) | |
| (hp : 0 < (p : β)) (hp3 : 3*(p : β) β€ 1) : | |
| β Dβ : β, β D : β, Dβ β€ D β β (V : Type u) [Fintype V] [DecidableEq V] | |
| (P : Fin 3 β SimpleGraph V) [β i, DecidableRel (P i).Adj], | |
| D^(9/10 : β) β€ (Fintype.card V : β) β | |
| (Fintype.card V : β) β€ D^(51/50 : β) β | |
| (β i, CutExpansion (P i) (c*D^(9/10 : β))) β | |
| β W : Fin 3 β Finset V, | |
| (β i j, i β j β Disjoint (W i) (W j)) β§ | |
| (β i, ((W i).card : β) β€ 2*(p : β)*Fintype.card V) β§ | |
| (β i v, (p : β)*(c*D^(9/10 : β))/2 β€ ((neighborsIn (P i) v (W i)).card : β)) β§ | |
| (β i, CutExpansionOn (P i) (W i) (D^(37/50 : β))) := by | |
| have hp1 : (p : β) < 1 := by linarith | |
| obtain β¨Dβ,hDββ© := vertex_sampling_uniform.{u} c hc p hp hp1 (1/4) (by norm_num) | |
| refine β¨Dβ, ?_β© | |
| intro D hD V _ _ P _ hlo hhi hcut | |
| let ΞΌ := reservoirMeasure V p hp3 | |
| let B : Fin 3 β Set (V β Fin 4) := fun i => | |
| {Ο | Β¬SampleGood (P i) (p : β) (c*D^(9/10 : β)) (D^(37/50 : β)) (reservoirSample i Ο)} | |
| have hB : β i, ΞΌ.real (B i) β€ 1/4 := by | |
| intro i | |
| have hm := (reservoirSample_preserving (V := V) p hp3 i).measure_preimage | |
| ((Set.Finite.measurableSet (Set.toFinite {Ο | Β¬SampleGood (P i) (p : β) (c*D^(9/10 : β)) | |
| (D^(37/50 : β)) Ο})).nullMeasurableSet) | |
| change (ΞΌ (B i)).toReal β€ 1/4 | |
| rw [show ΞΌ (B i) = (sampleMeasure V p) {Ο | Β¬SampleGood (P i) (p : β) | |
| (c*D^(9/10 : β)) (D^(37/50 : β)) Ο} from hm] | |
| exact hDβ D hD V (P i) hlo hhi (hcut i) | |
| have hi : β i β (Finset.univ : Finset (Fin 3)), ΞΌ.real (B i) < 1 := by | |
| calc | |
| _ β€ β i β (Finset.univ : Finset (Fin 3)), (1/4 : β) := by | |
| exact Finset.sum_le_sum (fun i _ => hB i) | |
| _ < 1 := by norm_num | |
| obtain β¨Ο,hΟβ© := exists_avoiding_finite_events (ΞΌ := ΞΌ) Finset.univ B hi | |
| have hgood : β i, SampleGood (P i) (p : β) (c*D^(9/10 : β)) (D^(37/50 : β)) | |
| (reservoirSample i Ο) := by | |
| intro i | |
| exact not_not.mp (hΟ i (Finset.mem_univ i)) | |
| refine β¨fun i => sampleVertices (reservoirSample i Ο), reservoirSamples_disjoint Ο, | |
| fun i => (hgood i).1, fun i => (hgood i).2.1, fun i => (hgood i).2.2β© | |
| end | |
| end ErdosGallai.Sampling | |
| end | |
| end | |
| end | |
| end OAI | |