src/HOL/Probability/Caratheodory.thy
author noschinl
Tue Sep 13 16:21:48 2011 +0200 (2011-09-13)
changeset 44918 6a80fbc4e72c
parent 44568 e6f291cb5810
child 44928 7ef6505bde7f
permissions -rw-r--r--
tune simpset for Complete_Lattices
hoelzl@42067
     1
(*  Title:      HOL/Probability/Caratheodory.thy
hoelzl@42067
     2
    Author:     Lawrence C Paulson
hoelzl@42067
     3
    Author:     Johannes Hölzl, TU München
hoelzl@42067
     4
*)
hoelzl@42067
     5
paulson@33271
     6
header {*Caratheodory Extension Theorem*}
paulson@33271
     7
paulson@33271
     8
theory Caratheodory
haftmann@44106
     9
imports Sigma_Algebra "~~/src/HOL/Multivariate_Analysis/Extended_Real_Limits"
paulson@33271
    10
begin
paulson@33271
    11
hoelzl@42950
    12
lemma sums_def2:
hoelzl@42950
    13
  "f sums x \<longleftrightarrow> (\<lambda>n. (\<Sum>i\<le>n. f i)) ----> x"
hoelzl@42950
    14
  unfolding sums_def
hoelzl@42950
    15
  apply (subst LIMSEQ_Suc_iff[symmetric])
hoelzl@42950
    16
  unfolding atLeastLessThanSuc_atLeastAtMost atLeast0AtMost ..
hoelzl@42950
    17
hoelzl@42067
    18
text {*
hoelzl@42067
    19
  Originally from the Hurd/Coble measure theory development, translated by Lawrence Paulson.
hoelzl@42067
    20
*}
hoelzl@42067
    21
hoelzl@43920
    22
lemma suminf_ereal_2dimen:
hoelzl@43920
    23
  fixes f:: "nat \<times> nat \<Rightarrow> ereal"
hoelzl@41981
    24
  assumes pos: "\<And>p. 0 \<le> f p"
hoelzl@41981
    25
  assumes "\<And>m. g m = (\<Sum>n. f (m,n))"
hoelzl@41981
    26
  shows "(\<Sum>i. f (prod_decode i)) = suminf g"
hoelzl@41981
    27
proof -
hoelzl@41981
    28
  have g_def: "g = (\<lambda>m. (\<Sum>n. f (m,n)))"
hoelzl@41981
    29
    using assms by (simp add: fun_eq_iff)
hoelzl@41981
    30
  have reindex: "\<And>B. (\<Sum>x\<in>B. f (prod_decode x)) = setsum f (prod_decode ` B)"
hoelzl@41981
    31
    by (simp add: setsum_reindex[OF inj_prod_decode] comp_def)
hoelzl@41981
    32
  { fix n
hoelzl@41981
    33
    let ?M = "\<lambda>f. Suc (Max (f ` prod_decode ` {..<n}))"
hoelzl@41981
    34
    { fix a b x assume "x < n" and [symmetric]: "(a, b) = prod_decode x"
hoelzl@41981
    35
      then have "a < ?M fst" "b < ?M snd"
hoelzl@41981
    36
        by (auto intro!: Max_ge le_imp_less_Suc image_eqI) }
hoelzl@41981
    37
    then have "setsum f (prod_decode ` {..<n}) \<le> setsum f ({..<?M fst} \<times> {..<?M snd})"
hoelzl@41981
    38
      by (auto intro!: setsum_mono3 simp: pos)
hoelzl@41981
    39
    then have "\<exists>a b. setsum f (prod_decode ` {..<n}) \<le> setsum f ({..<a} \<times> {..<b})" by auto }
hoelzl@41981
    40
  moreover
hoelzl@41981
    41
  { fix a b
hoelzl@41981
    42
    let ?M = "prod_decode ` {..<Suc (Max (prod_encode ` ({..<a} \<times> {..<b})))}"
hoelzl@41981
    43
    { fix a' b' assume "a' < a" "b' < b" then have "(a', b') \<in> ?M"
hoelzl@41981
    44
        by (auto intro!: Max_ge le_imp_less_Suc image_eqI[where x="prod_encode (a', b')"]) }
hoelzl@41981
    45
    then have "setsum f ({..<a} \<times> {..<b}) \<le> setsum f ?M"
hoelzl@41981
    46
      by (auto intro!: setsum_mono3 simp: pos) }
hoelzl@41981
    47
  ultimately
hoelzl@41981
    48
  show ?thesis unfolding g_def using pos
hoelzl@41981
    49
    by (auto intro!: SUPR_eq  simp: setsum_cartesian_product reindex le_SUPI2
hoelzl@43920
    50
                     setsum_nonneg suminf_ereal_eq_SUPR SUPR_pair
hoelzl@43920
    51
                     SUPR_ereal_setsum[symmetric] incseq_setsumI setsum_nonneg)
hoelzl@41981
    52
qed
hoelzl@41981
    53
paulson@33271
    54
subsection {* Measure Spaces *}
paulson@33271
    55
hoelzl@41689
    56
record 'a measure_space = "'a algebra" +
hoelzl@43920
    57
  measure :: "'a set \<Rightarrow> ereal"
paulson@33271
    58
hoelzl@43920
    59
definition positive where "positive M f \<longleftrightarrow> f {} = (0::ereal) \<and> (\<forall>A\<in>sets M. 0 \<le> f A)"
paulson@33271
    60
hoelzl@41689
    61
definition additive where "additive M f \<longleftrightarrow>
hoelzl@41689
    62
  (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<inter> y = {} \<longrightarrow> f (x \<union> y) = f x + f y)"
paulson@33271
    63
hoelzl@43920
    64
definition countably_additive :: "('a, 'b) algebra_scheme \<Rightarrow> ('a set \<Rightarrow> ereal) \<Rightarrow> bool" where
hoelzl@41981
    65
  "countably_additive M f \<longleftrightarrow> (\<forall>A. range A \<subseteq> sets M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> sets M \<longrightarrow>
hoelzl@41981
    66
    (\<Sum>i. f (A i)) = f (\<Union>i. A i))"
paulson@33271
    67
hoelzl@41689
    68
definition increasing where "increasing M f \<longleftrightarrow>
hoelzl@41689
    69
  (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<subseteq> y \<longrightarrow> f x \<le> f y)"
paulson@33271
    70
hoelzl@41689
    71
definition subadditive where "subadditive M f \<longleftrightarrow>
hoelzl@41981
    72
  (\<forall>x \<in> sets M. \<forall>y \<in> sets M. x \<inter> y = {} \<longrightarrow> f (x \<union> y) \<le> f x + f y)"
paulson@33271
    73
hoelzl@41689
    74
definition countably_subadditive where "countably_subadditive M f \<longleftrightarrow>
hoelzl@41689
    75
  (\<forall>A. range A \<subseteq> sets M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> sets M \<longrightarrow>
hoelzl@41981
    76
    (f (\<Union>i. A i) \<le> (\<Sum>i. f (A i))))"
hoelzl@41689
    77
hoelzl@41689
    78
definition lambda_system where "lambda_system M f = {l \<in> sets M.
hoelzl@41689
    79
  \<forall>x \<in> sets M. f (l \<inter> x) + f ((space M - l) \<inter> x) = f x}"
paulson@33271
    80
hoelzl@41689
    81
definition outer_measure_space where "outer_measure_space M f \<longleftrightarrow>
hoelzl@41689
    82
  positive M f \<and> increasing M f \<and> countably_subadditive M f"
hoelzl@41689
    83
hoelzl@41689
    84
definition measure_set where "measure_set M f X = {r.
hoelzl@41981
    85
  \<exists>A. range A \<subseteq> sets M \<and> disjoint_family A \<and> X \<subseteq> (\<Union>i. A i) \<and> (\<Sum>i. f (A i)) = r}"
paulson@33271
    86
hoelzl@41689
    87
locale measure_space = sigma_algebra M for M :: "('a, 'b) measure_space_scheme" +
hoelzl@41981
    88
  assumes measure_positive: "positive M (measure M)"
hoelzl@41689
    89
      and ca: "countably_additive M (measure M)"
paulson@33271
    90
hoelzl@41689
    91
abbreviation (in measure_space) "\<mu> \<equiv> measure M"
paulson@33271
    92
hoelzl@41981
    93
lemma (in measure_space)
hoelzl@41981
    94
  shows empty_measure[simp, intro]: "\<mu> {} = 0"
hoelzl@41981
    95
  and positive_measure[simp, intro!]: "\<And>A. A \<in> sets M \<Longrightarrow> 0 \<le> \<mu> A"
hoelzl@41981
    96
  using measure_positive unfolding positive_def by auto
hoelzl@41981
    97
paulson@33271
    98
lemma increasingD:
hoelzl@41689
    99
  "increasing M f \<Longrightarrow> x \<subseteq> y \<Longrightarrow> x\<in>sets M \<Longrightarrow> y\<in>sets M \<Longrightarrow> f x \<le> f y"
paulson@33271
   100
  by (auto simp add: increasing_def)
paulson@33271
   101
paulson@33271
   102
lemma subadditiveD:
hoelzl@41689
   103
  "subadditive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> sets M \<Longrightarrow> y \<in> sets M
hoelzl@41689
   104
    \<Longrightarrow> f (x \<union> y) \<le> f x + f y"
paulson@33271
   105
  by (auto simp add: subadditive_def)
paulson@33271
   106
paulson@33271
   107
lemma additiveD:
hoelzl@41689
   108
  "additive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> sets M \<Longrightarrow> y \<in> sets M
hoelzl@41689
   109
    \<Longrightarrow> f (x \<union> y) = f x + f y"
paulson@33271
   110
  by (auto simp add: additive_def)
paulson@33271
   111
hoelzl@41689
   112
lemma countably_additiveI:
hoelzl@41981
   113
  assumes "\<And>A x. range A \<subseteq> sets M \<Longrightarrow> disjoint_family A \<Longrightarrow> (\<Union>i. A i) \<in> sets M
hoelzl@41981
   114
    \<Longrightarrow> (\<Sum>i. f (A i)) = f (\<Union>i. A i)"
hoelzl@41981
   115
  shows "countably_additive M f"
hoelzl@41981
   116
  using assms by (simp add: countably_additive_def)
paulson@33271
   117
hoelzl@38656
   118
section "Extend binary sets"
paulson@33271
   119
hoelzl@35582
   120
lemma LIMSEQ_binaryset:
paulson@33271
   121
  assumes f: "f {} = 0"
hoelzl@41981
   122
  shows  "(\<lambda>n. \<Sum>i<n. f (binaryset A B i)) ----> f A + f B"
paulson@33271
   123
