src/HOL/Analysis/Measure_Space.thy
author nipkow
Mon Oct 17 11:46:22 2016 +0200 (2016-10-17)
changeset 64267 b9a1486e79be
parent 64008 17a20ca86d62
child 64283 979cdfdf7a79
permissions -rw-r--r--
setsum -> sum
hoelzl@63627
     1
(*  Title:      HOL/Analysis/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@61808
     7
section \<open>Measure spaces and their properties\<close>
hoelzl@47694
     8
hoelzl@47694
     9
theory Measure_Space
hoelzl@47694
    10
imports
hoelzl@63626
    11
  Measurable "~~/src/HOL/Library/Extended_Nonnegative_Real"
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@62975
    17
  fixes f :: "nat \<Rightarrow> ennreal"
hoelzl@62975
    18
  assumes "disjoint_family A" "x \<in> A i"
hoelzl@47694
    19
  shows "(\<Sum>n. f n * indicator (A n) x) = f i"
hoelzl@47694
    20
proof -
hoelzl@62975
    21
  have **: "\<And>n. f n * indicator (A n) x = (if n = i then f n else 0 :: ennreal)"
wenzelm@61808
    22
    using \<open>x \<in> A i\<close> assms unfolding disjoint_family_on_def indicator_def by auto
hoelzl@62975
    23
  then have "\<And>n. (\<Sum>j<n. f j * indicator (A j) x) = (if i < n then f i else 0 :: ennreal)"
nipkow@64267
    24
    by (auto simp: sum.If_cases)
hoelzl@62975
    25
  moreover have "(SUP n. if i < n then f i else 0) = (f i :: ennreal)"
hoelzl@51000
    26
  proof (rule SUP_eqI)
hoelzl@62975
    27
    fix y :: ennreal 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@63333
    29
  qed (insert assms, simp)
hoelzl@47694
    30
  ultimately show ?thesis using assms
hoelzl@62975
    31
    by (subst suminf_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@62975
    36
  shows "(\<Sum>n. indicator (A n) x :: ennreal) = 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
wenzelm@61808
    40
  from suminf_cmult_indicator[OF assms(1), OF \<open>x \<in> A i\<close>, of "\<lambda>k. 1"]
hoelzl@47694
    41
  show ?thesis using * by simp
hoelzl@47694
    42
qed simp
hoelzl@47694
    43
nipkow@64267
    44
lemma sum_indicator_disjoint_family:
hoelzl@60727
    45
  fixes f :: "'d \<Rightarrow> 'e::semiring_1"
hoelzl@60727
    46
  assumes d: "disjoint_family_on A P" and "x \<in> A j" and "finite P" and "j \<in> P"
hoelzl@60727
    47
  shows "(\<Sum>i\<in>P. f i * indicator (A i) x) = f j"
hoelzl@60727
    48
proof -
hoelzl@60727
    49
  have "P \<inter> {i. x \<in> A i} = {j}"
wenzelm@61808
    50
    using d \<open>x \<in> A j\<close> \<open>j \<in> P\<close> unfolding disjoint_family_on_def
hoelzl@60727
    51
    by auto
hoelzl@60727
    52
  thus ?thesis
hoelzl@60727
    53
    unfolding indicator_def
nipkow@64267
    54
    by (simp add: if_distrib sum.If_cases[OF \<open>finite P\<close>])
hoelzl@60727
    55
qed
hoelzl@60727
    56
wenzelm@61808
    57
text \<open>
hoelzl@47694
    58
  The type for emeasure spaces is already defined in @{theory Sigma_Algebra}, as it is also used to
hoelzl@47694
    59
  represent sigma algebras (with an arbitrary emeasure).
wenzelm@61808
    60
\<close>
hoelzl@47694
    61
hoelzl@56994
    62
subsection "Extend binary sets"
hoelzl@47694
    63
hoelzl@47694
    64
lemma LIMSEQ_binaryset:
hoelzl@47694
    65
  assumes f: "f {} = 0"
wenzelm@61969
    66
  shows  "(\<lambda>n. \<Sum>i<n. f (binaryset A B i)) \<longlonglongrightarrow> f A + f B"
hoelzl@47694
    67
proof -
hoelzl@47694
    68
  have "(\<lambda>n. \<Sum>i < Suc (Suc n). f (binaryset A B i)) = (\<lambda>n. f A + f B)"
hoelzl@47694
    69
    proof
hoelzl@47694
    70
      fix n
hoelzl@47694
    71
      show "(\<Sum>i < Suc (Suc n). f (binaryset A B i)) = f A + f B"
hoelzl@47694
    72
        by (induct n)  (auto simp add: binaryset_def f)
hoelzl@47694
    73
    qed
hoelzl@47694
    74
  moreover
wenzelm@61969
    75
  have "... \<longlonglongrightarrow> f A + f B" by (rule tendsto_const)
hoelzl@47694
    76
  ultimately
wenzelm@61969
    77
  have "(\<lambda>n. \<Sum>i< Suc (Suc n). f (binaryset A B i)) \<longlonglongrightarrow> f A + f B"
hoelzl@47694
    78
    by metis
wenzelm@61969
    79
  hence "(\<lambda>n. \<Sum>i< n+2. f (binaryset A B i)) \<longlonglongrightarrow> f A + f B"
hoelzl@47694
    80
    by simp
hoelzl@47694
    81
  thus ?thesis by (rule LIMSEQ_offset [where k=2])
hoelzl@47694
    82
qed
hoelzl@47694
    83
hoelzl@47694
    84
lemma binaryset_sums:
hoelzl@47694
    85
  assumes f: "f {} = 0"
hoelzl@47694
    86
  shows  "(\<lambda>n. f (binaryset A B n)) sums (f A + f B)"
hoelzl@47694
    87
    by (simp add: sums_def LIMSEQ_binaryset [where f=f, OF f] atLeast0LessThan)
hoelzl@47694
    88
hoelzl@47694
    89
lemma suminf_binaryset_eq:
hoelzl@47694
    90
  fixes f :: "'a set \<Rightarrow> 'b::{comm_monoid_add, t2_space}"
hoelzl@47694
    91
  shows "f {} = 0 \<Longrightarrow> (\<Sum>n. f (binaryset A B n)) = f A + f B"
hoelzl@47694
    92
  by (metis binaryset_sums sums_unique)
hoelzl@47694
    93
wenzelm@61808
    94
subsection \<open>Properties of a premeasure @{term \<mu>}\<close>
hoelzl@47694
    95
wenzelm@61808
    96
text \<open>
hoelzl@47694
    97
  The definitions for @{const positive} and @{const countably_additive} should be here, by they are
hoelzl@47694
    98
  necessary to define @{typ "'a measure"} in @{theory Sigma_Algebra}.
wenzelm@61808
    99
\<close>
hoelzl@47694
   100
hoelzl@62975
   101
definition subadditive where
hoelzl@62975
   102
  "subadditive M f \<longleftrightarrow> (\<forall>x\<in>M. \<forall>y\<in>M. x \<inter> y = {} \<longrightarrow> f (x \<union> y) \<le> f x + f y)"
hoelzl@62975
   103
hoelzl@62975
   104
lemma subadditiveD: "subadditive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> M \<Longrightarrow> y \<in> M \<Longrightarrow> f (x \<union> y) \<le> f x + f y"
hoelzl@62975
   105
  by (auto simp add: subadditive_def)
hoelzl@62975
   106
hoelzl@62975
   107
definition countably_subadditive where
hoelzl@62975
   108
  "countably_subadditive M f \<longleftrightarrow>
hoelzl@62975
   109
    (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> (f (\<Union>i. A i) \<le> (\<Sum>i. f (A i))))"
hoelzl@62975
   110
hoelzl@62975
   111
lemma (in ring_of_sets) countably_subadditive_subadditive:
hoelzl@62975
   112
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@62975
   113
  assumes f: "positive M f" and cs: "countably_subadditive M f"
hoelzl@62975
   114
  shows  "subadditive M f"
hoelzl@62975
   115
proof (auto simp add: subadditive_def)
hoelzl@62975
   116
  fix x y
hoelzl@62975
   117
  assume x: "x \<in> M" and y: "y \<in> M" and "x \<inter> y = {}"
hoelzl@62975
   118
  hence "disjoint_family (binaryset x y)"
hoelzl@62975
   119
    by (auto simp add: disjoint_family_on_def binaryset_def)
hoelzl@62975
   120
  hence "range (binaryset x y) \<subseteq> M \<longrightarrow>
hoelzl@62975
   121
         (\<Union>i. binaryset x y i) \<in> M \<longrightarrow>
hoelzl@62975
   122
         f (\<Union>i. binaryset x y i) \<le> (\<Sum> n. f (binaryset x y n))"
hoelzl@62975
   123
    using cs by (auto simp add: countably_subadditive_def)
hoelzl@62975
   124
  hence "{x,y,{}} \<subseteq> M \<longrightarrow> x \<union> y \<in> M \<longrightarrow>
hoelzl@62975
   125
         f (x \<union> y) \<le> (\<Sum> n. f (binaryset x y n))"
hoelzl@62975
   126
    by (simp add: range_binaryset_eq UN_binaryset_eq)
hoelzl@62975
   127
  thus "f (x \<union> y) \<le>  f x + f y" using f x y
hoelzl@62975
   128
    by (auto simp add: Un o_def suminf_binaryset_eq positive_def)
hoelzl@62975
   129
qed
hoelzl@62975
   130
hoelzl@47694
   131
definition additive where
hoelzl@47694
   132
  "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
   133
hoelzl@47694
   134
definition increasing where
hoelzl@47694
   135
  "increasing M \<mu> \<longleftrightarrow> (\<forall>x\<in>M. \<forall>y\<in>M. x \<subseteq> y \<longrightarrow> \<mu> x \<le> \<mu> y)"
hoelzl@47694
   136
hoelzl@49773
   137
lemma positiveD1: "positive M f \<Longrightarrow> f {} = 0" by (auto simp: positive_def)
hoelzl@49773
   138
hoelzl@47694
   139
lemma positiveD_empty:
hoelzl@47694
   140
  "positive M f \<Longrightarrow> f {} = 0"
hoelzl@47694
   141
  by (auto simp add: positive_def)
hoelzl@47694
   142
hoelzl@47694
   143
lemma additiveD:
hoelzl@47694
   144
  "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
   145
  by (auto simp add: additive_def)
hoelzl@47694
   146
hoelzl@47694
   147
lemma increasingD:
hoelzl@47694
   148
  "increasing M f \<Longrightarrow> x \<subseteq> y \<Longrightarrow> x\<in>M \<Longrightarrow> y\<in>M \<Longrightarrow> f x \<le> f y"
hoelzl@47694
   149
  by (auto simp add: increasing_def)
hoelzl@47694
   150
hoelzl@50104
   151
lemma countably_additiveI[case_names countably]:
hoelzl@47694
   152
  "(\<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
   153
  \<Longrightarrow> countably_additive M f"
hoelzl@47694
   154
  by (simp add: countably_additive_def)
hoelzl@47694
   155
hoelzl@47694
   156
lemma (in ring_of_sets) disjointed_additive:
hoelzl@47694
   157
  assumes f: "positive M f" "additive M f" and A: "range A \<subseteq> M" "incseq A"
hoelzl@47694
   158
  shows "(\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
hoelzl@47694
   159
proof (induct n)
hoelzl@47694
   160
  case (Suc n)
hoelzl@47694
   161
  then have "(\<Sum>i\<le>Suc n. f (disjointed A i)) = f (A n) + f (disjointed A (Suc n))"
hoelzl@47694
   162
    by simp
hoelzl@47694
   163
  also have "\<dots> = f (A n \<union> disjointed A (Suc n))"
hoelzl@60727
   164
    using A by (subst f(2)[THEN additiveD]) (auto simp: disjointed_mono)
hoelzl@47694
   165
  also have "A n \<union> disjointed A (Suc n) = A (Suc n)"
wenzelm@61808
   166
    using \<open>incseq A\<close> by (auto dest: incseq_SucD simp: disjointed_mono)
hoelzl@47694
   167
  finally show ?case .
hoelzl@47694
   168
qed simp
hoelzl@47694
   169
hoelzl@47694
   170
lemma (in ring_of_sets) additive_sum:
hoelzl@47694
   171
  fixes A:: "'i \<Rightarrow> 'a set"
hoelzl@47694
   172
  assumes f: "positive M f" and ad: "additive M f" and "finite S"
hoelzl@47694
   173
      and A: "A`S \<subseteq> M"
hoelzl@47694
   174
      and disj: "disjoint_family_on A S"
hoelzl@47694
   175
  shows  "(\<Sum>i\<in>S. f (A i)) = f (\<Union>i\<in>S. A i)"
wenzelm@61808
   176
  using \<open>finite S\<close> disj A
wenzelm@53374
   177
proof induct
hoelzl@47694
   178
  case empty show ?case using f by (simp add: positive_def)
hoelzl@47694
   179
next
hoelzl@47694
   180
  case (insert s S)
hoelzl@47694
   181
  then have "A s \<inter> (\<Union>i\<in>S. A i) = {}"
hoelzl@47694
   182
    by (auto simp add: disjoint_family_on_def neq_iff)
hoelzl@47694
   183
  moreover
hoelzl@47694
   184
  have "A s \<in> M" using insert by blast
hoelzl@47694
   185
  moreover have "(\<Union>i\<in>S. A i) \<in> M"
wenzelm@61808
   186
    using insert \<open>finite S\<close> by auto
hoelzl@47694
   187
  ultimately have "f (A s \<union> (\<Union>i\<in>S. A i)) = f (A s) + f(\<Union>i\<in>S. A i)"
hoelzl@47694
   188
    using ad UNION_in_sets A by (auto simp add: additive_def)
hoelzl@47694
   189
  with insert show ?case using ad disjoint_family_on_mono[of S "insert s S" A]
hoelzl@47694
   190
    by (auto simp add: additive_def subset_insertI)
hoelzl@47694
   191
qed
hoelzl@47694
   192
hoelzl@47694
   193
lemma (in ring_of_sets) additive_increasing:
hoelzl@62975
   194
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@47694
   195
  assumes posf: "positive M f" and addf: "additive M f"
hoelzl@47694
   196
  shows "increasing M f"
hoelzl@47694
   197
proof (auto simp add: increasing_def)
hoelzl@47694
   198
  fix x y
hoelzl@47694
   199
  assume xy: "x \<in> M" "y \<in> M" "x \<subseteq> y"
hoelzl@47694
   200
  then have "y - x \<in> M" by auto
hoelzl@62975
   201
  then have "f x + 0 \<le> f x + f (y-x)" by (intro add_left_mono zero_le)
hoelzl@47694
   202
  also have "... = f (x \<union> (y-x))" using addf
hoelzl@47694
   203
    by (auto simp add: additive_def) (metis Diff_disjoint Un_Diff_cancel Diff xy(1,2))
hoelzl@47694
   204
  also have "... = f y"
hoelzl@47694
   205
    by (metis Un_Diff_cancel Un_absorb1 xy(3))
hoelzl@47694
   206
  finally show "f x \<le> f y" by simp
hoelzl@47694
   207
qed
hoelzl@47694
   208
immler@50087
   209
lemma (in ring_of_sets) subadditive:
hoelzl@62975
   210
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@62975
   211
  assumes f: "positive M f" "additive M f" and A: "A`S \<subseteq> M" and S: "finite S"
immler@50087
   212
  shows "f (\<Union>i\<in>S. A i) \<le> (\<Sum>i\<in>S. f (A i))"
hoelzl@62975
   213
using S A
immler@50087
   214
proof (induct S)
immler@50087
   215
  case empty thus ?case using f by (auto simp: positive_def)
immler@50087
   216
next
immler@50087
   217
  case (insert x F)
wenzelm@60585
   218
  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+
wenzelm@60585
   219
  have subs: "(\<Union>i\<in>F. A i) - A x \<subseteq> (\<Union>i\<in>F. A i)" by auto
wenzelm@60585
   220
  have "(\<Union>i\<in>(insert x F). A i) = A x \<union> ((\<Union>i\<in>F. A i) - A x)" by auto
wenzelm@60585
   221
  hence "f (\<Union>i\<in>(insert x F). A i) = f (A x \<union> ((\<Union>i\<in>F. A i) - A x))"
immler@50087
   222
    by simp
wenzelm@60585
   223
  also have "\<dots> = f (A x) + f ((\<Union>i\<in>F. A i) - A x)"
immler@50087
   224
    using f(2) by (rule additiveD) (insert in_M, auto)
wenzelm@60585
   225
  also have "\<dots> \<le> f (A x) + f (\<Union>i\<in>F. A i)"
immler@50087
   226
    using additive_increasing[OF f] in_M subs by (auto simp: increasing_def intro: add_left_mono)
immler@50087
   227
  also have "\<dots> \<le> f (A x) + (\<Sum>i\<in>F. f (A i))" using insert by (auto intro: add_left_mono)
wenzelm@60585
   228
  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
   229
qed
immler@50087
   230
hoelzl@47694
   231
lemma (in ring_of_sets) countably_additive_additive:
hoelzl@62975
   232
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@47694
   233
  assumes posf: "positive M f" and ca: "countably_additive M f"
hoelzl@47694
   234
  shows "additive M f"
hoelzl@47694
   235
proof (auto simp add: additive_def)
hoelzl@47694
   236
  fix x y
hoelzl@47694
   237
  assume x: "x \<in> M" and y: "y \<in> M" and "x \<inter> y = {}"
hoelzl@47694
   238
  hence "disjoint_family (binaryset x y)"
hoelzl@47694
   239
    by (auto simp add: disjoint_family_on_def binaryset_def)
hoelzl@47694
   240
  hence "range (binaryset x y) \<subseteq> M \<longrightarrow>
hoelzl@47694
   241
         (\<Union>i. binaryset x y i) \<in> M \<longrightarrow>
hoelzl@47694
   242
         f (\<Union>i. binaryset x y i) = (\<Sum> n. f (binaryset x y n))"
hoelzl@47694
   243
    using ca
hoelzl@47694
   244
    by (simp add: countably_additive_def)
hoelzl@47694
   245
  hence "{x,y,{}} \<subseteq> M \<longrightarrow> x \<union> y \<in> M \<longrightarrow>
hoelzl@47694
   246
         f (x \<union> y) = (\<Sum>n. f (binaryset x y n))"
hoelzl@47694
   247
    by (simp add: range_binaryset_eq UN_binaryset_eq)
hoelzl@47694
   248
  thus "f (x \<union> y) = f x + f y" using posf x y
hoelzl@47694
   249
    by (auto simp add: Un suminf_binaryset_eq positive_def)
hoelzl@47694
   250
qed
hoelzl@47694
   251
hoelzl@47694
   252
lemma (in algebra) increasing_additive_bound:
hoelzl@62975
   253
  fixes A:: "nat \<Rightarrow> 'a set" and  f :: "'a set \<Rightarrow> ennreal"
hoelzl@47694
   254
  assumes f: "positive M f" and ad: "additive M f"
hoelzl@47694
   255
      and inc: "increasing M f"
hoelzl@47694
   256
      and A: "range A \<subseteq> M"
hoelzl@47694
   257
      and disj: "disjoint_family A"
hoelzl@47694
   258
  shows  "(\<Sum>i. f (A i)) \<le> f \<Omega>"
hoelzl@62975
   259
proof (safe intro!: suminf_le_const)
hoelzl@47694
   260
  fix N
hoelzl@47694
   261
  note disj_N = disjoint_family_on_mono[OF _ disj, of "{..<N}"]
hoelzl@47694
   262
  have "(\<Sum>i<N. f (A i)) = f (\<Union>i\<in>{..<N}. A i)"
hoelzl@47694
   263
    using A by (intro additive_sum [OF f ad _ _]) (auto simp: disj_N)
hoelzl@47694
   264
  also have "... \<le> f \<Omega>" using space_closed A
hoelzl@47694
   265
    by (intro increasingD[OF inc] finite_UN) auto
hoelzl@47694
   266
  finally show "(\<Sum>i<N. f (A i)) \<le> f \<Omega>" by simp
hoelzl@47694
   267
qed (insert f A, auto simp: positive_def)
hoelzl@47694
   268
hoelzl@47694
   269
lemma (in ring_of_sets) countably_additiveI_finite:
hoelzl@62975
   270
  fixes \<mu> :: "'a set \<Rightarrow> ennreal"
hoelzl@47694
   271
  assumes "finite \<Omega>" "positive M \<mu>" "additive M \<mu>"
hoelzl@47694
   272
  shows "countably_additive M \<mu>"
hoelzl@47694
   273
proof (rule countably_additiveI)
hoelzl@47694
   274
  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
   275
hoelzl@47694
   276
  have "\<forall>i\<in>{i. F i \<noteq> {}}. \<exists>x. x \<in> F i" by auto
hoelzl@47694
   277
  from bchoice[OF this] obtain f where f: "\<And>i. F i \<noteq> {} \<Longrightarrow> f i \<in> F i" by auto
hoelzl@47694
   278
hoelzl@47694
   279
  have inj_f: "inj_on f {i. F i \<noteq> {}}"
hoelzl@47694
   280
  proof (rule inj_onI, simp)
hoelzl@47694
   281
    fix i j a b assume *: "f i = f j" "F i \<noteq> {}" "F j \<noteq> {}"
hoelzl@47694
   282
    then have "f i \<in> F i" "f j \<in> F j" using f by force+
hoelzl@47694
   283
    with disj * show "i = j" by (auto simp: disjoint_family_on_def)
hoelzl@47694
   284
  qed
hoelzl@47694
   285
  have "finite (\<Union>i. F i)"
hoelzl@47694
   286
    by (metis F(2) assms(1) infinite_super sets_into_space)
hoelzl@47694
   287
hoelzl@47694
   288
  have F_subset: "{i. \<mu> (F i) \<noteq> 0} \<subseteq> {i. F i \<noteq> {}}"
wenzelm@61808
   289
    by (auto simp: positiveD_empty[OF \<open>positive M \<mu>\<close>])
hoelzl@47694
   290
  moreover have fin_not_empty: "finite {i. F i \<noteq> {}}"
hoelzl@47694
   291
  proof (rule finite_imageD)
hoelzl@47694
   292
    from f have "f`{i. F i \<noteq> {}} \<subseteq> (\<Union>i. F i)" by auto
hoelzl@47694
   293
    then show "finite (f`{i. F i \<noteq> {}})"
hoelzl@47694
   294
      by (rule finite_subset) fact
hoelzl@47694
   295
  qed fact
hoelzl@47694
   296
  ultimately have fin_not_0: "finite {i. \<mu> (F i) \<noteq> 0}"
hoelzl@47694
   297
    by (rule finite_subset)
hoelzl@47694
   298
hoelzl@47694
   299
  have disj_not_empty: "disjoint_family_on F {i. F i \<noteq> {}}"
hoelzl@47694
   300
    using disj by (auto simp: disjoint_family_on_def)
hoelzl@47694
   301
hoelzl@47694
   302
  from fin_not_0 have "(\<Sum>i. \<mu> (F i)) = (\<Sum>i | \<mu> (F i) \<noteq> 0. \<mu> (F i))"
hoelzl@47761
   303
    by (rule suminf_finite) auto
hoelzl@47694
   304
  also have "\<dots> = (\<Sum>i | F i \<noteq> {}. \<mu> (F i))"
nipkow@64267
   305
    using fin_not_empty F_subset by (rule sum.mono_neutral_left) auto
hoelzl@47694
   306
  also have "\<dots> = \<mu> (\<Union>i\<in>{i. F i \<noteq> {}}. F i)"
wenzelm@61808
   307
    using \<open>positive M \<mu>\<close> \<open>additive M \<mu>\<close> fin_not_empty disj_not_empty F by (intro additive_sum) auto
hoelzl@47694
   308
  also have "\<dots> = \<mu> (\<Union>i. F i)"
hoelzl@47694
   309
    by (rule arg_cong[where f=\<mu>]) auto
hoelzl@47694
   310
  finally show "(\<Sum>i. \<mu> (F i)) = \<mu> (\<Union>i. F i)" .
hoelzl@47694
   311
qed
hoelzl@47694
   312
hoelzl@49773
   313
lemma (in ring_of_sets) countably_additive_iff_continuous_from_below:
hoelzl@62975
   314
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@49773
   315
  assumes f: "positive M f" "additive M f"
hoelzl@49773
   316
  shows "countably_additive M f \<longleftrightarrow>
wenzelm@61969
   317
    (\<forall>A. range A \<subseteq> M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> (\<lambda>i. f (A i)) \<longlonglongrightarrow> f (\<Union>i. A i))"
hoelzl@49773
   318
  unfolding countably_additive_def
hoelzl@49773
   319
proof safe
hoelzl@49773
   320
  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
   321
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "incseq A" "(\<Union>i. A i) \<in> M"
hoelzl@49773
   322
  then have dA: "range (disjointed A) \<subseteq> M" by (auto simp: range_disjointed_sets)
hoelzl@49773
   323
  with count_sum[THEN spec, of "disjointed A"] A(3)
hoelzl@49773
   324
  have f_UN: "(\<Sum>i. f (disjointed A i)) = f (\<Union>i. A i)"
hoelzl@49773
   325
    by (auto simp: UN_disjointed_eq disjoint_family_disjointed)
wenzelm@61969
   326
  moreover have "(\<lambda>n. (\<Sum>i<n. f (disjointed A i))) \<longlonglongrightarrow> (\<Sum>i. f (disjointed A i))"
hoelzl@49773
   327
    using f(1)[unfolded positive_def] dA
hoelzl@63333
   328
    by (auto intro!: summable_LIMSEQ)
hoelzl@49773
   329
  from LIMSEQ_Suc[OF this]
wenzelm@61969
   330
  have "(\<lambda>n. (\<Sum>i\<le>n. f (disjointed A i))) \<longlonglongrightarrow> (\<Sum>i. f (disjointed A i))"
hoelzl@56193
   331
    unfolding lessThan_Suc_atMost .
hoelzl@49773
   332
  moreover have "\<And>n. (\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
hoelzl@49773
   333
    using disjointed_additive[OF f A(1,2)] .
wenzelm@61969
   334
  ultimately show "(\<lambda>i. f (A i)) \<longlonglongrightarrow> f (\<Union>i. A i)" by simp
hoelzl@49773
   335
next
wenzelm@61969
   336
  assume cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> (\<lambda>i. f (A i)) \<longlonglongrightarrow> f (\<Union>i. A i)"
hoelzl@49773
   337
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "disjoint_family A" "(\<Union>i. A i) \<in> M"
hoelzl@57446
   338
  have *: "(\<Union>n. (\<Union>i<n. A i)) = (\<Union>i. A i)" by auto
wenzelm@61969
   339
  have "(\<lambda>n. f (\<Union>i<n. A i)) \<longlonglongrightarrow> f (\<Union>i. A i)"
hoelzl@49773
   340
  proof (unfold *[symmetric], intro cont[rule_format])
wenzelm@60585
   341
    show "range (\<lambda>i. \<Union>i<i. A i) \<subseteq> M" "(\<Union>i. \<Union>i<i. A i) \<in> M"
hoelzl@49773
   342
      using A * by auto
hoelzl@49773
   343
  qed (force intro!: incseq_SucI)
hoelzl@57446
   344
  moreover have "\<And>n. f (\<Union>i<n. A i) = (\<Sum>i<n. f (A i))"
hoelzl@49773
   345
    using A
hoelzl@49773
   346
    by (intro additive_sum[OF f, of _ A, symmetric])
hoelzl@49773
   347
       (auto intro: disjoint_family_on_mono[where B=UNIV])
hoelzl@49773
   348
  ultimately
hoelzl@49773
   349
  have "(\<lambda>i. f (A i)) sums f (\<Union>i. A i)"
hoelzl@57446
   350
    unfolding sums_def by simp
hoelzl@49773
   351
  from sums_unique[OF this]
hoelzl@49773
   352
  show "(\<Sum>i. f (A i)) = f (\<Union>i. A i)" by simp
hoelzl@49773
   353
qed
hoelzl@49773
   354
hoelzl@49773
   355
lemma (in ring_of_sets) continuous_from_above_iff_empty_continuous:
hoelzl@62975
   356
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@49773
   357
  assumes f: "positive M f" "additive M f"
wenzelm@61969
   358
  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)) \<longlonglongrightarrow> f (\<Inter>i. A i))
