src/HOL/Analysis/Sigma_Algebra.thy
author hoelzl
Mon Aug 08 14:13:14 2016 +0200 (2016-08-08)
changeset 63627 6ddb43c6b711
parent 63626 src/HOL/Multivariate_Analysis/Sigma_Algebra.thy@44ce6b524ff3
child 64008 17a20ca86d62
permissions -rw-r--r--
rename HOL-Multivariate_Analysis to HOL-Analysis.
hoelzl@63627
     1
(*  Title:      HOL/Analysis/Sigma_Algebra.thy
hoelzl@42067
     2
    Author:     Stefan Richter, Markus Wenzel, TU München
hoelzl@42067
     3
    Author:     Johannes Hölzl, TU München
hoelzl@41981
     4
    Plus material from the Hurd/Coble measure theory development,
hoelzl@41981
     5
    translated by Lawrence Paulson.
paulson@33271
     6
*)
paulson@33271
     7
wenzelm@61808
     8
section \<open>Describing measurable sets\<close>
paulson@33271
     9
wenzelm@41413
    10
theory Sigma_Algebra
wenzelm@41413
    11
imports
hoelzl@42145
    12
  Complex_Main
immler@50245
    13
  "~~/src/HOL/Library/Countable_Set"
wenzelm@41413
    14
  "~~/src/HOL/Library/FuncSet"
wenzelm@41413
    15
  "~~/src/HOL/Library/Indicator_Function"
hoelzl@62975
    16
  "~~/src/HOL/Library/Extended_Nonnegative_Real"
hoelzl@60727
    17
  "~~/src/HOL/Library/Disjoint_Sets"
wenzelm@41413
    18
begin
paulson@33271
    19
wenzelm@61808
    20
text \<open>Sigma algebras are an elementary concept in measure
paulson@33271
    21
  theory. To measure --- that is to integrate --- functions, we first have
paulson@33271
    22
  to measure sets. Unfortunately, when dealing with a large universe,
paulson@33271
    23
  it is often not possible to consistently assign a measure to every
paulson@33271
    24
  subset. Therefore it is necessary to define the set of measurable
paulson@33271
    25
  subsets of the universe. A sigma algebra is such a set that has
wenzelm@61808
    26
  three very natural and desirable properties.\<close>
paulson@33271
    27
wenzelm@61808
    28
subsection \<open>Families of sets\<close>
paulson@33271
    29
hoelzl@47694
    30
locale subset_class =
hoelzl@47694
    31
  fixes \<Omega> :: "'a set" and M :: "'a set set"
hoelzl@47694
    32
  assumes space_closed: "M \<subseteq> Pow \<Omega>"
paulson@33271
    33
hoelzl@47694
    34
lemma (in subset_class) sets_into_space: "x \<in> M \<Longrightarrow> x \<subseteq> \<Omega>"
paulson@33271
    35
  by (metis PowD contra_subsetD space_closed)
paulson@33271
    36
wenzelm@61808
    37
subsubsection \<open>Semiring of sets\<close>
hoelzl@47762
    38
hoelzl@47762
    39
locale semiring_of_sets = subset_class +
hoelzl@47762
    40
  assumes empty_sets[iff]: "{} \<in> M"