proof -
hoelzl@41981
   124
  have "(\<lambda>n. \<Sum>i < Suc (Suc n). f (binaryset A B i)) = (\<lambda>n. f A + f B)"
hoelzl@35582
   125
    proof
paulson@33271
   126
      fix n
hoelzl@41981
   127
      show "(\<Sum>i < Suc (Suc n). f (binaryset A B i)) = f A + f B"
hoelzl@35582
   128
        by (induct n)  (auto simp add: binaryset_def f)
paulson@33271
   129
    qed
paulson@33271
   130
  moreover
huffman@44568
   131
  have "... ----> f A + f B" by (rule tendsto_const)
paulson@33271
   132
  ultimately
hoelzl@41981
   133
  have "(\<lambda>n. \<Sum>i< Suc (Suc n). f (binaryset A B i)) ----> f A + f B"
paulson@33271
   134
    by metis
hoelzl@41981
   135
  hence "(\<lambda>n. \<Sum>i< n+2. f (binaryset A B i)) ----> f A + f B"
paulson@33271
   136
    by simp
paulson@33271
   137
  thus ?thesis by (rule LIMSEQ_offset [where k=2])
paulson@33271
   138
qed
paulson@33271
   139
paulson@33271
   140
lemma binaryset_sums:
paulson@33271
   141
  assumes f: "f {} = 0"
paulson@33271
   142
  shows  "(\<lambda>n. f (binaryset A B n)) sums (f A + f B)"
hoelzl@41981
   143
    by (simp add: sums_def LIMSEQ_binaryset [where f=f, OF f] atLeast0LessThan)
paulson@33271
   144
paulson@33271
   145
lemma suminf_binaryset_eq:
hoelzl@41981
   146
  fixes f :: "'a set \<Rightarrow> 'b::{comm_monoid_add, t2_space}"
hoelzl@41689
   147
  shows "f {} = 0 \<Longrightarrow> (\<Sum>n. f (binaryset A B n)) = f A + f B"
paulson@33271
   148
  by (metis binaryset_sums sums_unique)
paulson@33271
   149
paulson@33271
   150
subsection {* Lambda Systems *}
paulson@33271
   151
paulson@33271
   152
lemma (in algebra) lambda_system_eq:
hoelzl@41689
   153
  shows "lambda_system M f = {l \<in> sets M.
hoelzl@41689
   154
    \<forall>x \<in> sets M. f (x \<inter> l) + f (x - l) = f x}"
paulson@33271
   155
proof -
paulson@33271
   156
  have [simp]: "!!l x. l \<in> sets M \<Longrightarrow> x \<in> sets M \<Longrightarrow> (space M - l) \<inter> x = x - l"
huffman@37032
   157
    by (metis Int_Diff Int_absorb1 Int_commute sets_into_space)
paulson@33271
   158
  show ?thesis
huffman@37032
   159
    by (auto simp add: lambda_system_def) (metis Int_commute)+
paulson@33271
   160
qed
paulson@33271
   161
paulson@33271
   162
lemma (in algebra) lambda_system_empty:
hoelzl@41689
   163
  "positive M f \<Longrightarrow> {} \<in> lambda_system M f"
hoelzl@42066
   164
  by (auto simp add: positive_def lambda_system_eq)
paulson@33271
   165
paulson@33271
   166
lemma lambda_system_sets:
hoelzl@41689
   167
  "x \<in> lambda_system M f \<Longrightarrow> x \<in> sets M"
hoelzl@41689
   168
  by (simp add: lambda_system_def)
paulson@33271
   169
paulson@33271
   170
lemma (in algebra) lambda_system_Compl:
hoelzl@43920
   171
  fixes f:: "'a set \<Rightarrow> ereal"
paulson@33271
   172
  assumes x: "x \<in> lambda_system M f"
paulson@33271
   173
  shows "space M - x \<in> lambda_system M f"
hoelzl@41689
   174
proof -
hoelzl@41689
   175
  have "x \<subseteq> space M"
hoelzl@41689
   176
    by (metis sets_into_space lambda_system_sets x)
hoelzl@41689
   177
  hence "space M - (space M - x) = x"
hoelzl@41689
   178
    by (metis double_diff equalityE)
hoelzl@41689
   179
  with x show ?thesis
hoelzl@41689
   180
    by (force simp add: lambda_system_def ac_simps)
hoelzl@41689
   181
qed
paulson@33271
   182
paulson@33271
   183
lemma (in algebra) lambda_system_Int:
hoelzl@43920
   184
  fixes f:: "'a set \<Rightarrow> ereal"
paulson@33271
   185
  assumes xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
paulson@33271
   186
  shows "x \<inter> y \<in> lambda_system M f"
hoelzl@41689
   187
proof -
hoelzl@41689
   188
  from xl yl show ?thesis
hoelzl@41689
   189
  proof (auto simp add: positive_def lambda_system_eq Int)
hoelzl@41689
   190
    fix u
hoelzl@41689
   191
    assume x: "x \<in> sets M" and y: "y \<in> sets M" and u: "u \<in> sets M"
hoelzl@41689
   192
       and fx: "\<forall>z\<in>sets M. f (z \<inter> x) + f (z - x) = f z"
hoelzl@41689
   193
       and fy: "\<forall>z\<in>sets M. f (z \<inter> y) + f (z - y) = f z"
hoelzl@41689
   194
    have "u - x \<inter> y \<in> sets M"
hoelzl@41689
   195
      by (metis Diff Diff_Int Un u x y)
hoelzl@41689
   196
    moreover
hoelzl@41689
   197
    have "(u - (x \<inter> y)) \<inter> y = u \<inter> y - x" by blast
hoelzl@41689
   198
    moreover
hoelzl@41689
   199
    have "u - x \<inter> y - y = u - y" by blast
hoelzl@41689
   200
    ultimately
hoelzl@41689
   201
    have ey: "f (u - x \<inter> y) = f (u \<inter> y - x) + f (u - y)" using fy
hoelzl@41689
   202
      by force
hoelzl@41689
   203
    have "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y)
hoelzl@41689
   204
          = (f (u \<inter> (x \<inter> y)) + f (u \<inter> y - x)) + f (u - y)"
hoelzl@41689
   205
      by (simp add: ey ac_simps)
hoelzl@41689
   206
    also have "... =  (f ((u \<inter> y) \<inter> x) + f (u \<inter> y - x)) + f (u - y)"
hoelzl@41689
   207
      by (simp add: Int_ac)
hoelzl@41689
   208
    also have "... = f (u \<inter> y) + f (u - y)"
hoelzl@41689
   209
      using fx [THEN bspec, of "u \<inter> y"] Int y u
hoelzl@41689
   210
      by force
hoelzl@41689
   211
    also have "... = f u"
hoelzl@41689
   212
      by (metis fy u)
hoelzl@41689
   213
    finally show "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y) = f u" .
paulson@33271
   214
  qed
hoelzl@41689
   215
qed
paulson@33271
   216
paulson@33271
   217
lemma (in algebra) lambda_system_Un:
hoelzl@43920
   218
  fixes f:: "'a set \<Rightarrow> ereal"
paulson@33271
   219
  assumes xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
paulson@33271
   220
  shows "x \<union> y \<in> lambda_system M f"
paulson@33271
   221
proof -
paulson@33271
   222
  have "(space M - x) \<inter> (space M - y) \<in> sets M"
hoelzl@38656
   223
    by (metis Diff_Un Un compl_sets lambda_system_sets xl yl)
paulson@33271
   224
  moreover
paulson@33271
   225
  have "x \<union> y = space M - ((space M - x) \<inter> (space M - y))"
paulson@33271
   226
    by auto  (metis subsetD lambda_system_sets sets_into_space xl yl)+
paulson@33271
   227
  ultimately show ?thesis
hoelzl@38656
   228
    by (metis lambda_system_Compl lambda_system_Int xl yl)
paulson@33271
   229
qed
paulson@33271
   230
paulson@33271
   231
lemma (in algebra) lambda_system_algebra:
hoelzl@41689
   232
  "positive M f \<Longrightarrow> algebra (M\<lparr>sets := lambda_system M f\<rparr>)"
hoelzl@42065
   233
  apply (auto simp add: algebra_iff_Un)
paulson@33271
   234
  apply (metis lambda_system_sets set_mp sets_into_space)
paulson@33271
   235
  apply (metis lambda_system_empty)
paulson@33271
   236
  apply (metis lambda_system_Compl)
hoelzl@38656
   237
  apply (metis lambda_system_Un)
paulson@33271
   238
  done
paulson@33271
   239
paulson@33271
   240
lemma (in algebra) lambda_system_strong_additive:
paulson@33271
   241
  assumes z: "z \<in> sets M" and disj: "x \<inter> y = {}"
paulson@33271
   242
      and xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
paulson@33271
   243
  shows "f (z \<inter> (x \<union> y)) = f (z \<inter> x) + f (z \<inter> y)"
hoelzl@41689
   244
proof -
hoelzl@41689
   245
  have "z \<inter> x = (z \<inter> (x \<union> y)) \<inter> x" using disj by blast
hoelzl@41689
   246
  moreover
hoelzl@41689
   247
  have "z \<inter> y = (z \<inter> (x \<union> y)) - x" using disj by blast
hoelzl@41689
   248
  moreover
hoelzl@41689
   249
  have "(z \<inter> (x \<union> y)) \<in> sets M"
hoelzl@41689
   250
    by (metis Int Un lambda_system_sets xl yl z)
hoelzl@41689
   251
  ultimately show ?thesis using xl yl
hoelzl@41689
   252
    by (simp add: lambda_system_eq)
hoelzl@41689
   253
qed
paulson@33271
   254
paulson@33271
   255
lemma (in algebra) lambda_system_additive:
paulson@33271
   256
     "additive (M (|sets := lambda_system M f|)) f"
hoelzl@41689
   257
proof (auto simp add: additive_def)
hoelzl@41689
   258
  fix x and y
hoelzl@41689
   259
  assume disj: "x \<inter> y = {}"
hoelzl@41689
   260
     and xl: "x \<in> lambda_system M f" and yl: "y \<in> lambda_system M f"
hoelzl@41689
   261
  hence  "x \<in> sets M" "y \<in> sets M" by (blast intro: lambda_system_sets)+
hoelzl@41689
   262
  thus "f (x \<union> y) = f x + f y"
hoelzl@41689
   263
    using lambda_system_strong_additive [OF top disj xl yl]
hoelzl@41689
   264
    by (simp add: Un)
hoelzl@41689
   265
qed
paulson@33271
   266
hoelzl@42145
   267
lemma (in ring_of_sets) disjointed_additive:
hoelzl@42145
   268
  assumes f: "positive M f" "additive M f" and A: "range A \<subseteq> sets M" "incseq A"
