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