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