hoelzl@42145
   269
  shows "(\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
hoelzl@42145
   270
proof (induct n)
hoelzl@42145
   271
  case (Suc n)
hoelzl@42145
   272
  then have "(\<Sum>i\<le>Suc n. f (disjointed A i)) = f (A n) + f (disjointed A (Suc n))"
hoelzl@42145
   273
    by simp
hoelzl@42145
   274
  also have "\<dots> = f (A n \<union> disjointed A (Suc n))"
hoelzl@42145
   275
    using A by (subst f(2)[THEN additiveD]) (auto simp: disjointed_incseq)
hoelzl@42145
   276
  also have "A n \<union> disjointed A (Suc n) = A (Suc n)"
hoelzl@42145
   277
    using `incseq A` by (auto dest: incseq_SucD simp: disjointed_incseq)
hoelzl@42145
   278
  finally show ?case .
hoelzl@42145
   279
qed simp
hoelzl@42145
   280
hoelzl@42145
   281
lemma (in ring_of_sets) countably_subadditive_subadditive:
hoelzl@41689
   282
  assumes f: "positive M f" and cs: "countably_subadditive M f"
paulson@33271
   283
  shows  "subadditive M f"
hoelzl@35582
   284
proof (auto simp add: subadditive_def)
paulson@33271
   285
  fix x y
paulson@33271
   286
  assume x: "x \<in> sets M" and y: "y \<in> sets M" and "x \<inter> y = {}"
paulson@33271
   287
  hence "disjoint_family (binaryset x y)"
hoelzl@35582
   288
    by (auto simp add: disjoint_family_on_def binaryset_def)
hoelzl@35582
   289
  hence "range (binaryset x y) \<subseteq> sets M \<longrightarrow>
hoelzl@35582
   290
         (\<Union>i. binaryset x y i) \<in> sets M \<longrightarrow>
hoelzl@41981
   291
         f (\<Union>i. binaryset x y i) \<le> (\<Sum> n. f (binaryset x y n))"
hoelzl@41981
   292
    using cs by (auto simp add: countably_subadditive_def)
hoelzl@35582
   293
  hence "{x,y,{}} \<subseteq> sets M \<longrightarrow> x \<union> y \<in> sets M \<longrightarrow>
hoelzl@41981
   294
         f (x \<union> y) \<le> (\<Sum> n. f (binaryset x y n))"
paulson@33271
   295
    by (simp add: range_binaryset_eq UN_binaryset_eq)
hoelzl@38656
   296
  thus "f (x \<union> y) \<le>  f x + f y" using f x y
hoelzl@41981
   297
    by (auto simp add: Un o_def suminf_binaryset_eq positive_def)
paulson@33271
   298
qed
paulson@33271
   299
hoelzl@42145
   300
lemma (in ring_of_sets) additive_sum:
paulson@33271
   301
  fixes A:: "nat \<Rightarrow> 'a set"
hoelzl@41981
   302
  assumes f: "positive M f" and ad: "additive M f" and "finite S"
paulson@33271
   303
      and A: "range A \<subseteq> sets M"
hoelzl@41981
   304
      and disj: "disjoint_family_on A S"
hoelzl@41981
   305
  shows  "(\<Sum>i\<in>S. f (A i)) = f (\<Union>i\<in>S. A i)"
hoelzl@41981
   306
using `finite S` disj proof induct
hoelzl@41981
   307
  case empty show ?case using f by (simp add: positive_def)
paulson@33271
   308
next
hoelzl@41981
   309
  case (insert s S)
hoelzl@41981
   310
  then have "A s \<inter> (\<Union>i\<in>S. A i) = {}"
hoelzl@41981
   311
    by (auto simp add: disjoint_family_on_def neq_iff)
hoelzl@38656
   312
  moreover
hoelzl@41981
   313
  have "A s \<in> sets M" using A by blast
hoelzl@41981
   314
  moreover have "(\<Union>i\<in>S. A i) \<in> sets M"
hoelzl@41981
   315
    using A `finite S` by auto
hoelzl@38656
   316
  moreover
hoelzl@41981
   317
  ultimately have "f (A s \<union> (\<Union>i\<in>S. A i)) = f (A s) + f(\<Union>i\<in>S. A i)"
hoelzl@38656
   318
    using ad UNION_in_sets A by (auto simp add: additive_def)
hoelzl@41981
   319
  with insert show ?case using ad disjoint_family_on_mono[of S "insert s S" A]
hoelzl@41981
   320
    by (auto simp add: additive_def subset_insertI)
paulson@33271
   321
qed
paulson@33271
   322
hoelzl@38656
   323
lemma (in algebra) increasing_additive_bound:
hoelzl@43920
   324
  fixes A:: "nat \<Rightarrow> 'a set" and  f :: "'a set \<Rightarrow> ereal"
hoelzl@41689
   325
  assumes f: "positive M f" and ad: "additive M f"
paulson@33271
   326
      and inc: "increasing M f"
paulson@33271
   327
      and A: "range A \<subseteq> sets M"
paulson@33271
   328
      and disj: "disjoint_family A"
hoelzl@41981
   329
  shows  "(\<Sum>i. f (A i)) \<le> f (space M)"
hoelzl@41981
   330
proof (safe intro!: suminf_bound)
hoelzl@38656
   331
  fix N
hoelzl@41981
   332
  note disj_N = disjoint_family_on_mono[OF _ disj, of "{..<N}"]
hoelzl@41981
   333
  have "(\<Sum>i<N. f (A i)) = f (\<Union>i\<in>{..<N}. A i)"
hoelzl@41981
   334
    by (rule additive_sum [OF f ad _ A]) (auto simp: disj_N)
paulson@33271
   335
  also have "... \<le> f (space M)" using space_closed A
hoelzl@41981
   336
    by (intro increasingD[OF inc] finite_UN) auto
hoelzl@41981
   337
  finally show "(\<Sum>i<N. f (A i)) \<le> f (space M)" by simp
hoelzl@41981
   338
qed (insert f A, auto simp: positive_def)
paulson@33271
   339
paulson@33271
   340
lemma lambda_system_increasing:
hoelzl@41689
   341
 "increasing M f \<Longrightarrow> increasing (M (|sets := lambda_system M f|)) f"
hoelzl@38656
   342
  by (simp add: increasing_def lambda_system_def)
paulson@33271
   343
hoelzl@41689
   344
lemma lambda_system_positive:
hoelzl@41689
   345
  "positive M f \<Longrightarrow> positive (M (|sets := lambda_system M f|)) f"
hoelzl@41689
   346
  by (simp add: positive_def lambda_system_def)
hoelzl@41689
   347
paulson@33271
   348
lemma (in algebra) lambda_system_strong_sum:
hoelzl@43920
   349
  fixes A:: "nat \<Rightarrow> 'a set" and f :: "'a set \<Rightarrow> ereal"
hoelzl@41689
   350
  assumes f: "positive M f" and a: "a \<in> sets M"
paulson@33271
   351
      and A: "range A \<subseteq> lambda_system M f"
paulson@33271
   352
      and disj: "disjoint_family A"
paulson@33271
   353
  shows  "(\<Sum>i = 0..<n. f (a \<inter>A i)) = f (a \<inter> (\<Union>i\<in>{0..<n}. A i))"
paulson@33271
   354
proof (induct n)
hoelzl@38656
   355
  case 0 show ?case using f by (simp add: positive_def)
paulson@33271
   356
next
hoelzl@38656
   357
  case (Suc n)
paulson@33271
   358
  have 2: "A n \<inter> UNION {0..<n} A = {}" using disj
hoelzl@38656
   359
    by (force simp add: disjoint_family_on_def neq_iff)
paulson@33271
   360
  have 3: "A n \<in> lambda_system M f" using A
paulson@33271
   361
    by blast
hoelzl@42065
   362
  interpret l: algebra "M\<lparr>sets := lambda_system M f\<rparr>"
hoelzl@42065
   363
    using f by (rule lambda_system_algebra)
paulson@33271
   364
  have 4: "UNION {0..<n} A \<in> lambda_system M f"
hoelzl@42065
   365
    using A l.UNION_in_sets by simp
paulson@33271
   366
  from Suc.hyps show ?case
paulson@33271
   367
    by (simp add: atLeastLessThanSuc lambda_system_strong_additive [OF a 2 3 4])
paulson@33271
   368
qed
paulson@33271
   369
paulson@33271
   370
lemma (in sigma_algebra) lambda_system_caratheodory:
paulson@33271
   371
  assumes oms: "outer_measure_space M f"
paulson@33271
   372
      and A: "range A \<subseteq> lambda_system M f"
paulson@33271
   373
      and disj: "disjoint_family A"
hoelzl@41981
   374
  shows  "(\<Union>i. A i) \<in> lambda_system M f \<and> (\<Sum>i. f (A i)) = f (\<Union>i. A i)"
paulson@33271
   375
proof -
hoelzl@41689
   376
  have pos: "positive M f" and inc: "increasing M f"
hoelzl@38656
   377
   and csa: "countably_subadditive M f"
paulson@33271
   378
    by (metis oms outer_measure_space_def)+
paulson@33271
   379
  have sa: "subadditive M f"
hoelzl@38656
   380
    by (metis countably_subadditive_subadditive csa pos)
hoelzl@38656
   381
  have A': "range A \<subseteq> sets (M(|sets := lambda_system M f|))" using A
paulson@33271
   382
    by simp
hoelzl@42065
   383
  interpret ls: algebra "M\<lparr>sets := lambda_system M f\<rparr>"
hoelzl@42065
   384
    using pos by (rule lambda_system_algebra)
paulson@33271
   385
  have A'': "range A \<subseteq> sets M"
paulson@33271
   386
     by (metis A image_subset_iff lambda_system_sets)
hoelzl@38656
   387
paulson@33271
   388
  have U_in: "(\<Union>i. A i) \<in> sets M"
huffman@37032
   389
    by (metis A'' countable_UN)
hoelzl@41981
   390
  have U_eq: "f (\<Union>i. A i) = (\<Sum>i. f (A i))"
hoelzl@41689
   391
  proof (rule antisym)
hoelzl@41981
   392
    show "f (\<Union>i. A i) \<le> (\<Sum>i. f (A i))"
hoelzl@41981
   393
      using csa[unfolded countably_subadditive_def] A'' disj U_in by auto
hoelzl@41981
   394
    have *: "\<And>i. 0 \<le> f (A i)" using pos A'' unfolding positive_def by auto
hoelzl@41981
   395
    have dis: "\<And>N. disjoint_family_on A {..<N}" by (intro disjoint_family_on_mono[OF _ disj]) auto
hoelzl@41981
   396
    show "(\<Sum>i. f (A i)) \<le> f (\<Union>i. A i)"
