src/HOL/Probability/Probability_Space.thy
author blanchet
Wed, 15 Dec 2010 18:10:32 +0100
changeset 41171 043f8dc3b51f
parent 41097 a1abfa4e2b44
child 41544 c3b977fee8a3
permissions -rw-r--r--
facilitate debugging
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     1
theory Probability_Space
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
     2
imports Lebesgue_Integration Radon_Nikodym Product_Measure
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     3
begin
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
     4
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
     5
lemma real_of_pextreal_inverse[simp]:
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
     6
  fixes X :: pextreal
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
     7
  shows "real (inverse X) = 1 / real X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
     8
  by (cases X) (auto simp: inverse_eq_divide)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
     9
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
    10
lemma real_of_pextreal_le_0[simp]: "real (X :: pextreal) \<le> 0 \<longleftrightarrow> (X = 0 \<or> X = \<omega>)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    11
  by (cases X) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    12
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
    13
lemma real_of_pextreal_less_0[simp]: "\<not> (real (X :: pextreal) < 0)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    14
  by (cases X) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    15
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    16
locale prob_space = measure_space +
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    17
  assumes measure_space_1: "\<mu> (space M) = 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    18
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
    19
lemma abs_real_of_pextreal[simp]: "\<bar>real (X :: pextreal)\<bar> = real X"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    20
  by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    21
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
    22
