src/HOL/Probability/Measure_Space.thy
author haftmann
Fri Jun 19 07:53:35 2015 +0200 (2015-06-19)
changeset 60517 f16e4fb20652
parent 60172 423273355b55
child 60580 7e741e22d7fc
permissions -rw-r--r--
separate class for notions specific for integral (semi)domains, in contrast to fields where these are trivial
hoelzl@47694
     1
(*  Title:      HOL/Probability/Measure_Space.thy
hoelzl@47694
     2
    Author:     Lawrence C Paulson
hoelzl@47694
     3
    Author:     Johannes Hölzl, TU München
hoelzl@47694
     4
    Author:     Armin Heller, TU München
hoelzl@47694
     5
*)
hoelzl@47694
     6
wenzelm@58876
     7
section {* Measure spaces and their properties *}
hoelzl@47694
     8
hoelzl@47694
     9
theory Measure_Space
hoelzl@47694
    10
imports
hoelzl@59593
    11
  Measurable "~~/src/HOL/Multivariate_Analysis/Multivariate_Analysis"
hoelzl@47694
    12
begin
hoelzl@47694
    13
hoelzl@50104
    14
subsection "Relate extended reals and the indicator function"
hoelzl@50104
    15
hoelzl@47694
    16
lemma suminf_cmult_indicator:
hoelzl@47694
    17
  fixes f :: "nat \<Rightarrow> ereal"
hoelzl@47694
    18
  assumes "disjoint_family A" "x \<in> A i" "\<And>i. 0 \<le> f i"
hoelzl@47694
    19
  shows "(\<Sum>n. f n * indicator (A n) x) = f i"
hoelzl@47694
    20
proof -
hoelzl@47694
    21
  have **: "\<And>n. f n * indicator (A n) x = (if n = i then f n else 0 :: ereal)"
hoelzl@47694
    22
    using `x \<in> A i` assms unfolding disjoint_family_on_def indicator_def by auto
hoelzl@47694
    23
  then have "\<And>n. (\<Sum>j<n. f j * indicator (A j) x) = (if i < n then f i else 0 :: ereal)"
haftmann@57418
    24
    by (auto simp: setsum.If_cases)
hoelzl@47694
    25
  moreover have "(SUP n. if i < n then f i else 0) = (f i :: ereal)"
hoelzl@51000
    26
  proof (rule SUP_eqI)
hoelzl@47694
    27
    fix y :: ereal assume "\<And>n. n \<in> UNIV \<Longrightarrow> (if i < n then f i else 0) \<le> y"
hoelzl@47694
    28
    from this[of "Suc i"] show "f i \<le> y" by auto
hoelzl@47694
    29
  qed (insert assms, simp)
hoelzl@47694
    30
  ultimately show ?thesis using assms
haftmann@56212
    31
    by (subst suminf_ereal_eq_SUP) (auto simp: indicator_def)
hoelzl@47694
    32
qed
hoelzl@47694
    33
hoelzl@47694
    34
lemma suminf_indicator:
hoelzl@47694
    35
  assumes "disjoint_family A"
hoelzl@47694
    36
  shows "(\<Sum>n. indicator (A n) x :: ereal) = indicator (\<Union>i. A i) x"
hoelzl@47694
    37
proof cases
hoelzl@47694
    38
  assume *: "x \<in> (\<Union>i. A i)"
hoelzl@47694
    39
  then obtain i where "x \<in> A i" by auto
hoelzl@47694
    40
  from suminf_cmult_indicator[OF assms(1), OF `x \<in> A i`, of "\<lambda>k. 1"]
hoelzl@47694
    41
  show ?thesis using * by simp
hoelzl@47694
    42
qed simp
hoelzl@47694
    43
hoelzl@47694
    44
text {*
hoelzl@47694
    45
  The type for emeasure spaces is already defined in @{theory Sigma_Algebra}, as it is also used to
hoelzl@47694
    46
  represent sigma algebras (with an arbitrary emeasure).
hoelzl@47694
    47
*}
hoelzl@47694
    48
hoelzl@56994
    49
subsection "Extend binary sets"
hoelzl@47694
    50
hoelzl@47694
    51
lemma LIMSEQ_binaryset:
hoelzl@47694
    52
  assumes f: "f {} = 0"
hoelzl@47694
    53
  shows  "(\<lambda>n. \<Sum>i<n. f (binaryset A B i)) ----> f A + f B"
hoelzl@47694
    54
proof -
hoelzl@47694
    55
  have "(\<lambda>n. \<Sum>i < Suc (Suc n). f (binaryset A B i)) = (\<lambda>n. f A + f B)"
hoelzl@47694
    56
    proof
hoelzl@47694
    57
      fix n
hoelzl@47694
    58
      show "(\<Sum>i < Suc (Suc n). f (binaryset A B i)) = f A + f B"
hoelzl@47694
    59
        by (induct n)  (auto simp add: binaryset_def f)
hoelzl@47694
    60
    qed
hoelzl@47694
    61
  moreover
hoelzl@47694
    62
  have "... ----> f A + f B" by (rule tendsto_const)
hoelzl@47694
    63
  ultimately
hoelzl@47694
    64
  have "(\<lambda>n. \<Sum>i< Suc (Suc n). f (binaryset A B i)) ----> f A + f B"
hoelzl@47694
    65
    by metis
hoelzl@47694
    66
  hence "(\<lambda>n. \<Sum>i< n+2. f (binaryset A B i)) ----> f A + f B"
hoelzl@47694
    67
    by simp
hoelzl@47694
    68
  thus ?thesis by (rule LIMSEQ_offset [where k=2])
hoelzl@47694
    69
qed
hoelzl@47694
    70
hoelzl@47694
    71
lemma binaryset_sums:
hoelzl@47694
    72
  assumes f: "f {} = 0"
hoelzl@47694
    73
  shows  "(\<lambda>n. f (binaryset A B n)) sums (f A + f B)"
hoelzl@47694
    74
    by (simp add: sums_def LIMSEQ_binaryset [where f=f, OF f] atLeast0LessThan)
hoelzl@47694
    75
hoelzl@47694
    76
lemma suminf_binaryset_eq:
hoelzl@47694
    77
  fixes f :: "'a set \<Rightarrow> 'b::{comm_monoid_add, t2_space}"
hoelzl@47694
    78
  shows "f {} = 0 \<Longrightarrow> (\<Sum>n. f (binaryset A B n)) = f A + f B"
hoelzl@47694
    79
  by (metis binaryset_sums sums_unique)
hoelzl@47694
    80
hoelzl@56994
    81
subsection {* Properties of a premeasure @{term \<mu>} *}
hoelzl@47694
    82
hoelzl@47694
    83
text {*
hoelzl@47694
    84
  The definitions for @{const positive} and @{const countably_additive} should be here, by they are
hoelzl@47694
    85
  necessary to define @{typ "'a measure"} in @{theory Sigma_Algebra}.
hoelzl@47694
    86
*}
hoelzl@47694
    87
hoelzl@47694
    88
definition additive where
hoelzl@47694
    89
  "additive M \<mu> \<longleftrightarrow> (\<forall>x\<in>M. \<forall>y\<in>M. x \<inter> y = {} \<longrightarrow> \<mu> (x \<union> y) = \<mu> x + \<mu> y)"
hoelzl@47694
    90
hoelzl@47694
    91
definition increasing where
hoelzl@47694
    92
  "increasing M \<mu> \<longleftrightarrow> (\<forall>x\<in>M. \<forall>y\<in>M. x \<subseteq> y \<longrightarrow> \<mu> x \<le> \<mu> y)"
hoelzl@47694
    93
hoelzl@49773
    94
lemma positiveD1: "positive M f \<Longrightarrow> f {} = 0" by (auto simp: positive_def)
hoelzl@49773
    95
lemma positiveD2: "positive M f \<Longrightarrow> A \<in> M \<Longrightarrow> 0 \<le> f A" by (auto simp: positive_def)
hoelzl@49773
    96
hoelzl@47694
    97
lemma positiveD_empty:
hoelzl@47694
    98
  "positive M f \<Longrightarrow> f {} = 0"
hoelzl@47694
    99
  by (auto simp add: positive_def)
hoelzl@47694
   100
hoelzl@47694
   101
lemma additiveD:
hoelzl@47694
   102
  "additive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> M \<Longrightarrow> y \<in> M \<Longrightarrow> f (x \<union> y) = f x + f y"
hoelzl@47694
   103
  by (auto simp add: additive_def)
hoelzl@47694
   104
hoelzl@47694
   105
lemma increasingD:
hoelzl@47694
   106
  "increasing M f \<Longrightarrow> x \<subseteq> y \<Longrightarrow> x\<in>M \<Longrightarrow> y\<in>M \<Longrightarrow> f x \<le> f y"
hoelzl@47694
   107
  by (auto simp add: increasing_def)
hoelzl@47694
   108
hoelzl@50104
   109
lemma countably_additiveI[case_names countably]:
hoelzl@47694
   110
  "(\<And>A. range A \<subseteq> M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i. A i) \<in> M \<Longrightarrow> (\<Sum>i. f (A i)) = f (\<Union>i. A i))
hoelzl@47694
   111
  \<Longrightarrow> countably_additive M f"
hoelzl@47694
   112
  by (simp add: countably_additive_def)
hoelzl@47694
   113
hoelzl@47694
   114
lemma (in ring_of_sets) disjointed_additive:
hoelzl@47694
   115
  assumes f: "positive M f" "additive M f" and A: "range A \<subseteq> M" "incseq A"
hoelzl@47694
   116
  shows "(\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
hoelzl@47694
   117
proof (induct n)
hoelzl@47694
   118
  case (Suc n)
hoelzl@47694
   119
  then have "(\<Sum>i\<le>Suc n. f (disjointed A i)) = f (A n) + f (disjointed A (Suc n))"
hoelzl@47694
   120
    by simp
hoelzl@47694
   121
  also have "\<dots> = f (A n \<union> disjointed A (Suc n))"
hoelzl@47694
   122
    using A by (subst f(2)[THEN additiveD]) (auto simp: disjointed_incseq)
hoelzl@47694
   123
  also have "A n \<union> disjointed A (Suc n) = A (Suc n)"
hoelzl@47694
   124
    using `incseq A` by (auto dest: incseq_SucD simp: disjointed_incseq)
hoelzl@47694
   125
  finally show ?case .
hoelzl@47694
   126
qed simp
hoelzl@47694
   127
hoelzl@47694
   128
lemma (in ring_of_sets) additive_sum:
hoelzl@47694
   129
  fixes A:: "'i \<Rightarrow> 'a set"
hoelzl@47694
   130
  assumes f: "positive M f" and ad: "additive M f" and "finite S"
hoelzl@47694
   131
      and A: "A`S \<subseteq> M"
hoelzl@47694
   132
      and disj: "disjoint_family_on A S"
hoelzl@47694
   133
  shows  "(\<Sum>i\<in>S. f (A i)) = f (\<Union>i\<in>S. A i)"
wenzelm@53374
   134
  using `finite S` disj A
wenzelm@53374
   135
proof induct
hoelzl@47694
   136
  case empty show ?case using f by (simp add: positive_def)
hoelzl@47694
   137
next
hoelzl@47694
   138
  case (insert s S)
hoelzl@47694
   139
  then have "A s \<inter> (\<Union>i\<in>S. A i) = {}"
hoelzl@47694
   140
    by (auto simp add: disjoint_family_on_def neq_iff)
hoelzl@47694
   141
  moreover
hoelzl@47694
   142
  have "A s \<in> M" using insert by blast
hoelzl@47694
   143
  moreover have "(\<Union>i\<in>S. A i) \<in> M"
hoelzl@47694
   144
    using insert `finite S` by auto
hoelzl@47694
   145
  ultimately have "f (A s \<union> (\<Union>i\<in>S. A i)) = f (A s) + f(\<Union>i\<in>S. A i)"
hoelzl@47694
   146
    using ad UNION_in_sets A by (auto simp add: additive_def)
hoelzl@47694
   147
  with insert show ?case using ad disjoint_family_on_mono[of S "insert s S" A]
hoelzl@47694
   148
    by (auto simp add: additive_def subset_insertI)
hoelzl@47694
   149
qed
hoelzl@47694
   150
hoelzl@47694
   151
lemma (in ring_of_sets) additive_increasing:
hoelzl@47694
   152
  assumes posf: "positive M f" and addf: "additive M f"
hoelzl@47694
   153
  shows "increasing M f"
hoelzl@47694
   154
proof (auto simp add: increasing_def)
hoelzl@47694
   155
  fix x y
hoelzl@47694
   156
  assume xy: "x \<in> M" "y \<in> M" "x \<subseteq> y"
hoelzl@47694
   157
  then have "y - x \<in> M" by auto
hoelzl@47694
   158
  then have "0 \<le> f (y-x)" using posf[unfolded positive_def] by auto
hoelzl@47694
   159
  then have "f x + 0 \<le> f x + f (y-x)" by (intro add_left_mono) auto
hoelzl@47694
   160
  also have "... = f (x \<union> (y-x))" using addf
hoelzl@47694
   161
    by (auto simp add: additive_def) (metis Diff_disjoint Un_Diff_cancel Diff xy(1,2))
hoelzl@47694
   162
  also have "... = f y"
hoelzl@47694
   163
    by (metis Un_Diff_cancel Un_absorb1 xy(3))
hoelzl@47694
   164
  finally show "f x \<le> f y" by simp
hoelzl@47694
   165
qed
hoelzl@47694
   166
immler@50087
   167
lemma (in ring_of_sets) subadditive:
immler@50087
   168
  assumes f: "positive M f" "additive M f" and A: "range A \<subseteq> M" and S: "finite S"
immler@50087
   169
  shows "f (\<Union>i\<in>S. A i) \<le> (\<Sum>i\<in>S. f (A i))"
immler@50087
   170
using S
immler@50087
   171
proof (induct S)
immler@50087
   172
  case empty thus ?case using f by (auto simp: positive_def)
immler@50087
   173
next
immler@50087
   174
  case (insert x F)
immler@50087
   175
  hence in_M: "A x \<in> M" "(\<Union> i\<in>F. A i) \<in> M" "(\<Union> i\<in>F. A i) - A x \<in> M" using A by force+
immler@50087
   176
  have subs: "(\<Union> i\<in>F. A i) - A x \<subseteq> (\<Union> i\<in>F. A i)" by auto
immler@50087
   177
  have "(\<Union> i\<in>(insert x F). A i) = A x \<union> ((\<Union> i\<in>F. A i) - A x)" by auto
immler@50087
   178
  hence "f (\<Union> i\<in>(insert x F). A i) = f (A x \<union> ((\<Union> i\<in>F. A i) - A x))"
immler@50087
   179
    by simp
immler@50087
   180
  also have "\<dots> = f (A x) + f ((\<Union> i\<in>F. A i) - A x)"
immler@50087
   181
    using f(2) by (rule additiveD) (insert in_M, auto)
immler@50087
   182
  also have "\<dots> \<le> f (A x) + f (\<Union> i\<in>F. A i)"
immler@50087
   183
    using additive_increasing[OF f] in_M subs by (auto simp: increasing_def intro: add_left_mono)
immler@50087
   184
  also have "\<dots> \<le> f (A x) + (\<Sum>i\<in>F. f (A i))" using insert by (auto intro: add_left_mono)
immler@50087
   185
  finally show "f (\<Union> i\<in>(insert x F). A i) \<le> (\<Sum>i\<in>(insert x F). f (A i))" using insert by simp
immler@50087
   186
qed
immler@50087
   187
hoelzl@47694
   188
lemma (in ring_of_sets) countably_additive_additive:
hoelzl@47694
   189
  assumes posf: "positive M f" and ca: "countably_additive M f"
hoelzl@47694
   190
  shows "additive M f"
hoelzl@47694
   191
proof (auto simp add: additive_def)
hoelzl@47694
   192
  fix x y
hoelzl@47694
   193
  assume x: "x \<in> M" and y: "y \<in> M" and "x \<inter> y = {}"
hoelzl@47694
   194
  hence "disjoint_family (binaryset x y)"
hoelzl@47694
   195
    by (auto simp add: disjoint_family_on_def binaryset_def)
hoelzl@47694
   196
  hence "range (binaryset x y) \<subseteq> M \<longrightarrow>
hoelzl@47694
   197
         (\<Union>i. binaryset x y i) \<in> M \<longrightarrow>
hoelzl@47694
   198
         f (\<Union>i. binaryset x y i) = (\<Sum> n. f (binaryset x y n))"
hoelzl@47694
   199
    using ca
hoelzl@47694
   200
    by (simp add: countably_additive_def)
hoelzl@47694
   201
  hence "{x,y,{}} \<subseteq> M \<longrightarrow> x \<union> y \<in> M \<longrightarrow>
hoelzl@47694
   202
         f (x \<union> y) = (\<Sum>n. f (binaryset x y n))"
hoelzl@47694
   203
    by (simp add: range_binaryset_eq UN_binaryset_eq)
hoelzl@47694
   204
  thus "f (x \<union> y) = f x + f y" using posf x y
hoelzl@47694
   205
    by (auto simp add: Un suminf_binaryset_eq positive_def)
hoelzl@47694
   206
qed
hoelzl@47694
   207
hoelzl@47694
   208
lemma (in algebra) increasing_additive_bound:
hoelzl@47694
   209
  fixes A:: "nat \<Rightarrow> 'a set" and  f :: "'a set \<Rightarrow> ereal"
hoelzl@47694
   210
  assumes f: "positive M f" and ad: "additive M f"
hoelzl@47694
   211
      and inc: "increasing M f"
hoelzl@47694
   212
      and A: "range A \<subseteq> M"
hoelzl@47694
   213
      and disj: "disjoint_family A"
hoelzl@47694
   214
  shows  "(\<Sum>i. f (A i)) \<le> f \<Omega>"
hoelzl@47694
   215
proof (safe intro!: suminf_bound)
hoelzl@47694
   216
  fix N
hoelzl@47694
   217
  note disj_N = disjoint_family_on_mono[OF _ disj, of "{..<N}"]
hoelzl@47694
   218
  have "(\<Sum>i<N. f (A i)) = f (\<Union>i\<in>{..<N}. A i)"
hoelzl@47694
   219
    using A by (intro additive_sum [OF f ad _ _]) (auto simp: disj_N)
hoelzl@47694
   220
  also have "... \<le> f \<Omega>" using space_closed A
hoelzl@47694
   221
    by (intro increasingD[OF inc] finite_UN) auto
hoelzl@47694
   222
  finally show "(\<Sum>i<N. f (A i)) \<le> f \<Omega>" by simp
hoelzl@47694
   223
qed (insert f A, auto simp: positive_def)
hoelzl@47694
   224
hoelzl@47694
   225
lemma (in ring_of_sets) countably_additiveI_finite:
hoelzl@47694
   226
  assumes "finite \<Omega>" "positive M \<mu>" "additive M \<mu>"
hoelzl@47694
   227
  shows "countably_additive M \<mu>"
hoelzl@47694
   228
proof (rule countably_additiveI)
hoelzl@47694
   229
  fix F :: "nat \<Rightarrow> 'a set" assume F: "range F \<subseteq> M" "(\<Union>i. F i) \<in> M" and disj: "disjoint_family F"
hoelzl@47694
   230
hoelzl@47694
   231
  have "\<forall>i\<in>{i. F i \<noteq> {}}. \<exists>x. x \<in> F i" by auto
hoelzl@47694
   232
  from bchoice[OF this] obtain f where f: "\<And>i. F i \<noteq> {} \<Longrightarrow> f i \<in> F i" by auto
hoelzl@47694
   233
hoelzl@47694
   234
  have inj_f: "inj_on f {i. F i \<noteq> {}}"
hoelzl@47694
   235
  proof (rule inj_onI, simp)
hoelzl@47694
   236
    fix i j a b assume *: "f i = f j" "F i \<noteq> {}" "F j \<noteq> {}"
hoelzl@47694
   237
    then have "f i \<in> F i" "f j \<in> F j" using f by force+
hoelzl@47694
   238
    with disj * show "i = j" by (auto simp: disjoint_family_on_def)
hoelzl@47694
   239
  qed
hoelzl@47694
   240
  have "finite (\<Union>i. F i)"
hoelzl@47694
   241
    by (metis F(2) assms(1) infinite_super sets_into_space)
hoelzl@47694
   242
hoelzl@47694
   243
  have F_subset: "{i. \<mu> (F i) \<noteq> 0} \<subseteq> {i. F i \<noteq> {}}"
hoelzl@47694
   244
    by (auto simp: positiveD_empty[OF `positive M \<mu>`])
hoelzl@47694
   245
  moreover have fin_not_empty: "finite {i. F i \<noteq> {}}"
hoelzl@47694
   246
  proof (rule finite_imageD)
hoelzl@47694
   247
    from f have "f`{i. F i \<noteq> {}} \<subseteq> (\<Union>i. F i)" by auto
hoelzl@47694
   248
    then show "finite (f`{i. F i \<noteq> {}})"
hoelzl@47694
   249
      by (rule finite_subset) fact
hoelzl@47694
   250
  qed fact
hoelzl@47694
   251
  ultimately have fin_not_0: "finite {i. \<mu> (F i) \<noteq> 0}"
