have h := (p.map C).prob_le_expect_div (fun a => (p.conditionOn C a).prob Bad)
(fun a => (p.conditionOn C a).prob_nonneg _) (bynorm_num : (0:ℝ)<1/2)
rw [p.conditionOn_prob] at h
linarith only [h]
let u :=fun x => p.prob (fun ω =>Good ω ∧ x∉E ω)
let f :=fun x => p.prob (fun ω =>Good ω ∧ x∈E ω)
letK:=Finset.univ.filter (funx : G=> u x<1/4)
havehsum : (∑x : G, f x) ≤ e :=by
simp only [f,prob]
rw [Finset.sum_comm]
have hh (ω : Ω) : (∑x : G, ifGood ω ∧ x∈E ω then p ω else0) ≤ p ω*e :=byby_cases hg : Good ω
· havehc : (∑x : G, ifGood ω ∧ x∈E ω then p ω else0) = p ω*(E ω).card :=by
simp only [hg,true_and]
calc
_ = ∑x : G, p ω*(if x∈E ω then (1:ℝ) else0) :=by
apply Finset.sum_congr rfl
intro x _
split_ifs <;> simp
_ = _ :=by rw [←Finset.mul_sum]; simp
rw [hc]
exact mul_le_mul_of_nonneg_left (hE ω hg) (p.nonneg ω)
· simp only [hg,false_and,ite_false,Finset.sum_const_zero]
exact mul_nonneg (p.nonneg ω) he
have ht :=Finset.sum_le_sum (s :=Finset.univ) (fun ω _ => hh ω)
simp only [←Finset.sum_mul,p.sum_one,one_mul] at ht
convert ht using1
apply Finset.sum_congr rfl
intro ω _
apply Finset.sum_congr rfl
intro x _
split_ifs <;> rfl
have hk (x : G) (hx : x∈K) : (1/4:ℝ)≤f x :=byhave h := p.prob_and_split Good (fun ω => x∈E ω)
havehu : u x<1/4:= (Finset.mem_filter.mp hx).2
change f x+u x=p.prob Good at h
linarith only [hu,h,hG]
havehl : (K.card:ℝ)/4≤∑ x∈K, f x :=byhave h :=Finset.sum_le_sum (s :=K) (fun x hx => hk x hx)
simpa only [Finset.sum_const,nsmul_eq_mul,div_eq_mul_inv,one_mul] using h
havehr : (∑ x∈K, f x) ≤∑x:G, f x :=Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ K)
(fun x _ _ => p.prob_nonneg _)
change (K.card:ℝ)≤4*e
linarith only [hl,hr,hsum]
lemmaprob_exists_eq_sum_disjoint {ι : Type uIota} [Fintype ι]
(p : FinLaw Ω) (E : ι → Ω →Prop)
(h : ∀ ω i j, E i ω →E j ω → i=j) :
p.prob (fun ω =>∃ i, E i ω) = ∑ i, p.prob (E i) :=by
proof · 16
lines
simp only [prob]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro ω _
by_cases he : ∃ i, E i ω
· obtain ⟨i,hi⟩ := he
rw [ite_eq_left ⟨i,hi⟩,Finset.sum_eq_single i]
· simp [hi]
· intro j _ hji
exact ite_eq_right (fun hj => hji (h ω j i hj hi))
· simp
· simp only [ite_eq_right he]
symm
apply Finset.sum_eq_zero
intro i _
exact ite_eq_right (fun hi => he ⟨i,hi⟩)
unfold cHf
rw [Hf_pair_comm,Hf_joint_pair_vary]
have h := (p.joint q).Hf_mapProd.fst id
rw [joint_map_fst,Hf_id] at h
change p.entropy = (p.joint q).HfProd.fst at h
rw [← h]
ring
lemmajoint_iid_eval (p : FinLaw ι) (q : ι →FinLaw Ω) (n : ℕ) (i : Fin n) :
(p.joint (fun a => (q a).iid n)).map (fun v => (v.1,v.2 i)) = p.joint q :=by
proof · 4
lines
calc
_ = p.joint (fun a => ((q a).iid n).map (funx : Fin n → Ω => x i)) :=
joint_map_second p (fun a => (q a).iid n) (funx : Fin n → Ω => x i)
_ = _ :=by simp only [iid_map_eval]
lemmaexpect_card_passingList (q : FinLaw Γ) (hit : Γ →G→Prop)
(E : FinsetG) {c : ℝ} (hhit : ∀ x ∉E, c≤q.prob (fun v => hit v x)) (n : ℕ) :
(∑ v, q.iid n v*((passingList hit n v).card:ℝ)) ≤
(E.card:ℝ)+(Fintype.card G:ℝ)*Real.exp (-(n:ℝ)*c) :=by
proof · 27
lines
have hprob (x : G) (hx : x ∉E) :
(q.iid n).prob (fun v => x∈passingList hit n v) ≤Real.exp (-(n:ℝ)*c) :=byhave hh := q.iid_survival_exp (fun v =>¬hit v x) n (c := c) (by
rw [q.prob_compl]; linarith only [hhit x hx])
simpa only [passingList,Finset.mem_filter,Finset.mem_univ,true_and] using hh
havehe : (∑ v, q.iid n v*((passingList hit n v).card:ℝ)) =
∑x : G, (q.iid n).prob (fun v => x∈passingList hit n v) :=byhave hc (v : Fin n → Γ) : ((passingList hit n v).card:ℝ) =
∑x : G, if x∈passingList hit n v then (1:ℝ) else0:=by simp
simp only [hc,Finset.mul_sum,prob]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro x _
apply Finset.sum_congr rfl
intro v _
by_cases hx : x∈passingList hit n v <;> simp only [hx,ite_true,ite_false,mul_one,mul_zero]
rw [he]
have hh (x : G) : (q.iid n).prob (fun v => x∈passingList hit n v) ≤
(if x∈Ethen (1:ℝ) else0)+Real.exp (-(n:ℝ)*c) :=byby_cases hx : x∈E
· simp only [hx,ite_true]
exact ((q.iid n).prob_le_one _).trans (le_add_of_nonneg_right (Real.exp_nonneg _))
· simp only [hx,ite_false,zero_add]
exact hprob x hx
have hs :=Finset.sum_le_sum (s :=Finset.univ) (fun x _ => hh x)
simpa only [Finset.sum_add_distrib,Finset.sum_boole,Finset.filter_mem_eq_inter,
Finset.univ_inter,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] using hs
lemmapassingList_true (q : FinLaw Γ) (hit : Γ →G→Prop) (x : G)
(h : ∀ v, q v≠0→¬hit v x) (n : ℕ) :
∀ v, q.iid n v≠0→ x∈passingList hit n v :=by
proof · 8
lines
intro v hv
simp only [passingList,Finset.mem_filter,Finset.mem_univ,true_and]
intro i
apply h
intro hz
apply hv
change (∏j : Fin n, q (v j)) = 0
exact Finset.prod_eq_zero (Finset.mem_univ i) hz
lemmaexpect_log_le_log_expect (p : FinLaw Ω) (f : Ω →ℝ)
(hf : ∀ ω, p ω≠0→0<f ω) :
(∑ ω, p ω*Real.log (f ω)) ≤Real.log (∑ ω, p ω*f ω) :=by
proof · 9
lines
let f' :=fun ω =>if p ω=0then (1:ℝ) else f ω
have hh := strictConcaveOn_log_Ioi.concaveOn.le_map_sum
(fun ω _ => p.nonneg ω) p.sum_one (fun ω _ =>show0<f' ω fromby
dsimp only [f']; split_ifs with hz; norm_num; exact hf ω hz)
have he (ω : Ω) : p ω*f' ω=p ω*f ω :=by
dsimp only [f']; split_ifs with hz; simp [hz]; rfl
have hl (ω : Ω) : p ω*Real.log (f' ω)=p ω*Real.log (f ω) :=by
dsimp only [f']; split_ifs with hz; simp [hz]; rfl
simpa only [smul_eq_mul,he,hl] using hh
lemmaexpected_log_card_passingList (q : FinLaw Γ) (hit : Γ →G→Prop)
(x : G) (htrue : ∀ v, q v≠0→¬hit v x)
(E : FinsetG) {c : ℝ} (hhit : ∀ y ∉E, c≤q.prob (fun v => hit v y)) (n : ℕ) :
(∑ v, q.iid n v*Real.log (passingList hit n v).card) ≤Real.log ((E.card:ℝ)+(Fintype.card G:ℝ)*Real.exp (-(n:ℝ)*c)) :=by
proof · 14
lines
have hp (v : Fin n → Γ) (hv : q.iid n v≠0) : (0:ℝ)<(passingList hit n v).card :=by
exact_mod_cast Finset.card_pos.mpr ⟨x,q.passingList_true hit x htrue n v hv⟩
apply ((q.iid n).expect_log_le_log_expect (fun v => ((passingList hit n v).card:ℝ)) hp).trans
apply Real.log_le_log ?_ (q.expect_card_passingList hit E hhit n)
havehex : ∃ v, 0 < q.iid n v :=by
by_contra hh
push Not at hh
havehz : ∀ v, q.iid n v=0:=fun v => le_antisymm (hh v) ((q.iid n).nonneg v)
have hs := (q.iid n).sum_one
simp only [hz,Finset.sum_const_zero] at hs
norm_num at hs
obtain ⟨v,hv⟩ := hex
exact Finset.sum_pos' (fun v _ => mul_nonneg ((q.iid n).nonneg v) (Nat.cast_nonneg _))
⟨v,Finset.mem_univ v,mul_pos hv (hp v hv.ne')⟩
lemmaconditional_passing_support (p : FinLaw Ω) (X : Ω →G) (C : Ω → α)
(hit : α →G→Prop) (hs : ∀ ω, p ω≠0→¬hit (C ω) (X ω)) :
p.cHf XC≤∑ a, p.map C a*Real.log ((Finset.univ.filter (fun x =>¬hit a x)).card) :=by
proof · 5
lines
have h := p.condH_le_support XC (fun a =>Finset.univ.filter (fun x =>¬hit a x)) (by
intro ω hw
simp only [Finset.mem_filter,Finset.mem_univ,true_and]
exact hs ω hw)
simpa only [condH,←Hf_eq_H,cHf] using h
lemmacHf_prefix_step (p : FinLaw Ω) {n k : ℕ} (X : Ω →Fin n → α)
(C : Ω → β) (hk : k<n) :
p.cHf (prefixVar X (Equiv.refl _) (k+1)) C =
p.cHf (prefixVar X (Equiv.refl _) k) C+
p.cHf (fun ω =>X ω ⟨k,hk⟩) (fun ω => (prefixVar X (Equiv.refl _) k ω,C ω)) :=by
proof · 23
lines
havehe : p.cHf (prefixVar X (Equiv.refl _) (k+1)) C =
p.cHf (fun ω => (prefixVar X (Equiv.refl _) k ω,X ω ⟨k,hk⟩)) C:=by
apply p.cHf_eq_of_fibers
intro ω ν _
constructor
· intro h
refine Prod.ext ?_ ?_
· funext i
by_cases hi : i.val<k
· simpa only [prefixVar,hi,ite_eq_left,show i.val<k+1by omega] using congrFun h i
· simp [prefixVar,hi]
· simpa [prefixVar] using congrFun h ⟨k,hk⟩
· intro h
funext i
by_cases hi : i.val<k
· simpa only [prefixVar,hi,ite_eq_left,show i.val<k+1by omega] using
congrFun (congrArg Prod.fst h) i
· by_cases hie : i.val=k
· havehi' : i=⟨k,hk⟩ :=Fin.ext hie
subst i
simpa [prefixVar] using congrArg some (congrArg Prod.snd h)
· simp [prefixVar,show¬i.val<k+1by omega]
rw [he,p.cHf_chain]