hoelzl@42065
   397
      using ls.additive_sum [OF lambda_system_positive[OF pos] lambda_system_additive _ A' dis]
hoelzl@41981
   398
      using A''
hoelzl@41981
   399
      by (intro suminf_bound[OF _ *]) (auto intro!: increasingD[OF inc] allI countable_UN)
hoelzl@41689
   400
  qed
paulson@33271
   401
  {
hoelzl@38656
   402
    fix a
hoelzl@38656
   403
    assume a [iff]: "a \<in> sets M"
paulson@33271
   404
    have "f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i)) = f a"
paulson@33271
   405
    proof -
paulson@33271
   406
      show ?thesis
paulson@33271
   407
      proof (rule antisym)
wenzelm@33536
   408
        have "range (\<lambda>i. a \<inter> A i) \<subseteq> sets M" using A''
wenzelm@33536
   409
          by blast
hoelzl@38656
   410
        moreover
wenzelm@33536
   411
        have "disjoint_family (\<lambda>i. a \<inter> A i)" using disj
hoelzl@38656
   412
          by (auto simp add: disjoint_family_on_def)
hoelzl@38656
   413
        moreover
wenzelm@33536
   414
        have "a \<inter> (\<Union>i. A i) \<in> sets M"
wenzelm@33536
   415
          by (metis Int U_in a)
hoelzl@38656
   416
        ultimately
hoelzl@41981
   417
        have "f (a \<inter> (\<Union>i. A i)) \<le> (\<Sum>i. f (a \<inter> A i))"
hoelzl@41981
   418
          using csa[unfolded countably_subadditive_def, rule_format, of "(\<lambda>i. a \<inter> A i)"]
hoelzl@38656
   419
          by (simp add: o_def)
hoelzl@38656
   420
        hence "f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i)) \<le>
hoelzl@41981
   421
            (\<Sum>i. f (a \<inter> A i)) + f (a - (\<Union>i. A i))"
hoelzl@38656
   422
          by (rule add_right_mono)
hoelzl@38656
   423
        moreover
hoelzl@41981
   424
        have "(\<Sum>i. f (a \<inter> A i)) + f (a - (\<Union>i. A i)) \<le> f a"
hoelzl@41981
   425
          proof (intro suminf_bound_add allI)
wenzelm@33536
   426
            fix n
wenzelm@33536
   427
            have UNION_in: "(\<Union>i\<in>{0..<n}. A i) \<in> sets M"
hoelzl@38656
   428
              by (metis A'' UNION_in_sets)
wenzelm@33536
   429
            have le_fa: "f (UNION {0..<n} A \<inter> a) \<le> f a" using A''
huffman@37032
   430
              by (blast intro: increasingD [OF inc] A'' UNION_in_sets)
wenzelm@33536
   431
            have ls: "(\<Union>i\<in>{0..<n}. A i) \<in> lambda_system M f"
hoelzl@42065
   432
              using ls.UNION_in_sets by (simp add: A)
hoelzl@38656
   433
            hence eq_fa: "f a = f (a \<inter> (\<Union>i\<in>{0..<n}. A i)) + f (a - (\<Union>i\<in>{0..<n}. A i))"
huffman@37032
   434
              by (simp add: lambda_system_eq UNION_in)
wenzelm@33536
   435
            have "f (a - (\<Union>i. A i)) \<le> f (a - (\<Union>i\<in>{0..<n}. A i))"
haftmann@44106
   436
              by (blast intro: increasingD [OF inc] UNION_in U_in)
hoelzl@41981
   437
            thus "(\<Sum>i<n. f (a \<inter> A i)) + f (a - (\<Union>i. A i)) \<le> f a"
hoelzl@38656
   438
              by (simp add: lambda_system_strong_sum pos A disj eq_fa add_left_mono atLeast0LessThan[symmetric])
hoelzl@41981
   439
          next
hoelzl@41981
   440
            have "\<And>i. a \<inter> A i \<in> sets M" using A'' by auto
hoelzl@41981
   441
            then show "\<And>i. 0 \<le> f (a \<inter> A i)" using pos[unfolded positive_def] by auto
hoelzl@41981
   442
            have "\<And>i. a - (\<Union>i. A i) \<in> sets M" using A'' by auto
hoelzl@41981
   443
            then have "\<And>i. 0 \<le> f (a - (\<Union>i. A i))" using pos[unfolded positive_def] by auto
hoelzl@41981
   444
            then show "f (a - (\<Union>i. A i)) \<noteq> -\<infinity>" by auto
wenzelm@33536
   445
          qed
hoelzl@38656
   446
        ultimately show "f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i)) \<le> f a"
hoelzl@38656
   447
          by (rule order_trans)
paulson@33271
   448
      next
hoelzl@38656
   449
        have "f a \<le> f (a \<inter> (\<Union>i. A i) \<union> (a - (\<Union>i. A i)))"
huffman@37032
   450
          by (blast intro:  increasingD [OF inc] U_in)
wenzelm@33536
   451
        also have "... \<le>  f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i))"
huffman@37032
   452
          by (blast intro: subadditiveD [OF sa] U_in)
wenzelm@33536
   453
        finally show "f a \<le> f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i))" .
paulson@33271
   454
        qed
paulson@33271
   455
     qed
paulson@33271
   456
  }
paulson@33271
   457
  thus  ?thesis
hoelzl@38656
   458
    by (simp add: lambda_system_eq sums_iff U_eq U_in)
paulson@33271
   459
qed
paulson@33271
   460
paulson@33271
   461
lemma (in sigma_algebra) caratheodory_lemma:
paulson@33271
   462
  assumes oms: "outer_measure_space M f"
hoelzl@41689
   463
  shows "measure_space \<lparr> space = space M, sets = lambda_system M f, measure = f \<rparr>"
hoelzl@41689
   464
    (is "measure_space ?M")
paulson@33271
   465
proof -
hoelzl@41689
   466
  have pos: "positive M f"
paulson@33271
   467
    by (metis oms outer_measure_space_def)
hoelzl@41689
   468
  have alg: "algebra ?M"
hoelzl@38656
   469
    using lambda_system_algebra [of f, OF pos]
hoelzl@42065
   470
    by (simp add: algebra_iff_Un)
hoelzl@42065
   471
  then
hoelzl@41689
   472
  have "sigma_algebra ?M"
paulson@33271
   473
    using lambda_system_caratheodory [OF oms]
hoelzl@38656
   474
    by (simp add: sigma_algebra_disjoint_iff)
hoelzl@38656
   475
  moreover
hoelzl@41689
   476
  have "measure_space_axioms ?M"
paulson@33271
   477
    using pos lambda_system_caratheodory [OF oms]
hoelzl@38656
   478
    by (simp add: measure_space_axioms_def positive_def lambda_system_sets
hoelzl@38656
   479
                  countably_additive_def o_def)
hoelzl@38656
   480
  ultimately
paulson@33271
   481
  show ?thesis
hoelzl@42065
   482
    by (simp add: measure_space_def)
paulson@33271
   483
qed
paulson@33271
   484
hoelzl@42066
   485
lemma (in ring_of_sets) additive_increasing:
hoelzl@41689
   486
  assumes posf: "positive M f" and addf: "additive M f"
paulson@33271
   487
  shows "increasing M f"
hoelzl@38656
   488
proof (auto simp add: increasing_def)
paulson@33271
   489
  fix x y
paulson@33271
   490
  assume xy: "x \<in> sets M" "y \<in> sets M" "x \<subseteq> y"
hoelzl@41981
   491
  then have "y - x \<in> sets M" by auto
hoelzl@41981
   492
  then have "0 \<le> f (y-x)" using posf[unfolded positive_def] by auto
hoelzl@41981
   493
  then have "f x + 0 \<le> f x + f (y-x)" by (intro add_left_mono) auto
paulson@33271
   494
  also have "... = f (x \<union> (y-x))" using addf
huffman@37032
   495
    by (auto simp add: additive_def) (metis Diff_disjoint Un_Diff_cancel Diff xy(1,2))
paulson@33271
   496
  also have "... = f y"
huffman@37032
   497
    by (metis Un_Diff_cancel Un_absorb1 xy(3))
hoelzl@41981
   498
  finally show "f x \<le> f y" by simp
paulson@33271
   499
qed
paulson@33271
   500
hoelzl@42066
   501
lemma (in ring_of_sets) countably_additive_additive:
hoelzl@41689
   502
  assumes posf: "positive M f" and ca: "countably_additive M f"
paulson@33271
   503
  shows "additive M f"
hoelzl@38656
   504
proof (auto simp add: additive_def)
paulson@33271
   505
  fix x y
paulson@33271
   506
  assume x: "x \<in> sets M" and y: "y \<in> sets M" and "x \<inter> y = {}"
paulson@33271
   507
  hence "disjoint_family (binaryset x y)"
hoelzl@38656
   508
    by (auto simp add: disjoint_family_on_def binaryset_def)
hoelzl@38656
   509
  hence "range (binaryset x y) \<subseteq> sets M \<longrightarrow>
hoelzl@38656
   510
         (\<Union>i. binaryset x y i) \<in> sets M \<longrightarrow>
hoelzl@41981
   511
         f (\<Union>i. binaryset x y i) = (\<Sum> n. f (binaryset x y n))"
paulson@33271
   512
    using ca
hoelzl@38656
   513
    by (simp add: countably_additive_def)
hoelzl@38656
   514
  hence "{x,y,{}} \<subseteq> sets M \<longrightarrow> x \<union> y \<in> sets M \<longrightarrow>
hoelzl@41981
   515
         f (x \<union> y) = (\<Sum>n. f (binaryset x y n))"
paulson@33271
   516
    by (simp add: range_binaryset_eq UN_binaryset_eq)
paulson@33271
   517
  thus "f (x \<union> y) = f x + f y" using posf x y
hoelzl@41981
   518
    by (auto simp add: Un suminf_binaryset_eq positive_def)
hoelzl@38656
   519
qed
hoelzl@38656
   520
hoelzl@39096
   521
lemma inf_measure_nonempty:
hoelzl@41689
   522
  assumes f: "positive M f" and b: "b \<in> sets M" and a: "a \<subseteq> b" "{} \<in> sets M"
hoelzl@39096
   523
  shows "f b \<in> measure_set M f a"
hoelzl@39096
   524
proof -
hoelzl@41981
   525
  let ?A = "\<lambda>i::nat. (if i = 0 then b else {})"
hoelzl@41981
   526
  have "(\<Sum>i. f (?A i)) = (\<Sum>i<1::nat. f (?A i))"
hoelzl@41981
   527
    by (rule suminf_finite) (simp add: f[unfolded positive_def])
hoelzl@39096
   528
  also have "... = f b"
hoelzl@39096
   529
    by simp
hoelzl@41981
   530
  finally show ?thesis using assms
hoelzl@41981
   531
    by (auto intro!: exI [of _ ?A]
hoelzl@39096
   532
             simp: measure_set_def disjoint_family_on_def split_if_mem2 comp_def)
hoelzl@39096
   533
qed
hoelzl@39096
   534
hoelzl@42066
   535
lemma (in ring_of_sets) inf_measure_agrees:
hoelzl@41689
   536
  assumes posf: "positive M f" and ca: "countably_additive M f"
hoelzl@38656
   537
      and s: "s \<in> sets M"
paulson@33271
   538
  shows "Inf (measure_set M f s) = f s"
hoelzl@43920
   539
  unfolding Inf_ereal_def
hoelzl@38656
   540
proof (safe intro!: Greatest_equality)
paulson@33271
   541
  fix z
paulson@33271
   542
  assume z: "z \<in> measure_set M f s"
hoelzl@38656
   543
  from this obtain A where
paulson@33271
   544
    A: "range A \<subseteq> sets M" and disj: "disjoint_family A"
hoelzl@41981
   545
    and "s \<subseteq> (\<Union>x. A x)" and si: "(\<Sum>i. f (A i)) = z"
hoelzl@38656
   546
    by (auto simp add: measure_set_def comp_def)
paulson@33271
   547
  hence seq: "s = (\<Union>i. A i \<inter> s)" by blast
paulson@33271
   548
  have inc: "increasing M f"
paulson@33271
   549
    by (metis additive_increasing ca countably_additive_additive posf)
hoelzl@41981
   550
  have sums: "(\<Sum>i. f (A i \<inter> s)) = f (\<Union>i. A i \<inter> s)"
hoelzl@41981
   551
    proof (rule ca[unfolded countably_additive_def, rule_format])
paulson@33271
   552
      show "range (\<lambda>n. A n \<inter> s) \<subseteq> sets M" using A s
wenzelm@33536
   553
        by blast
paulson@33271
   554
      show "disjoint_family (\<lambda>n. A n \<inter> s)" using disj
hoelzl@35582
   555
        by (auto simp add: disjoint_family_on_def)
paulson@33271
   556
      show "(\<Union>i. A i \<inter> s) \<in> sets M" using A s
wenzelm@33536
   557
        by (metis UN_extend_simps(4) s seq)
paulson@33271
   558
    qed
hoelzl@41981
   559
  hence "f s = (\<Sum>i. f (A i \<inter> s))"
huffman@37032
   560
    using seq [symmetric] by (simp add: sums_iff)
hoelzl@41981
   561
  also have "... \<le> (\<Sum>i. f (A i))"
hoelzl@41981
   562
    proof (rule suminf_le_pos)
hoelzl@41981
   563
      fix n show "f (A n \<inter> s) \<le> f (A n)" using A s
hoelzl@38656
   564
        by (force intro: increasingD [OF inc])
hoelzl@41981
   565
      fix N have "A N \<inter> s \<in> sets M"  using A s by auto
hoelzl@41981
   566
      then show "0 \<le> f (A N \<inter> s)" using posf unfolding positive_def by auto
paulson@33271
   567
    qed
hoelzl@38656
   568
  also have "... = z" by (rule si)
paulson@33271
   569
  finally show "f s \<le> z" .
paulson@33271
   570
next
paulson@33271
   571
  fix y
hoelzl@38656
   572
  assume y: "\<forall>u \<in> measure_set M f s. y \<le> u"
paulson@33271
   573
  thus "y \<le> f s"
hoelzl@41689
   574
    by (blast intro: inf_measure_nonempty [of _ f, OF posf s subset_refl])
paulson@33271
   575
qed
paulson@33271
   576
hoelzl@41981
   577
lemma measure_set_pos:
hoelzl@41981
   578
  assumes posf: "positive M f" "r \<in> measure_set M f X"
hoelzl@41981
   579
  shows "0 \<le> r"
hoelzl@41981
   580
proof -
hoelzl@41981
   581
  obtain A where "range A \<subseteq> sets M" and r: "r = (\<Sum>i. f (A i))"
hoelzl@41981
   582
    using `r \<in> measure_set M f X` unfolding measure_set_def by auto
hoelzl@41981
   583
  then show "0 \<le> r" using posf unfolding r positive_def
hoelzl@41981
   584
    by (intro suminf_0_le) auto
hoelzl@41981
   585
qed
hoelzl@41981
   586
hoelzl@41981
   587
lemma inf_measure_pos:
hoelzl@41981
   588
  assumes posf: "positive M f"
hoelzl@41981
   589
  shows "0 \<le> Inf (measure_set M f X)"
hoelzl@41981
   590
proof (rule complete_lattice_class.Inf_greatest)
hoelzl@41981
   591
  fix r assume "r \<in> measure_set M f X" with posf show "0 \<le> r"
hoelzl@41981
   592
    by (rule measure_set_pos)
hoelzl@41981
   593
qed
hoelzl@41981
   594
hoelzl@41689
   595
lemma inf_measure_empty:
hoelzl@41981
   596
  assumes posf: "positive M f" and "{} \<in> sets M"
paulson@33271
   597
  shows "Inf (measure_set M f {}) = 0"
paulson@33271
   598
proof (rule antisym)
paulson@33271
   599
  show "Inf (measure_set M f {}) \<le> 0"
hoelzl@41689
   600
    by (metis complete_lattice_class.Inf_lower `{} \<in> sets M`
hoelzl@41689
   601
              inf_measure_nonempty[OF posf] subset_refl posf[unfolded positive_def])
hoelzl@41981
   602
qed (rule inf_measure_pos[OF posf])
paulson@33271
   603
hoelzl@42066
   604
lemma (in ring_of_sets) inf_measure_positive:
hoelzl@41981
   605
  assumes p: "positive M f" and "{} \<in> sets M"
hoelzl@41981
   606
  shows "positive M (\<lambda>x. Inf (measure_set M f x))"
hoelzl@41981
   607
proof (unfold positive_def, intro conjI ballI)
hoelzl@41981
   608
  show "Inf (measure_set M f {}) = 0" using inf_measure_empty[OF assms] by auto
hoelzl@41981
   609
  fix A assume "A \<in> sets M"
hoelzl@41981
   610
qed (rule inf_measure_pos[OF p])
paulson@33271
   611
hoelzl@42066
   612
lemma (in ring_of_sets) inf_measure_increasing:
hoelzl@41689
   613
  assumes posf: "positive M f"
hoelzl@41689
   614
  shows "increasing \<lparr> space = space M, sets = Pow (space M) \<rparr>
paulson@33271
   615
                    (\<lambda>x. Inf (measure_set M f x))"
noschinl@44918
   616
apply (clarsimp simp add: increasing_def)
hoelzl@38656
   617
apply (rule complete_lattice_class.Inf_greatest)
hoelzl@38656
   618
apply (rule complete_lattice_class.Inf_lower)
huffman@37032
   619
apply (clarsimp simp add: measure_set_def, rule_tac x=A in exI, blast)
paulson@33271
   620
done
paulson@33271
   621
hoelzl@42066
   622
lemma (in ring_of_sets) inf_measure_le:
hoelzl@41689
   623
  assumes posf: "positive M f" and inc: "increasing M f"
hoelzl@41981
   624
      and x: "x \<in> {r . \<exists>A. range A \<subseteq> sets M \<and> s \<subseteq> (\<Union>i. A i) \<and> (\<Sum>i. f (A i)) = r}"
paulson@33271
   625
  shows "Inf (measure_set M f s) \<le> x"
paulson@33271
   626
proof -
hoelzl@38656
   627
  obtain A where A: "range A \<subseteq> sets M" and ss: "s \<subseteq> (\<Union>i. A i)"
hoelzl@41981
   628
             and xeq: "(\<Sum>i. f (A i)) = x"
hoelzl@41981
   629
    using x by auto
paulson@33271
   630
  have dA: "range (disjointed A) \<subseteq> sets M"
paulson@33271
   631
    by (metis A range_disjointed_sets)
hoelzl@41981
   632
  have "\<forall>n. f (disjointed A n) \<le> f (A n)"
hoelzl@38656
   633
    by (metis increasingD [OF inc] UNIV_I dA image_subset_iff disjointed_subset A comp_def)
hoelzl@41981
   634
  moreover have "\<forall>i. 0 \<le> f (disjointed A i)"
hoelzl@41981
   635
    using posf dA unfolding positive_def by auto
hoelzl@41981
   636
  ultimately have sda: "(\<Sum>i. f (disjointed A i)) \<le> (\<Sum>i. f (A i))"
hoelzl@41981
   637
    by (blast intro!: suminf_le_pos)
hoelzl@41981
   638
  hence ley: "(\<Sum>i. f (disjointed A i)) \<le> x"
hoelzl@38656
   639
    by (metis xeq)
hoelzl@41981
   640
  hence y: "(\<Sum>i. f (disjointed A i)) \<in> measure_set M f s"
paulson@33271
   641
    apply (auto simp add: measure_set_def)
hoelzl@38656
   642
    apply (rule_tac x="disjointed A" in exI)
hoelzl@38656
   643
    apply (simp add: disjoint_family_disjointed UN_disjointed_eq ss dA comp_def)
paulson@33271
   644
    done
paulson@33271
   645
  show ?thesis
hoelzl@38656
   646
    by (blast intro: y order_trans [OF _ ley] posf complete_lattice_class.Inf_lower)
paulson@33271
   647
qed
paulson@33271
   648
hoelzl@42066
   649
lemma (in ring_of_sets) inf_measure_close:
hoelzl@43920
   650
  fixes e :: ereal
hoelzl@42066
   651
  assumes posf: "positive M f" and e: "0 < e" and ss: "s \<subseteq> (space M)" and "Inf (measure_set M f s) \<noteq> \<infinity>"
hoelzl@38656
   652
  shows "\<exists>A. range A \<subseteq> sets M \<and> disjoint_family A \<and> s \<subseteq> (\<Union>i. A i) \<and>
hoelzl@41981
   653
               (\<Sum>i. f (A i)) \<le> Inf (measure_set M f s) + e"
hoelzl@42066
   654
proof -
hoelzl@42066
   655
  from `Inf (measure_set M f s) \<noteq> \<infinity>` have fin: "\<bar>Inf (measure_set M f s)\<bar> \<noteq> \<infinity>"
hoelzl@41981
   656
    using inf_measure_pos[OF posf, of s] by auto
hoelzl@38656
   657
  obtain l where "l \<in> measure_set M f s" "l \<le> Inf (measure_set M f s) + e"
hoelzl@43920
   658
    using Inf_ereal_close[OF fin e] by auto
hoelzl@38656
   659
  thus ?thesis
hoelzl@38656
   660
    by (auto intro!: exI[of _ l] simp: measure_set_def comp_def)
paulson@33271
   661
qed
paulson@33271
   662
hoelzl@42066
   663
lemma (in ring_of_sets) inf_measure_countably_subadditive:
hoelzl@41689
   664
  assumes posf: "positive M f" and inc: "increasing M f"
paulson@33271
   665
  shows "countably_subadditive (| space = space M, sets = Pow (space M) |)
paulson@33271
   666
                  (\<lambda>x. Inf (measure_set M f x))"
hoelzl@42066
   667
proof (simp add: countably_subadditive_def, safe)
hoelzl@42066
   668
  fix A :: "nat \<Rightarrow> 'a set"
hoelzl@42066
   669
  let "?outer B" = "Inf (measure_set M f B)"
hoelzl@38656
   670
  assume A: "range A \<subseteq> Pow (space M)"
hoelzl@38656
   671
     and disj: "disjoint_family A"
hoelzl@38656
   672
     and sb: "(\<Union>i. A i) \<subseteq> space M"
hoelzl@42066
   673
hoelzl@43920
   674
  { fix e :: ereal assume e: "0 < e" and "\<forall>i. ?outer (A i) \<noteq> \<infinity>"
hoelzl@42066
   675
    hence "\<exists>BB. \<forall>n. range (BB n) \<subseteq> sets M \<and> disjoint_family (BB n) \<and>
hoelzl@42066
   676
        A n \<subseteq> (\<Union>i. BB n i) \<and> (\<Sum>i. f (BB n i)) \<le> ?outer (A n) + e * (1/2)^(Suc n)"
hoelzl@42066
   677
      apply (safe intro!: choice inf_measure_close [of f, OF posf])
hoelzl@43920
   678
      using e sb by (auto simp: ereal_zero_less_0_iff one_ereal_def)
hoelzl@42066
   679
    then obtain BB
hoelzl@42066
   680
      where BB: "\<And>n. (range (BB n) \<subseteq> sets M)"
hoelzl@38656
   681
      and disjBB: "\<And>n. disjoint_family (BB n)"
hoelzl@38656
   682
      and sbBB: "\<And>n. A n \<subseteq> (\<Union>i. BB n i)"
hoelzl@42066
   683
      and BBle: "\<And>n. (\<Sum>i. f (BB n i)) \<le> ?outer (A n) + e * (1/2)^(Suc n)"
hoelzl@42066
   684
      by auto blast
hoelzl@42066
   685
    have sll: "(\<Sum>n. \<Sum>i. (f (BB n i))) \<le> (\<Sum>n. ?outer (A n)) + e"
hoelzl@38656
   686
    proof -
hoelzl@41981
   687
      have sum_eq_1: "(\<Sum>n. e*(1/2) ^ Suc n) = e"
hoelzl@43920
   688
        using suminf_half_series_ereal e
hoelzl@43920
   689
        by (simp add: ereal_zero_le_0_iff zero_le_divide_ereal suminf_cmult_ereal)
hoelzl@41981
   690
      have "\<And>n i. 0 \<le> f (BB n i)" using posf[unfolded positive_def] BB by auto
hoelzl@41981
   691
      then have "\<And>n. 0 \<le> (\<Sum>i. f (BB n i))" by (rule suminf_0_le)
hoelzl@42066
   692
      then have "(\<Sum>n. \<Sum>i. (f (BB n i))) \<le> (\<Sum>n. ?outer (A n) + e*(1/2) ^ Suc n)"
hoelzl@41981
   693
        by (rule suminf_le_pos[OF BBle])
hoelzl@42066
   694
      also have "... = (\<Sum>n. ?outer (A n)) + e"
hoelzl@41981
   695
        using sum_eq_1 inf_measure_pos[OF posf] e
hoelzl@43920
   696
        by (subst suminf_add_ereal) (auto simp add: ereal_zero_le_0_iff)
hoelzl@38656
   697
      finally show ?thesis .
hoelzl@38656
   698
    qed
hoelzl@42066
   699
    def C \<equiv> "(split BB) o prod_decode"
hoelzl@42066
   700
    have C: "!!n. C n \<in> sets M"
hoelzl@42066
   701
      apply (rule_tac p="prod_decode n" in PairE)
hoelzl@42066
   702
      apply (simp add: C_def)
hoelzl@42066
   703
      apply (metis BB subsetD rangeI)
hoelzl@42066
   704
      done
hoelzl@42066
   705
    have sbC: "(\<Union>i. A i) \<subseteq> (\<Union>i. C i)"
hoelzl@38656
   706
    proof (auto simp add: C_def)
hoelzl@38656
   707
      fix x i
hoelzl@38656
   708
      assume x: "x \<in> A i"
hoelzl@38656
   709
      with sbBB [of i] obtain j where "x \<in> BB i j"
hoelzl@38656
   710
        by blast
hoelzl@38656
   711
      thus "\<exists>i. x \<in> split BB (prod_decode i)"
hoelzl@38656
   712
        by (metis prod_encode_inverse prod.cases)
hoelzl@38656
   713
    qed
hoelzl@42066
   714
    have "(f \<circ> C) = (f \<circ> (\<lambda>(x, y). BB x y)) \<circ> prod_decode"
hoelzl@42066
   715
      by (rule ext)  (auto simp add: C_def)
hoelzl@42066
   716
    moreover have "suminf ... = (\<Sum>n. \<Sum>i. f (BB n i))" using BBle
hoelzl@42066
   717
      using BB posf[unfolded positive_def]
hoelzl@43920
   718
      by (force intro!: suminf_ereal_2dimen simp: o_def)
hoelzl@42066
   719
    ultimately have Csums: "(\<Sum>i. f (C i)) = (\<Sum>n. \<Sum>i. f (BB n i))" by (simp add: o_def)
hoelzl@42066
   720
    have "?outer (\<Union>i. A i) \<le> (\<Sum>n. \<Sum>i. f (BB n i))"
hoelzl@42066
   721
      apply (rule inf_measure_le [OF posf(1) inc], auto)
hoelzl@42066
   722
      apply (rule_tac x="C" in exI)
hoelzl@42066
   723
      apply (auto simp add: C sbC Csums)
hoelzl@42066
   724
      done
hoelzl@42066
   725
    also have "... \<le> (\<Sum>n. ?outer (A n)) + e" using sll
hoelzl@42066
   726
      by blast
hoelzl@42066
   727
    finally have "?outer (\<Union>i. A i) \<le> (\<Sum>n. ?outer (A n)) + e" . }
hoelzl@42066
   728
  note for_finite_Inf = this
hoelzl@42066
   729
hoelzl@42066
   730
  show "?outer (\<Union>i. A i) \<le> (\<Sum>n. ?outer (A n))"
hoelzl@42066
   731
  proof cases
hoelzl@42066
   732
    assume "\<forall>i. ?outer (A i) \<noteq> \<infinity>"
hoelzl@42066
   733
    with for_finite_Inf show ?thesis
hoelzl@43920
   734
      by (intro ereal_le_epsilon) auto
hoelzl@42066
   735
  next
hoelzl@42066
   736
    assume "\<not> (\<forall>i. ?outer (A i) \<noteq> \<infinity>)"
hoelzl@42066
   737
    then have "\<exists>i. ?outer (A i) = \<infinity>"
hoelzl@42066
   738
      by auto
hoelzl@42066
   739
    then have "(\<Sum>n. ?outer (A n)) = \<infinity>"
hoelzl@42066
   740
      using suminf_PInfty[OF inf_measure_pos, OF posf]
hoelzl@42066
   741
      by metis
hoelzl@42066
   742
    then show ?thesis by simp
hoelzl@42066
   743
  qed
paulson@33271
   744
qed
paulson@33271
   745
hoelzl@42066
   746
lemma (in ring_of_sets) inf_measure_outer:
hoelzl@41689
   747
  "\<lbrakk> positive M f ; increasing M f \<rbrakk>
hoelzl@41689
   748
   \<Longrightarrow> outer_measure_space \<lparr> space = space M, sets = Pow (space M) \<rparr>
paulson@33271
   749
                          (\<lambda>x. Inf (measure_set M f x))"
hoelzl@41981
   750
  using inf_measure_pos[of M f]
hoelzl@38656
   751
  by (simp add: outer_measure_space_def inf_measure_empty
hoelzl@38656
   752
                inf_measure_increasing inf_measure_countably_subadditive positive_def)
paulson@33271
   753
hoelzl@42066
   754
lemma (in ring_of_sets) algebra_subset_lambda_system:
hoelzl@41689
   755
  assumes posf: "positive M f" and inc: "increasing M f"
paulson@33271
   756
      and add: "additive M f"
hoelzl@42066
   757
  shows "sets M \<subseteq> lambda_system \<lparr> space = space M, sets = Pow (space M) \<rparr>
paulson@33271
   758
                                (\<lambda>x. Inf (measure_set M f x))"
hoelzl@38656
   759
proof (auto dest: sets_into_space
hoelzl@38656
   760
            simp add: algebra.lambda_system_eq [OF algebra_Pow])
paulson@33271
   761
  fix x s
paulson@33271
   762
  assume x: "x \<in> sets M"
paulson@33271
   763
     and s: "s \<subseteq> space M"
hoelzl@38656
   764
  have [simp]: "!!x. x \<in> sets M \<Longrightarrow> s \<inter> (space M - x) = s-x" using s
paulson@33271
   765
    by blast
paulson@33271
   766
  have "Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))
paulson@33271
   767
        \<le> Inf (measure_set M f s)"
hoelzl@42066
   768
  proof cases
hoelzl@42066
   769
    assume "Inf (measure_set M f s) = \<infinity>" then show ?thesis by simp
hoelzl@42066
   770
  next
hoelzl@42066
   771
    assume fin: "Inf (measure_set M f s) \<noteq> \<infinity>"
hoelzl@42066
   772
    then have "measure_set M f s \<noteq> {}"
hoelzl@43920
   773
      by (auto simp: top_ereal_def)
hoelzl@42066
   774
    show ?thesis
hoelzl@42066
   775
    proof (rule complete_lattice_class.Inf_greatest)
hoelzl@42066
   776
      fix r assume "r \<in> measure_set M f s"
hoelzl@42066
   777
      then obtain A where A: "disjoint_family A" "range A \<subseteq> sets M" "s \<subseteq> (\<Union>i. A i)"
hoelzl@42066
   778
        and r: "r = (\<Sum>i. f (A i))" unfolding measure_set_def by auto
hoelzl@42066
   779
      have "Inf (measure_set M f (s \<inter> x)) \<le> (\<Sum>i. f (A i \<inter> x))"
hoelzl@42066
   780
        unfolding measure_set_def
hoelzl@42066
   781
      proof (safe intro!: complete_lattice_class.Inf_lower exI[of _ "\<lambda>i. A i \<inter> x"])
hoelzl@42066
   782
        from A(1) show "disjoint_family (\<lambda>i. A i \<inter> x)"
hoelzl@42066
   783
          by (rule disjoint_family_on_bisimulation) auto
hoelzl@42066
   784
      qed (insert x A, auto)
hoelzl@42066
   785
      moreover
hoelzl@42066
   786
      have "Inf (measure_set M f (s - x)) \<le> (\<Sum>i. f (A i - x))"
hoelzl@42066
   787
        unfolding measure_set_def
hoelzl@42066
   788
      proof (safe intro!: complete_lattice_class.Inf_lower exI[of _ "\<lambda>i. A i - x"])
hoelzl@42066
   789
        from A(1) show "disjoint_family (\<lambda>i. A i - x)"
hoelzl@42066
   790
          by (rule disjoint_family_on_bisimulation) auto
hoelzl@42066
   791
      qed (insert x A, auto)
hoelzl@42066
   792
      ultimately have "Inf (measure_set M f (s \<inter> x)) + Inf (measure_set M f (s - x)) \<le>
hoelzl@42066
   793
          (\<Sum>i. f (A i \<inter> x)) + (\<Sum>i. f (A i - x))" by (rule add_mono)
hoelzl@42066
   794
      also have "\<dots> = (\<Sum>i. f (A i \<inter> x) + f (A i - x))"
hoelzl@43920
   795
        using A(2) x posf by (subst suminf_add_ereal) (auto simp: positive_def)
hoelzl@42066
   796
      also have "\<dots> = (\<Sum>i. f (A i))"
hoelzl@42066
   797
        using A x
hoelzl@42066
   798
        by (subst add[THEN additiveD, symmetric])
hoelzl@42066
   799
           (auto intro!: arg_cong[where f=suminf] arg_cong[where f=f])
hoelzl@42066
   800
      finally show "Inf (measure_set M f (s \<inter> x)) + Inf (measure_set M f (s - x)) \<le> r"
hoelzl@42066
   801
        using r by simp
paulson@33271
   802
    qed
hoelzl@42066
   803
  qed
hoelzl@38656
   804
  moreover
paulson@33271
   805
  have "Inf (measure_set M f s)
paulson@33271
   806
       \<le> Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))"
