src/HOL/Probability/Complete_Measure.thy
author hoelzl
Fri Feb 19 13:40:50 2016 +0100 (2016-02-19)
changeset 62378 85ed00c1fe7c
parent 62343 24106dc44def
child 62390 842917225d56
permissions -rw-r--r--
generalize more theorems to support enat and ennreal
wenzelm@41983
     1
(*  Title:      HOL/Probability/Complete_Measure.thy
hoelzl@40859
     2
    Author:     Robert Himmelmann, Johannes Hoelzl, TU Muenchen
hoelzl@40859
     3
*)
wenzelm@41983
     4
hoelzl@40859
     5
theory Complete_Measure
hoelzl@58587
     6
  imports Bochner_Integration Probability_Measure
hoelzl@40859
     7
begin
hoelzl@40859
     8
hoelzl@47694
     9
definition
hoelzl@47694
    10
  "split_completion M A p = (if A \<in> sets M then p = (A, {}) else
hoelzl@47694
    11
   \<exists>N'. A = fst p \<union> snd p \<and> fst p \<inter> snd p = {} \<and> fst p \<in> sets M \<and> snd p \<subseteq> N' \<and> N' \<in> null_sets M)"
hoelzl@41689
    12
hoelzl@47694
    13
definition
hoelzl@47694
    14
  "main_part M A = fst (Eps (split_completion M A))"
hoelzl@41689
    15
hoelzl@47694
    16
definition
hoelzl@47694
    17
  "null_part M A = snd (Eps (split_completion M A))"
hoelzl@40859
    18
hoelzl@47694
    19
definition completion :: "'a measure \<Rightarrow> 'a measure" where
hoelzl@47694
    20
  "completion M = measure_of (space M) { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }
hoelzl@47694
    21
    (emeasure M \<circ> main_part M)"
hoelzl@40859
    22
hoelzl@47694
    23
lemma completion_into_space:
hoelzl@47694
    24
  "{ S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' } \<subseteq> Pow (space M)"
immler@50244
    25
  using sets.sets_into_space by auto
hoelzl@40859
    26
hoelzl@47694
    27
lemma space_completion[simp]: "space (completion M) = space M"
hoelzl@47694
    28
  unfolding completion_def using space_measure_of[OF completion_into_space] by simp
hoelzl@40859
    29
hoelzl@47694
    30
lemma completionI:
hoelzl@47694
    31
  assumes "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
hoelzl@47694
    32
  shows "A \<in> { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
hoelzl@40859
    33
  using assms by auto
hoelzl@40859
    34
hoelzl@47694
    35
lemma completionE:
hoelzl@47694
    36
  assumes "A \<in> { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
hoelzl@47694
    37
  obtains S N N' where "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
hoelzl@47694
    38
  using assms by auto
hoelzl@47694
    39
hoelzl@47694
    40
lemma sigma_algebra_completion:
hoelzl@47694
    41
  "sigma_algebra (space M) { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
hoelzl@47694
    42
    (is "sigma_algebra _ ?A")
hoelzl@47694
    43
  unfolding sigma_algebra_iff2
hoelzl@47694
    44
proof (intro conjI ballI allI impI)
hoelzl@47694
    45
  show "?A \<subseteq> Pow (space M)"
immler@50244
    46
    using sets.sets_into_space by auto
hoelzl@40859
    47
next
hoelzl@47694
    48
  show "{} \<in> ?A" by auto
hoelzl@40859
    49
next
hoelzl@47694
    50
  let ?C = "space M"
hoelzl@47694
    51
  fix A assume "A \<in> ?A" from completionE[OF this] guess S N N' .
hoelzl@47694
    52
  then show "space M - A \<in> ?A"
hoelzl@47694
    53
    by (intro completionI[of _ "(?C - S) \<inter> (?C - N')" "(?C - S) \<inter> N' \<inter> (?C - N)"]) auto
hoelzl@47694
    54
