src/HOL/Probability/Caratheodory.thy
author hoelzl
Wed Apr 25 19:26:00 2012 +0200 (2012-04-25)
changeset 47761 dfe747e72fa8
parent 47694 05663f75964c
child 47762 d31085f07f60
permissions -rw-r--r--
moved lemmas to appropriate places
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
hoelzl@47694
     9
  imports Measure_Space
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@44928
    49
    by (auto intro!: SUPR_eq  simp: setsum_cartesian_product reindex SUP_upper2
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
definition subadditive where "subadditive M f \<longleftrightarrow>
hoelzl@47694
    57
  (\<forall>x\<in>M. \<forall>y\<in>M. x \<inter> y = {} \<longrightarrow> f (x \<union> y) \<le> f x + f y)"
paulson@33271
    58
hoelzl@41689
    59
definition countably_subadditive where "countably_subadditive M f \<longleftrightarrow>
hoelzl@47694
    60
  (\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow>
hoelzl@41981
    61
    (f (\<Union>i. A i) \<le> (\<Sum>i. f (A i))))"
hoelzl@41689
    62
hoelzl@47694
    63
definition lambda_system where "lambda_system \<Omega> M f = {l \<in> M.
hoelzl@47694
    64
  \<forall>x \<in> M. f (l \<inter> x) + f ((\<Omega> - l) \<inter> x) = f x}"
paulson@33271
    65
hoelzl@41689
    66
definition outer_measure_space where "outer_measure_space M f \<longleftrightarrow>
hoelzl@41689
    67
  positive M f \<and> increasing M f \<and> countably_subadditive M f"
hoelzl@41689
    68
hoelzl@41689
    69
definition measure_set where "measure_set M f X = {r.
hoelzl@47694
    70
  \<exists>A. range A \<subseteq> M \<and> disjoint_family A \<and> X \<subseteq> (\<Union>i. A i) \<and> (\<Sum>i. f (A i)) = r}"
paulson@33271
    71
paulson@33271
    72
lemma subadditiveD:
hoelzl@47694
    73
  "subadditive M f \<Longrightarrow> x \<inter> y = {} \<Longrightarrow> x \<in> M \<Longrightarrow> y \<in> M \<Longrightarrow> f (x \<union> y) \<le> f x + f y"
paulson@33271
    74
  by (auto simp add: subadditive_def)
paulson@33271
    75
paulson@33271
    76
subsection {* Lambda Systems *}
paulson@33271
    77
paulson@33271
    78
lemma (in algebra) lambda_system_eq:
hoelzl@47694
    79
  shows "lambda_system \<Omega> M f = {l \<in> M. \<forall>x \<in> M. f (x \<inter> l) + f (x - l) = f x}"
paulson@33271
    80
proof -
hoelzl@47694
    81
  have [simp]: "!!l x. l \<in> M \<Longrightarrow> x \<in> M \<Longrightarrow> (\<Omega> - l) \<inter> x = x - l"
huffman@37032
    82
    by (metis Int_Diff Int_absorb1 Int_commute sets_into_space)
paulson@33271
    83
  show ?thesis
huffman@37032
    84
    by (auto simp add: lambda_system_def) (metis Int_commute)+
paulson@33271
    85
qed
paulson@33271
    86
paulson@33271
    87
lemma (in algebra) lambda_system_empty:
hoelzl@47694
    88
  "positive M f \<Longrightarrow> {} \<in> lambda_system \<Omega> M f"
hoelzl@42066
    89
  by (auto simp add: positive_def lambda_system_eq)
paulson@33271
    90
paulson@33271
    91
lemma lambda_system_sets:
hoelzl@47694
    92
  "x \<in> lambda_system \<Omega> M f \<Longrightarrow> x \<in> M"
hoelzl@41689
    93
  by (simp add: lambda_system_def)
paulson@33271
    94
paulson@33271
    95
lemma (in algebra) lambda_system_Compl:
hoelzl@43920
    96
  fixes f:: "'a set \<Rightarrow> ereal"
hoelzl@47694
    97
  assumes x: "x \<in> lambda_system \<Omega> M f"
hoelzl@47694
    98
  shows "\<Omega> - x \<in> lambda_system \<Omega> M f"
hoelzl@41689
    99
proof -
hoelzl@47694
   100
  have "x \<subseteq> \<Omega>"
hoelzl@41689
   101
    by (metis sets_into_space lambda_system_sets x)
hoelzl@47694
   102
  hence "\<Omega> - (\<Omega> - x) = x"
hoelzl@41689
   103
    by (metis double_diff equalityE)
hoelzl@41689
   104
  with x show ?thesis
hoelzl@41689
   105
    by (force simp add: lambda_system_def ac_simps)
hoelzl@41689
   106
qed
paulson@33271
   107
paulson@33271
   108
lemma (in algebra) lambda_system_Int:
hoelzl@43920
   109
  fixes f:: "'a set \<Rightarrow> ereal"
hoelzl@47694
   110
  assumes xl: "x \<in> lambda_system \<Omega> M f" and yl: "y \<in> lambda_system \<Omega> M f"
hoelzl@47694
   111
  shows "x \<inter> y \<in> lambda_system \<Omega> M f"
hoelzl@41689
   112
proof -
hoelzl@41689
   113
  from xl yl show ?thesis
hoelzl@41689
   114
  proof (auto simp add: positive_def lambda_system_eq Int)
hoelzl@41689
   115
    fix u
hoelzl@47694
   116
    assume x: "x \<in> M" and y: "y \<in> M" and u: "u \<in> M"
hoelzl@47694
   117
       and fx: "\<forall>z\<in>M. f (z \<inter> x) + f (z - x) = f z"
hoelzl@47694
   118
       and fy: "\<forall>z\<in>M. f (z \<inter> y) + f (z - y) = f z"
hoelzl@47694
   119
    have "u - x \<inter> y \<in> M"
hoelzl@41689
   120
      by (metis Diff Diff_Int Un u x y)
hoelzl@41689
   121
    moreover
hoelzl@41689
   122
    have "(u - (x \<inter> y)) \<inter> y = u \<inter> y - x" by blast
hoelzl@41689
   123
    moreover
hoelzl@41689
   124
    have "u - x \<inter> y - y = u - y" by blast
hoelzl@41689
   125
    ultimately
hoelzl@41689
   126
    have ey: "f (u - x \<inter> y) = f (u \<inter> y - x) + f (u - y)" using fy
hoelzl@41689
   127
      by force
hoelzl@41689
   128
    have "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y)
hoelzl@41689
   129
          = (f (u \<inter> (x \<inter> y)) + f (u \<inter> y - x)) + f (u - y)"
hoelzl@41689
   130
      by (simp add: ey ac_simps)
hoelzl@41689
   131
    also have "... =  (f ((u \<inter> y) \<inter> x) + f (u \<inter> y - x)) + f (u - y)"
hoelzl@41689
   132
      by (simp add: Int_ac)
hoelzl@41689
   133
    also have "... = f (u \<inter> y) + f (u - y)"
hoelzl@41689
   134
      using fx [THEN bspec, of "u \<inter> y"] Int y u
hoelzl@41689
   135
      by force
hoelzl@41689
   136
    also have "... = f u"
hoelzl@41689
   137
      by (metis fy u)
hoelzl@41689
   138
    finally show "f (u \<inter> (x \<inter> y)) + f (u - x \<inter> y) = f u" .
paulson@33271
   139
  qed
hoelzl@41689
   140
qed
paulson@33271
   141
paulson@33271
   142
lemma (in algebra) lambda_system_Un:
hoelzl@43920
   143
  fixes f:: "'a set \<Rightarrow> ereal"
hoelzl@47694
   144
  assumes xl: "x \<in> lambda_system \<Omega> M f" and yl: "y \<in> lambda_system \<Omega> M f"
hoelzl@47694
   145
  shows "x \<union> y \<in> lambda_system \<Omega> M f"
paulson@33271
   146
proof -
hoelzl@47694
   147
  have "(\<Omega> - x) \<inter> (\<Omega> - y) \<in> M"
hoelzl@38656
   148
    by (metis Diff_Un Un compl_sets lambda_system_sets xl yl)
paulson@33271
   149
  moreover
hoelzl@47694
   150
  have "x \<union> y = \<Omega> - ((\<Omega> - x) \<inter> (\<Omega> - y))"
wenzelm@46731
   151
    by auto (metis subsetD lambda_system_sets sets_into_space xl yl)+
paulson@33271
   152
  ultimately show ?thesis
