src/HOL/Analysis/Sigma_Algebra.thy
changeset 70136 f03a01a18c6e
parent 69768 7e4966eaf781
child 74362 0135a0c77b64
equal deleted inserted replaced
70135:ad6d4a14adb5 70136:f03a01a18c6e
    28   subsets of the universe. A sigma algebra is such a set that has
    28   subsets of the universe. A sigma algebra is such a set that has
    29   three very natural and desirable properties.\<close>
    29   three very natural and desirable properties.\<close>
    30 
    30 
    31 subsection \<open>Families of sets\<close>
    31 subsection \<open>Families of sets\<close>
    32 
    32 
    33 locale%important subset_class =
    33 locale\<^marker>\<open>tag important\<close> subset_class =
    34   fixes \<Omega> :: "'a set" and M :: "'a set set"
    34   fixes \<Omega> :: "'a set" and M :: "'a set set"
    35   assumes space_closed: "M \<subseteq> Pow \<Omega>"
    35   assumes space_closed: "M \<subseteq> Pow \<Omega>"
    36 
    36 
    37 lemma (in subset_class) sets_into_space: "x \<in> M \<Longrightarrow> x \<subseteq> \<Omega>"
    37 lemma (in subset_class) sets_into_space: "x \<in> M \<Longrightarrow> x \<subseteq> \<Omega>"
    38   by (metis PowD contra_subsetD space_closed)
    38   by (metis PowD contra_subsetD space_closed)
    39 
    39 
    40 subsubsection \<open>Semiring of sets\<close>
    40 subsubsection \<open>Semiring of sets\<close>
    41 
    41 
    42 locale%important semiring_of_sets = subset_class +
    42 locale\<^marker>\<open>tag important\<close> semiring_of_sets = subset_class +
    43   assumes empty_sets[iff]: "{} \<in> M"
    43   assumes empty_sets[iff]: "{} \<in> M"
    44   assumes Int[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<inter> b \<in> M"
    44   assumes Int[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<inter> b \<in> M"
    45   assumes Diff_cover:
    45   assumes Diff_cover:
    46     "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> \<exists>C\<subseteq>M. finite C \<and> disjoint C \<and> a - b = \<Union>C"
    46     "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> \<exists>C\<subseteq>M. finite C \<and> disjoint C \<and> a - b = \<Union>C"
    47 
    47 
    74   with assms show ?thesis by auto
    74   with assms show ?thesis by auto
    75 qed
    75 qed
    76 
    76 
    77 subsubsection \<open>Ring of sets\<close>
    77 subsubsection \<open>Ring of sets\<close>
    78 
    78 
    79 locale%important ring_of_sets = semiring_of_sets +
    79 locale\<^marker>\<open>tag important\<close> ring_of_sets = semiring_of_sets +
    80   assumes Un [intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<union> b \<in> M"
    80   assumes Un [intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<union> b \<in> M"
    81 
    81 
    82 lemma (in ring_of_sets) finite_Union [intro]:
    82 lemma (in ring_of_sets) finite_Union [intro]:
    83   "finite X \<Longrightarrow> X \<subseteq> M \<Longrightarrow> \<Union>X \<in> M"
    83   "finite X \<Longrightarrow> X \<subseteq> M \<Longrightarrow> \<Union>X \<in> M"
    84   by (induct set: finite) (auto simp add: Un)
    84   by (induct set: finite) (auto simp add: Un)
   140   with assms show ?thesis by auto
   140   with assms show ?thesis by auto
   141 qed
   141 qed
   142 
   142 
   143 subsubsection \<open>Algebra of sets\<close>
   143 subsubsection \<open>Algebra of sets\<close>
   144 
   144 
   145 locale%important algebra = ring_of_sets +
   145 locale\<^marker>\<open>tag important\<close> algebra = ring_of_sets +
   146   assumes top [iff]: "\<Omega> \<in> M"
   146   assumes top [iff]: "\<Omega> \<in> M"
   147 
   147 
   148 lemma (in algebra) compl_sets [intro]:
   148 lemma (in algebra) compl_sets [intro]:
   149   "a \<in> M \<Longrightarrow> \<Omega> - a \<in> M"
   149   "a \<in> M \<Longrightarrow> \<Omega> - a \<in> M"
   150   by auto
   150   by auto
   219 
   219 
   220 lemma algebra_single_set:
   220 lemma algebra_single_set:
   221   "X \<subseteq> S \<Longrightarrow> algebra S { {}, X, S - X, S }"
   221   "X \<subseteq> S \<Longrightarrow> algebra S { {}, X, S - X, S }"
   222   by (auto simp: algebra_iff_Int)
   222   by (auto simp: algebra_iff_Int)
   223 
   223 
   224 subsubsection%unimportant \<open>Restricted algebras\<close>
   224 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Restricted algebras\<close>
   225 
   225 
   226 abbreviation (in algebra)
   226 abbreviation (in algebra)
   227   "restricted_space A \<equiv> ((\<inter>) A) ` M"
   227   "restricted_space A \<equiv> ((\<inter>) A) ` M"
   228 
   228 
   229 lemma (in algebra) restricted_algebra:
   229 lemma (in algebra) restricted_algebra:
   230   assumes "A \<in> M" shows "algebra A (restricted_space A)"
   230   assumes "A \<in> M" shows "algebra A (restricted_space A)"
   231   using assms by (auto simp: algebra_iff_Int)
   231   using assms by (auto simp: algebra_iff_Int)
   232 
   232 
   233 subsubsection \<open>Sigma Algebras\<close>
   233 subsubsection \<open>Sigma Algebras\<close>
   234 
   234 
   235 locale%important sigma_algebra = algebra +
   235 locale\<^marker>\<open>tag important\<close> sigma_algebra = algebra +
   236   assumes countable_nat_UN [intro]: "\<And>A. range A \<subseteq> M \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
   236   assumes countable_nat_UN [intro]: "\<And>A. range A \<subseteq> M \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
   237 
   237 
   238 lemma (in algebra) is_sigma_algebra:
   238 lemma (in algebra) is_sigma_algebra:
   239   assumes "finite M"
   239   assumes "finite M"
   240   shows "sigma_algebra \<Omega> M"
   240   shows "sigma_algebra \<Omega> M"
   429 lemma sigma_algebra_single_set:
   429 lemma sigma_algebra_single_set:
   430   assumes "X \<subseteq> S"
   430   assumes "X \<subseteq> S"
   431   shows "sigma_algebra S { {}, X, S - X, S }"
   431   shows "sigma_algebra S { {}, X, S - X, S }"
   432   using algebra.is_sigma_algebra[OF algebra_single_set[OF \<open>X \<subseteq> S\<close>]] by simp
   432   using algebra.is_sigma_algebra[OF algebra_single_set[OF \<open>X \<subseteq> S\<close>]] by simp
   433 
   433 
   434 subsubsection%unimportant \<open>Binary Unions\<close>
   434 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Binary Unions\<close>
   435 
   435 
   436 definition binary :: "'a \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a"
   436 definition binary :: "'a \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a"
   437   where "binary a b =  (\<lambda>x. b)(0 := a)"
   437   where "binary a b =  (\<lambda>x. b)(0 := a)"
   438 
   438 
   439 lemma range_binary_eq: "range(binary a b) = {a,b}"
   439 lemma range_binary_eq: "range(binary a b) = {a,b}"
   471 qed
   471 qed
   472 
   472 
   473 
   473 
   474 subsubsection \<open>Initial Sigma Algebra\<close>
   474 subsubsection \<open>Initial Sigma Algebra\<close>
   475 
   475 
   476 text%important \<open>Sigma algebras can naturally be created as the closure of any set of
   476 text\<^marker>\<open>tag important\<close> \<open>Sigma algebras can naturally be created as the closure of any set of
   477   M with regard to the properties just postulated.\<close>
   477   M with regard to the properties just postulated.\<close>
   478 
   478 
   479 inductive_set%important sigma_sets :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set"
   479 inductive_set\<^marker>\<open>tag important\<close> sigma_sets :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set"
   480   for sp :: "'a set" and A :: "'a set set"
   480   for sp :: "'a set" and A :: "'a set set"
   481   where
   481   where
   482     Basic[intro, simp]: "a \<in> A \<Longrightarrow> a \<in> sigma_sets sp A"
   482     Basic[intro, simp]: "a \<in> A \<Longrightarrow> a \<in> sigma_sets sp A"
   483   | Empty: "{} \<in> sigma_sets sp A"
   483   | Empty: "{} \<in> sigma_sets sp A"
   484   | Compl: "a \<in> sigma_sets sp A \<Longrightarrow> sp - a \<in> sigma_sets sp A"
   484   | Compl: "a \<in> sigma_sets sp A \<Longrightarrow> sp - a \<in> sigma_sets sp A"
   817   hence "(\<Union>i. disjointed A i) \<in> M"
   817   hence "(\<Union>i. disjointed A i) \<in> M"
   818     by (simp add: algebra.range_disjointed_sets'[of \<Omega>] M A disjoint_family_disjointed)
   818     by (simp add: algebra.range_disjointed_sets'[of \<Omega>] M A disjoint_family_disjointed)
   819   thus "(\<Union>i::nat. A i) \<in> M" by (simp add: UN_disjointed_eq)
   819   thus "(\<Union>i::nat. A i) \<in> M" by (simp add: UN_disjointed_eq)
   820 qed
   820 qed
   821 
   821 
   822 subsubsection%unimportant \<open>Ring generated by a semiring\<close>
   822 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Ring generated by a semiring\<close>
   823 
   823 
   824 definition (in semiring_of_sets) generated_ring :: "'a set set" where
   824 definition (in semiring_of_sets) generated_ring :: "'a set set" where
   825   "generated_ring = { \<Union>C | C. C \<subseteq> M \<and> finite C \<and> disjoint C }"
   825   "generated_ring = { \<Union>C | C. C \<subseteq> M \<and> finite C \<and> disjoint C }"
   826 
   826 
   827 lemma (in semiring_of_sets) generated_ringE[elim?]:
   827 lemma (in semiring_of_sets) generated_ringE[elim?]:
   948     using space_closed by (rule sigma_algebra_sigma_sets)
   948     using space_closed by (rule sigma_algebra_sigma_sets)
   949   show "sigma_sets \<Omega> generated_ring \<subseteq> sigma_sets \<Omega> M"
   949   show "sigma_sets \<Omega> generated_ring \<subseteq> sigma_sets \<Omega> M"
   950     by (blast intro!: sigma_sets_mono elim: generated_ringE)
   950     by (blast intro!: sigma_sets_mono elim: generated_ringE)
   951 qed (auto intro!: generated_ringI_Basic sigma_sets_mono)
   951 qed (auto intro!: generated_ringI_Basic sigma_sets_mono)
   952 
   952 
   953 subsubsection%unimportant \<open>A Two-Element Series\<close>
   953 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>A Two-Element Series\<close>
   954 
   954 
   955 definition binaryset :: "'a set \<Rightarrow> 'a set \<Rightarrow> nat \<Rightarrow> 'a set"
   955 definition binaryset :: "'a set \<Rightarrow> 'a set \<Rightarrow> nat \<Rightarrow> 'a set"
   956   where "binaryset A B = (\<lambda>x. {})(0 := A, Suc 0 := B)"
   956   where "binaryset A B = (\<lambda>x. {})(0 := A, Suc 0 := B)"
   957 
   957 
   958 lemma range_binaryset_eq: "range(binaryset A B) = {A,B,{}}"
   958 lemma range_binaryset_eq: "range(binaryset A B) = {A,B,{}}"
   964 lemma UN_binaryset_eq: "(\<Union>i. binaryset A B i) = A \<union> B"
   964 lemma UN_binaryset_eq: "(\<Union>i. binaryset A B i) = A \<union> B"
   965   by (simp add: range_binaryset_eq cong del: SUP_cong_simp)
   965   by (simp add: range_binaryset_eq cong del: SUP_cong_simp)
   966 
   966 
   967 subsubsection \<open>Closed CDI\<close>
   967 subsubsection \<open>Closed CDI\<close>
   968 
   968 
   969 definition%important closed_cdi :: "'a set \<Rightarrow> 'a set set \<Rightarrow> bool" where
   969 definition\<^marker>\<open>tag important\<close> closed_cdi :: "'a set \<Rightarrow> 'a set set \<Rightarrow> bool" where
   970   "closed_cdi \<Omega> M \<longleftrightarrow>
   970   "closed_cdi \<Omega> M \<longleftrightarrow>
   971    M \<subseteq> Pow \<Omega> &
   971    M \<subseteq> Pow \<Omega> &
   972    (\<forall>s \<in> M. \<Omega> - s \<in> M) &
   972    (\<forall>s \<in> M. \<Omega> - s \<in> M) &
   973    (\<forall>A. (range A \<subseteq> M) & (A 0 = {}) & (\<forall>n. A n \<subseteq> A (Suc n)) \<longrightarrow>
   973    (\<forall>A. (range A \<subseteq> M) & (A 0 = {}) & (\<forall>n. A n \<subseteq> A (Suc n)) \<longrightarrow>
   974         (\<Union>i. A i) \<in> M) &
   974         (\<Union>i. A i) \<in> M) &
  1198     by blast
  1198     by blast
  1199 qed
  1199 qed
  1200 
  1200 
  1201 subsubsection \<open>Dynkin systems\<close>
  1201 subsubsection \<open>Dynkin systems\<close>
  1202 
  1202 
  1203 locale%important Dynkin_system = subset_class +
  1203 locale\<^marker>\<open>tag important\<close> Dynkin_system = subset_class +
  1204   assumes space: "\<Omega> \<in> M"
  1204   assumes space: "\<Omega> \<in> M"
  1205     and   compl[intro!]: "\<And>A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M"
  1205     and   compl[intro!]: "\<And>A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M"
  1206     and   UN[intro!]: "\<And>A. disjoint_family A \<Longrightarrow> range A \<subseteq> M
  1206     and   UN[intro!]: "\<And>A. disjoint_family A \<Longrightarrow> range A \<subseteq> M
  1207                            \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
  1207                            \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
  1208 
  1208 
  1260   show ?thesis using sets_into_space by (fastforce intro!: Dynkin_systemI)
  1260   show ?thesis using sets_into_space by (fastforce intro!: Dynkin_systemI)
  1261 qed
  1261 qed
  1262 
  1262 
  1263 subsubsection "Intersection sets systems"
  1263 subsubsection "Intersection sets systems"
  1264 
  1264 
  1265 definition%important Int_stable :: "'a set set \<Rightarrow> bool" where
  1265 definition\<^marker>\<open>tag important\<close> Int_stable :: "'a set set \<Rightarrow> bool" where
  1266 "Int_stable M \<longleftrightarrow> (\<forall> a \<in> M. \<forall> b \<in> M. a \<inter> b \<in> M)"
  1266 "Int_stable M \<longleftrightarrow> (\<forall> a \<in> M. \<forall> b \<in> M. a \<inter> b \<in> M)"
  1267 
  1267 
  1268 lemma (in algebra) Int_stable: "Int_stable M"
  1268 lemma (in algebra) Int_stable: "Int_stable M"
  1269   unfolding Int_stable_def by auto
  1269   unfolding Int_stable_def by auto
  1270 
  1270 
  1301   qed auto
  1301   qed auto
  1302 qed
  1302 qed
  1303 
  1303 
  1304 subsubsection "Smallest Dynkin systems"
  1304 subsubsection "Smallest Dynkin systems"
  1305 
  1305 
  1306 definition%important Dynkin :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set" where
  1306 definition\<^marker>\<open>tag important\<close> Dynkin :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set" where
  1307   "Dynkin \<Omega> M =  (\<Inter>{D. Dynkin_system \<Omega> D \<and> M \<subseteq> D})"
  1307   "Dynkin \<Omega> M =  (\<Inter>{D. Dynkin_system \<Omega> D \<and> M \<subseteq> D})"
  1308 
  1308 
  1309 lemma Dynkin_system_Dynkin:
  1309 lemma Dynkin_system_Dynkin:
  1310   assumes "M \<subseteq> Pow (\<Omega>)"
  1310   assumes "M \<subseteq> Pow (\<Omega>)"
  1311   shows "Dynkin_system \<Omega> (Dynkin \<Omega> M)"
  1311   shows "Dynkin_system \<Omega> (Dynkin \<Omega> M)"
  1448     using assms by (auto simp: Dynkin_def)
  1448     using assms by (auto simp: Dynkin_def)
  1449 qed
  1449 qed
  1450 
  1450 
  1451 subsubsection \<open>Induction rule for intersection-stable generators\<close>
  1451 subsubsection \<open>Induction rule for intersection-stable generators\<close>
  1452 
  1452 
  1453 text%important \<open>The reason to introduce Dynkin-systems is the following induction rules for \<open>\<sigma>\<close>-algebras
  1453 text\<^marker>\<open>tag important\<close> \<open>The reason to introduce Dynkin-systems is the following induction rules for \<open>\<sigma>\<close>-algebras
  1454 generated by a generator closed under intersection.\<close>
  1454 generated by a generator closed under intersection.\<close>
  1455 
  1455 
  1456 proposition sigma_sets_induct_disjoint[consumes 3, case_names basic empty compl union]:
  1456 proposition sigma_sets_induct_disjoint[consumes 3, case_names basic empty compl union]:
  1457   assumes "Int_stable G"
  1457   assumes "Int_stable G"
  1458     and closed: "G \<subseteq> Pow \<Omega>"
  1458     and closed: "G \<subseteq> Pow \<Omega>"
  1474   with A show ?thesis by auto
  1474   with A show ?thesis by auto
  1475 qed
  1475 qed
  1476 
  1476 
  1477 subsection \<open>Measure type\<close>
  1477 subsection \<open>Measure type\<close>
  1478 
  1478 
  1479 definition%important positive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
  1479 definition\<^marker>\<open>tag important\<close> positive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
  1480   "positive M \<mu> \<longleftrightarrow> \<mu> {} = 0"
  1480   "positive M \<mu> \<longleftrightarrow> \<mu> {} = 0"
  1481 
  1481 
  1482 definition%important countably_additive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
  1482 definition\<^marker>\<open>tag important\<close> countably_additive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
  1483 "countably_additive M f \<longleftrightarrow>
  1483 "countably_additive M f \<longleftrightarrow>
  1484   (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow>
  1484   (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow>
  1485     (\<Sum>i. f (A i)) = f (\<Union>i. A i))"
  1485     (\<Sum>i. f (A i)) = f (\<Union>i. A i))"
  1486 
  1486 
  1487 definition%important measure_space :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
  1487 definition\<^marker>\<open>tag important\<close> measure_space :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
  1488 "measure_space \<Omega> A \<mu> \<longleftrightarrow>
  1488 "measure_space \<Omega> A \<mu> \<longleftrightarrow>
  1489   sigma_algebra \<Omega> A \<and> positive A \<mu> \<and> countably_additive A \<mu>"
  1489   sigma_algebra \<Omega> A \<and> positive A \<mu> \<and> countably_additive A \<mu>"
  1490 
  1490 
  1491 typedef%important 'a measure =
  1491 typedef\<^marker>\<open>tag important\<close> 'a measure =
  1492   "{(\<Omega>::'a set, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu> }"
  1492   "{(\<Omega>::'a set, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu> }"
  1493 proof%unimportant
  1493 proof
  1494   have "sigma_algebra UNIV {{}, UNIV}"
  1494   have "sigma_algebra UNIV {{}, UNIV}"
  1495     by (auto simp: sigma_algebra_iff2)
  1495     by (auto simp: sigma_algebra_iff2)
  1496   then show "(UNIV, {{}, UNIV}, \<lambda>A. 0) \<in> {(\<Omega>, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu>} "
  1496   then show "(UNIV, {{}, UNIV}, \<lambda>A. 0) \<in> {(\<Omega>, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu>} "
  1497     by (auto simp: measure_space_def positive_def countably_additive_def)
  1497     by (auto simp: measure_space_def positive_def countably_additive_def)
  1498 qed
  1498 qed
  1499 
  1499 
  1500 definition%important space :: "'a measure \<Rightarrow> 'a set" where
  1500 definition\<^marker>\<open>tag important\<close> space :: "'a measure \<Rightarrow> 'a set" where
  1501   "space M = fst (Rep_measure M)"
  1501   "space M = fst (Rep_measure M)"
  1502 
  1502 
  1503 definition%important sets :: "'a measure \<Rightarrow> 'a set set" where
  1503 definition\<^marker>\<open>tag important\<close> sets :: "'a measure \<Rightarrow> 'a set set" where
  1504   "sets M = fst (snd (Rep_measure M))"
  1504   "sets M = fst (snd (Rep_measure M))"
  1505 
  1505 
  1506 definition%important emeasure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> ennreal" where
  1506 definition\<^marker>\<open>tag important\<close> emeasure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> ennreal" where
  1507   "emeasure M = snd (snd (Rep_measure M))"
  1507   "emeasure M = snd (snd (Rep_measure M))"
  1508 
  1508 
  1509 definition%important measure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> real" where
  1509 definition\<^marker>\<open>tag important\<close> measure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> real" where
  1510   "measure M A = enn2real (emeasure M A)"
  1510   "measure M A = enn2real (emeasure M A)"
  1511 
  1511 
  1512 declare [[coercion sets]]
  1512 declare [[coercion sets]]
  1513 
  1513 
  1514 declare [[coercion measure]]
  1514 declare [[coercion measure]]
  1519   by (cases M) (auto simp: space_def sets_def emeasure_def Abs_measure_inverse)
  1519   by (cases M) (auto simp: space_def sets_def emeasure_def Abs_measure_inverse)
  1520 
  1520 
  1521 interpretation sets: sigma_algebra "space M" "sets M" for M :: "'a measure"
  1521 interpretation sets: sigma_algebra "space M" "sets M" for M :: "'a measure"
  1522   using measure_space[of M] by (auto simp: measure_space_def)
  1522   using measure_space[of M] by (auto simp: measure_space_def)
  1523 
  1523 
  1524 definition%important measure_of :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> 'a measure"
  1524 definition\<^marker>\<open>tag important\<close> measure_of :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> 'a measure"
  1525   where
  1525   where
  1526 "measure_of \<Omega> A \<mu> =
  1526 "measure_of \<Omega> A \<mu> =
  1527   Abs_measure (\<Omega>, if A \<subseteq> Pow \<Omega> then sigma_sets \<Omega> A else {{}, \<Omega>},
  1527   Abs_measure (\<Omega>, if A \<subseteq> Pow \<Omega> then sigma_sets \<Omega> A else {{}, \<Omega>},
  1528     \<lambda>a. if a \<in> sigma_sets \<Omega> A \<and> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> then \<mu> a else 0)"
  1528     \<lambda>a. if a \<in> sigma_sets \<Omega> A \<and> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> then \<mu> a else 0)"
  1529 
  1529 
  1738   shows "sigma \<Omega> M = sigma \<Omega> N"
  1738   shows "sigma \<Omega> M = sigma \<Omega> N"
  1739   by (rule measure_eqI) (simp_all add: emeasure_sigma)
  1739   by (rule measure_eqI) (simp_all add: emeasure_sigma)
  1740 
  1740 
  1741 subsubsection \<open>Measurable functions\<close>
  1741 subsubsection \<open>Measurable functions\<close>
  1742 
  1742 
  1743 definition%important measurable :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) set"
  1743 definition\<^marker>\<open>tag important\<close> measurable :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) set"
  1744   (infixr "\<rightarrow>\<^sub>M" 60) where
  1744   (infixr "\<rightarrow>\<^sub>M" 60) where
  1745 "measurable A B = {f \<in> space A \<rightarrow> space B. \<forall>y \<in> sets B. f -` y \<inter> space A \<in> sets A}"
  1745 "measurable A B = {f \<in> space A \<rightarrow> space B. \<forall>y \<in> sets B. f -` y \<inter> space A \<in> sets A}"
  1746 
  1746 
  1747 lemma measurableI:
  1747 lemma measurableI:
  1748   "(\<And>x. x \<in> space M \<Longrightarrow> f x \<in> space N) \<Longrightarrow> (\<And>A. A \<in> sets N \<Longrightarrow> f -` A \<inter> space M \<in> sets M) \<Longrightarrow>
  1748   "(\<And>x. x \<in> space M \<Longrightarrow> f x \<in> space N) \<Longrightarrow> (\<And>A. A \<in> sets N \<Longrightarrow> f -` A \<inter> space M \<in> sets M) \<Longrightarrow>
  1901     measurable (measure_of \<Omega> M \<mu>) N \<subseteq> measurable (measure_of \<Omega> M' \<mu>') N"
  1901     measurable (measure_of \<Omega> M \<mu>) N \<subseteq> measurable (measure_of \<Omega> M' \<mu>') N"
  1902   using measure_of_subset[of M' \<Omega> M] by (auto simp add: measurable_def)
  1902   using measure_of_subset[of M' \<Omega> M] by (auto simp add: measurable_def)
  1903 
  1903 
  1904 subsubsection \<open>Counting space\<close>
  1904 subsubsection \<open>Counting space\<close>
  1905 
  1905 
  1906 definition%important count_space :: "'a set \<Rightarrow> 'a measure" where
  1906 definition\<^marker>\<open>tag important\<close> count_space :: "'a set \<Rightarrow> 'a measure" where
  1907 "count_space \<Omega> = measure_of \<Omega> (Pow \<Omega>) (\<lambda>A. if finite A then of_nat (card A) else \<infinity>)"
  1907 "count_space \<Omega> = measure_of \<Omega> (Pow \<Omega>) (\<lambda>A. if finite A then of_nat (card A) else \<infinity>)"
  1908 
  1908 
  1909 lemma
  1909 lemma
  1910   shows space_count_space[simp]: "space (count_space \<Omega>) = \<Omega>"
  1910   shows space_count_space[simp]: "space (count_space \<Omega>) = \<Omega>"
  1911     and sets_count_space[simp]: "sets (count_space \<Omega>) = Pow \<Omega>"
  1911     and sets_count_space[simp]: "sets (count_space \<Omega>) = Pow \<Omega>"
  1977 
  1977 
  1978 lemma measurable_empty_iff:
  1978 lemma measurable_empty_iff:
  1979   "space N = {} \<Longrightarrow> f \<in> measurable M N \<longleftrightarrow> space M = {}"
  1979   "space N = {} \<Longrightarrow> f \<in> measurable M N \<longleftrightarrow> space M = {}"
  1980   by (auto simp add: measurable_def Pi_iff)
  1980   by (auto simp add: measurable_def Pi_iff)
  1981 
  1981 
  1982 subsubsection%unimportant \<open>Extend measure\<close>
  1982 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Extend measure\<close>
  1983 
  1983 
  1984 definition extend_measure :: "'a set \<Rightarrow> 'b set \<Rightarrow> ('b \<Rightarrow> 'a set) \<Rightarrow> ('b \<Rightarrow> ennreal) \<Rightarrow> 'a measure"
  1984 definition extend_measure :: "'a set \<Rightarrow> 'b set \<Rightarrow> ('b \<Rightarrow> 'a set) \<Rightarrow> ('b \<Rightarrow> ennreal) \<Rightarrow> 'a measure"
  1985   where
  1985   where
  1986 "extend_measure \<Omega> I G \<mu> =
  1986 "extend_measure \<Omega> I G \<mu> =
  1987   (if (\<exists>\<mu>'. (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>') \<and> \<not> (\<forall>i\<in>I. \<mu> i = 0)
  1987   (if (\<exists>\<mu>'. (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>') \<and> \<not> (\<forall>i\<in>I. \<mu> i = 0)
  2041   using emeasure_extend_measure[OF M _ _ ms(2,3), of "(i,j)"] eq ms(1) \<open>I i j\<close>
  2041   using emeasure_extend_measure[OF M _ _ ms(2,3), of "(i,j)"] eq ms(1) \<open>I i j\<close>
  2042   by (auto simp: subset_eq)
  2042   by (auto simp: subset_eq)
  2043 
  2043 
  2044 subsection \<open>The smallest \<open>\<sigma>\<close>-algebra regarding a function\<close>
  2044 subsection \<open>The smallest \<open>\<sigma>\<close>-algebra regarding a function\<close>
  2045 
  2045 
  2046 definition%important vimage_algebra :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure \<Rightarrow> 'a measure" where
  2046 definition\<^marker>\<open>tag important\<close> vimage_algebra :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure \<Rightarrow> 'a measure" where
  2047   "vimage_algebra X f M = sigma X {f -` A \<inter> X | A. A \<in> sets M}"
  2047   "vimage_algebra X f M = sigma X {f -` A \<inter> X | A. A \<in> sets M}"
  2048 
  2048 
  2049 lemma space_vimage_algebra[simp]: "space (vimage_algebra X f M) = X"
  2049 lemma space_vimage_algebra[simp]: "space (vimage_algebra X f M) = X"
  2050   unfolding vimage_algebra_def by (rule space_measure_of) auto
  2050   unfolding vimage_algebra_def by (rule space_measure_of) auto
  2051 
  2051