author | hoelzl |
Thu, 22 Jan 2015 14:51:08 +0100 | |
changeset 59425 | c5e79df8cc21 |
parent 59092 | d469103c0737 |
child 59427 | 084330e2ec5e |
permissions | -rw-r--r-- |
58606 | 1 |
(* Title: HOL/Probability/Giry_Monad.thy |
2 |
Author: Johannes Hölzl, TU München |
|
3 |
Author: Manuel Eberl, TU München |
|
4 |
||
5 |
Defines the subprobability spaces, the subprobability functor and the Giry monad on subprobability |
|
6 |
spaces. |
|
7 |
*) |
|
8 |
||
9 |
theory Giry_Monad |
|
59092
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
10 |
imports Probability_Measure Lebesgue_Integral_Substitution "~~/src/HOL/Library/Monad_Syntax" |
58606 | 11 |
begin |
12 |
||
13 |
section {* Sub-probability spaces *} |
|
14 |
||
15 |
locale subprob_space = finite_measure + |
|
16 |
assumes emeasure_space_le_1: "emeasure M (space M) \<le> 1" |
|
17 |
assumes subprob_not_empty: "space M \<noteq> {}" |
|
18 |
||
19 |
lemma subprob_spaceI[Pure.intro!]: |
|
20 |
assumes *: "emeasure M (space M) \<le> 1" |
|
21 |
assumes "space M \<noteq> {}" |
|
22 |
shows "subprob_space M" |
|
23 |
proof - |
|
24 |
interpret finite_measure M |
|
25 |
proof |
|
26 |
show "emeasure M (space M) \<noteq> \<infinity>" using * by auto |
|
27 |
qed |
|
28 |
show "subprob_space M" by default fact+ |
|
29 |
qed |
|
30 |
||
31 |
lemma prob_space_imp_subprob_space: |
|
32 |
"prob_space M \<Longrightarrow> subprob_space M" |
|
33 |
by (rule subprob_spaceI) (simp_all add: prob_space.emeasure_space_1 prob_space.not_empty) |
|
34 |
||
59425 | 35 |
lemma subprob_space_imp_sigma_finite: "subprob_space M \<Longrightarrow> sigma_finite_measure M" |
36 |
unfolding subprob_space_def finite_measure_def by simp |
|
37 |
||
58606 | 38 |
sublocale prob_space \<subseteq> subprob_space |
39 |
by (rule subprob_spaceI) (simp_all add: emeasure_space_1 not_empty) |
|
40 |
||
41 |
lemma (in subprob_space) subprob_space_distr: |
|
42 |
assumes f: "f \<in> measurable M M'" and "space M' \<noteq> {}" shows "subprob_space (distr M M' f)" |
|
43 |
proof (rule subprob_spaceI) |
|
44 |
have "f -` space M' \<inter> space M = space M" using f by (auto dest: measurable_space) |
|
45 |
with f show "emeasure (distr M M' f) (space (distr M M' f)) \<le> 1" |
|
46 |
by (auto simp: emeasure_distr emeasure_space_le_1) |
|
47 |
show "space (distr M M' f) \<noteq> {}" by (simp add: assms) |
|
48 |
qed |
|
49 |
||
59000 | 50 |
lemma (in subprob_space) subprob_emeasure_le_1: "emeasure M X \<le> 1" |
58606 | 51 |
by (rule order.trans[OF emeasure_space emeasure_space_le_1]) |
52 |
||
59000 | 53 |
lemma (in subprob_space) subprob_measure_le_1: "measure M X \<le> 1" |
54 |
using subprob_emeasure_le_1[of X] by (simp add: emeasure_eq_measure) |
|
55 |
||
59092
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
56 |
lemma emeasure_density_distr_interval: |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
57 |
fixes h :: "real \<Rightarrow> real" and g :: "real \<Rightarrow> real" and g' :: "real \<Rightarrow> real" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
58 |
assumes [simp]: "a \<le> b" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
59 |
assumes Mf[measurable]: "f \<in> borel_measurable borel" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
60 |
assumes Mg[measurable]: "g \<in> borel_measurable borel" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
61 |
assumes Mg'[measurable]: "g' \<in> borel_measurable borel" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
62 |
assumes Mh[measurable]: "h \<in> borel_measurable borel" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
63 |
assumes prob: "subprob_space (density lborel f)" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
64 |
assumes nonnegf: "\<And>x. f x \<ge> 0" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
65 |
assumes derivg: "\<And>x. x \<in> {a..b} \<Longrightarrow> (g has_real_derivative g' x) (at x)" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
66 |
assumes contg': "continuous_on {a..b} g'" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
67 |
assumes mono: "strict_mono_on g {a..b}" and inv: "\<And>x. h x \<in> {a..b} \<Longrightarrow> g (h x) = x" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
68 |
assumes range: "{a..b} \<subseteq> range h" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
69 |
shows "emeasure (distr (density lborel f) lborel h) {a..b} = |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
70 |
emeasure (density lborel (\<lambda>x. f (g x) * g' x)) {a..b}" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
71 |
proof (cases "a < b") |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
72 |
assume "a < b" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
73 |
from mono have inj: "inj_on g {a..b}" by (rule strict_mono_on_imp_inj_on) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
74 |
from mono have mono': "mono_on g {a..b}" by (rule strict_mono_on_imp_mono_on) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
75 |
from mono' derivg have "\<And>x. x \<in> {a<..<b} \<Longrightarrow> g' x \<ge> 0" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
76 |
by (rule mono_on_imp_deriv_nonneg) (auto simp: interior_atLeastAtMost_real) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
77 |
from contg' this have derivg_nonneg: "\<And>x. x \<in> {a..b} \<Longrightarrow> g' x \<ge> 0" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
78 |
by (rule continuous_ge_on_Iii) (simp_all add: `a < b`) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
79 |
|
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
80 |
from derivg have contg: "continuous_on {a..b} g" by (rule has_real_derivative_imp_continuous_on) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
81 |
have A: "h -` {a..b} = {g a..g b}" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
82 |
proof (intro equalityI subsetI) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
83 |
fix x assume x: "x \<in> h -` {a..b}" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
84 |
hence "g (h x) \<in> {g a..g b}" by (auto intro: mono_onD[OF mono']) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
85 |
with inv and x show "x \<in> {g a..g b}" by simp |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
86 |
next |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
87 |
fix y assume y: "y \<in> {g a..g b}" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
88 |
with IVT'[OF _ _ _ contg, of y] obtain x where "x \<in> {a..b}" "y = g x" by auto |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
89 |
with range and inv show "y \<in> h -` {a..b}" by auto |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
90 |
qed |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
91 |
|
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
92 |
have prob': "subprob_space (distr (density lborel f) lborel h)" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
93 |
by (rule subprob_space.subprob_space_distr[OF prob]) (simp_all add: Mh) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
94 |
have B: "emeasure (distr (density lborel f) lborel h) {a..b} = |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
95 |
\<integral>\<^sup>+x. f x * indicator (h -` {a..b}) x \<partial>lborel" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
96 |
by (subst emeasure_distr) (simp_all add: emeasure_density Mf Mh measurable_sets_borel[OF Mh]) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
97 |
also note A |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
98 |
also have "emeasure (distr (density lborel f) lborel h) {a..b} \<le> 1" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
99 |
by (rule subprob_space.subprob_emeasure_le_1) (rule prob') |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
100 |
hence "emeasure (distr (density lborel f) lborel h) {a..b} \<noteq> \<infinity>" by auto |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
101 |
with assms have "(\<integral>\<^sup>+x. f x * indicator {g a..g b} x \<partial>lborel) = |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
102 |
(\<integral>\<^sup>+x. f (g x) * g' x * indicator {a..b} x \<partial>lborel)" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
103 |
by (intro nn_integral_substitution_aux) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
104 |
(auto simp: derivg_nonneg A B emeasure_density mult.commute `a < b`) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
105 |
also have "... = emeasure (density lborel (\<lambda>x. f (g x) * g' x)) {a..b}" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
106 |
by (simp add: emeasure_density) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
107 |
finally show ?thesis . |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
108 |
next |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
109 |
assume "\<not>a < b" |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
110 |
with `a \<le> b` have [simp]: "b = a" by (simp add: not_less del: `a \<le> b`) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
111 |
from inv and range have "h -` {a} = {g a}" by auto |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
112 |
thus ?thesis by (simp_all add: emeasure_distr emeasure_density measurable_sets_borel[OF Mh]) |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
113 |
qed |
d469103c0737
add integral substitution theorems from Manuel Eberl, Jeremy Avigad, Luke Serafin, and Sudeep Kanav
hoelzl
parents:
59048
diff
changeset
|
114 |
|
58606 | 115 |
locale pair_subprob_space = |
116 |
pair_sigma_finite M1 M2 + M1: subprob_space M1 + M2: subprob_space M2 for M1 M2 |
|
117 |
||
118 |
sublocale pair_subprob_space \<subseteq> P: subprob_space "M1 \<Otimes>\<^sub>M M2" |
|
119 |
proof |
|
120 |
have "\<And>a b. \<lbrakk>a \<ge> 0; b \<ge> 0; a \<le> 1; b \<le> 1\<rbrakk> \<Longrightarrow> a * b \<le> (1::ereal)" |
|
121 |
by (metis comm_monoid_mult_class.mult.left_neutral dual_order.trans ereal_mult_right_mono) |
|
122 |
from this[OF _ _ M1.emeasure_space_le_1 M2.emeasure_space_le_1] |
|
123 |
show "emeasure (M1 \<Otimes>\<^sub>M M2) (space (M1 \<Otimes>\<^sub>M M2)) \<le> 1" |
|
124 |
by (simp add: M2.emeasure_pair_measure_Times space_pair_measure emeasure_nonneg) |
|
125 |
from M1.subprob_not_empty and M2.subprob_not_empty show "space (M1 \<Otimes>\<^sub>M M2) \<noteq> {}" |
|
126 |
by (simp add: space_pair_measure) |
|
127 |
qed |
|
128 |
||
59425 | 129 |
lemma subprob_space_null_measure_iff: |
130 |
"subprob_space (null_measure M) \<longleftrightarrow> space M \<noteq> {}" |
|
131 |
by (auto intro!: subprob_spaceI dest: subprob_space.subprob_not_empty) |
|
132 |
||
58606 | 133 |
definition subprob_algebra :: "'a measure \<Rightarrow> 'a measure measure" where |
134 |
"subprob_algebra K = |
|
135 |
(\<Squnion>\<^sub>\<sigma> A\<in>sets K. vimage_algebra {M. subprob_space M \<and> sets M = sets K} (\<lambda>M. emeasure M A) borel)" |
|
136 |
||
137 |
lemma space_subprob_algebra: "space (subprob_algebra A) = {M. subprob_space M \<and> sets M = sets A}" |
|
138 |
by (auto simp add: subprob_algebra_def space_Sup_sigma) |
|
139 |
||
140 |
lemma subprob_algebra_cong: "sets M = sets N \<Longrightarrow> subprob_algebra M = subprob_algebra N" |
|
141 |
by (simp add: subprob_algebra_def) |
|
142 |
||
143 |
lemma measurable_emeasure_subprob_algebra[measurable]: |
|
144 |
"a \<in> sets A \<Longrightarrow> (\<lambda>M. emeasure M a) \<in> borel_measurable (subprob_algebra A)" |
|
145 |
by (auto intro!: measurable_Sup_sigma1 measurable_vimage_algebra1 simp: subprob_algebra_def) |
|
146 |
||
59000 | 147 |
lemma subprob_measurableD: |
148 |
assumes N: "N \<in> measurable M (subprob_algebra S)" and x: "x \<in> space M" |
|
149 |
shows "space (N x) = space S" |
|
150 |
and "sets (N x) = sets S" |
|
151 |
and "measurable (N x) K = measurable S K" |
|
152 |
and "measurable K (N x) = measurable K S" |
|
153 |
using measurable_space[OF N x] |
|
154 |
by (auto simp: space_subprob_algebra intro!: measurable_cong_sets dest: sets_eq_imp_space_eq) |
|
155 |
||
59048 | 156 |
ML {* |
157 |
||
158 |
fun subprob_cong thm ctxt = ( |
|
159 |
let |
|
160 |
val thm' = Thm.transfer (Proof_Context.theory_of ctxt) thm |
|
161 |
val free = thm' |> concl_of |> HOLogic.dest_Trueprop |> dest_comb |> fst |> |
|
162 |
dest_comb |> snd |> strip_abs_body |> head_of |> is_Free |
|
163 |
in |
|
164 |
if free then ([], Measurable.add_local_cong (thm' RS @{thm subprob_measurableD(2)}) ctxt) |
|
165 |
else ([], ctxt) |
|
166 |
end |
|
167 |
handle THM _ => ([], ctxt) | TERM _ => ([], ctxt)) |
|
168 |
||
169 |
*} |
|
170 |
||
171 |
setup \<open> |
|
172 |
Context.theory_map (Measurable.add_preprocessor "subprob_cong" subprob_cong) |
|
173 |
\<close> |
|
174 |
||
58606 | 175 |
context |
176 |
fixes K M N assumes K: "K \<in> measurable M (subprob_algebra N)" |
|
177 |
begin |
|
178 |
||
179 |
lemma subprob_space_kernel: "a \<in> space M \<Longrightarrow> subprob_space (K a)" |
|
180 |
using measurable_space[OF K] by (simp add: space_subprob_algebra) |
|
181 |
||
182 |
lemma sets_kernel: "a \<in> space M \<Longrightarrow> sets (K a) = sets N" |
|
183 |
using measurable_space[OF K] by (simp add: space_subprob_algebra) |
|
184 |
||
185 |
lemma measurable_emeasure_kernel[measurable]: |
|
186 |
"A \<in> sets N \<Longrightarrow> (\<lambda>a. emeasure (K a) A) \<in> borel_measurable M" |
|
187 |
using measurable_compose[OF K measurable_emeasure_subprob_algebra] . |
|
188 |
||
189 |
end |
|
190 |
||
191 |
lemma measurable_subprob_algebra: |
|
192 |
"(\<And>a. a \<in> space M \<Longrightarrow> subprob_space (K a)) \<Longrightarrow> |
|
193 |
(\<And>a. a \<in> space M \<Longrightarrow> sets (K a) = sets N) \<Longrightarrow> |
|
194 |
(\<And>A. A \<in> sets N \<Longrightarrow> (\<lambda>a. emeasure (K a) A) \<in> borel_measurable M) \<Longrightarrow> |
|
195 |
K \<in> measurable M (subprob_algebra N)" |
|
196 |
by (auto intro!: measurable_Sup_sigma2 measurable_vimage_algebra2 simp: subprob_algebra_def) |
|
197 |
||
198 |
lemma space_subprob_algebra_empty_iff: |
|
199 |
"space (subprob_algebra N) = {} \<longleftrightarrow> space N = {}" |
|
200 |
proof |
|
201 |
have "\<And>x. x \<in> space N \<Longrightarrow> density N (\<lambda>_. 0) \<in> space (subprob_algebra N)" |
|
202 |
by (auto simp: space_subprob_algebra emeasure_density intro!: subprob_spaceI) |
|
203 |
then show "space (subprob_algebra N) = {} \<Longrightarrow> space N = {}" |
|
204 |
by auto |
|
205 |
next |
|
206 |
assume "space N = {}" |
|
207 |
hence "sets N = {{}}" by (simp add: space_empty_iff) |
|
208 |
moreover have "\<And>M. subprob_space M \<Longrightarrow> sets M \<noteq> {{}}" |
|
209 |
by (simp add: subprob_space.subprob_not_empty space_empty_iff[symmetric]) |
|
210 |
ultimately show "space (subprob_algebra N) = {}" by (auto simp: space_subprob_algebra) |
|
211 |
qed |
|
212 |
||
59048 | 213 |
lemma nn_integral_measurable_subprob_algebra': |
59000 | 214 |
assumes f: "f \<in> borel_measurable N" "\<And>x. 0 \<le> f x" |
215 |
shows "(\<lambda>M. integral\<^sup>N M f) \<in> borel_measurable (subprob_algebra N)" (is "_ \<in> ?B") |
|
216 |
using f |
|
217 |
proof induct |
|
218 |
case (cong f g) |
|
219 |
moreover have "(\<lambda>M'. \<integral>\<^sup>+M''. f M'' \<partial>M') \<in> ?B \<longleftrightarrow> (\<lambda>M'. \<integral>\<^sup>+M''. g M'' \<partial>M') \<in> ?B" |
|
220 |
by (intro measurable_cong nn_integral_cong cong) |
|
221 |
(auto simp: space_subprob_algebra dest!: sets_eq_imp_space_eq) |
|
222 |
ultimately show ?case by simp |
|
223 |
next |
|
224 |
case (set B) |
|
225 |
moreover then have "(\<lambda>M'. \<integral>\<^sup>+M''. indicator B M'' \<partial>M') \<in> ?B \<longleftrightarrow> (\<lambda>M'. emeasure M' B) \<in> ?B" |
|
226 |
by (intro measurable_cong nn_integral_indicator) (simp add: space_subprob_algebra) |
|
227 |
ultimately show ?case |
|
228 |
by (simp add: measurable_emeasure_subprob_algebra) |
|
229 |
next |
|
230 |
case (mult f c) |
|
231 |
moreover then have "(\<lambda>M'. \<integral>\<^sup>+M''. c * f M'' \<partial>M') \<in> ?B \<longleftrightarrow> (\<lambda>M'. c * \<integral>\<^sup>+M''. f M'' \<partial>M') \<in> ?B" |
|
59048 | 232 |
by (intro measurable_cong nn_integral_cmult) (auto simp add: space_subprob_algebra) |
59000 | 233 |
ultimately show ?case |
59048 | 234 |
using [[simp_trace_new]] |
59000 | 235 |
by simp |
236 |
next |
|
237 |
case (add f g) |
|
238 |
moreover then have "(\<lambda>M'. \<integral>\<^sup>+M''. f M'' + g M'' \<partial>M') \<in> ?B \<longleftrightarrow> (\<lambda>M'. (\<integral>\<^sup>+M''. f M'' \<partial>M') + (\<integral>\<^sup>+M''. g M'' \<partial>M')) \<in> ?B" |
|
59048 | 239 |
by (intro measurable_cong nn_integral_add) (auto simp add: space_subprob_algebra) |
59000 | 240 |
ultimately show ?case |
241 |
by (simp add: ac_simps) |
|
242 |
next |
|
243 |
case (seq F) |
|
244 |
moreover then have "(\<lambda>M'. \<integral>\<^sup>+M''. (SUP i. F i) M'' \<partial>M') \<in> ?B \<longleftrightarrow> (\<lambda>M'. SUP i. (\<integral>\<^sup>+M''. F i M'' \<partial>M')) \<in> ?B" |
|
245 |
unfolding SUP_apply |
|
59048 | 246 |
by (intro measurable_cong nn_integral_monotone_convergence_SUP) (auto simp add: space_subprob_algebra) |
59000 | 247 |
ultimately show ?case |
248 |
by (simp add: ac_simps) |
|
249 |
qed |
|
250 |
||
59048 | 251 |
lemma nn_integral_measurable_subprob_algebra: |
252 |
"f \<in> borel_measurable N \<Longrightarrow> (\<lambda>M. integral\<^sup>N M f) \<in> borel_measurable (subprob_algebra N)" |
|
253 |
by (subst nn_integral_max_0[symmetric]) |
|
254 |
(auto intro!: nn_integral_measurable_subprob_algebra') |
|
255 |
||
58606 | 256 |
lemma measurable_distr: |
257 |
assumes [measurable]: "f \<in> measurable M N" |
|
258 |
shows "(\<lambda>M'. distr M' N f) \<in> measurable (subprob_algebra M) (subprob_algebra N)" |
|
259 |
proof (cases "space N = {}") |
|
260 |
assume not_empty: "space N \<noteq> {}" |
|
261 |
show ?thesis |
|
262 |
proof (rule measurable_subprob_algebra) |
|
263 |
fix A assume A: "A \<in> sets N" |
|
264 |
then have "(\<lambda>M'. emeasure (distr M' N f) A) \<in> borel_measurable (subprob_algebra M) \<longleftrightarrow> |
|
265 |
(\<lambda>M'. emeasure M' (f -` A \<inter> space M)) \<in> borel_measurable (subprob_algebra M)" |
|
266 |
by (intro measurable_cong) |
|
59048 | 267 |
(auto simp: emeasure_distr space_subprob_algebra |
268 |
intro!: arg_cong2[where f=emeasure] sets_eq_imp_space_eq arg_cong2[where f="op \<inter>"]) |
|
58606 | 269 |
also have "\<dots>" |
270 |
using A by (intro measurable_emeasure_subprob_algebra) simp |
|
271 |
finally show "(\<lambda>M'. emeasure (distr M' N f) A) \<in> borel_measurable (subprob_algebra M)" . |
|
59048 | 272 |
qed (auto intro!: subprob_space.subprob_space_distr simp: space_subprob_algebra not_empty cong: measurable_cong_sets) |
58606 | 273 |
qed (insert assms, auto simp: measurable_empty_iff space_subprob_algebra_empty_iff) |
274 |
||
59000 | 275 |
lemma emeasure_space_subprob_algebra[measurable]: |
276 |
"(\<lambda>a. emeasure a (space a)) \<in> borel_measurable (subprob_algebra N)" |
|
277 |
proof- |
|
278 |
have "(\<lambda>a. emeasure a (space N)) \<in> borel_measurable (subprob_algebra N)" (is "?f \<in> ?M") |
|
279 |
by (rule measurable_emeasure_subprob_algebra) simp |
|
280 |
also have "?f \<in> ?M \<longleftrightarrow> (\<lambda>a. emeasure a (space a)) \<in> ?M" |
|
281 |
by (rule measurable_cong) (auto simp: space_subprob_algebra dest: sets_eq_imp_space_eq) |
|
282 |
finally show ?thesis . |
|
283 |
qed |
|
284 |
||
285 |
(* TODO: Rename. This name is too general – Manuel *) |
|
286 |
lemma measurable_pair_measure: |
|
287 |
assumes f: "f \<in> measurable M (subprob_algebra N)" |
|
288 |
assumes g: "g \<in> measurable M (subprob_algebra L)" |
|
289 |
shows "(\<lambda>x. f x \<Otimes>\<^sub>M g x) \<in> measurable M (subprob_algebra (N \<Otimes>\<^sub>M L))" |
|
290 |
proof (rule measurable_subprob_algebra) |
|
291 |
{ fix x assume "x \<in> space M" |
|
292 |
with measurable_space[OF f] measurable_space[OF g] |
|
293 |
have fx: "f x \<in> space (subprob_algebra N)" and gx: "g x \<in> space (subprob_algebra L)" |
|
294 |
by auto |
|
295 |
interpret F: subprob_space "f x" |
|
296 |
using fx by (simp add: space_subprob_algebra) |
|
297 |
interpret G: subprob_space "g x" |
|
298 |
using gx by (simp add: space_subprob_algebra) |
|
299 |
||
300 |
interpret pair_subprob_space "f x" "g x" .. |
|
301 |
show "subprob_space (f x \<Otimes>\<^sub>M g x)" by unfold_locales |
|
302 |
show sets_eq: "sets (f x \<Otimes>\<^sub>M g x) = sets (N \<Otimes>\<^sub>M L)" |
|
303 |
using fx gx by (simp add: space_subprob_algebra) |
|
304 |
||
305 |
have 1: "\<And>A B. A \<in> sets N \<Longrightarrow> B \<in> sets L \<Longrightarrow> emeasure (f x \<Otimes>\<^sub>M g x) (A \<times> B) = emeasure (f x) A * emeasure (g x) B" |
|
306 |
using fx gx by (intro G.emeasure_pair_measure_Times) (auto simp: space_subprob_algebra) |
|
307 |
have "emeasure (f x \<Otimes>\<^sub>M g x) (space (f x \<Otimes>\<^sub>M g x)) = |
|
308 |
emeasure (f x) (space (f x)) * emeasure (g x) (space (g x))" |
|
309 |
by (subst G.emeasure_pair_measure_Times[symmetric]) (simp_all add: space_pair_measure) |
|
310 |
hence 2: "\<And>A. A \<in> sets (N \<Otimes>\<^sub>M L) \<Longrightarrow> emeasure (f x \<Otimes>\<^sub>M g x) (space N \<times> space L - A) = |
|
311 |
... - emeasure (f x \<Otimes>\<^sub>M g x) A" |
|
312 |
using emeasure_compl[OF _ P.emeasure_finite] |
|
313 |
unfolding sets_eq |
|
314 |
unfolding sets_eq_imp_space_eq[OF sets_eq] |
|
315 |
by (simp add: space_pair_measure G.emeasure_pair_measure_Times) |
|
316 |
note 1 2 sets_eq } |
|
317 |
note Times = this(1) and Compl = this(2) and sets_eq = this(3) |
|
318 |
||
319 |
fix A assume A: "A \<in> sets (N \<Otimes>\<^sub>M L)" |
|
320 |
show "(\<lambda>a. emeasure (f a \<Otimes>\<^sub>M g a) A) \<in> borel_measurable M" |
|
321 |
using Int_stable_pair_measure_generator pair_measure_closed A |
|
322 |
unfolding sets_pair_measure |
|
323 |
proof (induct A rule: sigma_sets_induct_disjoint) |
|
324 |
case (basic A) then show ?case |
|
325 |
by (auto intro!: borel_measurable_ereal_times simp: Times cong: measurable_cong) |
|
326 |
(auto intro!: measurable_emeasure_kernel f g) |
|
327 |
next |
|
328 |
case (compl A) |
|
329 |
then have A: "A \<in> sets (N \<Otimes>\<^sub>M L)" |
|
330 |
by (auto simp: sets_pair_measure) |
|
331 |
have "(\<lambda>x. emeasure (f x) (space (f x)) * emeasure (g x) (space (g x)) - |
|
332 |
emeasure (f x \<Otimes>\<^sub>M g x) A) \<in> borel_measurable M" (is "?f \<in> ?M") |
|
333 |
using compl(2) f g by measurable |
|
334 |
thus ?case by (simp add: Compl A cong: measurable_cong) |
|
335 |
next |
|
336 |
case (union A) |
|
337 |
then have "range A \<subseteq> sets (N \<Otimes>\<^sub>M L)" "disjoint_family A" |
|
338 |
by (auto simp: sets_pair_measure) |
|
339 |
then have "(\<lambda>a. emeasure (f a \<Otimes>\<^sub>M g a) (\<Union>i. A i)) \<in> borel_measurable M \<longleftrightarrow> |
|
340 |
(\<lambda>a. \<Sum>i. emeasure (f a \<Otimes>\<^sub>M g a) (A i)) \<in> borel_measurable M" |
|
341 |
by (intro measurable_cong suminf_emeasure[symmetric]) |
|
342 |
(auto simp: sets_eq) |
|
343 |
also have "\<dots>" |
|
344 |
using union by auto |
|
345 |
finally show ?case . |
|
346 |
qed simp |
|
347 |
qed |
|
348 |
||
349 |
lemma restrict_space_measurable: |
|
350 |
assumes X: "X \<noteq> {}" "X \<in> sets K" |
|
351 |
assumes N: "N \<in> measurable M (subprob_algebra K)" |
|
352 |
shows "(\<lambda>x. restrict_space (N x) X) \<in> measurable M (subprob_algebra (restrict_space K X))" |
|
353 |
proof (rule measurable_subprob_algebra) |
|
354 |
fix a assume a: "a \<in> space M" |
|
355 |
from N[THEN measurable_space, OF this] |
|
356 |
have "subprob_space (N a)" and [simp]: "sets (N a) = sets K" "space (N a) = space K" |
|
357 |
by (auto simp add: space_subprob_algebra dest: sets_eq_imp_space_eq) |
|
358 |
then interpret subprob_space "N a" |
|
359 |
by simp |
|
360 |
show "subprob_space (restrict_space (N a) X)" |
|
361 |
proof |
|
362 |
show "space (restrict_space (N a) X) \<noteq> {}" |
|
363 |
using X by (auto simp add: space_restrict_space) |
|
364 |
show "emeasure (restrict_space (N a) X) (space (restrict_space (N a) X)) \<le> 1" |
|
365 |
using X by (simp add: emeasure_restrict_space space_restrict_space subprob_emeasure_le_1) |
|
366 |
qed |
|
367 |
show "sets (restrict_space (N a) X) = sets (restrict_space K X)" |
|
368 |
by (intro sets_restrict_space_cong) fact |
|
369 |
next |
|
370 |
fix A assume A: "A \<in> sets (restrict_space K X)" |
|
371 |
show "(\<lambda>a. emeasure (restrict_space (N a) X) A) \<in> borel_measurable M" |
|
372 |
proof (subst measurable_cong) |
|
373 |
fix a assume "a \<in> space M" |
|
374 |
from N[THEN measurable_space, OF this] |
|
375 |
have [simp]: "sets (N a) = sets K" "space (N a) = space K" |
|
376 |
by (auto simp add: space_subprob_algebra dest: sets_eq_imp_space_eq) |
|
377 |
show "emeasure (restrict_space (N a) X) A = emeasure (N a) (A \<inter> X)" |
|
378 |
using X A by (subst emeasure_restrict_space) (auto simp add: sets_restrict_space ac_simps) |
|
379 |
next |
|
380 |
show "(\<lambda>w. emeasure (N w) (A \<inter> X)) \<in> borel_measurable M" |
|
381 |
using A X |
|
382 |
by (intro measurable_compose[OF N measurable_emeasure_subprob_algebra]) |
|
383 |
(auto simp: sets_restrict_space) |
|
384 |
qed |
|
385 |
qed |
|
386 |
||
58606 | 387 |
section {* Properties of return *} |
388 |
||
389 |
definition return :: "'a measure \<Rightarrow> 'a \<Rightarrow> 'a measure" where |
|
390 |
"return R x = measure_of (space R) (sets R) (\<lambda>A. indicator A x)" |
|
391 |
||
392 |
lemma space_return[simp]: "space (return M x) = space M" |
|
393 |
by (simp add: return_def) |
|
394 |
||
395 |
lemma sets_return[simp]: "sets (return M x) = sets M" |
|
396 |
by (simp add: return_def) |
|
397 |
||
398 |
lemma measurable_return1[simp]: "measurable (return N x) L = measurable N L" |
|
399 |
by (simp cong: measurable_cong_sets) |
|
400 |
||
401 |
lemma measurable_return2[simp]: "measurable L (return N x) = measurable L N" |
|
402 |
by (simp cong: measurable_cong_sets) |
|
403 |
||
59000 | 404 |
lemma return_sets_cong: "sets M = sets N \<Longrightarrow> return M = return N" |
405 |
by (auto dest: sets_eq_imp_space_eq simp: fun_eq_iff return_def) |
|
406 |
||
407 |
lemma return_cong: "sets A = sets B \<Longrightarrow> return A x = return B x" |
|
408 |
by (auto simp add: return_def dest: sets_eq_imp_space_eq) |
|
409 |
||
58606 | 410 |
lemma emeasure_return[simp]: |
411 |
assumes "A \<in> sets M" |
|
412 |
shows "emeasure (return M x) A = indicator A x" |
|
413 |
proof (rule emeasure_measure_of[OF return_def]) |
|
414 |
show "sets M \<subseteq> Pow (space M)" by (rule sets.space_closed) |
|
415 |
show "positive (sets (return M x)) (\<lambda>A. indicator A x)" by (simp add: positive_def) |
|
416 |
from assms show "A \<in> sets (return M x)" unfolding return_def by simp |
|
417 |
show "countably_additive (sets (return M x)) (\<lambda>A. indicator A x)" |
|
418 |
by (auto intro: countably_additiveI simp: suminf_indicator) |
|
419 |
qed |
|
420 |
||
421 |
lemma prob_space_return: "x \<in> space M \<Longrightarrow> prob_space (return M x)" |
|
422 |
by rule simp |
|
423 |
||
424 |
lemma subprob_space_return: "x \<in> space M \<Longrightarrow> subprob_space (return M x)" |
|
425 |
by (intro prob_space_return prob_space_imp_subprob_space) |
|
426 |
||
59000 | 427 |
lemma subprob_space_return_ne: |
428 |
assumes "space M \<noteq> {}" shows "subprob_space (return M x)" |
|
429 |
proof |
|
430 |
show "emeasure (return M x) (space (return M x)) \<le> 1" |
|
431 |
by (subst emeasure_return) (auto split: split_indicator) |
|
432 |
qed (simp, fact) |
|
433 |
||
434 |
lemma measure_return: assumes X: "X \<in> sets M" shows "measure (return M x) X = indicator X x" |
|
435 |
unfolding measure_def emeasure_return[OF X, of x] by (simp split: split_indicator) |
|
436 |
||
58606 | 437 |
lemma AE_return: |
438 |
assumes [simp]: "x \<in> space M" and [measurable]: "Measurable.pred M P" |
|
439 |
shows "(AE y in return M x. P y) \<longleftrightarrow> P x" |
|
440 |
proof - |
|
441 |
have "(AE y in return M x. y \<notin> {x\<in>space M. \<not> P x}) \<longleftrightarrow> P x" |
|
442 |
by (subst AE_iff_null_sets[symmetric]) (simp_all add: null_sets_def split: split_indicator) |
|
443 |
also have "(AE y in return M x. y \<notin> {x\<in>space M. \<not> P x}) \<longleftrightarrow> (AE y in return M x. P y)" |
|
444 |
by (rule AE_cong) auto |
|
445 |
finally show ?thesis . |
|
446 |
qed |
|
447 |
||
448 |
lemma nn_integral_return: |
|
449 |
assumes "g x \<ge> 0" "x \<in> space M" "g \<in> borel_measurable M" |
|
450 |
shows "(\<integral>\<^sup>+ a. g a \<partial>return M x) = g x" |
|
451 |
proof- |
|
452 |
interpret prob_space "return M x" by (rule prob_space_return[OF `x \<in> space M`]) |
|
453 |
have "(\<integral>\<^sup>+ a. g a \<partial>return M x) = (\<integral>\<^sup>+ a. g x \<partial>return M x)" using assms |
|
454 |
by (intro nn_integral_cong_AE) (auto simp: AE_return) |
|
455 |
also have "... = g x" |
|
456 |
using nn_integral_const[OF `g x \<ge> 0`, of "return M x"] emeasure_space_1 by simp |
|
457 |
finally show ?thesis . |
|
458 |
qed |
|
459 |
||
59000 | 460 |
lemma integral_return: |
461 |
fixes g :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}" |
|
462 |
assumes "x \<in> space M" "g \<in> borel_measurable M" |
|
463 |
shows "(\<integral>a. g a \<partial>return M x) = g x" |
|
464 |
proof- |
|
465 |
interpret prob_space "return M x" by (rule prob_space_return[OF `x \<in> space M`]) |
|
466 |
have "(\<integral>a. g a \<partial>return M x) = (\<integral>a. g x \<partial>return M x)" using assms |
|
467 |
by (intro integral_cong_AE) (auto simp: AE_return) |
|
468 |
then show ?thesis |
|
469 |
using prob_space by simp |
|
470 |
qed |
|
471 |
||
472 |
lemma return_measurable[measurable]: "return N \<in> measurable N (subprob_algebra N)" |
|
58606 | 473 |
by (rule measurable_subprob_algebra) (auto simp: subprob_space_return) |
474 |
||
475 |
lemma distr_return: |
|
476 |
assumes "f \<in> measurable M N" and "x \<in> space M" |
|
477 |
shows "distr (return M x) N f = return N (f x)" |
|
478 |
using assms by (intro measure_eqI) (simp_all add: indicator_def emeasure_distr) |
|
479 |
||
59000 | 480 |
lemma return_restrict_space: |
481 |
"\<Omega> \<in> sets M \<Longrightarrow> return (restrict_space M \<Omega>) x = restrict_space (return M x) \<Omega>" |
|
482 |
by (auto intro!: measure_eqI simp: sets_restrict_space emeasure_restrict_space) |
|
483 |
||
484 |
lemma measurable_distr2: |
|
485 |
assumes f[measurable]: "split f \<in> measurable (L \<Otimes>\<^sub>M M) N" |
|
486 |
assumes g[measurable]: "g \<in> measurable L (subprob_algebra M)" |
|
487 |
shows "(\<lambda>x. distr (g x) N (f x)) \<in> measurable L (subprob_algebra N)" |
|
488 |
proof - |
|
489 |
have "(\<lambda>x. distr (g x) N (f x)) \<in> measurable L (subprob_algebra N) |
|
490 |
\<longleftrightarrow> (\<lambda>x. distr (return L x \<Otimes>\<^sub>M g x) N (split f)) \<in> measurable L (subprob_algebra N)" |
|
491 |
proof (rule measurable_cong) |
|
492 |
fix x assume x: "x \<in> space L" |
|
493 |
have gx: "g x \<in> space (subprob_algebra M)" |
|
494 |
using measurable_space[OF g x] . |
|
495 |
then have [simp]: "sets (g x) = sets M" |
|
496 |
by (simp add: space_subprob_algebra) |
|
497 |
then have [simp]: "space (g x) = space M" |
|
498 |
by (rule sets_eq_imp_space_eq) |
|
499 |
let ?R = "return L x" |
|
500 |
from measurable_compose_Pair1[OF x f] have f_M': "f x \<in> measurable M N" |
|
501 |
by simp |
|
502 |
interpret subprob_space "g x" |
|
503 |
using gx by (simp add: space_subprob_algebra) |
|
504 |
have space_pair_M'[simp]: "\<And>X. space (X \<Otimes>\<^sub>M g x) = space (X \<Otimes>\<^sub>M M)" |
|
505 |
by (simp add: space_pair_measure) |
|
506 |
show "distr (g x) N (f x) = distr (?R \<Otimes>\<^sub>M g x) N (split f)" (is "?l = ?r") |
|
507 |
proof (rule measure_eqI) |
|
508 |
show "sets ?l = sets ?r" |
|
509 |
by simp |
|
510 |
next |
|
511 |
fix A assume "A \<in> sets ?l" |
|
512 |
then have A[measurable]: "A \<in> sets N" |
|
513 |
by simp |
|
514 |
then have "emeasure ?r A = emeasure (?R \<Otimes>\<^sub>M g x) ((\<lambda>(x, y). f x y) -` A \<inter> space (?R \<Otimes>\<^sub>M g x))" |
|
515 |
by (auto simp add: emeasure_distr f_M' cong: measurable_cong_sets) |
|
516 |
also have "\<dots> = (\<integral>\<^sup>+M''. emeasure (g x) (f M'' -` A \<inter> space M) \<partial>?R)" |
|
517 |
apply (subst emeasure_pair_measure_alt) |
|
518 |
apply (rule measurable_sets[OF _ A]) |
|
519 |
apply (auto simp add: f_M' cong: measurable_cong_sets) |
|
520 |
apply (intro nn_integral_cong arg_cong[where f="emeasure (g x)"]) |
|
521 |
apply (auto simp: space_subprob_algebra space_pair_measure) |
|
522 |
done |
|
523 |
also have "\<dots> = emeasure (g x) (f x -` A \<inter> space M)" |
|
524 |
by (subst nn_integral_return) |
|
525 |
(auto simp: x intro!: measurable_emeasure) |
|
526 |
also have "\<dots> = emeasure ?l A" |
|
527 |
by (simp add: emeasure_distr f_M' cong: measurable_cong_sets) |
|
528 |
finally show "emeasure ?l A = emeasure ?r A" .. |
|
529 |
qed |
|
530 |
qed |
|
531 |
also have "\<dots>" |
|
532 |
apply (intro measurable_compose[OF measurable_pair_measure measurable_distr]) |
|
533 |
apply (rule return_measurable) |
|
534 |
apply measurable |
|
535 |
done |
|
536 |
finally show ?thesis . |
|
537 |
qed |
|
538 |
||
539 |
lemma nn_integral_measurable_subprob_algebra2: |
|
59048 | 540 |
assumes f[measurable]: "(\<lambda>(x, y). f x y) \<in> borel_measurable (M \<Otimes>\<^sub>M N)" |
59000 | 541 |
assumes N[measurable]: "L \<in> measurable M (subprob_algebra N)" |
542 |
shows "(\<lambda>x. integral\<^sup>N (L x) (f x)) \<in> borel_measurable M" |
|
543 |
proof - |
|
59048 | 544 |
note nn_integral_measurable_subprob_algebra[measurable] |
545 |
note measurable_distr2[measurable] |
|
59000 | 546 |
have "(\<lambda>x. integral\<^sup>N (distr (L x) (M \<Otimes>\<^sub>M N) (\<lambda>y. (x, y))) (\<lambda>(x, y). f x y)) \<in> borel_measurable M" |
59048 | 547 |
by measurable |
59000 | 548 |
then show "(\<lambda>x. integral\<^sup>N (L x) (f x)) \<in> borel_measurable M" |
59048 | 549 |
by (rule measurable_cong[THEN iffD1, rotated]) |
550 |
(simp add: nn_integral_distr) |
|
59000 | 551 |
qed |
552 |
||
553 |
lemma emeasure_measurable_subprob_algebra2: |
|
554 |
assumes A[measurable]: "(SIGMA x:space M. A x) \<in> sets (M \<Otimes>\<^sub>M N)" |
|
555 |
assumes L[measurable]: "L \<in> measurable M (subprob_algebra N)" |
|
556 |
shows "(\<lambda>x. emeasure (L x) (A x)) \<in> borel_measurable M" |
|
557 |
proof - |
|
558 |
{ fix x assume "x \<in> space M" |
|
559 |
then have "Pair x -` Sigma (space M) A = A x" |
|
560 |
by auto |
|
561 |
with sets_Pair1[OF A, of x] have "A x \<in> sets N" |
|
562 |
by auto } |
|
563 |
note ** = this |
|
564 |
||
565 |
have *: "\<And>x. fst x \<in> space M \<Longrightarrow> snd x \<in> A (fst x) \<longleftrightarrow> x \<in> (SIGMA x:space M. A x)" |
|
566 |
by (auto simp: fun_eq_iff) |
|
567 |
have "(\<lambda>(x, y). indicator (A x) y::ereal) \<in> borel_measurable (M \<Otimes>\<^sub>M N)" |
|
568 |
apply measurable |
|
569 |
apply (subst measurable_cong) |
|
570 |
apply (rule *) |
|
571 |
apply (auto simp: space_pair_measure) |
|
572 |
done |
|
573 |
then have "(\<lambda>x. integral\<^sup>N (L x) (indicator (A x))) \<in> borel_measurable M" |
|
574 |
by (intro nn_integral_measurable_subprob_algebra2[where N=N] ereal_indicator_nonneg L) |
|
575 |
then show "(\<lambda>x. emeasure (L x) (A x)) \<in> borel_measurable M" |
|
576 |
apply (rule measurable_cong[THEN iffD1, rotated]) |
|
577 |
apply (rule nn_integral_indicator) |
|
578 |
apply (simp add: subprob_measurableD[OF L] **) |
|
579 |
done |
|
580 |
qed |
|
581 |
||
582 |
lemma measure_measurable_subprob_algebra2: |
|
583 |
assumes A[measurable]: "(SIGMA x:space M. A x) \<in> sets (M \<Otimes>\<^sub>M N)" |
|
584 |
assumes L[measurable]: "L \<in> measurable M (subprob_algebra N)" |
|
585 |
shows "(\<lambda>x. measure (L x) (A x)) \<in> borel_measurable M" |
|
586 |
unfolding measure_def |
|
587 |
by (intro borel_measurable_real_of_ereal emeasure_measurable_subprob_algebra2[OF assms]) |
|
588 |
||
58606 | 589 |
definition "select_sets M = (SOME N. sets M = sets (subprob_algebra N))" |
590 |
||
591 |
lemma select_sets1: |
|
592 |
"sets M = sets (subprob_algebra N) \<Longrightarrow> sets M = sets (subprob_algebra (select_sets M))" |
|
593 |
unfolding select_sets_def by (rule someI) |
|
594 |
||
595 |
lemma sets_select_sets[simp]: |
|
596 |
assumes sets: "sets M = sets (subprob_algebra N)" |
|
597 |
shows "sets (select_sets M) = sets N" |
|
598 |
unfolding select_sets_def |
|
599 |
proof (rule someI2) |
|
600 |
show "sets M = sets (subprob_algebra N)" |
|
601 |
by fact |
|
602 |
next |
|
603 |
fix L assume "sets M = sets (subprob_algebra L)" |
|
604 |
with sets have eq: "space (subprob_algebra N) = space (subprob_algebra L)" |
|
605 |
by (intro sets_eq_imp_space_eq) simp |
|
606 |
show "sets L = sets N" |
|
607 |
proof cases |
|
608 |
assume "space (subprob_algebra N) = {}" |
|
609 |
with space_subprob_algebra_empty_iff[of N] space_subprob_algebra_empty_iff[of L] |
|
610 |
show ?thesis |
|
611 |
by (simp add: eq space_empty_iff) |
|
612 |
next |
|
613 |
assume "space (subprob_algebra N) \<noteq> {}" |
|
614 |
with eq show ?thesis |
|
615 |
by (fastforce simp add: space_subprob_algebra) |
|
616 |
qed |
|
617 |
qed |
|
618 |
||
619 |
lemma space_select_sets[simp]: |
|
620 |
"sets M = sets (subprob_algebra N) \<Longrightarrow> space (select_sets M) = space N" |
|
621 |
by (intro sets_eq_imp_space_eq sets_select_sets) |
|
622 |
||
623 |
section {* Join *} |
|
624 |
||
625 |
definition join :: "'a measure measure \<Rightarrow> 'a measure" where |
|
626 |
"join M = measure_of (space (select_sets M)) (sets (select_sets M)) (\<lambda>B. \<integral>\<^sup>+ M'. emeasure M' B \<partial>M)" |
|
627 |
||
628 |
lemma |
|
629 |
shows space_join[simp]: "space (join M) = space (select_sets M)" |
|
630 |
and sets_join[simp]: "sets (join M) = sets (select_sets M)" |
|
631 |
by (simp_all add: join_def) |
|
632 |
||
633 |
lemma emeasure_join: |
|
59048 | 634 |
assumes M[simp, measurable_cong]: "sets M = sets (subprob_algebra N)" and A: "A \<in> sets N" |
58606 | 635 |
shows "emeasure (join M) A = (\<integral>\<^sup>+ M'. emeasure M' A \<partial>M)" |
636 |
proof (rule emeasure_measure_of[OF join_def]) |
|
637 |
show "countably_additive (sets (join M)) (\<lambda>B. \<integral>\<^sup>+ M'. emeasure M' B \<partial>M)" |
|
638 |
proof (rule countably_additiveI) |
|
639 |
fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets (join M)" "disjoint_family A" |
|
640 |
have "(\<Sum>i. \<integral>\<^sup>+ M'. emeasure M' (A i) \<partial>M) = (\<integral>\<^sup>+M'. (\<Sum>i. emeasure M' (A i)) \<partial>M)" |
|
59048 | 641 |
using A by (subst nn_integral_suminf) (auto simp: measurable_emeasure_subprob_algebra) |
58606 | 642 |
also have "\<dots> = (\<integral>\<^sup>+M'. emeasure M' (\<Union>i. A i) \<partial>M)" |
643 |
proof (rule nn_integral_cong) |
|
644 |
fix M' assume "M' \<in> space M" |
|
645 |
then show "(\<Sum>i. emeasure M' (A i)) = emeasure M' (\<Union>i. A i)" |
|
646 |
using A sets_eq_imp_space_eq[OF M] by (simp add: suminf_emeasure space_subprob_algebra) |
|
647 |
qed |
|
648 |
finally show "(\<Sum>i. \<integral>\<^sup>+M'. emeasure M' (A i) \<partial>M) = (\<integral>\<^sup>+M'. emeasure M' (\<Union>i. A i) \<partial>M)" . |
|
649 |
qed |
|
650 |
qed (auto simp: A sets.space_closed positive_def nn_integral_nonneg) |
|
651 |
||
652 |
lemma measurable_join: |
|
653 |
"join \<in> measurable (subprob_algebra (subprob_algebra N)) (subprob_algebra N)" |
|
654 |
proof (cases "space N \<noteq> {}", rule measurable_subprob_algebra) |
|
655 |
fix A assume "A \<in> sets N" |
|
656 |
let ?B = "borel_measurable (subprob_algebra (subprob_algebra N))" |
|
657 |
have "(\<lambda>M'. emeasure (join M') A) \<in> ?B \<longleftrightarrow> (\<lambda>M'. (\<integral>\<^sup>+ M''. emeasure M'' A \<partial>M')) \<in> ?B" |
|
658 |
proof (rule measurable_cong) |
|
659 |
fix M' assume "M' \<in> space (subprob_algebra (subprob_algebra N))" |
|
660 |
then show "emeasure (join M') A = (\<integral>\<^sup>+ M''. emeasure M'' A \<partial>M')" |
|
661 |
by (intro emeasure_join) (auto simp: space_subprob_algebra `A\<in>sets N`) |
|
662 |
qed |
|
663 |
also have "(\<lambda>M'. \<integral>\<^sup>+M''. emeasure M'' A \<partial>M') \<in> ?B" |
|
59048 | 664 |
using measurable_emeasure_subprob_algebra[OF `A\<in>sets N`] |
58606 | 665 |
by (rule nn_integral_measurable_subprob_algebra) |
666 |
finally show "(\<lambda>M'. emeasure (join M') A) \<in> borel_measurable (subprob_algebra (subprob_algebra N))" . |
|
667 |
next |
|
668 |
assume [simp]: "space N \<noteq> {}" |
|
669 |
fix M assume M: "M \<in> space (subprob_algebra (subprob_algebra N))" |
|
670 |
then have "(\<integral>\<^sup>+M'. emeasure M' (space N) \<partial>M) \<le> (\<integral>\<^sup>+M'. 1 \<partial>M)" |
|
671 |
apply (intro nn_integral_mono) |
|
672 |
apply (auto simp: space_subprob_algebra |
|
673 |
dest!: sets_eq_imp_space_eq subprob_space.emeasure_space_le_1) |
|
674 |
done |
|
675 |
with M show "subprob_space (join M)" |
|
676 |
by (intro subprob_spaceI) |
|
677 |
(auto simp: emeasure_join space_subprob_algebra M assms dest: subprob_space.emeasure_space_le_1) |
|
678 |
next |
|
679 |
assume "\<not>(space N \<noteq> {})" |
|
680 |
thus ?thesis by (simp add: measurable_empty_iff space_subprob_algebra_empty_iff) |
|
681 |
qed (auto simp: space_subprob_algebra) |
|
682 |
||
59048 | 683 |
lemma nn_integral_join': |
684 |
assumes f: "f \<in> borel_measurable N" "\<And>x. 0 \<le> f x" |
|
685 |
and M[measurable_cong]: "sets M = sets (subprob_algebra N)" |
|
58606 | 686 |
shows "(\<integral>\<^sup>+x. f x \<partial>join M) = (\<integral>\<^sup>+M'. \<integral>\<^sup>+x. f x \<partial>M' \<partial>M)" |
687 |
using f |
|
688 |
proof induct |
|
689 |
case (cong f g) |
|
690 |
moreover have "integral\<^sup>N (join M) f = integral\<^sup>N (join M) g" |
|
691 |
by (intro nn_integral_cong cong) (simp add: M) |
|
692 |
moreover from M have "(\<integral>\<^sup>+ M'. integral\<^sup>N M' f \<partial>M) = (\<integral>\<^sup>+ M'. integral\<^sup>N M' g \<partial>M)" |
|
693 |
by (intro nn_integral_cong cong) |
|
694 |
(auto simp add: space_subprob_algebra dest!: sets_eq_imp_space_eq) |
|
695 |
ultimately show ?case |
|
696 |
by simp |
|
697 |
next |
|
698 |
case (set A) |
|
699 |
moreover with M have "(\<integral>\<^sup>+ M'. integral\<^sup>N M' (indicator A) \<partial>M) = (\<integral>\<^sup>+ M'. emeasure M' A \<partial>M)" |
|
700 |
by (intro nn_integral_cong nn_integral_indicator) |
|
701 |
(auto simp: space_subprob_algebra dest!: sets_eq_imp_space_eq) |
|
702 |
ultimately show ?case |
|
703 |
using M by (simp add: emeasure_join) |
|
704 |
next |
|
705 |
case (mult f c) |
|
706 |
have "(\<integral>\<^sup>+ M'. \<integral>\<^sup>+ x. c * f x \<partial>M' \<partial>M) = (\<integral>\<^sup>+ M'. c * \<integral>\<^sup>+ x. f x \<partial>M' \<partial>M)" |
|
59048 | 707 |
using mult M M[THEN sets_eq_imp_space_eq] |
708 |
by (intro nn_integral_cong nn_integral_cmult) (auto simp add: space_subprob_algebra) |
|
58606 | 709 |
also have "\<dots> = c * (\<integral>\<^sup>+ M'. \<integral>\<^sup>+ x. f x \<partial>M' \<partial>M)" |
59048 | 710 |
using nn_integral_measurable_subprob_algebra[OF mult(3)] |
58606 | 711 |
by (intro nn_integral_cmult mult) (simp add: M) |
712 |
also have "\<dots> = c * (integral\<^sup>N (join M) f)" |
|
713 |
by (simp add: mult) |
|
714 |
also have "\<dots> = (\<integral>\<^sup>+ x. c * f x \<partial>join M)" |
|
59048 | 715 |
using mult(2,3) by (intro nn_integral_cmult[symmetric] mult) (simp add: M cong: measurable_cong_sets) |
58606 | 716 |
finally show ?case by simp |
717 |
next |
|
718 |
case (add f g) |
|
719 |
have "(\<integral>\<^sup>+ M'. \<integral>\<^sup>+ x. f x + g x \<partial>M' \<partial>M) = (\<integral>\<^sup>+ M'. (\<integral>\<^sup>+ x. f x \<partial>M') + (\<integral>\<^sup>+ x. g x \<partial>M') \<partial>M)" |
|
59048 | 720 |
using add M M[THEN sets_eq_imp_space_eq] |
721 |
by (intro nn_integral_cong nn_integral_add) (auto simp add: space_subprob_algebra) |
|
58606 | 722 |
also have "\<dots> = (\<integral>\<^sup>+ M'. \<integral>\<^sup>+ x. f x \<partial>M' \<partial>M) + (\<integral>\<^sup>+ M'. \<integral>\<^sup>+ x. g x \<partial>M' \<partial>M)" |
59048 | 723 |
using nn_integral_measurable_subprob_algebra[OF add(1)] |
724 |
using nn_integral_measurable_subprob_algebra[OF add(5)] |
|
58606 | 725 |
by (intro nn_integral_add add) (simp_all add: M nn_integral_nonneg) |
726 |
also have "\<dots> = (integral\<^sup>N (join M) f) + (integral\<^sup>N (join M) g)" |
|
727 |
by (simp add: add) |
|
728 |
also have "\<dots> = (\<integral>\<^sup>+ x. f x + g x \<partial>join M)" |
|
59048 | 729 |
using add by (intro nn_integral_add[symmetric] add) (simp_all add: M cong: measurable_cong_sets) |
58606 | 730 |
finally show ?case by (simp add: ac_simps) |
731 |
next |
|
732 |
case (seq F) |
|
733 |
have "(\<integral>\<^sup>+ M'. \<integral>\<^sup>+ x. (SUP i. F i) x \<partial>M' \<partial>M) = (\<integral>\<^sup>+ M'. (SUP i. \<integral>\<^sup>+ x. F i x \<partial>M') \<partial>M)" |
|
59048 | 734 |
using seq M M[THEN sets_eq_imp_space_eq] unfolding SUP_apply |
58606 | 735 |
by (intro nn_integral_cong nn_integral_monotone_convergence_SUP) |
59048 | 736 |
(auto simp add: space_subprob_algebra) |
58606 | 737 |
also have "\<dots> = (SUP i. \<integral>\<^sup>+ M'. \<integral>\<^sup>+ x. F i x \<partial>M' \<partial>M)" |
59048 | 738 |
using nn_integral_measurable_subprob_algebra[OF seq(1)] seq |
58606 | 739 |
by (intro nn_integral_monotone_convergence_SUP) |
740 |
(simp_all add: M nn_integral_nonneg incseq_nn_integral incseq_def le_fun_def nn_integral_mono ) |
|
741 |
also have "\<dots> = (SUP i. integral\<^sup>N (join M) (F i))" |
|
742 |
by (simp add: seq) |
|
743 |
also have "\<dots> = (\<integral>\<^sup>+ x. (SUP i. F i x) \<partial>join M)" |
|
59048 | 744 |
using seq by (intro nn_integral_monotone_convergence_SUP[symmetric] seq) |
745 |
(simp_all add: M cong: measurable_cong_sets) |
|
58606 | 746 |
finally show ?case by (simp add: ac_simps) |
747 |
qed |
|
748 |
||
59048 | 749 |
lemma nn_integral_join: |
750 |
assumes f[measurable]: "f \<in> borel_measurable N" "sets M = sets (subprob_algebra N)" |
|
751 |
shows "(\<integral>\<^sup>+x. f x \<partial>join M) = (\<integral>\<^sup>+M'. \<integral>\<^sup>+x. f x \<partial>M' \<partial>M)" |
|
752 |
apply (subst (1 3) nn_integral_max_0[symmetric]) |
|
753 |
apply (rule nn_integral_join') |
|
754 |
apply (auto simp: f) |
|
755 |
done |
|
756 |
||
58606 | 757 |
lemma join_assoc: |
59048 | 758 |
assumes M[measurable_cong]: "sets M = sets (subprob_algebra (subprob_algebra N))" |
58606 | 759 |
shows "join (distr M (subprob_algebra N) join) = join (join M)" |
760 |
proof (rule measure_eqI) |
|
761 |
fix A assume "A \<in> sets (join (distr M (subprob_algebra N) join))" |
|
762 |
then have A: "A \<in> sets N" by simp |
|
763 |
show "emeasure (join (distr M (subprob_algebra N) join)) A = emeasure (join (join M)) A" |
|
764 |
using measurable_join[of N] |
|
765 |
by (auto simp: M A nn_integral_distr emeasure_join measurable_emeasure_subprob_algebra emeasure_nonneg |
|
59048 | 766 |
sets_eq_imp_space_eq[OF M] space_subprob_algebra nn_integral_join[OF _ M] |
767 |
intro!: nn_integral_cong emeasure_join) |
|
58606 | 768 |
qed (simp add: M) |
769 |
||
770 |
lemma join_return: |
|
771 |
assumes "sets M = sets N" and "subprob_space M" |
|
772 |
shows "join (return (subprob_algebra N) M) = M" |
|
773 |
by (rule measure_eqI) |
|
774 |
(simp_all add: emeasure_join emeasure_nonneg space_subprob_algebra |
|
775 |
measurable_emeasure_subprob_algebra nn_integral_return assms) |
|
776 |
||
777 |
lemma join_return': |
|
778 |
assumes "sets N = sets M" |
|
779 |
shows "join (distr M (subprob_algebra N) (return N)) = M" |
|
780 |
apply (rule measure_eqI) |
|
781 |
apply (simp add: assms) |
|
782 |
apply (subgoal_tac "return N \<in> measurable M (subprob_algebra N)") |
|
783 |
apply (simp add: emeasure_join nn_integral_distr measurable_emeasure_subprob_algebra assms) |
|
784 |
apply (subst measurable_cong_sets, rule assms[symmetric], rule refl, rule return_measurable) |
|
785 |
done |
|
786 |
||
787 |
lemma join_distr_distr: |
|
788 |
fixes f :: "'a \<Rightarrow> 'b" and M :: "'a measure measure" and N :: "'b measure" |
|
789 |
assumes "sets M = sets (subprob_algebra R)" and "f \<in> measurable R N" |
|
790 |
shows "join (distr M (subprob_algebra N) (\<lambda>M. distr M N f)) = distr (join M) N f" (is "?r = ?l") |
|
791 |
proof (rule measure_eqI) |
|
792 |
fix A assume "A \<in> sets ?r" |
|
793 |
hence A_in_N: "A \<in> sets N" by simp |
|
794 |
||
795 |
from assms have "f \<in> measurable (join M) N" |
|
796 |
by (simp cong: measurable_cong_sets) |
|
797 |
moreover from assms and A_in_N have "f-`A \<inter> space R \<in> sets R" |
|
798 |
by (intro measurable_sets) simp_all |
|
799 |
ultimately have "emeasure (distr (join M) N f) A = \<integral>\<^sup>+M'. emeasure M' (f-`A \<inter> space R) \<partial>M" |
|
800 |
by (simp_all add: A_in_N emeasure_distr emeasure_join assms) |
|
801 |
||
802 |
also have "... = \<integral>\<^sup>+ x. emeasure (distr x N f) A \<partial>M" using A_in_N |
|
803 |
proof (intro nn_integral_cong, subst emeasure_distr) |
|
804 |
fix M' assume "M' \<in> space M" |
|
805 |
from assms have "space M = space (subprob_algebra R)" |
|
806 |
using sets_eq_imp_space_eq by blast |
|
807 |
with `M' \<in> space M` have [simp]: "sets M' = sets R" using space_subprob_algebra by blast |
|
808 |
show "f \<in> measurable M' N" by (simp cong: measurable_cong_sets add: assms) |
|
809 |
have "space M' = space R" by (rule sets_eq_imp_space_eq) simp |
|
810 |
thus "emeasure M' (f -` A \<inter> space R) = emeasure M' (f -` A \<inter> space M')" by simp |
|
811 |
qed |
|
812 |
||
813 |
also have "(\<lambda>M. distr M N f) \<in> measurable M (subprob_algebra N)" |
|
814 |
by (simp cong: measurable_cong_sets add: assms measurable_distr) |
|
815 |
hence "(\<integral>\<^sup>+ x. emeasure (distr x N f) A \<partial>M) = |
|
816 |
emeasure (join (distr M (subprob_algebra N) (\<lambda>M. distr M N f))) A" |
|
817 |
by (simp_all add: emeasure_join assms A_in_N nn_integral_distr measurable_emeasure_subprob_algebra) |
|
818 |
finally show "emeasure ?r A = emeasure ?l A" .. |
|
819 |
qed simp |
|
820 |
||
821 |
definition bind :: "'a measure \<Rightarrow> ('a \<Rightarrow> 'b measure) \<Rightarrow> 'b measure" where |
|
822 |
"bind M f = (if space M = {} then count_space {} else |
|
823 |
join (distr M (subprob_algebra (f (SOME x. x \<in> space M))) f))" |
|
824 |
||
825 |
adhoc_overloading Monad_Syntax.bind bind |
|
826 |
||
827 |
lemma bind_empty: |
|
828 |
"space M = {} \<Longrightarrow> bind M f = count_space {}" |
|
829 |
by (simp add: bind_def) |
|
830 |
||
831 |
lemma bind_nonempty: |
|
832 |
"space M \<noteq> {} \<Longrightarrow> bind M f = join (distr M (subprob_algebra (f (SOME x. x \<in> space M))) f)" |
|
833 |
by (simp add: bind_def) |
|
834 |
||
835 |
lemma sets_bind_empty: "sets M = {} \<Longrightarrow> sets (bind M f) = {{}}" |
|
836 |
by (auto simp: bind_def) |
|
837 |
||
838 |
lemma space_bind_empty: "space M = {} \<Longrightarrow> space (bind M f) = {}" |
|
839 |
by (simp add: bind_def) |
|
840 |
||
59048 | 841 |
lemma sets_bind[simp, measurable_cong]: |
842 |
assumes f: "\<And>x. x \<in> space M \<Longrightarrow> sets (f x) = sets N" and M: "space M \<noteq> {}" |
|
58606 | 843 |
shows "sets (bind M f) = sets N" |
59048 | 844 |
using f [of "SOME x. x \<in> space M"] by (simp add: bind_nonempty M some_in_eq) |
58606 | 845 |
|
846 |
lemma space_bind[simp]: |
|
59048 | 847 |
assumes "\<And>x. x \<in> space M \<Longrightarrow> sets (f x) = sets N" and "space M \<noteq> {}" |
58606 | 848 |
shows "space (bind M f) = space N" |
59048 | 849 |
using assms by (intro sets_eq_imp_space_eq sets_bind) |
58606 | 850 |
|
851 |
lemma bind_cong: |
|
852 |
assumes "\<forall>x \<in> space M. f x = g x" |
|
853 |
shows "bind M f = bind M g" |
|
854 |
proof (cases "space M = {}") |
|
855 |
assume "space M \<noteq> {}" |
|
856 |
hence "(SOME x. x \<in> space M) \<in> space M" by (rule_tac someI_ex) blast |
|
857 |
with assms have "f (SOME x. x \<in> space M) = g (SOME x. x \<in> space M)" by blast |
|
858 |
with `space M \<noteq> {}` and assms show ?thesis by (simp add: bind_nonempty cong: distr_cong) |
|
859 |
qed (simp add: bind_empty) |
|
860 |
||
861 |
lemma bind_nonempty': |
|
862 |
assumes "f \<in> measurable M (subprob_algebra N)" "x \<in> space M" |
|
863 |
shows "bind M f = join (distr M (subprob_algebra N) f)" |
|
864 |
using assms |
|
865 |
apply (subst bind_nonempty, blast) |
|
866 |
apply (subst subprob_algebra_cong[OF sets_kernel[OF assms(1) someI_ex]], blast) |
|
867 |
apply (simp add: subprob_algebra_cong[OF sets_kernel[OF assms]]) |
|
868 |
done |
|
869 |
||
870 |
lemma bind_nonempty'': |
|
871 |
assumes "f \<in> measurable M (subprob_algebra N)" "space M \<noteq> {}" |
|
872 |
shows "bind M f = join (distr M (subprob_algebra N) f)" |
|
873 |
using assms by (auto intro: bind_nonempty') |
|
874 |
||
875 |
lemma emeasure_bind: |
|
876 |
"\<lbrakk>space M \<noteq> {}; f \<in> measurable M (subprob_algebra N);X \<in> sets N\<rbrakk> |
|
877 |
\<Longrightarrow> emeasure (M \<guillemotright>= f) X = \<integral>\<^sup>+x. emeasure (f x) X \<partial>M" |
|
878 |
by (simp add: bind_nonempty'' emeasure_join nn_integral_distr measurable_emeasure_subprob_algebra) |
|
879 |
||
59048 | 880 |
lemma nn_integral_bind: |
881 |
assumes f: "f \<in> borel_measurable B" |
|
59000 | 882 |
assumes N: "N \<in> measurable M (subprob_algebra B)" |
883 |
shows "(\<integral>\<^sup>+x. f x \<partial>(M \<guillemotright>= N)) = (\<integral>\<^sup>+x. \<integral>\<^sup>+y. f y \<partial>N x \<partial>M)" |
|
884 |
proof cases |
|
885 |
assume M: "space M \<noteq> {}" show ?thesis |
|
886 |
unfolding bind_nonempty''[OF N M] nn_integral_join[OF f sets_distr] |
|
887 |
by (rule nn_integral_distr[OF N nn_integral_measurable_subprob_algebra[OF f]]) |
|
888 |
qed (simp add: bind_empty space_empty[of M] nn_integral_count_space) |
|
889 |
||
890 |
lemma AE_bind: |
|
891 |
assumes P[measurable]: "Measurable.pred B P" |
|
892 |
assumes N[measurable]: "N \<in> measurable M (subprob_algebra B)" |
|
893 |
shows "(AE x in M \<guillemotright>= N. P x) \<longleftrightarrow> (AE x in M. AE y in N x. P y)" |
|
894 |
proof cases |
|
895 |
assume M: "space M = {}" show ?thesis |
|
896 |
unfolding bind_empty[OF M] unfolding space_empty[OF M] by (simp add: AE_count_space) |
|
897 |
next |
|
898 |
assume M: "space M \<noteq> {}" |
|
59048 | 899 |
note sets_kernel[OF N, simp] |
59000 | 900 |
have *: "(\<integral>\<^sup>+x. indicator {x. \<not> P x} x \<partial>(M \<guillemotright>= N)) = (\<integral>\<^sup>+x. indicator {x\<in>space B. \<not> P x} x \<partial>(M \<guillemotright>= N))" |
59048 | 901 |
by (intro nn_integral_cong) (simp add: space_bind[OF _ M] split: split_indicator) |
59000 | 902 |
|
903 |
have "(AE x in M \<guillemotright>= N. P x) \<longleftrightarrow> (\<integral>\<^sup>+ x. integral\<^sup>N (N x) (indicator {x \<in> space B. \<not> P x}) \<partial>M) = 0" |
|
59048 | 904 |
by (simp add: AE_iff_nn_integral sets_bind[OF _ M] space_bind[OF _ M] * nn_integral_bind[where B=B] |
59000 | 905 |
del: nn_integral_indicator) |
906 |
also have "\<dots> = (AE x in M. AE y in N x. P y)" |
|
907 |
apply (subst nn_integral_0_iff_AE) |
|
908 |
apply (rule measurable_compose[OF N nn_integral_measurable_subprob_algebra]) |
|
909 |
apply measurable |
|
910 |
apply (intro eventually_subst AE_I2) |
|
59048 | 911 |
apply (auto simp add: emeasure_le_0_iff subprob_measurableD(1)[OF N] |
912 |
intro!: AE_iff_measurable[symmetric]) |
|
59000 | 913 |
done |
914 |
finally show ?thesis . |
|
915 |
qed |
|
916 |
||
917 |
lemma measurable_bind': |
|
918 |
assumes M1: "f \<in> measurable M (subprob_algebra N)" and |
|
919 |
M2: "split g \<in> measurable (M \<Otimes>\<^sub>M N) (subprob_algebra R)" |
|
920 |
shows "(\<lambda>x. bind (f x) (g x)) \<in> measurable M (subprob_algebra R)" |
|
921 |
proof (subst measurable_cong) |
|
922 |
fix x assume x_in_M: "x \<in> space M" |
|
923 |
with assms have "space (f x) \<noteq> {}" |
|
924 |
by (blast dest: subprob_space_kernel subprob_space.subprob_not_empty) |
|
925 |
moreover from M2 x_in_M have "g x \<in> measurable (f x) (subprob_algebra R)" |
|
926 |
by (subst measurable_cong_sets[OF sets_kernel[OF M1 x_in_M] refl]) |
|
927 |
(auto dest: measurable_Pair2) |
|
928 |
ultimately show "bind (f x) (g x) = join (distr (f x) (subprob_algebra R) (g x))" |
|
929 |
by (simp_all add: bind_nonempty'') |
|
930 |
next |
|
931 |
show "(\<lambda>w. join (distr (f w) (subprob_algebra R) (g w))) \<in> measurable M (subprob_algebra R)" |
|
932 |
apply (rule measurable_compose[OF _ measurable_join]) |
|
933 |
apply (rule measurable_distr2[OF M2 M1]) |
|
934 |
done |
|
935 |
qed |
|
58606 | 936 |
|
59048 | 937 |
lemma measurable_bind[measurable (raw)]: |
59000 | 938 |
assumes M1: "f \<in> measurable M (subprob_algebra N)" and |
939 |
M2: "(\<lambda>x. g (fst x) (snd x)) \<in> measurable (M \<Otimes>\<^sub>M N) (subprob_algebra R)" |
|
940 |
shows "(\<lambda>x. bind (f x) (g x)) \<in> measurable M (subprob_algebra R)" |
|
941 |
using assms by (auto intro: measurable_bind' simp: measurable_split_conv) |
|
942 |
||
943 |
lemma measurable_bind2: |
|
944 |
assumes "f \<in> measurable M (subprob_algebra N)" and "g \<in> measurable N (subprob_algebra R)" |
|
945 |
shows "(\<lambda>x. bind (f x) g) \<in> measurable M (subprob_algebra R)" |
|
946 |
using assms by (intro measurable_bind' measurable_const) auto |
|
947 |
||
948 |
lemma subprob_space_bind: |
|
949 |
assumes "subprob_space M" "f \<in> measurable M (subprob_algebra N)" |
|
950 |
shows "subprob_space (M \<guillemotright>= f)" |
|
951 |
proof (rule subprob_space_kernel[of "\<lambda>x. x \<guillemotright>= f"]) |
|
952 |
show "(\<lambda>x. x \<guillemotright>= f) \<in> measurable (subprob_algebra M) (subprob_algebra N)" |
|
953 |
by (rule measurable_bind, rule measurable_ident_sets, rule refl, |
|
954 |
rule measurable_compose[OF measurable_snd assms(2)]) |
|
955 |
from assms(1) show "M \<in> space (subprob_algebra M)" |
|
956 |
by (simp add: space_subprob_algebra) |
|
957 |
qed |
|
58606 | 958 |
|
59000 | 959 |
lemma (in prob_space) prob_space_bind: |
960 |
assumes ae: "AE x in M. prob_space (N x)" |
|
961 |
and N[measurable]: "N \<in> measurable M (subprob_algebra S)" |
|
962 |
shows "prob_space (M \<guillemotright>= N)" |
|
963 |
proof |
|
964 |
have "emeasure (M \<guillemotright>= N) (space (M \<guillemotright>= N)) = (\<integral>\<^sup>+x. emeasure (N x) (space (N x)) \<partial>M)" |
|
965 |
by (subst emeasure_bind[where N=S]) |
|
59048 | 966 |
(auto simp: not_empty space_bind[OF sets_kernel] subprob_measurableD[OF N] intro!: nn_integral_cong) |
59000 | 967 |
also have "\<dots> = (\<integral>\<^sup>+x. 1 \<partial>M)" |
968 |
using ae by (intro nn_integral_cong_AE, eventually_elim) (rule prob_space.emeasure_space_1) |
|
969 |
finally show "emeasure (M \<guillemotright>= N) (space (M \<guillemotright>= N)) = 1" |
|
970 |
by (simp add: emeasure_space_1) |
|
971 |
qed |
|
972 |
||
973 |
lemma (in subprob_space) bind_in_space: |
|
974 |
"A \<in> measurable M (subprob_algebra N) \<Longrightarrow> (M \<guillemotright>= A) \<in> space (subprob_algebra N)" |
|
59048 | 975 |
by (auto simp add: space_subprob_algebra subprob_not_empty sets_kernel intro!: subprob_space_bind) |
59000 | 976 |
unfold_locales |
977 |
||
978 |
lemma (in subprob_space) measure_bind: |
|
979 |
assumes f: "f \<in> measurable M (subprob_algebra N)" and X: "X \<in> sets N" |
|
980 |
shows "measure (M \<guillemotright>= f) X = \<integral>x. measure (f x) X \<partial>M" |
|
981 |
proof - |
|
982 |
interpret Mf: subprob_space "M \<guillemotright>= f" |
|
983 |
by (rule subprob_space_bind[OF _ f]) unfold_locales |
|
984 |
||
985 |
{ fix x assume "x \<in> space M" |
|
986 |
from f[THEN measurable_space, OF this] interpret subprob_space "f x" |
|
987 |
by (simp add: space_subprob_algebra) |
|
988 |
have "emeasure (f x) X = ereal (measure (f x) X)" "measure (f x) X \<le> 1" |
|
989 |
by (auto simp: emeasure_eq_measure subprob_measure_le_1) } |
|
990 |
note this[simp] |
|
991 |
||
992 |
have "emeasure (M \<guillemotright>= f) X = \<integral>\<^sup>+x. emeasure (f x) X \<partial>M" |
|
993 |
using subprob_not_empty f X by (rule emeasure_bind) |
|
994 |
also have "\<dots> = \<integral>\<^sup>+x. ereal (measure (f x) X) \<partial>M" |
|
995 |
by (intro nn_integral_cong) simp |
|
996 |
also have "\<dots> = \<integral>x. measure (f x) X \<partial>M" |
|
997 |
by (intro nn_integral_eq_integral integrable_const_bound[where B=1] |
|
998 |
measure_measurable_subprob_algebra2[OF _ f] pair_measureI X) |
|
999 |
(auto simp: measure_nonneg) |
|
1000 |
finally show ?thesis |
|
1001 |
by (simp add: Mf.emeasure_eq_measure) |
|
58606 | 1002 |
qed |
1003 |
||
1004 |
lemma emeasure_bind_const: |
|
1005 |
"space M \<noteq> {} \<Longrightarrow> X \<in> sets N \<Longrightarrow> subprob_space N \<Longrightarrow> |
|
1006 |
emeasure (M \<guillemotright>= (\<lambda>x. N)) X = emeasure N X * emeasure M (space M)" |
|
1007 |
by (simp add: bind_nonempty emeasure_join nn_integral_distr |
|
1008 |
space_subprob_algebra measurable_emeasure_subprob_algebra emeasure_nonneg) |
|
1009 |
||
1010 |
lemma emeasure_bind_const': |
|
1011 |
assumes "subprob_space M" "subprob_space N" |
|
1012 |
shows "emeasure (M \<guillemotright>= (\<lambda>x. N)) X = emeasure N X * emeasure M (space M)" |
|
1013 |
using assms |
|
1014 |
proof (case_tac "X \<in> sets N") |
|
1015 |
fix X assume "X \<in> sets N" |
|
1016 |
thus "emeasure (M \<guillemotright>= (\<lambda>x. N)) X = emeasure N X * emeasure M (space M)" using assms |
|
1017 |
by (subst emeasure_bind_const) |
|
1018 |
(simp_all add: subprob_space.subprob_not_empty subprob_space.emeasure_space_le_1) |
|
1019 |
next |
|
1020 |
fix X assume "X \<notin> sets N" |
|
1021 |
with assms show "emeasure (M \<guillemotright>= (\<lambda>x. N)) X = emeasure N X * emeasure M (space M)" |
|
1022 |
by (simp add: sets_bind[of _ _ N] subprob_space.subprob_not_empty |
|
1023 |
space_subprob_algebra emeasure_notin_sets) |
|
1024 |
qed |
|
1025 |
||
1026 |
lemma emeasure_bind_const_prob_space: |
|
1027 |
assumes "prob_space M" "subprob_space N" |
|
1028 |
shows "emeasure (M \<guillemotright>= (\<lambda>x. N)) X = emeasure N X" |
|
1029 |
using assms by (simp add: emeasure_bind_const' prob_space_imp_subprob_space |
|
1030 |
prob_space.emeasure_space_1) |
|
1031 |
||
59000 | 1032 |
lemma bind_return: |
1033 |
assumes "f \<in> measurable M (subprob_algebra N)" and "x \<in> space M" |
|
1034 |
shows "bind (return M x) f = f x" |
|
1035 |
using sets_kernel[OF assms] assms |
|
1036 |
by (simp_all add: distr_return join_return subprob_space_kernel bind_nonempty' |
|
1037 |
cong: subprob_algebra_cong) |
|
1038 |
||
1039 |
lemma bind_return': |
|
1040 |
shows "bind M (return M) = M" |
|
1041 |
by (cases "space M = {}") |
|
1042 |
(simp_all add: bind_empty space_empty[symmetric] bind_nonempty join_return' |
|
1043 |
cong: subprob_algebra_cong) |
|
1044 |
||
1045 |
lemma distr_bind: |
|
1046 |
assumes N: "N \<in> measurable M (subprob_algebra K)" "space M \<noteq> {}" |
|
1047 |
assumes f: "f \<in> measurable K R" |
|
1048 |
shows "distr (M \<guillemotright>= N) R f = (M \<guillemotright>= (\<lambda>x. distr (N x) R f))" |
|
1049 |
unfolding bind_nonempty''[OF N] |
|
1050 |
apply (subst bind_nonempty''[OF measurable_compose[OF N(1) measurable_distr] N(2)]) |
|
1051 |
apply (rule f) |
|
1052 |
apply (simp add: join_distr_distr[OF _ f, symmetric]) |
|
1053 |
apply (subst distr_distr[OF measurable_distr, OF f N(1)]) |
|
1054 |
apply (simp add: comp_def) |
|
1055 |
done |
|
1056 |
||
1057 |
lemma bind_distr: |
|
1058 |
assumes f[measurable]: "f \<in> measurable M X" |
|
1059 |
assumes N[measurable]: "N \<in> measurable X (subprob_algebra K)" and "space M \<noteq> {}" |
|
1060 |
shows "(distr M X f \<guillemotright>= N) = (M \<guillemotright>= (\<lambda>x. N (f x)))" |
|
1061 |
proof - |
|
1062 |
have "space X \<noteq> {}" "space M \<noteq> {}" |
|
1063 |
using `space M \<noteq> {}` f[THEN measurable_space] by auto |
|
1064 |
then show ?thesis |
|
1065 |
by (simp add: bind_nonempty''[where N=K] distr_distr comp_def) |
|
1066 |
qed |
|
1067 |
||
1068 |
lemma bind_count_space_singleton: |
|
1069 |
assumes "subprob_space (f x)" |
|
1070 |
shows "count_space {x} \<guillemotright>= f = f x" |
|
1071 |
proof- |
|
1072 |
have A: "\<And>A. A \<subseteq> {x} \<Longrightarrow> A = {} \<or> A = {x}" by auto |
|
1073 |
have "count_space {x} = return (count_space {x}) x" |
|
1074 |
by (intro measure_eqI) (auto dest: A) |
|
1075 |
also have "... \<guillemotright>= f = f x" |
|
1076 |
by (subst bind_return[of _ _ "f x"]) (auto simp: space_subprob_algebra assms) |
|
1077 |
finally show ?thesis . |
|
1078 |
qed |
|
1079 |
||
1080 |
lemma restrict_space_bind: |
|
1081 |
assumes N: "N \<in> measurable M (subprob_algebra K)" |
|
1082 |
assumes "space M \<noteq> {}" |
|
1083 |
assumes X[simp]: "X \<in> sets K" "X \<noteq> {}" |
|
1084 |
shows "restrict_space (bind M N) X = bind M (\<lambda>x. restrict_space (N x) X)" |
|
1085 |
proof (rule measure_eqI) |
|
59048 | 1086 |
note N_sets = sets_bind[OF sets_kernel[OF N] assms(2), simp] |
1087 |
note N_space = sets_eq_imp_space_eq[OF N_sets, simp] |
|
1088 |
show "sets (restrict_space (bind M N) X) = sets (bind M (\<lambda>x. restrict_space (N x) X))" |
|
1089 |
by (simp add: sets_restrict_space assms(2) sets_bind[OF sets_kernel[OF restrict_space_measurable[OF assms(4,3,1)]]]) |
|
59000 | 1090 |
fix A assume "A \<in> sets (restrict_space (M \<guillemotright>= N) X)" |
1091 |
with X have "A \<in> sets K" "A \<subseteq> X" |
|
59048 | 1092 |
by (auto simp: sets_restrict_space) |
59000 | 1093 |
then show "emeasure (restrict_space (M \<guillemotright>= N) X) A = emeasure (M \<guillemotright>= (\<lambda>x. restrict_space (N x) X)) A" |
1094 |
using assms |
|
1095 |
apply (subst emeasure_restrict_space) |
|
59048 | 1096 |
apply (simp_all add: emeasure_bind[OF assms(2,1)]) |
59000 | 1097 |
apply (subst emeasure_bind[OF _ restrict_space_measurable[OF _ _ N]]) |
1098 |
apply (auto simp: sets_restrict_space emeasure_restrict_space space_subprob_algebra |
|
1099 |
intro!: nn_integral_cong dest!: measurable_space) |
|
1100 |
done |
|
59048 | 1101 |
qed |
59000 | 1102 |
|
58606 | 1103 |
lemma bind_const': "\<lbrakk>prob_space M; subprob_space N\<rbrakk> \<Longrightarrow> M \<guillemotright>= (\<lambda>x. N) = N" |
1104 |
by (intro measure_eqI) |
|
1105 |
(simp_all add: space_subprob_algebra prob_space.not_empty emeasure_bind_const_prob_space) |
|
1106 |
||
1107 |
lemma bind_return_distr: |
|
1108 |
"space M \<noteq> {} \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> bind M (return N \<circ> f) = distr M N f" |
|
1109 |
apply (simp add: bind_nonempty) |
|
1110 |
apply (subst subprob_algebra_cong) |
|
1111 |
apply (rule sets_return) |
|
1112 |
apply (subst distr_distr[symmetric]) |
|
1113 |
apply (auto intro!: return_measurable simp: distr_distr[symmetric] join_return') |
|
1114 |
done |
|
1115 |
||
1116 |
lemma bind_assoc: |
|
1117 |
fixes f :: "'a \<Rightarrow> 'b measure" and g :: "'b \<Rightarrow> 'c measure" |
|
1118 |
assumes M1: "f \<in> measurable M (subprob_algebra N)" and M2: "g \<in> measurable N (subprob_algebra R)" |
|
1119 |
shows "bind (bind M f) g = bind M (\<lambda>x. bind (f x) g)" |
|
1120 |
proof (cases "space M = {}") |
|
1121 |
assume [simp]: "space M \<noteq> {}" |
|
1122 |
from assms have [simp]: "space N \<noteq> {}" "space R \<noteq> {}" |
|
1123 |
by (auto simp: measurable_empty_iff space_subprob_algebra_empty_iff) |
|
1124 |
from assms have sets_fx[simp]: "\<And>x. x \<in> space M \<Longrightarrow> sets (f x) = sets N" |
|
1125 |
by (simp add: sets_kernel) |
|
1126 |
have ex_in: "\<And>A. A \<noteq> {} \<Longrightarrow> \<exists>x. x \<in> A" by blast |
|
1127 |
note sets_some[simp] = sets_kernel[OF M1 someI_ex[OF ex_in[OF `space M \<noteq> {}`]]] |
|
1128 |
sets_kernel[OF M2 someI_ex[OF ex_in[OF `space N \<noteq> {}`]]] |
|
1129 |
note space_some[simp] = sets_eq_imp_space_eq[OF this(1)] sets_eq_imp_space_eq[OF this(2)] |
|
1130 |
||
1131 |
have "bind M (\<lambda>x. bind (f x) g) = |
|
1132 |
join (distr M (subprob_algebra R) (join \<circ> (\<lambda>x. (distr x (subprob_algebra R) g)) \<circ> f))" |
|
1133 |
by (simp add: sets_eq_imp_space_eq[OF sets_fx] bind_nonempty o_def |
|
1134 |
cong: subprob_algebra_cong distr_cong) |
|
1135 |
also have "distr M (subprob_algebra R) (join \<circ> (\<lambda>x. (distr x (subprob_algebra R) g)) \<circ> f) = |
|
1136 |
distr (distr (distr M (subprob_algebra N) f) |
|
1137 |
(subprob_algebra (subprob_algebra R)) |
|
1138 |
(\<lambda>x. distr x (subprob_algebra R) g)) |
|
1139 |
(subprob_algebra R) join" |
|
1140 |
apply (subst distr_distr, |
|
1141 |
(blast intro: measurable_comp measurable_distr measurable_join M1 M2)+)+ |
|
1142 |
apply (simp add: o_assoc) |
|
1143 |
done |
|
1144 |
also have "join ... = bind (bind M f) g" |
|
1145 |
by (simp add: join_assoc join_distr_distr M2 bind_nonempty cong: subprob_algebra_cong) |
|
1146 |
finally show ?thesis .. |
|
1147 |
qed (simp add: bind_empty) |
|
1148 |
||
1149 |
lemma double_bind_assoc: |
|
1150 |
assumes Mg: "g \<in> measurable N (subprob_algebra N')" |
|
1151 |
assumes Mf: "f \<in> measurable M (subprob_algebra M')" |
|
1152 |
assumes Mh: "split h \<in> measurable (M \<Otimes>\<^sub>M M') N" |
|
1153 |
shows "do {x \<leftarrow> M; y \<leftarrow> f x; g (h x y)} = do {x \<leftarrow> M; y \<leftarrow> f x; return N (h x y)} \<guillemotright>= g" |
|
1154 |
proof- |
|
1155 |
have "do {x \<leftarrow> M; y \<leftarrow> f x; return N (h x y)} \<guillemotright>= g = |
|
1156 |
do {x \<leftarrow> M; do {y \<leftarrow> f x; return N (h x y)} \<guillemotright>= g}" |
|
1157 |
using Mh by (auto intro!: bind_assoc measurable_bind'[OF Mf] Mf Mg |
|
1158 |
measurable_compose[OF _ return_measurable] simp: measurable_split_conv) |
|
1159 |
also from Mh have "\<And>x. x \<in> space M \<Longrightarrow> h x \<in> measurable M' N" by measurable |
|
1160 |
hence "do {x \<leftarrow> M; do {y \<leftarrow> f x; return N (h x y)} \<guillemotright>= g} = |
|
1161 |
do {x \<leftarrow> M; y \<leftarrow> f x; return N (h x y) \<guillemotright>= g}" |
|
1162 |
apply (intro ballI bind_cong bind_assoc) |
|
1163 |
apply (subst measurable_cong_sets[OF sets_kernel[OF Mf] refl], simp) |
|
1164 |
apply (rule measurable_compose[OF _ return_measurable], auto intro: Mg) |
|
1165 |
done |
|
1166 |
also have "\<And>x. x \<in> space M \<Longrightarrow> space (f x) = space M'" |
|
1167 |
by (intro sets_eq_imp_space_eq sets_kernel[OF Mf]) |
|
1168 |
with measurable_space[OF Mh] |
|
1169 |
have "do {x \<leftarrow> M; y \<leftarrow> f x; return N (h x y) \<guillemotright>= g} = do {x \<leftarrow> M; y \<leftarrow> f x; g (h x y)}" |
|
1170 |
by (intro ballI bind_cong bind_return[OF Mg]) (auto simp: space_pair_measure) |
|
1171 |
finally show ?thesis .. |
|
1172 |
qed |
|
1173 |
||
59048 | 1174 |
lemma (in prob_space) M_in_subprob[measurable (raw)]: "M \<in> space (subprob_algebra M)" |
1175 |
by (simp add: space_subprob_algebra) unfold_locales |
|
1176 |
||
59000 | 1177 |
lemma (in pair_prob_space) pair_measure_eq_bind: |
1178 |
"(M1 \<Otimes>\<^sub>M M2) = (M1 \<guillemotright>= (\<lambda>x. M2 \<guillemotright>= (\<lambda>y. return (M1 \<Otimes>\<^sub>M M2) (x, y))))" |
|
1179 |
proof (rule measure_eqI) |
|
1180 |
have ps_M2: "prob_space M2" by unfold_locales |
|
1181 |
note return_measurable[measurable] |
|
1182 |
show "sets (M1 \<Otimes>\<^sub>M M2) = sets (M1 \<guillemotright>= (\<lambda>x. M2 \<guillemotright>= (\<lambda>y. return (M1 \<Otimes>\<^sub>M M2) (x, y))))" |
|
59048 | 1183 |
by (simp_all add: M1.not_empty M2.not_empty) |
59000 | 1184 |
fix A assume [measurable]: "A \<in> sets (M1 \<Otimes>\<^sub>M M2)" |
1185 |
show "emeasure (M1 \<Otimes>\<^sub>M M2) A = emeasure (M1 \<guillemotright>= (\<lambda>x. M2 \<guillemotright>= (\<lambda>y. return (M1 \<Otimes>\<^sub>M M2) (x, y)))) A" |
|
59048 | 1186 |
by (auto simp: M2.emeasure_pair_measure M1.not_empty M2.not_empty emeasure_bind[where N="M1 \<Otimes>\<^sub>M M2"] |
59000 | 1187 |
intro!: nn_integral_cong) |
1188 |
qed |
|
1189 |
||
1190 |
lemma (in pair_prob_space) bind_rotate: |
|
1191 |
assumes C[measurable]: "(\<lambda>(x, y). C x y) \<in> measurable (M1 \<Otimes>\<^sub>M M2) (subprob_algebra N)" |
|
1192 |
shows "(M1 \<guillemotright>= (\<lambda>x. M2 \<guillemotright>= (\<lambda>y. C x y))) = (M2 \<guillemotright>= (\<lambda>y. M1 \<guillemotright>= (\<lambda>x. C x y)))" |
|
1193 |
proof - |
|
1194 |
interpret swap: pair_prob_space M2 M1 by unfold_locales |
|
1195 |
note measurable_bind[where N="M2", measurable] |
|
1196 |
note measurable_bind[where N="M1", measurable] |
|
1197 |
have [simp]: "M1 \<in> space (subprob_algebra M1)" "M2 \<in> space (subprob_algebra M2)" |
|
1198 |
by (auto simp: space_subprob_algebra) unfold_locales |
|
1199 |
have "(M1 \<guillemotright>= (\<lambda>x. M2 \<guillemotright>= (\<lambda>y. C x y))) = |
|
1200 |
(M1 \<guillemotright>= (\<lambda>x. M2 \<guillemotright>= (\<lambda>y. return (M1 \<Otimes>\<^sub>M M2) (x, y)))) \<guillemotright>= (\<lambda>(x, y). C x y)" |
|
1201 |
by (auto intro!: bind_cong simp: bind_return[where N=N] space_pair_measure bind_assoc[where N="M1 \<Otimes>\<^sub>M M2" and R=N]) |
|
1202 |
also have "\<dots> = (distr (M2 \<Otimes>\<^sub>M M1) (M1 \<Otimes>\<^sub>M M2) (\<lambda>(x, y). (y, x))) \<guillemotright>= (\<lambda>(x, y). C x y)" |
|
1203 |
unfolding pair_measure_eq_bind[symmetric] distr_pair_swap[symmetric] .. |
|
1204 |
also have "\<dots> = (M2 \<guillemotright>= (\<lambda>x. M1 \<guillemotright>= (\<lambda>y. return (M2 \<Otimes>\<^sub>M M1) (x, y)))) \<guillemotright>= (\<lambda>(y, x). C x y)" |
|
1205 |
unfolding swap.pair_measure_eq_bind[symmetric] |
|
1206 |
by (auto simp add: space_pair_measure M1.not_empty M2.not_empty bind_distr[OF _ C] intro!: bind_cong) |
|
1207 |
also have "\<dots> = (M2 \<guillemotright>= (\<lambda>y. M1 \<guillemotright>= (\<lambda>x. C x y)))" |
|
1208 |
by (auto intro!: bind_cong simp: bind_return[where N=N] space_pair_measure bind_assoc[where N="M2 \<Otimes>\<^sub>M M1" and R=N]) |
|
1209 |
finally show ?thesis . |
|
1210 |
qed |
|
1211 |
||
58608 | 1212 |
section {* Measures form a $\omega$-chain complete partial order *} |
58606 | 1213 |
|
1214 |
definition SUP_measure :: "(nat \<Rightarrow> 'a measure) \<Rightarrow> 'a measure" where |
|
1215 |
"SUP_measure M = measure_of (\<Union>i. space (M i)) (\<Union>i. sets (M i)) (\<lambda>A. SUP i. emeasure (M i) A)" |
|
1216 |
||
1217 |
lemma |
|
1218 |
assumes const: "\<And>i j. sets (M i) = sets (M j)" |
|
1219 |
shows space_SUP_measure: "space (SUP_measure M) = space (M i)" (is ?sp) |
|
1220 |
and sets_SUP_measure: "sets (SUP_measure M) = sets (M i)" (is ?st) |
|
1221 |
proof - |
|
1222 |
have "(\<Union>i. sets (M i)) = sets (M i)" |
|
1223 |
using const by auto |
|
1224 |
moreover have "(\<Union>i. space (M i)) = space (M i)" |
|
1225 |
using const[THEN sets_eq_imp_space_eq] by auto |
|
1226 |
moreover have "\<And>i. sets (M i) \<subseteq> Pow (space (M i))" |
|
1227 |
by (auto dest: sets.sets_into_space) |
|
1228 |
ultimately show ?sp ?st |
|
1229 |
by (simp_all add: SUP_measure_def) |
|
1230 |
qed |
|
1231 |
||
1232 |
lemma emeasure_SUP_measure: |
|
1233 |
assumes const: "\<And>i j. sets (M i) = sets (M j)" |
|
1234 |
and mono: "mono (\<lambda>i. emeasure (M i))" |
|
1235 |
shows "emeasure (SUP_measure M) A = (SUP i. emeasure (M i) A)" |
|
1236 |
proof cases |
|
1237 |
assume "A \<in> sets (SUP_measure M)" |
|
1238 |
show ?thesis |
|
1239 |
proof (rule emeasure_measure_of[OF SUP_measure_def]) |
|
1240 |
show "countably_additive (sets (SUP_measure M)) (\<lambda>A. SUP i. emeasure (M i) A)" |
|
1241 |
proof (rule countably_additiveI) |
|
1242 |
fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> sets (SUP_measure M)" |
|
1243 |
then have "\<And>i j. A i \<in> sets (M j)" |
|
1244 |
using sets_SUP_measure[of M, OF const] by simp |
|
1245 |
moreover assume "disjoint_family A" |
|
1246 |
ultimately show "(\<Sum>i. SUP ia. emeasure (M ia) (A i)) = (SUP i. emeasure (M i) (\<Union>i. A i))" |
|
1247 |
using mono by (subst suminf_SUP_eq) (auto simp: mono_def le_fun_def intro!: SUP_cong suminf_emeasure) |
|
1248 |
qed |
|
1249 |
show "positive (sets (SUP_measure M)) (\<lambda>A. SUP i. emeasure (M i) A)" |
|
1250 |
by (auto simp: positive_def intro: SUP_upper2) |
|
1251 |
show "(\<Union>i. sets (M i)) \<subseteq> Pow (\<Union>i. space (M i))" |
|
1252 |
using sets.sets_into_space by auto |
|
1253 |
qed fact |
|
1254 |
next |
|
1255 |
assume "A \<notin> sets (SUP_measure M)" |
|
1256 |
with sets_SUP_measure[of M, OF const] show ?thesis |
|
1257 |
by (simp add: emeasure_notin_sets) |
|
1258 |
qed |
|
1259 |
||
59425 | 1260 |
lemma bind_return'': "sets M = sets N \<Longrightarrow> M \<guillemotright>= return N = M" |
1261 |
by (cases "space M = {}") |
|
1262 |
(simp_all add: bind_empty space_empty[symmetric] bind_nonempty join_return' |
|
1263 |
cong: subprob_algebra_cong) |
|
1264 |
||
1265 |
lemma (in prob_space) distr_const[simp]: |
|
1266 |
"c \<in> space N \<Longrightarrow> distr M N (\<lambda>x. c) = return N c" |
|
1267 |
by (rule measure_eqI) (auto simp: emeasure_distr emeasure_space_1) |
|
1268 |
||
1269 |
lemma return_count_space_eq_density: |
|
1270 |
"return (count_space M) x = density (count_space M) (indicator {x})" |
|
1271 |
by (rule measure_eqI) |
|
1272 |
(auto simp: indicator_inter_arith_ereal emeasure_density split: split_indicator) |
|
1273 |
||
58606 | 1274 |
end |