hoelzl@38656
   153
    by (metis lambda_system_Compl lambda_system_Int xl yl)
paulson@33271
   154
qed
paulson@33271
   155
paulson@33271
   156
lemma (in algebra) lambda_system_algebra:
hoelzl@47694
   157
  "positive M f \<Longrightarrow> algebra \<Omega> (lambda_system \<Omega> M f)"
hoelzl@42065
   158
  apply (auto simp add: algebra_iff_Un)
paulson@33271
   159
  apply (metis lambda_system_sets set_mp sets_into_space)
paulson@33271
   160
  apply (metis lambda_system_empty)
paulson@33271
   161
  apply (metis lambda_system_Compl)
hoelzl@38656
   162
  apply (metis lambda_system_Un)
paulson@33271
   163
  done
paulson@33271
   164
paulson@33271
   165
lemma (in algebra) lambda_system_strong_additive:
hoelzl@47694
   166
  assumes z: "z \<in> M" and disj: "x \<inter> y = {}"
hoelzl@47694
   167
      and xl: "x \<in> lambda_system \<Omega> M f" and yl: "y \<in> lambda_system \<Omega> M f"
paulson@33271
   168
  shows "f (z \<inter> (x \<union> y)) = f (z \<inter> x) + f (z \<inter> y)"
hoelzl@41689
   169
proof -
hoelzl@41689
   170
  have "z \<inter> x = (z \<inter> (x \<union> y)) \<inter> x" using disj by blast
hoelzl@41689
   171
  moreover
hoelzl@41689
   172
  have "z \<inter> y = (z \<inter> (x \<union> y)) - x" using disj by blast
hoelzl@41689
   173
  moreover
hoelzl@47694
   174
  have "(z \<inter> (x \<union> y)) \<in> M"
hoelzl@41689
   175
    by (metis Int Un lambda_system_sets xl yl z)
hoelzl@41689
   176
  ultimately show ?thesis using xl yl
hoelzl@41689
   177
    by (simp add: lambda_system_eq)
hoelzl@41689
   178
qed
paulson@33271
   179
hoelzl@47694
   180
lemma (in algebra) lambda_system_additive: "additive (lambda_system \<Omega> M f) f"
hoelzl@41689
   181
proof (auto simp add: additive_def)
hoelzl@41689
   182
  fix x and y
hoelzl@41689
   183
  assume disj: "x \<inter> y = {}"
hoelzl@47694
   184
     and xl: "x \<in> lambda_system \<Omega> M f" and yl: "y \<in> lambda_system \<Omega> M f"
hoelzl@47694
   185
  hence  "x \<in> M" "y \<in> M" by (blast intro: lambda_system_sets)+
hoelzl@41689
   186
  thus "f (x \<union> y) = f x + f y"
hoelzl@41689
   187
    using lambda_system_strong_additive [OF top disj xl yl]
hoelzl@41689
   188
    by (simp add: Un)
hoelzl@41689
   189
qed
paulson@33271
   190
hoelzl@42145
   191
lemma (in ring_of_sets) countably_subadditive_subadditive:
hoelzl@41689
   192
  assumes f: "positive M f" and cs: "countably_subadditive M f"
paulson@33271
   193
  shows  "subadditive M f"
hoelzl@35582
   194
proof (auto simp add: subadditive_def)
paulson@33271
   195
  fix x y
hoelzl@47694
   196
  assume x: "x \<in> M" and y: "y \<in> M" and "x \<inter> y = {}"
paulson@33271
   197
  hence "disjoint_family (binaryset x y)"
hoelzl@35582
   198
    by (auto simp add: disjoint_family_on_def binaryset_def)
hoelzl@47694
   199
  hence "range (binaryset x y) \<subseteq> M \<longrightarrow>
hoelzl@47694
   200
         (\<Union>i. binaryset x y i) \<in> M \<longrightarrow>
hoelzl@41981
   201
         f (\<Union>i. binaryset x y i) \<le> (\<Sum> n. f (binaryset x y n))"
hoelzl@41981
   202
    using cs by (auto simp add: countably_subadditive_def)
hoelzl@47694
   203
  hence "{x,y,{}} \<subseteq> M \<longrightarrow> x \<union> y \<in> M \<longrightarrow>
hoelzl@41981
   204
         f (x \<union> y) \<le> (\<Sum> n. f (binaryset x y n))"
paulson@33271
   205
    by (simp add: range_binaryset_eq UN_binaryset_eq)
hoelzl@38656
   206
  thus "f (x \<union> y) \<le>  f x + f y" using f x y
hoelzl@41981
   207
    by (auto simp add: Un o_def suminf_binaryset_eq positive_def)
paulson@33271
   208
qed
paulson@33271
   209
paulson@33271
   210
lemma lambda_system_increasing:
hoelzl@47694
   211
 "increasing M f \<Longrightarrow> increasing (lambda_system \<Omega> M f) f"
hoelzl@38656
   212
  by (simp add: increasing_def lambda_system_def)
paulson@33271
   213
hoelzl@41689
   214
lemma lambda_system_positive:
hoelzl@47694
   215
  "positive M f \<Longrightarrow> positive (lambda_system \<Omega> M f) f"
hoelzl@41689
   216
  by (simp add: positive_def lambda_system_def)
hoelzl@41689
   217
paulson@33271
   218
lemma (in algebra) lambda_system_strong_sum:
hoelzl@43920
   219
  fixes A:: "nat \<Rightarrow> 'a set" and f :: "'a set \<Rightarrow> ereal"
hoelzl@47694
   220
  assumes f: "positive M f" and a: "a \<in> M"
hoelzl@47694
   221
      and A: "range A \<subseteq> lambda_system \<Omega> M f"
paulson@33271
   222
      and disj: "disjoint_family A"
paulson@33271
   223
  shows  "(\<Sum>i = 0..<n. f (a \<inter>A i)) = f (a \<inter> (\<Union>i\<in>{0..<n}. A i))"
paulson@33271
   224
proof (induct n)
hoelzl@38656
   225
  case 0 show ?case using f by (simp add: positive_def)
paulson@33271
   226
next
hoelzl@38656
   227
  case (Suc n)
paulson@33271
   228
  have 2: "A n \<inter> UNION {0..<n} A = {}" using disj
hoelzl@38656
   229
    by (force simp add: disjoint_family_on_def neq_iff)
hoelzl@47694
   230
  have 3: "A n \<in> lambda_system \<Omega> M f" using A
paulson@33271
   231
    by blast
hoelzl@47694
   232
  interpret l: algebra \<Omega> "lambda_system \<Omega> M f"
hoelzl@42065
   233
    using f by (rule lambda_system_algebra)
hoelzl@47694
   234
  have 4: "UNION {0..<n} A \<in> lambda_system \<Omega> M f"
hoelzl@42065
   235
    using A l.UNION_in_sets by simp
paulson@33271
   236
  from Suc.hyps show ?case
paulson@33271
   237
    by (simp add: atLeastLessThanSuc lambda_system_strong_additive [OF a 2 3 4])
paulson@33271
   238
qed
paulson@33271
   239
paulson@33271
   240
lemma (in sigma_algebra) lambda_system_caratheodory:
paulson@33271
   241
  assumes oms: "outer_measure_space M f"
hoelzl@47694
   242
      and A: "range A \<subseteq> lambda_system \<Omega> M f"
paulson@33271
   243
      and disj: "disjoint_family A"
hoelzl@47694
   244
  shows  "(\<Union>i. A i) \<in> lambda_system \<Omega> M f \<and> (\<Sum>i. f (A i)) = f (\<Union>i. A i)"
paulson@33271
   245
proof -
hoelzl@41689
   246
  have pos: "positive M f" and inc: "increasing M f"
hoelzl@38656
   247
   and csa: "countably_subadditive M f"
paulson@33271
   248
    by (metis oms outer_measure_space_def)+
paulson@33271
   249
  have sa: "subadditive M f"
hoelzl@38656
   250
    by (metis countably_subadditive_subadditive csa pos)
hoelzl@47694
   251
  have A': "\<And>S. A`S \<subseteq> (lambda_system \<Omega> M f)" using A
hoelzl@47694
   252
    by auto
hoelzl@47694
   253
  interpret ls: algebra \<Omega> "lambda_system \<Omega> M f"
hoelzl@42065
   254
    using pos by (rule lambda_system_algebra)
hoelzl@47694
   255
  have A'': "range A \<subseteq> M"
paulson@33271
   256
     by (metis A image_subset_iff lambda_system_sets)
