src/HOL/Probability/Information.thy
changeset 57252 19b7ace1c5da
parent 57235 b0b9a10e4bf4
child 57418 6ab1c7cb0b8d
equal deleted inserted replaced
57251:f51985ebd152 57252:19b7ace1c5da
     6 header {*Information theory*}
     6 header {*Information theory*}
     7 
     7 
     8 theory Information
     8 theory Information
     9 imports
     9 imports
    10   Independent_Family
    10   Independent_Family
    11   Distributions
       
    12   "~~/src/HOL/Library/Convex"
    11   "~~/src/HOL/Library/Convex"
    13 begin
    12 begin
    14 
    13 
    15 lemma log_le: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x \<le> y \<Longrightarrow> log a x \<le> log a y"
    14 lemma log_le: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> x \<le> y \<Longrightarrow> log a x \<le> log a y"
    16   by (subst log_le_cancel_iff) auto
    15   by (subst log_le_cancel_iff) auto
   912     by (intro integral_cong) (auto split: split_indicator simp: log_divide_eq)
   911     by (intro integral_cong) (auto split: split_indicator simp: log_divide_eq)
   913   show "- (\<integral> x. indicator A x / measure MX A * log b (indicator A x / measure MX A) \<partial>MX) =
   912   show "- (\<integral> x. indicator A x / measure MX A * log b (indicator A x / measure MX A) \<partial>MX) =
   914     log b (measure MX A)"
   913     log b (measure MX A)"
   915     unfolding eq using uniform_distributed_params[OF X]
   914     unfolding eq using uniform_distributed_params[OF X]
   916     by (subst integral_mult_right) (auto simp: measure_def)
   915     by (subst integral_mult_right) (auto simp: measure_def)
   917 qed
       
   918 
       
   919 lemma (in information_space) entropy_exponential:
       
   920   assumes D: "distributed M lborel X (exponential_density l)"
       
   921   shows "entropy b lborel X = log b (exp 1 / l)"
       
   922 proof -
       
   923   have l[simp, arith]: "0 < l" by (rule exponential_distributed_params[OF D])
       
   924  
       
   925   have [simp]: "integrable lborel (exponential_density l)"
       
   926     using distributed_integrable[OF D, of "\<lambda>_. 1"] by simp
       
   927 
       
   928   have [simp]: "integral\<^sup>L lborel (exponential_density l) = 1"
       
   929     using distributed_integral[OF D, of "\<lambda>_. 1"] by (simp add: prob_space)
       
   930     
       
   931   have [simp]: "integrable lborel (\<lambda>x. exponential_density l x * x)"
       
   932     using erlang_ith_moment_integrable[OF l D, of 1] distributed_integrable[OF D, of "\<lambda>x. x"] by simp
       
   933 
       
   934   have [simp]: "integral\<^sup>L lborel (\<lambda>x. exponential_density l x * x) = 1 / l"
       
   935     using erlang_ith_moment[OF l D, of 1] distributed_integral[OF D, of "\<lambda>x. x"] by simp
       
   936     
       
   937   have "entropy b lborel X = - (\<integral> x. exponential_density l x * log b (exponential_density l x) \<partial>lborel)"
       
   938     using D by (rule entropy_distr)
       
   939   also have "(\<integral> x. exponential_density l x * log b (exponential_density l x) \<partial>lborel) = 
       
   940     (\<integral> x. (ln l * exponential_density l x - l * (exponential_density l x * x)) / ln b \<partial>lborel)"
       
   941     by (intro integral_cong) (auto simp: log_def ln_mult exponential_density_def field_simps)
       
   942   also have "\<dots> = (ln l - 1) / ln b"
       
   943     by simp
       
   944   finally show ?thesis
       
   945     by (simp add: log_def divide_simps ln_div)
       
   946 qed
   916 qed
   947 
   917 
   948 lemma (in information_space) entropy_simple_distributed:
   918 lemma (in information_space) entropy_simple_distributed:
   949   "simple_distributed M X f \<Longrightarrow> \<H>(X) = - (\<Sum>x\<in>X`space M. f x * log b (f x))"
   919   "simple_distributed M X f \<Longrightarrow> \<H>(X) = - (\<Sum>x\<in>X`space M. f x * log b (f x))"
   950   by (subst entropy_distr[OF simple_distributed])
   920   by (subst entropy_distr[OF simple_distributed])