hoelzl@42145
   807
  proof -
paulson@33271
   808
    have "Inf (measure_set M f s) = Inf (measure_set M f ((s\<inter>x) \<union> (s-x)))"
paulson@33271
   809
      by (metis Un_Diff_Int Un_commute)
hoelzl@38656
   810
    also have "... \<le> Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))"
hoelzl@38656
   811
      apply (rule subadditiveD)
hoelzl@42145
   812
      apply (rule ring_of_sets.countably_subadditive_subadditive [OF ring_of_sets_Pow])
hoelzl@41981
   813
      apply (simp add: positive_def inf_measure_empty[OF posf] inf_measure_pos[OF posf])
hoelzl@41689
   814
      apply (rule inf_measure_countably_subadditive)
hoelzl@41689
   815
      using s by (auto intro!: posf inc)
paulson@33271
   816
    finally show ?thesis .
hoelzl@42145
   817
  qed
hoelzl@38656
   818
  ultimately
paulson@33271
   819
  show "Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))
paulson@33271
   820
        = Inf (measure_set M f s)"
paulson@33271
   821
    by (rule order_antisym)
paulson@33271
   822
qed
paulson@33271
   823
paulson@33271
   824
lemma measure_down:
hoelzl@41689
   825
  "measure_space N \<Longrightarrow> sigma_algebra M \<Longrightarrow> sets M \<subseteq> sets N \<Longrightarrow> measure N = measure M \<Longrightarrow> measure_space M"