hoelzl@38656
   257
hoelzl@47694
   258
  have U_in: "(\<Union>i. A i) \<in> M"
huffman@37032
   259
    by (metis A'' countable_UN)
hoelzl@41981
   260
  have U_eq: "f (\<Union>i. A i) = (\<Sum>i. f (A i))"
hoelzl@41689
   261
  proof (rule antisym)
hoelzl@41981
   262
    show "f (\<Union>i. A i) \<le> (\<Sum>i. f (A i))"
hoelzl@41981
   263
      using csa[unfolded countably_subadditive_def] A'' disj U_in by auto
hoelzl@41981
   264
    have *: "\<And>i. 0 \<le> f (A i)" using pos A'' unfolding positive_def by auto
hoelzl@41981
   265
    have dis: "\<And>N. disjoint_family_on A {..<N}" by (intro disjoint_family_on_mono[OF _ disj]) auto
hoelzl@41981
   266
    show "(\<Sum>i. f (A i)) \<le> f (\<Union>i. A i)"
hoelzl@42065
   267
      using ls.additive_sum [OF lambda_system_positive[OF pos] lambda_system_additive _ A' dis]
hoelzl@41981
   268
      using A''
hoelzl@47694
   269
      by (intro suminf_bound[OF _ *]) (auto intro!: increasingD[OF inc] countable_UN)
hoelzl@41689
   270
  qed
paulson@33271
   271
  {
hoelzl@38656
   272
    fix a
hoelzl@47694
   273
    assume a [iff]: "a \<in> M"
paulson@33271
   274
    have "f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i)) = f a"
paulson@33271
   275
    proof -
paulson@33271
   276
      show ?thesis
paulson@33271
   277
      proof (rule antisym)
hoelzl@47694
   278
        have "range (\<lambda>i. a \<inter> A i) \<subseteq> M" using A''
wenzelm@33536
   279
          by blast
hoelzl@38656
   280
        moreover
wenzelm@33536
   281
        have "disjoint_family (\<lambda>i. a \<inter> A i)" using disj
hoelzl@38656
   282
          by (auto simp add: disjoint_family_on_def)
hoelzl@38656
   283
        moreover
hoelzl@47694
   284
        have "a \<inter> (\<Union>i. A i) \<in> M"
wenzelm@33536
   285
          by (metis Int U_in a)
hoelzl@38656
   286
        ultimately
hoelzl@41981
   287
        have "f (a \<inter> (\<Union>i. A i)) \<le> (\<Sum>i. f (a \<inter> A i))"
hoelzl@41981
   288
          using csa[unfolded countably_subadditive_def, rule_format, of "(\<lambda>i. a \<inter> A i)"]
hoelzl@38656
   289
          by (simp add: o_def)
hoelzl@38656
   290
        hence "f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i)) \<le>
hoelzl@41981
   291
            (\<Sum>i. f (a \<inter> A i)) + f (a - (\<Union>i. A i))"
hoelzl@38656
   292
          by (rule add_right_mono)
hoelzl@38656
   293
        moreover
hoelzl@41981
   294
        have "(\<Sum>i. f (a \<inter> A i)) + f (a - (\<Union>i. A i)) \<le> f a"
hoelzl@41981
   295
          proof (intro suminf_bound_add allI)
wenzelm@33536
   296
            fix n
hoelzl@47694
   297
            have UNION_in: "(\<Union>i\<in>{0..<n}. A i) \<in> M"
hoelzl@38656
   298
              by (metis A'' UNION_in_sets)
wenzelm@33536
   299
            have le_fa: "f (UNION {0..<n} A \<inter> a) \<le> f a" using A''
huffman@37032
   300
              by (blast intro: increasingD [OF inc] A'' UNION_in_sets)
hoelzl@47694
   301
            have ls: "(\<Union>i\<in>{0..<n}. A i) \<in> lambda_system \<Omega> M f"
hoelzl@42065
   302
              using ls.UNION_in_sets by (simp add: A)
hoelzl@38656
   303
            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
   304
              by (simp add: lambda_system_eq UNION_in)
wenzelm@33536
   305
            have "f (a - (\<Union>i. A i)) \<le> f (a - (\<Union>i\<in>{0..<n}. A i))"
haftmann@44106
   306
              by (blast intro: increasingD [OF inc] UNION_in U_in)
hoelzl@41981
   307
            thus "(\<Sum>i<n. f (a \<inter> A i)) + f (a - (\<Union>i. A i)) \<le> f a"
hoelzl@38656
   308
              by (simp add: lambda_system_strong_sum pos A disj eq_fa add_left_mono atLeast0LessThan[symmetric])
hoelzl@41981
   309
          next
hoelzl@47694
   310
            have "\<And>i. a \<inter> A i \<in> M" using A'' by auto
hoelzl@41981
   311
            then show "\<And>i. 0 \<le> f (a \<inter> A i)" using pos[unfolded positive_def] by auto
hoelzl@47694
   312
            have "\<And>i. a - (\<Union>i. A i) \<in> M" using A'' by auto
hoelzl@41981
   313
            then have "\<And>i. 0 \<le> f (a - (\<Union>i. A i))" using pos[unfolded positive_def] by auto
hoelzl@41981
   314
            then show "f (a - (\<Union>i. A i)) \<noteq> -\<infinity>" by auto
wenzelm@33536
   315
          qed
hoelzl@38656
   316
        ultimately show "f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i)) \<le> f a"
hoelzl@38656
   317
          by (rule order_trans)
paulson@33271
   318
      next
hoelzl@38656
   319
        have "f a \<le> f (a \<inter> (\<Union>i. A i) \<union> (a - (\<Union>i. A i)))"
huffman@37032
   320
          by (blast intro:  increasingD [OF inc] U_in)
wenzelm@33536
   321
        also have "... \<le>  f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i))"
huffman@37032
   322
          by (blast intro: subadditiveD [OF sa] U_in)
wenzelm@33536
   323
        finally show "f a \<le> f (a \<inter> (\<Union>i. A i)) + f (a - (\<Union>i. A i))" .
paulson@33271
   324
        qed
paulson@33271
   325
     qed
paulson@33271
   326
  }
paulson@33271
   327
  thus  ?thesis
hoelzl@38656
   328
    by (simp add: lambda_system_eq sums_iff U_eq U_in)
paulson@33271
   329
qed
paulson@33271
   330
paulson@33271
   331
lemma (in sigma_algebra) caratheodory_lemma:
paulson@33271
   332
  assumes oms: "outer_measure_space M f"
hoelzl@47694
   333
  defines "L \<equiv> lambda_system \<Omega> M f"
hoelzl@47694
   334
  shows "measure_space \<Omega> L f"
paulson@33271
   335
proof -
hoelzl@41689
   336
  have pos: "positive M f"
paulson@33271
   337
    by (metis oms outer_measure_space_def)
hoelzl@47694
   338
  have alg: "algebra \<Omega> L"
hoelzl@38656
   339
    using lambda_system_algebra [of f, OF pos]
hoelzl@47694
   340
    by (simp add: algebra_iff_Un L_def)
hoelzl@42065
   341
  then
hoelzl@47694
   342
  have "sigma_algebra \<Omega> L"
paulson@33271
   343
    using lambda_system_caratheodory [OF oms]
hoelzl@47694
   344
    by (simp add: sigma_algebra_disjoint_iff L_def)
hoelzl@38656
   345
  moreover
hoelzl@47694
   346
  have "countably_additive L f" "positive L f"
paulson@33271
   347
    using pos lambda_system_caratheodory [OF oms]
hoelzl@47694
   348
    by (auto simp add: lambda_system_sets L_def countably_additive_def positive_def)
hoelzl@38656
   349
  ultimately
paulson@33271
   350
  show ?thesis
hoelzl@47694
   351
    using pos by (simp add: measure_space_def)
hoelzl@38656
   352
qed
hoelzl@38656
   353
hoelzl@39096
   354
lemma inf_measure_nonempty:
hoelzl@47694
   355
  assumes f: "positive M f" and b: "b \<in> M" and a: "a \<subseteq> b" "{} \<in> M"
hoelzl@39096
   356
  shows "f b \<in> measure_set M f a"
hoelzl@39096
   357
proof -
hoelzl@41981
   358
  let ?A = "\<lambda>i::nat. (if i = 0 then b else {})"
hoelzl@41981
   359
  have "(\<Sum>i. f (?A i)) = (\<Sum>i<1::nat. f (?A i))"
hoelzl@47761
   360
    by (rule suminf_finite) (simp_all add: f[unfolded positive_def])
hoelzl@39096
   361
  also have "... = f b"
hoelzl@39096
   362
    by simp
hoelzl@41981
   363
  finally show ?thesis using assms
hoelzl@41981
   364
    by (auto intro!: exI [of _ ?A]
hoelzl@39096
   365
             simp: measure_set_def disjoint_family_on_def split_if_mem2 comp_def)
hoelzl@39096
   366
qed
hoelzl@39096
   367
hoelzl@42066
   368
lemma (in ring_of_sets) inf_measure_agrees:
hoelzl@41689
   369
  assumes posf: "positive M f" and ca: "countably_additive M f"
hoelzl@47694
   370
      and s: "s \<in> M"
paulson@33271
   371
  shows "Inf (measure_set M f s) = f s"
hoelzl@43920
   372
  unfolding Inf_ereal_def
hoelzl@38656
   373
proof (safe intro!: Greatest_equality)
paulson@33271
   374
  fix z
paulson@33271
   375
  assume z: "z \<in> measure_set M f s"
hoelzl@38656
   376
  from this obtain A where
hoelzl@47694
   377
    A: "range A \<subseteq> M" and disj: "disjoint_family A"
hoelzl@41981
   378
    and "s \<subseteq> (\<Union>x. A x)" and si: "(\<Sum>i. f (A i)) = z"
hoelzl@38656
   379
    by (auto simp add: measure_set_def comp_def)
paulson@33271
   380
  hence seq: "s = (\<Union>i. A i \<inter> s)" by blast
paulson@33271
   381
  have inc: "increasing M f"
paulson@33271
   382
    by (metis additive_increasing ca countably_additive_additive posf)
hoelzl@41981
   383
  have sums: "(\<Sum>i. f (A i \<inter> s)) = f (\<Union>i. A i \<inter> s)"
hoelzl@41981
   384
    proof (rule ca[unfolded countably_additive_def, rule_format])
hoelzl@47694
   385
      show "range (\<lambda>n. A n \<inter> s) \<subseteq> M" using A s
wenzelm@33536
   386
        by blast
paulson@33271
   387
      show "disjoint_family (\<lambda>n. A n \<inter> s)" using disj
hoelzl@35582
   388
        by (auto simp add: disjoint_family_on_def)
hoelzl@47694
   389
      show "(\<Union>i. A i \<inter> s) \<in> M" using A s
wenzelm@33536
   390
        by (metis UN_extend_simps(4) s seq)
paulson@33271
   391
    qed
hoelzl@41981
   392
  hence "f s = (\<Sum>i. f (A i \<inter> s))"
huffman@37032
   393
    using seq [symmetric] by (simp add: sums_iff)
hoelzl@41981
   394
  also have "... \<le> (\<Sum>i. f (A i))"
hoelzl@41981
   395
    proof (rule suminf_le_pos)
hoelzl@41981
   396
      fix n show "f (A n \<inter> s) \<le> f (A n)" using A s
hoelzl@38656
   397
        by (force intro: increasingD [OF inc])
hoelzl@47694
   398
      fix N have "A N \<inter> s \<in> M"  using A s by auto
hoelzl@41981
   399
      then show "0 \<le> f (A N \<inter> s)" using posf unfolding positive_def by auto
paulson@33271
   400
    qed
hoelzl@38656
   401
  also have "... = z" by (rule si)
paulson@33271
   402
  finally show "f s \<le> z" .
paulson@33271
   403
next
paulson@33271
   404
  fix y
hoelzl@38656
   405
  assume y: "\<forall>u \<in> measure_set M f s. y \<le> u"
paulson@33271
   406
  thus "y \<le> f s"
hoelzl@41689
   407
    by (blast intro: inf_measure_nonempty [of _ f, OF posf s subset_refl])
paulson@33271
   408
qed
paulson@33271
   409
hoelzl@41981
   410
lemma measure_set_pos:
hoelzl@41981
   411
  assumes posf: "positive M f" "r \<in> measure_set M f X"
hoelzl@41981
   412
  shows "0 \<le> r"
hoelzl@41981
   413
proof -
hoelzl@47694
   414
  obtain A where "range A \<subseteq> M" and r: "r = (\<Sum>i. f (A i))"
hoelzl@41981
   415
    using `r \<in> measure_set M f X` unfolding measure_set_def by auto
hoelzl@41981
   416
  then show "0 \<le> r" using posf unfolding r positive_def
hoelzl@41981
   417
    by (intro suminf_0_le) auto
hoelzl@41981
   418
qed
hoelzl@41981
   419
hoelzl@41981
   420
lemma inf_measure_pos:
hoelzl@41981
   421
  assumes posf: "positive M f"
hoelzl@41981
   422
  shows "0 \<le> Inf (measure_set M f X)"
hoelzl@41981
   423
proof (rule complete_lattice_class.Inf_greatest)
hoelzl@41981
   424
  fix r assume "r \<in> measure_set M f X" with posf show "0 \<le> r"
hoelzl@41981
   425
    by (rule measure_set_pos)
hoelzl@41981
   426
qed
hoelzl@41981
   427
hoelzl@41689
   428
lemma inf_measure_empty:
hoelzl@47694
   429
  assumes posf: "positive M f" and "{} \<in> M"
paulson@33271
   430
  shows "Inf (measure_set M f {}) = 0"
paulson@33271
   431
proof (rule antisym)
paulson@33271
   432
  show "Inf (measure_set M f {}) \<le> 0"
hoelzl@47694
   433
    by (metis complete_lattice_class.Inf_lower `{} \<in> M`
hoelzl@41689
   434
              inf_measure_nonempty[OF posf] subset_refl posf[unfolded positive_def])
hoelzl@41981
   435
qed (rule inf_measure_pos[OF posf])
paulson@33271
   436
hoelzl@42066
   437
lemma (in ring_of_sets) inf_measure_positive:
hoelzl@47694
   438
  assumes p: "positive M f" and "{} \<in> M"
hoelzl@41981
   439
  shows "positive M (\<lambda>x. Inf (measure_set M f x))"
hoelzl@41981
   440
proof (unfold positive_def, intro conjI ballI)
hoelzl@41981
   441
  show "Inf (measure_set M f {}) = 0" using inf_measure_empty[OF assms] by auto
hoelzl@47694
   442
  fix A assume "A \<in> M"
hoelzl@41981
   443
qed (rule inf_measure_pos[OF p])
paulson@33271
   444
hoelzl@42066
   445
lemma (in ring_of_sets) inf_measure_increasing:
hoelzl@41689
   446
  assumes posf: "positive M f"
hoelzl@47694
   447
  shows "increasing (Pow \<Omega>) (\<lambda>x. Inf (measure_set M f x))"
noschinl@44918
   448
apply (clarsimp simp add: increasing_def)
hoelzl@38656
   449
apply (rule complete_lattice_class.Inf_greatest)
hoelzl@38656
   450
apply (rule complete_lattice_class.Inf_lower)
huffman@37032
   451
apply (clarsimp simp add: measure_set_def, rule_tac x=A in exI, blast)
paulson@33271
   452
done
paulson@33271
   453
hoelzl@42066
   454
lemma (in ring_of_sets) inf_measure_le:
hoelzl@41689
   455
  assumes posf: "positive M f" and inc: "increasing M f"
hoelzl@47694
   456
      and x: "x \<in> {r . \<exists>A. range A \<subseteq> M \<and> s \<subseteq> (\<Union>i. A i) \<and> (\<Sum>i. f (A i)) = r}"
paulson@33271
   457
  shows "Inf (measure_set M f s) \<le> x"
paulson@33271
   458
proof -
hoelzl@47694
   459
  obtain A where A: "range A \<subseteq> M" and ss: "s \<subseteq> (\<Union>i. A i)"
hoelzl@41981
   460
             and xeq: "(\<Sum>i. f (A i)) = x"
hoelzl@41981
   461
    using x by auto
hoelzl@47694
   462
  have dA: "range (disjointed A) \<subseteq> M"
paulson@33271
   463
    by (metis A range_disjointed_sets)
hoelzl@41981
   464
  have "\<forall>n. f (disjointed A n) \<le> f (A n)"
hoelzl@38656
   465
    by (metis increasingD [OF inc] UNIV_I dA image_subset_iff disjointed_subset A comp_def)
hoelzl@41981
   466
  moreover have "\<forall>i. 0 \<le> f (disjointed A i)"
hoelzl@41981
   467
    using posf dA unfolding positive_def by auto
hoelzl@41981
   468
  ultimately have sda: "(\<Sum>i. f (disjointed A i)) \<le> (\<Sum>i. f (A i))"
hoelzl@41981
   469
    by (blast intro!: suminf_le_pos)
hoelzl@41981
   470
  hence ley: "(\<Sum>i. f (disjointed A i)) \<le> x"
hoelzl@38656
   471
    by (metis xeq)
hoelzl@41981
   472
  hence y: "(\<Sum>i. f (disjointed A i)) \<in> measure_set M f s"
paulson@33271
   473
    apply (auto simp add: measure_set_def)
hoelzl@38656
   474
    apply (rule_tac x="disjointed A" in exI)
hoelzl@38656
   475
    apply (simp add: disjoint_family_disjointed UN_disjointed_eq ss dA comp_def)
paulson@33271
   476
    done
paulson@33271
   477
  show ?thesis
hoelzl@38656
   478
    by (blast intro: y order_trans [OF _ ley] posf complete_lattice_class.Inf_lower)
paulson@33271
   479
qed
paulson@33271
   480
hoelzl@42066
   481
lemma (in ring_of_sets) inf_measure_close:
hoelzl@43920
   482
  fixes e :: ereal
hoelzl@47694
   483
  assumes posf: "positive M f" and e: "0 < e" and ss: "s \<subseteq> (\<Omega>)" and "Inf (measure_set M f s) \<noteq> \<infinity>"
hoelzl@47694
   484
  shows "\<exists>A. range A \<subseteq> M \<and> disjoint_family A \<and> s \<subseteq> (\<Union>i. A i) \<and>
hoelzl@41981
   485
               (\<Sum>i. f (A i)) \<le> Inf (measure_set M f s) + e"
hoelzl@42066
   486
proof -
hoelzl@42066
   487
  from `Inf (measure_set M f s) \<noteq> \<infinity>` have fin: "\<bar>Inf (measure_set M f s)\<bar> \<noteq> \<infinity>"
hoelzl@41981
   488
    using inf_measure_pos[OF posf, of s] by auto
hoelzl@38656
   489
  obtain l where "l \<in> measure_set M f s" "l \<le> Inf (measure_set M f s) + e"
hoelzl@43920
   490
    using Inf_ereal_close[OF fin e] by auto
hoelzl@38656
   491
  thus ?thesis
hoelzl@38656
   492
    by (auto intro!: exI[of _ l] simp: measure_set_def comp_def)
paulson@33271
   493
qed
paulson@33271
   494
hoelzl@42066
   495
lemma (in ring_of_sets) inf_measure_countably_subadditive:
hoelzl@41689
   496
  assumes posf: "positive M f" and inc: "increasing M f"
hoelzl@47694
   497
  shows "countably_subadditive (Pow \<Omega>) (\<lambda>x. Inf (measure_set M f x))"
hoelzl@42066
   498
proof (simp add: countably_subadditive_def, safe)
hoelzl@42066
   499
  fix A :: "nat \<Rightarrow> 'a set"
wenzelm@46731
   500
  let ?outer = "\<lambda>B. Inf (measure_set M f B)"
hoelzl@47694
   501
  assume A: "range A \<subseteq> Pow (\<Omega>)"
hoelzl@38656
   502
     and disj: "disjoint_family A"
hoelzl@47694
   503
     and sb: "(\<Union>i. A i) \<subseteq> \<Omega>"
hoelzl@42066
   504
hoelzl@43920
   505
  { fix e :: ereal assume e: "0 < e" and "\<forall>i. ?outer (A i) \<noteq> \<infinity>"
hoelzl@47694
   506
    hence "\<exists>BB. \<forall>n. range (BB n) \<subseteq> M \<and> disjoint_family (BB n) \<and>
hoelzl@42066
   507
        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
   508
      apply (safe intro!: choice inf_measure_close [of f, OF posf])
hoelzl@43920
   509
      using e sb by (auto simp: ereal_zero_less_0_iff one_ereal_def)
hoelzl@42066
   510
    then obtain BB
hoelzl@47694
   511
      where BB: "\<And>n. (range (BB n) \<subseteq> M)"
hoelzl@38656
   512
      and disjBB: "\<And>n. disjoint_family (BB n)"
hoelzl@38656
   513
      and sbBB: "\<And>n. A n \<subseteq> (\<Union>i. BB n i)"
hoelzl@42066
   514
      and BBle: "\<And>n. (\<Sum>i. f (BB n i)) \<le> ?outer (A n) + e * (1/2)^(Suc n)"
hoelzl@42066
   515
      by auto blast
hoelzl@42066
   516
    have sll: "(\<Sum>n. \<Sum>i. (f (BB n i))) \<le> (\<Sum>n. ?outer (A n)) + e"
hoelzl@38656
   517
    proof -
hoelzl@41981
   518
      have sum_eq_1: "(\<Sum>n. e*(1/2) ^ Suc n) = e"
hoelzl@43920
   519
        using suminf_half_series_ereal e
hoelzl@43920
   520
        by (simp add: ereal_zero_le_0_iff zero_le_divide_ereal suminf_cmult_ereal)
hoelzl@41981
   521
      have "\<And>n i. 0 \<le> f (BB n i)" using posf[unfolded positive_def] BB by auto
hoelzl@41981
   522
      then have "\<And>n. 0 \<le> (\<Sum>i. f (BB n i))" by (rule suminf_0_le)
hoelzl@42066
   523
      then have "(\<Sum>n. \<Sum>i. (f (BB n i))) \<le> (\<Sum>n. ?outer (A n) + e*(1/2) ^ Suc n)"
hoelzl@41981
   524
        by (rule suminf_le_pos[OF BBle])
hoelzl@42066
   525
      also have "... = (\<Sum>n. ?outer (A n)) + e"
hoelzl@41981
   526
        using sum_eq_1 inf_measure_pos[OF posf] e
hoelzl@43920
   527
        by (subst suminf_add_ereal) (auto simp add: ereal_zero_le_0_iff)
hoelzl@38656
   528
      finally show ?thesis .
hoelzl@38656
   529
    qed
hoelzl@42066
   530
    def C \<equiv> "(split BB) o prod_decode"
hoelzl@47694
   531
    have C: "!!n. C n \<in> M"
hoelzl@42066
   532
      apply (rule_tac p="prod_decode n" in PairE)
hoelzl@42066
   533
      apply (simp add: C_def)
hoelzl@42066
   534
      apply (metis BB subsetD rangeI)
hoelzl@42066
   535
      done
hoelzl@42066
   536
    have sbC: "(\<Union>i. A i) \<subseteq> (\<Union>i. C i)"
hoelzl@38656
   537
    proof (auto simp add: C_def)
hoelzl@38656
   538
      fix x i
hoelzl@38656
   539
      assume x: "x \<in> A i"
hoelzl@38656
   540
      with sbBB [of i] obtain j where "x \<in> BB i j"
hoelzl@38656
   541
        by blast
hoelzl@38656
   542
      thus "\<exists>i. x \<in> split BB (prod_decode i)"
hoelzl@38656
   543
        by (metis prod_encode_inverse prod.cases)
hoelzl@38656
   544
    qed
hoelzl@42066
   545
    have "(f \<circ> C) = (f \<circ> (\<lambda>(x, y). BB x y)) \<circ> prod_decode"
hoelzl@42066
   546
      by (rule ext)  (auto simp add: C_def)
hoelzl@42066
   547
    moreover have "suminf ... = (\<Sum>n. \<Sum>i. f (BB n i))" using BBle
hoelzl@42066
   548
      using BB posf[unfolded positive_def]
hoelzl@43920
   549
      by (force intro!: suminf_ereal_2dimen simp: o_def)
hoelzl@42066
   550
    ultimately have Csums: "(\<Sum>i. f (C i)) = (\<Sum>n. \<Sum>i. f (BB n i))" by (simp add: o_def)
hoelzl@42066
   551
    have "?outer (\<Union>i. A i) \<le> (\<Sum>n. \<Sum>i. f (BB n i))"
hoelzl@42066
   552
      apply (rule inf_measure_le [OF posf(1) inc], auto)
hoelzl@42066
   553
      apply (rule_tac x="C" in exI)
hoelzl@42066
   554
      apply (auto simp add: C sbC Csums)
hoelzl@42066
   555
      done
hoelzl@42066
   556
    also have "... \<le> (\<Sum>n. ?outer (A n)) + e" using sll
hoelzl@42066
   557
      by blast
hoelzl@42066
   558
    finally have "?outer (\<Union>i. A i) \<le> (\<Sum>n. ?outer (A n)) + e" . }
hoelzl@42066
   559
  note for_finite_Inf = this
hoelzl@42066
   560
hoelzl@42066
   561
  show "?outer (\<Union>i. A i) \<le> (\<Sum>n. ?outer (A n))"
hoelzl@42066
   562
  proof cases
hoelzl@42066
   563
    assume "\<forall>i. ?outer (A i) \<noteq> \<infinity>"
hoelzl@42066
   564
    with for_finite_Inf show ?thesis
hoelzl@43920
   565
      by (intro ereal_le_epsilon) auto
hoelzl@42066
   566
  next
hoelzl@42066
   567
    assume "\<not> (\<forall>i. ?outer (A i) \<noteq> \<infinity>)"
hoelzl@42066
   568
    then have "\<exists>i. ?outer (A i) = \<infinity>"
hoelzl@42066
   569
      by auto
hoelzl@42066
   570
    then have "(\<Sum>n. ?outer (A n)) = \<infinity>"
hoelzl@42066
   571
      using suminf_PInfty[OF inf_measure_pos, OF posf]
hoelzl@42066
   572
      by metis
hoelzl@42066
   573
    then show ?thesis by simp
hoelzl@42066
   574
  qed
paulson@33271
   575
qed
paulson@33271
   576
hoelzl@42066
   577
lemma (in ring_of_sets) inf_measure_outer:
hoelzl@47694
   578
  "\<lbrakk> positive M f ; increasing M f \<rbrakk> \<Longrightarrow>
hoelzl@47694
   579
    outer_measure_space (Pow \<Omega>) (\<lambda>x. Inf (measure_set M f x))"
hoelzl@41981
   580
  using inf_measure_pos[of M f]
hoelzl@38656
   581
  by (simp add: outer_measure_space_def inf_measure_empty
hoelzl@38656
   582
                inf_measure_increasing inf_measure_countably_subadditive positive_def)
paulson@33271
   583
hoelzl@42066
   584
lemma (in ring_of_sets) algebra_subset_lambda_system:
hoelzl@41689
   585
  assumes posf: "positive M f" and inc: "increasing M f"
paulson@33271
   586
      and add: "additive M f"
hoelzl@47694
   587
  shows "M \<subseteq> lambda_system \<Omega> (Pow \<Omega>) (\<lambda>x. Inf (measure_set M f x))"
hoelzl@38656
   588
proof (auto dest: sets_into_space
hoelzl@38656
   589
            simp add: algebra.lambda_system_eq [OF algebra_Pow])
paulson@33271
   590
  fix x s
hoelzl@47694
   591
  assume x: "x \<in> M"
hoelzl@47694
   592
     and s: "s \<subseteq> \<Omega>"
hoelzl@47694
   593
  have [simp]: "!!x. x \<in> M \<Longrightarrow> s \<inter> (\<Omega> - x) = s-x" using s
paulson@33271
   594
    by blast
paulson@33271
   595
  have "Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))
paulson@33271
   596
        \<le> Inf (measure_set M f s)"
hoelzl@42066
   597
  proof cases
hoelzl@42066
   598
    assume "Inf (measure_set M f s) = \<infinity>" then show ?thesis by simp
hoelzl@42066
   599
  next
hoelzl@42066
   600
    assume fin: "Inf (measure_set M f s) \<noteq> \<infinity>"
hoelzl@42066
   601
    then have "measure_set M f s \<noteq> {}"
hoelzl@43920
   602
      by (auto simp: top_ereal_def)
hoelzl@42066
   603
    show ?thesis
hoelzl@42066
   604
    proof (rule complete_lattice_class.Inf_greatest)
hoelzl@42066
   605
      fix r assume "r \<in> measure_set M f s"
hoelzl@47694
   606
      then obtain A where A: "disjoint_family A" "range A \<subseteq> M" "s \<subseteq> (\<Union>i. A i)"
hoelzl@42066
   607
        and r: "r = (\<Sum>i. f (A i))" unfolding measure_set_def by auto
hoelzl@42066
   608
      have "Inf (measure_set M f (s \<inter> x)) \<le> (\<Sum>i. f (A i \<inter> x))"
hoelzl@42066
   609
        unfolding measure_set_def
hoelzl@42066
   610
      proof (safe intro!: complete_lattice_class.Inf_lower exI[of _ "\<lambda>i. A i \<inter> x"])
hoelzl@42066
   611
        from A(1) show "disjoint_family (\<lambda>i. A i \<inter> x)"
hoelzl@42066
   612
          by (rule disjoint_family_on_bisimulation) auto
hoelzl@42066
   613
      qed (insert x A, auto)
hoelzl@42066
   614
      moreover
hoelzl@42066
   615
      have "Inf (measure_set M f (s - x)) \<le> (\<Sum>i. f (A i - x))"
hoelzl@42066
   616
        unfolding measure_set_def
hoelzl@42066
   617
      proof (safe intro!: complete_lattice_class.Inf_lower exI[of _ "\<lambda>i. A i - x"])
hoelzl@42066
   618
        from A(1) show "disjoint_family (\<lambda>i. A i - x)"
hoelzl@42066
   619
          by (rule disjoint_family_on_bisimulation) auto
hoelzl@42066
   620
      qed (insert x A, auto)
hoelzl@42066
   621
      ultimately have "Inf (measure_set M f (s \<inter> x)) + Inf (measure_set M f (s - x)) \<le>
hoelzl@42066
   622
          (\<Sum>i. f (A i \<inter> x)) + (\<Sum>i. f (A i - x))" by (rule add_mono)
hoelzl@42066
   623
      also have "\<dots> = (\<Sum>i. f (A i \<inter> x) + f (A i - x))"
hoelzl@43920
   624
        using A(2) x posf by (subst suminf_add_ereal) (auto simp: positive_def)
hoelzl@42066
   625
      also have "\<dots> = (\<Sum>i. f (A i))"
hoelzl@42066
   626
        using A x
hoelzl@42066
   627
        by (subst add[THEN additiveD, symmetric])
hoelzl@42066
   628
           (auto intro!: arg_cong[where f=suminf] arg_cong[where f=f])
hoelzl@42066
   629
      finally show "Inf (measure_set M f (s \<inter> x)) + Inf (measure_set M f (s - x)) \<le> r"
hoelzl@42066
   630
        using r by simp
paulson@33271
   631
    qed
hoelzl@42066
   632
  qed
hoelzl@38656
   633
  moreover
paulson@33271
   634
  have "Inf (measure_set M f s)
paulson@33271
   635
       \<le> Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))"
