| author | blanchet | 
| Tue, 20 May 2014 09:38:39 +0200 | |
| changeset 57013 | ed95456499e6 | 
| parent 56996 | 891e992e510f | 
| child 57166 | 5cfcc616d485 | 
| permissions | -rw-r--r-- | 
| 42067 | 1 | (* Title: HOL/Probability/Information.thy | 
| 2 | Author: Johannes Hölzl, TU München | |
| 3 | Author: Armin Heller, TU München | |
| 4 | *) | |
| 5 | ||
| 6 | header {*Information theory*}
 | |
| 7 | ||
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 8 | theory Information | 
| 41413 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 9 | imports | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 10 | Independent_Family | 
| 43556 
0d78c8d31d0d
move conditional expectation to its own theory file
 hoelzl parents: 
43340diff
changeset | 11 | Radon_Nikodym | 
| 41413 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 wenzelm parents: 
41095diff
changeset | 12 | "~~/src/HOL/Library/Convex" | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 13 | begin | 
| 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 14 | |
| 39097 | 15 | lemma log_le: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x \<le> y \<Longrightarrow> log a x \<le> log a y" | 
| 16 | by (subst log_le_cancel_iff) auto | |
| 17 | ||
| 18 | lemma log_less: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> log a x < log a y" | |
| 19 | by (subst log_less_cancel_iff) auto | |
| 20 | ||
| 21 | lemma setsum_cartesian_product': | |
| 22 | "(\<Sum>x\<in>A \<times> B. f x) = (\<Sum>x\<in>A. setsum (\<lambda>y. f (x, y)) B)" | |
| 23 | unfolding setsum_cartesian_product by simp | |
| 24 | ||
| 25 | lemma split_pairs: | |
| 40859 | 26 | "((A, B) = X) \<longleftrightarrow> (fst X = A \<and> snd X = B)" and | 
| 27 | "(X = (A, B)) \<longleftrightarrow> (fst X = A \<and> snd X = B)" by auto | |
| 38656 | 28 | |
| 56994 | 29 | subsection "Information theory" | 
| 38656 | 30 | |
| 40859 | 31 | locale information_space = prob_space + | 
| 38656 | 32 | fixes b :: real assumes b_gt_1: "1 < b" | 
| 33 | ||
| 40859 | 34 | context information_space | 
| 38656 | 35 | begin | 
| 36 | ||
| 40859 | 37 | text {* Introduce some simplification rules for logarithm of base @{term b}. *}
 | 
| 38 | ||
| 39 | lemma log_neg_const: | |
| 40 | assumes "x \<le> 0" | |
| 41 | shows "log b x = log b 0" | |
| 36624 | 42 | proof - | 
| 40859 | 43 |   { fix u :: real
 | 
| 44 | have "x \<le> 0" by fact | |
| 45 | also have "0 < exp u" | |
| 46 | using exp_gt_zero . | |
| 47 | finally have "exp u \<noteq> x" | |
| 48 | by auto } | |
| 49 | then show "log b x = log b 0" | |
| 50 | by (simp add: log_def ln_def) | |
| 38656 | 51 | qed | 
| 52 | ||
| 40859 | 53 | lemma log_mult_eq: | 
| 54 | "log b (A * B) = (if 0 < A * B then log b \<bar>A\<bar> + log b \<bar>B\<bar> else log b 0)" | |
| 55 | using log_mult[of b "\<bar>A\<bar>" "\<bar>B\<bar>"] b_gt_1 log_neg_const[of "A * B"] | |
| 56 | by (auto simp: zero_less_mult_iff mult_le_0_iff) | |
| 38656 | 57 | |
| 40859 | 58 | lemma log_inverse_eq: | 
| 59 | "log b (inverse B) = (if 0 < B then - log b B else log b 0)" | |
| 60 | using log_inverse[of b B] log_neg_const[of "inverse B"] b_gt_1 by simp | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 61 | |
| 40859 | 62 | lemma log_divide_eq: | 
| 63 | "log b (A / B) = (if 0 < A * B then log b \<bar>A\<bar> - log b \<bar>B\<bar> else log b 0)" | |
| 64 | unfolding divide_inverse log_mult_eq log_inverse_eq abs_inverse | |
| 65 | by (auto simp: zero_less_mult_iff mult_le_0_iff) | |
| 38656 | 66 | |
| 40859 | 67 | lemmas log_simps = log_mult_eq log_inverse_eq log_divide_eq | 
| 38656 | 68 | |
| 69 | end | |
| 70 | ||
| 39097 | 71 | subsection "Kullback$-$Leibler divergence" | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 72 | |
| 39097 | 73 | text {* The Kullback$-$Leibler divergence is also known as relative entropy or
 | 
| 74 | Kullback$-$Leibler distance. *} | |
| 75 | ||
| 76 | definition | |
| 47694 | 77 | "entropy_density b M N = log b \<circ> real \<circ> RN_deriv M N" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 78 | |
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 79 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 80 | "KL_divergence b M N = integral\<^sup>L N (entropy_density b M N)" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 81 | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 82 | lemma measurable_entropy_density[measurable]: "entropy_density b M N \<in> borel_measurable M" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 83 | unfolding entropy_density_def by auto | 
| 50003 | 84 | |
| 47694 | 85 | lemma (in sigma_finite_measure) KL_density: | 
| 86 | fixes f :: "'a \<Rightarrow> real" | |
| 87 | assumes "1 < b" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 88 | assumes f[measurable]: "f \<in> borel_measurable M" and nn: "AE x in M. 0 \<le> f x" | 
| 47694 | 89 | shows "KL_divergence b M (density M f) = (\<integral>x. f x * log b (f x) \<partial>M)" | 
| 90 | unfolding KL_divergence_def | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 91 | proof (subst integral_real_density) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 92 | show [measurable]: "entropy_density b M (density M (\<lambda>x. ereal (f x))) \<in> borel_measurable M" | 
| 49776 | 93 | using f | 
| 50003 | 94 | by (auto simp: comp_def entropy_density_def) | 
| 47694 | 95 | have "density M (RN_deriv M (density M f)) = density M f" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 96 | using f nn by (intro density_RN_deriv_density) auto | 
| 47694 | 97 | then have eq: "AE x in M. RN_deriv M (density M f) x = f x" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 98 | using f nn by (intro density_unique) (auto simp: RN_deriv_nonneg) | 
| 47694 | 99 | show "(\<integral>x. f x * entropy_density b M (density M (\<lambda>x. ereal (f x))) x \<partial>M) = (\<integral>x. f x * log b (f x) \<partial>M)" | 
| 100 | apply (intro integral_cong_AE) | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 101 | apply measurable | 
| 47694 | 102 | using eq | 
| 103 | apply eventually_elim | |
| 104 | apply (auto simp: entropy_density_def) | |
| 105 | done | |
| 106 | qed fact+ | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 107 | |
| 47694 | 108 | lemma (in sigma_finite_measure) KL_density_density: | 
| 109 | fixes f g :: "'a \<Rightarrow> real" | |
| 110 | assumes "1 < b" | |
| 111 | assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x" | |
| 112 | assumes g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x" | |
| 113 | assumes ac: "AE x in M. f x = 0 \<longrightarrow> g x = 0" | |
| 114 | shows "KL_divergence b (density M f) (density M g) = (\<integral>x. g x * log b (g x / f x) \<partial>M)" | |
| 115 | proof - | |
| 116 | interpret Mf: sigma_finite_measure "density M f" | |
| 117 | using f by (subst sigma_finite_iff_density_finite) auto | |
| 118 | have "KL_divergence b (density M f) (density M g) = | |
| 119 | KL_divergence b (density M f) (density (density M f) (\<lambda>x. g x / f x))" | |
| 120 | using f g ac by (subst density_density_divide) simp_all | |
| 121 | also have "\<dots> = (\<integral>x. (g x / f x) * log b (g x / f x) \<partial>density M f)" | |
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 122 | using f g `1 < b` by (intro Mf.KL_density) (auto simp: AE_density) | 
| 47694 | 123 | also have "\<dots> = (\<integral>x. g x * log b (g x / f x) \<partial>M)" | 
| 124 | using ac f g `1 < b` by (subst integral_density) (auto intro!: integral_cong_AE) | |
| 125 | finally show ?thesis . | |
| 126 | qed | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 127 | |
| 47694 | 128 | lemma (in information_space) KL_gt_0: | 
| 129 | fixes D :: "'a \<Rightarrow> real" | |
| 130 | assumes "prob_space (density M D)" | |
| 131 | assumes D: "D \<in> borel_measurable M" "AE x in M. 0 \<le> D x" | |
| 132 | assumes int: "integrable M (\<lambda>x. D x * log b (D x))" | |
| 133 | assumes A: "density M D \<noteq> M" | |
| 134 | shows "0 < KL_divergence b M (density M D)" | |
| 135 | proof - | |
| 136 | interpret N: prob_space "density M D" by fact | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 137 | |
| 47694 | 138 | obtain A where "A \<in> sets M" "emeasure (density M D) A \<noteq> emeasure M A" | 
| 139 | using measure_eqI[of "density M D" M] `density M D \<noteq> M` by auto | |
| 140 | ||
| 141 |   let ?D_set = "{x\<in>space M. D x \<noteq> 0}"
 | |
| 142 | have [simp, intro]: "?D_set \<in> sets M" | |
| 143 | using D by auto | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 144 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 145 | have D_neg: "(\<integral>\<^sup>+ x. ereal (- D x) \<partial>M) = 0" | 
| 56996 | 146 | using D by (subst nn_integral_0_iff_AE) auto | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 147 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 148 | have "(\<integral>\<^sup>+ x. ereal (D x) \<partial>M) = emeasure (density M D) (space M)" | 
| 56996 | 149 | using D by (simp add: emeasure_density cong: nn_integral_cong) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 150 | then have D_pos: "(\<integral>\<^sup>+ x. ereal (D x) \<partial>M) = 1" | 
| 47694 | 151 | using N.emeasure_space_1 by simp | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 152 | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 153 | have "integrable M D" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 154 | using D D_pos D_neg unfolding real_integrable_def real_lebesgue_integral_def by simp_all | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 155 | then have "integral\<^sup>L M D = 1" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 156 | using D D_pos D_neg by (simp add: real_lebesgue_integral_def) | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 157 | |
| 47694 | 158 | have "0 \<le> 1 - measure M ?D_set" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 159 | using prob_le_1 by (auto simp: field_simps) | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 160 | also have "\<dots> = (\<integral> x. D x - indicator ?D_set x \<partial>M)" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 161 | using `integrable M D` `integral\<^sup>L M D = 1` | 
| 47694 | 162 | by (simp add: emeasure_eq_measure) | 
| 163 | also have "\<dots> < (\<integral> x. D x * (ln b * log b (D x)) \<partial>M)" | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 164 | proof (rule integral_less_AE) | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 165 | show "integrable M (\<lambda>x. D x - indicator ?D_set x)" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 166 | using `integrable M D` by auto | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 167 | next | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 168 | from integrable_mult_left(1)[OF int, of "ln b"] | 
| 47694 | 169 | show "integrable M (\<lambda>x. D x * (ln b * log b (D x)))" | 
| 170 | by (simp add: ac_simps) | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 171 | next | 
| 47694 | 172 |     show "emeasure M {x\<in>space M. D x \<noteq> 1 \<and> D x \<noteq> 0} \<noteq> 0"
 | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 173 | proof | 
| 47694 | 174 |       assume eq_0: "emeasure M {x\<in>space M. D x \<noteq> 1 \<and> D x \<noteq> 0} = 0"
 | 
| 175 | then have disj: "AE x in M. D x = 1 \<or> D x = 0" | |
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50003diff
changeset | 176 | using D(1) by (auto intro!: AE_I[OF subset_refl] sets.sets_Collect) | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 177 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 178 |       have "emeasure M {x\<in>space M. D x = 1} = (\<integral>\<^sup>+ x. indicator {x\<in>space M. D x = 1} x \<partial>M)"
 | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 179 | using D(1) by auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 180 | also have "\<dots> = (\<integral>\<^sup>+ x. ereal (D x) \<partial>M)" | 
| 56996 | 181 | using disj by (auto intro!: nn_integral_cong_AE simp: indicator_def one_ereal_def) | 
| 47694 | 182 | finally have "AE x in M. D x = 1" | 
| 183 | using D D_pos by (intro AE_I_eq_1) auto | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 184 | then have "(\<integral>\<^sup>+x. indicator A x\<partial>M) = (\<integral>\<^sup>+x. ereal (D x) * indicator A x\<partial>M)" | 
| 56996 | 185 | by (intro nn_integral_cong_AE) (auto simp: one_ereal_def[symmetric]) | 
| 47694 | 186 | also have "\<dots> = density M D A" | 
| 187 | using `A \<in> sets M` D by (simp add: emeasure_density) | |
| 188 | finally show False using `A \<in> sets M` `emeasure (density M D) A \<noteq> emeasure M A` by simp | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 189 | qed | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 190 |     show "{x\<in>space M. D x \<noteq> 1 \<and> D x \<noteq> 0} \<in> sets M"
 | 
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50003diff
changeset | 191 | using D(1) by (auto intro: sets.sets_Collect_conj) | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 192 | |
| 47694 | 193 |     show "AE t in M. t \<in> {x\<in>space M. D x \<noteq> 1 \<and> D x \<noteq> 0} \<longrightarrow>
 | 
| 194 | D t - indicator ?D_set t \<noteq> D t * (ln b * log b (D t))" | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 195 | using D(2) | 
| 47694 | 196 | proof (eventually_elim, safe) | 
| 197 | fix t assume Dt: "t \<in> space M" "D t \<noteq> 1" "D t \<noteq> 0" "0 \<le> D t" | |
| 198 | and eq: "D t - indicator ?D_set t = D t * (ln b * log b (D t))" | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 199 | |
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 200 | have "D t - 1 = D t - indicator ?D_set t" | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 201 | using Dt by simp | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 202 | also note eq | 
| 47694 | 203 | also have "D t * (ln b * log b (D t)) = - D t * ln (1 / D t)" | 
| 204 | using b_gt_1 `D t \<noteq> 0` `0 \<le> D t` | |
| 205 | by (simp add: log_def ln_div less_le) | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 206 | finally have "ln (1 / D t) = 1 / D t - 1" | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 207 | using `D t \<noteq> 0` by (auto simp: field_simps) | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 208 | from ln_eq_minus_one[OF _ this] `D t \<noteq> 0` `0 \<le> D t` `D t \<noteq> 1` | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 209 | show False by auto | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 210 | qed | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 211 | |
| 47694 | 212 | show "AE t in M. D t - indicator ?D_set t \<le> D t * (ln b * log b (D t))" | 
| 213 | using D(2) AE_space | |
| 214 | proof eventually_elim | |
| 215 | fix t assume "t \<in> space M" "0 \<le> D t" | |
| 216 | show "D t - indicator ?D_set t \<le> D t * (ln b * log b (D t))" | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 217 | proof cases | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 218 | assume asm: "D t \<noteq> 0" | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 219 | then have "0 < D t" using `0 \<le> D t` by auto | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 220 | then have "0 < 1 / D t" by auto | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 221 | have "D t - indicator ?D_set t \<le> - D t * (1 / D t - 1)" | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 222 | using asm `t \<in> space M` by (simp add: field_simps) | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 223 | also have "- D t * (1 / D t - 1) \<le> - D t * ln (1 / D t)" | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 224 | using ln_le_minus_one `0 < 1 / D t` by (intro mult_left_mono_neg) auto | 
| 47694 | 225 | also have "\<dots> = D t * (ln b * log b (D t))" | 
| 226 | using `0 < D t` b_gt_1 | |
| 227 | by (simp_all add: log_def ln_div) | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 228 | finally show ?thesis by simp | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 229 | qed simp | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 230 | qed | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 231 | qed | 
| 47694 | 232 | also have "\<dots> = (\<integral> x. ln b * (D x * log b (D x)) \<partial>M)" | 
| 233 | by (simp add: ac_simps) | |
| 234 | also have "\<dots> = ln b * (\<integral> x. D x * log b (D x) \<partial>M)" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 235 | using int by simp | 
| 47694 | 236 | finally show ?thesis | 
| 237 | using b_gt_1 D by (subst KL_density) (auto simp: zero_less_mult_iff) | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 238 | qed | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 239 | |
| 47694 | 240 | lemma (in sigma_finite_measure) KL_same_eq_0: "KL_divergence b M M = 0" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 241 | proof - | 
| 47694 | 242 | have "AE x in M. 1 = RN_deriv M M x" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 243 | proof (rule RN_deriv_unique) | 
| 47694 | 244 | show "(\<lambda>x. 1) \<in> borel_measurable M" "AE x in M. 0 \<le> (1 :: ereal)" by auto | 
| 245 | show "density M (\<lambda>x. 1) = M" | |
| 246 | apply (auto intro!: measure_eqI emeasure_density) | |
| 247 | apply (subst emeasure_density) | |
| 248 | apply auto | |
| 249 | done | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 250 | qed | 
| 47694 | 251 | then have "AE x in M. log b (real (RN_deriv M M x)) = 0" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 252 | by (elim AE_mp) simp | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 253 | from integral_cong_AE[OF _ _ this] | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 254 | have "integral\<^sup>L M (entropy_density b M M) = 0" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 255 | by (simp add: entropy_density_def comp_def) | 
| 47694 | 256 | then show "KL_divergence b M M = 0" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 257 | unfolding KL_divergence_def | 
| 47694 | 258 | by auto | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 259 | qed | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 260 | |
| 47694 | 261 | lemma (in information_space) KL_eq_0_iff_eq: | 
| 262 | fixes D :: "'a \<Rightarrow> real" | |
| 263 | assumes "prob_space (density M D)" | |
| 264 | assumes D: "D \<in> borel_measurable M" "AE x in M. 0 \<le> D x" | |
| 265 | assumes int: "integrable M (\<lambda>x. D x * log b (D x))" | |
| 266 | shows "KL_divergence b M (density M D) = 0 \<longleftrightarrow> density M D = M" | |
| 267 | using KL_same_eq_0[of b] KL_gt_0[OF assms] | |
| 268 | by (auto simp: less_le) | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 269 | |
| 47694 | 270 | lemma (in information_space) KL_eq_0_iff_eq_ac: | 
| 271 | fixes D :: "'a \<Rightarrow> real" | |
| 272 | assumes "prob_space N" | |
| 273 | assumes ac: "absolutely_continuous M N" "sets N = sets M" | |
| 274 | assumes int: "integrable N (entropy_density b M N)" | |
| 275 | shows "KL_divergence b M N = 0 \<longleftrightarrow> N = M" | |
| 41833 
563bea92b2c0
add lemma KL_divergence_vimage, mutual_information_generic
 hoelzl parents: 