wenzelm@61969
   359
     \<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)) \<longlonglongrightarrow> 0)"
hoelzl@49773
   360
proof safe
wenzelm@61969
   361
  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)) \<longlonglongrightarrow> f (\<Inter>i. A i))"
hoelzl@49773
   362
  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>"
wenzelm@61969
   363
  with cont[THEN spec, of A] show "(\<lambda>i. f (A i)) \<longlonglongrightarrow> 0"
wenzelm@61808
   364
    using \<open>positive M f\<close>[unfolded positive_def] by auto
hoelzl@49773
   365
next
wenzelm@61969
   366
  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)) \<longlonglongrightarrow> 0"
hoelzl@49773
   367
  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
   368
hoelzl@49773
   369
  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
   370
    using additive_increasing[OF f] unfolding increasing_def by simp
hoelzl@49773
   371
hoelzl@49773
   372
  have decseq_fA: "decseq (\<lambda>i. f (A i))"
hoelzl@49773
   373
    using A by (auto simp: decseq_def intro!: f_mono)
hoelzl@49773
   374
  have decseq: "decseq (\<lambda>i. A i - (\<Inter>i. A i))"
hoelzl@49773
   375
    using A by (auto simp: decseq_def)
hoelzl@49773
   376
  then have decseq_f: "decseq (\<lambda>i. f (A i - (\<Inter>i. A i)))"
hoelzl@49773
   377
    using A unfolding decseq_def by (auto intro!: f_mono Diff)
hoelzl@49773
   378
  have "f (\<Inter>x. A x) \<le> f (A 0)"
hoelzl@49773
   379
    using A by (auto intro!: f_mono)
hoelzl@49773
   380
  then have f_Int_fin: "f (\<Inter>x. A x) \<noteq> \<infinity>"
hoelzl@62975
   381
    using A by (auto simp: top_unique)
hoelzl@49773
   382
  { fix i
hoelzl@49773
   383
    have "f (A i - (\<Inter>i. A i)) \<le> f (A i)" using A by (auto intro!: f_mono)
hoelzl@49773
   384
    then have "f (A i - (\<Inter>i. A i)) \<noteq> \<infinity>"
hoelzl@62975
   385
      using A by (auto simp: top_unique) }
hoelzl@49773
   386
  note f_fin = this
wenzelm@61969
   387
  have "(\<lambda>i. f (A i - (\<Inter>i. A i))) \<longlonglongrightarrow> 0"
hoelzl@49773
   388
  proof (intro cont[rule_format, OF _ decseq _ f_fin])
hoelzl@49773
   389
    show "range (\<lambda>i. A i - (\<Inter>i. A i)) \<subseteq> M" "(\<Inter>i. A i - (\<Inter>i. A i)) = {}"
hoelzl@49773
   390
      using A by auto
hoelzl@49773
   391
  qed
hoelzl@49773
   392
  from INF_Lim_ereal[OF decseq_f this]
hoelzl@49773
   393
  have "(INF n. f (A n - (\<Inter>i. A i))) = 0" .
hoelzl@49773
   394
  moreover have "(INF n. f (\<Inter>i. A i)) = f (\<Inter>i. A i)"
hoelzl@49773
   395
    by auto
hoelzl@49773
   396
  ultimately have "(INF n. f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i)) = 0 + f (\<Inter>i. A i)"
hoelzl@49773
   397
    using A(4) f_fin f_Int_fin
hoelzl@62975
   398
    by (subst INF_ennreal_add_const) (auto simp: decseq_f)
hoelzl@49773
   399
  moreover {
hoelzl@49773
   400
    fix n
hoelzl@49773
   401
    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
   402
      using A by (subst f(2)[THEN additiveD]) auto
hoelzl@49773
   403
    also have "(A n - (\<Inter>i. A i)) \<union> (\<Inter>i. A i) = A n"
hoelzl@49773
   404
      by auto
hoelzl@49773
   405
    finally have "f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i) = f (A n)" . }
hoelzl@49773
   406
  ultimately have "(INF n. f (A n)) = f (\<Inter>i. A i)"
hoelzl@49773
   407
    by simp
hoelzl@51351
   408
  with LIMSEQ_INF[OF decseq_fA]
wenzelm@61969
   409
  show "(\<lambda>i. f (A i)) \<longlonglongrightarrow> f (\<Inter>i. A i)" by simp
hoelzl@49773
   410
qed
hoelzl@49773
   411
hoelzl@49773
   412
lemma (in ring_of_sets) empty_continuous_imp_continuous_from_below:
hoelzl@62975
   413
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@49773
   414
  assumes f: "positive M f" "additive M f" "\<forall>A\<in>M. f A \<noteq> \<infinity>"
wenzelm@61969
   415
  assumes cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<lambda>i. f (A i)) \<longlonglongrightarrow> 0"
hoelzl@49773
   416
  assumes A: "range A \<subseteq> M" "incseq A" "(\<Union>i. A i) \<in> M"
wenzelm@61969
   417
  shows "(\<lambda>i. f (A i)) \<longlonglongrightarrow> f (\<Union>i. A i)"
hoelzl@49773
   418
proof -
wenzelm@61969
   419
  from A have "(\<lambda>i. f ((\<Union>i. A i) - A i)) \<longlonglongrightarrow> 0"
hoelzl@49773
   420
    by (intro cont[rule_format]) (auto simp: decseq_def incseq_def)
hoelzl@49773
   421
  moreover
hoelzl@49773
   422
  { fix i
hoelzl@62975
   423
    have "f ((\<Union>i. A i) - A i \<union> A i) = f ((\<Union>i. A i) - A i) + f (A i)"
hoelzl@62975
   424
      using A by (intro f(2)[THEN additiveD]) auto
hoelzl@62975
   425
    also have "((\<Union>i. A i) - A i) \<union> A i = (\<Union>i. A i)"
hoelzl@49773
   426
      by auto
hoelzl@62975
   427
    finally have "f ((\<Union>i. A i) - A i) = f (\<Union>i. A i) - f (A i)"
hoelzl@62975
   428
      using f(3)[rule_format, of "A i"] A by (auto simp: ennreal_add_diff_cancel subset_eq) }
hoelzl@62975
   429
  moreover have "\<forall>\<^sub>F i in sequentially. f (A i) \<le> f (\<Union>i. A i)"
hoelzl@62975
   430
    using increasingD[OF additive_increasing[OF f(1, 2)], of "A _" "\<Union>i. A i"] A
hoelzl@62975
   431
    by (auto intro!: always_eventually simp: subset_eq)
hoelzl@62975
   432
  ultimately show "(\<lambda>i. f (A i)) \<longlonglongrightarrow> f (\<Union>i. A i)"
hoelzl@62975
   433
    by (auto intro: ennreal_tendsto_const_minus)
hoelzl@49773
   434
qed
hoelzl@49773
   435
hoelzl@49773
   436
lemma (in ring_of_sets) empty_continuous_imp_countably_additive:
hoelzl@62975
   437
  fixes f :: "'a set \<Rightarrow> ennreal"
hoelzl@49773
   438
  assumes f: "positive M f" "additive M f" and fin: "\<forall>A\<in>M. f A \<noteq> \<infinity>"
wenzelm@61969
   439
  assumes cont: "\<And>A. range A \<subseteq> M \<Longrightarrow> decseq A \<Longrightarrow> (\<Inter>i. A i) = {} \<Longrightarrow> (\<lambda>i. f (A i)) \<longlonglongrightarrow> 0"
hoelzl@49773
   440
  shows "countably_additive M f"
hoelzl@49773
   441
  using countably_additive_iff_continuous_from_below[OF f]
hoelzl@49773
   442
  using empty_continuous_imp_continuous_from_below[OF f fin] cont
hoelzl@49773
   443
  by blast
hoelzl@49773
   444
wenzelm@61808
   445
subsection \<open>Properties of @{const emeasure}\<close>
hoelzl@47694
   446
hoelzl@47694
   447
lemma emeasure_positive: "positive (sets M) (emeasure M)"
hoelzl@47694
   448
  by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
hoelzl@47694
   449
hoelzl@47694
   450
lemma emeasure_empty[simp, intro]: "emeasure M {} = 0"
hoelzl@47694
   451
  using emeasure_positive[of M] by (simp add: positive_def)
hoelzl@47694
   452
hoelzl@59000
   453
lemma emeasure_single_in_space: "emeasure M {x} \<noteq> 0 \<Longrightarrow> x \<in> space M"
hoelzl@62975
   454
  using emeasure_notin_sets[of "{x}" M] by (auto dest: sets.sets_into_space zero_less_iff_neq_zero[THEN iffD2])
hoelzl@59000
   455
hoelzl@47694
   456
lemma emeasure_countably_additive: "countably_additive (sets M) (emeasure M)"
hoelzl@47694
   457
  by (cases M) (auto simp: sets_def emeasure_def Abs_measure_inverse measure_space_def)
hoelzl@47694
   458
hoelzl@47694
   459
lemma suminf_emeasure:
hoelzl@47694
   460
  "range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Sum>i. emeasure M (A i)) = emeasure M (\<Union>i. A i)"
immler@50244
   461
  using sets.countable_UN[of A UNIV M] emeasure_countably_additive[of M]
hoelzl@47694
   462
  by (simp add: countably_additive_def)
hoelzl@47694
   463
hoelzl@57447
   464
lemma sums_emeasure:
hoelzl@57447
   465
  "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@62975
   466
  unfolding sums_iff by (intro conjI suminf_emeasure) auto
hoelzl@57447
   467
hoelzl@47694
   468
lemma emeasure_additive: "additive (sets M) (emeasure M)"
immler@50244
   469
  by (metis sets.countably_additive_additive emeasure_positive emeasure_countably_additive)
hoelzl@47694
   470
hoelzl@47694
   471
lemma plus_emeasure:
hoelzl@47694
   472
  "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
   473
  using additiveD[OF emeasure_additive] ..
hoelzl@47694
   474
hoelzl@63968
   475
lemma emeasure_Union:
hoelzl@63968
   476
  "A \<in> sets M \<Longrightarrow> B \<in> sets M \<Longrightarrow> emeasure M (A \<union> B) = emeasure M A + emeasure M (B - A)"
hoelzl@63968
   477
  using plus_emeasure[of A M "B - A"] by auto
hoelzl@63968
   478
nipkow@64267
   479
lemma sum_emeasure:
hoelzl@47694
   480
  "F`I \<subseteq> sets M \<Longrightarrow> disjoint_family_on F I \<Longrightarrow> finite I \<Longrightarrow>
hoelzl@47694
   481
    (\<Sum>i\<in>I. emeasure M (F i)) = emeasure M (\<Union>i\<in>I. F i)"
immler@50244
   482
  by (metis sets.additive_sum emeasure_positive emeasure_additive)
hoelzl@47694
   483
hoelzl@47694
   484
lemma emeasure_mono:
hoelzl@47694
   485
  "a \<subseteq> b \<Longrightarrow> b \<in> sets M \<Longrightarrow> emeasure M a \<le> emeasure M b"
hoelzl@62975
   486
  by (metis zero_le sets.additive_increasing emeasure_additive emeasure_notin_sets emeasure_positive increasingD)
hoelzl@47694
   487
hoelzl@47694
   488
lemma emeasure_space:
hoelzl@47694
   489
  "emeasure M A \<le> emeasure M (space M)"
hoelzl@62975
   490
  by (metis emeasure_mono emeasure_notin_sets sets.sets_into_space sets.top zero_le)
hoelzl@47694
   491
hoelzl@47694
   492
lemma emeasure_Diff:
hoelzl@47694
   493
  assumes finite: "emeasure M B \<noteq> \<infinity>"
hoelzl@50002
   494
  and [measurable]: "A \<in> sets M" "B \<in> sets M" and "B \<subseteq> A"
hoelzl@47694
   495
  shows "emeasure M (A - B) = emeasure M A - emeasure M B"
hoelzl@47694
   496
proof -
wenzelm@61808
   497
  have "(A - B) \<union> B = A" using \<open>B \<subseteq> A\<close> by auto
hoelzl@47694
   498
  then have "emeasure M A = emeasure M ((A - B) \<union> B)" by simp
hoelzl@47694
   499
  also have "\<dots> = emeasure M (A - B) + emeasure M B"
hoelzl@50002
   500
    by (subst plus_emeasure[symmetric]) auto
hoelzl@47694
   501
  finally show "emeasure M (A - B) = emeasure M A - emeasure M B"
hoelzl@62975
   502
    using finite by simp
hoelzl@47694
   503
qed
hoelzl@47694
   504
hoelzl@62975
   505
lemma emeasure_compl:
hoelzl@62975
   506
  "s \<in> sets M \<Longrightarrow> emeasure M s \<noteq> \<infinity> \<Longrightarrow> emeasure M (space M - s) = emeasure M (space M) - emeasure M s"
hoelzl@62975
   507
  by (rule emeasure_Diff) (auto dest: sets.sets_into_space)
hoelzl@62975
   508
hoelzl@49773
   509
lemma Lim_emeasure_incseq:
wenzelm@61969
   510
  "range A \<subseteq> sets M \<Longrightarrow> incseq A \<Longrightarrow> (\<lambda>i. (emeasure M (A i))) \<longlonglongrightarrow> emeasure M (\<Union>i. A i)"
hoelzl@49773
   511
  using emeasure_countably_additive
immler@50244
   512
  by (auto simp add: sets.countably_additive_iff_continuous_from_below emeasure_positive
immler@50244
   513
    emeasure_additive)
hoelzl@47694
   514
hoelzl@47694
   515
lemma incseq_emeasure:
hoelzl@47694
   516
  assumes "range B \<subseteq> sets M" "incseq B"
hoelzl@47694
   517
  shows "incseq (\<lambda>i. emeasure M (B i))"
hoelzl@47694
   518
  using assms by (auto simp: incseq_def intro!: emeasure_mono)
hoelzl@47694
   519
hoelzl@49773
   520
lemma SUP_emeasure_incseq:
hoelzl@47694
   521
  assumes A: "range A \<subseteq> sets M" "incseq A"
hoelzl@49773
   522
  shows "(SUP n. emeasure M (A n)) = emeasure M (\<Union>i. A i)"
hoelzl@51000
   523
  using LIMSEQ_SUP[OF incseq_emeasure, OF A] Lim_emeasure_incseq[OF A]
hoelzl@49773
   524
  by (simp add: LIMSEQ_unique)
hoelzl@47694
   525
hoelzl@47694
   526
lemma decseq_emeasure:
hoelzl@47694
   527
  assumes "range B \<subseteq> sets M" "decseq B"
hoelzl@47694
   528
  shows "decseq (\<lambda>i. emeasure M (B i))"
hoelzl@47694
   529
  using assms by (auto simp: decseq_def intro!: emeasure_mono)
hoelzl@47694
   530
hoelzl@47694
   531
lemma INF_emeasure_decseq:
hoelzl@47694
   532
  assumes A: "range A \<subseteq> sets M" and "decseq A"
hoelzl@47694
   533
  and finite: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
   534
  shows "(INF n. emeasure M (A n)) = emeasure M (\<Inter>i. A i)"
hoelzl@47694
   535
proof -
hoelzl@47694
   536
  have le_MI: "emeasure M (\<Inter>i. A i) \<le> emeasure M (A 0)"
hoelzl@47694
   537
    using A by (auto intro!: emeasure_mono)
hoelzl@62975
   538
  hence *: "emeasure M (\<Inter>i. A i) \<noteq> \<infinity>" using finite[of 0] by (auto simp: top_unique)
hoelzl@47694
   539
hoelzl@62975
   540
  have "emeasure M (A 0) - (INF n. emeasure M (A n)) = (SUP n. emeasure M (A 0) - emeasure M (A n))"
hoelzl@62975
   541
    by (simp add: ennreal_INF_const_minus)
hoelzl@47694
   542
  also have "\<dots> = (SUP n. emeasure M (A 0 - A n))"
wenzelm@61808
   543
    using A finite \<open>decseq A\<close>[unfolded decseq_def] by (subst emeasure_Diff) auto
hoelzl@47694
   544
  also have "\<dots> = emeasure M (\<Union>i. A 0 - A i)"
hoelzl@47694
   545
  proof (rule SUP_emeasure_incseq)
hoelzl@47694
   546
    show "range (\<lambda>n. A 0 - A n) \<subseteq> sets M"
hoelzl@47694
   547
      using A by auto
hoelzl@47694
   548
    show "incseq (\<lambda>n. A 0 - A n)"
wenzelm@61808
   549
      using \<open>decseq A\<close> by (auto simp add: incseq_def decseq_def)
hoelzl@47694
   550
  qed
hoelzl@47694
   551
  also have "\<dots> = emeasure M (A 0) - emeasure M (\<Inter>i. A i)"
hoelzl@47694
   552
    using A finite * by (simp, subst emeasure_Diff) auto
hoelzl@47694
   553
  finally show ?thesis
hoelzl@62975
   554
    by (rule ennreal_minus_cancel[rotated 3])
hoelzl@62975
   555
       (insert finite A, auto intro: INF_lower emeasure_mono)
hoelzl@47694
   556
qed
hoelzl@47694
   557
hoelzl@63940
   558
lemma INF_emeasure_decseq':
hoelzl@63940
   559
  assumes A: "\<And>i. A i \<in> sets M" and "decseq A"
hoelzl@63940
   560
  and finite: "\<exists>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@63940
   561
  shows "(INF n. emeasure M (A n)) = emeasure M (\<Inter>i. A i)"
hoelzl@63940
   562
proof -
hoelzl@63940
   563
  from finite obtain i where i: "emeasure M (A i) < \<infinity>"
hoelzl@63940
   564
    by (auto simp: less_top)
hoelzl@63940
   565
  have fin: "i \<le> j \<Longrightarrow> emeasure M (A j) < \<infinity>" for j
hoelzl@63940
   566
    by (rule le_less_trans[OF emeasure_mono i]) (auto intro!: decseqD[OF \<open>decseq A\<close>] A)
hoelzl@63940
   567
hoelzl@63940
   568
  have "(INF n. emeasure M (A n)) = (INF n. emeasure M (A (n + i)))"
hoelzl@63940
   569
  proof (rule INF_eq)
hoelzl@63940
   570
    show "\<exists>j\<in>UNIV. emeasure M (A (j + i)) \<le> emeasure M (A i')" for i'