hoelzl@42145
   636
  proof -
paulson@33271
   637
    have "Inf (measure_set M f s) = Inf (measure_set M f ((s\<inter>x) \<union> (s-x)))"
paulson@33271
   638
      by (metis Un_Diff_Int Un_commute)
hoelzl@38656
   639
    also have "... \<le> Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))"
hoelzl@38656
   640
      apply (rule subadditiveD)
hoelzl@42145
   641
      apply (rule ring_of_sets.countably_subadditive_subadditive [OF ring_of_sets_Pow])
hoelzl@41981
   642
      apply (simp add: positive_def inf_measure_empty[OF posf] inf_measure_pos[OF posf])
hoelzl@41689
   643
      apply (rule inf_measure_countably_subadditive)
hoelzl@41689
   644
      using s by (auto intro!: posf inc)
paulson@33271
   645
    finally show ?thesis .
hoelzl@42145
   646
  qed
hoelzl@38656
   647
  ultimately
paulson@33271
   648
  show "Inf (measure_set M f (s\<inter>x)) + Inf (measure_set M f (s-x))
paulson@33271
   649
        = Inf (measure_set M f s)"
paulson@33271
   650
    by (rule order_antisym)
paulson@33271
   651
qed
paulson@33271
   652
paulson@33271
   653