next
hoelzl@47694
    55
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> ?A"
hoelzl@47694
    56
  then have "\<forall>n. \<exists>S N N'. A n = S \<union> N \<and> S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N'"
hoelzl@47694
    57
    by (auto simp: image_subset_iff)
hoelzl@40859
    58
  from choice[OF this] guess S ..
hoelzl@40859
    59
  from choice[OF this] guess N ..
hoelzl@40859
    60
  from choice[OF this] guess N' ..
hoelzl@47694
    61
  then show "UNION UNIV A \<in> ?A"
hoelzl@40859
    62
    using null_sets_UN[of N']
hoelzl@47694
    63
    by (intro completionI[of _ "UNION UNIV S" "UNION UNIV N" "UNION UNIV N'"]) auto
hoelzl@47694
    64
qed
hoelzl@47694
    65
hoelzl@47694
    66
lemma sets_completion:
hoelzl@47694
    67
  "sets (completion M) = { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
hoelzl@47694
    68
  using sigma_algebra.sets_measure_of_eq[OF sigma_algebra_completion] by (simp add: completion_def)
hoelzl@47694
    69
hoelzl@47694
    70
lemma sets_completionE:
hoelzl@47694
    71
  assumes "A \<in> sets (completion M)"
hoelzl@47694
    72
  obtains S N N' where "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
hoelzl@47694
    73
  using assms unfolding sets_completion by auto
hoelzl@47694
    74
hoelzl@47694
    75
lemma sets_completionI:
hoelzl@47694
    76
  assumes "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
hoelzl@47694
    77
  shows "A \<in> sets (completion M)"
hoelzl@47694
    78
  using assms unfolding sets_completion by auto
hoelzl@47694
    79
hoelzl@47694
    80
lemma sets_completionI_sets[intro, simp]:
hoelzl@47694
    81
  "A \<in> sets M \<Longrightarrow> A \<in> sets (completion M)"
hoelzl@47694
    82
  unfolding sets_completion by force
hoelzl@40859
    83
hoelzl@47694
    84
lemma null_sets_completion:
hoelzl@47694
    85
  assumes "N' \<in> null_sets M" "N \<subseteq> N'" shows "N \<in> sets (completion M)"
hoelzl@47694
    86
  using assms by (intro sets_completionI[of N "{}" N N']) auto
hoelzl@47694
    87
hoelzl@47694
    88
lemma split_completion:
hoelzl@47694
    89
  assumes "A \<in> sets (completion M)"
hoelzl@47694
    90
  shows "split_completion M A (main_part M A, null_part M A)"
hoelzl@47694
    91
proof cases
hoelzl@47694
    92
  assume "A \<in> sets M" then show ?thesis
hoelzl@47694
    93
    by (simp add: split_completion_def[abs_def] main_part_def null_part_def)
hoelzl@47694
    94
next
hoelzl@47694
    95
  assume nA: "A \<notin> sets M"
hoelzl@47694
    96
  show ?thesis
hoelzl@47694
    97
    unfolding main_part_def null_part_def if_not_P[OF nA]
hoelzl@47694
    98
  proof (rule someI2_ex)
hoelzl@47694
    99
    from assms[THEN sets_completionE] guess S N N' . note A = this
hoelzl@47694
   100
    let ?P = "(S, N - S)"
hoelzl@47694
   101
    show "\<exists>p. split_completion M A p"
hoelzl@47694
   102
      unfolding split_completion_def if_not_P[OF nA] using A
hoelzl@47694
   103
    proof (intro exI conjI)
hoelzl@47694
   104
      show "A = fst ?P \<union> snd ?P" using A by auto
hoelzl@47694
   105
      show "snd ?P \<subseteq> N'" using A by auto
hoelzl@47694
   106
   qed auto
hoelzl@40859
   107
  qed auto
hoelzl@47694
   108
qed
hoelzl@40859
   109
hoelzl@47694
   110
lemma
hoelzl@47694
   111
  assumes "S \<in> sets (completion M)"
hoelzl@47694
   112
  shows main_part_sets[intro, simp]: "main_part M S \<in> sets M"
hoelzl@47694
   113
    and main_part_null_part_Un[simp]: "main_part M S \<union> null_part M S = S"
hoelzl@47694
   114
    and main_part_null_part_Int[simp]: "main_part M S \<inter> null_part M S = {}"
hoelzl@47694
   115
  using split_completion[OF assms]
hoelzl@47694
   116
  by (auto simp: split_completion_def split: split_if_asm)
hoelzl@40859
   117
hoelzl@47694
   118
lemma main_part[simp]: "S \<in> sets M \<Longrightarrow> main_part M S = S"
hoelzl@47694
   119
  using split_completion[of S M]
hoelzl@47694
   120
  by (auto simp: split_completion_def split: split_if_asm)
hoelzl@40859
   121
hoelzl@47694
   122
lemma null_part:
hoelzl@47694
   123
  assumes "S \<in> sets (completion M)" shows "\<exists>N. N\<in>null_sets M \<and> null_part M S \<subseteq> N"
hoelzl@47694
   124
  using split_completion[OF assms] by (auto simp: split_completion_def split: split_if_asm)
hoelzl@47694
   125
hoelzl@47694
   126
lemma null_part_sets[intro, simp]:
hoelzl@47694
   127
  assumes "S \<in> sets M" shows "null_part M S \<in> sets M" "emeasure M (null_part M S) = 0"
hoelzl@40859
   128
proof -
hoelzl@47694
   129
  have S: "S \<in> sets (completion M)" using assms by auto
hoelzl@47694
   130
  have "S - main_part M S \<in> sets M" using assms by auto
hoelzl@40859
   131
  moreover
hoelzl@40859
   132
  from main_part_null_part_Un[OF S] main_part_null_part_Int[OF S]
hoelzl@47694
   133
  have "S - main_part M S = null_part M S" by auto
hoelzl@47694
   134
  ultimately show sets: "null_part M S \<in> sets M" by auto
hoelzl@40859
   135
  from null_part[OF S] guess N ..
hoelzl@47694
   136
  with emeasure_eq_0[of N _ "null_part M S"] sets
hoelzl@47694
   137
  show "emeasure M (null_part M S) = 0" by auto
hoelzl@40859
   138
qed
hoelzl@40859
   139
hoelzl@47694
   140
lemma emeasure_main_part_UN:
hoelzl@40859
   141
  fixes S :: "nat \<Rightarrow> 'a set"
hoelzl@47694
   142
  assumes "range S \<subseteq> sets (completion M)"
hoelzl@47694
   143
  shows "emeasure M (main_part M (\<Union>i. (S i))) = emeasure M (\<Union>i. main_part M (S i))"
hoelzl@40859
   144
proof -
hoelzl@47694
   145
  have S: "\<And>i. S i \<in> sets (completion M)" using assms by auto
hoelzl@47694
   146
  then have UN: "(\<Union>i. S i) \<in> sets (completion M)" by auto
hoelzl@47694
   147
  have "\<forall>i. \<exists>N. N \<in> null_sets M \<and> null_part M (S i) \<subseteq> N"
hoelzl@40859
   148
    using null_part[OF S] by auto
hoelzl@40859
   149
  from choice[OF this] guess N .. note N = this
hoelzl@47694
   150
  then have UN_N: "(\<Union>i. N i) \<in> null_sets M" by (intro null_sets_UN) auto
hoelzl@47694
   151
  have "(\<Union>i. S i) \<in> sets (completion M)" using S by auto
hoelzl@40859
   152
  from null_part[OF this] guess N' .. note N' = this
hoelzl@40859
   153
  let ?N = "(\<Union>i. N i) \<union> N'"
hoelzl@47694
   154
  have null_set: "?N \<in> null_sets M" using N' UN_N by (intro null_sets.Un) auto
hoelzl@47694
   155
  have "main_part M (\<Union>i. S i) \<union> ?N = (main_part M (\<Union>i. S i) \<union> null_part M (\<Union>i. S i)) \<union> ?N"
hoelzl@40859
   156
    using N' by auto
hoelzl@47694
   157
  also have "\<dots> = (\<Union>i. main_part M (S i) \<union> null_part M (S i)) \<union> ?N"
hoelzl@40859
   158
    unfolding main_part_null_part_Un[OF S] main_part_null_part_Un[OF UN] by auto
hoelzl@47694
   159
  also have "\<dots> = (\<Union>i. main_part M (S i)) \<union> ?N"
hoelzl@40859
   160
    using N by auto
hoelzl@47694
   161
  finally have *: "main_part M (\<Union>i. S i) \<union> ?N = (\<Union>i. main_part M (S i)) \<union> ?N" .
hoelzl@47694
   162
  have "emeasure M (main_part M (\<Union>i. S i)) = emeasure M (main_part M (\<Union>i. S i) \<union> ?N)"
hoelzl@47694
   163
    using null_set UN by (intro emeasure_Un_null_set[symmetric]) auto
hoelzl@47694
   164
  also have "\<dots> = emeasure M ((\<Union>i. main_part M (S i)) \<union> ?N)"
hoelzl@40859
   165
    unfolding * ..
hoelzl@47694
   166
  also have "\<dots> = emeasure M (\<Union>i. main_part M (S i))"
hoelzl@47694
   167
    using null_set S by (intro emeasure_Un_null_set) auto
hoelzl@41689
   168
  finally show ?thesis .
hoelzl@40859
   169
qed
hoelzl@40859
   170
hoelzl@47694
   171
lemma emeasure_completion[simp]:
hoelzl@47694
   172
  assumes S: "S \<in> sets (completion M)" shows "emeasure (completion M) S = emeasure M (main_part M S)"
hoelzl@47694
   173
proof (subst emeasure_measure_of[OF completion_def completion_into_space])
hoelzl@47694
   174
  let ?\<mu> = "emeasure M \<circ> main_part M"
hoelzl@47694
   175
  show "S \<in> sets (completion M)" "?\<mu> S = emeasure M (main_part M S) " using S by simp_all
hoelzl@47694
   176
  show "positive (sets (completion M)) ?\<mu>"
hoelzl@47694
   177
    by (simp add: positive_def emeasure_nonneg)
hoelzl@47694
   178
  show "countably_additive (sets (completion M)) ?\<mu>"
hoelzl@47694
   179
  proof (intro countably_additiveI)
hoelzl@47694
   180
    fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets (completion M)" "disjoint_family A"
hoelzl@47694
   181
    have "disjoint_family (\<lambda>i. main_part M (A i))"
hoelzl@47694
   182
    proof (intro disjoint_family_on_bisimulation[OF A(2)])
hoelzl@47694
   183
      fix n m assume "A n \<inter> A m = {}"
hoelzl@47694
   184
      then have "(main_part M (A n) \<union> null_part M (A n)) \<inter> (main_part M (A m) \<union> null_part M (A m)) = {}"
hoelzl@47694
   185
        using A by (subst (1 2) main_part_null_part_Un) auto
hoelzl@47694
   186
      then show "main_part M (A n) \<inter> main_part M (A m) = {}" by auto
hoelzl@47694
   187
    qed
hoelzl@47694
   188
    then have "(\<Sum>n. emeasure M (main_part M (A n))) = emeasure M (\<Union>i. main_part M (A i))"
hoelzl@47694
   189
      using A by (auto intro!: suminf_emeasure)
hoelzl@47694
   190
    then show "(\<Sum>n. ?\<mu> (A n)) = ?\<mu> (UNION UNIV A)"
hoelzl@47694
   191
      by (simp add: completion_def emeasure_main_part_UN[OF A(1)])
hoelzl@47694
   192
  qed
hoelzl@40859
   193
qed
hoelzl@40859
   194
hoelzl@47694
   195
lemma emeasure_completion_UN:
hoelzl@47694
   196
  "range S \<subseteq> sets (completion M) \<Longrightarrow>
hoelzl@47694
   197
    emeasure (completion M) (\<Union>i::nat. (S i)) = emeasure M (\<Union>i. main_part M (S i))"
hoelzl@47694
   198
  by (subst emeasure_completion) (auto simp add: emeasure_main_part_UN)
hoelzl@40859
   199
hoelzl@47694
   200
lemma emeasure_completion_Un:
hoelzl@47694
   201
  assumes S: "S \<in> sets (completion M)" and T: "T \<in> sets (completion M)"
hoelzl@47694
   202
  shows "emeasure (completion M) (S \<union> T) = emeasure M (main_part M S \<union> main_part M T)"
hoelzl@47694
   203
proof (subst emeasure_completion)
hoelzl@47694
   204
  have UN: "(\<Union>i. binary (main_part M S) (main_part M T) i) = (\<Union>i. main_part M (binary S T i))"
hoelzl@47694
   205
    unfolding binary_def by (auto split: split_if_asm)
hoelzl@47694
   206
  show "emeasure M (main_part M (S \<union> T)) = emeasure M (main_part M S \<union> main_part M T)"
hoelzl@47694
   207
    using emeasure_main_part_UN[of "binary S T" M] assms
haftmann@62343
   208
    by (simp add: range_binary_eq, simp add: Un_range_binary UN)
hoelzl@47694
   209
qed (auto intro: S T)
hoelzl@47694
   210
hoelzl@47694
   211
lemma sets_completionI_sub:
hoelzl@47694
   212
  assumes N: "N' \<in> null_sets M" "N \<subseteq> N'"
hoelzl@47694
   213
  shows "N \<in> sets (completion M)"
hoelzl@47694
   214
  using assms by (intro sets_completionI[of _ "{}" N N']) auto
hoelzl@47694
   215
hoelzl@47694
   216
lemma completion_ex_simple_function:
hoelzl@47694
   217
  assumes f: "simple_function (completion M) f"
hoelzl@47694
   218
  shows "\<exists>f'. simple_function M f' \<and> (AE x in M. f x = f' x)"
hoelzl@40859
   219
proof -
wenzelm@46731
   220
  let ?F = "\<lambda>x. f -` {x} \<inter> space M"
hoelzl@47694
   221
  have F: "\<And>x. ?F x \<in> sets (completion M)" and fin: "finite (f`space M)"
hoelzl@47694
   222
    using simple_functionD[OF f] simple_functionD[OF f] by simp_all
hoelzl@47694
   223
  have "\<forall>x. \<exists>N. N \<in> null_sets M \<and> null_part M (?F x) \<subseteq> N"
hoelzl@40859
   224
    using F null_part by auto
hoelzl@40859
   225
  from choice[OF this] obtain N where
hoelzl@47694
   226
    N: "\<And>x. null_part M (?F x) \<subseteq> N x" "\<And>x. N x \<in> null_sets M" by auto
wenzelm@46731
   227
  let ?N = "\<Union>x\<in>f`space M. N x"
wenzelm@46731
   228
  let ?f' = "\<lambda>x. if x \<in> ?N then undefined else f x"
hoelzl@47694
   229
  have sets: "?N \<in> null_sets M" using N fin by (intro null_sets.finite_UN) auto
hoelzl@40859
   230
  show ?thesis unfolding simple_function_def
hoelzl@40859
   231
  proof (safe intro!: exI[of _ ?f'])
hoelzl@40859
   232
    have "?f' ` space M \<subseteq> f`space M \<union> {undefined}" by auto
hoelzl@47694
   233
    from finite_subset[OF this] simple_functionD(1)[OF f]
hoelzl@40859
   234
    show "finite (?f' ` space M)" by auto
hoelzl@40859
   235
  next
hoelzl@40859
   236
    fix x assume "x \<in> space M"
hoelzl@40859
   237
    have "?f' -` {?f' x} \<inter> space M =
hoelzl@40859
   238
      (if x \<in> ?N then ?F undefined \<union> ?N
hoelzl@40859
   239
       else if f x = undefined then ?F (f x) \<union> ?N
hoelzl@40859
   240
       else ?F (f x) - ?N)"
immler@50244
   241
      using N(2) sets.sets_into_space by (auto split: split_if_asm simp: null_sets_def)
hoelzl@40859
   242
    moreover { fix y have "?F y \<union> ?N \<in> sets M"
hoelzl@40859
   243
      proof cases
hoelzl@40859
   244
        assume y: "y \<in> f`space M"
hoelzl@47694
   245
        have "?F y \<union> ?N = (main_part M (?F y) \<union> null_part M (?F y)) \<union> ?N"
hoelzl@40859
   246
          using main_part_null_part_Un[OF F] by auto
hoelzl@47694
   247
        also have "\<dots> = main_part M (?F y) \<union> ?N"
hoelzl@40859
   248
          using y N by auto
hoelzl@40859
   249
        finally show ?thesis
hoelzl@40859
   250
          using F sets by auto
hoelzl@40859
   251
      next
hoelzl@40859
   252
        assume "y \<notin> f`space M" then have "?F y = {}" by auto
hoelzl@40859
   253
        then show ?thesis using sets by auto
hoelzl@40859
   254
      qed }
hoelzl@40859
   255
    moreover {
hoelzl@47694
   256
      have "?F (f x) - ?N = main_part M (?F (f x)) \<union> null_part M (?F (f x)) - ?N"
hoelzl@40859
   257
        using main_part_null_part_Un[OF F] by auto
hoelzl@47694
   258
      also have "\<dots> = main_part M (?F (f x)) - ?N"
wenzelm@61808
   259
        using N \<open>x \<in> space M\<close> by auto
hoelzl@40859
   260
      finally have "?F (f x) - ?N \<in> sets M"
hoelzl@40859
   261
        using F sets by auto }
hoelzl@40859
   262
    ultimately show "?f' -` {?f' x} \<inter> space M \<in> sets M" by auto
hoelzl@40859
   263
  next
hoelzl@47694
   264
    show "AE x in M. f x = ?f' x"
hoelzl@40859
   265
      by (rule AE_I', rule sets) auto
hoelzl@40859
   266
  qed
hoelzl@40859
   267
qed
hoelzl@40859
   268
hoelzl@47694
   269
lemma completion_ex_borel_measurable_pos:
hoelzl@43920
   270
  fixes g :: "'a \<Rightarrow> ereal"
hoelzl@47694
   271
  assumes g: "g \<in> borel_measurable (completion M)" and "\<And>x. 0 \<le> g x"
hoelzl@47694
   272
  shows "\<exists>g'\<in>borel_measurable M. (AE x in M. g x = g' x)"
hoelzl@40859
   273
proof -
hoelzl@47694
   274
  from g[THEN borel_measurable_implies_simple_function_sequence'] guess f . note f = this
hoelzl@41981
   275
  from this(1)[THEN completion_ex_simple_function]
hoelzl@47694
   276
  have "\<forall>i. \<exists>f'. simple_function M f' \<and> (AE x in M. f i x = f' x)" ..
hoelzl@40859
   277
  from this[THEN choice] obtain f' where
hoelzl@41689
   278
    sf: "\<And>i. simple_function M (f' i)" and
hoelzl@47694
   279
    AE: "\<forall>i. AE x in M. f i x = f' i x" by auto
hoelzl@40859
   280
  show ?thesis
hoelzl@40859
   281
  proof (intro bexI)
hoelzl@41981
   282
    from AE[unfolded AE_all_countable[symmetric]]
hoelzl@47694
   283
    show "AE x in M. g x = (SUP i. f' i x)" (is "AE x in M. g x = ?f x")
hoelzl@41705
   284
    proof (elim AE_mp, safe intro!: AE_I2)
hoelzl@40859
   285
      fix x assume eq: "\<forall>i. f i x = f' i x"
hoelzl@41981
   286
      moreover have "g x = (SUP i. f i x)"
wenzelm@61808
   287
        unfolding f using \<open>0 \<le> g x\<close> by (auto split: split_max)
hoelzl@41981
   288
      ultimately show "g x = ?f x" by auto
hoelzl@40859
   289
    qed
hoelzl@40859
   290
    show "?f \<in> borel_measurable M"
hoelzl@56949
   291
      using sf[THEN borel_measurable_simple_function] by auto
hoelzl@40859
   292
  qed
hoelzl@40859
   293
qed
hoelzl@40859
   294
hoelzl@47694
   295
lemma completion_ex_borel_measurable:
hoelzl@43920
   296
  fixes g :: "'a \<Rightarrow> ereal"
hoelzl@47694
   297
  assumes g: "g \<in> borel_measurable (completion M)"
hoelzl@47694
   298
  shows "\<exists>g'\<in>borel_measurable M. (AE x in M. g x = g' x)"
hoelzl@41981
   299
proof -
hoelzl@47694
   300
  have "(\<lambda>x. max 0 (g x)) \<in> borel_measurable (completion M)" "\<And>x. 0 \<le> max 0 (g x)" using g by auto
hoelzl@41981
   301
  from completion_ex_borel_measurable_pos[OF this] guess g_pos ..
hoelzl@41981
   302
  moreover
hoelzl@47694
   303
  have "(\<lambda>x. max 0 (- g x)) \<in> borel_measurable (completion M)" "\<And>x. 0 \<le> max 0 (- g x)" using g by auto
hoelzl@41981
   304
  from completion_ex_borel_measurable_pos[OF this] guess g_neg ..
hoelzl@41981
   305
  ultimately
hoelzl@41981
   306
  show ?thesis
hoelzl@41981
   307
  proof (safe intro!: bexI[of _ "\<lambda>x. g_pos x - g_neg x"])
hoelzl@47694
   308
    show "AE x in M. max 0 (- g x) = g_neg x \<longrightarrow> max 0 (g x) = g_pos x \<longrightarrow> g x = g_pos x - g_neg x"
hoelzl@41981
   309
    proof (intro AE_I2 impI)
hoelzl@41981
   310
      fix x assume g: "max 0 (- g x) = g_neg x" "max 0 (g x) = g_pos x"
hoelzl@41981
   311
      show "g x = g_pos x - g_neg x" unfolding g[symmetric]
hoelzl@41981
   312
        by (cases "g x") (auto split: split_max)
hoelzl@41981
   313
    qed
hoelzl@41981
   314
  qed auto
hoelzl@41981
   315
qed
hoelzl@41981
   316
hoelzl@58587
   317
lemma (in prob_space) prob_space_completion: "prob_space (completion M)"
hoelzl@58587
   318
  by (rule prob_spaceI) (simp add: emeasure_space_1)
hoelzl@58587
   319
hoelzl@58587
   320
lemma null_sets_completionI: "N \<in> null_sets M \<Longrightarrow> N \<in> null_sets (completion M)"
hoelzl@58587
   321
  by (auto simp: null_sets_def)
hoelzl@58587
   322
hoelzl@58587
   323
lemma AE_completion: "(AE x in M. P x) \<Longrightarrow> (AE x in completion M. P x)"
hoelzl@58587
   324
  unfolding eventually_ae_filter by (auto intro: null_sets_completionI)
hoelzl@58587
   325
hoelzl@58587
   326
lemma null_sets_completion_iff: "N \<in> sets M \<Longrightarrow> N \<in> null_sets (completion M) \<longleftrightarrow> N \<in> null_sets M"
hoelzl@58587
   327
  by (auto simp: null_sets_def)
hoelzl@58587
   328
hoelzl@58587
   329
lemma AE_completion_iff: "{x\<in>space M. P x} \<in> sets M \<Longrightarrow> (AE x in M. P x) \<longleftrightarrow> (AE x in completion M. P x)"
hoelzl@58587
   330
  by (simp add: AE_iff_null null_sets_completion_iff)
hoelzl@58587
   331
hoelzl@40859
   332
end