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