41689diff
changeset | 276 | proof - | 
| 47694 | 277 | interpret N: prob_space N by fact | 
| 278 | have "finite_measure N" by unfold_locales | |
| 279 | from real_RN_deriv[OF this ac] guess D . note D = this | |
| 280 | ||
| 281 | have "N = density M (RN_deriv M N)" | |
| 282 | using ac by (rule density_RN_deriv[symmetric]) | |
| 283 | also have "\<dots> = density M D" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 284 | using D by (auto intro!: density_cong) | 
| 47694 | 285 | finally have N: "N = density M D" . | 
| 41833 
563bea92b2c0
add lemma KL_divergence_vimage, mutual_information_generic
 hoelzl parents: 
41689diff
changeset | 286 | |
| 47694 | 287 | from absolutely_continuous_AE[OF ac(2,1) D(2)] D b_gt_1 ac measurable_entropy_density | 
| 288 | have "integrable N (\<lambda>x. log b (D x))" | |
| 289 | by (intro integrable_cong_AE[THEN iffD2, OF _ _ _ int]) | |
| 290 | (auto simp: N entropy_density_def) | |
| 291 | with D b_gt_1 have "integrable M (\<lambda>x. D x * log b (D x))" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 292 | by (subst integrable_real_density[symmetric]) (auto simp: N[symmetric] comp_def) | 
| 47694 | 293 | with `prob_space N` D show ?thesis | 
| 294 | unfolding N | |
| 295 | by (intro KL_eq_0_iff_eq) auto | |
| 41833 
563bea92b2c0
add lemma KL_divergence_vimage, mutual_information_generic
 hoelzl parents: 
41689diff
changeset | 296 | qed | 
| 
563bea92b2c0
add lemma KL_divergence_vimage, mutual_information_generic
 hoelzl parents: 
41689diff
changeset | 297 | |
| 47694 | 298 | lemma (in information_space) KL_nonneg: | 
| 299 | assumes "prob_space (density M D)" | |
| 300 | assumes D: "D \<in> borel_measurable M" "AE x in M. 0 \<le> D x" | |
| 301 | assumes int: "integrable M (\<lambda>x. D x * log b (D x))" | |
| 302 | shows "0 \<le> KL_divergence b M (density M D)" | |
| 303 | using KL_gt_0[OF assms] by (cases "density M D = M") (auto simp: KL_same_eq_0) | |
| 40859 | 304 | |
| 47694 | 305 | lemma (in sigma_finite_measure) KL_density_density_nonneg: | 
| 306 | fixes f g :: "'a \<Rightarrow> real" | |
| 307 | assumes "1 < b" | |
| 308 | assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x" "prob_space (density M f)" | |
| 309 | assumes g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x" "prob_space (density M g)" | |
| 310 | assumes ac: "AE x in M. f x = 0 \<longrightarrow> g x = 0" | |
| 311 | assumes int: "integrable M (\<lambda>x. g x * log b (g x / f x))" | |
| 312 | shows "0 \<le> KL_divergence b (density M f) (density M g)" | |
| 313 | proof - | |
| 314 | interpret Mf: prob_space "density M f" by fact | |
| 315 | interpret Mf: information_space "density M f" b by default fact | |
| 316 | have eq: "density (density M f) (\<lambda>x. g x / f x) = density M g" (is "?DD = _") | |
| 317 | using f g ac by (subst density_density_divide) simp_all | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 318 | |
| 47694 | 319 | have "0 \<le> KL_divergence b (density M f) (density (density M f) (\<lambda>x. g x / f x))" | 
| 320 | proof (rule Mf.KL_nonneg) | |
| 321 | show "prob_space ?DD" unfolding eq by fact | |
| 322 | from f g show "(\<lambda>x. g x / f x) \<in> borel_measurable (density M f)" | |
| 323 | by auto | |
| 324 | show "AE x in density M f. 0 \<le> g x / f x" | |
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 325 | using f g by (auto simp: AE_density) | 
| 47694 | 326 | show "integrable (density M f) (\<lambda>x. g x / f x * log b (g x / f x))" | 
| 327 | using `1 < b` f g ac | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 328 | by (subst integrable_density) | 
| 47694 | 329 | (auto intro!: integrable_cong_AE[THEN iffD2, OF _ _ _ int] measurable_If) | 
| 330 | qed | |
| 331 | also have "\<dots> = KL_divergence b (density M f) (density M g)" | |
| 332 | using f g ac by (subst density_density_divide) simp_all | |
| 333 | finally show ?thesis . | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 334 | qed | 
| 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 335 | |
| 49803 | 336 | subsection {* Finite Entropy *}
 | 
| 337 | ||
| 338 | definition (in information_space) | |
| 339 | "finite_entropy S X f \<longleftrightarrow> distributed M S X f \<and> integrable S (\<lambda>x. f x * log b (f x))" | |
| 340 | ||
| 341 | lemma (in information_space) finite_entropy_simple_function: | |
| 342 | assumes X: "simple_function M X" | |
| 343 |   shows "finite_entropy (count_space (X`space M)) X (\<lambda>a. measure M {x \<in> space M. X x = a})"
 | |
| 344 | unfolding finite_entropy_def | |
| 345 | proof | |
| 346 | have [simp]: "finite (X ` space M)" | |
| 347 | using X by (auto simp: simple_function_def) | |
| 348 | then show "integrable (count_space (X ` space M)) | |
| 349 |      (\<lambda>x. prob {xa \<in> space M. X xa = x} * log b (prob {xa \<in> space M. X xa = x}))"
 | |
| 350 | by (rule integrable_count_space) | |
| 351 |   have d: "distributed M (count_space (X ` space M)) X (\<lambda>x. ereal (if x \<in> X`space M then prob {xa \<in> space M. X xa = x} else 0))"
 | |
| 352 | by (rule distributed_simple_function_superset[OF X]) (auto intro!: arg_cong[where f=prob]) | |
| 353 |   show "distributed M (count_space (X ` space M)) X (\<lambda>x. ereal (prob {xa \<in> space M. X xa = x}))"
 | |
| 354 | by (rule distributed_cong_density[THEN iffD1, OF _ _ _ d]) auto | |
| 355 | qed | |
| 356 | ||
| 357 | lemma distributed_transform_AE: | |
| 358 | assumes T: "T \<in> measurable P Q" "absolutely_continuous Q (distr P Q T)" | |
| 359 | assumes g: "distributed M Q Y g" | |
| 360 | shows "AE x in P. 0 \<le> g (T x)" | |
| 361 | using g | |
| 362 | apply (subst AE_distr_iff[symmetric, OF T(1)]) | |
| 50003 | 363 | apply simp | 
| 49803 | 364 | apply (rule absolutely_continuous_AE[OF _ T(2)]) | 
| 365 | apply simp | |
| 366 | apply (simp add: distributed_AE) | |
| 367 | done | |
| 368 | ||
| 369 | lemma ac_fst: | |
| 370 | assumes "sigma_finite_measure T" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 371 | shows "absolutely_continuous S (distr (S \<Otimes>\<^sub>M T) S fst)" | 
| 49803 | 372 | proof - | 
| 373 | interpret sigma_finite_measure T by fact | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 374 |   { fix A assume A: "A \<in> sets S" "emeasure S A = 0"
 | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 375 | then have "fst -` A \<inter> space (S \<Otimes>\<^sub>M T) = A \<times> space T" | 
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50003diff
changeset | 376 | by (auto simp: space_pair_measure dest!: sets.sets_into_space) | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 377 | with A have "emeasure (S \<Otimes>\<^sub>M T) (fst -` A \<inter> space (S \<Otimes>\<^sub>M T)) = 0" | 
| 49803 | 378 | by (simp add: emeasure_pair_measure_Times) } | 
| 379 | then show ?thesis | |
| 380 | unfolding absolutely_continuous_def | |
| 381 | apply (auto simp: null_sets_distr_iff) | |
| 382 | apply (auto simp: null_sets_def intro!: measurable_sets) | |
| 383 | done | |
| 384 | qed | |
| 385 | ||
| 386 | lemma ac_snd: | |
| 387 | assumes "sigma_finite_measure T" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 388 | shows "absolutely_continuous T (distr (S \<Otimes>\<^sub>M T) T snd)" | 
| 49803 | 389 | proof - | 
| 390 | interpret sigma_finite_measure T by fact | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 391 |   { fix A assume A: "A \<in> sets T" "emeasure T A = 0"
 | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 392 | then have "snd -` A \<inter> space (S \<Otimes>\<^sub>M T) = space S \<times> A" | 
| 50244 
de72bbe42190
qualified interpretation of sigma_algebra, to avoid name clashes
 immler parents: 
50003diff
changeset | 393 | by (auto simp: space_pair_measure dest!: sets.sets_into_space) | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53015diff
changeset | 394 | with A have "emeasure (S \<Otimes>\<^sub>M T) (snd -` A \<inter> space (S \<Otimes>\<^sub>M T)) = 0" | 
| 49803 | 395 | by (simp add: emeasure_pair_measure_Times) } | 
| 396 | then show ?thesis | |
| 397 | unfolding absolutely_continuous_def | |
| 398 | apply (auto simp: null_sets_distr_iff) | |
| 399 | apply (auto simp: null_sets_def intro!: measurable_sets) | |
| 400 | done | |
| 401 | qed | |
| 402 | ||
| 403 | lemma distributed_integrable: | |
| 404 | "distributed M N X f \<Longrightarrow> g \<in> borel_measurable N \<Longrightarrow> | |
| 405 | integrable N (\<lambda>x. f x * g x) \<longleftrightarrow> integrable M (\<lambda>x. g (X x))" | |
| 50003 | 406 | by (auto simp: distributed_real_AE | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 407 | distributed_distr_eq_density[symmetric] integrable_real_density[symmetric] integrable_distr_eq) | 
| 49803 | 408 | |
| 409 | lemma distributed_transform_integrable: | |
| 410 | assumes Px: "distributed M N X Px" | |
| 411 | assumes "distributed M P Y Py" | |
| 412 | assumes Y: "Y = (\<lambda>x. T (X x))" and T: "T \<in> measurable N P" and f: "f \<in> borel_measurable P" | |
| 413 | shows "integrable P (\<lambda>x. Py x * f x) \<longleftrightarrow> integrable N (\<lambda>x. Px x * f (T x))" | |
| 414 | proof - | |
| 415 | have "integrable P (\<lambda>x. Py x * f x) \<longleftrightarrow> integrable M (\<lambda>x. f (Y x))" | |
| 416 | by (rule distributed_integrable) fact+ | |
| 417 | also have "\<dots> \<longleftrightarrow> integrable M (\<lambda>x. f (T (X x)))" | |
| 418 | using Y by simp | |
| 419 | also have "\<dots> \<longleftrightarrow> integrable N (\<lambda>x. Px x * f (T x))" | |
| 420 | using measurable_comp[OF T f] Px by (intro distributed_integrable[symmetric]) (auto simp: comp_def) | |
| 421 | finally show ?thesis . | |
| 422 | qed | |
| 423 | ||
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 424 | lemma integrable_cong_AE_imp: | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 425 | "integrable M g \<Longrightarrow> f \<in> borel_measurable M \<Longrightarrow> (AE x in M. g x = f x) \<Longrightarrow> integrable M f" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 426 | using integrable_cong_AE[of f M g] by (auto simp: eq_commute) | 
| 49803 | 427 | |
| 428 | lemma (in information_space) finite_entropy_integrable: | |
| 429 | "finite_entropy S X Px \<Longrightarrow> integrable S (\<lambda>x. Px x * log b (Px x))" | |
| 430 | unfolding finite_entropy_def by auto | |
| 431 | ||
| 432 | lemma (in information_space) finite_entropy_distributed: | |
| 433 | "finite_entropy S X Px \<Longrightarrow> distributed M S X Px" | |
| 434 | unfolding finite_entropy_def by auto | |
| 435 | ||
| 436 | lemma (in information_space) finite_entropy_integrable_transform: | |
| 437 | assumes Fx: "finite_entropy S X Px" | |
| 438 | assumes Fy: "distributed M T Y Py" | |
| 439 | and "X = (\<lambda>x. f (Y x))" | |
| 440 | and "f \<in> measurable T S" | |
| 441 | shows "integrable T (\<lambda>x. Py x * log b (Px (f x)))" | |
| 442 | using assms unfolding finite_entropy_def | |
| 443 | using distributed_transform_integrable[of M T Y Py S X Px f "\<lambda>x. log b (Px x)"] | |
| 50003 | 444 | by auto | 
| 49803 | 445 | |
| 39097 | 446 | subsection {* Mutual Information *}
 | 
| 447 | ||
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 448 | definition (in prob_space) | 
| 38656 | 449 | "mutual_information b S T X Y = | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 450 | KL_divergence b (distr M S X \<Otimes>\<^sub>M distr M T Y) (distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)))" | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 451 | |
| 47694 | 452 | lemma (in information_space) mutual_information_indep_vars: | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 453 | fixes S T X Y | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 454 | defines "P \<equiv> distr M S X \<Otimes>\<^sub>M distr M T Y" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 455 | defines "Q \<equiv> distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 456 | shows "indep_var S X T Y \<longleftrightarrow> | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 457 | (random_variable S X \<and> random_variable T Y \<and> | 
| 47694 | 458 | absolutely_continuous P Q \<and> integrable Q (entropy_density b P Q) \<and> | 
| 459 | mutual_information b S T X Y = 0)" | |
| 460 | unfolding indep_var_distribution_eq | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 461 | proof safe | 
| 50003 | 462 | assume rv[measurable]: "random_variable S X" "random_variable T Y" | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 463 | |
| 47694 | 464 | interpret X: prob_space "distr M S X" | 
| 465 | by (rule prob_space_distr) fact | |
| 466 | interpret Y: prob_space "distr M T Y" | |
| 467 | by (rule prob_space_distr) fact | |
| 468 | interpret XY: pair_prob_space "distr M S X" "distr M T Y" by default | |
| 469 | interpret P: information_space P b unfolding P_def by default (rule b_gt_1) | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 470 | |
| 47694 | 471 | interpret Q: prob_space Q unfolding Q_def | 
| 50003 | 472 | by (rule prob_space_distr) simp | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 473 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 474 |   { assume "distr M S X \<Otimes>\<^sub>M distr M T Y = distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))"
 | 
| 47694 | 475 | then have [simp]: "Q = P" unfolding Q_def P_def by simp | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 476 | |
| 47694 | 477 | show ac: "absolutely_continuous P Q" by (simp add: absolutely_continuous_def) | 
| 478 | then have ed: "entropy_density b P Q \<in> borel_measurable P" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 479 | by simp | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 480 | |
| 47694 | 481 | have "AE x in P. 1 = RN_deriv P Q x" | 
| 482 | proof (rule P.RN_deriv_unique) | |
| 483 | show "density P (\<lambda>x. 1) = Q" | |
| 484 | unfolding `Q = P` by (intro measure_eqI) (auto simp: emeasure_density) | |
| 485 | qed auto | |
| 486 | then have ae_0: "AE x in P. entropy_density b P Q x = 0" | |
| 487 | by eventually_elim (auto simp: entropy_density_def) | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 488 | then have "integrable P (entropy_density b P Q) \<longleftrightarrow> integrable Q (\<lambda>x. 0::real)" | 
| 47694 | 489 | using ed unfolding `Q = P` by (intro integrable_cong_AE) auto | 
| 490 | then show "integrable Q (entropy_density b P Q)" by simp | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 491 | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 492 | from ae_0 have "mutual_information b S T X Y = (\<integral>x. 0 \<partial>P)" | 
| 47694 | 493 | unfolding mutual_information_def KL_divergence_def P_def[symmetric] Q_def[symmetric] `Q = P` | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 494 | by (intro integral_cong_AE) auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 495 | then show "mutual_information b S T X Y = 0" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 496 | by simp } | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 497 | |
| 47694 | 498 |   { assume ac: "absolutely_continuous P Q"
 | 
| 499 | assume int: "integrable Q (entropy_density b P Q)" | |
| 500 | assume I_eq_0: "mutual_information b S T X Y = 0" | |
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 501 | |
| 47694 | 502 | have eq: "Q = P" | 
| 503 | proof (rule P.KL_eq_0_iff_eq_ac[THEN iffD1]) | |
| 504 | show "prob_space Q" by unfold_locales | |
| 505 | show "absolutely_continuous P Q" by fact | |
| 506 | show "integrable Q (entropy_density b P Q)" by fact | |
| 507 | show "sets Q = sets P" by (simp add: P_def Q_def sets_pair_measure) | |
| 508 | show "KL_divergence b P Q = 0" | |
| 509 | using I_eq_0 unfolding mutual_information_def by (simp add: P_def Q_def) | |
| 510 | qed | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 511 | then show "distr M S X \<Otimes>\<^sub>M distr M T Y = distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))" | 
| 47694 | 512 | unfolding P_def Q_def .. } | 
| 43340 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 513 | qed | 
| 
60e181c4eae4
lemma: independence is equal to mutual information = 0
 hoelzl parents: 
42148diff
changeset | 514 | |
| 40859 | 515 | abbreviation (in information_space) | 
| 516 |   mutual_information_Pow ("\<I>'(_ ; _')") where
 | |
