src/HOL/Analysis/Complete_Measure.thy
author hoelzl
Thu, 29 Sep 2016 13:54:57 +0200
changeset 63958 02de4a58e210
parent 63941 f353674c2528
child 63959 f77dca1abf1b
permissions -rw-r--r--
HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63627
6ddb43c6b711 rename HOL-Multivariate_Analysis to HOL-Analysis.
hoelzl
parents: 63626
diff changeset
     1
(*  Title:      HOL/Analysis/Complete_Measure.thy
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
     2
    Author:     Robert Himmelmann, Johannes Hoelzl, TU Muenchen
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
     3
*)
41983
2dc6e382a58b standardized headers;
wenzelm
parents: 41981
diff changeset
     4
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
     5
theory Complete_Measure
63626
44ce6b524ff3 move measure theory from HOL-Probability to HOL-Multivariate_Analysis
hoelzl
parents: 62975
diff changeset
     6
  imports Bochner_Integration
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
     7
begin
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
     8
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
     9
locale complete_measure =
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
    10
  fixes M :: "'a measure"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
    11
  assumes complete: "\<And>A B. B \<subseteq> A \<Longrightarrow> A \<in> null_sets M \<Longrightarrow> B \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
    12
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    13
definition
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    14
  "split_completion M A p = (if A \<in> sets M then p = (A, {}) else
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    15
   \<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)"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41097
diff changeset
    16
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    17
definition
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    18
  "main_part M A = fst (Eps (split_completion M A))"
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41097
diff changeset
    19
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    20
definition
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    21
  "null_part M A = snd (Eps (split_completion M A))"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    22
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    23
definition completion :: "'a measure \<Rightarrow> 'a measure" where
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    24
  "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' }
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    25
    (emeasure M \<circ> main_part M)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    26
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    27
lemma completion_into_space:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    28
  "{ S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' } \<subseteq> Pow (space M)"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 47694
diff changeset
    29
  using sets.sets_into_space by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    30
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    31
lemma space_completion[simp]: "space (completion M) = space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    32
  unfolding completion_def using space_measure_of[OF completion_into_space] by simp
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    33
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    34
lemma completionI:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    35
  assumes "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    36
  shows "A \<in> { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    37
  using assms by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    38
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    39
lemma completionE:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    40
  assumes "A \<in> { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    41
  obtains S N N' where "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    42
  using assms by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    43
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    44
lemma sigma_algebra_completion:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    45
  "sigma_algebra (space M) { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    46
    (is "sigma_algebra _ ?A")
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    47
  unfolding sigma_algebra_iff2
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    48
proof (intro conjI ballI allI impI)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    49
  show "?A \<subseteq> Pow (space M)"
50244
de72bbe42190 qualified interpretation of sigma_algebra, to avoid name clashes
immler
parents: 47694
diff changeset
    50
    using sets.sets_into_space by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    51
next
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    52
  show "{} \<in> ?A" by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    53
