src/HOL/Probability/Probability_Measure.thy
author hoelzl
Mon, 19 May 2014 12:04:45 +0200
changeset 56993 e5366291d6aa
parent 56166 9a241bc276cd
child 56994 8d5e5ec1cac3
permissions -rw-r--r--
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42148
d596e7bb251f rename Probability_Space to Probability_Measure
hoelzl
parents: 42146
diff changeset
     1
(*  Title:      HOL/Probability/Probability_Measure.thy
42067
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
42148
d596e7bb251f rename Probability_Space to Probability_Measure
hoelzl
parents: 42146
diff changeset
     6
header {*Probability measure*}
42067
66c8281349ec standardized headers
hoelzl
parents: 41981
diff changeset
     7
42148
d596e7bb251f rename Probability_Space to Probability_Measure
hoelzl
parents: 42146
diff changeset
     8
theory Probability_Measure
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
     9
  imports Lebesgue_Measure Radon_Nikodym
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    10
begin
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    11
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    12
locale prob_space = finite_measure +
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    13
  assumes emeasure_space_1: "emeasure M (space M) = 1"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    14
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    15
lemma prob_spaceI[Pure.intro!]:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    16
  assumes *: "emeasure M (space M) = 1"
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    17
  shows "prob_space M"
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    18
proof -
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    19
  interpret finite_measure M
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    20
  proof
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    21
    show "emeasure M (space M) \<noteq> \<infinity>" using * by simp 
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    22
  qed
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
    23
  show "prob_space M" by default fact
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    24
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    25
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    26
abbreviation (in prob_space) "events \<equiv> sets M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    27
abbreviation (in prob_space) "prob \<equiv> measure M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    28
abbreviation (in prob_space) "random_variable M' X \<equiv> X \<in> measurable M M'"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
    29
abbreviation (in prob_space) "expectation \<equiv> integral\<^sup>L M"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    30
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    31
lemma (in prob_space) prob_space_distr:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    32
  assumes f: "f \<in> measurable M M'" shows "prob_space (distr M M' f)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    33
proof (rule prob_spaceI)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    34
  have "f -` space M' \<inter> space M = space M" using f by (auto dest: measurable_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    35
  with f show "emeasure (distr M M' f) (space (distr M M' f)) = 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    36
    by (auto simp: emeasure_distr emeasure_space_1)
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
    37
qed
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
    38
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    39
lemma (in prob_space) prob_space: "prob (space M) = 1"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    40
  using emeasure_space_1 unfolding measure_def by (simp add: one_ereal_def)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    41
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    42
lemma (in prob_space) prob_le_1[simp, intro]: "prob A \<le> 1"
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    43
  using bounded_measure[of A] by (simp add: prob_space)
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    44
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    45
lemma (in prob_space) not_empty: "space M \<noteq> {}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    46
  using prob_space by auto
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    47
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    48
lemma (in prob_space) measure_le_1: "emeasure M X \<le> 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    49
  using emeasure_space[of M X] by (simp add: emeasure_space_1)
42950
6e5c2a3c69da move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents: 42902
diff changeset
    50
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
    51
lemma (in prob_space) AE_I_eq_1:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    52
  assumes "emeasure M {x\<in>space M. P x} = 1" "{x\<in>space M. P x} \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    53
  shows "AE x in M. P x"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
    54
proof (rule AE_I)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    55
  show "emeasure M (space M - {x \<in> space M. P x}) = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    56
    using assms emeasure_space_1 by (simp add: emeasure_compl)
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
    57
qed (insert assms, auto)
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
    58
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    59
lemma (in prob_space) prob_compl:
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    60
  assumes A: "A \<in> events"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    61
  shows "prob (space M - A) = 1 - prob A"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41831
diff changeset
    62
  using finite_measure_compl[OF A] by (simp add: prob_space)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    63
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    64
lemma (in prob_space) AE_in_set_eq_1:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    65
  assumes "A \<in> events" shows "(AE x in M. x \<in> A) \<longleftrightarrow> prob A = 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    66
proof
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    67
  assume ae: "AE x in M. x \<in> A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    68
  have "{x \<in> space M. x \<in> A} = A" "{x \<in> space M. x \<notin> A} = space M - A"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
    69
    using `A \<in> events`[THEN sets.sets_into_space] by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    70
  with AE_E2[OF ae] `A \<in> events` have "1 - emeasure M A = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    71
    by (simp add: emeasure_compl emeasure_space_1)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    72
  then show "prob A = 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    73
    using `A \<in> events` by (simp add: emeasure_eq_measure one_ereal_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    74
next
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    75
  assume prob: "prob A = 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    76
  show "AE x in M. x \<in> A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    77
  proof (rule AE_I)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    78
    show "{x \<in> space M. x \<notin> A} \<subseteq> space M - A" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    79
    show "emeasure M (space M - A) = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    80
      using `A \<in> events` prob
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    81
      by (simp add: prob_compl emeasure_space_1 emeasure_eq_measure one_ereal_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    82
    show "space M - A \<in> events"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    83
      using `A \<in> events` by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    84
  qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    85
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    86
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    87
lemma (in prob_space) AE_False: "(AE x in M. False) \<longleftrightarrow> False"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    88
proof
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    89
  assume "AE x in M. False"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    90
  then have "AE x in M. x \<in> {}" by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    91
  then show False
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    92
    by (subst (asm) AE_in_set_eq_1) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    93
qed simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    94
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    95
lemma (in prob_space) AE_prob_1:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    96
  assumes "prob A = 1" shows "AE x in M. x \<in> A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    97
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    98
  from `prob A = 1` have "A \<in> events"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
    99
    by (metis measure_notin_sets zero_neq_one)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   100
  with AE_in_set_eq_1 assms show ?thesis by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   101
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   102
50098
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   103
lemma (in prob_space) AE_const[simp]: "(AE x in M. P) \<longleftrightarrow> P"
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   104
  by (cases P) (auto simp: AE_False)
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   105
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   106
lemma (in prob_space) AE_contr:
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   107
  assumes ae: "AE \<omega> in M. P \<omega>" "AE \<omega> in M. \<not> P \<omega>"
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   108
  shows False
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   109
proof -
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   110
  from ae have "AE \<omega> in M. False" by eventually_elim auto
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   111
  then show False by auto
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   112
qed
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   113
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   114
lemma (in prob_space) expectation_less:
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   115
  fixes X :: "_ \<Rightarrow> real"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   116
  assumes [simp]: "integrable M X"
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   117
  assumes gt: "AE x in M. X x < b"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   118
  shows "expectation X < b"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   119
proof -
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   120
  have "expectation X < expectation (\<lambda>x. b)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   121
    using gt emeasure_space_1
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 43339
diff changeset
   122
    by (intro integral_less_AE_space) auto
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   123
  then show ?thesis using prob_space by simp
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   124
qed
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   125
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   126
lemma (in prob_space) expectation_greater:
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   127
  fixes X :: "_ \<Rightarrow> real"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   128
  assumes [simp]: "integrable M X"
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   129
  assumes gt: "AE x in M. a < X x"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   130
  shows "a < expectation X"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   131
proof -
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   132
  have "expectation (\<lambda>x. a) < expectation X"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   133
    using gt emeasure_space_1
43340
60e181c4eae4 lemma: independence is equal to mutual information = 0
hoelzl
parents: 43339
diff changeset
   134
    by (intro integral_less_AE_space) auto
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   135
  then show ?thesis using prob_space by simp
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   136
qed
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   137
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   138
lemma (in prob_space) jensens_inequality:
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   139
  fixes q :: "real \<Rightarrow> real"
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   140
  assumes X: "integrable M X" "AE x in M. X x \<in> I"
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   141
  assumes I: "I = {a <..< b} \<or> I = {a <..} \<or> I = {..< b} \<or> I = UNIV"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   142
  assumes q: "integrable M (\<lambda>x. q (X x))" "convex_on I q"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   143
  shows "q (expectation X) \<le> expectation (\<lambda>x. q (X x))"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   144
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 45934
diff changeset
   145
  let ?F = "\<lambda>x. Inf ((\<lambda>t. (q x - q t) / (x - t)) ` ({x<..} \<inter> I))"
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   146
  from X(2) AE_False have "I \<noteq> {}" by auto
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   147
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   148
  from I have "open I" by auto
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   149
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   150
  note I
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   151
  moreover
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   152
  { assume "I \<subseteq> {a <..}"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   153
    with X have "a < expectation X"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   154
      by (intro expectation_greater) auto }
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   155
  moreover
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   156
  { assume "I \<subseteq> {..< b}"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   157
    with X have "expectation X < b"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   158
      by (intro expectation_less) auto }
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   159
  ultimately have "expectation X \<in> I"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   160
    by (elim disjE)  (auto simp: subset_eq)
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   161
  moreover
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   162
  { fix y assume y: "y \<in> I"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   163
    with q(2) `open I` have "Sup ((\<lambda>x. q x + ?F x * (y - x)) ` I) = q y"
56166
9a241bc276cd normalising simp rules for compound operators
haftmann
parents: 54418
diff changeset
   164
      by (auto intro!: cSup_eq_maximum convex_le_Inf_differential image_eqI [OF _ y] simp: interior_open simp del: Sup_image_eq Inf_image_eq) }
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   165
  ultimately have "q (expectation X) = Sup ((\<lambda>x. q x + ?F x * (expectation X - x)) ` I)"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   166
    by simp
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   167
  also have "\<dots> \<le> expectation (\<lambda>w. q (X w))"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50419
diff changeset
   168
  proof (rule cSup_least)
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   169
    show "(\<lambda>x. q x + ?F x * (expectation X - x)) ` I \<noteq> {}"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   170
      using `I \<noteq> {}` by auto
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   171
  next
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   172
    fix k assume "k \<in> (\<lambda>x. q x + ?F x * (expectation X - x)) ` I"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   173
    then guess x .. note x = this
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   174
    have "q x + ?F x * (expectation X  - x) = expectation (\<lambda>w. q x + ?F x * (X w - x))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   175
      using prob_space by (simp add: X)
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   176
    also have "\<dots> \<le> expectation (\<lambda>w. q (X w))"
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   177
      using `x \<in> I` `open I` X(2)
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   178
      apply (intro integral_mono_AE integrable_add integrable_mult_right integrable_diff
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   179
                integrable_const X q)
49786
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   180
      apply (elim eventually_elim1)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   181
      apply (intro convex_le_Inf_differential)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   182
      apply (auto simp: interior_open q)
f33d5f009627 continuous version of entropy_le
hoelzl
parents: 49783
diff changeset
   183
      done
43339
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   184
    finally show "k \<le> expectation (\<lambda>w. q (X w))" using x by auto
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   185
  qed
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   186
  finally show "q (expectation X) \<le> expectation (\<lambda>x. q (X x))" .
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   187
qed
9ba256ad6781 jensens inequality
hoelzl
parents: 42991
diff changeset
   188
50001
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   189
subsection  {* Introduce binder for probability *}
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   190
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   191
syntax
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   192
  "_prob" :: "pttrn \<Rightarrow> logic \<Rightarrow> logic \<Rightarrow> logic" ("('\<P>'(_ in _. _'))")
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   193
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   194
translations
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   195
  "\<P>(x in M. P)" => "CONST measure M {x \<in> CONST space M. P}"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   196
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   197
definition
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   198
  "cond_prob M P Q = \<P>(\<omega> in M. P \<omega> \<and> Q \<omega>) / \<P>(\<omega> in M. Q \<omega>)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   199
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   200
syntax
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   201
  "_conditional_prob" :: "pttrn \<Rightarrow> logic \<Rightarrow> logic \<Rightarrow> logic \<Rightarrow> logic" ("('\<P>'(_ in _. _ \<bar>/ _'))")
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   202
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   203
translations
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   204
  "\<P>(x in M. P \<bar> Q)" => "CONST cond_prob M (\<lambda>x. P) (\<lambda>x. Q)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   205
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   206
lemma (in prob_space) AE_E_prob:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   207
  assumes ae: "AE x in M. P x"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   208
  obtains S where "S \<subseteq> {x \<in> space M. P x}" "S \<in> events" "prob S = 1"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   209
proof -
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   210
  from ae[THEN AE_E] guess N .
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   211
  then show thesis
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   212
    by (intro that[of "space M - N"])
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   213
       (auto simp: prob_compl prob_space emeasure_eq_measure)
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   214
qed
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   215
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   216
lemma (in prob_space) prob_neg: "{x\<in>space M. P x} \<in> events \<Longrightarrow> \<P>(x in M. \<not> P x) = 1 - \<P>(x in M. P x)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   217
  by (auto intro!: arg_cong[where f=prob] simp add: prob_compl[symmetric])
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   218
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   219
lemma (in prob_space) prob_eq_AE:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   220
  "(AE x in M. P x \<longleftrightarrow> Q x) \<Longrightarrow> {x\<in>space M. P x} \<in> events \<Longrightarrow> {x\<in>space M. Q x} \<in> events \<Longrightarrow> \<P>(x in M. P x) = \<P>(x in M. Q x)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   221
  by (rule finite_measure_eq_AE) auto
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   222
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   223
lemma (in prob_space) prob_eq_0_AE:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   224
  assumes not: "AE x in M. \<not> P x" shows "\<P>(x in M. P x) = 0"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   225
proof cases
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   226
  assume "{x\<in>space M. P x} \<in> events"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   227
  with not have "\<P>(x in M. P x) = \<P>(x in M. False)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   228
    by (intro prob_eq_AE) auto
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   229
  then show ?thesis by simp
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   230
qed (simp add: measure_notin_sets)
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   231
50098
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   232
lemma (in prob_space) prob_Collect_eq_0:
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   233
  "{x \<in> space M. P x} \<in> sets M \<Longrightarrow> \<P>(x in M. P x) = 0 \<longleftrightarrow> (AE x in M. \<not> P x)"
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   234
  using AE_iff_measurable[OF _ refl, of M "\<lambda>x. \<not> P x"] by (simp add: emeasure_eq_measure)
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   235
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   236
lemma (in prob_space) prob_Collect_eq_1:
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   237
  "{x \<in> space M. P x} \<in> sets M \<Longrightarrow> \<P>(x in M. P x) = 1 \<longleftrightarrow> (AE x in M. P x)"
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   238
  using AE_in_set_eq_1[of "{x\<in>space M. P x}"] by simp
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   239
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   240
lemma (in prob_space) prob_eq_0:
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   241
  "A \<in> sets M \<Longrightarrow> prob A = 0 \<longleftrightarrow> (AE x in M. x \<notin> A)"
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   242
  using AE_iff_measurable[OF _ refl, of M "\<lambda>x. x \<notin> A"]
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   243
  by (auto simp add: emeasure_eq_measure Int_def[symmetric])
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   244
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   245
lemma (in prob_space) prob_eq_1:
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   246
  "A \<in> sets M \<Longrightarrow> prob A = 1 \<longleftrightarrow> (AE x in M. x \<in> A)"
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   247
  using AE_in_set_eq_1[of A] by simp
98abff4a775b rules for AE and prob
hoelzl
parents: 50003
diff changeset
   248
50001
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   249
lemma (in prob_space) prob_sums:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   250
  assumes P: "\<And>n. {x\<in>space M. P n x} \<in> events"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   251
  assumes Q: "{x\<in>space M. Q x} \<in> events"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   252
  assumes ae: "AE x in M. (\<forall>n. P n x \<longrightarrow> Q x) \<and> (Q x \<longrightarrow> (\<exists>!n. P n x))"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   253
  shows "(\<lambda>n. \<P>(x in M. P n x)) sums \<P>(x in M. Q x)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   254
proof -
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   255
  from ae[THEN AE_E_prob] guess S . note S = this
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   256
  then have disj: "disjoint_family (\<lambda>n. {x\<in>space M. P n x} \<inter> S)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   257
    by (auto simp: disjoint_family_on_def)
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   258
  from S have ae_S:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   259
    "AE x in M. x \<in> {x\<in>space M. Q x} \<longleftrightarrow> x \<in> (\<Union>n. {x\<in>space M. P n x} \<inter> S)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   260
    "\<And>n. AE x in M. x \<in> {x\<in>space M. P n x} \<longleftrightarrow> x \<in> {x\<in>space M. P n x} \<inter> S"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   261
    using ae by (auto dest!: AE_prob_1)
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   262
  from ae_S have *:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   263
    "\<P>(x in M. Q x) = prob (\<Union>n. {x\<in>space M. P n x} \<inter> S)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   264
    using P Q S by (intro finite_measure_eq_AE) auto
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   265
  from ae_S have **:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   266
    "\<And>n. \<P>(x in M. P n x) = prob ({x\<in>space M. P n x} \<inter> S)"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   267
    using P Q S by (intro finite_measure_eq_AE) auto
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   268
  show ?thesis
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   269
    unfolding * ** using S P disj
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   270
    by (intro finite_measure_UNION) auto
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   271
qed
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   272
54418
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   273
lemma (in prob_space) prob_EX_countable:
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   274
  assumes sets: "\<And>i. i \<in> I \<Longrightarrow> {x\<in>space M. P i x} \<in> sets M" and I: "countable I" 
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   275
  assumes disj: "AE x in M. \<forall>i\<in>I. \<forall>j\<in>I. P i x \<longrightarrow> P j x \<longrightarrow> i = j"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   276
  shows "\<P>(x in M. \<exists>i\<in>I. P i x) = (\<integral>\<^sup>+i. \<P>(x in M. P i x) \<partial>count_space I)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   277
proof -
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   278
  let ?N= "\<lambda>x. \<exists>!i\<in>I. P i x"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   279
  have "ereal (\<P>(x in M. \<exists>i\<in>I. P i x)) = \<P>(x in M. (\<exists>i\<in>I. P i x \<and> ?N x))"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   280
    unfolding ereal.inject
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   281
  proof (rule prob_eq_AE)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   282
    show "AE x in M. (\<exists>i\<in>I. P i x) = (\<exists>i\<in>I. P i x \<and> ?N x)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   283
      using disj by eventually_elim blast
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   284
  qed (auto intro!: sets.sets_Collect_countable_Ex' sets.sets_Collect_conj sets.sets_Collect_countable_Ex1' I sets)+
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   285
  also have "\<P>(x in M. (\<exists>i\<in>I. P i x \<and> ?N x)) = emeasure M (\<Union>i\<in>I. {x\<in>space M. P i x \<and> ?N x})"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   286
    unfolding emeasure_eq_measure by (auto intro!: arg_cong[where f=prob])
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   287
  also have "\<dots> = (\<integral>\<^sup>+i. emeasure M {x\<in>space M. P i x \<and> ?N x} \<partial>count_space I)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   288
    by (rule emeasure_UN_countable)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   289
       (auto intro!: sets.sets_Collect_countable_Ex' sets.sets_Collect_conj sets.sets_Collect_countable_Ex1' I sets
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   290
             simp: disjoint_family_on_def)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   291
  also have "\<dots> = (\<integral>\<^sup>+i. \<P>(x in M. P i x) \<partial>count_space I)"
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   292
    unfolding emeasure_eq_measure using disj
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   293
    by (intro positive_integral_cong ereal.inject[THEN iffD2] prob_eq_AE)
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   294
       (auto intro!: sets.sets_Collect_countable_Ex' sets.sets_Collect_conj sets.sets_Collect_countable_Ex1' I sets)+
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   295
  finally show ?thesis .
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   296
qed
3b8e33d1a39a measure of a countable union
hoelzl
parents: 53015
diff changeset
   297
50001
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   298
lemma (in prob_space) cond_prob_eq_AE:
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   299
  assumes P: "AE x in M. Q x \<longrightarrow> P x \<longleftrightarrow> P' x" "{x\<in>space M. P x} \<in> events" "{x\<in>space M. P' x} \<in> events"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   300
  assumes Q: "AE x in M. Q x \<longleftrightarrow> Q' x" "{x\<in>space M. Q x} \<in> events" "{x\<in>space M. Q' x} \<in> events"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   301
  shows "cond_prob M P Q = cond_prob M P' Q'"
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   302
  using P Q
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   303
  by (auto simp: cond_prob_def intro!: arg_cong2[where f="op /"] prob_eq_AE sets.sets_Collect_conj)
50001
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   304
382bd3173584 add syntax and a.e.-rules for (conditional) probability on predicates
hoelzl
parents: 49795
diff changeset
   305
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   306
lemma (in prob_space) joint_distribution_Times_le_fst:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   307
  "random_variable MX X \<Longrightarrow> random_variable MY Y \<Longrightarrow> A \<in> sets MX \<Longrightarrow> B \<in> sets MY
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   308
    \<Longrightarrow> emeasure (distr M (MX \<Otimes>\<^sub>M MY) (\<lambda>x. (X x, Y x))) (A \<times> B) \<le> emeasure (distr M MX X) A"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   309
  by (auto simp: emeasure_distr measurable_pair_iff comp_def intro!: emeasure_mono measurable_sets)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   310
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   311
lemma (in prob_space) joint_distribution_Times_le_snd:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   312
  "random_variable MX X \<Longrightarrow> random_variable MY Y \<Longrightarrow> A \<in> sets MX \<Longrightarrow> B \<in> sets MY
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   313
    \<Longrightarrow> emeasure (distr M (MX \<Otimes>\<^sub>M MY) (\<lambda>x. (X x, Y x))) (A \<times> B) \<le> emeasure (distr M MY Y) B"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   314
  by (auto simp: emeasure_distr measurable_pair_iff comp_def intro!: emeasure_mono measurable_sets)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   315
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   316
locale pair_prob_space = pair_sigma_finite M1 M2 + M1: prob_space M1 + M2: prob_space M2 for M1 M2
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
   317
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   318
sublocale pair_prob_space \<subseteq> P: prob_space "M1 \<Otimes>\<^sub>M M2"
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   319
proof
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   320
  show "emeasure (M1 \<Otimes>\<^sub>M M2) (space (M1 \<Otimes>\<^sub>M M2)) = 1"
49776
199d1d5bb17e tuned product measurability
hoelzl
parents: 47694
diff changeset
   321
    by (simp add: M2.emeasure_pair_measure_Times M1.emeasure_space_1 M2.emeasure_space_1 space_pair_measure)
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   322
qed
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   323
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   324
locale product_prob_space = product_sigma_finite M for M :: "'i \<Rightarrow> 'a measure" +
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   325
  fixes I :: "'i set"
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   326
  assumes prob_space: "\<And>i. prob_space (M i)"
42988
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   327
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   328
sublocale product_prob_space \<subseteq> M: prob_space "M i" for i
42988
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   329
  by (rule prob_space)
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   330
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   331
locale finite_product_prob_space = finite_product_sigma_finite M I + product_prob_space M I for M I
42988
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   332
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   333
sublocale finite_product_prob_space \<subseteq> prob_space "\<Pi>\<^sub>M i\<in>I. M i"
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   334
proof
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   335
  show "emeasure (\<Pi>\<^sub>M i\<in>I. M i) (space (\<Pi>\<^sub>M i\<in>I. M i)) = 1"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   336
    by (simp add: measure_times M.emeasure_space_1 setprod_1 space_PiM)
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   337
qed
42988
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   338
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   339
lemma (in finite_product_prob_space) prob_times:
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   340
  assumes X: "\<And>i. i \<in> I \<Longrightarrow> X i \<in> sets (M i)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   341
  shows "prob (\<Pi>\<^sub>E i\<in>I. X i) = (\<Prod>i\<in>I. M.prob i (X i))"
42988
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   342
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   343
  have "ereal (measure (\<Pi>\<^sub>M i\<in>I. M i) (\<Pi>\<^sub>E i\<in>I. X i)) = emeasure (\<Pi>\<^sub>M i\<in>I. M i) (\<Pi>\<^sub>E i\<in>I. X i)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   344
    using X by (simp add: emeasure_eq_measure)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   345
  also have "\<dots> = (\<Prod>i\<in>I. emeasure (M i) (X i))"
42988
d8f3fc934ff6 add lemma indep_distribution_eq_measure
hoelzl
parents: 42981
diff changeset
   346
    using measure_times X by simp
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   347
  also have "\<dots> = ereal (\<Prod>i\<in>I. measure (M i) (X i))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   348
    using X by (simp add: M.emeasure_eq_measure setprod_ereal)
42859
d9dfc733f25c add product of probability spaces with finite cardinality
hoelzl
parents: 42858
diff changeset
   349
  finally show ?thesis by simp
d9dfc733f25c add product of probability spaces with finite cardinality
hoelzl
parents: 42858
diff changeset
   350
qed
d9dfc733f25c add product of probability spaces with finite cardinality
hoelzl
parents: 42858
diff changeset
   351
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   352
section {* Distributions *}
42892
a61e30bfd0bc add lemma prob_finite_product
hoelzl
parents: 42860
diff changeset
   353
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   354
definition "distributed M N X f \<longleftrightarrow> distr M N X = density N f \<and> 
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   355
  f \<in> borel_measurable N \<and> (AE x in N. 0 \<le> f x) \<and> X \<in> measurable M N"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   356
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   357
lemma
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   358
  assumes "distributed M N X f"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   359
  shows distributed_distr_eq_density: "distr M N X = density N f"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   360
    and distributed_measurable: "X \<in> measurable M N"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   361
    and distributed_borel_measurable: "f \<in> borel_measurable N"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   362
    and distributed_AE: "(AE x in N. 0 \<le> f x)"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   363
  using assms by (simp_all add: distributed_def)
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   364
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   365
lemma
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   366
  assumes D: "distributed M N X f"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   367
  shows distributed_measurable'[measurable_dest]:
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   368
      "g \<in> measurable L M \<Longrightarrow> (\<lambda>x. X (g x)) \<in> measurable L N"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   369
    and distributed_borel_measurable'[measurable_dest]:
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   370
      "h \<in> measurable L N \<Longrightarrow> (\<lambda>x. f (h x)) \<in> borel_measurable L"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   371
  using distributed_measurable[OF D] distributed_borel_measurable[OF D]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   372
  by simp_all
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   373
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   374
lemma
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   375
  shows distributed_real_measurable: "distributed M N X (\<lambda>x. ereal (f x)) \<Longrightarrow> f \<in> borel_measurable N"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   376
    and distributed_real_AE: "distributed M N X (\<lambda>x. ereal (f x)) \<Longrightarrow> (AE x in N. 0 \<le> f x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   377
  by (simp_all add: distributed_def borel_measurable_ereal_iff)
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   378
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   379
lemma
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   380
  assumes D: "distributed M N X (\<lambda>x. ereal (f x))"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   381
  shows distributed_real_measurable'[measurable_dest]:
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   382
      "h \<in> measurable L N \<Longrightarrow> (\<lambda>x. f (h x)) \<in> borel_measurable L"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   383
  using distributed_real_measurable[OF D]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   384
  by simp_all
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   385
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   386
lemma
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   387
  assumes D: "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) f"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   388
  shows joint_distributed_measurable1[measurable_dest]:
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   389
      "h1 \<in> measurable N M \<Longrightarrow> (\<lambda>x. X (h1 x)) \<in> measurable N S"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   390
    and joint_distributed_measurable2[measurable_dest]:
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   391
      "h2 \<in> measurable N M \<Longrightarrow> (\<lambda>x. Y (h2 x)) \<in> measurable N T"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   392
  using measurable_compose[OF distributed_measurable[OF D] measurable_fst]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   393
  using measurable_compose[OF distributed_measurable[OF D] measurable_snd]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   394
  by auto
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   395
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   396
lemma distributed_count_space:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   397
  assumes X: "distributed M (count_space A) X P" and a: "a \<in> A" and A: "finite A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   398
  shows "P a = emeasure M (X -` {a} \<inter> space M)"
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   399
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   400
  have "emeasure M (X -` {a} \<inter> space M) = emeasure (distr M (count_space A) X) {a}"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   401
    using X a A by (simp add: emeasure_distr)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   402
  also have "\<dots> = emeasure (density (count_space A) P) {a}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   403
    using X by (simp add: distributed_distr_eq_density)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   404
  also have "\<dots> = (\<integral>\<^sup>+x. P a * indicator {a} x \<partial>count_space A)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   405
    using X a by (auto simp add: emeasure_density distributed_def indicator_def intro!: positive_integral_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   406
  also have "\<dots> = P a"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   407
    using X a by (subst positive_integral_cmult_indicator) (auto simp: distributed_def one_ereal_def[symmetric] AE_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   408
  finally show ?thesis ..
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   409
qed
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   410
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   411
lemma distributed_cong_density:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   412
  "(AE x in N. f x = g x) \<Longrightarrow> g \<in> borel_measurable N \<Longrightarrow> f \<in> borel_measurable N \<Longrightarrow>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   413
    distributed M N X f \<longleftrightarrow> distributed M N X g"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   414
  by (auto simp: distributed_def intro!: density_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   415
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   416
lemma subdensity:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   417
  assumes T: "T \<in> measurable P Q"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   418
  assumes f: "distributed M P X f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   419
  assumes g: "distributed M Q Y g"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   420
  assumes Y: "Y = T \<circ> X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   421
  shows "AE x in P. g (T x) = 0 \<longrightarrow> f x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   422
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   423
  have "{x\<in>space Q. g x = 0} \<in> null_sets (distr M Q (T \<circ> X))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   424
    using g Y by (auto simp: null_sets_density_iff distributed_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   425
  also have "distr M Q (T \<circ> X) = distr (distr M P X) Q T"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   426
    using T f[THEN distributed_measurable] by (rule distr_distr[symmetric])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   427
  finally have "T -` {x\<in>space Q. g x = 0} \<inter> space P \<in> null_sets (distr M P X)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   428
    using T by (subst (asm) null_sets_distr_iff) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   429
  also have "T -` {x\<in>space Q. g x = 0} \<inter> space P = {x\<in>space P. g (T x) = 0}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   430
    using T by (auto dest: measurable_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   431
  finally show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   432
    using f g by (auto simp add: null_sets_density_iff distributed_def)
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   433
qed
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   434
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   435
lemma subdensity_real:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   436
  fixes g :: "'a \<Rightarrow> real" and f :: "'b \<Rightarrow> real"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   437
  assumes T: "T \<in> measurable P Q"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   438
  assumes f: "distributed M P X f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   439
  assumes g: "distributed M Q Y g"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   440
  assumes Y: "Y = T \<circ> X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   441
  shows "AE x in P. g (T x) = 0 \<longrightarrow> f x = 0"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   442
  using subdensity[OF T, of M X "\<lambda>x. ereal (f x)" Y "\<lambda>x. ereal (g x)"] assms by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   443
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   444
lemma distributed_emeasure:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   445
  "distributed M N X f \<Longrightarrow> A \<in> sets N \<Longrightarrow> emeasure M (X -` A \<inter> space M) = (\<integral>\<^sup>+x. f x * indicator A x \<partial>N)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   446
  by (auto simp: distributed_AE
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   447
                 distributed_distr_eq_density[symmetric] emeasure_density[symmetric] emeasure_distr)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   448
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   449
lemma distributed_positive_integral:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   450
  "distributed M N X f \<Longrightarrow> g \<in> borel_measurable N \<Longrightarrow> (\<integral>\<^sup>+x. f x * g x \<partial>N) = (\<integral>\<^sup>+x. g (X x) \<partial>M)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   451
  by (auto simp: distributed_AE
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   452
                 distributed_distr_eq_density[symmetric] positive_integral_density[symmetric] positive_integral_distr)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   453
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   454
lemma distributed_integral:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   455
  "distributed M N X f \<Longrightarrow> g \<in> borel_measurable N \<Longrightarrow> (\<integral>x. f x * g x \<partial>N) = (\<integral>x. g (X x) \<partial>M)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   456
  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: 56166
diff changeset
   457
                 distributed_distr_eq_density[symmetric] integral_real_density[symmetric] integral_distr)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   458
  
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   459
lemma distributed_transform_integral:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   460
  assumes Px: "distributed M N X Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   461
  assumes "distributed M P Y Py"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   462
  assumes Y: "Y = T \<circ> X" and T: "T \<in> measurable N P" and f: "f \<in> borel_measurable P"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   463
  shows "(\<integral>x. Py x * f x \<partial>P) = (\<integral>x. Px x * f (T x) \<partial>N)"
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
   464
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   465
  have "(\<integral>x. Py x * f x \<partial>P) = (\<integral>x. f (Y x) \<partial>M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   466
    by (rule distributed_integral) fact+
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   467
  also have "\<dots> = (\<integral>x. f (T (X x)) \<partial>M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   468
    using Y by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   469
  also have "\<dots> = (\<integral>x. Px x * f (T x) \<partial>N)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   470
    using measurable_comp[OF T f] Px by (intro distributed_integral[symmetric]) (auto simp: comp_def)
45777
c36637603821 remove unnecessary sublocale instantiations in HOL-Probability (for clarity and speedup); remove Infinite_Product_Measure.product_prob_space which was a duplicate of Probability_Measure.product_prob_space
hoelzl
parents: 45712
diff changeset
   471
  finally show ?thesis .
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   472
qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   473
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   474
lemma (in prob_space) distributed_unique:
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   475
  assumes Px: "distributed M S X Px"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   476
  assumes Py: "distributed M S X Py"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   477
  shows "AE x in S. Px x = Py x"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   478
proof -
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   479
  interpret X: prob_space "distr M S X"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   480
    using Px by (intro prob_space_distr) simp
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   481
  have "sigma_finite_measure (distr M S X)" ..
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   482
  with sigma_finite_density_unique[of Px S Py ] Px Py
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   483
  show ?thesis
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   484
    by (auto simp: distributed_def)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   485
qed
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   486
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   487
lemma (in prob_space) distributed_jointI:
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   488
  assumes "sigma_finite_measure S" "sigma_finite_measure T"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   489
  assumes X[measurable]: "X \<in> measurable M S" and Y[measurable]: "Y \<in> measurable M T"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   490
  assumes [measurable]: "f \<in> borel_measurable (S \<Otimes>\<^sub>M T)" and f: "AE x in S \<Otimes>\<^sub>M T. 0 \<le> f x"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   491
  assumes eq: "\<And>A B. A \<in> sets S \<Longrightarrow> B \<in> sets T \<Longrightarrow> 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   492
    emeasure M {x \<in> space M. X x \<in> A \<and> Y x \<in> B} = (\<integral>\<^sup>+x. (\<integral>\<^sup>+y. f (x, y) * indicator B y \<partial>T) * indicator A x \<partial>S)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   493
  shows "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) f"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   494
  unfolding distributed_def
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   495
proof safe
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   496
  interpret S: sigma_finite_measure S by fact
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   497
  interpret T: sigma_finite_measure T by fact
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   498
  interpret ST: pair_sigma_finite S T by default
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   499
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   500
  from ST.sigma_finite_up_in_pair_measure_generator guess F :: "nat \<Rightarrow> ('b \<times> 'c) set" .. note F = this
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   501
  let ?E = "{a \<times> b |a b. a \<in> sets S \<and> b \<in> sets T}"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   502
  let ?P = "S \<Otimes>\<^sub>M T"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   503
  show "distr M ?P (\<lambda>x. (X x, Y x)) = density ?P f" (is "?L = ?R")
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   504
  proof (rule measure_eqI_generator_eq[OF Int_stable_pair_measure_generator[of S T]])
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   505
    show "?E \<subseteq> Pow (space ?P)"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   506
      using sets.space_closed[of S] sets.space_closed[of T] by (auto simp: space_pair_measure)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   507
    show "sets ?L = sigma_sets (space ?P) ?E"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   508
      by (simp add: sets_pair_measure space_pair_measure)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   509
    then show "sets ?R = sigma_sets (space ?P) ?E"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   510
      by simp
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   511
  next
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   512
    interpret L: prob_space ?L
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   513
      by (rule prob_space_distr) (auto intro!: measurable_Pair)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   514
    show "range F \<subseteq> ?E" "(\<Union>i. F i) = space ?P" "\<And>i. emeasure ?L (F i) \<noteq> \<infinity>"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   515
      using F by (auto simp: space_pair_measure)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   516
  next
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   517
    fix E assume "E \<in> ?E"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   518
    then obtain A B where E[simp]: "E = A \<times> B"
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   519
      and A[measurable]: "A \<in> sets S" and B[measurable]: "B \<in> sets T" by auto
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   520
    have "emeasure ?L E = emeasure M {x \<in> space M. X x \<in> A \<and> Y x \<in> B}"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   521
      by (auto intro!: arg_cong[where f="emeasure M"] simp add: emeasure_distr measurable_Pair)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   522
    also have "\<dots> = (\<integral>\<^sup>+x. (\<integral>\<^sup>+y. (f (x, y) * indicator B y) * indicator A x \<partial>T) \<partial>S)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   523
      using f by (auto simp add: eq positive_integral_multc intro!: positive_integral_cong)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   524
    also have "\<dots> = emeasure ?R E"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   525
      by (auto simp add: emeasure_density T.positive_integral_fst[symmetric]
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   526
               intro!: positive_integral_cong split: split_indicator)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   527
    finally show "emeasure ?L E = emeasure ?R E" .
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   528
  qed
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   529
qed (auto simp: f)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   530
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   531
lemma (in prob_space) distributed_swap:
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   532
  assumes "sigma_finite_measure S" "sigma_finite_measure T"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   533
  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: 51683
diff changeset
   534
  shows "distributed M (T \<Otimes>\<^sub>M S) (\<lambda>x. (Y x, X x)) (\<lambda>(x, y). Pxy (y, x))"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   535
proof -
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   536
  interpret S: sigma_finite_measure S by fact
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   537
  interpret T: sigma_finite_measure T by fact
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   538
  interpret ST: pair_sigma_finite S T by default
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   539
  interpret TS: pair_sigma_finite T S by default
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   540
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   541
  note Pxy[measurable]
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   542
  show ?thesis 
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   543
    apply (subst TS.distr_pair_swap)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   544
    unfolding distributed_def
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   545
  proof safe
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   546
    let ?D = "distr (S \<Otimes>\<^sub>M T) (T \<Otimes>\<^sub>M S) (\<lambda>(x, y). (y, x))"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   547
    show 1: "(\<lambda>(x, y). Pxy (y, x)) \<in> borel_measurable ?D"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   548
      by auto
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   549
    with Pxy
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   550
    show "AE x in distr (S \<Otimes>\<^sub>M T) (T \<Otimes>\<^sub>M S) (\<lambda>(x, y). (y, x)). 0 \<le> (case x of (x, y) \<Rightarrow> Pxy (y, x))"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   551
      by (subst AE_distr_iff)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   552
         (auto dest!: distributed_AE
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   553
               simp: measurable_split_conv split_beta
51683
baefa3b461c2 generalize Borel-set properties from real/ereal/ordered_euclidean_spaces to order_topology and real_normed_vector
hoelzl
parents: 51475
diff changeset
   554
               intro!: measurable_Pair)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   555
    show 2: "random_variable (distr (S \<Otimes>\<^sub>M T) (T \<Otimes>\<^sub>M S) (\<lambda>(x, y). (y, x))) (\<lambda>x. (Y x, X x))"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   556
      using Pxy by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   557
    { fix A assume A: "A \<in> sets (T \<Otimes>\<^sub>M S)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   558
      let ?B = "(\<lambda>(x, y). (y, x)) -` A \<inter> space (S \<Otimes>\<^sub>M T)"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   559
      from sets.sets_into_space[OF A]
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   560
      have "emeasure M ((\<lambda>x. (Y x, X x)) -` A \<inter> space M) =
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   561
        emeasure M ((\<lambda>x. (X x, Y x)) -` ?B \<inter> space M)"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   562
        by (auto intro!: arg_cong2[where f=emeasure] simp: space_pair_measure)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   563
      also have "\<dots> = (\<integral>\<^sup>+ x. Pxy x * indicator ?B x \<partial>(S \<Otimes>\<^sub>M T))"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   564
        using Pxy A by (intro distributed_emeasure) auto
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   565
      finally have "emeasure M ((\<lambda>x. (Y x, X x)) -` A \<inter> space M) =
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   566
        (\<integral>\<^sup>+ x. Pxy x * indicator A (snd x, fst x) \<partial>(S \<Otimes>\<^sub>M T))"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   567
        by (auto intro!: positive_integral_cong split: split_indicator) }
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   568
    note * = this
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   569
    show "distr M ?D (\<lambda>x. (Y x, X x)) = density ?D (\<lambda>(x, y). Pxy (y, x))"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   570
      apply (intro measure_eqI)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   571
      apply (simp_all add: emeasure_distr[OF 2] emeasure_density[OF 1])
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   572
      apply (subst positive_integral_distr)
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   573
      apply (auto intro!: * simp: comp_def split_beta)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   574
      done
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   575
  qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   576
qed
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   577
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   578
lemma (in prob_space) distr_marginal1:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   579
  assumes "sigma_finite_measure S" "sigma_finite_measure T"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   580
  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: 51683
diff changeset
   581
  defines "Px \<equiv> \<lambda>x. (\<integral>\<^sup>+z. Pxy (x, z) \<partial>T)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   582
  shows "distributed M S X Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   583
  unfolding distributed_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   584
proof safe
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   585
  interpret S: sigma_finite_measure S by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   586
  interpret T: sigma_finite_measure T by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   587
  interpret ST: pair_sigma_finite S T by default
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   588
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   589
  note Pxy[measurable]
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   590
  show X: "X \<in> measurable M S" by simp
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   591
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   592
  show borel: "Px \<in> borel_measurable S"
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   593
    by (auto intro!: T.positive_integral_fst simp: Px_def)
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   594
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   595
  interpret Pxy: prob_space "distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   596
    by (intro prob_space_distr) simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   597
  have "(\<integral>\<^sup>+ x. max 0 (- Pxy x) \<partial>(S \<Otimes>\<^sub>M T)) = (\<integral>\<^sup>+ x. 0 \<partial>(S \<Otimes>\<^sub>M T))"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   598
    using Pxy
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   599
    by (intro positive_integral_cong_AE) (auto simp: max_def dest: distributed_AE)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   600
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   601
  show "distr M S X = density S Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   602
  proof (rule measure_eqI)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   603
    fix A assume A: "A \<in> sets (distr M S X)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   604
    with X measurable_space[of Y M T]
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   605
    have "emeasure (distr M S X) A = emeasure (distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))) (A \<times> space T)"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   606
      by (auto simp add: emeasure_distr intro!: arg_cong[where f="emeasure M"])
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   607
    also have "\<dots> = emeasure (density (S \<Otimes>\<^sub>M T) Pxy) (A \<times> space T)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   608
      using Pxy by (simp add: distributed_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   609
    also have "\<dots> = \<integral>\<^sup>+ x. \<integral>\<^sup>+ y. Pxy (x, y) * indicator (A \<times> space T) (x, y) \<partial>T \<partial>S"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   610
      using A borel Pxy
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 56166
diff changeset
   611
      by (simp add: emeasure_density T.positive_integral_fst[symmetric])
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   612
    also have "\<dots> = \<integral>\<^sup>+ x. Px x * indicator A x \<partial>S"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   613
      apply (rule positive_integral_cong_AE)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   614
      using Pxy[THEN distributed_AE, THEN ST.AE_pair] AE_space
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   615
    proof eventually_elim
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   616
      fix x assume "x \<in> space S" "AE y in T. 0 \<le> Pxy (x, y)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   617
      moreover have eq: "\<And>y. y \<in> space T \<Longrightarrow> indicator (A \<times> space T) (x, y) = indicator A x"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   618
        by (auto simp: indicator_def)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   619
      ultimately have "(\<integral>\<^sup>+ y. Pxy (x, y) * indicator (A \<times> space T) (x, y) \<partial>T) = (\<integral>\<^sup>+ y. Pxy (x, y) \<partial>T) * indicator A x"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   620
        by (simp add: eq positive_integral_multc cong: positive_integral_cong)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   621
      also have "(\<integral>\<^sup>+ y. Pxy (x, y) \<partial>T) = Px x"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   622
        by (simp add: Px_def ereal_real positive_integral_positive)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   623
      finally show "(\<integral>\<^sup>+ y. Pxy (x, y) * indicator (A \<times> space T) (x, y) \<partial>T) = Px x * indicator A x" .
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   624
    qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   625
    finally show "emeasure (distr M S X) A = emeasure (density S Px) A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   626
      using A borel Pxy by (simp add: emeasure_density)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   627
  qed simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   628
  
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   629
  show "AE x in S. 0 \<le> Px x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   630
    by (simp add: Px_def positive_integral_positive real_of_ereal_pos)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   631
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   632
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   633
lemma (in prob_space) distr_marginal2:
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   634
  assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   635
  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: 51683
diff changeset
   636
  shows "distributed M T Y (\<lambda>y. (\<integral>\<^sup>+x. Pxy (x, y) \<partial>S))"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   637
  using distr_marginal1[OF T S distributed_swap[OF S T]] Pxy by simp
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   638
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   639
lemma (in prob_space) distributed_marginal_eq_joint1:
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   640
  assumes T: "sigma_finite_measure T"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   641
  assumes S: "sigma_finite_measure S"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   642
  assumes Px: "distributed M S X Px"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   643
  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: 51683
diff changeset
   644
  shows "AE x in S. Px x = (\<integral>\<^sup>+y. Pxy (x, y) \<partial>T)"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   645
  using Px distr_marginal1[OF S T Pxy] by (rule distributed_unique)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   646
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   647
lemma (in prob_space) distributed_marginal_eq_joint2:
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   648
  assumes T: "sigma_finite_measure T"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   649
  assumes S: "sigma_finite_measure S"
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   650
  assumes 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: 51683
diff changeset
   651
  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: 51683
diff changeset
   652
  shows "AE y in T. Py y = (\<integral>\<^sup>+x. Pxy (x, y) \<partial>S)"
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   653
  using Py distr_marginal2[OF S T Pxy] by (rule distributed_unique)
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   654
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   655
lemma (in prob_space) distributed_joint_indep':
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   656
  assumes S: "sigma_finite_measure S" and T: "sigma_finite_measure T"
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   657
  assumes X[measurable]: "distributed M S X Px" and Y[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: 51683
diff changeset
   658
  assumes indep: "distr M S X \<Otimes>\<^sub>M distr M T Y = distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   659
  shows "distributed M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) (\<lambda>(x, y). Px x * Py y)"
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   660
  unfolding distributed_def
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   661
proof safe
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   662
  interpret S: sigma_finite_measure S by fact
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   663
  interpret T: sigma_finite_measure T by fact
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   664
  interpret ST: pair_sigma_finite S T by default
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   665
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   666
  interpret X: prob_space "density S Px"
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   667
    unfolding distributed_distr_eq_density[OF X, symmetric]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   668
    by (rule prob_space_distr) simp
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   669
  have sf_X: "sigma_finite_measure (density S Px)" ..
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   670
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   671
  interpret Y: prob_space "density T Py"
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   672
    unfolding distributed_distr_eq_density[OF Y, symmetric]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   673
    by (rule prob_space_distr) simp
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   674
  have sf_Y: "sigma_finite_measure (density T Py)" ..
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   675
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   676
  show "distr M (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x)) = density (S \<Otimes>\<^sub>M T) (\<lambda>(x, y). Px x * Py y)"
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   677
    unfolding indep[symmetric] distributed_distr_eq_density[OF X] distributed_distr_eq_density[OF Y]
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   678
    using distributed_borel_measurable[OF X] distributed_AE[OF X]
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   679
    using distributed_borel_measurable[OF Y] distributed_AE[OF Y]
50003
8c213922ed49 use measurability prover
hoelzl
parents: 50002
diff changeset
   680
    by (rule pair_measure_density[OF _ _ _ _ T sf_Y])
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   681
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   682
  show "random_variable (S \<Otimes>\<^sub>M T) (\<lambda>x. (X x, Y x))" by auto
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   683
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   684
  show Pxy: "(\<lambda>(x, y). Px x * Py y) \<in> borel_measurable (S \<Otimes>\<^sub>M T)" by auto
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   685
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   686
  show "AE x in S \<Otimes>\<^sub>M T. 0 \<le> (case x of (x, y) \<Rightarrow> Px x * Py y)"
51683
baefa3b461c2 generalize Borel-set properties from real/ereal/ordered_euclidean_spaces to order_topology and real_normed_vector
hoelzl
parents: 51475
diff changeset
   687
    apply (intro ST.AE_pair_measure borel_measurable_le Pxy borel_measurable_const)
49795
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   688
    using distributed_AE[OF X]
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   689
    apply eventually_elim
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   690
    using distributed_AE[OF Y]
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   691
    apply eventually_elim
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   692
    apply auto
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   693
    done
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   694
qed
9f2fb9b25a77 joint distribution of independent variables
hoelzl
parents: 49788
diff changeset
   695
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   696
definition
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   697
  "simple_distributed M X f \<longleftrightarrow> distributed M (count_space (X`space M)) X (\<lambda>x. ereal (f x)) \<and>
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   698
    finite (X`space M)"
42902
e8dbf90a2f3b Add restricted borel measure to {0 .. 1}
hoelzl
parents: 42892
diff changeset
   699
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   700
lemma simple_distributed:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   701
  "simple_distributed M X Px \<Longrightarrow> distributed M (count_space (X`space M)) X Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   702
  unfolding simple_distributed_def by auto
42902
e8dbf90a2f3b Add restricted borel measure to {0 .. 1}
hoelzl
parents: 42892
diff changeset
   703
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   704
lemma simple_distributed_finite[dest]: "simple_distributed M X P \<Longrightarrow> finite (X`space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   705
  by (simp add: simple_distributed_def)
42902
e8dbf90a2f3b Add restricted borel measure to {0 .. 1}
hoelzl
parents: 42892
diff changeset
   706
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   707
lemma (in prob_space) distributed_simple_function_superset:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   708
  assumes X: "simple_function M X" "\<And>x. x \<in> X ` space M \<Longrightarrow> P x = measure M (X -` {x} \<inter> space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   709
  assumes A: "X`space M \<subseteq> A" "finite A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   710
  defines "S \<equiv> count_space A" and "P' \<equiv> (\<lambda>x. if x \<in> X`space M then P x else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   711
  shows "distributed M S X P'"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   712
  unfolding distributed_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   713
proof safe
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   714
  show "(\<lambda>x. ereal (P' x)) \<in> borel_measurable S" unfolding S_def by simp
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   715
  show "AE x in S. 0 \<le> ereal (P' x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   716
    using X by (auto simp: S_def P'_def simple_distributed_def intro!: measure_nonneg)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   717
  show "distr M S X = density S P'"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   718
  proof (rule measure_eqI_finite)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   719
    show "sets (distr M S X) = Pow A" "sets (density S P') = Pow A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   720
      using A unfolding S_def by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   721
    show "finite A" by fact
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   722
    fix a assume a: "a \<in> A"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   723
    then have "a \<notin> X`space M \<Longrightarrow> X -` {a} \<inter> space M = {}" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   724
    with A a X have "emeasure (distr M S X) {a} = P' a"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   725
      by (subst emeasure_distr)
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
   726
         (auto simp add: S_def P'_def simple_functionD emeasure_eq_measure measurable_count_space_eq2
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   727
               intro!: arg_cong[where f=prob])
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   728
    also have "\<dots> = (\<integral>\<^sup>+x. ereal (P' a) * indicator {a} x \<partial>S)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   729
      using A X a
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   730
      by (subst positive_integral_cmult_indicator)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   731
         (auto simp: S_def P'_def simple_distributed_def simple_functionD measure_nonneg)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   732
    also have "\<dots> = (\<integral>\<^sup>+x. ereal (P' x) * indicator {a} x \<partial>S)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   733
      by (auto simp: indicator_def intro!: positive_integral_cong)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   734
    also have "\<dots> = emeasure (density S P') {a}"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   735
      using a A by (intro emeasure_density[symmetric]) (auto simp: S_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   736
    finally show "emeasure (distr M S X) {a} = emeasure (density S P') {a}" .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   737
  qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   738
  show "random_variable S X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   739
    using X(1) A by (auto simp: measurable_def simple_functionD S_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   740
qed
42902
e8dbf90a2f3b Add restricted borel measure to {0 .. 1}
hoelzl
parents: 42892
diff changeset
   741
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   742
lemma (in prob_space) simple_distributedI:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   743
  assumes X: "simple_function M X" "\<And>x. x \<in> X ` space M \<Longrightarrow> P x = measure M (X -` {x} \<inter> space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   744
  shows "simple_distributed M X P"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   745
  unfolding simple_distributed_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   746
proof
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   747
  have "distributed M (count_space (X ` space M)) X (\<lambda>x. ereal (if x \<in> X`space M then P x else 0))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   748
    (is "?A")
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   749
    using simple_functionD[OF X(1)] by (intro distributed_simple_function_superset[OF X]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   750
  also have "?A \<longleftrightarrow> distributed M (count_space (X ` space M)) X (\<lambda>x. ereal (P x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   751
    by (rule distributed_cong_density) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   752
  finally show "\<dots>" .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   753
qed (rule simple_functionD[OF X(1)])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   754
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   755
lemma simple_distributed_joint_finite:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   756
  assumes X: "simple_distributed M (\<lambda>x. (X x, Y x)) Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   757
  shows "finite (X ` space M)" "finite (Y ` space M)"
42902
e8dbf90a2f3b Add restricted borel measure to {0 .. 1}
hoelzl
parents: 42892
diff changeset
   758
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   759
  have "finite ((\<lambda>x. (X x, Y x)) ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   760
    using X by (auto simp: simple_distributed_def simple_functionD)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   761
  then have "finite (fst ` (\<lambda>x. (X x, Y x)) ` space M)" "finite (snd ` (\<lambda>x. (X x, Y x)) ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   762
    by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   763
  then show fin: "finite (X ` space M)" "finite (Y ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   764
    by (auto simp: image_image)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   765
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   766
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   767
lemma simple_distributed_joint2_finite:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   768
  assumes X: "simple_distributed M (\<lambda>x. (X x, Y x, Z x)) Px"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   769
  shows "finite (X ` space M)" "finite (Y ` space M)" "finite (Z ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   770
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   771
  have "finite ((\<lambda>x. (X x, Y x, Z x)) ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   772
    using X by (auto simp: simple_distributed_def simple_functionD)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   773
  then have "finite (fst ` (\<lambda>x. (X x, Y x, Z x)) ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   774
    "finite ((fst \<circ> snd) ` (\<lambda>x. (X x, Y x, Z x)) ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   775
    "finite ((snd \<circ> snd) ` (\<lambda>x. (X x, Y x, Z x)) ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   776
    by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   777
  then show fin: "finite (X ` space M)" "finite (Y ` space M)" "finite (Z ` space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   778
    by (auto simp: image_image)
42902
e8dbf90a2f3b Add restricted borel measure to {0 .. 1}
hoelzl
parents: 42892
diff changeset
   779
qed
e8dbf90a2f3b Add restricted borel measure to {0 .. 1}
hoelzl
parents: 42892
diff changeset
   780
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   781
lemma simple_distributed_simple_function:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   782
  "simple_distributed M X Px \<Longrightarrow> simple_function M X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   783
  unfolding simple_distributed_def distributed_def
50002
ce0d316b5b44 add measurability prover; add support for Borel sets
hoelzl
parents: 50001
diff changeset
   784
  by (auto simp: simple_function_def measurable_count_space_eq2)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   785
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   786
lemma simple_distributed_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   787
  "simple_distributed M X P \<Longrightarrow> a \<in> X`space M \<Longrightarrow> P a = measure M (X -` {a} \<inter> space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   788
  using distributed_count_space[of M "X`space M" X P a, symmetric]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   789
  by (auto simp: simple_distributed_def measure_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   790
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   791
lemma simple_distributed_nonneg: "simple_distributed M X f \<Longrightarrow> x \<in> space M \<Longrightarrow> 0 \<le> f (X x)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   792
  by (auto simp: simple_distributed_measure measure_nonneg)
42860
b02349e70d5a add Bernoulli space
hoelzl
parents: 42859
diff changeset
   793
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   794
lemma (in prob_space) simple_distributed_joint:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   795
  assumes X: "simple_distributed M (\<lambda>x. (X x, Y x)) Px"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   796
  defines "S \<equiv> count_space (X`space M) \<Otimes>\<^sub>M count_space (Y`space M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   797
  defines "P \<equiv> (\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x))`space M then Px x else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   798
  shows "distributed M S (\<lambda>x. (X x, Y x)) P"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   799
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   800
  from simple_distributed_joint_finite[OF X, simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   801
  have S_eq: "S = count_space (X`space M \<times> Y`space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   802
    by (simp add: S_def pair_measure_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   803
  show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   804
    unfolding S_eq P_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   805
  proof (rule distributed_simple_function_superset)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   806
    show "simple_function M (\<lambda>x. (X x, Y x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   807
      using X by (rule simple_distributed_simple_function)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   808
    fix x assume "x \<in> (\<lambda>x. (X x, Y x)) ` space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   809
    from simple_distributed_measure[OF X this]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   810
    show "Px x = prob ((\<lambda>x. (X x, Y x)) -` {x} \<inter> space M)" .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   811
  qed auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   812
qed
42860
b02349e70d5a add Bernoulli space
hoelzl
parents: 42859
diff changeset
   813
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   814
lemma (in prob_space) simple_distributed_joint2:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   815
  assumes X: "simple_distributed M (\<lambda>x. (X x, Y x, Z x)) Px"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   816
  defines "S \<equiv> 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
   817
  defines "P \<equiv> (\<lambda>x. if x \<in> (\<lambda>x. (X x, Y x, Z x))`space M then Px x else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   818
  shows "distributed M S (\<lambda>x. (X x, Y x, Z x)) P"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   819
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   820
  from simple_distributed_joint2_finite[OF X, simp]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   821
  have S_eq: "S = count_space (X`space M \<times> Y`space M \<times> Z`space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   822
    by (simp add: S_def pair_measure_count_space)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   823
  show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   824
    unfolding S_eq P_def
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   825
  proof (rule distributed_simple_function_superset)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   826
    show "simple_function M (\<lambda>x. (X x, Y x, Z x))"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   827
      using X by (rule simple_distributed_simple_function)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   828
    fix x assume "x \<in> (\<lambda>x. (X x, Y x, Z x)) ` space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   829
    from simple_distributed_measure[OF X this]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   830
    show "Px x = prob ((\<lambda>x. (X x, Y x, Z x)) -` {x} \<inter> space M)" .
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   831
  qed auto
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   832
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   833
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   834
lemma (in prob_space) simple_distributed_setsum_space:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   835
  assumes X: "simple_distributed M X f"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   836
  shows "setsum f (X`space M) = 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   837
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   838
  from X have "setsum f (X`space M) = prob (\<Union>i\<in>X`space M. X -` {i} \<inter> space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   839
    by (subst finite_measure_finite_Union)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   840
       (auto simp add: disjoint_family_on_def simple_distributed_measure simple_distributed_simple_function simple_functionD
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   841
             intro!: setsum_cong arg_cong[where f="prob"])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   842
  also have "\<dots> = prob (space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   843
    by (auto intro!: arg_cong[where f=prob])
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   844
  finally show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   845
    using emeasure_space_1 by (simp add: emeasure_eq_measure one_ereal_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   846
qed
42860
b02349e70d5a add Bernoulli space
hoelzl
parents: 42859
diff changeset
   847
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   848
lemma (in prob_space) distributed_marginal_eq_joint_simple:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   849
  assumes Px: "simple_function M X"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   850
  assumes Py: "simple_distributed M Y Py"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   851
  assumes Pxy: "simple_distributed M (\<lambda>x. (X x, Y x)) Pxy"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   852
  assumes y: "y \<in> Y`space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   853
  shows "Py y = (\<Sum>x\<in>X`space M. if (x, y) \<in> (\<lambda>x. (X x, Y x)) ` space M then Pxy (x, y) else 0)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   854
proof -
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   855
  note Px = simple_distributedI[OF Px refl]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   856
  have *: "\<And>f A. setsum (\<lambda>x. max 0 (ereal (f x))) A = ereal (setsum (\<lambda>x. max 0 (f x)) A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   857
    by (simp add: setsum_ereal[symmetric] zero_ereal_def)
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   858
  from distributed_marginal_eq_joint2[OF
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   859
    sigma_finite_measure_count_space_finite
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   860
    sigma_finite_measure_count_space_finite
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   861
    simple_distributed[OF Py] simple_distributed_joint[OF Pxy],
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   862
    OF Py[THEN simple_distributed_finite] Px[THEN simple_distributed_finite]]
49788
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   863
    y
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   864
    Px[THEN simple_distributed_finite]
3c10763f5cb4 show and use distributed_swap and distributed_jointI
hoelzl
parents: 49786
diff changeset
   865
    Py[THEN simple_distributed_finite]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   866
    Pxy[THEN simple_distributed, THEN distributed_real_AE]
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   867
  show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   868
    unfolding AE_count_space
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   869
    apply (auto simp add: positive_integral_count_space_finite * intro!: setsum_cong split: split_max)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   870
    done
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   871
qed
42860
b02349e70d5a add Bernoulli space
hoelzl
parents: 42859
diff changeset
   872
50419
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   873
lemma distributedI_real:
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   874
  fixes f :: "'a \<Rightarrow> real"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   875
  assumes gen: "sets M1 = sigma_sets (space M1) E" and "Int_stable E"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   876
    and A: "range A \<subseteq> E" "(\<Union>i::nat. A i) = space M1" "\<And>i. emeasure (distr M M1 X) (A i) \<noteq> \<infinity>"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   877
    and X: "X \<in> measurable M M1"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   878
    and f: "f \<in> borel_measurable M1" "AE x in M1. 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   879
    and eq: "\<And>A. A \<in> E \<Longrightarrow> emeasure M (X -` A \<inter> space M) = (\<integral>\<^sup>+ x. f x * indicator A x \<partial>M1)"
50419
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   880
  shows "distributed M M1 X f"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   881
  unfolding distributed_def
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   882
proof (intro conjI)
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   883
  show "distr M M1 X = density M1 f"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   884
  proof (rule measure_eqI_generator_eq[where A=A])
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   885
    { fix A assume A: "A \<in> E"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   886
      then have "A \<in> sigma_sets (space M1) E" by auto
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   887
      then have "A \<in> sets M1"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   888
        using gen by simp
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   889
      with f A eq[of A] X show "emeasure (distr M M1 X) A = emeasure (density M1 f) A"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   890
        by (simp add: emeasure_distr emeasure_density borel_measurable_ereal
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   891
                      times_ereal.simps[symmetric] ereal_indicator
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   892
                 del: times_ereal.simps) }
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   893
    note eq_E = this
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   894
    show "Int_stable E" by fact
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   895
    { fix e assume "e \<in> E"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   896
      then have "e \<in> sigma_sets (space M1) E" by auto
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   897
      then have "e \<in> sets M1" unfolding gen .
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   898
      then have "e \<subseteq> space M1" by (rule sets.sets_into_space) }
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   899
    then show "E \<subseteq> Pow (space M1)" by auto
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   900
    show "sets (distr M M1 X) = sigma_sets (space M1) E"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   901
      "sets (density M1 (\<lambda>x. ereal (f x))) = sigma_sets (space M1) E"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   902
      unfolding gen[symmetric] by auto
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   903
  qed fact+
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   904
qed (insert X f, auto)
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   905
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   906
lemma distributedI_borel_atMost:
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   907
  fixes f :: "real \<Rightarrow> real"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   908
  assumes [measurable]: "X \<in> borel_measurable M"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   909
    and [measurable]: "f \<in> borel_measurable borel" and f[simp]: "AE x in lborel. 0 \<le> f x"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   910
    and g_eq: "\<And>a. (\<integral>\<^sup>+x. f x * indicator {..a} x \<partial>lborel)  = ereal (g a)"
50419
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   911
    and M_eq: "\<And>a. emeasure M {x\<in>space M. X x \<le> a} = ereal (g a)"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   912
  shows "distributed M lborel X f"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   913
proof (rule distributedI_real)
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   914
  show "sets lborel = sigma_sets (space lborel) (range atMost)"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   915
    by (simp add: borel_eq_atMost)
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   916
  show "Int_stable (range atMost :: real set set)"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   917
    by (auto simp: Int_stable_def)
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   918
  have vimage_eq: "\<And>a. (X -` {..a} \<inter> space M) = {x\<in>space M. X x \<le> a}" by auto
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   919
  def A \<equiv> "\<lambda>i::nat. {.. real i}"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   920
  then show "range A \<subseteq> range atMost" "(\<Union>i. A i) = space lborel"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   921
    "\<And>i. emeasure (distr M lborel X) (A i) \<noteq> \<infinity>"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   922
    by (auto simp: real_arch_simple emeasure_distr vimage_eq M_eq)
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   923
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   924
  fix A :: "real set" assume "A \<in> range atMost"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   925
  then obtain a where A: "A = {..a}" by auto
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51683
diff changeset
   926
  show "emeasure M (X -` A \<inter> space M) = (\<integral>\<^sup>+x. f x * indicator A x \<partial>lborel)"
50419
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   927
    unfolding vimage_eq A M_eq g_eq ..
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   928
qed auto
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   929
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   930
lemma (in prob_space) uniform_distributed_params:
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   931
  assumes X: "distributed M MX X (\<lambda>x. indicator A x / measure MX A)"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   932
  shows "A \<in> sets MX" "measure MX A \<noteq> 0"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   933
proof -
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   934
  interpret X: prob_space "distr M MX X"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   935
    using distributed_measurable[OF X] by (rule prob_space_distr)
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   936
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   937
  show "measure MX A \<noteq> 0"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   938
  proof
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   939
    assume "measure MX A = 0"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   940
    with X.emeasure_space_1 X.prob_space distributed_distr_eq_density[OF X]
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   941
    show False
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   942
      by (simp add: emeasure_density zero_ereal_def[symmetric])
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   943
  qed
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   944
  with measure_notin_sets[of A MX] show "A \<in> sets MX"
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   945
    by blast
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   946
qed
3177d0374701 add exponential and uniform distributions
hoelzl
parents: 50244
diff changeset
   947
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   948
lemma prob_space_uniform_measure:
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   949
  assumes A: "emeasure M A \<noteq> 0" "emeasure M A \<noteq> \<infinity>"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   950
  shows "prob_space (uniform_measure M A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   951
proof
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   952
  show "emeasure (uniform_measure M A) (space (uniform_measure M A)) = 1"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   953
    using emeasure_uniform_measure[OF emeasure_neq_0_sets[OF A(1)], of "space M"]
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 50104
diff changeset
   954
    using sets.sets_into_space[OF emeasure_neq_0_sets[OF A(1)]] A
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   955
    by (simp add: Int_absorb2 emeasure_nonneg)
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   956
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   957
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   958
lemma prob_space_uniform_count_measure: "finite A \<Longrightarrow> A \<noteq> {} \<Longrightarrow> prob_space (uniform_count_measure A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46905
diff changeset
   959
  by default (auto simp: emeasure_uniform_count_measure space_uniform_count_measure one_ereal_def)
42860
b02349e70d5a add Bernoulli space
hoelzl
parents: 42859
diff changeset
   960
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   961
end