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