Download data/lean/OAI/NumberTheory/GaussianMoat/GroupCoverage.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 20.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/GaussianMoat/GroupCoverage.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/GaussianMoat/GroupCoverage.lean
-
curl -L -o GroupCoverage.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/GaussianMoat/GroupCoverage.lean
20.3 kB
| import OAI.NumberTheory.GaussianMoat.KernelComposition | |
| namespace OAI | |
| universe uGroup uOmega uAlpha uIota uBeta uCapitalGamma | |
| namespace GaussianMoat | |
| section | |
| open scoped BigOperators Classical | |
| variable {G : Type uGroup} [Fintype G] [AddGroup G] | |
| noncomputable def overlapCount (K E : Finset G) (x : G) : β := | |
| (E.filter (fun y => x+y β K)).card | |
| lemma overlapCount_sum (K E : Finset G) : | |
| (β x : G, overlapCount K E x) = K.card*E.card := by | |
| simp only [overlapCount,Finset.card_filter] | |
| rw [Finset.sum_comm] | |
| have hh (y : G) : (β x : G, if x+y β K then (1:β) else 0) = K.card := by | |
| calc | |
| _ = β x : G, if x β K then (1:β) else 0 := | |
| Equiv.sum_comp (Equiv.addRight y) (fun x => if x β K then (1:β) else 0) | |
| _ = K.card := by simp | |
| simp only [hh,Finset.sum_const,smul_eq_mul] | |
| ring | |
| noncomputable def overlapExceptions (K E : Finset G) (Ξ΄ : β) : Finset G := | |
| Finset.univ.filter (fun x => Ξ΄*K.card < overlapCount K E x) | |
| lemma overlapExceptions_card (K E : Finset G) (hK : K.Nonempty) {Ξ΄ : β} (hΞ΄ : 0 < Ξ΄) : | |
| ((overlapExceptions K E Ξ΄).card:β) β€ E.card/Ξ΄ := by | |
| have hKp : (0:β) < K.card := by exact_mod_cast Finset.card_pos.mpr hK | |
| have hs : ((overlapExceptions K E Ξ΄).card:β)*(Ξ΄*K.card) β€ | |
| β x : G, (overlapCount K E x:β) := by | |
| have h1 : β x β overlapExceptions K E Ξ΄, Ξ΄*K.card β€ | |
| β x β overlapExceptions K E Ξ΄, (overlapCount K E x:β) := by | |
| apply Finset.sum_le_sum | |
| intro x hx | |
| exact (Finset.mem_filter.mp hx).2.le | |
| have h2 := Finset.sum_le_sum_of_subset_of_nonneg | |
| (Finset.subset_univ (overlapExceptions K E Ξ΄)) | |
| (fun x _ _ => (Nat.cast_nonneg (overlapCount K E x): (0:β)β€_)) | |
| simpa only [Finset.sum_const,nsmul_eq_mul] using h1.trans h2 | |
| have he : (β x : G, (overlapCount K E x:β)) = (K.card:β)*E.card := by | |
| exact_mod_cast overlapCount_sum K E | |
| rw [he] at hs | |
| apply (le_div_iffβ hΞ΄).mpr | |
| nlinarith only [hs,hKp] | |
| lemma coverage_hit_lower (q : FinLaw G) (K E : Finset G) {Ο Ξ΄ : β} | |
| (hΟ : 0 β€ Ο) (hΟ1 : Ο β€ 3/8) (hΞ΄ : 0 < Ξ΄) (hΞ΄1 : Ξ΄ β€ 1/64) | |
| (hq : β y β E, (Ο+4*Ξ΄)/(Fintype.card G:β) β€ q y) | |
| {x : G} (hx : x β overlapExceptions K E Ξ΄) : | |
| (Ο+2*Ξ΄)*(K.card:β)/(Fintype.card G:β) β€ q.prob (fun y => x+y β K) := by | |
| have hne := q.nonempty | |
| have hp : (0:β) < Fintype.card G := by exact_mod_cast Fintype.card_pos | |
| have hoc : (overlapCount K E x:β) β€ Ξ΄*K.card := by | |
| simpa only [overlapExceptions,Finset.mem_filter,Finset.mem_univ,true_and,not_lt] using hx | |
| let S := Finset.univ.filter (fun y : G => x+y β K β§ y β E) | |
| have hcount : (S.card:β)+(overlapCount K E x:β) = K.card := by | |
| have ht : S.card+overlapCount K E x=K.card := by | |
| have hbase : (Finset.univ.filter (fun y : G => x+y β K)).card = K.card := by | |
| simp only [Finset.card_filter] | |
| calc | |
| _ = β y : G, if y β K then (1:β) else 0 := | |
| Equiv.sum_comp (Equiv.addLeft x) (fun y => if y β K then (1:β) else 0) | |
| _ = K.card := by simp | |
| have hsplit := Finset.card_filter_add_card_filter_not | |
| (s := Finset.univ.filter (fun y : G => x+y β K)) (p := fun y => y β E) | |
| have hE : ((Finset.univ.filter (fun y : G => x+y β K)).filter (fun y => y β E)).card = | |
| overlapCount K E x := by | |
| unfold overlapCount | |
| congr 1 | |
| ext y | |
| simp only [Finset.mem_filter,Finset.mem_univ,true_and] | |
| tauto | |
| have hS : (Finset.univ.filter (fun y : G => x+y β K)).filter (fun y => y β E) = S := by | |
| ext y | |
| simp [S] | |
| rw [hE,hS,hbase] at hsplit | |
| omega | |
| exact_mod_cast ht | |
| have h1 : (S.card:β)*((Ο+4*Ξ΄)/(Fintype.card G:β)) β€ β y β S, q y := by | |
| simpa only [Finset.sum_const,nsmul_eq_mul] using Finset.sum_le_sum (s := S) | |
| (fun y hy => hq y (Finset.mem_filter.mp hy).2.2) | |
| have h2 : (β y β S, q y) β€ q.prob (fun y => x+y β K) := by | |
| have he : q.prob (fun y => x+y β K) = | |
| β y β Finset.univ.filter (fun y : G => x+y β K), q y := by | |
| simp only [FinLaw.prob,Finset.sum_filter] | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| by_cases hy : x+y β K <;> simp only [hy,ite_true,ite_false] | |
| rw [he] | |
| apply Finset.sum_le_sum_of_subset_of_nonneg | |
| Β· intro y hy | |
| exact Finset.mem_filter.mpr β¨Finset.mem_univ y,(Finset.mem_filter.mp hy).2.1β© | |
| Β· intro y _ _ | |
| exact q.nonneg y | |
| have h3 : (Ο+2*Ξ΄)*K.card β€ S.card*(Ο+4*Ξ΄) := by | |
| have hc : (0:β) β€ K.card := Nat.cast_nonneg _ | |
| have hd : Ο+2*Ξ΄ β€ (1-Ξ΄)*(Ο+4*Ξ΄) := by nlinarith only [hΟ1,hΞ΄1,hΞ΄] | |
| have hm := mul_le_mul_of_nonneg_right hd hc | |
| have hs : (1-Ξ΄)*(K.card:β) β€ S.card := by linarith only [hcount,hoc] | |
| have ht := mul_le_mul_of_nonneg_right hs (by positivity : (0:β) β€ Ο+4*Ξ΄) | |
| nlinarith only [hm,ht] | |
| calc | |
| _ β€ (S.card:β)*((Ο+4*Ξ΄)/(Fintype.card G:β)) := by | |
| simpa only [mul_div_assoc] using (div_le_div_iff_of_pos_right hp).mpr h3 | |
| _ β€ _ := h1.trans h2 | |
| noncomputable def coverageList (K : Finset G) (n : β) (Ο Ξ΄ : β) (h : Fin n β G) : Finset G := | |
| Finset.univ.filter (fun x => | |
| (β i : Fin n, if x+h i β K then (1:β) else 0) β€ | |
| n*(Ο+Ξ΄)*K.card/(Fintype.card G:β)) | |
| theorem coverageList_tail (q : FinLaw G) (K E : Finset G) (hK : K.Nonempty) | |
| {Ο Ξ΄ : β} (hΟ : 0 β€ Ο) (hΟ1 : Ο β€ 3/8) (hΞ΄ : 0 < Ξ΄) (hΞ΄1 : Ξ΄ β€ 1/64) | |
| (hq : β y β E, (Ο+4*Ξ΄)/(Fintype.card G:β) β€ q y) (n : β) : | |
| (q.iid n).prob (fun h => Β¬ coverageList K n Ο Ξ΄ h β overlapExceptions K E Ξ΄) β€ | |
| (Fintype.card G:β)*Real.exp (-(n:β)*Ξ΄^2*K.card/(2*(Fintype.card G:β))) := by | |
| have hne := q.nonempty | |
| have hp : (0:β) < Fintype.card G := by exact_mod_cast Fintype.card_pos | |
| have hKp : (0:β) < K.card := by exact_mod_cast Finset.card_pos.mpr hK | |
| let ΞΌ := (Ο+2*Ξ΄)*(K.card:β)/(Fintype.card G:β) | |
| let d := Ξ΄*(K.card:β)/(Fintype.card G:β) | |
| have hΞΌ : 0 < ΞΌ := by dsimp [ΞΌ]; positivity | |
| have hd : 0 β€ d := by dsimp [d]; positivity | |
| have hx (x : G) : (q.iid n).prob (fun h => x β coverageList K n Ο Ξ΄ h β§ | |
| x β overlapExceptions K E Ξ΄) β€ | |
| Real.exp (-(n:β)*Ξ΄^2*K.card/(2*(Fintype.card G:β))) := by | |
| by_cases he : x β overlapExceptions K E Ξ΄ | |
| Β· simp only [he,not_true_eq_false,and_false,FinLaw.prob,ite_false,Finset.sum_const_zero] | |
| exact (Real.exp_pos _).le | |
| Β· have hh := q.iid_lower_tail (fun y => x+y β K) n hΞΌ hd | |
| (coverage_hit_lower q K E hΟ hΟ1 hΞ΄ hΞ΄1 hq he) | |
| have hth : (n:β)*(ΞΌ-d) = (n:β)*(Ο+Ξ΄)*K.card/(Fintype.card G:β) := by | |
| dsimp [ΞΌ,d] | |
| ring | |
| rw [hth] at hh | |
| have hm : (q.iid n).prob (fun h => x β coverageList K n Ο Ξ΄ h β§ | |
| x β overlapExceptions K E Ξ΄) β€ | |
| (q.iid n).prob (fun h => | |
| (β i : Fin n, if x+h i β K then (1:β) else 0) β€ | |
| n*(Ο+Ξ΄)*K.card/(Fintype.card G:β)) := by | |
| apply FinLaw.prob_mono | |
| intro h hh | |
| exact (Finset.mem_filter.mp hh.1).2 | |
| apply (hm.trans (by | |
| convert! hh using 1 | |
| congr 1 | |
| funext v | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| by_cases hi : x+v i β K <;> simp only [hi,ite_true,ite_false])).trans | |
| apply Real.exp_le_exp.mpr | |
| have heq : d^2/ΞΌ = Ξ΄^2*(K.card:β)/((Ο+2*Ξ΄)*(Fintype.card G:β)) := by | |
| dsimp [d,ΞΌ] | |
| field_simp | |
| have ht : 0 < Ο+2*Ξ΄ := by positivity | |
| have ht1 : Ο+2*Ξ΄ β€ 1 := by linarith only [hΟ1,hΞ΄1] | |
| have hratio : Ξ΄^2*(K.card:β)/(Fintype.card G:β) β€ d^2/ΞΌ := by | |
| rw [heq] | |
| apply div_le_div_of_nonneg_left (by positivity) (mul_pos ht hp) | |
| exact mul_le_of_le_one_left hp.le ht1 | |
| have hmul := mul_le_mul_of_nonneg_left hratio (show (0:β) β€ n/2 by positivity) | |
| calc | |
| _ = -((n:β)/2*(d^2/ΞΌ)) := by simp only [div_eq_mul_inv,mul_inv_rev]; ring | |
| _ β€ -((n:β)/2*(Ξ΄^2*(K.card:β)/(Fintype.card G:β))) := neg_le_neg hmul | |
| _ = _ := by ring | |
| have hu := (q.iid n).prob_exists_le_sum (fun x h => x β coverageList K n Ο Ξ΄ h β§ | |
| x β overlapExceptions K E Ξ΄) | |
| have hm : (q.iid n).prob (fun h => Β¬ coverageList K n Ο Ξ΄ h β overlapExceptions K E Ξ΄) β€ | |
| (q.iid n).prob (fun h => β x, x β coverageList K n Ο Ξ΄ h β§ x β overlapExceptions K E Ξ΄) := by | |
| apply FinLaw.prob_mono | |
| intro h hh | |
| by_contra hn | |
| apply hh | |
| intro x hx | |
| by_contra he | |
| exact hn β¨x,hx,heβ© | |
| apply (hm.trans hu).trans | |
| simpa only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] using | |
| Finset.sum_le_sum (s := Finset.univ) (fun x _ => hx x) | |
| end | |
| namespace FinLaw | |
| section | |
| open scoped BigOperators Classical | |
| variable {Ξ© : Type uOmega} {Ξ± : Type uAlpha} [Fintype Ξ©] [Fintype Ξ±] | |
| lemma prod_ite_forall {ΞΉ : Type uIota} [Fintype ΞΉ] (P : ΞΉ β Prop) (f : ΞΉ β β) : | |
| (β i, if P i then f i else 0) = if β i, P i then β i, f i else 0 := by | |
| by_cases h : β i, P i | |
| Β· simp [h] | |
| Β· rw [ite_eq_right h] | |
| push Not at h | |
| obtain β¨i,hiβ© := h | |
| exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) | |
| lemma iid_map (p : FinLaw Ξ©) (f : Ξ© β Ξ±) (n : β) : | |
| (p.iid n).map (fun x i => f (x i)) = (p.map f).iid n := by | |
| ext y | |
| simp only [map_mass,iid_mass] | |
| rw [Fintype.prod_sum] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| rw [prod_ite_forall] | |
| congr 1 | |
| exact propext funext_iff | |
| lemma iid_prob_forall (p : FinLaw Ξ©) (E : Ξ© β Prop) (n : β) : | |
| (p.iid n).prob (fun x => β i, E (x i)) = (p.prob E)^n := by | |
| simp only [prob,iid_mass] | |
| calc | |
| _ = β x : Fin n β Ξ©, β i, if E (x i) then p (x i) else 0 := by | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| have h := prod_ite_forall (fun i => E (x i)) (fun i => p (x i)) | |
| by_cases hh : β i, E (x i) <;> simpa only [hh,ite_true,ite_false] using h.symm | |
| _ = _ := by | |
| rw [β Fintype.prod_sum (fun (_ : Fin n) (Ο : Ξ©) => if E Ο then p Ο else (0:β))] | |
| simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin] | |
| lemma iid_prob_implies (p : FinLaw Ξ©) (E F : Ξ© β Prop) (n : β) | |
| (h : β x, E x β Β¬ F x) : | |
| (p.iid n).prob (fun x => β i, E (x i)) β€ (1-p.prob F)^n := by | |
| rw [β p.prob_compl F,β p.iid_prob_forall] | |
| exact (p.iid n).prob_mono (fun x hx i => h _ (hx i)) | |
| lemma iid_survival_exp (p : FinLaw Ξ©) (E : Ξ© β Prop) (n : β) {c : β} | |
| (hp : c β€ 1-p.prob E) : | |
| (p.iid n).prob (fun x => β i, E (x i)) β€ Real.exp (-(n:β)*c) := by | |
| have hbase : p.prob E β€ Real.exp (-c) := by | |
| have h := Real.add_one_le_exp (-c) | |
| linarith only [hp,h] | |
| rw [iid_prob_forall] | |
| calc | |
| _ β€ (Real.exp (-c))^n := pow_le_pow_leftβ (p.prob_nonneg E) hbase n | |
| _ = _ := by rw [β Real.exp_nat_mul]; congr 1; ring | |
| lemma expect_map (p : FinLaw Ξ©) (f : Ξ© β Ξ±) (g : Ξ± β β) : | |
| (β a, p.map f a*g a) = β Ο, p Ο*g (f Ο) := by | |
| simp only [map_mass,Finset.sum_mul] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| simp only [ite_mul,zero_mul] | |
| simp | |
| lemma joint_expect_snd (p : FinLaw Ξ©) (q : Ξ© β FinLaw Ξ±) (f : Ξ© β Ξ± β β) : | |
| (β v, p.joint q v*f v.1 v.2) = β Ο, p Ο*(β a, q Ο a*f Ο a) := by | |
| simp only [Fintype.sum_prod_type,joint_mass,Finset.mul_sum,mul_assoc] | |
| lemma prob_map_true (p : FinLaw Ξ©) (E : Ξ© β Prop) : | |
| p.map (fun Ο => decide (E Ο)) true = p.prob E := by | |
| simp only [map_mass,decide_eq_true_eq,prob] | |
| lemma prob_le_of_expect (p : FinLaw Ξ©) (f : Ξ© β β) | |
| (hf : β Ο, 0 β€ f Ο) {c t : β} (ht : 0 < t) | |
| (hc : (β Ο, p Ο*f Ο) β€ c) : | |
| 1-c/t β€ p.prob (fun Ο => f Ο β€ t) := by | |
| have h := (p.prob_le_expect_div f hf ht).trans ((div_le_div_iff_of_pos_right ht).mpr hc) | |
| have he := p.prob_compl (fun Ο => f Ο β€ t) | |
| simp only [not_le] at he | |
| linarith only [h,he] | |
| end | |
| open scoped BigOperators Classical | |
| variable {Ξ© : Type uOmega} {Ξ± : Type uAlpha} {Ξ² : Type uBeta} [Fintype Ξ©] [Fintype Ξ±] [Fintype Ξ²] | |
| lemma H_sub_H_of_agree (p : FinLaw Ξ©) (X Y : Ξ© β Ξ±) (E : Ξ© β Bool) | |
| (hE : β Ο, p Ο β 0 β E Ο = true β X Ο=Y Ο) : | |
| p.H X-p.H Y β€ Real.binEntropy (p.map E true)+ | |
| (1-p.map E true)*Real.log (Fintype.card Ξ±) := by | |
| have h := p.short_list X Y (fun y => {y}) E (b := 1) le_rfl (by | |
| intro Ο hp he | |
| simp only [Finset.mem_singleton,Finset.card_singleton,Nat.cast_one,le_refl,and_true] | |
| exact hE Ο hp he) | |
| rw [Real.log_one,mul_zero,add_zero] at h | |
| have hc := p.H_le_condH_add X Y | |
| linarith only [h,hc] | |
| lemma condH_sub_condH_of_agree (p : FinLaw Ξ©) (X X' : Ξ© β Ξ±) (O O' : Ξ© β Ξ²) | |
| (E : Ξ© β Bool) (hE : β Ο, p Ο β 0 β E Ο=true β X Ο=X' Ο β§ O Ο=O' Ο) : | |
| p.condH X O-p.condH X' O' β€ 2*Real.binEntropy (p.map E true)+ | |
| (1-p.map E true)*(Real.log (Fintype.card Ξ±)+2*Real.log (Fintype.card Ξ²)) := by | |
| have h1 := p.H_sub_H_of_agree (fun Ο => (X Ο,O Ο)) (fun Ο => (X' Ο,O' Ο)) E | |
| (fun Ο hp he => Prod.ext (hE Ο hp he).1 (hE Ο hp he).2) | |
| have h2 := p.H_sub_H_of_agree O' O E (fun Ο hp he => (hE Ο hp he).2.symm) | |
| have hn := p.nonempty | |
| have ha : Nonempty Ξ± := β¨X (Classical.arbitrary Ξ©)β© | |
| have hb : Nonempty Ξ² := β¨O (Classical.arbitrary Ξ©)β© | |
| have hca : (Fintype.card Ξ±:β) β 0 := by exact_mod_cast Fintype.card_ne_zero | |
| have hcb : (Fintype.card Ξ²:β) β 0 := by exact_mod_cast Fintype.card_ne_zero | |
| rw [Fintype.card_prod,Nat.cast_mul,Real.log_mul hca hcb] at h1 | |
| unfold condH | |
| linarith only [h1,h2] | |
| lemma binEntropy_le_log_inverse {a : β} (ha : 0 < a) (ha1 : a β€ 1) : | |
| Real.binEntropy a β€ a*(1-Real.log a) := by | |
| have h : Real.negMulLog (1-a) β€ a := by | |
| by_cases hz : 1-a=0 | |
| Β· simp only [hz,Real.negMulLog_zero] | |
| exact ha.le | |
| Β· have hp : 0 < 1-a := lt_of_le_of_ne (by linarith) (Ne.symm hz) | |
| have hh := Real.log_le_sub_one_of_pos (inv_pos.mpr hp) | |
| rw [Real.log_inv] at hh | |
| have hm := mul_le_mul_of_nonneg_left hh hp.le | |
| rw [mul_sub,mul_inv_cancelβ hz,mul_one] at hm | |
| unfold Real.negMulLog | |
| nlinarith only [hm] | |
| rw [Real.binEntropy_eq_negMulLog_add_negMulLog_one_sub] | |
| dsimp only [Real.negMulLog] at h β’ | |
| nlinarith only [h] | |
| lemma binEntropy_sum_le {ΞΉ : Type uIota} [Fintype ΞΉ] (w : FinLaw ΞΉ) (a : ΞΉ β β) | |
| (ha : β i, a i β Set.Icc (0:β) 1) : | |
| (β i, w i*Real.binEntropy (a i)) β€ Real.binEntropy (β i, w i*a i) := by | |
| exact Real.strictConcave_binEntropy.concaveOn.le_map_sum (fun i _ => w.nonneg i) w.sum_one (fun i _ => ha i) | |
| end FinLaw | |
| open scoped BigOperators Classical | |
| namespace FinLaw | |
| variable {Ξ© : Type uOmega} {Ξ : Type uCapitalGamma} {G : Type uGroup} [Fintype Ξ©] [Fintype Ξ] [Fintype G] [AddCommGroup G] | |
| omit [AddCommGroup G] in | |
| lemma prob_mem_finset (p : FinLaw G) (K : Finset G) : | |
| p.prob (fun x => x β K) = β x β K, p x := by | |
| unfold prob | |
| calc | |
| _ = β x β K, if x β K then p x else 0 := by | |
| symm | |
| convert! Finset.sum_subset (Finset.subset_univ K) | |
| (f := fun x => if x β K then p x else (0:β)) | |
| (fun x _ hx => ite_eq_right hx) using 1 | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| by_cases hx : xβK <;> simp only [hx,ite_true,ite_false] | |
| _ = _ := Finset.sum_congr rfl (fun x hx => ite_eq_left hx) | |
| lemma joint_prob_le_bad_add (p : FinLaw Ξ©) (q : Ξ© β FinLaw Ξ) | |
| (Bad : Ξ© β Prop) (E : Ξ© Γ Ξ β Prop) {Ξ΅ : β} (hΞ΅ : 0 β€ Ξ΅) | |
| (hg : β Ο, Β¬ Bad Ο β (q Ο).prob (fun a => E (Ο,a)) β€ Ξ΅) : | |
| (p.joint q).prob E β€ p.prob Bad+Ξ΅ := by | |
| rw [prob_joint] | |
| have h (Ο : Ξ©) : (q Ο).prob (fun a => E (Ο,a)) β€ (if Bad Ο then 1 else 0)+Ξ΅ := by | |
| by_cases hb : Bad Ο | |
| Β· simpa only [hb,ite_true] using (q Ο).prob_le_one (fun a => E (Ο,a)) |>.trans (by linarith only [hΞ΅]) | |
| Β· simpa only [hb,ite_false,zero_add] using hg Ο hb | |
| have hh := Finset.sum_le_sum (s := Finset.univ) (fun Ο _ => | |
| mul_le_mul_of_nonneg_left (h Ο) (p.nonneg Ο)) | |
| convert! hh using 1 | |
| simp only [mul_add,Finset.sum_add_distrib,β Finset.sum_mul,p.sum_one,one_mul,prob] | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| split_ifs <;> simp | |
| omit [Fintype G] in | |
| lemma iid_true_hit_expect (p : FinLaw Ξ©) (q : Ξ© β FinLaw Ξ) | |
| (Y : Ξ© β G) (h : Ξ β G) (K : Finset G) (n : β) : | |
| (β v, p.joint (fun Ο => (q Ο).iid n) v * | |
| (β i : Fin n, if Y v.1+h (v.2 i) β K then (1:β) else 0)) = | |
| n*(p.joint q).prob (fun v => Y v.1+h v.2 β K) := by | |
| rw [joint_expect_snd p (fun Ο => (q Ο).iid n) | |
| (fun Ο v => β i : Fin n, if Y Ο+h (v i) β K then (1:β) else 0)] | |
| have he (i : Fin n) (Ο : Ξ©) : | |
| (β v, (q Ο).iid n v*(if Y Ο+h (v i) β K then (1:β) else 0)) = | |
| (q Ο).prob (fun a => Y Ο+h a β K) := by | |
| rw [β expect_map ((q Ο).iid n) (fun v => v i) (fun a => if Y Ο+h a β K then (1:β) else 0), | |
| iid_map_eval] | |
| unfold prob | |
| apply Finset.sum_congr rfl | |
| intro a _ | |
| split_ifs <;> simp | |
| have hh (Ο : Ξ©) : | |
| (β v, (q Ο).iid n v*(β i : Fin n, if Y Ο+h (v i) β K then (1:β) else 0)) = | |
| n*(q Ο).prob (fun a => Y Ο+h a β K) := by | |
| simp only [Finset.mul_sum] | |
| rw [Finset.sum_comm] | |
| simp only [he,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] | |
| simp only [hh,mul_left_comm (p _) (n:β)] | |
| rw [β Finset.mul_sum,prob_joint p q (fun v => Y v.1+h v.2βK)] | |
| lemma true_coverageList_probability (p : FinLaw Ξ©) (q : Ξ© β FinLaw Ξ) | |
| (Y : Ξ© β G) (h : Ξ β G) (K : Finset G) (hK : K.Nonempty) | |
| {Ο Ξ΄ : β} (hΟ : 0 β€ Ο) (hΞ΄ : 0 < Ξ΄) {n : β} (hn : 0 < n) | |
| (hp : (p.joint q).prob (fun v => Y v.1+h v.2 β K) β€ | |
| Ο*K.card/(Fintype.card G:β)) : | |
| Ξ΄/(Ο+Ξ΄) β€ (p.joint (fun Ο => (q Ο).iid n)).prob | |
| (fun v => Y v.1 β coverageList K n Ο Ξ΄ (fun i => h (v.2 i))) := by | |
| have hG : Nonempty G := β¨Y (Classical.choice p.nonempty)β© | |
| have hcard : (0:β) < Fintype.card G := by exact_mod_cast Fintype.card_pos | |
| have hkc : (0:β) < K.card := by exact_mod_cast Finset.card_pos.mpr hK | |
| have hnc : (0:β) < n := by exact_mod_cast hn | |
| have htd : 0 < Ο+Ξ΄ := by linarith | |
| have hb : (β v, p.joint (fun Ο => (q Ο).iid n) v * | |
| (β i : Fin n, if Y v.1+h (v.2 i) β K then (1:β) else 0)) β€ | |
| n*(Ο*K.card/(Fintype.card G:β)) := by | |
| rw [iid_true_hit_expect] | |
| exact mul_le_mul_of_nonneg_left hp hnc.le | |
| have hh := (p.joint (fun Ο => (q Ο).iid n)).prob_le_of_expect | |
| (fun v => β i : Fin n, if Y v.1+h (v.2 i) β K then (1:β) else 0) | |
| (fun _ => Finset.sum_nonneg (fun _ _ => by split_ifs <;> norm_num)) | |
| (t := n*(Ο+Ξ΄)*K.card/(Fintype.card G:β)) (by positivity) hb | |
| have he : 1-(n*(Ο*K.card/(Fintype.card G:β)))/(n*(Ο+Ξ΄)*K.card/(Fintype.card G:β)) = | |
| Ξ΄/(Ο+Ξ΄) := by field_simp; ring | |
| rw [he] at hh | |
| simpa only [coverageList,Finset.mem_filter,Finset.mem_univ,true_and] using hh | |
| lemma coverageList_size_probability (p : FinLaw Ξ©) (q : Ξ© β FinLaw Ξ) | |
| (h : Ξ β G) (K : Finset G) (hK : K.Nonempty) (E : Ξ© β Finset G) | |
| (Bad : Ξ© β Prop) {Ο Ξ΄ Ξ΅ b : β} | |
| (hΟ : 0 β€ Ο) (hΟ1 : Ο β€ 3/8) (hΞ΄ : 0 < Ξ΄) (hΞ΄1 : Ξ΄ β€ 1/64) | |
| (hΞ΅ : 0 β€ Ξ΅) (n : β) | |
| (hq : β Ο, Β¬ Bad Ο β β y β E Ο, | |
| (Ο+4*Ξ΄)/(Fintype.card G:β) β€ (q Ο).map h y) | |
| (hE : β Ο, Β¬ Bad Ο β ((E Ο).card:β)/Ξ΄ β€ b) | |
| (herr : (Fintype.card G:β)*Real.exp (-(n:β)*Ξ΄^2*K.card/(2*(Fintype.card G:β))) β€ Ξ΅) : | |
| (p.joint (fun Ο => (q Ο).iid n)).prob (fun v => | |
| b < ((coverageList K n Ο Ξ΄ (fun i => h (v.2 i))).card:β)) β€ p.prob Bad+Ξ΅ := by | |
| apply joint_prob_le_bad_add p _ Bad _ hΞ΅ | |
| intro Ο hg | |
| have ha := (coverageList_tail ((q Ο).map h) K (E Ο) hK hΟ hΟ1 hΞ΄ hΞ΄1 (hq Ο hg) n).trans herr | |
| rw [β iid_map,prob_map] at ha | |
| apply (prob_mono _ ?_).trans ha | |
| intro x hx hs | |
| have hc := Finset.card_le_card hs | |
| have hcR : ((coverageList K n Ο Ξ΄ (fun i => h (x i))).card:β) β€ | |
| ((overlapExceptions K (E Ο) Ξ΄).card:β) := by exact_mod_cast hc | |
| have hb := (overlapExceptions_card K (E Ο) hK hΞ΄).trans (hE Ο hg) | |
| linarith only [hx,hcR,hb] | |
| end FinLaw | |
| end GaussianMoat | |
| end OAI | |