src/HOL/Probability/Set_Integral.thy
author wenzelm
Mon Dec 28 01:28:28 2015 +0100 (2015-12-28)
changeset 61945 1135b8de26c3
parent 61880 ff4d33058566
child 61969 e01015e49041
permissions -rw-r--r--
more symbols;
hoelzl@59092
     1
(*  Title:      HOL/Probability/Set_Integral.thy
hoelzl@59092
     2
    Author:     Jeremy Avigad, Johannes Hölzl, Luke Serafin
hoelzl@59092
     3
hoelzl@59092
     4
Notation and useful facts for working with integrals over a set.
hoelzl@59092
     5
hoelzl@59092
     6
TODO: keep all these? Need unicode translations as well.
hoelzl@59092
     7
*)
hoelzl@59092
     8
hoelzl@59092
     9
theory Set_Integral
hoelzl@59092
    10
  imports Bochner_Integration Lebesgue_Measure
hoelzl@59092
    11
begin
hoelzl@59092
    12
lp15@60615
    13
(*
hoelzl@59092
    14
    Notation
hoelzl@59092
    15
*)
hoelzl@59092
    16
hoelzl@59092
    17
abbreviation "set_borel_measurable M A f \<equiv> (\<lambda>x. indicator A x *\<^sub>R f x) \<in> borel_measurable M"
hoelzl@59092
    18
hoelzl@59092
    19
abbreviation "set_integrable M A f \<equiv> integrable M (\<lambda>x. indicator A x *\<^sub>R f x)"
hoelzl@59092
    20
hoelzl@59092
    21
abbreviation "set_lebesgue_integral M A f \<equiv> lebesgue_integral M (\<lambda>x. indicator A x *\<^sub>R f x)"
hoelzl@59092
    22
hoelzl@59092
    23
syntax
hoelzl@59092
    24
"_ascii_set_lebesgue_integral" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'a measure \<Rightarrow> real \<Rightarrow> real"
Andreas@59358
    25
("(4LINT (_):(_)/|(_)./ _)" [0,60,110,61] 60)
hoelzl@59092
    26
hoelzl@59092
    27
translations
hoelzl@59092
    28
"LINT x:A|M. f" == "CONST set_lebesgue_integral M A (\<lambda>x. f)"
hoelzl@59092
    29
hoelzl@59092
    30
abbreviation
hoelzl@59092
    31
  "set_almost_everywhere A M P \<equiv> AE x in M. x \<in> A \<longrightarrow> P x"
hoelzl@59092
    32
hoelzl@59092
    33
syntax
hoelzl@59092
    34
  "_set_almost_everywhere" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'a \<Rightarrow> bool \<Rightarrow> bool"
Andreas@59358
    35
("AE _\<in>_ in _./ _" [0,0,0,10] 10)
hoelzl@59092
    36
hoelzl@59092
    37
translations
hoelzl@59092
    38
  "AE x\<in>A in M. P" == "CONST set_almost_everywhere A M (\<lambda>x. P)"
hoelzl@59092
    39
hoelzl@59092
    40
(*
hoelzl@59092
    41
    Notation for integration wrt lebesgue measure on the reals:
hoelzl@59092
    42
hoelzl@59092
    43
      LBINT x. f
hoelzl@59092
    44
      LBINT x : A. f
hoelzl@59092
    45
hoelzl@59092
    46
    TODO: keep all these? Need unicode.
hoelzl@59092
    47
*)
hoelzl@59092
    48
hoelzl@59092
    49
syntax
hoelzl@59092
    50
"_lebesgue_borel_integral" :: "pttrn \<Rightarrow> real \<Rightarrow> real"
Andreas@59358
    51
("(2LBINT _./ _)" [0,60] 60)
hoelzl@59092
    52
hoelzl@59092
    53
translations
hoelzl@59092
    54
"LBINT x. f" == "CONST lebesgue_integral CONST lborel (\<lambda>x. f)"
hoelzl@59092
    55
hoelzl@59092
    56
syntax
hoelzl@59092
    57
"_set_lebesgue_borel_integral" :: "pttrn \<Rightarrow> real set \<Rightarrow> real \<Rightarrow> real"
Andreas@59358
    58
("(3LBINT _:_./ _)" [0,60,61] 60)
hoelzl@59092
    59
hoelzl@59092
    60
translations
hoelzl@59092
    61
"LBINT x:A. f" == "CONST set_lebesgue_integral CONST lborel A (\<lambda>x. f)"
hoelzl@59092
    62
lp15@60615
    63
(*
lp15@60615
    64
    Basic properties
hoelzl@59092
    65
*)
hoelzl@59092
    66
hoelzl@59092
    67
(*
wenzelm@61945
    68
lemma indicator_abs_eq: "\<And>A x. \<bar>indicator A x\<bar> = ((indicator A x) :: real)"
hoelzl@59092
    69
  by (auto simp add: indicator_def)
hoelzl@59092
    70
*)
hoelzl@59092
    71
hoelzl@59092
    72
lemma set_lebesgue_integral_cong:
hoelzl@59092
    73
  assumes "A \<in> sets M" and "\<forall>x. x \<in> A \<longrightarrow> f x = g x"
hoelzl@59092
    74
  shows "(LINT x:A|M. f x) = (LINT x:A|M. g x)"
hoelzl@59092
    75
  using assms by (auto intro!: integral_cong split: split_indicator simp add: sets.sets_into_space)
hoelzl@59092
    76
hoelzl@59092
    77
lemma set_lebesgue_integral_cong_AE:
hoelzl@59092
    78
  assumes [measurable]: "A \<in> sets M" "f \<in> borel_measurable M" "g \<in> borel_measurable M"
hoelzl@59092
    79
  assumes "AE x \<in> A in M. f x = g x"
hoelzl@59092
    80
  shows "LINT x:A|M. f x = LINT x:A|M. g x"
hoelzl@59092
    81
proof-
hoelzl@59092
    82
  have "AE x in M. indicator A x *\<^sub>R f x = indicator A x *\<^sub>R g x"
hoelzl@59092
    83
    using assms by auto
hoelzl@59092
    84
  thus ?thesis by (intro integral_cong_AE) auto