lemma measure_down:
hoelzl@47694
   654
  "measure_space \<Omega> N \<mu> \<Longrightarrow> sigma_algebra \<Omega> M \<Longrightarrow> M \<subseteq> N \<Longrightarrow> measure_space \<Omega> M \<mu>"
hoelzl@47694
   655
  by (simp add: measure_space_def positive_def countably_additive_def)
paulson@33271
   656
     blast
paulson@33271
   657
hoelzl@42066
   658
theorem (in ring_of_sets) caratheodory:
hoelzl@41689
   659
  assumes posf: "positive M f" and ca: "countably_additive M f"
hoelzl@47694
   660
  shows "\<exists>\<mu> :: 'a set \<Rightarrow> ereal. (\<forall>s \<in> M. \<mu> s = f s) \<and> measure_space \<Omega> (sigma_sets \<Omega> M) \<mu>"
hoelzl@41689
   661
proof -
hoelzl@41689
   662
  have inc: "increasing M f"
hoelzl@41689
   663
    by (metis additive_increasing ca countably_additive_additive posf)
hoelzl@41689
   664
  let ?infm = "(\<lambda>x. Inf (measure_set M f x))"
hoelzl@47694
   665
  def ls \<equiv> "lambda_system \<Omega> (Pow \<Omega>) ?infm"
