src/HOL/Probability/Sigma_Algebra.thy
changeset 50244 de72bbe42190
parent 50096 7c9c5b1b6cd7
child 50245 dea9363887a6
equal deleted inserted replaced
50243:0d97ef1d6de9 50244:de72bbe42190
  1024 declare [[coercion emeasure]]
  1024 declare [[coercion emeasure]]
  1025 
  1025 
  1026 lemma measure_space: "measure_space (space M) (sets M) (emeasure M)"
  1026 lemma measure_space: "measure_space (space M) (sets M) (emeasure M)"
  1027   by (cases M) (auto simp: space_def sets_def emeasure_def Abs_measure_inverse)
  1027   by (cases M) (auto simp: space_def sets_def emeasure_def Abs_measure_inverse)
  1028 
  1028 
  1029 interpretation sigma_algebra "space M" "sets M" for M :: "'a measure"
  1029 interpretation sets!: sigma_algebra "space M" "sets M" for M :: "'a measure"
  1030   using measure_space[of M] by (auto simp: measure_space_def)
  1030   using measure_space[of M] by (auto simp: measure_space_def)
  1031 
  1031 
  1032 definition measure_of :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
  1032 definition measure_of :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
  1033   "measure_of \<Omega> A \<mu> = Abs_measure (\<Omega>, sigma_sets \<Omega> A,
  1033   "measure_of \<Omega> A \<mu> = Abs_measure (\<Omega>, sigma_sets \<Omega> A,
  1034     \<lambda>a. if a \<in> sigma_sets \<Omega> A \<and> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> then \<mu> a else 0)"
  1034     \<lambda>a. if a \<in> sigma_sets \<Omega> A \<and> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> then \<mu> a else 0)"
  1144   obtains (measure) \<Omega> A \<mu> where "x = Abs_measure (\<Omega>, A, \<mu>)" "\<forall>a\<in>-A. \<mu> a = 0" "measure_space \<Omega> A \<mu>"
  1144   obtains (measure) \<Omega> A \<mu> where "x = Abs_measure (\<Omega>, A, \<mu>)" "\<forall>a\<in>-A. \<mu> a = 0" "measure_space \<Omega> A \<mu>"
  1145   by atomize_elim (cases x, auto)
  1145   by atomize_elim (cases x, auto)
  1146 
  1146 
  1147 lemma sets_eq_imp_space_eq:
  1147 lemma sets_eq_imp_space_eq:
  1148   "sets M = sets M' \<Longrightarrow> space M = space M'"
  1148   "sets M = sets M' \<Longrightarrow> space M = space M'"
  1149   using top[of M] top[of M'] space_closed[of M] space_closed[of M']
  1149   using sets.top[of M] sets.top[of M'] sets.space_closed[of M] sets.space_closed[of M']
  1150   by blast
  1150   by blast
  1151 
  1151 
  1152 lemma emeasure_notin_sets: "A \<notin> sets M \<Longrightarrow> emeasure M A = 0"
  1152 lemma emeasure_notin_sets: "A \<notin> sets M \<Longrightarrow> emeasure M A = 0"
  1153   by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
  1153   by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
  1154 
  1154 
  1223       and f: "f \<in> space M \<rightarrow> \<Omega>"
  1223       and f: "f \<in> space M \<rightarrow> \<Omega>"
  1224       and ba: "\<And>y. y \<in> A \<Longrightarrow> (f -` y) \<inter> space M \<in> sets M"
  1224       and ba: "\<And>y. y \<in> A \<Longrightarrow> (f -` y) \<inter> space M \<in> sets M"
  1225   shows "f \<in> measurable M N"
  1225   shows "f \<in> measurable M N"
  1226 proof -
  1226 proof -
  1227   interpret A: sigma_algebra \<Omega> "sigma_sets \<Omega> A" using B(2) by (rule sigma_algebra_sigma_sets)
  1227   interpret A: sigma_algebra \<Omega> "sigma_sets \<Omega> A" using B(2) by (rule sigma_algebra_sigma_sets)
  1228   from B top[of N] A.top space_closed[of N] A.space_closed have \<Omega>: "\<Omega> = space N" by force
  1228   from B sets.top[of N] A.top sets.space_closed[of N] A.space_closed have \<Omega>: "\<Omega> = space N" by force
  1229   
  1229   
  1230   { fix X assume "X \<in> sigma_sets \<Omega> A"
  1230   { fix X assume "X \<in> sigma_sets \<Omega> A"
  1231     then have "f -` X \<inter> space M \<in> sets M \<and> X \<subseteq> \<Omega>"
  1231     then have "f -` X \<inter> space M \<in> sets M \<and> X \<subseteq> \<Omega>"
  1232       proof induct
  1232       proof induct
  1233         case (Basic a) then show ?case
  1233         case (Basic a) then show ?case
  1235       next
  1235       next
  1236         case (Compl a)
  1236         case (Compl a)
  1237         have [simp]: "f -` \<Omega> \<inter> space M = space M"
  1237         have [simp]: "f -` \<Omega> \<inter> space M = space M"
  1238           by (auto simp add: funcset_mem [OF f])
  1238           by (auto simp add: funcset_mem [OF f])
  1239         then show ?case
  1239         then show ?case
  1240           by (auto simp add: vimage_Diff Diff_Int_distrib2 compl_sets Compl)
  1240           by (auto simp add: vimage_Diff Diff_Int_distrib2 sets.compl_sets Compl)
  1241       next
  1241       next
  1242         case (Union a)
  1242         case (Union a)
  1243         then show ?case
  1243         then show ?case
  1244           by (simp add: vimage_UN, simp only: UN_extend_simps(4)) blast
  1244           by (simp add: vimage_UN, simp only: UN_extend_simps(4)) blast
  1245       qed auto }
  1245       qed auto }
  1314     ((f -` A \<inter> space M) \<inter> {x\<in>space M. P x}) \<union>
  1314     ((f -` A \<inter> space M) \<inter> {x\<in>space M. P x}) \<union>
  1315     ((g -` A \<inter> space M) \<inter> (space M - {x\<in>space M. P x}))"
  1315     ((g -` A \<inter> space M) \<inter> (space M - {x\<in>space M. P x}))"
  1316     using measure unfolding measurable_def by (auto split: split_if_asm)
  1316     using measure unfolding measurable_def by (auto split: split_if_asm)
  1317   show "(\<lambda>x. if P x then f x else g x) -` A \<inter> space M \<in> sets M"
  1317   show "(\<lambda>x. if P x then f x else g x) -` A \<inter> space M \<in> sets M"
  1318     using `A \<in> sets M'` measure P unfolding * measurable_def
  1318     using `A \<in> sets M'` measure P unfolding * measurable_def
  1319     by (auto intro!: Un)
  1319     by (auto intro!: sets.Un)
  1320 qed
  1320 qed
  1321 
  1321 
  1322 lemma measurable_If_set:
  1322 lemma measurable_If_set:
  1323   assumes measure: "f \<in> measurable M M'" "g \<in> measurable M M'"
  1323   assumes measure: "f \<in> measurable M M'" "g \<in> measurable M M'"
  1324   assumes P: "A \<inter> space M \<in> sets M"
  1324   assumes P: "A \<inter> space M \<in> sets M"
  1346       have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
  1346       have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
  1347         {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x})) \<union> (space M - (\<Union>i. {x\<in>space M. P i x}))"
  1347         {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x})) \<union> (space M - (\<Union>i. {x\<in>space M. P i x}))"
  1348         by (simp add: set_eq_iff, safe)
  1348         by (simp add: set_eq_iff, safe)
  1349            (insert i, auto dest: Least_le intro: LeastI intro!: Least_equality)
  1349            (insert i, auto dest: Least_le intro: LeastI intro!: Least_equality)
  1350       with meas show ?thesis
  1350       with meas show ?thesis
  1351         by (auto intro!: Int)
  1351         by (auto intro!: sets.Int)
  1352     next
  1352     next
  1353       assume i: "(LEAST j. False) \<noteq> i"
  1353       assume i: "(LEAST j. False) \<noteq> i"
  1354       then have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
  1354       then have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
  1355         {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x}))"
  1355         {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x}))"
  1356       proof (simp add: set_eq_iff, safe)
  1356       proof (simp add: set_eq_iff, safe)
  1361       qed (auto dest: Least_le intro!: Least_equality)
  1361       qed (auto dest: Least_le intro!: Least_equality)
  1362       with meas show ?thesis
  1362       with meas show ?thesis
  1363         by auto
  1363         by auto
  1364     qed }
  1364     qed }
  1365   then have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) \<in> sets M"
  1365   then have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) \<in> sets M"
  1366     by (intro countable_UN) auto
  1366     by (intro sets.countable_UN) auto
  1367   moreover have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) =
  1367   moreover have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) =
  1368     (\<lambda>x. LEAST j. P j x) -` A \<inter> space M" by auto
  1368     (\<lambda>x. LEAST j. P j x) -` A \<inter> space M" by auto
  1369   ultimately show ?thesis by auto
  1369   ultimately show ?thesis by auto
  1370 qed
  1370 qed
  1371 
  1371 
  1415   { fix X assume "X \<subseteq> A" "f \<in> space M \<rightarrow> A"
  1415   { fix X assume "X \<subseteq> A" "f \<in> space M \<rightarrow> A"
  1416     with `finite A` have "f -` X \<inter> space M = (\<Union>a\<in>X. f -` {a} \<inter> space M)" "finite X"
  1416     with `finite A` have "f -` X \<inter> space M = (\<Union>a\<in>X. f -` {a} \<inter> space M)" "finite X"
  1417       by (auto dest: finite_subset)
  1417       by (auto dest: finite_subset)
  1418     moreover assume "\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M"
  1418     moreover assume "\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M"
  1419     ultimately have "f -` X \<inter> space M \<in> sets M"
  1419     ultimately have "f -` X \<inter> space M \<in> sets M"
  1420       using `X \<subseteq> A` by (auto intro!: finite_UN simp del: UN_simps) }
  1420       using `X \<subseteq> A` by (auto intro!: sets.finite_UN simp del: UN_simps) }
  1421   then show ?thesis
  1421   then show ?thesis
  1422     unfolding measurable_def by auto
  1422     unfolding measurable_def by auto
  1423 qed
  1423 qed
  1424 
  1424 
  1425 lemma measurable_compose_countable:
  1425 lemma measurable_compose_countable:
  1432 next
  1432 next
  1433   fix A assume A: "A \<in> sets N"
  1433   fix A assume A: "A \<in> sets N"
  1434   have "(\<lambda>x. f (g x) x) -` A \<inter> space M = (\<Union>i. (g -` {i} \<inter> space M) \<inter> (f i -` A \<inter> space M))"
  1434   have "(\<lambda>x. f (g x) x) -` A \<inter> space M = (\<Union>i. (g -` {i} \<inter> space M) \<inter> (f i -` A \<inter> space M))"
  1435     by auto
  1435     by auto
  1436   also have "\<dots> \<in> sets M" using f[THEN measurable_sets, OF A] g[THEN measurable_sets]
  1436   also have "\<dots> \<in> sets M" using f[THEN measurable_sets, OF A] g[THEN measurable_sets]
  1437     by (auto intro!: countable_UN measurable_sets)
  1437     by (auto intro!: sets.countable_UN measurable_sets)
  1438   finally show "(\<lambda>x. f (g x) x) -` A \<inter> space M \<in> sets M" .
  1438   finally show "(\<lambda>x. f (g x) x) -` A \<inter> space M \<in> sets M" .
  1439 qed
  1439 qed
  1440 
  1440 
  1441 subsection {* Measurable method *}
  1441 subsection {* Measurable method *}
  1442 
  1442 
  1464   { fix X
  1464   { fix X
  1465     have "X \<in> Pow (UNIV :: bool set)" by simp
  1465     have "X \<in> Pow (UNIV :: bool set)" by simp
  1466     then have "P -` X \<inter> space M = {x\<in>space M. ((X = {True} \<longrightarrow> P x) \<and> (X = {False} \<longrightarrow> \<not> P x) \<and> X \<noteq> {})}"
  1466     then have "P -` X \<inter> space M = {x\<in>space M. ((X = {True} \<longrightarrow> P x) \<and> (X = {False} \<longrightarrow> \<not> P x) \<and> X \<noteq> {})}"
  1467       unfolding UNIV_bool Pow_insert Pow_empty by auto
  1467       unfolding UNIV_bool Pow_insert Pow_empty by auto
  1468     then have "P -` X \<inter> space M \<in> sets M"
  1468     then have "P -` X \<inter> space M \<in> sets M"
  1469       by (auto intro!: sets_Collect_neg sets_Collect_imp sets_Collect_conj sets_Collect_const P) }
  1469       by (auto intro!: sets.sets_Collect_neg sets.sets_Collect_imp sets.sets_Collect_conj sets.sets_Collect_const P) }
  1470   then show "pred M P"
  1470   then show "pred M P"
  1471     by (auto simp: measurable_def)
  1471     by (auto simp: measurable_def)
  1472 qed
  1472 qed
  1473 
  1473 
  1474 lemma pred_sets1: "{x\<in>space M. P x} \<in> sets M \<Longrightarrow> f \<in> measurable N M \<Longrightarrow> pred N (\<lambda>x. P (f x))"
  1474 lemma pred_sets1: "{x\<in>space M. P x} \<in> sets M \<Longrightarrow> f \<in> measurable N M \<Longrightarrow> pred N (\<lambda>x. P (f x))"
  1712 
  1712 
  1713 declare
  1713 declare
  1714   measurable_compose_rev[measurable_dest]
  1714   measurable_compose_rev[measurable_dest]
  1715   pred_sets1[measurable_dest]
  1715   pred_sets1[measurable_dest]
  1716   pred_sets2[measurable_dest]
  1716   pred_sets2[measurable_dest]
  1717   sets_into_space[measurable_dest]
  1717   sets.sets_into_space[measurable_dest]
  1718 
  1718 
  1719 declare
  1719 declare
  1720   top[measurable]
  1720   sets.top[measurable]
  1721   empty_sets[measurable (raw)]
  1721   sets.empty_sets[measurable (raw)]
  1722   Un[measurable (raw)]
  1722   sets.Un[measurable (raw)]
  1723   Diff[measurable (raw)]
  1723   sets.Diff[measurable (raw)]
  1724 
  1724 
  1725 declare
  1725 declare
  1726   measurable_count_space[measurable (raw)]
  1726   measurable_count_space[measurable (raw)]
  1727   measurable_ident[measurable (raw)]
  1727   measurable_ident[measurable (raw)]
  1728   measurable_ident_sets[measurable (raw)]
  1728   measurable_ident_sets[measurable (raw)]
  1775 lemma pred_intros_countable[measurable (raw)]:
  1775 lemma pred_intros_countable[measurable (raw)]:
  1776   fixes P :: "'a \<Rightarrow> 'i :: countable \<Rightarrow> bool"
  1776   fixes P :: "'a \<Rightarrow> 'i :: countable \<Rightarrow> bool"
  1777   shows 
  1777   shows 
  1778     "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i. P x i)"
  1778     "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i. P x i)"
  1779     "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i. P x i)"
  1779     "(\<And>i. pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i. P x i)"
  1780   by (auto intro!: sets_Collect_countable_All sets_Collect_countable_Ex simp: pred_def)
  1780   by (auto intro!: sets.sets_Collect_countable_All sets.sets_Collect_countable_Ex simp: pred_def)
  1781 
  1781 
  1782 lemma pred_intros_countable_bounded[measurable (raw)]:
  1782 lemma pred_intros_countable_bounded[measurable (raw)]:
  1783   fixes X :: "'i :: countable set"
  1783   fixes X :: "'i :: countable set"
  1784   shows 
  1784   shows 
  1785     "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>X. N x i))"
  1785     "(\<And>i. i \<in> X \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>X. N x i))"
  1791 lemma pred_intros_finite[measurable (raw)]:
  1791 lemma pred_intros_finite[measurable (raw)]:
  1792   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>I. N x i))"
  1792   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Inter>i\<in>I. N x i))"
  1793   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Union>i\<in>I. N x i))"
  1793   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. x \<in> N x i)) \<Longrightarrow> pred M (\<lambda>x. x \<in> (\<Union>i\<in>I. N x i))"
  1794   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i\<in>I. P x i)"
  1794   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<forall>i\<in>I. P x i)"
  1795   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i\<in>I. P x i)"
  1795   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> pred M (\<lambda>x. P x i)) \<Longrightarrow> pred M (\<lambda>x. \<exists>i\<in>I. P x i)"
  1796   by (auto intro!: sets_Collect_finite_Ex sets_Collect_finite_All simp: iff_conv_conj_imp pred_def)
  1796   by (auto intro!: sets.sets_Collect_finite_Ex sets.sets_Collect_finite_All simp: iff_conv_conj_imp pred_def)
  1797 
  1797 
  1798 lemma countable_Un_Int[measurable (raw)]:
  1798 lemma countable_Un_Int[measurable (raw)]:
  1799   "(\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Union>i\<in>I. N i) \<in> sets M"
  1799   "(\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Union>i\<in>I. N i) \<in> sets M"
  1800   "I \<noteq> {} \<Longrightarrow> (\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Inter>i\<in>I. N i) \<in> sets M"
  1800   "I \<noteq> {} \<Longrightarrow> (\<And>i :: 'i :: countable. i \<in> I \<Longrightarrow> N i \<in> sets M) \<Longrightarrow> (\<Inter>i\<in>I. N i) \<in> sets M"
  1801   by auto
  1801   by auto
  1852   assumes f: "f \<in> measurable M N" and c: "{c <..} \<in> sets N" shows "pred M (\<lambda>x. c < f x)"
  1852   assumes f: "f \<in> measurable M N" and c: "{c <..} \<in> sets N" shows "pred M (\<lambda>x. c < f x)"
  1853   using measurable_sets[OF f c]
  1853   using measurable_sets[OF f c]
  1854   by (auto simp: Int_def conj_commute eq_commute pred_def)
  1854   by (auto simp: Int_def conj_commute eq_commute pred_def)
  1855 
  1855 
  1856 declare
  1856 declare
  1857   Int[measurable (raw)]
  1857   sets.Int[measurable (raw)]
  1858 
  1858 
  1859 lemma pred_in_If[measurable (raw)]:
  1859 lemma pred_in_If[measurable (raw)]:
  1860   "(P \<Longrightarrow> pred M (\<lambda>x. x \<in> A x)) \<Longrightarrow> (\<not> P \<Longrightarrow> pred M (\<lambda>x. x \<in> B x)) \<Longrightarrow>
  1860   "(P \<Longrightarrow> pred M (\<lambda>x. x \<in> A x)) \<Longrightarrow> (\<not> P \<Longrightarrow> pred M (\<lambda>x. x \<in> B x)) \<Longrightarrow>
  1861     pred M (\<lambda>x. x \<in> (if P then A x else B x))"
  1861     pred M (\<lambda>x. x \<in> (if P then A x else B x))"
  1862   by auto
  1862   by auto