hoelzl@38656
   826
  by (simp add: measure_space_def measure_space_axioms_def positive_def
hoelzl@38656
   827
                countably_additive_def)
paulson@33271
   828
     blast
paulson@33271
   829
hoelzl@42066
   830
theorem (in ring_of_sets) caratheodory:
hoelzl@41689
   831
  assumes posf: "positive M f" and ca: "countably_additive M f"
hoelzl@43920
   832
  shows "\<exists>\<mu> :: 'a set \<Rightarrow> ereal. (\<forall>s \<in> sets M. \<mu> s = f s) \<and>
hoelzl@41689
   833
            measure_space \<lparr> space = space M, sets = sets (sigma M), measure = \<mu> \<rparr>"
hoelzl@41689
   834
proof -
hoelzl@41689
   835
  have inc: "increasing M f"
hoelzl@41689
   836
    by (metis additive_increasing ca countably_additive_additive posf)
hoelzl@41689
   837
  let ?infm = "(\<lambda>x. Inf (measure_set M f x))"
hoelzl@41689
   838
  def ls \<equiv> "lambda_system (|space = space M, sets = Pow (space M)|) ?infm"
hoelzl@41689
   839
  have mls: "measure_space \<lparr>space = space M, sets = ls, measure = ?infm\<rparr>"