hoelzl@47694
   666
  have mls: "measure_space \<Omega> ls ?infm"
hoelzl@41689
   667
    using sigma_algebra.caratheodory_lemma
hoelzl@41689
   668
            [OF sigma_algebra_Pow  inf_measure_outer [OF posf inc]]
hoelzl@41689
   669
    by (simp add: ls_def)
hoelzl@47694
   670
  hence sls: "sigma_algebra \<Omega> ls"
hoelzl@41689
   671
    by (simp add: measure_space_def)
hoelzl@47694
   672
  have "M \<subseteq> ls"
hoelzl@41689
   673
    by (simp add: ls_def)
hoelzl@41689
   674
       (metis ca posf inc countably_additive_additive algebra_subset_lambda_system)
hoelzl@47694
   675
  hence sgs_sb: "sigma_sets (\<Omega>) (M) \<subseteq> ls"
hoelzl@47694
   676
    using sigma_algebra.sigma_sets_subset [OF sls, of "M"]
hoelzl@41689
   677
    by simp
hoelzl@47694
   678
  have "measure_space \<Omega> (sigma_sets \<Omega> M) ?infm"
hoelzl@41689
   679
    by (rule measure_down [OF mls], rule sigma_algebra_sigma_sets)
hoelzl@41689
   680
       (simp_all add: sgs_sb space_closed)
