src/HOL/Probability/Information.thy
author blanchet
Mon, 02 Jun 2014 17:34:25 +0200
changeset 57156 3546a67226ea
parent 56996 891e992e510f
child 57166 5cfcc616d485
permissions -rw-r--r--
removed counterexample parser (obsolete and useless in practice)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42067
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     1
(*  Title:      HOL/Probability/Information.thy
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     2
    Author:     Johannes Hölzl, TU München
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     3
    Author:     Armin Heller, TU München
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     4
*)
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     5
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     6
header {*Information theory*}
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     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: 41095
diff changeset
     9
imports
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
    10
  Independent_Family
43556
0d78c8d31d0d move conditional expectation to its own theory file
hoelzl
parents: 43340
diff changeset
    11
  Radon_Nikodym
41413
64cd30d6b0b8 explicit file specifications -- avoid secondary load path;
wenzelm
parents: 41095
diff 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
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    15
lemma log_le: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x \<le> y \<Longrightarrow> log a x \<le> log a y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    16
  by (subst log_le_cancel_iff) auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    17
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    18
lemma log_less: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> log a x < log a y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    19
  by (subst log_less_cancel_iff) auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    20
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    21
lemma setsum_cartesian_product':
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    22
  "(\<Sum>x\<in>A \<times> B. f x) = (\<Sum>x\<in>A. setsum (\<lambda>y. f (x, y)) B)"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    23
  unfolding setsum_cartesian_product by simp
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    24
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    25
lemma split_pairs:
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    26
  "((A, B) = X) \<longleftrightarrow> (fst X = A \<and> snd X = B)" and
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    27
  "(X = (A, B)) \<longleftrightarrow> (fst X = A \<and> snd X = B)" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    28
56994
8d5e5ec1cac3 fixed document generation for HOL-Probability
hoelzl
parents: 56993
diff changeset
    29
subsection "Information theory"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    30
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    31
locale information_space = prob_space +
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    32
  fixes b :: real assumes b_gt_1: "1 < b"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    33
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    34
context information_space
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    35
begin
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    36
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    37
text {* Introduce some simplification rules for logarithm of base @{term b}. *}
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    38
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    39
lemma log_neg_const:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    40
  assumes "x \<le> 0"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    41
  shows "log b x = log b 0"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
    42
proof -
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    43
  { fix u :: real
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    44
    have "x \<le> 0" by fact
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    45
    also have "0 < exp u"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    46
      using exp_gt_zero .
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    47
    finally have "exp u \<noteq> x"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    48
      by auto }
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    49
  then show "log b x = log b 0"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    50
    by (simp add: log_def ln_def)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    51
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    52
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    53
lemma log_mult_eq:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    54
  "log b (A * B) = (if 0 < A * B then log b \<bar>A\<bar> + log b \<bar>B\<bar> else log b 0)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    55
  using log_mult[of b "\<bar>A\<bar>" "\<bar>B\<bar>"] b_gt_1 log_neg_const[of "A * B"]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    56
  by (auto simp: zero_less_mult_iff mult_le_0_iff)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    57
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    58
lemma log_inverse_eq:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    59
  "log b (inverse B) = (if 0 < B then - log b B else log b 0)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    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
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    62
lemma log_divide_eq:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    63
  "log b (A / B) = (if 0 < A * B then log b \<bar>A\<bar> - log b \<bar>B\<bar> else log b 0)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    64
  unfolding divide_inverse log_mult_eq log_inverse_eq abs_inverse
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    65
  by (auto simp: zero_less_mult_iff mult_le_0_iff)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    66
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    67
lemmas log_simps = log_mult_eq log_inverse_eq log_divide_eq
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    68
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    69
end
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
    70
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    71
subsection "Kullback$-$Leibler divergence"
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
    72
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    73
text {* The Kullback$-$Leibler divergence is also known as relative entropy or
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    74
Kullback$-$Leibler distance. *}
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    75
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
    76
definition
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    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: 42148
diff changeset
    78
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
    79
definition
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 42148
diff changeset
    81
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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: 56571
diff changeset
    83
  unfolding entropy_density_def by auto
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
    84
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    85
lemma (in sigma_finite_measure) KL_density:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    86
  fixes f :: "'a \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    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: 56571
diff changeset
    88
  assumes f[measurable]: "f \<in> borel_measurable M" and nn: "AE x in M. 0 \<le> f x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    89
  shows "KL_divergence b M (density M f) = (\<integral>x. f x * log b (f x) \<partial>M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    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: 56571
diff 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: 56571
diff changeset
    92
  show [measurable]: "entropy_density b M (density M (\<lambda>x. ereal (f x))) \<in> borel_measurable M"
