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