src/HOL/Probability/Probability_Space.thy
author haftmann
Fri, 11 Jun 2010 17:14:02 +0200
changeset 37407 61dd8c145da7
parent 36624 25153c08655e
child 38656 d5d342611edb
permissions -rw-r--r--
declare lex_prod_def [code del]
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     1
theory Probability_Space
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     2
imports Lebesgue
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     3
begin
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     4
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     5
locale prob_space = measure_space +
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     6
  assumes prob_space: "measure M (space M) = 1"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     7
begin
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     8
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     9
abbreviation "events \<equiv> sets M"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    10
abbreviation "prob \<equiv> measure M"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    11
abbreviation "prob_preserving \<equiv> measure_preserving"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    12
abbreviation "random_variable \<equiv> \<lambda> s X. X \<in> measurable M s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    13
abbreviation "expectation \<equiv> integral"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    14
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    15
definition
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    16
  "indep A B \<longleftrightarrow> A \<in> events \<and> B \<in> events \<and> prob (A \<inter> B) = prob A * prob B"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    17
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    18
definition
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    19
  "indep_families F G \<longleftrightarrow> (\<forall> A \<in> F. \<forall> B \<in> G. indep A B)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    20
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    21
definition
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    22
  "distribution X = (\<lambda>s. prob ((X -` s) \<inter> (space M)))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    23
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    24
abbreviation
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    25
  "joint_distribution X Y \<equiv> distribution (\<lambda>x. (X x, Y x))"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    26
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    27
(*
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    28
definition probably :: "('a \<Rightarrow> bool) \<Rightarrow> bool" (binder "\<forall>\<^sup>*" 10) where
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    29
  "probably P \<longleftrightarrow> { x. P x } \<in> events \<and> prob { x. P x } = 1"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    30
definition possibly :: "('a \<Rightarrow> bool) \<Rightarrow> bool" (binder "\<exists>\<^sup>*" 10) where
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    31
  "possibly P \<longleftrightarrow> { x. P x } \<in> events \<and> prob { x. P x } \<noteq> 0"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    32
*)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    33
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    34
definition
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    35
  "conditional_expectation X M' \<equiv> SOME f. f \<in> measurable M' borel_space \<and>
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    36
    (\<forall> g \<in> sets M'. measure_space.integral M' (\<lambda>x. f x * indicator_fn g x) =
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    37
                    measure_space.integral M' (\<lambda>x. X x * indicator_fn g x))"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    38
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    39
definition
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    40
  "conditional_prob E M' \<equiv> conditional_expectation (indicator_fn E) M'"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    41
35929
90f38c8831e2 Unhide measure_space.positive defined in Caratheodory.
hoelzl
parents: 35582
diff changeset
    42
lemma positive': "positive M prob"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    43
  unfolding positive_def using positive empty_measure by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    44
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    45
lemma prob_compl:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    46
  assumes "s \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    47
  shows "prob (space M - s) = 1 - prob s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    48
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    49
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    50
  have "prob ((space M - s) \<union> s) = prob (space M - s) + prob s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    51
    using assms additive[unfolded additive_def] by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    52
  thus ?thesis by (simp add:Un_absorb2[OF sets_into_space[OF assms]] prob_space)
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    53
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    54
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    55
lemma indep_space:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    56
  assumes "s \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    57
  shows "indep (space M) s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    58
using assms prob_space
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    59
unfolding indep_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    60
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    61
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    62
lemma prob_space_increasing:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    63
  "increasing M prob"
35929
90f38c8831e2 Unhide measure_space.positive defined in Caratheodory.
hoelzl
parents: 35582
diff changeset
    64
by (rule additive_increasing[OF positive' additive])
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    65
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    66
lemma prob_subadditive:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    67
  assumes "s \<in> events" "t \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    68
  shows "prob (s \<union> t) \<le> prob s + prob t"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    69
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    70
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    71
  have "prob (s \<union> t) = prob ((s - t) \<union> t)" by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    72
  also have "\<dots> = prob (s - t) + prob t"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    73
    using additive[unfolded additive_def, rule_format, of "s-t" "t"] 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    74
      assms by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    75
  also have "\<dots> \<le> prob s + prob t"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    76
    using prob_space_increasing[unfolded increasing_def, rule_format] assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    77
    by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    78
  finally show ?thesis by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    79
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    80
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    81
lemma prob_zero_union:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    82
  assumes "s \<in> events" "t \<in> events" "prob t = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    83
  shows "prob (s \<union> t) = prob s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    84
using assms 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    85
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    86
  have "prob (s \<union> t) \<le> prob s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    87
    using prob_subadditive[of s t] assms by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    88
  moreover have "prob (s \<union> t) \<ge> prob s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    89
    using prob_space_increasing[unfolded increasing_def, rule_format] 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    90
      assms by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    91
  ultimately show ?thesis by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    92
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    93
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    94
lemma prob_eq_compl:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    95
  assumes "s \<in> events" "t \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    96
  assumes "prob (space M - s) = prob (space M - t)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    97
  shows "prob s = prob t"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    98
using assms prob_compl by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    99
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   100
lemma prob_one_inter:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   101
  assumes events:"s \<in> events" "t \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   102
  assumes "prob t = 1"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   103
  shows "prob (s \<inter> t) = prob s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   104
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   105
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   106
  have "prob ((space M - s) \<union> (space M - t)) = prob (space M - s)" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   107
    using prob_compl[of "t"] prob_zero_union assms by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   108
  then show "prob (s \<inter> t) = prob s" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   109
    using prob_eq_compl[of "s \<inter> t"] events by (simp only: Diff_Int) auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   110
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   111
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   112
lemma prob_eq_bigunion_image:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   113
  assumes "range f \<subseteq> events" "range g \<subseteq> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   114
  assumes "disjoint_family f" "disjoint_family g"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   115
  assumes "\<And> n :: nat. prob (f n) = prob (g n)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   116
  shows "(prob (\<Union> i. f i) = prob (\<Union> i. g i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   117
using assms 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   118
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   119
  have a: "(\<lambda> i. prob (f i)) sums (prob (\<Union> i. f i))" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   120
    using ca[unfolded countably_additive_def] assms by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   121
  have b: "(\<lambda> i. prob (g i)) sums (prob (\<Union> i. g i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   122
    using ca[unfolded countably_additive_def] assms by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   123
  show ?thesis using sums_unique[OF b] sums_unique[OF a] assms by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   124
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   125
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   126
lemma prob_countably_subadditive: 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   127
  assumes "range f \<subseteq> events" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   128
  assumes "summable (prob \<circ> f)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   129
  shows "prob (\<Union>i. f i) \<le> (\<Sum> i. prob (f i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   130
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   131
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   132
  def f' == "\<lambda> i. f i - (\<Union> j \<in> {0 ..< i}. f j)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   133
  have "(\<Union> i. f' i) \<subseteq> (\<Union> i. f i)" unfolding f'_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   134
  moreover have "(\<Union> i. f' i) \<supseteq> (\<Union> i. f i)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   135
  proof (rule subsetI)
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   136
    fix x assume "x \<in> (\<Union> i. f i)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   137
    then obtain k where "x \<in> f k" by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   138
    hence k: "k \<in> {m. x \<in> f m}" by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   139
    have "\<exists> l. x \<in> f l \<and> (\<forall> l' < l. x \<notin> f l')"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   140
      using wfE_min[of "{(x, y). x < y}" "k" "{m. x \<in> f m}", 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   141
        OF wf_less k] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   142
    thus "x \<in> (\<Union> i. f' i)" unfolding f'_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   143
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   144
  ultimately have uf'f: "(\<Union> i. f' i) = (\<Union> i. f i)" by (rule equalityI)
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   145
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   146
  have df': "\<And> i j. i < j \<Longrightarrow> f' i \<inter> f' j = {}"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   147
    unfolding f'_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   148
  have "\<And> i j. i \<noteq> j \<Longrightarrow> f' i \<inter> f' j = {}"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   149
    apply (drule iffD1[OF nat_neq_iff])
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   150
    using df' by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   151
  hence df: "disjoint_family f'" unfolding disjoint_family_on_def by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   152
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   153
  have rf': "\<And> i. f' i \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   154
  proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   155
    fix i :: nat
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   156
    have "(\<Union> {f j | j. j \<in> {0 ..< i}}) = (\<Union> j \<in> {0 ..< i}. f j)" by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   157
    hence "(\<Union> {f j | j. j \<in> {0 ..< i}}) \<in> events 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   158
      \<Longrightarrow> (\<Union> j \<in> {0 ..< i}. f j) \<in> events" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   159
    thus "f' i \<in> events" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   160
      unfolding f'_def 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   161
      using assms finite_union[of "{f j | j. j \<in> {0 ..< i}}"]
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   162
        Diff[of "f i" "\<Union> j \<in> {0 ..< i}. f j"] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   163
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   164
  hence uf': "(\<Union> range f') \<in> events" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   165
  
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   166
  have "\<And> i. prob (f' i) \<le> prob (f i)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   167
    using prob_space_increasing[unfolded increasing_def, rule_format, OF rf']
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   168
      assms rf' unfolding f'_def by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   169
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   170
  hence absinc: "\<And> i. \<bar> prob (f' i) \<bar> \<le> prob (f i)"
35929
90f38c8831e2 Unhide measure_space.positive defined in Caratheodory.
hoelzl
parents: 35582
diff changeset
   171
    using abs_of_nonneg positive'[unfolded positive_def]
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   172
      assms rf' by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   173
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   174
  have "prob (\<Union> i. f i) = prob (\<Union> i. f' i)" using uf'f by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   175
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   176
  also have "\<dots> = (\<Sum> i. prob (f' i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   177
    using ca[unfolded countably_additive_def, rule_format]
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   178
    sums_unique rf' uf' df
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   179
    by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   180
  
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   181
  also have "\<dots> \<le> (\<Sum> i. prob (f i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   182
    using summable_le2[of "\<lambda> i. prob (f' i)" "\<lambda> i. prob (f i)", 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   183
      rule_format, OF absinc]
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   184
      assms[unfolded o_def] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   185
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   186
  finally show ?thesis by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   187
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   188
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   189
lemma prob_countably_zero:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   190
  assumes "range c \<subseteq> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   191
  assumes "\<And> i. prob (c i) = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   192
  shows "(prob (\<Union> i :: nat. c i) = 0)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   193
  using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   194
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   195
  have leq0: "0 \<le> prob (\<Union> i. c i)"
35929
90f38c8831e2 Unhide measure_space.positive defined in Caratheodory.
hoelzl
parents: 35582
diff changeset
   196
    using assms positive'[unfolded positive_def, rule_format] 
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   197
    by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   198
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   199
  have "prob (\<Union> i. c i) \<le> (\<Sum> i. prob (c i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   200
    using prob_countably_subadditive[of c, unfolded o_def]
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   201
      assms sums_zero sums_summable by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   202
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   203
  also have "\<dots> = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   204
    using assms sums_zero 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   205
      sums_unique[of "\<lambda> i. prob (c i)" "0"] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   206
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   207
  finally show "prob (\<Union> i. c i) = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   208
    using leq0 by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   209
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   210
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   211
lemma indep_sym:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   212
   "indep a b \<Longrightarrow> indep b a"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   213
unfolding indep_def using Int_commute[of a b] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   214
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   215
lemma indep_refl:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   216
  assumes "a \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   217
  shows "indep a a = (prob a = 0) \<or> (prob a = 1)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   218
using assms unfolding indep_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   219
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   220
lemma prob_equiprobable_finite_unions:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   221
  assumes "s \<in> events" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   222
  assumes "\<And>x. x \<in> s \<Longrightarrow> {x} \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   223
  assumes "finite s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   224
  assumes "\<And> x y. \<lbrakk>x \<in> s; y \<in> s\<rbrakk> \<Longrightarrow> (prob {x} = prob {y})"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   225
  shows "prob s = of_nat (card s) * prob {SOME x. x \<in> s}"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   226
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   227
proof (cases "s = {}")
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   228
  case True thus ?thesis by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   229
next
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   230
  case False hence " \<exists> x. x \<in> s" by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   231
  from someI_ex[OF this] assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   232
  have prob_some: "\<And> x. x \<in> s \<Longrightarrow> prob {x} = prob {SOME y. y \<in> s}" by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   233
  have "prob s = (\<Sum> x \<in> s. prob {x})"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   234
    using assms measure_real_sum_image by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   235
  also have "\<dots> = (\<Sum> x \<in> s. prob {SOME y. y \<in> s})" using prob_some by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   236
  also have "\<dots> = of_nat (card s) * prob {(SOME x. x \<in> s)}"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   237
    using setsum_constant assms by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   238
  finally show ?thesis by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   239
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   240
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   241
lemma prob_real_sum_image_fn:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   242
  assumes "e \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   243
  assumes "\<And> x. x \<in> s \<Longrightarrow> e \<inter> f x \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   244
  assumes "finite s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   245
  assumes "\<And> x y. \<lbrakk>x \<in> s ; y \<in> s ; x \<noteq> y\<rbrakk> \<Longrightarrow> f x \<inter> f y = {}"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   246
  assumes "space M \<subseteq> (\<Union> i \<in> s. f i)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   247
  shows "prob e = (\<Sum> x \<in> s. prob (e \<inter> f x))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   248
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   249
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   250
  let ?S = "{0 ..< card s}"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   251
  obtain g where "g ` ?S = s \<and> inj_on g ?S"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   252
    using ex_bij_betw_nat_finite[unfolded bij_betw_def, of s] assms by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   253
  moreover hence gs: "g ` ?S = s" by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   254
  ultimately have ginj: "inj_on g ?S" by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   255
  let ?f' = "\<lambda> i. e \<inter> f (g i)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   256
  have f': "?f' \<in> ?S \<rightarrow> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   257
    using gs assms by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   258
  hence "\<And> i j. \<lbrakk>i \<in> ?S ; j \<in> ?S ; i \<noteq> j\<rbrakk> 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   259
    \<Longrightarrow> ?f' i \<inter> ?f' j = {}" using assms ginj[unfolded inj_on_def] gs f' by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   260
  hence df': "\<And> i j. \<lbrakk>i < card s ; j < card s ; i \<noteq> j\<rbrakk> 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   261
    \<Longrightarrow> ?f' i \<inter> ?f' j = {}" by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   262
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   263
  have "e = e \<inter> space M" using assms sets_into_space by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   264
  also hence "\<dots> = e \<inter> (\<Union> x \<in> s. f x)" using assms by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   265
  also have "\<dots> = (\<Union> x \<in> g ` ?S. e \<inter> f x)" using gs by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   266
  also have "\<dots> = (\<Union> i \<in> ?S. ?f' i)" by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   267
  finally have "prob e = prob (\<Union> i \<in> ?S. ?f' i)" by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   268
  also have "\<dots> = (\<Sum> i \<in> ?S. prob (?f' i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   269
    apply (subst measure_finitely_additive'')
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   270
    using f' df' assms by (auto simp: disjoint_family_on_def)
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   271
  also have "\<dots> = (\<Sum> x \<in> g ` ?S. prob (e \<inter> f x))" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   272
    using setsum_reindex[of g "?S" "\<lambda> x. prob (e \<inter> f x)"]
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   273
      ginj by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   274
  also have "\<dots> = (\<Sum> x \<in> s. prob (e \<inter> f x))" using gs by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   275
  finally show ?thesis by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   276
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   277
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   278
lemma distribution_prob_space:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   279
  assumes "random_variable s X"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   280
  shows "prob_space \<lparr>space = space s, sets = sets s, measure = distribution X\<rparr>"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   281
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   282
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   283
  let ?N = "\<lparr>space = space s, sets = sets s, measure = distribution X\<rparr>"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   284
  interpret s: sigma_algebra "s" using assms[unfolded measurable_def] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   285
  hence sigN: "sigma_algebra ?N" using s.sigma_algebra_extend by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   286
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   287
  have pos: "\<And> e. e \<in> sets s \<Longrightarrow> distribution X e \<ge> 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   288
    unfolding distribution_def
35929
90f38c8831e2 Unhide measure_space.positive defined in Caratheodory.
hoelzl
parents: 35582
diff changeset
   289
    using positive'[unfolded positive_def]
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   290
    assms[unfolded measurable_def] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   291
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   292
  have cas: "countably_additive ?N (distribution X)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   293
  proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   294
    {
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   295
      fix f :: "nat \<Rightarrow> 'c \<Rightarrow> bool"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   296
      let ?g = "\<lambda> n. X -` f n \<inter> space M"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   297
      assume asm: "range f \<subseteq> sets s" "UNION UNIV f \<in> sets s" "disjoint_family f"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   298
      hence "range ?g \<subseteq> events" 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   299
        using assms unfolding measurable_def by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   300
      from ca[unfolded countably_additive_def, 
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   301
        rule_format, of ?g, OF this] countable_UN[OF this] asm
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   302
      have "(\<lambda> n. prob (?g n)) sums prob (UNION UNIV ?g)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   303
        unfolding disjoint_family_on_def by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   304
      moreover have "(X -` (\<Union> n. f n)) = (\<Union> n. X -` f n)" by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   305
      ultimately have "(\<lambda> n. distribution X (f n)) sums distribution X (UNION UNIV f)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   306
        unfolding distribution_def by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   307
    } thus ?thesis unfolding countably_additive_def by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   308
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   309
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   310
  have ds0: "distribution X {} = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   311
    unfolding distribution_def by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   312
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   313
  have "X -` space s \<inter> space M = space M"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   314
    using assms[unfolded measurable_def] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   315
  hence ds1: "distribution X (space s) = 1"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   316
    unfolding measurable_def distribution_def using prob_space by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   317
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   318
  from ds0 ds1 cas pos sigN
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   319
  show "prob_space ?N"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   320
    unfolding prob_space_def prob_space_axioms_def
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   321
    measure_space_def measure_space_axioms_def by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   322
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   323
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   324
lemma distribution_lebesgue_thm1:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   325
  assumes "random_variable s X"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   326
  assumes "A \<in> sets s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   327
  shows "distribution X A = expectation (indicator_fn (X -` A \<inter> space M))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   328
unfolding distribution_def
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   329
using assms unfolding measurable_def
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   330
using integral_indicator_fn by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   331
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   332
lemma distribution_lebesgue_thm2:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   333
  assumes "random_variable s X" "A \<in> sets s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   334
  shows "distribution X A = measure_space.integral \<lparr>space = space s, sets = sets s, measure = distribution X\<rparr> (indicator_fn A)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   335
  (is "_ = measure_space.integral ?M _")
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   336
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   337
  interpret S: prob_space ?M using assms(1) by (rule distribution_prob_space)
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   338
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   339
  show ?thesis
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   340
    using S.integral_indicator_fn(1)
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   341
    using assms unfolding distribution_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   342
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   343
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   344
lemma finite_expectation1:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   345
  assumes "finite (space M)" "random_variable borel_space X"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   346
  shows "expectation X = (\<Sum> r \<in> X ` space M. r * prob (X -` {r} \<inter> space M))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   347
  using assms integral_finite measurable_def
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   348
  unfolding borel_measurable_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   349
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   350
lemma finite_expectation:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   351
  assumes "finite (space M) \<and> random_variable borel_space X"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   352
  shows "expectation X = (\<Sum> r \<in> X ` (space M). r * distribution X {r})"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   353
using assms unfolding distribution_def using finite_expectation1 by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   354
lemma prob_x_eq_1_imp_prob_y_eq_0:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   355
  assumes "{x} \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   356
  assumes "(prob {x} = 1)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   357
  assumes "{y} \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   358
  assumes "y \<noteq> x"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   359
  shows "prob {y} = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   360
  using prob_one_inter[of "{y}" "{x}"] assms by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   361
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   362
lemma distribution_x_eq_1_imp_distribution_y_eq_0:
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   363
  assumes X: "random_variable \<lparr>space = X ` (space M), sets = Pow (X ` (space M))\<rparr> X"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   364
  assumes "(distribution X {x} = 1)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   365
  assumes "y \<noteq> x"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   366
  shows "distribution X {y} = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   367
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   368
  let ?S = "\<lparr>space = X ` (space M), sets = Pow (X ` (space M))\<rparr>"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   369
  let ?M = "\<lparr>space = X ` (space M), sets = Pow (X ` (space M)), measure = distribution X\<rparr>"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   370
  interpret S: prob_space ?M
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   371
    using distribution_prob_space[OF X] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   372
  { assume "{x} \<notin> sets ?M"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   373
    hence "x \<notin> X ` space M" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   374
    hence "X -` {x} \<inter> space M = {}" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   375
    hence "distribution X {x} = 0" unfolding distribution_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   376
    hence "False" using assms by auto }
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   377
  hence x: "{x} \<in> sets ?M" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   378
  { assume "{y} \<notin> sets ?M"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   379
    hence "y \<notin> X ` space M" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   380
    hence "X -` {y} \<inter> space M = {}" by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   381
    hence "distribution X {y} = 0" unfolding distribution_def by auto }
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   382
  moreover
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   383
  { assume "{y} \<in> sets ?M"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   384
    hence "distribution X {y} = 0" using assms S.prob_x_eq_1_imp_prob_y_eq_0[OF x] by auto }
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   385
  ultimately show ?thesis by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   386
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   387
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   388
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   389
end
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   390
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   391
locale finite_prob_space = prob_space + finite_measure_space
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   392
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   393
lemma finite_prob_space_eq:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   394
  "finite_prob_space M \<longleftrightarrow> finite_measure_space M \<and> measure M (space M) = 1"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   395
  unfolding finite_prob_space_def finite_measure_space_def prob_space_def prob_space_axioms_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   396
  by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   397
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   398
lemma (in prob_space) not_empty: "space M \<noteq> {}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   399
  using prob_space empty_measure by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   400
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   401
lemma (in finite_prob_space) sum_over_space_eq_1: "(\<Sum>x\<in>space M. measure M {x}) = 1"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   402
  using prob_space sum_over_space by simp
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   403
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   404
lemma (in finite_prob_space) positive_distribution: "0 \<le> distribution X x"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   405
  unfolding distribution_def using positive sets_eq_Pow by simp
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   406
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   407
lemma (in finite_prob_space) joint_distribution_restriction_fst:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   408
  "joint_distribution X Y A \<le> distribution X (fst ` A)"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   409
  unfolding distribution_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   410
proof (safe intro!: measure_mono)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   411
  fix x assume "x \<in> space M" and *: "(X x, Y x) \<in> A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   412
  show "x \<in> X -` fst ` A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   413
    by (auto intro!: image_eqI[OF _ *])
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   414
qed (simp_all add: sets_eq_Pow)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   415
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   416
lemma (in finite_prob_space) joint_distribution_restriction_snd:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   417
  "joint_distribution X Y A \<le> distribution Y (snd ` A)"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   418
  unfolding distribution_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   419
proof (safe intro!: measure_mono)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   420
  fix x assume "x \<in> space M" and *: "(X x, Y x) \<in> A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   421
  show "x \<in> Y -` snd ` A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   422
    by (auto intro!: image_eqI[OF _ *])
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   423
qed (simp_all add: sets_eq_Pow)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   424
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   425
lemma (in finite_prob_space) distribution_order:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   426
  shows "0 \<le> distribution X x'"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   427
  and "(distribution X x' \<noteq> 0) \<longleftrightarrow> (0 < distribution X x')"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   428
  and "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution X {x}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   429
  and "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution Y {y}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   430
  and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution X {x}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   431
  and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution Y {y}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   432
  and "distribution X {x} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   433
  and "distribution Y {y} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   434
  using positive_distribution[of X x']
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   435
    positive_distribution[of "\<lambda>x. (X x, Y x)" "{(x, y)}"]
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   436
    joint_distribution_restriction_fst[of X Y "{(x, y)}"]
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   437
    joint_distribution_restriction_snd[of X Y "{(x, y)}"]
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   438
  by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   439
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   440
lemma (in finite_prob_space) finite_product_measure_space:
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   441
  assumes "finite s1" "finite s2"
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   442
  shows "finite_measure_space \<lparr> space = s1 \<times> s2, sets = Pow (s1 \<times> s2), measure = joint_distribution X Y\<rparr>"
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   443
    (is "finite_measure_space ?M")
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   444
proof (rule finite_Pow_additivity_sufficient)
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   445
  show "positive ?M (measure ?M)"
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   446
    unfolding positive_def using positive'[unfolded positive_def] assms sets_eq_Pow
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   447
    by (simp add: distribution_def)
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   448
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   449
  show "additive ?M (measure ?M)" unfolding additive_def
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   450
  proof safe
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   451
    fix x y
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   452
    have A: "((\<lambda>x. (X x, Y x)) -` x) \<inter> space M \<in> sets M" using assms sets_eq_Pow by auto
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   453
    have B: "((\<lambda>x. (X x, Y x)) -` y) \<inter> space M \<in> sets M" using assms sets_eq_Pow by auto
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   454
    assume "x \<inter> y = {}"
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   455
    from additive[unfolded additive_def, rule_format, OF A B] this
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   456
    show "measure ?M (x \<union> y) = measure ?M x + measure ?M y"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   457
      apply (simp add: distribution_def)
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   458
      apply (subst Int_Un_distrib2)
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   459
      by auto
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   460
  qed
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   461
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   462
  show "finite (space ?M)"
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   463
    using assms by auto
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   464
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   465
  show "sets ?M = Pow (space ?M)"
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   466
    by simp
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   467
qed
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   468
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   469
lemma (in finite_prob_space) finite_product_measure_space_of_images:
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   470
  shows "finite_measure_space \<lparr> space = X ` space M \<times> Y ` space M,
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   471
                                sets = Pow (X ` space M \<times> Y ` space M),
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   472
                                measure = joint_distribution X Y\<rparr>"
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   473
    (is "finite_measure_space ?M")
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   474
  using finite_space by (auto intro!: finite_product_measure_space)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   475
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   476
lemma (in finite_prob_space) finite_measure_space:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   477
  shows "finite_measure_space \<lparr> space = X ` space M, sets = Pow (X ` space M), measure = distribution X\<rparr>"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   478
    (is "finite_measure_space ?S")
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   479
proof (rule finite_Pow_additivity_sufficient, simp_all)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   480
  show "finite (X ` space M)" using finite_space by simp
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   481
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   482
  show "positive ?S (distribution X)" unfolding distribution_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   483
    unfolding positive_def using positive'[unfolded positive_def] sets_eq_Pow by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   484
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   485
  show "additive ?S (distribution X)" unfolding additive_def distribution_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   486
  proof (simp, safe)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   487
    fix x y
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   488
    have x: "(X -` x) \<inter> space M \<in> sets M"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   489
      and y: "(X -` y) \<inter> space M \<in> sets M" using sets_eq_Pow by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   490
    assume "x \<inter> y = {}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   491
    from additive[unfolded additive_def, rule_format, OF x y] this
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   492
    have "prob (((X -` x) \<union> (X -` y)) \<inter> space M) =
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   493
      prob ((X -` x) \<inter> space M) + prob ((X -` y) \<inter> space M)"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   494
      apply (subst Int_Un_distrib2)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   495
      by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   496
    thus "prob ((X -` x \<union> X -` y) \<inter> space M) = prob (X -` x \<inter> space M) + prob (X -` y \<inter> space M)"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   497
      by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   498
  qed
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   499
qed
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   500
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   501
lemma (in finite_prob_space) finite_prob_space_of_images:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   502
  "finite_prob_space \<lparr> space = X ` space M, sets = Pow (X ` space M), measure = distribution X\<rparr>"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   503
  (is "finite_prob_space ?S")
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   504
proof (simp add: finite_prob_space_eq, safe)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   505
  show "finite_measure_space ?S" by (rule finite_measure_space)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   506
  have "X -` X ` space M \<inter> space M = space M" by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   507
  thus "distribution X (X`space M) = 1"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   508
    by (simp add: distribution_def prob_space)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   509
qed
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   510
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   511
lemma (in finite_prob_space) finite_product_prob_space_of_images:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   512
  "finite_prob_space \<lparr> space = X ` space M \<times> Y ` space M, sets = Pow (X ` space M \<times> Y ` space M), 
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   513
    measure = joint_distribution X Y\<rparr>"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   514
  (is "finite_prob_space ?S")
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   515
proof (simp add: finite_prob_space_eq, safe)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   516
  show "finite_measure_space ?S" by (rule finite_product_measure_space_of_images)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   517
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   518
  have "X -` X ` space M \<inter> Y -` Y ` space M \<inter> space M = space M" by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   519
  thus "joint_distribution X Y (X ` space M \<times> Y ` space M) = 1"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   520
    by (simp add: distribution_def prob_space vimage_Times comp_def)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   521
qed
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   522
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   523
end