hoelzl@41689
   681
  thus ?thesis using inf_measure_agrees [OF posf ca]
hoelzl@41689
   682
    by (intro exI[of _ ?infm]) auto
hoelzl@41689
   683
qed
paulson@33271
   684
hoelzl@42145
   685
subsubsection {*Alternative instances of caratheodory*}
hoelzl@42145
   686
hoelzl@42145
   687
lemma (in ring_of_sets) countably_additive_iff_continuous_from_below:
hoelzl@42145
   688
  assumes f: "positive M f" "additive M f"
hoelzl@42145
   689
  shows "countably_additive M f \<longleftrightarrow>
hoelzl@47694
   690
    (\<forall>A. range A \<subseteq> M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Union>i. A i))"
hoelzl@42145
   691
  unfolding countably_additive_def
hoelzl@42145
   692
proof safe
hoelzl@47694
   693
  assume count_sum: "\<forall>A. range A \<subseteq> M \<longrightarrow> disjoint_family A \<longrightarrow> UNION UNIV A \<in> M \<longrightarrow> (\<Sum>i. f (A i)) = f (UNION UNIV A)"
hoelzl@47694
   694
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "incseq A" "(\<Union>i. A i) \<in> M"
hoelzl@47694
   695
  then have dA: "range (disjointed A) \<subseteq> M" by (auto simp: range_disjointed_sets)
hoelzl@42145
   696
  with count_sum[THEN spec, of "disjointed A"] A(3)
hoelzl@42145
   697
  have f_UN: "(\<Sum>i. f (disjointed A i)) = f (\<Union>i. A i)"
hoelzl@42145
   698
    by (auto simp: UN_disjointed_eq disjoint_family_disjointed)
hoelzl@42145
   699
  moreover have "(\<lambda>n. (\<Sum>i=0..<n. f (disjointed A i))) ----> (\<Sum>i. f (disjointed A i))"
hoelzl@42145
   700
    using f(1)[unfolded positive_def] dA
hoelzl@43920
   701
    by (auto intro!: summable_sumr_LIMSEQ_suminf summable_ereal_pos)
hoelzl@42145
   702
  from LIMSEQ_Suc[OF this]
hoelzl@42145
   703
  have "(\<lambda>n. (\<Sum>i\<le>n. f (disjointed A i))) ----> (\<Sum>i. f (disjointed A i))"
hoelzl@42145
   704
    unfolding atLeastLessThanSuc_atLeastAtMost atLeast0AtMost .
hoelzl@42145
   705
  moreover have "\<And>n. (\<Sum>i\<le>n. f (disjointed A i)) = f (A n)"
hoelzl@42145
   706
    using disjointed_additive[OF f A(1,2)] .
hoelzl@42145
   707
  ultimately show "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)" by simp
hoelzl@42145
   708
next
hoelzl@47694
   709
  assume cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> incseq A \<longrightarrow> (\<Union>i. A i) \<in> M \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@47694
   710
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "disjoint_family A" "(\<Union>i. A i) \<in> M"
hoelzl@42145
   711
  have *: "(\<Union>n. (\<Union>i\<le>n. A i)) = (\<Union>i. A i)" by auto
hoelzl@42145
   712
  have "(\<lambda>n. f (\<Union>i\<le>n. A i)) ----> f (\<Union>i. A i)"
hoelzl@42145
   713
  proof (unfold *[symmetric], intro cont[rule_format])
hoelzl@47694
   714
    show "range (\<lambda>i. \<Union> i\<le>i. A i) \<subseteq> M" "(\<Union>i. \<Union> i\<le>i. A i) \<in> M"
hoelzl@42145
   715
      using A * by auto
hoelzl@42145
   716
  qed (force intro!: incseq_SucI)
hoelzl@42145
   717
  moreover have "\<And>n. f (\<Union>i\<le>n. A i) = (\<Sum>i\<le>n. f (A i))"
hoelzl@42145
   718
    using A
hoelzl@42145
   719
    by (intro additive_sum[OF f, of _ A, symmetric])
hoelzl@42145
   720
       (auto intro: disjoint_family_on_mono[where B=UNIV])
hoelzl@42145
   721
  ultimately
hoelzl@42145
   722
  have "(\<lambda>i. f (A i)) sums f (\<Union>i. A i)"
hoelzl@42145
   723
    unfolding sums_def2 by simp
hoelzl@42145
   724
  from sums_unique[OF this]
hoelzl@42145
   725
  show "(\<Sum>i. f (A i)) = f (\<Union>i. A i)" by simp
hoelzl@42145
   726
qed
hoelzl@42145
   727
hoelzl@42145
   728
lemma (in ring_of_sets) continuous_from_above_iff_empty_continuous:
hoelzl@42145
   729
  assumes f: "positive M f" "additive M f"
hoelzl@47694
   730
  shows "(\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) \<in> M \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Inter>i. A i))
hoelzl@47694
   731
     \<longleftrightarrow> (\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> 0)"
hoelzl@42145
   732
proof safe
hoelzl@47694
   733
  assume cont: "(\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) \<in> M \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> f (\<Inter>i. A i))"
hoelzl@47694
   734
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "decseq A" "(\<Inter>i. A i) = {}" "\<forall>i. f (A i) \<noteq> \<infinity>"
hoelzl@42145
   735
  with cont[THEN spec, of A] show "(\<lambda>i. f (A i)) ----> 0"
hoelzl@42145
   736
    using `positive M f`[unfolded positive_def] by auto
hoelzl@42145
   737
next
hoelzl@47694
   738
  assume cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<forall>i. f (A i) \<noteq> \<infinity>) \<longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@47694
   739
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> M" "decseq A" "(\<Inter>i. A i) \<in> M" "\<forall>i. f (A i) \<noteq> \<infinity>"
hoelzl@42145
   740
hoelzl@47694
   741
  have f_mono: "\<And>a b. a \<in> M \<Longrightarrow> b \<in> M \<Longrightarrow> a \<subseteq> b \<Longrightarrow> f a \<le> f b"
hoelzl@42145
   742
    using additive_increasing[OF f] unfolding increasing_def by simp
hoelzl@42145
   743
hoelzl@42145
   744
  have decseq_fA: "decseq (\<lambda>i. f (A i))"
hoelzl@42145
   745
    using A by (auto simp: decseq_def intro!: f_mono)
hoelzl@42145
   746
  have decseq: "decseq (\<lambda>i. A i - (\<Inter>i. A i))"