49776
199d1d5bb17e tuned product measurability
hoelzl
parents: 47694
diff changeset
    93
    using f
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
    94
    by (auto simp: comp_def entropy_density_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    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: 56571
diff changeset
    96
    using f nn by (intro density_RN_deriv_density) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    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: 56571
diff changeset
    98
    using f nn by (intro density_unique) (auto simp: RN_deriv_nonneg)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    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)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   101
    apply measurable
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   102
    using eq
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   103
    apply eventually_elim
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   104
    apply (auto simp: entropy_density_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   105
    done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   106
qed fact+
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   107
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   108
lemma (in sigma_finite_measure) KL_density_density:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   109
  fixes f g :: "'a \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   110
  assumes "1 < b"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   111
  assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   112
  assumes g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   113
  assumes ac: "AE x in M. f x = 0 \<longrightarrow> g x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   114
  shows "KL_divergence b (density M f) (density M g) = (\<integral>x. g x * log b (g x / f x) \<partial>M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   115
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   116
  interpret Mf: sigma_finite_measure "density M f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   117
    using f by (subst sigma_finite_iff_density_finite) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   118
  have "KL_divergence b (density M f) (density M g) =
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   119
    KL_divergence b (density M f) (density (density M f) (\<lambda>x. g x / f x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   120
    using f g ac by (subst density_density_divide) simp_all
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56544
diff changeset
   122
    using f g `1 < b` by (intro Mf.KL_density) (auto simp: AE_density)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   123
  also have "\<dots> = (\<integral>x. g x * log b (g x / f x) \<partial>M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   124
    using ac f g `1 < b` by (subst integral_density) (auto intro!: integral_cong_AE)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   125
  finally show ?thesis .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   126
qed
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   127
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   128
lemma (in information_space) KL_gt_0:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   129
  fixes D :: "'a \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   130
  assumes "prob_space (density M D)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   131
  assumes D: "D \<in> borel_measurable M" "AE x in M. 0 \<le> D x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   132
  assumes int: "integrable M (\<lambda>x. D x * log b (D x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   133
  assumes A: "density M D \<noteq> M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   134
  shows "0 < KL_divergence b M (density M D)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   135
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   136
  interpret N: prob_space "density M D" by fact
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   137
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   138
  obtain A where "A \<in> sets M" "emeasure (density M D) A \<noteq> emeasure M A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   139
    using measure_eqI[of "density M D" M] `density M D \<noteq> M` by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   140
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   141
  let ?D_set = "{x\<in>space M. D x \<noteq> 0}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   142
  have [simp, intro]: "?D_set \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   143
    using D by auto
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   144
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   145
  have D_neg: "(\<integral>\<^sup>+ x. ereal (- D x) \<partial>M) = 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   146
    using D by (subst nn_integral_0_iff_AE) auto
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   147
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   148
  have "(\<integral>\<^sup>+ x. ereal (D x) \<partial>M) = emeasure (density M D) (space M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   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: 50419
diff changeset
   150
  then have D_pos: "(\<integral>\<^sup>+ x. ereal (D x) \<partial>M) = 1"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   151
    using N.emeasure_space_1 by simp
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   152
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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: 56571
diff 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: 56571
diff 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: 56571
diff 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: 42148
diff changeset
   157
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   158
  have "0 \<le> 1 - measure M ?D_set"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   159
    using prob_le_1 by (auto simp: field_simps)
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 50419
diff changeset
   161
    using `integrable M D` `integral\<^sup>L M D = 1`
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   162
    by (simp add: emeasure_eq_measure)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   164
  proof (rule integral_less_AE)
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 56571
diff changeset
   166
      using `integrable M D` by auto
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   167
  next
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
   168
    from integrable_mult_left(1)[OF int, of "ln b"]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   169
    show "integrable M (\<lambda>x. D x * (ln b * log b (D x)))" 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   170
      by (simp add: ac_simps)
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   171
  next
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   173
    proof
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   174
      assume eq_0: "emeasure M {x\<in>space M. D x \<noteq> 1 \<and> D x \<noteq> 0} = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50003
diff 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: 42148
diff changeset
   177
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 42148
diff 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: 50419
diff changeset
   180
      also have "\<dots> = (\<integral>\<^sup>+ x. ereal (D x) \<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   181
        using disj by (auto intro!: nn_integral_cong_AE simp: indicator_def one_ereal_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   182
      finally have "AE x in M. D x = 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff changeset
   184
      then have "(\<integral>\<^sup>+x. indicator A x\<partial>M) = (\<integral>\<^sup>+x. ereal (D x) * indicator A x\<partial>M)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   185
        by (intro nn_integral_cong_AE) (auto simp: one_ereal_def[symmetric])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   186
      also have "\<dots> = density M D A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   187
        using `A \<in> sets M` D by (simp add: emeasure_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   189
    qed
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 50003
diff changeset
   191
      using D(1) by (auto intro: sets.sets_Collect_conj)
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   192
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   193
    show "AE t in M. t \<in> {x\<in>space M. D x \<noteq> 1 \<and> D x \<noteq> 0} \<longrightarrow>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   195
      using D(2)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   196
    proof (eventually_elim, safe)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   197
      fix t assume Dt: "t \<in> space M" "D t \<noteq> 1" "D t \<noteq> 0" "0 \<le> D t"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   199
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   200
      have "D t - 1 = D t - indicator ?D_set t"
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   201
        using Dt by simp
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   202
      also note eq
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   203
      also have "D t * (ln b * log b (D t)) = - D t * ln (1 / D t)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   204
        using b_gt_1 `D t \<noteq> 0` `0 \<le> D t`
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   205
        by (simp add: log_def ln_div less_le)
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   206
      finally have "ln (1 / D t) = 1 / D t - 1"
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   207
        using `D t \<noteq> 0` by (auto simp: field_simps)
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 42148
diff changeset
   209
      show False by auto
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   210
    qed
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   211
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   212
    show "AE t in M. D t - indicator ?D_set t \<le> D t * (ln b * log b (D t))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   213
      using D(2) AE_space
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   214
    proof eventually_elim
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   215
      fix t assume "t \<in> space M" "0 \<le> D t"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   217
      proof cases
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   218
        assume asm: "D t \<noteq> 0"
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 42148
diff changeset
   220
        then have "0 < 1 / D t" by auto
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 42148
diff changeset
   222
          using asm `t \<in> space M` by (simp add: field_simps)
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 42148
diff changeset
   224
          using ln_le_minus_one `0 < 1 / D t` by (intro mult_left_mono_neg) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   225
        also have "\<dots> = D t * (ln b * log b (D t))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   226
          using `0 < D t` b_gt_1
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   227
          by (simp_all add: log_def ln_div)
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   228
        finally show ?thesis by simp
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   229
      qed simp
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   230
    qed
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   231
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   232
  also have "\<dots> = (\<integral> x. ln b * (D x * log b (D x)) \<partial>M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   233
    by (simp add: ac_simps)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   235
    using int by simp
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   236
  finally show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   238
qed
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   239
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   241
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   242
  have "AE x in M. 1 = RN_deriv M M x"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   243
  proof (rule RN_deriv_unique)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   244
    show "(\<lambda>x. 1) \<in> borel_measurable M" "AE x in M. 0 \<le> (1 :: ereal)" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   245
    show "density M (\<lambda>x. 1) = M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   246
      apply (auto intro!: measure_eqI emeasure_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   247
      apply (subst emeasure_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   248
      apply auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   249
      done
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   250
  qed
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff 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: 56571
diff 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: 50419
diff 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: 42148
diff changeset
   255
    by (simp add: entropy_density_def comp_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   256
  then show "KL_divergence b M M = 0"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   257
    unfolding KL_divergence_def
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   258
    by auto
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   259
qed
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   260
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   261
lemma (in information_space) KL_eq_0_iff_eq:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   262
  fixes D :: "'a \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   263
  assumes "prob_space (density M D)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   264
  assumes D: "D \<in> borel_measurable M" "AE x in M. 0 \<le> D x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   265
  assumes int: "integrable M (\<lambda>x. D x * log b (D x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   266
  shows "KL_divergence b M (density M D) = 0 \<longleftrightarrow> density M D = M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   267
  using KL_same_eq_0[of b] KL_gt_0[OF assms]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   268
  by (auto simp: less_le)
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   269
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   270
lemma (in information_space) KL_eq_0_iff_eq_ac:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   271
  fixes D :: "'a \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   272
  assumes "prob_space N"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   273
  assumes ac: "absolutely_continuous M N" "sets N = sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   274
  assumes int: "integrable N (entropy_density b M N)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   275
  shows "KL_divergence b M N = 0 \<longleftrightarrow> N = M"
41833
563bea92b2c0 add lemma KL_divergence_vimage, mutual_information_generic
hoelzl
parents: 41689
diff changeset
   276
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   277
  interpret N: prob_space N by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   278
  have "finite_measure N" by unfold_locales
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   279
  from real_RN_deriv[OF this ac] guess D . note D = this
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   280
  
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   281
  have "N = density M (RN_deriv M N)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   282
    using ac by (rule density_RN_deriv[symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   284
    using D by (auto intro!: density_cong)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   285
  finally have N: "N = density M D" .
41833
563bea92b2c0 add lemma KL_divergence_vimage, mutual_information_generic
hoelzl
parents: 41689
diff changeset
   286
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   287
  from absolutely_continuous_AE[OF ac(2,1) D(2)] D b_gt_1 ac measurable_entropy_density
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   288
  have "integrable N (\<lambda>x. log b (D x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   289
    by (intro integrable_cong_AE[THEN iffD2, OF _ _ _ int])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   290
       (auto simp: N entropy_density_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   292
    by (subst integrable_real_density[symmetric]) (auto simp: N[symmetric] comp_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   293
  with `prob_space N` D show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   294
    unfolding N
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   295
    by (intro KL_eq_0_iff_eq) auto
41833
563bea92b2c0 add lemma KL_divergence_vimage, mutual_information_generic
hoelzl
parents: 41689
diff changeset
   296
qed
563bea92b2c0 add lemma KL_divergence_vimage, mutual_information_generic
hoelzl
parents: 41689
diff changeset
   297
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   298
lemma (in information_space) KL_nonneg:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   299
  assumes "prob_space (density M D)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   300
  assumes D: "D \<in> borel_measurable M" "AE x in M. 0 \<le> D x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   301
  assumes int: "integrable M (\<lambda>x. D x * log b (D x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   302
  shows "0 \<le> KL_divergence b M (density M D)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   303
  using KL_gt_0[OF assms] by (cases "density M D = M") (auto simp: KL_same_eq_0)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   304
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   305
lemma (in sigma_finite_measure) KL_density_density_nonneg:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   306
  fixes f g :: "'a \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   307
  assumes "1 < b"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   308
  assumes f: "f \<in> borel_measurable M" "AE x in M. 0 \<le> f x" "prob_space (density M f)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   309
  assumes g: "g \<in> borel_measurable M" "AE x in M. 0 \<le> g x" "prob_space (density M g)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   310
  assumes ac: "AE x in M. f x = 0 \<longrightarrow> g x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   311
  assumes int: "integrable M (\<lambda>x. g x * log b (g x / f x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   312
  shows "0 \<le> KL_divergence b (density M f) (density M g)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   313
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   314
  interpret Mf: prob_space "density M f" by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   315
  interpret Mf: information_space "density M f" b by default fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   316
  have eq: "density (density M f) (\<lambda>x. g x / f x) = density M g" (is "?DD = _")
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   319
  have "0 \<le> KL_divergence b (density M f) (density (density M f) (\<lambda>x. g x / f x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   320
  proof (rule Mf.KL_nonneg)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   321
    show "prob_space ?DD" unfolding eq by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   322
    from f g show "(\<lambda>x. g x / f x) \<in> borel_measurable (density M f)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   323
      by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56544
diff changeset
   325
      using f g by (auto simp: AE_density)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   326
    show "integrable (density M f) (\<lambda>x. g x / f x * log b (g x / f x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   328
      by (subst integrable_density)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   329
         (auto intro!: integrable_cong_AE[THEN iffD2, OF _ _ _ int] measurable_If)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   330
  qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   331
  also have "\<dots> = KL_divergence b (density M f) (density M g)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   332
    using f g ac by (subst density_density_divide) simp_all
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   336
subsection {* Finite Entropy *}
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   337
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   338
definition (in information_space) 
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   339
  "finite_entropy S X f \<longleftrightarrow> distributed M S X f \<and> integrable S (\<lambda>x. f x * log b (f x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   340
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   341
lemma (in information_space) finite_entropy_simple_function:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   342
  assumes X: "simple_function M X"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   343
  shows "finite_entropy (count_space (X`space M)) X (\<lambda>a. measure M {x \<in> space M. X x = a})"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   344
  unfolding finite_entropy_def
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   345
proof
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   346
  have [simp]: "finite (X ` space M)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   347
    using X by (auto simp: simple_function_def)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   348
  then show "integrable (count_space (X ` space M))
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   349
     (\<lambda>x. prob {xa \<in> space M. X xa = x} * log b (prob {xa \<in> space M. X xa = x}))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   350
    by (rule integrable_count_space)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   352
    by (rule distributed_simple_function_superset[OF X]) (auto intro!: arg_cong[where f=prob])
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   353
  show "distributed M (count_space (X ` space M)) X (\<lambda>x. ereal (prob {xa \<in> space M. X xa = x}))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   354
    by (rule distributed_cong_density[THEN iffD1, OF _ _ _ d]) auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   355
qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   356
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   357
lemma distributed_transform_AE:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   358
  assumes T: "T \<in> measurable P Q" "absolutely_continuous Q (distr P Q T)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   359
  assumes g: "distributed M Q Y g"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   360
  shows "AE x in P. 0 \<le> g (T x)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   361
  using g
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   362
  apply (subst AE_distr_iff[symmetric, OF T(1)])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   363
  apply simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   364
  apply (rule absolutely_continuous_AE[OF _ T(2)])
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   365
  apply simp
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   366
  apply (simp add: distributed_AE)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   367
  done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   368
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   369
lemma ac_fst:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   371
  shows "absolutely_continuous S (distr (S \<Otimes>\<^sub>M T) S fst)"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   372
proof -
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   373
  interpret sigma_finite_measure T by fact
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff 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: 53015
diff 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: 50003
diff 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: 53015
diff changeset
   377
    with A have "emeasure (S \<Otimes>\<^sub>M T) (fst -` A \<inter> space (S \<Otimes>\<^sub>M T)) = 0"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   378
      by (simp add: emeasure_pair_measure_Times) }
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   379
  then show ?thesis
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   380
    unfolding absolutely_continuous_def
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   381
    apply (auto simp: null_sets_distr_iff)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   382
    apply (auto simp: null_sets_def intro!: measurable_sets)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   383
    done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   384
qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   385
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   386
lemma ac_snd:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   388
  shows "absolutely_continuous T (distr (S \<Otimes>\<^sub>M T) T snd)"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   389
proof -
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   390
  interpret sigma_finite_measure T by fact
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff 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: 53015
diff 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: 50003
diff 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: 53015
diff changeset
   394
    with A have "emeasure (S \<Otimes>\<^sub>M T) (snd -` A \<inter> space (S \<Otimes>\<^sub>M T)) = 0"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   395
      by (simp add: emeasure_pair_measure_Times) }
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   396
  then show ?thesis
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   397
    unfolding absolutely_continuous_def
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   398
    apply (auto simp: null_sets_distr_iff)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   399
    apply (auto simp: null_sets_def intro!: measurable_sets)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   400
    done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   401
qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   402
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   403
lemma distributed_integrable:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   404
  "distributed M N X f \<Longrightarrow> g \<in> borel_measurable N \<Longrightarrow>
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   405
    integrable N (\<lambda>x. f x * g x) \<longleftrightarrow> integrable M (\<lambda>x. g (X x))"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   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: 56571
diff changeset
   407
                    distributed_distr_eq_density[symmetric] integrable_real_density[symmetric] integrable_distr_eq)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   408
  
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   409
lemma distributed_transform_integrable:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   410
  assumes Px: "distributed M N X Px"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   411
  assumes "distributed M P Y Py"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   412
  assumes Y: "Y = (\<lambda>x. T (X x))" and T: "T \<in> measurable N P" and f: "f \<in> borel_measurable P"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   413
  shows "integrable P (\<lambda>x. Py x * f x) \<longleftrightarrow> integrable N (\<lambda>x. Px x * f (T x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   414
proof -
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   415
  have "integrable P (\<lambda>x. Py x * f x) \<longleftrightarrow> integrable M (\<lambda>x. f (Y x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   416
    by (rule distributed_integrable) fact+
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   417
  also have "\<dots> \<longleftrightarrow> integrable M (\<lambda>x. f (T (X x)))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   418
    using Y by simp
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   419
  also have "\<dots> \<longleftrightarrow> integrable N (\<lambda>x. Px x * f (T x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   420
    using measurable_comp[OF T f] Px by (intro distributed_integrable[symmetric]) (auto simp: comp_def)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   421
  finally show ?thesis .
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   422
qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   423
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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: 56571
diff 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: 56571
diff changeset
   426
  using integrable_cong_AE[of f M g] by (auto simp: eq_commute)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   427
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   428
lemma (in information_space) finite_entropy_integrable:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   429
  "finite_entropy S X Px \<Longrightarrow> integrable S (\<lambda>x. Px x * log b (Px x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   430
  unfolding finite_entropy_def by auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   431
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   432
lemma (in information_space) finite_entropy_distributed:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   433
  "finite_entropy S X Px \<Longrightarrow> distributed M S X Px"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   434
  unfolding finite_entropy_def by auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   435
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   436
lemma (in information_space) finite_entropy_integrable_transform:
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   437
  assumes Fx: "finite_entropy S X Px"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   438
  assumes Fy: "distributed M T Y Py"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   439
    and "X = (\<lambda>x. f (Y x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   440
    and "f \<in> measurable T S"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   441
  shows "integrable T (\<lambda>x. Py x * log b (Px (f x)))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   442
  using assms unfolding finite_entropy_def
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   443
  using distributed_transform_integrable[of M T Y Py S X Px f "\<lambda>x. log b (Px x)"]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   444
  by auto
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   445
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   446
subsection {* Mutual Information *}
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   447
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
   448
definition (in prob_space)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36649
diff changeset
   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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   452
lemma (in information_space) mutual_information_indep_vars:
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff 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: 50419
diff 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: 50419
diff 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: 42148
diff changeset
   456
  shows "indep_var S X T Y \<longleftrightarrow>
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   457
    (random_variable S X \<and> random_variable T Y \<and>
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   458
      absolutely_continuous P Q \<and> integrable Q (entropy_density b P Q) \<and>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   459
      mutual_information b S T X Y = 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   460
  unfolding indep_var_distribution_eq
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   461
proof safe
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   462
  assume rv[measurable]: "random_variable S X" "random_variable T Y"
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   463
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   464
  interpret X: prob_space "distr M S X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   465
    by (rule prob_space_distr) fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   466
  interpret Y: prob_space "distr M T Y"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   467
    by (rule prob_space_distr) fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   468
  interpret XY: pair_prob_space "distr M S X" "distr M T Y" by default
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   470
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   471
  interpret Q: prob_space Q unfolding Q_def
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   472
    by (rule prob_space_distr) simp
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   473
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   476
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   477
    show ac: "absolutely_continuous P Q" by (simp add: absolutely_continuous_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   479
      by simp
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   480
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   481
    have "AE x in P. 1 = RN_deriv P Q x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   482
    proof (rule P.RN_deriv_unique)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   483
      show "density P (\<lambda>x. 1) = Q"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   484
        unfolding `Q = P` by (intro measure_eqI) (auto simp: emeasure_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   485
    qed auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   486
    then have ae_0: "AE x in P. entropy_density b P Q x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   488
    then have "integrable P (entropy_density b P Q) \<longleftrightarrow> integrable Q (\<lambda>x. 0::real)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   489
      using ed unfolding `Q = P` by (intro integrable_cong_AE) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   490
    then show "integrable Q (entropy_density b P Q)" by simp
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   491
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
   492
    from ae_0 have "mutual_information b S T X Y = (\<integral>x. 0 \<partial>P)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff 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: 56571
diff 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: 56571
diff changeset
   496
      by simp }
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   497
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   498
  { assume ac: "absolutely_continuous P Q"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   499
    assume int: "integrable Q (entropy_density b P Q)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 42148
diff changeset
   501
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   502
    have eq: "Q = P"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   503
    proof (rule P.KL_eq_0_iff_eq_ac[THEN iffD1])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   504
      show "prob_space Q" by unfold_locales
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   505
      show "absolutely_continuous P Q" by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   506
      show "integrable Q (entropy_density b P Q)" by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   507
      show "sets Q = sets P" by (simp add: P_def Q_def sets_pair_measure)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   508
      show "KL_divergence b P Q = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   509
        using I_eq_0 unfolding mutual_information_def by (simp add: P_def Q_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   510
    qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   512
      unfolding P_def Q_def .. }
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   513
qed
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 42148
diff changeset
   514
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   515
abbreviation (in information_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   516
  mutual_information_Pow ("\<I>'(_ ; _')") where
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 41661
diff changeset
   518
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   519
lemma (in information_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   520
  fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   521
  assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   523
  assumes Fxy: "finite_entropy (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   526
    and mutual_information_nonneg': "0 \<le> mutual_information b S T X Y"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   527
proof -
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   528
  have Px: "distributed M S X Px"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   529
    using Fx by (auto simp: finite_entropy_def)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   530
  have Py: "distributed M T Y Py"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   532
  have Pxy: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   533
    using Fxy by (auto simp: finite_entropy_def)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   534
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   535
  have X: "random_variable S X"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   536
    using Px by auto
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   537
  have Y: "random_variable T Y"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   538
    using Py by auto
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   539
  interpret S: sigma_finite_measure S by fact
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   540
  interpret T: sigma_finite_measure T by fact
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   541
  interpret ST: pair_sigma_finite S T ..
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   542
  interpret X: prob_space "distr M S X" using X by (rule prob_space_distr)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   543
  interpret Y: prob_space "distr M T Y" using Y by (rule prob_space_distr)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   545
  let ?P = "S \<Otimes>\<^sub>M T"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   546
  let ?D = "distr M ?P (\<lambda>x. (X x, Y x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   547
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   548
  { fix A assume "A \<in> sets S"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   549
    with X Y have "emeasure (distr M S X) A = emeasure ?D (A \<times> space T)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   550
      by (auto simp: emeasure_distr measurable_Pair measurable_space
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   551
               intro!: arg_cong[where f="emeasure M"]) }
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   552
  note marginal_eq1 = this
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   553
  { fix A assume "A \<in> sets T"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   554
    with X Y have "emeasure (distr M T Y) A = emeasure ?D (space S \<times> A)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   555
      by (auto simp: emeasure_distr measurable_Pair measurable_space
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   556
               intro!: arg_cong[where f="emeasure M"]) }
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   557
  note marginal_eq2 = this
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   558
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   559
  have eq: "(\<lambda>x. ereal (Px (fst x) * Py (snd x))) = (\<lambda>(x, y). ereal (Px x) * ereal (Py y))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   560
    by auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   561
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   563
    unfolding Px(1)[THEN distributed_distr_eq_density] Py(1)[THEN distributed_distr_eq_density] eq
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   564
  proof (subst pair_measure_density)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   565
    show "(\<lambda>x. ereal (Px x)) \<in> borel_measurable S" "(\<lambda>y. ereal (Py y)) \<in> borel_measurable T"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   566
      "AE x in S. 0 \<le> ereal (Px x)" "AE y in T. 0 \<le> ereal (Py y)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   567
      using Px Py by (auto simp: distributed_def)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   568
    show "sigma_finite_measure (density T Py)" unfolding Py(1)[THEN distributed_distr_eq_density, symmetric] ..
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   569
  qed (fact | simp)+
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   570
  
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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)))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   572
    unfolding mutual_information_def distr_eq Pxy(1)[THEN distributed_distr_eq_density] ..
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   573
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   574
  from Px Py have f: "(\<lambda>x. Px (fst x) * Py (snd x)) \<in> borel_measurable ?P"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   575
    by (intro borel_measurable_times) (auto intro: distributed_real_measurable measurable_fst'' measurable_snd'')
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   576
  have PxPy_nonneg: "AE x in ?P. 0 \<le> Px (fst x) * Py (snd x)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   577
  proof (rule ST.AE_pair_measure)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   578
    show "{x \<in> space ?P. 0 \<le> Px (fst x) * Py (snd x)} \<in> sets ?P"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   579
      using f by auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   580
    show "AE x in S. AE y in T. 0 \<le> Px (fst (x, y)) * Py (snd (x, y))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   581
      using Px Py by (auto simp: zero_le_mult_iff dest!: distributed_real_AE)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   582
  qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   583
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   584
  have "(AE x in ?P. Px (fst x) = 0 \<longrightarrow> Pxy x = 0)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   585
    by (rule subdensity_real[OF measurable_fst Pxy Px]) auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   586
  moreover
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   587
  have "(AE x in ?P. Py (snd x) = 0 \<longrightarrow> Pxy x = 0)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   588
    by (rule subdensity_real[OF measurable_snd Pxy Py]) auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   589
  ultimately have ac: "AE x in ?P. Px (fst x) * Py (snd x) = 0 \<longrightarrow> Pxy x = 0"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   590
    by eventually_elim auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   591
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   592
  show "?M = ?R"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   593
    unfolding M f_def
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   594
    using b_gt_1 f PxPy_nonneg Pxy[THEN distributed_real_measurable] Pxy[THEN distributed_real_AE] ac
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   595
    by (rule ST.KL_density_density)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   596
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   597
  have X: "X = fst \<circ> (\<lambda>x. (X x, Y x))" and Y: "Y = snd \<circ> (\<lambda>x. (X x, Y x))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   598
    by auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   599
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   601
    using finite_entropy_integrable[OF Fxy]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   602
    using finite_entropy_integrable_transform[OF Fx Pxy, of fst]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   603
    using finite_entropy_integrable_transform[OF Fy Pxy, of snd]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   604
    by simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   605
  moreover have "f \<in> borel_measurable (S \<Otimes>\<^sub>M T)"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   606
    unfolding f_def using Px Py Pxy
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   607
    by (auto intro: distributed_real_measurable measurable_fst'' measurable_snd''
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   609
  ultimately have int: "integrable (S \<Otimes>\<^sub>M T) f"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   610
    apply (rule integrable_cong_AE_imp)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   611
    using
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   612
      distributed_transform_AE[OF measurable_fst ac_fst, of T, OF T Px]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   613
      distributed_transform_AE[OF measurable_snd ac_snd, of _ _ _ _ S, OF T Py]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   614
      subdensity_real[OF measurable_fst Pxy Px X]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   615
      subdensity_real[OF measurable_snd Pxy Py Y]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   616
      distributed_real_AE[OF Pxy]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   617
    by eventually_elim
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56479
diff changeset
   618
       (auto simp: f_def log_divide_eq log_mult_eq field_simps zero_less_mult_iff)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   619
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   620
  show "0 \<le> ?M" unfolding M
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   621
  proof (rule ST.KL_density_density_nonneg
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   623
    show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Pxy x))) "
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   624
      unfolding distributed_distr_eq_density[OF Pxy, symmetric]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   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: 50419
diff changeset
   626
    show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Px (fst x) * Py (snd x))))"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   627
      unfolding distr_eq[symmetric] by unfold_locales
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   628
  qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   629
qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   630
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   631
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   632
lemma (in information_space)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
   633
  fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   634
  assumes "sigma_finite_measure S" "sigma_finite_measure T"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff changeset
   636
  assumes Pxy: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff 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: 50419
diff changeset
   639
    and mutual_information_nonneg: "integrable (S \<Otimes>\<^sub>M T) f \<Longrightarrow> 0 \<le> mutual_information b S T X Y"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   640
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   641
  have X: "random_variable S X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   642
    using Px by (auto simp: distributed_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   643
  have Y: "random_variable T Y"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   644
    using Py by (auto simp: distributed_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   645
  interpret S: sigma_finite_measure S by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   646
  interpret T: sigma_finite_measure T by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   647
  interpret ST: pair_sigma_finite S T ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   648
  interpret X: prob_space "distr M S X" using X by (rule prob_space_distr)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   649
  interpret Y: prob_space "distr M T Y" using Y by (rule prob_space_distr)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff changeset
   651
  let ?P = "S \<Otimes>\<^sub>M T"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   652
  let ?D = "distr M ?P (\<lambda>x. (X x, Y x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   653
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   654
  { fix A assume "A \<in> sets S"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   655
    with X Y have "emeasure (distr M S X) A = emeasure ?D (A \<times> space T)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   656
      by (auto simp: emeasure_distr measurable_Pair measurable_space
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   657
               intro!: arg_cong[where f="emeasure M"]) }
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   658
  note marginal_eq1 = this
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   659
  { fix A assume "A \<in> sets T"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   660
    with X Y have "emeasure (distr M T Y) A = emeasure ?D (space S \<times> A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   661
      by (auto simp: emeasure_distr measurable_Pair measurable_space
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   662
               intro!: arg_cong[where f="emeasure M"]) }
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   663
  note marginal_eq2 = this
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   664
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   665
  have eq: "(\<lambda>x. ereal (Px (fst x) * Py (snd x))) = (\<lambda>(x, y). ereal (Px x) * ereal (Py y))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   666
    by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   667
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   669
    unfolding Px(1)[THEN distributed_distr_eq_density] Py(1)[THEN distributed_distr_eq_density] eq
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   670
  proof (subst pair_measure_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   671
    show "(\<lambda>x. ereal (Px x)) \<in> borel_measurable S" "(\<lambda>y. ereal (Py y)) \<in> borel_measurable T"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   672
      "AE x in S. 0 \<le> ereal (Px x)" "AE y in T. 0 \<le> ereal (Py y)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   673
      using Px Py by (auto simp: distributed_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   674
    show "sigma_finite_measure (density T Py)" unfolding Py(1)[THEN distributed_distr_eq_density, symmetric] ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   675
  qed (fact | simp)+
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   676
  
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   678
    unfolding mutual_information_def distr_eq Pxy(1)[THEN distributed_distr_eq_density] ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   679
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   680
  from Px Py have f: "(\<lambda>x. Px (fst x) * Py (snd x)) \<in> borel_measurable ?P"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   681
    by (intro borel_measurable_times) (auto intro: distributed_real_measurable measurable_fst'' measurable_snd'')
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   682
  have PxPy_nonneg: "AE x in ?P. 0 \<le> Px (fst x) * Py (snd x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   683
  proof (rule ST.AE_pair_measure)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   684
    show "{x \<in> space ?P. 0 \<le> Px (fst x) * Py (snd x)} \<in> sets ?P"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   685
      using f by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   686
    show "AE x in S. AE y in T. 0 \<le> Px (fst (x, y)) * Py (snd (x, y))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   687
      using Px Py by (auto simp: zero_le_mult_iff dest!: distributed_real_AE)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   688
  qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   689
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   690
  have "(AE x in ?P. Px (fst x) = 0 \<longrightarrow> Pxy x = 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   691
    by (rule subdensity_real[OF measurable_fst Pxy Px]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   692
  moreover
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   693
  have "(AE x in ?P. Py (snd x) = 0 \<longrightarrow> Pxy x = 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   694
    by (rule subdensity_real[OF measurable_snd Pxy Py]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   695
  ultimately have ac: "AE x in ?P. Px (fst x) * Py (snd x) = 0 \<longrightarrow> Pxy x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   696
    by eventually_elim auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   697
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   698
  show "?M = ?R"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   699
    unfolding M f_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   700
    using b_gt_1 f PxPy_nonneg Pxy[THEN distributed_real_measurable] Pxy[THEN distributed_real_AE] ac
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   701
    by (rule ST.KL_density_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   702
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   703
  assume int: "integrable (S \<Otimes>\<^sub>M T) f"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   704
  show "0 \<le> ?M" unfolding M
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   705
  proof (rule ST.KL_density_density_nonneg
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff changeset
   707
    show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Pxy x))) "
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   708
      unfolding distributed_distr_eq_density[OF Pxy, symmetric]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff changeset
   710
    show "prob_space (density (S \<Otimes>\<^sub>M T) (\<lambda>x. ereal (Px (fst x) * Py (snd x))))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   711
      unfolding distr_eq[symmetric] by unfold_locales
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   712
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   713
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   714
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   715
lemma (in information_space)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   716
  fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff 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: 56571
diff changeset
   719
  assumes Pxy[measurable]: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   720
  assumes ae: "AE x in S. AE y in T. Pxy (x, y) = Px x * Py y"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   721
  shows mutual_information_eq_0: "mutual_information b S T X Y = 0"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
   722
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   723
  interpret S: sigma_finite_measure S by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   724
  interpret T: sigma_finite_measure T by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff changeset
   727
  have "AE x in S \<Otimes>\<^sub>M T. Px (fst x) = 0 \<longrightarrow> Pxy x = 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   728
    by (rule subdensity_real[OF measurable_fst Pxy Px]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   729
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   730
  have "AE x in S \<Otimes>\<^sub>M T. Py (snd x) = 0 \<longrightarrow> Pxy x = 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   731
    by (rule subdensity_real[OF measurable_snd Pxy Py]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   732
  moreover 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   733
  have "AE x in S \<Otimes>\<^sub>M T. Pxy x = Px (fst x) * Py (snd x)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   734
    using distributed_real_measurable[OF Px] distributed_real_measurable[OF Py] distributed_real_measurable[OF Pxy]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   737
    by eventually_elim simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 56571
diff changeset
   739
    by (intro integral_cong_AE) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   740
  then show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   744
lemma (in information_space) mutual_information_simple_distributed:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   745
  assumes X: "simple_distributed M X Px" and Y: "simple_distributed M Y Py"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   746
  assumes XY: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   748
proof (subst mutual_information_distr[OF _ _ simple_distributed[OF X] simple_distributed[OF Y] simple_distributed_joint[OF XY]])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   749
  note fin = simple_distributed_joint_finite[OF XY, simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   750
  show "sigma_finite_measure (count_space (X ` space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   751
    by (simp add: sigma_finite_measure_count_space_finite)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   752
  show "sigma_finite_measure (count_space (Y ` space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   753
    by (simp add: sigma_finite_measure_count_space_finite)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   754
  let ?Pxy = "\<lambda>x. (if x \<in> (\<lambda>x. (X x, Y x)) ` space M then Pxy x else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   755
  let ?f = "\<lambda>x. ?Pxy x * log b (?Pxy x / (Px (fst x) * Py (snd x)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   757
    by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   758
  with fin show "(\<integral> x. ?f x \<partial>(count_space (X ` space M) \<Otimes>\<^sub>M count_space (Y ` space M))) =
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   760
    by (auto simp add: pair_measure_count_space lebesgue_integral_count_space_finite setsum_cases split_beta'
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   761
             intro!: setsum_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   762
qed
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
   763
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   764
lemma (in information_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   765
  fixes Pxy :: "'b \<times> 'c \<Rightarrow> real" and Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   766
  assumes Px: "simple_distributed M X Px" and Py: "simple_distributed M Y Py"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   767
  assumes Pxy: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   768
  assumes ae: "\<forall>x\<in>space M. Pxy (X x, Y x) = Px (X x) * Py (Y x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   769
  shows mutual_information_eq_0_simple: "\<I>(X ; Y) = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   770
proof (subst mutual_information_simple_distributed[OF Px Py Pxy])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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))) =
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   772
    (\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   773
    by (intro setsum_cong) (auto simp: ae)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   774
  then show "(\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M.
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   775
    Pxy (x, y) * log b (Pxy (x, y) / (Px x * Py y))) = 0" by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   776
qed
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
   777
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   778
subsection {* Entropy *}
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   779
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   780
definition (in prob_space) entropy :: "real \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> real" where
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   781
  "entropy b S X = - KL_divergence b S (distr M S X)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   782
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   783
abbreviation (in information_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   784
  entropy_Pow ("\<H>'(_')") where
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 41833
diff changeset
   786
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   787
lemma (in prob_space) distributed_RN_deriv:
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   788
  assumes X: "distributed M S X Px"
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   789
  shows "AE x in S. RN_deriv S (density S Px) x = Px x"
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   790
proof -
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   791
  note D = distributed_measurable[OF X] distributed_borel_measurable[OF X] distributed_AE[OF X]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   792
  interpret X: prob_space "distr M S X"
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   793
    using D(1) by (rule prob_space_distr)
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   794
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   795
  have sf: "sigma_finite_measure (distr M S X)" by default
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   796
  show ?thesis
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   797
    using D
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   798
    apply (subst eq_commute)
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   799
    apply (intro RN_deriv_unique_sigma_finite)
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
   800
    apply (auto simp: distributed_distr_eq_density[symmetric, OF X] sf measure_nonneg)
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   801
    done
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   802
qed
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   803
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff changeset
   804
lemma (in information_space)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 56571
diff changeset
   806
  assumes X[measurable]: "distributed M MX X f"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff 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: 49787
diff changeset
   808
proof -
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   809
  note D = distributed_measurable[OF X] distributed_borel_measurable[OF X] distributed_AE[OF X]
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
   810
  note ae = distributed_RN_deriv[OF X]
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff changeset
   811
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff changeset
   812
  have ae_eq: "AE x in distr M MX X. log b (real (RN_deriv MX (distr M MX X) x)) =
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   813
    log b (f x)"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   814
    unfolding distributed_distr_eq_density[OF X]
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   815
    apply (subst AE_density)
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   816
    using D apply simp
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   817
    using ae apply eventually_elim
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   818
    apply auto
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   819
    done
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff changeset
   820
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   822
    unfolding distributed_distr_eq_density[OF X]
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   823
    using D
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   824
    by (subst integral_density)
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   825
       (auto simp: borel_measurable_ereal_iff)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff changeset
   826
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff 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: 56571
diff 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: 56571
diff changeset
   829
    using ae_eq by (intro integral_cong_AE) auto
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49787
diff changeset
   830
qed
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   831
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   832
lemma (in prob_space) distributed_imp_emeasure_nonzero:
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   833
  assumes X: "distributed M MX X Px"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   834
  shows "emeasure MX {x \<in> space MX. Px x \<noteq> 0} \<noteq> 0"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   835
proof
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   836
  note Px = distributed_borel_measurable[OF X] distributed_AE[OF X]
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   837
  interpret X: prob_space "distr M MX X"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   838
    using distributed_measurable[OF X] by (rule prob_space_distr)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   839
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   840
  assume "emeasure MX {x \<in> space MX. Px x \<noteq> 0} = 0"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   841
  with Px have "AE x in MX. Px x = 0"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   842
    by (intro AE_I[OF subset_refl]) (auto simp: borel_measurable_ereal_iff)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   843
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
   844
  from X.emeasure_space_1 have "(\<integral>\<^sup>+x. Px x \<partial>MX) = 1"
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   845
    unfolding distributed_distr_eq_density[OF X] using Px
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   846
    by (subst (asm) emeasure_density)
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   847
       (auto simp: borel_measurable_ereal_iff intro!: integral_cong cong: nn_integral_cong)
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   848
  ultimately show False
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   849
    by (simp add: nn_integral_cong_AE)
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   850
qed
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   851
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   852
lemma (in information_space) entropy_le:
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   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: 56571
diff changeset
   854
  assumes X[measurable]: "distributed M MX X Px"
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   855
  and fin: "emeasure MX {x \<in> space MX. Px x \<noteq> 0} \<noteq> \<infinity>"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   856
  and int: "integrable MX (\<lambda>x. - Px x * log b (Px x))"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   857
  shows "entropy b MX X \<le> log b (measure MX {x \<in> space MX. Px x \<noteq> 0})"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   858
proof -
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   859
  note Px = distributed_borel_measurable[OF X] distributed_AE[OF X]
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   860
  interpret X: prob_space "distr M MX X"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   861
    using distributed_measurable[OF X] by (rule prob_space_distr)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   862
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   863
  have " - log b (measure MX {x \<in> space MX. Px x \<noteq> 0}) = 
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   864
    - log b (\<integral> x. indicator {x \<in> space MX. Px x \<noteq> 0} x \<partial>MX)"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   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: 56571
diff changeset
   866
    by (subst integral_real_indicator) (auto simp: measure_def borel_measurable_ereal_iff)
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   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)"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   868
    unfolding distributed_distr_eq_density[OF X] using Px
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   869
    apply (intro arg_cong[where f="log b"] arg_cong[where f=uminus])
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   870
    by (subst integral_density) (auto simp: borel_measurable_ereal_iff intro!: integral_cong)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   871
  also have "\<dots> \<le> (\<integral> x. - log b (1 / Px x) \<partial>distr M MX X)"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   872
  proof (rule X.jensens_inequality[of "\<lambda>x. 1 / Px x" "{0<..}" 0 1 "\<lambda>x. - log b x"])
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   873
    show "AE x in distr M MX X. 1 / Px x \<in> {0<..}"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   874
      unfolding distributed_distr_eq_density[OF X]
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   875
      using Px by (auto simp: AE_density)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   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"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   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: 50419
diff 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
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   879
      by (intro nn_integral_cong) (auto split: split_max)
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   880
    then show "integrable (distr M MX X) (\<lambda>x. 1 / Px x)"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   881
      unfolding distributed_distr_eq_density[OF X] using Px
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   882
      by (auto simp: nn_integral_density real_integrable_def borel_measurable_ereal_iff fin nn_integral_max_0
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
   883
              cong: nn_integral_cong)
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   884
    have "integrable MX (\<lambda>x. Px x * log b (1 / Px x)) =
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   885
      integrable MX (\<lambda>x. - Px x * log b (Px x))"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   886
      using Px
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   887
      by (intro integrable_cong_AE)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   888
         (auto simp: borel_measurable_ereal_iff log_divide_eq
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   889
                  intro!: measurable_If)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   890
    then show "integrable (distr M MX X) (\<lambda>x. - log b (1 / Px x))"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   891
      unfolding distributed_distr_eq_density[OF X]
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   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: 56571
diff changeset
   893
      by (subst integrable_real_density) (auto simp: borel_measurable_ereal_iff)
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   894
  qed (auto simp: minus_log_convex[OF b_gt_1])
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   895
  also have "\<dots> = (\<integral> x. log b (Px x) \<partial>distr M MX X)"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   896
    unfolding distributed_distr_eq_density[OF X] using Px
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   897
    by (intro integral_cong_AE) (auto simp: AE_density log_divide_eq)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   898
  also have "\<dots> = - entropy b MX X"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   899
    unfolding distributed_distr_eq_density[OF X] using Px
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   900
    by (subst entropy_distr[OF X]) (auto simp: borel_measurable_ereal_iff integral_density)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   901
  finally show ?thesis
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   902
    by simp
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   903
qed
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   904
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   905
lemma (in information_space) entropy_le_space:
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   906
  fixes Px :: "'b \<Rightarrow> real" and MX :: "'b measure"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   907
  assumes X: "distributed M MX X Px"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   908
  and fin: "finite_measure MX"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   909
  and int: "integrable MX (\<lambda>x. - Px x * log b (Px x))"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   910
  shows "entropy b MX X \<le> log b (measure MX (space MX))"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   911
proof -
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   912
  note Px = distributed_borel_measurable[OF X] distributed_AE[OF X]
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   913
  interpret finite_measure MX by fact
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   914
  have "entropy b MX X \<le> log b (measure MX {x \<in> space MX. Px x \<noteq> 0})"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   915
    using int X by (intro entropy_le) auto
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   916
  also have "\<dots> \<le> log b (measure MX (space MX))"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   917
    using Px distributed_imp_emeasure_nonzero[OF X]
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   918
    by (intro log_le)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   919
       (auto intro!: borel_measurable_ereal_iff finite_measure_mono b_gt_1
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   920
                     less_le[THEN iffD2] measure_nonneg simp: emeasure_eq_measure)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   921
  finally show ?thesis .
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   922
qed
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   923
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   924
lemma (in information_space) entropy_uniform:
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   925
  assumes X: "distributed M MX X (\<lambda>x. indicator A x / measure MX A)" (is "distributed _ _ _ ?f")
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   926
  shows "entropy b MX X = log b (measure MX A)"
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   927
proof (subst entropy_distr[OF X])
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   928
  have [simp]: "emeasure MX A \<noteq> \<infinity>"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   929
    using uniform_distributed_params[OF X] by (auto simp add: measure_def)
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   930
  have eq: "(\<integral> x. indicator A x / measure MX A * log b (indicator A x / measure MX A) \<partial>MX) =
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   931
    (\<integral> x. (- log b (measure MX A) / measure MX A) * indicator A x \<partial>MX)"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   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: 56571
diff changeset
   933
    by (intro integral_cong) (auto split: split_indicator simp: log_divide_eq)
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   934
  show "- (\<integral> x. indicator A x / measure MX A * log b (indicator A x / measure MX A) \<partial>MX) =
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   935
    log b (measure MX A)"
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   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: 56571
diff changeset
   937
    by (subst integral_mult_right) (auto simp: measure_def)
49785
0a8adca22974 simplified entropy_uniform
hoelzl
parents: 49776
diff changeset
   938
qed
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
   939
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   940
lemma (in information_space) entropy_simple_distributed:
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   941
  "simple_distributed M X f \<Longrightarrow> \<H>(X) = - (\<Sum>x\<in>X`space M. f x * log b (f x))"
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   942
  by (subst entropy_distr[OF simple_distributed])
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
   943
     (auto simp add: lebesgue_integral_count_space_finite)
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   944
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   945
lemma (in information_space) entropy_le_card_not_0:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   946
  assumes X: "simple_distributed M X f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   947
  shows "\<H>(X) \<le> log b (card (X ` space M \<inter> {x. f x \<noteq> 0}))"
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   948
proof -
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff changeset
   955
  finally show ?thesis .
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   956
qed
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   957
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   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: 49786
diff changeset
   959
  assumes X: "simple_distributed M X f"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   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: 49786
diff changeset
   961
proof -
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff changeset
   967
    by (simp_all add: simple_distributed_finite[OF X] subset_eq emeasure_count_space measure_def)
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   968
  finally show ?thesis .
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   969
qed
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   970
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   971
subsection {* Conditional Mutual Information *}
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
   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: 41661
diff 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: 50419
diff 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: 41661
diff changeset
   976
    mutual_information b MX MZ X Z"
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
   977
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   978
abbreviation (in information_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   979
  conditional_mutual_information_Pow ("\<I>'( _ ; _ | _ ')") where
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
   980
  "\<I>(X ; Y | Z) \<equiv> conditional_mutual_information b
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   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: 49786
diff changeset
   983
lemma (in information_space)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   984
  assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" and P: "sigma_finite_measure P"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   985
  assumes Px[measurable]: "distributed M S X Px"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 49786
diff 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: 50419
diff 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: 49786
diff changeset
   994
    and conditional_mutual_information_generic_nonneg: "0 \<le> conditional_mutual_information b S T P X Y Z" (is "?nonneg")
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   995
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   996
  interpret S: sigma_finite_measure S by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   997
  interpret T: sigma_finite_measure T by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   998
  interpret P: sigma_finite_measure P by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   999
  interpret TP: pair_sigma_finite T P ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 49786
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff changeset
  1007
  have YZ: "random_variable (T \<Otimes>\<^sub>M P) (\<lambda>x. (Y x, Z x))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1008
    using Pyz by (simp add: distributed_measurable)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1009
  
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1012
    by (simp add: comp_def distr_distr)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1013
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff changeset
  1015
    (\<integral>x. Pxz x * log b (Pxz x / (Px (fst x) * Pz (snd x))) \<partial>(S \<Otimes>\<^sub>M P))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1018
    using b_gt_1 Pxz Px Pz
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1019
    by (subst distributed_transform_integral[OF Pxyz Pxz, where T="\<lambda>(x, y, z). (x, z)"]) (auto simp: split_beta')
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1020
  finally have mi_eq:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1022
  
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff changeset
  1031
  moreover have ae5: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Px (fst x)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff changeset
  1033
  moreover have ae6: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pyz (snd x)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff changeset
  1035
  moreover have ae7: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd (snd x))"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1036
    using Pz Pz[THEN distributed_real_measurable]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1039
    using Pxz[THEN distributed_real_AE, THEN SP.AE_pair]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1040
    by (auto intro!: TP.AE_pair_measure STP.AE_pair_measure)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff changeset
  1042
  ultimately have ae: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P.
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1043
    Pxyz x * log b (Pxyz x / (Px (fst x) * Pyz (snd x))) -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1044
    Pxyz x * log b (Pxz (fst x, snd (snd x)) / (Px (fst x) * Pz (snd (snd x)))) =
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1045
    Pxyz x * log b (Pxyz x * Pz (snd (snd x)) / (Pxz (fst x, snd (snd x)) * Pyz (snd x))) "
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1046
  proof eventually_elim
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1047
    case (goal1 x)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1048
    show ?case
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1049
    proof cases
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1050
      assume "Pxyz x \<noteq> 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1052
        by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1053
      then show ?thesis
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  1054
        using b_gt_1 by (simp add: log_simps less_imp_le field_simps)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1055
    qed simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1056
  qed
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1057
  with I1 I2 show ?eq
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1058
    unfolding conditional_mutual_information_def
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1059
    apply (subst mi_eq)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 56571
diff changeset
  1061
    apply (subst integral_diff[symmetric])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1062
    apply (auto intro!: integral_cong_AE simp: split_beta' simp del: integral_diff)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1063
    done
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1064
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 49786
diff changeset
  1066
  interpret P: prob_space ?P
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1067
    unfolding distributed_distr_eq_density[OF Pxyz, symmetric]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 49786
diff changeset
  1069
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 49786
diff changeset
  1071
  interpret Q: prob_space ?Q
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1072
    unfolding distributed_distr_eq_density[OF Pyz, symmetric]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 49786
diff changeset
  1074
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff changeset
  1076
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 50419
diff 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: 50419
diff changeset
  1079
  have aeX2: "AE x in T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd x)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 49786
diff changeset
  1081
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 49787
diff changeset
  1083
    using Pz distributed_marginal_eq_joint2[OF P S Pz Pxz]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 49786
diff changeset
  1085
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1087
    apply (subst nn_integral_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1088
    apply simp
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1089
    apply (rule distributed_AE[OF Pxyz])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1090
    apply auto []
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 49786
diff changeset
  1092
    using ae5 ae6 ae7 ae8
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1093
    apply eventually_elim
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  1094
    apply auto
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1095
    done
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 50419
diff changeset
  1098
  also have "\<dots> = (\<integral>\<^sup>+x. ereal (Pyz x) * 1 \<partial>T \<Otimes>\<^sub>M P)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 49786
diff 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: 49786
diff changeset
  1101
    apply eventually_elim
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff 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: 50419
diff 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: 50419
diff changeset
  1105
    then show "(\<integral>\<^sup>+ x. ereal (Pxz (x, b)) * ereal (Pyz (a, b) / Pz b) \<partial>S) = ereal (Pyz (a, b))"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1106
      by (subst nn_integral_multc)
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  1107
         (auto split: prod.split)
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1108
  qed
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1109
  also have "\<dots> = 1"
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1110
    using Q.emeasure_space_1 distributed_AE[OF Pyz] distributed_distr_eq_density[OF Pyz]
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 50419
diff 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: 49786
diff 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: 50419
diff 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: 49786
diff changeset
  1115
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1116
  have pos: "(\<integral>\<^sup>+x. ?f x \<partial>?P) \<noteq> 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1117
    apply (subst nn_integral_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1118
    apply simp
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1119
    apply (rule distributed_AE[OF Pxyz])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1120
    apply auto []
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1121
    apply (simp add: split_beta')
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1122
  proof
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 56571
diff 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: 50419
diff changeset
  1125
    then have "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. ?g x \<le> 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 50419
diff 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: 49786
diff 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: 49786
diff 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: 50419
diff changeset
  1130
    then have "(\<integral>\<^sup>+ x. ereal (Pxyz x) \<partial>S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) = 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 49786
diff changeset
  1132
    with P.emeasure_space_1 show False
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 49786
diff changeset
  1134
  qed
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1135
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1136
  have neg: "(\<integral>\<^sup>+ x. - ?f x \<partial>?P) = 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1137
    apply (rule nn_integral_0_iff_AE[THEN iffD2])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1138
    apply simp
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1139
    apply (subst AE_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1140
    apply simp
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1141
    using ae5 ae6 ae7 ae8
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1142
    apply eventually_elim
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  1143
    apply auto
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1144
    done
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1145
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 56571
diff 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: 49786
diff changeset
  1148
    using ae
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1149
    apply (auto simp: split_beta')
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1150
    done
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1151
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 49786
diff 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: 56571
diff 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: 56571
diff 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: 56571
diff 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: 56571
diff 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: 56571
diff changeset
  1158
        by simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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: 56571
diff changeset
  1160
        by simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1161
    qed simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1162
    then have "(\<integral>\<^sup>+ x. ?f x \<partial>?P) = (\<integral>x. ?f x \<partial>?P)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 56571
diff 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: 56571
diff changeset
  1165
      apply simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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: 56571
diff 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: 56571
diff changeset
  1168
      apply auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1169
      done
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 56571
diff 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: 56571
diff 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: 49786
diff changeset
  1173
  qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff changeset
  1178
      using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE]
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  1179
      by eventually_elim (auto)
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 56571
diff changeset
  1181
      unfolding real_integrable_def 
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 49786
diff 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: 56571
diff changeset
  1184
      apply (subst integrable_real_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1185
      apply simp
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1186
      apply (auto intro!: distributed_real_AE[OF Pxyz]) []
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1187
      apply simp
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1188
      apply (rule integrable_cong_AE[THEN iffD1, OF _ _ _ I3])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1189
      apply simp
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1190
      apply simp
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff changeset
  1192
      apply eventually_elim
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff changeset
  1194
      done
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff 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: 49786
diff 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: 56571
diff changeset
  1198
    apply (subst integral_real_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1199
    apply simp
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1200
    apply (auto intro!: distributed_real_AE[OF Pxyz]) []
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1201
    apply simp
49787
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1202
    apply (intro integral_cong_AE)
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff 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: 49786
diff changeset
  1205
    done
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1206
  finally show ?nonneg
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1207
    by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1208
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1209
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1210
lemma (in information_space)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1211
  fixes Px :: "_ \<Rightarrow> real"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1212
  assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T" and P: "sigma_finite_measure P"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1213
  assumes Fx: "finite_entropy S X Px"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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: 50419
diff 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: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1220
    and conditional_mutual_information_generic_nonneg': "0 \<le> conditional_mutual_information b S T P X Y Z" (is "?nonneg")
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1221
proof -
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1222
  note Px = Fx[THEN finite_entropy_distributed, measurable]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1223
  note Pz = Fz[THEN finite_entropy_distributed, measurable]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1224
  note Pyz = Fyz[THEN finite_entropy_distributed, measurable]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1225
  note Pxz = Fxz[THEN finite_entropy_distributed, measurable]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1226
  note Pxyz = Fxyz[THEN finite_entropy_distributed, measurable]
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1227
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1228
  interpret S: sigma_finite_measure S by fact
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1229
  interpret T: sigma_finite_measure T by fact
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1230
  interpret P: sigma_finite_measure P by fact
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1231
  interpret TP: pair_sigma_finite T P ..
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1232
  interpret SP: pair_sigma_finite S P ..
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff changeset
  1238
  have SP: "sigma_finite_measure (S \<Otimes>\<^sub>M P)" ..
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1239
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1242
    by (simp add: distr_distr comp_def)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1243
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff changeset
  1245
    (\<integral>x. Pxz x * log b (Pxz x / (Px (fst x) * Pz (snd x))) \<partial>(S \<Otimes>\<^sub>M P))"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1248
    using b_gt_1 Pxz Px Pz
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1249
    by (subst distributed_transform_integral[OF Pxyz Pxz, where T="\<lambda>(x, y, z). (x, z)"])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1250
       (auto simp: split_beta')
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1251
  finally have mi_eq:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1253
  
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff changeset
  1262
  moreover have ae5: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Px (fst x)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff changeset
  1264
  moreover have ae6: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pyz (snd x)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff changeset
  1266
  moreover have ae7: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd (snd x))"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1269
    using Pxz[THEN distributed_real_AE, THEN SP.AE_pair]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1270
    by (auto intro!: TP.AE_pair_measure STP.AE_pair_measure simp: comp_def)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff changeset
  1272
  ultimately have ae: "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P.
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1273
    Pxyz x * log b (Pxyz x / (Px (fst x) * Pyz (snd x))) -
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1274
    Pxyz x * log b (Pxz (fst x, snd (snd x)) / (Px (fst x) * Pz (snd (snd x)))) =
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1275
    Pxyz x * log b (Pxyz x * Pz (snd (snd x)) / (Pxz (fst x, snd (snd x)) * Pyz (snd x))) "
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1276
  proof eventually_elim
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1277
    case (goal1 x)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1278
    show ?case
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1279
    proof cases
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1280
      assume "Pxyz x \<noteq> 0"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1282
        by auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1283
      then show ?thesis
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  1284
        using b_gt_1 by (simp add: log_simps less_imp_le field_simps)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1285
    qed simp
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1286
  qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1287
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1288
  have "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1289
    (\<lambda>x. Pxyz x * log b (Pxyz x) - Pxyz x * log b (Px (fst x)) - Pxyz x * log b (Pyz (snd x)))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1290
    using finite_entropy_integrable[OF Fxyz]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1291
    using finite_entropy_integrable_transform[OF Fx Pxyz, of fst]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1292
    using finite_entropy_integrable_transform[OF Fyz Pxyz, of snd]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1293
    by simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1297
    apply (rule integrable_cong_AE_imp)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1298
    using ae1 ae4 ae5 ae6 ae9
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1299
    by eventually_elim
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56479
diff changeset
  1300
       (auto simp: log_divide_eq log_mult_eq field_simps zero_less_mult_iff)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1301
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1302
  have "integrable (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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))))"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1304
    using finite_entropy_integrable_transform[OF Fxz Pxyz, of "\<lambda>x. (fst x, snd (snd x))"]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1305
    using finite_entropy_integrable_transform[OF Fx Pxyz, of fst]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1306
    using finite_entropy_integrable_transform[OF Fz Pxyz, of "snd \<circ> snd"]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1307
    by simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1309
    using Pxyz Px Pz
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1310
    by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1312
    apply (rule integrable_cong_AE_imp)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1313
    using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 ae9
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1314
    by eventually_elim
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56479
diff changeset
  1315
       (auto simp: log_divide_eq log_mult_eq field_simps zero_less_mult_iff)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1316
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1317
  from ae I1 I2 show ?eq
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1318
    unfolding conditional_mutual_information_def
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1319
    apply (subst mi_eq)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 56571
diff changeset
  1321
    apply (subst integral_diff[symmetric])
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1322
    apply (auto intro!: integral_cong_AE simp: split_beta' simp del: integral_diff)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1323
    done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1324
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1325
  let ?P = "density (S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) Pxyz"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1326
  interpret P: prob_space ?P
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1327
    unfolding distributed_distr_eq_density[OF Pxyz, symmetric] by (rule prob_space_distr) simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1328
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1329
  let ?Q = "density (T \<Otimes>\<^sub>M P) Pyz"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1330
  interpret Q: prob_space ?Q
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1331
    unfolding distributed_distr_eq_density[OF Pyz, symmetric] by (rule prob_space_distr) simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1332
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1333
  let ?f = "\<lambda>(x, y, z). Pxz (x, z) * (Pyz (y, z) / Pz z) / Pxyz (x, y, z)"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1334
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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: 50419
diff changeset
  1337
  have aeX2: "AE x in T \<Otimes>\<^sub>M P. 0 \<le> Pz (snd x)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1338
    using Pz by (intro TP.AE_pair_measure) (auto dest: distributed_real_AE)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1339
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1341
    using Pz distributed_marginal_eq_joint2[OF P S Pz Pxz]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1344
    apply (subst nn_integral_density)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1345
    apply (rule distributed_borel_measurable[OF Pxyz])
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1346
    apply (rule distributed_AE[OF Pxyz])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1347
    apply simp
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1348
    apply (rule nn_integral_mono_AE)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1349
    using ae5 ae6 ae7 ae8
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1350
    apply eventually_elim
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  1351
    apply auto
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1352
    done
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 50419
diff changeset
  1355
  also have "\<dots> = (\<integral>\<^sup>+x. ereal (Pyz x) * 1 \<partial>T \<Otimes>\<^sub>M P)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1356
    apply (rule nn_integral_cong_AE)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1357
    using aeX1 aeX2 aeX3 distributed_AE[OF Pyz] AE_space
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1358
    apply eventually_elim
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1359
  proof (case_tac x, simp del: times_ereal.simps add: space_pair_measure)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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: 50419
diff changeset
  1362
    then show "(\<integral>\<^sup>+ x. ereal (Pxz (x, b)) * ereal (Pyz (a, b) / Pz b) \<partial>S) = ereal (Pyz (a, b))"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1363
      by (subst nn_integral_multc) auto
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1364
  qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1365
  also have "\<dots> = 1"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1366
    using Q.emeasure_space_1 distributed_AE[OF Pyz] distributed_distr_eq_density[OF Pyz]
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 50419
diff changeset
  1368
  finally have le1: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<le> 1" .
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff changeset
  1370
  finally have fin: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<noteq> \<infinity>" by simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1371
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1372
  have pos: "(\<integral>\<^sup>+ x. ?f x \<partial>?P) \<noteq> 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1373
    apply (subst nn_integral_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1374
    apply simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1375
    apply (rule distributed_AE[OF Pxyz])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1376
    apply simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1377
    apply (simp add: split_beta')
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1378
  proof
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff 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: 50419
diff changeset
  1381
    then have "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. ?g x \<le> 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 50419
diff changeset
  1383
    then have "AE x in S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P. Pxyz x = 0"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1384
      using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff changeset
  1386
    then have "(\<integral>\<^sup>+ x. ereal (Pxyz x) \<partial>S \<Otimes>\<^sub>M T \<Otimes>\<^sub>M P) = 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1387
      by (subst nn_integral_cong_AE[of _ "\<lambda>x. 0"]) auto
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1388
    with P.emeasure_space_1 show False
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1389
      by (subst (asm) emeasure_density) (auto cong: nn_integral_cong)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1390
  qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1391
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1392
  have neg: "(\<integral>\<^sup>+ x. - ?f x \<partial>?P) = 0"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  1393
    apply (rule nn_integral_0_iff_AE[THEN iffD2])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1394
    apply (auto simp: split_beta') []
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1395
    apply (subst AE_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1396
    apply (auto simp: split_beta') []
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1397
    using ae5 ae6 ae7 ae8
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1398
    apply eventually_elim
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  1399
    apply auto
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1400
    done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1401
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 56571
diff changeset
  1403
    apply (rule integrable_cong_AE[THEN iffD1, OF _ _ _ integrable_diff[OF I1 I2]])
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1404
    using ae
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1405
    apply (auto simp: split_beta')
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1406
    done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1407
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1408
  have "- log b 1 \<le> - log b (integral\<^sup>L ?P ?f)"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 56571
diff 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: 56571
diff 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: 56571
diff 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: 56571
diff 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: 56571
diff changeset
  1414
        by simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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: 56571
diff changeset
  1416
        by simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1417
    qed simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1418
    then have "(\<integral>\<^sup>+ x. ?f x \<partial>?P) = (\<integral>x. ?f x \<partial>?P)"
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 56571
diff 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: 56571
diff changeset
  1421
      apply simp
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff 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: 56571
diff 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: 56571
diff changeset
  1424
      apply auto
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1425
      done
56996
891e992e510f renamed positive_integral to nn_integral
hoelzl
parents: 56994
diff changeset
  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: 56571
diff 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: 56571
diff changeset
  1428
      by (simp_all add: one_ereal_def)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1429
  qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1430
  also have "- log b (integral\<^sup>L ?P ?f) \<le> (\<integral> x. - log b (?f x) \<partial>?P)"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1431
  proof (rule P.jensens_inequality[where a=0 and b=1 and I="{0<..}"])
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1432
    show "AE x in ?P. ?f x \<in> {0<..}"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1433
      unfolding AE_density[OF distributed_borel_measurable[OF Pxyz]]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1434
      using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE]
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  1435
      by eventually_elim (auto)
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 56571
diff changeset
  1437
      unfolding real_integrable_def
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1438
      using fin neg by (auto simp: split_beta')
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 56571
diff changeset
  1440
      apply (subst integrable_real_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1441
      apply simp
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1442
      apply (auto intro!: distributed_real_AE[OF Pxyz]) []
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1443
      apply simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1444
      apply (rule integrable_cong_AE[THEN iffD1, OF _ _ _ I3])
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1445
      apply simp
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1446
      apply simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1447
      using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1448
      apply eventually_elim
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1449
      apply (auto simp: log_divide_eq log_mult_eq zero_le_mult_iff zero_less_mult_iff zero_less_divide_iff field_simps)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1450
      done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1451
  qed (auto simp: b_gt_1 minus_log_convex)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1452
  also have "\<dots> = conditional_mutual_information b S T P X Y Z"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1453
    unfolding `?eq`
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56571
diff changeset
  1454
    apply (subst integral_real_density)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1455
    apply simp
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1456
    apply (auto intro!: distributed_real_AE[OF Pxyz]) []
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  1457
    apply simp
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1458
    apply (intro integral_cong_AE)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1459
    using ae1 ae2 ae3 ae4 ae5 ae6 ae7 ae8 Pxyz[THEN distributed_real_AE]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1460
    apply (auto simp: log_divide_eq zero_less_mult_iff zero_less_divide_iff field_simps)
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1461
    done
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1462
  finally show ?nonneg
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1463
    by simp
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1464
qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1465
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1466
lemma (in information_space) conditional_mutual_information_eq:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1467
  assumes Pz: "simple_distributed M Z Pz"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1468
  assumes Pyz: "simple_distributed M (\<lambda>x. (Y x, Z x)) Pyz"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1469
  assumes Pxz: "simple_distributed M (\<lambda>x. (X x, Z x)) Pxz"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1470
  assumes Pxyz: "simple_distributed M (\<lambda>x. (X x, Y x, Z x)) Pxyz"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1471
  shows "\<I>(X ; Y | Z) =
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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))))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1473
proof (subst conditional_mutual_information_generic_eq[OF _ _ _ _
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1474
    simple_distributed[OF Pz] simple_distributed_joint[OF Pyz] simple_distributed_joint[OF Pxz]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1475
    simple_distributed_joint2[OF Pxyz]])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1476
  note simple_distributed_joint2_finite[OF Pxyz, simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1477
  show "sigma_finite_measure (count_space (X ` space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1478
    by (simp add: sigma_finite_measure_count_space_finite)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1479
  show "sigma_finite_measure (count_space (Y ` space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1480
    by (simp add: sigma_finite_measure_count_space_finite)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1481
  show "sigma_finite_measure (count_space (Z ` space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1484
      count_space (X`space M \<times> Y`space M \<times> Z`space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1485
    (is "?P = ?C")
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1486
    by (simp add: pair_measure_count_space)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1487
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1490
    using simple_distributed_joint[OF Pxz] by (rule distributed_measurable)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1491
  from measurable_comp[OF this measurable_fst]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1492
  have "random_variable (count_space (X ` space M)) X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1493
    by (simp add: comp_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1494
  then have "simple_function M X"    
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 49999
diff changeset
  1495
    unfolding simple_function_def by (auto simp: measurable_count_space_eq2)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1496
  then have "simple_distributed M X ?Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1497
    by (rule simple_distributedI) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1498
  then show "distributed M (count_space (X ` space M)) X ?Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1499
    by (rule simple_distributed)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1500
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1501
  let ?f = "(\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x, Z x)) ` space M then Pxyz x else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1502
  let ?g = "(\<lambda>x. if x \<in> (\<lambda>x. (Y x, Z x)) ` space M then Pyz x else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1503
  let ?h = "(\<lambda>x. if x \<in> (\<lambda>x. (X x, Z x)) ` space M then Pxz x else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1504
  show
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1505
      "integrable ?P (\<lambda>(x, y, z). ?f (x, y, z) * log b (?f (x, y, z) / (?Px x * ?g (y, z))))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1506
      "integrable ?P (\<lambda>(x, y, z). ?f (x, y, z) * log b (?h (x, z) / (?Px x * Pz z)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1507
    by (auto intro!: integrable_count_space simp: pair_measure_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1511
    by (auto intro!: ext)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1513
    by (auto intro!: setsum_cong simp add: `?P = ?C` lebesgue_integral_count_space_finite simple_distributed_finite setsum_cases split_beta')
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1514
qed
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1515
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1516
lemma (in information_space) conditional_mutual_information_nonneg:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1517
  assumes X: "simple_function M X" and Y: "simple_function M Y" and Z: "simple_function M Z"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1518
  shows "0 \<le> \<I>(X ; Y | Z)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1519
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff changeset
  1525
  note sp = simple_function_Pair
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff changeset
  1526
  show ?thesis
d8de705b48d4 rule to show that conditional mutual information is non-negative in the continuous case
hoelzl
parents: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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: 49786
diff 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
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  1537
subsection {* Conditional Entropy *}
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  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: 50419
diff 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: 50419
diff 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
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1543
abbreviation (in information_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1544
  conditional_entropy_Pow ("\<H>'(_ | _')") where
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  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: 56571
diff changeset
  1548
  fixes Pxy :: "_ \<Rightarrow> real" and Py :: "'c \<Rightarrow> real"
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1549
  assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
  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: 50419
diff 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: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1553
proof -
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1554
  interpret S: sigma_finite_measure S by fact
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1555
  interpret T: sigma_finite_measure T by fact
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1556
  interpret ST: pair_sigma_finite S T ..
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1557
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1559
    unfolding AE_density[OF distributed_borel_measurable, OF Pxy]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1560
    unfolding distributed_distr_eq_density[OF Pxy]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1561
    using distributed_RN_deriv[OF Pxy]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1562
    by auto
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1563
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1565
    unfolding AE_density[OF distributed_borel_measurable, OF Pxy]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1566
    unfolding distributed_distr_eq_density[OF Py]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  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: 56571
diff changeset
  1568
    apply auto
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1569
    using distributed_RN_deriv[OF Py]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1570
    apply auto
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1571
    done    
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1572
  ultimately
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  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: 56571
diff 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: 56571
diff changeset
  1576
    apply (auto simp: distributed_real_AE[OF Pxy] distributed_distr_eq_density[OF Pxy]
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1577
                intro!: integral_cong_AE)
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1578
    done
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1579
  then show ?thesis by (simp add: split_beta')
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1580
qed
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1581
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1582
lemma (in information_space) conditional_entropy_eq_entropy:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1583
  fixes Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 56571
diff 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: 56571
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1590
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1591
  interpret S: sigma_finite_measure S by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1592
  interpret T: sigma_finite_measure T by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1593
  interpret ST: pair_sigma_finite S T ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1594
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1595
  have "entropy b T Y = - (\<integral>y. Py y * log b (Py y) \<partial>T)"
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
  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: 50419
diff changeset
  1597
  also have "\<dots> = - (\<integral>(x,y). Pxy (x,y) * log b (Py y) \<partial>(S \<Otimes>\<^sub>M T))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1598
    using b_gt_1 Py[THEN distributed_real_measurable]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1601
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1602
  have ae2: "AE x in S \<Otimes>\<^sub>M T. Py (snd x) = 0 \<longrightarrow> Pxy x = 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff changeset
  1604
  moreover have ae4: "AE x in S \<Otimes>\<^sub>M T. 0 \<le> Py (snd x)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 49787
diff 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: 50419
diff 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: 49788
diff changeset
  1608
    (Pxy x = 0 \<or> (Pxy x \<noteq> 0 \<longrightarrow> 0 < Pxy x \<and> 0 < Py (snd x)))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1609
    by eventually_elim auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1610
  then have ae: "AE x in S \<Otimes>\<^sub>M T.
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1611
     Pxy x * log b (Pxy x) - Pxy x * log b (Py (snd x)) = Pxy x * log b (Pxy x / Py (snd x))"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  1612
    by eventually_elim (auto simp: log_simps field_simps b_gt_1)
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  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: 50419
diff changeset
  1614
    - (\<integral>x. Pxy x * log b (Pxy x) - Pxy x * log b (Py (snd x)) \<partial>(S \<Otimes>\<^sub>M T))"
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1615
    unfolding conditional_entropy_generic_eq[OF S T Py Pxy] neg_equal_iff_equal
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1616
    apply (intro integral_cong_AE)
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1617
    using ae
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1618
    apply auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1619
    done
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1621
    by (simp add: integral_diff[OF I1 I2])
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1622
  finally show ?thesis 
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1623
    unfolding conditional_entropy_generic_eq[OF S T Py Pxy] entropy_distr[OF Pxy] e_eq
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1624
    by (simp add: split_beta')
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1625
qed
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1626
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1627
lemma (in information_space) conditional_entropy_eq_entropy_simple:
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  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: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1630
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1632
    (is "?P = ?C") using X Y by (simp add: simple_functionD pair_measure_count_space)
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1633
  show ?thesis
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1634
    by (rule conditional_entropy_eq_entropy sigma_finite_measure_count_space_finite
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1635
                 simple_functionD  X Y simple_distributed simple_distributedI[OF _ refl]
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1636
                 simple_distributed_joint simple_function_Pair integrable_count_space)+
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1637
       (auto simp: `?P = ?C` intro!: integrable_count_space simple_functionD  X Y)
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  1638
qed
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  1639
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1640
lemma (in information_space) conditional_entropy_eq:
49792
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1641
  assumes Y: "simple_distributed M Y Py"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1642
  assumes XY: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1644
proof (subst conditional_entropy_generic_eq[OF _ _
49790
6b9b9ebba47d remove unneeded assumption from conditional_entropy_generic_eq
hoelzl
parents: 49788
diff changeset
  1645
  simple_distributed[OF Y] simple_distributed_joint[OF XY]])
49792
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1646
  have "finite ((\<lambda>x. (X x, Y x))`space M)"
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1647
    using XY unfolding simple_distributed_def by auto
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1648
  from finite_imageI[OF this, of fst]
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1649
  have [simp]: "finite (X`space M)"
56154
f0a927235162 more complete set of lemmas wrt. image and composition
haftmann
parents: 53374
diff changeset
  1650
    by (simp add: image_comp comp_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1651
  note Y[THEN simple_distributed_finite, simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1652
  show "sigma_finite_measure (count_space (X ` space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1653
    by (simp add: sigma_finite_measure_count_space_finite)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1654
  show "sigma_finite_measure (count_space (Y ` space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1655
    by (simp add: sigma_finite_measure_count_space_finite)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1658
    (is "?P = ?C")
49792
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1659
    using Y by (simp add: simple_distributed_finite pair_measure_count_space)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1660
  have eq: "(\<lambda>(x, y). ?f (x, y) * log b (?f (x, y) / Py y)) =
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1662
    by auto
49792
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1663
  from Y show "- (\<integral> (x, y). ?f (x, y) * log b (?f (x, y) / Py y) \<partial>?P) =
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1664
    - (\<Sum>(x, y)\<in>(\<lambda>x. (X x, Y x)) ` space M. Pxy (x, y) * log b (Pxy (x, y) / Py y))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1665
    by (auto intro!: setsum_cong simp add: `?P = ?C` lebesgue_integral_count_space_finite simple_distributed_finite eq setsum_cases split_beta')
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1666
qed
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  1667
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 41661
diff changeset
  1669
  assumes X: "simple_function M X" and Y: "simple_function M Y"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1670
  shows "\<I>(X ; X | Y) = \<H>(X | Y)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1671
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1672
  def Py \<equiv> "\<lambda>x. if x \<in> Y`space M then measure M (Y -` {x} \<inter> space M) else 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1675
  let ?M = "X`space M \<times> X`space M \<times> Y`space M"
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  1676
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1677
  note XY = simple_function_Pair[OF X Y]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1678
  note XXY = simple_function_Pair[OF X XY]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1679
  have Py: "simple_distributed M Y Py"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1680
    using Y by (rule simple_distributedI) (auto simp: Py_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1681
  have Pxy: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1682
    using XY by (rule simple_distributedI) (auto simp: Pxy_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1683
  have Pxxy: "simple_distributed M (\<lambda>x. (X x, X x, Y x)) Pxxy"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1684
    using XXY by (rule simple_distributedI) (auto simp: Pxxy_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1686
    by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1687
  have inj: "\<And>A. inj_on (\<lambda>(x, y). (x, x, y)) A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1688
    by (auto simp: inj_on_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1689
  have Pxxy_eq: "\<And>x y. Pxxy (x, x, y) = Pxy (x, y)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1690
    by (auto simp: Pxxy_def Pxy_def intro!: arg_cong[where f=prob])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1691
  have "AE x in count_space ((\<lambda>x. (X x, Y x))`space M). Py (snd x) = 0 \<longrightarrow> Pxy x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1692
    by (intro subdensity_real[of snd, OF _ Pxy[THEN simple_distributed] Py[THEN simple_distributed]]) (auto intro: measurable_Pair)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1693
  then show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1694
    apply (subst conditional_mutual_information_eq[OF Py Pxy Pxy Pxxy])
49792
43f49922811d remove unnecessary assumption from conditional_entropy_eq
hoelzl
parents: 49791
diff changeset
  1695
    apply (subst conditional_entropy_eq[OF Py Pxy])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1696
    apply (auto intro!: setsum_cong simp: Pxxy_eq setsum_negf[symmetric] eq setsum_reindex[OF inj]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1697
                log_simps zero_less_mult_iff zero_le_mult_iff field_simps mult_less_0_iff AE_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 49788
diff changeset
  1699
  apply (auto simp add: not_le[symmetric] AE_count_space)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1700
    done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1701
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1702
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1703
lemma (in information_space) conditional_entropy_nonneg:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1704
  assumes X: "simple_function M X" and Y: "simple_function M Y" shows "0 \<le> \<H>(X | Y)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1705
  using conditional_mutual_information_eq_conditional_entropy[OF X Y] conditional_mutual_information_nonneg[OF X X Y]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1706
  by simp
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
  1707
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  1708
subsection {* Equalities *}
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39092
diff changeset
  1709
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1710
lemma (in information_space) mutual_information_eq_entropy_conditional_entropy_distr:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1711
  fixes Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" and Pxy :: "('b \<times> 'c) \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 56571
diff 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: 56571
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1719
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1720
  have X: "entropy b S X = - (\<integral>x. Pxy x * log b (Px (fst x)) \<partial>(S \<Otimes>\<^sub>M T))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1721
    using b_gt_1 Px[THEN distributed_real_measurable]
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
  1722
    apply (subst entropy_distr[OF Px])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1723
    apply (subst distributed_transform_integral[OF Pxy Px, where T=fst])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1724
    apply (auto intro!: integral_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1725
    done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1726
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1727
  have Y: "entropy b T Y = - (\<integral>x. Pxy x * log b (Py (snd x)) \<partial>(S \<Otimes>\<^sub>M T))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1728
    using b_gt_1 Py[THEN distributed_real_measurable]
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
  1729
    apply (subst entropy_distr[OF Py])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1730
    apply (subst distributed_transform_integral[OF Pxy Py, where T=snd])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1731
    apply (auto intro!: integral_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1732
    done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1733
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1734
  interpret S: sigma_finite_measure S by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1735
  interpret T: sigma_finite_measure T by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff changeset
  1737
  have ST: "sigma_finite_measure (S \<Otimes>\<^sub>M T)" ..
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1738
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
  1740
    by (subst entropy_distr[OF Pxy]) (auto intro!: integral_cong)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1741
  
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff changeset
  1742
  have "AE x in S \<Otimes>\<^sub>M T. Px (fst x) = 0 \<longrightarrow> Pxy x = 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff changeset
  1744
  moreover have "AE x in S \<Otimes>\<^sub>M T. Py (snd x) = 0 \<longrightarrow> Pxy x = 0"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff changeset
  1746
  moreover have "AE x in S \<Otimes>\<^sub>M T. 0 \<le> Px (fst x)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff changeset
  1748
  moreover have "AE x in S \<Otimes>\<^sub>M T. 0 \<le> Py (snd x)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1749
    using Py by (intro ST.AE_pair_measure) (auto simp: comp_def intro!: measurable_snd'' dest: distributed_real_AE distributed_real_measurable)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1752
    Pxy x * log b (Pxy x / (Px (fst x) * Py (snd x)))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1753
    (is "AE x in _. ?f x = ?g x")
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1754
  proof eventually_elim
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1755
    case (goal1 x)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1756
    show ?case
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1757
    proof cases
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1758
      assume "Pxy x \<noteq> 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1759
      with goal1 have "0 < Px (fst x)" "0 < Py (snd x)" "0 < Pxy x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1760
        by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1761
      then show ?thesis
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  1762
        using b_gt_1 by (simp add: log_simps less_imp_le field_simps)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1763
    qed simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1764
  qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1765
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1767
    unfolding X Y XY
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 56571
diff changeset
  1769
    apply (intro integrable_diff Ixy Ix Iy)+
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 56571
diff changeset
  1771
    apply (intro Ixy Ix Iy)+
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1772
    apply (simp add: field_simps)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1773
    done
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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: 56571
diff changeset
  1775
    using `AE x in _. ?f x = ?g x` by (intro integral_cong_AE) auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1776
  also have "\<dots> = mutual_information b S T X Y"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1777
    by (rule mutual_information_distr[OF S T Px Py Pxy, symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1778
  finally show ?thesis ..
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1779
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1780
49802
dd8dffaf84b9 continuous version of mutual_information_eq_entropy_conditional_entropy
hoelzl
parents: 49792
diff changeset
  1781
lemma (in information_space) mutual_information_eq_entropy_conditional_entropy':
dd8dffaf84b9 continuous version of mutual_information_eq_entropy_conditional_entropy
hoelzl
parents: 49792
diff 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: 49792
diff 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: 49792
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 50419
diff 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: 49792
diff 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: 49792
diff changeset
  1790
  using
dd8dffaf84b9 continuous version of mutual_information_eq_entropy_conditional_entropy
hoelzl
parents: 49792
diff 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: 49792
diff 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: 49792
diff changeset
  1793
  by simp
dd8dffaf84b9 continuous version of mutual_information_eq_entropy_conditional_entropy
hoelzl
parents: 49792
diff changeset
  1794
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1795
lemma (in information_space) mutual_information_eq_entropy_conditional_entropy:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1796
  assumes sf_X: "simple_function M X" and sf_Y: "simple_function M Y"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1797
  shows  "\<I>(X ; Y) = \<H>(X) - \<H>(X | Y)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1798
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1799
  have X: "simple_distributed M X (\<lambda>x. measure M (X -` {x} \<inter> space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1800
    using sf_X by (rule simple_distributedI) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1801
  have Y: "simple_distributed M Y (\<lambda>x. measure M (Y -` {x} \<inter> space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1802
    using sf_Y by (rule simple_distributedI) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1803
  have sf_XY: "simple_function M (\<lambda>x. (X x, Y x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1804
    using sf_X sf_Y by (rule simple_function_Pair)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1806
    by (rule simple_distributedI) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1809
    by (simp add: pair_measure_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1810
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1813
    by (rule mutual_information_eq_entropy_conditional_entropy_distr) (auto simp: eq integrable_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1814
  then show ?thesis
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1815
    unfolding conditional_entropy_eq_entropy_simple[OF sf_X sf_Y] by simp
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1816
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1817
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1818
lemma (in information_space) mutual_information_nonneg_simple:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1819
  assumes sf_X: "simple_function M X" and sf_Y: "simple_function M Y"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1820
  shows  "0 \<le> \<I>(X ; Y)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1821
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1822
  have X: "simple_distributed M X (\<lambda>x. measure M (X -` {x} \<inter> space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1823
    using sf_X by (rule simple_distributedI) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1824
  have Y: "simple_distributed M Y (\<lambda>x. measure M (Y -` {x} \<inter> space M))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1825
    using sf_Y by (rule simple_distributedI) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1826
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1827
  have sf_XY: "simple_function M (\<lambda>x. (X x, Y x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1828
    using sf_X sf_Y by (rule simple_function_Pair)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1830
    by (rule simple_distributedI) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1831
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1834
    by (simp add: pair_measure_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1835
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1836
  show ?thesis
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1837
    by (rule mutual_information_nonneg[OF _ _ simple_distributed[OF X] simple_distributed[OF Y] simple_distributed_joint[OF XY]])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1838
       (simp_all add: eq integrable_count_space sigma_finite_measure_count_space_finite)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1839
qed
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
  1840
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  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: 41661
diff changeset
  1842
  assumes X: "simple_function M X" and Z: "simple_function M Z"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1843
  shows "\<H>(X | Z) \<le> \<H>(X)"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1844
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1845
  have "0 \<le> \<I>(X ; Z)" using X Z by (rule mutual_information_nonneg_simple)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1846
  also have "\<I>(X ; Z) = \<H>(X) - \<H>(X | Z)" using mutual_information_eq_entropy_conditional_entropy[OF assms] .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1850
lemma (in information_space) 
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1851
  fixes Px :: "'b \<Rightarrow> real" and Py :: "'c \<Rightarrow> real" and Pxy :: "('b \<times> 'c) \<Rightarrow> real"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1852
  assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  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: 50419
diff changeset
  1854
  assumes Pxy: "finite_entropy (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) Pxy"
49803
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1855
  shows "conditional_entropy b S T X Y \<le> entropy b S X"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1856
proof -
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1857
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1858
  have "0 \<le> mutual_information b S T X Y" 
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1859
    by (rule mutual_information_nonneg') fact+
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1860
  also have "\<dots> = entropy b S X - conditional_entropy b S T X Y"
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1861
    apply (rule mutual_information_eq_entropy_conditional_entropy')
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1862
    using assms
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1863
    by (auto intro!: finite_entropy_integrable finite_entropy_distributed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1864
      finite_entropy_integrable_transform[OF Px]
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1865
      finite_entropy_integrable_transform[OF Py])
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1866
  finally show ?thesis by auto
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1867
qed
2f076e377703 add finite entropy
hoelzl
parents: 49802
diff changeset
  1868
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  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: 41661
diff changeset
  1870
  assumes X: "simple_function M X" and Y: "simple_function M Y"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1871
  shows  "\<H>(\<lambda>x. (X x, Y x)) = \<H>(X) + \<H>(Y|X)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1872
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1873
  note XY = simple_distributedI[OF simple_function_Pair[OF X Y] refl]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1874
  note YX = simple_distributedI[OF simple_function_Pair[OF Y X] refl]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1875
  note simple_distributed_joint_finite[OF this, simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1876
  let ?f = "\<lambda>x. prob ((\<lambda>x. (X x, Y x)) -` {x} \<inter> space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1877
  let ?g = "\<lambda>x. prob ((\<lambda>x. (Y x, X x)) -` {x} \<inter> space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1880
    using XY by (rule entropy_simple_distributed)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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)"])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1883
  also have "\<dots> = - (\<Sum>x\<in>(\<lambda>x. (Y x, X x)) ` space M. ?h x * log b (?h x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49785
diff changeset
  1886
    by (subst entropy_distr[OF simple_distributed_joint[OF YX]])
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1887
       (auto simp: pair_measure_count_space sigma_finite_measure_count_space_finite lebesgue_integral_count_space_finite
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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: 50419
diff 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
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1890
  then show ?thesis
49791
e0854abfb3fc alternative definition of conditional entropy
hoelzl
parents: 49790
diff changeset
  1891
    unfolding conditional_entropy_eq_entropy_simple[OF Y X] by simp
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1892
qed
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1893
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1894
lemma (in information_space) entropy_partition:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1895
  assumes X: "simple_function M X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1896
  shows "\<H>(X) = \<H>(f \<circ> X) + \<H>(X|f \<circ> X)"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1897
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1898
  note fX = simple_function_compose[OF X, of f]  
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1899
  have eq: "(\<lambda>x. ((f \<circ> X) x, X x)) ` space M = (\<lambda>x. (f x, x)) ` X ` space M" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1900
  have inj: "\<And>A. inj_on (\<lambda>x. (f x, x)) A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1901
    by (auto simp: inj_on_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1902
  show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1903
    apply (subst entropy_chain_rule[symmetric, OF fX X])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1904
    apply (subst entropy_simple_distributed[OF simple_distributedI[OF simple_function_Pair[OF fX X] refl]])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1905
    apply (subst entropy_simple_distributed[OF simple_distributedI[OF X refl]])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1906
    unfolding eq
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1907
    apply (subst setsum_reindex[OF inj])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1908
    apply (auto intro!: setsum_cong arg_cong[where f="\<lambda>A. prob A * log b (prob A)"])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1909
    done
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1910
qed
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1911
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  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: 41661
diff changeset
  1913
  assumes X: "simple_function M X" shows "\<H>(f \<circ> X) \<le> \<H>(X)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1914
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1915
  note fX = simple_function_compose[OF X, of f]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1916
  from X have "\<H>(X) = \<H>(f\<circ>X) + \<H>(X|f\<circ>X)" by (rule entropy_partition)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1917
  then show "\<H>(f \<circ> X) \<le> \<H>(X)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1918
    by (auto intro: conditional_entropy_nonneg[OF X fX])
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1919
qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1920
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  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: 41661
diff changeset
  1922
  assumes X: "simple_function M X" and inj: "inj_on f (X`space M)"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1923
  shows "\<H>(f \<circ> X) = \<H>(X)"
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1924
proof (rule antisym)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1925
  show "\<H>(f \<circ> X) \<le> \<H>(X)" using entropy_data_processing[OF X] .
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  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: 41661
diff changeset
  1927
  have sf: "simple_function M (f \<circ> X)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1928
    using X by auto
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1929
  have "\<H>(X) = \<H>(the_inv_into (X`space M) f \<circ> (f \<circ> X))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1930
    unfolding o_assoc
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1931
    apply (subst entropy_simple_distributed[OF simple_distributedI[OF X refl]])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  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)"])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1933
    apply (auto intro!: setsum_cong arg_cong[where f=prob] image_eqI simp: the_inv_into_f_f[OF inj] comp_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
  1934
    done
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1935
  also have "... \<le> \<H>(f \<circ> X)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
  1936
    using entropy_data_processing[OF sf] .
36624
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1937
  finally show "\<H>(X) \<le> \<H>(f \<circ> X)" .
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1938
qed
25153c08655e Cleanup information theory
hoelzl
parents: 36623
diff changeset
  1939
36080
0d9affa4e73c Added Information theory and Example: dining cryptographers
hoelzl
parents:
diff changeset
  1940
end