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