have hne := q.nonempty
havehp : (0:ℝ) < Fintype.card G:=by exact_mod_cast Fintype.card_pos
havehKp : (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:ℝ)
havehμ : 0 < μ :=by dsimp [μ]; positivity
havehd : 0≤ d :=by dsimp [d]; positivity
have hx (x : G) : (q.iid n).prob (fun h => x ∈ coverageList K n τ δ h ∧
x ∉ overlapExceptions KE δ) ≤Real.exp (-(n:ℝ)*δ^2*K.card/(2*(Fintype.card G:ℝ))) :=byby_cases he : x ∈ overlapExceptions KE δ
· 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 KE hτ hτ1 hδ hδ1 hq he)
havehth : (n:ℝ)*(μ-d) = (n:ℝ)*(τ+δ)*K.card/(Fintype.card G:ℝ) :=by
dsimp [μ,d]
ring
rw [hth] at hh
havehm : (q.iid n).prob (fun h => x ∈ coverageList K n τ δ h ∧
x ∉ overlapExceptions KE δ) ≤
(q.iid n).prob (fun h =>
(∑i : Fin n, if x+h i ∈Kthen (1:ℝ) else0) ≤
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 using1
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
haveheq : d^2/μ = δ^2*(K.card:ℝ)/((τ+2*δ)*(Fintype.card G:ℝ)) :=by
dsimp [d,μ]
field_simp
haveht : 0 < τ+2*δ :=by positivity
haveht1 : τ+2*δ ≤1:=by linarith only [hτ1,hδ1]
havehratio : δ^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/2by 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 KE δ)
havehm : (q.iid n).prob (fun h =>¬ coverageList K n τ δ h ⊆ overlapExceptions KE δ) ≤
(q.iid n).prob (fun h =>∃ x, x ∈ coverageList K n τ δ h ∧ x ∉ overlapExceptions KE δ) :=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] usingFinset.sum_le_sum (s :=Finset.univ) (fun x _ => hx x)
lemmaprod_ite_forall {ι : Type uIota} [Fintype ι] (P : ι →Prop) (f : ι →ℝ) :
(∏ i, ifP i then f i else0) = if∀ i, P i then∏ i, f i else0:=by
proof · 6
lines
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)
lemmaiid_prob_forall (p : FinLaw Ω) (E : Ω →Prop) (n : ℕ) :
(p.iid n).prob (fun x =>∀ i, E (x i)) = (p.prob E)^n :=by
proof · 10
lines
simp only [prob,iid_mass]
calc
_ = ∑x : Fin n → Ω, ∏ i, ifE (x i) then p (x i) else0:=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) (ω : Ω) =>ifE ω then p ω else (0:ℝ))]
simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin]
lemmaprob_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
proof · 4
lines
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]
have h := p.short_list XY (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_addXY
linarith only [h,hc]
lemmabinEntropy_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
proof · 1
line
exact Real.strictConcave_binEntropy.concaveOn.le_map_sum (fun i _ => w.nonneg i) w.sum_one (fun i _ => ha i)
lemmaprob_mem_finset (p : FinLawG) (K : FinsetG) :
p.prob (fun x => x ∈K) = ∑ x ∈K, p x :=by
proof · 11
lines
unfold prob
calc
_ = ∑ x ∈K, if x ∈Kthen p x else0:=by
symm
convert! Finset.sum_subset (Finset.subset_univ K)
(f :=fun x =>if x ∈Kthen p x else (0:ℝ))
(fun x _ hx => ite_eq_right hx) using1
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)
rw [joint_expect_snd p (fun ω => (q ω).iid n)
(fun ω v =>∑i : Fin n, ifY ω+h (v i) ∈Kthen (1:ℝ) else0)]
have he (i : Fin n) (ω : Ω) :
(∑ v, (q ω).iid n v*(ifY ω+h (v i) ∈Kthen (1:ℝ) else0)) =
(q ω).prob (fun a =>Y ω+h a ∈K) :=by
rw [← expect_map ((q ω).iid n) (fun v => v i) (fun a =>ifY ω+h a ∈Kthen (1:ℝ) else0),
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, ifY ω+h (v i) ∈Kthen (1:ℝ) else0)) =
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)]
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
havehcR : ((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]