hoelzl@42145
   747
    using A by (auto simp: decseq_def)
hoelzl@42145
   748
  then have decseq_f: "decseq (\<lambda>i. f (A i - (\<Inter>i. A i)))"
hoelzl@42145
   749
    using A unfolding decseq_def by (auto intro!: f_mono Diff)
hoelzl@42145
   750
  have "f (\<Inter>x. A x) \<le> f (A 0)"
hoelzl@42145
   751
    using A by (auto intro!: f_mono)
hoelzl@42145
   752
  then have f_Int_fin: "f (\<Inter>x. A x) \<noteq> \<infinity>"
hoelzl@42145
   753
    using A by auto
hoelzl@42145
   754
  { fix i
hoelzl@42145
   755
    have "f (A i - (\<Inter>i. A i)) \<le> f (A i)" using A by (auto intro!: f_mono)
hoelzl@42145
   756
    then have "f (A i - (\<Inter>i. A i)) \<noteq> \<infinity>"
hoelzl@42145
   757
      using A by auto }
hoelzl@42145
   758
  note f_fin = this
hoelzl@42145
   759
  have "(\<lambda>i. f (A i - (\<Inter>i. A i))) ----> 0"
hoelzl@42145
   760
  proof (intro cont[rule_format, OF _ decseq _ f_fin])
hoelzl@47694
   761
    show "range (\<lambda>i. A i - (\<Inter>i. A i)) \<subseteq> M" "(\<Inter>i. A i - (\<Inter>i. A i)) = {}"
hoelzl@42145
   762
      using A by auto
hoelzl@42145
   763
  qed
hoelzl@43920
   764
  from INF_Lim_ereal[OF decseq_f this]
hoelzl@42145
   765
  have "(INF n. f (A n - (\<Inter>i. A i))) = 0" .
hoelzl@42145
   766
  moreover have "(INF n. f (\<Inter>i. A i)) = f (\<Inter>i. A i)"
hoelzl@42145
   767
    by auto
hoelzl@42145
   768
  ultimately have "(INF n. f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i)) = 0 + f (\<Inter>i. A i)"
hoelzl@42145
   769
    using A(4) f_fin f_Int_fin
hoelzl@43920
   770
    by (subst INFI_ereal_add) (auto simp: decseq_f)
hoelzl@42145
   771
  moreover {
hoelzl@42145
   772
    fix n
hoelzl@42145
   773
    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
   774
      using A by (subst f(2)[THEN additiveD]) auto
hoelzl@42145
   775
    also have "(A n - (\<Inter>i. A i)) \<union> (\<Inter>i. A i) = A n"
hoelzl@42145
   776
      by auto
hoelzl@42145
   777
    finally have "f (A n - (\<Inter>i. A i)) + f (\<Inter>i. A i) = f (A n)" . }
hoelzl@42145
   778
  ultimately have "(INF n. f (A n)) = f (\<Inter>i. A i)"
hoelzl@42145
   779
    by simp
hoelzl@43920
   780
  with LIMSEQ_ereal_INFI[OF decseq_fA]
hoelzl@42145
   781
  show "(\<lambda>i. f (A i)) ----> f (\<Inter>i. A i)" by simp
hoelzl@42145
   782
qed
hoelzl@42145
   783
hoelzl@42145
   784
lemma positiveD1: "positive M f \<Longrightarrow> f {} = 0" by (auto simp: positive_def)
hoelzl@47694
   785
lemma positiveD2: "positive M f \<Longrightarrow> A \<in> M \<Longrightarrow> 0 \<le> f A" by (auto simp: positive_def)
hoelzl@42145
   786
hoelzl@42145
   787
lemma (in ring_of_sets) empty_continuous_imp_continuous_from_below:
hoelzl@47694
   788
  assumes f: "positive M f" "additive M f" "\<forall>A\<in>M. f A \<noteq> \<infinity>"
hoelzl@47694
   789
  assumes cont: "\<forall>A. range A \<subseteq> M \<longrightarrow> decseq A \<longrightarrow> (\<Inter>i. A i) = {} \<longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@47694
   790
  assumes A: "range A \<subseteq> M" "incseq A" "(\<Union>i. A i) \<in> M"
hoelzl@42145
   791
  shows "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@42145
   792
proof -
hoelzl@47694
   793
  have "\<forall>A\<in>M. \<exists>x. f A = ereal x"
hoelzl@42145
   794
  proof
hoelzl@47694
   795
    fix A assume "A \<in> M" with f show "\<exists>x. f A = ereal x"
hoelzl@42145
   796
      unfolding positive_def by (cases "f A") auto
hoelzl@42145
   797
  qed
hoelzl@42145
   798
  from bchoice[OF this] guess f' .. note f' = this[rule_format]
hoelzl@42145
   799
  from A have "(\<lambda>i. f ((\<Union>i. A i) - A i)) ----> 0"
hoelzl@42145
   800
    by (intro cont[rule_format]) (auto simp: decseq_def incseq_def)
hoelzl@42145
   801
  moreover
hoelzl@42145
   802
  { fix i
hoelzl@42145
   803
    have "f ((\<Union>i. A i) - A i) + f (A i) = f ((\<Union>i. A i) - A i \<union> A i)"
hoelzl@42145
   804
      using A by (intro f(2)[THEN additiveD, symmetric]) auto
hoelzl@42145
   805
    also have "(\<Union>i. A i) - A i \<union> A i = (\<Union>i. A i)"
hoelzl@42145
   806
      by auto
hoelzl@42145
   807
    finally have "f' (\<Union>i. A i) - f' (A i) = f' ((\<Union>i. A i) - A i)"
hoelzl@42145
   808
      using A by (subst (asm) (1 2 3) f') auto
hoelzl@43920
   809
    then have "f ((\<Union>i. A i) - A i) = ereal (f' (\<Union>i. A i) - f' (A i))"
hoelzl@42145
   810
      using A f' by auto }
hoelzl@42145
   811
  ultimately have "(\<lambda>i. f' (\<Union>i. A i) - f' (A i)) ----> 0"
hoelzl@43920
   812
    by (simp add: zero_ereal_def)
hoelzl@42145
   813
  then have "(\<lambda>i. f' (A i)) ----> f' (\<Union>i. A i)"
huffman@44568
   814
    by (rule LIMSEQ_diff_approach_zero2[OF tendsto_const])
hoelzl@42145
   815
  then show "(\<lambda>i. f (A i)) ----> f (\<Union>i. A i)"
hoelzl@42145
   816
    using A by (subst (1 2) f') auto
hoelzl@42145
   817
qed
hoelzl@42145
   818
hoelzl@42145
   819
lemma (in ring_of_sets) empty_continuous_imp_countably_additive:
hoelzl@47694
   820
  assumes f: "positive M f" "additive M f" and fin: "\<forall>A\<in>M. f A \<noteq> \<infinity>"
hoelzl@47694
   821
  assumes cont: "\<And>A. range A \<subseteq> M \<Longrightarrow> decseq A \<Longrightarrow> (\<Inter>i. A i) = {} \<Longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@42145
   822
  shows "countably_additive M f"
hoelzl@42145
   823
  using countably_additive_iff_continuous_from_below[OF f]
hoelzl@42145
   824
  using empty_continuous_imp_continuous_from_below[OF f fin] cont
hoelzl@42145
   825
  by blast
hoelzl@42145
   826
hoelzl@42145
   827
lemma (in ring_of_sets) caratheodory_empty_continuous:
hoelzl@47694
   828
  assumes f: "positive M f" "additive M f" and fin: "\<And>A. A \<in> M \<Longrightarrow> f A \<noteq> \<infinity>"
hoelzl@47694
   829
  assumes cont: "\<And>A. range A \<subseteq> M \<Longrightarrow> decseq A \<Longrightarrow> (\<Inter>i. A i) = {} \<Longrightarrow> (\<lambda>i. f (A i)) ----> 0"
hoelzl@47694
   830
  shows "\<exists>\<mu> :: 'a set \<Rightarrow> ereal. (\<forall>s \<in> M. \<mu> s = f s) \<and> measure_space \<Omega> (sigma_sets \<Omega> M) \<mu>"
hoelzl@42145
   831
proof (intro caratheodory empty_continuous_imp_countably_additive f)
hoelzl@47694
   832
  show "\<forall>A\<in>M. f A \<noteq> \<infinity>" using fin by auto
hoelzl@42145
   833
qed (rule cont)
hoelzl@42145
   834
paulson@33271
   835
end