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