| 47694 | 517 | "\<I>(X ; Y) \<equiv> mutual_information b (count_space (X`space M)) (count_space (Y`space M)) X Y" | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 518 | |
| 47694 | 519 | lemma (in information_space) | 
| 520 | fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" | |
| 49803 | 521 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" | 
| 522 | assumes Fx: "finite_entropy S X Px" and Fy: "finite_entropy T Y Py" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 523 | assumes Fxy: "finite_entropy (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 49803 | 524 | defines "f \<equiv> \<lambda>x. Pxy x * log b (Pxy x / (Px (fst x) * Py (snd x)))" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 525 | shows mutual_information_distr': "mutual_information b S T X Y = integral\<^sup>L (S \<Otimes>\<^sub>M T) f" (is "?M = ?R") | 
| 49803 | 526 | and mutual_information_nonneg': "0 \<le> mutual_information b S T X Y" | 
| 527 | proof - | |
| 528 | have Px: "distributed M S X Px" | |
| 529 | using Fx by (auto simp: finite_entropy_def) | |
| 530 | have Py: "distributed M T Y Py" | |
| 531 | using Fy by (auto simp: finite_entropy_def) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 532 | have Pxy: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 49803 | 533 | using Fxy by (auto simp: finite_entropy_def) | 
| 534 | ||
| 535 | have X: "random_variable S X" | |
| 50003 | 536 | using Px by auto | 
| 49803 | 537 | have Y: "random_variable T Y" | 
| 50003 | 538 | using Py by auto | 
| 49803 | 539 | interpret S: sigma_finite_measure S by fact | 
| 540 | interpret T: sigma_finite_measure T by fact | |
| 541 | interpret ST: pair_sigma_finite S T .. | |
| 542 | interpret X: prob_space "distr M S X" using X by (rule prob_space_distr) | |
| 543 | interpret Y: prob_space "distr M T Y" using Y by (rule prob_space_distr) | |
| 544 | interpret XY: pair_prob_space "distr M S X" "distr M T Y" .. | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 545 | let ?P = "S \<Otimes>\<^sub>M T" | 
| 49803 | 546 | let ?D = "distr M ?P (\<lambda>x. (X x, Y x))" | 
| 547 | ||
| 548 |   { fix A assume "A \<in> sets S"
 | |
| 549 | with X Y have "emeasure (distr M S X) A = emeasure ?D (A \<times> space T)" | |
| 550 | by (auto simp: emeasure_distr measurable_Pair measurable_space | |
| 551 | intro!: arg_cong[where f="emeasure M"]) } | |
| 552 | note marginal_eq1 = this | |
| 553 |   { fix A assume "A \<in> sets T"
 | |
| 554 | with X Y have "emeasure (distr M T Y) A = emeasure ?D (space S \<times> A)" | |
| 555 | by (auto simp: emeasure_distr measurable_Pair measurable_space | |
| 556 | intro!: arg_cong[where f="emeasure M"]) } | |
| 557 | note marginal_eq2 = this | |
| 558 | ||
| 559 | have eq: "(\<lambda>x. ereal (Px (fst x) * Py (snd x))) = (\<lambda>(x, y). ereal (Px x) * ereal (Py y))" | |
| 560 | by auto | |
| 561 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 562 | have distr_eq: "distr M S X \<Otimes>\<^sub>M distr M T Y = density ?P (\<lambda>x. ereal (Px (fst x) * Py (snd x)))" | 
| 49803 | 563 | unfolding Px(1)[THEN distributed_distr_eq_density] Py(1)[THEN distributed_distr_eq_density] eq | 
| 564 | proof (subst pair_measure_density) | |
| 565 | show "(\<lambda>x. ereal (Px x)) \<in> borel_measurable S" "(\<lambda>y. ereal (Py y)) \<in> borel_measurable T" | |
| 566 | "AE x in S. 0 \<le> ereal (Px x)" "AE y in T. 0 \<le> ereal (Py y)" | |
| 567 | using Px Py by (auto simp: distributed_def) | |
| 568 | show "sigma_finite_measure (density T Py)" unfolding Py(1)[THEN distributed_distr_eq_density, symmetric] .. | |
| 569 | qed (fact | simp)+ | |
| 570 | ||
| 571 | have M: "?M = KL_divergence b (density ?P (\<lambda>x. ereal (Px (fst x) * Py (snd x)))) (density ?P (\<lambda>x. ereal (Pxy x)))" | |
| 572 | unfolding mutual_information_def distr_eq Pxy(1)[THEN distributed_distr_eq_density] .. | |
| 573 | ||
| 574 | from Px Py have f: "(\<lambda>x. Px (fst x) * Py (snd x)) \<in> borel_measurable ?P" | |
| 575 | by (intro borel_measurable_times) (auto intro: distributed_real_measurable measurable_fst'' measurable_snd'') | |
| 576 | have PxPy_nonneg: "AE x in ?P. 0 \<le> Px (fst x) * Py (snd x)" | |
| 577 | proof (rule ST.AE_pair_measure) | |
| 578 |     show "{x \<in> space ?P. 0 \<le> Px (fst x) * Py (snd x)} \<in> sets ?P"
 | |
| 579 | using f by auto | |
| 580 | show "AE x in S. AE y in T. 0 \<le> Px (fst (x, y)) * Py (snd (x, y))" | |
| 581 | using Px Py by (auto simp: zero_le_mult_iff dest!: distributed_real_AE) | |
| 582 | qed | |
| 583 | ||
| 584 | have "(AE x in ?P. Px (fst x) = 0 \<longrightarrow> Pxy x = 0)" | |
| 585 | by (rule subdensity_real[OF measurable_fst Pxy Px]) auto | |
| 586 | moreover | |
| 587 | have "(AE x in ?P. Py (snd x) = 0 \<longrightarrow> Pxy x = 0)" | |
| 588 | by (rule subdensity_real[OF measurable_snd Pxy Py]) auto | |
| 589 | ultimately have ac: "AE x in ?P. Px (fst x) * Py (snd x) = 0 \<longrightarrow> Pxy x = 0" | |
| 590 | by eventually_elim auto | |
| 591 | ||
| 592 | show "?M = ?R" | |
| 593 | unfolding M f_def | |
| 594 | using b_gt_1 f PxPy_nonneg Pxy[THEN distributed_real_measurable] Pxy[THEN distributed_real_AE] ac | |
| 595 | by (rule ST.KL_density_density) | |
| 596 | ||
| 597 | have X: "X = fst \<circ> (\<lambda>x. (X x, Y x))" and Y: "Y = snd \<circ> (\<lambda>x. (X x, Y x))" | |
| 598 | by auto | |
| 599 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 600 | have "integrable (S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Pxy x) - Pxy x * log b (Px (fst x)) - Pxy x * log b (Py (snd x)))" | 
| 49803 | 601 | using finite_entropy_integrable[OF Fxy] | 
| 602 | using finite_entropy_integrable_transform[OF Fx Pxy, of fst] | |
| 603 | using finite_entropy_integrable_transform[OF Fy Pxy, of snd] | |
| 604 | by simp | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 605 | moreover have "f \<in> borel_measurable (S \<Otimes>\<^sub>M T)" | 
| 49803 | 606 | unfolding f_def using Px Py Pxy | 
| 607 | by (auto intro: distributed_real_measurable measurable_fst'' measurable_snd'' | |
| 608 | intro!: borel_measurable_times borel_measurable_log borel_measurable_divide) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 609 | ultimately have int: "integrable (S \<Otimes>\<^sub>M T) f" | 
| 49803 | 610 | apply (rule integrable_cong_AE_imp) | 
| 611 | using | |
| 612 | distributed_transform_AE[OF measurable_fst ac_fst, of T, OF T Px] | |
| 613 | distributed_transform_AE[OF measurable_snd ac_snd, of _ _ _ _ S, OF T Py] | |
| 614 | subdensity_real[OF measurable_fst Pxy Px X] | |
| 615 | subdensity_real[OF measurable_snd Pxy Py Y] | |
| 616 | distributed_real_AE[OF Pxy] | |
| 617 | by eventually_elim | |
| 56536 | 618 | (auto simp: f_def log_divide_eq log_mult_eq field_simps zero_less_mult_iff) | 
| 49803 | 619 | |
| 620 | show "0 \<le> ?M" unfolding M | |
| 621 | proof (rule ST.KL_density_density_nonneg | |
| 622 | [OF b_gt_1 f PxPy_nonneg _ Pxy[THEN distributed_real_measurable] Pxy[THEN distributed_real_AE] _ ac int[unfolded f_def]]) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 623 | show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Pxy x))) " | 
| 49803 | 624 | unfolding distributed_distr_eq_density[OF Pxy, symmetric] | 
| 625 | using distributed_measurable[OF Pxy] by (rule prob_space_distr) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 626 | show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Px (fst x) * Py (snd x))))" | 
| 49803 | 627 | unfolding distr_eq[symmetric] by unfold_locales | 
| 628 | qed | |
| 629 | qed | |
| 630 | ||
| 631 | ||
| 632 | lemma (in information_space) | |
| 633 | fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" | |
| 47694 | 634 | assumes "sigma_finite_measure S" "sigma_finite_measure T" | 
| 635 | assumes Px: "distributed M S X Px" and Py: "distributed M T Y Py" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 636 | assumes Pxy: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 47694 | 637 | defines "f \<equiv> \<lambda>x. Pxy x * log b (Pxy x / (Px (fst x) * Py (snd x)))" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 638 | shows mutual_information_distr: "mutual_information b S T X Y = integral\<^sup>L (S \<Otimes>\<^sub>M T) f" (is "?M = ?R") | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 639 | and mutual_information_nonneg: "integrable (S \<Otimes>\<^sub>M T) f \<Longrightarrow> 0 \<le> mutual_information b S T X Y" | 
| 40859 | 640 | proof - | 
| 47694 | 641 | have X: "random_variable S X" | 
| 642 | using Px by (auto simp: distributed_def) | |
| 643 | have Y: "random_variable T Y" | |
| 644 | using Py by (auto simp: distributed_def) | |
| 645 | interpret S: sigma_finite_measure S by fact | |
| 646 | interpret T: sigma_finite_measure T by fact | |
| 647 | interpret ST: pair_sigma_finite S T .. | |
| 648 | interpret X: prob_space "distr M S X" using X by (rule prob_space_distr) | |
| 649 | interpret Y: prob_space "distr M T Y" using Y by (rule prob_space_distr) | |
| 650 | interpret XY: pair_prob_space "distr M S X" "distr M T Y" .. | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 651 | let ?P = "S \<Otimes>\<^sub>M T" | 
| 47694 | 652 | let ?D = "distr M ?P (\<lambda>x. (X x, Y x))" | 
| 653 | ||
| 654 |   { fix A assume "A \<in> sets S"
 | |
| 655 | with X Y have "emeasure (distr M S X) A = emeasure ?D (A \<times> space T)" | |
| 656 | by (auto simp: emeasure_distr measurable_Pair measurable_space | |
| 657 | intro!: arg_cong[where f="emeasure M"]) } | |
| 658 | note marginal_eq1 = this | |
| 659 |   { fix A assume "A \<in> sets T"
 | |
| 660 | with X Y have "emeasure (distr M T Y) A = emeasure ?D (space S \<times> A)" | |
| 661 | by (auto simp: emeasure_distr measurable_Pair measurable_space | |
| 662 | intro!: arg_cong[where f="emeasure M"]) } | |
| 663 | note marginal_eq2 = this | |
| 664 | ||
| 665 | have eq: "(\<lambda>x. ereal (Px (fst x) * Py (snd x))) = (\<lambda>(x, y). ereal (Px x) * ereal (Py y))" | |
| 666 | by auto | |
| 667 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 668 | have distr_eq: "distr M S X \<Otimes>\<^sub>M distr M T Y = density ?P (\<lambda>x. ereal (Px (fst x) * Py (snd x)))" | 
| 47694 | 669 | unfolding Px(1)[THEN distributed_distr_eq_density] Py(1)[THEN distributed_distr_eq_density] eq | 
| 670 | proof (subst pair_measure_density) | |
| 671 | show "(\<lambda>x. ereal (Px x)) \<in> borel_measurable S" "(\<lambda>y. ereal (Py y)) \<in> borel_measurable T" | |
| 672 | "AE x in S. 0 \<le> ereal (Px x)" "AE y in T. 0 \<le> ereal (Py y)" | |
| 673 | using Px Py by (auto simp: distributed_def) | |
| 674 | show "sigma_finite_measure (density T Py)" unfolding Py(1)[THEN distributed_distr_eq_density, symmetric] .. | |
| 675 | qed (fact | simp)+ | |
| 676 | ||
| 677 | have M: "?M = KL_divergence b (density ?P (\<lambda>x. ereal (Px (fst x) * Py (snd x)))) (density ?P (\<lambda>x. ereal (Pxy x)))" | |
| 678 | unfolding mutual_information_def distr_eq Pxy(1)[THEN distributed_distr_eq_density] .. | |
| 679 | ||
| 680 | from Px Py have f: "(\<lambda>x. Px (fst x) * Py (snd x)) \<in> borel_measurable ?P" | |
| 681 | by (intro borel_measurable_times) (auto intro: distributed_real_measurable measurable_fst'' measurable_snd'') | |
| 682 | have PxPy_nonneg: "AE x in ?P. 0 \<le> Px (fst x) * Py (snd x)" | |
| 683 | proof (rule ST.AE_pair_measure) | |
| 684 |     show "{x \<in> space ?P. 0 \<le> Px (fst x) * Py (snd x)} \<in> sets ?P"
 | |
| 685 | using f by auto | |
| 686 | show "AE x in S. AE y in T. 0 \<le> Px (fst (x, y)) * Py (snd (x, y))" | |
| 687 | using Px Py by (auto simp: zero_le_mult_iff dest!: distributed_real_AE) | |
| 688 | qed | |
| 689 | ||
| 690 | have "(AE x in ?P. Px (fst x) = 0 \<longrightarrow> Pxy x = 0)" | |
| 691 | by (rule subdensity_real[OF measurable_fst Pxy Px]) auto | |
| 692 | moreover | |
| 693 | have "(AE x in ?P. Py (snd x) = 0 \<longrightarrow> Pxy x = 0)" | |
| 694 | by (rule subdensity_real[OF measurable_snd Pxy Py]) auto | |
| 695 | ultimately have ac: "AE x in ?P. Px (fst x) * Py (snd x) = 0 \<longrightarrow> Pxy x = 0" | |
| 696 | by eventually_elim auto | |
| 697 | ||
| 698 | show "?M = ?R" | |
| 699 | unfolding M f_def | |
| 700 | using b_gt_1 f PxPy_nonneg Pxy[THEN distributed_real_measurable] Pxy[THEN distributed_real_AE] ac | |
| 701 | by (rule ST.KL_density_density) | |
| 702 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 703 | assume int: "integrable (S \<Otimes>\<^sub>M T) f" | 
| 47694 | 704 | show "0 \<le> ?M" unfolding M | 
| 705 | proof (rule ST.KL_density_density_nonneg | |
| 706 | [OF b_gt_1 f PxPy_nonneg _ Pxy[THEN distributed_real_measurable] Pxy[THEN distributed_real_AE] _ ac int[unfolded f_def]]) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 707 | show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Pxy x))) " | 
| 47694 | 708 | unfolding distributed_distr_eq_density[OF Pxy, symmetric] | 
| 709 | using distributed_measurable[OF Pxy] by (rule prob_space_distr) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 710 | show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Px (fst x) * Py (snd x))))" | 
| 47694 | 711 | unfolding distr_eq[symmetric] by unfold_locales | 
| 40859 | 712 | qed | 
| 713 | qed | |
| 714 | ||
| 715 | lemma (in information_space) | |
| 47694 | 716 | fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" | 
| 717 | assumes "sigma_finite_measure S" "sigma_finite_measure T" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 718 | assumes Px[measurable]: "distributed M S X Px" and Py[measurable]: "distributed M T Y Py" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 719 | assumes Pxy[measurable]: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 47694 | 720 | assumes ae: "AE x in S. AE y in T. Pxy (x, y) = Px x * Py y" | 
| 721 | shows mutual_information_eq_0: "mutual_information b S T X Y = 0" | |
| 36624 | 722 | proof - | 
| 47694 | 723 | interpret S: sigma_finite_measure S by fact | 
| 724 | interpret T: sigma_finite_measure T by fact | |
| 725 | interpret ST: pair_sigma_finite S T .. | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 726 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 727 | have "AE x in S \<Otimes>\<^sub>M T. Px (fst x) = 0 \<longrightarrow> Pxy x = 0" | 
| 47694 | 728 | by (rule subdensity_real[OF measurable_fst Pxy Px]) auto | 
| 729 | moreover | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 730 | have "AE x in S \<Otimes>\<^sub>M T. Py (snd x) = 0 \<longrightarrow> Pxy x = 0" | 
| 47694 | 731 | by (rule subdensity_real[OF measurable_snd Pxy Py]) auto | 
| 732 | moreover | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 733 | have "AE x in S \<Otimes>\<^sub>M T. Pxy x = Px (fst x) * Py (snd x)" | 
| 47694 | 734 | using distributed_real_measurable[OF Px] distributed_real_measurable[OF Py] distributed_real_measurable[OF Pxy] | 
| 735 | by (intro ST.AE_pair_measure) (auto simp: ae intro!: measurable_snd'' measurable_fst'') | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 736 | ultimately have "AE x in S \<Otimes>\<^sub>M T. Pxy x * log b (Pxy x / (Px (fst x) * Py (snd x))) = 0" | 
| 47694 | 737 | by eventually_elim simp | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 738 | then have "(\<integral>x. Pxy x * log b (Pxy x / (Px (fst x) * Py (snd x))) \<partial>(S \<Otimes>\<^sub>M T)) = (\<integral>x. 0 \<partial>(S \<Otimes>\<^sub>M T))" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 739 | by (intro integral_cong_AE) auto | 
| 47694 | 740 | then show ?thesis | 
| 741 | by (subst mutual_information_distr[OF assms(1-5)]) simp | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 742 | qed | 
| 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 743 | |
| 47694 | 744 | lemma (in information_space) mutual_information_simple_distributed: | 
| 745 | assumes X: "simple_distributed M X Px" and Y: "simple_distributed M Y Py" | |
| 746 | assumes XY: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy" | |
| 747 | shows "\<I>(X ; Y) = (\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x))`space M. Pxy (x, y) * log b (Pxy (x, y) / (Px x * Py y)))" | |
| 748 | proof (subst mutual_information_distr[OF _ _ simple_distributed[OF X] simple_distributed[OF Y] simple_distributed_joint[OF XY]]) | |
| 749 | note fin = simple_distributed_joint_finite[OF XY, simp] | |
| 750 | show "sigma_finite_measure (count_space (X ` space M))" | |
| 751 | by (simp add: sigma_finite_measure_count_space_finite) | |
| 752 | show "sigma_finite_measure (count_space (Y ` space M))" | |
| 753 | by (simp add: sigma_finite_measure_count_space_finite) | |
| 754 | let ?Pxy = "\<lambda>x. (if x \<in> (\<lambda>x. (X x, Y x)) ` space M then Pxy x else 0)" | |
| 755 | let ?f = "\<lambda>x. ?Pxy x * log b (?Pxy x / (Px (fst x) * Py (snd x)))" | |
| 756 | have "\<And>x. ?f x = (if x \<in> (\<lambda>x. (X x, Y x)) ` space M then Pxy x * log b (Pxy x / (Px (fst x) * Py (snd x))) else 0)" | |
| 757 | by auto | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 758 | with fin show "(\<integral> x. ?f x \<partial>(count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M))) = | 
| 47694 | 759 | (\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. Pxy (x, y) * log b (Pxy (x, y) / (Px x * Py y)))" | 
| 760 | by (auto simp add: pair_measure_count_space lebesgue_integral_count_space_finite setsum_cases split_beta' | |
| 761 | intro!: setsum_cong) | |
| 762 | qed | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 763 | |
| 47694 | 764 | lemma (in information_space) | 
| 765 | fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" | |
| 766 | assumes Px: "simple_distributed M X Px" and Py: "simple_distributed M Y Py" | |
| 767 | assumes Pxy: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy" | |
| 768 | assumes ae: "\<forall>x\<in>space M. Pxy (X x, Y x) = Px (X x) * Py (Y x)" | |
| 769 | shows mutual_information_eq_0_simple: "\<I>(X ; Y) = 0" | |
| 770 | proof (subst mutual_information_simple_distributed[OF Px Py Pxy]) | |
| 771 | have "(\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. Pxy (x, y) * log b (Pxy (x, y) / (Px x * Py y))) = | |
| 772 | (\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. 0)" | |
| 773 | by (intro setsum_cong) (auto simp: ae) | |
| 774 | then show "(\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. | |
| 775 | Pxy (x, y) * log b (Pxy (x, y) / (Px x * Py y))) = 0" by simp | |
| 776 | qed | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 777 | |
| 39097 | 778 | subsection {* Entropy *}
 | 