hoelzl@59092
    85
qed
hoelzl@59092
    86
hoelzl@59092
    87
lemma set_integrable_cong_AE:
hoelzl@59092
    88
    "f \<in> borel_measurable M \<Longrightarrow> g \<in> borel_measurable M \<Longrightarrow>
lp15@60615
    89
    AE x \<in> A in M. f x = g x \<Longrightarrow> A \<in> sets M \<Longrightarrow>
hoelzl@59092
    90
    set_integrable M A f = set_integrable M A g"
hoelzl@59092
    91
  by (rule integrable_cong_AE) auto
hoelzl@59092
    92
lp15@60615
    93
lemma set_integrable_subset:
hoelzl@59092
    94
  fixes M A B and f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
lp15@60615
    95
  assumes "set_integrable M A f" "B \<in> sets M" "B \<subseteq> A"
hoelzl@59092
    96
  shows "set_integrable M B f"
hoelzl@59092
    97
proof -
hoelzl@59092
    98
  have "set_integrable M B (\<lambda>x. indicator A x *\<^sub>R f x)"
hoelzl@59092
    99
    by (rule integrable_mult_indicator) fact+
wenzelm@61808
   100
  with \<open>B \<subseteq> A\<close> show ?thesis
hoelzl@59092
   101
    by (simp add: indicator_inter_arith[symmetric] Int_absorb2)
hoelzl@59092
   102
qed
hoelzl@59092
   103
hoelzl@59092
   104
(* TODO: integral_cmul_indicator should be named set_integral_const *)
hoelzl@59092
   105
(* TODO: borel_integrable_atLeastAtMost should be named something like set_integrable_Icc_isCont *)
hoelzl@59092
   106
hoelzl@59092
   107
lemma set_integral_scaleR_right [simp]: "LINT t:A|M. a *\<^sub>R f t = a *\<^sub>R (LINT t:A|M. f t)"
hoelzl@59092
   108
  by (subst integral_scaleR_right[symmetric]) (auto intro!: integral_cong)
hoelzl@59092
   109
lp15@60615
   110
lemma set_integral_mult_right [simp]:
hoelzl@59092
   111
  fixes a :: "'a::{real_normed_field, second_countable_topology}"
hoelzl@59092
   112
  shows "LINT t:A|M. a * f t = a * (LINT t:A|M. f t)"
hoelzl@59092
   113
  by (subst integral_mult_right_zero[symmetric]) (auto intro!: integral_cong)
hoelzl@59092
   114
lp15@60615
   115
lemma set_integral_mult_left [simp]:
hoelzl@59092
   116
  fixes a :: "'a::{real_normed_field, second_countable_topology}"
hoelzl@59092
   117
  shows "LINT t:A|M. f t * a = (LINT t:A|M. f t) * a"
hoelzl@59092
   118
  by (subst integral_mult_left_zero[symmetric]) (auto intro!: integral_cong)
hoelzl@59092
   119
lp15@60615
   120
lemma set_integral_divide_zero [simp]:
haftmann@59867
   121
  fixes a :: "'a::{real_normed_field, field, second_countable_topology}"
hoelzl@59092
   122
  shows "LINT t:A|M. f t / a = (LINT t:A|M. f t) / a"
hoelzl@59092
   123
  by (subst integral_divide_zero[symmetric], intro integral_cong)
hoelzl@59092
   124
     (auto split: split_indicator)
hoelzl@59092
   125
hoelzl@59092
   126
lemma set_integrable_scaleR_right [simp, intro]:
hoelzl@59092
   127
  shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. a *\<^sub>R f t)"
hoelzl@59092
   128
  unfolding scaleR_left_commute by (rule integrable_scaleR_right)
hoelzl@59092
   129
hoelzl@59092
   130
lemma set_integrable_scaleR_left [simp, intro]:
hoelzl@59092
   131
  fixes a :: "_ :: {banach, second_countable_topology}"
hoelzl@59092
   132
  shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. f t *\<^sub>R a)"
hoelzl@59092
   133
  using integrable_scaleR_left[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
hoelzl@59092
   134
hoelzl@59092
   135
lemma set_integrable_mult_right [simp, intro]:
hoelzl@59092
   136
  fixes a :: "'a::{real_normed_field, second_countable_topology}"
hoelzl@59092
   137
  shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. a * f t)"