hoelzl@41689
   840
    using sigma_algebra.caratheodory_lemma
hoelzl@41689
   841
            [OF sigma_algebra_Pow  inf_measure_outer [OF posf inc]]
hoelzl@41689
   842
    by (simp add: ls_def)
hoelzl@41689
   843
  hence sls: "sigma_algebra (|space = space M, sets = ls, measure = ?infm|)"
hoelzl@41689
   844
    by (simp add: measure_space_def)
hoelzl@41689
   845
  have "sets M \<subseteq> ls"
hoelzl@41689
   846
    by (simp add: ls_def)
hoelzl@41689
   847
       (metis ca posf inc countably_additive_additive algebra_subset_lambda_system)
hoelzl@41689
   848
  hence sgs_sb: "sigma_sets (space M) (sets M) \<subseteq> ls"
hoelzl@41689
   849
    using sigma_algebra.sigma_sets_subset [OF sls, of "sets M"]
hoelzl@41689
   850
    by simp
hoelzl@41689
   851
  have "measure_space \<lparr> space = space M, sets = sets (sigma M), measure = ?infm \<rparr>"
hoelzl@41689
   852
    unfolding sigma_def
hoelzl@41689
   853
    by (rule measure_down [OF mls], rule sigma_algebra_sigma_sets)
hoelzl@41689
   854
       (simp_all add: sgs_sb space_closed)
hoelzl@41689
   855
  thus ?thesis using inf_measure_agrees [OF posf ca]
hoelzl@41689
   856
    by (intro exI[of _ ?infm]) auto
hoelzl@41689
   857
qed
paulson@33271
   858
hoelzl@42145
   859
subsubsection {*Alternative instances of caratheodory*}
hoelzl@42145
   860
hoelzl@42145
   861
lemma (in ring_of_sets) countably_additive_iff_continuous_from_below:
hoelzl@42145
   862
  assumes f: "positive M f" "additive M f"
hoelzl@42145
   863
  shows "countably_additive M f \<longleftrightarrow>
hoelzl@42145
   864
    (\<forall>A. range A \<subseteq> sets M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> sets M \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Union>i. A i))"
hoelzl@42145
   865
  unfolding countably_additive_def
hoelzl@42145
   866
proof safe
hoelzl@42145
   867
  assume count_sum: "\<forall>A. range A \<subseteq> sets M \<longrightarrow> disjoint_family A \<longrightarrow> UNION UNIV A \<in> sets M \<longrightarrow> (\<Sum>i. f (A i)) = f (UNION UNIV A)"
hoelzl@42145
   868
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets M" "incseq A" "(\<Union>i. A i) \<in> sets M"
hoelzl@42145
   869
  then have dA: "range (disjointed A) \<subseteq> sets M" by (auto simp: range_disjointed_sets)
hoelzl@42145
   870
  with count_sum[THEN spec, of "disjointed A"] A(3)
hoelzl@42145
   871
  have f_UN: "(\<Sum>i. f (disjointed A i)) = f (\<Union>i. A i)"
hoelzl@42145
   872
    by (auto simp: UN_disjointed_eq disjoint_family_disjointed)
hoelzl@42145
   873
  moreover have "(\<lambda>n. (\<Sum>i=0..<n. f (disjointed A i))) ----> (\<Sum>i. f (disjointed A i))"
hoelzl@42145
   874
    using f(1)[unfolded positive_def] dA
hoelzl@43920
   875
    by (auto intro!: summable_sumr_LIMSEQ_suminf summable_ereal_pos)
hoelzl@42145
   876
  from LIMSEQ_Suc[OF this]
hoelzl@42145
   877
  have "(\<lambda>n. (\<Sum>i\<le>n. f (disjointed A i))) ----> (\<Sum>i. f (disjointed A i))"
hoelzl@42145
   878
    unfolding atLeastLessThanSuc_atLeastAtMost atLeast0AtMost .
hoelzl@42145
   879
  moreover have "\<And>n. (\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
hoelzl@42145
   880
    using disjointed_additive[OF f A(1,2)] .
hoelzl@42145
   881
  ultimately show "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)" by simp
hoelzl@42145
   882
next
hoelzl@42145
   883
  assume cont: "\<forall>A. range A \<subseteq> sets M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> sets M \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@42145
   884
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets M" "disjoint_family A" "(\<Union>i. A i) \<in> sets M"
hoelzl@42145
   885
  have *: "(\<Union>n. (\<Union>i\<le>n. A i)) = (\<Union>i. A i)" by auto
hoelzl@42145
   886
  have "(\<lambda>n. f (\<Union>i\<le>n. A i)) ----> f (\<Union>i. A i)"
hoelzl@42145
   887
  proof (unfold *[symmetric], intro cont[rule_format])
hoelzl@42145
   888
    show "range (\<lambda>i. \<Union> i\<le>i. A i) \<subseteq> sets M" "(\<Union>i. \<Union> i\<le>i. A i) \<in> sets M"
hoelzl@42145
   889
      using A * by auto
hoelzl@42145
   890
  qed (force intro!: incseq_SucI)
hoelzl@42145
   891
  moreover have "\<And>n. f (\<Union>i\<le>n. A i) = (\<Sum>i\<le>n. f (A i))"
hoelzl@42145
   892
    using A
hoelzl@42145
   893
    by (intro additive_sum[OF f, of _ A, symmetric])
hoelzl@42145
   894
       (auto intro: disjoint_family_on_mono[where B=UNIV])
hoelzl@42145
   895
  ultimately
hoelzl@42145
   896
  have "(\<lambda>i. f (A i)) sums f (\<Union>i. A i)"