| 779 | ||
| 47694 | 780 | definition (in prob_space) entropy :: "real \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> real" where
 | 
| 781 | "entropy b S X = - KL_divergence b S (distr M S X)" | |
| 782 | ||
| 40859 | 783 | abbreviation (in information_space) | 
| 784 |   entropy_Pow ("\<H>'(_')") where
 | |
| 47694 | 785 | "\<H>(X) \<equiv> entropy b (count_space (X`space M)) X" | 
| 41981 
cdf7693bbe08
reworked Probability theory: measures are not type restricted to positive extended reals
 hoelzl parents: 
41833diff
changeset | 786 | |
| 49791 | 787 | lemma (in prob_space) distributed_RN_deriv: | 
| 788 | assumes X: "distributed M S X Px" | |
| 789 | shows "AE x in S. RN_deriv S (density S Px) x = Px x" | |
| 790 | proof - | |
| 791 | note D = distributed_measurable[OF X] distributed_borel_measurable[OF X] distributed_AE[OF X] | |
| 792 | interpret X: prob_space "distr M S X" | |
| 793 | using D(1) by (rule prob_space_distr) | |
| 794 | ||
| 795 | have sf: "sigma_finite_measure (distr M S X)" by default | |
| 796 | show ?thesis | |
| 797 | using D | |
| 798 | apply (subst eq_commute) | |
| 799 | apply (intro RN_deriv_unique_sigma_finite) | |
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 800 | apply (auto simp: distributed_distr_eq_density[symmetric, OF X] sf measure_nonneg) | 
| 49791 | 801 | done | 
| 802 | qed | |
| 803 | ||
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 804 | lemma (in information_space) | 
| 47694 | 805 | fixes X :: "'a \<Rightarrow> 'b" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 806 | assumes X[measurable]: "distributed M MX X f" | 
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 807 | shows entropy_distr: "entropy b MX X = - (\<integral>x. f x * log b (f x) \<partial>MX)" (is ?eq) | 
| 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 808 | proof - | 
| 49785 | 809 | note D = distributed_measurable[OF X] distributed_borel_measurable[OF X] distributed_AE[OF X] | 
| 49791 | 810 | note ae = distributed_RN_deriv[OF X] | 
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 811 | |
| 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 812 | have ae_eq: "AE x in distr M MX X. log b (real (RN_deriv MX (distr M MX X) x)) = | 
| 49785 | 813 | log b (f x)" | 
| 814 | unfolding distributed_distr_eq_density[OF X] | |
| 815 | apply (subst AE_density) | |
| 816 | using D apply simp | |
| 817 | using ae apply eventually_elim | |
| 818 | apply auto | |
| 819 | done | |
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 820 | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 821 | have int_eq: "(\<integral> x. f x * log b (f x) \<partial>MX) = (\<integral> x. log b (f x) \<partial>distr M MX X)" | 
| 49785 | 822 | unfolding distributed_distr_eq_density[OF X] | 
| 823 | using D | |
| 824 | by (subst integral_density) | |
| 825 | (auto simp: borel_measurable_ereal_iff) | |
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 826 | |
| 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 827 | show ?eq | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 828 | unfolding entropy_def KL_divergence_def entropy_density_def comp_def int_eq neg_equal_iff_equal | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 829 | using ae_eq by (intro integral_cong_AE) auto | 
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 830 | qed | 
| 49785 | 831 | |
| 49786 | 832 | lemma (in prob_space) distributed_imp_emeasure_nonzero: | 
| 833 | assumes X: "distributed M MX X Px" | |
| 834 |   shows "emeasure MX {x \<in> space MX. Px x \<noteq> 0} \<noteq> 0"
 | |
| 835 | proof | |
| 836 | note Px = distributed_borel_measurable[OF X] distributed_AE[OF X] | |
| 837 | interpret X: prob_space "distr M MX X" | |
| 838 | using distributed_measurable[OF X] by (rule prob_space_distr) | |
| 839 | ||
| 840 |   assume "emeasure MX {x \<in> space MX. Px x \<noteq> 0} = 0"
 | |
| 841 | with Px have "AE x in MX. Px x = 0" | |
| 842 | by (intro AE_I[OF subset_refl]) (auto simp: borel_measurable_ereal_iff) | |
| 843 | moreover | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 844 | from X.emeasure_space_1 have "(\<integral>\<^sup>+x. Px x \<partial>MX) = 1" | 
| 49786 | 845 | unfolding distributed_distr_eq_density[OF X] using Px | 
| 846 | by (subst (asm) emeasure_density) | |
| 56996 | 847 | (auto simp: borel_measurable_ereal_iff intro!: integral_cong cong: nn_integral_cong) | 
| 49786 | 848 | ultimately show False | 
| 56996 | 849 | by (simp add: nn_integral_cong_AE) | 
| 49786 | 850 | qed | 
| 851 | ||
| 852 | lemma (in information_space) entropy_le: | |
| 853 | fixes Px :: "'b \<Rightarrow> real" and MX :: "'b measure" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 854 | assumes X[measurable]: "distributed M MX X Px" | 
| 49786 | 855 |   and fin: "emeasure MX {x \<in> space MX. Px x \<noteq> 0} \<noteq> \<infinity>"
 | 
| 856 | and int: "integrable MX (\<lambda>x. - Px x * log b (Px x))" | |
| 857 |   shows "entropy b MX X \<le> log b (measure MX {x \<in> space MX. Px x \<noteq> 0})"
 | |
| 858 | proof - | |
| 859 | note Px = distributed_borel_measurable[OF X] distributed_AE[OF X] | |
| 860 | interpret X: prob_space "distr M MX X" | |
| 861 | using distributed_measurable[OF X] by (rule prob_space_distr) | |
| 862 | ||
| 863 |   have " - log b (measure MX {x \<in> space MX. Px x \<noteq> 0}) = 
 | |
| 864 |     - log b (\<integral> x. indicator {x \<in> space MX. Px x \<noteq> 0} x \<partial>MX)"
 | |
| 865 | using Px fin | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 866 | by (subst integral_real_indicator) (auto simp: measure_def borel_measurable_ereal_iff) | 
| 49786 | 867 |   also have "- log b (\<integral> x. indicator {x \<in> space MX. Px x \<noteq> 0} x \<partial>MX) = - log b (\<integral> x. 1 / Px x \<partial>distr M MX X)"
 | 
| 868 | unfolding distributed_distr_eq_density[OF X] using Px | |
| 869 | apply (intro arg_cong[where f="log b"] arg_cong[where f=uminus]) | |
| 870 | by (subst integral_density) (auto simp: borel_measurable_ereal_iff intro!: integral_cong) | |
| 871 | also have "\<dots> \<le> (\<integral> x. - log b (1 / Px x) \<partial>distr M MX X)" | |
| 872 |   proof (rule X.jensens_inequality[of "\<lambda>x. 1 / Px x" "{0<..}" 0 1 "\<lambda>x. - log b x"])
 | |
| 873 |     show "AE x in distr M MX X. 1 / Px x \<in> {0<..}"
 | |
| 874 | unfolding distributed_distr_eq_density[OF X] | |
| 875 | using Px by (auto simp: AE_density) | |
| 876 |     have [simp]: "\<And>x. x \<in> space MX \<Longrightarrow> ereal (if Px x = 0 then 0 else 1) = indicator {x \<in> space MX. Px x \<noteq> 0} x"
 | |
| 877 | by (auto simp: one_ereal_def) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 878 | have "(\<integral>\<^sup>+ x. max 0 (ereal (- (if Px x = 0 then 0 else 1))) \<partial>MX) = (\<integral>\<^sup>+ x. 0 \<partial>MX)" | 
| 56996 | 879 | by (intro nn_integral_cong) (auto split: split_max) | 
| 49786 | 880 | then show "integrable (distr M MX X) (\<lambda>x. 1 / Px x)" | 
| 881 | unfolding distributed_distr_eq_density[OF X] using Px | |
| 56996 | 882 | by (auto simp: nn_integral_density real_integrable_def borel_measurable_ereal_iff fin nn_integral_max_0 | 
| 883 | cong: nn_integral_cong) | |
| 49786 | 884 | have "integrable MX (\<lambda>x. Px x * log b (1 / Px x)) = | 
| 885 | integrable MX (\<lambda>x. - Px x * log b (Px x))" | |
| 886 | using Px | |
| 887 | by (intro integrable_cong_AE) | |
| 888 | (auto simp: borel_measurable_ereal_iff log_divide_eq | |
| 889 | intro!: measurable_If) | |
| 890 | then show "integrable (distr M MX X) (\<lambda>x. - log b (1 / Px x))" | |
| 891 | unfolding distributed_distr_eq_density[OF X] | |
| 892 | using Px int | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 893 | by (subst integrable_real_density) (auto simp: borel_measurable_ereal_iff) | 
| 49786 | 894 | qed (auto simp: minus_log_convex[OF b_gt_1]) | 
| 895 | also have "\<dots> = (\<integral> x. log b (Px x) \<partial>distr M MX X)" | |
| 896 | unfolding distributed_distr_eq_density[OF X] using Px | |
| 897 | by (intro integral_cong_AE) (auto simp: AE_density log_divide_eq) | |
| 898 | also have "\<dots> = - entropy b MX X" | |
| 899 | unfolding distributed_distr_eq_density[OF X] using Px | |
| 900 | by (subst entropy_distr[OF X]) (auto simp: borel_measurable_ereal_iff integral_density) | |
| 901 | finally show ?thesis | |
| 902 | by simp | |
| 903 | qed | |
| 904 | ||
| 905 | lemma (in information_space) entropy_le_space: | |
| 906 | fixes Px :: "'b \<Rightarrow> real" and MX :: "'b measure" | |
| 907 | assumes X: "distributed M MX X Px" | |
| 908 | and fin: "finite_measure MX" | |
| 909 | and int: "integrable MX (\<lambda>x. - Px x * log b (Px x))" | |
| 910 | shows "entropy b MX X \<le> log b (measure MX (space MX))" | |
| 911 | proof - | |
| 912 | note Px = distributed_borel_measurable[OF X] distributed_AE[OF X] | |
| 913 | interpret finite_measure MX by fact | |
| 914 |   have "entropy b MX X \<le> log b (measure MX {x \<in> space MX. Px x \<noteq> 0})"
 | |
| 915 | using int X by (intro entropy_le) auto | |
| 916 | also have "\<dots> \<le> log b (measure MX (space MX))" | |
| 917 | using Px distributed_imp_emeasure_nonzero[OF X] | |
| 918 | by (intro log_le) | |
| 919 | (auto intro!: borel_measurable_ereal_iff finite_measure_mono b_gt_1 | |
| 920 | less_le[THEN iffD2] measure_nonneg simp: emeasure_eq_measure) | |
| 921 | finally show ?thesis . | |
| 922 | qed | |
| 923 | ||
| 47694 | 924 | lemma (in information_space) entropy_uniform: | 
| 49785 | 925 | assumes X: "distributed M MX X (\<lambda>x. indicator A x / measure MX A)" (is "distributed _ _ _ ?f") | 
| 47694 | 926 | shows "entropy b MX X = log b (measure MX A)" | 
| 49785 | 927 | proof (subst entropy_distr[OF X]) | 
| 928 | have [simp]: "emeasure MX A \<noteq> \<infinity>" | |
| 929 | using uniform_distributed_params[OF X] by (auto simp add: measure_def) | |
| 930 | have eq: "(\<integral> x. indicator A x / measure MX A * log b (indicator A x / measure MX A) \<partial>MX) = | |
| 931 | (\<integral> x. (- log b (measure MX A) / measure MX A) * indicator A x \<partial>MX)" | |
| 932 | using measure_nonneg[of MX A] uniform_distributed_params[OF X] | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 933 | by (intro integral_cong) (auto split: split_indicator simp: log_divide_eq) | 
| 49785 | 934 | show "- (\<integral> x. indicator A x / measure MX A * log b (indicator A x / measure MX A) \<partial>MX) = | 
| 935 | log b (measure MX A)" | |
| 936 | unfolding eq using uniform_distributed_params[OF X] | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 937 | by (subst integral_mult_right) (auto simp: measure_def) | 
| 49785 | 938 | qed | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 939 | |
| 47694 | 940 | lemma (in information_space) entropy_simple_distributed: | 
| 49786 | 941 | "simple_distributed M X f \<Longrightarrow> \<H>(X) = - (\<Sum>x\<in>X`space M. f x * log b (f x))" | 
| 942 | by (subst entropy_distr[OF simple_distributed]) | |
| 943 | (auto simp add: lebesgue_integral_count_space_finite) | |
| 39097 | 944 | |
| 40859 | 945 | lemma (in information_space) entropy_le_card_not_0: | 
| 47694 | 946 | assumes X: "simple_distributed M X f" | 
| 947 |   shows "\<H>(X) \<le> log b (card (X ` space M \<inter> {x. f x \<noteq> 0}))"
 | |