lemma zero_less_real_of_pextreal: "0 < real (X :: pextreal) \<longleftrightarrow> X \<noteq> 0 \<and> X \<noteq> \<omega>"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    23
  by (cases X) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    24
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    25
sublocale prob_space < finite_measure
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    26
proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    27
  from measure_space_1 show "\<mu> (space M) \<noteq> \<omega>" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    28
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    29
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    30
abbreviation (in prob_space) "events \<equiv> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    31
abbreviation (in prob_space) "prob \<equiv> \<lambda>A. real (\<mu> A)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    32
abbreviation (in prob_space) "prob_preserving \<equiv> measure_preserving"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    33
abbreviation (in prob_space) "random_variable M' X \<equiv> sigma_algebra M' \<and> X \<in> measurable M M'"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    34
abbreviation (in prob_space) "expectation \<equiv> integral"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    35
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    36
definition (in prob_space)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    37
  "indep A B \<longleftrightarrow> A \<in> events \<and> B \<in> events \<and> prob (A \<inter> B) = prob A * prob B"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    38
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    39
definition (in prob_space)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    40
  "indep_families F G \<longleftrightarrow> (\<forall> A \<in> F. \<forall> B \<in> G. indep A B)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    41
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    42
definition (in prob_space)
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    43
  "distribution X = (\<lambda>s. \<mu> ((X -` s) \<inter> (space M)))"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    44
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    45
abbreviation (in prob_space)
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
    46
  "joint_distribution X Y \<equiv> distribution (\<lambda>x. (X x, Y x))"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    47
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    48
lemma (in prob_space) distribution_cong:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    49
  assumes "\<And>x. x \<in> space M \<Longrightarrow> X x = Y x"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    50
  shows "distribution X = distribution Y"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
    51
  unfolding distribution_def fun_eq_iff
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    52
  using assms by (auto intro!: arg_cong[where f="\<mu>"])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    53
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    54
lemma (in prob_space) joint_distribution_cong:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    55
  assumes "\<And>x. x \<in> space M \<Longrightarrow> X x = X' x"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    56
  assumes "\<And>x. x \<in> space M \<Longrightarrow> Y x = Y' x"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    57
  shows "joint_distribution X Y = joint_distribution X' Y'"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
    58
  unfolding distribution_def fun_eq_iff
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    59
  using assms by (auto intro!: arg_cong[where f="\<mu>"])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
    60
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    61
lemma (in prob_space) distribution_id[simp]:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    62
  assumes "N \<in> sets M" shows "distribution (\<lambda>x. x) N = \<mu> N"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    63
  using assms by (auto simp: distribution_def intro!: arg_cong[where f=\<mu>])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    64
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    65
lemma (in prob_space) prob_space: "prob (space M) = 1"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    66
  unfolding measure_space_1 by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    67
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    68
lemma (in prob_space) measure_le_1[simp, intro]:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    69
  assumes "A \<in> events" shows "\<mu> A \<le> 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    70
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    71
  have "\<mu> A \<le> \<mu> (space M)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    72
    using assms sets_into_space by(auto intro!: measure_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    73
  also note measure_space_1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    74
  finally show ?thesis .
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    75
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    76
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    77
lemma (in prob_space) prob_compl:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    78
  assumes "A \<in> events"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    79
  shows "prob (space M - A) = 1 - prob A"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    80
  using `A \<in> events`[THEN sets_into_space] `A \<in> events` measure_space_1
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    81
  by (subst real_finite_measure_Diff) auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    82
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    83
lemma (in prob_space) indep_space:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    84
  assumes "s \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    85
  shows "indep (space M) s"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    86
  using assms prob_space by (simp add: indep_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    87
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    88
lemma (in prob_space) prob_space_increasing: "increasing M prob"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    89
  by (auto intro!: real_measure_mono simp: increasing_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    90
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
    91
lemma (in prob_space) prob_zero_union:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    92
  assumes "s \<in> events" "t \<in> events" "prob t = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    93
  shows "prob (s \<union> t) = prob s"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    94
using assms
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    95
proof -
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    96
  have "prob (s \<union> t) \<le> prob s"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    97
    using real_finite_measure_subadditive[of s t] assms by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
    98
  moreover have "prob (s \<union> t) \<ge> prob s"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
    99
    using assms by (blast intro: real_measure_mono)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   100
  ultimately show ?thesis by simp
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   101
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   102
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   103
lemma (in prob_space) prob_eq_compl:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   104
  assumes "s \<in> events" "t \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   105
  assumes "prob (space M - s) = prob (space M - t)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   106
  shows "prob s = prob t"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   107
  using assms prob_compl by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   108
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   109
lemma (in prob_space) prob_one_inter:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   110
  assumes events:"s \<in> events" "t \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   111
  assumes "prob t = 1"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   112
  shows "prob (s \<inter> t) = prob s"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   113
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   114
  have "prob ((space M - s) \<union> (space M - t)) = prob (space M - s)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   115
    using events assms  prob_compl[of "t"] by (auto intro!: prob_zero_union)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   116
  also have "(space M - s) \<union> (space M - t) = space M - (s \<inter> t)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   117
    by blast
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   118
  finally show "prob (s \<inter> t) = prob s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   119
    using events by (auto intro!: prob_eq_compl[of "s \<inter> t" s])
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   120
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   121
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   122
lemma (in prob_space) prob_eq_bigunion_image:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   123
  assumes "range f \<subseteq> events" "range g \<subseteq> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   124
  assumes "disjoint_family f" "disjoint_family g"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   125
  assumes "\<And> n :: nat. prob (f n) = prob (g n)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   126
  shows "(prob (\<Union> i. f i) = prob (\<Union> i. g i))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   127
using assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   128
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   129
  have a: "(\<lambda> i. prob (f i)) sums (prob (\<Union> i. f i))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   130
    by (rule real_finite_measure_UNION[OF assms(1,3)])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   131
  have b: "(\<lambda> i. prob (g i)) sums (prob (\<Union> i. g i))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   132
    by (rule real_finite_measure_UNION[OF assms(2,4)])
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   133
  show ?thesis using sums_unique[OF b] sums_unique[OF a] assms by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   134
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   135
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   136
lemma (in prob_space) prob_countably_zero:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   137
  assumes "range c \<subseteq> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   138
  assumes "\<And> i. prob (c i) = 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   139
  shows "prob (\<Union> i :: nat. c i) = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   140
proof (rule antisym)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   141
  show "prob (\<Union> i :: nat. c i) \<le> 0"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   142
    using real_finite_measure_countably_subadditive[OF assms(1)]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   143
    by (simp add: assms(2) suminf_zero summable_zero)
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   144
  show "0 \<le> prob (\<Union> i :: nat. c i)" by (rule real_pextreal_nonneg)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   145
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   146
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   147
lemma (in prob_space) indep_sym:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   148
   "indep a b \<Longrightarrow> indep b a"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   149
unfolding indep_def using Int_commute[of a b] by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   150
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   151
lemma (in prob_space) indep_refl:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   152
  assumes "a \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   153
  shows "indep a a = (prob a = 0) \<or> (prob a = 1)"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   154
using assms unfolding indep_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   155
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   156
lemma (in prob_space) prob_equiprobable_finite_unions:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   157
  assumes "s \<in> events"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   158
  assumes s_finite: "finite s" "\<And>x. x \<in> s \<Longrightarrow> {x} \<in> events"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   159
  assumes "\<And> x y. \<lbrakk>x \<in> s; y \<in> s\<rbrakk> \<Longrightarrow> (prob {x} = prob {y})"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   160
  shows "prob s = real (card s) * prob {SOME x. x \<in> s}"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   161
proof (cases "s = {}")
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   162
  case False hence "\<exists> x. x \<in> s" by blast
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   163
  from someI_ex[OF this] assms
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   164
  have prob_some: "\<And> x. x \<in> s \<Longrightarrow> prob {x} = prob {SOME y. y \<in> s}" by blast
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   165
  have "prob s = (\<Sum> x \<in> s. prob {x})"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   166
    using real_finite_measure_finite_singelton[OF s_finite] by simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   167
  also have "\<dots> = (\<Sum> x \<in> s. prob {SOME y. y \<in> s})" using prob_some by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   168
  also have "\<dots> = real (card s) * prob {(SOME x. x \<in> s)}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   169
    using setsum_constant assms by (simp add: real_eq_of_nat)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   170
  finally show ?thesis by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   171
qed simp
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   172
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   173
lemma (in prob_space) prob_real_sum_image_fn:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   174
  assumes "e \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   175
  assumes "\<And> x. x \<in> s \<Longrightarrow> e \<inter> f x \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   176
  assumes "finite s"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   177
  assumes disjoint: "\<And> x y. \<lbrakk>x \<in> s ; y \<in> s ; x \<noteq> y\<rbrakk> \<Longrightarrow> f x \<inter> f y = {}"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   178
  assumes upper: "space M \<subseteq> (\<Union> i \<in> s. f i)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   179
  shows "prob e = (\<Sum> x \<in> s. prob (e \<inter> f x))"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   180
proof -
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   181
  have e: "e = (\<Union> i \<in> s. e \<inter> f i)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   182
    using `e \<in> events` sets_into_space upper by blast
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   183
  hence "prob e = prob (\<Union> i \<in> s. e \<inter> f i)" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   184
  also have "\<dots> = (\<Sum> x \<in> s. prob (e \<inter> f x))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   185
  proof (rule real_finite_measure_finite_Union)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   186
    show "finite s" by fact
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   187
    show "\<And>i. i \<in> s \<Longrightarrow> e \<inter> f i \<in> events" by fact
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   188
    show "disjoint_family_on (\<lambda>i. e \<inter> f i) s"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   189
      using disjoint by (auto simp: disjoint_family_on_def)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   190
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   191
  finally show ?thesis .
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   192
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   193
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   194
lemma (in prob_space) distribution_prob_space:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   195
  assumes "random_variable S X"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   196
  shows "prob_space S (distribution X)"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   197
proof -
39089
df379a447753 vimage of measurable function is a measure space
hoelzl
parents: 39085
diff changeset
   198
  interpret S: measure_space S "distribution X"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   199
    using measure_space_vimage[of X S] assms unfolding distribution_def by simp
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   200
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   201
  proof
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   202
    have "X -` space S \<inter> space M = space M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   203
      using `random_variable S X` by (auto simp: measurable_def)
39089
df379a447753 vimage of measurable function is a measure space
hoelzl
parents: 39085
diff changeset
   204
    then show "distribution X (space S) = 1"
df379a447753 vimage of measurable function is a measure space
hoelzl
parents: 39085
diff changeset
   205
      using measure_space_1 by (simp add: distribution_def)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   206
  qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   207
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   208
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   209
lemma (in prob_space) AE_distribution:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   210
  assumes X: "random_variable MX X" and "measure_space.almost_everywhere MX (distribution X) (\<lambda>x. Q x)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   211
  shows "AE x. Q (X x)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   212
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   213
  interpret X: prob_space MX "distribution X" using X by (rule distribution_prob_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   214
  obtain N where N: "N \<in> sets MX" "distribution X N = 0" "{x\<in>space MX. \<not> Q x} \<subseteq> N"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   215
    using assms unfolding X.almost_everywhere_def by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   216
  show "AE x. Q (X x)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   217
    using X[unfolded measurable_def] N unfolding distribution_def
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   218
    by (intro AE_I'[where N="X -` N \<inter> space M"]) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   219
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   220
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   221
lemma (in prob_space) distribution_lebesgue_thm1:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   222
  assumes "random_variable s X"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   223
  assumes "A \<in> sets s"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   224
  shows "real (distribution X A) = expectation (indicator (X -` A \<inter> space M))"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   225
unfolding distribution_def
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   226
using assms unfolding measurable_def
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   227
using integral_indicator by auto
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   228
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   229
lemma (in prob_space) distribution_lebesgue_thm2:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   230
  assumes "random_variable S X" and "A \<in> sets S"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   231
  shows "distribution X A =
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   232
    measure_space.positive_integral S (distribution X) (indicator A)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   233
  (is "_ = measure_space.positive_integral _ ?D _")
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   234
proof -
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   235
  interpret S: prob_space S "distribution X" using assms(1) by (rule distribution_prob_space)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   236
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   237
  show ?thesis
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   238
    using S.positive_integral_indicator(1)
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   239
    using assms unfolding distribution_def by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   240
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   241
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   242
lemma (in prob_space) finite_expectation1:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   243
  assumes f: "finite (X`space M)" and rv: "random_variable borel X"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   244
  shows "expectation X = (\<Sum> r \<in> X ` space M. r * prob (X -` {r} \<inter> space M))"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   245
proof (rule integral_on_finite(2)[OF rv[THEN conjunct2] f])
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   246
  fix x have "X -` {x} \<inter> space M \<in> sets M"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   247
    using rv unfolding measurable_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   248
  thus "\<mu> (X -` {x} \<inter> space M) \<noteq> \<omega>" using finite_measure by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   249
qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   250
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   251
lemma (in prob_space) finite_expectation:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   252
  assumes "finite (space M)" "random_variable borel X"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   253
  shows "expectation X = (\<Sum> r \<in> X ` (space M). r * real (distribution X {r}))"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   254
  using assms unfolding distribution_def using finite_expectation1 by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   255
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   256
lemma (in prob_space) prob_x_eq_1_imp_prob_y_eq_0:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   257
  assumes "{x} \<in> events"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   258
  assumes "prob {x} = 1"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   259
  assumes "{y} \<in> events"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   260
  assumes "y \<noteq> x"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   261
  shows "prob {y} = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   262
  using prob_one_inter[of "{y}" "{x}"] assms by auto
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   263
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   264
lemma (in prob_space) distribution_empty[simp]: "distribution X {} = 0"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   265
  unfolding distribution_def by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   266
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   267
lemma (in prob_space) distribution_space[simp]: "distribution X (X ` space M) = 1"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   268
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   269
  have "X -` X ` space M \<inter> space M = space M" by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   270
  thus ?thesis unfolding distribution_def by (simp add: measure_space_1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   271
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   272
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   273
lemma (in prob_space) distribution_one:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   274
  assumes "random_variable M' X" and "A \<in> sets M'"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   275
  shows "distribution X A \<le> 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   276
proof -
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   277
  have "distribution X A \<le> \<mu> (space M)" unfolding distribution_def
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   278
    using assms[unfolded measurable_def] by (auto intro!: measure_mono)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   279
  thus ?thesis by (simp add: measure_space_1)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   280
qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   281
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   282
lemma (in prob_space) distribution_finite:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   283
  assumes "random_variable M' X" and "A \<in> sets M'"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   284
  shows "distribution X A \<noteq> \<omega>"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   285
  using distribution_one[OF assms] by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   286
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   287
lemma (in prob_space) distribution_x_eq_1_imp_distribution_y_eq_0:
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   288
  assumes X: "random_variable \<lparr>space = X ` (space M), sets = Pow (X ` (space M))\<rparr> X"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   289
    (is "random_variable ?S X")
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   290
  assumes "distribution X {x} = 1"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   291
  assumes "y \<noteq> x"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   292
  shows "distribution X {y} = 0"
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   293
proof -
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   294
  from distribution_prob_space[OF X]
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   295
  interpret S: prob_space ?S "distribution X" by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   296
  have x: "{x} \<in> sets ?S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   297
  proof (rule ccontr)
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   298
    assume "{x} \<notin> sets ?S"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   299
    hence "X -` {x} \<inter> space M = {}" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   300
    thus "False" using assms unfolding distribution_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   301
  qed
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   302
  have [simp]: "{y} \<inter> {x} = {}" "{x} - {y} = {x}" using `y \<noteq> x` by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   303
  show ?thesis
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   304
  proof cases
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   305
    assume "{y} \<in> sets ?S"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   306
    with `{x} \<in> sets ?S` assms show "distribution X {y} = 0"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   307
      using S.measure_inter_full_set[of "{y}" "{x}"]
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   308
      by simp
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   309
  next
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   310
    assume "{y} \<notin> sets ?S"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   311
    hence "X -` {y} \<inter> space M = {}" by auto
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   312
    thus "distribution X {y} = 0" unfolding distribution_def by auto
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   313
  qed
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   314
qed
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   315
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   316
lemma (in prob_space) joint_distribution_Times_le_fst:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   317
  assumes X: "random_variable MX X" and Y: "random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   318
    and A: "A \<in> sets MX" and B: "B \<in> sets MY"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   319
  shows "joint_distribution X Y (A \<times> B) \<le> distribution X A"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   320
  unfolding distribution_def
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   321
proof (intro measure_mono)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   322
  show "(\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M \<subseteq> X -` A \<inter> space M" by force
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   323
  show "X -` A \<inter> space M \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   324
    using X A unfolding measurable_def by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   325
  have *: "(\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M =
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   326
    (X -` A \<inter> space M) \<inter> (Y -` B \<inter> space M)" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   327
  show "(\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   328
    unfolding * apply (rule Int)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   329
    using assms unfolding measurable_def by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   330
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   331
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   332
lemma (in prob_space) joint_distribution_commute:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   333
  "joint_distribution X Y x = joint_distribution Y X ((\<lambda>(x,y). (y,x))`x)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   334
  unfolding distribution_def by (auto intro!: arg_cong[where f=\<mu>])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   335
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   336
lemma (in prob_space) joint_distribution_Times_le_snd:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   337
  assumes X: "random_variable MX X" and Y: "random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   338
    and A: "A \<in> sets MX" and B: "B \<in> sets MY"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   339
  shows "joint_distribution X Y (A \<times> B) \<le> distribution Y B"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   340
  using assms
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   341
  by (subst joint_distribution_commute)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   342
     (simp add: swap_product joint_distribution_Times_le_fst)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   343
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   344
lemma (in prob_space) random_variable_pairI:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   345
  assumes "random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   346
  assumes "random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   347
  shows "random_variable (sigma (pair_algebra MX MY)) (\<lambda>x. (X x, Y x))"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   348
proof
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   349
  interpret MX: sigma_algebra MX using assms by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   350
  interpret MY: sigma_algebra MY using assms by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   351
  interpret P: pair_sigma_algebra MX MY by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   352
  show "sigma_algebra (sigma (pair_algebra MX MY))" by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   353
  have sa: "sigma_algebra M" by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   354
  show "(\<lambda>x. (X x, Y x)) \<in> measurable M (sigma (pair_algebra MX MY))"
41095
c335d880ff82 cleanup bijectivity btw. product spaces and pairs
hoelzl
parents: 41023
diff changeset
   355
    unfolding P.measurable_pair_iff[OF sa] using assms by (simp add: comp_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   356
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   357
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   358
lemma (in prob_space) distribution_order:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   359
  assumes "random_variable MX X" "random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   360
  assumes "{x} \<in> sets MX" "{y} \<in> sets MY"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   361
  shows "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution X {x}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   362
    and "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution Y {y}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   363
    and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution X {x}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   364
    and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution Y {y}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   365
    and "distribution X {x} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   366
    and "distribution Y {y} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   367
  using joint_distribution_Times_le_snd[OF assms]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   368
  using joint_distribution_Times_le_fst[OF assms]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   369
  by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   370
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   371
lemma (in prob_space) joint_distribution_commute_singleton:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   372
  "joint_distribution X Y {(x, y)} = joint_distribution Y X {(y, x)}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   373
  unfolding distribution_def by (auto intro!: arg_cong[where f=\<mu>])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   374
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   375
lemma (in prob_space) joint_distribution_assoc_singleton:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   376
  "joint_distribution X (\<lambda>x. (Y x, Z x)) {(x, y, z)} =
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   377
   joint_distribution (\<lambda>x. (X x, Y x)) Z {((x, y), z)}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   378
  unfolding distribution_def by (auto intro!: arg_cong[where f=\<mu>])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   379
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   380
locale pair_prob_space = M1: prob_space M1 p1 + M2: prob_space M2 p2 for M1 p1 M2 p2
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   381
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   382
sublocale pair_prob_space \<subseteq> pair_sigma_finite M1 p1 M2 p2 by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   383
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   384
sublocale pair_prob_space \<subseteq> P: prob_space P pair_measure
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   385
proof
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   386
  show "pair_measure (space P) = 1"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   387
    by (simp add: pair_algebra_def pair_measure_times M1.measure_space_1 M2.measure_space_1)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   388
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   389
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   390
lemma countably_additiveI[case_names countably]:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   391
  assumes "\<And>A. \<lbrakk> range A \<subseteq> sets M ; disjoint_family A ; (\<Union>i. A i) \<in> sets M\<rbrakk> \<Longrightarrow>
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   392
    (\<Sum>\<^isub>\<infinity>n. \<mu> (A n)) = \<mu> (\<Union>i. A i)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   393
  shows "countably_additive M \<mu>"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   394
  using assms unfolding countably_additive_def by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   395
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   396
lemma (in prob_space) joint_distribution_prob_space:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   397
  assumes "random_variable MX X" "random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   398
  shows "prob_space (sigma (pair_algebra MX MY)) (joint_distribution X Y)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   399
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   400
  interpret X: prob_space MX "distribution X" by (intro distribution_prob_space assms)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   401
  interpret Y: prob_space MY "distribution Y" by (intro distribution_prob_space assms)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   402
  interpret XY: pair_sigma_finite MX "distribution X" MY "distribution Y" by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   403
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   404
  proof
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   405
    let "?X A" = "(\<lambda>x. (X x, Y x)) -` A \<inter> space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   406
    show "joint_distribution X Y {} = 0" by (simp add: distribution_def)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   407
    show "countably_additive XY.P (joint_distribution X Y)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   408
    proof (rule countably_additiveI)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   409
      fix A :: "nat \<Rightarrow> ('b \<times> 'c) set"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   410
      assume A: "range A \<subseteq> sets XY.P" and df: "disjoint_family A"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   411
      have "(\<Sum>\<^isub>\<infinity>n. \<mu> (?X (A n))) = \<mu> (\<Union>x. ?X (A x))"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   412
      proof (intro measure_countably_additive)
41095
c335d880ff82 cleanup bijectivity btw. product spaces and pairs
hoelzl
parents: 41023
diff changeset
   413
        have "sigma_algebra M" by default
c335d880ff82 cleanup bijectivity btw. product spaces and pairs
hoelzl
parents: 41023
diff changeset
   414
        then have *: "(\<lambda>x. (X x, Y x)) \<in> measurable M XY.P"
c335d880ff82 cleanup bijectivity btw. product spaces and pairs
hoelzl
parents: 41023
diff changeset
   415
          using assms by (simp add: XY.measurable_pair comp_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   416
        show "range (\<lambda>n. ?X (A n)) \<subseteq> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   417
          using measurable_sets[OF *] A by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   418
        show "disjoint_family (\<lambda>n. ?X (A n))"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   419
          by (intro disjoint_family_on_bisimulation[OF df]) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   420
      qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   421
      then show "(\<Sum>\<^isub>\<infinity>n. joint_distribution X Y (A n)) = joint_distribution X Y (\<Union>i. A i)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   422
        by (simp add: distribution_def vimage_UN)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   423
    qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   424
    have "?X (space MX \<times> space MY) = space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   425
      using assms by (auto simp: measurable_def)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   426
    then show "joint_distribution X Y (space XY.P) = 1"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   427
      by (simp add: space_pair_algebra distribution_def measure_space_1)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   428
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   429
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   430
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   431
section "Probability spaces on finite sets"
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
   432
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   433
locale finite_prob_space = prob_space + finite_measure_space
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   434
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   435
abbreviation (in prob_space) "finite_random_variable M' X \<equiv> finite_sigma_algebra M' \<and> X \<in> measurable M M'"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   436
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   437
lemma (in prob_space) finite_random_variableD:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   438
  assumes "finite_random_variable M' X" shows "random_variable M' X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   439
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   440
  interpret M': finite_sigma_algebra M' using assms by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   441
  then show "random_variable M' X" using assms by simp default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   442
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   443
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   444
lemma (in prob_space) distribution_finite_prob_space:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   445
  assumes "finite_random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   446
  shows "finite_prob_space MX (distribution X)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   447
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   448
  interpret X: prob_space MX "distribution X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   449
    using assms[THEN finite_random_variableD] by (rule distribution_prob_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   450
  interpret MX: finite_sigma_algebra MX
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   451
    using assms by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   452
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   453
  proof
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   454
    fix x assume "x \<in> space MX"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   455
    then have "X -` {x} \<inter> space M \<in> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   456
      using assms unfolding measurable_def by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   457
    then show "distribution X {x} \<noteq> \<omega>"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   458
      unfolding distribution_def by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   459
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   460
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   461
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   462
lemma (in prob_space) simple_function_imp_finite_random_variable[simp, intro]:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   463
  assumes "simple_function X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   464
  shows "finite_random_variable \<lparr> space = X`space M, sets = Pow (X`space M) \<rparr> X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   465
proof (intro conjI)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   466
  have [simp]: "finite (X ` space M)" using assms unfolding simple_function_def by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   467
  interpret X: sigma_algebra "\<lparr>space = X ` space M, sets = Pow (X ` space M)\<rparr>"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   468
    by (rule sigma_algebra_Pow)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   469
  show "finite_sigma_algebra \<lparr>space = X ` space M, sets = Pow (X ` space M)\<rparr>"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   470
    by default auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   471
  show "X \<in> measurable M \<lparr>space = X ` space M, sets = Pow (X ` space M)\<rparr>"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   472
  proof (unfold measurable_def, clarsimp)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   473
    fix A assume A: "A \<subseteq> X`space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   474
    then have "finite A" by (rule finite_subset) simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   475
    then have "X -` (\<Union>a\<in>A. {a}) \<inter> space M \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   476
      unfolding vimage_UN UN_extend_simps
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   477
      apply (rule finite_UN)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   478
      using A assms unfolding simple_function_def by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   479
    then show "X -` A \<inter> space M \<in> events" by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   480
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   481
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   482
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   483
lemma (in prob_space) simple_function_imp_random_variable[simp, intro]:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   484
  assumes "simple_function X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   485
  shows "random_variable \<lparr> space = X`space M, sets = Pow (X`space M) \<rparr> X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   486
  using simple_function_imp_finite_random_variable[OF assms]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   487
  by (auto dest!: finite_random_variableD)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   488
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   489
lemma (in prob_space) sum_over_space_real_distribution:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   490
  "simple_function X \<Longrightarrow> (\<Sum>x\<in>X`space M. real (distribution X {x})) = 1"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   491
  unfolding distribution_def prob_space[symmetric]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   492
  by (subst real_finite_measure_finite_Union[symmetric])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   493
     (auto simp add: disjoint_family_on_def simple_function_def
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   494
           intro!: arg_cong[where f=prob])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   495
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   496
lemma (in prob_space) finite_random_variable_pairI:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   497
  assumes "finite_random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   498
  assumes "finite_random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   499
  shows "finite_random_variable (sigma (pair_algebra MX MY)) (\<lambda>x. (X x, Y x))"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   500
proof
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   501
  interpret MX: finite_sigma_algebra MX using assms by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   502
  interpret MY: finite_sigma_algebra MY using assms by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   503
  interpret P: pair_finite_sigma_algebra MX MY by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   504
  show "finite_sigma_algebra (sigma (pair_algebra MX MY))" by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   505
  have sa: "sigma_algebra M" by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   506
  show "(\<lambda>x. (X x, Y x)) \<in> measurable M (sigma (pair_algebra MX MY))"
41095
c335d880ff82 cleanup bijectivity btw. product spaces and pairs
hoelzl
parents: 41023
diff changeset
   507
    unfolding P.measurable_pair_iff[OF sa] using assms by (simp add: comp_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   508
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   509
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   510
lemma (in prob_space) finite_random_variable_imp_sets:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   511
  "finite_random_variable MX X \<Longrightarrow> x \<in> space MX \<Longrightarrow> {x} \<in> sets MX"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   512
  unfolding finite_sigma_algebra_def finite_sigma_algebra_axioms_def by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   513
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   514
lemma (in prob_space) finite_random_variable_vimage:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   515
  assumes X: "finite_random_variable MX X" shows "X -` A \<inter> space M \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   516
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   517
  interpret X: finite_sigma_algebra MX using X by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   518
  from X have vimage: "\<And>A. A \<subseteq> space MX \<Longrightarrow> X -` A \<inter> space M \<in> events" and
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   519
    "X \<in> space M \<rightarrow> space MX"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   520
    by (auto simp: measurable_def)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   521
  then have *: "X -` A \<inter> space M = X -` (A \<inter> space MX) \<inter> space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   522
    by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   523
  show "X -` A \<inter> space M \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   524
    unfolding * by (intro vimage) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   525
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   526
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   527
lemma (in prob_space) joint_distribution_finite_Times_le_fst:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   528
  assumes X: "finite_random_variable MX X" and Y: "finite_random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   529
  shows "joint_distribution X Y (A \<times> B) \<le> distribution X A"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   530
  unfolding distribution_def
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   531
proof (intro measure_mono)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   532
  show "(\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M \<subseteq> X -` A \<inter> space M" by force
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   533
  show "X -` A \<inter> space M \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   534
    using finite_random_variable_vimage[OF X] .
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   535
  have *: "(\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M =
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   536
    (X -` A \<inter> space M) \<inter> (Y -` B \<inter> space M)" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   537
  show "(\<lambda>x. (X x, Y x)) -` (A \<times> B) \<inter> space M \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   538
    unfolding * apply (rule Int)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   539
    using assms[THEN finite_random_variable_vimage] by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   540
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   541
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   542
lemma (in prob_space) joint_distribution_finite_Times_le_snd:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   543
  assumes X: "finite_random_variable MX X" and Y: "finite_random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   544
  shows "joint_distribution X Y (A \<times> B) \<le> distribution Y B"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   545
  using assms
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   546
  by (subst joint_distribution_commute)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   547
     (simp add: swap_product joint_distribution_finite_Times_le_fst)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   548
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   549
lemma (in prob_space) finite_distribution_order:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   550
  assumes "finite_random_variable MX X" "finite_random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   551
  shows "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution X {x}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   552
    and "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution Y {y}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   553
    and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution X {x}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   554
    and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution Y {y}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   555
    and "distribution X {x} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   556
    and "distribution Y {y} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   557
  using joint_distribution_finite_Times_le_snd[OF assms, of "{x}" "{y}"]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   558
  using joint_distribution_finite_Times_le_fst[OF assms, of "{x}" "{y}"]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   559
  by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   560
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   561
lemma (in prob_space) finite_distribution_finite:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   562
  assumes "finite_random_variable M' X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   563
  shows "distribution X {x} \<noteq> \<omega>"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   564
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   565
  have "distribution X {x} \<le> \<mu> (space M)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   566
    unfolding distribution_def
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   567
    using finite_random_variable_vimage[OF assms]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   568
    by (intro measure_mono) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   569
  then show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   570
    by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   571
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   572
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   573
lemma (in prob_space) setsum_joint_distribution:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   574
  assumes X: "finite_random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   575
  assumes Y: "random_variable MY Y" "B \<in> sets MY"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   576
  shows "(\<Sum>a\<in>space MX. joint_distribution X Y ({a} \<times> B)) = distribution Y B"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   577
  unfolding distribution_def
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   578
proof (subst measure_finitely_additive'')
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   579
  interpret MX: finite_sigma_algebra MX using X by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   580
  show "finite (space MX)" using MX.finite_space .
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   581
  let "?d i" = "(\<lambda>x. (X x, Y x)) -` ({i} \<times> B) \<inter> space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   582
  { fix i assume "i \<in> space MX"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   583
    moreover have "?d i = (X -` {i} \<inter> space M) \<inter> (Y -` B \<inter> space M)" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   584
    ultimately show "?d i \<in> events"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   585
      using measurable_sets[of X M MX] measurable_sets[of Y M MY B] X Y
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   586
      using MX.sets_eq_Pow by auto }
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   587
  show "disjoint_family_on ?d (space MX)" by (auto simp: disjoint_family_on_def)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   588
  show "\<mu> (\<Union>i\<in>space MX. ?d i) = \<mu> (Y -` B \<inter> space M)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   589
    using X[unfolded measurable_def]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   590
    by (auto intro!: arg_cong[where f=\<mu>])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   591
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   592
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   593
lemma (in prob_space) setsum_joint_distribution_singleton:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   594
  assumes X: "finite_random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   595
  assumes Y: "finite_random_variable MY Y" "b \<in> space MY"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   596
  shows "(\<Sum>a\<in>space MX. joint_distribution X Y {(a, b)}) = distribution Y {b}"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   597
  using setsum_joint_distribution[OF X
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   598
    finite_random_variableD[OF Y(1)]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   599
    finite_random_variable_imp_sets[OF Y]] by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   600
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   601
lemma (in prob_space) setsum_real_joint_distribution:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   602
  assumes X: "finite_random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   603
  assumes Y: "random_variable MY Y" "B \<in> sets MY"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   604
  shows "(\<Sum>a\<in>space MX. real (joint_distribution X Y ({a} \<times> B))) = real (distribution Y B)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   605
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   606
  interpret MX: finite_sigma_algebra MX using X by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   607
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   608
    unfolding setsum_joint_distribution[OF assms, symmetric]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   609
    using distribution_finite[OF random_variable_pairI[OF finite_random_variableD[OF X] Y(1)]] Y(2)
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   610
    by (simp add: space_pair_algebra in_sigma pair_algebraI MX.sets_eq_Pow real_of_pextreal_setsum)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   611
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   612
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   613
lemma (in prob_space) setsum_real_joint_distribution_singleton:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   614
  assumes X: "finite_random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   615
  assumes Y: "finite_random_variable MY Y" "b \<in> space MY"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   616
  shows "(\<Sum>a\<in>space MX. real (joint_distribution X Y {(a,b)})) = real (distribution Y {b})"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   617
  using setsum_real_joint_distribution[OF X
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   618
    finite_random_variableD[OF Y(1)]
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   619
    finite_random_variable_imp_sets[OF Y]] by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   620
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   621
locale pair_finite_prob_space = M1: finite_prob_space M1 p1 + M2: finite_prob_space M2 p2 for M1 p1 M2 p2
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   622
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   623
sublocale pair_finite_prob_space \<subseteq> pair_prob_space M1 p1 M2 p2 by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   624
sublocale pair_finite_prob_space \<subseteq> pair_finite_space M1 p1 M2 p2  by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   625
sublocale pair_finite_prob_space \<subseteq> finite_prob_space P pair_measure by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   626
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   627
lemma (in prob_space) joint_distribution_finite_prob_space:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   628
  assumes X: "finite_random_variable MX X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   629
  assumes Y: "finite_random_variable MY Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   630
  shows "finite_prob_space (sigma (pair_algebra MX MY)) (joint_distribution X Y)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   631
proof -
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   632
  interpret X: finite_prob_space MX "distribution X"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   633
    using X by (rule distribution_finite_prob_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   634
  interpret Y: finite_prob_space MY "distribution Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   635
    using Y by (rule distribution_finite_prob_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   636
  interpret P: prob_space "sigma (pair_algebra MX MY)" "joint_distribution X Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   637
    using assms[THEN finite_random_variableD] by (rule joint_distribution_prob_space)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   638
  interpret XY: pair_finite_prob_space MX "distribution X" MY "distribution Y"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   639
    by default
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   640
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   641
  proof
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   642
    fix x assume "x \<in> space XY.P"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   643
    moreover have "(\<lambda>x. (X x, Y x)) \<in> measurable M XY.P"
41095
c335d880ff82 cleanup bijectivity btw. product spaces and pairs
hoelzl
parents: 41023
diff changeset
   644
      using X Y by (intro XY.measurable_pair) (simp_all add: o_def, default)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   645
    ultimately have "(\<lambda>x. (X x, Y x)) -` {x} \<inter> space M \<in> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   646
      unfolding measurable_def by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   647
    then show "joint_distribution X Y {x} \<noteq> \<omega>"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   648
      unfolding distribution_def by simp
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   649
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   650
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   651
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   652
lemma finite_prob_space_eq:
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   653
  "finite_prob_space M \<mu> \<longleftrightarrow> finite_measure_space M \<mu> \<and> \<mu> (space M) = 1"
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   654
  unfolding finite_prob_space_def finite_measure_space_def prob_space_def prob_space_axioms_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   655
  by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   656
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   657
lemma (in prob_space) not_empty: "space M \<noteq> {}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   658
  using prob_space empty_measure by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   659
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   660
lemma (in finite_prob_space) sum_over_space_eq_1: "(\<Sum>x\<in>space M. \<mu> {x}) = 1"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   661
  using measure_space_1 sum_over_space by simp
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   662
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   663
lemma (in finite_prob_space) positive_distribution: "0 \<le> distribution X x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   664
  unfolding distribution_def by simp
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   665
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   666
lemma (in finite_prob_space) joint_distribution_restriction_fst:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   667
  "joint_distribution X Y A \<le> distribution X (fst ` A)"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   668
  unfolding distribution_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   669
proof (safe intro!: measure_mono)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   670
  fix x assume "x \<in> space M" and *: "(X x, Y x) \<in> A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   671
  show "x \<in> X -` fst ` A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   672
    by (auto intro!: image_eqI[OF _ *])
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   673
qed (simp_all add: sets_eq_Pow)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   674
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   675
lemma (in finite_prob_space) joint_distribution_restriction_snd:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   676
  "joint_distribution X Y A \<le> distribution Y (snd ` A)"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   677
  unfolding distribution_def
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   678
proof (safe intro!: measure_mono)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   679
  fix x assume "x \<in> space M" and *: "(X x, Y x) \<in> A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   680
  show "x \<in> Y -` snd ` A"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   681
    by (auto intro!: image_eqI[OF _ *])
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   682
qed (simp_all add: sets_eq_Pow)
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   683
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   684
lemma (in finite_prob_space) distribution_order:
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   685
  shows "0 \<le> distribution X x'"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   686
  and "(distribution X x' \<noteq> 0) \<longleftrightarrow> (0 < distribution X x')"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   687
  and "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution X {x}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   688
  and "r \<le> joint_distribution X Y {(x, y)} \<Longrightarrow> r \<le> distribution Y {y}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   689
  and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution X {x}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   690
  and "r < joint_distribution X Y {(x, y)} \<Longrightarrow> r < distribution Y {y}"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   691
  and "distribution X {x} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   692
  and "distribution Y {y} = 0 \<Longrightarrow> joint_distribution X Y {(x, y)} = 0"
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   693
  using positive_distribution[of X x']
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   694
    positive_distribution[of "\<lambda>x. (X x, Y x)" "{(x, y)}"]
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   695
    joint_distribution_restriction_fst[of X Y "{(x, y)}"]
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   696
    joint_distribution_restriction_snd[of X Y "{(x, y)}"]
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   697
  by auto
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   698
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   699
lemma (in finite_prob_space) distribution_mono:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   700
  assumes "\<And>t. \<lbrakk> t \<in> space M ; X t \<in> x \<rbrakk> \<Longrightarrow> Y t \<in> y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   701
  shows "distribution X x \<le> distribution Y y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   702
  unfolding distribution_def
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   703
  using assms by (auto simp: sets_eq_Pow intro!: measure_mono)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   704
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   705
lemma (in finite_prob_space) distribution_mono_gt_0:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   706
  assumes gt_0: "0 < distribution X x"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   707
  assumes *: "\<And>t. \<lbrakk> t \<in> space M ; X t \<in> x \<rbrakk> \<Longrightarrow> Y t \<in> y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   708
  shows "0 < distribution Y y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   709
  by (rule less_le_trans[OF gt_0 distribution_mono]) (rule *)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   710
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   711
lemma (in finite_prob_space) sum_over_space_distrib:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   712
  "(\<Sum>x\<in>X`space M. distribution X {x}) = 1"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   713
  unfolding distribution_def measure_space_1[symmetric] using finite_space
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   714
  by (subst measure_finitely_additive'')
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   715
     (auto simp add: disjoint_family_on_def sets_eq_Pow intro!: arg_cong[where f=\<mu>])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   716
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   717
lemma (in finite_prob_space) sum_over_space_real_distribution:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   718
  "(\<Sum>x\<in>X`space M. real (distribution X {x})) = 1"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   719
  unfolding distribution_def prob_space[symmetric] using finite_space
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   720
  by (subst real_finite_measure_finite_Union[symmetric])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   721
     (auto simp add: disjoint_family_on_def sets_eq_Pow intro!: arg_cong[where f=prob])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   722
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   723
lemma (in finite_prob_space) finite_sum_over_space_eq_1:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   724
  "(\<Sum>x\<in>space M. real (\<mu> {x})) = 1"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   725
  using sum_over_space_eq_1 finite_measure by (simp add: real_of_pextreal_setsum sets_eq_Pow)
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   726
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   727
lemma (in finite_prob_space) distribution_finite:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   728
  "distribution X A \<noteq> \<omega>"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   729
  using finite_measure[of "X -` A \<inter> space M"]
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   730
  unfolding distribution_def sets_eq_Pow by auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   731
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   732
lemma (in finite_prob_space) real_distribution_gt_0[simp]:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   733
  "0 < real (distribution Y y) \<longleftrightarrow>  0 < distribution Y y"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   734
  using assms by (auto intro!: real_pextreal_pos distribution_finite)
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   735
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   736
lemma (in finite_prob_space) real_distribution_mult_pos_pos:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   737
  assumes "0 < distribution Y y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   738
  and "0 < distribution X x"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   739
  shows "0 < real (distribution Y y * distribution X x)"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   740
  unfolding real_of_pextreal_mult[symmetric]
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   741
  using assms by (auto intro!: mult_pos_pos)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   742
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   743
lemma (in finite_prob_space) real_distribution_divide_pos_pos:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   744
  assumes "0 < distribution Y y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   745
  and "0 < distribution X x"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   746
  shows "0 < real (distribution Y y / distribution X x)"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   747
  unfolding divide_pextreal_def real_of_pextreal_mult[symmetric]
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   748
  using assms distribution_finite[of X x] by (cases "distribution X x") (auto intro!: mult_pos_pos)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   749
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   750
lemma (in finite_prob_space) real_distribution_mult_inverse_pos_pos:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   751
  assumes "0 < distribution Y y"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   752
  and "0 < distribution X x"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   753
  shows "0 < real (distribution Y y * inverse (distribution X x))"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   754
  unfolding divide_pextreal_def real_of_pextreal_mult[symmetric]
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   755
  using assms distribution_finite[of X x] by (cases "distribution X x") (auto intro!: mult_pos_pos)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   756
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   757
lemma (in prob_space) distribution_remove_const:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   758
  shows "joint_distribution X (\<lambda>x. ()) {(x, ())} = distribution X {x}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   759
  and "joint_distribution (\<lambda>x. ()) X {((), x)} = distribution X {x}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   760
  and "joint_distribution X (\<lambda>x. (Y x, ())) {(x, y, ())} = joint_distribution X Y {(x, y)}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   761
  and "joint_distribution X (\<lambda>x. ((), Y x)) {(x, (), y)} = joint_distribution X Y {(x, y)}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   762
  and "distribution (\<lambda>x. ()) {()} = 1"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   763
  unfolding measure_space_1[symmetric]
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   764
  by (auto intro!: arg_cong[where f="\<mu>"] simp: distribution_def)
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   765
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   766
lemma (in finite_prob_space) setsum_distribution_gen:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   767
  assumes "Z -` {c} \<inter> space M = (\<Union>x \<in> X`space M. Y -` {f x}) \<inter> space M"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   768
  and "inj_on f (X`space M)"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   769
  shows "(\<Sum>x \<in> X`space M. distribution Y {f x}) = distribution Z {c}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   770
  unfolding distribution_def assms
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   771
  using finite_space assms
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   772
  by (subst measure_finitely_additive'')
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   773
     (auto simp add: disjoint_family_on_def sets_eq_Pow inj_on_def
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   774
      intro!: arg_cong[where f=prob])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   775
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   776
lemma (in finite_prob_space) setsum_distribution:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   777
  "(\<Sum>x \<in> X`space M. joint_distribution X Y {(x, y)}) = distribution Y {y}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   778
  "(\<Sum>y \<in> Y`space M. joint_distribution X Y {(x, y)}) = distribution X {x}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   779
  "(\<Sum>x \<in> X`space M. joint_distribution X (\<lambda>x. (Y x, Z x)) {(x, y, z)}) = joint_distribution Y Z {(y, z)}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   780
  "(\<Sum>y \<in> Y`space M. joint_distribution X (\<lambda>x. (Y x, Z x)) {(x, y, z)}) = joint_distribution X Z {(x, z)}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   781
  "(\<Sum>z \<in> Z`space M. joint_distribution X (\<lambda>x. (Y x, Z x)) {(x, y, z)}) = joint_distribution X Y {(x, y)}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   782
  by (auto intro!: inj_onI setsum_distribution_gen)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   783
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   784
lemma (in finite_prob_space) setsum_real_distribution_gen:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   785
  assumes "Z -` {c} \<inter> space M = (\<Union>x \<in> X`space M. Y -` {f x}) \<inter> space M"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   786
  and "inj_on f (X`space M)"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   787
  shows "(\<Sum>x \<in> X`space M. real (distribution Y {f x})) = real (distribution Z {c})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   788
  unfolding distribution_def assms
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   789
  using finite_space assms
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   790
  by (subst real_finite_measure_finite_Union[symmetric])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   791
     (auto simp add: disjoint_family_on_def sets_eq_Pow inj_on_def
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   792
        intro!: arg_cong[where f=prob])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   793
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   794
lemma (in finite_prob_space) setsum_real_distribution:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   795
  "(\<Sum>x \<in> X`space M. real (joint_distribution X Y {(x, y)})) = real (distribution Y {y})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   796
  "(\<Sum>y \<in> Y`space M. real (joint_distribution X Y {(x, y)})) = real (distribution X {x})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   797
  "(\<Sum>x \<in> X`space M. real (joint_distribution X (\<lambda>x. (Y x, Z x)) {(x, y, z)})) = real (joint_distribution Y Z {(y, z)})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   798
  "(\<Sum>y \<in> Y`space M. real (joint_distribution X (\<lambda>x. (Y x, Z x)) {(x, y, z)})) = real (joint_distribution X Z {(x, z)})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   799
  "(\<Sum>z \<in> Z`space M. real (joint_distribution X (\<lambda>x. (Y x, Z x)) {(x, y, z)})) = real (joint_distribution X Y {(x, y)})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   800
  by (auto intro!: inj_onI setsum_real_distribution_gen)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   801
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   802
lemma (in finite_prob_space) real_distribution_order:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   803
  shows "r \<le> real (joint_distribution X Y {(x, y)}) \<Longrightarrow> r \<le> real (distribution X {x})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   804
  and "r \<le> real (joint_distribution X Y {(x, y)}) \<Longrightarrow> r \<le> real (distribution Y {y})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   805
  and "r < real (joint_distribution X Y {(x, y)}) \<Longrightarrow> r < real (distribution X {x})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   806
  and "r < real (joint_distribution X Y {(x, y)}) \<Longrightarrow> r < real (distribution Y {y})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   807
  and "distribution X {x} = 0 \<Longrightarrow> real (joint_distribution X Y {(x, y)}) = 0"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   808
  and "distribution Y {y} = 0 \<Longrightarrow> real (joint_distribution X Y {(x, y)}) = 0"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   809
  using real_of_pextreal_mono[OF distribution_finite joint_distribution_restriction_fst, of X Y "{(x, y)}"]
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   810
  using real_of_pextreal_mono[OF distribution_finite joint_distribution_restriction_snd, of X Y "{(x, y)}"]
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   811
  using real_pextreal_nonneg[of "joint_distribution X Y {(x, y)}"]
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   812
  by auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   813
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   814
lemma (in prob_space) joint_distribution_remove[simp]:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   815
    "joint_distribution X X {(x, x)} = distribution X {x}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   816
  unfolding distribution_def by (auto intro!: arg_cong[where f="\<mu>"])
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   817
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   818
lemma (in finite_prob_space) distribution_1:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   819
  "distribution X A \<le> 1"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   820
  unfolding distribution_def measure_space_1[symmetric]
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   821
  by (auto intro!: measure_mono simp: sets_eq_Pow)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   822
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   823
lemma (in finite_prob_space) real_distribution_1:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   824
  "real (distribution X A) \<le> 1"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   825
  unfolding real_pextreal_1[symmetric]
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   826
  by (rule real_of_pextreal_mono[OF _ distribution_1]) simp
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   827
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   828
lemma (in finite_prob_space) uniform_prob:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   829
  assumes "x \<in> space M"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   830
  assumes "\<And> x y. \<lbrakk>x \<in> space M ; y \<in> space M\<rbrakk> \<Longrightarrow> prob {x} = prob {y}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   831
  shows "prob {x} = 1 / real (card (space M))"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   832
proof -
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   833
  have prob_x: "\<And> y. y \<in> space M \<Longrightarrow> prob {y} = prob {x}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   834
    using assms(2)[OF _ `x \<in> space M`] by blast
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   835
  have "1 = prob (space M)"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   836
    using prob_space by auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   837
  also have "\<dots> = (\<Sum> x \<in> space M. prob {x})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   838
    using real_finite_measure_finite_Union[of "space M" "\<lambda> x. {x}", simplified]
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   839
      sets_eq_Pow inj_singleton[unfolded inj_on_def, rule_format]
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   840
      finite_space unfolding disjoint_family_on_def  prob_space[symmetric]
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   841
    by (auto simp add:setsum_restrict_set)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   842
  also have "\<dots> = (\<Sum> y \<in> space M. prob {x})"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   843
    using prob_x by auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   844
  also have "\<dots> = real_of_nat (card (space M)) * prob {x}" by simp
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   845
  finally have one: "1 = real (card (space M)) * prob {x}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   846
    using real_eq_of_nat by auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   847
  hence two: "real (card (space M)) \<noteq> 0" by fastsimp 
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   848
  from one have three: "prob {x} \<noteq> 0" by fastsimp
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   849
  thus ?thesis using one two three divide_cancel_right
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   850
    by (auto simp:field_simps)
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   851
qed
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   852
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   853
lemma (in prob_space) prob_space_subalgebra:
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   854
  assumes "N \<subseteq> sets M" "sigma_algebra (M\<lparr> sets := N \<rparr>)"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   855
  shows "prob_space (M\<lparr> sets := N \<rparr>) \<mu>"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   856
proof -
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   857
  interpret N: measure_space "M\<lparr> sets := N \<rparr>" \<mu>
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   858
    using measure_space_subalgebra[OF assms] .
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   859
  show ?thesis
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   860
    proof qed (simp add: measure_space_1)
35977
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   861
qed
30d42bfd0174 Added finite measure space.
hoelzl
parents: 35929
diff changeset
   862
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   863
lemma (in prob_space) prob_space_of_restricted_space:
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   864
  assumes "\<mu> A \<noteq> 0" "\<mu> A \<noteq> \<omega>" "A \<in> sets M"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   865
  shows "prob_space (restricted_space A) (\<lambda>S. \<mu> S / \<mu> A)"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   866
  unfolding prob_space_def prob_space_axioms_def
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   867
proof
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   868
  show "\<mu> (space (restricted_space A)) / \<mu> A = 1"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   869
    using `\<mu> A \<noteq> 0` `\<mu> A \<noteq> \<omega>` by (auto simp: pextreal_noteq_omega_Ex)
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   870
  have *: "\<And>S. \<mu> S / \<mu> A = inverse (\<mu> A) * \<mu> S" by (simp add: mult_commute)
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   871
  interpret A: measure_space "restricted_space A" \<mu>
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   872
    using `A \<in> sets M` by (rule restricted_measure_space)
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   873
  show "measure_space (restricted_space A) (\<lambda>S. \<mu> S / \<mu> A)"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   874
  proof
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   875
    show "\<mu> {} / \<mu> A = 0" by auto
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   876
    show "countably_additive (restricted_space A) (\<lambda>S. \<mu> S / \<mu> A)"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   877
        unfolding countably_additive_def psuminf_cmult_right *
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   878
        using A.measure_countably_additive by auto
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   879
  qed
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   880
qed
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   881
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   882
lemma finite_prob_spaceI:
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   883
  assumes "finite (space M)" "sets M = Pow(space M)" "\<mu> (space M) = 1" "\<mu> {} = 0"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   884
    and "\<And>A B. A\<subseteq>space M \<Longrightarrow> B\<subseteq>space M \<Longrightarrow> A \<inter> B = {} \<Longrightarrow> \<mu> (A \<union> B) = \<mu> A + \<mu> B"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   885
  shows "finite_prob_space M \<mu>"
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   886
  unfolding finite_prob_space_eq
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   887
proof
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   888
  show "finite_measure_space M \<mu>" using assms
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   889
     by (auto intro!: finite_measure_spaceI)
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   890
  show "\<mu> (space M) = 1" by fact
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   891
qed
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   892
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   893
lemma (in finite_prob_space) finite_measure_space:
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   894
  fixes X :: "'a \<Rightarrow> 'x"
38656
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   895
  shows "finite_measure_space \<lparr>space = X ` space M, sets = Pow (X ` space M)\<rparr> (distribution X)"
d5d342611edb Rewrite the Probability theory.
hoelzl
parents: 36624
diff changeset
   896
    (is "finite_measure_space ?S _")
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
   897
proof (rule finite_measure_spaceI, simp_all)
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   898
  show "finite (X ` space M)" using finite_space by simp
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   899
next
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   900
  fix A B :: "'x set" assume "A \<inter> B = {}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   901
  then show "distribution X (A \<union> B) = distribution X A + distribution X B"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   902
    unfolding distribution_def
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   903
    by (subst measure_additive)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   904
       (auto intro!: arg_cong[where f=\<mu>] simp: sets_eq_Pow)
36624
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   905
qed
25153c08655e Cleanup information theory
hoelzl
parents: 35977
diff changeset
   906
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   907
lemma (in finite_prob_space) finite_prob_space_of_images:
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   908
  "finite_prob_space \<lparr> space = X ` space M, sets = Pow (X ` space M)\<rparr> (distribution X)"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   909
  by (simp add: finite_prob_space_eq finite_measure_space)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   910
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   911
lemma (in finite_prob_space) real_distribution_order':
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   912
  shows "real (distribution X {x}) = 0 \<Longrightarrow> real (joint_distribution X Y {(x, y)}) = 0"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   913
  and "real (distribution Y {y}) = 0 \<Longrightarrow> real (joint_distribution X Y {(x, y)}) = 0"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   914
  using real_of_pextreal_mono[OF distribution_finite joint_distribution_restriction_fst, of X Y "{(x, y)}"]
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   915
  using real_of_pextreal_mono[OF distribution_finite joint_distribution_restriction_snd, of X Y "{(x, y)}"]
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   916
  using real_pextreal_nonneg[of "joint_distribution X Y {(x, y)}"]
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   917
  by auto
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   918
39096
hoelzl
parents: 39092
diff changeset
   919
lemma (in finite_prob_space) finite_product_measure_space:
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   920
  fixes X :: "'a \<Rightarrow> 'x" and Y :: "'a \<Rightarrow> 'y"
39096
hoelzl
parents: 39092
diff changeset
   921
  assumes "finite s1" "finite s2"
hoelzl
parents: 39092
diff changeset
   922
  shows "finite_measure_space \<lparr> space = s1 \<times> s2, sets = Pow (s1 \<times> s2)\<rparr> (joint_distribution X Y)"
hoelzl
parents: 39092
diff changeset
   923
    (is "finite_measure_space ?M ?D")
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   924
proof (rule finite_measure_spaceI, simp_all)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   925
  show "finite (s1 \<times> s2)"
39096
hoelzl
parents: 39092
diff changeset
   926
    using assms by auto
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   927
  show "joint_distribution X Y (s1\<times>s2) \<noteq> \<omega>"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   928
    using distribution_finite .
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   929
next
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   930
  fix A B :: "('x*'y) set" assume "A \<inter> B = {}"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   931
  then show "joint_distribution X Y (A \<union> B) = joint_distribution X Y A + joint_distribution X Y B"
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   932
    unfolding distribution_def
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   933
    by (subst measure_additive)
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   934
       (auto intro!: arg_cong[where f=\<mu>] simp: sets_eq_Pow)
39096
hoelzl
parents: 39092
diff changeset
   935
qed
hoelzl
parents: 39092
diff changeset
   936
39097
943c7b348524 Moved lemmas to appropriate locations
hoelzl
parents: 39096
diff changeset
   937
lemma (in finite_prob_space) finite_product_measure_space_of_images:
39096
hoelzl
parents: 39092
diff changeset
   938
  shows "finite_measure_space \<lparr> space = X ` space M \<times> Y ` space M,
hoelzl
parents: 39092
diff changeset
   939
                                sets = Pow (X ` space M \<times> Y ` space M) \<rparr>
hoelzl
parents: 39092
diff changeset
   940
                              (joint_distribution X Y)"
hoelzl
parents: 39092
diff changeset
   941
  using finite_space by (auto intro!: finite_product_measure_space)
hoelzl
parents: 39092
diff changeset
   942
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   943
lemma (in finite_prob_space) finite_product_prob_space_of_images:
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   944
  "finite_prob_space \<lparr> space = X ` space M \<times> Y ` space M, sets = Pow (X ` space M \<times> Y ` space M)\<rparr>
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   945
                     (joint_distribution X Y)"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   946
  (is "finite_prob_space ?S _")
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   947
proof (simp add: finite_prob_space_eq finite_product_measure_space_of_images)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   948
  have "X -` X ` space M \<inter> Y -` Y ` space M \<inter> space M = space M" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   949
  thus "joint_distribution X Y (X ` space M \<times> Y ` space M) = 1"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   950
    by (simp add: distribution_def prob_space vimage_Times comp_def measure_space_1)
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   951
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents: 39302
diff changeset
   952
39085
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   953
section "Conditional Expectation and Probability"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   954
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   955
lemma (in prob_space) conditional_expectation_exists:
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
   956
  fixes X :: "'a \<Rightarrow> pextreal"
39083
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   957
  assumes borel: "X \<in> borel_measurable M"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   958
  and N_subalgebra: "N \<subseteq> sets M" "sigma_algebra (M\<lparr> sets := N \<rparr>)"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   959
  shows "\<exists>Y\<in>borel_measurable (M\<lparr> sets := N \<rparr>). \<forall>C\<in>N.
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   960
      positive_integral (\<lambda>x. Y x * indicator C x) = positive_integral (\<lambda>x. X x * indicator C x)"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   961
proof -
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   962
  interpret P: prob_space "M\<lparr> sets := N \<rparr>" \<mu>
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   963
    using prob_space_subalgebra[OF N_subalgebra] .
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   964
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   965
  let "?f A" = "\<lambda>x. X x * indicator A x"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   966
  let "?Q A" = "positive_integral (?f A)"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   967
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   968
  from measure_space_density[OF borel]
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   969
  have Q: "measure_space (M\<lparr> sets := N \<rparr>) ?Q"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   970
    by (rule measure_space.measure_space_subalgebra[OF _ N_subalgebra])
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   971
  then interpret Q: measure_space "M\<lparr> sets := N \<rparr>" ?Q .
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   972
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   973
  have "P.absolutely_continuous ?Q"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   974
    unfolding P.absolutely_continuous_def
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   975
  proof (safe, simp)
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   976
    fix A assume "A \<in> N" "\<mu> A = 0"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   977
    moreover then have f_borel: "?f A \<in> borel_measurable M"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   978
      using borel N_subalgebra by (auto intro: borel_measurable_indicator)
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   979
    moreover have "{x\<in>space M. ?f A x \<noteq> 0} = (?f A -` {0<..} \<inter> space M) \<inter> A"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   980
      by (auto simp: indicator_def)
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   981
    moreover have "\<mu> \<dots> \<le> \<mu> A"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   982
      using `A \<in> N` N_subalgebra f_borel
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   983
      by (auto intro!: measure_mono Int[of _ A] measurable_sets)
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   984
    ultimately show "?Q A = 0"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   985
      by (simp add: positive_integral_0_iff)
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   986
  qed
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   987
  from P.Radon_Nikodym[OF Q this]
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   988
  obtain Y where Y: "Y \<in> borel_measurable (M\<lparr>sets := N\<rparr>)"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   989
    "\<And>A. A \<in> sets (M\<lparr>sets:=N\<rparr>) \<Longrightarrow> ?Q A = P.positive_integral (\<lambda>x. Y x * indicator A x)"
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   990
    by blast
39084
7a6ecce97661 proved existence of conditional expectation
hoelzl
parents: 39083
diff changeset
   991
  with N_subalgebra show ?thesis
7a6ecce97661 proved existence of conditional expectation
hoelzl
parents: 39083
diff changeset
   992
    by (auto intro!: bexI[OF _ Y(1)])
39083
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   993
qed
e46acc0ea1fe introduced integration on subalgebras
hoelzl
parents: 38656
diff changeset
   994
39085
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   995
definition (in prob_space)
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   996
  "conditional_expectation N X = (SOME Y. Y\<in>borel_measurable (M\<lparr>sets:=N\<rparr>)
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   997
    \<and> (\<forall>C\<in>N. positive_integral (\<lambda>x. Y x * indicator C x) = positive_integral (\<lambda>x. X x * indicator C x)))"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   998
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
   999
abbreviation (in prob_space)
39092
98de40859858 move lemmas to correct theory files
hoelzl
parents: 39091
diff changeset
  1000
  "conditional_prob N A \<equiv> conditional_expectation N (indicator A)"
39085
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1001
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1002
lemma (in prob_space)
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
  1003
  fixes X :: "'a \<Rightarrow> pextreal"
39085
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1004
  assumes borel: "X \<in> borel_measurable M"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1005
  and N_subalgebra: "N \<subseteq> sets M" "sigma_algebra (M\<lparr> sets := N \<rparr>)"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1006
  shows borel_measurable_conditional_expectation:
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1007
    "conditional_expectation N X \<in> borel_measurable (M\<lparr> sets := N \<rparr>)"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1008
  and conditional_expectation: "\<And>C. C \<in> N \<Longrightarrow>
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1009
      positive_integral (\<lambda>x. conditional_expectation N X x * indicator C x) =
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1010
      positive_integral (\<lambda>x. X x * indicator C x)"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1011
   (is "\<And>C. C \<in> N \<Longrightarrow> ?eq C")
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1012
proof -
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1013
  note CE = conditional_expectation_exists[OF assms, unfolded Bex_def]
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1014
  then show "conditional_expectation N X \<in> borel_measurable (M\<lparr> sets := N \<rparr>)"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1015
    unfolding conditional_expectation_def by (rule someI2_ex) blast
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1016
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1017
  from CE show "\<And>C. C\<in>N \<Longrightarrow> ?eq C"
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1018
    unfolding conditional_expectation_def by (rule someI2_ex) blast
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1019
qed
8b7c009da23c added definition of conditional expectation
hoelzl
parents: 39084
diff changeset
  1020
39091
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1021
lemma (in sigma_algebra) factorize_measurable_function:
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
  1022
  fixes Z :: "'a \<Rightarrow> pextreal" and Y :: "'a \<Rightarrow> 'c"
39091
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1023
  assumes "sigma_algebra M'" and "Y \<in> measurable M M'" "Z \<in> borel_measurable M"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1024
  shows "Z \<in> borel_measurable (sigma_algebra.vimage_algebra M' (space M) Y)
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1025
    \<longleftrightarrow> (\<exists>g\<in>borel_measurable M'. \<forall>x\<in>space M. Z x = g (Y x))"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1026
proof safe
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1027
  interpret M': sigma_algebra M' by fact
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1028
  have Y: "Y \<in> space M \<rightarrow> space M'" using assms unfolding measurable_def by auto
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1029
  from M'.sigma_algebra_vimage[OF this]
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1030
  interpret va: sigma_algebra "M'.vimage_algebra (space M) Y" .
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1031
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
  1032
  { fix g :: "'c \<Rightarrow> pextreal" assume "g \<in> borel_measurable M'"
39091
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1033
    with M'.measurable_vimage_algebra[OF Y]
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1034
    have "g \<circ> Y \<in> borel_measurable (M'.vimage_algebra (space M) Y)"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1035
      by (rule measurable_comp)
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1036
    moreover assume "\<forall>x\<in>space M. Z x = g (Y x)"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1037
    then have "Z \<in> borel_measurable (M'.vimage_algebra (space M) Y) \<longleftrightarrow>
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1038
       g \<circ> Y \<in> borel_measurable (M'.vimage_algebra (space M) Y)"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1039
       by (auto intro!: measurable_cong)
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1040
    ultimately show "Z \<in> borel_measurable (M'.vimage_algebra (space M) Y)"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1041
      by simp }
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1042
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1043
  assume "Z \<in> borel_measurable (M'.vimage_algebra (space M) Y)"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1044
  from va.borel_measurable_implies_simple_function_sequence[OF this]
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1045
  obtain f where f: "\<And>i. va.simple_function (f i)" and "f \<up> Z" by blast
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1046
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1047
  have "\<forall>i. \<exists>g. M'.simple_function g \<and> (\<forall>x\<in>space M. f i x = g (Y x))"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1048
  proof
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1049
    fix i
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1050
    from f[of i] have "finite (f i`space M)" and B_ex:
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1051
      "\<forall>z\<in>(f i)`space M. \<exists>B. B \<in> sets M' \<and> (f i) -` {z} \<inter> space M = Y -` B \<inter> space M"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1052
      unfolding va.simple_function_def by auto
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1053
    from B_ex[THEN bchoice] guess B .. note B = this
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1054
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1055
    let ?g = "\<lambda>x. \<Sum>z\<in>f i`space M. z * indicator (B z) x"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1056
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1057
    show "\<exists>g. M'.simple_function g \<and> (\<forall>x\<in>space M. f i x = g (Y x))"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1058
    proof (intro exI[of _ ?g] conjI ballI)
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1059
      show "M'.simple_function ?g" using B by auto
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1060
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1061
      fix x assume "x \<in> space M"
41023
9118eb4eb8dc it is known as the extended reals, not the infinite reals
hoelzl
parents: 40859
diff changeset
  1062
      then have "\<And>z. z \<in> f i`space M \<Longrightarrow> indicator (B z) (Y x) = (indicator (f i -` {z} \<inter> space M) x::pextreal)"
39091
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1063
        unfolding indicator_def using B by auto
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1064
      then show "f i x = ?g (Y x)" using `x \<in> space M` f[of i]
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1065
        by (subst va.simple_function_indicator_representation) auto
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1066
    qed
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1067
  qed
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1068
  from choice[OF this] guess g .. note g = this
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1069
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1070
  show "\<exists>g\<in>borel_measurable M'. \<forall>x\<in>space M. Z x = g (Y x)"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1071
  proof (intro ballI bexI)
41097
a1abfa4e2b44 use SUPR_ and INFI_apply instead of SUPR_, INFI_fun_expand
hoelzl
parents: 41095
diff changeset
  1072
    show "(\<lambda>x. SUP i. g i x) \<in> borel_measurable M'"
39091
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1073
      using g by (auto intro: M'.borel_measurable_simple_function)
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1074
    fix x assume "x \<in> space M"
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1075
    have "Z x = (SUP i. f i) x" using `f \<up> Z` unfolding isoton_def by simp
41097
a1abfa4e2b44 use SUPR_ and INFI_apply instead of SUPR_, INFI_fun_expand
hoelzl
parents: 41095
diff changeset
  1076
    also have "\<dots> = (SUP i. g i (Y x))" unfolding SUPR_apply
39091
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1077
      using g `x \<in> space M` by simp
41097
a1abfa4e2b44 use SUPR_ and INFI_apply instead of SUPR_, INFI_fun_expand
hoelzl
parents: 41095
diff changeset
  1078
    finally show "Z x = (SUP i. g i (Y x))" .
39091
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1079
  qed
11314c196e11 factorizable measurable functions
hoelzl
parents: 39090
diff changeset
  1080
qed
39090
a2d38b8b693e Introduced sigma algebra generated by function preimages.
hoelzl
parents: 39089
diff changeset
  1081
35582
b16d99a72dc9 Add Lebesgue integral and probability space.
hoelzl
parents:
diff changeset
  1082
end