src/HOL/Probability/Sigma_Algebra.thy
 author hoelzl Tue Jan 18 21:37:23 2011 +0100 (2011-01-18) changeset 41654 32fe42892983 parent 41543 646a1399e792 child 41689 3e39b0e730d6 permissions -rw-r--r--
Gauge measure removed
```     1 (*  Title:      Sigma_Algebra.thy
```
```     2     Author:     Stefan Richter, Markus Wenzel, TU Muenchen
```
```     3     Plus material from the Hurd/Coble measure theory development,
```
```     4     translated by Lawrence Paulson.
```
```     5 *)
```
```     6
```
```     7 header {* Sigma Algebras *}
```
```     8
```
```     9 theory Sigma_Algebra
```
```    10 imports
```
```    11   Main
```
```    12   "~~/src/HOL/Library/Countable"
```
```    13   "~~/src/HOL/Library/FuncSet"
```
```    14   "~~/src/HOL/Library/Indicator_Function"
```
```    15 begin
```
```    16
```
```    17 text {* Sigma algebras are an elementary concept in measure
```
```    18   theory. To measure --- that is to integrate --- functions, we first have
```
```    19   to measure sets. Unfortunately, when dealing with a large universe,
```
```    20   it is often not possible to consistently assign a measure to every
```
```    21   subset. Therefore it is necessary to define the set of measurable
```
```    22   subsets of the universe. A sigma algebra is such a set that has
```
```    23   three very natural and desirable properties. *}
```
```    24
```
```    25 subsection {* Algebras *}
```
```    26
```
```    27 record 'a algebra =
```
```    28   space :: "'a set"
```
```    29   sets :: "'a set set"
```
```    30
```
```    31 locale algebra =
```
```    32   fixes M :: "'a algebra"
```
```    33   assumes space_closed: "sets M \<subseteq> Pow (space M)"
```
```    34      and  empty_sets [iff]: "{} \<in> sets M"
```
```    35      and  compl_sets [intro]: "!!a. a \<in> sets M \<Longrightarrow> space M - a \<in> sets M"
```
```    36      and  Un [intro]: "!!a b. a \<in> sets M \<Longrightarrow> b \<in> sets M \<Longrightarrow> a \<union> b \<in> sets M"
```
```    37
```
```    38 lemma (in algebra) top [iff]: "space M \<in> sets M"
```
```    39   by (metis Diff_empty compl_sets empty_sets)
```
```    40
```
```    41 lemma (in algebra) sets_into_space: "x \<in> sets M \<Longrightarrow> x \<subseteq> space M"
```
```    42   by (metis PowD contra_subsetD space_closed)
```
```    43
```
```    44 lemma (in algebra) Int [intro]:
```
```    45   assumes a: "a \<in> sets M" and b: "b \<in> sets M" shows "a \<inter> b \<in> sets M"
```
```    46 proof -
```
```    47   have "((space M - a) \<union> (space M - b)) \<in> sets M"
```
```    48     by (metis a b compl_sets Un)
```
```    49   moreover
```
```    50   have "a \<inter> b = space M - ((space M - a) \<union> (space M - b))"
```
```    51     using space_closed a b
```
```    52     by blast
```
```    53   ultimately show ?thesis
```
```    54     by (metis compl_sets)
```
```    55 qed
```
```    56
```
```    57 lemma (in algebra) Diff [intro]:
```
```    58   assumes a: "a \<in> sets M" and b: "b \<in> sets M" shows "a - b \<in> sets M"
```
```    59 proof -
```
```    60   have "(a \<inter> (space M - b)) \<in> sets M"
```
```    61     by (metis a b compl_sets Int)
```
```    62   moreover
```
```    63   have "a - b = (a \<inter> (space M - b))"
```
```    64     by (metis Int_Diff Int_absorb1 Int_commute a sets_into_space)
```
```    65   ultimately show ?thesis
```
```    66     by metis
```
```    67 qed
```
```    68
```
```    69 lemma (in algebra) finite_union [intro]:
```
```    70   "finite X \<Longrightarrow> X \<subseteq> sets M \<Longrightarrow> Union X \<in> sets M"
```
```    71   by (induct set: finite) (auto simp add: Un)
```
```    72
```
```    73 lemma algebra_iff_Int:
```
```    74      "algebra M \<longleftrightarrow>
```
```    75        sets M \<subseteq> Pow (space M) & {} \<in> sets M &
```
```    76        (\<forall>a \<in> sets M. space M - a \<in> sets M) &
```
```    77        (\<forall>a \<in> sets M. \<forall> b \<in> sets M. a \<inter> b \<in> sets M)"
```
```    78 proof (auto simp add: algebra.Int, auto simp add: algebra_def)
```
```    79   fix a b
```
```    80   assume ab: "sets M \<subseteq> Pow (space M)"
```
```    81              "\<forall>a\<in>sets M. space M - a \<in> sets M"
```
```    82              "\<forall>a\<in>sets M. \<forall>b\<in>sets M. a \<inter> b \<in> sets M"
```
```    83              "a \<in> sets M" "b \<in> sets M"
```
```    84   hence "a \<union> b = space M - ((space M - a) \<inter> (space M - b))"
```
```    85     by blast
```
```    86   also have "... \<in> sets M"
```
```    87     by (metis ab)
```
```    88   finally show "a \<union> b \<in> sets M" .
```
```    89 qed
```
```    90
```
```    91 lemma (in algebra) insert_in_sets:
```
```    92   assumes "{x} \<in> sets M" "A \<in> sets M" shows "insert x A \<in> sets M"
```
```    93 proof -
```
```    94   have "{x} \<union> A \<in> sets M" using assms by (rule Un)
```
```    95   thus ?thesis by auto
```
```    96 qed
```
```    97
```
```    98 lemma (in algebra) Int_space_eq1 [simp]: "x \<in> sets M \<Longrightarrow> space M \<inter> x = x"
```
```    99   by (metis Int_absorb1 sets_into_space)
```
```   100
```
```   101 lemma (in algebra) Int_space_eq2 [simp]: "x \<in> sets M \<Longrightarrow> x \<inter> space M = x"
```
```   102   by (metis Int_absorb2 sets_into_space)
```
```   103
```
```   104 section {* Restricted algebras *}
```
```   105
```
```   106 abbreviation (in algebra)
```
```   107   "restricted_space A \<equiv> \<lparr> space = A, sets = (\<lambda>S. (A \<inter> S)) ` sets M \<rparr>"
```
```   108
```
```   109 lemma (in algebra) restricted_algebra:
```
```   110   assumes "A \<in> sets M" shows "algebra (restricted_space A)"
```
```   111   using assms by unfold_locales auto
```
```   112
```
```   113 subsection {* Sigma Algebras *}
```
```   114
```
```   115 locale sigma_algebra = algebra +
```
```   116   assumes countable_nat_UN [intro]:
```
```   117          "!!A. range A \<subseteq> sets M \<Longrightarrow> (\<Union>i::nat. A i) \<in> sets M"
```
```   118
```
```   119 lemma countable_UN_eq:
```
```   120   fixes A :: "'i::countable \<Rightarrow> 'a set"
```
```   121   shows "(range A \<subseteq> sets M \<longrightarrow> (\<Union>i. A i) \<in> sets M) \<longleftrightarrow>
```
```   122     (range (A \<circ> from_nat) \<subseteq> sets M \<longrightarrow> (\<Union>i. (A \<circ> from_nat) i) \<in> sets M)"
```
```   123 proof -
```
```   124   let ?A' = "A \<circ> from_nat"
```
```   125   have *: "(\<Union>i. ?A' i) = (\<Union>i. A i)" (is "?l = ?r")
```
```   126   proof safe
```
```   127     fix x i assume "x \<in> A i" thus "x \<in> ?l"
```
```   128       by (auto intro!: exI[of _ "to_nat i"])
```
```   129   next
```
```   130     fix x i assume "x \<in> ?A' i" thus "x \<in> ?r"
```
```   131       by (auto intro!: exI[of _ "from_nat i"])
```
```   132   qed
```
```   133   have **: "range ?A' = range A"
```
```   134     using surj_from_nat
```
```   135     by (auto simp: image_compose intro!: imageI)
```
```   136   show ?thesis unfolding * ** ..
```
```   137 qed
```
```   138
```
```   139 lemma (in sigma_algebra) countable_UN[intro]:
```
```   140   fixes A :: "'i::countable \<Rightarrow> 'a set"
```
```   141   assumes "A`X \<subseteq> sets M"
```
```   142   shows  "(\<Union>x\<in>X. A x) \<in> sets M"
```
```   143 proof -
```
```   144   let "?A i" = "if i \<in> X then A i else {}"
```
```   145   from assms have "range ?A \<subseteq> sets M" by auto
```
```   146   with countable_nat_UN[of "?A \<circ> from_nat"] countable_UN_eq[of ?A M]
```
```   147   have "(\<Union>x. ?A x) \<in> sets M" by auto
```
```   148   moreover have "(\<Union>x. ?A x) = (\<Union>x\<in>X. A x)" by (auto split: split_if_asm)
```
```   149   ultimately show ?thesis by simp
```
```   150 qed
```
```   151
```
```   152 lemma (in sigma_algebra) finite_UN:
```
```   153   assumes "finite I" and "\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets M"
```
```   154   shows "(\<Union>i\<in>I. A i) \<in> sets M"
```
```   155   using assms by induct auto
```
```   156
```
```   157 lemma (in sigma_algebra) countable_INT [intro]:
```
```   158   fixes A :: "'i::countable \<Rightarrow> 'a set"
```
```   159   assumes A: "A`X \<subseteq> sets M" "X \<noteq> {}"
```
```   160   shows "(\<Inter>i\<in>X. A i) \<in> sets M"
```
```   161 proof -
```
```   162   from A have "\<forall>i\<in>X. A i \<in> sets M" by fast
```
```   163   hence "space M - (\<Union>i\<in>X. space M - A i) \<in> sets M" by blast
```
```   164   moreover
```
```   165   have "(\<Inter>i\<in>X. A i) = space M - (\<Union>i\<in>X. space M - A i)" using space_closed A
```
```   166     by blast
```
```   167   ultimately show ?thesis by metis
```
```   168 qed
```
```   169
```
```   170 lemma (in sigma_algebra) finite_INT:
```
```   171   assumes "finite I" "I \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets M"
```
```   172   shows "(\<Inter>i\<in>I. A i) \<in> sets M"
```
```   173   using assms by (induct rule: finite_ne_induct) auto
```
```   174
```
```   175 lemma algebra_Pow:
```
```   176      "algebra \<lparr> space = sp, sets = Pow sp, \<dots> = X \<rparr>"
```
```   177   by (auto simp add: algebra_def)
```
```   178
```
```   179 lemma sigma_algebra_Pow:
```
```   180      "sigma_algebra \<lparr> space = sp, sets = Pow sp, \<dots> = X \<rparr>"
```
```   181   by (auto simp add: sigma_algebra_def sigma_algebra_axioms_def algebra_Pow)
```
```   182
```
```   183 lemma sigma_algebra_iff:
```
```   184      "sigma_algebra M \<longleftrightarrow>
```
```   185       algebra M \<and> (\<forall>A. range A \<subseteq> sets M \<longrightarrow> (\<Union>i::nat. A i) \<in> sets M)"
```
```   186   by (simp add: sigma_algebra_def sigma_algebra_axioms_def)
```
```   187
```
```   188 subsection {* Binary Unions *}
```
```   189
```
```   190 definition binary :: "'a \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a"
```
```   191   where "binary a b =  (\<lambda>\<^isup>x. b)(0 := a)"
```
```   192
```
```   193 lemma range_binary_eq: "range(binary a b) = {a,b}"
```
```   194   by (auto simp add: binary_def)
```
```   195
```
```   196 lemma Un_range_binary: "a \<union> b = (\<Union>i::nat. binary a b i)"
```
```   197   by (simp add: UNION_eq_Union_image range_binary_eq)
```
```   198
```
```   199 lemma Int_range_binary: "a \<inter> b = (\<Inter>i::nat. binary a b i)"
```
```   200   by (simp add: INTER_eq_Inter_image range_binary_eq)
```
```   201
```
```   202 lemma sigma_algebra_iff2:
```
```   203      "sigma_algebra M \<longleftrightarrow>
```
```   204        sets M \<subseteq> Pow (space M) \<and>
```
```   205        {} \<in> sets M \<and> (\<forall>s \<in> sets M. space M - s \<in> sets M) \<and>
```
```   206        (\<forall>A. range A \<subseteq> sets M \<longrightarrow> (\<Union>i::nat. A i) \<in> sets M)"
```
```   207   by (auto simp add: range_binary_eq sigma_algebra_def sigma_algebra_axioms_def
```
```   208          algebra_def Un_range_binary)
```
```   209
```
```   210 subsection {* Initial Sigma Algebra *}
```
```   211
```
```   212 text {*Sigma algebras can naturally be created as the closure of any set of
```
```   213   sets with regard to the properties just postulated.  *}
```
```   214
```
```   215 inductive_set
```
```   216   sigma_sets :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set"
```
```   217   for sp :: "'a set" and A :: "'a set set"
```
```   218   where
```
```   219     Basic: "a \<in> A \<Longrightarrow> a \<in> sigma_sets sp A"
```
```   220   | Empty: "{} \<in> sigma_sets sp A"
```
```   221   | Compl: "a \<in> sigma_sets sp A \<Longrightarrow> sp - a \<in> sigma_sets sp A"
```
```   222   | Union: "(\<And>i::nat. a i \<in> sigma_sets sp A) \<Longrightarrow> (\<Union>i. a i) \<in> sigma_sets sp A"
```
```   223
```
```   224 definition
```
```   225   "sigma M = \<lparr> space = space M, sets = sigma_sets (space M) (sets M) \<rparr>"
```
```   226
```
```   227 lemma (in sigma_algebra) sigma_sets_subset:
```
```   228   assumes a: "a \<subseteq> sets M"
```
```   229   shows "sigma_sets (space M) a \<subseteq> sets M"
```
```   230 proof
```
```   231   fix x
```
```   232   assume "x \<in> sigma_sets (space M) a"
```
```   233   from this show "x \<in> sets M"
```
```   234     by (induct rule: sigma_sets.induct, auto) (metis a subsetD)
```
```   235 qed
```
```   236
```
```   237 lemma sigma_sets_into_sp: "A \<subseteq> Pow sp \<Longrightarrow> x \<in> sigma_sets sp A \<Longrightarrow> x \<subseteq> sp"
```
```   238   by (erule sigma_sets.induct, auto)
```
```   239
```
```   240 lemma sigma_algebra_sigma_sets:
```
```   241      "a \<subseteq> Pow (space M) \<Longrightarrow> sets M = sigma_sets (space M) a \<Longrightarrow> sigma_algebra M"
```
```   242   by (auto simp add: sigma_algebra_iff2 dest: sigma_sets_into_sp
```
```   243            intro!: sigma_sets.Union sigma_sets.Empty sigma_sets.Compl)
```
```   244
```
```   245 lemma sigma_sets_least_sigma_algebra:
```
```   246   assumes "A \<subseteq> Pow S"
```
```   247   shows "sigma_sets S A = \<Inter>{B. A \<subseteq> B \<and> sigma_algebra \<lparr>space = S, sets = B\<rparr>}"
```
```   248 proof safe
```
```   249   fix B X assume "A \<subseteq> B" and sa: "sigma_algebra \<lparr> space = S, sets = B \<rparr>"
```
```   250     and X: "X \<in> sigma_sets S A"
```
```   251   from sigma_algebra.sigma_sets_subset[OF sa, simplified, OF `A \<subseteq> B`] X
```
```   252   show "X \<in> B" by auto
```
```   253 next
```
```   254   fix X assume "X \<in> \<Inter>{B. A \<subseteq> B \<and> sigma_algebra \<lparr>space = S, sets = B\<rparr>}"
```
```   255   then have [intro!]: "\<And>B. A \<subseteq> B \<Longrightarrow> sigma_algebra \<lparr>space = S, sets = B\<rparr> \<Longrightarrow> X \<in> B"
```
```   256      by simp
```
```   257   have "A \<subseteq> sigma_sets S A" using assms
```
```   258     by (auto intro!: sigma_sets.Basic)
```
```   259   moreover have "sigma_algebra \<lparr>space = S, sets = sigma_sets S A\<rparr>"
```
```   260     using assms by (intro sigma_algebra_sigma_sets[of A]) auto
```
```   261   ultimately show "X \<in> sigma_sets S A" by auto
```
```   262 qed
```
```   263
```
```   264 lemma sets_sigma: "sets (sigma M) = sigma_sets (space M) (sets M)"
```
```   265   unfolding sigma_def by simp
```
```   266
```
```   267 lemma space_sigma [simp]: "space (sigma M) = space M"
```
```   268   by (simp add: sigma_def)
```
```   269
```
```   270 lemma sigma_sets_top: "sp \<in> sigma_sets sp A"
```
```   271   by (metis Diff_empty sigma_sets.Compl sigma_sets.Empty)
```
```   272
```
```   273 lemma sigma_sets_Un:
```
```   274   "a \<in> sigma_sets sp A \<Longrightarrow> b \<in> sigma_sets sp A \<Longrightarrow> a \<union> b \<in> sigma_sets sp A"
```
```   275 apply (simp add: Un_range_binary range_binary_eq)
```
```   276 apply (rule Union, simp add: binary_def)
```
```   277 done
```
```   278
```
```   279 lemma sigma_sets_Inter:
```
```   280   assumes Asb: "A \<subseteq> Pow sp"
```
```   281   shows "(\<And>i::nat. a i \<in> sigma_sets sp A) \<Longrightarrow> (\<Inter>i. a i) \<in> sigma_sets sp A"
```
```   282 proof -
```
```   283   assume ai: "\<And>i::nat. a i \<in> sigma_sets sp A"
```
```   284   hence "\<And>i::nat. sp-(a i) \<in> sigma_sets sp A"
```
```   285     by (rule sigma_sets.Compl)
```
```   286   hence "(\<Union>i. sp-(a i)) \<in> sigma_sets sp A"
```
```   287     by (rule sigma_sets.Union)
```
```   288   hence "sp-(\<Union>i. sp-(a i)) \<in> sigma_sets sp A"
```
```   289     by (rule sigma_sets.Compl)
```
```   290   also have "sp-(\<Union>i. sp-(a i)) = sp Int (\<Inter>i. a i)"
```
```   291     by auto
```
```   292   also have "... = (\<Inter>i. a i)" using ai
```
```   293     by (blast dest: sigma_sets_into_sp [OF Asb])
```
```   294   finally show ?thesis .
```
```   295 qed
```
```   296
```
```   297 lemma sigma_sets_INTER:
```
```   298   assumes Asb: "A \<subseteq> Pow sp"
```
```   299       and ai: "\<And>i::nat. i \<in> S \<Longrightarrow> a i \<in> sigma_sets sp A" and non: "S \<noteq> {}"
```
```   300   shows "(\<Inter>i\<in>S. a i) \<in> sigma_sets sp A"
```
```   301 proof -
```
```   302   from ai have "\<And>i. (if i\<in>S then a i else sp) \<in> sigma_sets sp A"
```
```   303     by (simp add: sigma_sets.intros sigma_sets_top)
```
```   304   hence "(\<Inter>i. (if i\<in>S then a i else sp)) \<in> sigma_sets sp A"
```
```   305     by (rule sigma_sets_Inter [OF Asb])
```
```   306   also have "(\<Inter>i. (if i\<in>S then a i else sp)) = (\<Inter>i\<in>S. a i)"
```
```   307     by auto (metis ai non sigma_sets_into_sp subset_empty subset_iff Asb)+
```
```   308   finally show ?thesis .
```
```   309 qed
```
```   310
```
```   311 lemma (in sigma_algebra) sigma_sets_eq:
```
```   312      "sigma_sets (space M) (sets M) = sets M"
```
```   313 proof
```
```   314   show "sets M \<subseteq> sigma_sets (space M) (sets M)"
```
```   315     by (metis Set.subsetI sigma_sets.Basic)
```
```   316   next
```
```   317   show "sigma_sets (space M) (sets M) \<subseteq> sets M"
```
```   318     by (metis sigma_sets_subset subset_refl)
```
```   319 qed
```
```   320
```
```   321 lemma sigma_algebra_sigma:
```
```   322     "sets M \<subseteq> Pow (space M) \<Longrightarrow> sigma_algebra (sigma M)"
```
```   323   apply (rule sigma_algebra_sigma_sets)
```
```   324   apply (auto simp add: sigma_def)
```
```   325   done
```
```   326
```
```   327 lemma (in sigma_algebra) sigma_subset:
```
```   328     "sets N \<subseteq> sets M \<Longrightarrow> space N = space M \<Longrightarrow> sets (sigma N) \<subseteq> (sets M)"
```
```   329   by (simp add: sigma_def sigma_sets_subset)
```
```   330
```
```   331 lemma (in sigma_algebra) restriction_in_sets:
```
```   332   fixes A :: "nat \<Rightarrow> 'a set"
```
```   333   assumes "S \<in> sets M"
```
```   334   and *: "range A \<subseteq> (\<lambda>A. S \<inter> A) ` sets M" (is "_ \<subseteq> ?r")
```
```   335   shows "range A \<subseteq> sets M" "(\<Union>i. A i) \<in> (\<lambda>A. S \<inter> A) ` sets M"
```
```   336 proof -
```
```   337   { fix i have "A i \<in> ?r" using * by auto
```
```   338     hence "\<exists>B. A i = B \<inter> S \<and> B \<in> sets M" by auto
```
```   339     hence "A i \<subseteq> S" "A i \<in> sets M" using `S \<in> sets M` by auto }
```
```   340   thus "range A \<subseteq> sets M" "(\<Union>i. A i) \<in> (\<lambda>A. S \<inter> A) ` sets M"
```
```   341     by (auto intro!: image_eqI[of _ _ "(\<Union>i. A i)"])
```
```   342 qed
```
```   343
```
```   344 lemma (in sigma_algebra) restricted_sigma_algebra:
```
```   345   assumes "S \<in> sets M"
```
```   346   shows "sigma_algebra (restricted_space S)"
```
```   347   unfolding sigma_algebra_def sigma_algebra_axioms_def
```
```   348 proof safe
```
```   349   show "algebra (restricted_space S)" using restricted_algebra[OF assms] .
```
```   350 next
```
```   351   fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> sets (restricted_space S)"
```
```   352   from restriction_in_sets[OF assms this[simplified]]
```
```   353   show "(\<Union>i. A i) \<in> sets (restricted_space S)" by simp
```
```   354 qed
```
```   355
```
```   356 lemma sigma_sets_Int:
```
```   357   assumes "A \<in> sigma_sets sp st"
```
```   358   shows "op \<inter> A ` sigma_sets sp st = sigma_sets (A \<inter> sp) (op \<inter> A ` st)"
```
```   359 proof (intro equalityI subsetI)
```
```   360   fix x assume "x \<in> op \<inter> A ` sigma_sets sp st"
```
```   361   then obtain y where "y \<in> sigma_sets sp st" "x = y \<inter> A" by auto
```
```   362   then show "x \<in> sigma_sets (A \<inter> sp) (op \<inter> A ` st)"
```
```   363   proof (induct arbitrary: x)
```
```   364     case (Compl a)
```
```   365     then show ?case
```
```   366       by (force intro!: sigma_sets.Compl simp: Diff_Int_distrib ac_simps)
```
```   367   next
```
```   368     case (Union a)
```
```   369     then show ?case
```
```   370       by (auto intro!: sigma_sets.Union
```
```   371                simp add: UN_extend_simps simp del: UN_simps)
```
```   372   qed (auto intro!: sigma_sets.intros)
```
```   373 next
```
```   374   fix x assume "x \<in> sigma_sets (A \<inter> sp) (op \<inter> A ` st)"
```
```   375   then show "x \<in> op \<inter> A ` sigma_sets sp st"
```
```   376   proof induct
```
```   377     case (Compl a)
```
```   378     then obtain x where "a = A \<inter> x" "x \<in> sigma_sets sp st" by auto
```
```   379     then show ?case
```
```   380       by (force simp add: image_iff intro!: bexI[of _ "sp - x"] sigma_sets.Compl)
```
```   381   next
```
```   382     case (Union a)
```
```   383     then have "\<forall>i. \<exists>x. x \<in> sigma_sets sp st \<and> a i = A \<inter> x"
```
```   384       by (auto simp: image_iff Bex_def)
```
```   385     from choice[OF this] guess f ..
```
```   386     then show ?case
```
```   387       by (auto intro!: bexI[of _ "(\<Union>x. f x)"] sigma_sets.Union
```
```   388                simp add: image_iff)
```
```   389   qed (auto intro!: sigma_sets.intros)
```
```   390 qed
```
```   391
```
```   392 lemma sigma_sets_single[simp]: "sigma_sets {X} {{X}} = {{}, {X}}"
```
```   393 proof (intro set_eqI iffI)
```
```   394   fix x assume "x \<in> sigma_sets {X} {{X}}"
```
```   395   from sigma_sets_into_sp[OF _ this]
```
```   396   show "x \<in> {{}, {X}}" by auto
```
```   397 next
```
```   398   fix x assume "x \<in> {{}, {X}}"
```
```   399   then show "x \<in> sigma_sets {X} {{X}}"
```
```   400     by (auto intro: sigma_sets.Empty sigma_sets_top)
```
```   401 qed
```
```   402
```
```   403 lemma (in sigma_algebra) sets_sigma_subset:
```
```   404   assumes "space N = space M"
```
```   405   assumes "sets N \<subseteq> sets M"
```
```   406   shows "sets (sigma N) \<subseteq> sets M"
```
```   407   by (unfold assms sets_sigma, rule sigma_sets_subset, rule assms)
```
```   408
```
```   409 lemma in_sigma[intro, simp]: "A \<in> sets M \<Longrightarrow> A \<in> sets (sigma M)"
```
```   410   unfolding sigma_def by (auto intro!: sigma_sets.Basic)
```
```   411
```
```   412 lemma (in sigma_algebra) sigma_eq[simp]: "sigma M = M"
```
```   413   unfolding sigma_def sigma_sets_eq by simp
```
```   414
```
```   415 section {* Measurable functions *}
```
```   416
```
```   417 definition
```
```   418   "measurable A B = {f \<in> space A -> space B. \<forall>y \<in> sets B. f -` y \<inter> space A \<in> sets A}"
```
```   419
```
```   420 lemma (in sigma_algebra) measurable_sigma:
```
```   421   assumes B: "sets N \<subseteq> Pow (space N)"
```
```   422       and f: "f \<in> space M -> space N"
```
```   423       and ba: "\<And>y. y \<in> sets N \<Longrightarrow> (f -` y) \<inter> space M \<in> sets M"
```
```   424   shows "f \<in> measurable M (sigma N)"
```
```   425 proof -
```
```   426   have "sigma_sets (space N) (sets N) \<subseteq> {y . (f -` y) \<inter> space M \<in> sets M & y \<subseteq> space N}"
```
```   427     proof clarify
```
```   428       fix x
```
```   429       assume "x \<in> sigma_sets (space N) (sets N)"
```
```   430       thus "f -` x \<inter> space M \<in> sets M \<and> x \<subseteq> space N"
```
```   431         proof induct
```
```   432           case (Basic a)
```
```   433           thus ?case
```
```   434             by (auto simp add: ba) (metis B subsetD PowD)
```
```   435         next
```
```   436           case Empty
```
```   437           thus ?case
```
```   438             by auto
```
```   439         next
```
```   440           case (Compl a)
```
```   441           have [simp]: "f -` space N \<inter> space M = space M"
```
```   442             by (auto simp add: funcset_mem [OF f])
```
```   443           thus ?case
```
```   444             by (auto simp add: vimage_Diff Diff_Int_distrib2 compl_sets Compl)
```
```   445         next
```
```   446           case (Union a)
```
```   447           thus ?case
```
```   448             by (simp add: vimage_UN, simp only: UN_extend_simps(4)) blast
```
```   449         qed
```
```   450     qed
```
```   451   thus ?thesis
```
```   452     by (simp add: measurable_def sigma_algebra_axioms sigma_algebra_sigma B f)
```
```   453        (auto simp add: sigma_def)
```
```   454 qed
```
```   455
```
```   456 lemma measurable_cong:
```
```   457   assumes "\<And> w. w \<in> space M \<Longrightarrow> f w = g w"
```
```   458   shows "f \<in> measurable M M' \<longleftrightarrow> g \<in> measurable M M'"
```
```   459   unfolding measurable_def using assms
```
```   460   by (simp cong: vimage_inter_cong Pi_cong)
```
```   461
```
```   462 lemma measurable_space:
```
```   463   "f \<in> measurable M A \<Longrightarrow> x \<in> space M \<Longrightarrow> f x \<in> space A"
```
```   464    unfolding measurable_def by auto
```
```   465
```
```   466 lemma measurable_sets:
```
```   467   "f \<in> measurable M A \<Longrightarrow> S \<in> sets A \<Longrightarrow> f -` S \<inter> space M \<in> sets M"
```
```   468    unfolding measurable_def by auto
```
```   469
```
```   470 lemma (in sigma_algebra) measurable_subset:
```
```   471      "(\<And>S. S \<in> sets A \<Longrightarrow> S \<subseteq> space A) \<Longrightarrow> measurable M A \<subseteq> measurable M (sigma A)"
```
```   472   by (auto intro: measurable_sigma measurable_sets measurable_space)
```
```   473
```
```   474 lemma measurable_eqI:
```
```   475      "\<lbrakk> space m1 = space m1' ; space m2 = space m2' ;
```
```   476         sets m1 = sets m1' ; sets m2 = sets m2' \<rbrakk>
```
```   477       \<Longrightarrow> measurable m1 m2 = measurable m1' m2'"
```
```   478   by (simp add: measurable_def sigma_algebra_iff2)
```
```   479
```
```   480 lemma (in sigma_algebra) measurable_const[intro, simp]:
```
```   481   assumes "c \<in> space M'"
```
```   482   shows "(\<lambda>x. c) \<in> measurable M M'"
```
```   483   using assms by (auto simp add: measurable_def)
```
```   484
```
```   485 lemma (in sigma_algebra) measurable_If:
```
```   486   assumes measure: "f \<in> measurable M M'" "g \<in> measurable M M'"
```
```   487   assumes P: "{x\<in>space M. P x} \<in> sets M"
```
```   488   shows "(\<lambda>x. if P x then f x else g x) \<in> measurable M M'"
```
```   489   unfolding measurable_def
```
```   490 proof safe
```
```   491   fix x assume "x \<in> space M"
```
```   492   thus "(if P x then f x else g x) \<in> space M'"
```
```   493     using measure unfolding measurable_def by auto
```
```   494 next
```
```   495   fix A assume "A \<in> sets M'"
```
```   496   hence *: "(\<lambda>x. if P x then f x else g x) -` A \<inter> space M =
```
```   497     ((f -` A \<inter> space M) \<inter> {x\<in>space M. P x}) \<union>
```
```   498     ((g -` A \<inter> space M) \<inter> (space M - {x\<in>space M. P x}))"
```
```   499     using measure unfolding measurable_def by (auto split: split_if_asm)
```
```   500   show "(\<lambda>x. if P x then f x else g x) -` A \<inter> space M \<in> sets M"
```
```   501     using `A \<in> sets M'` measure P unfolding * measurable_def
```
```   502     by (auto intro!: Un)
```
```   503 qed
```
```   504
```
```   505 lemma (in sigma_algebra) measurable_If_set:
```
```   506   assumes measure: "f \<in> measurable M M'" "g \<in> measurable M M'"
```
```   507   assumes P: "A \<in> sets M"
```
```   508   shows "(\<lambda>x. if x \<in> A then f x else g x) \<in> measurable M M'"
```
```   509 proof (rule measurable_If[OF measure])
```
```   510   have "{x \<in> space M. x \<in> A} = A" using `A \<in> sets M` sets_into_space by auto
```
```   511   thus "{x \<in> space M. x \<in> A} \<in> sets M" using `A \<in> sets M` by auto
```
```   512 qed
```
```   513
```
```   514 lemma (in algebra) measurable_ident[intro, simp]: "id \<in> measurable M M"
```
```   515   by (auto simp add: measurable_def)
```
```   516
```
```   517 lemma measurable_comp[intro]:
```
```   518   fixes f :: "'a \<Rightarrow> 'b" and g :: "'b \<Rightarrow> 'c"
```
```   519   shows "f \<in> measurable a b \<Longrightarrow> g \<in> measurable b c \<Longrightarrow> (g o f) \<in> measurable a c"
```
```   520   apply (auto simp add: measurable_def vimage_compose)
```
```   521   apply (subgoal_tac "f -` g -` y \<inter> space a = f -` (g -` y \<inter> space b) \<inter> space a")
```
```   522   apply force+
```
```   523   done
```
```   524
```
```   525 lemma measurable_strong:
```
```   526   fixes f :: "'a \<Rightarrow> 'b" and g :: "'b \<Rightarrow> 'c"
```
```   527   assumes f: "f \<in> measurable a b" and g: "g \<in> (space b -> space c)"
```
```   528       and a: "sigma_algebra a" and b: "sigma_algebra b" and c: "sigma_algebra c"
```
```   529       and t: "f ` (space a) \<subseteq> t"
```
```   530       and cb: "\<And>s. s \<in> sets c \<Longrightarrow> (g -` s) \<inter> t \<in> sets b"
```
```   531   shows "(g o f) \<in> measurable a c"
```
```   532 proof -
```
```   533   have fab: "f \<in> (space a -> space b)"
```
```   534    and ba: "\<And>y. y \<in> sets b \<Longrightarrow> (f -` y) \<inter> (space a) \<in> sets a" using f
```
```   535      by (auto simp add: measurable_def)
```
```   536   have eq: "f -` g -` y \<inter> space a = f -` (g -` y \<inter> t) \<inter> space a" using t
```
```   537     by force
```
```   538   show ?thesis
```
```   539     apply (auto simp add: measurable_def vimage_compose a c)
```
```   540     apply (metis funcset_mem fab g)
```
```   541     apply (subst eq, metis ba cb)
```
```   542     done
```
```   543 qed
```
```   544
```
```   545 lemma measurable_mono1:
```
```   546      "a \<subseteq> b \<Longrightarrow> sigma_algebra \<lparr>space = X, sets = b\<rparr>
```
```   547       \<Longrightarrow> measurable \<lparr>space = X, sets = a\<rparr> c \<subseteq> measurable \<lparr>space = X, sets = b\<rparr> c"
```
```   548   by (auto simp add: measurable_def)
```
```   549
```
```   550 lemma measurable_up_sigma:
```
```   551   "measurable A M \<subseteq> measurable (sigma A) M"
```
```   552   unfolding measurable_def
```
```   553   by (auto simp: sigma_def intro: sigma_sets.Basic)
```
```   554
```
```   555 lemma (in sigma_algebra) measurable_range_reduce:
```
```   556    "\<lbrakk> f \<in> measurable M \<lparr>space = s, sets = Pow s\<rparr> ; s \<noteq> {} \<rbrakk>
```
```   557     \<Longrightarrow> f \<in> measurable M \<lparr>space = s \<inter> (f ` space M), sets = Pow (s \<inter> (f ` space M))\<rparr>"
```
```   558   by (simp add: measurable_def sigma_algebra_Pow del: Pow_Int_eq) blast
```
```   559
```
```   560 lemma (in sigma_algebra) measurable_Pow_to_Pow:
```
```   561    "(sets M = Pow (space M)) \<Longrightarrow> f \<in> measurable M \<lparr>space = UNIV, sets = Pow UNIV\<rparr>"
```
```   562   by (auto simp add: measurable_def sigma_algebra_def sigma_algebra_axioms_def algebra_def)
```
```   563
```
```   564 lemma (in sigma_algebra) measurable_Pow_to_Pow_image:
```
```   565    "sets M = Pow (space M)
```
```   566     \<Longrightarrow> f \<in> measurable M \<lparr>space = f ` space M, sets = Pow (f ` space M)\<rparr>"
```
```   567   by (simp add: measurable_def sigma_algebra_Pow) intro_locales
```
```   568
```
```   569 lemma (in sigma_algebra) measurable_iff_sigma:
```
```   570   assumes "sets E \<subseteq> Pow (space E)" and "f \<in> space M \<rightarrow> space E"
```
```   571   shows "f \<in> measurable M (sigma E) \<longleftrightarrow> (\<forall>A\<in>sets E. f -` A \<inter> space M \<in> sets M)"
```
```   572   using measurable_sigma[OF assms]
```
```   573   by (fastsimp simp: measurable_def sets_sigma intro: sigma_sets.intros)
```
```   574
```
```   575 section "Disjoint families"
```
```   576
```
```   577 definition
```
```   578   disjoint_family_on  where
```
```   579   "disjoint_family_on A S \<longleftrightarrow> (\<forall>m\<in>S. \<forall>n\<in>S. m \<noteq> n \<longrightarrow> A m \<inter> A n = {})"
```
```   580
```
```   581 abbreviation
```
```   582   "disjoint_family A \<equiv> disjoint_family_on A UNIV"
```
```   583
```
```   584 lemma range_subsetD: "range f \<subseteq> B \<Longrightarrow> f i \<in> B"
```
```   585   by blast
```
```   586
```
```   587 lemma Int_Diff_disjoint: "A \<inter> B \<inter> (A - B) = {}"
```
```   588   by blast
```
```   589
```
```   590 lemma Int_Diff_Un: "A \<inter> B \<union> (A - B) = A"
```
```   591   by blast
```
```   592
```
```   593 lemma disjoint_family_subset:
```
```   594      "disjoint_family A \<Longrightarrow> (!!x. B x \<subseteq> A x) \<Longrightarrow> disjoint_family B"
```
```   595   by (force simp add: disjoint_family_on_def)
```
```   596
```
```   597 lemma disjoint_family_on_bisimulation:
```
```   598   assumes "disjoint_family_on f S"
```
```   599   and "\<And>n m. n \<in> S \<Longrightarrow> m \<in> S \<Longrightarrow> n \<noteq> m \<Longrightarrow> f n \<inter> f m = {} \<Longrightarrow> g n \<inter> g m = {}"
```
```   600   shows "disjoint_family_on g S"
```
```   601   using assms unfolding disjoint_family_on_def by auto
```
```   602
```
```   603 lemma disjoint_family_on_mono:
```
```   604   "A \<subseteq> B \<Longrightarrow> disjoint_family_on f B \<Longrightarrow> disjoint_family_on f A"
```
```   605   unfolding disjoint_family_on_def by auto
```
```   606
```
```   607 lemma disjoint_family_Suc:
```
```   608   assumes Suc: "!!n. A n \<subseteq> A (Suc n)"
```
```   609   shows "disjoint_family (\<lambda>i. A (Suc i) - A i)"
```
```   610 proof -
```
```   611   {
```
```   612     fix m
```
```   613     have "!!n. A n \<subseteq> A (m+n)"
```
```   614     proof (induct m)
```
```   615       case 0 show ?case by simp
```
```   616     next
```
```   617       case (Suc m) thus ?case
```
```   618         by (metis Suc_eq_plus1 assms nat_add_commute nat_add_left_commute subset_trans)
```
```   619     qed
```
```   620   }
```
```   621   hence "!!m n. m < n \<Longrightarrow> A m \<subseteq> A n"
```
```   622     by (metis add_commute le_add_diff_inverse nat_less_le)
```
```   623   thus ?thesis
```
```   624     by (auto simp add: disjoint_family_on_def)
```
```   625       (metis insert_absorb insert_subset le_SucE le_antisym not_leE)
```
```   626 qed
```
```   627
```
```   628 lemma setsum_indicator_disjoint_family:
```
```   629   fixes f :: "'d \<Rightarrow> 'e::semiring_1"
```
```   630   assumes d: "disjoint_family_on A P" and "x \<in> A j" and "finite P" and "j \<in> P"
```
```   631   shows "(\<Sum>i\<in>P. f i * indicator (A i) x) = f j"
```
```   632 proof -
```
```   633   have "P \<inter> {i. x \<in> A i} = {j}"
```
```   634     using d `x \<in> A j` `j \<in> P` unfolding disjoint_family_on_def
```
```   635     by auto
```
```   636   thus ?thesis
```
```   637     unfolding indicator_def
```
```   638     by (simp add: if_distrib setsum_cases[OF `finite P`])
```
```   639 qed
```
```   640
```
```   641 definition disjointed :: "(nat \<Rightarrow> 'a set) \<Rightarrow> nat \<Rightarrow> 'a set "
```
```   642   where "disjointed A n = A n - (\<Union>i\<in>{0..<n}. A i)"
```
```   643
```
```   644 lemma finite_UN_disjointed_eq: "(\<Union>i\<in>{0..<n}. disjointed A i) = (\<Union>i\<in>{0..<n}. A i)"
```
```   645 proof (induct n)
```
```   646   case 0 show ?case by simp
```
```   647 next
```
```   648   case (Suc n)
```
```   649   thus ?case by (simp add: atLeastLessThanSuc disjointed_def)
```
```   650 qed
```
```   651
```
```   652 lemma UN_disjointed_eq: "(\<Union>i. disjointed A i) = (\<Union>i. A i)"
```
```   653   apply (rule UN_finite2_eq [where k=0])
```
```   654   apply (simp add: finite_UN_disjointed_eq)
```
```   655   done
```
```   656
```
```   657 lemma less_disjoint_disjointed: "m<n \<Longrightarrow> disjointed A m \<inter> disjointed A n = {}"
```
```   658   by (auto simp add: disjointed_def)
```
```   659
```
```   660 lemma disjoint_family_disjointed: "disjoint_family (disjointed A)"
```
```   661   by (simp add: disjoint_family_on_def)
```
```   662      (metis neq_iff Int_commute less_disjoint_disjointed)
```
```   663
```
```   664 lemma disjointed_subset: "disjointed A n \<subseteq> A n"
```
```   665   by (auto simp add: disjointed_def)
```
```   666
```
```   667 lemma (in algebra) UNION_in_sets:
```
```   668   fixes A:: "nat \<Rightarrow> 'a set"
```
```   669   assumes A: "range A \<subseteq> sets M "
```
```   670   shows  "(\<Union>i\<in>{0..<n}. A i) \<in> sets M"
```
```   671 proof (induct n)
```
```   672   case 0 show ?case by simp
```
```   673 next
```
```   674   case (Suc n)
```
```   675   thus ?case
```
```   676     by (simp add: atLeastLessThanSuc) (metis A Un UNIV_I image_subset_iff)
```
```   677 qed
```
```   678
```
```   679 lemma (in algebra) range_disjointed_sets:
```
```   680   assumes A: "range A \<subseteq> sets M "
```
```   681   shows  "range (disjointed A) \<subseteq> sets M"
```
```   682 proof (auto simp add: disjointed_def)
```
```   683   fix n
```
```   684   show "A n - (\<Union>i\<in>{0..<n}. A i) \<in> sets M" using UNION_in_sets
```
```   685     by (metis A Diff UNIV_I image_subset_iff)
```
```   686 qed
```
```   687
```
```   688 lemma sigma_algebra_disjoint_iff:
```
```   689      "sigma_algebra M \<longleftrightarrow>
```
```   690       algebra M &
```
```   691       (\<forall>A. range A \<subseteq> sets M \<longrightarrow> disjoint_family A \<longrightarrow>
```
```   692            (\<Union>i::nat. A i) \<in> sets M)"
```
```   693 proof (auto simp add: sigma_algebra_iff)
```
```   694   fix A :: "nat \<Rightarrow> 'a set"
```
```   695   assume M: "algebra M"
```
```   696      and A: "range A \<subseteq> sets M"
```
```   697      and UnA: "\<forall>A. range A \<subseteq> sets M \<longrightarrow>
```
```   698                disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> sets M"
```
```   699   hence "range (disjointed A) \<subseteq> sets M \<longrightarrow>
```
```   700          disjoint_family (disjointed A) \<longrightarrow>
```
```   701          (\<Union>i. disjointed A i) \<in> sets M" by blast
```
```   702   hence "(\<Union>i. disjointed A i) \<in> sets M"
```
```   703     by (simp add: algebra.range_disjointed_sets M A disjoint_family_disjointed)
```
```   704   thus "(\<Union>i::nat. A i) \<in> sets M" by (simp add: UN_disjointed_eq)
```
```   705 qed
```
```   706
```
```   707 subsection {* Sigma algebra generated by function preimages *}
```
```   708
```
```   709 definition (in sigma_algebra)
```
```   710   "vimage_algebra S f = \<lparr> space = S, sets = (\<lambda>A. f -` A \<inter> S) ` sets M \<rparr>"
```
```   711
```
```   712 lemma (in sigma_algebra) in_vimage_algebra[simp]:
```
```   713   "A \<in> sets (vimage_algebra S f) \<longleftrightarrow> (\<exists>B\<in>sets M. A = f -` B \<inter> S)"
```
```   714   by (simp add: vimage_algebra_def image_iff)
```
```   715
```
```   716 lemma (in sigma_algebra) space_vimage_algebra[simp]:
```
```   717   "space (vimage_algebra S f) = S"
```
```   718   by (simp add: vimage_algebra_def)
```
```   719
```
```   720 lemma (in sigma_algebra) sigma_algebra_preimages:
```
```   721   fixes f :: "'x \<Rightarrow> 'a"
```
```   722   assumes "f \<in> A \<rightarrow> space M"
```
```   723   shows "sigma_algebra \<lparr> space = A, sets = (\<lambda>M. f -` M \<inter> A) ` sets M \<rparr>"
```
```   724     (is "sigma_algebra \<lparr> space = _, sets = ?F ` sets M \<rparr>")
```
```   725 proof (simp add: sigma_algebra_iff2, safe)
```
```   726   show "{} \<in> ?F ` sets M" by blast
```
```   727 next
```
```   728   fix S assume "S \<in> sets M"
```
```   729   moreover have "A - ?F S = ?F (space M - S)"
```
```   730     using assms by auto
```
```   731   ultimately show "A - ?F S \<in> ?F ` sets M"
```
```   732     by blast
```
```   733 next
```
```   734   fix S :: "nat \<Rightarrow> 'x set" assume *: "range S \<subseteq> ?F ` sets M"
```
```   735   have "\<forall>i. \<exists>b. b \<in> sets M \<and> S i = ?F b"
```
```   736   proof safe
```
```   737     fix i
```
```   738     have "S i \<in> ?F ` sets M" using * by auto
```
```   739     then show "\<exists>b. b \<in> sets M \<and> S i = ?F b" by auto
```
```   740   qed
```
```   741   from choice[OF this] obtain b where b: "range b \<subseteq> sets M" "\<And>i. S i = ?F (b i)"
```
```   742     by auto
```
```   743   then have "(\<Union>i. S i) = ?F (\<Union>i. b i)" by auto
```
```   744   then show "(\<Union>i. S i) \<in> ?F ` sets M" using b(1) by blast
```
```   745 qed
```
```   746
```
```   747 lemma (in sigma_algebra) sigma_algebra_vimage:
```
```   748   fixes S :: "'c set" assumes "f \<in> S \<rightarrow> space M"
```
```   749   shows "sigma_algebra (vimage_algebra S f)"
```
```   750 proof -
```
```   751   from sigma_algebra_preimages[OF assms]
```
```   752   show ?thesis unfolding vimage_algebra_def by (auto simp: sigma_algebra_iff2)
```
```   753 qed
```
```   754
```
```   755 lemma (in sigma_algebra) measurable_vimage_algebra:
```
```   756   fixes S :: "'c set" assumes "f \<in> S \<rightarrow> space M"
```
```   757   shows "f \<in> measurable (vimage_algebra S f) M"
```
```   758     unfolding measurable_def using assms by force
```
```   759
```
```   760 lemma (in sigma_algebra) measurable_vimage:
```
```   761   fixes g :: "'a \<Rightarrow> 'c" and f :: "'d \<Rightarrow> 'a"
```
```   762   assumes "g \<in> measurable M M2" "f \<in> S \<rightarrow> space M"
```
```   763   shows "(\<lambda>x. g (f x)) \<in> measurable (vimage_algebra S f) M2"
```
```   764 proof -
```
```   765   note measurable_vimage_algebra[OF assms(2)]
```
```   766   from measurable_comp[OF this assms(1)]
```
```   767   show ?thesis by (simp add: comp_def)
```
```   768 qed
```
```   769
```
```   770 lemma (in sigma_algebra) vimage_vimage_inv:
```
```   771   assumes f: "bij_betw f S (space M)"
```
```   772   assumes [simp]: "\<And>x. x \<in> space M \<Longrightarrow> f (g x) = x" and g: "g \<in> space M \<rightarrow> S"
```
```   773   shows "sigma_algebra.vimage_algebra (vimage_algebra S f) (space M) g = M"
```
```   774 proof -
```
```   775   interpret T: sigma_algebra "vimage_algebra S f"
```
```   776     using f by (safe intro!: sigma_algebra_vimage bij_betw_imp_funcset)
```
```   777
```
```   778   have inj: "inj_on f S" and [simp]: "f`S = space M"
```
```   779     using f unfolding bij_betw_def by auto
```
```   780
```
```   781   { fix A assume A: "A \<in> sets M"
```
```   782     have "g -` f -` A \<inter> g -` S \<inter> space M = (f \<circ> g) -` A \<inter> space M"
```
```   783       using g by auto
```
```   784     also have "\<dots> = A"
```
```   785       using `A \<in> sets M`[THEN sets_into_space] by auto
```
```   786     finally have "g -` f -` A \<inter> g -` S \<inter> space M = A" . }
```
```   787   note X = this
```
```   788   show ?thesis
```
```   789     unfolding T.vimage_algebra_def unfolding vimage_algebra_def
```
```   790     by (simp add: image_compose[symmetric] comp_def X cong: image_cong)
```
```   791 qed
```
```   792
```
```   793 lemma (in sigma_algebra) measurable_vimage_iff:
```
```   794   fixes f :: "'b \<Rightarrow> 'a" assumes f: "bij_betw f S (space M)"
```
```   795   shows "g \<in> measurable M M' \<longleftrightarrow> (g \<circ> f) \<in> measurable (vimage_algebra S f) M'"
```
```   796 proof
```
```   797   assume "g \<in> measurable M M'"
```
```   798   from measurable_vimage[OF this f[THEN bij_betw_imp_funcset]]
```
```   799   show "(g \<circ> f) \<in> measurable (vimage_algebra S f) M'" unfolding comp_def .
```
```   800 next
```
```   801   interpret v: sigma_algebra "vimage_algebra S f"
```
```   802     using f[THEN bij_betw_imp_funcset] by (rule sigma_algebra_vimage)
```
```   803   note f' = f[THEN bij_betw_the_inv_into]
```
```   804   assume "g \<circ> f \<in> measurable (vimage_algebra S f) M'"
```
```   805   from v.measurable_vimage[OF this, unfolded space_vimage_algebra, OF f'[THEN bij_betw_imp_funcset]]
```
```   806   show "g \<in> measurable M M'"
```
```   807     using f f'[THEN bij_betw_imp_funcset] f[unfolded bij_betw_def]
```
```   808     by (subst (asm) vimage_vimage_inv)
```
```   809        (simp_all add: f_the_inv_into_f cong: measurable_cong)
```
```   810 qed
```
```   811
```
```   812 lemma sigma_sets_vimage:
```
```   813   assumes "f \<in> S' \<rightarrow> S" and "A \<subseteq> Pow S"
```
```   814   shows "sigma_sets S' ((\<lambda>X. f -` X \<inter> S') ` A) = (\<lambda>X. f -` X \<inter> S') ` sigma_sets S A"
```
```   815 proof (intro set_eqI iffI)
```
```   816   let ?F = "\<lambda>X. f -` X \<inter> S'"
```
```   817   fix X assume "X \<in> sigma_sets S' (?F ` A)"
```
```   818   then show "X \<in> ?F ` sigma_sets S A"
```
```   819   proof induct
```
```   820     case (Basic X) then obtain X' where "X = ?F X'" "X' \<in> A"
```
```   821       by auto
```
```   822     then show ?case by (auto intro!: sigma_sets.Basic)
```
```   823   next
```
```   824     case Empty then show ?case
```
```   825       by (auto intro!: image_eqI[of _ _ "{}"] sigma_sets.Empty)
```
```   826   next
```
```   827     case (Compl X) then obtain X' where X: "X = ?F X'" and "X' \<in> sigma_sets S A"
```
```   828       by auto
```
```   829     then have "S - X' \<in> sigma_sets S A"
```
```   830       by (auto intro!: sigma_sets.Compl)
```
```   831     then show ?case
```
```   832       using X assms by (auto intro!: image_eqI[where x="S - X'"])
```
```   833   next
```
```   834     case (Union F)
```
```   835     then have "\<forall>i. \<exists>F'.  F' \<in> sigma_sets S A \<and> F i = f -` F' \<inter> S'"
```
```   836       by (auto simp: image_iff Bex_def)
```
```   837     from choice[OF this] obtain F' where
```
```   838       "\<And>i. F' i \<in> sigma_sets S A" and "\<And>i. F i = f -` F' i \<inter> S'"
```
```   839       by auto
```
```   840     then show ?case
```
```   841       by (auto intro!: sigma_sets.Union image_eqI[where x="\<Union>i. F' i"])
```
```   842   qed
```
```   843 next
```
```   844   let ?F = "\<lambda>X. f -` X \<inter> S'"
```
```   845   fix X assume "X \<in> ?F ` sigma_sets S A"
```
```   846   then obtain X' where "X' \<in> sigma_sets S A" "X = ?F X'" by auto
```
```   847   then show "X \<in> sigma_sets S' (?F ` A)"
```
```   848   proof (induct arbitrary: X)
```
```   849     case (Basic X') then show ?case by (auto intro: sigma_sets.Basic)
```
```   850   next
```
```   851     case Empty then show ?case by (auto intro: sigma_sets.Empty)
```
```   852   next
```
```   853     case (Compl X')
```
```   854     have "S' - (S' - X) \<in> sigma_sets S' (?F ` A)"
```
```   855       apply (rule sigma_sets.Compl)
```
```   856       using assms by (auto intro!: Compl.hyps simp: Compl.prems)
```
```   857     also have "S' - (S' - X) = X"
```
```   858       using assms Compl by auto
```
```   859     finally show ?case .
```
```   860   next
```
```   861     case (Union F)
```
```   862     have "(\<Union>i. f -` F i \<inter> S') \<in> sigma_sets S' (?F ` A)"
```
```   863       by (intro sigma_sets.Union Union.hyps) simp
```
```   864     also have "(\<Union>i. f -` F i \<inter> S') = X"
```
```   865       using assms Union by auto
```
```   866     finally show ?case .
```
```   867   qed
```
```   868 qed
```
```   869
```
```   870 section {* Conditional space *}
```
```   871
```
```   872 definition (in algebra)
```
```   873   "image_space X = \<lparr> space = X`space M, sets = (\<lambda>S. X`S) ` sets M \<rparr>"
```
```   874
```
```   875 definition (in algebra)
```
```   876   "conditional_space X A = algebra.image_space (restricted_space A) X"
```
```   877
```
```   878 lemma (in algebra) space_conditional_space:
```
```   879   assumes "A \<in> sets M" shows "space (conditional_space X A) = X`A"
```
```   880 proof -
```
```   881   interpret r: algebra "restricted_space A" using assms by (rule restricted_algebra)
```
```   882   show ?thesis unfolding conditional_space_def r.image_space_def
```
```   883     by simp
```
```   884 qed
```
```   885
```
```   886 subsection {* A Two-Element Series *}
```
```   887
```
```   888 definition binaryset :: "'a set \<Rightarrow> 'a set \<Rightarrow> nat \<Rightarrow> 'a set "
```
```   889   where "binaryset A B = (\<lambda>\<^isup>x. {})(0 := A, Suc 0 := B)"
```
```   890
```
```   891 lemma range_binaryset_eq: "range(binaryset A B) = {A,B,{}}"
```
```   892   apply (simp add: binaryset_def)
```
```   893   apply (rule set_eqI)
```
```   894   apply (auto simp add: image_iff)
```
```   895   done
```
```   896
```
```   897 lemma UN_binaryset_eq: "(\<Union>i. binaryset A B i) = A \<union> B"
```
```   898   by (simp add: UNION_eq_Union_image range_binaryset_eq)
```
```   899
```
```   900 section {* Closed CDI *}
```
```   901
```
```   902 definition
```
```   903   closed_cdi  where
```
```   904   "closed_cdi M \<longleftrightarrow>
```
```   905    sets M \<subseteq> Pow (space M) &
```
```   906    (\<forall>s \<in> sets M. space M - s \<in> sets M) &
```
```   907    (\<forall>A. (range A \<subseteq> sets M) & (A 0 = {}) & (\<forall>n. A n \<subseteq> A (Suc n)) \<longrightarrow>
```
```   908         (\<Union>i. A i) \<in> sets M) &
```
```   909    (\<forall>A. (range A \<subseteq> sets M) & disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> sets M)"
```
```   910
```
```   911
```
```   912 inductive_set
```
```   913   smallest_ccdi_sets :: "('a, 'b) algebra_scheme \<Rightarrow> 'a set set"
```
```   914   for M
```
```   915   where
```
```   916     Basic [intro]:
```
```   917       "a \<in> sets M \<Longrightarrow> a \<in> smallest_ccdi_sets M"
```
```   918   | Compl [intro]:
```
```   919       "a \<in> smallest_ccdi_sets M \<Longrightarrow> space M - a \<in> smallest_ccdi_sets M"
```
```   920   | Inc:
```
```   921       "range A \<in> Pow(smallest_ccdi_sets M) \<Longrightarrow> A 0 = {} \<Longrightarrow> (\<And>n. A n \<subseteq> A (Suc n))
```
```   922        \<Longrightarrow> (\<Union>i. A i) \<in> smallest_ccdi_sets M"
```
```   923   | Disj:
```
```   924       "range A \<in> Pow(smallest_ccdi_sets M) \<Longrightarrow> disjoint_family A
```
```   925        \<Longrightarrow> (\<Union>i::nat. A i) \<in> smallest_ccdi_sets M"
```
```   926   monos Pow_mono
```
```   927
```
```   928
```
```   929 definition
```
```   930   smallest_closed_cdi  where
```
```   931   "smallest_closed_cdi M = (|space = space M, sets = smallest_ccdi_sets M|)"
```
```   932
```
```   933 lemma space_smallest_closed_cdi [simp]:
```
```   934      "space (smallest_closed_cdi M) = space M"
```
```   935   by (simp add: smallest_closed_cdi_def)
```
```   936
```
```   937 lemma (in algebra) smallest_closed_cdi1: "sets M \<subseteq> sets (smallest_closed_cdi M)"
```
```   938   by (auto simp add: smallest_closed_cdi_def)
```
```   939
```
```   940 lemma (in algebra) smallest_ccdi_sets:
```
```   941      "smallest_ccdi_sets M \<subseteq> Pow (space M)"
```
```   942   apply (rule subsetI)
```
```   943   apply (erule smallest_ccdi_sets.induct)
```
```   944   apply (auto intro: range_subsetD dest: sets_into_space)
```
```   945   done
```
```   946
```
```   947 lemma (in algebra) smallest_closed_cdi2: "closed_cdi (smallest_closed_cdi M)"
```
```   948   apply (auto simp add: closed_cdi_def smallest_closed_cdi_def smallest_ccdi_sets)
```
```   949   apply (blast intro: smallest_ccdi_sets.Inc smallest_ccdi_sets.Disj) +
```
```   950   done
```
```   951
```
```   952 lemma (in algebra) smallest_closed_cdi3:
```
```   953      "sets (smallest_closed_cdi M) \<subseteq> Pow (space M)"
```
```   954   by (simp add: smallest_closed_cdi_def smallest_ccdi_sets)
```
```   955
```
```   956 lemma closed_cdi_subset: "closed_cdi M \<Longrightarrow> sets M \<subseteq> Pow (space M)"
```
```   957   by (simp add: closed_cdi_def)
```
```   958
```
```   959 lemma closed_cdi_Compl: "closed_cdi M \<Longrightarrow> s \<in> sets M \<Longrightarrow> space M - s \<in> sets M"
```
```   960   by (simp add: closed_cdi_def)
```
```   961
```
```   962 lemma closed_cdi_Inc:
```
```   963      "closed_cdi M \<Longrightarrow> range A \<subseteq> sets M \<Longrightarrow> A 0 = {} \<Longrightarrow> (!!n. A n \<subseteq> A (Suc n)) \<Longrightarrow>
```
```   964         (\<Union>i. A i) \<in> sets M"
```
```   965   by (simp add: closed_cdi_def)
```
```   966
```
```   967 lemma closed_cdi_Disj:
```
```   968      "closed_cdi M \<Longrightarrow> range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i::nat. A i) \<in> sets M"
```
```   969   by (simp add: closed_cdi_def)
```
```   970
```
```   971 lemma closed_cdi_Un:
```
```   972   assumes cdi: "closed_cdi M" and empty: "{} \<in> sets M"
```
```   973       and A: "A \<in> sets M" and B: "B \<in> sets M"
```
```   974       and disj: "A \<inter> B = {}"
```
```   975     shows "A \<union> B \<in> sets M"
```
```   976 proof -
```
```   977   have ra: "range (binaryset A B) \<subseteq> sets M"
```
```   978    by (simp add: range_binaryset_eq empty A B)
```
```   979  have di:  "disjoint_family (binaryset A B)" using disj
```
```   980    by (simp add: disjoint_family_on_def binaryset_def Int_commute)
```
```   981  from closed_cdi_Disj [OF cdi ra di]
```
```   982  show ?thesis
```
```   983    by (simp add: UN_binaryset_eq)
```
```   984 qed
```
```   985
```
```   986 lemma (in algebra) smallest_ccdi_sets_Un:
```
```   987   assumes A: "A \<in> smallest_ccdi_sets M" and B: "B \<in> smallest_ccdi_sets M"
```
```   988       and disj: "A \<inter> B = {}"
```
```   989     shows "A \<union> B \<in> smallest_ccdi_sets M"
```
```   990 proof -
```
```   991   have ra: "range (binaryset A B) \<in> Pow (smallest_ccdi_sets M)"
```
```   992     by (simp add: range_binaryset_eq  A B smallest_ccdi_sets.Basic)
```
```   993   have di:  "disjoint_family (binaryset A B)" using disj
```
```   994     by (simp add: disjoint_family_on_def binaryset_def Int_commute)
```
```   995   from Disj [OF ra di]
```
```   996   show ?thesis
```
```   997     by (simp add: UN_binaryset_eq)
```
```   998 qed
```
```   999
```
```  1000 lemma (in algebra) smallest_ccdi_sets_Int1:
```
```  1001   assumes a: "a \<in> sets M"
```
```  1002   shows "b \<in> smallest_ccdi_sets M \<Longrightarrow> a \<inter> b \<in> smallest_ccdi_sets M"
```
```  1003 proof (induct rule: smallest_ccdi_sets.induct)
```
```  1004   case (Basic x)
```
```  1005   thus ?case
```
```  1006     by (metis a Int smallest_ccdi_sets.Basic)
```
```  1007 next
```
```  1008   case (Compl x)
```
```  1009   have "a \<inter> (space M - x) = space M - ((space M - a) \<union> (a \<inter> x))"
```
```  1010     by blast
```
```  1011   also have "... \<in> smallest_ccdi_sets M"
```
```  1012     by (metis smallest_ccdi_sets.Compl a Compl(2) Diff_Int2 Diff_Int_distrib2
```
```  1013            Diff_disjoint Int_Diff Int_empty_right Un_commute
```
```  1014            smallest_ccdi_sets.Basic smallest_ccdi_sets.Compl
```
```  1015            smallest_ccdi_sets_Un)
```
```  1016   finally show ?case .
```
```  1017 next
```
```  1018   case (Inc A)
```
```  1019   have 1: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) = a \<inter> (\<Union>i. A i)"
```
```  1020     by blast
```
```  1021   have "range (\<lambda>i. a \<inter> A i) \<in> Pow(smallest_ccdi_sets M)" using Inc
```
```  1022     by blast
```
```  1023   moreover have "(\<lambda>i. a \<inter> A i) 0 = {}"
```
```  1024     by (simp add: Inc)
```
```  1025   moreover have "!!n. (\<lambda>i. a \<inter> A i) n \<subseteq> (\<lambda>i. a \<inter> A i) (Suc n)" using Inc
```
```  1026     by blast
```
```  1027   ultimately have 2: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) \<in> smallest_ccdi_sets M"
```
```  1028     by (rule smallest_ccdi_sets.Inc)
```
```  1029   show ?case
```
```  1030     by (metis 1 2)
```
```  1031 next
```
```  1032   case (Disj A)
```
```  1033   have 1: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) = a \<inter> (\<Union>i. A i)"
```
```  1034     by blast
```
```  1035   have "range (\<lambda>i. a \<inter> A i) \<in> Pow(smallest_ccdi_sets M)" using Disj
```
```  1036     by blast
```
```  1037   moreover have "disjoint_family (\<lambda>i. a \<inter> A i)" using Disj
```
```  1038     by (auto simp add: disjoint_family_on_def)
```
```  1039   ultimately have 2: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) \<in> smallest_ccdi_sets M"
```
```  1040     by (rule smallest_ccdi_sets.Disj)
```
```  1041   show ?case
```
```  1042     by (metis 1 2)
```
```  1043 qed
```
```  1044
```
```  1045
```
```  1046 lemma (in algebra) smallest_ccdi_sets_Int:
```
```  1047   assumes b: "b \<in> smallest_ccdi_sets M"
```
```  1048   shows "a \<in> smallest_ccdi_sets M \<Longrightarrow> a \<inter> b \<in> smallest_ccdi_sets M"
```
```  1049 proof (induct rule: smallest_ccdi_sets.induct)
```
```  1050   case (Basic x)
```
```  1051   thus ?case
```
```  1052     by (metis b smallest_ccdi_sets_Int1)
```
```  1053 next
```
```  1054   case (Compl x)
```
```  1055   have "(space M - x) \<inter> b = space M - (x \<inter> b \<union> (space M - b))"
```
```  1056     by blast
```
```  1057   also have "... \<in> smallest_ccdi_sets M"
```
```  1058     by (metis Compl(2) Diff_disjoint Int_Diff Int_commute Int_empty_right b
```
```  1059            smallest_ccdi_sets.Compl smallest_ccdi_sets_Un)
```
```  1060   finally show ?case .
```
```  1061 next
```
```  1062   case (Inc A)
```
```  1063   have 1: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) = (\<Union>i. A i) \<inter> b"
```
```  1064     by blast
```
```  1065   have "range (\<lambda>i. A i \<inter> b) \<in> Pow(smallest_ccdi_sets M)" using Inc
```
```  1066     by blast
```
```  1067   moreover have "(\<lambda>i. A i \<inter> b) 0 = {}"
```
```  1068     by (simp add: Inc)
```
```  1069   moreover have "!!n. (\<lambda>i. A i \<inter> b) n \<subseteq> (\<lambda>i. A i \<inter> b) (Suc n)" using Inc
```
```  1070     by blast
```
```  1071   ultimately have 2: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) \<in> smallest_ccdi_sets M"
```
```  1072     by (rule smallest_ccdi_sets.Inc)
```
```  1073   show ?case
```
```  1074     by (metis 1 2)
```
```  1075 next
```
```  1076   case (Disj A)
```
```  1077   have 1: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) = (\<Union>i. A i) \<inter> b"
```
```  1078     by blast
```
```  1079   have "range (\<lambda>i. A i \<inter> b) \<in> Pow(smallest_ccdi_sets M)" using Disj
```
```  1080     by blast
```
```  1081   moreover have "disjoint_family (\<lambda>i. A i \<inter> b)" using Disj
```
```  1082     by (auto simp add: disjoint_family_on_def)
```
```  1083   ultimately have 2: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) \<in> smallest_ccdi_sets M"
```
```  1084     by (rule smallest_ccdi_sets.Disj)
```
```  1085   show ?case
```
```  1086     by (metis 1 2)
```
```  1087 qed
```
```  1088
```
```  1089 lemma (in algebra) sets_smallest_closed_cdi_Int:
```
```  1090    "a \<in> sets (smallest_closed_cdi M) \<Longrightarrow> b \<in> sets (smallest_closed_cdi M)
```
```  1091     \<Longrightarrow> a \<inter> b \<in> sets (smallest_closed_cdi M)"
```
```  1092   by (simp add: smallest_ccdi_sets_Int smallest_closed_cdi_def)
```
```  1093
```
```  1094 lemma (in algebra) sigma_property_disjoint_lemma:
```
```  1095   assumes sbC: "sets M \<subseteq> C"
```
```  1096       and ccdi: "closed_cdi (|space = space M, sets = C|)"
```
```  1097   shows "sigma_sets (space M) (sets M) \<subseteq> C"
```
```  1098 proof -
```
```  1099   have "smallest_ccdi_sets M \<in> {B . sets M \<subseteq> B \<and> sigma_algebra (|space = space M, sets = B|)}"
```
```  1100     apply (auto simp add: sigma_algebra_disjoint_iff algebra_iff_Int
```
```  1101             smallest_ccdi_sets_Int)
```
```  1102     apply (metis Union_Pow_eq Union_upper subsetD smallest_ccdi_sets)
```
```  1103     apply (blast intro: smallest_ccdi_sets.Disj)
```
```  1104     done
```
```  1105   hence "sigma_sets (space M) (sets M) \<subseteq> smallest_ccdi_sets M"
```
```  1106     by clarsimp
```
```  1107        (drule sigma_algebra.sigma_sets_subset [where a="sets M"], auto)
```
```  1108   also have "...  \<subseteq> C"
```
```  1109     proof
```
```  1110       fix x
```
```  1111       assume x: "x \<in> smallest_ccdi_sets M"
```
```  1112       thus "x \<in> C"
```
```  1113         proof (induct rule: smallest_ccdi_sets.induct)
```
```  1114           case (Basic x)
```
```  1115           thus ?case
```
```  1116             by (metis Basic subsetD sbC)
```
```  1117         next
```
```  1118           case (Compl x)
```
```  1119           thus ?case
```
```  1120             by (blast intro: closed_cdi_Compl [OF ccdi, simplified])
```
```  1121         next
```
```  1122           case (Inc A)
```
```  1123           thus ?case
```
```  1124                by (auto intro: closed_cdi_Inc [OF ccdi, simplified])
```
```  1125         next
```
```  1126           case (Disj A)
```
```  1127           thus ?case
```
```  1128                by (auto intro: closed_cdi_Disj [OF ccdi, simplified])
```
```  1129         qed
```
```  1130     qed
```
```  1131   finally show ?thesis .
```
```  1132 qed
```
```  1133
```
```  1134 lemma (in algebra) sigma_property_disjoint:
```
```  1135   assumes sbC: "sets M \<subseteq> C"
```
```  1136       and compl: "!!s. s \<in> C \<inter> sigma_sets (space M) (sets M) \<Longrightarrow> space M - s \<in> C"
```
```  1137       and inc: "!!A. range A \<subseteq> C \<inter> sigma_sets (space M) (sets M)
```
```  1138                      \<Longrightarrow> A 0 = {} \<Longrightarrow> (!!n. A n \<subseteq> A (Suc n))
```
```  1139                      \<Longrightarrow> (\<Union>i. A i) \<in> C"
```
```  1140       and disj: "!!A. range A \<subseteq> C \<inter> sigma_sets (space M) (sets M)
```
```  1141                       \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i::nat. A i) \<in> C"
```
```  1142   shows "sigma_sets (space M) (sets M) \<subseteq> C"
```
```  1143 proof -
```
```  1144   have "sigma_sets (space M) (sets M) \<subseteq> C \<inter> sigma_sets (space M) (sets M)"
```
```  1145     proof (rule sigma_property_disjoint_lemma)
```
```  1146       show "sets M \<subseteq> C \<inter> sigma_sets (space M) (sets M)"
```
```  1147         by (metis Int_greatest Set.subsetI sbC sigma_sets.Basic)
```
```  1148     next
```
```  1149       show "closed_cdi \<lparr>space = space M, sets = C \<inter> sigma_sets (space M) (sets M)\<rparr>"
```
```  1150         by (simp add: closed_cdi_def compl inc disj)
```
```  1151            (metis PowI Set.subsetI le_infI2 sigma_sets_into_sp space_closed
```
```  1152              IntE sigma_sets.Compl range_subsetD sigma_sets.Union)
```
```  1153     qed
```
```  1154   thus ?thesis
```
```  1155     by blast
```
```  1156 qed
```
```  1157
```
```  1158 section {* Dynkin systems *}
```
```  1159
```
```  1160 locale dynkin_system =
```
```  1161   fixes M :: "'a algebra"
```
```  1162   assumes space_closed: "sets M \<subseteq> Pow (space M)"
```
```  1163     and   space: "space M \<in> sets M"
```
```  1164     and   compl[intro!]: "\<And>A. A \<in> sets M \<Longrightarrow> space M - A \<in> sets M"
```
```  1165     and   UN[intro!]: "\<And>A. disjoint_family A \<Longrightarrow> range A \<subseteq> sets M
```
```  1166                            \<Longrightarrow> (\<Union>i::nat. A i) \<in> sets M"
```
```  1167
```
```  1168 lemma (in dynkin_system) sets_into_space: "\<And> A. A \<in> sets M \<Longrightarrow> A \<subseteq> space M"
```
```  1169   using space_closed by auto
```
```  1170
```
```  1171 lemma (in dynkin_system) empty[intro, simp]: "{} \<in> sets M"
```
```  1172   using space compl[of "space M"] by simp
```
```  1173
```
```  1174 lemma (in dynkin_system) diff:
```
```  1175   assumes sets: "D \<in> sets M" "E \<in> sets M" and "D \<subseteq> E"
```
```  1176   shows "E - D \<in> sets M"
```
```  1177 proof -
```
```  1178   let ?f = "\<lambda>x. if x = 0 then D else if x = Suc 0 then space M - E else {}"
```
```  1179   have "range ?f = {D, space M - E, {}}"
```
```  1180     by (auto simp: image_iff)
```
```  1181   moreover have "D \<union> (space M - E) = (\<Union>i. ?f i)"
```
```  1182     by (auto simp: image_iff split: split_if_asm)
```
```  1183   moreover
```
```  1184   then have "disjoint_family ?f" unfolding disjoint_family_on_def
```
```  1185     using `D \<in> sets M`[THEN sets_into_space] `D \<subseteq> E` by auto
```
```  1186   ultimately have "space M - (D \<union> (space M - E)) \<in> sets M"
```
```  1187     using sets by auto
```
```  1188   also have "space M - (D \<union> (space M - E)) = E - D"
```
```  1189     using assms sets_into_space by auto
```
```  1190   finally show ?thesis .
```
```  1191 qed
```
```  1192
```
```  1193 lemma dynkin_systemI:
```
```  1194   assumes "\<And> A. A \<in> sets M \<Longrightarrow> A \<subseteq> space M" "space M \<in> sets M"
```
```  1195   assumes "\<And> A. A \<in> sets M \<Longrightarrow> space M - A \<in> sets M"
```
```  1196   assumes "\<And> A. disjoint_family A \<Longrightarrow> range A \<subseteq> sets M
```
```  1197           \<Longrightarrow> (\<Union>i::nat. A i) \<in> sets M"
```
```  1198   shows "dynkin_system M"
```
```  1199   using assms by (auto simp: dynkin_system_def)
```
```  1200
```
```  1201 lemma dynkin_system_trivial:
```
```  1202   shows "dynkin_system \<lparr> space = A, sets = Pow A \<rparr>"
```
```  1203   by (rule dynkin_systemI) auto
```
```  1204
```
```  1205 lemma sigma_algebra_imp_dynkin_system:
```
```  1206   assumes "sigma_algebra M" shows "dynkin_system M"
```
```  1207 proof -
```
```  1208   interpret sigma_algebra M by fact
```
```  1209   show ?thesis using sets_into_space by (fastsimp intro!: dynkin_systemI)
```
```  1210 qed
```
```  1211
```
```  1212 subsection "Intersection stable algebras"
```
```  1213
```
```  1214 definition "Int_stable M \<longleftrightarrow> (\<forall> a \<in> sets M. \<forall> b \<in> sets M. a \<inter> b \<in> sets M)"
```
```  1215
```
```  1216 lemma (in algebra) Int_stable: "Int_stable M"
```
```  1217   unfolding Int_stable_def by auto
```
```  1218
```
```  1219 lemma (in dynkin_system) sigma_algebra_eq_Int_stable:
```
```  1220   "sigma_algebra M \<longleftrightarrow> Int_stable M"
```
```  1221 proof
```
```  1222   assume "sigma_algebra M" then show "Int_stable M"
```
```  1223     unfolding sigma_algebra_def using algebra.Int_stable by auto
```
```  1224 next
```
```  1225   assume "Int_stable M"
```
```  1226   show "sigma_algebra M"
```
```  1227     unfolding sigma_algebra_disjoint_iff algebra_def
```
```  1228   proof (intro conjI ballI allI impI)
```
```  1229     show "sets M \<subseteq> Pow (space M)" using sets_into_space by auto
```
```  1230   next
```
```  1231     fix A B assume "A \<in> sets M" "B \<in> sets M"
```
```  1232     then have "A \<union> B = space M - ((space M - A) \<inter> (space M - B))"
```
```  1233               "space M - A \<in> sets M" "space M - B \<in> sets M"
```
```  1234       using sets_into_space by auto
```
```  1235     then show "A \<union> B \<in> sets M"
```
```  1236       using `Int_stable M` unfolding Int_stable_def by auto
```
```  1237   qed auto
```
```  1238 qed
```
```  1239
```
```  1240 subsection "Smallest Dynkin systems"
```
```  1241
```
```  1242 definition dynkin :: "'a algebra \<Rightarrow> 'a algebra" where
```
```  1243   "dynkin M = \<lparr> space = space M,
```
```  1244      sets =  \<Inter>{D. dynkin_system \<lparr> space = space M, sets = D\<rparr> \<and> sets M \<subseteq> D}\<rparr>"
```
```  1245
```
```  1246 lemma dynkin_system_dynkin:
```
```  1247   fixes M :: "'a algebra"
```
```  1248   assumes "sets M \<subseteq> Pow (space M)"
```
```  1249   shows "dynkin_system (dynkin M)"
```
```  1250 proof (rule dynkin_systemI)
```
```  1251   fix A assume "A \<in> sets (dynkin M)"
```
```  1252   moreover
```
```  1253   { fix D assume "A \<in> D" and d: "dynkin_system \<lparr> space = space M, sets = D \<rparr>"
```
```  1254     from dynkin_system.sets_into_space[OF d] `A \<in> D`
```
```  1255     have "A \<subseteq> space M" by auto }
```
```  1256   moreover have "{D. dynkin_system \<lparr> space = space M, sets = D\<rparr> \<and> sets M \<subseteq> D} \<noteq> {}"
```
```  1257     using assms dynkin_system_trivial by fastsimp
```
```  1258   ultimately show "A \<subseteq> space (dynkin M)"
```
```  1259     unfolding dynkin_def using assms
```
```  1260     by simp (metis dynkin_system.sets_into_space in_mono mem_def)
```
```  1261 next
```
```  1262   show "space (dynkin M) \<in> sets (dynkin M)"
```
```  1263     unfolding dynkin_def using dynkin_system.space by fastsimp
```
```  1264 next
```
```  1265   fix A assume "A \<in> sets (dynkin M)"
```
```  1266   then show "space (dynkin M) - A \<in> sets (dynkin M)"
```
```  1267     unfolding dynkin_def using dynkin_system.compl by force
```
```  1268 next
```
```  1269   fix A :: "nat \<Rightarrow> 'a set"
```
```  1270   assume A: "disjoint_family A" "range A \<subseteq> sets (dynkin M)"
```
```  1271   show "(\<Union>i. A i) \<in> sets (dynkin M)" unfolding dynkin_def
```
```  1272   proof (simp, safe)
```
```  1273     fix D assume "dynkin_system \<lparr>space = space M, sets = D\<rparr>" "sets M \<subseteq> D"
```
```  1274     with A have "(\<Union>i. A i) \<in> sets \<lparr>space = space M, sets = D\<rparr>"
```
```  1275       by (intro dynkin_system.UN) (auto simp: dynkin_def)
```
```  1276     then show "(\<Union>i. A i) \<in> D" by auto
```
```  1277   qed
```
```  1278 qed
```
```  1279
```
```  1280 lemma dynkin_Basic[intro]:
```
```  1281   "A \<in> sets M \<Longrightarrow> A \<in> sets (dynkin M)"
```
```  1282   unfolding dynkin_def by auto
```
```  1283
```
```  1284 lemma dynkin_space[simp]:
```
```  1285   "space (dynkin M) = space M"
```
```  1286   unfolding dynkin_def by auto
```
```  1287
```
```  1288 lemma (in dynkin_system) restricted_dynkin_system:
```
```  1289   assumes "D \<in> sets M"
```
```  1290   shows "dynkin_system \<lparr> space = space M,
```
```  1291                          sets = {Q. Q \<subseteq> space M \<and> Q \<inter> D \<in> sets M} \<rparr>"
```
```  1292 proof (rule dynkin_systemI, simp_all)
```
```  1293   have "space M \<inter> D = D"
```
```  1294     using `D \<in> sets M` sets_into_space by auto
```
```  1295   then show "space M \<inter> D \<in> sets M"
```
```  1296     using `D \<in> sets M` by auto
```
```  1297 next
```
```  1298   fix A assume "A \<subseteq> space M \<and> A \<inter> D \<in> sets M"
```
```  1299   moreover have "(space M - A) \<inter> D = (space M - (A \<inter> D)) - (space M - D)"
```
```  1300     by auto
```
```  1301   ultimately show "space M - A \<subseteq> space M \<and> (space M - A) \<inter> D \<in> sets M"
```
```  1302     using  `D \<in> sets M` by (auto intro: diff)
```
```  1303 next
```
```  1304   fix A :: "nat \<Rightarrow> 'a set"
```
```  1305   assume "disjoint_family A" "range A \<subseteq> {Q. Q \<subseteq> space M \<and> Q \<inter> D \<in> sets M}"
```
```  1306   then have "\<And>i. A i \<subseteq> space M" "disjoint_family (\<lambda>i. A i \<inter> D)"
```
```  1307     "range (\<lambda>i. A i \<inter> D) \<subseteq> sets M" "(\<Union>x. A x) \<inter> D = (\<Union>x. A x \<inter> D)"
```
```  1308     by ((fastsimp simp: disjoint_family_on_def)+)
```
```  1309   then show "(\<Union>x. A x) \<subseteq> space M \<and> (\<Union>x. A x) \<inter> D \<in> sets M"
```
```  1310     by (auto simp del: UN_simps)
```
```  1311 qed
```
```  1312
```
```  1313 lemma (in dynkin_system) dynkin_subset:
```
```  1314   fixes N :: "'a algebra"
```
```  1315   assumes "sets N \<subseteq> sets M"
```
```  1316   assumes "space N = space M"
```
```  1317   shows "sets (dynkin N) \<subseteq> sets M"
```
```  1318 proof -
```
```  1319   have *: "\<lparr>space = space N, sets = sets M\<rparr> = M"
```
```  1320     unfolding `space N = space M` by simp
```
```  1321   have "dynkin_system M" by default
```
```  1322   then have "dynkin_system \<lparr>space = space N, sets = sets M\<rparr>"
```
```  1323     using assms unfolding * by simp
```
```  1324   with `sets N \<subseteq> sets M` show ?thesis by (auto simp add: dynkin_def)
```
```  1325 qed
```
```  1326
```
```  1327 lemma sigma_eq_dynkin:
```
```  1328   fixes M :: "'a algebra"
```
```  1329   assumes sets: "sets M \<subseteq> Pow (space M)"
```
```  1330   assumes "Int_stable M"
```
```  1331   shows "sigma M = dynkin M"
```
```  1332 proof -
```
```  1333   have "sets (dynkin M) \<subseteq> sigma_sets (space M) (sets M)"
```
```  1334     using sigma_algebra_imp_dynkin_system
```
```  1335     unfolding dynkin_def sigma_def sigma_sets_least_sigma_algebra[OF sets] by auto
```
```  1336   moreover
```
```  1337   interpret dynkin_system "dynkin M"
```
```  1338     using dynkin_system_dynkin[OF sets] .
```
```  1339   have "sigma_algebra (dynkin M)"
```
```  1340     unfolding sigma_algebra_eq_Int_stable Int_stable_def
```
```  1341   proof (intro ballI)
```
```  1342     fix A B assume "A \<in> sets (dynkin M)" "B \<in> sets (dynkin M)"
```
```  1343     let "?D E" = "\<lparr> space = space M,
```
```  1344                     sets = {Q. Q \<subseteq> space M \<and> Q \<inter> E \<in> sets (dynkin M)} \<rparr>"
```
```  1345     have "sets M \<subseteq> sets (?D B)"
```
```  1346     proof
```
```  1347       fix E assume "E \<in> sets M"
```
```  1348       then have "sets M \<subseteq> sets (?D E)" "E \<in> sets (dynkin M)"
```
```  1349         using sets_into_space `Int_stable M` by (auto simp: Int_stable_def)
```
```  1350       then have "sets (dynkin M) \<subseteq> sets (?D E)"
```
```  1351         using restricted_dynkin_system `E \<in> sets (dynkin M)`
```
```  1352         by (intro dynkin_system.dynkin_subset) simp_all
```
```  1353       then have "B \<in> sets (?D E)"
```
```  1354         using `B \<in> sets (dynkin M)` by auto
```
```  1355       then have "E \<inter> B \<in> sets (dynkin M)"
```
```  1356         by (subst Int_commute) simp
```
```  1357       then show "E \<in> sets (?D B)"
```
```  1358         using sets `E \<in> sets M` by auto
```
```  1359     qed
```
```  1360     then have "sets (dynkin M) \<subseteq> sets (?D B)"
```
```  1361       using restricted_dynkin_system `B \<in> sets (dynkin M)`
```
```  1362       by (intro dynkin_system.dynkin_subset) simp_all
```
```  1363     then show "A \<inter> B \<in> sets (dynkin M)"
```
```  1364       using `A \<in> sets (dynkin M)` sets_into_space by auto
```
```  1365   qed
```
```  1366   from sigma_algebra.sigma_sets_subset[OF this, of "sets M"]
```
```  1367   have "sigma_sets (space M) (sets M) \<subseteq> sets (dynkin M)" by auto
```
```  1368   ultimately have "sigma_sets (space M) (sets M) = sets (dynkin M)" by auto
```
```  1369   then show ?thesis
```
```  1370     by (intro algebra.equality) (simp_all add: sigma_def)
```
```  1371 qed
```
```  1372
```
```  1373 lemma (in dynkin_system) dynkin_idem:
```
```  1374   "dynkin M = M"
```
```  1375 proof -
```
```  1376   have "sets (dynkin M) = sets M"
```
```  1377   proof
```
```  1378     show "sets M \<subseteq> sets (dynkin M)"
```
```  1379       using dynkin_Basic by auto
```
```  1380     show "sets (dynkin M) \<subseteq> sets M"
```
```  1381       by (intro dynkin_subset) auto
```
```  1382   qed
```
```  1383   then show ?thesis
```
```  1384     by (auto intro!: algebra.equality)
```
```  1385 qed
```
```  1386
```
```  1387 lemma (in dynkin_system) dynkin_lemma:
```
```  1388   fixes E :: "'a algebra"
```
```  1389   assumes "Int_stable E" and E: "sets E \<subseteq> sets M" "space E = space M"
```
```  1390   and "sets M \<subseteq> sets (sigma E)"
```
```  1391   shows "sigma E = M"
```
```  1392 proof -
```
```  1393   have "sets E \<subseteq> Pow (space E)"
```
```  1394     using E sets_into_space by auto
```
```  1395   then have "sigma E = dynkin E"
```
```  1396     using `Int_stable E` by (rule sigma_eq_dynkin)
```
```  1397   moreover then have "sets (dynkin E) = sets M"
```
```  1398     using assms dynkin_subset[OF E] by simp
```
```  1399   ultimately show ?thesis
```
```  1400     using E by simp
```
```  1401 qed
```
```  1402
```
```  1403 subsection "Sigma algebras on finite sets"
```
```  1404
```
```  1405 locale finite_sigma_algebra = sigma_algebra +
```
```  1406   assumes finite_space: "finite (space M)"
```
```  1407   and sets_eq_Pow[simp]: "sets M = Pow (space M)"
```
```  1408
```
```  1409 lemma (in finite_sigma_algebra) sets_image_space_eq_Pow:
```
```  1410   "sets (image_space X) = Pow (space (image_space X))"
```
```  1411 proof safe
```
```  1412   fix x S assume "S \<in> sets (image_space X)" "x \<in> S"
```
```  1413   then show "x \<in> space (image_space X)"
```
```  1414     using sets_into_space by (auto intro!: imageI simp: image_space_def)
```
```  1415 next
```
```  1416   fix S assume "S \<subseteq> space (image_space X)"
```
```  1417   then obtain S' where "S = X`S'" "S'\<in>sets M"
```
```  1418     by (auto simp: subset_image_iff sets_eq_Pow image_space_def)
```
```  1419   then show "S \<in> sets (image_space X)"
```
```  1420     by (auto simp: image_space_def)
```
```  1421 qed
```
```  1422
```
```  1423 subsection "Bijective functions with inverse"
```
```  1424
```
```  1425 definition "bij_inv A B f g \<longleftrightarrow>
```
```  1426   f \<in> A \<rightarrow> B \<and> g \<in> B \<rightarrow> A \<and> (\<forall>x\<in>A. g (f x) = x) \<and> (\<forall>x\<in>B. f (g x) = x)"
```
```  1427
```
```  1428 lemma bij_inv_symmetric[sym]: "bij_inv A B f g \<Longrightarrow> bij_inv B A g f"
```
```  1429   unfolding bij_inv_def by auto
```
```  1430
```
```  1431 lemma bij_invI:
```
```  1432   assumes "f \<in> A \<rightarrow> B" "g \<in> B \<rightarrow> A"
```
```  1433   and "\<And>x. x \<in> A \<Longrightarrow> g (f x) = x"
```
```  1434   and "\<And>x. x \<in> B \<Longrightarrow> f (g x) = x"
```
```  1435   shows "bij_inv A B f g"
```
```  1436   using assms unfolding bij_inv_def by auto
```
```  1437
```
```  1438 lemma bij_invE:
```
```  1439   assumes "bij_inv A B f g"
```
```  1440     "\<lbrakk> f \<in> A \<rightarrow> B ; g \<in> B \<rightarrow> A ;
```
```  1441         (\<And>x. x \<in> A \<Longrightarrow> g (f x) = x) ;
```
```  1442         (\<And>x. x \<in> B \<Longrightarrow> f (g x) = x) \<rbrakk> \<Longrightarrow> P"
```
```  1443   shows P
```
```  1444   using assms unfolding bij_inv_def by auto
```
```  1445
```
```  1446 lemma bij_inv_bij_betw:
```
```  1447   assumes "bij_inv A B f g"
```
```  1448   shows "bij_betw f A B" "bij_betw g B A"
```
```  1449   using assms by (auto intro: bij_betwI elim!: bij_invE)
```
```  1450
```
```  1451 lemma bij_inv_vimage_vimage:
```
```  1452   assumes "bij_inv A B f e"
```
```  1453   shows "f -` (e -` X \<inter> B) \<inter> A = X \<inter> A"
```
```  1454   using assms by (auto elim!: bij_invE)
```
```  1455
```
```  1456 lemma (in sigma_algebra) measurable_vimage_iff_inv:
```
```  1457   fixes f :: "'b \<Rightarrow> 'a" assumes "bij_inv S (space M) f g"
```
```  1458   shows "h \<in> measurable (vimage_algebra S f) M' \<longleftrightarrow> (\<lambda>x. h (g x)) \<in> measurable M M'"
```
```  1459   unfolding measurable_vimage_iff[OF bij_inv_bij_betw(1), OF assms]
```
```  1460 proof (rule measurable_cong)
```
```  1461   fix w assume "w \<in> space (vimage_algebra S f)"
```
```  1462   then have "w \<in> S" by auto
```
```  1463   then show "h w = ((\<lambda>x. h (g x)) \<circ> f) w"
```
```  1464     using assms by (auto elim: bij_invE)
```
```  1465 qed
```
```  1466
```
```  1467 lemma vimage_algebra_sigma:
```
```  1468   assumes bi: "bij_inv (space (sigma F)) (space (sigma E)) f e"
```
```  1469     and "sets E \<subseteq> Pow (space E)" and F: "sets F \<subseteq> Pow (space F)"
```
```  1470     and "f \<in> measurable F E" "e \<in> measurable E F"
```
```  1471   shows "sigma_algebra.vimage_algebra (sigma E) (space (sigma F)) f = sigma F"
```
```  1472 proof -
```
```  1473   interpret sigma_algebra "sigma E"
```
```  1474     using assms by (intro sigma_algebra_sigma) auto
```
```  1475   have eq: "sets F = (\<lambda>X. f -` X \<inter> space F) ` sets E"
```
```  1476   proof safe
```
```  1477     fix X assume "X \<in> sets F"
```
```  1478     then have "e -` X \<inter> space E \<in> sets E"
```
```  1479       using `e \<in> measurable E F` unfolding measurable_def by auto
```
```  1480     then show "X \<in>(\<lambda>Y. f -` Y \<inter> space F) ` sets E"
```
```  1481       apply (rule rev_image_eqI)
```
```  1482       unfolding bij_inv_vimage_vimage[OF bi[simplified]]
```
```  1483       using F `X \<in> sets F` by auto
```
```  1484   next
```
```  1485     fix X assume "X \<in> sets E" then show "f -` X \<inter> space F \<in> sets F"
```
```  1486       using `f \<in> measurable F E` unfolding measurable_def by auto
```
```  1487   qed
```
```  1488   show "vimage_algebra (space (sigma F)) f = sigma F"
```
```  1489     unfolding vimage_algebra_def
```
```  1490     using assms by (auto simp: bij_inv_def eq sigma_sets_vimage[symmetric] sigma_def)
```
```  1491 qed
```
```  1492
```
```  1493 lemma measurable_sigma_sigma:
```
```  1494   assumes M: "sets M \<subseteq> Pow (space M)" and N: "sets N \<subseteq> Pow (space N)"
```
```  1495   shows "f \<in> measurable M N \<Longrightarrow> f \<in> measurable (sigma M) (sigma N)"
```
```  1496   using sigma_algebra.measurable_subset[OF sigma_algebra_sigma[OF M], of N]
```
```  1497   using measurable_up_sigma[of M N] N by auto
```
```  1498
```
```  1499 lemma bij_inv_the_inv_into:
```
```  1500   assumes "bij_betw f A B" shows "bij_inv A B f (the_inv_into A f)"
```
```  1501 proof (rule bij_invI)
```
```  1502   show "the_inv_into A f \<in> B \<rightarrow> A"
```
```  1503     using bij_betw_the_inv_into[OF assms] by (rule bij_betw_imp_funcset)
```
```  1504   show "f \<in> A \<rightarrow> B" using assms by (rule bij_betw_imp_funcset)
```
```  1505   show "\<And>x. x \<in> A \<Longrightarrow> the_inv_into A f (f x) = x"
```
```  1506     "\<And>x. x \<in> B \<Longrightarrow> f (the_inv_into A f x) = x"
```
```  1507     using the_inv_into_f_f[of f A] f_the_inv_into_f[of f A]
```
```  1508     using assms by (auto simp: bij_betw_def)
```
```  1509 qed
```
```  1510
```
```  1511 end
```