classical
havehe : ((p.map f).mix (q.map f)).entropy=((p.mix q).map f).entropy :=bylet s := p.support ∪ q.support
rw [mix_map_entropy p q f s Finset.subset_union_left Finset.subset_union_right,
(p.mix q).entropy_map_on f s (by exact fun _ h => h)]
rfl
have hp := p.entropy_map_le f
have hq := q.entropy_map_le f
unfold js
rw [he]
linarith
theoremtv_maps_le_disagreement {α : Type uα} {β : Type uβ} (p : FiniteDistribution α) (f g : α → β) :
(p.map f).tv (p.map g) ≤∑ a ∈ p.support, if f a = g a then0else p.weight a :=by
proof · 45
lines
classical
let t := (p.map f).support ∪ (p.map g).support
rw [(p.map f).tv_on (p.map g) t Finset.subset_union_left Finset.subset_union_right]
unfold FiniteEntropy.totalVariation
have hm (k : α → β) (b : β) : (p.map k).weight b =
∑ a ∈ p.support, if k a=b then p.weight a else0:=by
rw [map_weight_on p k p.support (fun _ h => h)]
simp only [FiniteEntropy.mass,Finset.sum_filter]
havehsum : ∑ b ∈ t, |(p.map f).weight b-(p.map g).weight b| ≤∑ a ∈ p.support, if f a = g a then0else2*p.weight a :=bycalc
_ ≤∑ b ∈ t, ∑ a ∈ p.support,
|(if f a=b then p.weight a else0)-(if g a=b then p.weight a else0)| :=by
apply Finset.sum_le_sum
intro b _
rw [hm f b,hm g b,←Finset.sum_sub_distrib]
exact Finset.abs_sum_le_sum_abs _ _
_ = _ :=by
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro a ha
by_cases h : f a=g a
· simp [h]
· havehf : f a ∈ t :=Finset.mem_union_left _ (Finset.mem_image_of_mem f ha)
havehg : g a ∈ t :=Finset.mem_union_right _ (Finset.mem_image_of_mem g ha)
havehabs : ∀ b, |(if f a=b then p.weight a else0)-(if g a=b then p.weight a else0)| =
(if f a=b then p.weight a else0)+(if g a=b then p.weight a else0) :=by
intro b
by_cases hfb : f a=b <;> by_cases hgb : g a=b
· exact (h (hfb.trans hgb.symm)).elim
· simp [hfb,hgb,abs_of_nonneg (p.nonneg a)]
· simp [hfb,hgb,abs_of_nonneg (p.nonneg a)]
· simp [hfb,hgb]
simp_rw [habs]
rw [Finset.sum_add_distrib]
simp only [Finset.sum_ite_eq,hf,hg,ite_true,h,ite_false]
ring
havehe : (∑ a ∈ p.support, if f a=g a then0else2*p.weight a) =
2*∑ a ∈ p.support, if f a=g a then0else p.weight a :=by
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro a _
split_ifs <;> ring
rw [he] at hsum
linarith
theoremintegral_finite_observation {α : Type uα} {β : Type uβ} [MeasurableSpace α] [MeasurableSpace β]
[MeasurableSingletonClass β] (μ : Measure α) [IsFiniteMeasure μ]
(f : α → β) (hf : Measurable f) (s : Finset β) (hs : ∀ᵐ x ∂μ, f x ∈ s)
(F : β →ℝ) : ∫ x, F (f x) ∂μ = ∑ b ∈ s, mass μ f b*F b :=by
proof · 14
lines
classical
havehe : (fun x =>F (f x)) =ᵐ[μ]
fun x =>∑ b ∈ s, ({x | f x=b} : Set α).indicator (fun _ =>F b) x :=by
filter_upwards [hs] with x hx
simp only [Set.indicator_apply,Set.mem_ofPred]
simp [Finset.sum_ite_eq,hx]
rw [integral_congr_ae he, integral_finsetSum]
· apply Finset.sum_congr rfl
intro b _
change (∫ a, (f ⁻¹' {b}).indicator (fun _ =>F b) a ∂μ) = _
rw [integral_indicator_const _ ((measurableSet_singleton b).preimage hf)]
rfl
· intro b _
exact (integrable_const _).indicator ((measurableSet_singleton b).preimage hf)
theorementropy_binary_extra {α : Type uα} {β : Type uβ} [MeasurableSpace α] [MeasurableSpace β]
[MeasurableSingletonClass β] [DecidableEq β]
(μ : Measure α) [IsProbabilityMeasure μ] (f : α → β) (g : α →ℤ)
(hf : Measurable f) (hg : Measurable g) (s : Finset β)
(hs : ∀ᵐ x ∂μ, f x ∈ s) (hg01 : ∀ᵐ x ∂μ, g x ∈Finset.Icc (0 : ℤ) 1)
(bad : β →Prop) [DecidablePred bad]
(hgood : ∀ᵐ x ∂μ, ¬bad (f x) → g x=0) :
entropy μ (fun x => (g x,f x))-entropy μ f ≤
(∫ x, if bad (f x) then (1 : ℝ) else0 ∂μ)*Real.log 2:=by
proof · 44
lines
classical
let t := ((Finset.Icc (0 : ℤ) 1) ×ˢ s).filter (fun y => bad y.2∨ y.1=0)
letF:=fun x => (g x,f x)
havehF : MeasurableF:= hg.prodMk hf
haveht : ∀ᵐ x ∂μ, F x ∈ t :=by
filter_upwards [hs,hg01,hgood] with x hx hgx hgoodx
exact Finset.mem_filter.mpr ⟨Finset.mem_product.mpr ⟨hgx,hx⟩,or_iff_not_imp_left.mpr hgoodx⟩
have hh :=FiniteEntropy.conditionalEntropy_le_bad_mass t (mass μ F) Prod.fst Prod.snd bad
(fun a _ => mass_nonneg μ F a) (by
intro a ha b hb hab hbad
have ha' := (Finset.mem_filter.mp ha).2.resolve_left hbad
have hb' := (Finset.mem_filter.mp hb).2.resolve_left (hab ▸ hbad)
exact ha'.trans hb'.symm)
havehi : (funa : ℤ× β => (a.1,a.2))=id := rfl
unfold FiniteEntropy.conditionalEntropy at hh
rw [hi,FiniteEntropy.observableEntropy_id,← entropy_comp μ F hF t ht Prod.snd] at hh
change FiniteEntropy.entropy t (mass μ F)-entropy μ f ≤ _ at hh
unfold FiniteEntropy.entropy at hh
rw [← entropy_eq_sum μ F t ht] at hh
havehbad0 : 0≤∑ a ∈ t, if bad a.2then mass μ F a else0:=by
apply Finset.sum_nonneg
intro a _
split_ifs
· exact mass_nonneg μ F a
· exact le_rfl
havehc : (t.image Prod.fst).card ≤2:=byhavehsub : t.image Prod.fst ⊆Finset.Icc (0 : ℤ) 1:=by
rintro a ha
obtain ⟨b,hb,rfl⟩ :=Finset.mem_image.mp ha
exact (Finset.mem_product.mp (Finset.mem_filter.mp hb).1).1
simpa usingFinset.card_le_card hsub
havehl : Real.log (t.image Prod.fst).card ≤Real.log 2:=byby_cases hz : (t.image Prod.fst).card=0
· simp [hz,Real.log_nonneg (bynorm_num : (1 : ℝ) ≤2)]
· apply Real.log_le_log (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hz))
exact_mod_cast hc
havehe : (∫ x, if bad (f x) then (1 : ℝ) else0 ∂μ) =
∑ a ∈ t, if bad a.2then mass μ F a else0:=byhave h := integral_finite_observation μ F hF t ht
(funa : ℤ× β =>if bad a.2then (1 : ℝ) else0)
simpa only [F, mul_ite, mul_one, mul_zero] using h
rw [he]
exact hh.trans (mul_le_mul_of_nonneg_left hl hbad0)