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