hoelzl@47762
    41
  assumes Int[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<inter> b \<in> M"
hoelzl@47762
    42
  assumes Diff_cover:
hoelzl@47762
    43
    "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> \<exists>C\<subseteq>M. finite C \<and> disjoint C \<and> a - b = \<Union>C"
hoelzl@47762
    44
hoelzl@47762
    45
lemma (in semiring_of_sets) finite_INT[intro]:
hoelzl@47762
    46
  assumes "finite I" "I \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> A i \<in> M"
hoelzl@47762
    47
  shows "(\<Inter>i\<in>I. A i) \<in> M"
hoelzl@47762
    48
  using assms by (induct rule: finite_ne_induct) auto
hoelzl@47762
    49
hoelzl@47762
    50
lemma (in semiring_of_sets) Int_space_eq1 [simp]: "x \<in> M \<Longrightarrow> \<Omega> \<inter> x = x"
hoelzl@47762
    51
  by (metis Int_absorb1 sets_into_space)
hoelzl@47762
    52
hoelzl@47762
    53
lemma (in semiring_of_sets) Int_space_eq2 [simp]: "x \<in> M \<Longrightarrow> x \<inter> \<Omega> = x"
hoelzl@47762
    54
  by (metis Int_absorb2 sets_into_space)
hoelzl@47762
    55
hoelzl@47762
    56
lemma (in semiring_of_sets) sets_Collect_conj:
hoelzl@47762
    57
  assumes "{x\<in>\<Omega>. P x} \<in> M" "{x\<in>\<Omega>. Q x} \<in> M"
hoelzl@47762
    58
  shows "{x\<in>\<Omega>. Q x \<and> P x} \<in> M"
paulson@33271
    59
proof -
hoelzl@47762
    60
  have "{x\<in>\<Omega>. Q x \<and> P x} = {x\<in>\<Omega>. Q x} \<inter> {x\<in>\<Omega>. P x}"
hoelzl@42065
    61
    by auto
hoelzl@47762
    62
  with assms show ?thesis by auto
paulson@33271
    63
qed
paulson@33271
    64
hoelzl@50002
    65
lemma (in semiring_of_sets) sets_Collect_finite_All':
hoelzl@47762
    66
  assumes "\<And>i. i \<in> S \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M" "finite S" "S \<noteq> {}"
hoelzl@47762
    67
  shows "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} \<in> M"
hoelzl@47762
    68
proof -
hoelzl@47762
    69
  have "{x\<in>\<Omega>. \<forall>i\<in>S. P i x} = (\<Inter>i\<in>S. {x\<in>\<Omega>. P i x})"
wenzelm@61808
    70
    using \<open>S \<noteq> {}\<close> by auto
hoelzl@47762
    71
  with assms show ?thesis by auto
hoelzl@47762
    72
qed
hoelzl@47762
    73
hoelzl@47762
    74
locale ring_of_sets = semiring_of_sets +
hoelzl@47762
    75
  assumes Un [intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<union> b \<in> M"
hoelzl@47762
    76
hoelzl@42065
    77
lemma (in ring_of_sets) finite_Union [intro]:
wenzelm@61952
    78
  "finite X \<Longrightarrow> X \<subseteq> M \<Longrightarrow> \<Union>X \<in> M"
hoelzl@38656
    79
  by (induct set: finite) (auto simp add: Un)
paulson@33271
    80
hoelzl@42065
    81
lemma (in ring_of_sets) finite_UN[intro]:
hoelzl@47694
    82
  assumes "finite I" and "\<And>i. i \<in> I \<Longrightarrow> A i \<in> M"
hoelzl@47694
    83
  shows "(\<Union>i\<in>I. A i) \<in> M"
hoelzl@41981
    84
  using assms by induct auto
hoelzl@41981
    85
hoelzl@47762
    86
lemma (in ring_of_sets) Diff [intro]:
hoelzl@47762
    87
  assumes "a \<in> M" "b \<in> M" shows "a - b \<in> M"
hoelzl@47762
    88
  using Diff_cover[OF assms] by auto
hoelzl@47762
    89
hoelzl@47762
    90
lemma ring_of_setsI:
hoelzl@47762
    91
  assumes space_closed: "M \<subseteq> Pow \<Omega>"
hoelzl@47762
    92
  assumes empty_sets[iff]: "{} \<in> M"
hoelzl@47762
    93
  assumes Un[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<union> b \<in> M"
hoelzl@47762
    94
  assumes Diff[intro]: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a - b \<in> M"
hoelzl@47762
    95
  shows "ring_of_sets \<Omega> M"
hoelzl@47762
    96
proof
hoelzl@47762
    97
  fix a b assume ab: "a \<in> M" "b \<in> M"
hoelzl@47762
    98
  from ab show "\<exists>C\<subseteq>M. finite C \<and> disjoint C \<and> a - b = \<Union>C"
hoelzl@47762
    99
    by (intro exI[of _ "{a - b}"]) (auto simp: disjoint_def)
hoelzl@47762
   100
  have "a \<inter> b = a - (a - b)" by auto
hoelzl@47762
   101
  also have "\<dots> \<in> M" using ab by auto
hoelzl@47762
   102
  finally show "a \<inter> b \<in> M" .
hoelzl@47762
   103
qed fact+
hoelzl@47762
   104
hoelzl@47762
   105
lemma ring_of_sets_iff: "ring_of_sets \<Omega> M \<longleftrightarrow> M \<subseteq> Pow \<Omega> \<and> {} \<in> M \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a \<union> b \<in> M) \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a - b \<in> M)"
hoelzl@47762
   106
proof
hoelzl@47762
   107
  assume "ring_of_sets \<Omega> M"
hoelzl@47762
   108
  then interpret ring_of_sets \<Omega> M .
hoelzl@47762
   109
  show "M \<subseteq> Pow \<Omega> \<and> {} \<in> M \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a \<union> b \<in> M) \<and> (\<forall>a\<in>M. \<forall>b\<in>M. a - b \<in> M)"
hoelzl@47762
   110
    using space_closed by auto
hoelzl@47762
   111
qed (auto intro!: ring_of_setsI)
hoelzl@41981
   112
hoelzl@42065
   113
lemma (in ring_of_sets) insert_in_sets:
hoelzl@47694
   114
  assumes "{x} \<in> M" "A \<in> M" shows "insert x A \<in> M"
hoelzl@38656
   115
proof -
hoelzl@47694
   116
  have "{x} \<union> A \<in> M" using assms by (rule Un)
hoelzl@38656
   117
  thus ?thesis by auto
hoelzl@38656
   118
qed
hoelzl@38656
   119
hoelzl@42867
   120
lemma (in ring_of_sets) sets_Collect_disj:
hoelzl@47694
   121
  assumes "{x\<in>\<Omega>. P x} \<in> M" "{x\<in>\<Omega>. Q x} \<in> M"
hoelzl@47694
   122
  shows "{x\<in>\<Omega>. Q x \<or> P x} \<in> M"
hoelzl@42867
   123
proof -
hoelzl@47694
   124
  have "{x\<in>\<Omega>. Q x \<or> P x} = {x\<in>\<Omega>. Q x} \<union> {x\<in>\<Omega>. P x}"
hoelzl@42867
   125
    by auto
hoelzl@42867
   126
  with assms show ?thesis by auto
hoelzl@42867
   127
qed
hoelzl@42867
   128
hoelzl@42867
   129
lemma (in ring_of_sets) sets_Collect_finite_Ex:
hoelzl@47694
   130
  assumes "\<And>i. i \<in> S \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M" "finite S"
hoelzl@47694
   131
  shows "{x\<in>\<Omega>. \<exists>i\<in>S. P i x} \<in> M"
hoelzl@42867
   132
proof -
hoelzl@47694
   133
  have "{x\<in>\<Omega>. \<exists>i\<in>S. P i x} = (\<Union>i\<in>S. {x\<in>\<Omega>. P i x})"
hoelzl@42867
   134
    by auto
hoelzl@42867
   135
  with assms show ?thesis by auto
hoelzl@42867
   136
qed
hoelzl@42867
   137
hoelzl@42065
   138
locale algebra = ring_of_sets +
hoelzl@47694
   139
  assumes top [iff]: "\<Omega> \<in> M"
hoelzl@42065
   140
hoelzl@42065
   141
lemma (in algebra) compl_sets [intro]:
hoelzl@47694
   142
  "a \<in> M \<Longrightarrow> \<Omega> - a \<in> M"
hoelzl@42065
   143
  by auto
hoelzl@42065
   144
hoelzl@42065
   145
lemma algebra_iff_Un:
hoelzl@47694
   146
  "algebra \<Omega> M \<longleftrightarrow>
hoelzl@47694
   147
    M \<subseteq> Pow \<Omega> \<and>
hoelzl@47694
   148
    {} \<in> M \<and>
hoelzl@47694
   149
    (\<forall>a \<in> M. \<Omega> - a \<in> M) \<and>
hoelzl@47694
   150
    (\<forall>a \<in> M. \<forall> b \<in> M. a \<union> b \<in> M)" (is "_ \<longleftrightarrow> ?Un")
hoelzl@42065
   151
proof
hoelzl@47694
   152
  assume "algebra \<Omega> M"
hoelzl@47694
   153
  then interpret algebra \<Omega> M .
hoelzl@42065
   154
  show ?Un using sets_into_space by auto
hoelzl@42065
   155
next
hoelzl@42065
   156
  assume ?Un
hoelzl@47762
   157
  then have "\<Omega> \<in> M" by auto
hoelzl@47762
   158
  interpret ring_of_sets \<Omega> M
hoelzl@47762
   159
  proof (rule ring_of_setsI)
hoelzl@47762
   160
    show \<Omega>: "M \<subseteq> Pow \<Omega>" "{} \<in> M"
wenzelm@61808
   161
      using \<open>?Un\<close> by auto
hoelzl@47694
   162
    fix a b assume a: "a \<in> M" and b: "b \<in> M"
wenzelm@61808
   163
    then show "a \<union> b \<in> M" using \<open>?Un\<close> by auto
hoelzl@47694
   164
    have "a - b = \<Omega> - ((\<Omega> - a) \<union> b)"
hoelzl@47694
   165
      using \<Omega> a b by auto
hoelzl@47694
   166
    then show "a - b \<in> M"
wenzelm@61808
   167
      using a b  \<open>?Un\<close> by auto
hoelzl@42065
   168
  qed
hoelzl@47762
   169
  show "algebra \<Omega> M" proof qed fact
hoelzl@42065
   170
qed
hoelzl@42065
   171
hoelzl@42065
   172
lemma algebra_iff_Int:
hoelzl@47694
   173
     "algebra \<Omega> M \<longleftrightarrow>
hoelzl@47694
   174
       M \<subseteq> Pow \<Omega> & {} \<in> M &
hoelzl@47694
   175
       (\<forall>a \<in> M. \<Omega> - a \<in> M) &
hoelzl@47694
   176
       (\<forall>a \<in> M. \<forall> b \<in> M. a \<inter> b \<in> M)" (is "_ \<longleftrightarrow> ?Int")
hoelzl@42065
   177
proof
hoelzl@47694
   178
  assume "algebra \<Omega> M"
hoelzl@47694
   179
  then interpret algebra \<Omega> M .
hoelzl@42065
   180
  show ?Int using sets_into_space by auto
hoelzl@42065
   181
next
hoelzl@42065
   182
  assume ?Int
hoelzl@47694
   183
  show "algebra \<Omega> M"
hoelzl@42065
   184
  proof (unfold algebra_iff_Un, intro conjI ballI)
hoelzl@47694
   185
    show \<Omega>: "M \<subseteq> Pow \<Omega>" "{} \<in> M"
wenzelm@61808
   186
      using \<open>?Int\<close> by auto
wenzelm@61808
   187
    from \<open>?Int\<close> show "\<And>a. a \<in> M \<Longrightarrow> \<Omega> - a \<in> M" by auto
hoelzl@47694
   188
    fix a b assume M: "a \<in> M" "b \<in> M"
hoelzl@47694
   189
    hence "a \<union> b = \<Omega> - ((\<Omega> - a) \<inter> (\<Omega> - b))"
hoelzl@47694
   190
      using \<Omega> by blast
hoelzl@47694
   191
    also have "... \<in> M"
wenzelm@61808
   192
      using M \<open>?Int\<close> by auto
hoelzl@47694
   193
    finally show "a \<union> b \<in> M" .
hoelzl@42065
   194
  qed
hoelzl@42065
   195
qed
hoelzl@42065
   196
hoelzl@42867
   197
lemma (in algebra) sets_Collect_neg:
hoelzl@47694
   198
  assumes "{x\<in>\<Omega>. P x} \<in> M"
hoelzl@47694
   199
  shows "{x\<in>\<Omega>. \<not> P x} \<in> M"
hoelzl@42867
   200
proof -
hoelzl@47694
   201
  have "{x\<in>\<Omega>. \<not> P x} = \<Omega> - {x\<in>\<Omega>. P x}" by auto
hoelzl@42867
   202
  with assms show ?thesis by auto
hoelzl@42867
   203
qed
hoelzl@42867
   204
hoelzl@42867
   205
lemma (in algebra) sets_Collect_imp:
hoelzl@47694
   206
  "{x\<in>\<Omega>. P x} \<in> M \<Longrightarrow> {x\<in>\<Omega>. Q x} \<in> M \<Longrightarrow> {x\<in>\<Omega>. Q x \<longrightarrow> P x} \<in> M"
hoelzl@42867
   207
  unfolding imp_conv_disj by (intro sets_Collect_disj sets_Collect_neg)
hoelzl@42867
   208
hoelzl@42867
   209
lemma (in algebra) sets_Collect_const:
hoelzl@47694
   210
  "{x\<in>\<Omega>. P} \<in> M"
hoelzl@42867
   211
  by (cases P) auto
hoelzl@42867
   212
hoelzl@42984
   213
lemma algebra_single_set:
hoelzl@47762
   214
  "X \<subseteq> S \<Longrightarrow> algebra S { {}, X, S - X, S }"
hoelzl@47762
   215
  by (auto simp: algebra_iff_Int)
hoelzl@42984
   216
wenzelm@61808
   217
subsubsection \<open>Restricted algebras\<close>
hoelzl@39092
   218
hoelzl@39092
   219
abbreviation (in algebra)
hoelzl@47694
   220
  "restricted_space A \<equiv> (op \<inter> A) ` M"
hoelzl@39092
   221
hoelzl@38656
   222
lemma (in algebra) restricted_algebra:
hoelzl@47694
   223
  assumes "A \<in> M" shows "algebra A (restricted_space A)"
hoelzl@47762
   224
  using assms by (auto simp: algebra_iff_Int)
paulson@33271
   225
wenzelm@61808
   226
subsubsection \<open>Sigma Algebras\<close>
paulson@33271
   227
paulson@33271
   228
locale sigma_algebra = algebra +
hoelzl@47694
   229
  assumes countable_nat_UN [intro]: "\<And>A. range A \<subseteq> M \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
paulson@33271
   230
hoelzl@42984
   231
lemma (in algebra) is_sigma_algebra:
hoelzl@47694
   232
  assumes "finite M"
hoelzl@47694
   233
  shows "sigma_algebra \<Omega> M"
hoelzl@42984
   234
proof
hoelzl@47694
   235
  fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> M"
hoelzl@47694
   236
  then have "(\<Union>i. A i) = (\<Union>s\<in>M \<inter> range A. s)"
hoelzl@42984
   237
    by auto
hoelzl@47694
   238
  also have "(\<Union>s\<in>M \<inter> range A. s) \<in> M"
wenzelm@61808
   239
    using \<open>finite M\<close> by auto
hoelzl@47694
   240
  finally show "(\<Union>i. A i) \<in> M" .
hoelzl@42984
   241
qed
hoelzl@42984
   242
hoelzl@38656
   243
lemma countable_UN_eq:
hoelzl@38656
   244
  fixes A :: "'i::countable \<Rightarrow> 'a set"
hoelzl@47694
   245
  shows "(range A \<subseteq> M \<longrightarrow> (\<Union>i. A i) \<in> M) \<longleftrightarrow>
hoelzl@47694
   246
    (range (A \<circ> from_nat) \<subseteq> M \<longrightarrow> (\<Union>i. (A \<circ> from_nat) i) \<in> M)"
hoelzl@38656
   247
proof -
hoelzl@38656
   248
  let ?A' = "A \<circ> from_nat"
hoelzl@38656
   249
  have *: "(\<Union>i. ?A' i) = (\<Union>i. A i)" (is "?l = ?r")
hoelzl@38656
   250
  proof safe
hoelzl@38656
   251
    fix x i assume "x \<in> A i" thus "x \<in> ?l"
hoelzl@38656
   252
      by (auto intro!: exI[of _ "to_nat i"])
hoelzl@38656
   253
  next
hoelzl@38656
   254
    fix x i assume "x \<in> ?A' i" thus "x \<in> ?r"
hoelzl@38656
   255
      by (auto intro!: exI[of _ "from_nat i"])
hoelzl@38656
   256
  qed
hoelzl@38656
   257
  have **: "range ?A' = range A"
hoelzl@40702
   258
    using surj_from_nat
haftmann@56154
   259
    by (auto simp: image_comp [symmetric] intro!: imageI)
hoelzl@38656
   260
  show ?thesis unfolding * ** ..
hoelzl@38656
   261
qed
hoelzl@38656
   262
immler@50245
   263
lemma (in sigma_algebra) countable_Union [intro]:
wenzelm@61952
   264
  assumes "countable X" "X \<subseteq> M" shows "\<Union>X \<in> M"
immler@50245
   265
proof cases
immler@50245
   266
  assume "X \<noteq> {}"
immler@50245
   267
  hence "\<Union>X = (\<Union>n. from_nat_into X n)"
immler@50245
   268
    using assms by (auto intro: from_nat_into) (metis from_nat_into_surj)
immler@50245
   269
  also have "\<dots> \<in> M" using assms
wenzelm@61808
   270
    by (auto intro!: countable_nat_UN) (metis \<open>X \<noteq> {}\<close> from_nat_into set_mp)
immler@50245
   271
  finally show ?thesis .
immler@50245
   272
qed simp
immler@50245
   273
hoelzl@38656
   274
lemma (in sigma_algebra) countable_UN[intro]:
hoelzl@38656
   275
  fixes A :: "'i::countable \<Rightarrow> 'a set"
hoelzl@47694
   276
  assumes "A`X \<subseteq> M"
hoelzl@47694
   277
  shows  "(\<Union>x\<in>X. A x) \<in> M"
hoelzl@38656
   278
proof -
wenzelm@46731
   279
  let ?A = "\<lambda>i. if i \<in> X then A i else {}"
hoelzl@47694
   280
  from assms have "range ?A \<subseteq> M" by auto
hoelzl@38656
   281
  with countable_nat_UN[of "?A \<circ> from_nat"] countable_UN_eq[of ?A M]
hoelzl@47694
   282
  have "(\<Union>x. ?A x) \<in> M" by auto
nipkow@62390
   283
  moreover have "(\<Union>x. ?A x) = (\<Union>x\<in>X. A x)" by (auto split: if_split_asm)
hoelzl@38656
   284
  ultimately show ?thesis by simp
hoelzl@38656
   285
qed
hoelzl@38656
   286
hoelzl@50526
   287
lemma (in sigma_algebra) countable_UN':
hoelzl@50526
   288
  fixes A :: "'i \<Rightarrow> 'a set"
hoelzl@50526
   289
  assumes X: "countable X"
hoelzl@50526
   290
  assumes A: "A`X \<subseteq> M"
hoelzl@50526
   291
  shows  "(\<Union>x\<in>X. A x) \<in> M"
hoelzl@50526
   292
proof -
hoelzl@50526
   293
  have "(\<Union>x\<in>X. A x) = (\<Union>i\<in>to_nat_on X ` X. A (from_nat_into X i))"
hoelzl@50526
   294
    using X by auto
hoelzl@50526
   295
  also have "\<dots> \<in> M"
hoelzl@50526
   296
    using A X
hoelzl@50526
   297
    by (intro countable_UN) auto
hoelzl@50526
   298
  finally show ?thesis .
hoelzl@50526
   299
qed
hoelzl@50526
   300
Andreas@61633
   301
lemma (in sigma_algebra) countable_UN'':
Andreas@61633
   302
  "\<lbrakk> countable X; \<And>x y. x \<in> X \<Longrightarrow> A x \<in> M \<rbrakk> \<Longrightarrow> (\<Union>x\<in>X. A x) \<in> M"
Andreas@61633
   303
by(erule countable_UN')(auto)
Andreas@61633
   304
paulson@33533
   305
lemma (in sigma_algebra) countable_INT [intro]:
hoelzl@38656
   306
  fixes A :: "'i::countable \<Rightarrow> 'a set"
hoelzl@47694
   307
  assumes A: "A`X \<subseteq> M" "X \<noteq> {}"
hoelzl@47694
   308
  shows "(\<Inter>i\<in>X. A i) \<in> M"
paulson@33271
   309
proof -
hoelzl@47694
   310
  from A have "\<forall>i\<in>X. A i \<in> M" by fast
hoelzl@47694
   311
  hence "\<Omega> - (\<Union>i\<in>X. \<Omega> - A i) \<in> M" by blast
paulson@33271
   312
  moreover
hoelzl@47694
   313
  have "(\<Inter>i\<in>X. A i) = \<Omega> - (\<Union>i\<in>X. \<Omega> - A i)" using space_closed A
paulson@33271
   314
    by blast
paulson@33271
   315
  ultimately show ?thesis by metis
paulson@33271
   316
qed
paulson@33271
   317
hoelzl@50526
   318
lemma (in sigma_algebra) countable_INT':
hoelzl@50526
   319
  fixes A :: "'i \<Rightarrow> 'a set"
hoelzl@50526
   320
  assumes X: "countable X" "X \<noteq> {}"
hoelzl@50526
   321
  assumes A: "A`X \<subseteq> M"
hoelzl@50526
   322
  shows  "(\<Inter>x\<in>X. A x) \<in> M"
hoelzl@50526
   323
proof -
hoelzl@50526
   324
  have "(\<Inter>x\<in>X. A x) = (\<Inter>i\<in>to_nat_on X ` X. A (from_nat_into X i))"
hoelzl@50526
   325
    using X by auto
hoelzl@50526
   326
  also have "\<dots> \<in> M"
hoelzl@50526
   327
    using A X
hoelzl@50526
   328
    by (intro countable_INT) auto
hoelzl@50526
   329
  finally show ?thesis .
hoelzl@50526
   330
qed
hoelzl@50526
   331
hoelzl@59088
   332
lemma (in sigma_algebra) countable_INT'':
hoelzl@59088
   333
  "UNIV \<in> M \<Longrightarrow> countable I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> F i \<in> M) \<Longrightarrow> (\<Inter>i\<in>I. F i) \<in> M"
hoelzl@59088
   334
  by (cases "I = {}") (auto intro: countable_INT')
hoelzl@57275
   335
hoelzl@57275
   336
lemma (in sigma_algebra) countable:
hoelzl@57275
   337
  assumes "\<And>a. a \<in> A \<Longrightarrow> {a} \<in> M" "countable A"
hoelzl@57275
   338
  shows "A \<in> M"
hoelzl@57275
   339
proof -
hoelzl@57275
   340
  have "(\<Union>a\<in>A. {a}) \<in> M"
hoelzl@57275
   341
    using assms by (intro countable_UN') auto
hoelzl@57275
   342
  also have "(\<Union>a\<in>A. {a}) = A" by auto
hoelzl@57275
   343
  finally show ?thesis by auto
hoelzl@57275
   344
qed
hoelzl@57275
   345
hoelzl@47694
   346
lemma ring_of_sets_Pow: "ring_of_sets sp (Pow sp)"
hoelzl@47762
   347
  by (auto simp: ring_of_sets_iff)
hoelzl@42145
   348
hoelzl@47694
   349
lemma algebra_Pow: "algebra sp (Pow sp)"
hoelzl@47762
   350
  by (auto simp: algebra_iff_Un)
hoelzl@38656
   351
hoelzl@38656
   352
lemma sigma_algebra_iff:
hoelzl@47694
   353
  "sigma_algebra \<Omega> M \<longleftrightarrow>
hoelzl@47694
   354
    algebra \<Omega> M \<and> (\<forall>A. range A \<subseteq> M \<longrightarrow> (\<Union>i::nat. A i) \<in> M)"
hoelzl@38656
   355
  by (simp add: sigma_algebra_def sigma_algebra_axioms_def)
paulson@33271
   356
hoelzl@47762
   357
lemma sigma_algebra_Pow: "sigma_algebra sp (Pow sp)"
hoelzl@47762
   358
  by (auto simp: sigma_algebra_iff algebra_iff_Int)
hoelzl@47762
   359
hoelzl@42867
   360
lemma (in sigma_algebra) sets_Collect_countable_All:
hoelzl@47694
   361
  assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
hoelzl@47694
   362
  shows "{x\<in>\<Omega>. \<forall>i::'i::countable. P i x} \<in> M"
hoelzl@42867
   363
proof -
hoelzl@47694
   364
  have "{x\<in>\<Omega>. \<forall>i::'i::countable. P i x} = (\<Inter>i. {x\<in>\<Omega>. P i x})" by auto
hoelzl@42867
   365
  with assms show ?thesis by auto
hoelzl@42867
   366
qed
hoelzl@42867
   367
hoelzl@42867
   368
lemma (in sigma_algebra) sets_Collect_countable_Ex:
hoelzl@47694
   369
  assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
hoelzl@47694
   370
  shows "{x\<in>\<Omega>. \<exists>i::'i::countable. P i x} \<in> M"
hoelzl@42867
   371
proof -
hoelzl@47694
   372
  have "{x\<in>\<Omega>. \<exists>i::'i::countable. P i x} = (\<Union>i. {x\<in>\<Omega>. P i x})" by auto
hoelzl@42867
   373
  with assms show ?thesis by auto
hoelzl@42867
   374
qed
hoelzl@42867
   375
hoelzl@50526
   376
lemma (in sigma_algebra) sets_Collect_countable_Ex':
hoelzl@54418
   377
  assumes "\<And>i. i \<in> I \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M"
hoelzl@50526
   378
  assumes "countable I"
hoelzl@50526
   379
  shows "{x\<in>\<Omega>. \<exists>i\<in>I. P i x} \<in> M"
hoelzl@50526
   380
proof -
hoelzl@50526
   381
  have "{x\<in>\<Omega>. \<exists>i\<in>I. P i x} = (\<Union>i\<in>I. {x\<in>\<Omega>. P i x})" by auto
hoelzl@62975
   382
  with assms show ?thesis
hoelzl@50526
   383
    by (auto intro!: countable_UN')
hoelzl@50526
   384
qed
hoelzl@50526
   385
hoelzl@54418
   386
lemma (in sigma_algebra) sets_Collect_countable_All':
hoelzl@54418
   387
  assumes "\<And>i. i \<in> I \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M"
hoelzl@54418
   388
  assumes "countable I"
hoelzl@54418
   389
  shows "{x\<in>\<Omega>. \<forall>i\<in>I. P i x} \<in> M"
hoelzl@54418
   390
proof -
hoelzl@54418
   391
  have "{x\<in>\<Omega>. \<forall>i\<in>I. P i x} = (\<Inter>i\<in>I. {x\<in>\<Omega>. P i x}) \<inter> \<Omega>" by auto
hoelzl@62975
   392
  with assms show ?thesis
hoelzl@54418
   393
    by (cases "I = {}") (auto intro!: countable_INT')
hoelzl@54418
   394
qed
hoelzl@54418
   395
hoelzl@54418
   396
lemma (in sigma_algebra) sets_Collect_countable_Ex1':
hoelzl@54418
   397
  assumes "\<And>i. i \<in> I \<Longrightarrow> {x\<in>\<Omega>. P i x} \<in> M"
hoelzl@54418
   398
  assumes "countable I"
hoelzl@54418
   399
  shows "{x\<in>\<Omega>. \<exists>!i\<in>I. P i x} \<in> M"
hoelzl@54418
   400
proof -
hoelzl@54418
   401
  have "{x\<in>\<Omega>. \<exists>!i\<in>I. P i x} = {x\<in>\<Omega>. \<exists>i\<in>I. P i x \<and> (\<forall>j\<in>I. P j x \<longrightarrow> i = j)}"
hoelzl@54418
   402
    by auto
hoelzl@62975
   403
  with assms show ?thesis
hoelzl@54418
   404
    by (auto intro!: sets_Collect_countable_All' sets_Collect_countable_Ex' sets_Collect_conj sets_Collect_imp sets_Collect_const)
hoelzl@54418
   405
qed
hoelzl@54418
   406
hoelzl@42867
   407
lemmas (in sigma_algebra) sets_Collect =
hoelzl@42867
   408
  sets_Collect_imp sets_Collect_disj sets_Collect_conj sets_Collect_neg sets_Collect_const
hoelzl@42867
   409
  sets_Collect_countable_All sets_Collect_countable_Ex sets_Collect_countable_All
hoelzl@42867
   410
hoelzl@47694
   411
lemma (in sigma_algebra) sets_Collect_countable_Ball:
hoelzl@47694
   412
  assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
hoelzl@47694
   413
  shows "{x\<in>\<Omega>. \<forall>i::'i::countable\<in>X. P i x} \<in> M"
hoelzl@47694
   414
  unfolding Ball_def by (intro sets_Collect assms)
hoelzl@47694
   415
hoelzl@47694
   416
lemma (in sigma_algebra) sets_Collect_countable_Bex:
hoelzl@47694
   417
  assumes "\<And>i. {x\<in>\<Omega>. P i x} \<in> M"
hoelzl@47694
   418
  shows "{x\<in>\<Omega>. \<exists>i::'i::countable\<in>X. P i x} \<in> M"
hoelzl@47694
   419
  unfolding Bex_def by (intro sets_Collect assms)
hoelzl@47694
   420
hoelzl@42984
   421
lemma sigma_algebra_single_set:
hoelzl@42984
   422
  assumes "X \<subseteq> S"
hoelzl@47694
   423
  shows "sigma_algebra S { {}, X, S - X, S }"
wenzelm@61808
   424
  using algebra.is_sigma_algebra[OF algebra_single_set[OF \<open>X \<subseteq> S\<close>]] by simp
hoelzl@42984
   425
wenzelm@61808
   426
subsubsection \<open>Binary Unions\<close>
paulson@33271
   427
paulson@33271
   428
definition binary :: "'a \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a"
wenzelm@50252
   429
  where "binary a b =  (\<lambda>x. b)(0 := a)"
paulson@33271
   430
hoelzl@38656
   431
lemma range_binary_eq: "range(binary a b) = {a,b}"
hoelzl@38656
   432
  by (auto simp add: binary_def)
paulson@33271
   433
hoelzl@38656
   434
lemma Un_range_binary: "a \<union> b = (\<Union>i::nat. binary a b i)"
haftmann@62343
   435
  by (simp add: range_binary_eq cong del: strong_SUP_cong)
paulson@33271
   436
hoelzl@38656
   437
lemma Int_range_binary: "a \<inter> b = (\<Inter>i::nat. binary a b i)"
haftmann@62343
   438
  by (simp add: range_binary_eq cong del: strong_INF_cong)
paulson@33271
   439
paulson@33271
   440
lemma sigma_algebra_iff2:
hoelzl@47694
   441
     "sigma_algebra \<Omega> M \<longleftrightarrow>
hoelzl@47694
   442
       M \<subseteq> Pow \<Omega> \<and>
hoelzl@47694
   443
       {} \<in> M \<and> (\<forall>s \<in> M. \<Omega> - s \<in> M) \<and>
hoelzl@47694
   444
       (\<forall>A. range A \<subseteq> M \<longrightarrow> (\<Union>i::nat. A i) \<in> M)"
hoelzl@38656
   445
  by (auto simp add: range_binary_eq sigma_algebra_def sigma_algebra_axioms_def
hoelzl@42065
   446
         algebra_iff_Un Un_range_binary)
paulson@33271
   447
wenzelm@61808
   448
subsubsection \<open>Initial Sigma Algebra\<close>
paulson@33271
   449
wenzelm@61808
   450
text \<open>Sigma algebras can naturally be created as the closure of any set of
wenzelm@61808
   451
  M with regard to the properties just postulated.\<close>
paulson@33271
   452
hoelzl@51683
   453
inductive_set sigma_sets :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set"
paulson@33271
   454
  for sp :: "'a set" and A :: "'a set set"
paulson@33271
   455
  where
hoelzl@47694
   456
    Basic[intro, simp]: "a \<in> A \<Longrightarrow> a \<in> sigma_sets sp A"
paulson@33271
   457
  | Empty: "{} \<in> sigma_sets sp A"
paulson@33271
   458
  | Compl: "a \<in> sigma_sets sp A \<Longrightarrow> sp - a \<in> sigma_sets sp A"
paulson@33271
   459
  | Union: "(\<And>i::nat. a i \<in> sigma_sets sp A) \<Longrightarrow> (\<Union>i. a i) \<in> sigma_sets sp A"
paulson@33271
   460
hoelzl@41543
   461
lemma (in sigma_algebra) sigma_sets_subset:
hoelzl@47694
   462
  assumes a: "a \<subseteq> M"
hoelzl@47694
   463
  shows "sigma_sets \<Omega> a \<subseteq> M"
hoelzl@41543
   464
proof
hoelzl@41543
   465
  fix x
hoelzl@47694
   466
  assume "x \<in> sigma_sets \<Omega> a"
hoelzl@47694
   467
  from this show "x \<in> M"
hoelzl@41543
   468
    by (induct rule: sigma_sets.induct, auto) (metis a subsetD)
hoelzl@41543
   469
qed
hoelzl@41543
   470
hoelzl@41543
   471
lemma sigma_sets_into_sp: "A \<subseteq> Pow sp \<Longrightarrow> x \<in> sigma_sets sp A \<Longrightarrow> x \<subseteq> sp"
hoelzl@41543
   472
  by (erule sigma_sets.induct, auto)
hoelzl@41543
   473
hoelzl@41543
   474
lemma sigma_algebra_sigma_sets:
hoelzl@47694
   475
     "a \<subseteq> Pow \<Omega> \<Longrightarrow> sigma_algebra \<Omega> (sigma_sets \<Omega> a)"
hoelzl@41543
   476
  by (auto simp add: sigma_algebra_iff2 dest: sigma_sets_into_sp
hoelzl@41543
   477
           intro!: sigma_sets.Union sigma_sets.Empty sigma_sets.Compl)
hoelzl@41543
   478
hoelzl@41543
   479
lemma sigma_sets_least_sigma_algebra:
hoelzl@41543
   480
  assumes "A \<subseteq> Pow S"
hoelzl@47694
   481
  shows "sigma_sets S A = \<Inter>{B. A \<subseteq> B \<and> sigma_algebra S B}"
hoelzl@41543
   482
proof safe
hoelzl@47694
   483
  fix B X assume "A \<subseteq> B" and sa: "sigma_algebra S B"
hoelzl@41543
   484
    and X: "X \<in> sigma_sets S A"
wenzelm@61808
   485
  from sigma_algebra.sigma_sets_subset[OF sa, simplified, OF \<open>A \<subseteq> B\<close>] X
hoelzl@41543
   486
  show "X \<in> B" by auto
hoelzl@41543
   487
next
hoelzl@47694
   488
  fix X assume "X \<in> \<Inter>{B. A \<subseteq> B \<and> sigma_algebra S B}"
hoelzl@47694
   489
  then have [intro!]: "\<And>B. A \<subseteq> B \<Longrightarrow> sigma_algebra S B \<Longrightarrow> X \<in> B"
hoelzl@41543
   490
     by simp
hoelzl@47694
   491
  have "A \<subseteq> sigma_sets S A" using assms by auto
hoelzl@47694
   492
  moreover have "sigma_algebra S (sigma_sets S A)"
hoelzl@41543
   493
    using assms by (intro sigma_algebra_sigma_sets[of A]) auto
hoelzl@41543
   494
  ultimately show "X \<in> sigma_sets S A" by auto
hoelzl@41543
   495
qed
paulson@33271
   496
paulson@33271
   497
lemma sigma_sets_top: "sp \<in> sigma_sets sp A"
paulson@33271
   498
  by (metis Diff_empty sigma_sets.Compl sigma_sets.Empty)
paulson@33271
   499
hoelzl@38656
   500
lemma sigma_sets_Un:
paulson@33271
   501
  "a \<in> sigma_sets sp A \<Longrightarrow> b \<in> sigma_sets sp A \<Longrightarrow> a \<union> b \<in> sigma_sets sp A"
hoelzl@38656
   502
apply (simp add: Un_range_binary range_binary_eq)
hoelzl@40859
   503
apply (rule Union, simp add: binary_def)
paulson@33271
   504
done
paulson@33271
   505
paulson@33271
   506
lemma sigma_sets_Inter:
paulson@33271
   507
  assumes Asb: "A \<subseteq> Pow sp"
paulson@33271
   508
  shows "(\<And>i::nat. a i \<in> sigma_sets sp A) \<Longrightarrow> (\<Inter>i. a i) \<in> sigma_sets sp A"
paulson@33271
   509
proof -
paulson@33271
   510
  assume ai: "\<And>i::nat. a i \<in> sigma_sets sp A"
hoelzl@38656
   511
  hence "\<And>i::nat. sp-(a i) \<in> sigma_sets sp A"
paulson@33271
   512
    by (rule sigma_sets.Compl)
hoelzl@38656
   513
  hence "(\<Union>i. sp-(a i)) \<in> sigma_sets sp A"
paulson@33271
   514
    by (rule sigma_sets.Union)
hoelzl@38656
   515
  hence "sp-(\<Union>i. sp-(a i)) \<in> sigma_sets sp A"
paulson@33271
   516
    by (rule sigma_sets.Compl)
hoelzl@38656
   517
  also have "sp-(\<Union>i. sp-(a i)) = sp Int (\<Inter>i. a i)"
paulson@33271
   518
    by auto
paulson@33271
   519
  also have "... = (\<Inter>i. a i)" using ai
hoelzl@38656
   520
    by (blast dest: sigma_sets_into_sp [OF Asb])
hoelzl@38656
   521
  finally show ?thesis .
paulson@33271
   522
qed
paulson@33271
   523
paulson@33271
   524
lemma sigma_sets_INTER:
hoelzl@38656
   525
  assumes Asb: "A \<subseteq> Pow sp"
paulson@33271
   526
      and ai: "\<And>i::nat. i \<in> S \<Longrightarrow> a i \<in> sigma_sets sp A" and non: "S \<noteq> {}"
paulson@33271
   527
  shows "(\<Inter>i\<in>S. a i) \<in> sigma_sets sp A"
paulson@33271
   528
proof -
paulson@33271
   529
  from ai have "\<And>i. (if i\<in>S then a i else sp) \<in> sigma_sets sp A"
hoelzl@47694
   530
    by (simp add: sigma_sets.intros(2-) sigma_sets_top)
paulson@33271
   531
  hence "(\<Inter>i. (if i\<in>S then a i else sp)) \<in> sigma_sets sp A"
paulson@33271
   532
    by (rule sigma_sets_Inter [OF Asb])
paulson@33271
   533
  also have "(\<Inter>i. (if i\<in>S then a i else sp)) = (\<Inter>i\<in>S. a i)"
paulson@33271
   534
    by auto (metis ai non sigma_sets_into_sp subset_empty subset_iff Asb)+
paulson@33271
   535
  finally show ?thesis .
paulson@33271
   536
qed
paulson@33271
   537
haftmann@62343
   538
lemma sigma_sets_UNION:
haftmann@62343
   539
  "countable B \<Longrightarrow> (\<And>b. b \<in> B \<Longrightarrow> b \<in> sigma_sets X A) \<Longrightarrow> (\<Union>B) \<in> sigma_sets X A"
hoelzl@51683
   540
  apply (cases "B = {}")
hoelzl@51683
   541
  apply (simp add: sigma_sets.Empty)
haftmann@62343
   542
  using from_nat_into [of B] range_from_nat_into [of B] sigma_sets.Union [of "from_nat_into B" X A]
haftmann@62343
   543
  apply simp
haftmann@62343
   544
  apply auto
wenzelm@63167
   545
  apply (metis Sup_bot_conv(1) Union_empty \<open>\<lbrakk>B \<noteq> {}; countable B\<rbrakk> \<Longrightarrow> range (from_nat_into B) = B\<close>)
hoelzl@51683
   546
  done
hoelzl@51683
   547
paulson@33271
   548
lemma (in sigma_algebra) sigma_sets_eq:
hoelzl@47694
   549
     "sigma_sets \<Omega> M = M"
paulson@33271
   550
proof
hoelzl@47694
   551
  show "M \<subseteq> sigma_sets \<Omega> M"
huffman@37032
   552
    by (metis Set.subsetI sigma_sets.Basic)
paulson@33271
   553
  next
hoelzl@47694
   554
  show "sigma_sets \<Omega> M \<subseteq> M"
paulson@33271
   555
    by (metis sigma_sets_subset subset_refl)
paulson@33271
   556
qed
paulson@33271
   557
hoelzl@42981
   558
lemma sigma_sets_eqI:
hoelzl@42981
   559
  assumes A: "\<And>a. a \<in> A \<Longrightarrow> a \<in> sigma_sets M B"
hoelzl@42981
   560
  assumes B: "\<And>b. b \<in> B \<Longrightarrow> b \<in> sigma_sets M A"
hoelzl@42981
   561
  shows "sigma_sets M A = sigma_sets M B"
hoelzl@42981
   562
proof (intro set_eqI iffI)
hoelzl@42981
   563
  fix a assume "a \<in> sigma_sets M A"
hoelzl@42981
   564
  from this A show "a \<in> sigma_sets M B"
hoelzl@47694
   565
    by induct (auto intro!: sigma_sets.intros(2-) del: sigma_sets.Basic)
hoelzl@42981
   566
next
hoelzl@42981
   567
  fix b assume "b \<in> sigma_sets M B"
hoelzl@42981
   568
  from this B show "b \<in> sigma_sets M A"
hoelzl@47694
   569
    by induct (auto intro!: sigma_sets.intros(2-) del: sigma_sets.Basic)
hoelzl@42981
   570
qed
hoelzl@42981
   571
hoelzl@42984
   572
lemma sigma_sets_subseteq: assumes "A \<subseteq> B" shows "sigma_sets X A \<subseteq> sigma_sets X B"
hoelzl@42984
   573
proof
hoelzl@42984
   574
  fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B"
wenzelm@61808
   575
    by induct (insert \<open>A \<subseteq> B\<close>, auto intro: sigma_sets.intros(2-))
hoelzl@42984
   576
qed
hoelzl@42984
   577
hoelzl@47762
   578
lemma sigma_sets_mono: assumes "A \<subseteq> sigma_sets X B" shows "sigma_sets X A \<subseteq> sigma_sets X B"
hoelzl@47762
   579
proof
hoelzl@47762
   580
  fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B"
wenzelm@61808
   581
    by induct (insert \<open>A \<subseteq> sigma_sets X B\<close>, auto intro: sigma_sets.intros(2-))
hoelzl@47762
   582
qed
hoelzl@47762
   583
hoelzl@47762
   584
lemma sigma_sets_mono': assumes "A \<subseteq> B" shows "sigma_sets X A \<subseteq> sigma_sets X B"
hoelzl@47762
   585
proof
hoelzl@47762
   586
  fix x assume "x \<in> sigma_sets X A" then show "x \<in> sigma_sets X B"
wenzelm@61808
   587
    by induct (insert \<open>A \<subseteq> B\<close>, auto intro: sigma_sets.intros(2-))
hoelzl@47762
   588
qed
hoelzl@47762
   589
hoelzl@47762
   590
lemma sigma_sets_superset_generator: "A \<subseteq> sigma_sets X A"
hoelzl@47762
   591
  by (auto intro: sigma_sets.Basic)
hoelzl@47762
   592
hoelzl@38656
   593
lemma (in sigma_algebra) restriction_in_sets:
hoelzl@38656
   594
  fixes A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
   595
  assumes "S \<in> M"
hoelzl@47694
   596
  and *: "range A \<subseteq> (\<lambda>A. S \<inter> A) ` M" (is "_ \<subseteq> ?r")
hoelzl@47694
   597
  shows "range A \<subseteq> M" "(\<Union>i. A i) \<in> (\<lambda>A. S \<inter> A) ` M"
hoelzl@38656
   598
proof -
hoelzl@38656
   599
  { fix i have "A i \<in> ?r" using * by auto
hoelzl@47694
   600
    hence "\<exists>B. A i = B \<inter> S \<and> B \<in> M" by auto
wenzelm@61808
   601
    hence "A i \<subseteq> S" "A i \<in> M" using \<open>S \<in> M\<close> by auto }
hoelzl@47694
   602
  thus "range A \<subseteq> M" "(\<Union>i. A i) \<in> (\<lambda>A. S \<inter> A) ` M"
hoelzl@38656
   603
    by (auto intro!: image_eqI[of _ _ "(\<Union>i. A i)"])
hoelzl@38656
   604
qed
hoelzl@38656
   605
hoelzl@38656
   606
lemma (in sigma_algebra) restricted_sigma_algebra:
hoelzl@47694
   607
  assumes "S \<in> M"
hoelzl@47694
   608
  shows "sigma_algebra S (restricted_space S)"
hoelzl@38656
   609
  unfolding sigma_algebra_def sigma_algebra_axioms_def
hoelzl@38656
   610
proof safe
hoelzl@47694
   611
  show "algebra S (restricted_space S)" using restricted_algebra[OF assms] .
hoelzl@38656
   612
next
hoelzl@47694
   613
  fix A :: "nat \<Rightarrow> 'a set" assume "range A \<subseteq> restricted_space S"
hoelzl@38656
   614
  from restriction_in_sets[OF assms this[simplified]]
hoelzl@47694
   615
  show "(\<Union>i. A i) \<in> restricted_space S" by simp
hoelzl@38656
   616
qed
hoelzl@38656
   617
hoelzl@40859
   618
lemma sigma_sets_Int:
hoelzl@41689
   619
  assumes "A \<in> sigma_sets sp st" "A \<subseteq> sp"
hoelzl@41689
   620
  shows "op \<inter> A ` sigma_sets sp st = sigma_sets A (op \<inter> A ` st)"
hoelzl@40859
   621
proof (intro equalityI subsetI)
hoelzl@40859
   622
  fix x assume "x \<in> op \<inter> A ` sigma_sets sp st"
hoelzl@40859
   623
  then obtain y where "y \<in> sigma_sets sp st" "x = y \<inter> A" by auto
hoelzl@41689
   624
  then have "x \<in> sigma_sets (A \<inter> sp) (op \<inter> A ` st)"
hoelzl@40859
   625
  proof (induct arbitrary: x)
hoelzl@40859
   626
    case (Compl a)
hoelzl@40859
   627
    then show ?case
hoelzl@40859
   628
      by (force intro!: sigma_sets.Compl simp: Diff_Int_distrib ac_simps)
hoelzl@40859
   629
  next
hoelzl@40859
   630
    case (Union a)
hoelzl@40859
   631
    then show ?case
hoelzl@40859
   632
      by (auto intro!: sigma_sets.Union
hoelzl@40859
   633
               simp add: UN_extend_simps simp del: UN_simps)
hoelzl@47694
   634
  qed (auto intro!: sigma_sets.intros(2-))
hoelzl@41689
   635
  then show "x \<in> sigma_sets A (op \<inter> A ` st)"
wenzelm@61808
   636
    using \<open>A \<subseteq> sp\<close> by (simp add: Int_absorb2)
hoelzl@40859
   637
next
hoelzl@41689
   638
  fix x assume "x \<in> sigma_sets A (op \<inter> A ` st)"
hoelzl@40859
   639
  then show "x \<in> op \<inter> A ` sigma_sets sp st"
hoelzl@40859
   640
  proof induct
hoelzl@40859
   641
    case (Compl a)
hoelzl@40859
   642
    then obtain x where "a = A \<inter> x" "x \<in> sigma_sets sp st" by auto
wenzelm@61808
   643
    then show ?case using \<open>A \<subseteq> sp\<close>
hoelzl@40859
   644
      by (force simp add: image_iff intro!: bexI[of _ "sp - x"] sigma_sets.Compl)
hoelzl@40859
   645
  next
hoelzl@40859
   646
    case (Union a)
hoelzl@40859
   647
    then have "\<forall>i. \<exists>x. x \<in> sigma_sets sp st \<and> a i = A \<inter> x"
hoelzl@40859
   648
      by (auto simp: image_iff Bex_def)
hoelzl@40859
   649
    from choice[OF this] guess f ..
hoelzl@40859
   650
    then show ?case
hoelzl@40859
   651
      by (auto intro!: bexI[of _ "(\<Union>x. f x)"] sigma_sets.Union
hoelzl@40859
   652
               simp add: image_iff)
hoelzl@47694
   653
  qed (auto intro!: sigma_sets.intros(2-))
hoelzl@40859
   654
qed
hoelzl@40859
   655
hoelzl@47694
   656
lemma sigma_sets_empty_eq: "sigma_sets A {} = {{}, A}"
hoelzl@40859
   657
proof (intro set_eqI iffI)
hoelzl@47694
   658
  fix a assume "a \<in> sigma_sets A {}" then show "a \<in> {{}, A}"
hoelzl@47694
   659
    by induct blast+
hoelzl@47694
   660
qed (auto intro: sigma_sets.Empty sigma_sets_top)
hoelzl@47694
   661
hoelzl@47694
   662
lemma sigma_sets_single[simp]: "sigma_sets A {A} = {{}, A}"
hoelzl@47694
   663
proof (intro set_eqI iffI)
hoelzl@47694
   664
  fix x assume "x \<in> sigma_sets A {A}"
hoelzl@47694
   665
  then show "x \<in> {{}, A}"
hoelzl@47694
   666
    by induct blast+
hoelzl@40859
   667
next
hoelzl@47694
   668
  fix x assume "x \<in> {{}, A}"
hoelzl@47694
   669
  then show "x \<in> sigma_sets A {A}"
hoelzl@40859
   670
    by (auto intro: sigma_sets.Empty sigma_sets_top)
hoelzl@40859
   671
qed
hoelzl@40859
   672
hoelzl@42987
   673
lemma sigma_sets_sigma_sets_eq:
hoelzl@42987
   674
  "M \<subseteq> Pow S \<Longrightarrow> sigma_sets S (sigma_sets S M) = sigma_sets S M"
hoelzl@47694
   675
  by (rule sigma_algebra.sigma_sets_eq[OF sigma_algebra_sigma_sets, of M S]) auto
hoelzl@42987
   676
hoelzl@42984
   677
lemma sigma_sets_singleton:
hoelzl@42984
   678
  assumes "X \<subseteq> S"
hoelzl@42984
   679
  shows "sigma_sets S { X } = { {}, X, S - X, S }"
hoelzl@42984
   680
proof -
hoelzl@47694
   681
  interpret sigma_algebra S "{ {}, X, S - X, S }"
hoelzl@42984
   682
    by (rule sigma_algebra_single_set) fact
hoelzl@42984
   683
  have "sigma_sets S { X } \<subseteq> sigma_sets S { {}, X, S - X, S }"
hoelzl@42984
   684
    by (rule sigma_sets_subseteq) simp
hoelzl@42984
   685
  moreover have "\<dots> = { {}, X, S - X, S }"
hoelzl@47694
   686
    using sigma_sets_eq by simp
hoelzl@42984
   687
  moreover
hoelzl@42984
   688
  { fix A assume "A \<in> { {}, X, S - X, S }"
hoelzl@42984
   689
    then have "A \<in> sigma_sets S { X }"
hoelzl@47694
   690
      by (auto intro: sigma_sets.intros(2-) sigma_sets_top) }
hoelzl@42984
   691
  ultimately have "sigma_sets S { X } = sigma_sets S { {}, X, S - X, S }"
hoelzl@42984
   692
    by (intro antisym) auto
hoelzl@47694
   693
  with sigma_sets_eq show ?thesis by simp
hoelzl@42984
   694
qed
hoelzl@42984
   695
hoelzl@42863
   696
lemma restricted_sigma:
hoelzl@47694
   697
  assumes S: "S \<in> sigma_sets \<Omega> M" and M: "M \<subseteq> Pow \<Omega>"
hoelzl@47694
   698
  shows "algebra.restricted_space (sigma_sets \<Omega> M) S =
hoelzl@47694
   699
    sigma_sets S (algebra.restricted_space M S)"
hoelzl@42863
   700
proof -
hoelzl@42863
   701
  from S sigma_sets_into_sp[OF M]
hoelzl@47694
   702
  have "S \<in> sigma_sets \<Omega> M" "S \<subseteq> \<Omega>" by auto
hoelzl@42863
   703
  from sigma_sets_Int[OF this]
hoelzl@47694
   704
  show ?thesis by simp
hoelzl@42863
   705
qed
hoelzl@42863
   706
hoelzl@42987
   707
lemma sigma_sets_vimage_commute:
hoelzl@47694
   708
  assumes X: "X \<in> \<Omega> \<rightarrow> \<Omega>'"
hoelzl@47694
   709
  shows "{X -` A \<inter> \<Omega> |A. A \<in> sigma_sets \<Omega>' M'}
hoelzl@47694
   710
       = sigma_sets \<Omega> {X -` A \<inter> \<Omega> |A. A \<in> M'}" (is "?L = ?R")
hoelzl@42987
   711
proof
hoelzl@42987
   712
  show "?L \<subseteq> ?R"
hoelzl@42987
   713
  proof clarify
hoelzl@47694
   714
    fix A assume "A \<in> sigma_sets \<Omega>' M'"
hoelzl@47694
   715
    then show "X -` A \<inter> \<Omega> \<in> ?R"
hoelzl@42987
   716
    proof induct
hoelzl@42987
   717
      case Empty then show ?case
hoelzl@42987
   718
        by (auto intro!: sigma_sets.Empty)
hoelzl@42987
   719
    next
hoelzl@42987
   720
      case (Compl B)
hoelzl@47694
   721
      have [simp]: "X -` (\<Omega>' - B) \<inter> \<Omega> = \<Omega> - (X -` B \<inter> \<Omega>)"
hoelzl@42987
   722
        by (auto simp add: funcset_mem [OF X])
hoelzl@42987
   723
      with Compl show ?case
hoelzl@42987
   724
        by (auto intro!: sigma_sets.Compl)
hoelzl@42987
   725
    next
hoelzl@42987
   726
      case (Union F)
hoelzl@42987
   727
      then show ?case
hoelzl@42987
   728
        by (auto simp add: vimage_UN UN_extend_simps(4) simp del: UN_simps
hoelzl@42987
   729
                 intro!: sigma_sets.Union)
hoelzl@47694
   730
    qed auto
hoelzl@42987
   731
  qed
hoelzl@42987
   732
  show "?R \<subseteq> ?L"
hoelzl@42987
   733
  proof clarify
hoelzl@42987
   734
    fix A assume "A \<in> ?R"
hoelzl@47694
   735
    then show "\<exists>B. A = X -` B \<inter> \<Omega> \<and> B \<in> sigma_sets \<Omega>' M'"
hoelzl@42987
   736
    proof induct
hoelzl@42987
   737
      case (Basic B) then show ?case by auto
hoelzl@42987
   738
    next
hoelzl@42987
   739
      case Empty then show ?case
hoelzl@47694
   740
        by (auto intro!: sigma_sets.Empty exI[of _ "{}"])
hoelzl@42987
   741
    next
hoelzl@42987
   742
      case (Compl B)
hoelzl@47694
   743
      then obtain A where A: "B = X -` A \<inter> \<Omega>" "A \<in> sigma_sets \<Omega>' M'" by auto
hoelzl@47694
   744
      then have [simp]: "\<Omega> - B = X -` (\<Omega>' - A) \<inter> \<Omega>"
hoelzl@42987
   745
        by (auto simp add: funcset_mem [OF X])
hoelzl@42987
   746
      with A(2) show ?case
hoelzl@47694
   747
        by (auto intro: sigma_sets.Compl)
hoelzl@42987
   748
    next
hoelzl@42987
   749
      case (Union F)
hoelzl@47694
   750
      then have "\<forall>i. \<exists>B. F i = X -` B \<inter> \<Omega> \<and> B \<in> sigma_sets \<Omega>' M'" by auto
hoelzl@42987
   751
      from choice[OF this] guess A .. note A = this
hoelzl@42987
   752
      with A show ?case
hoelzl@47694
   753
        by (auto simp: vimage_UN[symmetric] intro: sigma_sets.Union)
hoelzl@42987
   754
    qed
hoelzl@42987
   755
  qed
hoelzl@42987
   756
qed
hoelzl@42987
   757
hoelzl@42065
   758
lemma (in ring_of_sets) UNION_in_sets:
hoelzl@38656
   759
  fixes A:: "nat \<Rightarrow> 'a set"
hoelzl@47694
   760
  assumes A: "range A \<subseteq> M"
hoelzl@47694
   761
  shows  "(\<Union>i\<in>{0..<n}. A i) \<in> M"
hoelzl@38656
   762
proof (induct n)
hoelzl@38656
   763
  case 0 show ?case by simp
hoelzl@38656
   764
next
hoelzl@38656
   765
  case (Suc n)
hoelzl@38656
   766
  thus ?case
hoelzl@38656
   767
    by (simp add: atLeastLessThanSuc) (metis A Un UNIV_I image_subset_iff)
hoelzl@38656
   768
qed
hoelzl@38656
   769
hoelzl@42065
   770
lemma (in ring_of_sets) range_disjointed_sets:
hoelzl@47694
   771
  assumes A: "range A \<subseteq> M"
hoelzl@47694
   772
  shows  "range (disjointed A) \<subseteq> M"
hoelzl@38656
   773
proof (auto simp add: disjointed_def)
hoelzl@38656
   774
  fix n
hoelzl@47694
   775
  show "A n - (\<Union>i\<in>{0..<n}. A i) \<in> M" using UNION_in_sets
hoelzl@38656
   776
    by (metis A Diff UNIV_I image_subset_iff)
hoelzl@38656
   777
qed
hoelzl@38656
   778
hoelzl@42065
   779
lemma (in algebra) range_disjointed_sets':
hoelzl@47694
   780
  "range A \<subseteq> M \<Longrightarrow> range (disjointed A) \<subseteq> M"
hoelzl@42065
   781
  using range_disjointed_sets .
hoelzl@42065
   782
hoelzl@38656
   783
lemma sigma_algebra_disjoint_iff:
hoelzl@47694
   784
  "sigma_algebra \<Omega> M \<longleftrightarrow> algebra \<Omega> M \<and>
hoelzl@47694
   785
    (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M)"
hoelzl@38656
   786
proof (auto simp add: sigma_algebra_iff)
hoelzl@38656
   787
  fix A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
   788
  assume M: "algebra \<Omega> M"
hoelzl@47694
   789
     and A: "range A \<subseteq> M"
hoelzl@47694
   790
     and UnA: "\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M"
hoelzl@47694
   791
  hence "range (disjointed A) \<subseteq> M \<longrightarrow>
hoelzl@38656
   792
         disjoint_family (disjointed A) \<longrightarrow>
hoelzl@47694
   793
         (\<Union>i. disjointed A i) \<in> M" by blast
hoelzl@47694
   794
  hence "(\<Union>i. disjointed A i) \<in> M"
hoelzl@47694
   795
    by (simp add: algebra.range_disjointed_sets'[of \<Omega>] M A disjoint_family_disjointed)
hoelzl@47694
   796
  thus "(\<Union>i::nat. A i) \<in> M" by (simp add: UN_disjointed_eq)
hoelzl@47694
   797
qed
hoelzl@47694
   798
wenzelm@61808
   799
subsubsection \<open>Ring generated by a semiring\<close>
hoelzl@47762
   800
hoelzl@47762
   801
definition (in semiring_of_sets)
hoelzl@47762
   802
  "generated_ring = { \<Union>C | C. C \<subseteq> M \<and> finite C \<and> disjoint C }"
hoelzl@47762
   803
hoelzl@47762
   804
lemma (in semiring_of_sets) generated_ringE[elim?]:
hoelzl@47762
   805
  assumes "a \<in> generated_ring"
hoelzl@47762
   806
  obtains C where "finite C" "disjoint C" "C \<subseteq> M" "a = \<Union>C"
hoelzl@47762
   807
  using assms unfolding generated_ring_def by auto
hoelzl@47762
   808
hoelzl@47762
   809
lemma (in semiring_of_sets) generated_ringI[intro?]:
hoelzl@47762
   810
  assumes "finite C" "disjoint C" "C \<subseteq> M" "a = \<Union>C"
hoelzl@47762
   811
  shows "a \<in> generated_ring"
hoelzl@47762
   812
  using assms unfolding generated_ring_def by auto
hoelzl@47762
   813
hoelzl@47762
   814
lemma (in semiring_of_sets) generated_ringI_Basic:
hoelzl@47762
   815
  "A \<in> M \<Longrightarrow> A \<in> generated_ring"
hoelzl@47762
   816
  by (rule generated_ringI[of "{A}"]) (auto simp: disjoint_def)
hoelzl@47762
   817
hoelzl@47762
   818
lemma (in semiring_of_sets) generated_ring_disjoint_Un[intro]:
hoelzl@47762
   819
  assumes a: "a \<in> generated_ring" and b: "b \<in> generated_ring"
hoelzl@47762
   820
  and "a \<inter> b = {}"
hoelzl@47762
   821
  shows "a \<union> b \<in> generated_ring"
hoelzl@47762
   822
proof -
hoelzl@47762
   823
  from a guess Ca .. note Ca = this
hoelzl@47762
   824
  from b guess Cb .. note Cb = this
hoelzl@47762
   825
  show ?thesis
hoelzl@47762
   826
  proof
hoelzl@47762
   827
    show "disjoint (Ca \<union> Cb)"
wenzelm@61808
   828
      using \<open>a \<inter> b = {}\<close> Ca Cb by (auto intro!: disjoint_union)
hoelzl@47762
   829
  qed (insert Ca Cb, auto)
hoelzl@47762
   830
qed
hoelzl@47762
   831
hoelzl@47762
   832
lemma (in semiring_of_sets) generated_ring_empty: "{} \<in> generated_ring"
hoelzl@47762
   833
  by (auto simp: generated_ring_def disjoint_def)
hoelzl@47762
   834
hoelzl@47762
   835
lemma (in semiring_of_sets) generated_ring_disjoint_Union:
hoelzl@47762
   836
  assumes "finite A" shows "A \<subseteq> generated_ring \<Longrightarrow> disjoint A \<Longrightarrow> \<Union>A \<in> generated_ring"
hoelzl@47762
   837
  using assms by (induct A) (auto simp: disjoint_def intro!: generated_ring_disjoint_Un generated_ring_empty)
hoelzl@47762
   838
hoelzl@47762
   839
lemma (in semiring_of_sets) generated_ring_disjoint_UNION:
hoelzl@47762
   840
  "finite I \<Longrightarrow> disjoint (A ` I) \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> A i \<in> generated_ring) \<Longrightarrow> UNION I A \<in> generated_ring"
haftmann@62343
   841
  by (intro generated_ring_disjoint_Union) auto
hoelzl@47762
   842
hoelzl@47762
   843
lemma (in semiring_of_sets) generated_ring_Int:
hoelzl@47762
   844
  assumes a: "a \<in> generated_ring" and b: "b \<in> generated_ring"
hoelzl@47762
   845
  shows "a \<inter> b \<in> generated_ring"
hoelzl@47762
   846
proof -
hoelzl@47762
   847
  from a guess Ca .. note Ca = this
hoelzl@47762
   848
  from b guess Cb .. note Cb = this
wenzelm@63040
   849
  define C where "C = (\<lambda>(a,b). a \<inter> b)` (Ca\<times>Cb)"
hoelzl@47762
   850
  show ?thesis
hoelzl@47762
   851
  proof
hoelzl@47762
   852
    show "disjoint C"
hoelzl@47762
   853
    proof (simp add: disjoint_def C_def, intro ballI impI)
hoelzl@47762
   854
      fix a1 b1 a2 b2 assume sets: "a1 \<in> Ca" "b1 \<in> Cb" "a2 \<in> Ca" "b2 \<in> Cb"
hoelzl@47762
   855
      assume "a1 \<inter> b1 \<noteq> a2 \<inter> b2"
hoelzl@47762
   856
      then have "a1 \<noteq> a2 \<or> b1 \<noteq> b2" by auto
hoelzl@47762
   857
      then show "(a1 \<inter> b1) \<inter> (a2 \<inter> b2) = {}"
hoelzl@47762
   858
      proof
hoelzl@47762
   859
        assume "a1 \<noteq> a2"
hoelzl@47762
   860
        with sets Ca have "a1 \<inter> a2 = {}"
hoelzl@47762
   861
          by (auto simp: disjoint_def)
hoelzl@47762
   862
        then show ?thesis by auto
hoelzl@47762
   863
      next
hoelzl@47762
   864
        assume "b1 \<noteq> b2"
hoelzl@47762
   865
        with sets Cb have "b1 \<inter> b2 = {}"
hoelzl@47762
   866
          by (auto simp: disjoint_def)
hoelzl@47762
   867
        then show ?thesis by auto
hoelzl@47762
   868
      qed
hoelzl@47762
   869
    qed
hoelzl@47762
   870
  qed (insert Ca Cb, auto simp: C_def)
hoelzl@47762
   871
qed
hoelzl@47762
   872
hoelzl@47762
   873
lemma (in semiring_of_sets) generated_ring_Inter:
hoelzl@47762
   874
  assumes "finite A" "A \<noteq> {}" shows "A \<subseteq> generated_ring \<Longrightarrow> \<Inter>A \<in> generated_ring"
hoelzl@47762
   875
  using assms by (induct A rule: finite_ne_induct) (auto intro: generated_ring_Int)
hoelzl@47762
   876
hoelzl@47762
   877
lemma (in semiring_of_sets) generated_ring_INTER:
hoelzl@47762
   878
  "finite I \<Longrightarrow> I \<noteq> {} \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> A i \<in> generated_ring) \<Longrightarrow> INTER I A \<in> generated_ring"
haftmann@62343
   879
  by (intro generated_ring_Inter) auto
hoelzl@47762
   880
hoelzl@47762
   881
lemma (in semiring_of_sets) generating_ring:
hoelzl@47762
   882
  "ring_of_sets \<Omega> generated_ring"
hoelzl@47762
   883
proof (rule ring_of_setsI)
hoelzl@47762
   884
  let ?R = generated_ring
hoelzl@47762
   885
  show "?R \<subseteq> Pow \<Omega>"
hoelzl@47762
   886
    using sets_into_space by (auto simp: generated_ring_def generated_ring_empty)
hoelzl@47762
   887
  show "{} \<in> ?R" by (rule generated_ring_empty)
hoelzl@47762
   888
hoelzl@47762
   889
  { fix a assume a: "a \<in> ?R" then guess Ca .. note Ca = this
hoelzl@47762
   890
    fix b assume b: "b \<in> ?R" then guess Cb .. note Cb = this
hoelzl@62975
   891
hoelzl@47762
   892
    show "a - b \<in> ?R"
hoelzl@47762
   893
    proof cases
wenzelm@61808
   894
      assume "Cb = {}" with Cb \<open>a \<in> ?R\<close> show ?thesis
hoelzl@47762
   895
        by simp
hoelzl@47762
   896
    next
hoelzl@47762
   897
      assume "Cb \<noteq> {}"
hoelzl@47762
   898
      with Ca Cb have "a - b = (\<Union>a'\<in>Ca. \<Inter>b'\<in>Cb. a' - b')" by auto
hoelzl@47762
   899
      also have "\<dots> \<in> ?R"
hoelzl@47762
   900
      proof (intro generated_ring_INTER generated_ring_disjoint_UNION)
hoelzl@47762
   901
        fix a b assume "a \<in> Ca" "b \<in> Cb"
hoelzl@47762
   902
        with Ca Cb Diff_cover[of a b] show "a - b \<in> ?R"
hoelzl@47762
   903
          by (auto simp add: generated_ring_def)
haftmann@62343
   904
            (metis DiffI Diff_eq_empty_iff empty_iff)
hoelzl@47762
   905
      next
hoelzl@47762
   906
        show "disjoint ((\<lambda>a'. \<Inter>b'\<in>Cb. a' - b')`Ca)"
wenzelm@61808
   907
          using Ca by (auto simp add: disjoint_def \<open>Cb \<noteq> {}\<close>)
hoelzl@47762
   908
      next
hoelzl@47762
   909
        show "finite Ca" "finite Cb" "Cb \<noteq> {}" by fact+
hoelzl@47762
   910
      qed
hoelzl@47762
   911
      finally show "a - b \<in> ?R" .
hoelzl@47762
   912
    qed }
hoelzl@47762
   913
  note Diff = this
hoelzl@47762
   914
hoelzl@47762
   915
  fix a b assume sets: "a \<in> ?R" "b \<in> ?R"
hoelzl@47762
   916
  have "a \<union> b = (a - b) \<union> (a \<inter> b) \<union> (b - a)" by auto
hoelzl@47762
   917
  also have "\<dots> \<in> ?R"
hoelzl@47762
   918
    by (intro sets generated_ring_disjoint_Un generated_ring_Int Diff) auto
hoelzl@47762
   919
  finally show "a \<union> b \<in> ?R" .
hoelzl@47762
   920
qed
hoelzl@47762
   921
hoelzl@47762
   922
lemma (in semiring_of_sets) sigma_sets_generated_ring_eq: "sigma_sets \<Omega> generated_ring = sigma_sets \<Omega> M"
hoelzl@47762
   923
proof
hoelzl@47762
   924
  interpret M: sigma_algebra \<Omega> "sigma_sets \<Omega> M"
hoelzl@47762
   925
    using space_closed by (rule sigma_algebra_sigma_sets)
hoelzl@47762
   926
  show "sigma_sets \<Omega> generated_ring \<subseteq> sigma_sets \<Omega> M"
hoelzl@47762
   927
    by (blast intro!: sigma_sets_mono elim: generated_ringE)
hoelzl@47762
   928
qed (auto intro!: generated_ringI_Basic sigma_sets_mono)
hoelzl@47762
   929
wenzelm@61808
   930
subsubsection \<open>A Two-Element Series\<close>
hoelzl@38656
   931
hoelzl@62975
   932
definition binaryset :: "'a set \<Rightarrow> 'a set \<Rightarrow> nat \<Rightarrow> 'a set"
wenzelm@50252
   933
  where "binaryset A B = (\<lambda>x. {})(0 := A, Suc 0 := B)"
hoelzl@38656
   934
hoelzl@38656
   935
lemma range_binaryset_eq: "range(binaryset A B) = {A,B,{}}"
hoelzl@38656
   936
  apply (simp add: binaryset_def)
nipkow@39302
   937
  apply (rule set_eqI)
hoelzl@38656
   938
  apply (auto simp add: image_iff)
hoelzl@38656
   939
  done
hoelzl@38656
   940
hoelzl@38656
   941
lemma UN_binaryset_eq: "(\<Union>i. binaryset A B i) = A \<union> B"
haftmann@62343
   942
  by (simp add: range_binaryset_eq cong del: strong_SUP_cong)
hoelzl@38656
   943
wenzelm@61808
   944
subsubsection \<open>Closed CDI\<close>
hoelzl@38656
   945
hoelzl@47694
   946
definition closed_cdi where
hoelzl@47694
   947
  "closed_cdi \<Omega> M \<longleftrightarrow>
hoelzl@47694
   948
   M \<subseteq> Pow \<Omega> &
hoelzl@47694
   949
   (\<forall>s \<in> M. \<Omega> - s \<in> M) &
hoelzl@47694
   950
   (\<forall>A. (range A \<subseteq> M) & (A 0 = {}) & (\<forall>n. A n \<subseteq> A (Suc n)) \<longrightarrow>
hoelzl@47694
   951
        (\<Union>i. A i) \<in> M) &
hoelzl@47694
   952
   (\<forall>A. (range A \<subseteq> M) & disjoint_family A \<longrightarrow> (\<Union>i::nat. A i) \<in> M)"
hoelzl@38656
   953
hoelzl@38656
   954
inductive_set
hoelzl@47694
   955
  smallest_ccdi_sets :: "'a set \<Rightarrow> 'a set set \<Rightarrow> 'a set set"
hoelzl@47694
   956
  for \<Omega> M
hoelzl@38656
   957
  where
hoelzl@38656
   958
    Basic [intro]:
hoelzl@47694
   959
      "a \<in> M \<Longrightarrow> a \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
   960
  | Compl [intro]:
hoelzl@47694
   961
      "a \<in> smallest_ccdi_sets \<Omega> M \<Longrightarrow> \<Omega> - a \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
   962
  | Inc:
hoelzl@47694
   963
      "range A \<in> Pow(smallest_ccdi_sets \<Omega> M) \<Longrightarrow> A 0 = {} \<Longrightarrow> (\<And>n. A n \<subseteq> A (Suc n))
hoelzl@47694
   964
       \<Longrightarrow> (\<Union>i. A i) \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
   965
  | Disj:
hoelzl@47694
   966
      "range A \<in> Pow(smallest_ccdi_sets \<Omega> M) \<Longrightarrow> disjoint_family A
hoelzl@47694
   967
       \<Longrightarrow> (\<Union>i::nat. A i) \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
   968
hoelzl@47694
   969
lemma (in subset_class) smallest_closed_cdi1: "M \<subseteq> smallest_ccdi_sets \<Omega> M"
hoelzl@47694
   970
  by auto
hoelzl@38656
   971
hoelzl@47694
   972
lemma (in subset_class) smallest_ccdi_sets: "smallest_ccdi_sets \<Omega> M \<subseteq> Pow \<Omega>"
hoelzl@38656
   973
  apply (rule subsetI)
hoelzl@38656
   974
  apply (erule smallest_ccdi_sets.induct)
hoelzl@38656
   975
  apply (auto intro: range_subsetD dest: sets_into_space)
hoelzl@38656
   976
  done
hoelzl@38656
   977
hoelzl@47694
   978
lemma (in subset_class) smallest_closed_cdi2: "closed_cdi \<Omega> (smallest_ccdi_sets \<Omega> M)"
hoelzl@47694
   979
  apply (auto simp add: closed_cdi_def smallest_ccdi_sets)
hoelzl@38656
   980
  apply (blast intro: smallest_ccdi_sets.Inc smallest_ccdi_sets.Disj) +
hoelzl@38656
   981
  done
hoelzl@38656
   982
hoelzl@47694
   983
lemma closed_cdi_subset: "closed_cdi \<Omega> M \<Longrightarrow> M \<subseteq> Pow \<Omega>"
hoelzl@38656
   984
  by (simp add: closed_cdi_def)
hoelzl@38656
   985
hoelzl@47694
   986
lemma closed_cdi_Compl: "closed_cdi \<Omega> M \<Longrightarrow> s \<in> M \<Longrightarrow> \<Omega> - s \<in> M"
hoelzl@38656
   987
  by (simp add: closed_cdi_def)
hoelzl@38656
   988
hoelzl@38656
   989
lemma closed_cdi_Inc:
hoelzl@47694
   990
  "closed_cdi \<Omega> M \<Longrightarrow> range A \<subseteq> M \<Longrightarrow> A 0 = {} \<Longrightarrow> (!!n. A n \<subseteq> A (Suc n)) \<Longrightarrow> (\<Union>i. A i) \<in> M"
hoelzl@38656
   991
  by (simp add: closed_cdi_def)
hoelzl@38656
   992
hoelzl@38656
   993
lemma closed_cdi_Disj:
hoelzl@47694
   994
  "closed_cdi \<Omega> M \<Longrightarrow> range A \<subseteq> M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
hoelzl@38656
   995
  by (simp add: closed_cdi_def)
hoelzl@38656
   996
hoelzl@38656
   997
lemma closed_cdi_Un:
hoelzl@47694
   998
  assumes cdi: "closed_cdi \<Omega> M" and empty: "{} \<in> M"
hoelzl@47694
   999
      and A: "A \<in> M" and B: "B \<in> M"
hoelzl@38656
  1000
      and disj: "A \<inter> B = {}"
hoelzl@47694
  1001
    shows "A \<union> B \<in> M"
hoelzl@38656
  1002
proof -
hoelzl@47694
  1003
  have ra: "range (binaryset A B) \<subseteq> M"
hoelzl@38656
  1004
   by (simp add: range_binaryset_eq empty A B)
hoelzl@38656
  1005
 have di:  "disjoint_family (binaryset A B)" using disj
hoelzl@38656
  1006
   by (simp add: disjoint_family_on_def binaryset_def Int_commute)
hoelzl@38656
  1007
 from closed_cdi_Disj [OF cdi ra di]
hoelzl@38656
  1008
 show ?thesis
hoelzl@38656
  1009
   by (simp add: UN_binaryset_eq)
hoelzl@38656
  1010
qed
hoelzl@38656
  1011
hoelzl@38656
  1012
lemma (in algebra) smallest_ccdi_sets_Un:
hoelzl@47694
  1013
  assumes A: "A \<in> smallest_ccdi_sets \<Omega> M" and B: "B \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1014
      and disj: "A \<inter> B = {}"
hoelzl@47694
  1015
    shows "A \<union> B \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1016
proof -
hoelzl@47694
  1017
  have ra: "range (binaryset A B) \<in> Pow (smallest_ccdi_sets \<Omega> M)"
hoelzl@38656
  1018
    by (simp add: range_binaryset_eq  A B smallest_ccdi_sets.Basic)
hoelzl@38656
  1019
  have di:  "disjoint_family (binaryset A B)" using disj
hoelzl@38656
  1020
    by (simp add: disjoint_family_on_def binaryset_def Int_commute)
hoelzl@38656
  1021
  from Disj [OF ra di]
hoelzl@38656
  1022
  show ?thesis
hoelzl@38656
  1023
    by (simp add: UN_binaryset_eq)
hoelzl@38656
  1024
qed
hoelzl@38656
  1025
hoelzl@38656
  1026
lemma (in algebra) smallest_ccdi_sets_Int1:
hoelzl@47694
  1027
  assumes a: "a \<in> M"
hoelzl@47694
  1028
  shows "b \<in> smallest_ccdi_sets \<Omega> M \<Longrightarrow> a \<inter> b \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1029
proof (induct rule: smallest_ccdi_sets.induct)
hoelzl@38656
  1030
  case (Basic x)
hoelzl@38656
  1031
  thus ?case
hoelzl@38656
  1032
    by (metis a Int smallest_ccdi_sets.Basic)
hoelzl@38656
  1033
next
hoelzl@38656
  1034
  case (Compl x)
hoelzl@47694
  1035
  have "a \<inter> (\<Omega> - x) = \<Omega> - ((\<Omega> - a) \<union> (a \<inter> x))"
hoelzl@38656
  1036
    by blast
hoelzl@47694
  1037
  also have "... \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1038
    by (metis smallest_ccdi_sets.Compl a Compl(2) Diff_Int2 Diff_Int_distrib2
hoelzl@47694
  1039
           Diff_disjoint Int_Diff Int_empty_right smallest_ccdi_sets_Un
hoelzl@47694
  1040
           smallest_ccdi_sets.Basic smallest_ccdi_sets.Compl)
hoelzl@38656
  1041
  finally show ?case .
hoelzl@38656
  1042
next
hoelzl@38656
  1043
  case (Inc A)
hoelzl@38656
  1044
  have 1: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) = a \<inter> (\<Union>i. A i)"
hoelzl@38656
  1045
    by blast
hoelzl@47694
  1046
  have "range (\<lambda>i. a \<inter> A i) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Inc
hoelzl@38656
  1047
    by blast
hoelzl@38656
  1048
  moreover have "(\<lambda>i. a \<inter> A i) 0 = {}"
hoelzl@38656
  1049
    by (simp add: Inc)
hoelzl@38656
  1050
  moreover have "!!n. (\<lambda>i. a \<inter> A i) n \<subseteq> (\<lambda>i. a \<inter> A i) (Suc n)" using Inc
hoelzl@38656
  1051
    by blast
hoelzl@47694
  1052
  ultimately have 2: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1053
    by (rule smallest_ccdi_sets.Inc)
hoelzl@38656
  1054
  show ?case
hoelzl@38656
  1055
    by (metis 1 2)
hoelzl@38656
  1056
next
hoelzl@38656
  1057
  case (Disj A)
hoelzl@38656
  1058
  have 1: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) = a \<inter> (\<Union>i. A i)"
hoelzl@38656
  1059
    by blast
hoelzl@47694
  1060
  have "range (\<lambda>i. a \<inter> A i) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Disj
hoelzl@38656
  1061
    by blast
hoelzl@38656
  1062
  moreover have "disjoint_family (\<lambda>i. a \<inter> A i)" using Disj
hoelzl@38656
  1063
    by (auto simp add: disjoint_family_on_def)
hoelzl@47694
  1064
  ultimately have 2: "(\<Union>i. (\<lambda>i. a \<inter> A i) i) \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1065
    by (rule smallest_ccdi_sets.Disj)
hoelzl@38656
  1066
  show ?case
hoelzl@38656
  1067
    by (metis 1 2)
hoelzl@38656
  1068
qed
hoelzl@38656
  1069
hoelzl@38656
  1070
hoelzl@38656
  1071
lemma (in algebra) smallest_ccdi_sets_Int:
hoelzl@47694
  1072
  assumes b: "b \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@47694
  1073
  shows "a \<in> smallest_ccdi_sets \<Omega> M \<Longrightarrow> a \<inter> b \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1074
proof (induct rule: smallest_ccdi_sets.induct)
hoelzl@38656
  1075
  case (Basic x)
hoelzl@38656
  1076
  thus ?case
hoelzl@38656
  1077
    by (metis b smallest_ccdi_sets_Int1)
hoelzl@38656
  1078
next
hoelzl@38656
  1079
  case (Compl x)
hoelzl@47694
  1080
  have "(\<Omega> - x) \<inter> b = \<Omega> - (x \<inter> b \<union> (\<Omega> - b))"
hoelzl@38656
  1081
    by blast
hoelzl@47694
  1082
  also have "... \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1083
    by (metis Compl(2) Diff_disjoint Int_Diff Int_commute Int_empty_right b
hoelzl@38656
  1084
           smallest_ccdi_sets.Compl smallest_ccdi_sets_Un)
hoelzl@38656
  1085
  finally show ?case .
hoelzl@38656
  1086
next
hoelzl@38656
  1087
  case (Inc A)
hoelzl@38656
  1088
  have 1: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) = (\<Union>i. A i) \<inter> b"
hoelzl@38656
  1089
    by blast
hoelzl@47694
  1090
  have "range (\<lambda>i. A i \<inter> b) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Inc
hoelzl@38656
  1091
    by blast
hoelzl@38656
  1092
  moreover have "(\<lambda>i. A i \<inter> b) 0 = {}"
hoelzl@38656
  1093
    by (simp add: Inc)
hoelzl@38656
  1094
  moreover have "!!n. (\<lambda>i. A i \<inter> b) n \<subseteq> (\<lambda>i. A i \<inter> b) (Suc n)" using Inc
hoelzl@38656
  1095
    by blast
hoelzl@47694
  1096
  ultimately have 2: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1097
    by (rule smallest_ccdi_sets.Inc)
hoelzl@38656
  1098
  show ?case
hoelzl@38656
  1099
    by (metis 1 2)
hoelzl@38656
  1100
next
hoelzl@38656
  1101
  case (Disj A)
hoelzl@38656
  1102
  have 1: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) = (\<Union>i. A i) \<inter> b"
hoelzl@38656
  1103
    by blast
hoelzl@47694
  1104
  have "range (\<lambda>i. A i \<inter> b) \<in> Pow(smallest_ccdi_sets \<Omega> M)" using Disj
hoelzl@38656
  1105
    by blast
hoelzl@38656
  1106
  moreover have "disjoint_family (\<lambda>i. A i \<inter> b)" using Disj
hoelzl@38656
  1107
    by (auto simp add: disjoint_family_on_def)
hoelzl@47694
  1108
  ultimately have 2: "(\<Union>i. (\<lambda>i. A i \<inter> b) i) \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1109
    by (rule smallest_ccdi_sets.Disj)
hoelzl@38656
  1110
  show ?case
hoelzl@38656
  1111
    by (metis 1 2)
hoelzl@38656
  1112
qed
hoelzl@38656
  1113
hoelzl@38656
  1114
lemma (in algebra) sigma_property_disjoint_lemma:
hoelzl@47694
  1115
  assumes sbC: "M \<subseteq> C"
hoelzl@47694
  1116
      and ccdi: "closed_cdi \<Omega> C"
hoelzl@47694
  1117
  shows "sigma_sets \<Omega> M \<subseteq> C"
hoelzl@38656
  1118
proof -
hoelzl@47694
  1119
  have "smallest_ccdi_sets \<Omega> M \<in> {B . M \<subseteq> B \<and> sigma_algebra \<Omega> B}"
hoelzl@38656
  1120
    apply (auto simp add: sigma_algebra_disjoint_iff algebra_iff_Int
hoelzl@38656
  1121
            smallest_ccdi_sets_Int)
hoelzl@38656
  1122
    apply (metis Union_Pow_eq Union_upper subsetD smallest_ccdi_sets)
hoelzl@38656
  1123
    apply (blast intro: smallest_ccdi_sets.Disj)
hoelzl@38656
  1124
    done
hoelzl@47694
  1125
  hence "sigma_sets (\<Omega>) (M) \<subseteq> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1126
    by clarsimp
hoelzl@47694
  1127
       (drule sigma_algebra.sigma_sets_subset [where a="M"], auto)
hoelzl@38656
  1128
  also have "...  \<subseteq> C"
hoelzl@38656
  1129
    proof
hoelzl@38656
  1130
      fix x
hoelzl@47694
  1131
      assume x: "x \<in> smallest_ccdi_sets \<Omega> M"
hoelzl@38656
  1132
      thus "x \<in> C"
hoelzl@38656
  1133
        proof (induct rule: smallest_ccdi_sets.induct)
hoelzl@38656
  1134
          case (Basic x)
hoelzl@38656
  1135
          thus ?case
hoelzl@38656
  1136
            by (metis Basic subsetD sbC)
hoelzl@38656
  1137
        next
hoelzl@38656
  1138
          case (Compl x)
hoelzl@38656
  1139
          thus ?case
hoelzl@38656
  1140
            by (blast intro: closed_cdi_Compl [OF ccdi, simplified])
hoelzl@38656
  1141
        next
hoelzl@38656
  1142
          case (Inc A)
hoelzl@38656
  1143
          thus ?case
hoelzl@38656
  1144
               by (auto intro: closed_cdi_Inc [OF ccdi, simplified])
hoelzl@38656
  1145
        next
hoelzl@38656
  1146
          case (Disj A)
hoelzl@38656
  1147
          thus ?case
hoelzl@38656
  1148
               by (auto intro: closed_cdi_Disj [OF ccdi, simplified])
hoelzl@38656
  1149
        qed
hoelzl@38656
  1150
    qed
hoelzl@38656
  1151
  finally show ?thesis .
hoelzl@38656
  1152
qed
hoelzl@38656
  1153
hoelzl@38656
  1154
lemma (in algebra) sigma_property_disjoint:
hoelzl@47694
  1155
  assumes sbC: "M \<subseteq> C"
hoelzl@47694
  1156
      and compl: "!!s. s \<in> C \<inter> sigma_sets (\<Omega>) (M) \<Longrightarrow> \<Omega> - s \<in> C"
hoelzl@47694
  1157
      and inc: "!!A. range A \<subseteq> C \<inter> sigma_sets (\<Omega>) (M)
hoelzl@38656
  1158
                     \<Longrightarrow> A 0 = {} \<Longrightarrow> (!!n. A n \<subseteq> A (Suc n))
hoelzl@38656
  1159
                     \<Longrightarrow> (\<Union>i. A i) \<in> C"
hoelzl@47694
  1160
      and disj: "!!A. range A \<subseteq> C \<inter> sigma_sets (\<Omega>) (M)
hoelzl@38656
  1161
                      \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i::nat. A i) \<in> C"
hoelzl@47694
  1162
  shows "sigma_sets (\<Omega>) (M) \<subseteq> C"
hoelzl@38656
  1163
proof -
hoelzl@47694
  1164
  have "sigma_sets (\<Omega>) (M) \<subseteq> C \<inter> sigma_sets (\<Omega>) (M)"
hoelzl@38656
  1165
    proof (rule sigma_property_disjoint_lemma)
hoelzl@47694
  1166
      show "M \<subseteq> C \<inter> sigma_sets (\<Omega>) (M)"
hoelzl@38656
  1167
        by (metis Int_greatest Set.subsetI sbC sigma_sets.Basic)
hoelzl@38656
  1168
    next
hoelzl@47694
  1169
      show "closed_cdi \<Omega> (C \<inter> sigma_sets (\<Omega>) (M))"
hoelzl@38656
  1170
        by (simp add: closed_cdi_def compl inc disj)
hoelzl@38656
  1171
           (metis PowI Set.subsetI le_infI2 sigma_sets_into_sp space_closed
hoelzl@38656
  1172
             IntE sigma_sets.Compl range_subsetD sigma_sets.Union)
hoelzl@38656
  1173
    qed
hoelzl@38656
  1174
  thus ?thesis
hoelzl@38656
  1175
    by blast
hoelzl@38656
  1176
qed
hoelzl@38656
  1177
wenzelm@61808
  1178
subsubsection \<open>Dynkin systems\<close>
hoelzl@40859
  1179
hoelzl@42065
  1180
locale dynkin_system = subset_class +
hoelzl@47694
  1181
  assumes space: "\<Omega> \<in> M"
hoelzl@47694
  1182
    and   compl[intro!]: "\<And>A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M"
hoelzl@47694
  1183
    and   UN[intro!]: "\<And>A. disjoint_family A \<Longrightarrow> range A \<subseteq> M
hoelzl@47694
  1184
                           \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
hoelzl@40859
  1185
hoelzl@47694
  1186
lemma (in dynkin_system) empty[intro, simp]: "{} \<in> M"
hoelzl@47694
  1187
  using space compl[of "\<Omega>"] by simp
hoelzl@40859
  1188
hoelzl@40859
  1189
lemma (in dynkin_system) diff:
hoelzl@47694
  1190
  assumes sets: "D \<in> M" "E \<in> M" and "D \<subseteq> E"
hoelzl@47694
  1191
  shows "E - D \<in> M"
hoelzl@40859
  1192
proof -
hoelzl@47694
  1193
  let ?f = "\<lambda>x. if x = 0 then D else if x = Suc 0 then \<Omega> - E else {}"
hoelzl@47694
  1194
  have "range ?f = {D, \<Omega> - E, {}}"
hoelzl@40859
  1195
    by (auto simp: image_iff)
hoelzl@47694
  1196
  moreover have "D \<union> (\<Omega> - E) = (\<Union>i. ?f i)"
nipkow@62390
  1197
    by (auto simp: image_iff split: if_split_asm)
hoelzl@40859
  1198
  moreover
wenzelm@53374
  1199
  have "disjoint_family ?f" unfolding disjoint_family_on_def
wenzelm@61808
  1200
    using \<open>D \<in> M\<close>[THEN sets_into_space] \<open>D \<subseteq> E\<close> by auto
hoelzl@47694
  1201
  ultimately have "\<Omega> - (D \<union> (\<Omega> - E)) \<in> M"
hoelzl@40859
  1202
    using sets by auto
hoelzl@47694
  1203
  also have "\<Omega> - (D \<union> (\<Omega> - E)) = E - D"
hoelzl@40859
  1204
    using assms sets_into_space by auto
hoelzl@40859
  1205
  finally show ?thesis .
hoelzl@40859
  1206
qed
hoelzl@40859
  1207
hoelzl@40859
  1208
lemma dynkin_systemI:
hoelzl@47694
  1209
  assumes "\<And> A. A \<in> M \<Longrightarrow> A \<subseteq> \<Omega>" "\<Omega> \<in> M"
hoelzl@47694
  1210
  assumes "\<And> A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M"
hoelzl@47694
  1211
  assumes "\<And> A. disjoint_family A \<Longrightarrow> range A \<subseteq> M
hoelzl@47694
  1212
          \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
hoelzl@47694
  1213
  shows "dynkin_system \<Omega> M"
hoelzl@42065
  1214
  using assms by (auto simp: dynkin_system_def dynkin_system_axioms_def subset_class_def)
hoelzl@40859
  1215
hoelzl@42988
  1216
lemma dynkin_systemI':
hoelzl@47694
  1217
  assumes 1: "\<And> A. A \<in> M \<Longrightarrow> A \<subseteq> \<Omega>"
hoelzl@47694
  1218
  assumes empty: "{} \<in> M"
hoelzl@47694
  1219
  assumes Diff: "\<And> A. A \<in> M \<Longrightarrow> \<Omega> - A \<in> M"
hoelzl@47694
  1220
  assumes 2: "\<And> A. disjoint_family A \<Longrightarrow> range A \<subseteq> M
hoelzl@47694
  1221
          \<Longrightarrow> (\<Union>i::nat. A i) \<in> M"
hoelzl@47694
  1222
  shows "dynkin_system \<Omega> M"
hoelzl@42988
  1223
proof -
hoelzl@47694
  1224
  from Diff[OF empty] have "\<Omega> \<in> M" by auto
hoelzl@42988
  1225
  from 1 this Diff 2 show ?thesis
hoelzl@42988
  1226
    by (intro dynkin_systemI) auto
hoelzl@42988
  1227
qed
hoelzl@42988
  1228
hoelzl@40859
  1229
lemma dynkin_system_trivial:
hoelzl@47694
  1230
  shows "dynkin_system A (Pow A)"
hoelzl@40859
  1231
  by (rule dynkin_systemI) auto
hoelzl@40859
  1232
hoelzl@40859
  1233
lemma sigma_algebra_imp_dynkin_system:
hoelzl@47694
  1234
  assumes "sigma_algebra \<Omega> M" shows "dynkin_system \<Omega> M"
hoelzl@40859
  1235
proof -
hoelzl@47694
  1236
  interpret sigma_algebra \<Omega> M by fact
nipkow@44890
  1237
  show ?thesis using sets_into_space by (fastforce intro!: dynkin_systemI)
hoelzl@40859
  1238
qed
hoelzl@40859
  1239
hoelzl@56994
  1240
subsubsection "Intersection sets systems"
hoelzl@40859
  1241
hoelzl@47694
  1242
definition "Int_stable M \<longleftrightarrow> (\<forall> a \<in> M. \<forall> b \<in> M. a \<inter> b \<in> M)"
hoelzl@40859
  1243
hoelzl@40859
  1244
lemma (in algebra) Int_stable: "Int_stable M"
hoelzl@40859
  1245
  unfolding Int_stable_def by auto
hoelzl@40859
  1246
hoelzl@42981
  1247
lemma Int_stableI:
hoelzl@47694
  1248
  "(\<And>a b. a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> a \<inter> b \<in> A) \<Longrightarrow> Int_stable A"
hoelzl@42981
  1249
  unfolding Int_stable_def by auto
hoelzl@42981
  1250
hoelzl@42981
  1251
lemma Int_stableD:
hoelzl@47694
  1252
  "Int_stable M \<Longrightarrow> a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<inter> b \<in> M"
hoelzl@42981
  1253
  unfolding Int_stable_def by auto
hoelzl@42981
  1254
hoelzl@40859
  1255
lemma (in dynkin_system) sigma_algebra_eq_Int_stable:
hoelzl@47694
  1256
  "sigma_algebra \<Omega> M \<longleftrightarrow> Int_stable M"
hoelzl@40859
  1257
proof
hoelzl@47694
  1258
  assume "sigma_algebra \<Omega> M" then show "Int_stable M"
hoelzl@40859
  1259
    unfolding sigma_algebra_def using algebra.Int_stable by auto
hoelzl@40859
  1260
next
hoelzl@40859
  1261
  assume "Int_stable M"
hoelzl@47694
  1262
  show "sigma_algebra \<Omega> M"
hoelzl@42065
  1263
    unfolding sigma_algebra_disjoint_iff algebra_iff_Un
hoelzl@40859
  1264
  proof (intro conjI ballI allI impI)
hoelzl@47694
  1265
    show "M \<subseteq> Pow (\<Omega>)" using sets_into_space by auto
hoelzl@40859
  1266
  next
hoelzl@47694
  1267
    fix A B assume "A \<in> M" "B \<in> M"
hoelzl@47694
  1268
    then have "A \<union> B = \<Omega> - ((\<Omega> - A) \<inter> (\<Omega> - B))"
hoelzl@47694
  1269
              "\<Omega> - A \<in> M" "\<Omega> - B \<in> M"
hoelzl@40859
  1270
      using sets_into_space by auto
hoelzl@47694
  1271
    then show "A \<union> B \<in> M"
wenzelm@61808
  1272
      using \<open>Int_stable M\<close> unfolding Int_stable_def by auto
hoelzl@40859
  1273
  qed auto
hoelzl@40859
  1274
qed
hoelzl@40859
  1275
hoelzl@56994
  1276
subsubsection "Smallest Dynkin systems"
hoelzl@40859
  1277
hoelzl@41689
  1278
definition dynkin where
hoelzl@47694
  1279
  "dynkin \<Omega> M =  (\<Inter>{D. dynkin_system \<Omega> D \<and> M \<subseteq> D})"
hoelzl@40859
  1280
hoelzl@40859
  1281
lemma dynkin_system_dynkin:
hoelzl@47694
  1282
  assumes "M \<subseteq> Pow (\<Omega>)"
hoelzl@47694
  1283
  shows "dynkin_system \<Omega> (dynkin \<Omega> M)"
hoelzl@40859
  1284
proof (rule dynkin_systemI)
hoelzl@47694
  1285
  fix A assume "A \<in> dynkin \<Omega> M"
hoelzl@40859
  1286
  moreover
hoelzl@47694
  1287
  { fix D assume "A \<in> D" and d: "dynkin_system \<Omega> D"
hoelzl@47694
  1288
    then have "A \<subseteq> \<Omega>" by (auto simp: dynkin_system_def subset_class_def) }
hoelzl@47694
  1289
  moreover have "{D. dynkin_system \<Omega> D \<and> M \<subseteq> D} \<noteq> {}"
nipkow@44890
  1290
    using assms dynkin_system_trivial by fastforce
hoelzl@47694
  1291
  ultimately show "A \<subseteq> \<Omega>"
hoelzl@40859
  1292
    unfolding dynkin_def using assms
hoelzl@47694
  1293
    by auto
hoelzl@40859
  1294
next
hoelzl@47694
  1295
  show "\<Omega> \<in> dynkin \<Omega> M"
nipkow@44890
  1296
    unfolding dynkin_def using dynkin_system.space by fastforce
hoelzl@40859
  1297
next
hoelzl@47694
  1298
  fix A assume "A \<in> dynkin \<Omega> M"
hoelzl@47694
  1299
  then show "\<Omega> - A \<in> dynkin \<Omega> M"
hoelzl@40859
  1300
    unfolding dynkin_def using dynkin_system.compl by force
hoelzl@40859
  1301
next
hoelzl@40859
  1302
  fix A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
  1303
  assume A: "disjoint_family A" "range A \<subseteq> dynkin \<Omega> M"
hoelzl@47694
  1304
  show "(\<Union>i. A i) \<in> dynkin \<Omega> M" unfolding dynkin_def
hoelzl@40859
  1305
  proof (simp, safe)
hoelzl@47694
  1306
    fix D assume "dynkin_system \<Omega> D" "M \<subseteq> D"
hoelzl@47694
  1307
    with A have "(\<Union>i. A i) \<in> D"
hoelzl@40859
  1308
      by (intro dynkin_system.UN) (auto simp: dynkin_def)
hoelzl@40859
  1309
    then show "(\<Union>i. A i) \<in> D" by auto
hoelzl@40859
  1310
  qed
hoelzl@40859
  1311
qed
hoelzl@40859
  1312
hoelzl@47694
  1313
lemma dynkin_Basic[intro]: "A \<in> M \<Longrightarrow> A \<in> dynkin \<Omega> M"
hoelzl@40859
  1314
  unfolding dynkin_def by auto
hoelzl@40859
  1315
hoelzl@40859
  1316
lemma (in dynkin_system) restricted_dynkin_system:
hoelzl@47694
  1317
  assumes "D \<in> M"
hoelzl@47694
  1318
  shows "dynkin_system \<Omega> {Q. Q \<subseteq> \<Omega> \<and> Q \<inter> D \<in> M}"
hoelzl@40859
  1319
proof (rule dynkin_systemI, simp_all)
hoelzl@47694
  1320
  have "\<Omega> \<inter> D = D"
wenzelm@61808
  1321
    using \<open>D \<in> M\<close> sets_into_space by auto
hoelzl@47694
  1322
  then show "\<Omega> \<inter> D \<in> M"
wenzelm@61808
  1323
    using \<open>D \<in> M\<close> by auto
hoelzl@40859
  1324
next
hoelzl@47694
  1325
  fix A assume "A \<subseteq> \<Omega> \<and> A \<inter> D \<in> M"
hoelzl@47694
  1326
  moreover have "(\<Omega> - A) \<inter> D = (\<Omega> - (A \<inter> D)) - (\<Omega> - D)"
hoelzl@40859
  1327
    by auto
hoelzl@47694
  1328
  ultimately show "\<Omega> - A \<subseteq> \<Omega> \<and> (\<Omega> - A) \<inter> D \<in> M"
wenzelm@61808
  1329
    using  \<open>D \<in> M\<close> by (auto intro: diff)
hoelzl@40859
  1330
next
hoelzl@40859
  1331
  fix A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
  1332
  assume "disjoint_family A" "range A \<subseteq> {Q. Q \<subseteq> \<Omega> \<and> Q \<inter> D \<in> M}"
hoelzl@47694
  1333
  then have "\<And>i. A i \<subseteq> \<Omega>" "disjoint_family (\<lambda>i. A i \<inter> D)"
hoelzl@47694
  1334
    "range (\<lambda>i. A i \<inter> D) \<subseteq> M" "(\<Union>x. A x) \<inter> D = (\<Union>x. A x \<inter> D)"
nipkow@44890
  1335
    by ((fastforce simp: disjoint_family_on_def)+)
hoelzl@47694
  1336
  then show "(\<Union>x. A x) \<subseteq> \<Omega> \<and> (\<Union>x. A x) \<inter> D \<in> M"
hoelzl@40859
  1337
    by (auto simp del: UN_simps)
hoelzl@40859
  1338
qed
hoelzl@40859
  1339
hoelzl@40859
  1340
lemma (in dynkin_system) dynkin_subset:
hoelzl@47694
  1341
  assumes "N \<subseteq> M"
hoelzl@47694
  1342
  shows "dynkin \<Omega> N \<subseteq> M"
hoelzl@40859
  1343
proof -
wenzelm@61169
  1344
  have "dynkin_system \<Omega> M" ..
hoelzl@47694
  1345
  then have "dynkin_system \<Omega> M"
hoelzl@42065
  1346
    using assms unfolding dynkin_system_def dynkin_system_axioms_def subset_class_def by simp
wenzelm@61808
  1347
  with \<open>N \<subseteq> M\<close> show ?thesis by (auto simp add: dynkin_def)
hoelzl@40859
  1348
qed
hoelzl@40859
  1349
hoelzl@40859
  1350
lemma sigma_eq_dynkin:
hoelzl@47694
  1351
  assumes sets: "M \<subseteq> Pow \<Omega>"
hoelzl@40859
  1352
  assumes "Int_stable M"
hoelzl@47694
  1353
  shows "sigma_sets \<Omega> M = dynkin \<Omega> M"
hoelzl@40859
  1354
proof -
hoelzl@47694
  1355
  have "dynkin \<Omega> M \<subseteq> sigma_sets (\<Omega>) (M)"
hoelzl@40859
  1356
    using sigma_algebra_imp_dynkin_system
hoelzl@47694
  1357
    unfolding dynkin_def sigma_sets_least_sigma_algebra[OF sets] by auto
hoelzl@40859
  1358
  moreover
hoelzl@47694
  1359
  interpret dynkin_system \<Omega> "dynkin \<Omega> M"
hoelzl@40859
  1360
    using dynkin_system_dynkin[OF sets] .
hoelzl@47694
  1361
  have "sigma_algebra \<Omega> (dynkin \<Omega> M)"
hoelzl@40859
  1362
    unfolding sigma_algebra_eq_Int_stable Int_stable_def
hoelzl@40859
  1363
  proof (intro ballI)
hoelzl@47694
  1364
    fix A B assume "A \<in> dynkin \<Omega> M" "B \<in> dynkin \<Omega> M"
hoelzl@47694
  1365
    let ?D = "\<lambda>E. {Q. Q \<subseteq> \<Omega> \<and> Q \<inter> E \<in> dynkin \<Omega> M}"
hoelzl@47694
  1366
    have "M \<subseteq> ?D B"
hoelzl@40859
  1367
    proof
hoelzl@47694
  1368
      fix E assume "E \<in> M"
hoelzl@47694
  1369
      then have "M \<subseteq> ?D E" "E \<in> dynkin \<Omega> M"
wenzelm@61808
  1370
        using sets_into_space \<open>Int_stable M\<close> by (auto simp: Int_stable_def)
hoelzl@47694
  1371
      then have "dynkin \<Omega> M \<subseteq> ?D E"
wenzelm@61808
  1372
        using restricted_dynkin_system \<open>E \<in> dynkin \<Omega> M\<close>
hoelzl@40859
  1373
        by (intro dynkin_system.dynkin_subset) simp_all
hoelzl@47694
  1374
      then have "B \<in> ?D E"
wenzelm@61808
  1375
        using \<open>B \<in> dynkin \<Omega> M\<close> by auto
hoelzl@47694
  1376
      then have "E \<inter> B \<in> dynkin \<Omega> M"
hoelzl@40859
  1377
        by (subst Int_commute) simp
hoelzl@47694
  1378
      then show "E \<in> ?D B"
wenzelm@61808
  1379
        using sets \<open>E \<in> M\<close> by auto
hoelzl@40859
  1380
    qed
hoelzl@47694
  1381
    then have "dynkin \<Omega> M \<subseteq> ?D B"
wenzelm@61808
  1382
      using restricted_dynkin_system \<open>B \<in> dynkin \<Omega> M\<close>
hoelzl@40859
  1383
      by (intro dynkin_system.dynkin_subset) simp_all
hoelzl@47694
  1384
    then show "A \<inter> B \<in> dynkin \<Omega> M"
wenzelm@61808
  1385
      using \<open>A \<in> dynkin \<Omega> M\<close> sets_into_space by auto
hoelzl@40859
  1386
  qed
hoelzl@47694
  1387
  from sigma_algebra.sigma_sets_subset[OF this, of "M"]
hoelzl@47694
  1388
  have "sigma_sets (\<Omega>) (M) \<subseteq> dynkin \<Omega> M" by auto
hoelzl@47694
  1389
  ultimately have "sigma_sets (\<Omega>) (M) = dynkin \<Omega> M" by auto
hoelzl@40859
  1390
  then show ?thesis
hoelzl@47694
  1391
    by (auto simp: dynkin_def)
hoelzl@40859
  1392
qed
hoelzl@40859
  1393
hoelzl@40859
  1394
lemma (in dynkin_system) dynkin_idem:
hoelzl@47694
  1395
  "dynkin \<Omega> M = M"
hoelzl@40859
  1396
proof -
hoelzl@47694
  1397
  have "dynkin \<Omega> M = M"
hoelzl@40859
  1398
  proof
hoelzl@47694
  1399
    show "M \<subseteq> dynkin \<Omega> M"
hoelzl@40859
  1400
      using dynkin_Basic by auto
hoelzl@47694
  1401
    show "dynkin \<Omega> M \<subseteq> M"
hoelzl@40859
  1402
      by (intro dynkin_subset) auto
hoelzl@40859
  1403
  qed
hoelzl@40859
  1404
  then show ?thesis
hoelzl@47694
  1405
    by (auto simp: dynkin_def)
hoelzl@40859
  1406
qed
hoelzl@40859
  1407
hoelzl@40859
  1408
lemma (in dynkin_system) dynkin_lemma:
hoelzl@41689
  1409
  assumes "Int_stable E"
hoelzl@47694
  1410
  and E: "E \<subseteq> M" "M \<subseteq> sigma_sets \<Omega> E"
hoelzl@47694
  1411
  shows "sigma_sets \<Omega> E = M"
hoelzl@40859
  1412
proof -
hoelzl@47694
  1413
  have "E \<subseteq> Pow \<Omega>"
hoelzl@41689
  1414
    using E sets_into_space by force
wenzelm@53374
  1415
  then have *: "sigma_sets \<Omega> E = dynkin \<Omega> E"
wenzelm@61808
  1416
    using \<open>Int_stable E\<close> by (rule sigma_eq_dynkin)
wenzelm@53374
  1417
  then have "dynkin \<Omega> E = M"
hoelzl@47694
  1418
    using assms dynkin_subset[OF E(1)] by simp
wenzelm@53374
  1419
  with * show ?thesis
hoelzl@47694
  1420
    using assms by (auto simp: dynkin_def)
hoelzl@42864
  1421
qed
hoelzl@42864
  1422
wenzelm@61808
  1423
subsubsection \<open>Induction rule for intersection-stable generators\<close>
hoelzl@56994
  1424
wenzelm@61808
  1425
text \<open>The reason to introduce Dynkin-systems is the following induction rules for $\sigma$-algebras
wenzelm@61808
  1426
generated by a generator closed under intersection.\<close>
hoelzl@56994
  1427
hoelzl@49789
  1428
lemma sigma_sets_induct_disjoint[consumes 3, case_names basic empty compl union]:
hoelzl@49789
  1429
  assumes "Int_stable G"
hoelzl@49789
  1430
    and closed: "G \<subseteq> Pow \<Omega>"
hoelzl@49789
  1431
    and A: "A \<in> sigma_sets \<Omega> G"
hoelzl@49789
  1432
  assumes basic: "\<And>A. A \<in> G \<Longrightarrow> P A"
hoelzl@49789
  1433
    and empty: "P {}"
hoelzl@49789
  1434
    and compl: "\<And>A. A \<in> sigma_sets \<Omega> G \<Longrightarrow> P A \<Longrightarrow> P (\<Omega> - A)"
hoelzl@49789
  1435
    and union: "\<And>A. disjoint_family A \<Longrightarrow> range A \<subseteq> sigma_sets \<Omega> G \<Longrightarrow> (\<And>i. P (A i)) \<Longrightarrow> P (\<Union>i::nat. A i)"
hoelzl@49789
  1436
  shows "P A"
hoelzl@49789
  1437
proof -
hoelzl@49789
  1438
  let ?D = "{ A \<in> sigma_sets \<Omega> G. P A }"
hoelzl@49789
  1439
  interpret sigma_algebra \<Omega> "sigma_sets \<Omega> G"
hoelzl@49789
  1440
    using closed by (rule sigma_algebra_sigma_sets)
hoelzl@49789
  1441
  from compl[OF _ empty] closed have space: "P \<Omega>" by simp
hoelzl@49789
  1442
  interpret dynkin_system \<Omega> ?D
wenzelm@61169
  1443
    by standard (auto dest: sets_into_space intro!: space compl union)
hoelzl@49789
  1444
  have "sigma_sets \<Omega> G = ?D"
wenzelm@61808
  1445
    by (rule dynkin_lemma) (auto simp: basic \<open>Int_stable G\<close>)
hoelzl@49789
  1446
  with A show ?thesis by auto
hoelzl@49789
  1447
qed
hoelzl@49789
  1448
wenzelm@61808
  1449
subsection \<open>Measure type\<close>
hoelzl@56994
  1450
hoelzl@62975
  1451
definition positive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
hoelzl@62975
  1452
  "positive M \<mu> \<longleftrightarrow> \<mu> {} = 0"
hoelzl@56994
  1453
hoelzl@62975
  1454
definition countably_additive :: "'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
hoelzl@56994
  1455
  "countably_additive M f \<longleftrightarrow> (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow>
hoelzl@56994
  1456
    (\<Sum>i. f (A i)) = f (\<Union>i. A i))"
hoelzl@56994
  1457
hoelzl@62975
  1458
definition measure_space :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> bool" where
hoelzl@56994
  1459
  "measure_space \<Omega> A \<mu> \<longleftrightarrow> sigma_algebra \<Omega> A \<and> positive A \<mu> \<and> countably_additive A \<mu>"
hoelzl@56994
  1460
hoelzl@56994
  1461
typedef 'a measure = "{(\<Omega>::'a set, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu> }"
hoelzl@56994
  1462
proof
hoelzl@56994
  1463
  have "sigma_algebra UNIV {{}, UNIV}"
hoelzl@56994
  1464
    by (auto simp: sigma_algebra_iff2)
hoelzl@56994
  1465
  then show "(UNIV, {{}, UNIV}, \<lambda>A. 0) \<in> {(\<Omega>, A, \<mu>). (\<forall>a\<in>-A. \<mu> a = 0) \<and> measure_space \<Omega> A \<mu>} "
hoelzl@56994
  1466
    by (auto simp: measure_space_def positive_def countably_additive_def)
hoelzl@56994
  1467
qed
hoelzl@56994
  1468
hoelzl@56994
  1469
definition space :: "'a measure \<Rightarrow> 'a set" where
hoelzl@56994
  1470
  "space M = fst (Rep_measure M)"
hoelzl@56994
  1471
hoelzl@56994
  1472
definition sets :: "'a measure \<Rightarrow> 'a set set" where
hoelzl@56994
  1473
  "sets M = fst (snd (Rep_measure M))"
hoelzl@56994
  1474
hoelzl@62975
  1475
definition emeasure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> ennreal" where
hoelzl@56994
  1476
  "emeasure M = snd (snd (Rep_measure M))"
hoelzl@56994
  1477
hoelzl@56994
  1478
definition measure :: "'a measure \<Rightarrow> 'a set \<Rightarrow> real" where
hoelzl@62975
  1479
  "measure M A = enn2real (emeasure M A)"
hoelzl@56994
  1480
hoelzl@56994
  1481
declare [[coercion sets]]
hoelzl@56994
  1482
hoelzl@56994
  1483
declare [[coercion measure]]
hoelzl@56994
  1484
hoelzl@56994
  1485
declare [[coercion emeasure]]
hoelzl@56994
  1486
hoelzl@56994
  1487
lemma measure_space: "measure_space (space M) (sets M) (emeasure M)"
hoelzl@56994
  1488
  by (cases M) (auto simp: space_def sets_def emeasure_def Abs_measure_inverse)
hoelzl@56994
  1489
wenzelm@61605
  1490
interpretation sets: sigma_algebra "space M" "sets M" for M :: "'a measure"
hoelzl@56994
  1491
  using measure_space[of M] by (auto simp: measure_space_def)
hoelzl@56994
  1492
hoelzl@62975
  1493
definition measure_of :: "'a set \<Rightarrow> 'a set set \<Rightarrow> ('a set \<Rightarrow> ennreal) \<Rightarrow> 'a measure" where
hoelzl@56994
  1494
  "measure_of \<Omega> A \<mu> = Abs_measure (\<Omega>, if A \<subseteq> Pow \<Omega> then sigma_sets \<Omega> A else {{}, \<Omega>},
hoelzl@56994
  1495
    \<lambda>a. if a \<in> sigma_sets \<Omega> A \<and> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> then \<mu> a else 0)"
hoelzl@56994
  1496
hoelzl@56994
  1497
abbreviation "sigma \<Omega> A \<equiv> measure_of \<Omega> A (\<lambda>x. 0)"
hoelzl@56994
  1498
hoelzl@56994
  1499
lemma measure_space_0: "A \<subseteq> Pow \<Omega> \<Longrightarrow> measure_space \<Omega> (sigma_sets \<Omega> A) (\<lambda>x. 0)"
hoelzl@56994
  1500
  unfolding measure_space_def
hoelzl@56994
  1501
  by (auto intro!: sigma_algebra_sigma_sets simp: positive_def countably_additive_def)
hoelzl@56994
  1502
hoelzl@56994
  1503
lemma sigma_algebra_trivial: "sigma_algebra \<Omega> {{}, \<Omega>}"
hoelzl@56994
  1504
by unfold_locales(fastforce intro: exI[where x="{{}}"] exI[where x="{\<Omega>}"])+
hoelzl@56994
  1505
hoelzl@56994
  1506
lemma measure_space_0': "measure_space \<Omega> {{}, \<Omega>} (\<lambda>x. 0)"
hoelzl@56994
  1507
by(simp add: measure_space_def positive_def countably_additive_def sigma_algebra_trivial)
hoelzl@56994
  1508
hoelzl@56994
  1509
lemma measure_space_closed:
hoelzl@56994
  1510
  assumes "measure_space \<Omega> M \<mu>"
hoelzl@56994
  1511
  shows "M \<subseteq> Pow \<Omega>"
hoelzl@56994
  1512
proof -
hoelzl@56994
  1513
  interpret sigma_algebra \<Omega> M using assms by(simp add: measure_space_def)
hoelzl@56994
  1514
  show ?thesis by(rule space_closed)
hoelzl@56994
  1515
qed
hoelzl@56994
  1516
hoelzl@56994
  1517
lemma (in ring_of_sets) positive_cong_eq:
hoelzl@56994
  1518
  "(\<And>a. a \<in> M \<Longrightarrow> \<mu>' a = \<mu> a) \<Longrightarrow> positive M \<mu>' = positive M \<mu>"
hoelzl@56994
  1519
  by (auto simp add: positive_def)
hoelzl@56994
  1520
hoelzl@56994
  1521
lemma (in sigma_algebra) countably_additive_eq:
hoelzl@56994
  1522
  "(\<And>a. a \<in> M \<Longrightarrow> \<mu>' a = \<mu> a) \<Longrightarrow> countably_additive M \<mu>' = countably_additive M \<mu>"
hoelzl@56994
  1523
  unfolding countably_additive_def
hoelzl@56994
  1524
  by (intro arg_cong[where f=All] ext) (auto simp add: countably_additive_def subset_eq)
hoelzl@56994
  1525
hoelzl@56994
  1526
lemma measure_space_eq:
hoelzl@56994
  1527
  assumes closed: "A \<subseteq> Pow \<Omega>" and eq: "\<And>a. a \<in> sigma_sets \<Omega> A \<Longrightarrow> \<mu> a = \<mu>' a"
hoelzl@56994
  1528
  shows "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> = measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>'"
hoelzl@56994
  1529
proof -
hoelzl@56994
  1530
  interpret sigma_algebra \<Omega> "sigma_sets \<Omega> A" using closed by (rule sigma_algebra_sigma_sets)
hoelzl@56994
  1531
  from positive_cong_eq[OF eq, of "\<lambda>i. i"] countably_additive_eq[OF eq, of "\<lambda>i. i"] show ?thesis
hoelzl@56994
  1532
    by (auto simp: measure_space_def)
hoelzl@56994
  1533
qed
hoelzl@56994
  1534
hoelzl@56994
  1535
lemma measure_of_eq:
hoelzl@56994
  1536
  assumes closed: "A \<subseteq> Pow \<Omega>" and eq: "(\<And>a. a \<in> sigma_sets \<Omega> A \<Longrightarrow> \<mu> a = \<mu>' a)"
hoelzl@56994
  1537
  shows "measure_of \<Omega> A \<mu> = measure_of \<Omega> A \<mu>'"
hoelzl@56994
  1538
proof -
hoelzl@56994
  1539
  have "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> = measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>'"
hoelzl@56994
  1540
    using assms by (rule measure_space_eq)
hoelzl@56994
  1541
  with eq show ?thesis
hoelzl@56994
  1542
    by (auto simp add: measure_of_def intro!: arg_cong[where f=Abs_measure])
hoelzl@56994
  1543
qed
hoelzl@56994
  1544
hoelzl@56994
  1545
lemma
hoelzl@56994
  1546
  shows space_measure_of_conv: "space (measure_of \<Omega> A \<mu>) = \<Omega>" (is ?space)
hoelzl@56994
  1547
  and sets_measure_of_conv:
hoelzl@56994
  1548
  "sets (measure_of \<Omega> A \<mu>) = (if A \<subseteq> Pow \<Omega> then sigma_sets \<Omega> A else {{}, \<Omega>})" (is ?sets)
hoelzl@62975
  1549
  and emeasure_measure_of_conv:
hoelzl@62975
  1550
  "emeasure (measure_of \<Omega> A \<mu>) =
hoelzl@56994
  1551
  (\<lambda>B. if B \<in> sigma_sets \<Omega> A \<and> measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> then \<mu> B else 0)" (is ?emeasure)
hoelzl@56994
  1552
proof -
hoelzl@56994
  1553
  have "?space \<and> ?sets \<and> ?emeasure"
hoelzl@56994
  1554
  proof(cases "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>")
hoelzl@56994
  1555
    case True
hoelzl@56994
  1556
    from measure_space_closed[OF this] sigma_sets_superset_generator[of A \<Omega>]
hoelzl@56994
  1557
    have "A \<subseteq> Pow \<Omega>" by simp
hoelzl@56994
  1558
    hence "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu> = measure_space \<Omega> (sigma_sets \<Omega> A)
hoelzl@56994
  1559
      (\<lambda>a. if a \<in> sigma_sets \<Omega> A then \<mu> a else 0)"
hoelzl@56994
  1560
      by(rule measure_space_eq) auto
wenzelm@61808
  1561
    with True \<open>A \<subseteq> Pow \<Omega>\<close> show ?thesis
hoelzl@56994
  1562
      by(simp add: measure_of_def space_def sets_def emeasure_def Abs_measure_inverse)
hoelzl@56994
  1563
  next
hoelzl@56994
  1564
    case False thus ?thesis
hoelzl@56994
  1565
      by(cases "A \<subseteq> Pow \<Omega>")(simp_all add: Abs_measure_inverse measure_of_def sets_def space_def emeasure_def measure_space_0 measure_space_0')
hoelzl@56994
  1566
  qed
hoelzl@56994
  1567
  thus ?space ?sets ?emeasure by simp_all
hoelzl@56994
  1568
qed
hoelzl@56994
  1569
hoelzl@56994
  1570
lemma [simp]:
hoelzl@56994
  1571
  assumes A: "A \<subseteq> Pow \<Omega>"
hoelzl@56994
  1572
  shows sets_measure_of: "sets (measure_of \<Omega> A \<mu>) = sigma_sets \<Omega> A"
hoelzl@56994
  1573
    and space_measure_of: "space (measure_of \<Omega> A \<mu>) = \<Omega>"
hoelzl@56994
  1574
using assms
hoelzl@56994
  1575
by(simp_all add: sets_measure_of_conv space_measure_of_conv)
hoelzl@56994
  1576
hoelzl@56994
  1577
lemma (in sigma_algebra) sets_measure_of_eq[simp]: "sets (measure_of \<Omega> M \<mu>) = M"
hoelzl@56994
  1578
  using space_closed by (auto intro!: sigma_sets_eq)
hoelzl@56994
  1579
hoelzl@56994
  1580
lemma (in sigma_algebra) space_measure_of_eq[simp]: "space (measure_of \<Omega> M \<mu>) = \<Omega>"
hoelzl@56994
  1581
  by (rule space_measure_of_conv)
hoelzl@56994
  1582
hoelzl@56994
  1583
lemma measure_of_subset: "M \<subseteq> Pow \<Omega> \<Longrightarrow> M' \<subseteq> M \<Longrightarrow> sets (measure_of \<Omega> M' \<mu>) \<subseteq> sets (measure_of \<Omega> M \<mu>')"
hoelzl@56994
  1584
  by (auto intro!: sigma_sets_subseteq)
hoelzl@56994
  1585
hoelzl@59000
  1586
lemma emeasure_sigma: "emeasure (sigma \<Omega> A) = (\<lambda>x. 0)"
hoelzl@59000
  1587
  unfolding measure_of_def emeasure_def
hoelzl@59000
  1588
  by (subst Abs_measure_inverse)
hoelzl@59000
  1589
     (auto simp: measure_space_def positive_def countably_additive_def
hoelzl@59000
  1590
           intro!: sigma_algebra_sigma_sets sigma_algebra_trivial)
hoelzl@59000
  1591
hoelzl@56994
  1592
lemma sigma_sets_mono'':
hoelzl@56994
  1593
  assumes "A \<in> sigma_sets C D"
hoelzl@56994
  1594
  assumes "B \<subseteq> D"
hoelzl@56994
  1595
  assumes "D \<subseteq> Pow C"
hoelzl@56994
  1596
  shows "sigma_sets A B \<subseteq> sigma_sets C D"
hoelzl@56994
  1597
proof
hoelzl@56994
  1598
  fix x assume "x \<in> sigma_sets A B"
hoelzl@56994
  1599
  thus "x \<in> sigma_sets C D"
hoelzl@56994
  1600
  proof induct
hoelzl@56994
  1601
    case (Basic a) with assms have "a \<in> D" by auto
hoelzl@56994
  1602
    thus ?case ..
hoelzl@56994
  1603
  next
hoelzl@56994
  1604
    case Empty show ?case by (rule sigma_sets.Empty)
hoelzl@56994
  1605
  next
wenzelm@61808
  1606
    from assms have "A \<in> sets (sigma C D)" by (subst sets_measure_of[OF \<open>D \<subseteq> Pow C\<close>])
wenzelm@61808
  1607
    moreover case (Compl a) hence "a \<in> sets (sigma C D)" by (subst sets_measure_of[OF \<open>D \<subseteq> Pow C\<close>])
hoelzl@56994
  1608
    ultimately have "A - a \<in> sets (sigma C D)" ..
wenzelm@61808
  1609
    thus ?case by (subst (asm) sets_measure_of[OF \<open>D \<subseteq> Pow C\<close>])
hoelzl@56994
  1610
  next
hoelzl@56994
  1611
    case (Union a)
hoelzl@56994
  1612
    thus ?case by (intro sigma_sets.Union)
hoelzl@56994
  1613
  qed
hoelzl@56994
  1614
qed
hoelzl@56994
  1615
hoelzl@56994
  1616
lemma in_measure_of[intro, simp]: "M \<subseteq> Pow \<Omega> \<Longrightarrow> A \<in> M \<Longrightarrow> A \<in> sets (measure_of \<Omega> M \<mu>)"
hoelzl@56994
  1617
  by auto
hoelzl@56994
  1618
hoelzl@58606
  1619
lemma space_empty_iff: "space N = {} \<longleftrightarrow> sets N = {{}}"
hoelzl@58606
  1620
  by (metis Pow_empty Sup_bot_conv(1) cSup_singleton empty_iff
hoelzl@58606
  1621
            sets.sigma_sets_eq sets.space_closed sigma_sets_top subset_singletonD)
hoelzl@58606
  1622
wenzelm@61808
  1623
subsubsection \<open>Constructing simple @{typ "'a measure"}\<close>
hoelzl@56994
  1624
hoelzl@56994
  1625
lemma emeasure_measure_of:
hoelzl@56994
  1626
  assumes M: "M = measure_of \<Omega> A \<mu>"
hoelzl@56994
  1627
  assumes ms: "A \<subseteq> Pow \<Omega>" "positive (sets M) \<mu>" "countably_additive (sets M) \<mu>"
hoelzl@56994
  1628
  assumes X: "X \<in> sets M"
hoelzl@56994
  1629
  shows "emeasure M X = \<mu> X"
hoelzl@56994
  1630
proof -
hoelzl@56994
  1631
  interpret sigma_algebra \<Omega> "sigma_sets \<Omega> A" by (rule sigma_algebra_sigma_sets) fact
hoelzl@56994
  1632
  have "measure_space \<Omega> (sigma_sets \<Omega> A) \<mu>"
hoelzl@56994
  1633
    using ms M by (simp add: measure_space_def sigma_algebra_sigma_sets)
hoelzl@56994
  1634
  thus ?thesis using X ms
hoelzl@56994
  1635
    by(simp add: M emeasure_measure_of_conv sets_measure_of_conv)
hoelzl@56994
  1636
qed
hoelzl@56994
  1637
hoelzl@56994
  1638
lemma emeasure_measure_of_sigma:
hoelzl@56994
  1639
  assumes ms: "sigma_algebra \<Omega> M" "positive M \<mu>" "countably_additive M \<mu>"
hoelzl@56994
  1640
  assumes A: "A \<in> M"
hoelzl@56994
  1641
  shows "emeasure (measure_of \<Omega> M \<mu>) A = \<mu> A"
hoelzl@56994
  1642
proof -
hoelzl@56994
  1643
  interpret sigma_algebra \<Omega> M by fact
hoelzl@56994
  1644
  have "measure_space \<Omega> (sigma_sets \<Omega> M) \<mu>"
hoelzl@56994
  1645
    using ms sigma_sets_eq by (simp add: measure_space_def)
hoelzl@56994
  1646
  thus ?thesis by(simp add: emeasure_measure_of_conv A)
hoelzl@56994
  1647
qed
hoelzl@56994
  1648
hoelzl@56994
  1649
lemma measure_cases[cases type: measure]:
hoelzl@56994
  1650
  obtains (measure) \<Omega> A \<mu> where "x = Abs_measure (\<Omega>, A, \<mu>)" "\<forall>a\<in>-A. \<mu> a = 0" "measure_space \<Omega> A \<mu>"
hoelzl@56994
  1651
  by atomize_elim (cases x, auto)
hoelzl@56994
  1652
hoelzl@60772
  1653
lemma sets_le_imp_space_le: "sets A \<subseteq> sets B \<Longrightarrow> space A \<subseteq> space B"
hoelzl@60772
  1654
  by (auto dest: sets.sets_into_space)
hoelzl@60772
  1655
hoelzl@60772
  1656
lemma sets_eq_imp_space_eq: "sets M = sets M' \<Longrightarrow> space M = space M'"
hoelzl@60772
  1657
  by (auto intro!: antisym sets_le_imp_space_le)
hoelzl@56994
  1658
hoelzl@56994
  1659
lemma emeasure_notin_sets: "A \<notin> sets M \<Longrightarrow> emeasure M A = 0"
hoelzl@56994
  1660
  by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
hoelzl@56994
  1661
hoelzl@56994
  1662
lemma emeasure_neq_0_sets: "emeasure M A \<noteq> 0 \<Longrightarrow> A \<in> sets M"
hoelzl@56994
  1663
  using emeasure_notin_sets[of A M] by blast
hoelzl@56994
  1664
hoelzl@56994
  1665
lemma measure_notin_sets: "A \<notin> sets M \<Longrightarrow> measure M A = 0"
hoelzl@62975
  1666
  by (simp add: measure_def emeasure_notin_sets zero_ennreal.rep_eq)
hoelzl@56994
  1667
hoelzl@56994
  1668
lemma measure_eqI:
hoelzl@56994
  1669
  fixes M N :: "'a measure"
hoelzl@56994
  1670
  assumes "sets M = sets N" and eq: "\<And>A. A \<in> sets M \<Longrightarrow> emeasure M A = emeasure N A"
hoelzl@56994
  1671
  shows "M = N"
hoelzl@56994
  1672
proof (cases M N rule: measure_cases[case_product measure_cases])
hoelzl@56994
  1673
  case (measure_measure \<Omega> A \<mu> \<Omega>' A' \<mu>')
hoelzl@56994
  1674
  interpret M: sigma_algebra \<Omega> A using measure_measure by (auto simp: measure_space_def)
hoelzl@56994
  1675
  interpret N: sigma_algebra \<Omega>' A' using measure_measure by (auto simp: measure_space_def)
hoelzl@56994
  1676
  have "A = sets M" "A' = sets N"
hoelzl@56994
  1677
    using measure_measure by (simp_all add: sets_def Abs_measure_inverse)
wenzelm@61808
  1678
  with \<open>sets M = sets N\<close> have AA': "A = A'" by simp
hoelzl@56994
  1679
  moreover from M.top N.top M.space_closed N.space_closed AA' have "\<Omega> = \<Omega>'" by auto
hoelzl@56994
  1680
  moreover { fix B have "\<mu> B = \<mu>' B"
hoelzl@56994
  1681
    proof cases
hoelzl@56994
  1682
      assume "B \<in> A"
wenzelm@61808
  1683
      with eq \<open>A = sets M\<close> have "emeasure M B = emeasure N B" by simp
hoelzl@56994
  1684
      with measure_measure show "\<mu> B = \<mu>' B"
hoelzl@56994
  1685
        by (simp add: emeasure_def Abs_measure_inverse)
hoelzl@56994
  1686
    next
hoelzl@56994
  1687
      assume "B \<notin> A"
wenzelm@61808
  1688
      with \<open>A = sets M\<close> \<open>A' = sets N\<close> \<open>A = A'\<close> have "B \<notin> sets M" "B \<notin> sets N"
hoelzl@56994
  1689
        by auto
hoelzl@56994
  1690
      then have "emeasure M B = 0" "emeasure N B = 0"
hoelzl@56994
  1691
        by (simp_all add: emeasure_notin_sets)
hoelzl@56994
  1692
      with measure_measure show "\<mu> B = \<mu>' B"
hoelzl@56994
  1693
        by (simp add: emeasure_def Abs_measure_inverse)
hoelzl@56994
  1694
    qed }
hoelzl@56994
  1695
  then have "\<mu> = \<mu>'" by auto
hoelzl@56994
  1696
  ultimately show "M = N"
hoelzl@56994
  1697
    by (simp add: measure_measure)
hoelzl@56994
  1698
qed
hoelzl@56994
  1699
hoelzl@56994
  1700
lemma sigma_eqI:
hoelzl@56994
  1701
  assumes [simp]: "M \<subseteq> Pow \<Omega>" "N \<subseteq> Pow \<Omega>" "sigma_sets \<Omega> M = sigma_sets \<Omega> N"
hoelzl@56994
  1702
  shows "sigma \<Omega> M = sigma \<Omega> N"
hoelzl@56994
  1703
  by (rule measure_eqI) (simp_all add: emeasure_sigma)
hoelzl@56994
  1704
wenzelm@61808
  1705
subsubsection \<open>Measurable functions\<close>
hoelzl@56994
  1706
hoelzl@61847
  1707
definition measurable :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) set" (infixr "\<rightarrow>\<^sub>M" 60) where
wenzelm@61384
  1708
  "measurable A B = {f \<in> space A \<rightarrow> space B. \<forall>y \<in> sets B. f -` y \<inter> space A \<in> sets A}"
hoelzl@56994
  1709
hoelzl@59415
  1710
lemma measurableI:
hoelzl@59415
  1711
  "(\<And>x. x \<in> space M \<Longrightarrow> f x \<in> space N) \<Longrightarrow> (\<And>A. A \<in> sets N \<Longrightarrow> f -` A \<inter> space M \<in> sets M) \<Longrightarrow>
hoelzl@59415
  1712
    f \<in> measurable M N"
hoelzl@59415
  1713
  by (auto simp: measurable_def)
hoelzl@59415
  1714
hoelzl@56994
  1715
lemma measurable_space:
hoelzl@56994
  1716
  "f \<in> measurable M A \<Longrightarrow> x \<in> space M \<Longrightarrow> f x \<in> space A"
hoelzl@56994
  1717
   unfolding measurable_def by auto
hoelzl@56994
  1718
hoelzl@56994
  1719
lemma measurable_sets:
hoelzl@56994
  1720
  "f \<in> measurable M A \<Longrightarrow> S \<in> sets A \<Longrightarrow> f -` S \<inter> space M \<in> sets M"
hoelzl@56994
  1721
   unfolding measurable_def by auto
hoelzl@56994
  1722
hoelzl@56994
  1723
lemma measurable_sets_Collect:
hoelzl@56994
  1724
  assumes f: "f \<in> measurable M N" and P: "{x\<in>space N. P x} \<in> sets N" shows "{x\<in>space M. P (f x)} \<in> sets M"
hoelzl@56994
  1725
proof -
hoelzl@56994
  1726
  have "f -` {x \<in> space N. P x} \<inter> space M = {x\<in>space M. P (f x)}"
hoelzl@56994
  1727
    using measurable_space[OF f] by auto
hoelzl@56994
  1728
  with measurable_sets[OF f P] show ?thesis
hoelzl@56994
  1729
    by simp
hoelzl@56994
  1730
qed
hoelzl@56994
  1731
hoelzl@56994
  1732
lemma measurable_sigma_sets:
hoelzl@56994
  1733
  assumes B: "sets N = sigma_sets \<Omega> A" "A \<subseteq> Pow \<Omega>"
hoelzl@56994
  1734
      and f: "f \<in> space M \<rightarrow> \<Omega>"
hoelzl@56994
  1735
      and ba: "\<And>y. y \<in> A \<Longrightarrow> (f -` y) \<inter> space M \<in> sets M"
hoelzl@56994
  1736
  shows "f \<in> measurable M N"
hoelzl@56994
  1737
proof -
hoelzl@56994
  1738
  interpret A: sigma_algebra \<Omega> "sigma_sets \<Omega> A" using B(2) by (rule sigma_algebra_sigma_sets)
hoelzl@56994
  1739
  from B sets.top[of N] A.top sets.space_closed[of N] A.space_closed have \<Omega>: "\<Omega> = space N" by force
hoelzl@62975
  1740
hoelzl@56994
  1741
  { fix X assume "X \<in> sigma_sets \<Omega> A"
hoelzl@56994
  1742
    then have "f -` X \<inter> space M \<in> sets M \<and> X \<subseteq> \<Omega>"
hoelzl@56994
  1743
      proof induct
hoelzl@56994
  1744
        case (Basic a) then show ?case
hoelzl@56994
  1745
          by (auto simp add: ba) (metis B(2) subsetD PowD)
hoelzl@56994
  1746
      next
hoelzl@56994
  1747
        case (Compl a)
hoelzl@56994
  1748
        have [simp]: "f -` \<Omega> \<inter> space M = space M"
hoelzl@56994
  1749
          by (auto simp add: funcset_mem [OF f])
hoelzl@56994
  1750
        then show ?case
hoelzl@56994
  1751
          by (auto simp add: vimage_Diff Diff_Int_distrib2 sets.compl_sets Compl)
hoelzl@56994
  1752
      next
hoelzl@56994
  1753
        case (Union a)
hoelzl@56994
  1754
        then show ?case
hoelzl@56994
  1755
          by (simp add: vimage_UN, simp only: UN_extend_simps(4)) blast
hoelzl@56994
  1756
      qed auto }
hoelzl@56994
  1757
  with f show ?thesis
hoelzl@56994
  1758
    by (auto simp add: measurable_def B \<Omega>)
hoelzl@56994
  1759
qed
hoelzl@56994
  1760
hoelzl@56994
  1761
lemma measurable_measure_of:
hoelzl@56994
  1762
  assumes B: "N \<subseteq> Pow \<Omega>"
hoelzl@56994
  1763
      and f: "f \<in> space M \<rightarrow> \<Omega>"
hoelzl@56994
  1764
      and ba: "\<And>y. y \<in> N \<Longrightarrow> (f -` y) \<inter> space M \<in> sets M"
hoelzl@56994
  1765
  shows "f \<in> measurable M (measure_of \<Omega> N \<mu>)"
hoelzl@56994
  1766
proof -
hoelzl@56994
  1767
  have "sets (measure_of \<Omega> N \<mu>) = sigma_sets \<Omega> N"
hoelzl@56994
  1768
    using B by (rule sets_measure_of)
hoelzl@56994
  1769
  from this assms show ?thesis by (rule measurable_sigma_sets)
hoelzl@56994
  1770
qed
hoelzl@56994
  1771
hoelzl@56994
  1772
lemma measurable_iff_measure_of:
hoelzl@56994
  1773
  assumes "N \<subseteq> Pow \<Omega>" "f \<in> space M \<rightarrow> \<Omega>"
hoelzl@56994
  1774
  shows "f \<in> measurable M (measure_of \<Omega> N \<mu>) \<longleftrightarrow> (\<forall>A\<in>N. f -` A \<inter> space M \<in> sets M)"
hoelzl@56994
  1775
  by (metis assms in_measure_of measurable_measure_of assms measurable_sets)
hoelzl@56994
  1776
hoelzl@56994
  1777
lemma measurable_cong_sets:
hoelzl@56994
  1778
  assumes sets: "sets M = sets M'" "sets N = sets N'"
hoelzl@56994
  1779
  shows "measurable M N = measurable M' N'"
hoelzl@56994
  1780
  using sets[THEN sets_eq_imp_space_eq] sets by (simp add: measurable_def)
hoelzl@56994
  1781
hoelzl@56994
  1782
lemma measurable_cong:
hoelzl@59415
  1783
  assumes "\<And>w. w \<in> space M \<Longrightarrow> f w = g w"
hoelzl@56994
  1784
  shows "f \<in> measurable M M' \<longleftrightarrow> g \<in> measurable M M'"
hoelzl@56994
  1785
  unfolding measurable_def using assms
hoelzl@56994
  1786
  by (simp cong: vimage_inter_cong Pi_cong)
hoelzl@56994
  1787
hoelzl@59415
  1788
lemma measurable_cong':
hoelzl@59415
  1789
  assumes "\<And>w. w \<in> space M =simp=> f w = g w"
hoelzl@59415
  1790
  shows "f \<in> measurable M M' \<longleftrightarrow> g \<in> measurable M M'"
hoelzl@59415
  1791
  unfolding measurable_def using assms
hoelzl@59415
  1792
  by (simp cong: vimage_inter_cong Pi_cong add: simp_implies_def)
hoelzl@59415
  1793
hoelzl@56994
  1794
lemma measurable_cong_strong:
hoelzl@56994
  1795
  "M = N \<Longrightarrow> M' = N' \<Longrightarrow> (\<And>w. w \<in> space M \<Longrightarrow> f w = g w) \<Longrightarrow>
hoelzl@56994
  1796
    f \<in> measurable M M' \<longleftrightarrow> g \<in> measurable N N'"
hoelzl@56994
  1797
  by (metis measurable_cong)
hoelzl@56994
  1798
hoelzl@56994
  1799
lemma measurable_compose:
hoelzl@56994
  1800
  assumes f: "f \<in> measurable M N" and g: "g \<in> measurable N L"
hoelzl@56994
  1801
  shows "(\<lambda>x. g (f x)) \<in> measurable M L"
hoelzl@56994
  1802
proof -
hoelzl@56994
  1803
  have "\<And>A. (\<lambda>x. g (f x)) -` A \<inter> space M = f -` (g -` A \<inter> space N) \<inter> space M"
hoelzl@56994
  1804
    using measurable_space[OF f] by auto
hoelzl@56994
  1805
  with measurable_space[OF f] measurable_space[OF g] show ?thesis
hoelzl@56994
  1806
    by (auto intro: measurable_sets[OF f] measurable_sets[OF g]
hoelzl@56994
  1807
             simp del: vimage_Int simp add: measurable_def)
hoelzl@56994
  1808
qed
hoelzl@56994
  1809
hoelzl@56994
  1810
lemma measurable_comp:
hoelzl@56994
  1811
  "f \<in> measurable M N \<Longrightarrow> g \<in> measurable N L \<Longrightarrow> g \<circ> f \<in> measurable M L"
hoelzl@56994
  1812
  using measurable_compose[of f M N g L] by (simp add: comp_def)
hoelzl@56994
  1813
hoelzl@56994
  1814
lemma measurable_const:
hoelzl@56994
  1815
  "c \<in> space M' \<Longrightarrow> (\<lambda>x. c) \<in> measurable M M'"
hoelzl@56994
  1816
  by (auto simp add: measurable_def)
hoelzl@56994
  1817
hoelzl@56994
  1818
lemma measurable_ident: "id \<in> measurable M M"
hoelzl@56994
  1819
  by (auto simp add: measurable_def)
hoelzl@56994
  1820
hoelzl@59048
  1821
lemma measurable_id: "(\<lambda>x. x) \<in> measurable M M"
hoelzl@59048
  1822
  by (simp add: measurable_def)
hoelzl@59048
  1823
hoelzl@56994
  1824
lemma measurable_ident_sets:
hoelzl@56994
  1825
  assumes eq: "sets M = sets M'" shows "(\<lambda>x. x) \<in> measurable M M'"
hoelzl@56994
  1826
  using measurable_ident[of M]
hoelzl@56994
  1827
  unfolding id_def measurable_def eq sets_eq_imp_space_eq[OF eq] .
hoelzl@56994
  1828
hoelzl@56994
  1829
lemma sets_Least:
hoelzl@56994
  1830
  assumes meas: "\<And>i::nat. {x\<in>space M. P i x} \<in> M"
hoelzl@56994
  1831
  shows "(\<lambda>x. LEAST j. P j x) -` A \<inter> space M \<in> sets M"
hoelzl@56994
  1832
proof -
hoelzl@56994
  1833
  { fix i have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M \<in> sets M"
hoelzl@56994
  1834
    proof cases
hoelzl@56994
  1835
      assume i: "(LEAST j. False) = i"
hoelzl@56994
  1836
      have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
hoelzl@56994
  1837
        {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x})) \<union> (space M - (\<Union>i. {x\<in>space M. P i x}))"
hoelzl@56994
  1838
        by (simp add: set_eq_iff, safe)
hoelzl@56994
  1839
           (insert i, auto dest: Least_le intro: LeastI intro!: Least_equality)
hoelzl@56994
  1840
      with meas show ?thesis
hoelzl@56994
  1841
        by (auto intro!: sets.Int)
hoelzl@56994
  1842
    next
hoelzl@56994
  1843
      assume i: "(LEAST j. False) \<noteq> i"
hoelzl@56994
  1844
      then have "(\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M =
hoelzl@56994
  1845
        {x\<in>space M. P i x} \<inter> (space M - (\<Union>j<i. {x\<in>space M. P j x}))"
hoelzl@56994
  1846
      proof (simp add: set_eq_iff, safe)
hoelzl@56994
  1847
        fix x assume neq: "(LEAST j. False) \<noteq> (LEAST j. P j x)"
hoelzl@56994
  1848
        have "\<exists>j. P j x"
hoelzl@56994
  1849
          by (rule ccontr) (insert neq, auto)
hoelzl@56994
  1850
        then show "P (LEAST j. P j x) x" by (rule LeastI_ex)
hoelzl@56994
  1851
      qed (auto dest: Least_le intro!: Least_equality)
hoelzl@56994
  1852
      with meas show ?thesis
hoelzl@56994
  1853
        by auto
hoelzl@56994
  1854
    qed }
hoelzl@56994
  1855
  then have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) \<in> sets M"