next
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    54
  let ?C = "space M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    55
  fix A assume "A \<in> ?A" from completionE[OF this] guess S N N' .
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    56
  then show "space M - A \<in> ?A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    57
    by (intro completionI[of _ "(?C - S) \<inter> (?C - N')" "(?C - S) \<inter> N' \<inter> (?C - N)"]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    58
next
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    59
  fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> ?A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    60
  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'"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    61
    by (auto simp: image_subset_iff)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    62
  from choice[OF this] guess S ..
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    63
  from choice[OF this] guess N ..
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    64
  from choice[OF this] guess N' ..
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    65
  then show "UNION UNIV A \<in> ?A"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    66
    using null_sets_UN[of N']
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    67
    by (intro completionI[of _ "UNION UNIV S" "UNION UNIV N" "UNION UNIV N'"]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    68
qed
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    69
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    70
lemma sets_completion:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    71
  "sets (completion M) = { S \<union> N |S N N'. S \<in> sets M \<and> N' \<in> null_sets M \<and> N \<subseteq> N' }"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    72
  using sigma_algebra.sets_measure_of_eq[OF sigma_algebra_completion] by (simp add: completion_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    73
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    74
lemma sets_completionE:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    75
  assumes "A \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    76
  obtains S N N' where "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    77
  using assms unfolding sets_completion by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    78
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    79
lemma sets_completionI:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    80
  assumes "A = S \<union> N" "N \<subseteq> N'" "N' \<in> null_sets M" "S \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    81
  shows "A \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    82
  using assms unfolding sets_completion by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    83
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    84
lemma sets_completionI_sets[intro, simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    85
  "A \<in> sets M \<Longrightarrow> A \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    86
  unfolding sets_completion by force
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
    87
63958
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
    88
lemma measurable_completion: "f \<in> M \<rightarrow>\<^sub>M N \<Longrightarrow> f \<in> completion M \<rightarrow>\<^sub>M N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
    89
  by (auto simp: measurable_def)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
    90
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    91
lemma null_sets_completion:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    92
  assumes "N' \<in> null_sets M" "N \<subseteq> N'" shows "N \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    93
  using assms by (intro sets_completionI[of N "{}" N N']) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    94
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    95
lemma split_completion:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    96
  assumes "A \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    97
  shows "split_completion M A (main_part M A, null_part M A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    98
proof cases
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
    99
  assume "A \<in> sets M" then show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   100
    by (simp add: split_completion_def[abs_def] main_part_def null_part_def)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   101
next
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   102
  assume nA: "A \<notin> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   103
  show ?thesis
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   104
    unfolding main_part_def null_part_def if_not_P[OF nA]
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   105
  proof (rule someI2_ex)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   106
    from assms[THEN sets_completionE] guess S N N' . note A = this
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   107
    let ?P = "(S, N - S)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   108
    show "\<exists>p. split_completion M A p"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   109
      unfolding split_completion_def if_not_P[OF nA] using A
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   110
    proof (intro exI conjI)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   111
      show "A = fst ?P \<union> snd ?P" using A by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   112
      show "snd ?P \<subseteq> N'" using A by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   113
   qed auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   114
  qed auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   115
qed
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   116
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   117
lemma
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   118
  assumes "S \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   119
  shows main_part_sets[intro, simp]: "main_part M S \<in> sets M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   120
    and main_part_null_part_Un[simp]: "main_part M S \<union> null_part M S = S"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   121
    and main_part_null_part_Int[simp]: "main_part M S \<inter> null_part M S = {}"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   122
  using split_completion[OF assms]
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   123
  by (auto simp: split_completion_def split: if_split_asm)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   124
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   125
lemma main_part[simp]: "S \<in> sets M \<Longrightarrow> main_part M S = S"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   126
  using split_completion[of S M]
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   127
  by (auto simp: split_completion_def split: if_split_asm)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   128
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   129
lemma null_part:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   130
  assumes "S \<in> sets (completion M)" shows "\<exists>N. N\<in>null_sets M \<and> null_part M S \<subseteq> N"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   131
  using split_completion[OF assms] by (auto simp: split_completion_def split: if_split_asm)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   132
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   133
lemma null_part_sets[intro, simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   134
  assumes "S \<in> sets M" shows "null_part M S \<in> sets M" "emeasure M (null_part M S) = 0"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   135
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   136
  have S: "S \<in> sets (completion M)" using assms by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   137
  have "S - main_part M S \<in> sets M" using assms by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   138
  moreover
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   139
  from main_part_null_part_Un[OF S] main_part_null_part_Int[OF S]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   140
  have "S - main_part M S = null_part M S" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   141
  ultimately show sets: "null_part M S \<in> sets M" by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   142
  from null_part[OF S] guess N ..
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   143
  with emeasure_eq_0[of N _ "null_part M S"] sets
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   144
  show "emeasure M (null_part M S) = 0" by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   145
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   146
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   147
lemma emeasure_main_part_UN:
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   148
  fixes S :: "nat \<Rightarrow> 'a set"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   149
  assumes "range S \<subseteq> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   150
  shows "emeasure M (main_part M (\<Union>i. (S i))) = emeasure M (\<Union>i. main_part M (S i))"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   151
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   152
  have S: "\<And>i. S i \<in> sets (completion M)" using assms by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   153
  then have UN: "(\<Union>i. S i) \<in> sets (completion M)" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   154
  have "\<forall>i. \<exists>N. N \<in> null_sets M \<and> null_part M (S i) \<subseteq> N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   155
    using null_part[OF S] by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   156
  from choice[OF this] guess N .. note N = this
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   157
  then have UN_N: "(\<Union>i. N i) \<in> null_sets M" by (intro null_sets_UN) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   158
  have "(\<Union>i. S i) \<in> sets (completion M)" using S by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   159
  from null_part[OF this] guess N' .. note N' = this
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   160
  let ?N = "(\<Union>i. N i) \<union> N'"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   161
  have null_set: "?N \<in> null_sets M" using N' UN_N by (intro null_sets.Un) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   162
  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"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   163
    using N' by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   164
  also have "\<dots> = (\<Union>i. main_part M (S i) \<union> null_part M (S i)) \<union> ?N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   165
    unfolding main_part_null_part_Un[OF S] main_part_null_part_Un[OF UN] by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   166
  also have "\<dots> = (\<Union>i. main_part M (S i)) \<union> ?N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   167
    using N by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   168
  finally have *: "main_part M (\<Union>i. S i) \<union> ?N = (\<Union>i. main_part M (S i)) \<union> ?N" .
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   169
  have "emeasure M (main_part M (\<Union>i. S i)) = emeasure M (main_part M (\<Union>i. S i) \<union> ?N)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   170
    using null_set UN by (intro emeasure_Un_null_set[symmetric]) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   171
  also have "\<dots> = emeasure M ((\<Union>i. main_part M (S i)) \<union> ?N)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   172
    unfolding * ..
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   173
  also have "\<dots> = emeasure M (\<Union>i. main_part M (S i))"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   174
    using null_set S by (intro emeasure_Un_null_set) auto
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41097
diff changeset
   175
  finally show ?thesis .
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   176
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   177
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   178
lemma emeasure_completion[simp]:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   179
  assumes S: "S \<in> sets (completion M)" shows "emeasure (completion M) S = emeasure M (main_part M S)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   180
proof (subst emeasure_measure_of[OF completion_def completion_into_space])
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   181
  let ?\<mu> = "emeasure M \<circ> main_part M"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   182
  show "S \<in> sets (completion M)" "?\<mu> S = emeasure M (main_part M S) " using S by simp_all
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   183
  show "positive (sets (completion M)) ?\<mu>"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62390
diff changeset
   184
    by (simp add: positive_def)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   185
  show "countably_additive (sets (completion M)) ?\<mu>"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   186
  proof (intro countably_additiveI)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   187
    fix A :: "nat \<Rightarrow> 'a set" assume A: "range A \<subseteq> sets (completion M)" "disjoint_family A"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   188
    have "disjoint_family (\<lambda>i. main_part M (A i))"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   189
    proof (intro disjoint_family_on_bisimulation[OF A(2)])
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   190
      fix n m assume "A n \<inter> A m = {}"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   191
      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)) = {}"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   192
        using A by (subst (1 2) main_part_null_part_Un) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   193
      then show "main_part M (A n) \<inter> main_part M (A m) = {}" by auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   194
    qed
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   195
    then have "(\<Sum>n. emeasure M (main_part M (A n))) = emeasure M (\<Union>i. main_part M (A i))"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   196
      using A by (auto intro!: suminf_emeasure)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   197
    then show "(\<Sum>n. ?\<mu> (A n)) = ?\<mu> (UNION UNIV A)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   198
      by (simp add: completion_def emeasure_main_part_UN[OF A(1)])
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   199
  qed
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   200
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   201
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   202
lemma emeasure_completion_UN:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   203
  "range S \<subseteq> sets (completion M) \<Longrightarrow>
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   204
    emeasure (completion M) (\<Union>i::nat. (S i)) = emeasure M (\<Union>i. main_part M (S i))"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   205
  by (subst emeasure_completion) (auto simp add: emeasure_main_part_UN)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   206
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   207
lemma emeasure_completion_Un:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   208
  assumes S: "S \<in> sets (completion M)" and T: "T \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   209
  shows "emeasure (completion M) (S \<union> T) = emeasure M (main_part M S \<union> main_part M T)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   210
proof (subst emeasure_completion)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   211
  have UN: "(\<Union>i. binary (main_part M S) (main_part M T) i) = (\<Union>i. main_part M (binary S T i))"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   212
    unfolding binary_def by (auto split: if_split_asm)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   213
  show "emeasure M (main_part M (S \<union> T)) = emeasure M (main_part M S \<union> main_part M T)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   214
    using emeasure_main_part_UN[of "binary S T" M] assms
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 61808
diff changeset
   215
    by (simp add: range_binary_eq, simp add: Un_range_binary UN)
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   216
qed (auto intro: S T)
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   217
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   218
lemma sets_completionI_sub:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   219
  assumes N: "N' \<in> null_sets M" "N \<subseteq> N'"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   220
  shows "N \<in> sets (completion M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   221
  using assms by (intro sets_completionI[of _ "{}" N N']) auto
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   222
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   223
lemma completion_ex_simple_function:
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   224
  assumes f: "simple_function (completion M) f"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   225
  shows "\<exists>f'. simple_function M f' \<and> (AE x in M. f x = f' x)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   226
proof -
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 43920
diff changeset
   227
  let ?F = "\<lambda>x. f -` {x} \<inter> space M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   228
  have F: "\<And>x. ?F x \<in> sets (completion M)" and fin: "finite (f`space M)"
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   229
    using simple_functionD[OF f] simple_functionD[OF f] by simp_all
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   230
  have "\<forall>x. \<exists>N. N \<in> null_sets M \<and> null_part M (?F x) \<subseteq> N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   231
    using F null_part by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   232
  from choice[OF this] obtain N where
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   233
    N: "\<And>x. null_part M (?F x) \<subseteq> N x" "\<And>x. N x \<in> null_sets M" by auto
46731
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 43920
diff changeset
   234
  let ?N = "\<Union>x\<in>f`space M. N x"
5302e932d1e5 avoid undeclared variables in let bindings;
wenzelm
parents: 43920
diff changeset
   235
  let ?f' = "\<lambda>x. if x \<in> ?N then undefined else f x"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   236
  have sets: "?N \<in> null_sets M" using N fin by (intro null_sets.finite_UN) auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   237
  show ?thesis unfolding simple_function_def
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   238
  proof (safe intro!: exI[of _ ?f'])
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   239
    have "?f' ` space M \<subseteq> f`space M \<union> {undefined}" by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   240
    from finite_subset[OF this] simple_functionD(1)[OF f]
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   241
    show "finite (?f' ` space M)" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   242
  next
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   243
    fix x assume "x \<in> space M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   244
    have "?f' -` {?f' x} \<inter> space M =
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   245
      (if x \<in> ?N then ?F undefined \<union> ?N
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   246
       else if f x = undefined then ?F (f x) \<union> ?N
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   247
       else ?F (f x) - ?N)"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   248
      using N(2) sets.sets_into_space by (auto split: if_split_asm simp: null_sets_def)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   249
    moreover { fix y have "?F y \<union> ?N \<in> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   250
      proof cases
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   251
        assume y: "y \<in> f`space M"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   252
        have "?F y \<union> ?N = (main_part M (?F y) \<union> null_part M (?F y)) \<union> ?N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   253
          using main_part_null_part_Un[OF F] by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   254
        also have "\<dots> = main_part M (?F y) \<union> ?N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   255
          using y N by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   256
        finally show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   257
          using F sets by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   258
      next
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   259
        assume "y \<notin> f`space M" then have "?F y = {}" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   260
        then show ?thesis using sets by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   261
      qed }
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   262
    moreover {
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   263
      have "?F (f x) - ?N = main_part M (?F (f x)) \<union> null_part M (?F (f x)) - ?N"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   264
        using main_part_null_part_Un[OF F] by auto
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   265
      also have "\<dots> = main_part M (?F (f x)) - ?N"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 58587
diff changeset
   266
        using N \<open>x \<in> space M\<close> by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   267
      finally have "?F (f x) - ?N \<in> sets M"
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   268
        using F sets by auto }
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   269
    ultimately show "?f' -` {?f' x} \<inter> space M \<in> sets M" by auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   270
  next
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   271
    show "AE x in M. f x = ?f' x"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   272
      by (rule AE_I', rule sets) auto
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   273
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   274
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   275
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62390
diff changeset
   276
lemma completion_ex_borel_measurable:
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62390
diff changeset
   277
  fixes g :: "'a \<Rightarrow> ennreal"
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62390
diff changeset
   278
  assumes g: "g \<in> borel_measurable (completion M)"
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   279
  shows "\<exists>g'\<in>borel_measurable M. (AE x in M. g x = g' x)"
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   280
proof -
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   281
  from g[THEN borel_measurable_implies_simple_function_sequence'] guess f . note f = this
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41959
diff changeset
   282
  from this(1)[THEN completion_ex_simple_function]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   283
  have "\<forall>i. \<exists>f'. simple_function M f' \<and> (AE x in M. f i x = f' x)" ..
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   284
  from this[THEN choice] obtain f' where
41689
3e39b0e730d6 the measure valuation is again part of the measure_space type, instead of an explicit parameter to the locale;
hoelzl
parents: 41097
diff changeset
   285
    sf: "\<And>i. simple_function M (f' i)" and
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   286
    AE: "\<forall>i. AE x in M. f i x = f' i x" by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   287
  show ?thesis
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   288
  proof (intro bexI)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41959
diff changeset
   289
    from AE[unfolded AE_all_countable[symmetric]]
47694
05663f75964c reworked Probability theory
hoelzl
parents: 46731
diff changeset
   290
    show "AE x in M. g x = (SUP i. f' i x)" (is "AE x in M. g x = ?f x")
41705
1100512e16d8 add auto support for AE_mp
hoelzl
parents: 41689
diff changeset
   291
    proof (elim AE_mp, safe intro!: AE_I2)
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   292
      fix x assume eq: "\<forall>i. f i x = f' i x"
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41959
diff changeset
   293
      moreover have "g x = (SUP i. f i x)"
62975
1d066f6ab25d Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl
parents: 62390
diff changeset
   294
        unfolding f by (auto split: split_max)
41981
cdf7693bbe08 reworked Probability theory: measures are not type restricted to positive extended reals
hoelzl
parents: 41959
diff changeset
   295
      ultimately show "g x = ?f x" by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   296
    qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   297
    show "?f \<in> borel_measurable M"
56949
d1a937cbf858 clean up Lebesgue integration
hoelzl
parents: 50244
diff changeset
   298
      using sf[THEN borel_measurable_simple_function] by auto
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   299
  qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   300
qed
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
   301
58587
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   302
lemma null_sets_completionI: "N \<in> null_sets M \<Longrightarrow> N \<in> null_sets (completion M)"
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   303
  by (auto simp: null_sets_def)
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   304
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   305
lemma AE_completion: "(AE x in M. P x) \<Longrightarrow> (AE x in completion M. P x)"
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   306
  unfolding eventually_ae_filter by (auto intro: null_sets_completionI)
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   307
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   308
lemma null_sets_completion_iff: "N \<in> sets M \<Longrightarrow> N \<in> null_sets (completion M) \<longleftrightarrow> N \<in> null_sets M"
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   309
  by (auto simp: null_sets_def)
5484f6079bcd add type for probability mass functions, i.e. discrete probability distribution
hoelzl
parents: 56993
diff changeset
   310
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   311
lemma sets_completion_AE: "(AE x in M. \<not> P x) \<Longrightarrow> Measurable.pred (completion M) P"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   312
  unfolding pred_def sets_completion eventually_ae_filter
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   313
  by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   314
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   315
lemma null_sets_completion_iff2:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   316
  "A \<in> null_sets (completion M) \<longleftrightarrow> (\<exists>N'\<in>null_sets M. A \<subseteq> N')"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   317
proof safe
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   318
  assume "A \<in> null_sets (completion M)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   319
  then have A: "A \<in> sets (completion M)" and "main_part M A \<in> null_sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   320
    by (auto simp: null_sets_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   321
  moreover obtain N where "N \<in> null_sets M" "null_part M A \<subseteq> N"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   322
    using null_part[OF A] by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   323
  ultimately show "\<exists>N'\<in>null_sets M. A \<subseteq> N'"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   324
  proof (intro bexI)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   325
    show "A \<subseteq> N \<union> main_part M A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   326
      using \<open>null_part M A \<subseteq> N\<close> by (subst main_part_null_part_Un[OF A, symmetric]) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   327
  qed auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   328
next
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   329
  fix N assume "N \<in> null_sets M" "A \<subseteq> N"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   330
  then have "A \<in> sets (completion M)" and N: "N \<in> sets M" "A \<subseteq> N" "emeasure M N = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   331
    by (auto intro: null_sets_completion)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   332
  moreover have "emeasure (completion M) A = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   333
    using N by (intro emeasure_eq_0[of N _ A]) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   334
  ultimately show "A \<in> null_sets (completion M)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   335
    by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   336
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   337
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   338
lemma null_sets_completion_subset:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   339
  "B \<subseteq> A \<Longrightarrow> A \<in> null_sets (completion M) \<Longrightarrow> B \<in> null_sets (completion M)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   340
  unfolding null_sets_completion_iff2 by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   341
63958
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   342
interpretation completion: complete_measure "completion M" for M
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   343
proof
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   344
  show "B \<subseteq> A \<Longrightarrow> A \<in> null_sets (completion M) \<Longrightarrow> B \<in> sets (completion M)" for B A
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   345
    using null_sets_completion_subset[of B A M] by (simp add: null_sets_def)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   346
qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   347
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   348
lemma null_sets_restrict_space:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   349
  "\<Omega> \<in> sets M \<Longrightarrow> A \<in> null_sets (restrict_space M \<Omega>) \<longleftrightarrow> A \<subseteq> \<Omega> \<and> A \<in> null_sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   350
  by (auto simp: null_sets_def emeasure_restrict_space sets_restrict_space)
63941
f353674c2528 move absolutely_integrable_on to Equivalence_Lebesgue_Henstock_Integration, now based on the Lebesgue integral
hoelzl
parents: 63940
diff changeset
   351
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   352
lemma completion_ex_borel_measurable_real:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   353
  fixes g :: "'a \<Rightarrow> real"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   354
  assumes g: "g \<in> borel_measurable (completion M)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   355
  shows "\<exists>g'\<in>borel_measurable M. (AE x in M. g x = g' x)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   356
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   357
  have "(\<lambda>x. ennreal (g x)) \<in> completion M \<rightarrow>\<^sub>M borel" "(\<lambda>x. ennreal (- g x)) \<in> completion M \<rightarrow>\<^sub>M borel"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   358
    using g by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   359
  from this[THEN completion_ex_borel_measurable]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   360
  obtain pf nf :: "'a \<Rightarrow> ennreal"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   361
    where [measurable]: "nf \<in> M \<rightarrow>\<^sub>M borel" "pf \<in> M \<rightarrow>\<^sub>M borel"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   362
      and ae: "AE x in M. pf x = ennreal (g x)" "AE x in M. nf x = ennreal (- g x)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   363
    by (auto simp: eq_commute)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   364
  then have "AE x in M. pf x = ennreal (g x) \<and> nf x = ennreal (- g x)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   365
    by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   366
  then obtain N where "N \<in> null_sets M" "{x\<in>space M. pf x \<noteq> ennreal (g x) \<and> nf x \<noteq> ennreal (- g x)} \<subseteq> N"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   367
    by (auto elim!: AE_E)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   368
  show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   369
  proof
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   370
    let ?F = "\<lambda>x. indicator (space M - N) x * (enn2real (pf x) - enn2real (nf x))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   371
    show "?F \<in> M \<rightarrow>\<^sub>M borel"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   372
      using \<open>N \<in> null_sets M\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   373
    show "AE x in M. g x = ?F x"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   374
      using \<open>N \<in> null_sets M\<close>[THEN AE_not_in] ae AE_space
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   375
      apply eventually_elim
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   376
      subgoal for x
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   377
        by (cases "0::real" "g x" rule: linorder_le_cases) (auto simp: ennreal_neg)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   378
      done
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   379
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   380
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   381
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   382
lemma simple_function_completion: "simple_function M f \<Longrightarrow> simple_function (completion M) f"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   383
  by (simp add: simple_function_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   384
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   385
lemma simple_integral_completion:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   386
  "simple_function M f \<Longrightarrow> simple_integral (completion M) f = simple_integral M f"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   387
  unfolding simple_integral_def by simp
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   388
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   389
lemma nn_integral_completion: "nn_integral (completion M) f = nn_integral M f"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   390
  unfolding nn_integral_def
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   391
proof (safe intro!: SUP_eq)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   392
  fix s assume s: "simple_function (completion M) s" and "s \<le> f"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   393
  then obtain s' where s': "simple_function M s'" "AE x in M. s x = s' x"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   394
    by (auto dest: completion_ex_simple_function)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   395
  then obtain N where N: "N \<in> null_sets M" "{x\<in>space M. s x \<noteq> s' x} \<subseteq> N"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   396
    by (auto elim!: AE_E)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   397
  then have ae_N: "AE x in M. (s x \<noteq> s' x \<longrightarrow> x \<in> N) \<and> x \<notin> N"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   398
    by (auto dest: AE_not_in)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   399
  define s'' where "s'' x = (if x \<in> N then 0 else s x)" for x
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   400
  then have ae_s_eq_s'': "AE x in completion M. s x = s'' x"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   401
    using s' ae_N by (intro AE_completion) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   402
  have s'': "simple_function M s''"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   403
  proof (subst simple_function_cong)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   404
    show "t \<in> space M \<Longrightarrow> s'' t = (if t \<in> N then 0 else s' t)" for t
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   405
      using N by (auto simp: s''_def dest: sets.sets_into_space)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   406
    show "simple_function M (\<lambda>t. if t \<in> N then 0 else s' t)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   407
      unfolding s''_def[abs_def] using N by (auto intro!: simple_function_If s')
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   408
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   409
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   410
  show "\<exists>j\<in>{g. simple_function M g \<and> g \<le> f}. integral\<^sup>S (completion M) s \<le> integral\<^sup>S M j"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   411
  proof (safe intro!: bexI[of _ s''])
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   412
    have "integral\<^sup>S (completion M) s = integral\<^sup>S (completion M) s''"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   413
      by (intro simple_integral_cong_AE s simple_function_completion s'' ae_s_eq_s'')
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   414
    then show "integral\<^sup>S (completion M) s \<le> integral\<^sup>S M s''"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   415
      using s'' by (simp add: simple_integral_completion)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   416
    from \<open>s \<le> f\<close> show "s'' \<le> f"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   417
      unfolding s''_def le_fun_def by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   418
  qed fact
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   419
next
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   420
  fix s assume "simple_function M s" "s \<le> f"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   421
  then show "\<exists>j\<in>{g. simple_function (completion M) g \<and> g \<le> f}. integral\<^sup>S M s \<le> integral\<^sup>S (completion M) j"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   422
    by (intro bexI[of _ s]) (auto simp: simple_integral_completion simple_function_completion)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   423
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   424
63958
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   425
lemma integrable_completion:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   426
  fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   427
  shows "f \<in> M \<rightarrow>\<^sub>M borel \<Longrightarrow> integrable (completion M) f \<longleftrightarrow> integrable M f"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   428
  by (rule integrable_subalgebra[symmetric]) auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   429
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   430
lemma integral_completion:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   431
  fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   432
  assumes f: "f \<in> M \<rightarrow>\<^sub>M borel" shows "integral\<^sup>L (completion M) f = integral\<^sup>L M f"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   433
  by (rule integral_subalgebra[symmetric]) (auto intro: f)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   434
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   435
locale semifinite_measure =
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   436
  fixes M :: "'a measure"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   437
  assumes semifinite:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   438
    "\<And>A. A \<in> sets M \<Longrightarrow> emeasure M A = \<infinity> \<Longrightarrow> \<exists>B\<in>sets M. B \<subseteq> A \<and> emeasure M B < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   439
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   440
locale locally_determined_measure = semifinite_measure +
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   441
  assumes locally_determined:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   442
    "\<And>A. A \<subseteq> space M \<Longrightarrow> (\<And>B. B \<in> sets M \<Longrightarrow> emeasure M B < \<infinity> \<Longrightarrow> A \<inter> B \<in> sets M) \<Longrightarrow> A \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   443
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   444
locale cld_measure = complete_measure M + locally_determined_measure M for M :: "'a measure"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   445
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   446
definition outer_measure_of :: "'a measure \<Rightarrow> 'a set \<Rightarrow> ennreal"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   447
  where "outer_measure_of M A = (INF B : {B\<in>sets M. A \<subseteq> B}. emeasure M B)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   448
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   449
lemma outer_measure_of_eq[simp]: "A \<in> sets M \<Longrightarrow> outer_measure_of M A = emeasure M A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   450
  by (auto simp: outer_measure_of_def intro!: INF_eqI emeasure_mono)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   451
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   452
lemma outer_measure_of_mono: "A \<subseteq> B \<Longrightarrow> outer_measure_of M A \<le> outer_measure_of M B"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   453
  unfolding outer_measure_of_def by (intro INF_superset_mono) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   454
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   455
lemma outer_measure_of_attain:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   456
  assumes "A \<subseteq> space M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   457
  shows "\<exists>E\<in>sets M. A \<subseteq> E \<and> outer_measure_of M A = emeasure M E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   458
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   459
  have "emeasure M ` {B \<in> sets M. A \<subseteq> B} \<noteq> {}"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   460
    using \<open>A \<subseteq> space M\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   461
  from ennreal_Inf_countable_INF[OF this]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   462
  obtain f
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   463
    where f: "range f \<subseteq> emeasure M ` {B \<in> sets M. A \<subseteq> B}" "decseq f"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   464
      and "outer_measure_of M A = (INF i. f i)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   465
    unfolding outer_measure_of_def by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   466
  have "\<exists>E. \<forall>n. (E n \<in> sets M \<and> A \<subseteq> E n \<and> emeasure M (E n) \<le> f n) \<and> E (Suc n) \<subseteq> E n"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   467
  proof (rule dependent_nat_choice)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   468
    show "\<exists>x. x \<in> sets M \<and> A \<subseteq> x \<and> emeasure M x \<le> f 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   469
      using f(1) by (fastforce simp: image_subset_iff image_iff intro: eq_refl[OF sym])
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   470
  next
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   471
    fix E n assume "E \<in> sets M \<and> A \<subseteq> E \<and> emeasure M E \<le> f n"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   472
    moreover obtain F where "F \<in> sets M" "A \<subseteq> F" "f (Suc n) = emeasure M F"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   473
      using f(1) by (auto simp: image_subset_iff image_iff)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   474
    ultimately show "\<exists>y. (y \<in> sets M \<and> A \<subseteq> y \<and> emeasure M y \<le> f (Suc n)) \<and> y \<subseteq> E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   475
      by (auto intro!: exI[of _ "F \<inter> E"] emeasure_mono)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   476
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   477
  then obtain E
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   478
    where [simp]: "\<And>n. E n \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   479
      and "\<And>n. A \<subseteq> E n"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   480
      and le_f: "\<And>n. emeasure M (E n) \<le> f n"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   481
      and "decseq E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   482
    by (auto simp: decseq_Suc_iff)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   483
  show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   484
  proof cases
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   485
    assume fin: "\<exists>i. emeasure M (E i) < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   486
    show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   487
    proof (intro bexI[of _ "\<Inter>i. E i"] conjI)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   488
      show "A \<subseteq> (\<Inter>i. E i)" "(\<Inter>i. E i) \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   489
        using \<open>\<And>n. A \<subseteq> E n\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   490
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   491
      have " (INF i. emeasure M (E i)) \<le> outer_measure_of M A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   492
        unfolding \<open>outer_measure_of M A = (INF n. f n)\<close>
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   493
        by (intro INF_superset_mono le_f) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   494
      moreover have "outer_measure_of M A \<le> (INF i. outer_measure_of M (E i))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   495
        by (intro INF_greatest outer_measure_of_mono \<open>\<And>n. A \<subseteq> E n\<close>)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   496
      ultimately have "outer_measure_of M A = (INF i. emeasure M (E i))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   497
        by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   498
      also have "\<dots> = emeasure M (\<Inter>i. E i)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   499
        using fin by (intro INF_emeasure_decseq' \<open>decseq E\<close>) (auto simp: less_top)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   500
      finally show "outer_measure_of M A = emeasure M (\<Inter>i. E i)" .
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   501
    qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   502
  next
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   503
    assume "\<nexists>i. emeasure M (E i) < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   504
    then have "f n = \<infinity>" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   505
      using le_f by (auto simp: not_less top_unique)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   506
    moreover have "\<exists>E\<in>sets M. A \<subseteq> E \<and> f 0 = emeasure M E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   507
      using f by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   508
    ultimately show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   509
      unfolding \<open>outer_measure_of M A = (INF n. f n)\<close> by simp
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   510
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   511
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   512
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   513
lemma SUP_outer_measure_of_incseq:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   514
  assumes A: "\<And>n. A n \<subseteq> space M" and "incseq A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   515
  shows "(SUP n. outer_measure_of M (A n)) = outer_measure_of M (\<Union>i. A i)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   516
proof (rule antisym)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   517
  obtain E
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   518
    where E: "\<And>n. E n \<in> sets M" "\<And>n. A n \<subseteq> E n" "\<And>n. outer_measure_of M (A n) = emeasure M (E n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   519
    using outer_measure_of_attain[OF A] by metis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   520
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   521
  define F where "F n = (\<Inter>i\<in>{n ..}. E i)" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   522
  with E have F: "incseq F" "\<And>n. F n \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   523
    by (auto simp: incseq_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   524
  have "A n \<subseteq> F n" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   525
    using incseqD[OF \<open>incseq A\<close>, of n] \<open>\<And>n. A n \<subseteq> E n\<close> by (auto simp: F_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   526
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   527
  have eq: "outer_measure_of M (A n) = outer_measure_of M (F n)" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   528
  proof (intro antisym)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   529
    have "outer_measure_of M (F n) \<le> outer_measure_of M (E n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   530
      by (intro outer_measure_of_mono) (auto simp add: F_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   531
    with E show "outer_measure_of M (F n) \<le> outer_measure_of M (A n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   532
      by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   533
    show "outer_measure_of M (A n) \<le> outer_measure_of M (F n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   534
      by (intro outer_measure_of_mono \<open>A n \<subseteq> F n\<close>)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   535
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   536
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   537
  have "outer_measure_of M (\<Union>n. A n) \<le> outer_measure_of M (\<Union>n. F n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   538
    using \<open>\<And>n. A n \<subseteq> F n\<close> by (intro outer_measure_of_mono) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   539
  also have "\<dots> = (SUP n. emeasure M (F n))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   540
    using F by (simp add: SUP_emeasure_incseq subset_eq)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   541
  finally show "outer_measure_of M (\<Union>n. A n) \<le> (SUP n. outer_measure_of M (A n))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   542
    by (simp add: eq F)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   543
qed (auto intro: SUP_least outer_measure_of_mono)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   544
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   545
definition measurable_envelope :: "'a measure \<Rightarrow> 'a set \<Rightarrow> 'a set \<Rightarrow> bool"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   546
  where "measurable_envelope M A E \<longleftrightarrow>
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   547
    (A \<subseteq> E \<and> E \<in> sets M \<and> (\<forall>F\<in>sets M. emeasure M (F \<inter> E) = outer_measure_of M (F \<inter> A)))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   548
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   549
lemma measurable_envelopeD:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   550
  assumes "measurable_envelope M A E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   551
  shows "A \<subseteq> E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   552
    and "E \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   553
    and "\<And>F. F \<in> sets M \<Longrightarrow> emeasure M (F \<inter> E) = outer_measure_of M (F \<inter> A)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   554
    and "A \<subseteq> space M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   555
  using assms sets.sets_into_space[of E] by (auto simp: measurable_envelope_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   556
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   557
lemma measurable_envelopeD1:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   558
  assumes E: "measurable_envelope M A E" and F: "F \<in> sets M" "F \<subseteq> E - A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   559
  shows "emeasure M F = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   560
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   561
  have "emeasure M F = emeasure M (F \<inter> E)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   562
    using F by (intro arg_cong2[where f=emeasure]) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   563
  also have "\<dots> = outer_measure_of M (F \<inter> A)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   564
    using measurable_envelopeD[OF E] \<open>F \<in> sets M\<close> by (auto simp: measurable_envelope_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   565
  also have "\<dots> = outer_measure_of M {}"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   566
    using \<open>F \<subseteq> E - A\<close> by (intro arg_cong2[where f=outer_measure_of]) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   567
  finally show "emeasure M F = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   568
    by simp
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   569
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   570
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   571
lemma measurable_envelope_eq1:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   572
  assumes "A \<subseteq> E" "E \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   573
  shows "measurable_envelope M A E \<longleftrightarrow> (\<forall>F\<in>sets M. F \<subseteq> E - A \<longrightarrow> emeasure M F = 0)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   574
proof safe
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   575
  assume *: "\<forall>F\<in>sets M. F \<subseteq> E - A \<longrightarrow> emeasure M F = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   576
  show "measurable_envelope M A E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   577
    unfolding measurable_envelope_def
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   578
  proof (rule ccontr, auto simp add: \<open>E \<in> sets M\<close> \<open>A \<subseteq> E\<close>)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   579
    fix F assume "F \<in> sets M" "emeasure M (F \<inter> E) \<noteq> outer_measure_of M (F \<inter> A)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   580
    then have "outer_measure_of M (F \<inter> A) < emeasure M (F \<inter> E)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   581
      using outer_measure_of_mono[of "F \<inter> A" "F \<inter> E" M] \<open>A \<subseteq> E\<close> \<open>E \<in> sets M\<close> by (auto simp: less_le)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   582
    then obtain G where G: "G \<in> sets M" "F \<inter> A \<subseteq> G" and less: "emeasure M G < emeasure M (E \<inter> F)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   583
      unfolding outer_measure_of_def INF_less_iff by (auto simp: ac_simps)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   584
    have le: "emeasure M (G \<inter> E \<inter> F) \<le> emeasure M G"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   585
      using \<open>E \<in> sets M\<close> \<open>G \<in> sets M\<close> \<open>F \<in> sets M\<close> by (auto intro!: emeasure_mono)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   586
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   587
    from G have "E \<inter> F - G \<in> sets M" "E \<inter> F - G \<subseteq> E - A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   588
      using \<open>F \<in> sets M\<close> \<open>E \<in> sets M\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   589
    with * have "0 = emeasure M (E \<inter> F - G)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   590
      by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   591
    also have "E \<inter> F - G = E \<inter> F - (G \<inter> E \<inter> F)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   592
      by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   593
    also have "emeasure M (E \<inter> F - (G \<inter> E \<inter> F)) = emeasure M (E \<inter> F) - emeasure M (G \<inter> E \<inter> F)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   594
      using \<open>E \<in> sets M\<close> \<open>F \<in> sets M\<close> le less G by (intro emeasure_Diff) (auto simp: top_unique)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   595
    also have "\<dots> > 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   596
      using le less by (intro diff_gr0_ennreal) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   597
    finally show False by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   598
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   599
qed (rule measurable_envelopeD1)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   600
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   601
lemma measurable_envelopeD2:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   602
  assumes E: "measurable_envelope M A E" shows "emeasure M E = outer_measure_of M A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   603
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   604
  from \<open>measurable_envelope M A E\<close> have "emeasure M (E \<inter> E) = outer_measure_of M (E \<inter> A)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   605
    by (auto simp: measurable_envelope_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   606
  with measurable_envelopeD[OF E] show "emeasure M E = outer_measure_of M A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   607
    by (auto simp: Int_absorb1)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   608
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   609
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   610
lemma measurable_envelope_eq2:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   611
  assumes "A \<subseteq> E" "E \<in> sets M" "emeasure M E < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   612
  shows "measurable_envelope M A E \<longleftrightarrow> (emeasure M E = outer_measure_of M A)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   613
proof safe
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   614
  assume *: "emeasure M E = outer_measure_of M A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   615
  show "measurable_envelope M A E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   616
    unfolding measurable_envelope_eq1[OF \<open>A \<subseteq> E\<close> \<open>E \<in> sets M\<close>]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   617
  proof (intro conjI ballI impI assms)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   618
    fix F assume F: "F \<in> sets M" "F \<subseteq> E - A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   619
    with \<open>E \<in> sets M\<close> have le: "emeasure M F \<le> emeasure M  E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   620
      by (intro emeasure_mono) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   621
    from F \<open>A \<subseteq> E\<close> have "outer_measure_of M A \<le> outer_measure_of M (E - F)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   622
      by (intro outer_measure_of_mono) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   623
    then have "emeasure M E - 0 \<le> emeasure M (E - F)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   624
      using * \<open>E \<in> sets M\<close> \<open>F \<in> sets M\<close> by simp
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   625
    also have "\<dots> = emeasure M E - emeasure M F"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   626
      using \<open>E \<in> sets M\<close> \<open>emeasure M E < \<infinity>\<close> F le by (intro emeasure_Diff) (auto simp: top_unique)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   627
    finally show "emeasure M F = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   628
      using ennreal_mono_minus_cancel[of "emeasure M E" 0 "emeasure M F"] le assms by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   629
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   630
qed (auto intro: measurable_envelopeD2)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   631
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   632
lemma measurable_envelopeI_countable:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   633
  fixes A :: "nat \<Rightarrow> 'a set"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   634
  assumes E: "\<And>n. measurable_envelope M (A n) (E n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   635
  shows "measurable_envelope M (\<Union>n. A n) (\<Union>n. E n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   636
proof (subst measurable_envelope_eq1)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   637
  show "(\<Union>n. A n) \<subseteq> (\<Union>n. E n)" "(\<Union>n. E n) \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   638
    using measurable_envelopeD(1,2)[OF E] by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   639
  show "\<forall>F\<in>sets M. F \<subseteq> (\<Union>n. E n) - (\<Union>n. A n) \<longrightarrow> emeasure M F = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   640
  proof safe
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   641
    fix F assume F: "F \<in> sets M" "F \<subseteq> (\<Union>n. E n) - (\<Union>n. A n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   642
    then have "F \<inter> E n \<in> sets M" "F \<inter> E n \<subseteq> E n - A n" "F \<subseteq> (\<Union>n. E n)" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   643
      using measurable_envelopeD(1,2)[OF E] by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   644
    then have "emeasure M (\<Union>n. F \<inter> E n) = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   645
      by (intro emeasure_UN_eq_0 measurable_envelopeD1[OF E]) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   646
    then show "emeasure M F = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   647
      using \<open>F \<subseteq> (\<Union>n. E n)\<close> by (auto simp: Int_absorb2)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   648
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   649
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   650
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   651
lemma measurable_envelopeI_countable_cover:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   652
  fixes A and C :: "nat \<Rightarrow> 'a set"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   653
  assumes C: "A \<subseteq> (\<Union>n. C n)" "\<And>n. C n \<in> sets M" "\<And>n. emeasure M (C n) < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   654
  shows "\<exists>E\<subseteq>(\<Union>n. C n). measurable_envelope M A E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   655
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   656
  have "A \<inter> C n \<subseteq> space M" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   657
    using \<open>C n \<in> sets M\<close> by (auto dest: sets.sets_into_space)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   658
  then have "\<forall>n. \<exists>E\<in>sets M. A \<inter> C n \<subseteq> E \<and> outer_measure_of M (A \<inter> C n) = emeasure M E"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   659
    using outer_measure_of_attain[of "A \<inter> C n" M for n] by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   660
  then obtain E
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   661
    where E: "\<And>n. E n \<in> sets M" "\<And>n. A \<inter> C n \<subseteq> E n"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   662
      and eq: "\<And>n. outer_measure_of M (A \<inter> C n) = emeasure M (E n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   663
    by metis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   664
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   665
  have "outer_measure_of M (A \<inter> C n) \<le> outer_measure_of M (E n \<inter> C n)" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   666
    using E by (intro outer_measure_of_mono) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   667
  moreover have "outer_measure_of M (E n \<inter> C n) \<le> outer_measure_of M (E n)" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   668
    by (intro outer_measure_of_mono) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   669
  ultimately have eq: "outer_measure_of M (A \<inter> C n) = emeasure M (E n \<inter> C n)" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   670
    using E C by (intro antisym) (auto simp: eq)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   671
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   672
  { fix n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   673
    have "outer_measure_of M (A \<inter> C n) \<le> outer_measure_of M (C n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   674
      by (intro outer_measure_of_mono) simp
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   675
    also have "\<dots> < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   676
      using assms by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   677
    finally have "emeasure M (E n \<inter> C n) < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   678
      using eq by simp }
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   679
  then have "measurable_envelope M (\<Union>n. A \<inter> C n) (\<Union>n. E n \<inter> C n)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   680
    using E C by (intro measurable_envelopeI_countable measurable_envelope_eq2[THEN iffD2]) (auto simp: eq)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   681
  with \<open>A \<subseteq> (\<Union>n. C n)\<close> show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   682
    by (intro exI[of _ "(\<Union>n. E n \<inter> C n)"]) (auto simp add: Int_absorb2)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   683
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   684
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   685
lemma (in complete_measure) complete_sets_sandwich:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   686
  assumes [measurable]: "A \<in> sets M" "C \<in> sets M" and subset: "A \<subseteq> B" "B \<subseteq> C"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   687
    and measure: "emeasure M A = emeasure M C" "emeasure M A < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   688
  shows "B \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   689
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   690
  have "B - A \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   691
  proof (rule complete)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   692
    show "B - A \<subseteq> C - A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   693
      using subset by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   694
    show "C - A \<in> null_sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   695
      using measure subset by(simp add: emeasure_Diff null_setsI)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   696
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   697
  then have "A \<union> (B - A) \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   698
    by measurable
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   699
  also have "A \<union> (B - A) = B"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   700
    using \<open>A \<subseteq> B\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   701
  finally show ?thesis .
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   702
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   703
63958
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   704
lemma (in complete_measure) complete_sets_sandwich_fmeasurable:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   705
  assumes [measurable]: "A \<in> fmeasurable M" "C \<in> fmeasurable M" and subset: "A \<subseteq> B" "B \<subseteq> C"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   706
    and measure: "measure M A = measure M C"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   707
  shows "B \<in> fmeasurable M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   708
proof (rule fmeasurableI2)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   709
  show "B \<subseteq> C" "C \<in> fmeasurable M" by fact+
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   710
  show "B \<in> sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   711
  proof (rule complete_sets_sandwich)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   712
    show "A \<in> sets M" "C \<in> sets M" "A \<subseteq> B" "B \<subseteq> C"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   713
      using assms by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   714
    show "emeasure M A < \<infinity>"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   715
      using \<open>A \<in> fmeasurable M\<close> by (auto simp: fmeasurable_def)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   716
    show "emeasure M A = emeasure M C"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   717
      using assms by (simp add: emeasure_eq_measure2)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   718
  qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   719
qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   720
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   721
lemma AE_completion_iff: "(AE x in completion M. P x) \<longleftrightarrow> (AE x in M. P x)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   722
proof
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   723
  assume "AE x in completion M. P x"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   724
  then obtain N where "N \<in> null_sets (completion M)" and P: "{x\<in>space M. \<not> P x} \<subseteq> N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   725
    unfolding eventually_ae_filter by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   726
  then obtain N' where N': "N' \<in> null_sets M" and "N \<subseteq> N'"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   727
    unfolding null_sets_completion_iff2 by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   728
  from P \<open>N \<subseteq> N'\<close> have "{x\<in>space M. \<not> P x} \<subseteq> N'"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   729
    by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   730
  with N' show "AE x in M. P x"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   731
    unfolding eventually_ae_filter by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   732
qed (rule AE_completion)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   733
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   734
lemma null_part_null_sets: "S \<in> completion M \<Longrightarrow> null_part M S \<in> null_sets (completion M)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   735
  by (auto dest!: null_part intro: null_sets_completionI null_sets_completion_subset)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   736
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   737
lemma AE_notin_null_part: "S \<in> completion M \<Longrightarrow> (AE x in M. x \<notin> null_part M S)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   738
  by (auto dest!: null_part_null_sets AE_not_in simp: AE_completion_iff)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   739
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   740
lemma completion_upper:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   741
  assumes A: "A \<in> sets (completion M)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   742
  shows "\<exists>A'\<in>sets M. A \<subseteq> A' \<and> emeasure (completion M) A = emeasure M A'"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   743
proof -
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   744
  from AE_notin_null_part[OF A] obtain N where N: "N \<in> null_sets M" "null_part M A \<subseteq> N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   745
    unfolding eventually_ae_filter using null_part_null_sets[OF A, THEN null_setsD2, THEN sets.sets_into_space] by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   746
  show ?thesis
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   747
  proof (intro bexI conjI)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   748
    show "A \<subseteq> main_part M A \<union> N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   749
      using \<open>null_part M A \<subseteq> N\<close> by (subst main_part_null_part_Un[symmetric, OF A]) auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   750
    show "emeasure (completion M) A = emeasure M (main_part M A \<union> N)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   751
      using A \<open>N \<in> null_sets M\<close> by (simp add: emeasure_Un_null_set)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   752
  qed (use A N in auto)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   753
qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   754
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   755
lemma AE_in_main_part:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   756
  assumes A: "A \<in> completion M" shows "AE x in M. x \<in> main_part M A \<longleftrightarrow> x \<in> A"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   757
  using AE_notin_null_part[OF A]
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   758
  by (subst (2) main_part_null_part_Un[symmetric, OF A]) auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   759
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   760
lemma completion_density_eq:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   761
  assumes ae: "AE x in M. 0 < f x" and [measurable]: "f \<in> M \<rightarrow>\<^sub>M borel"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   762
  shows "completion (density M f) = density (completion M) f"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   763
proof (intro measure_eqI)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   764
  have "N' \<in> sets M \<and> (AE x\<in>N' in M. f x = 0) \<longleftrightarrow> N' \<in> null_sets M" for N'
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   765
  proof safe
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   766
    assume N': "N' \<in> sets M" and ae_N': "AE x\<in>N' in M. f x = 0"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   767
    from ae_N' ae have "AE x in M. x \<notin> N'"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   768
      by eventually_elim auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   769
    then show "N' \<in> null_sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   770
      using N' by (simp add: AE_iff_null_sets)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   771
  next
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   772
    assume N': "N' \<in> null_sets M" then show "N' \<in> sets M" "AE x\<in>N' in M. f x = 0"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   773
      using ae AE_not_in[OF N'] by (auto simp: less_le)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   774
  qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   775
  then show sets_eq: "sets (completion (density M f)) = sets (density (completion M) f)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   776
    by (simp add: sets_completion null_sets_density_iff)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   777
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   778
  fix A assume A: \<open>A \<in> completion (density M f)\<close>
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   779
  moreover
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   780
  have "A \<in> completion M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   781
    using A unfolding sets_eq by simp
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   782
  moreover
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   783
  have "main_part (density M f) A \<in> M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   784
    using A main_part_sets[of A "density M f"] unfolding sets_density sets_eq by simp
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   785
  moreover have "AE x in M. x \<in> main_part (density M f) A \<longleftrightarrow> x \<in> A"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   786
    using AE_in_main_part[OF \<open>A \<in> completion (density M f)\<close>] ae by (auto simp add: AE_density)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   787
  ultimately show "emeasure (completion (density M f)) A = emeasure (density (completion M) f) A"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   788
    by (auto simp add: emeasure_density measurable_completion nn_integral_completion intro!: nn_integral_cong_AE)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   789
qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   790
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   791
lemma null_sets_subset: "A \<subseteq> B \<Longrightarrow> A \<in> sets M \<Longrightarrow> B \<in> null_sets M \<Longrightarrow> A \<in> null_sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   792
  using emeasure_mono[of A B M] by (simp add: null_sets_def)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   793
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   794
lemma (in complete_measure) complete2: "A \<subseteq> B \<Longrightarrow> B \<in> null_sets M \<Longrightarrow> A \<in> null_sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   795
  using complete[of A B] null_sets_subset[of A B M] by simp
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   796
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   797
lemma (in complete_measure) vimage_null_part_null_sets:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   798
  assumes f: "f \<in> M \<rightarrow>\<^sub>M N" and eq: "null_sets N \<subseteq> null_sets (distr M N f)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   799
    and A: "A \<in> completion N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   800
  shows "f -` null_part N A \<inter> space M \<in> null_sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   801
proof -
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   802
  obtain N' where "N' \<in> null_sets N" "null_part N A \<subseteq> N'"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   803
    using null_part[OF A] by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   804
  then have N': "N' \<in> null_sets (distr M N f)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   805
    using eq by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   806
  show ?thesis
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   807
  proof (rule complete2)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   808
    show "f -` null_part N A \<inter> space M \<subseteq> f -` N' \<inter> space M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   809
      using \<open>null_part N A \<subseteq> N'\<close> by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   810
    show "f -` N' \<inter> space M \<in> null_sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   811
      using f N' by (auto simp: null_sets_def emeasure_distr)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   812
  qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   813
qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   814
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   815
lemma (in complete_measure) vimage_null_part_sets:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   816
  "f \<in> M \<rightarrow>\<^sub>M N \<Longrightarrow> null_sets N \<subseteq> null_sets (distr M N f) \<Longrightarrow> A \<in> completion N \<Longrightarrow>
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   817
  f -` null_part N A \<inter> space M \<in> sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   818
  using vimage_null_part_null_sets[of f N A] by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   819
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   820
lemma (in complete_measure) measurable_completion2:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   821
  assumes f: "f \<in> M \<rightarrow>\<^sub>M N" and null_sets: "null_sets N \<subseteq> null_sets (distr M N f)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   822
  shows "f \<in> M \<rightarrow>\<^sub>M completion N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   823
proof (rule measurableI)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   824
  show "x \<in> space M \<Longrightarrow> f x \<in> space (completion N)" for x
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   825
    using f[THEN measurable_space] by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   826
  fix A assume A: "A \<in> sets (completion N)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   827
  have "f -` A \<inter> space M = (f -` main_part N A \<inter> space M) \<union> (f -` null_part N A \<inter> space M)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   828
    using main_part_null_part_Un[OF A] by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   829
  then show "f -` A \<inter> space M \<in> sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   830
    using f A null_sets by (auto intro: vimage_null_part_sets measurable_sets)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   831
qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   832
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   833
lemma (in complete_measure) completion_distr_eq:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   834
  assumes X: "X \<in> M \<rightarrow>\<^sub>M N" and null_sets: "null_sets (distr M N X) = null_sets N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   835
  shows "completion (distr M N X) = distr M (completion N) X"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   836
proof (rule measure_eqI)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   837
  show eq: "sets (completion (distr M N X)) = sets (distr M (completion N) X)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   838
    by (simp add: sets_completion null_sets)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   839
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   840
  fix A assume A: "A \<in> completion (distr M N X)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   841
  moreover have A': "A \<in> completion N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   842
    using A by (simp add: eq)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   843
  moreover have "main_part (distr M N X) A \<in> sets N"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   844
    using main_part_sets[OF A] by simp
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   845
  moreover have "X -` A \<inter> space M = (X -` main_part (distr M N X) A \<inter> space M) \<union> (X -` null_part (distr M N X) A \<inter> space M)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   846
    using main_part_null_part_Un[OF A] by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   847
  moreover have "X -` null_part (distr M N X) A \<inter> space M \<in> null_sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   848
    using X A by (intro vimage_null_part_null_sets) (auto cong: distr_cong)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   849
  ultimately show "emeasure (completion (distr M N X)) A = emeasure (distr M (completion N) X) A"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   850
    using X by (auto simp: emeasure_distr measurable_completion null_sets measurable_completion2
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   851
                     intro!: emeasure_Un_null_set[symmetric])
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   852
qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   853
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   854
lemma distr_completion: "X \<in> M \<rightarrow>\<^sub>M N \<Longrightarrow> distr (completion M) N X = distr M N X"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   855
  by (intro measure_eqI) (auto simp: emeasure_distr measurable_completion)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   856
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   857
proposition (in complete_measure) fmeasurable_inner_outer:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   858
  "S \<in> fmeasurable M \<longleftrightarrow>
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   859
    (\<forall>e>0. \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>measure M T - measure M U\<bar> < e)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   860
  (is "_ \<longleftrightarrow> ?approx")
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   861
proof safe
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   862
  let ?\<mu> = "measure M" let ?D = "\<lambda>T U . \<bar>?\<mu> T - ?\<mu> U\<bar>"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   863
  assume ?approx
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   864
  have "\<exists>A. \<forall>n. (fst (A n) \<in> fmeasurable M \<and> snd (A n) \<in> fmeasurable M \<and> fst (A n) \<subseteq> S \<and> S \<subseteq> snd (A n) \<and>
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   865
    ?D (fst (A n)) (snd (A n)) < 1/Suc n) \<and> (fst (A n) \<subseteq> fst (A (Suc n)) \<and> snd (A (Suc n)) \<subseteq> snd (A n))"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   866
    (is "\<exists>A. \<forall>n. ?P n (A n) \<and> ?Q (A n) (A (Suc n))")
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   867
  proof (intro dependent_nat_choice)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   868
    show "\<exists>A. ?P 0 A"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   869
      using \<open>?approx\<close>[THEN spec, of 1] by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   870
  next
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   871
    fix A n assume "?P n A"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   872
    moreover
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   873
    from \<open>?approx\<close>[THEN spec, of "1/Suc (Suc n)"]
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   874
    obtain T U where *: "T \<in> fmeasurable M" "U \<in> fmeasurable M" "T \<subseteq> S" "S \<subseteq> U" "?D T U < 1 / Suc (Suc n)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   875
      by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   876
    ultimately have "?\<mu> T \<le> ?\<mu> (T \<union> fst A)" "?\<mu> (U \<inter> snd A) \<le> ?\<mu> U"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   877
      "?\<mu> T \<le> ?\<mu> U" "?\<mu> (T \<union> fst A) \<le> ?\<mu> (U \<inter> snd A)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   878
      by (auto intro!: measure_mono_fmeasurable)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   879
    then have "?D (T \<union> fst A) (U \<inter> snd A) \<le> ?D T U"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   880
      by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   881
    also have "?D T U < 1/Suc (Suc n)" by fact
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   882
    finally show "\<exists>B. ?P (Suc n) B \<and> ?Q A B"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   883
      using \<open>?P n A\<close> *
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   884
      by (intro exI[of _ "(T \<union> fst A, U \<inter> snd A)"] conjI) auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   885
  qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   886
  then obtain A
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   887
    where lm: "\<And>n. fst (A n) \<in> fmeasurable M" "\<And>n. snd (A n) \<in> fmeasurable M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   888
      and set_bound: "\<And>n. fst (A n) \<subseteq> S" "\<And>n. S \<subseteq> snd (A n)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   889
      and mono: "\<And>n. fst (A n) \<subseteq> fst (A (Suc n))" "\<And>n. snd (A (Suc n)) \<subseteq> snd (A n)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   890
      and bound: "\<And>n. ?D (fst (A n)) (snd (A n)) < 1/Suc n"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   891
    by metis
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   892
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   893
  have INT_sA: "(\<Inter>n. snd (A n)) \<in> fmeasurable M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   894
    using lm by (intro fmeasurable_INT[of _ 0]) auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   895
  have UN_fA: "(\<Union>n. fst (A n)) \<in> fmeasurable M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   896
    using lm order_trans[OF set_bound(1) set_bound(2)[of 0]] by (intro fmeasurable_UN[of _ _ "snd (A 0)"]) auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   897
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   898
  have "(\<lambda>n. ?\<mu> (fst (A n)) - ?\<mu> (snd (A n))) \<longlonglongrightarrow> 0"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   899
    using bound
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   900
    by (subst tendsto_rabs_zero_iff[symmetric])
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   901
       (intro tendsto_sandwich[OF _ _ tendsto_const LIMSEQ_inverse_real_of_nat];
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   902
        auto intro!: always_eventually less_imp_le simp: divide_inverse)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   903
  moreover
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   904
  have "(\<lambda>n. ?\<mu> (fst (A n)) - ?\<mu> (snd (A n))) \<longlonglongrightarrow> ?\<mu> (\<Union>n. fst (A n)) - ?\<mu> (\<Inter>n. snd (A n))"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   905
  proof (intro tendsto_diff Lim_measure_incseq Lim_measure_decseq)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   906
    show "range (\<lambda>i. fst (A i)) \<subseteq> sets M" "range (\<lambda>i. snd (A i)) \<subseteq> sets M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   907
      "incseq (\<lambda>i. fst (A i))" "decseq (\<lambda>n. snd (A n))"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   908
      using mono lm by (auto simp: incseq_Suc_iff decseq_Suc_iff intro!: measure_mono_fmeasurable)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   909
    show "emeasure M (\<Union>x. fst (A x)) \<noteq> \<infinity>" "emeasure M (snd (A n)) \<noteq> \<infinity>" for n
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   910
      using lm(2)[of n] UN_fA by (auto simp: fmeasurable_def)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   911
  qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   912
  ultimately have eq: "0 = ?\<mu> (\<Union>n. fst (A n)) - ?\<mu> (\<Inter>n. snd (A n))"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   913
    by (rule LIMSEQ_unique)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   914
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   915
  show "S \<in> fmeasurable M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   916
    using UN_fA INT_sA
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   917
  proof (rule complete_sets_sandwich_fmeasurable)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   918
    show "(\<Union>n. fst (A n)) \<subseteq> S" "S \<subseteq> (\<Inter>n. snd (A n))"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   919
      using set_bound by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   920
    show "?\<mu> (\<Union>n. fst (A n)) = ?\<mu> (\<Inter>n. snd (A n))"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   921
      using eq by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   922
  qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   923
qed (auto intro!: bexI[of _ S])
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   924
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   925
lemma (in complete_measure) fmeasurable_measure_inner_outer:
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   926
   "(S \<in> fmeasurable M \<and> m = measure M S) \<longleftrightarrow>
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   927
      (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < measure M T) \<and>
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   928
      (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> measure M U < m + e)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   929
    (is "?lhs = ?rhs")
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   930
proof
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   931
  assume RHS: ?rhs
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   932
  then have T: "\<And>e. 0 < e \<longrightarrow> (\<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < measure M T)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   933
        and U: "\<And>e. 0 < e \<longrightarrow> (\<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> measure M U < m + e)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   934
    by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   935
  have "S \<in> fmeasurable M"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   936
  proof (subst fmeasurable_inner_outer, safe)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   937
    fix e::real assume "0 < e"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   938
    with RHS obtain T U where T: "T \<in> fmeasurable M" "T \<subseteq> S" "m - e/2 < measure M T"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   939
                          and U: "U \<in> fmeasurable M" "S \<subseteq> U" "measure M U < m + e/2"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   940
      by (meson half_gt_zero)+
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   941
    moreover have "measure M U - measure M T < (m + e/2) - (m - e/2)"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   942
      by (intro diff_strict_mono) fact+
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   943
    moreover have "measure M T \<le> measure M U"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   944
      using T U by (intro measure_mono_fmeasurable) auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   945
    ultimately show "\<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>measure M T - measure M U\<bar> < e"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   946
      apply (rule_tac bexI[OF _ \<open>T \<in> fmeasurable M\<close>])
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   947
      apply (rule_tac bexI[OF _ \<open>U \<in> fmeasurable M\<close>])
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   948
      by auto
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   949
  qed
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   950
  moreover have "m = measure M S"
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   951
    using \<open>S \<in> fmeasurable M\<close> U[of "measure M S - m"] T[of "m - measure M S"]
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   952
    by (cases m "measure M S" rule: linorder_cases)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   953
       (auto simp: not_le[symmetric] measure_mono_fmeasurable)
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   954
  ultimately show ?lhs
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   955
    by simp
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   956
qed (auto intro!: bexI[of _ S])
02de4a58e210 HOL-Analysis: add measurable sets with finite measures, prove affine transformation rule for the Lebesgue measure
hoelzl
parents: 63941
diff changeset
   957
63940
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   958
lemma (in cld_measure) notin_sets_outer_measure_of_cover:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   959
  assumes E: "E \<subseteq> space M" "E \<notin> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   960
  shows "\<exists>B\<in>sets M. 0 < emeasure M B \<and> emeasure M B < \<infinity> \<and>
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   961
    outer_measure_of M (B \<inter> E) = emeasure M B \<and> outer_measure_of M (B - E) = emeasure M B"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   962
proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   963
  from locally_determined[OF \<open>E \<subseteq> space M\<close>] \<open>E \<notin> sets M\<close>
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   964
  obtain F
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   965
    where [measurable]: "F \<in> sets M" and "emeasure M F < \<infinity>" "E \<inter> F \<notin> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   966
    by blast
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   967
  then obtain H H'
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   968
    where H: "measurable_envelope M (F \<inter> E) H" and H': "measurable_envelope M (F - E) H'"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   969
    using measurable_envelopeI_countable_cover[of "F \<inter> E" "\<lambda>_. F" M]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   970
       measurable_envelopeI_countable_cover[of "F - E" "\<lambda>_. F" M]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   971
    by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   972
  note measurable_envelopeD(2)[OF H', measurable] measurable_envelopeD(2)[OF H, measurable]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   973
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   974
  from measurable_envelopeD(1)[OF H'] measurable_envelopeD(1)[OF H]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   975
  have subset: "F - H' \<subseteq> F \<inter> E" "F \<inter> E \<subseteq> F \<inter> H"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   976
    by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   977
  moreover define G where "G = (F \<inter> H) - (F - H')"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   978
  ultimately have G: "G = F \<inter> H \<inter> H'"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   979
    by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   980
  have "emeasure M (F \<inter> H) \<noteq> 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   981
  proof
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   982
    assume "emeasure M (F \<inter> H) = 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   983
    then have "F \<inter> H \<in> null_sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   984
      by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   985
    with \<open>E \<inter> F \<notin> sets M\<close> show False
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   986
      using complete[OF \<open>F \<inter> E \<subseteq> F \<inter> H\<close>] by (auto simp: Int_commute)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   987
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   988
  moreover
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   989
  have "emeasure M (F - H') \<noteq> emeasure M (F \<inter> H)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   990
  proof
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   991
    assume "emeasure M (F - H') = emeasure M (F \<inter> H)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   992
    with \<open>E \<inter> F \<notin> sets M\<close> emeasure_mono[of "F \<inter> H" F M] \<open>emeasure M F < \<infinity>\<close>
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   993
    have "F \<inter> E \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   994
      by (intro complete_sets_sandwich[OF _ _ subset]) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   995
    with \<open>E \<inter> F \<notin> sets M\<close> show False
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   996
      by (simp add: Int_commute)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   997
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   998
  moreover have "emeasure M (F - H') \<le> emeasure M (F \<inter> H)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
   999
    using subset by (intro emeasure_mono) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1000
  ultimately have "emeasure M G \<noteq> 0"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1001
    unfolding G_def using subset
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1002
    by (subst emeasure_Diff) (auto simp: top_unique diff_eq_0_iff_ennreal)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1003
  show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1004
  proof (intro bexI conjI)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1005
    have "emeasure M G \<le> emeasure M F"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1006
      unfolding G by (auto intro!: emeasure_mono)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1007
    with \<open>emeasure M F < \<infinity>\<close> show "0 < emeasure M G" "emeasure M G < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1008
      using \<open>emeasure M G \<noteq> 0\<close> by (auto simp: zero_less_iff_neq_zero)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1009
    show [measurable]: "G \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1010
      unfolding G by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1011
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1012
    have "emeasure M G = outer_measure_of M (F \<inter> H' \<inter> (F \<inter> E))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1013
      using measurable_envelopeD(3)[OF H, of "F \<inter> H'"] unfolding G by (simp add: ac_simps)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1014
    also have "\<dots> \<le> outer_measure_of M (G \<inter> E)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1015
      using measurable_envelopeD(1)[OF H] by (intro outer_measure_of_mono) (auto simp: G)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1016
    finally show "outer_measure_of M (G \<inter> E) = emeasure M G"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1017
      using outer_measure_of_mono[of "G \<inter> E" G M] by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1018
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1019
    have "emeasure M G = outer_measure_of M (F \<inter> H \<inter> (F - E))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1020
      using measurable_envelopeD(3)[OF H', of "F \<inter> H"] unfolding G by (simp add: ac_simps)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1021
    also have "\<dots> \<le> outer_measure_of M (G - E)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1022
      using measurable_envelopeD(1)[OF H'] by (intro outer_measure_of_mono) (auto simp: G)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1023
    finally show "outer_measure_of M (G - E) = emeasure M G"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1024
      using outer_measure_of_mono[of "G - E" G M] by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1025
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1026
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1027
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1028
text \<open>The following theorem is a specialization of D.H. Fremlin, Measure Theory vol 4I (413G). We
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1029
  only show one direction and do not use a inner regular family $K$.\<close>
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1030
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1031
lemma (in cld_measure) borel_measurable_cld:
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1032
  fixes f :: "'a \<Rightarrow> real"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1033
  assumes "\<And>A a b. A \<in> sets M \<Longrightarrow> 0 < emeasure M A \<Longrightarrow> emeasure M A < \<infinity> \<Longrightarrow> a < b \<Longrightarrow>
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1034
      min (outer_measure_of M {x\<in>A. f x \<le> a}) (outer_measure_of M {x\<in>A. b \<le> f x}) < emeasure M A"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1035
  shows "f \<in> M \<rightarrow>\<^sub>M borel"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1036
proof (rule ccontr)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1037
  let ?E = "\<lambda>a. {x\<in>space M. f x \<le> a}" and ?F = "\<lambda>a. {x\<in>space M. a \<le> f x}"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1038
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1039
  assume "f \<notin> M \<rightarrow>\<^sub>M borel"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1040
  then obtain a where "?E a \<notin> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1041
    unfolding borel_measurable_iff_le by blast
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1042
  from notin_sets_outer_measure_of_cover[OF _ this]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1043
  obtain K
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1044
    where K: "K \<in> sets M" "0 < emeasure M K" "emeasure M K < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1045
      and eq1: "outer_measure_of M (K \<inter> ?E a) = emeasure M K"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1046
      and eq2: "outer_measure_of M (K - ?E a) = emeasure M K"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1047
    by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1048
  then have me_K: "measurable_envelope M (K \<inter> ?E a) K"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1049
    by (subst measurable_envelope_eq2) auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1050
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1051
  define b where "b n = a + inverse (real (Suc n))" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1052
  have "(SUP n. outer_measure_of M (K \<inter> ?F (b n))) = outer_measure_of M (\<Union>n. K \<inter> ?F (b n))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1053
  proof (intro SUP_outer_measure_of_incseq)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1054
    have "x \<le> y \<Longrightarrow> b y \<le> b x" for x y
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1055
      by (auto simp: b_def field_simps)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1056
    then show "incseq (\<lambda>n. K \<inter> {x \<in> space M. b n \<le> f x})"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1057
      by (auto simp: incseq_def intro: order_trans)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1058
  qed auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1059
  also have "(\<Union>n. K \<inter> ?F (b n)) = K - ?E a"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1060
  proof -
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1061
    have "b \<longlonglongrightarrow> a"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1062
      unfolding b_def by (rule LIMSEQ_inverse_real_of_nat_add)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1063
    then have "\<forall>n. \<not> b n \<le> f x \<Longrightarrow> f x \<le> a" for x
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1064
      by (rule LIMSEQ_le_const) (auto intro: less_imp_le simp: not_le)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1065
    moreover have "\<not> b n \<le> a" for n
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1066
      by (auto simp: b_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1067
    ultimately show ?thesis
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1068
      using \<open>K \<in> sets M\<close>[THEN sets.sets_into_space] by (auto simp: subset_eq intro: order_trans)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1069
  qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1070
  finally have "0 < (SUP n. outer_measure_of M (K \<inter> ?F (b n)))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1071
    using K by (simp add: eq2)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1072
  then obtain n where pos_b: "0 < outer_measure_of M (K \<inter> ?F (b n))" and "a < b n"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1073
    unfolding less_SUP_iff by (auto simp: b_def)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1074
  from measurable_envelopeI_countable_cover[of "K \<inter> ?F (b n)" "\<lambda>_. K" M] K
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1075
  obtain K' where "K' \<subseteq> K" and me_K': "measurable_envelope M (K \<inter> ?F (b n)) K'"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1076
    by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1077
  then have K'_le_K: "emeasure M K' \<le> emeasure M K"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1078
    by (intro emeasure_mono K)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1079
  have "K' \<in> sets M"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1080
    using me_K' by (rule measurable_envelopeD)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1081
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1082
  have "min (outer_measure_of M {x\<in>K'. f x \<le> a}) (outer_measure_of M {x\<in>K'. b n \<le> f x}) < emeasure M K'"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1083
  proof (rule assms)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1084
    show "0 < emeasure M K'" "emeasure M K' < \<infinity>"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1085
      using measurable_envelopeD2[OF me_K'] pos_b K K'_le_K by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1086
  qed fact+
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1087
  also have "{x\<in>K'. f x \<le> a} = K' \<inter> (K \<inter> ?E a)"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1088
    using \<open>K' \<in> sets M\<close>[THEN sets.sets_into_space] \<open>K' \<subseteq> K\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1089
  also have "{x\<in>K'. b n \<le> f x} = K' \<inter> (K \<inter> ?F (b n))"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1090
    using \<open>K' \<in> sets M\<close>[THEN sets.sets_into_space] \<open>K' \<subseteq> K\<close> by auto
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1091
  finally have "min (emeasure M K) (emeasure M K') < emeasure M K'"
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1092
    unfolding
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1093
      measurable_envelopeD(3)[OF me_K \<open>K' \<in> sets M\<close>, symmetric]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1094
      measurable_envelopeD(3)[OF me_K' \<open>K' \<in> sets M\<close>, symmetric]
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1095
    using \<open>K' \<subseteq> K\<close> by (simp add: Int_absorb1 Int_absorb2)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1096
  with K'_le_K show False
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1097
    by (auto simp: min_def split: if_split_asm)
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1098
qed
0d82c4c94014 prove HK-integrable implies Lebesgue measurable; prove HK-integral equals Lebesgue integral for nonneg functions
hoelzl
parents: 63627
diff changeset
  1099
40859
de0b30e6c2d2 Support product spaces on sigma finite measures.
hoelzl
parents:
diff changeset
  1100
end