hoelzl@63940
   571
      by (intro bexI[of _ i'] emeasure_mono decseqD[OF \<open>decseq A\<close>] A) auto
hoelzl@63940
   572
  qed auto
hoelzl@63940
   573
  also have "\<dots> = emeasure M (INF n. (A (n + i)))"
hoelzl@63940
   574
    using A \<open>decseq A\<close> fin by (intro INF_emeasure_decseq) (auto simp: decseq_def less_top)
hoelzl@63940
   575
  also have "(INF n. (A (n + i))) = (INF n. A n)"
hoelzl@63940
   576
    by (meson INF_eq UNIV_I assms(2) decseqD le_add1)
hoelzl@63940
   577
  finally show ?thesis .
hoelzl@63940
   578
qed
hoelzl@63940
   579
hoelzl@61359
   580
lemma emeasure_INT_decseq_subset:
hoelzl@61359
   581
  fixes F :: "nat \<Rightarrow> 'a set"
hoelzl@61359
   582
  assumes I: "I \<noteq> {}" and F: "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> i \<le> j \<Longrightarrow> F j \<subseteq> F i"
hoelzl@61359
   583
  assumes F_sets[measurable]: "\<And>i. i \<in> I \<Longrightarrow> F i \<in> sets M"
hoelzl@61359
   584
    and fin: "\<And>i. i \<in> I \<Longrightarrow> emeasure M (F i) \<noteq> \<infinity>"
hoelzl@61359
   585
  shows "emeasure M (\<Inter>i\<in>I. F i) = (INF i:I. emeasure M (F i))"
hoelzl@61359
   586
proof cases
hoelzl@61359
   587
  assume "finite I"
hoelzl@61359
   588
  have "(\<Inter>i\<in>I. F i) = F (Max I)"
hoelzl@61359
   589
    using I \<open>finite I\<close> by (intro antisym INF_lower INF_greatest F) auto
hoelzl@61359
   590
  moreover have "(INF i:I. emeasure M (F i)) = emeasure M (F (Max I))"
hoelzl@61359
   591
    using I \<open>finite I\<close> by (intro antisym INF_lower INF_greatest F emeasure_mono) auto
hoelzl@61359
   592
  ultimately show ?thesis
hoelzl@61359
   593
    by simp
hoelzl@61359
   594
next
hoelzl@61359
   595
  assume "infinite I"
wenzelm@63040
   596
  define L where "L n = (LEAST i. i \<in> I \<and> i \<ge> n)" for n
hoelzl@61359
   597
  have L: "L n \<in> I \<and> n \<le> L n" for n
hoelzl@61359
   598
    unfolding L_def
hoelzl@61359
   599
  proof (rule LeastI_ex)
hoelzl@61359
   600
    show "\<exists>x. x \<in> I \<and> n \<le> x"
hoelzl@61359
   601
      using \<open>infinite I\<close> finite_subset[of I "{..< n}"]
hoelzl@61359
   602
      by (rule_tac ccontr) (auto simp: not_le)
hoelzl@61359
   603
  qed
hoelzl@61359
   604
  have L_eq[simp]: "i \<in> I \<Longrightarrow> L i = i" for i
hoelzl@61359
   605
    unfolding L_def by (intro Least_equality) auto
hoelzl@61359
   606
  have L_mono: "i \<le> j \<Longrightarrow> L i \<le> L j" for i j
hoelzl@61359
   607
    using L[of j] unfolding L_def by (intro Least_le) (auto simp: L_def)
hoelzl@61359
   608
hoelzl@61359
   609
  have "emeasure M (\<Inter>i. F (L i)) = (INF i. emeasure M (F (L i)))"
hoelzl@61359
   610
  proof (intro INF_emeasure_decseq[symmetric])
hoelzl@61359
   611
    show "decseq (\<lambda>i. F (L i))"
hoelzl@61359
   612
      using L by (intro antimonoI F L_mono) auto
hoelzl@61359
   613
  qed (insert L fin, auto)
hoelzl@61359
   614
  also have "\<dots> = (INF i:I. emeasure M (F i))"
hoelzl@61359
   615
  proof (intro antisym INF_greatest)
hoelzl@61359
   616
    show "i \<in> I \<Longrightarrow> (INF i. emeasure M (F (L i))) \<le> emeasure M (F i)" for i
hoelzl@61359
   617
      by (intro INF_lower2[of i]) auto
hoelzl@61359
   618
  qed (insert L, auto intro: INF_lower)
hoelzl@61359
   619
  also have "(\<Inter>i. F (L i)) = (\<Inter>i\<in>I. F i)"
hoelzl@61359
   620
  proof (intro antisym INF_greatest)
hoelzl@61359
   621
    show "i \<in> I \<Longrightarrow> (\<Inter>i. F (L i)) \<subseteq> F i" for i
hoelzl@61359
   622
      by (intro INF_lower2[of i]) auto
hoelzl@61359
   623
  qed (insert L, auto)
hoelzl@61359
   624
  finally show ?thesis .
hoelzl@61359
   625
qed
hoelzl@61359
   626
hoelzl@47694
   627
lemma Lim_emeasure_decseq:
hoelzl@47694
   628
  assumes A: "range A \<subseteq> sets M" "decseq A" and fin: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
wenzelm@61969
   629
  shows "(\<lambda>i. emeasure M (A i)) \<longlonglongrightarrow> emeasure M (\<Inter>i. A i)"
hoelzl@51351
   630
  using LIMSEQ_INF[OF decseq_emeasure, OF A]
hoelzl@47694
   631
  using INF_emeasure_decseq[OF A fin] by simp
hoelzl@47694
   632
hoelzl@60636
   633
lemma emeasure_lfp'[consumes 1, case_names cont measurable]:
hoelzl@59000
   634
  assumes "P M"
hoelzl@60172
   635
  assumes cont: "sup_continuous F"
hoelzl@59000
   636
  assumes *: "\<And>M A. P M \<Longrightarrow> (\<And>N. P N \<Longrightarrow> Measurable.pred N A) \<Longrightarrow> Measurable.pred M (F A)"
hoelzl@59000
   637
  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
   638
proof -
hoelzl@59000
   639
  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
   640
    using sup_continuous_lfp[OF cont] by (auto simp add: bot_fun_def intro!: arg_cong2[where f=emeasure])
wenzelm@61808
   641
  moreover { fix i from \<open>P M\<close> have "{x\<in>space M. (F ^^ i) (\<lambda>x. False) x} \<in> sets M"
hoelzl@59000
   642
    by (induct i arbitrary: M) (auto simp add: pred_def[symmetric] intro: *) }
hoelzl@59000
   643
  moreover have "incseq (\<lambda>i. {x\<in>space M. (F ^^ i) (\<lambda>x. False) x})"
hoelzl@59000
   644
  proof (rule incseq_SucI)
hoelzl@59000
   645
    fix i
hoelzl@59000
   646
    have "(F ^^ i) (\<lambda>x. False) \<le> (F ^^ (Suc i)) (\<lambda>x. False)"
hoelzl@59000
   647
    proof (induct i)
hoelzl@59000
   648
      case 0 show ?case by (simp add: le_fun_def)
hoelzl@59000
   649
    next
hoelzl@60172
   650
      case Suc thus ?case using monoD[OF sup_continuous_mono[OF cont] Suc] by auto
hoelzl@59000
   651
    qed
hoelzl@59000
   652
    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
   653
      by auto
hoelzl@59000
   654
  qed
hoelzl@59000
   655
  ultimately show ?thesis
hoelzl@59000
   656
    by (subst SUP_emeasure_incseq) auto
hoelzl@59000
   657
qed
hoelzl@59000
   658
hoelzl@60636
   659
lemma emeasure_lfp:
hoelzl@60636
   660
  assumes [simp]: "\<And>s. sets (M s) = sets N"
hoelzl@60636
   661
  assumes cont: "sup_continuous F" "sup_continuous f"
hoelzl@60636
   662
  assumes meas: "\<And>P. Measurable.pred N P \<Longrightarrow> Measurable.pred N (F P)"
hoelzl@60714
   663
  assumes iter: "\<And>P s. Measurable.pred N P \<Longrightarrow> P \<le> lfp F \<Longrightarrow> emeasure (M s) {x\<in>space N. F P x} = f (\<lambda>s. emeasure (M s) {x\<in>space N. P x}) s"
hoelzl@60636
   664
  shows "emeasure (M s) {x\<in>space N. lfp F x} = lfp f s"
hoelzl@60636
   665
proof (subst lfp_transfer_bounded[where \<alpha>="\<lambda>F s. emeasure (M s) {x\<in>space N. F x}" and g=f and f=F and P="Measurable.pred N", symmetric])
hoelzl@60636
   666
  fix C assume "incseq C" "\<And>i. Measurable.pred N (C i)"
hoelzl@60636
   667
  then show "(\<lambda>s. emeasure (M s) {x \<in> space N. (SUP i. C i) x}) = (SUP i. (\<lambda>s. emeasure (M s) {x \<in> space N. C i x}))"
hoelzl@60636
   668
    unfolding SUP_apply[abs_def]
hoelzl@60636
   669
    by (subst SUP_emeasure_incseq) (auto simp: mono_def fun_eq_iff intro!: arg_cong2[where f=emeasure])
hoelzl@62975
   670
qed (auto simp add: iter le_fun_def SUP_apply[abs_def] intro!: meas cont)
hoelzl@47694
   671
hoelzl@47694
   672
lemma emeasure_subadditive_finite:
hoelzl@62975
   673
  "finite I \<Longrightarrow> A ` I \<subseteq> sets M \<Longrightarrow> emeasure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. emeasure M (A i))"
hoelzl@62975
   674
  by (rule sets.subadditive[OF emeasure_positive emeasure_additive]) auto
hoelzl@62975
   675
hoelzl@62975
   676
lemma emeasure_subadditive:
hoelzl@62975
   677
  "A \<in> sets M \<Longrightarrow> B \<in> sets M \<Longrightarrow> emeasure M (A \<union> B) \<le> emeasure M A + emeasure M B"
hoelzl@62975
   678
  using emeasure_subadditive_finite[of "{True, False}" "\<lambda>True \<Rightarrow> A | False \<Rightarrow> B" M] by simp
hoelzl@47694
   679
hoelzl@47694
   680
lemma emeasure_subadditive_countably:
hoelzl@47694
   681
  assumes "range f \<subseteq> sets M"
hoelzl@47694
   682
  shows "emeasure M (\<Union>i. f i) \<le> (\<Sum>i. emeasure M (f i))"
hoelzl@47694
   683
proof -
hoelzl@47694
   684
  have "emeasure M (\<Union>i. f i) = emeasure M (\<Union>i. disjointed f i)"
hoelzl@47694
   685
    unfolding UN_disjointed_eq ..
hoelzl@47694
   686
  also have "\<dots> = (\<Sum>i. emeasure M (disjointed f i))"
immler@50244
   687
    using sets.range_disjointed_sets[OF assms] suminf_emeasure[of "disjointed f"]
hoelzl@47694
   688
    by (simp add:  disjoint_family_disjointed comp_def)
hoelzl@47694
   689
  also have "\<dots> \<le> (\<Sum>i. emeasure M (f i))"
immler@50244
   690
    using sets.range_disjointed_sets[OF assms] assms
hoelzl@62975
   691
    by (auto intro!: suminf_le emeasure_mono disjointed_subset)
hoelzl@47694
   692
  finally show ?thesis .
hoelzl@47694
   693
qed
hoelzl@47694
   694
hoelzl@47694
   695
lemma emeasure_insert:
hoelzl@47694
   696
  assumes sets: "{x} \<in> sets M" "A \<in> sets M" and "x \<notin> A"
hoelzl@47694
   697
  shows "emeasure M (insert x A) = emeasure M {x} + emeasure M A"
hoelzl@47694
   698
proof -
wenzelm@61808
   699
  have "{x} \<inter> A = {}" using \<open>x \<notin> A\<close> by auto
hoelzl@47694
   700
  from plus_emeasure[OF sets this] show ?thesis by simp
hoelzl@47694
   701
qed
hoelzl@47694
   702
hoelzl@57447
   703
lemma emeasure_insert_ne:
hoelzl@57447
   704
  "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"
lp15@61609
   705
  by (rule emeasure_insert)
hoelzl@57447
   706
nipkow@64267
   707
lemma emeasure_eq_sum_singleton:
hoelzl@47694
   708
  assumes "finite S" "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
hoelzl@47694
   709
  shows "emeasure M S = (\<Sum>x\<in>S. emeasure M {x})"
nipkow@64267
   710
  using sum_emeasure[of "\<lambda>x. {x}" S M] assms
hoelzl@47694
   711
  by (auto simp: disjoint_family_on_def subset_eq)
hoelzl@47694
   712
nipkow@64267
   713
lemma sum_emeasure_cover:
hoelzl@47694
   714
  assumes "finite S" and "A \<in> sets M" and br_in_M: "B ` S \<subseteq> sets M"
hoelzl@47694
   715
  assumes A: "A \<subseteq> (\<Union>i\<in>S. B i)"
hoelzl@47694
   716
  assumes disj: "disjoint_family_on B S"
hoelzl@47694
   717
  shows "emeasure M A = (\<Sum>i\<in>S. emeasure M (A \<inter> (B i)))"
hoelzl@47694
   718
proof -
hoelzl@47694
   719
  have "(\<Sum>i\<in>S. emeasure M (A \<inter> (B i))) = emeasure M (\<Union>i\<in>S. A \<inter> (B i))"
nipkow@64267
   720
  proof (rule sum_emeasure)
hoelzl@47694
   721
    show "disjoint_family_on (\<lambda>i. A \<inter> B i) S"
wenzelm@61808
   722
      using \<open>disjoint_family_on B S\<close>
hoelzl@47694
   723
      unfolding disjoint_family_on_def by auto
hoelzl@47694
   724
  qed (insert assms, auto)
hoelzl@47694
   725
  also have "(\<Union>i\<in>S. A \<inter> (B i)) = A"
hoelzl@47694
   726
    using A by auto
hoelzl@47694
   727
  finally show ?thesis by simp
hoelzl@47694
   728
qed
hoelzl@47694
   729
hoelzl@47694
   730
lemma emeasure_eq_0:
hoelzl@47694
   731
  "N \<in> sets M \<Longrightarrow> emeasure M N = 0 \<Longrightarrow> K \<subseteq> N \<Longrightarrow> emeasure M K = 0"
hoelzl@62975
   732
  by (metis emeasure_mono order_eq_iff zero_le)
hoelzl@47694
   733
hoelzl@47694
   734
lemma emeasure_UN_eq_0:
hoelzl@47694
   735
  assumes "\<And>i::nat. emeasure M (N i) = 0" and "range N \<subseteq> sets M"
wenzelm@60585
   736
  shows "emeasure M (\<Union>i. N i) = 0"
hoelzl@47694
   737
proof -
hoelzl@62975
   738
  have "emeasure M (\<Union>i. N i) \<le> 0"
hoelzl@47694
   739
    using emeasure_subadditive_countably[OF assms(2)] assms(1) by simp
hoelzl@62975
   740
  then show ?thesis
hoelzl@62975
   741
    by (auto intro: antisym zero_le)
hoelzl@47694
   742
qed
hoelzl@47694
   743
hoelzl@47694
   744
lemma measure_eqI_finite:
hoelzl@47694
   745
  assumes [simp]: "sets M = Pow A" "sets N = Pow A" and "finite A"
hoelzl@47694
   746
  assumes eq: "\<And>a. a \<in> A \<Longrightarrow> emeasure M {a} = emeasure N {a}"
hoelzl@47694
   747
  shows "M = N"
hoelzl@47694
   748
proof (rule measure_eqI)
hoelzl@47694
   749
  fix X assume "X \<in> sets M"
hoelzl@47694
   750
  then have X: "X \<subseteq> A" by auto
hoelzl@47694
   751
  then have "emeasure M X = (\<Sum>a\<in>X. emeasure M {a})"
nipkow@64267
   752
    using \<open>finite A\<close> by (subst emeasure_eq_sum_singleton) (auto dest: finite_subset)
hoelzl@47694
   753
  also have "\<dots> = (\<Sum>a\<in>X. emeasure N {a})"
nipkow@64267
   754
    using X eq by (auto intro!: sum.cong)
hoelzl@47694
   755
  also have "\<dots> = emeasure N X"
nipkow@64267
   756
    using X \<open>finite A\<close> by (subst emeasure_eq_sum_singleton) (auto dest: finite_subset)
hoelzl@47694
   757
  finally show "emeasure M X = emeasure N X" .
hoelzl@47694
   758
qed simp
hoelzl@47694
   759
hoelzl@47694
   760
lemma measure_eqI_generator_eq:
hoelzl@47694
   761
  fixes M N :: "'a measure" and E :: "'a set set" and A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
   762
  assumes "Int_stable E" "E \<subseteq> Pow \<Omega>"
hoelzl@47694
   763
  and eq: "\<And>X. X \<in> E \<Longrightarrow> emeasure M X = emeasure N X"
hoelzl@47694
   764
  and M: "sets M = sigma_sets \<Omega> E"
hoelzl@47694
   765
  and N: "sets N = sigma_sets \<Omega> E"
hoelzl@49784
   766
  and A: "range A \<subseteq> E" "(\<Union>i. A i) = \<Omega>" "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@47694
   767
  shows "M = N"
hoelzl@47694
   768
proof -
hoelzl@49773
   769
  let ?\<mu>  = "emeasure M" and ?\<nu> = "emeasure N"
hoelzl@47694
   770
  interpret S: sigma_algebra \<Omega> "sigma_sets \<Omega> E" by (rule sigma_algebra_sigma_sets) fact
hoelzl@49789
   771
  have "space M = \<Omega>"
wenzelm@61808
   772
    using sets.top[of M] sets.space_closed[of M] S.top S.space_closed \<open>sets M = sigma_sets \<Omega> E\<close>
immler@50244
   773
    by blast
hoelzl@49789
   774
hoelzl@49789
   775
  { fix F D assume "F \<in> E" and "?\<mu> F \<noteq> \<infinity>"
hoelzl@47694
   776
    then have [intro]: "F \<in> sigma_sets \<Omega> E" by auto
wenzelm@61808
   777
    have "?\<nu> F \<noteq> \<infinity>" using \<open>?\<mu> F \<noteq> \<infinity>\<close> \<open>F \<in> E\<close> eq by simp
hoelzl@49789
   778
    assume "D \<in> sets M"
wenzelm@61808
   779
    with \<open>Int_stable E\<close> \<open>E \<subseteq> Pow \<Omega>\<close> have "emeasure M (F \<inter> D) = emeasure N (F \<inter> D)"
hoelzl@49789
   780
      unfolding M
hoelzl@49789
   781
    proof (induct rule: sigma_sets_induct_disjoint)
hoelzl@49789
   782
      case (basic A)
wenzelm@61808
   783
      then have "F \<inter> A \<in> E" using \<open>Int_stable E\<close> \<open>F \<in> E\<close> by (auto simp: Int_stable_def)
hoelzl@49789
   784
      then show ?case using eq by auto
hoelzl@47694
   785
    next
hoelzl@49789
   786
      case empty then show ?case by simp
hoelzl@47694
   787
    next
hoelzl@49789
   788
      case (compl A)
hoelzl@47694
   789
      then have **: "F \<inter> (\<Omega> - A) = F - (F \<inter> A)"
hoelzl@47694
   790
        and [intro]: "F \<inter> A \<in> sigma_sets \<Omega> E"
wenzelm@61808
   791
        using \<open>F \<in> E\<close> S.sets_into_space by (auto simp: M)
hoelzl@49773
   792
      have "?\<nu> (F \<inter> A) \<le> ?\<nu> F" by (auto intro!: emeasure_mono simp: M N)
hoelzl@62975
   793
      then have "?\<nu> (F \<inter> A) \<noteq> \<infinity>" using \<open>?\<nu> F \<noteq> \<infinity>\<close> by (auto simp: top_unique)
hoelzl@49773
   794
      have "?\<mu> (F \<inter> A) \<le> ?\<mu> F" by (auto intro!: emeasure_mono simp: M N)
hoelzl@62975
   795
      then have "?\<mu> (F \<inter> A) \<noteq> \<infinity>" using \<open>?\<mu> F \<noteq> \<infinity>\<close> by (auto simp: top_unique)
hoelzl@49773
   796
      then have "?\<mu> (F \<inter> (\<Omega> - A)) = ?\<mu> F - ?\<mu> (F \<inter> A)" unfolding **
wenzelm@61808
   797
        using \<open>F \<inter> A \<in> sigma_sets \<Omega> E\<close> by (auto intro!: emeasure_Diff simp: M N)
wenzelm@61808
   798
      also have "\<dots> = ?\<nu> F - ?\<nu> (F \<inter> A)" using eq \<open>F \<in> E\<close> compl by simp
hoelzl@49773
   799
      also have "\<dots> = ?\<nu> (F \<inter> (\<Omega> - A))" unfolding **
wenzelm@61808
   800
        using \<open>F \<inter> A \<in> sigma_sets \<Omega> E\<close> \<open>?\<nu> (F \<inter> A) \<noteq> \<infinity>\<close>
hoelzl@47694
   801
        by (auto intro!: emeasure_Diff[symmetric] simp: M N)
hoelzl@49789
   802
      finally show ?case
wenzelm@61808
   803
        using \<open>space M = \<Omega>\<close> by auto
hoelzl@47694
   804
    next
hoelzl@49789
   805
      case (union A)
hoelzl@49773
   806
      then have "?\<mu> (\<Union>x. F \<inter> A x) = ?\<nu> (\<Union>x. F \<inter> A x)"
hoelzl@49773
   807
        by (subst (1 2) suminf_emeasure[symmetric]) (auto simp: disjoint_family_on_def subset_eq M N)
hoelzl@49789
   808
      with A show ?case
hoelzl@49773
   809
        by auto
hoelzl@49789
   810
    qed }
hoelzl@47694
   811
  note * = this
hoelzl@47694
   812
  show "M = N"
hoelzl@47694
   813
  proof (rule measure_eqI)
hoelzl@47694
   814
    show "sets M = sets N"
hoelzl@47694
   815
      using M N by simp
hoelzl@49784
   816
    have [simp, intro]: "\<And>i. A i \<in> sets M"
hoelzl@49784
   817
      using A(1) by (auto simp: subset_eq M)
hoelzl@49773
   818
    fix F assume "F \<in> sets M"
hoelzl@49784
   819
    let ?D = "disjointed (\<lambda>i. F \<inter> A i)"
wenzelm@61808
   820
    from \<open>space M = \<Omega>\<close> have F_eq: "F = (\<Union>i. ?D i)"
wenzelm@61808
   821
      using \<open>F \<in> sets M\<close>[THEN sets.sets_into_space] A(2)[symmetric] by (auto simp: UN_disjointed_eq)
hoelzl@49784
   822
    have [simp, intro]: "\<And>i. ?D i \<in> sets M"
wenzelm@61808
   823
      using sets.range_disjointed_sets[of "\<lambda>i. F \<inter> A i" M] \<open>F \<in> sets M\<close>
hoelzl@49784
   824
      by (auto simp: subset_eq)
hoelzl@49784
   825
    have "disjoint_family ?D"
hoelzl@49784
   826
      by (auto simp: disjoint_family_disjointed)
hoelzl@50002
   827
    moreover
hoelzl@50002
   828
    have "(\<Sum>i. emeasure M (?D i)) = (\<Sum>i. emeasure N (?D i))"
hoelzl@50002
   829
    proof (intro arg_cong[where f=suminf] ext)
hoelzl@50002
   830
      fix i
hoelzl@49784
   831
      have "A i \<inter> ?D i = ?D i"
hoelzl@49784
   832
        by (auto simp: disjointed_def)
hoelzl@50002
   833
      then show "emeasure M (?D i) = emeasure N (?D i)"
hoelzl@50002
   834
        using *[of "A i" "?D i", OF _ A(3)] A(1) by auto
hoelzl@50002
   835
    qed
hoelzl@50002
   836
    ultimately show "emeasure M F = emeasure N F"
wenzelm@61808
   837
      by (simp add: image_subset_iff \<open>sets M = sets N\<close>[symmetric] F_eq[symmetric] suminf_emeasure)
hoelzl@47694
   838
  qed
hoelzl@47694
   839
qed
hoelzl@47694
   840
hoelzl@64008
   841
lemma space_empty: "space M = {} \<Longrightarrow> M = count_space {}"
hoelzl@64008
   842
  by (rule measure_eqI) (simp_all add: space_empty_iff)
hoelzl@64008
   843
hoelzl@64008
   844
lemma measure_eqI_generator_eq_countable:
hoelzl@64008
   845
  fixes M N :: "'a measure" and E :: "'a set set" and A :: "'a set set"
hoelzl@64008
   846
  assumes E: "Int_stable E" "E \<subseteq> Pow \<Omega>" "\<And>X. X \<in> E \<Longrightarrow> emeasure M X = emeasure N X"
hoelzl@64008
   847
    and sets: "sets M = sigma_sets \<Omega> E" "sets N = sigma_sets \<Omega> E"
hoelzl@64008
   848
  and A: "A \<subseteq> E" "(\<Union>A) = \<Omega>" "countable A" "\<And>a. a \<in> A \<Longrightarrow> emeasure M a \<noteq> \<infinity>"
hoelzl@64008
   849
  shows "M = N"
hoelzl@64008
   850
proof cases
hoelzl@64008
   851
  assume "\<Omega> = {}"
hoelzl@64008
   852
  have *: "sigma_sets \<Omega> E = sets (sigma \<Omega> E)"
hoelzl@64008
   853
    using E(2) by simp
hoelzl@64008
   854
  have "space M = \<Omega>" "space N = \<Omega>"
hoelzl@64008
   855
    using sets E(2) unfolding * by (auto dest: sets_eq_imp_space_eq simp del: sets_measure_of)
hoelzl@64008
   856
  then show "M = N"
hoelzl@64008
   857
    unfolding \<open>\<Omega> = {}\<close> by (auto dest: space_empty)
hoelzl@64008
   858
next
hoelzl@64008
   859
  assume "\<Omega> \<noteq> {}" with \<open>\<Union>A = \<Omega>\<close> have "A \<noteq> {}" by auto
hoelzl@64008
   860
  from this \<open>countable A\<close> have rng: "range (from_nat_into A) = A"
hoelzl@64008
   861
    by (rule range_from_nat_into)
hoelzl@64008
   862
  show "M = N"
hoelzl@64008
   863
  proof (rule measure_eqI_generator_eq[OF E sets])
hoelzl@64008
   864
    show "range (from_nat_into A) \<subseteq> E"
hoelzl@64008
   865
      unfolding rng using \<open>A \<subseteq> E\<close> .
hoelzl@64008
   866
    show "(\<Union>i. from_nat_into A i) = \<Omega>"
hoelzl@64008
   867
      unfolding rng using \<open>\<Union>A = \<Omega>\<close> .
hoelzl@64008
   868
    show "emeasure M (from_nat_into A i) \<noteq> \<infinity>" for i
hoelzl@64008
   869
      using rng by (intro A) auto
hoelzl@64008
   870
  qed
hoelzl@64008
   871
qed
hoelzl@64008
   872
hoelzl@47694
   873
lemma measure_of_of_measure: "measure_of (space M) (sets M) (emeasure M) = M"
hoelzl@47694
   874
proof (intro measure_eqI emeasure_measure_of_sigma)
hoelzl@47694
   875
  show "sigma_algebra (space M) (sets M)" ..
hoelzl@47694
   876
  show "positive (sets M) (emeasure M)"
hoelzl@62975
   877
    by (simp add: positive_def)
hoelzl@47694
   878
  show "countably_additive (sets M) (emeasure M)"
hoelzl@47694
   879
    by (simp add: emeasure_countably_additive)
hoelzl@47694
   880
qed simp_all
hoelzl@47694
   881
wenzelm@61808
   882
subsection \<open>\<open>\<mu>\<close>-null sets\<close>
hoelzl@47694
   883
hoelzl@47694
   884
definition null_sets :: "'a measure \<Rightarrow> 'a set set" where
hoelzl@47694
   885
  "null_sets M = {N\<in>sets M. emeasure M N = 0}"
hoelzl@47694
   886
hoelzl@47694
   887
lemma null_setsD1[dest]: "A \<in> null_sets M \<Longrightarrow> emeasure M A = 0"
hoelzl@47694
   888
  by (simp add: null_sets_def)
hoelzl@47694
   889
hoelzl@47694
   890
lemma null_setsD2[dest]: "A \<in> null_sets M \<Longrightarrow> A \<in> sets M"
hoelzl@47694
   891
  unfolding null_sets_def by simp
hoelzl@47694
   892
hoelzl@47694
   893
lemma null_setsI[intro]: "emeasure M A = 0 \<Longrightarrow> A \<in> sets M \<Longrightarrow> A \<in> null_sets M"
hoelzl@47694
   894
  unfolding null_sets_def by simp
hoelzl@47694
   895
hoelzl@47694
   896
interpretation null_sets: ring_of_sets "space M" "null_sets M" for M
hoelzl@47762
   897
proof (rule ring_of_setsI)
hoelzl@47694
   898
  show "null_sets M \<subseteq> Pow (space M)"
immler@50244
   899
    using sets.sets_into_space by auto
hoelzl@47694
   900
  show "{} \<in> null_sets M"
hoelzl@47694
   901
    by auto
wenzelm@53374
   902
  fix A B assume null_sets: "A \<in> null_sets M" "B \<in> null_sets M"
wenzelm@53374
   903
  then have sets: "A \<in> sets M" "B \<in> sets M"
hoelzl@47694
   904
    by auto
wenzelm@53374
   905
  then have *: "emeasure M (A \<union> B) \<le> emeasure M A + emeasure M B"
hoelzl@47694
   906
    "emeasure M (A - B) \<le> emeasure M A"
hoelzl@47694
   907
    by (auto intro!: emeasure_subadditive emeasure_mono)
wenzelm@53374
   908
  then have "emeasure M B = 0" "emeasure M A = 0"
wenzelm@53374
   909
    using null_sets by auto
wenzelm@53374
   910
  with sets * show "A - B \<in> null_sets M" "A \<union> B \<in> null_sets M"
hoelzl@62975
   911
    by (auto intro!: antisym zero_le)
hoelzl@47694
   912
qed
hoelzl@47694
   913
lp15@61609
   914
lemma UN_from_nat_into:
hoelzl@57275
   915
  assumes I: "countable I" "I \<noteq> {}"
hoelzl@57275
   916
  shows "(\<Union>i\<in>I. N i) = (\<Union>i. N (from_nat_into I i))"
hoelzl@47694
   917
proof -
hoelzl@57275
   918
  have "(\<Union>i\<in>I. N i) = \<Union>(N ` range (from_nat_into I))"
hoelzl@57275
   919
    using I by simp
hoelzl@57275
   920
  also have "\<dots> = (\<Union>i. (N \<circ> from_nat_into I) i)"
haftmann@62343
   921
    by simp
hoelzl@57275
   922
  finally show ?thesis by simp
hoelzl@57275
   923
qed
hoelzl@57275
   924
hoelzl@57275
   925
lemma null_sets_UN':
hoelzl@57275
   926
  assumes "countable I"
hoelzl@57275
   927
  assumes "\<And>i. i \<in> I \<Longrightarrow> N i \<in> null_sets M"
hoelzl@57275
   928
  shows "(\<Union>i\<in>I. N i) \<in> null_sets M"
hoelzl@57275
   929
proof cases
hoelzl@57275
   930
  assume "I = {}" then show ?thesis by simp
hoelzl@57275
   931
next
hoelzl@57275
   932
  assume "I \<noteq> {}"
hoelzl@57275
   933
  show ?thesis
hoelzl@57275
   934
  proof (intro conjI CollectI null_setsI)
hoelzl@57275
   935
    show "(\<Union>i\<in>I. N i) \<in> sets M"
hoelzl@57275
   936
      using assms by (intro sets.countable_UN') auto
hoelzl@57275
   937
    have "emeasure M (\<Union>i\<in>I. N i) \<le> (\<Sum>n. emeasure M (N (from_nat_into I n)))"
wenzelm@61808
   938
      unfolding UN_from_nat_into[OF \<open>countable I\<close> \<open>I \<noteq> {}\<close>]
wenzelm@61808
   939
      using assms \<open>I \<noteq> {}\<close> by (intro emeasure_subadditive_countably) (auto intro: from_nat_into)
hoelzl@57275
   940
    also have "(\<lambda>n. emeasure M (N (from_nat_into I n))) = (\<lambda>_. 0)"
wenzelm@61808
   941
      using assms \<open>I \<noteq> {}\<close> by (auto intro: from_nat_into)
hoelzl@57275
   942
    finally show "emeasure M (\<Union>i\<in>I. N i) = 0"
hoelzl@62975
   943
      by (intro antisym zero_le) simp
hoelzl@57275
   944
  qed
hoelzl@47694
   945
qed
hoelzl@47694
   946
hoelzl@47694
   947
lemma null_sets_UN[intro]:
hoelzl@57275
   948
  "(\<And>i::'i::countable. N i \<in> null_sets M) \<Longrightarrow> (\<Union>i. N i) \<in> null_sets M"
hoelzl@57275
   949
  by (rule null_sets_UN') auto
hoelzl@47694
   950
hoelzl@47694
   951
lemma null_set_Int1:
hoelzl@47694
   952
  assumes "B \<in> null_sets M" "A \<in> sets M" shows "A \<inter> B \<in> null_sets M"
hoelzl@47694
   953
proof (intro CollectI conjI null_setsI)
hoelzl@47694
   954
  show "emeasure M (A \<inter> B) = 0" using assms
hoelzl@47694
   955
    by (intro emeasure_eq_0[of B _ "A \<inter> B"]) auto
hoelzl@47694
   956
qed (insert assms, auto)
hoelzl@47694
   957
hoelzl@47694
   958
lemma null_set_Int2:
hoelzl@47694
   959
  assumes "B \<in> null_sets M" "A \<in> sets M" shows "B \<inter> A \<in> null_sets M"
hoelzl@47694
   960
  using assms by (subst Int_commute) (rule null_set_Int1)
hoelzl@47694
   961
hoelzl@47694
   962
lemma emeasure_Diff_null_set:
hoelzl@47694
   963
  assumes "B \<in> null_sets M" "A \<in> sets M"
hoelzl@47694
   964
  shows "emeasure M (A - B) = emeasure M A"
hoelzl@47694
   965
proof -
hoelzl@47694
   966
  have *: "A - B = (A - (A \<inter> B))" by auto
hoelzl@47694
   967
  have "A \<inter> B \<in> null_sets M" using assms by (rule null_set_Int1)
hoelzl@47694
   968
  then show ?thesis
hoelzl@47694
   969
    unfolding * using assms
hoelzl@47694
   970
    by (subst emeasure_Diff) auto
hoelzl@47694
   971
qed
hoelzl@47694
   972
hoelzl@47694
   973
lemma null_set_Diff:
hoelzl@47694
   974
  assumes "B \<in> null_sets M" "A \<in> sets M" shows "B - A \<in> null_sets M"
hoelzl@47694
   975
proof (intro CollectI conjI null_setsI)
hoelzl@47694
   976
  show "emeasure M (B - A) = 0" using assms by (intro emeasure_eq_0[of B _ "B - A"]) auto
hoelzl@47694
   977
qed (insert assms, auto)
hoelzl@47694
   978
hoelzl@47694
   979
lemma emeasure_Un_null_set:
hoelzl@47694
   980
  assumes "A \<in> sets M" "B \<in> null_sets M"
hoelzl@47694
   981
  shows "emeasure M (A \<union> B) = emeasure M A"
hoelzl@47694
   982
proof -
hoelzl@47694
   983
  have *: "A \<union> B = A \<union> (B - A)" by auto
hoelzl@47694
   984
  have "B - A \<in> null_sets M" using assms(2,1) by (rule null_set_Diff)
hoelzl@47694
   985
  then show ?thesis
hoelzl@47694
   986
    unfolding * using assms
hoelzl@47694
   987
    by (subst plus_emeasure[symmetric]) auto
hoelzl@47694
   988
qed
hoelzl@47694
   989
wenzelm@61808
   990
subsection \<open>The almost everywhere filter (i.e.\ quantifier)\<close>
hoelzl@47694
   991
hoelzl@47694
   992
definition ae_filter :: "'a measure \<Rightarrow> 'a filter" where
hoelzl@57276
   993
  "ae_filter M = (INF N:null_sets M. principal (space M - N))"
hoelzl@47694
   994
hoelzl@57276
   995
abbreviation almost_everywhere :: "'a measure \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where
hoelzl@47694
   996
  "almost_everywhere M P \<equiv> eventually P (ae_filter M)"
hoelzl@47694
   997
hoelzl@47694
   998
syntax
hoelzl@47694
   999
  "_almost_everywhere" :: "pttrn \<Rightarrow> 'a \<Rightarrow> bool \<Rightarrow> bool" ("AE _ in _. _" [0,0,10] 10)
hoelzl@47694
  1000
hoelzl@47694
  1001
translations
hoelzl@62975
  1002
  "AE x in M. P" \<rightleftharpoons> "CONST almost_everywhere M (\<lambda>x. P)"
hoelzl@47694
  1003
hoelzl@63958
  1004
abbreviation
hoelzl@63958
  1005
  "set_almost_everywhere A M P \<equiv> AE x in M. x \<in> A \<longrightarrow> P x"
hoelzl@63958
  1006
hoelzl@63958
  1007
syntax
hoelzl@63958
  1008
  "_set_almost_everywhere" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'a \<Rightarrow> bool \<Rightarrow> bool"
hoelzl@63958
  1009
  ("AE _\<in>_ in _./ _" [0,0,0,10] 10)
hoelzl@63958
  1010
hoelzl@63958
  1011
translations
hoelzl@63958
  1012
  "AE x\<in>A in M. P" \<rightleftharpoons> "CONST set_almost_everywhere A M (\<lambda>x. P)"
hoelzl@63958
  1013
hoelzl@57276
  1014
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
  1015
  unfolding ae_filter_def by (subst eventually_INF_base) (auto simp: eventually_principal subset_eq)
hoelzl@47694
  1016
hoelzl@47694
  1017
lemma AE_I':
hoelzl@47694
  1018
  "N \<in> null_sets M \<Longrightarrow> {x\<in>space M. \<not> P x} \<subseteq> N \<Longrightarrow> (AE x in M. P x)"
hoelzl@47694
  1019
  unfolding eventually_ae_filter by auto
hoelzl@47694
  1020
hoelzl@47694
  1021
lemma AE_iff_null:
hoelzl@47694
  1022
  assumes "{x\<in>space M. \<not> P x} \<in> sets M" (is "?P \<in> sets M")
hoelzl@47694
  1023
  shows "(AE x in M. P x) \<longleftrightarrow> {x\<in>space M. \<not> P x} \<in> null_sets M"
hoelzl@47694
  1024
proof
hoelzl@47694
  1025
  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
  1026
    unfolding eventually_ae_filter by auto
hoelzl@62975
  1027
  have "emeasure M ?P \<le> emeasure M N"
hoelzl@47694
  1028
    using assms N(1,2) by (auto intro: emeasure_mono)
hoelzl@62975
  1029
  then have "emeasure M ?P = 0"
hoelzl@62975
  1030
    unfolding \<open>emeasure M N = 0\<close> by auto
hoelzl@47694
  1031
  then show "?P \<in> null_sets M" using assms by auto
hoelzl@47694
  1032
next
hoelzl@47694
  1033
  assume "?P \<in> null_sets M" with assms show "AE x in M. P x" by (auto intro: AE_I')
hoelzl@47694
  1034
qed
hoelzl@47694
  1035
hoelzl@47694
  1036
lemma AE_iff_null_sets:
hoelzl@47694
  1037
  "N \<in> sets M \<Longrightarrow> N \<in> null_sets M \<longleftrightarrow> (AE x in M. x \<notin> N)"
immler@50244
  1038
  using Int_absorb1[OF sets.sets_into_space, of N M]
hoelzl@47694
  1039
  by (subst AE_iff_null) (auto simp: Int_def[symmetric])
hoelzl@47694
  1040
hoelzl@47761
  1041
lemma AE_not_in:
hoelzl@47761
  1042
  "N \<in> null_sets M \<Longrightarrow> AE x in M. x \<notin> N"
hoelzl@47761
  1043
  by (metis AE_iff_null_sets null_setsD2)
hoelzl@47761
  1044
hoelzl@47694
  1045
lemma AE_iff_measurable:
hoelzl@47694
  1046
  "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
  1047
  using AE_iff_null[of _ P] by auto
hoelzl@47694
  1048
hoelzl@47694
  1049
lemma AE_E[consumes 1]:
hoelzl@47694
  1050
  assumes "AE x in M. P x"
hoelzl@47694
  1051
  obtains N where "{x \<in> space M. \<not> P x} \<subseteq> N" "emeasure M N = 0" "N \<in> sets M"
hoelzl@47694
  1052
  using assms unfolding eventually_ae_filter by auto
hoelzl@47694
  1053
hoelzl@47694
  1054
lemma AE_E2:
hoelzl@47694
  1055
  assumes "AE x in M. P x" "{x\<in>space M. P x} \<in> sets M"
hoelzl@47694
  1056
  shows "emeasure M {x\<in>space M. \<not> P x} = 0" (is "emeasure M ?P = 0")
hoelzl@47694
  1057
proof -
hoelzl@47694
  1058
  have "{x\<in>space M. \<not> P x} = space M - {x\<in>space M. P x}" by auto
hoelzl@47694
  1059
  with AE_iff_null[of M P] assms show ?thesis by auto
hoelzl@47694
  1060
qed
hoelzl@47694
  1061
hoelzl@47694
  1062
lemma AE_I:
hoelzl@47694
  1063
  assumes "{x \<in> space M. \<not> P x} \<subseteq> N" "emeasure M N = 0" "N \<in> sets M"
hoelzl@47694
  1064
  shows "AE x in M. P x"
hoelzl@47694
  1065
  using assms unfolding eventually_ae_filter by auto
hoelzl@47694
  1066
hoelzl@47694
  1067
lemma AE_mp[elim!]:
hoelzl@47694
  1068
  assumes AE_P: "AE x in M. P x" and AE_imp: "AE x in M. P x \<longrightarrow> Q x"
hoelzl@47694
  1069
  shows "AE x in M. Q x"
hoelzl@47694
  1070
proof -
hoelzl@47694
  1071
  from AE_P obtain A where P: "{x\<in>space M. \<not> P x} \<subseteq> A"
hoelzl@47694
  1072
    and A: "A \<in> sets M" "emeasure M A = 0"
hoelzl@47694
  1073
    by (auto elim!: AE_E)
hoelzl@47694
  1074
hoelzl@47694
  1075
  from AE_imp obtain B where imp: "{x\<in>space M. P x \<and> \<not> Q x} \<subseteq> B"
hoelzl@47694
  1076
    and B: "B \<in> sets M" "emeasure M B = 0"
hoelzl@47694
  1077
    by (auto elim!: AE_E)
hoelzl@47694
  1078
hoelzl@47694
  1079
  show ?thesis
hoelzl@47694
  1080
  proof (intro AE_I)
hoelzl@62975
  1081
    have "emeasure M (A \<union> B) \<le> 0"
hoelzl@47694
  1082
      using emeasure_subadditive[of A M B] A B by auto
hoelzl@62975
  1083
    then show "A \<union> B \<in> sets M" "emeasure M (A \<union> B) = 0"
hoelzl@62975
  1084
      using A B by auto
hoelzl@47694
  1085
    show "{x\<in>space M. \<not> Q x} \<subseteq> A \<union> B"
hoelzl@47694
  1086
      using P imp by auto
hoelzl@47694
  1087
  qed
hoelzl@47694
  1088
qed
hoelzl@47694
  1089
hoelzl@47694
  1090
(* depricated replace by laws about eventually *)
hoelzl@47694
  1091
lemma
hoelzl@47694
  1092
  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
  1093
    and AE_disjI1: "AE x in M. P x \<Longrightarrow> AE x in M. P x \<or> Q x"
hoelzl@47694
  1094
    and AE_disjI2: "AE x in M. Q x \<Longrightarrow> AE x in M. P x \<or> Q x"
hoelzl@47694
  1095
    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
  1096
    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
  1097
  by auto
hoelzl@47694
  1098
hoelzl@47694
  1099
lemma AE_impI:
hoelzl@47694
  1100
  "(P \<Longrightarrow> AE x in M. Q x) \<Longrightarrow> AE x in M. P \<longrightarrow> Q x"
hoelzl@47694
  1101
  by (cases P) auto
hoelzl@47694
  1102
hoelzl@47694
  1103
lemma AE_measure:
hoelzl@47694
  1104
  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
  1105
  shows "emeasure M {x\<in>space M. P x} = emeasure M (space M)"
hoelzl@47694
  1106
proof -
hoelzl@47694
  1107
  from AE_E[OF AE] guess N . note N = this
hoelzl@47694
  1108
  with sets have "emeasure M (space M) \<le> emeasure M (?P \<union> N)"
hoelzl@47694
  1109
    by (intro emeasure_mono) auto
hoelzl@47694
  1110
  also have "\<dots> \<le> emeasure M ?P + emeasure M N"
hoelzl@47694
  1111
    using sets N by (intro emeasure_subadditive) auto
hoelzl@47694
  1112
  also have "\<dots> = emeasure M ?P" using N by simp
hoelzl@47694
  1113
  finally show "emeasure M ?P = emeasure M (space M)"
hoelzl@47694
  1114
    using emeasure_space[of M "?P"] by auto
hoelzl@47694
  1115
qed
hoelzl@47694
  1116
hoelzl@47694
  1117
lemma AE_space: "AE x in M. x \<in> space M"
hoelzl@47694
  1118
  by (rule AE_I[where N="{}"]) auto
hoelzl@47694
  1119
hoelzl@47694
  1120
lemma AE_I2[simp, intro]:
hoelzl@47694
  1121
  "(\<And>x. x \<in> space M \<Longrightarrow> P x) \<Longrightarrow> AE x in M. P x"
hoelzl@47694
  1122
  using AE_space by force
hoelzl@47694
  1123
hoelzl@47694
  1124
lemma AE_Ball_mp:
hoelzl@47694
  1125
  "\<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
  1126
  by auto
hoelzl@47694
  1127
hoelzl@47694
  1128
lemma AE_cong[cong]:
hoelzl@47694
  1129
  "(\<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
  1130
  by auto
hoelzl@47694
  1131
hoelzl@64008
  1132
lemma AE_cong_strong: "M = N \<Longrightarrow> (\<And>x. x \<in> space N =simp=> P x = Q x) \<Longrightarrow> (AE x in M. P x) \<longleftrightarrow> (AE x in N. Q x)"
hoelzl@64008
  1133
  by (auto simp: simp_implies_def)
hoelzl@64008
  1134
hoelzl@47694
  1135
lemma AE_all_countable:
hoelzl@47694
  1136
  "(AE x in M. \<forall>i. P i x) \<longleftrightarrow> (\<forall>i::'i::countable. AE x in M. P i x)"
hoelzl@47694
  1137
proof
hoelzl@47694
  1138
  assume "\<forall>i. AE x in M. P i x"
hoelzl@47694
  1139
  from this[unfolded eventually_ae_filter Bex_def, THEN choice]
hoelzl@47694
  1140
  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
  1141
  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
  1142
  also have "\<dots> \<subseteq> (\<Union>i. N i)" using N by auto
hoelzl@47694
  1143
  finally have "{x\<in>space M. \<not> (\<forall>i. P i x)} \<subseteq> (\<Union>i. N i)" .
hoelzl@47694
  1144
  moreover from N have "(\<Union>i. N i) \<in> null_sets M"
hoelzl@47694
  1145
    by (intro null_sets_UN) auto
hoelzl@47694
  1146
  ultimately show "AE x in M. \<forall>i. P i x"
hoelzl@47694
  1147
    unfolding eventually_ae_filter by auto
hoelzl@47694
  1148
qed auto
hoelzl@47694
  1149
lp15@61609
  1150
lemma AE_ball_countable:
hoelzl@59000
  1151
  assumes [intro]: "countable X"
hoelzl@59000
  1152
  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
  1153
proof
hoelzl@59000
  1154
  assume "\<forall>y\<in>X. AE x in M. P x y"
hoelzl@59000
  1155
  from this[unfolded eventually_ae_filter Bex_def, THEN bchoice]
hoelzl@59000
  1156
  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
  1157
    by auto
hoelzl@59000
  1158
  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
  1159
    by auto
hoelzl@59000
  1160
  also have "\<dots> \<subseteq> (\<Union>y\<in>X. N y)"
hoelzl@59000
  1161
    using N by auto
hoelzl@59000
  1162
  finally have "{x\<in>space M. \<not> (\<forall>y\<in>X. P x y)} \<subseteq> (\<Union>y\<in>X. N y)" .
hoelzl@59000
  1163
  moreover from N have "(\<Union>y\<in>X. N y) \<in> null_sets M"
hoelzl@59000
  1164
    by (intro null_sets_UN') auto
hoelzl@59000
  1165
  ultimately show "AE x in M. \<forall>y\<in>X. P x y"
hoelzl@59000
  1166
    unfolding eventually_ae_filter by auto
hoelzl@59000
  1167
qed auto
hoelzl@59000
  1168
hoelzl@63959
  1169
lemma pairwise_alt: "pairwise R S \<longleftrightarrow> (\<forall>x\<in>S. \<forall>y\<in>S-{x}. R x y)"
hoelzl@63959
  1170
  by (auto simp add: pairwise_def)
hoelzl@63959
  1171
hoelzl@63959
  1172
lemma AE_pairwise: "countable F \<Longrightarrow> pairwise (\<lambda>A B. AE x in M. R x A B) F \<longleftrightarrow> (AE x in M. pairwise (R x) F)"
hoelzl@63959
  1173
  unfolding pairwise_alt by (simp add: AE_ball_countable)
hoelzl@63959
  1174
hoelzl@57275
  1175
lemma AE_discrete_difference:
hoelzl@57275
  1176
  assumes X: "countable X"
lp15@61609
  1177
  assumes null: "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0"
hoelzl@57275
  1178
  assumes sets: "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
hoelzl@57275
  1179
  shows "AE x in M. x \<notin> X"
hoelzl@57275
  1180
proof -
hoelzl@57275
  1181
  have "(\<Union>x\<in>X. {x}) \<in> null_sets M"
hoelzl@57275
  1182
    using assms by (intro null_sets_UN') auto
hoelzl@57275
  1183
  from AE_not_in[OF this] show "AE x in M. x \<notin> X"
hoelzl@57275
  1184
    by auto
hoelzl@57275
  1185
qed
hoelzl@57275
  1186
hoelzl@47694
  1187
lemma AE_finite_all:
hoelzl@47694
  1188
  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
  1189
  using f by induct auto
hoelzl@47694
  1190
hoelzl@47694
  1191
lemma AE_finite_allI:
hoelzl@47694
  1192
  assumes "finite S"
hoelzl@47694
  1193
  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"
wenzelm@61808
  1194
  using AE_finite_all[OF \<open>finite S\<close>] by auto
hoelzl@47694
  1195
hoelzl@47694
  1196
lemma emeasure_mono_AE:
hoelzl@47694
  1197
  assumes imp: "AE x in M. x \<in> A \<longrightarrow> x \<in> B"
hoelzl@47694
  1198
    and B: "B \<in> sets M"
hoelzl@47694
  1199
  shows "emeasure M A \<le> emeasure M B"
hoelzl@47694
  1200
proof cases
hoelzl@47694
  1201
  assume A: "A \<in> sets M"
hoelzl@47694
  1202
  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
  1203
    by (auto simp: eventually_ae_filter)
hoelzl@47694
  1204
  have "emeasure M A = emeasure M (A - N)"
hoelzl@47694
  1205
    using N A by (subst emeasure_Diff_null_set) auto
hoelzl@47694
  1206
  also have "emeasure M (A - N) \<le> emeasure M (B - N)"
immler@50244
  1207
    using N A B sets.sets_into_space by (auto intro!: emeasure_mono)
hoelzl@47694
  1208
  also have "emeasure M (B - N) = emeasure M B"
hoelzl@47694
  1209
    using N B by (subst emeasure_Diff_null_set) auto
hoelzl@47694
  1210
  finally show ?thesis .
hoelzl@62975
  1211
qed (simp add: emeasure_notin_sets)
hoelzl@47694
  1212
hoelzl@47694
  1213
lemma emeasure_eq_AE:
hoelzl@47694
  1214
  assumes iff: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@47694
  1215
  assumes A: "A \<in> sets M" and B: "B \<in> sets M"
hoelzl@47694
  1216
  shows "emeasure M A = emeasure M B"
hoelzl@47694
  1217
  using assms by (safe intro!: antisym emeasure_mono_AE) auto
hoelzl@47694
  1218
hoelzl@59000
  1219
lemma emeasure_Collect_eq_AE:
hoelzl@59000
  1220
  "AE x in M. P x \<longleftrightarrow> Q x \<Longrightarrow> Measurable.pred M Q \<Longrightarrow> Measurable.pred M P \<Longrightarrow>
hoelzl@59000
  1221
   emeasure M {x\<in>space M. P x} = emeasure M {x\<in>space M. Q x}"
hoelzl@59000
  1222
   by (intro emeasure_eq_AE) auto
hoelzl@59000
  1223
hoelzl@59000
  1224
lemma emeasure_eq_0_AE: "AE x in M. \<not> P x \<Longrightarrow> emeasure M {x\<in>space M. P x} = 0"
hoelzl@59000
  1225
  using AE_iff_measurable[OF _ refl, of M "\<lambda>x. \<not> P x"]
hoelzl@59000
  1226
  by (cases "{x\<in>space M. P x} \<in> sets M") (simp_all add: emeasure_notin_sets)
hoelzl@59000
  1227
hoelzl@60715
  1228
lemma emeasure_add_AE:
hoelzl@60715
  1229
  assumes [measurable]: "A \<in> sets M" "B \<in> sets M" "C \<in> sets M"
hoelzl@60715
  1230
  assumes 1: "AE x in M. x \<in> C \<longleftrightarrow> x \<in> A \<or> x \<in> B"
hoelzl@60715
  1231
  assumes 2: "AE x in M. \<not> (x \<in> A \<and> x \<in> B)"
hoelzl@60715
  1232
  shows "emeasure M C = emeasure M A + emeasure M B"
hoelzl@60715
  1233
proof -
hoelzl@60715
  1234
  have "emeasure M C = emeasure M (A \<union> B)"
hoelzl@60715
  1235
    by (rule emeasure_eq_AE) (insert 1, auto)
hoelzl@60715
  1236
  also have "\<dots> = emeasure M A + emeasure M (B - A)"
hoelzl@60715
  1237
    by (subst plus_emeasure) auto
hoelzl@60715
  1238
  also have "emeasure M (B - A) = emeasure M B"
hoelzl@60715
  1239
    by (rule emeasure_eq_AE) (insert 2, auto)
hoelzl@60715
  1240
  finally show ?thesis .
hoelzl@60715
  1241
qed
hoelzl@60715
  1242
wenzelm@61808
  1243
subsection \<open>\<open>\<sigma>\<close>-finite Measures\<close>
hoelzl@47694
  1244
hoelzl@47694
  1245
locale sigma_finite_measure =
hoelzl@47694
  1246
  fixes M :: "'a measure"
hoelzl@57447
  1247
  assumes sigma_finite_countable:
hoelzl@57447
  1248
    "\<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
  1249
hoelzl@57447
  1250
lemma (in sigma_finite_measure) sigma_finite:
hoelzl@57447
  1251
  obtains A :: "nat \<Rightarrow> 'a set"
hoelzl@57447
  1252
  where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
hoelzl@57447
  1253
proof -
hoelzl@57447
  1254
  obtain A :: "'a set set" where
hoelzl@57447
  1255
    [simp]: "countable A" and
hoelzl@57447
  1256
    A: "A \<subseteq> sets M" "(\<Union>A) = space M" "\<And>a. a \<in> A \<Longrightarrow> emeasure M a \<noteq> \<infinity>"
hoelzl@57447
  1257
    using sigma_finite_countable by metis
hoelzl@57447
  1258
  show thesis
hoelzl@57447
  1259
  proof cases
wenzelm@61808
  1260
    assume "A = {}" with \<open>(\<Union>A) = space M\<close> show thesis
hoelzl@57447
  1261
      by (intro that[of "\<lambda>_. {}"]) auto
hoelzl@57447
  1262
  next
lp15@61609
  1263
    assume "A \<noteq> {}"
hoelzl@57447
  1264
    show thesis
hoelzl@57447
  1265
    proof
hoelzl@57447
  1266
      show "range (from_nat_into A) \<subseteq> sets M"
wenzelm@61808
  1267
        using \<open>A \<noteq> {}\<close> A by auto
hoelzl@57447
  1268
      have "(\<Union>i. from_nat_into A i) = \<Union>A"
wenzelm@61808
  1269
        using range_from_nat_into[OF \<open>A \<noteq> {}\<close> \<open>countable A\<close>] by auto
hoelzl@57447
  1270
      with A show "(\<Union>i. from_nat_into A i) = space M"
hoelzl@57447
  1271
        by auto
wenzelm@61808
  1272
    qed (intro A from_nat_into \<open>A \<noteq> {}\<close>)
hoelzl@57447
  1273
  qed
hoelzl@57447
  1274
qed
hoelzl@47694
  1275
hoelzl@47694
  1276
lemma (in sigma_finite_measure) sigma_finite_disjoint:
hoelzl@47694
  1277
  obtains A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
  1278
  where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>" "disjoint_family A"
wenzelm@60580
  1279
proof -
hoelzl@47694
  1280
  obtain A :: "nat \<Rightarrow> 'a set" where
hoelzl@47694
  1281
    range: "range A \<subseteq> sets M" and
hoelzl@47694
  1282
    space: "(\<Union>i. A i) = space M" and
hoelzl@47694
  1283
    measure: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
haftmann@62343
  1284
    using sigma_finite by blast
wenzelm@60580
  1285
  show thesis
wenzelm@60580
  1286
  proof (rule that[of "disjointed A"])
wenzelm@60580
  1287
    show "range (disjointed A) \<subseteq> sets M"
wenzelm@60580
  1288
      by (rule sets.range_disjointed_sets[OF range])
wenzelm@60580
  1289
    show "(\<Union>i. disjointed A i) = space M"
wenzelm@60580
  1290
      and "disjoint_family (disjointed A)"
wenzelm@60580
  1291
      using disjoint_family_disjointed UN_disjointed_eq[of A] space range
wenzelm@60580
  1292
      by auto
wenzelm@60580
  1293
    show "emeasure M (disjointed A i) \<noteq> \<infinity>" for i
wenzelm@60580
  1294
    proof -
wenzelm@60580
  1295
      have "emeasure M (disjointed A i) \<le> emeasure M (A i)"
wenzelm@60580
  1296
        using range disjointed_subset[of A i] by (auto intro!: emeasure_mono)
hoelzl@62975
  1297
      then show ?thesis using measure[of i] by (auto simp: top_unique)
wenzelm@60580
  1298
    qed
wenzelm@60580
  1299
  qed
hoelzl@47694
  1300
qed
hoelzl@47694
  1301
hoelzl@47694
  1302
lemma (in sigma_finite_measure) sigma_finite_incseq:
hoelzl@47694
  1303
  obtains A :: "nat \<Rightarrow> 'a set"
hoelzl@47694
  1304
  where "range A \<subseteq> sets M" "(\<Union>i. A i) = space M" "\<And>i. emeasure M (A i) \<noteq> \<infinity>" "incseq A"
wenzelm@60580
  1305
proof -
hoelzl@47694
  1306
  obtain F :: "nat \<Rightarrow> 'a set" where
hoelzl@47694
  1307
    F: "range F \<subseteq> sets M" "(\<Union>i. F i) = space M" "\<And>i. emeasure M (F i) \<noteq> \<infinity>"
haftmann@62343
  1308
    using sigma_finite by blast
wenzelm@60580
  1309
  show thesis
wenzelm@60580
  1310
  proof (rule that[of "\<lambda>n. \<Union>i\<le>n. F i"])
wenzelm@60580
  1311
    show "range (\<lambda>n. \<Union>i\<le>n. F i) \<subseteq> sets M"
wenzelm@60580
  1312
      using F by (force simp: incseq_def)
wenzelm@60580
  1313
    show "(\<Union>n. \<Union>i\<le>n. F i) = space M"
wenzelm@60580
  1314
    proof -
wenzelm@60580
  1315
      from F have "\<And>x. x \<in> space M \<Longrightarrow> \<exists>i. x \<in> F i" by auto
wenzelm@60580
  1316
      with F show ?thesis by fastforce
wenzelm@60580
  1317
    qed
wenzelm@60585
  1318
    show "emeasure M (\<Union>i\<le>n. F i) \<noteq> \<infinity>" for n
wenzelm@60580
  1319
    proof -
wenzelm@60585
  1320
      have "emeasure M (\<Union>i\<le>n. F i) \<le> (\<Sum>i\<le>n. emeasure M (F i))"
wenzelm@60580
  1321
        using F by (auto intro!: emeasure_subadditive_finite)
wenzelm@60580
  1322
      also have "\<dots> < \<infinity>"
nipkow@64267
  1323
        using F by (auto simp: sum_Pinfty less_top)
wenzelm@60580
  1324
      finally show ?thesis by simp
wenzelm@60580
  1325
    qed
wenzelm@60580
  1326
    show "incseq (\<lambda>n. \<Union>i\<le>n. F i)"
wenzelm@60580
  1327
      by (force simp: incseq_def)
wenzelm@60580
  1328
  qed
hoelzl@47694
  1329
qed
hoelzl@47694
  1330
wenzelm@61808
  1331
subsection \<open>Measure space induced by distribution of @{const measurable}-functions\<close>
hoelzl@47694
  1332
hoelzl@47694
  1333
definition distr :: "'a measure \<Rightarrow> 'b measure \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b measure" where
hoelzl@47694
  1334
  "distr M N f = measure_of (space N) (sets N) (\<lambda>A. emeasure M (f -` A \<inter> space M))"
hoelzl@47694
  1335
hoelzl@47694
  1336
lemma
hoelzl@59048
  1337
  shows sets_distr[simp, measurable_cong]: "sets (distr M N f) = sets N"
hoelzl@47694
  1338
    and space_distr[simp]: "space (distr M N f) = space N"
hoelzl@47694
  1339
  by (auto simp: distr_def)
hoelzl@47694
  1340
hoelzl@47694
  1341
lemma
hoelzl@47694
  1342
  shows measurable_distr_eq1[simp]: "measurable (distr Mf Nf f) Mf' = measurable Nf Mf'"
hoelzl@47694
  1343
    and measurable_distr_eq2[simp]: "measurable Mg' (distr Mg Ng g) = measurable Mg' Ng"
hoelzl@47694
  1344
  by (auto simp: measurable_def)
hoelzl@47694
  1345
hoelzl@54417
  1346
lemma distr_cong:
hoelzl@54417
  1347
  "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
  1348
  using sets_eq_imp_space_eq[of N L] by (simp add: distr_def Int_def cong: rev_conj_cong)
hoelzl@54417
  1349
hoelzl@47694
  1350
lemma emeasure_distr:
hoelzl@47694
  1351
  fixes f :: "'a \<Rightarrow> 'b"
hoelzl@47694
  1352
  assumes f: "f \<in> measurable M N" and A: "A \<in> sets N"
hoelzl@47694
  1353
  shows "emeasure (distr M N f) A = emeasure M (f -` A \<inter> space M)" (is "_ = ?\<mu> A")
hoelzl@47694
  1354
  unfolding distr_def
hoelzl@47694
  1355
proof (rule emeasure_measure_of_sigma)
hoelzl@47694
  1356
  show "positive (sets N) ?\<mu>"
hoelzl@47694
  1357
    by (auto simp: positive_def)
hoelzl@47694
  1358
hoelzl@47694
  1359
  show "countably_additive (sets N) ?\<mu>"
hoelzl@47694
  1360
  proof (intro countably_additiveI)
hoelzl@47694
  1361
    fix A :: "nat \<Rightarrow> 'b set" assume "range A \<subseteq> sets N" "disjoint_family A"
hoelzl@47694
  1362
    then have A: "\<And>i. A i \<in> sets N" "(\<Union>i. A i) \<in> sets N" by auto
hoelzl@47694
  1363
    then have *: "range (\<lambda>i. f -` (A i) \<inter> space M) \<subseteq> sets M"
hoelzl@47694
  1364
      using f by (auto simp: measurable_def)
hoelzl@47694
  1365
    moreover have "(\<Union>i. f -`  A i \<inter> space M) \<in> sets M"
hoelzl@47694
  1366
      using * by blast
hoelzl@47694
  1367
    moreover have **: "disjoint_family (\<lambda>i. f -` A i \<inter> space M)"
wenzelm@61808
  1368
      using \<open>disjoint_family A\<close> by (auto simp: disjoint_family_on_def)
hoelzl@47694
  1369
    ultimately show "(\<Sum>i. ?\<mu> (A i)) = ?\<mu> (\<Union>i. A i)"
hoelzl@47694
  1370
      using suminf_emeasure[OF _ **] A f
hoelzl@47694
  1371
      by (auto simp: comp_def vimage_UN)
hoelzl@47694
  1372
  qed
hoelzl@47694
  1373
  show "sigma_algebra (space N) (sets N)" ..
hoelzl@47694
  1374
qed fact
hoelzl@47694
  1375
hoelzl@59000
  1376
lemma emeasure_Collect_distr:
hoelzl@59000
  1377
  assumes X[measurable]: "X \<in> measurable M N" "Measurable.pred N P"
hoelzl@59000
  1378
  shows "emeasure (distr M N X) {x\<in>space N. P x} = emeasure M {x\<in>space M. P (X x)}"
hoelzl@59000
  1379
  by (subst emeasure_distr)
hoelzl@59000
  1380
     (auto intro!: arg_cong2[where f=emeasure] X(1)[THEN measurable_space])
hoelzl@59000
  1381
hoelzl@59000
  1382
lemma emeasure_lfp2[consumes 1, case_names cont f measurable]:
hoelzl@59000
  1383
  assumes "P M"
hoelzl@60172
  1384
  assumes cont: "sup_continuous F"
hoelzl@59000
  1385
  assumes f: "\<And>M. P M \<Longrightarrow> f \<in> measurable M' M"
hoelzl@59000
  1386
  assumes *: "\<And>M A. P M \<Longrightarrow> (\<And>N. P N \<Longrightarrow> Measurable.pred N A) \<Longrightarrow> Measurable.pred M (F A)"
hoelzl@59000
  1387
  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
  1388
proof (subst (1 2) emeasure_Collect_distr[symmetric, where X=f])
hoelzl@59000
  1389
  show "f \<in> measurable M' M"  "f \<in> measurable M' M"
wenzelm@61808
  1390
    using f[OF \<open>P M\<close>] by auto
hoelzl@59000
  1391
  { fix i show "Measurable.pred M ((F ^^ i) (\<lambda>x. False))"
wenzelm@61808
  1392
    using \<open>P M\<close> by (induction i arbitrary: M) (auto intro!: *) }
hoelzl@59000
  1393
  show "Measurable.pred M (lfp F)"
wenzelm@61808
  1394
    using \<open>P M\<close> cont * by (rule measurable_lfp_coinduct[of P])
hoelzl@59000
  1395
hoelzl@59000
  1396
  have "emeasure (distr M' M f) {x \<in> space (distr M' M f). lfp F x} =
hoelzl@59000
  1397
    (SUP i. emeasure (distr M' M f) {x \<in> space (distr M' M f). (F ^^ i) (\<lambda>x. False) x})"
wenzelm@61808
  1398
    using \<open>P M\<close>
hoelzl@60636
  1399
  proof (coinduction arbitrary: M rule: emeasure_lfp')
hoelzl@59000
  1400
    case (measurable A N) then have "\<And>N. P N \<Longrightarrow> Measurable.pred (distr M' N f) A"
hoelzl@59000
  1401
      by metis
hoelzl@59000
  1402
    then have "\<And>N. P N \<Longrightarrow> Measurable.pred N A"
hoelzl@59000
  1403
      by simp
wenzelm@61808
  1404
    with \<open>P N\<close>[THEN *] show ?case
hoelzl@59000
  1405
      by auto
hoelzl@59000
  1406
  qed fact
hoelzl@59000
  1407
  then show "emeasure (distr M' M f) {x \<in> space M. lfp F x} =
hoelzl@59000
  1408
    (SUP i. emeasure (distr M' M f) {x \<in> space M. (F ^^ i) (\<lambda>x. False) x})"
hoelzl@59000
  1409
   by simp
hoelzl@59000
  1410
qed
hoelzl@59000
  1411
hoelzl@50104
  1412
lemma distr_id[simp]: "distr N N (\<lambda>x. x) = N"
hoelzl@50104
  1413
  by (rule measure_eqI) (auto simp: emeasure_distr)
hoelzl@50104
  1414
hoelzl@50001
  1415
lemma measure_distr:
hoelzl@50001
  1416
  "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
  1417
  by (simp add: emeasure_distr measure_def)
hoelzl@50001
  1418
hoelzl@57447
  1419
lemma distr_cong_AE:
lp15@61609
  1420
  assumes 1: "M = K" "sets N = sets L" and
hoelzl@57447
  1421
    2: "(AE x in M. f x = g x)" and "f \<in> measurable M N" and "g \<in> measurable K L"
hoelzl@57447
  1422
  shows "distr M N f = distr K L g"
hoelzl@57447
  1423
proof (rule measure_eqI)
hoelzl@57447
  1424
  fix A assume "A \<in> sets (distr M N f)"
hoelzl@57447
  1425
  with assms show "emeasure (distr M N f) A = emeasure (distr K L g) A"
hoelzl@57447
  1426
    by (auto simp add: emeasure_distr intro!: emeasure_eq_AE measurable_sets)
hoelzl@57447
  1427
qed (insert 1, simp)
hoelzl@57447
  1428
hoelzl@47694
  1429
lemma AE_distrD:
hoelzl@47694
  1430
  assumes f: "f \<in> measurable M M'"
hoelzl@47694
  1431
    and AE: "AE x in distr M M' f. P x"
hoelzl@47694
  1432
  shows "AE x in M. P (f x)"
hoelzl@47694
  1433
proof -
hoelzl@47694
  1434
  from AE[THEN AE_E] guess N .
hoelzl@47694
  1435
  with f show ?thesis
hoelzl@47694
  1436
    unfolding eventually_ae_filter
hoelzl@47694
  1437
    by (intro bexI[of _ "f -` N \<inter> space M"])
hoelzl@47694
  1438
       (auto simp: emeasure_distr measurable_def)
hoelzl@47694
  1439
qed
hoelzl@47694
  1440
hoelzl@49773
  1441
lemma AE_distr_iff:
hoelzl@50002
  1442
  assumes f[measurable]: "f \<in> measurable M N" and P[measurable]: "{x \<in> space N. P x} \<in> sets N"
hoelzl@49773
  1443
  shows "(AE x in distr M N f. P x) \<longleftrightarrow> (AE x in M. P (f x))"
hoelzl@49773
  1444
proof (subst (1 2) AE_iff_measurable[OF _ refl])
hoelzl@50002
  1445
  have "f -` {x\<in>space N. \<not> P x} \<inter> space M = {x \<in> space M. \<not> P (f x)}"
hoelzl@50002
  1446
    using f[THEN measurable_space] by auto
hoelzl@50002
  1447
  then show "(emeasure (distr M N f) {x \<in> space (distr M N f). \<not> P x} = 0) =
hoelzl@49773
  1448
    (emeasure M {x \<in> space M. \<not> P (f x)} = 0)"
hoelzl@50002
  1449
    by (simp add: emeasure_distr)
hoelzl@50002
  1450
qed auto
hoelzl@49773
  1451
hoelzl@47694
  1452
lemma null_sets_distr_iff:
hoelzl@47694
  1453
  "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
  1454
  by (auto simp add: null_sets_def emeasure_distr)
hoelzl@47694
  1455
hoelzl@47694
  1456
lemma distr_distr:
hoelzl@50002
  1457
  "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
  1458
  by (auto simp add: emeasure_distr measurable_space
hoelzl@47694
  1459
           intro!: arg_cong[where f="emeasure M"] measure_eqI)
hoelzl@47694
  1460
wenzelm@61808
  1461
subsection \<open>Real measure values\<close>
hoelzl@47694
  1462
hoelzl@62975
  1463
lemma ring_of_finite_sets: "ring_of_sets (space M) {A\<in>sets M. emeasure M A \<noteq> top}"
hoelzl@62975
  1464
proof (rule ring_of_setsI)
hoelzl@62975
  1465
  show "a \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow> b \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow>
hoelzl@62975
  1466
    a \<union> b \<in> {A \<in> sets M. emeasure M A \<noteq> top}" for a b
hoelzl@62975
  1467
    using emeasure_subadditive[of a M b] by (auto simp: top_unique)
hoelzl@62975
  1468
hoelzl@62975
  1469
  show "a \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow> b \<in> {A \<in> sets M. emeasure M A \<noteq> top} \<Longrightarrow>
hoelzl@62975
  1470
    a - b \<in> {A \<in> sets M. emeasure M A \<noteq> top}" for a b
hoelzl@62975
  1471
    using emeasure_mono[of "a - b" a M] by (auto simp: Diff_subset top_unique)
hoelzl@62975
  1472
qed (auto dest: sets.sets_into_space)
hoelzl@62975
  1473
hoelzl@62975
  1474
lemma measure_nonneg[simp]: "0 \<le> measure M A"
hoelzl@63333
  1475
  unfolding measure_def by auto
hoelzl@47694
  1476
hoelzl@61880
  1477
lemma zero_less_measure_iff: "0 < measure M A \<longleftrightarrow> measure M A \<noteq> 0"
hoelzl@61880
  1478
  using measure_nonneg[of M A] by (auto simp add: le_less)
hoelzl@61880
  1479
hoelzl@59000
  1480
lemma measure_le_0_iff: "measure M X \<le> 0 \<longleftrightarrow> measure M X = 0"
hoelzl@62975
  1481
  using measure_nonneg[of M X] by linarith
hoelzl@59000
  1482
hoelzl@47694
  1483
lemma measure_empty[simp]: "measure M {} = 0"
hoelzl@62975
  1484
  unfolding measure_def by (simp add: zero_ennreal.rep_eq)
hoelzl@62975
  1485
hoelzl@62975
  1486
lemma emeasure_eq_ennreal_measure:
hoelzl@62975
  1487
  "emeasure M A \<noteq> top \<Longrightarrow> emeasure M A = ennreal (measure M A)"
hoelzl@62975
  1488
  by (cases "emeasure M A" rule: ennreal_cases) (auto simp: measure_def)
hoelzl@47694
  1489
hoelzl@62975
  1490
lemma measure_zero_top: "emeasure M A = top \<Longrightarrow> measure M A = 0"
hoelzl@62975
  1491
  by (simp add: measure_def enn2ereal_top)
hoelzl@47694
  1492
hoelzl@62975
  1493
lemma measure_eq_emeasure_eq_ennreal: "0 \<le> x \<Longrightarrow> emeasure M A = ennreal x \<Longrightarrow> measure M A = x"
hoelzl@62975
  1494
  using emeasure_eq_ennreal_measure[of M A]
hoelzl@62975
  1495
  by (cases "A \<in> M") (auto simp: measure_notin_sets emeasure_notin_sets)
hoelzl@62975
  1496
hoelzl@62975
  1497
lemma enn2real_plus:"a < top \<Longrightarrow> b < top \<Longrightarrow> enn2real (a + b) = enn2real a + enn2real b"
hoelzl@63333
  1498
  by (simp add: enn2real_def plus_ennreal.rep_eq real_of_ereal_add less_top
hoelzl@62975
  1499
           del: real_of_ereal_enn2ereal)
Andreas@61633
  1500
hoelzl@63959
  1501
lemma measure_eq_AE:
hoelzl@63959
  1502
  assumes iff: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@63959
  1503
  assumes A: "A \<in> sets M" and B: "B \<in> sets M"
hoelzl@63959
  1504
  shows "measure M A = measure M B"
hoelzl@63959
  1505
  using assms emeasure_eq_AE[OF assms] by (simp add: measure_def)
hoelzl@63959
  1506
hoelzl@47694
  1507
lemma measure_Union:
hoelzl@62975
  1508
  "emeasure M A \<noteq> \<infinity> \<Longrightarrow> emeasure M B \<noteq> \<infinity> \<Longrightarrow> A \<in> sets M \<Longrightarrow> B \<in> sets M \<Longrightarrow> A \<inter> B = {} \<Longrightarrow>
hoelzl@62975
  1509
    measure M (A \<union> B) = measure M A + measure M B"
hoelzl@63333
  1510
  by (simp add: measure_def plus_emeasure[symmetric] enn2real_plus less_top)
hoelzl@62975
  1511
hoelzl@62975
  1512
lemma disjoint_family_on_insert:
hoelzl@62975
  1513
  "i \<notin> I \<Longrightarrow> disjoint_family_on A (insert i I) \<longleftrightarrow> A i \<inter> (\<Union>i\<in>I. A i) = {} \<and> disjoint_family_on A I"
hoelzl@62975
  1514
  by (fastforce simp: disjoint_family_on_def)
hoelzl@47694
  1515
hoelzl@47694
  1516
lemma measure_finite_Union:
hoelzl@62975
  1517
  "finite S \<Longrightarrow> A`S \<subseteq> sets M \<Longrightarrow> disjoint_family_on A S \<Longrightarrow> (\<And>i. i \<in> S \<Longrightarrow> emeasure M (A i) \<noteq> \<infinity>) \<Longrightarrow>
hoelzl@62975
  1518
    measure M (\<Union>i\<in>S. A i) = (\<Sum>i\<in>S. measure M (A i))"
hoelzl@62975
  1519
  by (induction S rule: finite_induct)
nipkow@64267
  1520
     (auto simp: disjoint_family_on_insert measure_Union sum_emeasure[symmetric] sets.countable_UN'[OF countable_finite])
hoelzl@47694
  1521
hoelzl@47694
  1522
lemma measure_Diff:
hoelzl@47694
  1523
  assumes finite: "emeasure M A \<noteq> \<infinity>"
hoelzl@47694
  1524
  and measurable: "A \<in> sets M" "B \<in> sets M" "B \<subseteq> A"
hoelzl@47694
  1525
  shows "measure M (A - B) = measure M A - measure M B"
hoelzl@47694
  1526
proof -
hoelzl@47694
  1527
  have "emeasure M (A - B) \<le> emeasure M A" "emeasure M B \<le> emeasure M A"
hoelzl@47694
  1528
    using measurable by (auto intro!: emeasure_mono)
hoelzl@47694
  1529
  hence "measure M ((A - B) \<union> B) = measure M (A - B) + measure M B"
hoelzl@62975
  1530
    using measurable finite by (rule_tac measure_Union) (auto simp: top_unique)
wenzelm@61808
  1531
  thus ?thesis using \<open>B \<subseteq> A\<close> by (auto simp: Un_absorb2)
hoelzl@47694
  1532
qed
hoelzl@47694
  1533
hoelzl@47694
  1534
lemma measure_UNION:
hoelzl@47694
  1535
  assumes measurable: "range A \<subseteq> sets M" "disjoint_family A"
hoelzl@47694
  1536
  assumes finite: "emeasure M (\<Union>i. A i) \<noteq> \<infinity>"
hoelzl@47694
  1537
  shows "(\<lambda>i. measure M (A i)) sums (measure M (\<Union>i. A i))"
hoelzl@47694
  1538
proof -
hoelzl@62975
  1539
  have "(\<lambda>i. emeasure M (A i)) sums (emeasure M (\<Union>i. A i))"
hoelzl@62975
  1540
    unfolding suminf_emeasure[OF measurable, symmetric] by (simp add: summable_sums)
hoelzl@47694
  1541
  moreover
hoelzl@47694
  1542
  { fix i
hoelzl@47694
  1543
    have "emeasure M (A i) \<le> emeasure M (\<Union>i. A i)"
hoelzl@47694
  1544
      using measurable by (auto intro!: emeasure_mono)
hoelzl@62975
  1545
    then have "emeasure M (A i) = ennreal ((measure M (A i)))"
hoelzl@62975
  1546
      using finite by (intro emeasure_eq_ennreal_measure) (auto simp: top_unique) }
hoelzl@47694
  1547
  ultimately show ?thesis using finite
hoelzl@63333
  1548
    by (subst (asm) (2) emeasure_eq_ennreal_measure) simp_all
hoelzl@47694
  1549
qed
hoelzl@47694
  1550
hoelzl@47694
  1551
lemma measure_subadditive:
hoelzl@47694
  1552
  assumes measurable: "A \<in> sets M" "B \<in> sets M"
hoelzl@47694
  1553
  and fin: "emeasure M A \<noteq> \<infinity>" "emeasure M B \<noteq> \<infinity>"
hoelzl@62975
  1554
  shows "measure M (A \<union> B) \<le> measure M A + measure M B"
hoelzl@47694
  1555
proof -
hoelzl@47694
  1556
  have "emeasure M (A \<union> B) \<noteq> \<infinity>"
hoelzl@62975
  1557
    using emeasure_subadditive[OF measurable] fin by (auto simp: top_unique)
hoelzl@47694
  1558
  then show "(measure M (A \<union> B)) \<le> (measure M A) + (measure M B)"
hoelzl@47694
  1559
    using emeasure_subadditive[OF measurable] fin
hoelzl@62975
  1560
    apply simp
hoelzl@62975
  1561
    apply (subst (asm) (2 3 4) emeasure_eq_ennreal_measure)
hoelzl@62975
  1562
    apply (auto simp add: ennreal_plus[symmetric] simp del: ennreal_plus)
hoelzl@62975
  1563
    done
hoelzl@47694
  1564
qed
hoelzl@47694
  1565
hoelzl@47694
  1566
lemma measure_subadditive_finite:
hoelzl@47694
  1567
  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
  1568
  shows "measure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. measure M (A i))"
hoelzl@47694
  1569
proof -
hoelzl@47694
  1570
  { have "emeasure M (\<Union>i\<in>I. A i) \<le> (\<Sum>i\<in>I. emeasure M (A i))"
hoelzl@47694
  1571
      using emeasure_subadditive_finite[OF A] .
hoelzl@47694
  1572
    also have "\<dots> < \<infinity>"
hoelzl@62975
  1573
      using fin by (simp add: less_top A)
hoelzl@62975
  1574
    finally have "emeasure M (\<Union>i\<in>I. A i) \<noteq> top" by simp }
hoelzl@62975
  1575
  note * = this
hoelzl@62975
  1576
  show ?thesis
hoelzl@47694
  1577
    using emeasure_subadditive_finite[OF A] fin
hoelzl@62975
  1578
    unfolding emeasure_eq_ennreal_measure[OF *]
nipkow@64267
  1579
    by (simp_all add: sum_nonneg emeasure_eq_ennreal_measure)
hoelzl@47694
  1580
qed
hoelzl@47694
  1581
hoelzl@47694
  1582
lemma measure_subadditive_countably:
hoelzl@47694
  1583
  assumes A: "range A \<subseteq> sets M" and fin: "(\<Sum>i. emeasure M (A i)) \<noteq> \<infinity>"
hoelzl@47694
  1584
  shows "measure M (\<Union>i. A i) \<le> (\<Sum>i. measure M (A i))"
hoelzl@47694
  1585
proof -
hoelzl@62975
  1586
  from fin have **: "\<And>i. emeasure M (A i) \<noteq> top"
hoelzl@62975
  1587
    using ennreal_suminf_lessD[of "\<lambda>i. emeasure M (A i)"] by (simp add: less_top)
hoelzl@47694
  1588
  { have "emeasure M (\<Union>i. A i) \<le> (\<Sum>i. emeasure M (A i))"
hoelzl@47694
  1589
      using emeasure_subadditive_countably[OF A] .
hoelzl@47694
  1590
    also have "\<dots> < \<infinity>"
hoelzl@62975
  1591
      using fin by (simp add: less_top)
hoelzl@62975
  1592
    finally have "emeasure M (\<Union>i. A i) \<noteq> top" by simp }
hoelzl@62975
  1593
  then have "ennreal (measure M (\<Union>i. A i)) = emeasure M (\<Union>i. A i)"
hoelzl@62975
  1594
    by (rule emeasure_eq_ennreal_measure[symmetric])
hoelzl@62975
  1595
  also have "\<dots> \<le> (\<Sum>i. emeasure M (A i))"
hoelzl@62975
  1596
    using emeasure_subadditive_countably[OF A] .
hoelzl@62975
  1597
  also have "\<dots> = ennreal (\<Sum>i. measure M (A i))"
hoelzl@62975
  1598
    using fin unfolding emeasure_eq_ennreal_measure[OF **]
hoelzl@62975
  1599
    by (subst suminf_ennreal) (auto simp: **)
hoelzl@62975
  1600
  finally show ?thesis
hoelzl@62975
  1601
    apply (rule ennreal_le_iff[THEN iffD1, rotated])
hoelzl@62975
  1602
    apply (intro suminf_nonneg allI measure_nonneg summable_suminf_not_top)
hoelzl@62975
  1603
    using fin
hoelzl@62975
  1604
    apply (simp add: emeasure_eq_ennreal_measure[OF **])
hoelzl@62975
  1605
    done
hoelzl@47694
  1606
qed
hoelzl@47694
  1607
hoelzl@63959
  1608
lemma measure_Un_null_set: "A \<in> sets M \<Longrightarrow> B \<in> null_sets M \<Longrightarrow> measure M (A \<union> B) = measure M A"
hoelzl@63959
  1609
  by (simp add: measure_def emeasure_Un_null_set)
hoelzl@63959
  1610
hoelzl@63959
  1611
lemma measure_Diff_null_set: "A \<in> sets M \<Longrightarrow> B \<in> null_sets M \<Longrightarrow> measure M (A - B) = measure M A"
hoelzl@63959
  1612
  by (simp add: measure_def emeasure_Diff_null_set)
hoelzl@63959
  1613
nipkow@64267
  1614
lemma measure_eq_sum_singleton:
hoelzl@62975
  1615
  "finite S \<Longrightarrow> (\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M) \<Longrightarrow> (\<And>x. x \<in> S \<Longrightarrow> emeasure M {x} \<noteq> \<infinity>) \<Longrightarrow>
hoelzl@62975
  1616
    measure M S = (\<Sum>x\<in>S. measure M {x})"
nipkow@64267
  1617
  using emeasure_eq_sum_singleton[of S M]
nipkow@64267
  1618
  by (intro measure_eq_emeasure_eq_ennreal) (auto simp: sum_nonneg emeasure_eq_ennreal_measure)
hoelzl@47694
  1619
hoelzl@47694
  1620
lemma Lim_measure_incseq:
hoelzl@47694
  1621
  assumes A: "range A \<subseteq> sets M" "incseq A" and fin: "emeasure M (\<Union>i. A i) \<noteq> \<infinity>"
hoelzl@62975
  1622
  shows "(\<lambda>i. measure M (A i)) \<longlonglongrightarrow> measure M (\<Union>i. A i)"
hoelzl@62975
  1623
proof (rule tendsto_ennrealD)
hoelzl@62975
  1624
  have "ennreal (measure M (\<Union>i. A i)) = emeasure M (\<Union>i. A i)"
hoelzl@62975
  1625
    using fin by (auto simp: emeasure_eq_ennreal_measure)
hoelzl@62975
  1626
  moreover have "ennreal (measure M (A i)) = emeasure M (A i)" for i
hoelzl@62975
  1627
    using assms emeasure_mono[of "A _" "\<Union>i. A i" M]
hoelzl@62975
  1628
    by (intro emeasure_eq_ennreal_measure[symmetric]) (auto simp: less_top UN_upper intro: le_less_trans)
hoelzl@62975
  1629
  ultimately show "(\<lambda>x. ennreal (Sigma_Algebra.measure M (A x))) \<longlonglongrightarrow> ennreal (Sigma_Algebra.measure M (\<Union>i. A i))"
hoelzl@62975
  1630
    using A by (auto intro!: Lim_emeasure_incseq)
hoelzl@62975
  1631
qed auto
hoelzl@47694
  1632
hoelzl@47694
  1633
lemma Lim_measure_decseq:
hoelzl@47694
  1634
  assumes A: "range A \<subseteq> sets M" "decseq A" and fin: "\<And>i. emeasure M (A i) \<noteq> \<infinity>"
wenzelm@61969
  1635
  shows "(\<lambda>n. measure M (A n)) \<longlonglongrightarrow> measure M (\<Inter>i. A i)"
hoelzl@62975
  1636
proof (rule tendsto_ennrealD)
hoelzl@62975
  1637
  have "ennreal (measure M (\<Inter>i. A i)) = emeasure M (\<Inter>i. A i)"
hoelzl@62975
  1638
    using fin[of 0] A emeasure_mono[of "\<Inter>i. A i" "A 0" M]
hoelzl@62975
  1639
    by (auto intro!: emeasure_eq_ennreal_measure[symmetric] simp: INT_lower less_top intro: le_less_trans)
hoelzl@62975
  1640
  moreover have "ennreal (measure M (A i)) = emeasure M (A i)" for i
hoelzl@62975
  1641
    using A fin[of i] by (intro emeasure_eq_ennreal_measure[symmetric]) auto
hoelzl@62975
  1642
  ultimately show "(\<lambda>x. ennreal (Sigma_Algebra.measure M (A x))) \<longlonglongrightarrow> ennreal (Sigma_Algebra.measure M (\<Inter>i. A i))"
hoelzl@62975
  1643
    using fin A by (auto intro!: Lim_emeasure_decseq)
hoelzl@62975
  1644
qed auto
hoelzl@47694
  1645
hoelzl@63958
  1646
subsection \<open>Set of measurable sets with finite measure\<close>
hoelzl@63958
  1647
hoelzl@63958
  1648
definition fmeasurable :: "'a measure \<Rightarrow> 'a set set"
hoelzl@63958
  1649
where
hoelzl@63958
  1650
  "fmeasurable M = {A\<in>sets M. emeasure M A < \<infinity>}"
hoelzl@63958
  1651
hoelzl@63958
  1652
lemma fmeasurableD[dest, measurable_dest]: "A \<in> fmeasurable M \<Longrightarrow> A \<in> sets M"
hoelzl@63958
  1653
  by (auto simp: fmeasurable_def)
hoelzl@63958
  1654
hoelzl@63959
  1655
lemma fmeasurableD2: "A \<in> fmeasurable M \<Longrightarrow> emeasure M A \<noteq> top"
hoelzl@63959
  1656
  by (auto simp: fmeasurable_def)
hoelzl@63959
  1657
hoelzl@63958
  1658
lemma fmeasurableI: "A \<in> sets M \<Longrightarrow> emeasure M A < \<infinity> \<Longrightarrow> A \<in> fmeasurable M"
hoelzl@63958
  1659
  by (auto simp: fmeasurable_def)
hoelzl@63958
  1660
hoelzl@63958
  1661
lemma fmeasurableI_null_sets: "A \<in> null_sets M \<Longrightarrow> A \<in> fmeasurable M"
hoelzl@63958
  1662
  by (auto simp: fmeasurable_def)
hoelzl@63958
  1663
hoelzl@63958
  1664
lemma fmeasurableI2: "A \<in> fmeasurable M \<Longrightarrow> B \<subseteq> A \<Longrightarrow> B \<in> sets M \<Longrightarrow> B \<in> fmeasurable M"
hoelzl@63958
  1665
  using emeasure_mono[of B A M] by (auto simp: fmeasurable_def)
hoelzl@63958
  1666
hoelzl@63958
  1667
lemma measure_mono_fmeasurable:
hoelzl@63958
  1668
  "A \<subseteq> B \<Longrightarrow> A \<in> sets M \<Longrightarrow> B \<in> fmeasurable M \<Longrightarrow> measure M A \<le> measure M B"
hoelzl@63958
  1669
  by (auto simp: measure_def fmeasurable_def intro!: emeasure_mono enn2real_mono)
hoelzl@63958
  1670
hoelzl@63958
  1671
lemma emeasure_eq_measure2: "A \<in> fmeasurable M \<Longrightarrow> emeasure M A = measure M A"
hoelzl@63958
  1672
  by (simp add: emeasure_eq_ennreal_measure fmeasurable_def less_top)
hoelzl@63958
  1673
hoelzl@63958
  1674
interpretation fmeasurable: ring_of_sets "space M" "fmeasurable M"
hoelzl@63958
  1675
proof (rule ring_of_setsI)
hoelzl@63958
  1676
  show "fmeasurable M \<subseteq> Pow (space M)" "{} \<in> fmeasurable M"
hoelzl@63958
  1677
    by (auto simp: fmeasurable_def dest: sets.sets_into_space)
hoelzl@63958
  1678
  fix a b assume *: "a \<in> fmeasurable M" "b \<in> fmeasurable M"
hoelzl@63958
  1679
  then have "emeasure M (a \<union> b) \<le> emeasure M a + emeasure M b"
hoelzl@63958
  1680
    by (intro emeasure_subadditive) auto
hoelzl@63958
  1681
  also have "\<dots> < top"
hoelzl@63958
  1682
    using * by (auto simp: fmeasurable_def)
hoelzl@63958
  1683
  finally show  "a \<union> b \<in> fmeasurable M"
hoelzl@63958
  1684
    using * by (auto intro: fmeasurableI)
hoelzl@63958
  1685
  show "a - b \<in> fmeasurable M"
hoelzl@63958
  1686
    using emeasure_mono[of "a - b" a M] * by (auto simp: fmeasurable_def Diff_subset)
hoelzl@63958
  1687
qed
hoelzl@63958
  1688
hoelzl@63958
  1689
lemma fmeasurable_Diff: "A \<in> fmeasurable M \<Longrightarrow> B \<in> sets M \<Longrightarrow> A - B \<in> fmeasurable M"
hoelzl@63958
  1690
  using fmeasurableI2[of A M "A - B"] by auto
hoelzl@63958
  1691
hoelzl@63958
  1692
lemma fmeasurable_UN:
hoelzl@63958
  1693
  assumes "countable I" "\<And>i. i \<in> I \<Longrightarrow> F i \<subseteq> A" "\<And>i. i \<in> I \<Longrightarrow> F i \<in> sets M" "A \<in> fmeasurable M"
hoelzl@63958
  1694
  shows "(\<Union>i\<in>I. F i) \<in> fmeasurable M"
hoelzl@63958
  1695
proof (rule fmeasurableI2)
hoelzl@63958
  1696
  show "A \<in> fmeasurable M" "(\<Union>i\<in>I. F i) \<subseteq> A" using assms by auto
hoelzl@63958
  1697
  show "(\<Union>i\<in>I. F i) \<in> sets M"
hoelzl@63958
  1698
    using assms by (intro sets.countable_UN') auto
hoelzl@63958
  1699
qed
hoelzl@63958
  1700
hoelzl@63958
  1701
lemma fmeasurable_INT:
hoelzl@63958
  1702
  assumes "countable I" "i \<in> I" "\<And>i. i \<in> I \<Longrightarrow> F i \<in> sets M" "F i \<in> fmeasurable M"
hoelzl@63958
  1703
  shows "(\<Inter>i\<in>I. F i) \<in> fmeasurable M"
hoelzl@63958
  1704
proof (rule fmeasurableI2)
hoelzl@63958
  1705
  show "F i \<in> fmeasurable M" "(\<Inter>i\<in>I. F i) \<subseteq> F i"
hoelzl@63958
  1706
    using assms by auto
hoelzl@63958
  1707
  show "(\<Inter>i\<in>I. F i) \<in> sets M"
hoelzl@63958
  1708
    using assms by (intro sets.countable_INT') auto
hoelzl@63958
  1709
qed
hoelzl@63958
  1710
hoelzl@63959
  1711
lemma measure_Un2:
hoelzl@63959
  1712
  "A \<in> fmeasurable M \<Longrightarrow> B \<in> fmeasurable M \<Longrightarrow> measure M (A \<union> B) = measure M A + measure M (B - A)"
hoelzl@63959
  1713
  using measure_Union[of M A "B - A"] by (auto simp: fmeasurableD2 fmeasurable.Diff)
hoelzl@63959
  1714
hoelzl@63959
  1715
lemma measure_Un3:
hoelzl@63959
  1716
  assumes "A \<in> fmeasurable M" "B \<in> fmeasurable M"
hoelzl@63959
  1717
  shows "measure M (A \<union> B) = measure M A + measure M B - measure M (A \<inter> B)"
hoelzl@63959
  1718
proof -
hoelzl@63959
  1719
  have "measure M (A \<union> B) = measure M A + measure M (B - A)"
hoelzl@63959
  1720
    using assms by (rule measure_Un2)
hoelzl@63959
  1721
  also have "B - A = B - (A \<inter> B)"
hoelzl@63959
  1722
    by auto
hoelzl@63959
  1723
  also have "measure M (B - (A \<inter> B)) = measure M B - measure M (A \<inter> B)"
hoelzl@63959
  1724
    using assms by (intro measure_Diff) (auto simp: fmeasurable_def)
hoelzl@63959
  1725
  finally show ?thesis
hoelzl@63959
  1726
    by simp
hoelzl@63959
  1727
qed
hoelzl@63959
  1728
hoelzl@63959
  1729
lemma measure_Un_AE:
hoelzl@63959
  1730
  "AE x in M. x \<notin> A \<or> x \<notin> B \<Longrightarrow> A \<in> fmeasurable M \<Longrightarrow> B \<in> fmeasurable M \<Longrightarrow>
hoelzl@63959
  1731
  measure M (A \<union> B) = measure M A + measure M B"
hoelzl@63959
  1732
  by (subst measure_Un2) (auto intro!: measure_eq_AE)
hoelzl@63959
  1733
hoelzl@63959
  1734
lemma measure_UNION_AE:
hoelzl@63959
  1735
  assumes I: "finite I"
hoelzl@63959
  1736
  shows "(\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M) \<Longrightarrow> pairwise (\<lambda>i j. AE x in M. x \<notin> F i \<or> x \<notin> F j) I \<Longrightarrow>
hoelzl@63959
  1737
    measure M (\<Union>i\<in>I. F i) = (\<Sum>i\<in>I. measure M (F i))"
hoelzl@63959
  1738
  unfolding AE_pairwise[OF countable_finite, OF I]
hoelzl@63959
  1739
  using I
hoelzl@63959
  1740
  apply (induction I rule: finite_induct)
hoelzl@63959
  1741
   apply simp
hoelzl@63959
  1742
  apply (simp add: pairwise_insert)
hoelzl@63959
  1743
  apply (subst measure_Un_AE)
hoelzl@63959
  1744
  apply auto
hoelzl@63959
  1745
  done
hoelzl@63959
  1746
hoelzl@63959
  1747
lemma measure_UNION':
hoelzl@63959
  1748
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> F i \<in> fmeasurable M) \<Longrightarrow> pairwise (\<lambda>i j. disjnt (F i) (F j)) I \<Longrightarrow>
hoelzl@63959
  1749
    measure M (\<Union>i\<in>I. F i) = (\<Sum>i\<in>I. measure M (F i))"
hoelzl@63959
  1750
  by (intro measure_UNION_AE) (auto simp: disjnt_def elim!: pairwise_mono intro!: always_eventually)
hoelzl@63959
  1751
hoelzl@63959
  1752
lemma measure_Union_AE:
hoelzl@63959
  1753
  "finite F \<Longrightarrow> (\<And>S. S \<in> F \<Longrightarrow> S \<in> fmeasurable M) \<Longrightarrow> pairwise (\<lambda>S T. AE x in M. x \<notin> S \<or> x \<notin> T) F \<Longrightarrow>
hoelzl@63959
  1754
    measure M (\<Union>F) = (\<Sum>S\<in>F. measure M S)"
hoelzl@63959
  1755
  using measure_UNION_AE[of F "\<lambda>x. x" M] by simp
hoelzl@63959
  1756
hoelzl@63959
  1757
lemma measure_Union':
hoelzl@63959
  1758
  "finite F \<Longrightarrow> (\<And>S. S \<in> F \<Longrightarrow> S \<in> fmeasurable M) \<Longrightarrow> pairwise disjnt F \<Longrightarrow> measure M (\<Union>F) = (\<Sum>S\<in>F. measure M S)"
hoelzl@63959
  1759
  using measure_UNION'[of F "\<lambda>x. x" M] by simp
hoelzl@63959
  1760
hoelzl@63959
  1761
lemma measure_Un_le:
hoelzl@63959
  1762
  assumes "A \<in> sets M" "B \<in> sets M" shows "measure M (A \<union> B) \<le> measure M A + measure M B"
hoelzl@63959
  1763
proof cases
hoelzl@63959
  1764
  assume "A \<in> fmeasurable M \<and> B \<in> fmeasurable M"
hoelzl@63959
  1765
  with measure_subadditive[of A M B] assms show ?thesis
hoelzl@63959
  1766
    by (auto simp: fmeasurableD2)
hoelzl@63959
  1767
next
hoelzl@63959
  1768
  assume "\<not> (A \<in> fmeasurable M \<and> B \<in> fmeasurable M)"
hoelzl@63959
  1769
  then have "A \<union> B \<notin> fmeasurable M"
hoelzl@63959
  1770
    using fmeasurableI2[of "A \<union> B" M A] fmeasurableI2[of "A \<union> B" M B] assms by auto
hoelzl@63959
  1771
  with assms show ?thesis
hoelzl@63959
  1772
    by (auto simp: fmeasurable_def measure_def less_top[symmetric])
hoelzl@63959
  1773
qed
hoelzl@63959
  1774
hoelzl@63959
  1775
lemma measure_UNION_le:
hoelzl@63959
  1776
  "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> F i \<in> sets M) \<Longrightarrow> measure M (\<Union>i\<in>I. F i) \<le> (\<Sum>i\<in>I. measure M (F i))"
hoelzl@63959
  1777
proof (induction I rule: finite_induct)
hoelzl@63959
  1778
  case (insert i I)
hoelzl@63959
  1779
  then have "measure M (\<Union>i\<in>insert i I. F i) \<le> measure M (F i) + measure M (\<Union>i\<in>I. F i)"
hoelzl@63959
  1780
    by (auto intro!: measure_Un_le)
hoelzl@63959
  1781
  also have "measure M (\<Union>i\<in>I. F i) \<le> (\<Sum>i\<in>I. measure M (F i))"
hoelzl@63959
  1782
    using insert by auto
hoelzl@63959
  1783
  finally show ?case
hoelzl@63959
  1784
    using insert by simp
hoelzl@63959
  1785
qed simp
hoelzl@63959
  1786
hoelzl@63959
  1787
lemma measure_Union_le:
hoelzl@63959
  1788
  "finite F \<Longrightarrow> (\<And>S. S \<in> F \<Longrightarrow> S \<in> sets M) \<Longrightarrow> measure M (\<Union>F) \<le> (\<Sum>S\<in>F. measure M S)"
hoelzl@63959
  1789
  using measure_UNION_le[of F "\<lambda>x. x" M] by simp
hoelzl@63959
  1790
hoelzl@63968
  1791
lemma
hoelzl@63968
  1792
  assumes "countable I" and I: "\<And>i. i \<in> I \<Longrightarrow> A i \<in> fmeasurable M"
hoelzl@63968
  1793
    and bound: "\<And>I'. I' \<subseteq> I \<Longrightarrow> finite I' \<Longrightarrow> measure M (\<Union>i\<in>I'. A i) \<le> B" and "0 \<le> B"
hoelzl@63968
  1794
  shows fmeasurable_UN_bound: "(\<Union>i\<in>I. A i) \<in> fmeasurable M" (is ?fm)
hoelzl@63968
  1795
    and measure_UN_bound: "measure M (\<Union>i\<in>I. A i) \<le> B" (is ?m)
hoelzl@63968
  1796
proof -
hoelzl@63968
  1797
  have "?fm \<and> ?m"
hoelzl@63968
  1798
  proof cases
hoelzl@63968
  1799
    assume "I = {}" with \<open>0 \<le> B\<close> show ?thesis by simp
hoelzl@63968
  1800
  next
hoelzl@63968
  1801
    assume "I \<noteq> {}"
hoelzl@63968
  1802
    have "(\<Union>i\<in>I. A i) = (\<Union>i. (\<Union>n\<le>i. A (from_nat_into I n)))"
hoelzl@63968
  1803
      by (subst range_from_nat_into[symmetric, OF \<open>I \<noteq> {}\<close> \<open>countable I\<close>]) auto
hoelzl@63968
  1804
    then have "emeasure M (\<Union>i\<in>I. A i) = emeasure M (\<Union>i. (\<Union>n\<le>i. A (from_nat_into I n)))" by simp
hoelzl@63968
  1805
    also have "\<dots> = (SUP i. emeasure M (\<Union>n\<le>i. A (from_nat_into I n)))"
hoelzl@63968
  1806
      using I \<open>I \<noteq> {}\<close>[THEN from_nat_into] by (intro SUP_emeasure_incseq[symmetric]) (fastforce simp: incseq_Suc_iff)+
hoelzl@63968
  1807
    also have "\<dots> \<le> B"
hoelzl@63968
  1808
    proof (intro SUP_least)
hoelzl@63968
  1809
      fix i :: nat
hoelzl@63968
  1810
      have "emeasure M (\<Union>n\<le>i. A (from_nat_into I n)) = measure M (\<Union>n\<le>i. A (from_nat_into I n))"
hoelzl@63968
  1811
        using I \<open>I \<noteq> {}\<close>[THEN from_nat_into] by (intro emeasure_eq_measure2 fmeasurable.finite_UN) auto
hoelzl@63968
  1812
      also have "\<dots> = measure M (\<Union>n\<in>from_nat_into I ` {..i}. A n)"
hoelzl@63968
  1813
        by simp
hoelzl@63968
  1814
      also have "\<dots> \<le> B"
hoelzl@63968
  1815
        by (intro ennreal_leI bound) (auto intro:  from_nat_into[OF \<open>I \<noteq> {}\<close>])
hoelzl@63968
  1816
      finally show "emeasure M (\<Union>n\<le>i. A (from_nat_into I n)) \<le> ennreal B" .
hoelzl@63968
  1817
    qed
hoelzl@63968
  1818
    finally have *: "emeasure M (\<Union>i\<in>I. A i) \<le> B" .
hoelzl@63968
  1819
    then have ?fm
hoelzl@63968
  1820
      using I \<open>countable I\<close> by (intro fmeasurableI conjI) (auto simp: less_top[symmetric] top_unique)
hoelzl@63968
  1821
    with * \<open>0\<le>B\<close> show ?thesis
hoelzl@63968
  1822
      by (simp add: emeasure_eq_measure2)
hoelzl@63968
  1823
  qed
hoelzl@63968
  1824
  then show ?fm ?m by auto
hoelzl@63968
  1825
qed
hoelzl@63968
  1826
wenzelm@61808
  1827
subsection \<open>Measure spaces with @{term "emeasure M (space M) < \<infinity>"}\<close>
hoelzl@47694
  1828
hoelzl@47694
  1829
locale finite_measure = sigma_finite_measure M for M +
hoelzl@62975
  1830
  assumes finite_emeasure_space: "emeasure M (space M) \<noteq> top"
hoelzl@47694
  1831
hoelzl@47694
  1832
lemma finite_measureI[Pure.intro!]:
hoelzl@57447
  1833
  "emeasure M (space M) \<noteq> \<infinity> \<Longrightarrow> finite_measure M"
hoelzl@57447
  1834
  proof qed (auto intro!: exI[of _ "{space M}"])
hoelzl@47694
  1835
hoelzl@62975
  1836
lemma (in finite_measure) emeasure_finite[simp, intro]: "emeasure M A \<noteq> top"
hoelzl@62975
  1837
  using finite_emeasure_space emeasure_space[of M A] by (auto simp: top_unique)
hoelzl@47694
  1838
hoelzl@63958
  1839
lemma (in finite_measure) fmeasurable_eq_sets: "fmeasurable M = sets M"
hoelzl@63958
  1840
  by (auto simp: fmeasurable_def less_top[symmetric])
hoelzl@63958
  1841
hoelzl@62975
  1842
lemma (in finite_measure) emeasure_eq_measure: "emeasure M A = ennreal (measure M A)"
hoelzl@62975
  1843
  by (intro emeasure_eq_ennreal_measure) simp
hoelzl@47694
  1844
hoelzl@62975
  1845
lemma (in finite_measure) emeasure_real: "\<exists>r. 0 \<le> r \<and> emeasure M A = ennreal r"
hoelzl@62975
  1846
  using emeasure_finite[of A] by (cases "emeasure M A" rule: ennreal_cases) auto
hoelzl@47694
  1847
hoelzl@47694
  1848
lemma (in finite_measure) bounded_measure: "measure M A \<le> measure M (space M)"
hoelzl@47694
  1849
  using emeasure_space[of M A] emeasure_real[of A] emeasure_real[of "space M"] by (auto simp: measure_def)
hoelzl@47694
  1850
hoelzl@47694
  1851
lemma (in finite_measure) finite_measure_Diff:
hoelzl@47694
  1852
  assumes sets: "A \<in> sets M" "B \<in> sets M" and "B \<subseteq> A"
hoelzl@47694
  1853
  shows "measure M (A - B) = measure M A - measure M B"
hoelzl@47694
  1854
  using measure_Diff[OF _ assms] by simp
hoelzl@47694
  1855
hoelzl@47694
  1856
lemma (in finite_measure) finite_measure_Union:
hoelzl@47694
  1857
  assumes sets: "A \<in> sets M" "B \<in> sets M" and "A \<inter> B = {}"
hoelzl@47694
  1858
  shows "measure M (A \<union> B) = measure M A + measure M B"
hoelzl@47694
  1859
  using measure_Union[OF _ _ assms] by simp
hoelzl@47694
  1860
hoelzl@47694
  1861
lemma (in finite_measure) finite_measure_finite_Union:
hoelzl@62975
  1862
  assumes measurable: "finite S" "A`S \<subseteq> sets M" "disjoint_family_on A S"
hoelzl@47694
  1863
  shows "measure M (\<Union>i\<in>S. A i) = (\<Sum>i\<in>S. measure M (A i))"
hoelzl@47694
  1864
  using measure_finite_Union[OF assms] by simp
hoelzl@47694
  1865
hoelzl@47694
  1866
lemma (in finite_measure) finite_measure_UNION:
hoelzl@47694
  1867
  assumes A: "range A \<subseteq> sets M" "disjoint_family A"
hoelzl@47694
  1868
  shows "(\<lambda>i. measure M (A i)) sums (measure M (\<Union>i. A i))"
hoelzl@47694
  1869
  using measure_UNION[OF A] by simp
hoelzl@47694
  1870
hoelzl@47694
  1871
lemma (in finite_measure) finite_measure_mono:
hoelzl@47694
  1872
  assumes "A \<subseteq> B" "B \<in> sets M" shows "measure M A \<le> measure M B"
hoelzl@47694
  1873
  using emeasure_mono[OF assms] emeasure_real[of A] emeasure_real[of B] by (auto simp: measure_def)
hoelzl@47694
  1874
hoelzl@47694
  1875
lemma (in finite_measure) finite_measure_subadditive:
hoelzl@47694
  1876
  assumes m: "A \<in> sets M" "B \<in> sets M"
hoelzl@47694
  1877
  shows "measure M (A \<union> B) \<le> measure M A + measure M B"
hoelzl@47694
  1878
  using measure_subadditive[OF m] by simp
hoelzl@47694
  1879
hoelzl@47694
  1880
lemma (in finite_measure) finite_measure_subadditive_finite:
hoelzl@47694
  1881
  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
  1882
  using measure_subadditive_finite[OF assms] by simp
hoelzl@47694
  1883
hoelzl@47694
  1884
lemma (in finite_measure) finite_measure_subadditive_countably:
hoelzl@62975
  1885
  "range A \<subseteq> sets M \<Longrightarrow> summable (\<lambda>i. measure M (A i)) \<Longrightarrow> measure M (\<Union>i. A i) \<le> (\<Sum>i. measure M (A i))"
hoelzl@62975
  1886
  by (rule measure_subadditive_countably)
hoelzl@62975
  1887
     (simp_all add: ennreal_suminf_neq_top emeasure_eq_measure)
hoelzl@47694
  1888
nipkow@64267
  1889
lemma (in finite_measure) finite_measure_eq_sum_singleton:
hoelzl@47694
  1890
  assumes "finite S" and *: "\<And>x. x \<in> S \<Longrightarrow> {x} \<in> sets M"
hoelzl@47694
  1891
  shows "measure M S = (\<Sum>x\<in>S. measure M {x})"
nipkow@64267
  1892
  using measure_eq_sum_singleton[OF assms] by simp
hoelzl@47694
  1893
hoelzl@47694
  1894
lemma (in finite_measure) finite_Lim_measure_incseq:
hoelzl@47694
  1895
  assumes A: "range A \<subseteq> sets M" "incseq A"
wenzelm@61969
  1896
  shows "(\<lambda>i. measure M (A i)) \<longlonglongrightarrow> measure M (\<Union>i. A i)"
hoelzl@47694
  1897
  using Lim_measure_incseq[OF A] by simp
hoelzl@47694
  1898
hoelzl@47694
  1899
lemma (in finite_measure) finite_Lim_measure_decseq:
hoelzl@47694
  1900
  assumes A: "range A \<subseteq> sets M" "decseq A"
wenzelm@61969
  1901
  shows "(\<lambda>n. measure M (A n)) \<longlonglongrightarrow> measure M (\<Inter>i. A i)"
hoelzl@47694
  1902
  using Lim_measure_decseq[OF A] by simp
hoelzl@47694
  1903
hoelzl@47694
  1904
lemma (in finite_measure) finite_measure_compl:
hoelzl@47694
  1905
  assumes S: "S \<in> sets M"
hoelzl@47694
  1906
  shows "measure M (space M - S) = measure M (space M) - measure M S"
immler@50244
  1907
  using measure_Diff[OF _ sets.top S sets.sets_into_space] S by simp
hoelzl@47694
  1908
hoelzl@47694
  1909
lemma (in finite_measure) finite_measure_mono_AE:
hoelzl@47694
  1910
  assumes imp: "AE x in M. x \<in> A \<longrightarrow> x \<in> B" and B: "B \<in> sets M"
hoelzl@47694
  1911
  shows "measure M A \<le> measure M B"
hoelzl@47694
  1912
  using assms emeasure_mono_AE[OF imp B]
hoelzl@47694
  1913
  by (simp add: emeasure_eq_measure)
hoelzl@47694
  1914
hoelzl@47694
  1915
lemma (in finite_measure) finite_measure_eq_AE:
hoelzl@47694
  1916
  assumes iff: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@47694
  1917
  assumes A: "A \<in> sets M" and B: "B \<in> sets M"
hoelzl@47694
  1918
  shows "measure M A = measure M B"
hoelzl@47694
  1919
  using assms emeasure_eq_AE[OF assms] by (simp add: emeasure_eq_measure)
hoelzl@47694
  1920
hoelzl@50104
  1921
lemma (in finite_measure) measure_increasing: "increasing M (measure M)"
hoelzl@50104
  1922
  by (auto intro!: finite_measure_mono simp: increasing_def)
hoelzl@50104
  1923
hoelzl@50104
  1924
lemma (in finite_measure) measure_zero_union:
hoelzl@50104
  1925
  assumes "s \<in> sets M" "t \<in> sets M" "measure M t = 0"
hoelzl@50104
  1926
  shows "measure M (s \<union> t) = measure M s"
hoelzl@50104
  1927
using assms
hoelzl@50104
  1928
proof -
hoelzl@50104
  1929
  have "measure M (s \<union> t) \<le> measure M s"
hoelzl@50104
  1930
    using finite_measure_subadditive[of s t] assms by auto
hoelzl@50104
  1931
  moreover have "measure M (s \<union> t) \<ge> measure M s"
hoelzl@50104
  1932
    using assms by (blast intro: finite_measure_mono)
hoelzl@50104
  1933
  ultimately show ?thesis by simp
hoelzl@50104
  1934
qed
hoelzl@50104
  1935
hoelzl@50104
  1936
lemma (in finite_measure) measure_eq_compl:
hoelzl@50104
  1937
  assumes "s \<in> sets M" "t \<in> sets M"
hoelzl@50104
  1938
  assumes "measure M (space M - s) = measure M (space M - t)"
hoelzl@50104
  1939
  shows "measure M s = measure M t"
hoelzl@50104
  1940
  using assms finite_measure_compl by auto
hoelzl@50104
  1941
hoelzl@50104
  1942
lemma (in finite_measure) measure_eq_bigunion_image:
hoelzl@50104
  1943
  assumes "range f \<subseteq> sets M" "range g \<subseteq> sets M"
hoelzl@50104
  1944
  assumes "disjoint_family f" "disjoint_family g"
hoelzl@50104
  1945
  assumes "\<And> n :: nat. measure M (f n) = measure M (g n)"
wenzelm@60585
  1946
  shows "measure M (\<Union>i. f i) = measure M (\<Union>i. g i)"
hoelzl@50104
  1947
using assms
hoelzl@50104
  1948
proof -
wenzelm@60585
  1949
  have a: "(\<lambda> i. measure M (f i)) sums (measure M (\<Union>i. f i))"
hoelzl@50104
  1950
    by (rule finite_measure_UNION[OF assms(1,3)])
wenzelm@60585
  1951
  have b: "(\<lambda> i. measure M (g i)) sums (measure M (\<Union>i. g i))"
hoelzl@50104
  1952
    by (rule finite_measure_UNION[OF assms(2,4)])
hoelzl@50104
  1953
  show ?thesis using sums_unique[OF b] sums_unique[OF a] assms by simp
hoelzl@50104
  1954
qed
hoelzl@50104
  1955
hoelzl@50104
  1956
lemma (in finite_measure) measure_countably_zero:
hoelzl@50104
  1957
  assumes "range c \<subseteq> sets M"
hoelzl@50104
  1958
  assumes "\<And> i. measure M (c i) = 0"
wenzelm@60585
  1959
  shows "measure M (\<Union>i :: nat. c i) = 0"
hoelzl@50104
  1960
proof (rule antisym)
wenzelm@60585
  1961
  show "measure M (\<Union>i :: nat. c i) \<le> 0"
hoelzl@50104
  1962
    using finite_measure_subadditive_countably[OF assms(1)] by (simp add: assms(2))
hoelzl@62975
  1963
qed simp
hoelzl@50104
  1964
hoelzl@50104
  1965
lemma (in finite_measure) measure_space_inter:
hoelzl@50104
  1966
  assumes events:"s \<in> sets M" "t \<in> sets M"
hoelzl@50104
  1967
  assumes "measure M t = measure M (space M)"
hoelzl@50104
  1968
  shows "measure M (s \<inter> t) = measure M s"
hoelzl@50104
  1969
proof -
hoelzl@50104
  1970
  have "measure M ((space M - s) \<union> (space M - t)) = measure M (space M - s)"
hoelzl@50104
  1971
    using events assms finite_measure_compl[of "t"] by (auto intro!: measure_zero_union)
hoelzl@50104
  1972
  also have "(space M - s) \<union> (space M - t) = space M - (s \<inter> t)"
hoelzl@50104
  1973
    by blast
hoelzl@50104
  1974
  finally show "measure M (s \<inter> t) = measure M s"
hoelzl@50104
  1975
    using events by (auto intro!: measure_eq_compl[of "s \<inter> t" s])
hoelzl@50104
  1976
qed
hoelzl@50104
  1977
hoelzl@50104
  1978
lemma (in finite_measure) measure_equiprobable_finite_unions:
hoelzl@50104
  1979
  assumes s: "finite s" "\<And>x. x \<in> s \<Longrightarrow> {x} \<in> sets M"
hoelzl@50104
  1980
  assumes "\<And> x y. \<lbrakk>x \<in> s; y \<in> s\<rbrakk> \<Longrightarrow> measure M {x} = measure M {y}"
hoelzl@50104
  1981
  shows "measure M s = real (card s) * measure M {SOME x. x \<in> s}"
hoelzl@50104
  1982
proof cases
hoelzl@50104
  1983
  assume "s \<noteq> {}"
hoelzl@50104
  1984
  then have "\<exists> x. x \<in> s" by blast
hoelzl@50104
  1985
  from someI_ex[OF this] assms
hoelzl@50104
  1986
  have prob_some: "\<And> x. x \<in> s \<Longrightarrow> measure M {x} = measure M {SOME y. y \<in> s}" by blast
hoelzl@50104
  1987
  have "measure M s = (\<Sum> x \<in> s. measure M {x})"
nipkow@64267
  1988
    using finite_measure_eq_sum_singleton[OF s] by simp
hoelzl@50104
  1989
  also have "\<dots> = (\<Sum> x \<in> s. measure M {SOME y. y \<in> s})" using prob_some by auto
hoelzl@50104
  1990
  also have "\<dots> = real (card s) * measure M {(SOME x. x \<in> s)}"
nipkow@64267
  1991
    using sum_constant assms by simp
hoelzl@50104
  1992
  finally show ?thesis by simp
hoelzl@50104
  1993
qed simp
hoelzl@50104
  1994
hoelzl@50104
  1995
lemma (in finite_measure) measure_real_sum_image_fn:
hoelzl@50104
  1996
  assumes "e \<in> sets M"
hoelzl@50104
  1997
  assumes "\<And> x. x \<in> s \<Longrightarrow> e \<inter> f x \<in> sets M"
hoelzl@50104
  1998
  assumes "finite s"
hoelzl@50104
  1999
  assumes disjoint: "\<And> x y. \<lbrakk>x \<in> s ; y \<in> s ; x \<noteq> y\<rbrakk> \<Longrightarrow> f x \<inter> f y = {}"
wenzelm@60585
  2000
  assumes upper: "space M \<subseteq> (\<Union>i \<in> s. f i)"
hoelzl@50104
  2001
  shows "measure M e = (\<Sum> x \<in> s. measure M (e \<inter> f x))"
hoelzl@50104
  2002
proof -
haftmann@62343
  2003
  have "e \<subseteq> (\<Union>i\<in>s. f i)"
wenzelm@61808
  2004
    using \<open>e \<in> sets M\<close> sets.sets_into_space upper by blast
haftmann@62343
  2005
  then have e: "e = (\<Union>i \<in> s. e \<inter> f i)"
haftmann@62343
  2006
    by auto
wenzelm@60585
  2007
  hence "measure M e = measure M (\<Union>i \<in> s. e \<inter> f i)" by simp
hoelzl@50104
  2008
  also have "\<dots> = (\<Sum> x \<in> s. measure M (e \<inter> f x))"
hoelzl@50104
  2009
  proof (rule finite_measure_finite_Union)
hoelzl@50104
  2010
    show "finite s" by fact
hoelzl@50104
  2011
    show "(\<lambda>i. e \<inter> f i)`s \<subseteq> sets M" using assms(2) by auto
hoelzl@50104
  2012
    show "disjoint_family_on (\<lambda>i. e \<inter> f i) s"
hoelzl@50104
  2013
      using disjoint by (auto simp: disjoint_family_on_def)
hoelzl@50104
  2014
  qed
hoelzl@50104
  2015
  finally show ?thesis .
hoelzl@50104
  2016
qed
hoelzl@50104
  2017
hoelzl@50104
  2018
lemma (in finite_measure) measure_exclude:
hoelzl@50104
  2019
  assumes "A \<in> sets M" "B \<in> sets M"
hoelzl@50104
  2020
  assumes "measure M A = measure M (space M)" "A \<inter> B = {}"
hoelzl@50104
  2021
  shows "measure M B = 0"
hoelzl@50104
  2022
  using measure_space_inter[of B A] assms by (auto simp: ac_simps)
hoelzl@57235
  2023
lemma (in finite_measure) finite_measure_distr:
lp15@61609
  2024
  assumes f: "f \<in> measurable M M'"
hoelzl@57235
  2025
  shows "finite_measure (distr M M' f)"
hoelzl@57235
  2026
proof (rule finite_measureI)
hoelzl@57235
  2027
  have "f -` space M' \<inter> space M = space M" using f by (auto dest: measurable_space)
hoelzl@57235
  2028
  with f show "emeasure (distr M M' f) (space (distr M M' f)) \<noteq> \<infinity>" by (auto simp: emeasure_distr)
hoelzl@57235
  2029
qed
hoelzl@57235
  2030
hoelzl@60636
  2031
lemma emeasure_gfp[consumes 1, case_names cont measurable]:
hoelzl@60636
  2032
  assumes sets[simp]: "\<And>s. sets (M s) = sets N"
hoelzl@60636
  2033
  assumes "\<And>s. finite_measure (M s)"
hoelzl@60636
  2034
  assumes cont: "inf_continuous F" "inf_continuous f"
hoelzl@60636
  2035
  assumes meas: "\<And>P. Measurable.pred N P \<Longrightarrow> Measurable.pred N (F P)"
hoelzl@60636
  2036
  assumes iter: "\<And>P s. Measurable.pred N P \<Longrightarrow> emeasure (M s) {x\<in>space N. F P x} = f (\<lambda>s. emeasure (M s) {x\<in>space N. P x}) s"
hoelzl@60636
  2037
  assumes bound: "\<And>P. f P \<le> f (\<lambda>s. emeasure (M s) (space (M s)))"
hoelzl@60636
  2038
  shows "emeasure (M s) {x\<in>space N. gfp F x} = gfp f s"
hoelzl@60636
  2039
proof (subst gfp_transfer_bounded[where \<alpha>="\<lambda>F s. emeasure (M s) {x\<in>space N. F x}" and g=f and f=F and
hoelzl@60636
  2040
    P="Measurable.pred N", symmetric])
hoelzl@60636
  2041
  interpret finite_measure "M s" for s by fact
hoelzl@60636
  2042
  fix C assume "decseq C" "\<And>i. Measurable.pred N (C i)"
hoelzl@60636
  2043
  then show "(\<lambda>s. emeasure (M s) {x \<in> space N. (INF i. C i) x}) = (INF i. (\<lambda>s. emeasure (M s) {x \<in> space N. C i x}))"
hoelzl@60636
  2044
    unfolding INF_apply[abs_def]
hoelzl@60636
  2045
    by (subst INF_emeasure_decseq) (auto simp: antimono_def fun_eq_iff intro!: arg_cong2[where f=emeasure])
hoelzl@60636
  2046
next
hoelzl@60636
  2047
  show "f x \<le> (\<lambda>s. emeasure (M s) {x \<in> space N. F top x})" for x
hoelzl@60636
  2048
    using bound[of x] sets_eq_imp_space_eq[OF sets] by (simp add: iter)
hoelzl@60636
  2049
qed (auto simp add: iter le_fun_def INF_apply[abs_def] intro!: meas cont)
hoelzl@60636
  2050
wenzelm@61808
  2051
subsection \<open>Counting space\<close>
hoelzl@47694
  2052
hoelzl@49773
  2053
lemma strict_monoI_Suc:
hoelzl@49773
  2054
  assumes ord [simp]: "(\<And>n. f n < f (Suc n))" shows "strict_mono f"
hoelzl@49773
  2055
  unfolding strict_mono_def
hoelzl@49773
  2056
proof safe
hoelzl@49773
  2057
  fix n m :: nat assume "n < m" then show "f n < f m"
hoelzl@49773
  2058
    by (induct m) (auto simp: less_Suc_eq intro: less_trans ord)
hoelzl@49773
  2059
qed
hoelzl@49773
  2060
hoelzl@47694
  2061
lemma emeasure_count_space:
hoelzl@62975
  2062
  assumes "X \<subseteq> A" shows "emeasure (count_space A) X = (if finite X then of_nat (card X) else \<infinity>)"
hoelzl@47694
  2063
    (is "_ = ?M X")
hoelzl@47694
  2064
  unfolding count_space_def
hoelzl@47694
  2065
proof (rule emeasure_measure_of_sigma)
wenzelm@61808
  2066
  show "X \<in> Pow A" using \<open>X \<subseteq> A\<close> by auto
hoelzl@47694
  2067
  show "sigma_algebra A (Pow A)" by (rule sigma_algebra_Pow)
hoelzl@49773
  2068
  show positive: "positive (Pow A) ?M"
hoelzl@47694
  2069
    by (auto simp: positive_def)
hoelzl@49773
  2070
  have additive: "additive (Pow A) ?M"
hoelzl@49773
  2071
    by (auto simp: card_Un_disjoint additive_def)
hoelzl@47694
  2072
hoelzl@49773
  2073
  interpret ring_of_sets A "Pow A"
hoelzl@49773
  2074
    by (rule ring_of_setsI) auto
lp15@61609
  2075
  show "countably_additive (Pow A) ?M"
hoelzl@49773
  2076
    unfolding countably_additive_iff_continuous_from_below[OF positive additive]
hoelzl@49773
  2077
  proof safe
hoelzl@49773
  2078
    fix F :: "nat \<Rightarrow> 'a set" assume "incseq F"
wenzelm@61969
  2079
    show "(\<lambda>i. ?M (F i)) \<longlonglongrightarrow> ?M (\<Union>i. F i)"
hoelzl@49773
  2080
    proof cases
hoelzl@49773
  2081
      assume "\<exists>i. \<forall>j\<ge>i. F i = F j"
hoelzl@49773
  2082
      then guess i .. note i = this
wenzelm@61808
  2083
      { fix j from i \<open>incseq F\<close> have "F j \<subseteq> F i"
hoelzl@49773
  2084
          by (cases "i \<le> j") (auto simp: incseq_def) }
hoelzl@49773
  2085
      then have eq: "(\<Union>i. F i) = F i"
hoelzl@49773
  2086
        by auto
hoelzl@49773
  2087
      with i show ?thesis
hoelzl@63626
  2088
        by (auto intro!: Lim_transform_eventually[OF _ tendsto_const] eventually_sequentiallyI[where c=i])
hoelzl@49773
  2089
    next
hoelzl@49773
  2090
      assume "\<not> (\<exists>i. \<forall>j\<ge>i. F i = F j)"
wenzelm@53374
  2091
      then obtain f where f: "\<And>i. i \<le> f i" "\<And>i. F i \<noteq> F (f i)" by metis
wenzelm@61808
  2092
      then have "\<And>i. F i \<subseteq> F (f i)" using \<open>incseq F\<close> by (auto simp: incseq_def)
wenzelm@53374
  2093
      with f have *: "\<And>i. F i \<subset> F (f i)" by auto
hoelzl@47694
  2094
hoelzl@49773
  2095
      have "incseq (\<lambda>i. ?M (F i))"
wenzelm@61808
  2096
        using \<open>incseq F\<close> unfolding incseq_def by (auto simp: card_mono dest: finite_subset)
wenzelm@61969
  2097
      then have "(\<lambda>i. ?M (F i)) \<longlonglongrightarrow> (SUP n. ?M (F n))"
hoelzl@51000
  2098
        by (rule LIMSEQ_SUP)
hoelzl@47694
  2099
hoelzl@62975
  2100
      moreover have "(SUP n. ?M (F n)) = top"
hoelzl@62975
  2101
      proof (rule ennreal_SUP_eq_top)
hoelzl@62975
  2102
        fix n :: nat show "\<exists>k::nat\<in>UNIV. of_nat n \<le> ?M (F k)"
hoelzl@49773
  2103
        proof (induct n)
hoelzl@49773
  2104
          case (Suc n)
hoelzl@49773
  2105
          then guess k .. note k = this
hoelzl@49773
  2106
          moreover have "finite (F k) \<Longrightarrow> finite (F (f k)) \<Longrightarrow> card (F k) < card (F (f k))"
wenzelm@61808
  2107
            using \<open>F k \<subset> F (f k)\<close> by (simp add: psubset_card_mono)
hoelzl@49773
  2108
          moreover have "finite (F (f k)) \<Longrightarrow> finite (F k)"
wenzelm@61808
  2109
            using \<open>k \<le> f k\<close> \<open>incseq F\<close> by (auto simp: incseq_def dest: finite_subset)
hoelzl@49773
  2110
          ultimately show ?case
hoelzl@62975
  2111
            by (auto intro!: exI[of _ "f k"] simp del: of_nat_Suc)
hoelzl@49773
  2112
        qed auto
hoelzl@47694
  2113
      qed
hoelzl@49773
  2114
hoelzl@49773
  2115
      moreover
hoelzl@49773
  2116
      have "inj (\<lambda>n. F ((f ^^ n) 0))"
hoelzl@49773
  2117
        by (intro strict_mono_imp_inj_on strict_monoI_Suc) (simp add: *)
hoelzl@49773
  2118
      then have 1: "infinite (range (\<lambda>i. F ((f ^^ i) 0)))"
hoelzl@49773
  2119
        by (rule range_inj_infinite)
hoelzl@49773
  2120
      have "infinite (Pow (\<Union>i. F i))"
hoelzl@49773
  2121
        by (rule infinite_super[OF _ 1]) auto
hoelzl@49773
  2122
      then have "infinite (\<Union>i. F i)"
hoelzl@49773
  2123
        by auto
lp15@61609
  2124
hoelzl@49773
  2125
      ultimately show ?thesis by auto
hoelzl@49773
  2126
    qed
hoelzl@47694
  2127
  qed
hoelzl@47694
  2128
qed
hoelzl@47694
  2129
hoelzl@59011
  2130
lemma distr_bij_count_space:
hoelzl@59011
  2131
  assumes f: "bij_betw f A B"
hoelzl@59011
  2132
  shows "distr (count_space A) (count_space B) f = count_space B"
hoelzl@59011
  2133
proof (rule measure_eqI)
hoelzl@59011
  2134
  have f': "f \<in> measurable (count_space A) (count_space B)"
hoelzl@59011
  2135
    using f unfolding Pi_def bij_betw_def by auto
hoelzl@59011
  2136
  fix X assume "X \<in> sets (distr (count_space A) (count_space B) f)"
hoelzl@59011
  2137
  then have X: "X \<in> sets (count_space B)" by auto
wenzelm@63540
  2138
  moreover from X have "f -` X \<inter> A = the_inv_into A f ` X"
hoelzl@59011
  2139
    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
  2140
  moreover have "inj_on (the_inv_into A f) B"
hoelzl@59011
  2141
    using X f by (auto simp: bij_betw_def inj_on_the_inv_into)
hoelzl@59011
  2142
  with X have "inj_on (the_inv_into A f) X"
hoelzl@59011
  2143
    by (auto intro: subset_inj_on)
hoelzl@59011
  2144
  ultimately show "emeasure (distr (count_space A) (count_space B) f) X = emeasure (count_space B) X"
hoelzl@59011
  2145
    using f unfolding emeasure_distr[OF f' X]
hoelzl@59011
  2146
    by (subst (1 2) emeasure_count_space) (auto simp: card_image dest: finite_imageD)
hoelzl@59011
  2147
qed simp
hoelzl@59011
  2148
hoelzl@47694
  2149
lemma emeasure_count_space_finite[simp]:
hoelzl@62975
  2150
  "X \<subseteq> A \<Longrightarrow> finite X \<Longrightarrow> emeasure (count_space A) X = of_nat (card X)"
hoelzl@47694
  2151
  using emeasure_count_space[of X A] by simp
hoelzl@47694
  2152
hoelzl@47694
  2153
lemma emeasure_count_space_infinite[simp]:
hoelzl@47694
  2154
  "X \<subseteq> A \<Longrightarrow> infinite X \<Longrightarrow> emeasure (count_space A) X = \<infinity>"
hoelzl@47694
  2155
  using emeasure_count_space[of X A] by simp
hoelzl@47694
  2156
hoelzl@62975
  2157
lemma measure_count_space: "measure (count_space A) X = (if X \<subseteq> A then of_nat (card X) else 0)"
hoelzl@62975
  2158
  by (cases "finite X") (auto simp: measure_notin_sets ennreal_of_nat_eq_real_of_nat
hoelzl@62975
  2159
                                    measure_zero_top measure_eq_emeasure_eq_ennreal)
hoelzl@58606
  2160
hoelzl@47694
  2161
lemma emeasure_count_space_eq_0:
hoelzl@47694
  2162
  "emeasure (count_space A) X = 0 \<longleftrightarrow> (X \<subseteq> A \<longrightarrow> X = {})"
hoelzl@47694
  2163
proof cases
hoelzl@47694
  2164
  assume X: "X \<subseteq> A"
hoelzl@47694
  2165
  then show ?thesis
hoelzl@47694
  2166
  proof (intro iffI impI)
hoelzl@47694
  2167
    assume "emeasure (count_space A) X = 0"
hoelzl@47694
  2168
    with X show "X = {}"
nipkow@62390
  2169
      by (subst (asm) emeasure_count_space) (auto split: if_split_asm)
hoelzl@47694
  2170
  qed simp
hoelzl@47694
  2171
qed (simp add: emeasure_notin_sets)
hoelzl@47694
  2172
hoelzl@47694
  2173
lemma null_sets_count_space: "null_sets (count_space A) = { {} }"
hoelzl@47694
  2174
  unfolding null_sets_def by (auto simp add: emeasure_count_space_eq_0)
hoelzl@47694
  2175
hoelzl@47694
  2176
lemma AE_count_space: "(AE x in count_space A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
hoelzl@47694
  2177
  unfolding eventually_ae_filter by (auto simp add: null_sets_count_space)
hoelzl@47694
  2178
hoelzl@57025
  2179
lemma sigma_finite_measure_count_space_countable:
hoelzl@57025
  2180
  assumes A: "countable A"
hoelzl@47694
  2181
  shows "sigma_finite_measure (count_space A)"
hoelzl@62975
  2182
  proof qed (insert A, auto intro!: exI[of _ "(\<lambda>a. {a}) ` A"])
hoelzl@47694
  2183
hoelzl@57025
  2184
lemma sigma_finite_measure_count_space:
hoelzl@57025
  2185
  fixes A :: "'a::countable set" shows "sigma_finite_measure (count_space A)"
hoelzl@57025
  2186
  by (rule sigma_finite_measure_count_space_countable) auto
hoelzl@57025
  2187
hoelzl@47694
  2188
lemma finite_measure_count_space:
hoelzl@47694
  2189
  assumes [simp]: "finite A"
hoelzl@47694
  2190
  shows "finite_measure (count_space A)"
hoelzl@47694
  2191
  by rule simp
hoelzl@47694
  2192
hoelzl@47694
  2193
lemma sigma_finite_measure_count_space_finite:
hoelzl@47694
  2194
  assumes A: "finite A" shows "sigma_finite_measure (count_space A)"
hoelzl@47694
  2195
proof -
hoelzl@47694
  2196
  interpret finite_measure "count_space A" using A by (rule finite_measure_count_space)
hoelzl@47694
  2197
  show "sigma_finite_measure (count_space A)" ..
hoelzl@47694
  2198
qed
hoelzl@47694
  2199
wenzelm@61808
  2200
subsection \<open>Measure restricted to space\<close>
hoelzl@54417
  2201
hoelzl@54417
  2202
lemma emeasure_restrict_space:
hoelzl@57025
  2203
  assumes "\<Omega> \<inter> space M \<in> sets M" "A \<subseteq> \<Omega>"
hoelzl@54417
  2204
  shows "emeasure (restrict_space M \<Omega>) A = emeasure M A"
wenzelm@63540
  2205
proof (cases "A \<in> sets M")
wenzelm@63540
  2206
  case True
hoelzl@57025
  2207
  show ?thesis
hoelzl@54417
  2208
  proof (rule emeasure_measure_of[OF restrict_space_def])
hoelzl@57025
  2209
    show "op \<inter> \<Omega> ` sets M \<subseteq> Pow (\<Omega> \<inter> space M)" "A \<in> sets (restrict_space M \<Omega>)"
wenzelm@61808
  2210
      using \<open>A \<subseteq> \<Omega>\<close> \<open>A \<in> sets M\<close> sets.space_closed by (auto simp: sets_restrict_space)
hoelzl@57025
  2211
    show "positive (sets (restrict_space M \<Omega>)) (emeasure M)"
hoelzl@62975
  2212
      by (auto simp: positive_def)
hoelzl@57025
  2213
    show "countably_additive (sets (restrict_space M \<Omega>)) (emeasure M)"
hoelzl@54417
  2214
    proof (rule countably_additiveI)
hoelzl@54417
  2215
      fix A :: "nat \<Rightarrow> _" assume "range A \<subseteq> sets (restrict_space M \<Omega>)" "disjoint_family A"
hoelzl@54417
  2216
      with assms have "\<And>i. A i \<in> sets M" "\<And>i. A i \<subseteq> space M" "disjoint_family A"
hoelzl@57025
  2217
        by (fastforce simp: sets_restrict_space_iff[OF assms(1)] image_subset_iff
hoelzl@57025
  2218
                      dest: sets.sets_into_space)+
hoelzl@57025
  2219
      then show "(\<Sum>i. emeasure M (A i)) = emeasure M (\<Union>i. A i)"
hoelzl@54417
  2220
        by (subst suminf_emeasure) (auto simp: disjoint_family_subset)
hoelzl@54417
  2221
    qed
hoelzl@54417
  2222
  qed
hoelzl@54417
  2223
next
wenzelm@63540
  2224
  case False
wenzelm@63540
  2225
  with assms have "A \<notin> sets (restrict_space M \<Omega>)"
hoelzl@54417
  2226
    by (simp add: sets_restrict_space_iff)
wenzelm@63540
  2227
  with False show ?thesis
hoelzl@54417
  2228
    by (simp add: emeasure_notin_sets)
hoelzl@54417
  2229
qed
hoelzl@54417
  2230
hoelzl@57137
  2231
lemma measure_restrict_space:
hoelzl@57137
  2232
  assumes "\<Omega> \<inter> space M \<in> sets M" "A \<subseteq> \<Omega>"
hoelzl@57137
  2233
  shows "measure (restrict_space M \<Omega>) A = measure M A"
hoelzl@57137
  2234
  using emeasure_restrict_space[OF assms] by (simp add: measure_def)
hoelzl@57137
  2235
hoelzl@57137
  2236
lemma AE_restrict_space_iff:
hoelzl@57137
  2237
  assumes "\<Omega> \<inter> space M \<in> sets M"
hoelzl@57137
  2238
  shows "(AE x in restrict_space M \<Omega>. P x) \<longleftrightarrow> (AE x in M. x \<in> \<Omega> \<longrightarrow> P x)"
hoelzl@57137
  2239
proof -
hoelzl@57137
  2240
  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
  2241
    by auto
hoelzl@57137
  2242
  { fix X assume X: "X \<in> sets M" "emeasure M X = 0"
hoelzl@57137
  2243
    then have "emeasure M (\<Omega> \<inter> space M \<inter> X) \<le> emeasure M X"
hoelzl@57137
  2244
      by (intro emeasure_mono) auto
hoelzl@57137
  2245
    then have "emeasure M (\<Omega> \<inter> space M \<inter> X) = 0"
hoelzl@57137
  2246
      using X by (auto intro!: antisym) }
hoelzl@57137
  2247
  with assms show ?thesis
hoelzl@57137
  2248
    unfolding eventually_ae_filter
hoelzl@57137
  2249
    by (auto simp add: space_restrict_space null_sets_def sets_restrict_space_iff
hoelzl@57137
  2250
                       emeasure_restrict_space cong: conj_cong
hoelzl@57137
  2251
             intro!: ex_cong[where f="\<lambda>X. (\<Omega> \<inter> space M) \<inter> X"])
lp15@61609
  2252
qed
hoelzl@57137
  2253
hoelzl@57025
  2254
lemma restrict_restrict_space:
hoelzl@57025
  2255
  assumes "A \<inter> space M \<in> sets M" "B \<inter> space M \<in> sets M"
hoelzl@57025
  2256
  shows "restrict_space (restrict_space M A) B = restrict_space M (A \<inter> B)" (is "?l = ?r")
hoelzl@57025
  2257
proof (rule measure_eqI[symmetric])
hoelzl@57025
  2258
  show "sets ?r = sets ?l"
hoelzl@57025
  2259
    unfolding sets_restrict_space image_comp by (intro image_cong) auto
hoelzl@57025
  2260
next
hoelzl@57025
  2261
  fix X assume "X \<in> sets (restrict_space M (A \<inter> B))"
hoelzl@57025
  2262
  then obtain Y where "Y \<in> sets M" "X = Y \<inter> A \<inter> B"
hoelzl@57025
  2263
    by (auto simp: sets_restrict_space)
hoelzl@57025
  2264
  with assms sets.Int[OF assms] show "emeasure ?r X = emeasure ?l X"
hoelzl@57025
  2265
    by (subst (1 2) emeasure_restrict_space)
hoelzl@57025
  2266
       (auto simp: space_restrict_space sets_restrict_space_iff emeasure_restrict_space ac_simps)
hoelzl@57025
  2267
qed
hoelzl@57025
  2268
hoelzl@57025
  2269
lemma restrict_count_space: "restrict_space (count_space B) A = count_space (A \<inter> B)"
hoelzl@54417
  2270
proof (rule measure_eqI)
hoelzl@57025
  2271
  show "sets (restrict_space (count_space B) A) = sets (count_space (A \<inter> B))"
hoelzl@57025
  2272
    by (subst sets_restrict_space) auto
hoelzl@54417
  2273
  moreover fix X assume "X \<in> sets (restrict_space (count_space B) A)"
hoelzl@57025
  2274
  ultimately have "X \<subseteq> A \<inter> B" by auto
hoelzl@57025
  2275
  then show "emeasure (restrict_space (count_space B) A) X = emeasure (count_space (A \<inter> B)) X"
hoelzl@54417
  2276
    by (cases "finite X") (auto simp add: emeasure_restrict_space)
hoelzl@54417
  2277
qed
hoelzl@54417
  2278
Andreas@60063
  2279
lemma sigma_finite_measure_restrict_space:
Andreas@60063
  2280
  assumes "sigma_finite_measure M"
Andreas@60063
  2281
  and A: "A \<in> sets M"
Andreas@60063
  2282
  shows "sigma_finite_measure (restrict_space M A)"
Andreas@60063
  2283
proof -
Andreas@60063
  2284
  interpret sigma_finite_measure M by fact
Andreas@60063
  2285
  from sigma_finite_countable obtain C
Andreas@60063
  2286
    where C: "countable C" "C \<subseteq> sets M" "(\<Union>C) = space M" "\<forall>a\<in>C. emeasure M a \<noteq> \<infinity>"
Andreas@60063
  2287
    by blast
Andreas@60063
  2288
  let ?C = "op \<inter> A ` C"
Andreas@60063
  2289
  from C have "countable ?C" "?C \<subseteq> sets (restrict_space M A)" "(\<Union>?C) = space (restrict_space M A)"
Andreas@60063
  2290
    by(auto simp add: sets_restrict_space space_restrict_space)
Andreas@60063
  2291
  moreover {
Andreas@60063
  2292
    fix a
Andreas@60063
  2293
    assume "a \<in> ?C"
Andreas@60063
  2294
    then obtain a' where "a = A \<inter> a'" "a' \<in> C" ..
Andreas@60063
  2295
    then have "emeasure (restrict_space M A) a \<le> emeasure M a'"
Andreas@60063
  2296
      using A C by(auto simp add: emeasure_restrict_space intro: emeasure_mono)
hoelzl@62975
  2297
    also have "\<dots> < \<infinity>" using C(4)[rule_format, of a'] \<open>a' \<in> C\<close> by (simp add: less_top)
Andreas@60063
  2298
    finally have "emeasure (restrict_space M A) a \<noteq> \<infinity>" by simp }
Andreas@60063
  2299
  ultimately show ?thesis
Andreas@60063
  2300
    by unfold_locales (rule exI conjI|assumption|blast)+
Andreas@60063
  2301
qed
Andreas@60063
  2302
Andreas@60063
  2303
lemma finite_measure_restrict_space:
Andreas@60063
  2304
  assumes "finite_measure M"
Andreas@60063
  2305
  and A: "A \<in> sets M"
Andreas@60063
  2306
  shows "finite_measure (restrict_space M A)"
Andreas@60063
  2307
proof -
Andreas@60063
  2308
  interpret finite_measure M by fact
Andreas@60063
  2309
  show ?thesis
Andreas@60063
  2310
    by(rule finite_measureI)(simp add: emeasure_restrict_space A space_restrict_space)
Andreas@60063
  2311
qed
Andreas@60063
  2312
lp15@61609
  2313
lemma restrict_distr:
hoelzl@57137
  2314
  assumes [measurable]: "f \<in> measurable M N"
hoelzl@57137
  2315
  assumes [simp]: "\<Omega> \<inter> space N \<in> sets N" and restrict: "f \<in> space M \<rightarrow> \<Omega>"
hoelzl@57137
  2316
  shows "restrict_space (distr M N f) \<Omega> = distr M (restrict_space N \<Omega>) f"
hoelzl@57137
  2317
  (is "?l = ?r")
hoelzl@57137
  2318
proof (rule measure_eqI)
hoelzl@57137
  2319
  fix A assume "A \<in> sets (restrict_space (distr M N f) \<Omega>)"
hoelzl@57137
  2320
  with restrict show "emeasure ?l A = emeasure ?r A"
hoelzl@57137
  2321
    by (subst emeasure_distr)
hoelzl@57137
  2322
       (auto simp: sets_restrict_space_iff emeasure_restrict_space emeasure_distr
hoelzl@57137
  2323
             intro!: measurable_restrict_space2)
<