hoelzl@56994
  1856
    by (intro sets.countable_UN) auto
hoelzl@56994
  1857
  moreover have "(\<Union>i\<in>A. (\<lambda>x. LEAST j. P j x) -` {i} \<inter> space M) =
hoelzl@56994
  1858
    (\<lambda>x. LEAST j. P j x) -` A \<inter> space M" by auto
hoelzl@56994
  1859
  ultimately show ?thesis by auto
hoelzl@56994
  1860
qed
hoelzl@56994
  1861
hoelzl@56994
  1862
lemma measurable_mono1:
hoelzl@56994
  1863
  "M' \<subseteq> Pow \<Omega> \<Longrightarrow> M \<subseteq> M' \<Longrightarrow>
hoelzl@56994
  1864
    measurable (measure_of \<Omega> M \<mu>) N \<subseteq> measurable (measure_of \<Omega> M' \<mu>') N"
hoelzl@56994
  1865
  using measure_of_subset[of M' \<Omega> M] by (auto simp add: measurable_def)
hoelzl@56994
  1866
wenzelm@61808
  1867
subsubsection \<open>Counting space\<close>
hoelzl@56994
  1868
hoelzl@56994
  1869
definition count_space :: "'a set \<Rightarrow> 'a measure" where
hoelzl@62975
  1870
  "count_space \<Omega> = measure_of \<Omega> (Pow \<Omega>) (\<lambda>A. if finite A then of_nat (card A) else \<infinity>)"
hoelzl@56994
  1871
hoelzl@62975
  1872
lemma
hoelzl@56994
  1873
  shows space_count_space[simp]: "space (count_space \<Omega>) = \<Omega>"
hoelzl@56994
  1874
    and sets_count_space[simp]: "sets (count_space \<Omega>) = Pow \<Omega>"
hoelzl@56994
  1875
  using sigma_sets_into_sp[of "Pow \<Omega>" \<Omega>]
hoelzl@56994
  1876
  by (auto simp: count_space_def)
hoelzl@56994
  1877
hoelzl@56994
  1878
lemma measurable_count_space_eq1[simp]:
hoelzl@56994
  1879
  "f \<in> measurable (count_space A) M \<longleftrightarrow> f \<in> A \<rightarrow> space M"
hoelzl@56994
  1880
 unfolding measurable_def by simp
hoelzl@56994
  1881
hoelzl@59000
  1882
lemma measurable_compose_countable':
hoelzl@59000
  1883
  assumes f: "\<And>i. i \<in> I \<Longrightarrow> (\<lambda>x. f i x) \<in> measurable M N"
hoelzl@59000
  1884
  and g: "g \<in> measurable M (count_space I)" and I: "countable I"
hoelzl@56994
  1885
  shows "(\<lambda>x. f (g x) x) \<in> measurable M N"
hoelzl@56994
  1886
  unfolding measurable_def
hoelzl@56994
  1887
proof safe
hoelzl@56994
  1888
  fix x assume "x \<in> space M" then show "f (g x) x \<in> space N"
hoelzl@59000
  1889
    using measurable_space[OF f] g[THEN measurable_space] by auto
hoelzl@56994
  1890
next
hoelzl@56994
  1891
  fix A assume A: "A \<in> sets N"
hoelzl@59000
  1892
  have "(\<lambda>x. f (g x) x) -` A \<inter> space M = (\<Union>i\<in>I. (g -` {i} \<inter> space M) \<inter> (f i -` A \<inter> space M))"