hoelzl@47694
   252
    by (rule finite_subset)
hoelzl@47694
   253
hoelzl@47694
   254
  have disj_not_empty: "disjoint_family_on F {i. F i \<noteq> {}}"
hoelzl@47694
   255
    using disj by (auto simp: disjoint_family_on_def)
hoelzl@47694
   256
hoelzl@47694
   257
  from fin_not_0 have "(\<Sum>i. \<mu> (F i)) = (\<Sum>i | \<mu> (F i) \<noteq> 0. \<mu> (F i))"
hoelzl@47761
   258
    by (rule suminf_finite) auto
hoelzl@47694
   259
  also have "\<dots> = (\<Sum>i | F i \<noteq> {}. \<mu> (F i))"
haftmann@57418
   260
    using fin_not_empty F_subset by (rule setsum.mono_neutral_left) auto
hoelzl@47694
   261
  also have "\<dots> = \<mu> (\<Union>i\<in>{i. F i \<noteq> {}}. F i)"
hoelzl@47694
   262
    using `positive M \<mu>` `additive M \<mu>` fin_not_empty disj_not_empty F by (intro additive_sum) auto
hoelzl@47694
   263
  also have "\<dots> = \<mu> (\<Union>i. F i)"
hoelzl@47694
   264
    by (rule arg_cong[where f=\<mu>]) auto
hoelzl@47694
   265
  finally show "(\<Sum>i. \<mu> (F i)) = \<mu> (\<Union>i. F i)" .
hoelzl@47694
   266
qed
hoelzl@47694
   267
hoelzl@49773
   268
lemma (in ring_of_sets) countably_additive_iff_continuous_from_below:
hoelzl@49773
   269
  assumes f: "positive M f" "additive M f"
hoelzl@49773
   270
  shows "countably_additive M f \<longleftrightarrow>
hoelzl@49773
   271
    (\<forall>A. range A \<subseteq> M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Union>i. A i))"
hoelzl@49773
   272
  unfolding countably_additive_def
hoelzl@49773
   273
proof safe
hoelzl@49773
   274
  assume count_sum: "\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> UNION UNIV A \<in> M \<longrightarrow> (\<Sum>i. f (A i)) = f (UNION UNIV A)"
hoelzl@49773
   275
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "incseq A" "(\<Union>i. A i) \<in> M"
hoelzl@49773
   276
  then have dA: "range (disjointed A) \<subseteq> M" by (auto simp: range_disjointed_sets)
hoelzl@49773
   277
  with count_sum[THEN spec, of "disjointed A"] A(3)
hoelzl@49773
   278
  have f_UN: "(\<Sum>i. f (disjointed A i)) = f (\<Union>i. A i)"
hoelzl@49773
   279
    by (auto simp: UN_disjointed_eq disjoint_family_disjointed)
hoelzl@56193
   280
  moreover have "(\<lambda>n. (\<Sum>i<n. f (disjointed A i))) ----> (\<Sum>i. f (disjointed A i))"
hoelzl@49773
   281
    using f(1)[unfolded positive_def] dA
hoelzl@56193
   282
    by (auto intro!: summable_LIMSEQ summable_ereal_pos)
hoelzl@49773
   283
  from LIMSEQ_Suc[OF this]
hoelzl@49773
   284
  have "(\<lambda>n. (\<Sum>i\<le>n. f (disjointed A i))) ----> (\<Sum>i. f (disjointed A i))"
hoelzl@56193
   285
    unfolding lessThan_Suc_atMost .
hoelzl@49773
   286
  moreover have "\<And>n. (\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
hoelzl@49773
   287
    using disjointed_additive[OF f A(1,2)] .
hoelzl@49773
   288
  ultimately show "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)" by simp
hoelzl@49773
   289
next
hoelzl@49773
   290
  assume cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@49773
   291
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "disjoint_family A" "(\<Union>i. A i) \<in> M"
hoelzl@57446
   292
  have *: "(\<Union>n. (\<Union>i<n. A i)) = (\<Union>i. A i)" by auto
hoelzl@57446
   293
  have "(\<lambda>n. f (\<Union>i<n. A i)) ----> f (\<Union>i. A i)"
hoelzl@49773
   294
  proof (unfold *[symmetric], intro cont[rule_format])
hoelzl@57446
   295
    show "range (\<lambda>i. \<Union> i<i. A i) \<subseteq> M" "(\<Union>i. \<Union> i<i. A i) \<in> M"
hoelzl@49773
   296
      using A * by auto
hoelzl@49773
   297
  qed (force intro!: incseq_SucI)
hoelzl@57446
   298
  moreover have "\<And>n. f (\<Union>i<n. A i) = (\<Sum>i<n. f (A i))"
hoelzl@49773
   299
    using A
hoelzl@49773
   300
    by (intro additive_sum[OF f, of _ A, symmetric])
hoelzl@49773
   301
       (auto intro: disjoint_family_on_mono[where B=UNIV])
hoelzl@49773
   302
  ultimately
hoelzl@49773
   303
  have "(\<lambda>i. f (A i)) sums f (\<Union>i. A i)"
hoelzl@57446
   304
    unfolding sums_def by simp
hoelzl@49773
   305
  from sums_unique[OF this]
hoelzl@49773
   306
  show "(\<Sum>i. f (A i)) = f (\<Union>i. A i)" by simp
hoelzl@49773
   307
qed
hoelzl@49773
   308
hoelzl@49773
   309
lemma (in ring_of_sets) continuous_from_above_iff_empty_continuous:
hoelzl@49773
   310
  assumes f: "positive M f" "additive M f"
hoelzl@49773
   311
  shows "(\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) \<in> M \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Inter>i. A i))
hoelzl@49773
   312
     \<longleftrightarrow> (\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> 0)"
hoelzl@49773
   313
proof safe
hoelzl@49773
   314
  assume cont: "(\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) \<in> M \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Inter>i. A i))"
hoelzl@49773
   315
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "decseq A" "(\<Inter>i. A i) = {}" "\<forall>i. f (A i) \<noteq> \<infinity>"
hoelzl@49773
   316
  with cont[THEN spec, of A] show "(\<lambda>i. f (A i)) ----> 0"
hoelzl@49773
   317
    using `positive M f`[unfolded positive_def] by auto
hoelzl@49773
   318
next
hoelzl@49773
   319
  assume cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@49773
   320
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "decseq A" "(\<Inter>i. A i) \<in> M" "\<forall>i. f (A i) \<noteq> \<infinity>"
hoelzl@49773
   321
hoelzl@49773
   322
  have f_mono: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<subseteq> b \<Longrightarrow> f a \<le> f b"
hoelzl@49773
   323
    using additive_increasing[OF f] unfolding increasing_def by simp
hoelzl@49773
   324
hoelzl@49773
   325
  have decseq_fA: "decseq (\<lambda>i. f (A i))"
hoelzl@49773
   326
    using A by (auto simp: decseq_def intro!: f_mono)
hoelzl@49773
   327
  have decseq: "decseq (\<lambda>i. A i - (\<Inter>i. A i))"
hoelzl@49773
   328
    using A by (auto simp: decseq_def)
hoelzl@49773
   329
  then have decseq_f: "decseq (\<lambda>i. f (A i - (\<Inter>i. A i)))"
hoelzl@49773
   330
    using A unfolding decseq_def by (auto intro!: f_mono Diff)
hoelzl@49773
   331
  have "f (\<Inter>x. A x) \<le> f (A 0)"
hoelzl@49773
   332
    using A by (auto intro!: f_mono)
hoelzl@49773
   333
  then have f_Int_fin: "f (\<Inter>x. A x) \<noteq> \<infinity>"
hoelzl@49773
   334
    using A by auto
hoelzl@49773
   335
  { fix i
hoelzl@49773
   336
    have "f (A i - (\<Inter>i. A i)) \<le> f (A i)" using A by (auto intro!: f_mono)
hoelzl@49773
   337
    then have "f (A i - (\<Inter>i. A i)) \<noteq> \<infinity>"
hoelzl@49773
   338
      using A by auto }
hoelzl@49773
   339
  note f_fin = this
hoelzl@49773
   340
  have "(\<lambda>i. f (A i - (\<Inter>i. A i))) ----> 0"
hoelzl@49773
   341
  proof (intro cont[rule_format, OF _ decseq _ f_fin])
hoelzl@49773
   342
    show "range (\<lambda>i. A i - (\<Inter>i. A i)) \<subseteq> M" "(\<Inter>i. A i - (\<Inter>i. A i)) = {}"
hoelzl@49773
   343
      using A by auto
hoelzl@49773
   344
  qed
hoelzl@49773
   345
  from INF_Lim_ereal[OF decseq_f this]
hoelzl@49773
   346
  have "(INF n. f (A n - (\<Inter>i. A i))) = 0" .
hoelzl@49773
   347
  moreover have "(INF n. f (\<Inter>i. A i)) = f (\<Inter>i. A i)"
hoelzl@49773
   348
    by auto
hoelzl@49773
   349
  ultimately have "(INF n. f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i)) = 0 + f (\<Inter>i. A i)"
hoelzl@49773
   350
    using A(4) f_fin f_Int_fin
haftmann@56212
   351
    by (subst INF_ereal_add) (auto simp: decseq_f)
hoelzl@49773
   352
  moreover {
hoelzl@49773
   353
    fix n
hoelzl@49773
   354
    have "f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i) = f ((A n - (\<Inter>i. A i)) \<union> (\<Inter>i. A i))"
hoelzl@49773
   355
      using A by (subst f(2)[THEN additiveD]) auto
hoelzl@49773
   356
    also have "(A n - (\<Inter>i. A i)) \<union> (\<Inter>i. A i) = A n"
hoelzl@49773
   357
      by auto
hoelzl@49773
   358
    finally have "f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i) = f (A n)" . }
hoelzl@49773
   359
  ultimately have "(INF n. f (A n)) = f (\<Inter>i. A i)"
hoelzl@49773
   360
    by simp
hoelzl@51351
   361
  with LIMSEQ_INF[OF decseq_fA]
hoelzl@49773
   362
  show "(\<lambda>i. f (A i)) ----> f (\<Inter>i. A i)" by simp
hoelzl@49773
   363
qed
hoelzl@49773
   364
hoelzl@49773
   365
lemma (in ring_of_sets) empty_continuous_imp_continuous_from_below:
hoelzl@49773
   366
  assumes f: "positive M f" "additive M f" "\<forall>A\<in>M. f A \<noteq> \<infinity>"
hoelzl@49773
   367
  assumes cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@49773
   368
  assumes A: "range A \<subseteq> M" "incseq A" "(\<Union>i. A i) \<in> M"
hoelzl@49773
   369
  shows "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@49773
   370
proof -
hoelzl@49773
   371
  have "\<forall>A\<in>M. \<exists>x. f A = ereal x"
hoelzl@49773
   372
  proof
hoelzl@49773
   373
    fix A assume "A \<in> M" with f show "\<exists>x. f A = ereal x"
hoelzl@49773
   374
      unfolding positive_def by (cases "f A") auto
hoelzl@49773
   375
  qed
hoelzl@49773
   376
  from bchoice[OF this] guess f' .. note f' = this[rule_format]
hoelzl@49773
   377
  from A have "(\<lambda>i. f ((\<Union>i. A i) - A i)) ----> 0"
hoelzl@49773
   378
    by (intro cont[rule_format]) (auto simp: decseq_def incseq_def)
hoelzl@49773
   379
  moreover