hoelzl@42145
   897
    unfolding sums_def2 by simp
hoelzl@42145
   898
  from sums_unique[OF this]
hoelzl@42145
   899
  show "(\<Sum>i. f (A i)) = f (\<Union>i. A i)" by simp
hoelzl@42145
   900
qed
hoelzl@42145
   901
hoelzl@42145
   902
lemma (in ring_of_sets) continuous_from_above_iff_empty_continuous:
hoelzl@42145
   903
  assumes f: "positive M f" "additive M f"
hoelzl@42145
   904
  shows "(\<forall>A. range A \<subseteq> sets M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) \<in> sets M \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Inter>i. A i))
hoelzl@42145
   905
     \<longleftrightarrow> (\<forall>A. range A \<subseteq> sets M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> 0)"
hoelzl@42145
   906
proof safe
hoelzl@42145
   907
  assume cont: "(\<forall>A. range A \<subseteq> sets M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) \<in> sets M \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Inter>i. A i))"
hoelzl@42145
   908
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets M" "decseq A" "(\<Inter>i. A i) = {}" "\<forall>i. f (A i) \<noteq> \<infinity>"
hoelzl@42145
   909
  with cont[THEN spec, of A] show "(\<lambda>i. f (A i)) ----> 0"
hoelzl@42145
   910
    using `positive M f`[unfolded positive_def] by auto
hoelzl@42145
   911
next
hoelzl@42145
   912
  assume cont: "\<forall>A. range A \<subseteq> sets M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@42145
   913
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets M" "decseq A" "(\<Inter>i. A i) \<in> sets M" "\<forall>i. f (A i) \<noteq> \<infinity>"
hoelzl@42145
   914
hoelzl@42145
   915
  have f_mono: "\<And>a b. a \<in> sets M \<Longrightarrow> b \<in> sets M \<Longrightarrow> a \<subseteq> b \<Longrightarrow> f a \<le> f b"
hoelzl@42145
   916
    using additive_increasing[OF f] unfolding increasing_def by simp
hoelzl@42145
   917
hoelzl@42145
   918
  have decseq_fA: "decseq (\<lambda>i. f (A i))"
hoelzl@42145
   919
    using A by (auto simp: decseq_def intro!: f_mono)
hoelzl@42145
   920
  have decseq: "decseq (\<lambda>i. A i - (\<Inter>i. A i))"
hoelzl@42145
   921
    using A by (auto simp: decseq_def)
hoelzl@42145
   922
  then have decseq_f: "decseq (\<lambda>i. f (A i - (\<Inter>i. A i)))"
hoelzl@42145
   923
    using A unfolding decseq_def by (auto intro!: f_mono Diff)
hoelzl@42145
   924
  have "f (\<Inter>x. A x) \<le> f (A 0)"
hoelzl@42145
   925
    using A by (auto intro!: f_mono)
hoelzl@42145
   926
  then have f_Int_fin: "f (\<Inter>x. A x) \<noteq> \<infinity>"
hoelzl@42145
   927
    using A by auto
hoelzl@42145
   928
  { fix i
hoelzl@42145
   929
    have "f (A i - (\<Inter>i. A i)) \<le> f (A i)" using A by (auto intro!: f_mono)
hoelzl@42145
   930
    then have "f (A i - (\<Inter>i. A i)) \<noteq> \<infinity>"
hoelzl@42145
   931
      using A by auto }
hoelzl@42145
   932
  note f_fin = this
hoelzl@42145
   933
  have "(\<lambda>i. f (A i - (\<Inter>i. A i))) ----> 0"
hoelzl@42145
   934
  proof (intro cont[rule_format, OF _ decseq _ f_fin])
hoelzl@42145
   935
    show "range (\<lambda>i. A i - (\<Inter>i. A i)) \<subseteq> sets M" "(\<Inter>i. A i - (\<Inter>i. A i)) = {}"
hoelzl@42145
   936
      using A by auto
hoelzl@42145
   937
  qed
hoelzl@43920
   938
  from INF_Lim_ereal[OF decseq_f this]
hoelzl@42145
   939
  have "(INF n. f (A n - (\<Inter>i. A i))) = 0" .
hoelzl@42145
   940
  moreover have "(INF n. f (\<Inter>i. A i)) = f (\<Inter>i. A i)"
hoelzl@42145
   941
    by auto
hoelzl@42145
   942
  ultimately have "(INF n. f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i)) = 0 + f (\<Inter>i. A i)"
hoelzl@42145
   943
    using A(4) f_fin f_Int_fin
hoelzl@43920
   944
    by (subst INFI_ereal_add) (auto simp: decseq_f)
hoelzl@42145
   945
  moreover {
hoelzl@42145
   946
    fix n
hoelzl@42145
   947
    have "f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i) = f ((A n - (\<Inter>i. A i)) \<union> (\<Inter>i. A i))"
hoelzl@42145
   948
      using A by (subst f(2)[THEN additiveD]) auto
hoelzl@42145
   949
    also have "(A n - (\<Inter>i. A i)) \<union> (\<Inter>i. A i) = A n"
hoelzl@42145
   950
      by auto
hoelzl@42145
   951
    finally have "f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i) = f (A n)" . }
hoelzl@42145
   952
  ultimately have "(INF n. f (A n)) = f (\<Inter>i. A i)"
hoelzl@42145
   953
    by simp
hoelzl@43920
   954
  with LIMSEQ_ereal_INFI[OF decseq_fA]
hoelzl@42145
   955
  show "(\<lambda>i. f (A i)) ----> f (\<Inter>i. A i)" by simp
hoelzl@42145
   956
qed
hoelzl@42145
   957
hoelzl@42145
   958
lemma positiveD1: "positive M f \<Longrightarrow> f {} = 0" by (auto simp: positive_def)
hoelzl@42145
   959
lemma positiveD2: "positive M f \<Longrightarrow> A \<in> sets M \<Longrightarrow> 0 \<le> f A" by (auto simp: positive_def)
hoelzl@42145
   960
hoelzl@42145
   961
lemma (in ring_of_sets) empty_continuous_imp_continuous_from_below:
hoelzl@42145
   962
  assumes f: "positive M f" "additive M f" "\<forall>A\<in>sets M. f A \<noteq> \<infinity>"
hoelzl@42145
   963
  assumes cont: "\<forall>A. range A \<subseteq> sets M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@42145
   964
  assumes A: "range A \<subseteq> sets M" "incseq A" "(\<Union>i. A i) \<in> sets M"
hoelzl@42145
   965
  shows "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@42145
   966
proof -
hoelzl@43920
   967
  have "\<forall>A\<in>sets M. \<exists>x. f A = ereal x"
hoelzl@42145
   968
  proof
hoelzl@43920
   969
    fix A assume "A \<in> sets M" with f show "\<exists>x. f A = ereal x"
hoelzl@42145
   970
      unfolding positive_def by (cases "f A") auto
hoelzl@42145
   971
  qed
hoelzl@42145
   972
  from bchoice[OF this] guess f' .. note f' = this[rule_format]
hoelzl@42145
   973
  from A have "(\<lambda>i. f ((\<Union>i. A i) - A i)) ----> 0"
hoelzl@42145
   974
    by (intro cont[rule_format]) (auto simp: decseq_def incseq_def)
hoelzl@42145
   975
  moreover
hoelzl@42145
   976
  { fix i
hoelzl@42145
   977
    have "f ((\<Union>i. A i) - A i) + f (A i) = f ((\<Union>i. A i) - A i \<union> A i)"
hoelzl@42145
   978
      using A by (intro f(2)[THEN additiveD, symmetric]) auto
hoelzl@42145
   979
    also have "(\<Union>i. A i) - A i \<union> A i = (\<Union>i. A i)"
hoelzl@42145
   980
      by auto
hoelzl@42145
   981
    finally have "f' (\<Union>i. A i) - f' (A i) = f' ((\<Union>i. A i) - A i)"
hoelzl@42145
   982
      using A by (subst (asm) (1 2 3) f') auto
hoelzl@43920
   983
    then have "f ((\<Union>i. A i) - A i) = ereal (f' (\<Union>i. A i) - f' (A i))"
hoelzl@42145
   984
      using A f' by auto }
hoelzl@42145
   985
  ultimately have "(\<lambda>i. f' (\<Union>i. A i) - f' (A i)) ----> 0"
hoelzl@43920
   986
    by (simp add: zero_ereal_def)
hoelzl@42145
   987
  then have "(\<lambda>i. f' (A i)) ----> f' (\<Union>i. A i)"
huffman@44568
   988
    by (rule LIMSEQ_diff_approach_zero2[OF tendsto_const])
hoelzl@42145
   989
  then show "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@42145
   990
    using A by (subst (1 2) f') auto
hoelzl@42145
   991
qed
hoelzl@42145
   992
hoelzl@42145
   993
lemma (in ring_of_sets) empty_continuous_imp_countably_additive:
hoelzl@42145
   994
  assumes f: "positive M f" "additive M f" and fin: "\<forall>A\<in>sets M. f A \<noteq> \<infinity>"
hoelzl@42145
   995
  assumes cont: "\<And>A. range A \<subseteq> sets M \<Longrightarrow> decseq A \<Longrightarrow> (\<Inter>i. A i) = {} \<Longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@42145
   996
  shows "countably_additive M f"
hoelzl@42145
   997
  using countably_additive_iff_continuous_from_below[OF f]
hoelzl@42145
   998
  using empty_continuous_imp_continuous_from_below[OF f fin] cont
hoelzl@42145
   999
  by blast
hoelzl@42145
  1000
hoelzl@42145
  1001
lemma (in ring_of_sets) caratheodory_empty_continuous:
hoelzl@42145
  1002
  assumes f: "positive M f" "additive M f" and fin: "\<And>A. A \<in> sets M \<Longrightarrow> f A \<noteq> \<infinity>"
hoelzl@42145
  1003
  assumes cont: "\<And>A. range A \<subseteq> sets M \<Longrightarrow> decseq A \<Longrightarrow> (\<Inter>i. A i) = {} \<Longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@43920
  1004
  shows "\<exists>\<mu> :: 'a set \<Rightarrow> ereal. (\<forall>s \<in> sets M. \<mu> s = f s) \<and>
hoelzl@42145
  1005
            measure_space \<lparr> space = space M, sets = sets (sigma M), measure = \<mu> \<rparr>"
hoelzl@42145
  1006
proof (intro caratheodory empty_continuous_imp_countably_additive f)
hoelzl@42145
  1007
  show "\<forall>A\<in>sets M. f A \<noteq> \<infinity>" using fin by auto
hoelzl@42145
  1008
qed (rule cont)
hoelzl@42145
  1009
paulson@33271
  1010
end