hoelzl@59000
  1893
    using measurable_space[OF g] by auto
hoelzl@59415
  1894
  also have "\<dots> \<in> sets M"
hoelzl@59415
  1895
    using f[THEN measurable_sets, OF _ A] g[THEN measurable_sets]
hoelzl@59415
  1896
    by (auto intro!: sets.countable_UN' I intro: sets.Int[OF measurable_sets measurable_sets])
hoelzl@56994
  1897
  finally show "(\<lambda>x. f (g x) x) -` A \<inter> space M \<in> sets M" .
hoelzl@56994
  1898
qed
hoelzl@56994
  1899
hoelzl@56994
  1900
lemma measurable_count_space_eq_countable:
hoelzl@56994
  1901
  assumes "countable A"
hoelzl@56994
  1902
  shows "f \<in> measurable M (count_space A) \<longleftrightarrow> (f \<in> space M \<rightarrow> A \<and> (\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M))"
hoelzl@56994
  1903
proof -
hoelzl@56994
  1904
  { fix X assume "X \<subseteq> A" "f \<in> space M \<rightarrow> A"
wenzelm@61808
  1905
    with \<open>countable A\<close> have "f -` X \<inter> space M = (\<Union>a\<in>X. f -` {a} \<inter> space M)" "countable X"
hoelzl@56994
  1906
      by (auto dest: countable_subset)
hoelzl@56994
  1907
    moreover assume "\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M"
hoelzl@56994
  1908
    ultimately have "f -` X \<inter> space M \<in> sets M"
wenzelm@61808
  1909
      using \<open>X \<subseteq> A\<close> by (auto intro!: sets.countable_UN' simp del: UN_simps) }
hoelzl@56994
  1910
  then show ?thesis
hoelzl@56994
  1911
    unfolding measurable_def by auto
hoelzl@56994
  1912
qed
hoelzl@56994
  1913
hoelzl@59415
  1914
lemma measurable_count_space_eq2:
hoelzl@59415
  1915
  "finite A \<Longrightarrow> f \<in> measurable M (count_space A) \<longleftrightarrow> (f \<in> space M \<rightarrow> A \<and> (\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M))"
hoelzl@59415
  1916
  by (intro measurable_count_space_eq_countable countable_finite)
hoelzl@59415
  1917
hoelzl@59415
  1918
lemma measurable_count_space_eq2_countable:
hoelzl@59415
  1919
  fixes f :: "'a => 'c::countable"
hoelzl@59415
  1920
  shows "f \<in> measurable M (count_space A) \<longleftrightarrow> (f \<in> space M \<rightarrow> A \<and> (\<forall>a\<in>A. f -` {a} \<inter> space M \<in> sets M))"
hoelzl@59415
  1921
  by (intro measurable_count_space_eq_countable countableI_type)
hoelzl@59415
  1922
hoelzl@59415
  1923
lemma measurable_compose_countable:
hoelzl@59415
  1924
  assumes f: "\<And>i::'i::countable. (\<lambda>x. f i x) \<in> measurable M N" and g: "g \<in> measurable M (count_space UNIV)"
hoelzl@59415
  1925
  shows "(\<lambda>x. f (g x) x) \<in> measurable M N"
hoelzl@59415
  1926
  by (rule measurable_compose_countable'[OF assms]) auto
hoelzl@59415
  1927
hoelzl@59415
  1928
lemma measurable_count_space_const:
hoelzl@59415
  1929
  "(\<lambda>x. c) \<in> measurable M (count_space UNIV)"
hoelzl@59415
  1930
  by (simp add: measurable_const)
hoelzl@59415
  1931
hoelzl@59415
  1932
lemma measurable_count_space:
hoelzl@59415
  1933
  "f \<in> measurable (count_space A) (count_space UNIV)"
hoelzl@59415
  1934
  by simp
hoelzl@59415
  1935
hoelzl@59415
  1936
lemma measurable_compose_rev:
hoelzl@59415
  1937
  assumes f: "f \<in> measurable L N" and g: "g \<in> measurable M L"
hoelzl@59415
  1938
  shows "(\<lambda>x. f (g x)) \<in> measurable M N"
hoelzl@59415
  1939
  using measurable_compose[OF g f] .
hoelzl@59415
  1940
hoelzl@62975
  1941
lemma measurable_empty_iff:
hoelzl@58606
  1942
  "space N = {} \<Longrightarrow> f \<in> measurable M N \<longleftrightarrow> space M = {}"
hoelzl@58606
  1943
  by (auto simp add: measurable_def Pi_iff)
hoelzl@58606
  1944
wenzelm@61808
  1945
subsubsection \<open>Extend measure\<close>
hoelzl@56994
  1946
hoelzl@56994
  1947
definition "extend_measure \<Omega> I G \<mu> =
hoelzl@56994
  1948
  (if (\<exists>\<mu>'. (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>') \<and> \<not> (\<forall>i\<in>I. \<mu> i = 0)
hoelzl@56994
  1949
      then measure_of \<Omega> (G`I) (SOME \<mu>'. (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>')
hoelzl@56994
  1950
      else measure_of \<Omega> (G`I) (\<lambda>_. 0))"
hoelzl@56994
  1951
hoelzl@56994
  1952
lemma space_extend_measure: "G ` I \<subseteq> Pow \<Omega> \<Longrightarrow> space (extend_measure \<Omega> I G \<mu>) = \<Omega>"
hoelzl@56994
  1953
  unfolding extend_measure_def by simp
hoelzl@56994
  1954
hoelzl@56994
  1955
lemma sets_extend_measure: "G ` I \<subseteq> Pow \<Omega> \<Longrightarrow> sets (extend_measure \<Omega> I G \<mu>) = sigma_sets \<Omega> (G`I)"
hoelzl@56994
  1956
  unfolding extend_measure_def by simp
hoelzl@56994
  1957
hoelzl@56994
  1958
lemma emeasure_extend_measure:
hoelzl@56994
  1959
  assumes M: "M = extend_measure \<Omega> I G \<mu>"
hoelzl@56994
  1960
    and eq: "\<And>i. i \<in> I \<Longrightarrow> \<mu>' (G i) = \<mu> i"
hoelzl@56994
  1961
    and ms: "G ` I \<subseteq> Pow \<Omega>" "positive (sets M) \<mu>'" "countably_additive (sets M) \<mu>'"
hoelzl@56994
  1962
    and "i \<in> I"
hoelzl@56994
  1963
  shows "emeasure M (G i) = \<mu> i"
hoelzl@56994
  1964
proof cases
hoelzl@56994
  1965
  assume *: "(\<forall>i\<in>I. \<mu> i = 0)"
hoelzl@56994
  1966
  with M have M_eq: "M = measure_of \<Omega> (G`I) (\<lambda>_. 0)"
hoelzl@56994
  1967
   by (simp add: extend_measure_def)
wenzelm@61808
  1968
  from measure_space_0[OF ms(1)] ms \<open>i\<in>I\<close>
hoelzl@56994
  1969
  have "emeasure M (G i) = 0"
hoelzl@56994
  1970
    by (intro emeasure_measure_of[OF M_eq]) (auto simp add: M measure_space_def sets_extend_measure)
wenzelm@61808
  1971
  with \<open>i\<in>I\<close> * show ?thesis
hoelzl@56994
  1972
    by simp
hoelzl@56994
  1973
next
wenzelm@63040
  1974
  define P where "P \<mu>' \<longleftrightarrow> (\<forall>i\<in>I. \<mu>' (G i) = \<mu> i) \<and> measure_space \<Omega> (sigma_sets \<Omega> (G`I)) \<mu>'" for \<mu>'
hoelzl@56994
  1975
  assume "\<not> (\<forall>i\<in>I. \<mu> i = 0)"
hoelzl@56994
  1976
  moreover
hoelzl@56994
  1977
  have "measure_space (space M) (sets M) \<mu>'"
wenzelm@61169
  1978
    using ms unfolding measure_space_def by auto standard
hoelzl@56994
  1979
  with ms eq have "\<exists>\<mu>'. P \<mu>'"
hoelzl@56994
  1980
    unfolding P_def
hoelzl@56994
  1981
    by (intro exI[of _ \<mu>']) (auto simp add: M space_extend_measure sets_extend_measure)
hoelzl@56994
  1982
  ultimately have M_eq: "M = measure_of \<Omega> (G`I) (Eps P)"
hoelzl@56994
  1983
    by (simp add: M extend_measure_def P_def[symmetric])
hoelzl@56994
  1984
wenzelm@61808
  1985
  from \<open>\<exists>\<mu>'. P \<mu>'\<close> have P: "P (Eps P)" by (rule someI_ex)
hoelzl@56994
  1986
  show "emeasure M (G i) = \<mu> i"
hoelzl@56994
  1987
  proof (subst emeasure_measure_of[OF M_eq])
hoelzl@56994
  1988
    have sets_M: "sets M = sigma_sets \<Omega> (G`I)"
hoelzl@56994
  1989
      using M_eq ms by (auto simp: sets_extend_measure)
wenzelm@61808
  1990
    then show "G i \<in> sets M" using \<open>i \<in> I\<close> by auto
hoelzl@56994
  1991
    show "positive (sets M) (Eps P)" "countably_additive (sets M) (Eps P)" "Eps P (G i) = \<mu> i"
wenzelm@61808
  1992
      using P \<open>i\<in>I\<close> by (auto simp add: sets_M measure_space_def P_def)
hoelzl@56994
  1993
  qed fact
hoelzl@56994
  1994
qed
hoelzl@56994
  1995
hoelzl@56994
  1996
lemma emeasure_extend_measure_Pair:
hoelzl@56994
  1997
  assumes M: "M = extend_measure \<Omega> {(i, j). I i j} (\<lambda>(i, j). G i j) (\<lambda>(i, j). \<mu> i j)"
hoelzl@56994
  1998
    and eq: "\<And>i j. I i j \<Longrightarrow> \<mu>' (G i j) = \<mu> i j"
hoelzl@56994
  1999
    and ms: "\<And>i j. I i j \<Longrightarrow> G i j \<in> Pow \<Omega>" "positive (sets M) \<mu>'" "countably_additive (sets M) \<mu>'"
hoelzl@56994
  2000
    and "I i j"
hoelzl@56994
  2001
  shows "emeasure M (G i j) = \<mu> i j"
wenzelm@61808
  2002
  using emeasure_extend_measure[OF M _ _ ms(2,3), of "(i,j)"] eq ms(1) \<open>I i j\<close>
hoelzl@56994
  2003
  by (auto simp: subset_eq)
hoelzl@56994
  2004
wenzelm@61808
  2005
subsection \<open>The smallest $\sigma$-algebra regarding a function\<close>
hoelzl@56994
  2006
hoelzl@58588
  2007
definition
hoelzl@58588
  2008
  "vimage_algebra X f M = sigma X {f -` A \<inter> X | A. A \<in> sets M}"
hoelzl@58588
  2009
hoelzl@58588
  2010
lemma space_vimage_algebra[simp]: "space (vimage_algebra X f M) = X"
hoelzl@58588
  2011
  unfolding vimage_algebra_def by (rule space_measure_of) auto
hoelzl@56994
  2012
hoelzl@58588
  2013
lemma sets_vimage_algebra: "sets (vimage_algebra X f M) = sigma_sets X {f -` A \<inter> X | A. A \<in> sets M}"
hoelzl@58588
  2014
  unfolding vimage_algebra_def by (rule sets_measure_of) auto
hoelzl@58588
  2015
hoelzl@58588
  2016
lemma sets_vimage_algebra2:
hoelzl@58588
  2017
  "f \<in> X \<rightarrow> space M \<Longrightarrow> sets (vimage_algebra X f M) = {f -` A \<inter> X | A. A \<in> sets M}"
hoelzl@58588
  2018
  using sigma_sets_vimage_commute[of f X "space M" "sets M"]
hoelzl@58588
  2019
  unfolding sets_vimage_algebra sets.sigma_sets_eq by simp
hoelzl@56994
  2020
hoelzl@59092
  2021
lemma sets_vimage_algebra_cong: "sets M = sets N \<Longrightarrow> sets (vimage_algebra X f M) = sets (vimage_algebra X f N)"
hoelzl@59000
  2022
  by (simp add: sets_vimage_algebra)
hoelzl@59000
  2023
hoelzl@59092
  2024
lemma vimage_algebra_cong:
hoelzl@59092
  2025
  assumes "X = Y"
hoelzl@59092
  2026
  assumes "\<And>x. x \<in> Y \<Longrightarrow> f x = g x"
hoelzl@59092
  2027
  assumes "sets M = sets N"
hoelzl@59092
  2028
  shows "vimage_algebra X f M = vimage_algebra Y g N"
hoelzl@59092
  2029
  by (auto simp: vimage_algebra_def assms intro!: arg_cong2[where f=sigma])
hoelzl@59092
  2030
hoelzl@58588
  2031
lemma in_vimage_algebra: "A \<in> sets M \<Longrightarrow> f -` A \<inter> X \<in> sets (vimage_algebra X f M)"
hoelzl@58588
  2032
  by (auto simp: vimage_algebra_def)
hoelzl@58588
  2033
hoelzl@58588
  2034
lemma sets_image_in_sets:
hoelzl@58588
  2035
  assumes N: "space N = X"
hoelzl@58588
  2036
  assumes f: "f \<in> measurable N M"
hoelzl@58588
  2037
  shows "sets (vimage_algebra X f M) \<subseteq> sets N"
hoelzl@58588
  2038
  unfolding sets_vimage_algebra N[symmetric]
hoelzl@58588
  2039
  by (rule sets.sigma_sets_subset) (auto intro!: measurable_sets f)
hoelzl@58588
  2040
hoelzl@58588
  2041
lemma measurable_vimage_algebra1: "f \<in> X \<rightarrow> space M \<Longrightarrow> f \<in> measurable (vimage_algebra X f M) M"
hoelzl@58588
  2042
  unfolding measurable_def by (auto intro: in_vimage_algebra)
hoelzl@58588
  2043
hoelzl@58588
  2044
lemma measurable_vimage_algebra2:
hoelzl@58588
  2045
  assumes g: "g \<in> space N \<rightarrow> X" and f: "(\<lambda>x. f (g x)) \<in> measurable N M"
hoelzl@58588
  2046
  shows "g \<in> measurable N (vimage_algebra X f M)"
hoelzl@58588
  2047
  unfolding vimage_algebra_def
hoelzl@58588
  2048
proof (rule measurable_measure_of)
hoelzl@58588
  2049
  fix A assume "A \<in> {f -` A \<inter> X | A. A \<in> sets M}"
hoelzl@58588
  2050
  then obtain Y where Y: "Y \<in> sets M" and A: "A = f -` Y \<inter> X"
hoelzl@58588
  2051
    by auto
hoelzl@58588
  2052
  then have "g -` A \<inter> space N = (\<lambda>x. f (g x)) -` Y \<inter> space N"
hoelzl@58588
  2053
    using g by auto
hoelzl@58588
  2054
  also have "\<dots> \<in> sets N"
hoelzl@58588
  2055
    using f Y by (rule measurable_sets)
hoelzl@58588
  2056
  finally show "g -` A \<inter> space N \<in> sets N" .
hoelzl@58588
  2057
qed (insert g, auto)
hoelzl@56994
  2058
hoelzl@59088
  2059
lemma vimage_algebra_sigma:
hoelzl@59088
  2060
  assumes X: "X \<subseteq> Pow \<Omega>'" and f: "f \<in> \<Omega> \<rightarrow> \<Omega>'"
hoelzl@59088
  2061
  shows "vimage_algebra \<Omega> f (sigma \<Omega>' X) = sigma \<Omega> {f -` A \<inter> \<Omega> | A. A \<in> X }" (is "?V = ?S")
hoelzl@59088
  2062
proof (rule measure_eqI)
hoelzl@59088
  2063
  have \<Omega>: "{f -` A \<inter> \<Omega> |A. A \<in> X} \<subseteq> Pow \<Omega>" by auto
hoelzl@59088
  2064
  show "sets ?V = sets ?S"
hoelzl@59088
  2065
    using sigma_sets_vimage_commute[OF f, of X]
hoelzl@59088
  2066
    by (simp add: space_measure_of_conv f sets_vimage_algebra2 \<Omega> X)
hoelzl@59088
  2067
qed (simp add: vimage_algebra_def emeasure_sigma)
hoelzl@59088
  2068
hoelzl@59000
  2069
lemma vimage_algebra_vimage_algebra_eq:
hoelzl@59000
  2070
  assumes *: "f \<in> X \<rightarrow> Y" "g \<in> Y \<rightarrow> space M"
hoelzl@59000
  2071
  shows "vimage_algebra X f (vimage_algebra Y g M) = vimage_algebra X (\<lambda>x. g (f x)) M"
hoelzl@59088
  2072
    (is "?VV = ?V")
hoelzl@59000
  2073
proof (rule measure_eqI)
hoelzl@59000
  2074
  have "(\<lambda>x. g (f x)) \<in> X \<rightarrow> space M" "\<And>A. A \<inter> f -` Y \<inter> X = A \<inter> X"
hoelzl@59000
  2075
    using * by auto
hoelzl@59000
  2076
  with * show "sets ?VV = sets ?V"
hoelzl@59000
  2077
    by (simp add: sets_vimage_algebra2 ex_simps[symmetric] vimage_comp comp_def del: ex_simps)
hoelzl@59000
  2078
qed (simp add: vimage_algebra_def emeasure_sigma)
hoelzl@59000
  2079
wenzelm@61808
  2080
subsubsection \<open>Restricted Space Sigma Algebra\<close>
hoelzl@56994
  2081
hoelzl@57025
  2082
definition restrict_space where
hoelzl@57025
  2083
  "restrict_space M \<Omega> = measure_of (\<Omega> \<inter> space M) ((op \<inter> \<Omega>) ` sets M) (emeasure M)"
hoelzl@56994
  2084
hoelzl@57025
  2085
lemma space_restrict_space: "space (restrict_space M \<Omega>) = \<Omega> \<inter> space M"