hoelzl@49773
   380
  { fix i
hoelzl@49773
   381
    have "f ((\<Union>i. A i) - A i) + f (A i) = f ((\<Union>i. A i) - A i \<union> A i)"
hoelzl@49773
   382
      using A by (intro f(2)[THEN additiveD, symmetric]) auto
hoelzl@49773
   383
    also have "(\<Union>i. A i) - A i \<union> A i = (\<Union>i. A i)"
hoelzl@49773
   384
      by auto
hoelzl@49773
   385
    finally have "f' (\<Union>i. A i) - f' (A i) = f' ((\<Union>i. A i) - A i)"
hoelzl@49773
   386
      using A by (subst (asm) (1 2 3) f') auto
hoelzl@49773
   387
    then have "f ((\<Union>i. A i) - A i) = ereal (f' (\<Union>i. A i) - f' (A i))"
hoelzl@49773
   388
      using A f' by auto }
hoelzl@49773
   389
  ultimately have "(\<lambda>i. f' (\<Union>i. A i) - f' (A i)) ----> 0"
hoelzl@49773
   390
    by (simp add: zero_ereal_def)
hoelzl@49773
   391
  then have "(\<lambda>i. f' (A i)) ----> f' (\<Union>i. A i)"
lp15@60142
   392
    by (rule Lim_transform2[OF tendsto_const])
hoelzl@49773
   393
  then show "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@49773
   394
    using A by (subst (1 2) f') auto
hoelzl@49773
   395
qed
hoelzl@49773
   396
hoelzl@49773
   397
lemma (in ring_of_sets) empty_continuous_imp_countably_additive:
hoelzl@49773
   398
  assumes f: "positive M f" "additive M f" and fin: "\<forall>A\<in>M. f A \<noteq> \<infinity>"
hoelzl@49773
   399
  assumes cont: "\<And>A. range A \<subseteq> M \<Longrightarrow> decseq A \<Longrightarrow> (\<Inter>i. A i) = {} \<Longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@49773
   400
  shows "countably_additive M f"
hoelzl@49773
   401
  using countably_additive_iff_continuous_from_below[OF f]
hoelzl@49773
   402
  using empty_continuous_imp_continuous_from_below[OF f fin] cont
hoelzl@49773
   403
  by blast
hoelzl@49773
   404
hoelzl@56994
   405
subsection {* Properties of @{const emeasure} *}
hoelzl@47694
   406
hoelzl@47694
   407
lemma emeasure_positive: "positive (sets M) (emeasure M)"
hoelzl@47694
   408
  by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
hoelzl@47694
   409
hoelzl@47694
   410
lemma emeasure_empty[simp, intro]: "emeasure M {} = 0"
hoelzl@47694
   411
  using emeasure_positive[of M] by (simp add: positive_def)
hoelzl@47694
   412
hoelzl@47694
   413
lemma emeasure_nonneg[intro!]: "0 \<le> emeasure M A"
hoelzl@47694
   414
  using emeasure_notin_sets[of A M] emeasure_positive[of M]
hoelzl@47694
   415
  by (cases "A \<in> sets M") (auto simp: positive_def)
hoelzl@47694
   416
hoelzl@47694
   417
lemma emeasure_not_MInf[simp]: "emeasure M A \<noteq> - \<infinity>"
hoelzl@47694
   418
  using emeasure_nonneg[of M A] by auto
hoelzl@50419
   419
hoelzl@50419
   420
lemma emeasure_le_0_iff: "emeasure M A \<le> 0 \<longleftrightarrow> emeasure M A = 0"
hoelzl@50419
   421
  using emeasure_nonneg[of M A] by auto
hoelzl@50419
   422
hoelzl@50419
   423
lemma emeasure_less_0_iff: "emeasure M A < 0 \<longleftrightarrow> False"
hoelzl@50419
   424
  using emeasure_nonneg[of M A] by auto
hoelzl@59000
   425
hoelzl@59000
   426
lemma emeasure_single_in_space: "emeasure M {x} \<noteq> 0 \<Longrightarrow> x \<in> space M"
hoelzl@59000
   427
  using emeasure_notin_sets[of "{x}" M] by (auto dest: sets.sets_into_space)
hoelzl@59000
   428
hoelzl@47694
   429
lemma emeasure_countably_additive: "countably_additive (sets M) (emeasure M)"
hoelzl@47694
   430
  by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
hoelzl@47694
   431
hoelzl@47694
   432
lemma suminf_emeasure:
hoelzl@47694
   433
  "range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Sum>i. emeasure M (A i)) = emeasure M (\<Union>i. A i)"
immler@50244
   434
  using sets.countable_UN[of A UNIV M] emeasure_countably_additive[of M]
hoelzl@47694
   435
  by (simp add: countably_additive_def)
hoelzl@47694
   436
hoelzl@57447
   437
lemma sums_emeasure:
hoelzl@57447
   438
  "disjoint_family F \<Longrightarrow> (\<And>i. F i \<in> sets M) \<Longrightarrow> (\<lambda>i. emeasure M (F i)) sums emeasure M (\<Union>i. F i)"
hoelzl@57447
   439
  unfolding sums_iff by (intro conjI summable_ereal_pos emeasure_nonneg suminf_emeasure) auto
hoelzl@57447
   440
hoelzl@47694
   441
lemma emeasure_additive: "additive (sets M) (emeasure M)"
immler@50244
   442
  by (metis sets.countably_additive_additive emeasure_positive emeasure_countably_additive)
hoelzl@47694
   443
hoelzl@47694
   444
lemma plus_emeasure:
hoelzl@47694
   445
  "a \<in> sets M \<Longrightarrow> b \<in> sets M \<Longrightarrow> a \<inter> b = {} \<Longrightarrow> emeasure M a + emeasure M b = emeasure M (a \<union> b)"
hoelzl@47694
   446
  using additiveD[OF emeasure_additive] ..
hoelzl@47694
   447
hoelzl@47694
   448
lemma setsum_emeasure:
hoelzl@47694
   449
  "F`I \<subseteq> sets M \<Longrightarrow> disjoint_family_on F I \<Longrightarrow> finite I \<Longrightarrow>
hoelzl@47694
   450
    (\<Sum>i\<in>I. emeasure M (F i)) = emeasure M (\<Union>i\<in>I. F i)"
immler@50244
   451
  by (metis sets.additive_sum emeasure_positive emeasure_additive)
hoelzl@47694
   452
hoelzl@47694
   453
lemma emeasure_mono:
hoelzl@47694
   454
  "a \<subseteq> b \<Longrightarrow> b \<in> sets M \<Longrightarrow> emeasure M a \<le> emeasure M b"
immler@50244
   455
  by (metis sets.additive_increasing emeasure_additive emeasure_nonneg emeasure_notin_sets
hoelzl@47694
   456
            emeasure_positive increasingD)
hoelzl@47694
   457
hoelzl@47694
   458
lemma emeasure_space:
hoelzl@47694
   459
  "emeasure M A \<le> emeasure M (space M)"
immler@50244
   460
  by (metis emeasure_mono emeasure_nonneg emeasure_notin_sets sets.sets_into_space sets.top)
hoelzl@47694
   461
hoelzl@47694
   462
lemma emeasure_compl:
hoelzl@47694
   463
  assumes s: "s \<in> sets M" and fin: "emeasure M s \<noteq> \<infinity>"
hoelzl@47694
   464
  shows "emeasure M (space M - s) = emeasure M (space M) - emeasure M s"
hoelzl@47694
   465
proof -
hoelzl@47694
   466
  from s have "0 \<le> emeasure M s" by auto
hoelzl@47694
   467
  have "emeasure M (space M) = emeasure M (s \<union> (space M - s))" using s
immler@50244
   468
    by (metis Un_Diff_cancel Un_absorb1 s sets.sets_into_space)
hoelzl@47694
   469
  also have "... = emeasure M s + emeasure M (space M - s)"
hoelzl@47694
   470
    by (rule plus_emeasure[symmetric]) (auto simp add: s)
hoelzl@47694
   471
  finally have "emeasure M (space M) = emeasure M s + emeasure M (space M - s)" .
hoelzl@47694
   472
  then show ?thesis
hoelzl@47694
   473
    using fin `0 \<le> emeasure M s`
hoelzl@47694
   474
    unfolding ereal_eq_minus_iff by (auto simp: ac_simps)
hoelzl@47694
   475
qed
hoelzl@47694
   476
hoelzl@47694
   477
lemma emeasure_Diff:
hoelzl@47694
   478
  assumes finite: "emeasure M B \<noteq> \<infinity>"
hoelzl@50002
   479
  and [measurable]: "A \<in> sets M" "B \<in> sets M" and "B \<subseteq> A"
hoelzl@47694
   480
  shows "emeasure M (A - B) = emeasure M A - emeasure M B"
hoelzl@47694
   481
proof -
hoelzl@47694
   482
  have "0 \<le> emeasure M B" using assms by auto
hoelzl@47694
   483
  have "(A - B) \<union> B = A" using `B \<subseteq> A` by auto
hoelzl@47694
   484
  then have "emeasure M A = emeasure M ((A - B) \<union> B)" by simp
hoelzl@47694
   485
  also have "\<dots> = emeasure M (A - B) + emeasure M B"
hoelzl@50002
   486
    by (subst plus_emeasure[symmetric]) auto
hoelzl@47694
   487
  finally show "emeasure M (A - B) = emeasure M A - emeasure M B"
hoelzl@47694
   488
    unfolding ereal_eq_minus_iff
hoelzl@47694
   489
    using finite `0 \<le> emeasure M B` by auto
hoelzl@47694
   490
qed
hoelzl@47694
   491
hoelzl@49773
   492
lemma Lim_emeasure_incseq:
hoelzl@49773
   493
  "range A \<subseteq> sets M \<Longrightarrow> incseq A \<Longrightarrow> (\<lambda>i. (emeasure M (A i))) ----> emeasure M (\<Union>i. A i)"
hoelzl@49773
   494
  using emeasure_countably_additive
immler@50244
   495
  by (auto simp add: sets.countably_additive_iff_continuous_from_below emeasure_positive
immler@50244
   496
    emeasure_additive)
hoelzl@47694
   497
hoelzl@47694
   498
lemma incseq_emeasure:
hoelzl@47694
   499
  assumes "range B \<subseteq> sets M" "incseq B"
hoelzl@47694
   500
  shows "incseq (\<lambda>i. emeasure M (B i))"
hoelzl@47694
   501
  using assms by (auto simp: incseq_def intro!: emeasure_mono)
hoelzl@47694
   502
hoelzl@49773
   503
lemma SUP_emeasure_incseq:
hoelzl@47694
   504
  assumes A: "range A \<subseteq> sets M" "incseq A"
hoelzl@49773
   505
  shows "(SUP n. emeasure M (A n)) = emeasure M (\<Union>i. A i)"
hoelzl@51000
   506
  using LIMSEQ_SUP[OF incseq_emeasure, OF A] Lim_emeasure_incseq[OF A]
hoelzl@49773
   507
  by (simp add: LIMSEQ_unique)
hoelzl@47694
   508
hoelzl@47694
   509
lemma decseq_emeasure:
hoelzl@47694
   510
  assumes "range B \<subseteq> sets M" "decseq B"
hoelzl@47694
   511
  shows "decseq (\<lambda>i. emeasure M (B i))"
hoelzl@47694
   512
  using assms by (auto simp: decseq_def intro!: emeasure_mono)
hoelzl@47694
   513
hoelzl@47694
   514
lemma INF_emeasure_decseq:
hoelzl@47694
   515
  assumes A: "range A \<subseteq> sets M" and "decseq A"
hoelzl@47694
   516
  and finite: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
   517
  shows "(INF n. emeasure M (A n)) = emeasure M (\<Inter>i. A i)"
hoelzl@47694
   518
proof -
hoelzl@47694
   519
  have le_MI: "emeasure M (\<Inter>i. A i) \<le> emeasure M (A 0)"
hoelzl@47694
   520
    using A by (auto intro!: emeasure_mono)
hoelzl@47694
   521
  hence *: "emeasure M (\<Inter>i. A i) \<noteq> \<infinity>" using finite[of 0] by auto
hoelzl@47694
   522
hoelzl@47694
   523
  have A0: "0 \<le> emeasure M (A 0)" using A by auto
hoelzl@47694
   524
hoelzl@47694
   525
  have "emeasure M (A 0) - (INF n. emeasure M (A n)) = emeasure M (A 0) + (SUP n. - emeasure M (A n))"
haftmann@56212
   526
    by (simp add: ereal_SUP_uminus minus_ereal_def)
hoelzl@47694
   527
  also have "\<dots> = (SUP n. emeasure M (A 0) - emeasure M (A n))"
hoelzl@47694
   528
    unfolding minus_ereal_def using A0 assms
haftmann@56212
   529
    by (subst SUP_ereal_add) (auto simp add: decseq_emeasure)
hoelzl@47694
   530
  also have "\<dots> = (SUP n. emeasure M (A 0 - A n))"
hoelzl@47694
   531
    using A finite `decseq A`[unfolded decseq_def] by (subst emeasure_Diff) auto
hoelzl@47694
   532
  also have "\<dots> = emeasure M (\<Union>i. A 0 - A i)"
hoelzl@47694
   533
  proof (rule SUP_emeasure_incseq)
hoelzl@47694
   534
    show "range (\<lambda>n. A 0 - A n) \<subseteq> sets M"
hoelzl@47694
   535
      using A by auto
hoelzl@47694
   536
    show "incseq (\<lambda>n. A 0 - A n)"
hoelzl@47694
   537
      using `decseq A` by (auto simp add: incseq_def decseq_def)
hoelzl@47694
   538
  qed
hoelzl@47694
   539
  also have "\<dots> = emeasure M (A 0) - emeasure M (\<Inter>i. A i)"
hoelzl@47694
   540
    using A finite * by (simp, subst emeasure_Diff) auto
hoelzl@47694
   541
  finally show ?thesis
hoelzl@47694
   542
    unfolding ereal_minus_eq_minus_iff using finite A0 by auto
hoelzl@47694
   543
qed
hoelzl@47694
   544
hoelzl@47694
   545
lemma Lim_emeasure_decseq:
hoelzl@47694
   546
  assumes A: "range A \<subseteq> sets M" "decseq A" and fin: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
   547
  shows "(\<lambda>i. emeasure M (A i)) ----> emeasure M (\<Inter>i. A i)"
hoelzl@51351
   548
  using LIMSEQ_INF[OF decseq_emeasure, OF A]
hoelzl@47694
   549
  using INF_emeasure_decseq[OF A fin] by simp
hoelzl@47694
   550
hoelzl@59000
   551
lemma emeasure_lfp[consumes 1, case_names cont measurable]:
hoelzl@59000
   552
  assumes "P M"
hoelzl@60172
   553
  assumes cont: "sup_continuous F"
hoelzl@59000
   554
  assumes *: "\<And>M A. P M \<Longrightarrow> (\<And>N. P N \<Longrightarrow> Measurable.pred N A) \<Longrightarrow> Measurable.pred M (F A)"
hoelzl@59000
   555
  shows "emeasure M {x\<in>space M. lfp F x} = (SUP i. emeasure M {x\<in>space M. (F ^^ i) (\<lambda>x. False) x})"
hoelzl@59000
   556
proof -
hoelzl@59000
   557
  have "emeasure M {x\<in>space M. lfp F x} = emeasure M (\<Union>i. {x\<in>space M. (F ^^ i) (\<lambda>x. False) x})"
hoelzl@60172
   558
    using sup_continuous_lfp[OF cont] by (auto simp add: bot_fun_def intro!: arg_cong2[where f=emeasure])
hoelzl@59000
   559
  moreover { fix i from `P M` have "{x\<in>space M. (F ^^ i) (\<lambda>x. False) x} \<in> sets M"
hoelzl@59000
   560
    by (induct i arbitrary: M) (auto simp add: pred_def[symmetric] intro: *) }
hoelzl@59000
   561
  moreover have "incseq (\<lambda>i. {x\<in>space M. (F ^^ i) (\<lambda>x. False) x})"
hoelzl@59000
   562
  proof (rule incseq_SucI)
hoelzl@59000
   563
    fix i
hoelzl@59000
   564
    have "(F ^^ i) (\<lambda>x. False) \<le> (F ^^ (Suc i)) (\<lambda>x. False)"
hoelzl@59000
   565
    proof (induct i)
hoelzl@59000
   566
      case 0 show ?case by (simp add: le_fun_def)
hoelzl@59000
   567
    next
hoelzl@60172
   568
      case Suc thus ?case using monoD[OF sup_continuous_mono[OF cont] Suc] by auto
hoelzl@59000
   569
    qed
hoelzl@59000
   570
    then show "{x \<in> space M. (F ^^ i) (\<lambda>x. False) x} \<subseteq> {x \<in> space M. (F ^^ Suc i) (\<lambda>x. False) x}"
hoelzl@59000
   571
      by auto
hoelzl@59000
   572
  qed
hoelzl@59000
   573
  ultimately show ?thesis
hoelzl@59000
   574
    by (subst SUP_emeasure_incseq) auto
hoelzl@59000
   575
qed
hoelzl@59000
   576
hoelzl@47694
   577
lemma emeasure_subadditive:
hoelzl@50002
   578
  assumes [measurable]: "A \<in> sets M" "B \<in> sets M"
hoelzl@47694
   579
  shows "emeasure M (A \<union> B) \<le> emeasure M A + emeasure M B"
hoelzl@47694
   580
proof -
hoelzl@47694
   581
  from plus_emeasure[of A M "B - A"]
hoelzl@50002
   582
  have "emeasure M (A \<union> B) = emeasure M A + emeasure M (B - A)" by simp
hoelzl@47694
   583
  also have "\<dots> \<le> emeasure M A + emeasure M B"
hoelzl@47694
   584
    using assms by (auto intro!: add_left_mono emeasure_mono)
hoelzl@47694
   585
  finally show ?thesis .
hoelzl@47694
   586
qed
hoelzl@47694
   587
hoelzl@47694
   588
lemma emeasure_subadditive_finite:
hoelzl@47694
   589
  assumes "finite I" "A ` I \<subseteq> sets M"
hoelzl@47694
   590
  shows "emeasure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. emeasure M (A i))"
hoelzl@47694
   591
using assms proof induct
hoelzl@47694
   592
  case (insert i I)
hoelzl@47694
   593
  then have "emeasure M (\<Union>i\<in>insert i I. A i) = emeasure M (A i \<union> (\<Union>i\<in>I. A i))"
hoelzl@47694
   594
    by simp
hoelzl@47694
   595
  also have "\<dots> \<le> emeasure M (A i) + emeasure M (\<Union>i\<in>I. A i)"
hoelzl@50002
   596
    using insert by (intro emeasure_subadditive) auto
hoelzl@47694
   597
  also have "\<dots> \<le> emeasure M (A i) + (\<Sum>i\<in>I. emeasure M (A i))"
hoelzl@47694
   598
    using insert by (intro add_mono) auto
hoelzl@47694
   599
  also have "\<dots> = (\<Sum>i\<in>insert i I. emeasure M (A i))"
hoelzl@47694
   600
    using insert by auto
hoelzl@47694
   601
  finally show ?case .
hoelzl@47694
   602
qed simp
hoelzl@47694
   603
hoelzl@47694
   604
lemma emeasure_subadditive_countably:
hoelzl@47694
   605
  assumes "range f \<subseteq> sets M"
hoelzl@47694
   606
  shows "emeasure M (\<Union>i. f i) \<le> (\<Sum>i. emeasure M (f i))"
hoelzl@47694
   607
proof -
hoelzl@47694
   608
  have "emeasure M (\<Union>i. f i) = emeasure M (\<Union>i. disjointed f i)"
hoelzl@47694
   609
    unfolding UN_disjointed_eq ..
hoelzl@47694
   610
  also have "\<dots> = (\<Sum>i. emeasure M (disjointed f i))"
immler@50244
   611
    using sets.range_disjointed_sets[OF assms] suminf_emeasure[of "disjointed f"]
hoelzl@47694
   612
    by (simp add:  disjoint_family_disjointed comp_def)
hoelzl@47694
   613
  also have "\<dots> \<le> (\<Sum>i. emeasure M (f i))"
immler@50244
   614
    using sets.range_disjointed_sets[OF assms] assms
hoelzl@47694
   615
    by (auto intro!: suminf_le_pos emeasure_mono disjointed_subset)
hoelzl@47694
   616
  finally show ?thesis .
hoelzl@47694
   617
qed
hoelzl@47694
   618
hoelzl@47694
   619
lemma emeasure_insert:
hoelzl@47694
   620
  assumes sets: "{x} \<in> sets M" "A \<in> sets M" and "x \<notin> A"
hoelzl@47694
   621
  shows "emeasure M (insert x A) = emeasure M {x} + emeasure M A"
hoelzl@47694
   622
proof -
hoelzl@47694
   623
  have "{x} \<inter> A = {}" using `x \<notin> A` by auto
hoelzl@47694
   624
  from plus_emeasure[OF sets this] show ?thesis by simp
hoelzl@47694
   625
qed
hoelzl@47694
   626
hoelzl@57447
   627
lemma emeasure_insert_ne:
hoelzl@57447
   628
  "A \<noteq> {} \<Longrightarrow> {x} \<in> sets M \<Longrightarrow> A \<in> sets M \<Longrightarrow> x \<notin> A \<Longrightarrow> emeasure M (insert x A) = emeasure M {x} + emeasure M A"
hoelzl@57447
   629
  by (rule emeasure_insert) 
hoelzl@57447
   630
hoelzl@47694
   631
lemma emeasure_eq_setsum_singleton:
hoelzl@47694
   632
  assumes "finite S" "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
hoelzl@47694
   633
  shows "emeasure M S = (\<Sum>x\<in>S. emeasure M {x})"
hoelzl@47694
   634
  using setsum_emeasure[of "\<lambda>x. {x}" S M] assms
hoelzl@47694
   635
  by (auto simp: disjoint_family_on_def subset_eq)
hoelzl@47694
   636
hoelzl@47694
   637
lemma setsum_emeasure_cover:
hoelzl@47694
   638
  assumes "finite S" and "A \<in> sets M" and br_in_M: "B ` S \<subseteq> sets M"
hoelzl@47694
   639
  assumes A: "A \<subseteq> (\<Union>i\<in>S. B i)"
hoelzl@47694
   640
  assumes disj: "disjoint_family_on B S"
hoelzl@47694
   641
  shows "emeasure M A = (\<Sum>i\<in>S. emeasure M (A \<inter> (B i)))"
hoelzl@47694
   642
proof -
hoelzl@47694
   643
  have "(\<Sum>i\<in>S. emeasure M (A \<inter> (B i))) = emeasure M (\<Union>i\<in>S. A \<inter> (B i))"
hoelzl@47694
   644
  proof (rule setsum_emeasure)
hoelzl@47694
   645
    show "disjoint_family_on (\<lambda>i. A \<inter> B i) S"
hoelzl@47694
   646
      using `disjoint_family_on B S`
hoelzl@47694
   647
      unfolding disjoint_family_on_def by auto
hoelzl@47694
   648
  qed (insert assms, auto)
hoelzl@47694
   649
  also have "(\<Union>i\<in>S. A \<inter> (B i)) = A"
hoelzl@47694
   650
    using A by auto
hoelzl@47694
   651
  finally show ?thesis by simp
hoelzl@47694
   652
qed
hoelzl@47694
   653
hoelzl@47694
   654
lemma emeasure_eq_0:
hoelzl@47694
   655
  "N \<in> sets M \<Longrightarrow> emeasure M N = 0 \<Longrightarrow> K \<subseteq> N \<Longrightarrow> emeasure M K = 0"
hoelzl@47694
   656
  by (metis emeasure_mono emeasure_nonneg order_eq_iff)
hoelzl@47694
   657
hoelzl@47694
   658
lemma emeasure_UN_eq_0:
hoelzl@47694
   659
  assumes "\<And>i::nat. emeasure M (N i) = 0" and "range N \<subseteq> sets M"
hoelzl@47694
   660
  shows "emeasure M (\<Union> i. N i) = 0"
hoelzl@47694
   661
proof -
hoelzl@47694
   662
  have "0 \<le> emeasure M (\<Union> i. N i)" using assms by auto
hoelzl@47694
   663
  moreover have "emeasure M (\<Union> i. N i) \<le> 0"
hoelzl@47694
   664
    using emeasure_subadditive_countably[OF assms(2)] assms(1) by simp
hoelzl@47694
   665
  ultimately show ?thesis by simp
hoelzl@47694
   666
qed
hoelzl@47694
   667
hoelzl@47694
   668
lemma measure_eqI_finite:
hoelzl@47694
   669
  assumes [simp]: "sets M = Pow A" "sets N = Pow A" and "finite A"
hoelzl@47694
   670
  assumes eq: "\<And>a. a \<in> A \<Longrightarrow> emeasure M {a} = emeasure N {a}"
hoelzl@47694
   671
  shows "M = N"
hoelzl@47694
   672
proof (rule measure_eqI)
hoelzl@47694
   673
  fix X assume "X \<in> sets M"
hoelzl@47694
   674
  then have X: "X \<subseteq> A" by auto
hoelzl@47694
   675
  then have "emeasure M X = (\<Sum>a\<in>X. emeasure M {a})"
hoelzl@47694
   676
    using `finite A` by (subst emeasure_eq_setsum_singleton) (auto dest: finite_subset)
hoelzl@47694
   677
  also have "\<dots> = (\<Sum>a\<in>X. emeasure N {a})"
haftmann@57418
   678
    using X eq by (auto intro!: setsum.cong)
hoelzl@47694
   679
  also have "\<dots> = emeasure N X"
hoelzl@47694
   680
    using X `finite A` by (subst emeasure_eq_setsum_singleton) (auto dest: finite_subset)
hoelzl@47694
   681
  finally show "emeasure M X = emeasure N X" .
hoelzl@47694
   682
qed simp
hoelzl@47694
   683
hoelzl@47694
   684
lemma measure_eqI_generator_eq:
hoelzl@47694
   685
  fixes M N :: "'a measure" and E :: "'a set set" and A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
   686
  assumes "Int_stable E" "E \<subseteq> Pow \<Omega>"
hoelzl@47694
   687
  and eq: "\<And>X. X \<in> E \<Longrightarrow> emeasure M X = emeasure N X"
hoelzl@47694
   688
  and M: "sets M = sigma_sets \<Omega> E"
hoelzl@47694
   689
  and N: "sets N = sigma_sets \<Omega> E"
hoelzl@49784
   690
  and A: "range A \<subseteq> E" "(\<Union>i. A i) = \<Omega>" "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
   691
  shows "M = N"
hoelzl@47694
   692
proof -
hoelzl@49773
   693
  let ?\<mu>  = "emeasure M" and ?\<nu> = "emeasure N"
hoelzl@47694
   694
  interpret S: sigma_algebra \<Omega> "sigma_sets \<Omega> E" by (rule sigma_algebra_sigma_sets) fact
hoelzl@49789
   695
  have "space M = \<Omega>"
immler@50244
   696
    using sets.top[of M] sets.space_closed[of M] S.top S.space_closed `sets M = sigma_sets \<Omega> E`
immler@50244
   697
    by blast
hoelzl@49789
   698
hoelzl@49789
   699
  { fix F D assume "F \<in> E" and "?\<mu> F \<noteq> \<infinity>"
hoelzl@47694
   700
    then have [intro]: "F \<in> sigma_sets \<Omega> E" by auto
hoelzl@49773
   701
    have "?\<nu> F \<noteq> \<infinity>" using `?\<mu> F \<noteq> \<infinity>` `F \<in> E` eq by simp
hoelzl@49789
   702
    assume "D \<in> sets M"
hoelzl@49789
   703
    with `Int_stable E` `E \<subseteq> Pow \<Omega>` have "emeasure M (F \<inter> D) = emeasure N (F \<inter> D)"
hoelzl@49789
   704
      unfolding M
hoelzl@49789
   705
    proof (induct rule: sigma_sets_induct_disjoint)
hoelzl@49789
   706
      case (basic A)
hoelzl@49789
   707
      then have "F \<inter> A \<in> E" using `Int_stable E` `F \<in> E` by (auto simp: Int_stable_def)
hoelzl@49789
   708
      then show ?case using eq by auto
hoelzl@47694
   709
    next
hoelzl@49789
   710
      case empty then show ?case by simp
hoelzl@47694
   711
    next
hoelzl@49789
   712
      case (compl A)
hoelzl@47694
   713
      then have **: "F \<inter> (\<Omega> - A) = F - (F \<inter> A)"
hoelzl@47694
   714
        and [intro]: "F \<inter> A \<in> sigma_sets \<Omega> E"
hoelzl@49789
   715
        using `F \<in> E` S.sets_into_space by (auto simp: M)
hoelzl@49773
   716
      have "?\<nu> (F \<inter> A) \<le> ?\<nu> F" by (auto intro!: emeasure_mono simp: M N)
hoelzl@49773
   717
      then have "?\<nu> (F \<inter> A) \<noteq> \<infinity>" using `?\<nu> F \<noteq> \<infinity>` by auto
hoelzl@49773
   718
      have "?\<mu> (F \<inter> A) \<le> ?\<mu> F" by (auto intro!: emeasure_mono simp: M N)
hoelzl@49773
   719
      then have "?\<mu> (F \<inter> A) \<noteq> \<infinity>" using `?\<mu> F \<noteq> \<infinity>` by auto
hoelzl@49773
   720
      then have "?\<mu> (F \<inter> (\<Omega> - A)) = ?\<mu> F - ?\<mu> (F \<inter> A)" unfolding **
hoelzl@47694
   721
        using `F \<inter> A \<in> sigma_sets \<Omega> E` by (auto intro!: emeasure_Diff simp: M N)
hoelzl@49789
   722
      also have "\<dots> = ?\<nu> F - ?\<nu> (F \<inter> A)" using eq `F \<in> E` compl by simp
hoelzl@49773
   723
      also have "\<dots> = ?\<nu> (F \<inter> (\<Omega> - A))" unfolding **
hoelzl@49773
   724
        using `F \<inter> A \<in> sigma_sets \<Omega> E` `?\<nu> (F \<inter> A) \<noteq> \<infinity>`
hoelzl@47694
   725
        by (auto intro!: emeasure_Diff[symmetric] simp: M N)
hoelzl@49789
   726
      finally show ?case
hoelzl@49789
   727
        using `space M = \<Omega>` by auto
hoelzl@47694
   728
    next
hoelzl@49789
   729
      case (union A)
hoelzl@49773
   730
      then have "?\<mu> (\<Union>x. F \<inter> A x) = ?\<nu> (\<Union>x. F \<inter> A x)"
hoelzl@49773
   731
        by (subst (1 2) suminf_emeasure[symmetric]) (auto simp: disjoint_family_on_def subset_eq M N)
hoelzl@49789
   732
      with A show ?case
hoelzl@49773
   733
        by auto
hoelzl@49789
   734
    qed }
hoelzl@47694
   735
  note * = this
hoelzl@47694
   736
  show "M = N"
hoelzl@47694
   737
  proof (rule measure_eqI)
hoelzl@47694
   738
    show "sets M = sets N"
hoelzl@47694
   739
      using M N by simp
hoelzl@49784
   740
    have [simp, intro]: "\<And>i. A i \<in> sets M"
hoelzl@49784
   741
      using A(1) by (auto simp: subset_eq M)
hoelzl@49773
   742
    fix F assume "F \<in> sets M"
hoelzl@49784
   743
    let ?D = "disjointed (\<lambda>i. F \<inter> A i)"
hoelzl@49789
   744
    from `space M = \<Omega>` have F_eq: "F = (\<Union>i. ?D i)"
immler@50244
   745
      using `F \<in> sets M`[THEN sets.sets_into_space] A(2)[symmetric] by (auto simp: UN_disjointed_eq)
hoelzl@49784
   746
    have [simp, intro]: "\<And>i. ?D i \<in> sets M"
immler@50244
   747
      using sets.range_disjointed_sets[of "\<lambda>i. F \<inter> A i" M] `F \<in> sets M`
hoelzl@49784
   748
      by (auto simp: subset_eq)
hoelzl@49784
   749
    have "disjoint_family ?D"
hoelzl@49784
   750
      by (auto simp: disjoint_family_disjointed)
hoelzl@50002
   751
    moreover
hoelzl@50002
   752
    have "(\<Sum>i. emeasure M (?D i)) = (\<Sum>i. emeasure N (?D i))"
hoelzl@50002
   753
    proof (intro arg_cong[where f=suminf] ext)
hoelzl@50002
   754
      fix i
hoelzl@49784
   755
      have "A i \<inter> ?D i = ?D i"
hoelzl@49784
   756
        by (auto simp: disjointed_def)
hoelzl@50002
   757
      then show "emeasure M (?D i) = emeasure N (?D i)"
hoelzl@50002
   758
        using *[of "A i" "?D i", OF _ A(3)] A(1) by auto
hoelzl@50002
   759
    qed
hoelzl@50002
   760
    ultimately show "emeasure M F = emeasure N F"
hoelzl@50002
   761
      by (simp add: image_subset_iff `sets M = sets N`[symmetric] F_eq[symmetric] suminf_emeasure)
hoelzl@47694
   762
  qed
hoelzl@47694
   763
qed
hoelzl@47694
   764
hoelzl@47694
   765
lemma measure_of_of_measure: "measure_of (space M) (sets M) (emeasure M) = M"
hoelzl@47694
   766
proof (intro measure_eqI emeasure_measure_of_sigma)
hoelzl@47694
   767
  show "sigma_algebra (space M) (sets M)" ..
hoelzl@47694
   768
  show "positive (sets M) (emeasure M)"
hoelzl@47694
   769
    by (simp add: positive_def emeasure_nonneg)
hoelzl@47694
   770
  show "countably_additive (sets M) (emeasure M)"
hoelzl@47694
   771
    by (simp add: emeasure_countably_additive)
hoelzl@47694
   772
qed simp_all
hoelzl@47694
   773
hoelzl@56994
   774
subsection {* @{text \<mu>}-null sets *}
hoelzl@47694
   775
hoelzl@47694
   776
definition null_sets :: "'a measure \<Rightarrow> 'a set set" where
hoelzl@47694
   777
  "null_sets M = {N\<in>sets M. emeasure M N = 0}"
hoelzl@47694
   778
hoelzl@47694
   779
lemma null_setsD1[dest]: "A \<in> null_sets M \<Longrightarrow> emeasure M A = 0"
hoelzl@47694
   780
  by (simp add: null_sets_def)
hoelzl@47694
   781
hoelzl@47694
   782
lemma null_setsD2[dest]: "A \<in> null_sets M \<Longrightarrow> A \<in> sets M"
hoelzl@47694
   783
  unfolding null_sets_def by simp
hoelzl@47694
   784
hoelzl@47694
   785
lemma null_setsI[intro]: "emeasure M A = 0 \<Longrightarrow> A \<in> sets M \<Longrightarrow> A \<in> null_sets M"
hoelzl@47694
   786
  unfolding null_sets_def by simp
hoelzl@47694
   787
hoelzl@47694
   788
interpretation null_sets: ring_of_sets "space M" "null_sets M" for M
hoelzl@47762
   789
proof (rule ring_of_setsI)
hoelzl@47694
   790
  show "null_sets M \<subseteq> Pow (space M)"
immler@50244
   791
    using sets.sets_into_space by auto
hoelzl@47694
   792
  show "{} \<in> null_sets M"
hoelzl@47694
   793
    by auto
wenzelm@53374
   794
  fix A B assume null_sets: "A \<in> null_sets M" "B \<in> null_sets M"
wenzelm@53374
   795
  then have sets: "A \<in> sets M" "B \<in> sets M"
hoelzl@47694
   796
    by auto
wenzelm@53374
   797
  then have *: "emeasure M (A \<union> B) \<le> emeasure M A + emeasure M B"
hoelzl@47694
   798
    "emeasure M (A - B) \<le> emeasure M A"
hoelzl@47694
   799
    by (auto intro!: emeasure_subadditive emeasure_mono)
wenzelm@53374
   800
  then have "emeasure M B = 0" "emeasure M A = 0"
wenzelm@53374
   801
    using null_sets by auto
wenzelm@53374
   802
  with sets * show "A - B \<in> null_sets M" "A \<union> B \<in> null_sets M"
hoelzl@47694
   803
    by (auto intro!: antisym)
hoelzl@47694
   804
qed
hoelzl@47694
   805
hoelzl@57275
   806
lemma UN_from_nat_into: 
hoelzl@57275
   807
  assumes I: "countable I" "I \<noteq> {}"
hoelzl@57275
   808
  shows "(\<Union>i\<in>I. N i) = (\<Union>i. N (from_nat_into I i))"
hoelzl@47694
   809
proof -
hoelzl@57275
   810
  have "(\<Union>i\<in>I. N i) = \<Union>(N ` range (from_nat_into I))"
hoelzl@57275
   811
    using I by simp
hoelzl@57275
   812
  also have "\<dots> = (\<Union>i. (N \<circ> from_nat_into I) i)"
haftmann@56154
   813
    by (simp only: SUP_def image_comp)
hoelzl@57275
   814
  finally show ?thesis by simp
hoelzl@57275
   815
qed
hoelzl@57275
   816
hoelzl@57275
   817
lemma null_sets_UN':
hoelzl@57275
   818
  assumes "countable I"
hoelzl@57275
   819
  assumes "\<And>i. i \<in> I \<Longrightarrow> N i \<in> null_sets M"
hoelzl@57275
   820
  shows "(\<Union>i\<in>I. N i) \<in> null_sets M"
hoelzl@57275
   821
proof cases
hoelzl@57275
   822
  assume "I = {}" then show ?thesis by simp
hoelzl@57275
   823
next
hoelzl@57275
   824
  assume "I \<noteq> {}"
hoelzl@57275
   825
  show ?thesis
hoelzl@57275
   826
  proof (intro conjI CollectI null_setsI)
hoelzl@57275
   827
    show "(\<Union>i\<in>I. N i) \<in> sets M"
hoelzl@57275
   828
      using assms by (intro sets.countable_UN') auto
hoelzl@57275
   829
    have "emeasure M (\<Union>i\<in>I. N i) \<le> (\<Sum>n. emeasure M (N (from_nat_into I n)))"
hoelzl@57275
   830
      unfolding UN_from_nat_into[OF `countable I` `I \<noteq> {}`]
hoelzl@57275
   831
      using assms `I \<noteq> {}` by (intro emeasure_subadditive_countably) (auto intro: from_nat_into)
hoelzl@57275
   832
    also have "(\<lambda>n. emeasure M (N (from_nat_into I n))) = (\<lambda>_. 0)"
hoelzl@57275
   833
      using assms `I \<noteq> {}` by (auto intro: from_nat_into)
hoelzl@57275
   834
    finally show "emeasure M (\<Union>i\<in>I. N i) = 0"
hoelzl@57275
   835
      by (intro antisym emeasure_nonneg) simp
hoelzl@57275
   836
  qed
hoelzl@47694
   837
qed
hoelzl@47694
   838
hoelzl@47694
   839
lemma null_sets_UN[intro]:
hoelzl@57275
   840
  "(\<And>i::'i::countable. N i \<in> null_sets M) \<Longrightarrow> (\<Union>i. N i) \<in> null_sets M"
hoelzl@57275
   841
  by (rule null_sets_UN') auto
hoelzl@47694
   842
hoelzl@47694
   843
lemma null_set_Int1:
hoelzl@47694
   844
  assumes "B \<in> null_sets M" "A \<in> sets M" shows "A \<inter> B \<in> null_sets M"
hoelzl@47694
   845
proof (intro CollectI conjI null_setsI)
hoelzl@47694
   846
  show "emeasure M (A \<inter> B) = 0" using assms
hoelzl@47694
   847
    by (intro emeasure_eq_0[of B _ "A \<inter> B"]) auto
hoelzl@47694
   848
qed (insert assms, auto)
hoelzl@47694
   849
hoelzl@47694
   850
lemma null_set_Int2:
hoelzl@47694
   851
  assumes "B \<in> null_sets M" "A \<in> sets M" shows "B \<inter> A \<in> null_sets M"
hoelzl@47694
   852
  using assms by (subst Int_commute) (rule null_set_Int1)
hoelzl@47694
   853
hoelzl@47694
   854
lemma emeasure_Diff_null_set:
hoelzl@47694
   855
  assumes "B \<in> null_sets M" "A \<in> sets M"
hoelzl@47694
   856
  shows "emeasure M (A - B) = emeasure M A"
hoelzl@47694
   857
proof -
hoelzl@47694
   858
  have *: "A - B = (A - (A \<inter> B))" by auto
hoelzl@47694
   859
  have "A \<inter> B \<in> null_sets M" using assms by (rule null_set_Int1)
hoelzl@47694
   860
  then show ?thesis
hoelzl@47694
   861
    unfolding * using assms
hoelzl@47694
   862
    by (subst emeasure_Diff) auto
hoelzl@47694
   863
qed
hoelzl@47694
   864
hoelzl@47694
   865
lemma null_set_Diff:
hoelzl@47694
   866
  assumes "B \<in> null_sets M" "A \<in> sets M" shows "B - A \<in> null_sets M"
hoelzl@47694
   867
proof (intro CollectI conjI null_setsI)
hoelzl@47694
   868
  show "emeasure M (B - A) = 0" using assms by (intro emeasure_eq_0[of B _ "B - A"]) auto
hoelzl@47694
   869
qed (insert assms, auto)
hoelzl@47694
   870
hoelzl@47694
   871
lemma emeasure_Un_null_set:
hoelzl@47694
   872
  assumes "A \<in> sets M" "B \<in> null_sets M"
hoelzl@47694
   873
  shows "emeasure M (A \<union> B) = emeasure M A"
hoelzl@47694
   874
proof -
hoelzl@47694
   875
  have *: "A \<union> B = A \<union> (B - A)" by auto
hoelzl@47694
   876
  have "B - A \<in> null_sets M" using assms(2,1) by (rule null_set_Diff)
hoelzl@47694
   877
  then show ?thesis
hoelzl@47694
   878
    unfolding * using assms
hoelzl@47694
   879
    by (subst plus_emeasure[symmetric]) auto
hoelzl@47694
   880
qed
hoelzl@47694
   881
hoelzl@56994
   882
subsection {* The almost everywhere filter (i.e.\ quantifier) *}
hoelzl@47694
   883
hoelzl@47694
   884
definition ae_filter :: "'a measure \<Rightarrow> 'a filter" where
hoelzl@57276
   885
  "ae_filter M = (INF N:null_sets M. principal (space M - N))"
hoelzl@47694
   886
hoelzl@57276
   887
abbreviation almost_everywhere :: "'a measure \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where
hoelzl@47694
   888
  "almost_everywhere M P \<equiv> eventually P (ae_filter M)"
hoelzl@47694
   889
hoelzl@47694
   890
syntax
hoelzl@47694
   891
  "_almost_everywhere" :: "pttrn \<Rightarrow> 'a \<Rightarrow> bool \<Rightarrow> bool" ("AE _ in _. _" [0,0,10] 10)
hoelzl@47694
   892
hoelzl@47694
   893
translations
hoelzl@57276
   894
  "AE x in M. P" == "CONST almost_everywhere M (\<lambda>x. P)"
hoelzl@47694
   895
hoelzl@57276
   896
lemma eventually_ae_filter: "eventually P (ae_filter M) \<longleftrightarrow> (\<exists>N\<in>null_sets M. {x \<in> space M. \<not> P x} \<subseteq> N)"
hoelzl@57276
   897
  unfolding ae_filter_def by (subst eventually_INF_base) (auto simp: eventually_principal subset_eq)
hoelzl@47694
   898
hoelzl@47694
   899
lemma AE_I':
hoelzl@47694
   900
  "N \<in> null_sets M \<Longrightarrow> {x\<in>space M. \<not> P x} \<subseteq> N \<Longrightarrow> (AE x in M. P x)"
hoelzl@47694
   901
  unfolding eventually_ae_filter by auto
hoelzl@47694
   902
hoelzl@47694
   903
lemma AE_iff_null:
hoelzl@47694
   904
  assumes "{x\<in>space M. \<not> P x} \<in> sets M" (is "?P \<in> sets M")
hoelzl@47694
   905
  shows "(AE x in M. P x) \<longleftrightarrow> {x\<in>space M. \<not> P x} \<in> null_sets M"
hoelzl@47694
   906
proof
hoelzl@47694
   907
  assume "AE x in M. P x" then obtain N where N: "N \<in> sets M" "?P \<subseteq> N" "emeasure M N = 0"
hoelzl@47694
   908
    unfolding eventually_ae_filter by auto
hoelzl@47694
   909
  have "0 \<le> emeasure M ?P" by auto
hoelzl@47694
   910
  moreover have "emeasure M ?P \<le> emeasure M N"
hoelzl@47694
   911
    using assms N(1,2) by (auto intro: emeasure_mono)
hoelzl@47694
   912
  ultimately have "emeasure M ?P = 0" unfolding `emeasure M N = 0` by auto
hoelzl@47694
   913
  then show "?P \<in> null_sets M" using assms by auto
hoelzl@47694
   914
next
hoelzl@47694
   915
  assume "?P \<in> null_sets M" with assms show "AE x in M. P x" by (auto intro: AE_I')
hoelzl@47694
   916
qed
hoelzl@47694
   917
hoelzl@47694
   918
lemma AE_iff_null_sets:
hoelzl@47694
   919
  "N \<in> sets M \<Longrightarrow> N \<in> null_sets M \<longleftrightarrow> (AE x in M. x \<notin> N)"
immler@50244
   920
  using Int_absorb1[OF sets.sets_into_space, of N M]
hoelzl@47694
   921
  by (subst AE_iff_null) (auto simp: Int_def[symmetric])
hoelzl@47694
   922
hoelzl@47761
   923
lemma AE_not_in:
hoelzl@47761
   924
  "N \<in> null_sets M \<Longrightarrow> AE x in M. x \<notin> N"
hoelzl@47761
   925
  by (metis AE_iff_null_sets null_setsD2)
hoelzl@47761
   926
hoelzl@47694
   927
lemma AE_iff_measurable:
hoelzl@47694
   928
  "N \<in> sets M \<Longrightarrow> {x\<in>space M. \<not> P x} = N \<Longrightarrow> (AE x in M. P x) \<longleftrightarrow> emeasure M N = 0"
hoelzl@47694
   929
  using AE_iff_null[of _ P] by auto
hoelzl@47694
   930
hoelzl@47694
   931
lemma AE_E[consumes 1]:
hoelzl@47694
   932
  assumes "AE x in M. P x"
hoelzl@47694
   933
  obtains N where "{x \<in> space M. \<not> P x} \<subseteq> N" "emeasure M N = 0" "N \<in> sets M"
hoelzl@47694
   934
  using assms unfolding eventually_ae_filter by auto
hoelzl@47694
   935
hoelzl@47694
   936
lemma AE_E2:
hoelzl@47694
   937
  assumes "AE x in M. P x" "{x\<in>space M. P x} \<in> sets M"
hoelzl@47694
   938
  shows "emeasure M {x\<in>space M. \<not> P x} = 0" (is "emeasure M ?P = 0")
hoelzl@47694
   939
proof -
hoelzl@47694
   940
  have "{x\<in>space M. \<not> P x} = space M - {x\<in>space M. P x}" by auto
hoelzl@47694
   941
  with AE_iff_null[of M P] assms show ?thesis by auto
hoelzl@47694
   942
qed
hoelzl@47694
   943
hoelzl@47694
   944
lemma AE_I:
hoelzl@47694
   945
  assumes "{x \<in> space M. \<not> P x} \<subseteq> N" "emeasure M N = 0" "N \<in> sets M"
hoelzl@47694
   946
  shows "AE x in M. P x"
hoelzl@47694
   947
  using assms unfolding eventually_ae_filter by auto
hoelzl@47694
   948
hoelzl@47694
   949
lemma AE_mp[elim!]:
hoelzl@47694
   950
  assumes AE_P: "AE x in M. P x" and AE_imp: "AE x in M. P x \<longrightarrow> Q x"
hoelzl@47694
   951
  shows "AE x in M. Q x"
hoelzl@47694
   952
proof -
hoelzl@47694
   953
  from AE_P obtain A where P: "{x\<in>space M. \<not> P x} \<subseteq> A"
hoelzl@47694
   954
    and A: "A \<in> sets M" "emeasure M A = 0"
hoelzl@47694
   955
    by (auto elim!: AE_E)
hoelzl@47694
   956
hoelzl@47694
   957
  from AE_imp obtain B where imp: "{x\<in>space M. P x \<and> \<not> Q x} \<subseteq> B"
hoelzl@47694
   958
    and B: "B \<in> sets M" "emeasure M B = 0"
hoelzl@47694
   959
    by (auto elim!: AE_E)
hoelzl@47694
   960
hoelzl@47694
   961
  show ?thesis
hoelzl@47694
   962
  proof (intro AE_I)
hoelzl@47694
   963
    have "0 \<le> emeasure M (A \<union> B)" using A B by auto
hoelzl@47694
   964
    moreover have "emeasure M (A \<union> B) \<le> 0"
hoelzl@47694
   965
      using emeasure_subadditive[of A M B] A B by auto
hoelzl@47694
   966
    ultimately show "A \<union> B \<in> sets M" "emeasure M (A \<union> B) = 0" using A B by auto
hoelzl@47694
   967
    show "{x\<in>space M. \<not> Q x} \<subseteq> A \<union> B"
hoelzl@47694
   968
      using P imp by auto
hoelzl@47694
   969
  qed
hoelzl@47694
   970
qed
hoelzl@47694
   971
hoelzl@47694
   972
(* depricated replace by laws about eventually *)
hoelzl@47694
   973
lemma
hoelzl@47694
   974
  shows AE_iffI: "AE x in M. P x \<Longrightarrow> AE x in M. P x \<longleftrightarrow> Q x \<Longrightarrow> AE x in M. Q x"
hoelzl@47694
   975
    and AE_disjI1: "AE x in M. P x \<Longrightarrow> AE x in M. P x \<or> Q x"
hoelzl@47694
   976
    and AE_disjI2: "AE x in M. Q x \<Longrightarrow> AE x in M. P x \<or> Q x"
hoelzl@47694
   977
    and AE_conjI: "AE x in M. P x \<Longrightarrow> AE x in M. Q x \<Longrightarrow> AE x in M. P x \<and> Q x"
hoelzl@47694
   978
    and AE_conj_iff[simp]: "(AE x in M. P x \<and> Q x) \<longleftrightarrow> (AE x in M. P x) \<and> (AE x in M. Q x)"
hoelzl@47694
   979
  by auto
hoelzl@47694
   980
hoelzl@47694
   981
lemma AE_impI:
hoelzl@47694
   982
  "(P \<Longrightarrow> AE x in M. Q x) \<Longrightarrow> AE x in M. P \<longrightarrow> Q x"
hoelzl@47694
   983
  by (cases P) auto
hoelzl@47694
   984
hoelzl@47694
   985
lemma AE_measure:
hoelzl@47694
   986
  assumes AE: "AE x in M. P x" and sets: "{x\<in>space M. P x} \<in> sets M" (is "?P \<in> sets M")
hoelzl@47694
   987
  shows "emeasure M {x\<in>space M. P x} = emeasure M (space M)"
hoelzl@47694
   988
proof -
hoelzl@47694
   989
  from AE_E[OF AE] guess N . note N = this
hoelzl@47694
   990
  with sets have "emeasure M (space M) \<le> emeasure M (?P \<union> N)"
hoelzl@47694
   991
    by (intro emeasure_mono) auto
hoelzl@47694
   992
  also have "\<dots> \<le> emeasure M ?P + emeasure M N"
hoelzl@47694
   993
    using sets N by (intro emeasure_subadditive) auto
hoelzl@47694
   994
  also have "\<dots> = emeasure M ?P" using N by simp
hoelzl@47694
   995
  finally show "emeasure M ?P = emeasure M (space M)"
hoelzl@47694
   996
    using emeasure_space[of M "?P"] by auto
hoelzl@47694
   997
qed
hoelzl@47694
   998
hoelzl@47694
   999
lemma AE_space: "AE x in M. x \<in> space M"
hoelzl@47694
  1000
  by (rule AE_I[where N="{}"]) auto
hoelzl@47694
  1001
hoelzl@47694
  1002
lemma AE_I2[simp, intro]:
hoelzl@47694
  1003
  "(\<And>x. x \<in> space M \<Longrightarrow> P x) \<Longrightarrow> AE x in M. P x"
hoelzl@47694
  1004
  using AE_space by force
hoelzl@47694
  1005
hoelzl@47694
  1006
lemma AE_Ball_mp:
hoelzl@47694
  1007
  "\<forall>x\<in>space M. P x \<Longrightarrow> AE x in M. P x \<longrightarrow> Q x \<Longrightarrow> AE x in M. Q x"
hoelzl@47694
  1008
  by auto
hoelzl@47694
  1009
hoelzl@47694
  1010
lemma AE_cong[cong]:
hoelzl@47694
  1011
  "(\<And>x. x \<in> space M \<Longrightarrow> P x \<longleftrightarrow> Q x) \<Longrightarrow> (AE x in M. P x) \<longleftrightarrow> (AE x in M. Q x)"
hoelzl@47694
  1012
  by auto
hoelzl@47694
  1013
hoelzl@47694
  1014
lemma AE_all_countable:
hoelzl@47694
  1015
  "(AE x in M. \<forall>i. P i x) \<longleftrightarrow> (\<forall>i::'i::countable. AE x in M. P i x)"
hoelzl@47694
  1016
proof
hoelzl@47694
  1017
  assume "\<forall>i. AE x in M. P i x"
hoelzl@47694
  1018
  from this[unfolded eventually_ae_filter Bex_def, THEN choice]
hoelzl@47694
  1019
  obtain N where N: "\<And>i. N i \<in> null_sets M" "\<And>i. {x\<in>space M. \<not> P i x} \<subseteq> N i" by auto
hoelzl@47694
  1020
  have "{x\<in>space M. \<not> (\<forall>i. P i x)} \<subseteq> (\<Union>i. {x\<in>space M. \<not> P i x})" by auto
hoelzl@47694
  1021
  also have "\<dots> \<subseteq> (\<Union>i. N i)" using N by auto
hoelzl@47694
  1022
  finally have "{x\<in>space M. \<not> (\<forall>i. P i x)} \<subseteq> (\<Union>i. N i)" .
hoelzl@47694
  1023
  moreover from N have "(\<Union>i. N i) \<in> null_sets M"
hoelzl@47694
  1024
    by (intro null_sets_UN) auto
hoelzl@47694
  1025
  ultimately show "AE x in M. \<forall>i. P i x"
hoelzl@47694
  1026
    unfolding eventually_ae_filter by auto
hoelzl@47694
  1027
qed auto
hoelzl@47694
  1028
hoelzl@59000
  1029
lemma AE_ball_countable: 
hoelzl@59000
  1030
  assumes [intro]: "countable X"
hoelzl@59000
  1031
  shows "(AE x in M. \<forall>y\<in>X. P x y) \<longleftrightarrow> (\<forall>y\<in>X. AE x in M. P x y)"
hoelzl@59000
  1032
proof
hoelzl@59000
  1033
  assume "\<forall>y\<in>X. AE x in M. P x y"
hoelzl@59000
  1034
  from this[unfolded eventually_ae_filter Bex_def, THEN bchoice]
hoelzl@59000
  1035
  obtain N where N: "\<And>y. y \<in> X \<Longrightarrow> N y \<in> null_sets M" "\<And>y. y \<in> X \<Longrightarrow> {x\<in>space M. \<not> P x y} \<subseteq> N y"
hoelzl@59000
  1036
    by auto
hoelzl@59000
  1037
  have "{x\<in>space M. \<not> (\<forall>y\<in>X. P x y)} \<subseteq> (\<Union>y\<in>X. {x\<in>space M. \<not> P x y})"
hoelzl@59000
  1038
    by auto
hoelzl@59000
  1039
  also have "\<dots> \<subseteq> (\<Union>y\<in>X. N y)"
hoelzl@59000
  1040
    using N by auto
hoelzl@59000
  1041
  finally have "{x\<in>space M. \<not> (\<forall>y\<in>X. P x y)} \<subseteq> (\<Union>y\<in>X. N y)" .
hoelzl@59000
  1042
  moreover from N have "(\<Union>y\<in>X. N y) \<in> null_sets M"
hoelzl@59000
  1043
    by (intro null_sets_UN') auto
hoelzl@59000
  1044
  ultimately show "AE x in M. \<forall>y\<in>X. P x y"
hoelzl@59000
  1045
    unfolding eventually_ae_filter by auto
hoelzl@59000
  1046
qed auto
hoelzl@59000
  1047
hoelzl@57275
  1048
lemma AE_discrete_difference:
hoelzl@57275
  1049
  assumes X: "countable X"
hoelzl@57275
  1050
  assumes null: "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" 
hoelzl@57275
  1051
  assumes sets: "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
hoelzl@57275
  1052
  shows "AE x in M. x \<notin> X"
hoelzl@57275
  1053
proof -
hoelzl@57275
  1054
  have "(\<Union>x\<in>X. {x}) \<in> null_sets M"
hoelzl@57275
  1055
    using assms by (intro null_sets_UN') auto
hoelzl@57275
  1056
  from AE_not_in[OF this] show "AE x in M. x \<notin> X"
hoelzl@57275
  1057
    by auto
hoelzl@57275
  1058
qed
hoelzl@57275
  1059
hoelzl@47694
  1060
lemma AE_finite_all:
hoelzl@47694
  1061
  assumes f: "finite S" shows "(AE x in M. \<forall>i\<in>S. P i x) \<longleftrightarrow> (\<forall>i\<in>S. AE x in M. P i x)"
hoelzl@47694
  1062
  using f by induct auto
hoelzl@47694
  1063
hoelzl@47694
  1064
lemma AE_finite_allI:
hoelzl@47694
  1065
  assumes "finite S"
hoelzl@47694
  1066
  shows "(\<And>s. s \<in> S \<Longrightarrow> AE x in M. Q s x) \<Longrightarrow> AE x in M. \<forall>s\<in>S. Q s x"
hoelzl@47694
  1067
  using AE_finite_all[OF `finite S`] by auto
hoelzl@47694
  1068
hoelzl@47694
  1069
lemma emeasure_mono_AE:
hoelzl@47694
  1070
  assumes imp: "AE x in M. x \<in> A \<longrightarrow> x \<in> B"
hoelzl@47694
  1071
    and B: "B \<in> sets M"
hoelzl@47694
  1072
  shows "emeasure M A \<le> emeasure M B"
hoelzl@47694
  1073
proof cases
hoelzl@47694
  1074
  assume A: "A \<in> sets M"
hoelzl@47694
  1075
  from imp obtain N where N: "{x\<in>space M. \<not> (x \<in> A \<longrightarrow> x \<in> B)} \<subseteq> N" "N \<in> null_sets M"
hoelzl@47694
  1076
    by (auto simp: eventually_ae_filter)
hoelzl@47694
  1077
  have "emeasure M A = emeasure M (A - N)"
hoelzl@47694
  1078
    using N A by (subst emeasure_Diff_null_set) auto
hoelzl@47694
  1079
  also have "emeasure M (A - N) \<le> emeasure M (B - N)"
immler@50244
  1080
    using N A B sets.sets_into_space by (auto intro!: emeasure_mono)
hoelzl@47694
  1081
  also have "emeasure M (B - N) = emeasure M B"
hoelzl@47694
  1082
    using N B by (subst emeasure_Diff_null_set) auto
hoelzl@47694
  1083
  finally show ?thesis .
hoelzl@47694
  1084
qed (simp add: emeasure_nonneg emeasure_notin_sets)
hoelzl@47694
  1085
hoelzl@47694
  1086
lemma emeasure_eq_AE:
hoelzl@47694
  1087
  assumes iff: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@47694
  1088
  assumes A: "A \<in> sets M" and B: "B \<in> sets M"
hoelzl@47694
  1089
  shows "emeasure M A = emeasure M B"
hoelzl@47694
  1090
  using assms by (safe intro!: antisym emeasure_mono_AE) auto
hoelzl@47694
  1091
hoelzl@59000
  1092
lemma emeasure_Collect_eq_AE:
hoelzl@59000
  1093
  "AE x in M. P x \<longleftrightarrow> Q x \<Longrightarrow> Measurable.pred M Q \<Longrightarrow> Measurable.pred M P \<Longrightarrow>
hoelzl@59000
  1094
   emeasure M {x\<in>space M. P x} = emeasure M {x\<in>space M. Q x}"
hoelzl@59000
  1095
   by (intro emeasure_eq_AE) auto
hoelzl@59000
  1096
hoelzl@59000
  1097
lemma emeasure_eq_0_AE: "AE x in M. \<not> P x \<Longrightarrow> emeasure M {x\<in>space M. P x} = 0"
hoelzl@59000
  1098
  using AE_iff_measurable[OF _ refl, of M "\<lambda>x. \<not> P x"]
hoelzl@59000
  1099
  by (cases "{x\<in>space M. P x} \<in> sets M") (simp_all add: emeasure_notin_sets)
hoelzl@59000
  1100
hoelzl@56994
  1101
subsection {* @{text \<sigma>}-finite Measures *}
hoelzl@47694
  1102
hoelzl@47694
  1103
locale sigma_finite_measure =
hoelzl@47694
  1104
  fixes M :: "'a measure"
hoelzl@57447
  1105
  assumes sigma_finite_countable:
hoelzl@57447
  1106
    "\<exists>A::'a set set. countable A \<and> A \<subseteq> sets M \<and> (\<Union>A) = space M \<and> (\<forall>a\<in>A. emeasure M a \<noteq> \<infinity>)"
hoelzl@57447
  1107
hoelzl@57447
  1108
lemma (in sigma_finite_measure) sigma_finite:
hoelzl@57447
  1109
  obtains A :: "nat \<Rightarrow> 'a set"
hoelzl@57447
  1110
  where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@57447
  1111
proof -
hoelzl@57447
  1112
  obtain A :: "'a set set" where
hoelzl@57447
  1113
    [simp]: "countable A" and
hoelzl@57447
  1114
    A: "A \<subseteq> sets M" "(\<Union>A) = space M" "\<And>a. a \<in> A \<Longrightarrow> emeasure M a \<noteq> \<infinity>"
hoelzl@57447
  1115
    using sigma_finite_countable by metis
hoelzl@57447
  1116
  show thesis
hoelzl@57447
  1117
  proof cases
hoelzl@57447
  1118
    assume "A = {}" with `(\<Union>A) = space M` show thesis
hoelzl@57447
  1119
      by (intro that[of "\<lambda>_. {}"]) auto
hoelzl@57447
  1120
  next
hoelzl@57447
  1121
    assume "A \<noteq> {}" 
hoelzl@57447
  1122
    show thesis
hoelzl@57447
  1123
    proof
hoelzl@57447
  1124
      show "range (from_nat_into A) \<subseteq> sets M"
hoelzl@57447
  1125
        using `A \<noteq> {}` A by auto
hoelzl@57447
  1126
      have "(\<Union>i. from_nat_into A i) = \<Union>A"
hoelzl@57447
  1127
        using range_from_nat_into[OF `A \<noteq> {}` `countable A`] by auto
hoelzl@57447
  1128
      with A show "(\<Union>i. from_nat_into A i) = space M"
hoelzl@57447
  1129
        by auto
hoelzl@57447
  1130
    qed (intro A from_nat_into `A \<noteq> {}`)
hoelzl@57447
  1131
  qed
hoelzl@57447
  1132
qed
hoelzl@47694
  1133
hoelzl@47694
  1134
lemma (in sigma_finite_measure) sigma_finite_disjoint:
hoelzl@47694
  1135
  obtains A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
  1136
  where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>" "disjoint_family A"
hoelzl@47694
  1137
proof atomize_elim
hoelzl@47694
  1138
  case goal1
hoelzl@47694
  1139
  obtain A :: "nat \<Rightarrow> 'a set" where
hoelzl@47694
  1140
    range: "range A \<subseteq> sets M" and
hoelzl@47694
  1141
    space: "(\<Union>i. A i) = space M" and
hoelzl@47694
  1142
    measure: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
  1143
    using sigma_finite by auto
immler@50244
  1144
  note range' = sets.range_disjointed_sets[OF range] range
hoelzl@47694
  1145
  { fix i
hoelzl@47694
  1146
    have "emeasure M (disjointed A i) \<le> emeasure M (A i)"
hoelzl@47694
  1147
      using range' disjointed_subset[of A i] by (auto intro!: emeasure_mono)
hoelzl@47694
  1148
    then have "emeasure M (disjointed A i) \<noteq> \<infinity>"
hoelzl@47694
  1149
      using measure[of i] by auto }
hoelzl@47694
  1150
  with disjoint_family_disjointed UN_disjointed_eq[of A] space range'
hoelzl@47694
  1151
  show ?case by (auto intro!: exI[of _ "disjointed A"])
hoelzl@47694
  1152
qed
hoelzl@47694
  1153
hoelzl@47694
  1154
lemma (in sigma_finite_measure) sigma_finite_incseq:
hoelzl@47694
  1155
  obtains A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
  1156
  where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>" "incseq A"
hoelzl@47694
  1157
proof atomize_elim
hoelzl@47694
  1158
  case goal1
hoelzl@47694
  1159
  obtain F :: "nat \<Rightarrow> 'a set" where
hoelzl@47694
  1160
    F: "range F \<subseteq> sets M" "(\<Union>i. F i) = space M" "\<And>i. emeasure M (F i) \<noteq> \<infinity>"
hoelzl@47694
  1161
    using sigma_finite by auto
hoelzl@47694
  1162
  then show ?case
hoelzl@47694
  1163
  proof (intro exI[of _ "\<lambda>n. \<Union>i\<le>n. F i"] conjI allI)
hoelzl@47694
  1164
    from F have "\<And>x. x \<in> space M \<Longrightarrow> \<exists>i. x \<in> F i" by auto
hoelzl@47694
  1165
    then show "(\<Union>n. \<Union> i\<le>n. F i) = space M"
hoelzl@47694
  1166
      using F by fastforce
hoelzl@47694
  1167
  next
hoelzl@47694
  1168
    fix n
hoelzl@47694
  1169
    have "emeasure M (\<Union> i\<le>n. F i) \<le> (\<Sum>i\<le>n. emeasure M (F i))" using F
hoelzl@47694
  1170
      by (auto intro!: emeasure_subadditive_finite)
hoelzl@47694
  1171
    also have "\<dots> < \<infinity>"
hoelzl@47694
  1172
      using F by (auto simp: setsum_Pinfty)
hoelzl@47694
  1173
    finally show "emeasure M (\<Union> i\<le>n. F i) \<noteq> \<infinity>" by simp
hoelzl@47694
  1174
  qed (force simp: incseq_def)+
hoelzl@47694
  1175
qed
hoelzl@47694
  1176
hoelzl@56994
  1177
subsection {* Measure space induced by distribution of @{const measurable}-functions *}
hoelzl@47694
  1178
hoelzl@47694
  1179
definition distr :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure" where
hoelzl@47694
  1180
  "distr M N f = measure_of (space N) (sets N) (\<lambda>A. emeasure M (f -` A \<inter> space M))"
hoelzl@47694
  1181
hoelzl@47694
  1182
lemma
hoelzl@59048
  1183
  shows sets_distr[simp, measurable_cong]: "sets (distr M N f) = sets N"
hoelzl@47694
  1184
    and space_distr[simp]: "space (distr M N f) = space N"
hoelzl@47694
  1185
  by (auto simp: distr_def)
hoelzl@47694
  1186
hoelzl@47694
  1187
lemma
hoelzl@47694
  1188
  shows measurable_distr_eq1[simp]: "measurable (distr Mf Nf f) Mf' = measurable Nf Mf'"
hoelzl@47694
  1189
    and measurable_distr_eq2[simp]: "measurable Mg' (distr Mg Ng g) = measurable Mg' Ng"
hoelzl@47694
  1190
  by (auto simp: measurable_def)
hoelzl@47694
  1191
hoelzl@54417
  1192
lemma distr_cong:
hoelzl@54417
  1193
  "M = K \<Longrightarrow> sets N = sets L \<Longrightarrow> (\<And>x. x \<in> space M \<Longrightarrow> f x = g x) \<Longrightarrow> distr M N f = distr K L g"
hoelzl@54417
  1194
  using sets_eq_imp_space_eq[of N L] by (simp add: distr_def Int_def cong: rev_conj_cong)
hoelzl@54417
  1195
hoelzl@47694
  1196
lemma emeasure_distr:
hoelzl@47694
  1197
  fixes f :: "'a \<Rightarrow> 'b"
hoelzl@47694
  1198
  assumes f: "f \<in> measurable M N" and A: "A \<in> sets N"
hoelzl@47694
  1199
  shows "emeasure (distr M N f) A = emeasure M (f -` A \<inter> space M)" (is "_ = ?\<mu> A")
hoelzl@47694
  1200
  unfolding distr_def
hoelzl@47694
  1201
proof (rule emeasure_measure_of_sigma)
hoelzl@47694
  1202
  show "positive (sets N) ?\<mu>"
hoelzl@47694
  1203
    by (auto simp: positive_def)
hoelzl@47694
  1204
hoelzl@47694
  1205
  show "countably_additive (sets N) ?\<mu>"
hoelzl@47694
  1206
  proof (intro countably_additiveI)
hoelzl@47694
  1207
    fix A :: "nat \<Rightarrow> 'b set" assume "range A \<subseteq> sets N" "disjoint_family A"
hoelzl@47694
  1208
    then have A: "\<And>i. A i \<in> sets N" "(\<Union>i. A i) \<in> sets N" by auto
hoelzl@47694
  1209
    then have *: "range (\<lambda>i. f -` (A i) \<inter> space M) \<subseteq> sets M"
hoelzl@47694
  1210
      using f by (auto simp: measurable_def)
hoelzl@47694
  1211
    moreover have "(\<Union>i. f -`  A i \<inter> space M) \<in> sets M"
hoelzl@47694
  1212
      using * by blast
hoelzl@47694
  1213
    moreover have **: "disjoint_family (\<lambda>i. f -` A i \<inter> space M)"
hoelzl@47694
  1214
      using `disjoint_family A` by (auto simp: disjoint_family_on_def)
hoelzl@47694
  1215
    ultimately show "(\<Sum>i. ?\<mu> (A i)) = ?\<mu> (\<Union>i. A i)"
hoelzl@47694
  1216
      using suminf_emeasure[OF _ **] A f
hoelzl@47694
  1217
      by (auto simp: comp_def vimage_UN)
hoelzl@47694
  1218
  qed
hoelzl@47694
  1219
  show "sigma_algebra (space N) (sets N)" ..
hoelzl@47694
  1220
qed fact
hoelzl@47694
  1221
hoelzl@59000
  1222
lemma emeasure_Collect_distr:
hoelzl@59000
  1223
  assumes X[measurable]: "X \<in> measurable M N" "Measurable.pred N P"
hoelzl@59000
  1224
  shows "emeasure (distr M N X) {x\<in>space N. P x} = emeasure M {x\<in>space M. P (X x)}"
hoelzl@59000
  1225
  by (subst emeasure_distr)
hoelzl@59000
  1226
     (auto intro!: arg_cong2[where f=emeasure] X(1)[THEN measurable_space])
hoelzl@59000
  1227
hoelzl@59000
  1228
lemma emeasure_lfp2[consumes 1, case_names cont f measurable]:
hoelzl@59000
  1229
  assumes "P M"
hoelzl@60172
  1230
  assumes cont: "sup_continuous F"
hoelzl@59000
  1231
  assumes f: "\<And>M. P M \<Longrightarrow> f \<in> measurable M' M"
hoelzl@59000
  1232
  assumes *: "\<And>M A. P M \<Longrightarrow> (\<And>N. P N \<Longrightarrow> Measurable.pred N A) \<Longrightarrow> Measurable.pred M (F A)"
hoelzl@59000
  1233
  shows "emeasure M' {x\<in>space M'. lfp F (f x)} = (SUP i. emeasure M' {x\<in>space M'. (F ^^ i) (\<lambda>x. False) (f x)})"
hoelzl@59000
  1234
proof (subst (1 2) emeasure_Collect_distr[symmetric, where X=f])
hoelzl@59000
  1235
  show "f \<in> measurable M' M"  "f \<in> measurable M' M"
hoelzl@59000
  1236
    using f[OF `P M`] by auto
hoelzl@59000
  1237
  { fix i show "Measurable.pred M ((F ^^ i) (\<lambda>x. False))"
hoelzl@59000
  1238
    using `P M` by (induction i arbitrary: M) (auto intro!: *) }
hoelzl@59000
  1239
  show "Measurable.pred M (lfp F)"
hoelzl@59000
  1240
    using `P M` cont * by (rule measurable_lfp_coinduct[of P])
hoelzl@59000
  1241
hoelzl@59000
  1242
  have "emeasure (distr M' M f) {x \<in> space (distr M' M f). lfp F x} =
hoelzl@59000
  1243
    (SUP i. emeasure (distr M' M f) {x \<in> space (distr M' M f). (F ^^ i) (\<lambda>x. False) x})"
hoelzl@59000
  1244
    using `P M`
hoelzl@59000
  1245
  proof (coinduction arbitrary: M rule: emeasure_lfp)
hoelzl@59000
  1246
    case (measurable A N) then have "\<And>N. P N \<Longrightarrow> Measurable.pred (distr M' N f) A"
hoelzl@59000
  1247
      by metis
hoelzl@59000
  1248
    then have "\<And>N. P N \<Longrightarrow> Measurable.pred N A"
hoelzl@59000
  1249
      by simp
hoelzl@59000
  1250
    with `P N`[THEN *] show ?case
hoelzl@59000
  1251
      by auto
hoelzl@59000
  1252
  qed fact
hoelzl@59000
  1253
  then show "emeasure (distr M' M f) {x \<in> space M. lfp F x} =
hoelzl@59000
  1254
    (SUP i. emeasure (distr M' M f) {x \<in> space M. (F ^^ i) (\<lambda>x. False) x})"
hoelzl@59000
  1255
   by simp
hoelzl@59000
  1256
qed
hoelzl@59000
  1257
hoelzl@50104
  1258
lemma distr_id[simp]: "distr N N (\<lambda>x. x) = N"
hoelzl@50104
  1259
  by (rule measure_eqI) (auto simp: emeasure_distr)
hoelzl@50104
  1260
hoelzl@50001
  1261
lemma measure_distr:
hoelzl@50001
  1262
  "f \<in> measurable M N \<Longrightarrow> S \<in> sets N \<Longrightarrow> measure (distr M N f) S = measure M (f -` S \<inter> space M)"
hoelzl@50001
  1263
  by (simp add: emeasure_distr measure_def)
hoelzl@50001
  1264
hoelzl@57447
  1265
lemma distr_cong_AE:
hoelzl@57447
  1266
  assumes 1: "M = K" "sets N = sets L" and 
hoelzl@57447
  1267
    2: "(AE x in M. f x = g x)" and "f \<in> measurable M N" and "g \<in> measurable K L"
hoelzl@57447
  1268
  shows "distr M N f = distr K L g"
hoelzl@57447
  1269
proof (rule measure_eqI)
hoelzl@57447
  1270
  fix A assume "A \<in> sets (distr M N f)"
hoelzl@57447
  1271
  with assms show "emeasure (distr M N f) A = emeasure (distr K L g) A"
hoelzl@57447
  1272
    by (auto simp add: emeasure_distr intro!: emeasure_eq_AE measurable_sets)
hoelzl@57447
  1273
qed (insert 1, simp)
hoelzl@57447
  1274
hoelzl@47694
  1275
lemma AE_distrD:
hoelzl@47694
  1276
  assumes f: "f \<in> measurable M M'"
hoelzl@47694
  1277
    and AE: "AE x in distr M M' f. P x"
hoelzl@47694
  1278
  shows "AE x in M. P (f x)"
hoelzl@47694
  1279
proof -
hoelzl@47694
  1280
  from AE[THEN AE_E] guess N .
hoelzl@47694
  1281
  with f show ?thesis
hoelzl@47694
  1282
    unfolding eventually_ae_filter
hoelzl@47694
  1283
    by (intro bexI[of _ "f -` N \<inter> space M"])
hoelzl@47694
  1284
       (auto simp: emeasure_distr measurable_def)
hoelzl@47694
  1285
qed
hoelzl@47694
  1286
hoelzl@49773
  1287
lemma AE_distr_iff:
hoelzl@50002
  1288
  assumes f[measurable]: "f \<in> measurable M N" and P[measurable]: "{x \<in> space N. P x} \<in> sets N"
hoelzl@49773
  1289
  shows "(AE x in distr M N f. P x) \<longleftrightarrow> (AE x in M. P (f x))"
hoelzl@49773
  1290
proof (subst (1 2) AE_iff_measurable[OF _ refl])
hoelzl@50002
  1291
  have "f -` {x\<in>space N. \<not> P x} \<inter> space M = {x \<in> space M. \<not> P (f x)}"
hoelzl@50002
  1292
    using f[THEN measurable_space] by auto
hoelzl@50002
  1293
  then show "(emeasure (distr M N f) {x \<in> space (distr M N f). \<not> P x} = 0) =
hoelzl@49773
  1294
    (emeasure M {x \<in> space M. \<not> P (f x)} = 0)"
hoelzl@50002
  1295
    by (simp add: emeasure_distr)
hoelzl@50002
  1296
qed auto
hoelzl@49773
  1297
hoelzl@47694
  1298
lemma null_sets_distr_iff:
hoelzl@47694
  1299
  "f \<in> measurable M N \<Longrightarrow> A \<in> null_sets (distr M N f) \<longleftrightarrow> f -` A \<inter> space M \<in> null_sets M \<and> A \<in> sets N"
hoelzl@50002
  1300
  by (auto simp add: null_sets_def emeasure_distr)
hoelzl@47694
  1301
hoelzl@47694
  1302
lemma distr_distr:
hoelzl@50002
  1303
  "g \<in> measurable N L \<Longrightarrow> f \<in> measurable M N \<Longrightarrow> distr (distr M N f) L g = distr M L (g \<circ> f)"
hoelzl@50002
  1304
  by (auto simp add: emeasure_distr measurable_space
hoelzl@47694
  1305
           intro!: arg_cong[where f="emeasure M"] measure_eqI)
hoelzl@47694
  1306
hoelzl@56994
  1307
subsection {* Real measure values *}
hoelzl@47694
  1308
hoelzl@47694
  1309
lemma measure_nonneg: "0 \<le> measure M A"
hoelzl@47694
  1310
  using emeasure_nonneg[of M A] unfolding measure_def by (auto intro: real_of_ereal_pos)
hoelzl@47694
  1311
hoelzl@59000
  1312
lemma measure_le_0_iff: "measure M X \<le> 0 \<longleftrightarrow> measure M X = 0"
hoelzl@59000
  1313
  using measure_nonneg[of M X] by auto
hoelzl@59000
  1314
hoelzl@47694
  1315
lemma measure_empty[simp]: "measure M {} = 0"
hoelzl@47694
  1316
  unfolding measure_def by simp
hoelzl@47694
  1317
hoelzl@47694
  1318
lemma emeasure_eq_ereal_measure:
hoelzl@47694
  1319
  "emeasure M A \<noteq> \<infinity> \<Longrightarrow> emeasure M A = ereal (measure M A)"
hoelzl@47694
  1320
  using emeasure_nonneg[of M A]
hoelzl@47694
  1321
  by (cases "emeasure M A") (auto simp: measure_def)
hoelzl@47694
  1322
hoelzl@47694
  1323
lemma measure_Union:
hoelzl@47694
  1324
  assumes finite: "emeasure M A \<noteq> \<infinity>" "emeasure M B \<noteq> \<infinity>"
hoelzl@47694
  1325
  and measurable: "A \<in> sets M" "B \<in> sets M" "A \<inter> B = {}"
hoelzl@47694
  1326
  shows "measure M (A \<union> B) = measure M A + measure M B"
hoelzl@47694
  1327
  unfolding measure_def
hoelzl@47694
  1328
  using plus_emeasure[OF measurable, symmetric] finite
hoelzl@47694
  1329
  by (simp add: emeasure_eq_ereal_measure)
hoelzl@47694
  1330
hoelzl@47694
  1331
lemma measure_finite_Union:
hoelzl@47694
  1332
  assumes measurable: "A`S \<subseteq> sets M" "disjoint_family_on A S" "finite S"
hoelzl@47694
  1333
  assumes finite: "\<And>i. i \<in> S \<Longrightarrow> emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
  1334
  shows "measure M (\<Union>i\<in>S. A i) = (\<Sum>i\<in>S. measure M (A i))"
hoelzl@47694
  1335
  unfolding measure_def
hoelzl@47694
  1336
  using setsum_emeasure[OF measurable, symmetric] finite
hoelzl@47694
  1337
  by (simp add: emeasure_eq_ereal_measure)
hoelzl@47694
  1338
hoelzl@47694
  1339
lemma measure_Diff:
hoelzl@47694
  1340
  assumes finite: "emeasure M A \<noteq> \<infinity>"
hoelzl@47694
  1341
  and measurable: "A \<in> sets M" "B \<in> sets M" "B \<subseteq> A"
hoelzl@47694
  1342
  shows "measure M (A - B) = measure M A - measure M B"
hoelzl@47694
  1343
proof -
hoelzl@47694
  1344
  have "emeasure M (A - B) \<le> emeasure M A" "emeasure M B \<le> emeasure M A"
hoelzl@47694
  1345
    using measurable by (auto intro!: emeasure_mono)
hoelzl@47694
  1346
  hence "measure M ((A - B) \<union> B) = measure M (A - B) + measure M B"
hoelzl@47694
  1347
    using measurable finite by (rule_tac measure_Union) auto
hoelzl@47694
  1348
  thus ?thesis using `B \<subseteq> A` by (auto simp: Un_absorb2)
hoelzl@47694
  1349
qed
hoelzl@47694
  1350
hoelzl@47694
  1351
lemma measure_UNION:
hoelzl@47694
  1352
  assumes measurable: "range A \<subseteq> sets M" "disjoint_family A"
hoelzl@47694
  1353
  assumes finite: "emeasure M (\<Union>i. A i) \<noteq> \<infinity>"
hoelzl@47694
  1354
  shows "(\<lambda>i. measure M (A i)) sums (measure M (\<Union>i. A i))"
hoelzl@47694
  1355
proof -
hoelzl@47694
  1356
  from summable_sums[OF summable_ereal_pos, of "\<lambda>i. emeasure M (A i)"]
hoelzl@47694
  1357
       suminf_emeasure[OF measurable] emeasure_nonneg[of M]
hoelzl@47694
  1358
  have "(\<lambda>i. emeasure M (A i)) sums (emeasure M (\<Union>i. A i))" by simp
hoelzl@47694
  1359
  moreover
hoelzl@47694
  1360
  { fix i
hoelzl@47694
  1361
    have "emeasure M (A i) \<le> emeasure M (\<Union>i. A i)"
hoelzl@47694
  1362
      using measurable by (auto intro!: emeasure_mono)
hoelzl@47694
  1363
    then have "emeasure M (A i) = ereal ((measure M (A i)))"
hoelzl@47694
  1364
      using finite by (intro emeasure_eq_ereal_measure) auto }
hoelzl@47694
  1365
  ultimately show ?thesis using finite
hoelzl@47694
  1366
    unfolding sums_ereal[symmetric] by (simp add: emeasure_eq_ereal_measure)
hoelzl@47694
  1367
qed
hoelzl@47694
  1368
hoelzl@47694
  1369
lemma measure_subadditive:
hoelzl@47694
  1370
  assumes measurable: "A \<in> sets M" "B \<in> sets M"
hoelzl@47694
  1371
  and fin: "emeasure M A \<noteq> \<infinity>" "emeasure M B \<noteq> \<infinity>"
hoelzl@47694
  1372
  shows "(measure M (A \<union> B)) \<le> (measure M A) + (measure M B)"
hoelzl@47694
  1373
proof -
hoelzl@47694
  1374
  have "emeasure M (A \<union> B) \<noteq> \<infinity>"
hoelzl@47694
  1375
    using emeasure_subadditive[OF measurable] fin by auto
hoelzl@47694
  1376
  then show "(measure M (A \<union> B)) \<le> (measure M A) + (measure M B)"
hoelzl@47694
  1377
    using emeasure_subadditive[OF measurable] fin
hoelzl@47694
  1378
    by (auto simp: emeasure_eq_ereal_measure)
hoelzl@47694
  1379
qed
hoelzl@47694
  1380
hoelzl@47694
  1381
lemma measure_subadditive_finite:
hoelzl@47694
  1382
  assumes A: "finite I" "A`I \<subseteq> sets M" and fin: "\<And>i. i \<in> I \<Longrightarrow> emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
  1383
  shows "measure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. measure M (A i))"
hoelzl@47694
  1384
proof -
hoelzl@47694
  1385
  { have "emeasure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. emeasure M (A i))"
hoelzl@47694
  1386
      using emeasure_subadditive_finite[OF A] .
hoelzl@47694
  1387
    also have "\<dots> < \<infinity>"
hoelzl@47694
  1388
      using fin by (simp add: setsum_Pinfty)
hoelzl@47694
  1389
    finally have "emeasure M (\<Union>i\<in>I. A i) \<noteq> \<infinity>" by simp }
hoelzl@47694
  1390
  then show ?thesis
hoelzl@47694
  1391
    using emeasure_subadditive_finite[OF A] fin
hoelzl@47694
  1392
    unfolding measure_def by (simp add: emeasure_eq_ereal_measure suminf_ereal measure_nonneg)
hoelzl@47694
  1393
qed
hoelzl@47694
  1394
hoelzl@47694
  1395
lemma measure_subadditive_countably:
hoelzl@47694
  1396
  assumes A: "range A \<subseteq> sets M" and fin: "(\<Sum>i. emeasure M (A i)) \<noteq> \<infinity>"
hoelzl@47694
  1397
  shows "measure M (\<Union>i. A i) \<le> (\<Sum>i. measure M (A i))"
hoelzl@47694
  1398
proof -
hoelzl@47694
  1399
  from emeasure_nonneg fin have "\<And>i. emeasure M (A i) \<noteq> \<infinity>" by (rule suminf_PInfty)
hoelzl@47694
  1400
  moreover
hoelzl@47694
  1401
  { have "emeasure M (\<Union>i. A i) \<le> (\<Sum>i. emeasure M (A i))"
hoelzl@47694
  1402
      using emeasure_subadditive_countably[OF A] .
hoelzl@47694
  1403
    also have "\<dots> < \<infinity>"
hoelzl@47694
  1404
      using fin by simp
hoelzl@47694
  1405
    finally have "emeasure M (\<Union>i. A i) \<noteq> \<infinity>" by simp }
hoelzl@47694
  1406
  ultimately  show ?thesis
hoelzl@47694
  1407
    using emeasure_subadditive_countably[OF A] fin
hoelzl@47694
  1408
    unfolding measure_def by (simp add: emeasure_eq_ereal_measure suminf_ereal measure_nonneg)
hoelzl@47694
  1409
qed
hoelzl@47694
  1410
hoelzl@47694
  1411
lemma measure_eq_setsum_singleton:
hoelzl@47694
  1412
  assumes S: "finite S" "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
hoelzl@47694
  1413
  and fin: "\<And>x. x \<in> S \<Longrightarrow> emeasure M {x} \<noteq> \<infinity>"
hoelzl@47694
  1414
  shows "(measure M S) = (\<Sum>x\<in>S. (measure M {x}))"
hoelzl@47694
  1415
  unfolding measure_def
hoelzl@47694
  1416
  using emeasure_eq_setsum_singleton[OF S] fin
hoelzl@47694
  1417
  by simp (simp add: emeasure_eq_ereal_measure)
hoelzl@47694
  1418
hoelzl@47694
  1419
lemma Lim_measure_incseq:
hoelzl@47694
  1420
  assumes A: "range A \<subseteq> sets M" "incseq A" and fin: "emeasure M (\<Union>i. A i) \<noteq> \<infinity>"
hoelzl@47694
  1421
  shows "(\<lambda>i. (measure M (A i))) ----> (measure M (\<Union>i. A i))"
hoelzl@47694
  1422
proof -
hoelzl@47694
  1423
  have "ereal ((measure M (\<Union>i. A i))) = emeasure M (\<Union>i. A i)"
hoelzl@47694
  1424
    using fin by (auto simp: emeasure_eq_ereal_measure)
hoelzl@47694
  1425
  then show ?thesis
hoelzl@47694
  1426
    using Lim_emeasure_incseq[OF A]
hoelzl@47694
  1427
    unfolding measure_def
hoelzl@47694
  1428
    by (intro lim_real_of_ereal) simp
hoelzl@47694
  1429
qed
hoelzl@47694
  1430
hoelzl@47694
  1431
lemma Lim_measure_decseq:
hoelzl@47694
  1432
  assumes A: "range A \<subseteq> sets M" "decseq A" and fin: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
  1433
  shows "(\<lambda>n. measure M (A n)) ----> measure M (\<Inter>i. A i)"
hoelzl@47694
  1434
proof -
hoelzl@47694
  1435
  have "emeasure M (\<Inter>i. A i) \<le> emeasure M (A 0)"
hoelzl@47694
  1436
    using A by (auto intro!: emeasure_mono)
hoelzl@47694
  1437
  also have "\<dots> < \<infinity>"
hoelzl@47694
  1438
    using fin[of 0] by auto
hoelzl@47694
  1439
  finally have "ereal ((measure M (\<Inter>i. A i))) = emeasure M (\<Inter>i. A i)"
hoelzl@47694
  1440
    by (auto simp: emeasure_eq_ereal_measure)
hoelzl@47694
  1441
  then show ?thesis
hoelzl@47694
  1442
    unfolding measure_def
hoelzl@47694
  1443
    using Lim_emeasure_decseq[OF A fin]
hoelzl@47694
  1444
    by (intro lim_real_of_ereal) simp
hoelzl@47694
  1445
qed
hoelzl@47694
  1446
hoelzl@56994
  1447
subsection {* Measure spaces with @{term "emeasure M (space M) < \<infinity>"} *}
hoelzl@47694
  1448
hoelzl@47694
  1449
locale finite_measure = sigma_finite_measure M for M +
hoelzl@47694
  1450
  assumes finite_emeasure_space: "emeasure M (space M) \<noteq> \<infinity>"
hoelzl@47694
  1451
hoelzl@47694
  1452
lemma finite_measureI[Pure.intro!]:
hoelzl@57447
  1453
  "emeasure M (space M) \<noteq> \<infinity> \<Longrightarrow> finite_measure M"
hoelzl@57447
  1454
  proof qed (auto intro!: exI[of _ "{space M}"])
hoelzl@47694
  1455
hoelzl@47694
  1456
lemma (in finite_measure) emeasure_finite[simp, intro]: "emeasure M A \<noteq> \<infinity>"
hoelzl@47694
  1457
  using finite_emeasure_space emeasure_space[of M A] by auto
hoelzl@47694
  1458
hoelzl@47694
  1459
lemma (in finite_measure) emeasure_eq_measure: "emeasure M A = ereal (measure M A)"
hoelzl@47694
  1460
  unfolding measure_def by (simp add: emeasure_eq_ereal_measure)
hoelzl@47694
  1461
hoelzl@47694
  1462
lemma (in finite_measure) emeasure_real: "\<exists>r. 0 \<le> r \<and> emeasure M A = ereal r"
hoelzl@47694
  1463
  using emeasure_finite[of A] emeasure_nonneg[of M A] by (cases "emeasure M A") auto
hoelzl@47694
  1464
hoelzl@47694
  1465
lemma (in finite_measure) bounded_measure: "measure M A \<le> measure M (space M)"
hoelzl@47694
  1466
  using emeasure_space[of M A] emeasure_real[of A] emeasure_real[of "space M"] by (auto simp: measure_def)
hoelzl@47694
  1467
hoelzl@47694
  1468
lemma (in finite_measure) finite_measure_Diff:
hoelzl@47694
  1469
  assumes sets: "A \<in> sets M" "B \<in> sets M" and "B \<subseteq> A"
hoelzl@47694
  1470
  shows "measure M (A - B) = measure M A - measure M B"
hoelzl@47694
  1471
  using measure_Diff[OF _ assms] by simp
hoelzl@47694
  1472
hoelzl@47694
  1473
lemma (in finite_measure) finite_measure_Union:
hoelzl@47694
  1474
  assumes sets: "A \<in> sets M" "B \<in> sets M" and "A \<inter> B = {}"
hoelzl@47694
  1475
  shows "measure M (A \<union> B) = measure M A + measure M B"
hoelzl@47694
  1476
  using measure_Union[OF _ _ assms] by simp
hoelzl@47694
  1477
hoelzl@47694
  1478
lemma (in finite_measure) finite_measure_finite_Union:
hoelzl@47694
  1479
  assumes measurable: "A`S \<subseteq> sets M" "disjoint_family_on A S" "finite S"
hoelzl@47694
  1480
  shows "measure M (\<Union>i\<in>S. A i) = (\<Sum>i\<in>S. measure M (A i))"
hoelzl@47694
  1481
  using measure_finite_Union[OF assms] by simp
hoelzl@47694
  1482
hoelzl@47694
  1483
lemma (in finite_measure) finite_measure_UNION:
hoelzl@47694
  1484
  assumes A: "range A \<subseteq> sets M" "disjoint_family A"
hoelzl@47694
  1485
  shows "(\<lambda>i. measure M (A i)) sums (measure M (\<Union>i. A i))"
hoelzl@47694
  1486
  using measure_UNION[OF A] by simp
hoelzl@47694
  1487
hoelzl@47694
  1488
lemma (in finite_measure) finite_measure_mono:
hoelzl@47694
  1489
  assumes "A \<subseteq> B" "B \<in> sets M" shows "measure M A \<le> measure M B"
hoelzl@47694
  1490
  using emeasure_mono[OF assms] emeasure_real[of A] emeasure_real[of B] by (auto simp: measure_def)
hoelzl@47694
  1491
hoelzl@47694
  1492
lemma (in finite_measure) finite_measure_subadditive:
hoelzl@47694
  1493
  assumes m: "A \<in> sets M" "B \<in> sets M"
hoelzl@47694
  1494
  shows "measure M (A \<union> B) \<le> measure M A + measure M B"
hoelzl@47694
  1495
  using measure_subadditive[OF m] by simp
hoelzl@47694
  1496
hoelzl@47694
  1497
lemma (in finite_measure) finite_measure_subadditive_finite:
hoelzl@47694
  1498
  assumes "finite I" "A`I \<subseteq> sets M" shows "measure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. measure M (A i))"
hoelzl@47694
  1499
  using measure_subadditive_finite[OF assms] by simp
hoelzl@47694
  1500
hoelzl@47694
  1501
lemma (in finite_measure) finite_measure_subadditive_countably:
hoelzl@47694
  1502
  assumes A: "range A \<subseteq> sets M" and sum: "summable (\<lambda>i. measure M (A i))"
hoelzl@47694
  1503
  shows "measure M (\<Union>i. A i) \<le> (\<Sum>i. measure M (A i))"
hoelzl@47694
  1504
proof -
hoelzl@47694
  1505
  from `summable (\<lambda>i. measure M (A i))`
hoelzl@47694
  1506
  have "(\<lambda>i. ereal (measure M (A i))) sums ereal (\<Sum>i. measure M (A i))"
hoelzl@47694
  1507
    by (simp add: sums_ereal) (rule summable_sums)
hoelzl@47694
  1508
  from sums_unique[OF this, symmetric]
hoelzl@47694
  1509
       measure_subadditive_countably[OF A]
hoelzl@47694
  1510
  show ?thesis by (simp add: emeasure_eq_measure)
hoelzl@47694
  1511
qed
hoelzl@47694
  1512
hoelzl@47694
  1513
lemma (in finite_measure) finite_measure_eq_setsum_singleton:
hoelzl@47694
  1514
  assumes "finite S" and *: "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
hoelzl@47694
  1515
  shows "measure M S = (\<Sum>x\<in>S. measure M {x})"
hoelzl@47694
  1516
  using measure_eq_setsum_singleton[OF assms] by simp
hoelzl@47694
  1517
hoelzl@47694
  1518
lemma (in finite_measure) finite_Lim_measure_incseq:
hoelzl@47694
  1519
  assumes A: "range A \<subseteq> sets M" "incseq A"
hoelzl@47694
  1520
  shows "(\<lambda>i. measure M (A i)) ----> measure M (\<Union>i. A i)"
hoelzl@47694
  1521
  using Lim_measure_incseq[OF A] by simp
hoelzl@47694
  1522
hoelzl@47694
  1523
lemma (in finite_measure) finite_Lim_measure_decseq:
hoelzl@47694
  1524
  assumes A: "range A \<subseteq> sets M" "decseq A"
hoelzl@47694
  1525
  shows "(\<lambda>n. measure M (A n)) ----> measure M (\<Inter>i. A i)"
hoelzl@47694
  1526
  using Lim_measure_decseq[OF A] by simp
hoelzl@47694
  1527
hoelzl@47694
  1528
lemma (in finite_measure) finite_measure_compl:
hoelzl@47694
  1529
  assumes S: "S \<in> sets M"
hoelzl@47694
  1530
  shows "measure M (space M - S) = measure M (space M) - measure M S"
immler@50244
  1531
  using measure_Diff[OF _ sets.top S sets.sets_into_space] S by simp
hoelzl@47694
  1532
hoelzl@47694
  1533
lemma (in finite_measure) finite_measure_mono_AE:
hoelzl@47694
  1534
  assumes imp: "AE x in M. x \<in> A \<longrightarrow> x \<in> B" and B: "B \<in> sets M"
hoelzl@47694
  1535
  shows "measure M A \<le> measure M B"
hoelzl@47694
  1536
  using assms emeasure_mono_AE[OF imp B]
hoelzl@47694
  1537
  by (simp add: emeasure_eq_measure)
hoelzl@47694
  1538
hoelzl@47694
  1539
lemma (in finite_measure) finite_measure_eq_AE:
hoelzl@47694
  1540
  assumes iff: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@47694
  1541
  assumes A: "A \<in> sets M" and B: "B \<in> sets M"
hoelzl@47694
  1542
  shows "measure M A = measure M B"
hoelzl@47694
  1543
  using assms emeasure_eq_AE[OF assms] by (simp add: emeasure_eq_measure)
hoelzl@47694
  1544
hoelzl@50104
  1545
lemma (in finite_measure) measure_increasing: "increasing M (measure M)"
hoelzl@50104
  1546
  by (auto intro!: finite_measure_mono simp: increasing_def)
hoelzl@50104
  1547
hoelzl@50104
  1548
lemma (in finite_measure) measure_zero_union:
hoelzl@50104
  1549
  assumes "s \<in> sets M" "t \<in> sets M" "measure M t = 0"
hoelzl@50104
  1550
  shows "measure M (s \<union> t) = measure M s"
hoelzl@50104
  1551
using assms
hoelzl@50104
  1552
proof -
hoelzl@50104
  1553
  have "measure M (s \<union> t) \<le> measure M s"
hoelzl@50104
  1554
    using finite_measure_subadditive[of s t] assms by auto
hoelzl@50104
  1555
  moreover have "measure M (s \<union> t) \<ge> measure M s"
hoelzl@50104
  1556
    using assms by (blast intro: finite_measure_mono)
hoelzl@50104
  1557
  ultimately show ?thesis by simp
hoelzl@50104
  1558
qed
hoelzl@50104
  1559
hoelzl@50104
  1560
lemma (in finite_measure) measure_eq_compl:
hoelzl@50104
  1561
  assumes "s \<in> sets M" "t \<in> sets M"
hoelzl@50104
  1562
  assumes "measure M (space M - s) = measure M (space M - t)"
hoelzl@50104
  1563
  shows "measure M s = measure M t"
hoelzl@50104
  1564
  using assms finite_measure_compl by auto
hoelzl@50104
  1565
hoelzl@50104
  1566
lemma (in finite_measure) measure_eq_bigunion_image:
hoelzl@50104
  1567
  assumes "range f \<subseteq> sets M" "range g \<subseteq> sets M"
hoelzl@50104
  1568
  assumes "disjoint_family f" "disjoint_family g"
hoelzl@50104
  1569
  assumes "\<And> n :: nat. measure M (f n) = measure M (g n)"
hoelzl@50104
  1570
  shows "measure M (\<Union> i. f i) = measure M (\<Union> i. g i)"
hoelzl@50104
  1571
using assms
hoelzl@50104
  1572
proof -
hoelzl@50104
  1573
  have a: "(\<lambda> i. measure M (f i)) sums (measure M (\<Union> i. f i))"
hoelzl@50104
  1574
    by (rule finite_measure_UNION[OF assms(1,3)])
hoelzl@50104
  1575
  have b: "(\<lambda> i. measure M (g i)) sums (measure M (\<Union> i. g i))"
hoelzl@50104
  1576
    by (rule finite_measure_UNION[OF assms(2,4)])
hoelzl@50104
  1577
  show ?thesis using sums_unique[OF b] sums_unique[OF a] assms by simp
hoelzl@50104
  1578
qed
hoelzl@50104
  1579
hoelzl@50104
  1580
lemma (in finite_measure) measure_countably_zero:
hoelzl@50104
  1581
  assumes "range c \<subseteq> sets M"
hoelzl@50104
  1582
  assumes "\<And> i. measure M (c i) = 0"
hoelzl@50104
  1583
  shows "measure M (\<Union> i :: nat. c i) = 0"
hoelzl@50104
  1584
proof (rule antisym)
hoelzl@50104
  1585
  show "measure M (\<Union> i :: nat. c i) \<le> 0"
hoelzl@50104
  1586
    using finite_measure_subadditive_countably[OF assms(1)] by (simp add: assms(2))
hoelzl@50104
  1587
qed (simp add: measure_nonneg)
hoelzl@50104
  1588
hoelzl@50104
  1589
lemma (in finite_measure) measure_space_inter:
hoelzl@50104
  1590
  assumes events:"s \<in> sets M" "t \<in> sets M"
hoelzl@50104
  1591
  assumes "measure M t = measure M (space M)"
hoelzl@50104
  1592
  shows "measure M (s \<inter> t) = measure M s"
hoelzl@50104
  1593
proof -
hoelzl@50104
  1594
  have "measure M ((space M - s) \<union> (space M - t)) = measure M (space M - s)"
hoelzl@50104
  1595
    using events assms finite_measure_compl[of "t"] by (auto intro!: measure_zero_union)
hoelzl@50104
  1596
  also have "(space M - s) \<union> (space M - t) = space M - (s \<inter> t)"
hoelzl@50104
  1597
    by blast
hoelzl@50104
  1598
  finally show "measure M (s \<inter> t) = measure M s"
hoelzl@50104
  1599
    using events by (auto intro!: measure_eq_compl[of "s \<inter> t" s])
hoelzl@50104
  1600
qed
hoelzl@50104
  1601
hoelzl@50104
  1602
lemma (in finite_measure) measure_equiprobable_finite_unions:
hoelzl@50104
  1603
  assumes s: "finite s" "\<And>x. x \<in> s \<Longrightarrow> {x} \<in> sets M"
hoelzl@50104
  1604
  assumes "\<And> x y. \<lbrakk>x \<in> s; y \<in> s\<rbrakk> \<Longrightarrow> measure M {x} = measure M {y}"
hoelzl@50104
  1605
  shows "measure M s = real (card s) * measure M {SOME x. x \<in> s}"
hoelzl@50104
  1606
proof cases
hoelzl@50104
  1607
  assume "s \<noteq> {}"
hoelzl@50104
  1608
  then have "\<exists> x. x \<in> s" by blast
hoelzl@50104
  1609
  from someI_ex[OF this] assms
hoelzl@50104
  1610
  have prob_some: "\<And> x. x \<in> s \<Longrightarrow> measure M {x} = measure M {SOME y. y \<in> s}" by blast
hoelzl@50104
  1611
  have "measure M s = (\<Sum> x \<in> s. measure M {x})"
hoelzl@50104
  1612
    using finite_measure_eq_setsum_singleton[OF s] by simp
hoelzl@50104
  1613
  also have "\<dots> = (\<Sum> x \<in> s. measure M {SOME y. y \<in> s})" using prob_some by auto
hoelzl@50104
  1614
  also have "\<dots> = real (card s) * measure M {(SOME x. x \<in> s)}"
hoelzl@50104
  1615
    using setsum_constant assms by (simp add: real_eq_of_nat)
hoelzl@50104
  1616
  finally show ?thesis by simp
hoelzl@50104
  1617
qed simp
hoelzl@50104
  1618
hoelzl@50104
  1619
lemma (in finite_measure) measure_real_sum_image_fn:
hoelzl@50104
  1620
  assumes "e \<in> sets M"
hoelzl@50104
  1621
  assumes "\<And> x. x \<in> s \<Longrightarrow> e \<inter> f x \<in> sets M"
hoelzl@50104
  1622
  assumes "finite s"
hoelzl@50104
  1623
  assumes disjoint: "\<And> x y. \<lbrakk>x \<in> s ; y \<in> s ; x \<noteq> y\<rbrakk> \<Longrightarrow> f x \<inter> f y = {}"
hoelzl@50104
  1624
  assumes upper: "space M \<subseteq> (\<Union> i \<in> s. f i)"
hoelzl@50104
  1625
  shows "measure M e = (\<Sum> x \<in> s. measure M (e \<inter> f x))"
hoelzl@50104
  1626
proof -
hoelzl@50104
  1627
  have e: "e = (\<Union> i \<in> s. e \<inter> f i)"
immler@50244
  1628
    using `e \<in> sets M` sets.sets_into_space upper by blast
hoelzl@50104
  1629
  hence "measure M e = measure M (\<Union> i \<in> s. e \<inter> f i)" by simp
hoelzl@50104
  1630
  also have "\<dots> = (\<Sum> x \<in> s. measure M (e \<inter> f x))"
hoelzl@50104
  1631
  proof (rule finite_measure_finite_Union)
hoelzl@50104
  1632
    show "finite s" by fact
hoelzl@50104
  1633
    show "(\<lambda>i. e \<inter> f i)`s \<subseteq> sets M" using assms(2) by auto
hoelzl@50104
  1634
    show "disjoint_family_on (\<lambda>i. e \<inter> f i) s"
hoelzl@50104
  1635
      using disjoint by (auto simp: disjoint_family_on_def)
hoelzl@50104
  1636
  qed
hoelzl@50104
  1637
  finally show ?thesis .
hoelzl@50104
  1638
qed
hoelzl@50104
  1639
hoelzl@50104
  1640
lemma (in finite_measure) measure_exclude:
hoelzl@50104
  1641
  assumes "A \<in> sets M" "B \<in> sets M"
hoelzl@50104
  1642
  assumes "measure M A = measure M (space M)" "A \<inter> B = {}"
hoelzl@50104
  1643
  shows "measure M B = 0"
hoelzl@50104
  1644
  using measure_space_inter[of B A] assms by (auto simp: ac_simps)
hoelzl@57235
  1645
lemma (in finite_measure) finite_measure_distr:
hoelzl@57235
  1646
  assumes f: "f \<in> measurable M M'" 
hoelzl@57235
  1647
  shows "finite_measure (distr M M' f)"
hoelzl@57235
  1648
proof (rule finite_measureI)
hoelzl@57235
  1649
  have "f -` space M' \<inter> space M = space M" using f by (auto dest: measurable_space)
hoelzl@57235
  1650
  with f show "emeasure (distr M M' f) (space (distr M M' f)) \<noteq> \<infinity>" by (auto simp: emeasure_distr)
hoelzl@57235
  1651
qed
hoelzl@57235
  1652
hoelzl@56994
  1653
subsection {* Counting space *}
hoelzl@47694
  1654
hoelzl@49773
  1655
lemma strict_monoI_Suc:
hoelzl@49773
  1656
  assumes ord [simp]: "(\<And>n. f n < f (Suc n))" shows "strict_mono f"
hoelzl@49773
  1657
  unfolding strict_mono_def
hoelzl@49773
  1658
proof safe
hoelzl@49773
  1659
  fix n m :: nat assume "n < m" then show "f n < f m"
hoelzl@49773
  1660
    by (induct m) (auto simp: less_Suc_eq intro: less_trans ord)
hoelzl@49773
  1661
qed
hoelzl@49773
  1662
hoelzl@47694
  1663
lemma emeasure_count_space:
hoelzl@47694
  1664
  assumes "X \<subseteq> A" shows "emeasure (count_space A) X = (if finite X then ereal (card X) else \<infinity>)"
hoelzl@47694
  1665
    (is "_ = ?M X")
hoelzl@47694
  1666
  unfolding count_space_def
hoelzl@47694
  1667
proof (rule emeasure_measure_of_sigma)
hoelzl@49773
  1668
  show "X \<in> Pow A" using `X \<subseteq> A` by auto
hoelzl@47694
  1669
  show "sigma_algebra A (Pow A)" by (rule sigma_algebra_Pow)
hoelzl@49773
  1670
  show positive: "positive (Pow A) ?M"
hoelzl@47694
  1671
    by (auto simp: positive_def)
hoelzl@49773
  1672
  have additive: "additive (Pow A) ?M"
hoelzl@49773
  1673
    by (auto simp: card_Un_disjoint additive_def)
hoelzl@47694
  1674
hoelzl@49773
  1675
  interpret ring_of_sets A "Pow A"
hoelzl@49773
  1676
    by (rule ring_of_setsI) auto
hoelzl@49773
  1677
  show "countably_additive (Pow A) ?M" 
hoelzl@49773
  1678
    unfolding countably_additive_iff_continuous_from_below[OF positive additive]
hoelzl@49773
  1679
  proof safe
hoelzl@49773
  1680
    fix F :: "nat \<Rightarrow> 'a set" assume "incseq F"
hoelzl@49773
  1681
    show "(\<lambda>i. ?M (F i)) ----> ?M (\<Union>i. F i)"
hoelzl@49773
  1682
    proof cases
hoelzl@49773
  1683
      assume "\<exists>i. \<forall>j\<ge>i. F i = F j"
hoelzl@49773
  1684
      then guess i .. note i = this
hoelzl@49773
  1685
      { fix j from i `incseq F` have "F j \<subseteq> F i"
hoelzl@49773
  1686
          by (cases "i \<le> j") (auto simp: incseq_def) }
hoelzl@49773
  1687
      then have eq: "(\<Union>i. F i) = F i"
hoelzl@49773
  1688
        by auto
hoelzl@49773
  1689
      with i show ?thesis
hoelzl@49773
  1690
        by (auto intro!: Lim_eventually eventually_sequentiallyI[where c=i])
hoelzl@49773
  1691
    next
hoelzl@49773
  1692
      assume "\<not> (\<exists>i. \<forall>j\<ge>i. F i = F j)"
wenzelm@53374
  1693
      then obtain f where f: "\<And>i. i \<le> f i" "\<And>i. F i \<noteq> F (f i)" by metis
wenzelm@53374
  1694
      then have "\<And>i. F i \<subseteq> F (f i)" using `incseq F` by (auto simp: incseq_def)
wenzelm@53374
  1695
      with f have *: "\<And>i. F i \<subset> F (f i)" by auto
hoelzl@47694
  1696
hoelzl@49773
  1697
      have "incseq (\<lambda>i. ?M (F i))"
hoelzl@49773
  1698
        using `incseq F` unfolding incseq_def by (auto simp: card_mono dest: finite_subset)
hoelzl@49773
  1699
      then have "(\<lambda>i. ?M (F i)) ----> (SUP n. ?M (F n))"
hoelzl@51000
  1700
        by (rule LIMSEQ_SUP)
hoelzl@47694
  1701
hoelzl@49773
  1702
      moreover have "(SUP n. ?M (F n)) = \<infinity>"
hoelzl@49773
  1703
      proof (rule SUP_PInfty)
hoelzl@49773
  1704
        fix n :: nat show "\<exists>k::nat\<in>UNIV. ereal n \<le> ?M (F k)"
hoelzl@49773
  1705
        proof (induct n)
hoelzl@49773
  1706
          case (Suc n)
hoelzl@49773
  1707
          then guess k .. note k = this
hoelzl@49773
  1708
          moreover have "finite (F k) \<Longrightarrow> finite (F (f k)) \<Longrightarrow> card (F k) < card (F (f k))"
hoelzl@49773
  1709
            using `F k \<subset> F (f k)` by (simp add: psubset_card_mono)
hoelzl@49773
  1710
          moreover have "finite (F (f k)) \<Longrightarrow> finite (F k)"
hoelzl@49773
  1711
            using `k \<le> f k` `incseq F` by (auto simp: incseq_def dest: finite_subset)
hoelzl@49773
  1712
          ultimately show ?case
hoelzl@49773
  1713
            by (auto intro!: exI[of _ "f k"])
hoelzl@49773
  1714
        qed auto
hoelzl@47694
  1715
      qed
hoelzl@49773
  1716
hoelzl@49773
  1717
      moreover
hoelzl@49773
  1718
      have "inj (\<lambda>n. F ((f ^^ n) 0))"
hoelzl@49773
  1719
        by (intro strict_mono_imp_inj_on strict_monoI_Suc) (simp add: *)
hoelzl@49773
  1720
      then have 1: "infinite (range (\<lambda>i. F ((f ^^ i) 0)))"
hoelzl@49773
  1721
        by (rule range_inj_infinite)
hoelzl@49773
  1722
      have "infinite (Pow (\<Union>i. F i))"
hoelzl@49773
  1723
        by (rule infinite_super[OF _ 1]) auto
hoelzl@49773
  1724
      then have "infinite (\<Union>i. F i)"
hoelzl@49773
  1725
        by auto
hoelzl@49773
  1726
      
hoelzl@49773
  1727
      ultimately show ?thesis by auto
hoelzl@49773
  1728
    qed
hoelzl@47694
  1729
  qed
hoelzl@47694
  1730
qed
hoelzl@47694
  1731
hoelzl@59011
  1732
lemma distr_bij_count_space:
hoelzl@59011
  1733
  assumes f: "bij_betw f A B"
hoelzl@59011
  1734
  shows "distr (count_space A) (count_space B) f = count_space B"
hoelzl@59011
  1735
proof (rule measure_eqI)
hoelzl@59011
  1736
  have f': "f \<in> measurable (count_space A) (count_space B)"
hoelzl@59011
  1737
    using f unfolding Pi_def bij_betw_def by auto
hoelzl@59011
  1738
  fix X assume "X \<in> sets (distr (count_space A) (count_space B) f)"
hoelzl@59011
  1739
  then have X: "X \<in> sets (count_space B)" by auto
hoelzl@59011
  1740
  moreover then have "f -` X \<inter> A = the_inv_into A f ` X"
hoelzl@59011
  1741
    using f by (auto simp: bij_betw_def subset_image_iff image_iff the_inv_into_f_f intro: the_inv_into_f_f[symmetric])
hoelzl@59011
  1742
  moreover have "inj_on (the_inv_into A f) B"
hoelzl@59011
  1743
    using X f by (auto simp: bij_betw_def inj_on_the_inv_into)
hoelzl@59011
  1744
  with X have "inj_on (the_inv_into A f) X"
hoelzl@59011
  1745
    by (auto intro: subset_inj_on)
hoelzl@59011
  1746
  ultimately show "emeasure (distr (count_space A) (count_space B) f) X = emeasure (count_space B) X"
hoelzl@59011
  1747
    using f unfolding emeasure_distr[OF f' X]
hoelzl@59011
  1748
    by (subst (1 2) emeasure_count_space) (auto simp: card_image dest: finite_imageD)
hoelzl@59011
  1749
qed simp
hoelzl@59011
  1750
hoelzl@47694
  1751
lemma emeasure_count_space_finite[simp]:
hoelzl@47694
  1752
  "X \<subseteq> A \<Longrightarrow> finite X \<Longrightarrow> emeasure (count_space A) X = ereal (card X)"
hoelzl@47694
  1753
  using emeasure_count_space[of X A] by simp
hoelzl@47694
  1754
hoelzl@47694
  1755
lemma emeasure_count_space_infinite[simp]:
hoelzl@47694
  1756
  "X \<subseteq> A \<Longrightarrow> infinite X \<Longrightarrow> emeasure (count_space A) X = \<infinity>"
hoelzl@47694
  1757
  using emeasure_count_space[of X A] by simp
hoelzl@47694
  1758
hoelzl@58606
  1759
lemma measure_count_space: "measure (count_space A) X = (if X \<subseteq> A then card X else 0)"
hoelzl@58606
  1760
  unfolding measure_def
hoelzl@58606
  1761
  by (cases "finite X") (simp_all add: emeasure_notin_sets)
hoelzl@58606
  1762
hoelzl@47694
  1763
lemma emeasure_count_space_eq_0:
hoelzl@47694
  1764
  "emeasure (count_space A) X = 0 \<longleftrightarrow> (X \<subseteq> A \<longrightarrow> X = {})"
hoelzl@47694
  1765
proof cases
hoelzl@47694
  1766
  assume X: "X \<subseteq> A"
hoelzl@47694
  1767
  then show ?thesis
hoelzl@47694
  1768
  proof (intro iffI impI)
hoelzl@47694
  1769
    assume "emeasure (count_space A) X = 0"
hoelzl@47694
  1770
    with X show "X = {}"
hoelzl@47694
  1771
      by (subst (asm) emeasure_count_space) (auto split: split_if_asm)
hoelzl@47694
  1772
  qed simp
hoelzl@47694
  1773
qed (simp add: emeasure_notin_sets)
hoelzl@47694
  1774
hoelzl@58606
  1775
lemma space_empty: "space M = {} \<Longrightarrow> M = count_space {}"
hoelzl@58606
  1776
  by (rule measure_eqI) (simp_all add: space_empty_iff)
hoelzl@58606
  1777
hoelzl@47694
  1778
lemma null_sets_count_space: "null_sets (count_space A) = { {} }"
hoelzl@47694
  1779
  unfolding null_sets_def by (auto simp add: emeasure_count_space_eq_0)
hoelzl@47694
  1780
hoelzl@47694
  1781
lemma AE_count_space: "(AE x in count_space A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
hoelzl@47694
  1782
  unfolding eventually_ae_filter by (auto simp add: null_sets_count_space)
hoelzl@47694
  1783
hoelzl@57025
  1784
lemma sigma_finite_measure_count_space_countable:
hoelzl@57025
  1785
  assumes A: "countable A"
hoelzl@47694
  1786
  shows "sigma_finite_measure (count_space A)"
hoelzl@57447
  1787
  proof qed (auto intro!: exI[of _ "(\<lambda>a. {a}) ` A"] simp: A)
hoelzl@47694
  1788
hoelzl@57025
  1789
lemma sigma_finite_measure_count_space:
hoelzl@57025
  1790
  fixes A :: "'a::countable set" shows "sigma_finite_measure (count_space A)"
hoelzl@57025
  1791
  by (rule sigma_finite_measure_count_space_countable) auto
hoelzl@57025
  1792
hoelzl@47694
  1793
lemma finite_measure_count_space:
hoelzl@47694
  1794
  assumes [simp]: "finite A"
hoelzl@47694
  1795
  shows "finite_measure (count_space A)"
hoelzl@47694
  1796
  by rule simp
hoelzl@47694
  1797
hoelzl@47694
  1798
lemma sigma_finite_measure_count_space_finite:
hoelzl@47694
  1799
  assumes A: "finite A" shows "sigma_finite_measure (count_space A)"
hoelzl@47694
  1800
proof -
hoelzl@47694
  1801
  interpret finite_measure "count_space A" using A by (rule finite_measure_count_space)
hoelzl@47694
  1802
  show "sigma_finite_measure (count_space A)" ..
hoelzl@47694
  1803
qed
hoelzl@47694
  1804
hoelzl@56994
  1805
subsection {* Measure restricted to space *}
hoelzl@54417
  1806
hoelzl@54417
  1807
lemma emeasure_restrict_space:
hoelzl@57025
  1808
  assumes "\<Omega> \<inter> space M \<in> sets M" "A \<subseteq> \<Omega>"
hoelzl@54417
  1809
  shows "emeasure (restrict_space M \<Omega>) A = emeasure M A"
hoelzl@54417
  1810
proof cases
hoelzl@54417
  1811
  assume "A \<in> sets M"
hoelzl@57025
  1812
  show ?thesis
hoelzl@54417
  1813
  proof (rule emeasure_measure_of[OF restrict_space_def])
hoelzl@57025
  1814
    show "op \<inter> \<Omega> ` sets M \<subseteq> Pow (\<Omega> \<inter> space M)" "A \<in> sets (restrict_space M \<Omega>)"
hoelzl@57025
  1815
      using `A \<subseteq> \<Omega>` `A \<in> sets M` sets.space_closed by (auto simp: sets_restrict_space)
hoelzl@57025
  1816
    show "positive (sets (restrict_space M \<Omega>)) (emeasure M)"
hoelzl@54417
  1817
      by (auto simp: positive_def emeasure_nonneg)
hoelzl@57025
  1818
    show "countably_additive (sets (restrict_space M \<Omega>)) (emeasure M)"
hoelzl@54417
  1819
    proof (rule countably_additiveI)
hoelzl@54417
  1820
      fix A :: "nat \<Rightarrow> _" assume "range A \<subseteq> sets (restrict_space M \<Omega>)" "disjoint_family A"
hoelzl@54417
  1821
      with assms have "\<And>i. A i \<in> sets M" "\<And>i. A i \<subseteq> space M" "disjoint_family A"
hoelzl@57025
  1822
        by (fastforce simp: sets_restrict_space_iff[OF assms(1)] image_subset_iff
hoelzl@57025
  1823
                      dest: sets.sets_into_space)+
hoelzl@57025
  1824
      then show "(\<Sum>i. emeasure M (A i)) = emeasure M (\<Union>i. A i)"
hoelzl@54417
  1825
        by (subst suminf_emeasure) (auto simp: disjoint_family_subset)
hoelzl@54417
  1826
    qed
hoelzl@54417
  1827
  qed
hoelzl@54417
  1828
next
hoelzl@54417
  1829
  assume "A \<notin> sets M"
hoelzl@54417
  1830
  moreover with assms have "A \<notin> sets (restrict_space M \<Omega>)"
hoelzl@54417
  1831
    by (simp add: sets_restrict_space_iff)
hoelzl@54417
  1832
  ultimately show ?thesis
hoelzl@54417
  1833
    by (simp add: emeasure_notin_sets)
hoelzl@54417
  1834
qed
hoelzl@54417
  1835
hoelzl@57137
  1836
lemma measure_restrict_space:
hoelzl@57137
  1837
  assumes "\<Omega> \<inter> space M \<in> sets M" "A \<subseteq> \<Omega>"
hoelzl@57137
  1838
  shows "measure (restrict_space M \<Omega>) A = measure M A"
hoelzl@57137
  1839
  using emeasure_restrict_space[OF assms] by (simp add: measure_def)
hoelzl@57137
  1840
hoelzl@57137
  1841
lemma AE_restrict_space_iff:
hoelzl@57137
  1842
  assumes "\<Omega> \<inter> space M \<in> sets M"
hoelzl@57137
  1843
  shows "(AE x in restrict_space M \<Omega>. P x) \<longleftrightarrow> (AE x in M. x \<in> \<Omega> \<longrightarrow> P x)"
hoelzl@57137
  1844
proof -
hoelzl@57137
  1845
  have ex_cong: "\<And>P Q f. (\<And>x. P x \<Longrightarrow> Q x) \<Longrightarrow> (\<And>x. Q x \<Longrightarrow> P (f x)) \<Longrightarrow> (\<exists>x. P x) \<longleftrightarrow> (\<exists>x. Q x)"
hoelzl@57137
  1846
    by auto
hoelzl@57137
  1847
  { fix X assume X: "X \<in> sets M" "emeasure M X = 0"
hoelzl@57137
  1848
    then have "emeasure M (\<Omega> \<inter> space M \<inter> X) \<le> emeasure M X"
hoelzl@57137
  1849
      by (intro emeasure_mono) auto
hoelzl@57137
  1850
    then have "emeasure M (\<Omega> \<inter> space M \<inter> X) = 0"
hoelzl@57137
  1851
      using X by (auto intro!: antisym) }
hoelzl@57137
  1852
  with assms show ?thesis
hoelzl@57137
  1853
    unfolding eventually_ae_filter
hoelzl@57137
  1854
    by (auto simp add: space_restrict_space null_sets_def sets_restrict_space_iff
hoelzl@57137
  1855
                       emeasure_restrict_space cong: conj_cong
hoelzl@57137
  1856
             intro!: ex_cong[where f="\<lambda>X. (\<Omega> \<inter> space M) \<inter> X"])
hoelzl@57137
  1857
qed  
hoelzl@57137
  1858
hoelzl@57025
  1859
lemma restrict_restrict_space:
hoelzl@57025
  1860
  assumes "A \<inter> space M \<in> sets M" "B \<inter> space M \<in> sets M"
hoelzl@57025
  1861
  shows "restrict_space (restrict_space M A) B = restrict_space M (A \<inter> B)" (is "?l = ?r")
hoelzl@57025
  1862
proof (rule measure_eqI[symmetric])
hoelzl@57025
  1863
  show "sets ?r = sets ?l"
hoelzl@57025
  1864
    unfolding sets_restrict_space image_comp by (intro image_cong) auto
hoelzl@57025
  1865
next
hoelzl@57025
  1866
  fix X assume "X \<in> sets (restrict_space M (A \<inter> B))"
hoelzl@57025
  1867
  then obtain Y where "Y \<in> sets M" "X = Y \<inter> A \<inter> B"
hoelzl@57025
  1868
    by (auto simp: sets_restrict_space)
hoelzl@57025
  1869
  with assms sets.Int[OF assms] show "emeasure ?r X = emeasure ?l X"
hoelzl@57025
  1870
    by (subst (1 2) emeasure_restrict_space)
hoelzl@57025
  1871
       (auto simp: space_restrict_space sets_restrict_space_iff emeasure_restrict_space ac_simps)
hoelzl@57025
  1872
qed
hoelzl@57025
  1873
hoelzl@57025
  1874
lemma restrict_count_space: "restrict_space (count_space B) A = count_space (A \<inter> B)"
hoelzl@54417
  1875
proof (rule measure_eqI)
hoelzl@57025
  1876
  show "sets (restrict_space (count_space B) A) = sets (count_space (A \<inter> B))"
hoelzl@57025
  1877
    by (subst sets_restrict_space) auto
hoelzl@54417
  1878
  moreover fix X assume "X \<in> sets (restrict_space (count_space B) A)"
hoelzl@57025
  1879
  ultimately have "X \<subseteq> A \<inter> B" by auto
hoelzl@57025
  1880
  then show "emeasure (restrict_space (count_space B) A) X = emeasure (count_space (A \<inter> B)) X"
hoelzl@54417
  1881
    by (cases "finite X") (auto simp add: emeasure_restrict_space)
hoelzl@54417
  1882
qed
hoelzl@54417
  1883
Andreas@60063
  1884
lemma sigma_finite_measure_restrict_space:
Andreas@60063
  1885
  assumes "sigma_finite_measure M"
Andreas@60063
  1886
  and A: "A \<in> sets M"
Andreas@60063
  1887
  shows "sigma_finite_measure (restrict_space M A)"
Andreas@60063
  1888
proof -
Andreas@60063
  1889
  interpret sigma_finite_measure M by fact
Andreas@60063
  1890
  from sigma_finite_countable obtain C
Andreas@60063
  1891
    where C: "countable C" "C \<subseteq> sets M" "(\<Union>C) = space M" "\<forall>a\<in>C. emeasure M a \<noteq> \<infinity>"
Andreas@60063
  1892
    by blast
Andreas@60063
  1893
  let ?C = "op \<inter> A ` C"
Andreas@60063
  1894
  from C have "countable ?C" "?C \<subseteq> sets (restrict_space M A)" "(\<Union>?C) = space (restrict_space M A)"
Andreas@60063
  1895
    by(auto simp add: sets_restrict_space space_restrict_space)
Andreas@60063
  1896
  moreover {
Andreas@60063
  1897
    fix a
Andreas@60063
  1898
    assume "a \<in> ?C"
Andreas@60063
  1899
    then obtain a' where "a = A \<inter> a'" "a' \<in> C" ..
Andreas@60063
  1900
    then have "emeasure (restrict_space M A) a \<le> emeasure M a'"
Andreas@60063
  1901
      using A C by(auto simp add: emeasure_restrict_space intro: emeasure_mono)
Andreas@60063
  1902
    also have "\<dots> < \<infinity>" using C(4)[rule_format, of a'] \<open>a' \<in> C\<close> by simp
Andreas@60063
  1903
    finally have "emeasure (restrict_space M A) a \<noteq> \<infinity>" by simp }
Andreas@60063
  1904
  ultimately show ?thesis
Andreas@60063
  1905
    by unfold_locales (rule exI conjI|assumption|blast)+
Andreas@60063
  1906
qed
Andreas@60063
  1907
Andreas@60063
  1908
lemma finite_measure_restrict_space:
Andreas@60063
  1909
  assumes "finite_measure M"
Andreas@60063
  1910
  and A: "A \<in> sets M"
Andreas@60063
  1911
  shows "finite_measure (restrict_space M A)"
Andreas@60063
  1912
proof -
Andreas@60063
  1913
  interpret finite_measure M by fact
Andreas@60063
  1914
  show ?thesis
Andreas@60063
  1915
    by(rule finite_measureI)(simp add: emeasure_restrict_space A space_restrict_space)
Andreas@60063
  1916
qed
Andreas@60063
  1917
hoelzl@57137
  1918
lemma restrict_distr: 
hoelzl@57137
  1919
  assumes [measurable]: "f \<in> measurable M N"
hoelzl@57137
  1920
  assumes [simp]: "\<Omega> \<inter> space N \<in> sets N" and restrict: "f \<in> space M \<rightarrow> \<Omega>"
hoelzl@57137
  1921
  shows "restrict_space (distr M N f) \<Omega> = distr M (restrict_space N \<Omega>) f"
hoelzl@57137
  1922
  (is "?l = ?r")
hoelzl@57137
  1923
proof (rule measure_eqI)
hoelzl@57137
  1924
  fix A assume "A \<in> sets (restrict_space (distr M N f) \<Omega>)"
hoelzl@57137
  1925
  with restrict show "emeasure ?l A = emeasure ?r A"
hoelzl@57137
  1926
    by (subst emeasure_distr)
hoelzl@57137
  1927
       (auto simp: sets_restrict_space_iff emeasure_restrict_space emeasure_distr
hoelzl@57137
  1928
             intro!: measurable_restrict_space2)
hoelzl@57137
  1929
qed (simp add: sets_restrict_space)
hoelzl@57137
  1930
hoelzl@59000
  1931
lemma measure_eqI_restrict_generator:
hoelzl@59000
  1932
  assumes E: "Int_stable E" "E \<subseteq> Pow \<Omega>" "\<And>X. X \<in> E \<Longrightarrow> emeasure M X = emeasure N X"
hoelzl@59000
  1933
  assumes sets_eq: "sets M = sets N" and \<Omega>: "\<Omega> \<in> sets M"
hoelzl@59000
  1934
  assumes "sets (restrict_space M \<Omega>) = sigma_sets \<Omega> E"
hoelzl@59000
  1935
  assumes "sets (restrict_space N \<Omega>) = sigma_sets \<Omega> E" 
hoelzl@59000
  1936
  assumes ae: "AE x in M. x \<in> \<Omega>" "AE x in N. x \<in> \<Omega>"
hoelzl@59000
  1937
  assumes A: "countable A" "A \<noteq> {}" "A \<subseteq> E" "\<Union>A = \<Omega>" "\<And>a. a \<in> A \<Longrightarrow> emeasure M a \<noteq> \<infinity>"
hoelzl@59000
  1938
  shows "M = N"
hoelzl@59000
  1939
proof (rule measure_eqI)
hoelzl@59000
  1940
  fix X assume X: "X \<in> sets M"
hoelzl@59000
  1941
  then have "emeasure M X = emeasure (restrict_space M \<Omega>) (X \<inter> \<Omega>)"
hoelzl@59000
  1942
    using ae \<Omega> by (auto simp add: emeasure_restrict_space intro!: emeasure_eq_AE)
hoelzl@59000
  1943
  also have "restrict_space M \<Omega> = restrict_space N \<Omega>"
hoelzl@59000
  1944
  proof (rule measure_eqI_generator_eq)
hoelzl@59000
  1945
    fix X assume "X \<in> E"
hoelzl@59000
  1946
    then show "emeasure (restrict_space M \<Omega>) X = emeasure (restrict_space N \<Omega>) X"
hoelzl@59000
  1947
      using E \<Omega> by (subst (1 2) emeasure_restrict_space) (auto simp: sets_eq sets_eq[THEN sets_eq_imp_space_eq])
hoelzl@59000
  1948
  next
hoelzl@59000
  1949
    show "range (from_nat_into A) \<subseteq> E" "(\<Union>i. from_nat_into A i) = \<Omega>"
hoelzl@59000
  1950
      unfolding Sup_image_eq[symmetric, where f="from_nat_into A"] using A by auto
hoelzl@59000
  1951
  next
hoelzl@59000
  1952
    fix i
hoelzl@59000
  1953
    have "emeasure (restrict_space M \<Omega>) (from_nat_into A i) = emeasure M (from_nat_into A i)"
hoelzl@59000
  1954
      using A \<Omega> by (subst emeasure_restrict_space)
hoelzl@59000
  1955
                   (auto simp: sets_eq sets_eq[THEN sets_eq_imp_space_eq] intro: from_nat_into)
hoelzl@59000
  1956
    with A show "emeasure (restrict_space M \<Omega>) (from_nat_into A i) \<noteq> \<infinity>"
hoelzl@59000
  1957
      by (auto intro: from_nat_into)
hoelzl@59000
  1958
  qed fact+
hoelzl@59000
  1959
  also have "emeasure (restrict_space N \<Omega>) (X \<inter> \<Omega>) = emeasure N X"
hoelzl@59000
  1960
    using X ae \<Omega> by (auto simp add: emeasure_restrict_space sets_eq intro!: emeasure_eq_AE)
hoelzl@59000
  1961
  finally show "emeasure M X = emeasure N X" .
hoelzl@59000
  1962
qed fact
hoelzl@59000
  1963
hoelzl@59425
  1964
subsection {* Null measure *}
hoelzl@59425
  1965
hoelzl@59425
  1966
definition "null_measure M = sigma (space M) (sets M)"
hoelzl@59425
  1967
hoelzl@59425
  1968
lemma space_null_measure[simp]: "space (null_measure M) = space M"
hoelzl@59425
  1969
  by (simp add: null_measure_def)
hoelzl@59425
  1970
hoelzl@59425
  1971
lemma sets_null_measure[simp, measurable_cong]: "sets (null_measure M) = sets M" 
hoelzl@59425
  1972
  by (simp add: null_measure_def)
hoelzl@59425
  1973
hoelzl@59425
  1974
lemma emeasure_null_measure[simp]: "emeasure (null_measure M) X = 0"
hoelzl@59425
  1975
  by (cases "X \<in> sets M", rule emeasure_measure_of)
hoelzl@59425
  1976
     (auto simp: positive_def countably_additive_def emeasure_notin_sets null_measure_def
hoelzl@59425
  1977
           dest: sets.sets_into_space)
hoelzl@59425
  1978
hoelzl@59425
  1979
lemma measure_null_measure[simp]: "measure (null_measure M) X = 0"
hoelzl@59425
  1980
  by (simp add: measure_def)
hoelzl@59425
  1981
hoelzl@47694
  1982
end
hoelzl@47694
  1983