hoelzl@59092
   138
  using integrable_mult_right[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
hoelzl@59092
   139
hoelzl@59092
   140
lemma set_integrable_mult_left [simp, intro]:
hoelzl@59092
   141
  fixes a :: "'a::{real_normed_field, second_countable_topology}"
hoelzl@59092
   142
  shows "(a \<noteq> 0 \<Longrightarrow> set_integrable M A f) \<Longrightarrow> set_integrable M A (\<lambda>t. f t * a)"
hoelzl@59092
   143
  using integrable_mult_left[of a M "\<lambda>x. indicator A x *\<^sub>R f x"] by simp
hoelzl@59092
   144
hoelzl@59092
   145
lemma set_integrable_divide [simp, intro]:
haftmann@59867
   146
  fixes a :: "'a::{real_normed_field, field, second_countable_topology}"
hoelzl@59092
   147
  assumes "a \<noteq> 0 \<Longrightarrow> set_integrable M A f"
hoelzl@59092
   148
  shows "set_integrable M A (\<lambda>t. f t / a)"
hoelzl@59092
   149
proof -
hoelzl@59092
   150
  have "integrable M (\<lambda>x. indicator A x *\<^sub>R f x / a)"
hoelzl@59092
   151
    using assms by (rule integrable_divide_zero)
hoelzl@59092
   152
  also have "(\<lambda>x. indicator A x *\<^sub>R f x / a) = (\<lambda>x. indicator A x *\<^sub>R (f x / a))"
hoelzl@59092
   153
    by (auto split: split_indicator)
hoelzl@59092
   154
  finally show ?thesis .
hoelzl@59092
   155
qed
hoelzl@59092
   156
hoelzl@59092
   157
lemma set_integral_add [simp, intro]:
hoelzl@59092
   158
  fixes f g :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   159
  assumes "set_integrable M A f" "set_integrable M A g"
hoelzl@59092
   160
  shows "set_integrable M A (\<lambda>x. f x + g x)"
hoelzl@59092
   161
    and "LINT x:A|M. f x + g x = (LINT x:A|M. f x) + (LINT x:A|M. g x)"
hoelzl@59092
   162
  using assms by (simp_all add: scaleR_add_right)
hoelzl@59092
   163
hoelzl@59092
   164
lemma set_integral_diff [simp, intro]:
hoelzl@59092
   165
  assumes "set_integrable M A f" "set_integrable M A g"
hoelzl@59092
   166
  shows "set_integrable M A (\<lambda>x. f x - g x)" and "LINT x:A|M. f x - g x =
hoelzl@59092
   167
    (LINT x:A|M. f x) - (LINT x:A|M. g x)"
hoelzl@59092
   168
  using assms by (simp_all add: scaleR_diff_right)
hoelzl@59092
   169
hoelzl@59092
   170
lemma set_integral_reflect:
hoelzl@59092
   171
  fixes S and f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@59092
   172
  shows "(LBINT x : S. f x) = (LBINT x : {x. - x \<in> S}. f (- x))"
hoelzl@59092
   173
  using assms
hoelzl@59092
   174
  by (subst lborel_integral_real_affine[where c="-1" and t=0])
hoelzl@59092
   175
     (auto intro!: integral_cong split: split_indicator)
hoelzl@59092
   176
hoelzl@59092
   177
(* question: why do we have this for negation, but multiplication by a constant
hoelzl@59092
   178
   requires an integrability assumption? *)
hoelzl@59092
   179
lemma set_integral_uminus: "set_integrable M A f \<Longrightarrow> LINT x:A|M. - f x = - (LINT x:A|M. f x)"
hoelzl@59092
   180
  by (subst integral_minus[symmetric]) simp_all
hoelzl@59092
   181
hoelzl@59092
   182
lemma set_integral_complex_of_real:
hoelzl@59092
   183
  "LINT x:A|M. complex_of_real (f x) = of_real (LINT x:A|M. f x)"
hoelzl@59092
   184
  by (subst integral_complex_of_real[symmetric])
hoelzl@59092
   185
     (auto intro!: integral_cong split: split_indicator)
hoelzl@59092
   186
hoelzl@59092
   187
lemma set_integral_mono:
hoelzl@59092
   188
  fixes f g :: "_ \<Rightarrow> real"
hoelzl@59092
   189
  assumes "set_integrable M A f" "set_integrable M A g"
hoelzl@59092
   190
    "\<And>x. x \<in> A \<Longrightarrow> f x \<le> g x"
hoelzl@59092
   191
  shows "(LINT x:A|M. f x) \<le> (LINT x:A|M. g x)"
hoelzl@59092
   192
using assms by (auto intro: integral_mono split: split_indicator)
hoelzl@59092
   193
lp15@60615
   194
lemma set_integral_mono_AE:
hoelzl@59092
   195
  fixes f g :: "_ \<Rightarrow> real"
hoelzl@59092
   196
  assumes "set_integrable M A f" "set_integrable M A g"
hoelzl@59092
   197
    "AE x \<in> A in M. f x \<le> g x"
hoelzl@59092
   198
  shows "(LINT x:A|M. f x) \<le> (LINT x:A|M. g x)"
hoelzl@59092
   199
using assms by (auto intro: integral_mono_AE split: split_indicator)
hoelzl@59092
   200
hoelzl@59092
   201
lemma set_integrable_abs: "set_integrable M A f \<Longrightarrow> set_integrable M A (\<lambda>x. \<bar>f x\<bar> :: real)"
hoelzl@59092
   202
  using integrable_abs[of M "\<lambda>x. f x * indicator A x"] by (simp add: abs_mult ac_simps)
hoelzl@59092
   203
hoelzl@59092
   204
lemma set_integrable_abs_iff:
hoelzl@59092
   205
  fixes f :: "_ \<Rightarrow> real"
lp15@60615
   206
  shows "set_borel_measurable M A f \<Longrightarrow> set_integrable M A (\<lambda>x. \<bar>f x\<bar>) = set_integrable M A f"
hoelzl@59092
   207
  by (subst (2) integrable_abs_iff[symmetric]) (simp_all add: abs_mult ac_simps)
hoelzl@59092
   208
hoelzl@59092
   209
lemma set_integrable_abs_iff':
hoelzl@59092
   210
  fixes f :: "_ \<Rightarrow> real"
lp15@60615
   211
  shows "f \<in> borel_measurable M \<Longrightarrow> A \<in> sets M \<Longrightarrow>
hoelzl@59092
   212
    set_integrable M A (\<lambda>x. \<bar>f x\<bar>) = set_integrable M A f"
hoelzl@59092
   213
by (intro set_integrable_abs_iff) auto
hoelzl@59092
   214
hoelzl@59092
   215
lemma set_integrable_discrete_difference:
hoelzl@59092
   216
  fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
hoelzl@59092
   217
  assumes "countable X"
hoelzl@59092
   218
  assumes diff: "(A - B) \<union> (B - A) \<subseteq> X"
hoelzl@59092
   219
  assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
hoelzl@59092
   220
  shows "set_integrable M A f \<longleftrightarrow> set_integrable M B f"
hoelzl@59092
   221
proof (rule integrable_discrete_difference[where X=X])
hoelzl@59092
   222
  show "\<And>x. x \<in> space M \<Longrightarrow> x \<notin> X \<Longrightarrow> indicator A x *\<^sub>R f x = indicator B x *\<^sub>R f x"
hoelzl@59092
   223
    using diff by (auto split: split_indicator)
hoelzl@59092
   224
qed fact+
hoelzl@59092
   225
hoelzl@59092
   226
lemma set_integral_discrete_difference:
hoelzl@59092
   227
  fixes f :: "'a \<Rightarrow> 'b::{banach, second_countable_topology}"
hoelzl@59092
   228
  assumes "countable X"
hoelzl@59092
   229
  assumes diff: "(A - B) \<union> (B - A) \<subseteq> X"
hoelzl@59092
   230
  assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
hoelzl@59092
   231
  shows "set_lebesgue_integral M A f = set_lebesgue_integral M B f"
hoelzl@59092
   232
proof (rule integral_discrete_difference[where X=X])
hoelzl@59092
   233
  show "\<And>x. x \<in> space M \<Longrightarrow> x \<notin> X \<Longrightarrow> indicator A x *\<^sub>R f x = indicator B x *\<^sub>R f x"
hoelzl@59092
   234
    using diff by (auto split: split_indicator)
hoelzl@59092
   235
qed fact+
hoelzl@59092
   236
hoelzl@59092
   237
lemma set_integrable_Un:
hoelzl@59092
   238
  fixes f g :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   239
  assumes f_A: "set_integrable M A f" and f_B:  "set_integrable M B f"
hoelzl@59092
   240
    and [measurable]: "A \<in> sets M" "B \<in> sets M"
hoelzl@59092
   241
  shows "set_integrable M (A \<union> B) f"
hoelzl@59092
   242
proof -
hoelzl@59092
   243
  have "set_integrable M (A - B) f"
hoelzl@59092
   244
    using f_A by (rule set_integrable_subset) auto
hoelzl@59092
   245
  from integrable_add[OF this f_B] show ?thesis
hoelzl@59092
   246
    by (rule integrable_cong[THEN iffD1, rotated 2]) (auto split: split_indicator)
hoelzl@59092
   247
qed
hoelzl@59092
   248
hoelzl@59092
   249
lemma set_integrable_UN:
hoelzl@59092
   250
  fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   251
  assumes "finite I" "\<And>i. i\<in>I \<Longrightarrow> set_integrable M (A i) f"
hoelzl@59092
   252
    "\<And>i. i\<in>I \<Longrightarrow> A i \<in> sets M"
hoelzl@59092
   253
  shows "set_integrable M (\<Union>i\<in>I. A i) f"
hoelzl@59092
   254
using assms by (induct I) (auto intro!: set_integrable_Un)
hoelzl@59092
   255
hoelzl@59092
   256
lemma set_integral_Un:
hoelzl@59092
   257
  fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   258
  assumes "A \<inter> B = {}"
hoelzl@59092
   259
  and "set_integrable M A f"
hoelzl@59092
   260
  and "set_integrable M B f"
hoelzl@59092
   261
  shows "LINT x:A\<union>B|M. f x = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
hoelzl@59092
   262
by (auto simp add: indicator_union_arith indicator_inter_arith[symmetric]
hoelzl@59092
   263
      scaleR_add_left assms)
hoelzl@59092
   264
hoelzl@59092
   265
lemma set_integral_cong_set:
hoelzl@59092
   266
  fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   267
  assumes [measurable]: "set_borel_measurable M A f" "set_borel_measurable M B f"
hoelzl@59092
   268
    and ae: "AE x in M. x \<in> A \<longleftrightarrow> x \<in> B"
hoelzl@59092
   269
  shows "LINT x:B|M. f x = LINT x:A|M. f x"
hoelzl@59092
   270
proof (rule integral_cong_AE)
hoelzl@59092
   271
  show "AE x in M. indicator B x *\<^sub>R f x = indicator A x *\<^sub>R f x"
hoelzl@59092
   272
    using ae by (auto simp: subset_eq split: split_indicator)
hoelzl@59092
   273
qed fact+
hoelzl@59092
   274
hoelzl@59092
   275
lemma set_borel_measurable_subset:
hoelzl@59092
   276
  fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   277
  assumes [measurable]: "set_borel_measurable M A f" "B \<in> sets M" and "B \<subseteq> A"
hoelzl@59092
   278
  shows "set_borel_measurable M B f"
hoelzl@59092
   279
proof -
hoelzl@59092
   280
  have "set_borel_measurable M B (\<lambda>x. indicator A x *\<^sub>R f x)"
hoelzl@59092
   281
    by measurable
hoelzl@59092
   282
  also have "(\<lambda>x. indicator B x *\<^sub>R indicator A x *\<^sub>R f x) = (\<lambda>x. indicator B x *\<^sub>R f x)"
wenzelm@61808
   283
    using \<open>B \<subseteq> A\<close> by (auto simp: fun_eq_iff split: split_indicator)
hoelzl@59092
   284
  finally show ?thesis .
hoelzl@59092
   285
qed
hoelzl@59092
   286
hoelzl@59092
   287
lemma set_integral_Un_AE:
hoelzl@59092
   288
  fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   289
  assumes ae: "AE x in M. \<not> (x \<in> A \<and> x \<in> B)" and [measurable]: "A \<in> sets M" "B \<in> sets M"
hoelzl@59092
   290
  and "set_integrable M A f"
hoelzl@59092
   291
  and "set_integrable M B f"
hoelzl@59092
   292
  shows "LINT x:A\<union>B|M. f x = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
hoelzl@59092
   293
proof -
hoelzl@59092
   294
  have f: "set_integrable M (A \<union> B) f"
hoelzl@59092
   295
    by (intro set_integrable_Un assms)
hoelzl@59092
   296
  then have f': "set_borel_measurable M (A \<union> B) f"
hoelzl@59092
   297
    by (rule borel_measurable_integrable)
hoelzl@59092
   298
  have "LINT x:A\<union>B|M. f x = LINT x:(A - A \<inter> B) \<union> (B - A \<inter> B)|M. f x"
lp15@60615
   299
  proof (rule set_integral_cong_set)
hoelzl@59092
   300
    show "AE x in M. (x \<in> A - A \<inter> B \<union> (B - A \<inter> B)) = (x \<in> A \<union> B)"
hoelzl@59092
   301
      using ae by auto
hoelzl@59092
   302
    show "set_borel_measurable M (A - A \<inter> B \<union> (B - A \<inter> B)) f"
hoelzl@59092
   303
      using f' by (rule set_borel_measurable_subset) auto
hoelzl@59092
   304
  qed fact
hoelzl@59092
   305
  also have "\<dots> = (LINT x:(A - A \<inter> B)|M. f x) + (LINT x:(B - A \<inter> B)|M. f x)"
hoelzl@59092
   306
    by (auto intro!: set_integral_Un set_integrable_subset[OF f])
hoelzl@59092
   307
  also have "\<dots> = (LINT x:A|M. f x) + (LINT x:B|M. f x)"
hoelzl@59092
   308
    using ae
hoelzl@59092
   309
    by (intro arg_cong2[where f="op+"] set_integral_cong_set)
hoelzl@59092
   310
       (auto intro!: set_borel_measurable_subset[OF f'])
hoelzl@59092
   311
  finally show ?thesis .
hoelzl@59092
   312
qed
hoelzl@59092
   313
hoelzl@59092
   314
lemma set_integral_finite_Union:
hoelzl@59092
   315
  fixes f :: "_ \<Rightarrow> _ :: {banach, second_countable_topology}"
hoelzl@59092
   316
  assumes "finite I" "disjoint_family_on A I"
hoelzl@59092
   317
    and "\<And>i. i \<in> I \<Longrightarrow> set_integrable M (A i) f" "\<And>i. i \<in> I \<Longrightarrow> A i \<in> sets M"
hoelzl@59092
   318
  shows "(LINT x:(\<Union>i\<in>I. A i)|M. f x) = (\<Sum>i\<in>I. LINT x:A i|M. f x)"
hoelzl@59092
   319
  using assms
hoelzl@59092
   320
  apply induct
hoelzl@59092
   321
  apply (auto intro!: set_integral_Un set_integrable_Un set_integrable_UN simp: disjoint_family_on_def)
hoelzl@59092
   322
by (subst set_integral_Un, auto intro: set_integrable_UN)
hoelzl@59092
   323
hoelzl@59092
   324
(* TODO: find a better name? *)
hoelzl@59092
   325
lemma pos_integrable_to_top:
hoelzl@59092
   326
  fixes l::real
hoelzl@59092
   327
  assumes "\<And>i. A i \<in> sets M" "mono A"
hoelzl@59092
   328
  assumes nneg: "\<And>x i. x \<in> A i \<Longrightarrow> 0 \<le> f x"
hoelzl@59092
   329
  and intgbl: "\<And>i::nat. set_integrable M (A i) f"
hoelzl@59092
   330
  and lim: "(\<lambda>i::nat. LINT x:A i|M. f x) ----> l"
hoelzl@59092
   331
  shows "set_integrable M (\<Union>i. A i) f"
hoelzl@59092
   332
  apply (rule integrable_monotone_convergence[where f = "\<lambda>i::nat. \<lambda>x. indicator (A i) x *\<^sub>R f x" and x = l])
hoelzl@59092
   333
  apply (rule intgbl)
hoelzl@59092
   334
  prefer 3 apply (rule lim)
hoelzl@59092
   335
  apply (rule AE_I2)
wenzelm@61808
   336
  using \<open>mono A\<close> apply (auto simp: mono_def nneg split: split_indicator) []
hoelzl@59092
   337
proof (rule AE_I2)
hoelzl@59092
   338
  { fix x assume "x \<in> space M"
hoelzl@59092
   339
    show "(\<lambda>i. indicator (A i) x *\<^sub>R f x) ----> indicator (\<Union>i. A i) x *\<^sub>R f x"
hoelzl@59092
   340
    proof cases
hoelzl@59092
   341
      assume "\<exists>i. x \<in> A i"
hoelzl@59092
   342
      then guess i ..
hoelzl@59092
   343
      then have *: "eventually (\<lambda>i. x \<in> A i) sequentially"
wenzelm@61808
   344
        using \<open>x \<in> A i\<close> \<open>mono A\<close> by (auto simp: eventually_sequentially mono_def)
hoelzl@59092
   345
      show ?thesis
hoelzl@59092
   346
        apply (intro Lim_eventually)
hoelzl@59092
   347
        using *
hoelzl@59092
   348
        apply eventually_elim
hoelzl@59092
   349
        apply (auto split: split_indicator)
hoelzl@59092
   350
        done
hoelzl@59092
   351
    qed auto }
hoelzl@59092
   352
  then show "(\<lambda>x. indicator (\<Union>i. A i) x *\<^sub>R f x) \<in> borel_measurable M"
hoelzl@59092
   353
    apply (rule borel_measurable_LIMSEQ)
hoelzl@59092
   354
    apply assumption
hoelzl@59092
   355
    apply (intro borel_measurable_integrable intgbl)
hoelzl@59092
   356
    done
hoelzl@59092
   357
qed
hoelzl@59092
   358
hoelzl@59092
   359
(* Proof from Royden Real Analysis, p. 91. *)
hoelzl@59092
   360
lemma lebesgue_integral_countable_add:
hoelzl@59092
   361
  fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@59092
   362
  assumes meas[intro]: "\<And>i::nat. A i \<in> sets M"
hoelzl@59092
   363
    and disj: "\<And>i j. i \<noteq> j \<Longrightarrow> A i \<inter> A j = {}"
hoelzl@59092
   364
    and intgbl: "set_integrable M (\<Union>i. A i) f"
hoelzl@59092
   365
  shows "LINT x:(\<Union>i. A i)|M. f x = (\<Sum>i. (LINT x:(A i)|M. f x))"
hoelzl@59092
   366
proof (subst integral_suminf[symmetric])
hoelzl@59092
   367
  show int_A: "\<And>i. set_integrable M (A i) f"
hoelzl@59092
   368
    using intgbl by (rule set_integrable_subset) auto
hoelzl@59092
   369
  { fix x assume "x \<in> space M"
hoelzl@59092
   370
    have "(\<lambda>i. indicator (A i) x *\<^sub>R f x) sums (indicator (\<Union>i. A i) x *\<^sub>R f x)"
hoelzl@59092
   371
      by (intro sums_scaleR_left indicator_sums) fact }
hoelzl@59092
   372
  note sums = this
hoelzl@59092
   373
hoelzl@59092
   374
  have norm_f: "\<And>i. set_integrable M (A i) (\<lambda>x. norm (f x))"
hoelzl@59092
   375
    using int_A[THEN integrable_norm] by auto
hoelzl@59092
   376
hoelzl@59092
   377
  show "AE x in M. summable (\<lambda>i. norm (indicator (A i) x *\<^sub>R f x))"
hoelzl@59092
   378
    using disj by (intro AE_I2) (auto intro!: summable_mult2 sums_summable[OF indicator_sums])
hoelzl@59092
   379
hoelzl@59092
   380
  show "summable (\<lambda>i. LINT x|M. norm (indicator (A i) x *\<^sub>R f x))"
hoelzl@59092
   381
  proof (rule summableI_nonneg_bounded)
hoelzl@59092
   382
    fix n
hoelzl@59092
   383
    show "0 \<le> LINT x|M. norm (indicator (A n) x *\<^sub>R f x)"
hoelzl@59092
   384
      using norm_f by (auto intro!: integral_nonneg_AE)
lp15@60615
   385
hoelzl@59092
   386
    have "(\<Sum>i<n. LINT x|M. norm (indicator (A i) x *\<^sub>R f x)) =
hoelzl@59092
   387
      (\<Sum>i<n. set_lebesgue_integral M (A i) (\<lambda>x. norm (f x)))"
hoelzl@59092
   388
      by (simp add: abs_mult)
hoelzl@59092
   389
    also have "\<dots> = set_lebesgue_integral M (\<Union>i<n. A i) (\<lambda>x. norm (f x))"
hoelzl@59092
   390
      using norm_f
hoelzl@59092
   391
      by (subst set_integral_finite_Union) (auto simp: disjoint_family_on_def disj)
hoelzl@59092
   392
    also have "\<dots> \<le> set_lebesgue_integral M (\<Union>i. A i) (\<lambda>x. norm (f x))"
hoelzl@59092
   393
      using intgbl[THEN integrable_norm]
hoelzl@59092
   394
      by (intro integral_mono set_integrable_UN[of "{..<n}"] norm_f)
hoelzl@59092
   395
         (auto split: split_indicator)
hoelzl@59092
   396
    finally show "(\<Sum>i<n. LINT x|M. norm (indicator (A i) x *\<^sub>R f x)) \<le>
hoelzl@59092
   397
      set_lebesgue_integral M (\<Union>i. A i) (\<lambda>x. norm (f x))"
hoelzl@59092
   398
      by simp
hoelzl@59092
   399
  qed
hoelzl@59092
   400
  show "set_lebesgue_integral M (UNION UNIV A) f = LINT x|M. (\<Sum>i. indicator (A i) x *\<^sub>R f x)"
hoelzl@59092
   401
    apply (rule integral_cong[OF refl])
hoelzl@59092
   402
    apply (subst suminf_scaleR_left[OF sums_summable[OF indicator_sums, OF disj], symmetric])
hoelzl@59092
   403
    using sums_unique[OF indicator_sums[OF disj]]
hoelzl@59092
   404
    apply auto
hoelzl@59092
   405
    done
hoelzl@59092
   406
qed
hoelzl@59092
   407
hoelzl@59092
   408
lemma set_integral_cont_up:
hoelzl@59092
   409
  fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@59092
   410
  assumes [measurable]: "\<And>i. A i \<in> sets M" and A: "incseq A"
hoelzl@59092
   411
  and intgbl: "set_integrable M (\<Union>i. A i) f"
hoelzl@59092
   412
  shows "(\<lambda>i. LINT x:(A i)|M. f x) ----> LINT x:(\<Union>i. A i)|M. f x"
hoelzl@59092
   413
proof (intro integral_dominated_convergence[where w="\<lambda>x. indicator (\<Union>i. A i) x *\<^sub>R norm (f x)"])
hoelzl@59092
   414
  have int_A: "\<And>i. set_integrable M (A i) f"
hoelzl@59092
   415
    using intgbl by (rule set_integrable_subset) auto
hoelzl@59092
   416
  then show "\<And>i. set_borel_measurable M (A i) f" "set_borel_measurable M (\<Union>i. A i) f"
hoelzl@59092
   417
    "set_integrable M (\<Union>i. A i) (\<lambda>x. norm (f x))"
hoelzl@59092
   418
    using intgbl integrable_norm[OF intgbl] by auto
lp15@60615
   419
hoelzl@59092
   420
  { fix x i assume "x \<in> A i"
hoelzl@59092
   421
    with A have "(\<lambda>xa. indicator (A xa) x::real) ----> 1 \<longleftrightarrow> (\<lambda>xa. 1::real) ----> 1"
hoelzl@59092
   422
      by (intro filterlim_cong refl)
hoelzl@59092
   423
         (fastforce simp: eventually_sequentially incseq_def subset_eq intro!: exI[of _ i]) }
hoelzl@59092
   424
  then show "AE x in M. (\<lambda>i. indicator (A i) x *\<^sub>R f x) ----> indicator (\<Union>i. A i) x *\<^sub>R f x"
hoelzl@59092
   425
    by (intro AE_I2 tendsto_intros) (auto split: split_indicator)
hoelzl@59092
   426
qed (auto split: split_indicator)
lp15@60615
   427
hoelzl@59092
   428
(* Can the int0 hypothesis be dropped? *)
hoelzl@59092
   429
lemma set_integral_cont_down:
hoelzl@59092
   430
  fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@59092
   431
  assumes [measurable]: "\<And>i. A i \<in> sets M" and A: "decseq A"
hoelzl@59092
   432
  and int0: "set_integrable M (A 0) f"
hoelzl@59092
   433
  shows "(\<lambda>i::nat. LINT x:(A i)|M. f x) ----> LINT x:(\<Inter>i. A i)|M. f x"
hoelzl@59092
   434
proof (rule integral_dominated_convergence)
hoelzl@59092
   435
  have int_A: "\<And>i. set_integrable M (A i) f"
hoelzl@59092
   436
    using int0 by (rule set_integrable_subset) (insert A, auto simp: decseq_def)
hoelzl@59092
   437
  show "set_integrable M (A 0) (\<lambda>x. norm (f x))"
hoelzl@59092
   438
    using int0[THEN integrable_norm] by simp
hoelzl@59092
   439
  have "set_integrable M (\<Inter>i. A i) f"
hoelzl@59092
   440
    using int0 by (rule set_integrable_subset) (insert A, auto simp: decseq_def)
hoelzl@59092
   441
  with int_A show "set_borel_measurable M (\<Inter>i. A i) f" "\<And>i. set_borel_measurable M (A i) f"
hoelzl@59092
   442
    by auto
hoelzl@59092
   443
  show "\<And>i. AE x in M. norm (indicator (A i) x *\<^sub>R f x) \<le> indicator (A 0) x *\<^sub>R norm (f x)"
hoelzl@59092
   444
    using A by (auto split: split_indicator simp: decseq_def)
hoelzl@59092
   445
  { fix x i assume "x \<in> space M" "x \<notin> A i"
hoelzl@59092
   446
    with A have "(\<lambda>i. indicator (A i) x::real) ----> 0 \<longleftrightarrow> (\<lambda>i. 0::real) ----> 0"
hoelzl@59092
   447
      by (intro filterlim_cong refl)
hoelzl@59092
   448
         (auto split: split_indicator simp: eventually_sequentially decseq_def intro!: exI[of _ i]) }
hoelzl@59092
   449
  then show "AE x in M. (\<lambda>i. indicator (A i) x *\<^sub>R f x) ----> indicator (\<Inter>i. A i) x *\<^sub>R f x"
hoelzl@59092
   450
    by (intro AE_I2 tendsto_intros) (auto split: split_indicator)
hoelzl@59092
   451
qed
hoelzl@59092
   452
hoelzl@59092
   453
lemma set_integral_at_point:
hoelzl@59092
   454
  fixes a :: real
hoelzl@59092
   455
  assumes "set_integrable M {a} f"
hoelzl@59092
   456
  and [simp]: "{a} \<in> sets M" and "(emeasure M) {a} \<noteq> \<infinity>"
hoelzl@59092
   457
  shows "(LINT x:{a} | M. f x) = f a * measure M {a}"
hoelzl@59092
   458
proof-
hoelzl@59092
   459
  have "set_lebesgue_integral M {a} f = set_lebesgue_integral M {a} (%x. f a)"
hoelzl@59092
   460
    by (intro set_lebesgue_integral_cong) simp_all
hoelzl@59092
   461
  then show ?thesis using assms by simp
hoelzl@59092
   462
qed
hoelzl@59092
   463
hoelzl@59092
   464
hoelzl@59092
   465
abbreviation complex_integrable :: "'a measure \<Rightarrow> ('a \<Rightarrow> complex) \<Rightarrow> bool" where
hoelzl@59092
   466
  "complex_integrable M f \<equiv> integrable M f"
hoelzl@59092
   467
hoelzl@59092
   468
abbreviation complex_lebesgue_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> complex) \<Rightarrow> complex" ("integral\<^sup>C") where
hoelzl@59092
   469
  "integral\<^sup>C M f == integral\<^sup>L M f"
hoelzl@59092
   470
hoelzl@59092
   471
syntax
hoelzl@59092
   472
  "_complex_lebesgue_integral" :: "pttrn \<Rightarrow> complex \<Rightarrow> 'a measure \<Rightarrow> complex"
hoelzl@59092
   473
 ("\<integral>\<^sup>C _. _ \<partial>_" [60,61] 110)
hoelzl@59092
   474
hoelzl@59092
   475
translations
hoelzl@59092
   476
  "\<integral>\<^sup>Cx. f \<partial>M" == "CONST complex_lebesgue_integral M (\<lambda>x. f)"
hoelzl@59092
   477
hoelzl@59092
   478
syntax
hoelzl@59092
   479
  "_ascii_complex_lebesgue_integral" :: "pttrn \<Rightarrow> 'a measure \<Rightarrow> real \<Rightarrow> real"
hoelzl@59092
   480
  ("(3CLINT _|_. _)" [0,110,60] 60)
hoelzl@59092
   481
hoelzl@59092
   482
translations
hoelzl@59092
   483
  "CLINT x|M. f" == "CONST complex_lebesgue_integral M (\<lambda>x. f)"
hoelzl@59092
   484
hoelzl@59092
   485
lemma complex_integrable_cnj [simp]:
hoelzl@59092
   486
  "complex_integrable M (\<lambda>x. cnj (f x)) \<longleftrightarrow> complex_integrable M f"
hoelzl@59092
   487
proof
hoelzl@59092
   488
  assume "complex_integrable M (\<lambda>x. cnj (f x))"
hoelzl@59092
   489
  then have "complex_integrable M (\<lambda>x. cnj (cnj (f x)))"
hoelzl@59092
   490
    by (rule integrable_cnj)
hoelzl@59092
   491
  then show "complex_integrable M f"
hoelzl@59092
   492
    by simp
hoelzl@59092
   493
qed simp
hoelzl@59092
   494
hoelzl@59092
   495
lemma complex_of_real_integrable_eq:
hoelzl@59092
   496
  "complex_integrable M (\<lambda>x. complex_of_real (f x)) \<longleftrightarrow> integrable M f"
hoelzl@59092
   497
proof
hoelzl@59092
   498
  assume "complex_integrable M (\<lambda>x. complex_of_real (f x))"
hoelzl@59092
   499
  then have "integrable M (\<lambda>x. Re (complex_of_real (f x)))"
hoelzl@59092
   500
    by (rule integrable_Re)
hoelzl@59092
   501
  then show "integrable M f"
hoelzl@59092
   502
    by simp
hoelzl@59092
   503
qed simp
hoelzl@59092
   504
hoelzl@59092
   505
hoelzl@59092
   506
abbreviation complex_set_integrable :: "'a measure \<Rightarrow> 'a set \<Rightarrow> ('a \<Rightarrow> complex) \<Rightarrow> bool" where
hoelzl@59092
   507
  "complex_set_integrable M A f \<equiv> set_integrable M A f"
hoelzl@59092
   508
hoelzl@59092
   509
abbreviation complex_set_lebesgue_integral :: "'a measure \<Rightarrow> 'a set \<Rightarrow> ('a \<Rightarrow> complex) \<Rightarrow> complex" where
hoelzl@59092
   510
  "complex_set_lebesgue_integral M A f \<equiv> set_lebesgue_integral M A f"
hoelzl@59092
   511
hoelzl@59092
   512
syntax
hoelzl@59092
   513
"_ascii_complex_set_lebesgue_integral" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'a measure \<Rightarrow> real \<Rightarrow> real"
hoelzl@59092
   514
("(4CLINT _:_|_. _)" [0,60,110,61] 60)
hoelzl@59092
   515
hoelzl@59092
   516
translations
hoelzl@59092
   517
"CLINT x:A|M. f" == "CONST complex_set_lebesgue_integral M A (\<lambda>x. f)"
hoelzl@59092
   518
hoelzl@59092
   519
(*
wenzelm@61945
   520
lemma cmod_mult: "cmod ((a :: real) * (x :: complex)) = \<bar>a\<bar> * cmod x"
hoelzl@59092
   521
  apply (simp add: norm_mult)
hoelzl@59092
   522
  by (subst norm_mult, auto)
hoelzl@59092
   523
*)
hoelzl@59092
   524
hoelzl@59092
   525
lemma borel_integrable_atLeastAtMost':
hoelzl@59092
   526
  fixes f :: "real \<Rightarrow> 'a::{banach, second_countable_topology}"
hoelzl@59092
   527
  assumes f: "continuous_on {a..b} f"
hoelzl@59092
   528
  shows "set_integrable lborel {a..b} f" (is "integrable _ ?f")
hoelzl@59092
   529
  by (intro borel_integrable_compact compact_Icc f)
hoelzl@59092
   530
hoelzl@59092
   531
lemma integral_FTC_atLeastAtMost:
hoelzl@59092
   532
  fixes f :: "real \<Rightarrow> 'a :: euclidean_space"
hoelzl@59092
   533
  assumes "a \<le> b"
hoelzl@59092
   534
    and F: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> (F has_vector_derivative f x) (at x within {a .. b})"
hoelzl@59092
   535
    and f: "continuous_on {a .. b} f"
hoelzl@59092
   536
  shows "integral\<^sup>L lborel (\<lambda>x. indicator {a .. b} x *\<^sub>R f x) = F b - F a"
hoelzl@59092
   537
proof -
hoelzl@59092
   538
  let ?f = "\<lambda>x. indicator {a .. b} x *\<^sub>R f x"
hoelzl@59092
   539
  have "(?f has_integral (\<integral>x. ?f x \<partial>lborel)) UNIV"
hoelzl@59092
   540
    using borel_integrable_atLeastAtMost'[OF f] by (rule has_integral_integral_lborel)
hoelzl@59092
   541
  moreover
hoelzl@59092
   542
  have "(f has_integral F b - F a) {a .. b}"
hoelzl@59092
   543
    by (intro fundamental_theorem_of_calculus ballI assms) auto
hoelzl@59092
   544
  then have "(?f has_integral F b - F a) {a .. b}"
lp15@60615
   545
    by (subst has_integral_cong[where g=f]) auto
hoelzl@59092
   546
  then have "(?f has_integral F b - F a) UNIV"
hoelzl@59092
   547
    by (intro has_integral_on_superset[where t=UNIV and s="{a..b}"]) auto
hoelzl@59092
   548
  ultimately show "integral\<^sup>L lborel ?f = F b - F a"
hoelzl@59092
   549
    by (rule has_integral_unique)
hoelzl@59092
   550
qed
hoelzl@59092
   551
hoelzl@59092
   552
lemma set_borel_integral_eq_integral:
hoelzl@59092
   553
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
hoelzl@59092
   554
  assumes "set_integrable lborel S f"
hoelzl@59092
   555
  shows "f integrable_on S" "LINT x : S | lborel. f x = integral S f"
hoelzl@59092
   556
proof -
hoelzl@59092
   557
  let ?f = "\<lambda>x. indicator S x *\<^sub>R f x"
hoelzl@59092
   558
  have "(?f has_integral LINT x : S | lborel. f x) UNIV"
hoelzl@59092
   559
    by (rule has_integral_integral_lborel) fact
hoelzl@59092
   560
  hence 1: "(f has_integral (set_lebesgue_integral lborel S f)) S"
hoelzl@59092
   561
    apply (subst has_integral_restrict_univ [symmetric])
hoelzl@59092
   562
    apply (rule has_integral_eq)
hoelzl@59092
   563
    by auto
hoelzl@59092
   564
  thus "f integrable_on S"
hoelzl@59092
   565
    by (auto simp add: integrable_on_def)
hoelzl@59092
   566
  with 1 have "(f has_integral (integral S f)) S"
hoelzl@59092
   567
    by (intro integrable_integral, auto simp add: integrable_on_def)
hoelzl@59092
   568
  thus "LINT x : S | lborel. f x = integral S f"
hoelzl@59092
   569
    by (intro has_integral_unique [OF 1])
hoelzl@59092
   570
qed
hoelzl@59092
   571
hoelzl@59092
   572
lemma set_borel_measurable_continuous:
hoelzl@59092
   573
  fixes f :: "_ \<Rightarrow> _::real_normed_vector"
hoelzl@59092
   574
  assumes "S \<in> sets borel" "continuous_on S f"
hoelzl@59092
   575
  shows "set_borel_measurable borel S f"
hoelzl@59092
   576
proof -
hoelzl@59092
   577
  have "(\<lambda>x. if x \<in> S then f x else 0) \<in> borel_measurable borel"
hoelzl@59092
   578
    by (intro assms borel_measurable_continuous_on_if continuous_on_const)
hoelzl@59092
   579
  also have "(\<lambda>x. if x \<in> S then f x else 0) = (\<lambda>x. indicator S x *\<^sub>R f x)"
hoelzl@59092
   580
    by auto
hoelzl@59092
   581
  finally show ?thesis .
hoelzl@59092
   582
qed
hoelzl@59092
   583
hoelzl@59092
   584
lemma set_measurable_continuous_on_ivl:
hoelzl@59092
   585
  assumes "continuous_on {a..b} (f :: real \<Rightarrow> real)"
hoelzl@59092
   586
  shows "set_borel_measurable borel {a..b} f"
hoelzl@59092
   587
  by (rule set_borel_measurable_continuous[OF _ assms]) simp
hoelzl@59092
   588
hoelzl@59092
   589
end
hoelzl@59092
   590