| 39097 | 948 | proof - | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 949 | let ?X = "count_space (X`space M)" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 950 |   have "\<H>(X) \<le> log b (measure ?X {x \<in> space ?X. f x \<noteq> 0})"
 | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 951 | by (rule entropy_le[OF simple_distributed[OF X]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 952 | (simp_all add: simple_distributed_finite[OF X] subset_eq integrable_count_space emeasure_count_space) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 953 |   also have "measure ?X {x \<in> space ?X. f x \<noteq> 0} = card (X ` space M \<inter> {x. f x \<noteq> 0})"
 | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 954 | by (simp_all add: simple_distributed_finite[OF X] subset_eq emeasure_count_space measure_def Int_def) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 955 | finally show ?thesis . | 
| 39097 | 956 | qed | 
| 957 | ||
| 40859 | 958 | lemma (in information_space) entropy_le_card: | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 959 | assumes X: "simple_distributed M X f" | 
| 40859 | 960 | shows "\<H>(X) \<le> log b (real (card (X ` space M)))" | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 961 | proof - | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 962 | let ?X = "count_space (X`space M)" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 963 | have "\<H>(X) \<le> log b (measure ?X (space ?X))" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 964 | by (rule entropy_le_space[OF simple_distributed[OF X]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 965 | (simp_all add: simple_distributed_finite[OF X] subset_eq integrable_count_space emeasure_count_space finite_measure_count_space) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 966 | also have "measure ?X (space ?X) = card (X ` space M)" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 967 | by (simp_all add: simple_distributed_finite[OF X] subset_eq emeasure_count_space measure_def) | 
| 39097 | 968 | finally show ?thesis . | 
| 969 | qed | |
| 970 | ||
| 971 | subsection {* Conditional Mutual Information *}
 | |
| 972 | ||
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 973 | definition (in prob_space) | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 974 | "conditional_mutual_information b MX MY MZ X Y Z \<equiv> | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 975 | mutual_information b MX (MY \<Otimes>\<^sub>M MZ) X (\<lambda>x. (Y x, Z x)) - | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 976 | mutual_information b MX MZ X Z" | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 977 | |
| 40859 | 978 | abbreviation (in information_space) | 
| 979 |   conditional_mutual_information_Pow ("\<I>'( _ ; _ | _ ')") where
 | |
| 36624 | 980 | "\<I>(X ; Y | Z) \<equiv> conditional_mutual_information b | 
| 47694 | 981 | (count_space (X ` space M)) (count_space (Y ` space M)) (count_space (Z ` space M)) X Y Z" | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 982 | |
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 983 | lemma (in information_space) | 
| 47694 | 984 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" and P: "sigma_finite_measure P" | 
| 50003 | 985 | assumes Px[measurable]: "distributed M S X Px" | 
| 986 | assumes Pz[measurable]: "distributed M P Z Pz" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 987 | assumes Pyz[measurable]: "distributed M (T \<Otimes>\<^sub>M P) (\<lambda>x. (Y x, Z x)) Pyz" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 988 | assumes Pxz[measurable]: "distributed M (S \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Z x)) Pxz" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 989 | assumes Pxyz[measurable]: "distributed M (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Y x, Z x)) Pxyz" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 990 | assumes I1: "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Px x * Pyz (y, z))))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 991 | assumes I2: "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxz (x, z) / (Px x * Pz z)))" | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 992 | shows conditional_mutual_information_generic_eq: "conditional_mutual_information b S T P X Y Z | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 993 | = (\<integral>(x, y, z). Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Pxz (x, z) * (Pyz (y,z) / Pz z))) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" (is "?eq") | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 994 | and conditional_mutual_information_generic_nonneg: "0 \<le> conditional_mutual_information b S T P X Y Z" (is "?nonneg") | 
| 40859 | 995 | proof - | 
| 47694 | 996 | interpret S: sigma_finite_measure S by fact | 
| 997 | interpret T: sigma_finite_measure T by fact | |
| 998 | interpret P: sigma_finite_measure P by fact | |
| 999 | interpret TP: pair_sigma_finite T P .. | |
| 1000 | interpret SP: pair_sigma_finite S P .. | |
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1001 | interpret ST: pair_sigma_finite S T .. | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1002 | interpret SPT: pair_sigma_finite "S \<Otimes>\<^sub>M P" T .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1003 | interpret STP: pair_sigma_finite S "T \<Otimes>\<^sub>M P" .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1004 | interpret TPS: pair_sigma_finite "T \<Otimes>\<^sub>M P" S .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1005 | have TP: "sigma_finite_measure (T \<Otimes>\<^sub>M P)" .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1006 | have SP: "sigma_finite_measure (S \<Otimes>\<^sub>M P)" .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1007 | have YZ: "random_variable (T \<Otimes>\<^sub>M P) (\<lambda>x. (Y x, Z x))" | 
| 47694 | 1008 | using Pyz by (simp add: distributed_measurable) | 
| 1009 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1010 | from Pxz Pxyz have distr_eq: "distr M (S \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Z x)) = | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1011 | distr (distr M (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Y x, Z x))) (S \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). (x, z))" | 
| 50003 | 1012 | by (simp add: comp_def distr_distr) | 
| 40859 | 1013 | |
| 47694 | 1014 | have "mutual_information b S P X Z = | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1015 | (\<integral>x. Pxz x * log b (Pxz x / (Px (fst x) * Pz (snd x))) \<partial>(S \<Otimes>\<^sub>M P))" | 
| 47694 | 1016 | by (rule mutual_information_distr[OF S P Px Pz Pxz]) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1017 | also have "\<dots> = (\<integral>(x,y,z). Pxyz (x,y,z) * log b (Pxz (x,z) / (Px x * Pz z)) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" | 
| 47694 | 1018 | using b_gt_1 Pxz Px Pz | 
| 50003 | 1019 | by (subst distributed_transform_integral[OF Pxyz Pxz, where T="\<lambda>(x, y, z). (x, z)"]) (auto simp: split_beta') | 
| 47694 | 1020 | finally have mi_eq: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1021 | "mutual_information b S P X Z = (\<integral>(x,y,z). Pxyz (x,y,z) * log b (Pxz (x,z) / (Px x * Pz z)) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" . | 
| 47694 | 1022 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1023 | have ae1: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Px (fst x) = 0 \<longrightarrow> Pxyz x = 0" | 
| 47694 | 1024 | by (intro subdensity_real[of fst, OF _ Pxyz Px]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1025 | moreover have ae2: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pz (snd (snd x)) = 0 \<longrightarrow> Pxyz x = 0" | 
| 50003 | 1026 | by (intro subdensity_real[of "\<lambda>x. snd (snd x)", OF _ Pxyz Pz]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1027 | moreover have ae3: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pxz (fst x, snd (snd x)) = 0 \<longrightarrow> Pxyz x = 0" | 
| 50003 | 1028 | by (intro subdensity_real[of "\<lambda>x. (fst x, snd (snd x))", OF _ Pxyz Pxz]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1029 | moreover have ae4: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pyz (snd x) = 0 \<longrightarrow> Pxyz x = 0" | 
| 50003 | 1030 | by (intro subdensity_real[of snd, OF _ Pxyz Pyz]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1031 | moreover have ae5: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Px (fst x)" | 
| 50003 | 1032 | using Px by (intro STP.AE_pair_measure) (auto simp: comp_def dest: distributed_real_AE) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1033 | moreover have ae6: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pyz (snd x)" | 
| 50003 | 1034 | using Pyz by (intro STP.AE_pair_measure) (auto simp: comp_def dest: distributed_real_AE) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1035 | moreover have ae7: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd (snd x))" | 
| 50003 | 1036 | using Pz Pz[THEN distributed_real_measurable] | 
| 1037 | by (auto intro!: TP.AE_pair_measure STP.AE_pair_measure AE_I2[of S] dest: distributed_real_AE) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1038 | moreover have ae8: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pxz (fst x, snd (snd x))" | 
| 47694 | 1039 | using Pxz[THEN distributed_real_AE, THEN SP.AE_pair] | 
| 50003 | 1040 | by (auto intro!: TP.AE_pair_measure STP.AE_pair_measure) | 
| 47694 | 1041 | moreover note Pxyz[THEN distributed_real_AE] | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1042 | ultimately have ae: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. | 
| 47694 | 1043 | Pxyz x * log b (Pxyz x / (Px (fst x) * Pyz (snd x))) - | 
| 1044 | Pxyz x * log b (Pxz (fst x, snd (snd x)) / (Px (fst x) * Pz (snd (snd x)))) = | |
| 1045 | Pxyz x * log b (Pxyz x * Pz (snd (snd x)) / (Pxz (fst x, snd (snd x)) * Pyz (snd x))) " | |
| 1046 | proof eventually_elim | |
| 1047 | case (goal1 x) | |
| 1048 | show ?case | |
| 40859 | 1049 | proof cases | 
| 47694 | 1050 | assume "Pxyz x \<noteq> 0" | 
| 1051 | with goal1 have "0 < Px (fst x)" "0 < Pz (snd (snd x))" "0 < Pxz (fst x, snd (snd x))" "0 < Pyz (snd x)" "0 < Pxyz x" | |
| 1052 | by auto | |
| 1053 | then show ?thesis | |
| 56544 | 1054 | using b_gt_1 by (simp add: log_simps less_imp_le field_simps) | 
| 40859 | 1055 | qed simp | 
| 1056 | qed | |
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1057 | with I1 I2 show ?eq | 
| 40859 | 1058 | unfolding conditional_mutual_information_def | 
| 47694 | 1059 | apply (subst mi_eq) | 
| 1060 | apply (subst mutual_information_distr[OF S TP Px Pyz Pxyz]) | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1061 | apply (subst integral_diff[symmetric]) | 
| 47694 | 1062 | apply (auto intro!: integral_cong_AE simp: split_beta' simp del: integral_diff) | 
| 1063 | done | |
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1064 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1065 | let ?P = "density (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) Pxyz" | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1066 | interpret P: prob_space ?P | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1067 | unfolding distributed_distr_eq_density[OF Pxyz, symmetric] | 
| 50003 | 1068 | by (rule prob_space_distr) simp | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1069 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1070 | let ?Q = "density (T \<Otimes>\<^sub>M P) Pyz" | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1071 | interpret Q: prob_space ?Q | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1072 | unfolding distributed_distr_eq_density[OF Pyz, symmetric] | 
| 50003 | 1073 | by (rule prob_space_distr) simp | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1074 | |
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1075 | let ?f = "\<lambda>(x, y, z). Pxz (x, z) * (Pyz (y, z) / Pz z) / Pxyz (x, y, z)" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1076 | |
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1077 | from subdensity_real[of snd, OF _ Pyz Pz] | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1078 | have aeX1: "AE x in T \<Otimes>\<^sub>M P. Pz (snd x) = 0 \<longrightarrow> Pyz x = 0" by (auto simp: comp_def) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1079 | have aeX2: "AE x in T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd x)" | 
| 50003 | 1080 | using Pz by (intro TP.AE_pair_measure) (auto simp: comp_def dest: distributed_real_AE) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1081 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1082 | have aeX3: "AE y in T \<Otimes>\<^sub>M P. (\<integral>\<^sup>+ x. ereal (Pxz (x, snd y)) \<partial>S) = ereal (Pz (snd y))" | 
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 1083 | using Pz distributed_marginal_eq_joint2[OF P S Pz Pxz] | 
| 50003 | 1084 | by (intro TP.AE_pair_measure) (auto dest: distributed_real_AE) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1085 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1086 | have "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<le> (\<integral>\<^sup>+ (x, y, z). Pxz (x, z) * (Pyz (y, z) / Pz z) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" | 
| 56996 | 1087 | apply (subst nn_integral_density) | 
| 50003 | 1088 | apply simp | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1089 | apply (rule distributed_AE[OF Pxyz]) | 
| 50003 | 1090 | apply auto [] | 
| 56996 | 1091 | apply (rule nn_integral_mono_AE) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1092 | using ae5 ae6 ae7 ae8 | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1093 | apply eventually_elim | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 1094 | apply auto | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1095 | done | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1096 | also have "\<dots> = (\<integral>\<^sup>+(y, z). \<integral>\<^sup>+ x. ereal (Pxz (x, z)) * ereal (Pyz (y, z) / Pz z) \<partial>S \<partial>T \<Otimes>\<^sub>M P)" | 
| 56996 | 1097 | by (subst STP.nn_integral_snd[symmetric]) (auto simp add: split_beta') | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1098 | also have "\<dots> = (\<integral>\<^sup>+x. ereal (Pyz x) * 1 \<partial>T \<Otimes>\<^sub>M P)" | 
| 56996 | 1099 | apply (rule nn_integral_cong_AE) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1100 | using aeX1 aeX2 aeX3 distributed_AE[OF Pyz] AE_space | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1101 | apply eventually_elim | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1102 | proof (case_tac x, simp del: times_ereal.simps add: space_pair_measure) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1103 | fix a b assume "Pz b = 0 \<longrightarrow> Pyz (a, b) = 0" "0 \<le> Pz b" "a \<in> space T \<and> b \<in> space P" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1104 | "(\<integral>\<^sup>+ x. ereal (Pxz (x, b)) \<partial>S) = ereal (Pz b)" "0 \<le> Pyz (a, b)" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1105 | then show "(\<integral>\<^sup>+ x. ereal (Pxz (x, b)) * ereal (Pyz (a, b) / Pz b) \<partial>S) = ereal (Pyz (a, b))" | 
| 56996 | 1106 | by (subst nn_integral_multc) | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 1107 | (auto split: prod.split) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1108 | qed | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1109 | also have "\<dots> = 1" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1110 | using Q.emeasure_space_1 distributed_AE[OF Pyz] distributed_distr_eq_density[OF Pyz] | 
| 56996 | 1111 | by (subst nn_integral_density[symmetric]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1112 | finally have le1: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<le> 1" . | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1113 | also have "\<dots> < \<infinity>" by simp | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1114 | finally have fin: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<noteq> \<infinity>" by simp | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1115 | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1116 | have pos: "(\<integral>\<^sup>+x. ?f x \<partial>?P) \<noteq> 0" | 
| 56996 | 1117 | apply (subst nn_integral_density) | 
| 50003 | 1118 | apply simp | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1119 | apply (rule distributed_AE[OF Pxyz]) | 
| 50003 | 1120 | apply auto [] | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1121 | apply (simp add: split_beta') | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1122 | proof | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1123 | let ?g = "\<lambda>x. ereal (if Pxyz x = 0 then 0 else Pxz (fst x, snd (snd x)) * Pyz (snd x) / Pz (snd (snd x)))" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1124 | assume "(\<integral>\<^sup>+x. ?g x \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P)) = 0" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1125 | then have "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. ?g x \<le> 0" | 
| 56996 | 1126 | by (intro nn_integral_0_iff_AE[THEN iffD1]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1127 | then have "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pxyz x = 0" | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1128 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1129 | by eventually_elim (auto split: split_if_asm simp: mult_le_0_iff divide_le_0_iff) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1130 | then have "(\<integral>\<^sup>+ x. ereal (Pxyz x) \<partial>S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) = 0" | 
| 56996 | 1131 | by (subst nn_integral_cong_AE[of _ "\<lambda>x. 0"]) auto | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1132 | with P.emeasure_space_1 show False | 
| 56996 | 1133 | by (subst (asm) emeasure_density) (auto cong: nn_integral_cong) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1134 | qed | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1135 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1136 | have neg: "(\<integral>\<^sup>+ x. - ?f x \<partial>?P) = 0" | 
| 56996 | 1137 | apply (rule nn_integral_0_iff_AE[THEN iffD2]) | 
| 50003 | 1138 | apply simp | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1139 | apply (subst AE_density) | 
| 50003 | 1140 | apply simp | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1141 | using ae5 ae6 ae7 ae8 | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1142 | apply eventually_elim | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 1143 | apply auto | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1144 | done | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1145 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1146 | have I3: "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Pxz (x, z) * (Pyz (y,z) / Pz z))))" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1147 | apply (rule integrable_cong_AE[THEN iffD1, OF _ _ _ integrable_diff[OF I1 I2]]) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1148 | using ae | 
| 50003 | 1149 | apply (auto simp: split_beta') | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1150 | done | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1151 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1152 | have "- log b 1 \<le> - log b (integral\<^sup>L ?P ?f)" | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1153 | proof (intro le_imp_neg_le log_le[OF b_gt_1]) | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1154 | have If: "integrable ?P ?f" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1155 | unfolding real_integrable_def | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1156 | proof (intro conjI) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1157 | from neg show "(\<integral>\<^sup>+ x. - ?f x \<partial>?P) \<noteq> \<infinity>" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1158 | by simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1159 | from fin show "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<noteq> \<infinity>" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1160 | by simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1161 | qed simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1162 | then have "(\<integral>\<^sup>+ x. ?f x \<partial>?P) = (\<integral>x. ?f x \<partial>?P)" | 
| 56996 | 1163 | apply (rule nn_integral_eq_integral) | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1164 | apply (subst AE_density) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1165 | apply simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1166 | using ae5 ae6 ae7 ae8 | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1167 | apply eventually_elim | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1168 | apply auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1169 | done | 
| 56996 | 1170 | with nn_integral_nonneg[of ?P ?f] pos le1 | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1171 | show "0 < (\<integral>x. ?f x \<partial>?P)" "(\<integral>x. ?f x \<partial>?P) \<le> 1" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1172 | by (simp_all add: one_ereal_def) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1173 | qed | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1174 | also have "- log b (integral\<^sup>L ?P ?f) \<le> (\<integral> x. - log b (?f x) \<partial>?P)" | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1175 |   proof (rule P.jensens_inequality[where a=0 and b=1 and I="{0<..}"])
 | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1176 |     show "AE x in ?P. ?f x \<in> {0<..}"
 | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1177 | unfolding AE_density[OF distributed_borel_measurable[OF Pxyz]] | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1178 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | 
| 56544 | 1179 | by eventually_elim (auto) | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1180 | show "integrable ?P ?f" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1181 | unfolding real_integrable_def | 
| 50003 | 1182 | using fin neg by (auto simp: split_beta') | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1183 | show "integrable ?P (\<lambda>x. - log b (?f x))" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1184 | apply (subst integrable_real_density) | 
| 50003 | 1185 | apply simp | 
| 1186 | apply (auto intro!: distributed_real_AE[OF Pxyz]) [] | |
| 1187 | apply simp | |
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1188 | apply (rule integrable_cong_AE[THEN iffD1, OF _ _ _ I3]) | 
| 50003 | 1189 | apply simp | 
| 1190 | apply simp | |
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1191 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1192 | apply eventually_elim | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1193 | apply (auto simp: log_divide_eq log_mult_eq zero_le_mult_iff zero_less_mult_iff zero_less_divide_iff field_simps) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1194 | done | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1195 | qed (auto simp: b_gt_1 minus_log_convex) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1196 | also have "\<dots> = conditional_mutual_information b S T P X Y Z" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1197 | unfolding `?eq` | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1198 | apply (subst integral_real_density) | 
| 50003 | 1199 | apply simp | 
| 1200 | apply (auto intro!: distributed_real_AE[OF Pxyz]) [] | |
| 1201 | apply simp | |
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1202 | apply (intro integral_cong_AE) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1203 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1204 | apply (auto simp: log_divide_eq zero_less_mult_iff zero_less_divide_iff field_simps) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1205 | done | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1206 | finally show ?nonneg | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1207 | by simp | 
| 40859 | 1208 | qed | 
| 1209 | ||
| 49803 | 1210 | lemma (in information_space) | 
| 1211 | fixes Px :: "_ \<Rightarrow> real" | |
| 1212 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" and P: "sigma_finite_measure P" | |
| 1213 | assumes Fx: "finite_entropy S X Px" | |
| 1214 | assumes Fz: "finite_entropy P Z Pz" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1215 | assumes Fyz: "finite_entropy (T \<Otimes>\<^sub>M P) (\<lambda>x. (Y x, Z x)) Pyz" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1216 | assumes Fxz: "finite_entropy (S \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Z x)) Pxz" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1217 | assumes Fxyz: "finite_entropy (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Y x, Z x)) Pxyz" | 
| 49803 | 1218 | shows conditional_mutual_information_generic_eq': "conditional_mutual_information b S T P X Y Z | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1219 | = (\<integral>(x, y, z). Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Pxz (x, z) * (Pyz (y,z) / Pz z))) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" (is "?eq") | 
| 49803 | 1220 | and conditional_mutual_information_generic_nonneg': "0 \<le> conditional_mutual_information b S T P X Y Z" (is "?nonneg") | 
| 1221 | proof - | |
| 50003 | 1222 | note Px = Fx[THEN finite_entropy_distributed, measurable] | 
| 1223 | note Pz = Fz[THEN finite_entropy_distributed, measurable] | |
| 1224 | note Pyz = Fyz[THEN finite_entropy_distributed, measurable] | |
| 1225 | note Pxz = Fxz[THEN finite_entropy_distributed, measurable] | |
| 1226 | note Pxyz = Fxyz[THEN finite_entropy_distributed, measurable] | |
| 49803 | 1227 | |
| 1228 | interpret S: sigma_finite_measure S by fact | |
| 1229 | interpret T: sigma_finite_measure T by fact | |
| 1230 | interpret P: sigma_finite_measure P by fact | |
| 1231 | interpret TP: pair_sigma_finite T P .. | |
| 1232 | interpret SP: pair_sigma_finite S P .. | |
| 1233 | interpret ST: pair_sigma_finite S T .. | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1234 | interpret SPT: pair_sigma_finite "S \<Otimes>\<^sub>M P" T .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1235 | interpret STP: pair_sigma_finite S "T \<Otimes>\<^sub>M P" .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1236 | interpret TPS: pair_sigma_finite "T \<Otimes>\<^sub>M P" S .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1237 | have TP: "sigma_finite_measure (T \<Otimes>\<^sub>M P)" .. | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1238 | have SP: "sigma_finite_measure (S \<Otimes>\<^sub>M P)" .. | 
| 49803 | 1239 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1240 | from Pxz Pxyz have distr_eq: "distr M (S \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Z x)) = | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1241 | distr (distr M (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>x. (X x, Y x, Z x))) (S \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). (x, z))" | 
| 50003 | 1242 | by (simp add: distr_distr comp_def) | 
| 49803 | 1243 | |
| 1244 | have "mutual_information b S P X Z = | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1245 | (\<integral>x. Pxz x * log b (Pxz x / (Px (fst x) * Pz (snd x))) \<partial>(S \<Otimes>\<^sub>M P))" | 
| 49803 | 1246 | by (rule mutual_information_distr[OF S P Px Pz Pxz]) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1247 | also have "\<dots> = (\<integral>(x,y,z). Pxyz (x,y,z) * log b (Pxz (x,z) / (Px x * Pz z)) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" | 
| 49803 | 1248 | using b_gt_1 Pxz Px Pz | 
| 1249 | by (subst distributed_transform_integral[OF Pxyz Pxz, where T="\<lambda>(x, y, z). (x, z)"]) | |
| 50003 | 1250 | (auto simp: split_beta') | 
| 49803 | 1251 | finally have mi_eq: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1252 | "mutual_information b S P X Z = (\<integral>(x,y,z). Pxyz (x,y,z) * log b (Pxz (x,z) / (Px x * Pz z)) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" . | 
| 49803 | 1253 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1254 | have ae1: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Px (fst x) = 0 \<longrightarrow> Pxyz x = 0" | 
| 49803 | 1255 | by (intro subdensity_real[of fst, OF _ Pxyz Px]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1256 | moreover have ae2: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pz (snd (snd x)) = 0 \<longrightarrow> Pxyz x = 0" | 
| 50003 | 1257 | by (intro subdensity_real[of "\<lambda>x. snd (snd x)", OF _ Pxyz Pz]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1258 | moreover have ae3: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pxz (fst x, snd (snd x)) = 0 \<longrightarrow> Pxyz x = 0" | 
| 50003 | 1259 | by (intro subdensity_real[of "\<lambda>x. (fst x, snd (snd x))", OF _ Pxyz Pxz]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1260 | moreover have ae4: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pyz (snd x) = 0 \<longrightarrow> Pxyz x = 0" | 
| 50003 | 1261 | by (intro subdensity_real[of snd, OF _ Pxyz Pyz]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1262 | moreover have ae5: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Px (fst x)" | 
| 50003 | 1263 | using Px by (intro STP.AE_pair_measure) (auto dest: distributed_real_AE) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1264 | moreover have ae6: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pyz (snd x)" | 
| 50003 | 1265 | using Pyz by (intro STP.AE_pair_measure) (auto dest: distributed_real_AE) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1266 | moreover have ae7: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd (snd x))" | 
| 50003 | 1267 | using Pz Pz[THEN distributed_real_measurable] by (auto intro!: TP.AE_pair_measure STP.AE_pair_measure AE_I2[of S] dest: distributed_real_AE) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1268 | moreover have ae8: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pxz (fst x, snd (snd x))" | 
| 49803 | 1269 | using Pxz[THEN distributed_real_AE, THEN SP.AE_pair] | 
| 1270 | by (auto intro!: TP.AE_pair_measure STP.AE_pair_measure simp: comp_def) | |
| 1271 | moreover note ae9 = Pxyz[THEN distributed_real_AE] | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1272 | ultimately have ae: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. | 
| 49803 | 1273 | Pxyz x * log b (Pxyz x / (Px (fst x) * Pyz (snd x))) - | 
| 1274 | Pxyz x * log b (Pxz (fst x, snd (snd x)) / (Px (fst x) * Pz (snd (snd x)))) = | |
| 1275 | Pxyz x * log b (Pxyz x * Pz (snd (snd x)) / (Pxz (fst x, snd (snd x)) * Pyz (snd x))) " | |
| 1276 | proof eventually_elim | |
| 1277 | case (goal1 x) | |
| 1278 | show ?case | |
| 1279 | proof cases | |
| 1280 | assume "Pxyz x \<noteq> 0" | |
| 1281 | with goal1 have "0 < Px (fst x)" "0 < Pz (snd (snd x))" "0 < Pxz (fst x, snd (snd x))" "0 < Pyz (snd x)" "0 < Pxyz x" | |
| 1282 | by auto | |
| 1283 | then show ?thesis | |
| 56544 | 1284 | using b_gt_1 by (simp add: log_simps less_imp_le field_simps) | 
| 49803 | 1285 | qed simp | 
| 1286 | qed | |
| 1287 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1288 | have "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) | 
| 49803 | 1289 | (\<lambda>x. Pxyz x * log b (Pxyz x) - Pxyz x * log b (Px (fst x)) - Pxyz x * log b (Pyz (snd x)))" | 
| 1290 | using finite_entropy_integrable[OF Fxyz] | |
| 1291 | using finite_entropy_integrable_transform[OF Fx Pxyz, of fst] | |
| 1292 | using finite_entropy_integrable_transform[OF Fyz Pxyz, of snd] | |
| 1293 | by simp | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1294 | moreover have "(\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Px x * Pyz (y, z)))) \<in> borel_measurable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P)" | 
| 50003 | 1295 | using Pxyz Px Pyz by simp | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1296 | ultimately have I1: "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Px x * Pyz (y, z))))" | 
| 49803 | 1297 | apply (rule integrable_cong_AE_imp) | 
| 1298 | using ae1 ae4 ae5 ae6 ae9 | |
| 1299 | by eventually_elim | |
| 56536 | 1300 | (auto simp: log_divide_eq log_mult_eq field_simps zero_less_mult_iff) | 
| 49803 | 1301 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1302 | have "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) | 
| 49803 | 1303 | (\<lambda>x. Pxyz x * log b (Pxz (fst x, snd (snd x))) - Pxyz x * log b (Px (fst x)) - Pxyz x * log b (Pz (snd (snd x))))" | 
| 1304 | using finite_entropy_integrable_transform[OF Fxz Pxyz, of "\<lambda>x. (fst x, snd (snd x))"] | |
| 1305 | using finite_entropy_integrable_transform[OF Fx Pxyz, of fst] | |
| 1306 | using finite_entropy_integrable_transform[OF Fz Pxyz, of "snd \<circ> snd"] | |
| 50003 | 1307 | by simp | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1308 | moreover have "(\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxz (x, z) / (Px x * Pz z))) \<in> borel_measurable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P)" | 
| 49803 | 1309 | using Pxyz Px Pz | 
| 50003 | 1310 | by auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1311 | ultimately have I2: "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxz (x, z) / (Px x * Pz z)))" | 
| 49803 | 1312 | apply (rule integrable_cong_AE_imp) | 
| 1313 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 ae9 | |
| 1314 | by eventually_elim | |
| 56536 | 1315 | (auto simp: log_divide_eq log_mult_eq field_simps zero_less_mult_iff) | 
| 49803 | 1316 | |
| 1317 | from ae I1 I2 show ?eq | |
| 1318 | unfolding conditional_mutual_information_def | |
| 1319 | apply (subst mi_eq) | |
| 1320 | apply (subst mutual_information_distr[OF S TP Px Pyz Pxyz]) | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1321 | apply (subst integral_diff[symmetric]) | 
| 49803 | 1322 | apply (auto intro!: integral_cong_AE simp: split_beta' simp del: integral_diff) | 
| 1323 | done | |
| 1324 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1325 | let ?P = "density (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) Pxyz" | 
| 49803 | 1326 | interpret P: prob_space ?P | 
| 50003 | 1327 | unfolding distributed_distr_eq_density[OF Pxyz, symmetric] by (rule prob_space_distr) simp | 
| 49803 | 1328 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1329 | let ?Q = "density (T \<Otimes>\<^sub>M P) Pyz" | 
| 49803 | 1330 | interpret Q: prob_space ?Q | 
| 50003 | 1331 | unfolding distributed_distr_eq_density[OF Pyz, symmetric] by (rule prob_space_distr) simp | 
| 49803 | 1332 | |
| 1333 | let ?f = "\<lambda>(x, y, z). Pxz (x, z) * (Pyz (y, z) / Pz z) / Pxyz (x, y, z)" | |
| 1334 | ||
| 1335 | from subdensity_real[of snd, OF _ Pyz Pz] | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1336 | have aeX1: "AE x in T \<Otimes>\<^sub>M P. Pz (snd x) = 0 \<longrightarrow> Pyz x = 0" by (auto simp: comp_def) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1337 | have aeX2: "AE x in T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd x)" | 
| 50003 | 1338 | using Pz by (intro TP.AE_pair_measure) (auto dest: distributed_real_AE) | 
| 49803 | 1339 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1340 | have aeX3: "AE y in T \<Otimes>\<^sub>M P. (\<integral>\<^sup>+ x. ereal (Pxz (x, snd y)) \<partial>S) = ereal (Pz (snd y))" | 
| 49803 | 1341 | using Pz distributed_marginal_eq_joint2[OF P S Pz Pxz] | 
| 50003 | 1342 | by (intro TP.AE_pair_measure) (auto dest: distributed_real_AE) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1343 | have "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<le> (\<integral>\<^sup>+ (x, y, z). Pxz (x, z) * (Pyz (y, z) / Pz z) \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P))" | 
| 56996 | 1344 | apply (subst nn_integral_density) | 
| 49803 | 1345 | apply (rule distributed_borel_measurable[OF Pxyz]) | 
| 1346 | apply (rule distributed_AE[OF Pxyz]) | |
| 50003 | 1347 | apply simp | 
| 56996 | 1348 | apply (rule nn_integral_mono_AE) | 
| 49803 | 1349 | using ae5 ae6 ae7 ae8 | 
| 1350 | apply eventually_elim | |
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 1351 | apply auto | 
| 49803 | 1352 | done | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1353 | also have "\<dots> = (\<integral>\<^sup>+(y, z). \<integral>\<^sup>+ x. ereal (Pxz (x, z)) * ereal (Pyz (y, z) / Pz z) \<partial>S \<partial>T \<Otimes>\<^sub>M P)" | 
| 56996 | 1354 | by (subst STP.nn_integral_snd[symmetric]) (auto simp add: split_beta') | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1355 | also have "\<dots> = (\<integral>\<^sup>+x. ereal (Pyz x) * 1 \<partial>T \<Otimes>\<^sub>M P)" | 
| 56996 | 1356 | apply (rule nn_integral_cong_AE) | 
| 49803 | 1357 | using aeX1 aeX2 aeX3 distributed_AE[OF Pyz] AE_space | 
| 1358 | apply eventually_elim | |
| 1359 | proof (case_tac x, simp del: times_ereal.simps add: space_pair_measure) | |
| 1360 | fix a b assume "Pz b = 0 \<longrightarrow> Pyz (a, b) = 0" "0 \<le> Pz b" "a \<in> space T \<and> b \<in> space P" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1361 | "(\<integral>\<^sup>+ x. ereal (Pxz (x, b)) \<partial>S) = ereal (Pz b)" "0 \<le> Pyz (a, b)" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1362 | then show "(\<integral>\<^sup>+ x. ereal (Pxz (x, b)) * ereal (Pyz (a, b) / Pz b) \<partial>S) = ereal (Pyz (a, b))" | 
| 56996 | 1363 | by (subst nn_integral_multc) auto | 
| 49803 | 1364 | qed | 
| 1365 | also have "\<dots> = 1" | |
| 1366 | using Q.emeasure_space_1 distributed_AE[OF Pyz] distributed_distr_eq_density[OF Pyz] | |
| 56996 | 1367 | by (subst nn_integral_density[symmetric]) auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1368 | finally have le1: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<le> 1" . | 
| 49803 | 1369 | also have "\<dots> < \<infinity>" by simp | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1370 | finally have fin: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<noteq> \<infinity>" by simp | 
| 49803 | 1371 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1372 | have pos: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<noteq> 0" | 
| 56996 | 1373 | apply (subst nn_integral_density) | 
| 50003 | 1374 | apply simp | 
| 49803 | 1375 | apply (rule distributed_AE[OF Pxyz]) | 
| 50003 | 1376 | apply simp | 
| 49803 | 1377 | apply (simp add: split_beta') | 
| 1378 | proof | |
| 1379 | let ?g = "\<lambda>x. ereal (if Pxyz x = 0 then 0 else Pxz (fst x, snd (snd x)) * Pyz (snd x) / Pz (snd (snd x)))" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1380 | assume "(\<integral>\<^sup>+ x. ?g x \<partial>(S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P)) = 0" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1381 | then have "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. ?g x \<le> 0" | 
| 56996 | 1382 | by (intro nn_integral_0_iff_AE[THEN iffD1]) (auto intro!: borel_measurable_ereal measurable_If) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1383 | then have "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pxyz x = 0" | 
| 49803 | 1384 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | 
| 1385 | by eventually_elim (auto split: split_if_asm simp: mult_le_0_iff divide_le_0_iff) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1386 | then have "(\<integral>\<^sup>+ x. ereal (Pxyz x) \<partial>S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) = 0" | 
| 56996 | 1387 | by (subst nn_integral_cong_AE[of _ "\<lambda>x. 0"]) auto | 
| 49803 | 1388 | with P.emeasure_space_1 show False | 
| 56996 | 1389 | by (subst (asm) emeasure_density) (auto cong: nn_integral_cong) | 
| 49803 | 1390 | qed | 
| 1391 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1392 | have neg: "(\<integral>\<^sup>+ x. - ?f x \<partial>?P) = 0" | 
| 56996 | 1393 | apply (rule nn_integral_0_iff_AE[THEN iffD2]) | 
| 50003 | 1394 | apply (auto simp: split_beta') [] | 
| 49803 | 1395 | apply (subst AE_density) | 
| 50003 | 1396 | apply (auto simp: split_beta') [] | 
| 49803 | 1397 | using ae5 ae6 ae7 ae8 | 
| 1398 | apply eventually_elim | |
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 1399 | apply auto | 
| 49803 | 1400 | done | 
| 1401 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1402 | have I3: "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) (\<lambda>(x, y, z). Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Pxz (x, z) * (Pyz (y,z) / Pz z))))" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1403 | apply (rule integrable_cong_AE[THEN iffD1, OF _ _ _ integrable_diff[OF I1 I2]]) | 
| 49803 | 1404 | using ae | 
| 50003 | 1405 | apply (auto simp: split_beta') | 
| 49803 | 1406 | done | 
| 1407 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1408 | have "- log b 1 \<le> - log b (integral\<^sup>L ?P ?f)" | 
| 49803 | 1409 | proof (intro le_imp_neg_le log_le[OF b_gt_1]) | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1410 | have If: "integrable ?P ?f" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1411 | unfolding real_integrable_def | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1412 | proof (intro conjI) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1413 | from neg show "(\<integral>\<^sup>+ x. - ?f x \<partial>?P) \<noteq> \<infinity>" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1414 | by simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1415 | from fin show "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<noteq> \<infinity>" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1416 | by simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1417 | qed simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1418 | then have "(\<integral>\<^sup>+ x. ?f x \<partial>?P) = (\<integral>x. ?f x \<partial>?P)" | 
| 56996 | 1419 | apply (rule nn_integral_eq_integral) | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1420 | apply (subst AE_density) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1421 | apply simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1422 | using ae5 ae6 ae7 ae8 | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1423 | apply eventually_elim | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1424 | apply auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1425 | done | 
| 56996 | 1426 | with nn_integral_nonneg[of ?P ?f] pos le1 | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1427 | show "0 < (\<integral>x. ?f x \<partial>?P)" "(\<integral>x. ?f x \<partial>?P) \<le> 1" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1428 | by (simp_all add: one_ereal_def) | 
| 49803 | 1429 | qed | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1430 | also have "- log b (integral\<^sup>L ?P ?f) \<le> (\<integral> x. - log b (?f x) \<partial>?P)" | 
| 49803 | 1431 |   proof (rule P.jensens_inequality[where a=0 and b=1 and I="{0<..}"])
 | 
| 1432 |     show "AE x in ?P. ?f x \<in> {0<..}"
 | |
| 1433 | unfolding AE_density[OF distributed_borel_measurable[OF Pxyz]] | |
| 1434 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | |
| 56544 | 1435 | by eventually_elim (auto) | 
| 49803 | 1436 | show "integrable ?P ?f" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1437 | unfolding real_integrable_def | 
| 50003 | 1438 | using fin neg by (auto simp: split_beta') | 
| 49803 | 1439 | show "integrable ?P (\<lambda>x. - log b (?f x))" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1440 | apply (subst integrable_real_density) | 
| 50003 | 1441 | apply simp | 
| 1442 | apply (auto intro!: distributed_real_AE[OF Pxyz]) [] | |
| 1443 | apply simp | |
| 49803 | 1444 | apply (rule integrable_cong_AE[THEN iffD1, OF _ _ _ I3]) | 
| 50003 | 1445 | apply simp | 
| 1446 | apply simp | |
| 49803 | 1447 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | 
| 1448 | apply eventually_elim | |
| 1449 | apply (auto simp: log_divide_eq log_mult_eq zero_le_mult_iff zero_less_mult_iff zero_less_divide_iff field_simps) | |
| 1450 | done | |
| 1451 | qed (auto simp: b_gt_1 minus_log_convex) | |
| 1452 | also have "\<dots> = conditional_mutual_information b S T P X Y Z" | |
| 1453 | unfolding `?eq` | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1454 | apply (subst integral_real_density) | 
| 50003 | 1455 | apply simp | 
| 1456 | apply (auto intro!: distributed_real_AE[OF Pxyz]) [] | |
| 1457 | apply simp | |
| 49803 | 1458 | apply (intro integral_cong_AE) | 
| 1459 | using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE] | |
| 1460 | apply (auto simp: log_divide_eq zero_less_mult_iff zero_less_divide_iff field_simps) | |
| 1461 | done | |
| 1462 | finally show ?nonneg | |
| 1463 | by simp | |
| 1464 | qed | |
| 1465 | ||
| 40859 | 1466 | lemma (in information_space) conditional_mutual_information_eq: | 
| 47694 | 1467 | assumes Pz: "simple_distributed M Z Pz" | 
| 1468 | assumes Pyz: "simple_distributed M (\<lambda>x. (Y x, Z x)) Pyz" | |
| 1469 | assumes Pxz: "simple_distributed M (\<lambda>x. (X x, Z x)) Pxz" | |
| 1470 | assumes Pxyz: "simple_distributed M (\<lambda>x. (X x, Y x, Z x)) Pxyz" | |
| 1471 | shows "\<I>(X ; Y | Z) = | |
| 1472 | (\<Sum>(x, y, z)\<in>(\<lambda>x. (X x, Y x, Z x))`space M. Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Pxz (x, z) * (Pyz (y,z) / Pz z))))" | |
| 1473 | proof (subst conditional_mutual_information_generic_eq[OF _ _ _ _ | |
| 1474 | simple_distributed[OF Pz] simple_distributed_joint[OF Pyz] simple_distributed_joint[OF Pxz] | |
| 1475 | simple_distributed_joint2[OF Pxyz]]) | |
| 1476 | note simple_distributed_joint2_finite[OF Pxyz, simp] | |
| 1477 | show "sigma_finite_measure (count_space (X ` space M))" | |
| 1478 | by (simp add: sigma_finite_measure_count_space_finite) | |
| 1479 | show "sigma_finite_measure (count_space (Y ` space M))" | |
| 1480 | by (simp add: sigma_finite_measure_count_space_finite) | |
| 1481 | show "sigma_finite_measure (count_space (Z ` space M))" | |
| 1482 | by (simp add: sigma_finite_measure_count_space_finite) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1483 | have "count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M) \<Otimes>\<^sub>M count_space (Z ` space M) = | 
| 47694 | 1484 | count_space (X`space M \<times> Y`space M \<times> Z`space M)" | 
| 1485 | (is "?P = ?C") | |
| 1486 | by (simp add: pair_measure_count_space) | |
| 40859 | 1487 | |
| 47694 | 1488 |   let ?Px = "\<lambda>x. measure M (X -` {x} \<inter> space M)"
 | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1489 | have "(\<lambda>x. (X x, Z x)) \<in> measurable M (count_space (X ` space M) \<Otimes>\<^sub>M count_space (Z ` space M))" | 
| 47694 | 1490 | using simple_distributed_joint[OF Pxz] by (rule distributed_measurable) | 
| 1491 | from measurable_comp[OF this measurable_fst] | |
| 1492 | have "random_variable (count_space (X ` space M)) X" | |
| 1493 | by (simp add: comp_def) | |
| 1494 | then have "simple_function M X" | |
| 50002 
ce0d316b5b44
add measurability prover; add support for Borel sets
 hoelzl parents: 
49999diff
changeset | 1495 | unfolding simple_function_def by (auto simp: measurable_count_space_eq2) | 
| 47694 | 1496 | then have "simple_distributed M X ?Px" | 
| 1497 | by (rule simple_distributedI) auto | |
| 1498 | then show "distributed M (count_space (X ` space M)) X ?Px" | |
| 1499 | by (rule simple_distributed) | |
| 1500 | ||
| 1501 | let ?f = "(\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x, Z x)) ` space M then Pxyz x else 0)" | |
| 1502 | let ?g = "(\<lambda>x. if x \<in> (\<lambda>x. (Y x, Z x)) ` space M then Pyz x else 0)" | |
| 1503 | let ?h = "(\<lambda>x. if x \<in> (\<lambda>x. (X x, Z x)) ` space M then Pxz x else 0)" | |
| 1504 | show | |
| 1505 | "integrable ?P (\<lambda>(x, y, z). ?f (x, y, z) * log b (?f (x, y, z) / (?Px x * ?g (y, z))))" | |
| 1506 | "integrable ?P (\<lambda>(x, y, z). ?f (x, y, z) * log b (?h (x, z) / (?Px x * Pz z)))" | |
| 1507 | by (auto intro!: integrable_count_space simp: pair_measure_count_space) | |
| 1508 | let ?i = "\<lambda>x y z. ?f (x, y, z) * log b (?f (x, y, z) / (?h (x, z) * (?g (y, z) / Pz z)))" | |
| 1509 | let ?j = "\<lambda>x y z. Pxyz (x, y, z) * log b (Pxyz (x, y, z) / (Pxz (x, z) * (Pyz (y,z) / Pz z)))" | |
| 1510 | have "(\<lambda>(x, y, z). ?i x y z) = (\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x, Z x)) ` space M then ?j (fst x) (fst (snd x)) (snd (snd x)) else 0)" | |
| 1511 | by (auto intro!: ext) | |
| 1512 | then show "(\<integral> (x, y, z). ?i x y z \<partial>?P) = (\<Sum>(x, y, z)\<in>(\<lambda>x. (X x, Y x, Z x)) ` space M. ?j x y z)" | |
| 1513 | by (auto intro!: setsum_cong simp add: `?P = ?C` lebesgue_integral_count_space_finite simple_distributed_finite setsum_cases split_beta') | |
| 36624 | 1514 | qed | 
| 1515 | ||
| 47694 | 1516 | lemma (in information_space) conditional_mutual_information_nonneg: | 
| 1517 | assumes X: "simple_function M X" and Y: "simple_function M Y" and Z: "simple_function M Z" | |
| 1518 | shows "0 \<le> \<I>(X ; Y | Z)" | |
| 1519 | proof - | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1520 | have [simp]: "count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M) \<Otimes>\<^sub>M count_space (Z ` space M) = | 
| 49787 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1521 | count_space (X`space M \<times> Y`space M \<times> Z`space M)" | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1522 | by (simp add: pair_measure_count_space X Y Z simple_functionD) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1523 | note sf = sigma_finite_measure_count_space_finite[OF simple_functionD(1)] | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1524 | note sd = simple_distributedI[OF _ refl] | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1525 | note sp = simple_function_Pair | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1526 | show ?thesis | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1527 | apply (rule conditional_mutual_information_generic_nonneg[OF sf[OF X] sf[OF Y] sf[OF Z]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1528 | apply (rule simple_distributed[OF sd[OF X]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1529 | apply (rule simple_distributed[OF sd[OF Z]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1530 | apply (rule simple_distributed_joint[OF sd[OF sp[OF Y Z]]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1531 | apply (rule simple_distributed_joint[OF sd[OF sp[OF X Z]]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1532 | apply (rule simple_distributed_joint2[OF sd[OF sp[OF X sp[OF Y Z]]]]) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1533 | apply (auto intro!: integrable_count_space simp: X Y Z simple_functionD) | 
| 
d8de705b48d4
rule to show that conditional mutual information is non-negative in the continuous case
 hoelzl parents: 
49786diff
changeset | 1534 | done | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1535 | qed | 
| 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1536 | |
| 39097 | 1537 | subsection {* Conditional Entropy *}
 | 
| 1538 | ||
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1539 | definition (in prob_space) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1540 | "conditional_entropy b S T X Y = - (\<integral>(x, y). log b (real (RN_deriv (S \<Otimes>\<^sub>M T) (distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))) (x, y)) / | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1541 | real (RN_deriv T (distr M T Y) y)) \<partial>distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)))" | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1542 | |
| 40859 | 1543 | abbreviation (in information_space) | 
| 1544 |   conditional_entropy_Pow ("\<H>'(_ | _')") where
 | |
| 47694 | 1545 | "\<H>(X | Y) \<equiv> conditional_entropy b (count_space (X`space M)) (count_space (Y`space M)) X Y" | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1546 | |
| 49791 | 1547 | lemma (in information_space) conditional_entropy_generic_eq: | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1548 | fixes Pxy :: "_ \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" | 
| 49791 | 1549 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" | 
| 50003 | 1550 | assumes Py[measurable]: "distributed M T Y Py" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1551 | assumes Pxy[measurable]: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1552 | shows "conditional_entropy b S T X Y = - (\<integral>(x, y). Pxy (x, y) * log b (Pxy (x, y) / Py y) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 49791 | 1553 | proof - | 
| 1554 | interpret S: sigma_finite_measure S by fact | |
| 1555 | interpret T: sigma_finite_measure T by fact | |
| 1556 | interpret ST: pair_sigma_finite S T .. | |
| 1557 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1558 | have "AE x in density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Pxy x)). Pxy x = real (RN_deriv (S \<Otimes>\<^sub>M T) (distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))) x)" | 
| 49791 | 1559 | unfolding AE_density[OF distributed_borel_measurable, OF Pxy] | 
| 1560 | unfolding distributed_distr_eq_density[OF Pxy] | |
| 1561 | using distributed_RN_deriv[OF Pxy] | |
| 1562 | by auto | |
| 1563 | moreover | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1564 | have "AE x in density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Pxy x)). Py (snd x) = real (RN_deriv T (distr M T Y) (snd x))" | 
| 49791 | 1565 | unfolding AE_density[OF distributed_borel_measurable, OF Pxy] | 
| 1566 | unfolding distributed_distr_eq_density[OF Py] | |
| 1567 | apply (rule ST.AE_pair_measure) | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1568 | apply auto | 
| 49791 | 1569 | using distributed_RN_deriv[OF Py] | 
| 1570 | apply auto | |
| 1571 | done | |
| 1572 | ultimately | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1573 | have "conditional_entropy b S T X Y = - (\<integral>x. Pxy x * log b (Pxy x / Py (snd x)) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 49791 | 1574 | unfolding conditional_entropy_def neg_equal_iff_equal | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1575 | apply (subst integral_real_density[symmetric]) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1576 | apply (auto simp: distributed_real_AE[OF Pxy] distributed_distr_eq_density[OF Pxy] | 
| 49791 | 1577 | intro!: integral_cong_AE) | 
| 1578 | done | |
| 1579 | then show ?thesis by (simp add: split_beta') | |
| 1580 | qed | |
| 1581 | ||
| 1582 | lemma (in information_space) conditional_entropy_eq_entropy: | |
| 47694 | 1583 | fixes Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" | 
| 1584 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1585 | assumes Py[measurable]: "distributed M T Y Py" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1586 | assumes Pxy[measurable]: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1587 | assumes I1: "integrable (S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Pxy x))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1588 | assumes I2: "integrable (S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Py (snd x)))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1589 | shows "conditional_entropy b S T X Y = entropy b (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) - entropy b T Y" | 
| 40859 | 1590 | proof - | 
| 47694 | 1591 | interpret S: sigma_finite_measure S by fact | 
| 1592 | interpret T: sigma_finite_measure T by fact | |
| 1593 | interpret ST: pair_sigma_finite S T .. | |
| 1594 | ||
| 1595 | have "entropy b T Y = - (\<integral>y. Py y * log b (Py y) \<partial>T)" | |
| 49786 | 1596 | by (rule entropy_distr[OF Py]) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1597 | also have "\<dots> = - (\<integral>(x,y). Pxy (x,y) * log b (Py y) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 47694 | 1598 | using b_gt_1 Py[THEN distributed_real_measurable] | 
| 1599 | by (subst distributed_transform_integral[OF Pxy Py, where T=snd]) (auto intro!: integral_cong) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1600 | finally have e_eq: "entropy b T Y = - (\<integral>(x,y). Pxy (x,y) * log b (Py y) \<partial>(S \<Otimes>\<^sub>M T))" . | 
| 49791 | 1601 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1602 | have ae2: "AE x in S \<Otimes>\<^sub>M T. Py (snd x) = 0 \<longrightarrow> Pxy x = 0" | 
| 47694 | 1603 | by (intro subdensity_real[of snd, OF _ Pxy Py]) (auto intro: measurable_Pair) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1604 | moreover have ae4: "AE x in S \<Otimes>\<^sub>M T. 0 \<le> Py (snd x)" | 
| 47694 | 1605 | using Py by (intro ST.AE_pair_measure) (auto simp: comp_def intro!: measurable_snd'' dest: distributed_real_AE distributed_real_measurable) | 
| 49788 
3c10763f5cb4
show and use distributed_swap and distributed_jointI
 hoelzl parents: 
49787diff
changeset | 1606 | moreover note ae5 = Pxy[THEN distributed_real_AE] | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1607 | ultimately have "AE x in S \<Otimes>\<^sub>M T. 0 \<le> Pxy x \<and> 0 \<le> Py (snd x) \<and> | 
| 49790 
6b9b9ebba47d
remove unneeded assumption from conditional_entropy_generic_eq
 hoelzl parents: 
49788diff
changeset | 1608 | (Pxy x = 0 \<or> (Pxy x \<noteq> 0 \<longrightarrow> 0 < Pxy x \<and> 0 < Py (snd x)))" | 
| 47694 | 1609 | by eventually_elim auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1610 | then have ae: "AE x in S \<Otimes>\<^sub>M T. | 
| 47694 | 1611 | Pxy x * log b (Pxy x) - Pxy x * log b (Py (snd x)) = Pxy x * log b (Pxy x / Py (snd x))" | 
| 56544 | 1612 | by eventually_elim (auto simp: log_simps field_simps b_gt_1) | 
| 49791 | 1613 | have "conditional_entropy b S T X Y = | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1614 | - (\<integral>x. Pxy x * log b (Pxy x) - Pxy x * log b (Py (snd x)) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 49791 | 1615 | unfolding conditional_entropy_generic_eq[OF S T Py Pxy] neg_equal_iff_equal | 
| 1616 | apply (intro integral_cong_AE) | |
| 1617 | using ae | |
| 1618 | apply auto | |
| 47694 | 1619 | done | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1620 | also have "\<dots> = - (\<integral>x. Pxy x * log b (Pxy x) \<partial>(S \<Otimes>\<^sub>M T)) - - (\<integral>x. Pxy x * log b (Py (snd x)) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 49791 | 1621 | by (simp add: integral_diff[OF I1 I2]) | 
| 1622 | finally show ?thesis | |
| 1623 | unfolding conditional_entropy_generic_eq[OF S T Py Pxy] entropy_distr[OF Pxy] e_eq | |
| 1624 | by (simp add: split_beta') | |
| 1625 | qed | |
| 1626 | ||
| 1627 | lemma (in information_space) conditional_entropy_eq_entropy_simple: | |
| 1628 | assumes X: "simple_function M X" and Y: "simple_function M Y" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1629 | shows "\<H>(X | Y) = entropy b (count_space (X`space M) \<Otimes>\<^sub>M count_space (Y`space M)) (\<lambda>x. (X x, Y x)) - \<H>(Y)" | 
| 49791 | 1630 | proof - | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1631 | have "count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M) = count_space (X`space M \<times> Y`space M)" | 
| 49791 | 1632 | (is "?P = ?C") using X Y by (simp add: simple_functionD pair_measure_count_space) | 
| 1633 | show ?thesis | |
| 1634 | by (rule conditional_entropy_eq_entropy sigma_finite_measure_count_space_finite | |
| 1635 | simple_functionD X Y simple_distributed simple_distributedI[OF _ refl] | |
| 1636 | simple_distributed_joint simple_function_Pair integrable_count_space)+ | |
| 1637 | (auto simp: `?P = ?C` intro!: integrable_count_space simple_functionD X Y) | |
| 39097 | 1638 | qed | 
| 1639 | ||
| 40859 | 1640 | lemma (in information_space) conditional_entropy_eq: | 
| 49792 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1641 | assumes Y: "simple_distributed M Y Py" | 
| 47694 | 1642 | assumes XY: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy" | 
| 1643 | shows "\<H>(X | Y) = - (\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. Pxy (x, y) * log b (Pxy (x, y) / Py y))" | |
| 1644 | proof (subst conditional_entropy_generic_eq[OF _ _ | |
| 49790 
6b9b9ebba47d
remove unneeded assumption from conditional_entropy_generic_eq
 hoelzl parents: 
49788diff
changeset | 1645 | simple_distributed[OF Y] simple_distributed_joint[OF XY]]) | 
| 49792 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1646 | have "finite ((\<lambda>x. (X x, Y x))`space M)" | 
| 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1647 | using XY unfolding simple_distributed_def by auto | 
| 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1648 | from finite_imageI[OF this, of fst] | 
| 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1649 | have [simp]: "finite (X`space M)" | 
| 56154 
f0a927235162
more complete set of lemmas wrt. image and composition
 haftmann parents: 
53374diff
changeset | 1650 | by (simp add: image_comp comp_def) | 
| 47694 | 1651 | note Y[THEN simple_distributed_finite, simp] | 
| 1652 | show "sigma_finite_measure (count_space (X ` space M))" | |
| 1653 | by (simp add: sigma_finite_measure_count_space_finite) | |
| 1654 | show "sigma_finite_measure (count_space (Y ` space M))" | |
| 1655 | by (simp add: sigma_finite_measure_count_space_finite) | |
| 1656 | let ?f = "(\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x)) ` space M then Pxy x else 0)" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1657 | have "count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M) = count_space (X`space M \<times> Y`space M)" | 
| 47694 | 1658 | (is "?P = ?C") | 
| 49792 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1659 | using Y by (simp add: simple_distributed_finite pair_measure_count_space) | 
| 47694 | 1660 | have eq: "(\<lambda>(x, y). ?f (x, y) * log b (?f (x, y) / Py y)) = | 
| 1661 | (\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x)) ` space M then Pxy x * log b (Pxy x / Py (snd x)) else 0)" | |
| 1662 | by auto | |
| 49792 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1663 | from Y show "- (\<integral> (x, y). ?f (x, y) * log b (?f (x, y) / Py y) \<partial>?P) = | 
| 47694 | 1664 | - (\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. Pxy (x, y) * log b (Pxy (x, y) / Py y))" | 
| 1665 | by (auto intro!: setsum_cong simp add: `?P = ?C` lebesgue_integral_count_space_finite simple_distributed_finite eq setsum_cases split_beta') | |
| 1666 | qed | |
| 39097 | 1667 | |
| 47694 | 1668 | lemma (in information_space) conditional_mutual_information_eq_conditional_entropy: | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 1669 | assumes X: "simple_function M X" and Y: "simple_function M Y" | 
| 47694 | 1670 | shows "\<I>(X ; X | Y) = \<H>(X | Y)" | 
| 1671 | proof - | |
| 1672 |   def Py \<equiv> "\<lambda>x. if x \<in> Y`space M then measure M (Y -` {x} \<inter> space M) else 0"
 | |
| 1673 |   def Pxy \<equiv> "\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x))`space M then measure M ((\<lambda>x. (X x, Y x)) -` {x} \<inter> space M) else 0"
 | |
| 1674 |   def Pxxy \<equiv> "\<lambda>x. if x \<in> (\<lambda>x. (X x, X x, Y x))`space M then measure M ((\<lambda>x. (X x, X x, Y x)) -` {x} \<inter> space M) else 0"
 | |
| 1675 | let ?M = "X`space M \<times> X`space M \<times> Y`space M" | |
| 39097 | 1676 | |
| 47694 | 1677 | note XY = simple_function_Pair[OF X Y] | 
| 1678 | note XXY = simple_function_Pair[OF X XY] | |
| 1679 | have Py: "simple_distributed M Y Py" | |
| 1680 | using Y by (rule simple_distributedI) (auto simp: Py_def) | |
| 1681 | have Pxy: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy" | |
| 1682 | using XY by (rule simple_distributedI) (auto simp: Pxy_def) | |
| 1683 | have Pxxy: "simple_distributed M (\<lambda>x. (X x, X x, Y x)) Pxxy" | |
| 1684 | using XXY by (rule simple_distributedI) (auto simp: Pxxy_def) | |
| 1685 | have eq: "(\<lambda>x. (X x, X x, Y x)) ` space M = (\<lambda>(x, y). (x, x, y)) ` (\<lambda>x. (X x, Y x)) ` space M" | |
| 1686 | by auto | |
| 1687 | have inj: "\<And>A. inj_on (\<lambda>(x, y). (x, x, y)) A" | |
| 1688 | by (auto simp: inj_on_def) | |
| 1689 | have Pxxy_eq: "\<And>x y. Pxxy (x, x, y) = Pxy (x, y)" | |
| 1690 | by (auto simp: Pxxy_def Pxy_def intro!: arg_cong[where f=prob]) | |
| 1691 | have "AE x in count_space ((\<lambda>x. (X x, Y x))`space M). Py (snd x) = 0 \<longrightarrow> Pxy x = 0" | |
| 1692 | by (intro subdensity_real[of snd, OF _ Pxy[THEN simple_distributed] Py[THEN simple_distributed]]) (auto intro: measurable_Pair) | |
| 1693 | then show ?thesis | |
| 1694 | apply (subst conditional_mutual_information_eq[OF Py Pxy Pxy Pxxy]) | |
| 49792 
43f49922811d
remove unnecessary assumption from conditional_entropy_eq
 hoelzl parents: 
49791diff
changeset | 1695 | apply (subst conditional_entropy_eq[OF Py Pxy]) | 
| 47694 | 1696 | apply (auto intro!: setsum_cong simp: Pxxy_eq setsum_negf[symmetric] eq setsum_reindex[OF inj] | 
| 1697 | log_simps zero_less_mult_iff zero_le_mult_iff field_simps mult_less_0_iff AE_count_space) | |
| 1698 | using Py[THEN simple_distributed, THEN distributed_real_AE] Pxy[THEN simple_distributed, THEN distributed_real_AE] | |
| 49790 
6b9b9ebba47d
remove unneeded assumption from conditional_entropy_generic_eq
 hoelzl parents: 
49788diff
changeset | 1699 | apply (auto simp add: not_le[symmetric] AE_count_space) | 
| 47694 | 1700 | done | 
| 1701 | qed | |
| 1702 | ||
| 1703 | lemma (in information_space) conditional_entropy_nonneg: | |
| 1704 | assumes X: "simple_function M X" and Y: "simple_function M Y" shows "0 \<le> \<H>(X | Y)" | |
| 1705 | using conditional_mutual_information_eq_conditional_entropy[OF X Y] conditional_mutual_information_nonneg[OF X X Y] | |
| 1706 | by simp | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1707 | |
| 39097 | 1708 | subsection {* Equalities *}
 | 
| 1709 | ||
| 47694 | 1710 | lemma (in information_space) mutual_information_eq_entropy_conditional_entropy_distr: | 
| 1711 |   fixes Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" and Pxy :: "('b \<times> 'c) \<Rightarrow> real"
 | |
| 1712 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1713 | assumes Px[measurable]: "distributed M S X Px" and Py[measurable]: "distributed M T Y Py" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1714 | assumes Pxy[measurable]: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1715 | assumes Ix: "integrable(S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Px (fst x)))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1716 | assumes Iy: "integrable(S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Py (snd x)))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1717 | assumes Ixy: "integrable(S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Pxy x))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1718 | shows "mutual_information b S T X Y = entropy b S X + entropy b T Y - entropy b (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))" | 
| 40859 | 1719 | proof - | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1720 | have X: "entropy b S X = - (\<integral>x. Pxy x * log b (Px (fst x)) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 47694 | 1721 | using b_gt_1 Px[THEN distributed_real_measurable] | 
| 49786 | 1722 | apply (subst entropy_distr[OF Px]) | 
| 47694 | 1723 | apply (subst distributed_transform_integral[OF Pxy Px, where T=fst]) | 
| 1724 | apply (auto intro!: integral_cong) | |
| 1725 | done | |
| 1726 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1727 | have Y: "entropy b T Y = - (\<integral>x. Pxy x * log b (Py (snd x)) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 47694 | 1728 | using b_gt_1 Py[THEN distributed_real_measurable] | 
| 49786 | 1729 | apply (subst entropy_distr[OF Py]) | 
| 47694 | 1730 | apply (subst distributed_transform_integral[OF Pxy Py, where T=snd]) | 
| 1731 | apply (auto intro!: integral_cong) | |
| 1732 | done | |
| 1733 | ||
| 1734 | interpret S: sigma_finite_measure S by fact | |
| 1735 | interpret T: sigma_finite_measure T by fact | |
| 1736 | interpret ST: pair_sigma_finite S T .. | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1737 | have ST: "sigma_finite_measure (S \<Otimes>\<^sub>M T)" .. | 
| 47694 | 1738 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1739 | have XY: "entropy b (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) = - (\<integral>x. Pxy x * log b (Pxy x) \<partial>(S \<Otimes>\<^sub>M T))" | 
| 49786 | 1740 | by (subst entropy_distr[OF Pxy]) (auto intro!: integral_cong) | 
| 47694 | 1741 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1742 | have "AE x in S \<Otimes>\<^sub>M T. Px (fst x) = 0 \<longrightarrow> Pxy x = 0" | 
| 47694 | 1743 | by (intro subdensity_real[of fst, OF _ Pxy Px]) (auto intro: measurable_Pair) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1744 | moreover have "AE x in S \<Otimes>\<^sub>M T. Py (snd x) = 0 \<longrightarrow> Pxy x = 0" | 
| 47694 | 1745 | by (intro subdensity_real[of snd, OF _ Pxy Py]) (auto intro: measurable_Pair) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1746 | moreover have "AE x in S \<Otimes>\<^sub>M T. 0 \<le> Px (fst x)" | 
| 47694 | 1747 | using Px by (intro ST.AE_pair_measure) (auto simp: comp_def intro!: measurable_fst'' dest: distributed_real_AE distributed_real_measurable) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1748 | moreover have "AE x in S \<Otimes>\<^sub>M T. 0 \<le> Py (snd x)" | 
| 47694 | 1749 | using Py by (intro ST.AE_pair_measure) (auto simp: comp_def intro!: measurable_snd'' dest: distributed_real_AE distributed_real_measurable) | 
| 1750 | moreover note Pxy[THEN distributed_real_AE] | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1751 | ultimately have "AE x in S \<Otimes>\<^sub>M T. Pxy x * log b (Pxy x) - Pxy x * log b (Px (fst x)) - Pxy x * log b (Py (snd x)) = | 
| 47694 | 1752 | Pxy x * log b (Pxy x / (Px (fst x) * Py (snd x)))" | 
| 1753 | (is "AE x in _. ?f x = ?g x") | |
| 1754 | proof eventually_elim | |
| 1755 | case (goal1 x) | |
| 1756 | show ?case | |
| 1757 | proof cases | |
| 1758 | assume "Pxy x \<noteq> 0" | |
| 1759 | with goal1 have "0 < Px (fst x)" "0 < Py (snd x)" "0 < Pxy x" | |
| 1760 | by auto | |
| 1761 | then show ?thesis | |
| 56544 | 1762 | using b_gt_1 by (simp add: log_simps less_imp_le field_simps) | 
| 47694 | 1763 | qed simp | 
| 1764 | qed | |
| 1765 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1766 | have "entropy b S X + entropy b T Y - entropy b (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) = integral\<^sup>L (S \<Otimes>\<^sub>M T) ?f" | 
| 47694 | 1767 | unfolding X Y XY | 
| 1768 | apply (subst integral_diff) | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1769 | apply (intro integrable_diff Ixy Ix Iy)+ | 
| 47694 | 1770 | apply (subst integral_diff) | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1771 | apply (intro Ixy Ix Iy)+ | 
| 47694 | 1772 | apply (simp add: field_simps) | 
| 1773 | done | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1774 | also have "\<dots> = integral\<^sup>L (S \<Otimes>\<^sub>M T) ?g" | 
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56571diff
changeset | 1775 | using `AE x in _. ?f x = ?g x` by (intro integral_cong_AE) auto | 
| 47694 | 1776 | also have "\<dots> = mutual_information b S T X Y" | 
| 1777 | by (rule mutual_information_distr[OF S T Px Py Pxy, symmetric]) | |
| 1778 | finally show ?thesis .. | |
| 1779 | qed | |
| 1780 | ||
| 49802 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1781 | lemma (in information_space) mutual_information_eq_entropy_conditional_entropy': | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1782 |   fixes Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" and Pxy :: "('b \<times> 'c) \<Rightarrow> real"
 | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1783 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1784 | assumes Px: "distributed M S X Px" and Py: "distributed M T Y Py" | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1785 | assumes Pxy: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1786 | assumes Ix: "integrable(S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Px (fst x)))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1787 | assumes Iy: "integrable(S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Py (snd x)))" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1788 | assumes Ixy: "integrable(S \<Otimes>\<^sub>M T) (\<lambda>x. Pxy x * log b (Pxy x))" | 
| 49802 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1789 | shows "mutual_information b S T X Y = entropy b S X - conditional_entropy b S T X Y" | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1790 | using | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1791 | mutual_information_eq_entropy_conditional_entropy_distr[OF S T Px Py Pxy Ix Iy Ixy] | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1792 | conditional_entropy_eq_entropy[OF S T Py Pxy Ixy Iy] | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1793 | by simp | 
| 
dd8dffaf84b9
continuous version of mutual_information_eq_entropy_conditional_entropy
 hoelzl parents: 
49792diff
changeset | 1794 | |
| 47694 | 1795 | lemma (in information_space) mutual_information_eq_entropy_conditional_entropy: | 
| 1796 | assumes sf_X: "simple_function M X" and sf_Y: "simple_function M Y" | |
| 1797 | shows "\<I>(X ; Y) = \<H>(X) - \<H>(X | Y)" | |
| 1798 | proof - | |
| 1799 |   have X: "simple_distributed M X (\<lambda>x. measure M (X -` {x} \<inter> space M))"
 | |
| 1800 | using sf_X by (rule simple_distributedI) auto | |
| 1801 |   have Y: "simple_distributed M Y (\<lambda>x. measure M (Y -` {x} \<inter> space M))"
 | |
| 1802 | using sf_Y by (rule simple_distributedI) auto | |
| 1803 | have sf_XY: "simple_function M (\<lambda>x. (X x, Y x))" | |
| 1804 | using sf_X sf_Y by (rule simple_function_Pair) | |
| 1805 |   then have XY: "simple_distributed M (\<lambda>x. (X x, Y x)) (\<lambda>x. measure M ((\<lambda>x. (X x, Y x)) -` {x} \<inter> space M))"
 | |
| 1806 | by (rule simple_distributedI) auto | |
| 1807 | from simple_distributed_joint_finite[OF this, simp] | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1808 | have eq: "count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M) = count_space (X ` space M \<times> Y ` space M)" | 
| 47694 | 1809 | by (simp add: pair_measure_count_space) | 
| 1810 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1811 | have "\<I>(X ; Y) = \<H>(X) + \<H>(Y) - entropy b (count_space (X`space M) \<Otimes>\<^sub>M count_space (Y`space M)) (\<lambda>x. (X x, Y x))" | 
| 47694 | 1812 | using sigma_finite_measure_count_space_finite sigma_finite_measure_count_space_finite simple_distributed[OF X] simple_distributed[OF Y] simple_distributed_joint[OF XY] | 
| 1813 | by (rule mutual_information_eq_entropy_conditional_entropy_distr) (auto simp: eq integrable_count_space) | |
| 1814 | then show ?thesis | |
| 49791 | 1815 | unfolding conditional_entropy_eq_entropy_simple[OF sf_X sf_Y] by simp | 
| 47694 | 1816 | qed | 
| 1817 | ||
| 1818 | lemma (in information_space) mutual_information_nonneg_simple: | |
| 1819 | assumes sf_X: "simple_function M X" and sf_Y: "simple_function M Y" | |
| 1820 | shows "0 \<le> \<I>(X ; Y)" | |
| 1821 | proof - | |
| 1822 |   have X: "simple_distributed M X (\<lambda>x. measure M (X -` {x} \<inter> space M))"
 | |
| 1823 | using sf_X by (rule simple_distributedI) auto | |
| 1824 |   have Y: "simple_distributed M Y (\<lambda>x. measure M (Y -` {x} \<inter> space M))"
 | |
| 1825 | using sf_Y by (rule simple_distributedI) auto | |
| 1826 | ||
| 1827 | have sf_XY: "simple_function M (\<lambda>x. (X x, Y x))" | |
| 1828 | using sf_X sf_Y by (rule simple_function_Pair) | |
| 1829 |   then have XY: "simple_distributed M (\<lambda>x. (X x, Y x)) (\<lambda>x. measure M ((\<lambda>x. (X x, Y x)) -` {x} \<inter> space M))"
 | |
| 1830 | by (rule simple_distributedI) auto | |
| 1831 | ||
| 1832 | from simple_distributed_joint_finite[OF this, simp] | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1833 | have eq: "count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M) = count_space (X ` space M \<times> Y ` space M)" | 
| 47694 | 1834 | by (simp add: pair_measure_count_space) | 
| 1835 | ||
| 40859 | 1836 | show ?thesis | 
| 47694 | 1837 | by (rule mutual_information_nonneg[OF _ _ simple_distributed[OF X] simple_distributed[OF Y] simple_distributed_joint[OF XY]]) | 
| 1838 | (simp_all add: eq integrable_count_space sigma_finite_measure_count_space_finite) | |
| 40859 | 1839 | qed | 
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1840 | |
| 40859 | 1841 | lemma (in information_space) conditional_entropy_less_eq_entropy: | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 1842 | assumes X: "simple_function M X" and Z: "simple_function M Z" | 
| 40859 | 1843 | shows "\<H>(X | Z) \<le> \<H>(X)" | 
| 36624 | 1844 | proof - | 
| 47694 | 1845 | have "0 \<le> \<I>(X ; Z)" using X Z by (rule mutual_information_nonneg_simple) | 
| 1846 | also have "\<I>(X ; Z) = \<H>(X) - \<H>(X | Z)" using mutual_information_eq_entropy_conditional_entropy[OF assms] . | |
| 1847 | finally show ?thesis by auto | |
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1848 | qed | 
| 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1849 | |
| 49803 | 1850 | lemma (in information_space) | 
| 1851 |   fixes Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" and Pxy :: "('b \<times> 'c) \<Rightarrow> real"
 | |
| 1852 | assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" | |
| 1853 | assumes Px: "finite_entropy S X Px" and Py: "finite_entropy T Y Py" | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1854 | assumes Pxy: "finite_entropy (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy" | 
| 49803 | 1855 | shows "conditional_entropy b S T X Y \<le> entropy b S X" | 
| 1856 | proof - | |
| 1857 | ||
| 1858 | have "0 \<le> mutual_information b S T X Y" | |
| 1859 | by (rule mutual_information_nonneg') fact+ | |
| 1860 | also have "\<dots> = entropy b S X - conditional_entropy b S T X Y" | |
| 1861 | apply (rule mutual_information_eq_entropy_conditional_entropy') | |
| 1862 | using assms | |
| 1863 | by (auto intro!: finite_entropy_integrable finite_entropy_distributed | |
| 1864 | finite_entropy_integrable_transform[OF Px] | |
| 1865 | finite_entropy_integrable_transform[OF Py]) | |
| 1866 | finally show ?thesis by auto | |
| 1867 | qed | |
| 1868 | ||
| 40859 | 1869 | lemma (in information_space) entropy_chain_rule: | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 1870 | assumes X: "simple_function M X" and Y: "simple_function M Y" | 
| 40859 | 1871 | shows "\<H>(\<lambda>x. (X x, Y x)) = \<H>(X) + \<H>(Y|X)" | 
| 1872 | proof - | |
| 47694 | 1873 | note XY = simple_distributedI[OF simple_function_Pair[OF X Y] refl] | 
| 1874 | note YX = simple_distributedI[OF simple_function_Pair[OF Y X] refl] | |
| 1875 | note simple_distributed_joint_finite[OF this, simp] | |
| 1876 |   let ?f = "\<lambda>x. prob ((\<lambda>x. (X x, Y x)) -` {x} \<inter> space M)"
 | |
| 1877 |   let ?g = "\<lambda>x. prob ((\<lambda>x. (Y x, X x)) -` {x} \<inter> space M)"
 | |
| 1878 |   let ?h = "\<lambda>x. if x \<in> (\<lambda>x. (Y x, X x)) ` space M then prob ((\<lambda>x. (Y x, X x)) -` {x} \<inter> space M) else 0"
 | |
| 1879 | have "\<H>(\<lambda>x. (X x, Y x)) = - (\<Sum>x\<in>(\<lambda>x. (X x, Y x)) ` space M. ?f x * log b (?f x))" | |
| 1880 | using XY by (rule entropy_simple_distributed) | |
| 1881 | also have "\<dots> = - (\<Sum>x\<in>(\<lambda>(x, y). (y, x)) ` (\<lambda>x. (X x, Y x)) ` space M. ?g x * log b (?g x))" | |
| 1882 | by (subst (2) setsum_reindex) (auto simp: inj_on_def intro!: setsum_cong arg_cong[where f="\<lambda>A. prob A * log b (prob A)"]) | |
| 1883 | also have "\<dots> = - (\<Sum>x\<in>(\<lambda>x. (Y x, X x)) ` space M. ?h x * log b (?h x))" | |
| 1884 | by (auto intro!: setsum_cong) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1885 | also have "\<dots> = entropy b (count_space (Y ` space M) \<Otimes>\<^sub>M count_space (X ` space M)) (\<lambda>x. (Y x, X x))" | 
| 49786 | 1886 | by (subst entropy_distr[OF simple_distributed_joint[OF YX]]) | 
| 47694 | 1887 | (auto simp: pair_measure_count_space sigma_finite_measure_count_space_finite lebesgue_integral_count_space_finite | 
| 1888 | cong del: setsum_cong intro!: setsum_mono_zero_left) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
50419diff
changeset | 1889 | finally have "\<H>(\<lambda>x. (X x, Y x)) = entropy b (count_space (Y ` space M) \<Otimes>\<^sub>M count_space (X ` space M)) (\<lambda>x. (Y x, X x))" . | 
| 47694 | 1890 | then show ?thesis | 
| 49791 | 1891 | unfolding conditional_entropy_eq_entropy_simple[OF Y X] by simp | 
| 36624 | 1892 | qed | 
| 1893 | ||
| 40859 | 1894 | lemma (in information_space) entropy_partition: | 
| 47694 | 1895 | assumes X: "simple_function M X" | 
| 1896 | shows "\<H>(X) = \<H>(f \<circ> X) + \<H>(X|f \<circ> X)" | |
| 36624 | 1897 | proof - | 
| 47694 | 1898 | note fX = simple_function_compose[OF X, of f] | 
| 1899 | have eq: "(\<lambda>x. ((f \<circ> X) x, X x)) ` space M = (\<lambda>x. (f x, x)) ` X ` space M" by auto | |
| 1900 | have inj: "\<And>A. inj_on (\<lambda>x. (f x, x)) A" | |
| 1901 | by (auto simp: inj_on_def) | |
| 1902 | show ?thesis | |
| 1903 | apply (subst entropy_chain_rule[symmetric, OF fX X]) | |
| 1904 | apply (subst entropy_simple_distributed[OF simple_distributedI[OF simple_function_Pair[OF fX X] refl]]) | |
| 1905 | apply (subst entropy_simple_distributed[OF simple_distributedI[OF X refl]]) | |
| 1906 | unfolding eq | |
| 1907 | apply (subst setsum_reindex[OF inj]) | |
| 1908 | apply (auto intro!: setsum_cong arg_cong[where f="\<lambda>A. prob A * log b (prob A)"]) | |
| 1909 | done | |
| 36624 | 1910 | qed | 
| 1911 | ||
| 40859 | 1912 | corollary (in information_space) entropy_data_processing: | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 1913 | assumes X: "simple_function M X" shows "\<H>(f \<circ> X) \<le> \<H>(X)" | 
| 40859 | 1914 | proof - | 
| 47694 | 1915 | note fX = simple_function_compose[OF X, of f] | 
| 1916 | from X have "\<H>(X) = \<H>(f\<circ>X) + \<H>(X|f\<circ>X)" by (rule entropy_partition) | |
| 40859 | 1917 | then show "\<H>(f \<circ> X) \<le> \<H>(X)" | 
| 47694 | 1918 | by (auto intro: conditional_entropy_nonneg[OF X fX]) | 
| 40859 | 1919 | qed | 
| 36624 | 1920 | |
| 40859 | 1921 | corollary (in information_space) entropy_of_inj: | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 1922 | assumes X: "simple_function M X" and inj: "inj_on f (X`space M)" | 
| 36624 | 1923 | shows "\<H>(f \<circ> X) = \<H>(X)" | 
| 1924 | proof (rule antisym) | |
| 40859 | 1925 | show "\<H>(f \<circ> X) \<le> \<H>(X)" using entropy_data_processing[OF X] . | 
| 36624 | 1926 | next | 
| 41689 
3e39b0e730d6
the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
 hoelzl parents: 
41661diff
changeset | 1927 | have sf: "simple_function M (f \<circ> X)" | 
| 40859 | 1928 | using X by auto | 
| 36624 | 1929 | have "\<H>(X) = \<H>(the_inv_into (X`space M) f \<circ> (f \<circ> X))" | 
| 47694 | 1930 | unfolding o_assoc | 
| 1931 | apply (subst entropy_simple_distributed[OF simple_distributedI[OF X refl]]) | |
| 1932 |     apply (subst entropy_simple_distributed[OF simple_distributedI[OF simple_function_compose[OF X]], where f="\<lambda>x. prob (X -` {x} \<inter> space M)"])
 | |
| 1933 | apply (auto intro!: setsum_cong arg_cong[where f=prob] image_eqI simp: the_inv_into_f_f[OF inj] comp_def) | |
| 1934 | done | |
| 36624 | 1935 | also have "... \<le> \<H>(f \<circ> X)" | 
| 40859 | 1936 | using entropy_data_processing[OF sf] . | 
| 36624 | 1937 | finally show "\<H>(X) \<le> \<H>(f \<circ> X)" . | 
| 1938 | qed | |
| 1939 | ||
| 36080 
0d9affa4e73c
Added Information theory and Example: dining cryptographers
 hoelzl parents: diff
changeset | 1940 | end |