src/HOL/Probability/Lebesgue_Measure.thy
author hoelzl
Thu Apr 14 15:48:11 2016 +0200 (2016-04-14)
changeset 62975 1d066f6ab25d
parent 62390 842917225d56
child 63040 eb4ddd18d635
permissions -rw-r--r--
Probability: move emeasure and nn_integral from ereal to ennreal
hoelzl@42067
     1
(*  Title:      HOL/Probability/Lebesgue_Measure.thy
hoelzl@42067
     2
    Author:     Johannes Hölzl, TU München
hoelzl@42067
     3
    Author:     Robert Himmelmann, TU München
hoelzl@57447
     4
    Author:     Jeremy Avigad
hoelzl@57447
     5
    Author:     Luke Serafin
hoelzl@42067
     6
*)
hoelzl@42067
     7
wenzelm@61808
     8
section \<open>Lebesgue measure\<close>
hoelzl@42067
     9
hoelzl@38656
    10
theory Lebesgue_Measure
hoelzl@57447
    11
  imports Finite_Product_Measure Bochner_Integration Caratheodory
hoelzl@38656
    12
begin
hoelzl@38656
    13
wenzelm@61808
    14
subsection \<open>Every right continuous and nondecreasing function gives rise to a measure\<close>
hoelzl@57447
    15
hoelzl@57447
    16
definition interval_measure :: "(real \<Rightarrow> real) \<Rightarrow> real measure" where
hoelzl@62975
    17
  "interval_measure F = extend_measure UNIV {(a, b). a \<le> b} (\<lambda>(a, b). {a <.. b}) (\<lambda>(a, b). ennreal (F b - F a))"
hoelzl@49777
    18
hoelzl@57447
    19
lemma emeasure_interval_measure_Ioc:
hoelzl@57447
    20
  assumes "a \<le> b"
hoelzl@57447
    21
  assumes mono_F: "\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y"
lp15@60615
    22
  assumes right_cont_F : "\<And>a. continuous (at_right a) F"
hoelzl@57447
    23
  shows "emeasure (interval_measure F) {a <.. b} = F b - F a"
wenzelm@61808
    24
proof (rule extend_measure_caratheodory_pair[OF interval_measure_def \<open>a \<le> b\<close>])
hoelzl@57447
    25
  show "semiring_of_sets UNIV {{a<..b} |a b :: real. a \<le> b}"
hoelzl@57447
    26
  proof (unfold_locales, safe)
hoelzl@57447
    27
    fix a b c d :: real assume *: "a \<le> b" "c \<le> d"
hoelzl@57447
    28
    then show "\<exists>C\<subseteq>{{a<..b} |a b. a \<le> b}. finite C \<and> disjoint C \<and> {a<..b} - {c<..d} = \<Union>C"
hoelzl@57447
    29
    proof cases
hoelzl@57447
    30
      let ?C = "{{a<..b}}"
hoelzl@57447
    31
      assume "b < c \<or> d \<le> a \<or> d \<le> c"
hoelzl@57447
    32
      with * have "?C \<subseteq> {{a<..b} |a b. a \<le> b} \<and> finite ?C \<and> disjoint ?C \<and> {a<..b} - {c<..d} = \<Union>?C"
hoelzl@57447
    33
        by (auto simp add: disjoint_def)
hoelzl@57447
    34
      thus ?thesis ..
hoelzl@57447
    35
    next
hoelzl@57447
    36
      let ?C = "{{a<..c}, {d<..b}}"
hoelzl@57447
    37
      assume "\<not> (b < c \<or> d \<le> a \<or> d \<le> c)"
hoelzl@57447
    38
      with * have "?C \<subseteq> {{a<..b} |a b. a \<le> b} \<and> finite ?C \<and> disjoint ?C \<and> {a<..b} - {c<..d} = \<Union>?C"
hoelzl@57447
    39
        by (auto simp add: disjoint_def Ioc_inj) (metis linear)+
hoelzl@57447
    40
      thus ?thesis ..
hoelzl@57447
    41
    qed
hoelzl@57447
    42
  qed (auto simp: Ioc_inj, metis linear)
hoelzl@57447
    43
next
hoelzl@57447
    44
  fix l r :: "nat \<Rightarrow> real" and a b :: real
lp15@60615
    45
  assume l_r[simp]: "\<And>n. l n \<le> r n" and "a \<le> b" and disj: "disjoint_family (\<lambda>n. {l n<..r n})"
hoelzl@57447
    46
  assume lr_eq_ab: "(\<Union>i. {l i<..r i}) = {a<..b}"
hoelzl@57447
    47
lp15@61762
    48
  have [intro, simp]: "\<And>a b. a \<le> b \<Longrightarrow> F a \<le> F b"
lp15@61762
    49
    by (auto intro!: l_r mono_F)
hoelzl@57447
    50
hoelzl@57447
    51
  { fix S :: "nat set" assume "finite S"
wenzelm@61808
    52
    moreover note \<open>a \<le> b\<close>
hoelzl@57447
    53
    moreover have "\<And>i. i \<in> S \<Longrightarrow> {l i <.. r i} \<subseteq> {a <.. b}"
hoelzl@57447
    54
      unfolding lr_eq_ab[symmetric] by auto
hoelzl@57447
    55
    ultimately have "(\<Sum>i\<in>S. F (r i) - F (l i)) \<le> F b - F a"
hoelzl@57447
    56
    proof (induction S arbitrary: a rule: finite_psubset_induct)
hoelzl@57447
    57
      case (psubset S)
hoelzl@57447
    58
      show ?case
hoelzl@57447
    59
      proof cases
hoelzl@57447
    60
        assume "\<exists>i\<in>S. l i < r i"
wenzelm@61808
    61
        with \<open>finite S\<close> have "Min (l ` {i\<in>S. l i < r i}) \<in> l ` {i\<in>S. l i < r i}"
hoelzl@57447
    62
          by (intro Min_in) auto
hoelzl@57447
    63
        then obtain m where m: "m \<in> S" "l m < r m" "l m = Min (l ` {i\<in>S. l i < r i})"
hoelzl@57447
    64
          by fastforce
hoelzl@50104
    65
hoelzl@57447
    66
        have "(\<Sum>i\<in>S. F (r i) - F (l i)) = (F (r m) - F (l m)) + (\<Sum>i\<in>S - {m}. F (r i) - F (l i))"
hoelzl@57447
    67
          using m psubset by (intro setsum.remove) auto
hoelzl@57447
    68
        also have "(\<Sum>i\<in>S - {m}. F (r i) - F (l i)) \<le> F b - F (r m)"
hoelzl@57447
    69
        proof (intro psubset.IH)
hoelzl@57447
    70
          show "S - {m} \<subset> S"
wenzelm@61808
    71
            using \<open>m\<in>S\<close> by auto
hoelzl@57447
    72
          show "r m \<le> b"
wenzelm@61808
    73
            using psubset.prems(2)[OF \<open>m\<in>S\<close>] \<open>l m < r m\<close> by auto
hoelzl@57447
    74
        next
hoelzl@57447
    75
          fix i assume "i \<in> S - {m}"
hoelzl@57447
    76
          then have i: "i \<in> S" "i \<noteq> m" by auto
hoelzl@57447
    77
          { assume i': "l i < r i" "l i < r m"
wenzelm@61808
    78
            moreover with \<open>finite S\<close> i m have "l m \<le> l i"
hoelzl@57447
    79
              by auto
hoelzl@57447
    80
            ultimately have "{l i <.. r i} \<inter> {l m <.. r m} \<noteq> {}"
hoelzl@57447
    81
              by auto
hoelzl@57447
    82
            then have False
hoelzl@57447
    83
              using disjoint_family_onD[OF disj, of i m] i by auto }
hoelzl@57447
    84
          then have "l i \<noteq> r i \<Longrightarrow> r m \<le> l i"
hoelzl@57447
    85
            unfolding not_less[symmetric] using l_r[of i] by auto
hoelzl@57447
    86
          then show "{l i <.. r i} \<subseteq> {r m <.. b}"
wenzelm@61808
    87
            using psubset.prems(2)[OF \<open>i\<in>S\<close>] by auto
hoelzl@57447
    88
        qed
hoelzl@57447
    89
        also have "F (r m) - F (l m) \<le> F (r m) - F a"
wenzelm@61808
    90
          using psubset.prems(2)[OF \<open>m \<in> S\<close>] \<open>l m < r m\<close>
hoelzl@57447
    91
          by (auto simp add: Ioc_subset_iff intro!: mono_F)
hoelzl@57447
    92
        finally show ?case
hoelzl@57447
    93
          by (auto intro: add_mono)
wenzelm@61808
    94
      qed (auto simp add: \<open>a \<le> b\<close> less_le)
hoelzl@57447
    95
    qed }
hoelzl@57447
    96
  note claim1 = this
hoelzl@57447
    97
hoelzl@57447
    98
  (* second key induction: a lower bound on the measures of any finite collection of Ai's
hoelzl@57447
    99
     that cover an interval {u..v} *)
hoelzl@57447
   100
hoelzl@57447
   101
  { fix S u v and l r :: "nat \<Rightarrow> real"
hoelzl@57447
   102
    assume "finite S" "\<And>i. i\<in>S \<Longrightarrow> l i < r i" "{u..v} \<subseteq> (\<Union>i\<in>S. {l i<..< r i})"
hoelzl@57447
   103
    then have "F v - F u \<le> (\<Sum>i\<in>S. F (r i) - F (l i))"
hoelzl@57447
   104
    proof (induction arbitrary: v u rule: finite_psubset_induct)
hoelzl@57447
   105
      case (psubset S)
hoelzl@57447
   106
      show ?case
hoelzl@57447
   107
      proof cases
hoelzl@57447
   108
        assume "S = {}" then show ?case
hoelzl@57447
   109
          using psubset by (simp add: mono_F)
hoelzl@57447
   110
      next
hoelzl@57447
   111
        assume "S \<noteq> {}"
hoelzl@57447
   112
        then obtain j where "j \<in> S"
hoelzl@57447
   113
          by auto
hoelzl@47694
   114
hoelzl@57447
   115
        let ?R = "r j < u \<or> l j > v \<or> (\<exists>i\<in>S-{j}. l i \<le> l j \<and> r j \<le> r i)"
hoelzl@57447
   116
        show ?case
hoelzl@57447
   117
        proof cases
hoelzl@57447
   118
          assume "?R"
wenzelm@61808
   119
          with \<open>j \<in> S\<close> psubset.prems have "{u..v} \<subseteq> (\<Union>i\<in>S-{j}. {l i<..< r i})"
hoelzl@57447
   120
            apply (auto simp: subset_eq Ball_def)
hoelzl@57447
   121
            apply (metis Diff_iff less_le_trans leD linear singletonD)
hoelzl@57447
   122
            apply (metis Diff_iff less_le_trans leD linear singletonD)
hoelzl@57447
   123
            apply (metis order_trans less_le_not_le linear)
hoelzl@57447
   124
            done
wenzelm@61808
   125
          with \<open>j \<in> S\<close> have "F v - F u \<le> (\<Sum>i\<in>S - {j}. F (r i) - F (l i))"
hoelzl@57447
   126
            by (intro psubset) auto
hoelzl@57447
   127
          also have "\<dots> \<le> (\<Sum>i\<in>S. F (r i) - F (l i))"
hoelzl@57447
   128
            using psubset.prems
hoelzl@57447
   129
            by (intro setsum_mono2 psubset) (auto intro: less_imp_le)
hoelzl@57447
   130
          finally show ?thesis .
hoelzl@57447
   131
        next
hoelzl@57447
   132
          assume "\<not> ?R"
hoelzl@57447
   133
          then have j: "u \<le> r j" "l j \<le> v" "\<And>i. i \<in> S - {j} \<Longrightarrow> r i < r j \<or> l i > l j"
hoelzl@57447
   134
            by (auto simp: not_less)
hoelzl@57447
   135
          let ?S1 = "{i \<in> S. l i < l j}"
hoelzl@57447
   136
          let ?S2 = "{i \<in> S. r i > r j}"
hoelzl@40859
   137
hoelzl@57447
   138
          have "(\<Sum>i\<in>S. F (r i) - F (l i)) \<ge> (\<Sum>i\<in>?S1 \<union> ?S2 \<union> {j}. F (r i) - F (l i))"
wenzelm@61808
   139
            using \<open>j \<in> S\<close> \<open>finite S\<close> psubset.prems j
hoelzl@57447
   140
            by (intro setsum_mono2) (auto intro: less_imp_le)
hoelzl@57447
   141
          also have "(\<Sum>i\<in>?S1 \<union> ?S2 \<union> {j}. F (r i) - F (l i)) =
hoelzl@57447
   142
            (\<Sum>i\<in>?S1. F (r i) - F (l i)) + (\<Sum>i\<in>?S2 . F (r i) - F (l i)) + (F (r j) - F (l j))"
hoelzl@57447
   143
            using psubset(1) psubset.prems(1) j
hoelzl@57447
   144
            apply (subst setsum.union_disjoint)
hoelzl@57447
   145
            apply simp_all
hoelzl@57447
   146
            apply (subst setsum.union_disjoint)
hoelzl@57447
   147
            apply auto
hoelzl@57447
   148
            apply (metis less_le_not_le)
hoelzl@57447
   149
            done
hoelzl@57447
   150
          also (xtrans) have "(\<Sum>i\<in>?S1. F (r i) - F (l i)) \<ge> F (l j) - F u"
wenzelm@61808
   151
            using \<open>j \<in> S\<close> \<open>finite S\<close> psubset.prems j
hoelzl@57447
   152
            apply (intro psubset.IH psubset)
hoelzl@57447
   153
            apply (auto simp: subset_eq Ball_def)
hoelzl@57447
   154
            apply (metis less_le_trans not_le)
hoelzl@57447
   155
            done
hoelzl@57447
   156
          also (xtrans) have "(\<Sum>i\<in>?S2. F (r i) - F (l i)) \<ge> F v - F (r j)"
wenzelm@61808
   157
            using \<open>j \<in> S\<close> \<open>finite S\<close> psubset.prems j
hoelzl@57447
   158
            apply (intro psubset.IH psubset)
hoelzl@57447
   159
            apply (auto simp: subset_eq Ball_def)
hoelzl@57447
   160
            apply (metis le_less_trans not_le)
hoelzl@57447
   161
            done
hoelzl@57447
   162
          finally (xtrans) show ?case
hoelzl@57447
   163
            by (auto simp: add_mono)
hoelzl@57447
   164
        qed
hoelzl@57447
   165
      qed
hoelzl@57447
   166
    qed }
hoelzl@57447
   167
  note claim2 = this
hoelzl@49777
   168
hoelzl@57447
   169
  (* now prove the inequality going the other way *)
hoelzl@62975
   170
  have "ennreal (F b - F a) \<le> (\<Sum>i. ennreal (F (r i) - F (l i)))"
hoelzl@62975
   171
  proof (rule ennreal_le_epsilon)
hoelzl@62975
   172
    fix epsilon :: real assume egt0: "epsilon > 0"
hoelzl@62975
   173
    have "\<forall>i. \<exists>d>0. F (r i + d) < F (r i) + epsilon / 2^(i+2)"
lp15@60615
   174
    proof
hoelzl@57447
   175
      fix i
hoelzl@57447
   176
      note right_cont_F [of "r i"]
hoelzl@62975
   177
      thus "\<exists>d>0. F (r i + d) < F (r i) + epsilon / 2^(i+2)"
hoelzl@57447
   178
        apply -
hoelzl@57447
   179
        apply (subst (asm) continuous_at_right_real_increasing)
hoelzl@57447
   180
        apply (rule mono_F, assumption)
hoelzl@57447
   181
        apply (drule_tac x = "epsilon / 2 ^ (i + 2)" in spec)
hoelzl@57447
   182
        apply (erule impE)
hoelzl@57447
   183
        using egt0 by (auto simp add: field_simps)
hoelzl@57447
   184
    qed
lp15@60615
   185
    then obtain delta where
hoelzl@57447
   186
        deltai_gt0: "\<And>i. delta i > 0" and
hoelzl@57447
   187
        deltai_prop: "\<And>i. F (r i + delta i) < F (r i) + epsilon / 2^(i+2)"
hoelzl@57447
   188
      by metis
hoelzl@57447
   189
    have "\<exists>a' > a. F a' - F a < epsilon / 2"
hoelzl@57447
   190
      apply (insert right_cont_F [of a])
hoelzl@57447
   191
      apply (subst (asm) continuous_at_right_real_increasing)
hoelzl@57447
   192
      using mono_F apply force
hoelzl@57447
   193
      apply (drule_tac x = "epsilon / 2" in spec)
haftmann@59554
   194
      using egt0 unfolding mult.commute [of 2] by force
lp15@60615
   195
    then obtain a' where a'lea [arith]: "a' > a" and
hoelzl@57447
   196
      a_prop: "F a' - F a < epsilon / 2"
hoelzl@57447
   197
      by auto
hoelzl@57447
   198
    def S' \<equiv> "{i. l i < r i}"
lp15@60615
   199
    obtain S :: "nat set" where
lp15@60615
   200
      "S \<subseteq> S'" and finS: "finite S" and
hoelzl@57447
   201
      Sprop: "{a'..b} \<subseteq> (\<Union>i \<in> S. {l i<..<r i + delta i})"
hoelzl@57447
   202
    proof (rule compactE_image)
hoelzl@57447
   203
      show "compact {a'..b}"
hoelzl@57447
   204
        by (rule compact_Icc)
hoelzl@57447
   205
      show "\<forall>i \<in> S'. open ({l i<..<r i + delta i})" by auto
hoelzl@57447
   206
      have "{a'..b} \<subseteq> {a <.. b}"
hoelzl@57447
   207
        by auto
hoelzl@57447
   208
      also have "{a <.. b} = (\<Union>i\<in>S'. {l i<..r i})"
hoelzl@57447
   209
        unfolding lr_eq_ab[symmetric] by (fastforce simp add: S'_def intro: less_le_trans)
hoelzl@57447
   210
      also have "\<dots> \<subseteq> (\<Union>i \<in> S'. {l i<..<r i + delta i})"
hoelzl@57447
   211
        apply (intro UN_mono)
hoelzl@57447
   212
        apply (auto simp: S'_def)
hoelzl@57447
   213
        apply (cut_tac i=i in deltai_gt0)
hoelzl@57447
   214
        apply simp
hoelzl@57447
   215
        done
hoelzl@57447
   216
      finally show "{a'..b} \<subseteq> (\<Union>i \<in> S'. {l i<..<r i + delta i})" .
hoelzl@57447
   217
    qed
hoelzl@57447
   218
    with S'_def have Sprop2: "\<And>i. i \<in> S \<Longrightarrow> l i < r i" by auto
lp15@60615
   219
    from finS have "\<exists>n. \<forall>i \<in> S. i \<le> n"
hoelzl@57447
   220
      by (subst finite_nat_set_iff_bounded_le [symmetric])
hoelzl@57447
   221
    then obtain n where Sbound [rule_format]: "\<forall>i \<in> S. i \<le> n" ..
hoelzl@57447
   222
    have "F b - F a' \<le> (\<Sum>i\<in>S. F (r i + delta i) - F (l i))"
hoelzl@57447
   223
      apply (rule claim2 [rule_format])
hoelzl@57447
   224
      using finS Sprop apply auto
hoelzl@57447
   225
      apply (frule Sprop2)
hoelzl@57447
   226
      apply (subgoal_tac "delta i > 0")
hoelzl@57447
   227
      apply arith
hoelzl@57447
   228
      by (rule deltai_gt0)
wenzelm@61954
   229
    also have "... \<le> (\<Sum>i \<in> S. F(r i) - F(l i) + epsilon / 2^(i+2))"
hoelzl@57447
   230
      apply (rule setsum_mono)
hoelzl@57447
   231
      apply simp
hoelzl@57447
   232
      apply (rule order_trans)
hoelzl@57447
   233
      apply (rule less_imp_le)
hoelzl@57447
   234
      apply (rule deltai_prop)
hoelzl@57447
   235
      by auto
wenzelm@61954
   236
    also have "... = (\<Sum>i \<in> S. F(r i) - F(l i)) +
wenzelm@61954
   237
        (epsilon / 4) * (\<Sum>i \<in> S. (1 / 2)^i)" (is "_ = ?t + _")
hoelzl@57447
   238
      by (subst setsum.distrib) (simp add: field_simps setsum_right_distrib)
hoelzl@57447
   239
    also have "... \<le> ?t + (epsilon / 4) * (\<Sum> i < Suc n. (1 / 2)^i)"
hoelzl@57447
   240
      apply (rule add_left_mono)
hoelzl@57447
   241
      apply (rule mult_left_mono)
hoelzl@57447
   242
      apply (rule setsum_mono2)
lp15@60615
   243
      using egt0 apply auto
hoelzl@57447
   244
      by (frule Sbound, auto)
hoelzl@57447
   245
    also have "... \<le> ?t + (epsilon / 2)"
hoelzl@57447
   246
      apply (rule add_left_mono)
hoelzl@57447
   247
      apply (subst geometric_sum)
hoelzl@57447
   248
      apply auto
hoelzl@57447
   249
      apply (rule mult_left_mono)
hoelzl@57447
   250
      using egt0 apply auto
hoelzl@57447
   251
      done
hoelzl@57447
   252
    finally have aux2: "F b - F a' \<le> (\<Sum>i\<in>S. F (r i) - F (l i)) + epsilon / 2"
hoelzl@57447
   253
      by simp
hoelzl@50526
   254
hoelzl@57447
   255
    have "F b - F a = (F b - F a') + (F a' - F a)"
hoelzl@57447
   256
      by auto
hoelzl@57447
   257
    also have "... \<le> (F b - F a') + epsilon / 2"
hoelzl@57447
   258
      using a_prop by (intro add_left_mono) simp
hoelzl@57447
   259
    also have "... \<le> (\<Sum>i\<in>S. F (r i) - F (l i)) + epsilon / 2 + epsilon / 2"
hoelzl@57447
   260
      apply (intro add_right_mono)
hoelzl@57447
   261
      apply (rule aux2)
hoelzl@57447
   262
      done
hoelzl@57447
   263
    also have "... = (\<Sum>i\<in>S. F (r i) - F (l i)) + epsilon"
hoelzl@57447
   264
      by auto
hoelzl@57447
   265
    also have "... \<le> (\<Sum>i\<le>n. F (r i) - F (l i)) + epsilon"
hoelzl@57447
   266
      using finS Sbound Sprop by (auto intro!: add_right_mono setsum_mono3)
hoelzl@62975
   267
    finally have "ennreal (F b - F a) \<le> (\<Sum>i\<le>n. ennreal (F (r i) - F (l i))) + epsilon"
hoelzl@62975
   268
      using egt0 by (simp add: ennreal_plus[symmetric] setsum_nonneg del: ennreal_plus)
hoelzl@62975
   269
    then show "ennreal (F b - F a) \<le> (\<Sum>i. ennreal (F (r i) - F (l i))) + (epsilon :: real)"
hoelzl@62975
   270
      by (rule order_trans) (auto intro!: add_mono setsum_le_suminf simp del: setsum_ennreal)
hoelzl@62975
   271
  qed
hoelzl@62975
   272
  moreover have "(\<Sum>i. ennreal (F (r i) - F (l i))) \<le> ennreal (F b - F a)"
hoelzl@62975
   273
    using \<open>a \<le> b\<close> by (auto intro!: suminf_le_const ennreal_le_iff[THEN iffD2] claim1)
hoelzl@62975
   274
  ultimately show "(\<Sum>n. ennreal (F (r n) - F (l n))) = ennreal (F b - F a)"
hoelzl@62975
   275
    by (rule antisym[rotated])
lp15@61762
   276
qed (auto simp: Ioc_inj mono_F)
hoelzl@38656
   277
hoelzl@57447
   278
lemma measure_interval_measure_Ioc:
hoelzl@57447
   279
  assumes "a \<le> b"
hoelzl@57447
   280
  assumes mono_F: "\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y"
lp15@60615
   281
  assumes right_cont_F : "\<And>a. continuous (at_right a) F"
hoelzl@57447
   282
  shows "measure (interval_measure F) {a <.. b} = F b - F a"
hoelzl@57447
   283
  unfolding measure_def
hoelzl@57447
   284
  apply (subst emeasure_interval_measure_Ioc)
hoelzl@57447
   285
  apply fact+
hoelzl@62975
   286
  apply (simp add: assms)
hoelzl@57447
   287
  done
hoelzl@57447
   288
hoelzl@57447
   289
lemma emeasure_interval_measure_Ioc_eq:
hoelzl@57447
   290
  "(\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y) \<Longrightarrow> (\<And>a. continuous (at_right a) F) \<Longrightarrow>
hoelzl@57447
   291
    emeasure (interval_measure F) {a <.. b} = (if a \<le> b then F b - F a else 0)"
hoelzl@57447
   292
  using emeasure_interval_measure_Ioc[of a b F] by auto
hoelzl@57447
   293
hoelzl@59048
   294
lemma sets_interval_measure [simp, measurable_cong]: "sets (interval_measure F) = sets borel"
hoelzl@57447
   295
  apply (simp add: sets_extend_measure interval_measure_def borel_sigma_sets_Ioc)
hoelzl@57447
   296
  apply (rule sigma_sets_eqI)
hoelzl@57447
   297
  apply auto
hoelzl@57447
   298
  apply (case_tac "a \<le> ba")
hoelzl@57447
   299
  apply (auto intro: sigma_sets.Empty)
hoelzl@57447
   300
  done
hoelzl@57447
   301
hoelzl@57447
   302
lemma space_interval_measure [simp]: "space (interval_measure F) = UNIV"
hoelzl@57447
   303
  by (simp add: interval_measure_def space_extend_measure)
hoelzl@57447
   304
hoelzl@57447
   305
lemma emeasure_interval_measure_Icc:
hoelzl@57447
   306
  assumes "a \<le> b"
hoelzl@57447
   307
  assumes mono_F: "\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y"
lp15@60615
   308
  assumes cont_F : "continuous_on UNIV F"
hoelzl@57447
   309
  shows "emeasure (interval_measure F) {a .. b} = F b - F a"
hoelzl@57447
   310
proof (rule tendsto_unique)
hoelzl@57447
   311
  { fix a b :: real assume "a \<le> b" then have "emeasure (interval_measure F) {a <.. b} = F b - F a"
hoelzl@57447
   312
      using cont_F
hoelzl@57447
   313
      by (subst emeasure_interval_measure_Ioc)
hoelzl@57447
   314
         (auto intro: mono_F continuous_within_subset simp: continuous_on_eq_continuous_within) }
hoelzl@57447
   315
  note * = this
hoelzl@38656
   316
hoelzl@57447
   317
  let ?F = "interval_measure F"
wenzelm@61973
   318
  show "((\<lambda>a. F b - F a) \<longlongrightarrow> emeasure ?F {a..b}) (at_left a)"
hoelzl@57447
   319
  proof (rule tendsto_at_left_sequentially)
hoelzl@57447
   320
    show "a - 1 < a" by simp
wenzelm@61969
   321
    fix X assume "\<And>n. X n < a" "incseq X" "X \<longlonglongrightarrow> a"
wenzelm@61969
   322
    with \<open>a \<le> b\<close> have "(\<lambda>n. emeasure ?F {X n<..b}) \<longlonglongrightarrow> emeasure ?F (\<Inter>n. {X n <..b})"
hoelzl@57447
   323
      apply (intro Lim_emeasure_decseq)
hoelzl@57447
   324
      apply (auto simp: decseq_def incseq_def emeasure_interval_measure_Ioc *)
hoelzl@57447
   325
      apply force
hoelzl@57447
   326
      apply (subst (asm ) *)
hoelzl@57447
   327
      apply (auto intro: less_le_trans less_imp_le)
hoelzl@57447
   328
      done
hoelzl@57447
   329
    also have "(\<Inter>n. {X n <..b}) = {a..b}"
wenzelm@61808
   330
      using \<open>\<And>n. X n < a\<close>
hoelzl@57447
   331
      apply auto
wenzelm@61969
   332
      apply (rule LIMSEQ_le_const2[OF \<open>X \<longlonglongrightarrow> a\<close>])
hoelzl@57447
   333
      apply (auto intro: less_imp_le)
hoelzl@57447
   334
      apply (auto intro: less_le_trans)
hoelzl@57447
   335
      done
hoelzl@57447
   336
    also have "(\<lambda>n. emeasure ?F {X n<..b}) = (\<lambda>n. F b - F (X n))"
wenzelm@61808
   337
      using \<open>\<And>n. X n < a\<close> \<open>a \<le> b\<close> by (subst *) (auto intro: less_imp_le less_le_trans)
wenzelm@61969
   338
    finally show "(\<lambda>n. F b - F (X n)) \<longlonglongrightarrow> emeasure ?F {a..b}" .
hoelzl@57447
   339
  qed
hoelzl@62975
   340
  show "((\<lambda>a. ennreal (F b - F a)) \<longlongrightarrow> F b - F a) (at_left a)"
hoelzl@62975
   341
    by (rule continuous_on_tendsto_compose[where g="\<lambda>x. x" and s=UNIV])
hoelzl@62975
   342
       (auto simp: continuous_on_ennreal continuous_on_diff cont_F continuous_on_const)
hoelzl@57447
   343
qed (rule trivial_limit_at_left_real)
lp15@60615
   344
hoelzl@57447
   345
lemma sigma_finite_interval_measure:
hoelzl@57447
   346
  assumes mono_F: "\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y"
lp15@60615
   347
  assumes right_cont_F : "\<And>a. continuous (at_right a) F"
hoelzl@57447
   348
  shows "sigma_finite_measure (interval_measure F)"
hoelzl@57447
   349
  apply unfold_locales
hoelzl@57447
   350
  apply (intro exI[of _ "(\<lambda>(a, b). {a <.. b}) ` (\<rat> \<times> \<rat>)"])
hoelzl@57447
   351
  apply (auto intro!: Rats_no_top_le Rats_no_bot_less countable_rat simp: emeasure_interval_measure_Ioc_eq[OF assms])
hoelzl@57447
   352
  done
hoelzl@57447
   353
wenzelm@61808
   354
subsection \<open>Lebesgue-Borel measure\<close>
hoelzl@57447
   355
hoelzl@57447
   356
definition lborel :: "('a :: euclidean_space) measure" where
hoelzl@57447
   357
  "lborel = distr (\<Pi>\<^sub>M b\<in>Basis. interval_measure (\<lambda>x. x)) borel (\<lambda>f. \<Sum>b\<in>Basis. f b *\<^sub>R b)"
hoelzl@57447
   358
lp15@60615
   359
lemma
hoelzl@59048
   360
  shows sets_lborel[simp, measurable_cong]: "sets lborel = sets borel"
hoelzl@57447
   361
    and space_lborel[simp]: "space lborel = space borel"
hoelzl@57447
   362
    and measurable_lborel1[simp]: "measurable M lborel = measurable M borel"
hoelzl@57447
   363
    and measurable_lborel2[simp]: "measurable lborel M = measurable borel M"
hoelzl@57447
   364
  by (simp_all add: lborel_def)
hoelzl@57447
   365
hoelzl@57447
   366
context
hoelzl@57447
   367
begin
hoelzl@57447
   368
hoelzl@57447
   369
interpretation sigma_finite_measure "interval_measure (\<lambda>x. x)"
hoelzl@57447
   370
  by (rule sigma_finite_interval_measure) auto
hoelzl@57447
   371
interpretation finite_product_sigma_finite "\<lambda>_. interval_measure (\<lambda>x. x)" Basis
hoelzl@57447
   372
  proof qed simp
hoelzl@57447
   373
hoelzl@57447
   374
lemma lborel_eq_real: "lborel = interval_measure (\<lambda>x. x)"
hoelzl@57447
   375
  unfolding lborel_def Basis_real_def
hoelzl@57447
   376
  using distr_id[of "interval_measure (\<lambda>x. x)"]
hoelzl@57447
   377
  by (subst distr_component[symmetric])
hoelzl@57447
   378
     (simp_all add: distr_distr comp_def del: distr_id cong: distr_cong)
hoelzl@57447
   379
hoelzl@57447
   380
lemma lborel_eq: "lborel = distr (\<Pi>\<^sub>M b\<in>Basis. lborel) borel (\<lambda>f. \<Sum>b\<in>Basis. f b *\<^sub>R b)"
hoelzl@57447
   381
  by (subst lborel_def) (simp add: lborel_eq_real)
hoelzl@57447
   382
hoelzl@57447
   383
lemma nn_integral_lborel_setprod:
hoelzl@57447
   384
  assumes [measurable]: "\<And>b. b \<in> Basis \<Longrightarrow> f b \<in> borel_measurable borel"
hoelzl@57447
   385
  assumes nn[simp]: "\<And>b x. b \<in> Basis \<Longrightarrow> 0 \<le> f b x"
hoelzl@57447
   386
  shows "(\<integral>\<^sup>+x. (\<Prod>b\<in>Basis. f b (x \<bullet> b)) \<partial>lborel) = (\<Prod>b\<in>Basis. (\<integral>\<^sup>+x. f b x \<partial>lborel))"
hoelzl@57447
   387
  by (simp add: lborel_def nn_integral_distr product_nn_integral_setprod
hoelzl@57447
   388
                product_nn_integral_singleton)
hoelzl@57447
   389
lp15@60615
   390
lemma emeasure_lborel_Icc[simp]:
hoelzl@57447
   391
  fixes l u :: real
hoelzl@57447
   392
  assumes [simp]: "l \<le> u"
hoelzl@57447
   393
  shows "emeasure lborel {l .. u} = u - l"
hoelzl@50526
   394
proof -
hoelzl@57447
   395
  have "((\<lambda>f. f 1) -` {l..u} \<inter> space (Pi\<^sub>M {1} (\<lambda>b. interval_measure (\<lambda>x. x)))) = {1::real} \<rightarrow>\<^sub>E {l..u}"
hoelzl@57447
   396
    by (auto simp: space_PiM)
hoelzl@57447
   397
  then show ?thesis
hoelzl@57447
   398
    by (simp add: lborel_def emeasure_distr emeasure_PiM emeasure_interval_measure_Icc continuous_on_id)
hoelzl@50104
   399
qed
hoelzl@50104
   400
hoelzl@62975
   401
lemma emeasure_lborel_Icc_eq: "emeasure lborel {l .. u} = ennreal (if l \<le> u then u - l else 0)"
hoelzl@57447
   402
  by simp
hoelzl@47694
   403
hoelzl@57447
   404
lemma emeasure_lborel_cbox[simp]:
hoelzl@57447
   405
  assumes [simp]: "\<And>b. b \<in> Basis \<Longrightarrow> l \<bullet> b \<le> u \<bullet> b"
hoelzl@57447
   406
  shows "emeasure lborel (cbox l u) = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
hoelzl@41654
   407
proof -
hoelzl@62975
   408
  have "(\<lambda>x. \<Prod>b\<in>Basis. indicator {l\<bullet>b .. u\<bullet>b} (x \<bullet> b) :: ennreal) = indicator (cbox l u)"
hoelzl@62975
   409
    by (auto simp: fun_eq_iff cbox_def split: split_indicator)
hoelzl@57447
   410
  then have "emeasure lborel (cbox l u) = (\<integral>\<^sup>+x. (\<Prod>b\<in>Basis. indicator {l\<bullet>b .. u\<bullet>b} (x \<bullet> b)) \<partial>lborel)"
hoelzl@57447
   411
    by simp
hoelzl@57447
   412
  also have "\<dots> = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
hoelzl@62975
   413
    by (subst nn_integral_lborel_setprod) (simp_all add: setprod_ennreal inner_diff_left)
hoelzl@47694
   414
  finally show ?thesis .
hoelzl@38656
   415
qed
hoelzl@38656
   416
hoelzl@57447
   417
lemma AE_lborel_singleton: "AE x in lborel::'a::euclidean_space measure. x \<noteq> c"
hoelzl@62975
   418
  using SOME_Basis AE_discrete_difference [of "{c}" lborel] emeasure_lborel_cbox [of c c]
hoelzl@62975
   419
  by (auto simp add: cbox_sing setprod_constant power_0_left)
hoelzl@47757
   420
hoelzl@57447
   421
lemma emeasure_lborel_Ioo[simp]:
hoelzl@57447
   422
  assumes [simp]: "l \<le> u"
hoelzl@62975
   423
  shows "emeasure lborel {l <..< u} = ennreal (u - l)"
hoelzl@40859
   424
proof -
hoelzl@57447
   425
  have "emeasure lborel {l <..< u} = emeasure lborel {l .. u}"
hoelzl@57447
   426
    using AE_lborel_singleton[of u] AE_lborel_singleton[of l] by (intro emeasure_eq_AE) auto
hoelzl@47694
   427
  then show ?thesis
hoelzl@57447
   428
    by simp
hoelzl@41981
   429
qed
hoelzl@38656
   430
hoelzl@57447
   431
lemma emeasure_lborel_Ioc[simp]:
hoelzl@57447
   432
  assumes [simp]: "l \<le> u"
hoelzl@62975
   433
  shows "emeasure lborel {l <.. u} = ennreal (u - l)"
hoelzl@41654
   434
proof -
hoelzl@57447
   435
  have "emeasure lborel {l <.. u} = emeasure lborel {l .. u}"
hoelzl@57447
   436
    using AE_lborel_singleton[of u] AE_lborel_singleton[of l] by (intro emeasure_eq_AE) auto
hoelzl@57447
   437
  then show ?thesis
hoelzl@57447
   438
    by simp
hoelzl@38656
   439
qed
hoelzl@38656
   440
hoelzl@57447
   441
lemma emeasure_lborel_Ico[simp]:
hoelzl@57447
   442
  assumes [simp]: "l \<le> u"
hoelzl@62975
   443
  shows "emeasure lborel {l ..< u} = ennreal (u - l)"
hoelzl@57447
   444
proof -
hoelzl@57447
   445
  have "emeasure lborel {l ..< u} = emeasure lborel {l .. u}"
hoelzl@57447
   446
    using AE_lborel_singleton[of u] AE_lborel_singleton[of l] by (intro emeasure_eq_AE) auto
hoelzl@57447
   447
  then show ?thesis
hoelzl@57447
   448
    by simp
hoelzl@38656
   449
qed
hoelzl@38656
   450
hoelzl@57447
   451
lemma emeasure_lborel_box[simp]:
hoelzl@57447
   452
  assumes [simp]: "\<And>b. b \<in> Basis \<Longrightarrow> l \<bullet> b \<le> u \<bullet> b"
hoelzl@57447
   453
  shows "emeasure lborel (box l u) = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
hoelzl@57447
   454
proof -
hoelzl@62975
   455
  have "(\<lambda>x. \<Prod>b\<in>Basis. indicator {l\<bullet>b <..< u\<bullet>b} (x \<bullet> b) :: ennreal) = indicator (box l u)"
hoelzl@62975
   456
    by (auto simp: fun_eq_iff box_def split: split_indicator)
hoelzl@57447
   457
  then have "emeasure lborel (box l u) = (\<integral>\<^sup>+x. (\<Prod>b\<in>Basis. indicator {l\<bullet>b <..< u\<bullet>b} (x \<bullet> b)) \<partial>lborel)"
hoelzl@57447
   458
    by simp
hoelzl@57447
   459
  also have "\<dots> = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
hoelzl@62975
   460
    by (subst nn_integral_lborel_setprod) (simp_all add: setprod_ennreal inner_diff_left)
hoelzl@57447
   461
  finally show ?thesis .
hoelzl@40859
   462
qed
hoelzl@38656
   463
hoelzl@57447
   464
lemma emeasure_lborel_cbox_eq:
hoelzl@57447
   465
  "emeasure lborel (cbox l u) = (if \<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b then \<Prod>b\<in>Basis. (u - l) \<bullet> b else 0)"
hoelzl@57447
   466
  using box_eq_empty(2)[THEN iffD2, of u l] by (auto simp: not_le)
hoelzl@41654
   467
hoelzl@57447
   468
lemma emeasure_lborel_box_eq:
hoelzl@57447
   469
  "emeasure lborel (box l u) = (if \<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b then \<Prod>b\<in>Basis. (u - l) \<bullet> b else 0)"
hoelzl@57447
   470
  using box_eq_empty(1)[THEN iffD2, of u l] by (auto simp: not_le dest!: less_imp_le) force
hoelzl@40859
   471
hoelzl@40859
   472
lemma
hoelzl@57447
   473
  fixes l u :: real
hoelzl@57447
   474
  assumes [simp]: "l \<le> u"
hoelzl@57447
   475
  shows measure_lborel_Icc[simp]: "measure lborel {l .. u} = u - l"
hoelzl@57447
   476
    and measure_lborel_Ico[simp]: "measure lborel {l ..< u} = u - l"
hoelzl@57447
   477
    and measure_lborel_Ioc[simp]: "measure lborel {l <.. u} = u - l"
hoelzl@57447
   478
    and measure_lborel_Ioo[simp]: "measure lborel {l <..< u} = u - l"
hoelzl@57447
   479
  by (simp_all add: measure_def)
hoelzl@40859
   480
lp15@60615
   481
lemma
hoelzl@57447
   482
  assumes [simp]: "\<And>b. b \<in> Basis \<Longrightarrow> l \<bullet> b \<le> u \<bullet> b"
hoelzl@57447
   483
  shows measure_lborel_box[simp]: "measure lborel (box l u) = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
hoelzl@57447
   484
    and measure_lborel_cbox[simp]: "measure lborel (cbox l u) = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
hoelzl@62975
   485
  by (simp_all add: measure_def inner_diff_left setprod_nonneg)
hoelzl@41654
   486
hoelzl@57447
   487
lemma sigma_finite_lborel: "sigma_finite_measure lborel"
hoelzl@57447
   488
proof
hoelzl@57447
   489
  show "\<exists>A::'a set set. countable A \<and> A \<subseteq> sets lborel \<and> \<Union>A = space lborel \<and> (\<forall>a\<in>A. emeasure lborel a \<noteq> \<infinity>)"
hoelzl@57447
   490
    by (intro exI[of _ "range (\<lambda>n::nat. box (- real n *\<^sub>R One) (real n *\<^sub>R One))"])
hoelzl@57447
   491
       (auto simp: emeasure_lborel_cbox_eq UN_box_eq_UNIV)
hoelzl@49777
   492
qed
hoelzl@40859
   493
hoelzl@57447
   494
end
hoelzl@41689
   495
hoelzl@57447
   496
lemma emeasure_lborel_UNIV: "emeasure lborel (UNIV::'a::euclidean_space set) = \<infinity>"
lp15@59741
   497
proof -
lp15@59741
   498
  { fix n::nat
lp15@59741
   499
    let ?Ba = "Basis :: 'a set"
lp15@59741
   500
    have "real n \<le> (2::real) ^ card ?Ba * real n"
lp15@59741
   501
      by (simp add: mult_le_cancel_right1)
lp15@60615
   502
    also
lp15@59741
   503
    have "... \<le> (2::real) ^ card ?Ba * real (Suc n) ^ card ?Ba"
lp15@59741
   504
      apply (rule mult_left_mono)
lp15@61609
   505
      apply (metis DIM_positive One_nat_def less_eq_Suc_le less_imp_le of_nat_le_iff of_nat_power self_le_power zero_less_Suc)
lp15@59741
   506
      apply (simp add: DIM_positive)
lp15@59741
   507
      done
lp15@59741
   508
    finally have "real n \<le> (2::real) ^ card ?Ba * real (Suc n) ^ card ?Ba" .
lp15@59741
   509
  } note [intro!] = this
lp15@59741
   510
  show ?thesis
lp15@59741
   511
    unfolding UN_box_eq_UNIV[symmetric]
lp15@59741
   512
    apply (subst SUP_emeasure_incseq[symmetric])
lp15@60615
   513
    apply (auto simp: incseq_def subset_box inner_add_left setprod_constant
hoelzl@62975
   514
      simp del: Sup_eq_top_iff SUP_eq_top_iff
hoelzl@62975
   515
      intro!: ennreal_SUP_eq_top)
lp15@60615
   516
    done
lp15@59741
   517
qed
hoelzl@40859
   518
hoelzl@57447
   519
lemma emeasure_lborel_singleton[simp]: "emeasure lborel {x} = 0"
hoelzl@57447
   520
  using emeasure_lborel_cbox[of x x] nonempty_Basis
hoelzl@62975
   521
  by (auto simp del: emeasure_lborel_cbox nonempty_Basis simp add: cbox_sing setprod_constant)
hoelzl@56993
   522
hoelzl@57447
   523
lemma emeasure_lborel_countable:
hoelzl@57447
   524
  fixes A :: "'a::euclidean_space set"
hoelzl@57447
   525
  assumes "countable A"
hoelzl@57447
   526
  shows "emeasure lborel A = 0"
hoelzl@57447
   527
proof -
hoelzl@57447
   528
  have "A \<subseteq> (\<Union>i. {from_nat_into A i})" using from_nat_into_surj assms by force
hoelzl@57447
   529
  moreover have "emeasure lborel (\<Union>i. {from_nat_into A i}) = 0"
hoelzl@57447
   530
    by (rule emeasure_UN_eq_0) auto
hoelzl@57447
   531
  ultimately have "emeasure lborel A \<le> 0" using emeasure_mono
haftmann@62343
   532
    by (smt UN_E emeasure_empty equalityI from_nat_into order_refl singletonD subsetI)
hoelzl@62975
   533
  thus ?thesis by (auto simp add: )
hoelzl@40859
   534
qed
hoelzl@40859
   535
hoelzl@59425
   536
lemma countable_imp_null_set_lborel: "countable A \<Longrightarrow> A \<in> null_sets lborel"
hoelzl@59425
   537
  by (simp add: null_sets_def emeasure_lborel_countable sets.countable)
hoelzl@59425
   538
hoelzl@59425
   539
lemma finite_imp_null_set_lborel: "finite A \<Longrightarrow> A \<in> null_sets lborel"
hoelzl@59425
   540
  by (intro countable_imp_null_set_lborel countable_finite)
hoelzl@59425
   541
hoelzl@59425
   542
lemma lborel_neq_count_space[simp]: "lborel \<noteq> count_space (A::('a::ordered_euclidean_space) set)"
hoelzl@59425
   543
proof
hoelzl@59425
   544
  assume asm: "lborel = count_space A"
hoelzl@59425
   545
  have "space lborel = UNIV" by simp
hoelzl@59425
   546
  hence [simp]: "A = UNIV" by (subst (asm) asm) (simp only: space_count_space)
lp15@60615
   547
  have "emeasure lborel {undefined::'a} = 1"
hoelzl@59425
   548
      by (subst asm, subst emeasure_count_space_finite) auto
hoelzl@59425
   549
  moreover have "emeasure lborel {undefined} \<noteq> 1" by simp
hoelzl@59425
   550
  ultimately show False by contradiction
hoelzl@59425
   551
qed
hoelzl@59425
   552
wenzelm@61808
   553
subsection \<open>Affine transformation on the Lebesgue-Borel\<close>
hoelzl@49777
   554
hoelzl@49777
   555
lemma lborel_eqI:
hoelzl@57447
   556
  fixes M :: "'a::euclidean_space measure"
hoelzl@57447
   557
  assumes emeasure_eq: "\<And>l u. (\<And>b. b \<in> Basis \<Longrightarrow> l \<bullet> b \<le> u \<bullet> b) \<Longrightarrow> emeasure M (box l u) = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
hoelzl@49777
   558
  assumes sets_eq: "sets M = sets borel"
hoelzl@49777
   559
  shows "lborel = M"
hoelzl@57447
   560
proof (rule measure_eqI_generator_eq)
hoelzl@57447
   561
  let ?E = "range (\<lambda>(a, b). box a b::'a set)"
hoelzl@57447
   562
  show "Int_stable ?E"
hoelzl@57447
   563
    by (auto simp: Int_stable_def box_Int_box)
hoelzl@57447
   564
hoelzl@49777
   565
  show "?E \<subseteq> Pow UNIV" "sets lborel = sigma_sets UNIV ?E" "sets M = sigma_sets UNIV ?E"
hoelzl@57447
   566
    by (simp_all add: borel_eq_box sets_eq)
hoelzl@49777
   567
hoelzl@57447
   568
  let ?A = "\<lambda>n::nat. box (- (real n *\<^sub>R One)) (real n *\<^sub>R One) :: 'a set"
hoelzl@57447
   569
  show "range ?A \<subseteq> ?E" "(\<Union>i. ?A i) = UNIV"
hoelzl@57447
   570
    unfolding UN_box_eq_UNIV by auto
hoelzl@49777
   571
hoelzl@57447
   572
  { fix i show "emeasure lborel (?A i) \<noteq> \<infinity>" by auto }
hoelzl@49777
   573
  { fix X assume "X \<in> ?E" then show "emeasure lborel X = emeasure M X"
hoelzl@57447
   574
      apply (auto simp: emeasure_eq emeasure_lborel_box_eq )
hoelzl@57447
   575
      apply (subst box_eq_empty(1)[THEN iffD2])
hoelzl@57447
   576
      apply (auto intro: less_imp_le simp: not_le)
hoelzl@57447
   577
      done }
hoelzl@49777
   578
qed
hoelzl@49777
   579
hoelzl@57447
   580
lemma lborel_affine:
hoelzl@57447
   581
  fixes t :: "'a::euclidean_space" assumes "c \<noteq> 0"
hoelzl@57447
   582
  shows "lborel = density (distr lborel borel (\<lambda>x. t + c *\<^sub>R x)) (\<lambda>_. \<bar>c\<bar>^DIM('a))" (is "_ = ?D")
hoelzl@49777
   583
proof (rule lborel_eqI)
hoelzl@57447
   584
  let ?B = "Basis :: 'a set"
hoelzl@57447
   585
  fix l u assume le: "\<And>b. b \<in> ?B \<Longrightarrow> l \<bullet> b \<le> u \<bullet> b"
hoelzl@57447
   586
  show "emeasure ?D (box l u) = (\<Prod>b\<in>?B. (u - l) \<bullet> b)"
hoelzl@49777
   587
  proof cases
hoelzl@49777
   588
    assume "0 < c"
hoelzl@57447
   589
    then have "(\<lambda>x. t + c *\<^sub>R x) -` box l u = box ((l - t) /\<^sub>R c) ((u - t) /\<^sub>R c)"
hoelzl@57447
   590
      by (auto simp: field_simps box_def inner_simps)
wenzelm@61808
   591
    with \<open>0 < c\<close> show ?thesis
hoelzl@57447
   592
      using le
hoelzl@62975
   593
      by (auto simp: field_simps inner_simps setprod_dividef setprod_constant setprod_nonneg
hoelzl@62975
   594
                     ennreal_mult[symmetric] emeasure_density nn_integral_distr emeasure_distr
hoelzl@62975
   595
                     nn_integral_cmult emeasure_lborel_box_eq borel_measurable_indicator')
hoelzl@49777
   596
  next
wenzelm@61808
   597
    assume "\<not> 0 < c" with \<open>c \<noteq> 0\<close> have "c < 0" by auto
hoelzl@57447
   598
    then have "box ((u - t) /\<^sub>R c) ((l - t) /\<^sub>R c) = (\<lambda>x. t + c *\<^sub>R x) -` box l u"
hoelzl@57447
   599
      by (auto simp: field_simps box_def inner_simps)
hoelzl@62975
   600
    then have *: "\<And>x. indicator (box l u) (t + c *\<^sub>R x) = (indicator (box ((u - t) /\<^sub>R c) ((l - t) /\<^sub>R c)) x :: ennreal)"
hoelzl@57447
   601
      by (auto split: split_indicator)
hoelzl@62975
   602
    have **: "(\<Prod>x\<in>Basis. (l \<bullet> x - u \<bullet> x) / c) = (\<Prod>x\<in>Basis. u \<bullet> x - l \<bullet> x) / (-c) ^ card (Basis::'a set)"
hoelzl@62975
   603
      using \<open>c < 0\<close>
hoelzl@62975
   604
      by (auto simp add: field_simps setprod_dividef[symmetric] setprod_constant[symmetric]
hoelzl@62975
   605
               intro!: setprod.cong)
hoelzl@62975
   606
    show ?thesis
wenzelm@61808
   607
      using \<open>c < 0\<close> le
hoelzl@62975
   608
      by (auto simp: * ** field_simps emeasure_density nn_integral_distr nn_integral_cmult
hoelzl@62975
   609
                     emeasure_lborel_box_eq inner_simps setprod_nonneg ennreal_mult[symmetric]
hoelzl@62975
   610
                     borel_measurable_indicator')
hoelzl@49777
   611
  qed
hoelzl@49777
   612
qed simp
hoelzl@49777
   613
hoelzl@57447
   614
lemma lborel_real_affine:
hoelzl@62975
   615
  "c \<noteq> 0 \<Longrightarrow> lborel = density (distr lborel borel (\<lambda>x. t + c * x)) (\<lambda>_. ennreal (abs c))"
hoelzl@57447
   616
  using lborel_affine[of c t] by simp
hoelzl@57447
   617
lp15@60615
   618
lemma AE_borel_affine:
hoelzl@57447
   619
  fixes P :: "real \<Rightarrow> bool"
hoelzl@57447
   620
  shows "c \<noteq> 0 \<Longrightarrow> Measurable.pred borel P \<Longrightarrow> AE x in lborel. P x \<Longrightarrow> AE x in lborel. P (t + c * x)"
hoelzl@57447
   621
  by (subst lborel_real_affine[where t="- t / c" and c="1 / c"])
hoelzl@57447
   622
     (simp_all add: AE_density AE_distr_iff field_simps)
hoelzl@57447
   623
hoelzl@56996
   624
lemma nn_integral_real_affine:
hoelzl@56993
   625
  fixes c :: real assumes [measurable]: "f \<in> borel_measurable borel" and c: "c \<noteq> 0"
hoelzl@56993
   626
  shows "(\<integral>\<^sup>+x. f x \<partial>lborel) = \<bar>c\<bar> * (\<integral>\<^sup>+x. f (t + c * x) \<partial>lborel)"
hoelzl@56993
   627
  by (subst lborel_real_affine[OF c, of t])
hoelzl@56996
   628
     (simp add: nn_integral_density nn_integral_distr nn_integral_cmult)
hoelzl@56993
   629
hoelzl@56993
   630
lemma lborel_integrable_real_affine:
hoelzl@57447
   631
  fixes f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@56993
   632
  assumes f: "integrable lborel f"
hoelzl@56993
   633
  shows "c \<noteq> 0 \<Longrightarrow> integrable lborel (\<lambda>x. f (t + c * x))"
hoelzl@56993
   634
  using f f[THEN borel_measurable_integrable] unfolding integrable_iff_bounded
hoelzl@62975
   635
  by (subst (asm) nn_integral_real_affine[where c=c and t=t]) (auto simp: ennreal_mult_less_top)
hoelzl@56993
   636
hoelzl@56993
   637
lemma lborel_integrable_real_affine_iff:
hoelzl@56993
   638
  fixes f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@56993
   639
  shows "c \<noteq> 0 \<Longrightarrow> integrable lborel (\<lambda>x. f (t + c * x)) \<longleftrightarrow> integrable lborel f"
hoelzl@56993
   640
  using
hoelzl@56993
   641
    lborel_integrable_real_affine[of f c t]
hoelzl@56993
   642
    lborel_integrable_real_affine[of "\<lambda>x. f (t + c * x)" "1/c" "-t/c"]
hoelzl@56993
   643
  by (auto simp add: field_simps)
hoelzl@56993
   644
hoelzl@56993
   645
lemma lborel_integral_real_affine:
hoelzl@56993
   646
  fixes f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}" and c :: real
hoelzl@57166
   647
  assumes c: "c \<noteq> 0" shows "(\<integral>x. f x \<partial> lborel) = \<bar>c\<bar> *\<^sub>R (\<integral>x. f (t + c * x) \<partial>lborel)"
hoelzl@57166
   648
proof cases
hoelzl@57166
   649
  assume f[measurable]: "integrable lborel f" then show ?thesis
hoelzl@57166
   650
    using c f f[THEN borel_measurable_integrable] f[THEN lborel_integrable_real_affine, of c t]
hoelzl@57447
   651
    by (subst lborel_real_affine[OF c, of t])
hoelzl@57447
   652
       (simp add: integral_density integral_distr)
hoelzl@57166
   653
next
hoelzl@57166
   654
  assume "\<not> integrable lborel f" with c show ?thesis
hoelzl@57166
   655
    by (simp add: lborel_integrable_real_affine_iff not_integrable_integral_eq)
hoelzl@57166
   656
qed
hoelzl@56993
   657
lp15@60615
   658
lemma divideR_right:
hoelzl@56993
   659
  fixes x y :: "'a::real_normed_vector"
hoelzl@56993
   660
  shows "r \<noteq> 0 \<Longrightarrow> y = x /\<^sub>R r \<longleftrightarrow> r *\<^sub>R y = x"
hoelzl@56993
   661
  using scaleR_cancel_left[of r y "x /\<^sub>R r"] by simp
hoelzl@56993
   662
hoelzl@56993
   663
lemma lborel_has_bochner_integral_real_affine_iff:
hoelzl@56993
   664
  fixes x :: "'a :: {banach, second_countable_topology}"
hoelzl@56993
   665
  shows "c \<noteq> 0 \<Longrightarrow>
hoelzl@56993
   666
    has_bochner_integral lborel f x \<longleftrightarrow>
hoelzl@56993
   667
    has_bochner_integral lborel (\<lambda>x. f (t + c * x)) (x /\<^sub>R \<bar>c\<bar>)"
hoelzl@56993
   668
  unfolding has_bochner_integral_iff lborel_integrable_real_affine_iff
hoelzl@56993
   669
  by (simp_all add: lborel_integral_real_affine[symmetric] divideR_right cong: conj_cong)
hoelzl@49777
   670
hoelzl@59425
   671
lemma lborel_distr_uminus: "distr lborel borel uminus = (lborel :: real measure)"
lp15@60615
   672
  by (subst lborel_real_affine[of "-1" 0])
hoelzl@62975
   673
     (auto simp: density_1 one_ennreal_def[symmetric])
hoelzl@59425
   674
lp15@60615
   675
lemma lborel_distr_mult:
hoelzl@59425
   676
  assumes "(c::real) \<noteq> 0"
hoelzl@59425
   677
  shows "distr lborel borel (op * c) = density lborel (\<lambda>_. inverse \<bar>c\<bar>)"
hoelzl@59425
   678
proof-
hoelzl@59425
   679
  have "distr lborel borel (op * c) = distr lborel lborel (op * c)" by (simp cong: distr_cong)
hoelzl@59425
   680
  also from assms have "... = density lborel (\<lambda>_. inverse \<bar>c\<bar>)"
hoelzl@59425
   681
    by (subst lborel_real_affine[of "inverse c" 0]) (auto simp: o_def distr_density_distr)
hoelzl@59425
   682
  finally show ?thesis .
hoelzl@59425
   683
qed
hoelzl@59425
   684
lp15@60615
   685
lemma lborel_distr_mult':
hoelzl@59425
   686
  assumes "(c::real) \<noteq> 0"
wenzelm@61945
   687
  shows "lborel = density (distr lborel borel (op * c)) (\<lambda>_. \<bar>c\<bar>)"
hoelzl@59425
   688
proof-
hoelzl@59425
   689
  have "lborel = density lborel (\<lambda>_. 1)" by (rule density_1[symmetric])
hoelzl@62975
   690
  also from assms have "(\<lambda>_. 1 :: ennreal) = (\<lambda>_. inverse \<bar>c\<bar> * \<bar>c\<bar>)" by (intro ext) simp
wenzelm@61945
   691
  also have "density lborel ... = density (density lborel (\<lambda>_. inverse \<bar>c\<bar>)) (\<lambda>_. \<bar>c\<bar>)"
hoelzl@62975
   692
    by (subst density_density_eq) (auto simp: ennreal_mult)
wenzelm@61945
   693
  also from assms have "density lborel (\<lambda>_. inverse \<bar>c\<bar>) = distr lborel borel (op * c)"
hoelzl@59425
   694
    by (rule lborel_distr_mult[symmetric])
hoelzl@59425
   695
  finally show ?thesis .
hoelzl@59425
   696
qed
hoelzl@59425
   697
hoelzl@59425
   698
lemma lborel_distr_plus: "distr lborel borel (op + c) = (lborel :: real measure)"
hoelzl@62975
   699
  by (subst lborel_real_affine[of 1 c]) (auto simp: density_1 one_ennreal_def[symmetric])
hoelzl@59425
   700
wenzelm@61605
   701
interpretation lborel: sigma_finite_measure lborel
hoelzl@57447
   702
  by (rule sigma_finite_lborel)
hoelzl@57447
   703
hoelzl@57447
   704
interpretation lborel_pair: pair_sigma_finite lborel lborel ..
hoelzl@57447
   705
hoelzl@59425
   706
lemma lborel_prod:
hoelzl@59425
   707
  "lborel \<Otimes>\<^sub>M lborel = (lborel :: ('a::euclidean_space \<times> 'b::euclidean_space) measure)"
hoelzl@59425
   708
proof (rule lborel_eqI[symmetric], clarify)
hoelzl@59425
   709
  fix la ua :: 'a and lb ub :: 'b
hoelzl@59425
   710
  assume lu: "\<And>a b. (a, b) \<in> Basis \<Longrightarrow> (la, lb) \<bullet> (a, b) \<le> (ua, ub) \<bullet> (a, b)"
hoelzl@59425
   711
  have [simp]:
hoelzl@59425
   712
    "\<And>b. b \<in> Basis \<Longrightarrow> la \<bullet> b \<le> ua \<bullet> b"
hoelzl@59425
   713
    "\<And>b. b \<in> Basis \<Longrightarrow> lb \<bullet> b \<le> ub \<bullet> b"
hoelzl@59425
   714
    "inj_on (\<lambda>u. (u, 0)) Basis" "inj_on (\<lambda>u. (0, u)) Basis"
hoelzl@59425
   715
    "(\<lambda>u. (u, 0)) ` Basis \<inter> (\<lambda>u. (0, u)) ` Basis = {}"
hoelzl@59425
   716
    "box (la, lb) (ua, ub) = box la ua \<times> box lb ub"
hoelzl@59425
   717
    using lu[of _ 0] lu[of 0] by (auto intro!: inj_onI simp add: Basis_prod_def ball_Un box_def)
hoelzl@59425
   718
  show "emeasure (lborel \<Otimes>\<^sub>M lborel) (box (la, lb) (ua, ub)) =
hoelzl@62975
   719
      ennreal (setprod (op \<bullet> ((ua, ub) - (la, lb))) Basis)"
hoelzl@59425
   720
    by (simp add: lborel.emeasure_pair_measure_Times Basis_prod_def setprod.union_disjoint
hoelzl@62975
   721
                  setprod.reindex ennreal_mult inner_diff_left setprod_nonneg)
hoelzl@59425
   722
qed (simp add: borel_prod[symmetric])
hoelzl@59425
   723
hoelzl@57447
   724
(* FIXME: conversion in measurable prover *)
hoelzl@57447
   725
lemma lborelD_Collect[measurable (raw)]: "{x\<in>space borel. P x} \<in> sets borel \<Longrightarrow> {x\<in>space lborel. P x} \<in> sets lborel" by simp
hoelzl@57447
   726
lemma lborelD[measurable (raw)]: "A \<in> sets borel \<Longrightarrow> A \<in> sets lborel" by simp
hoelzl@57447
   727
wenzelm@61808
   728
subsection \<open>Equivalence Lebesgue integral on @{const lborel} and HK-integral\<close>
hoelzl@41706
   729
hoelzl@57447
   730
lemma has_integral_measure_lborel:
hoelzl@57447
   731
  fixes A :: "'a::euclidean_space set"
hoelzl@57447
   732
  assumes A[measurable]: "A \<in> sets borel" and finite: "emeasure lborel A < \<infinity>"
hoelzl@57447
   733
  shows "((\<lambda>x. 1) has_integral measure lborel A) A"
hoelzl@57447
   734
proof -
hoelzl@57447
   735
  { fix l u :: 'a
hoelzl@57447
   736
    have "((\<lambda>x. 1) has_integral measure lborel (box l u)) (box l u)"
hoelzl@57447
   737
    proof cases
hoelzl@57447
   738
      assume "\<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b"
hoelzl@57447
   739
      then show ?thesis
hoelzl@57447
   740
        apply simp
hoelzl@57447
   741
        apply (subst has_integral_restrict[symmetric, OF box_subset_cbox])
hoelzl@57447
   742
        apply (subst has_integral_spike_interior_eq[where g="\<lambda>_. 1"])
hoelzl@57447
   743
        using has_integral_const[of "1::real" l u]
hoelzl@57447
   744
        apply (simp_all add: inner_diff_left[symmetric] content_cbox_cases)
hoelzl@57447
   745
        done
hoelzl@57447
   746
    next
hoelzl@57447
   747
      assume "\<not> (\<forall>b\<in>Basis. l \<bullet> b \<le> u \<bullet> b)"
hoelzl@57447
   748
      then have "box l u = {}"
hoelzl@57447
   749
        unfolding box_eq_empty by (auto simp: not_le intro: less_imp_le)
hoelzl@57447
   750
      then show ?thesis
hoelzl@57447
   751
        by simp
hoelzl@57447
   752
    qed }
hoelzl@57447
   753
  note has_integral_box = this
hoelzl@56993
   754
hoelzl@57447
   755
  { fix a b :: 'a let ?M = "\<lambda>A. measure lborel (A \<inter> box a b)"
hoelzl@57447
   756
    have "Int_stable  (range (\<lambda>(a, b). box a b))"
hoelzl@57447
   757
      by (auto simp: Int_stable_def box_Int_box)
hoelzl@57447
   758
    moreover have "(range (\<lambda>(a, b). box a b)) \<subseteq> Pow UNIV"
hoelzl@57447
   759
      by auto
hoelzl@57447
   760
    moreover have "A \<in> sigma_sets UNIV (range (\<lambda>(a, b). box a b))"
hoelzl@57447
   761
       using A unfolding borel_eq_box by simp
hoelzl@57447
   762
    ultimately have "((\<lambda>x. 1) has_integral ?M A) (A \<inter> box a b)"
hoelzl@57447
   763
    proof (induction rule: sigma_sets_induct_disjoint)
hoelzl@57447
   764
      case (basic A) then show ?case
hoelzl@57447
   765
        by (auto simp: box_Int_box has_integral_box)
hoelzl@57447
   766
    next
hoelzl@57447
   767
      case empty then show ?case
hoelzl@57447
   768
        by simp
hoelzl@57447
   769
    next
hoelzl@57447
   770
      case (compl A)
hoelzl@57447
   771
      then have [measurable]: "A \<in> sets borel"
hoelzl@57447
   772
        by (simp add: borel_eq_box)
hoelzl@56993
   773
hoelzl@57447
   774
      have "((\<lambda>x. 1) has_integral ?M (box a b)) (box a b)"
hoelzl@57447
   775
        by (simp add: has_integral_box)
hoelzl@57447
   776
      moreover have "((\<lambda>x. if x \<in> A \<inter> box a b then 1 else 0) has_integral ?M A) (box a b)"
hoelzl@57447
   777
        by (subst has_integral_restrict) (auto intro: compl)
hoelzl@57447
   778
      ultimately have "((\<lambda>x. 1 - (if x \<in> A \<inter> box a b then 1 else 0)) has_integral ?M (box a b) - ?M A) (box a b)"
hoelzl@57447
   779
        by (rule has_integral_sub)
hoelzl@57447
   780
      then have "((\<lambda>x. (if x \<in> (UNIV - A) \<inter> box a b then 1 else 0)) has_integral ?M (box a b) - ?M A) (box a b)"
lp15@60615
   781
        by (rule has_integral_cong[THEN iffD1, rotated 1]) auto
hoelzl@57447
   782
      then have "((\<lambda>x. 1) has_integral ?M (box a b) - ?M A) ((UNIV - A) \<inter> box a b)"
hoelzl@57447
   783
        by (subst (asm) has_integral_restrict) auto
hoelzl@57447
   784
      also have "?M (box a b) - ?M A = ?M (UNIV - A)"
hoelzl@57447
   785
        by (subst measure_Diff[symmetric]) (auto simp: emeasure_lborel_box_eq Diff_Int_distrib2)
hoelzl@57447
   786
      finally show ?case .
hoelzl@57447
   787
    next
hoelzl@57447
   788
      case (union F)
hoelzl@57447
   789
      then have [measurable]: "\<And>i. F i \<in> sets borel"
hoelzl@57447
   790
        by (simp add: borel_eq_box subset_eq)
hoelzl@57447
   791
      have "((\<lambda>x. if x \<in> UNION UNIV F \<inter> box a b then 1 else 0) has_integral ?M (\<Union>i. F i)) (box a b)"
hoelzl@57447
   792
      proof (rule has_integral_monotone_convergence_increasing)
hoelzl@57447
   793
        let ?f = "\<lambda>k x. \<Sum>i<k. if x \<in> F i \<inter> box a b then 1 else 0 :: real"
hoelzl@57447
   794
        show "\<And>k. (?f k has_integral (\<Sum>i<k. ?M (F i))) (box a b)"
hoelzl@57447
   795
          using union.IH by (auto intro!: has_integral_setsum simp del: Int_iff)
hoelzl@57447
   796
        show "\<And>k x. ?f k x \<le> ?f (Suc k) x"
hoelzl@57447
   797
          by (intro setsum_mono2) auto
hoelzl@57447
   798
        from union(1) have *: "\<And>x i j. x \<in> F i \<Longrightarrow> x \<in> F j \<longleftrightarrow> j = i"
hoelzl@57447
   799
          by (auto simp add: disjoint_family_on_def)
wenzelm@61969
   800
        show "\<And>x. (\<lambda>k. ?f k x) \<longlonglongrightarrow> (if x \<in> UNION UNIV F \<inter> box a b then 1 else 0)"
hoelzl@57447
   801
          apply (auto simp: * setsum.If_cases Iio_Int_singleton)
hoelzl@57447
   802
          apply (rule_tac k="Suc xa" in LIMSEQ_offset)
hoelzl@62975
   803
          apply simp
hoelzl@57447
   804
          done
hoelzl@57447
   805
        have *: "emeasure lborel ((\<Union>x. F x) \<inter> box a b) \<le> emeasure lborel (box a b)"
hoelzl@57447
   806
          by (intro emeasure_mono) auto
hoelzl@57447
   807
wenzelm@61969
   808
        with union(1) show "(\<lambda>k. \<Sum>i<k. ?M (F i)) \<longlonglongrightarrow> ?M (\<Union>i. F i)"
hoelzl@57447
   809
          unfolding sums_def[symmetric] UN_extend_simps
hoelzl@62975
   810
          by (intro measure_UNION) (auto simp: disjoint_family_on_def emeasure_lborel_box_eq top_unique)
hoelzl@57447
   811
      qed
hoelzl@57447
   812
      then show ?case
hoelzl@57447
   813
        by (subst (asm) has_integral_restrict) auto
hoelzl@57447
   814
    qed }
hoelzl@57447
   815
  note * = this
hoelzl@57447
   816
hoelzl@57447
   817
  show ?thesis
hoelzl@57447
   818
  proof (rule has_integral_monotone_convergence_increasing)
hoelzl@57447
   819
    let ?B = "\<lambda>n::nat. box (- real n *\<^sub>R One) (real n *\<^sub>R One) :: 'a set"
hoelzl@57447
   820
    let ?f = "\<lambda>n::nat. \<lambda>x. if x \<in> A \<inter> ?B n then 1 else 0 :: real"
hoelzl@57447
   821
    let ?M = "\<lambda>n. measure lborel (A \<inter> ?B n)"
hoelzl@57447
   822
hoelzl@57447
   823
    show "\<And>n::nat. (?f n has_integral ?M n) A"
hoelzl@57447
   824
      using * by (subst has_integral_restrict) simp_all
hoelzl@57447
   825
    show "\<And>k x. ?f k x \<le> ?f (Suc k) x"
hoelzl@57447
   826
      by (auto simp: box_def)
hoelzl@57447
   827
    { fix x assume "x \<in> A"
wenzelm@61969
   828
      moreover have "(\<lambda>k. indicator (A \<inter> ?B k) x :: real) \<longlonglongrightarrow> indicator (\<Union>k::nat. A \<inter> ?B k) x"
hoelzl@57447
   829
        by (intro LIMSEQ_indicator_incseq) (auto simp: incseq_def box_def)
wenzelm@61969
   830
      ultimately show "(\<lambda>k. if x \<in> A \<inter> ?B k then 1 else 0::real) \<longlonglongrightarrow> 1"
hoelzl@57447
   831
        by (simp add: indicator_def UN_box_eq_UNIV) }
hoelzl@57447
   832
wenzelm@61969
   833
    have "(\<lambda>n. emeasure lborel (A \<inter> ?B n)) \<longlonglongrightarrow> emeasure lborel (\<Union>n::nat. A \<inter> ?B n)"
hoelzl@57447
   834
      by (intro Lim_emeasure_incseq) (auto simp: incseq_def box_def)
hoelzl@57447
   835
    also have "(\<lambda>n. emeasure lborel (A \<inter> ?B n)) = (\<lambda>n. measure lborel (A \<inter> ?B n))"
hoelzl@62975
   836
    proof (intro ext emeasure_eq_ennreal_measure)
hoelzl@57447
   837
      fix n have "emeasure lborel (A \<inter> ?B n) \<le> emeasure lborel (?B n)"
hoelzl@57447
   838
        by (intro emeasure_mono) auto
hoelzl@62975
   839
      then show "emeasure lborel (A \<inter> ?B n) \<noteq> top"
hoelzl@62975
   840
        by (auto simp: top_unique)
hoelzl@57447
   841
    qed
wenzelm@61969
   842
    finally show "(\<lambda>n. measure lborel (A \<inter> ?B n)) \<longlonglongrightarrow> measure lborel A"
hoelzl@62975
   843
      using emeasure_eq_ennreal_measure[of lborel A] finite
hoelzl@62975
   844
      by (simp add: UN_box_eq_UNIV less_top)
hoelzl@41654
   845
  qed
hoelzl@40859
   846
qed
hoelzl@40859
   847
hoelzl@56996
   848
lemma nn_integral_has_integral:
hoelzl@57447
   849
  fixes f::"'a::euclidean_space \<Rightarrow> real"
hoelzl@62975
   850
  assumes f: "f \<in> borel_measurable borel" "\<And>x. 0 \<le> f x" "(\<integral>\<^sup>+x. f x \<partial>lborel) = ennreal r" "0 \<le> r"
hoelzl@56993
   851
  shows "(f has_integral r) UNIV"
hoelzl@62975
   852
using f proof (induct f arbitrary: r rule: borel_measurable_induct_real)
hoelzl@57447
   853
  case (set A)
hoelzl@57447
   854
  moreover then have "((\<lambda>x. 1) has_integral measure lborel A) A"
hoelzl@62975
   855
    by (intro has_integral_measure_lborel) (auto simp: ennreal_indicator)
hoelzl@57447
   856
  ultimately show ?case
hoelzl@62975
   857
    by (simp add: ennreal_indicator measure_def) (simp add: indicator_def)
hoelzl@56993
   858
next
hoelzl@56993
   859
  case (mult g c)
hoelzl@62975
   860
  then have "ennreal c * (\<integral>\<^sup>+ x. g x \<partial>lborel) = ennreal r"
hoelzl@62975
   861
    by (subst nn_integral_cmult[symmetric]) (auto simp: ennreal_mult)
hoelzl@62975
   862
  with \<open>0 \<le> r\<close> \<open>0 \<le> c\<close>
hoelzl@62975
   863
  obtain r' where "(c = 0 \<and> r = 0) \<or> (0 \<le> r' \<and> (\<integral>\<^sup>+ x. ennreal (g x) \<partial>lborel) = ennreal r' \<and> r = c * r')"
hoelzl@62975
   864
    by (cases "\<integral>\<^sup>+ x. ennreal (g x) \<partial>lborel" rule: ennreal_cases)
hoelzl@62975
   865
       (auto split: if_split_asm simp: ennreal_mult_top ennreal_mult[symmetric])
hoelzl@56993
   866
  with mult show ?case
hoelzl@56993
   867
    by (auto intro!: has_integral_cmult_real)
hoelzl@56993
   868
next
hoelzl@56993
   869
  case (add g h)
hoelzl@56993
   870
  moreover
hoelzl@57447
   871
  then have "(\<integral>\<^sup>+ x. h x + g x \<partial>lborel) = (\<integral>\<^sup>+ x. h x \<partial>lborel) + (\<integral>\<^sup>+ x. g x \<partial>lborel)"
hoelzl@62975
   872
    by (simp add: nn_integral_add)
hoelzl@62975
   873
  with add obtain a b where "0 \<le> a" "0 \<le> b" "(\<integral>\<^sup>+ x. h x \<partial>lborel) = ennreal a" "(\<integral>\<^sup>+ x. g x \<partial>lborel) = ennreal b" "r = a + b"
hoelzl@62975
   874
    by (cases "\<integral>\<^sup>+ x. h x \<partial>lborel" "\<integral>\<^sup>+ x. g x \<partial>lborel" rule: ennreal2_cases)
hoelzl@62975
   875
       (auto simp: add_top nn_integral_add top_add ennreal_plus[symmetric] simp del: ennreal_plus)
hoelzl@56993
   876
  ultimately show ?case
hoelzl@56993
   877
    by (auto intro!: has_integral_add)
hoelzl@56993
   878
next
hoelzl@56993
   879
  case (seq U)
hoelzl@56993
   880
  note seq(1)[measurable] and f[measurable]
hoelzl@40859
   881
lp15@60615
   882
  { fix i x
hoelzl@56993
   883
    have "U i x \<le> f x"
hoelzl@56993
   884
      using seq(5)
hoelzl@56993
   885
      apply (rule LIMSEQ_le_const)
hoelzl@56993
   886
      using seq(4)
hoelzl@56993
   887
      apply (auto intro!: exI[of _ i] simp: incseq_def le_fun_def)
hoelzl@56993
   888
      done }
hoelzl@56993
   889
  note U_le_f = this
lp15@60615
   890
hoelzl@56993
   891
  { fix i
hoelzl@62975
   892
    have "(\<integral>\<^sup>+x. U i x \<partial>lborel) \<le> (\<integral>\<^sup>+x. f x \<partial>lborel)"
hoelzl@62975
   893
      using seq(2) f(2) U_le_f by (intro nn_integral_mono) simp
hoelzl@62975
   894
    then obtain p where "(\<integral>\<^sup>+x. U i x \<partial>lborel) = ennreal p" "p \<le> r" "0 \<le> p"
hoelzl@62975
   895
      using seq(6) \<open>0\<le>r\<close> by (cases "\<integral>\<^sup>+x. U i x \<partial>lborel" rule: ennreal_cases) (auto simp: top_unique)
hoelzl@56993
   896
    moreover note seq
hoelzl@62975
   897
    ultimately have "\<exists>p. (\<integral>\<^sup>+x. U i x \<partial>lborel) = ennreal p \<and> 0 \<le> p \<and> p \<le> r \<and> (U i has_integral p) UNIV"
hoelzl@56993
   898
      by auto }
hoelzl@62975
   899
  then obtain p where p: "\<And>i. (\<integral>\<^sup>+x. ennreal (U i x) \<partial>lborel) = ennreal (p i)"
hoelzl@56993
   900
    and bnd: "\<And>i. p i \<le> r" "\<And>i. 0 \<le> p i"
hoelzl@56993
   901
    and U_int: "\<And>i.(U i has_integral (p i)) UNIV" by metis
hoelzl@56993
   902
hoelzl@56993
   903
  have int_eq: "\<And>i. integral UNIV (U i) = p i" using U_int by (rule integral_unique)
hoelzl@56993
   904
wenzelm@61969
   905
  have *: "f integrable_on UNIV \<and> (\<lambda>k. integral UNIV (U k)) \<longlonglongrightarrow> integral UNIV f"
hoelzl@56993
   906
  proof (rule monotone_convergence_increasing)
hoelzl@56993
   907
    show "\<forall>k. U k integrable_on UNIV" using U_int by auto
wenzelm@61808
   908
    show "\<forall>k. \<forall>x\<in>UNIV. U k x \<le> U (Suc k) x" using \<open>incseq U\<close> by (auto simp: incseq_def le_fun_def)
hoelzl@56993
   909
    then show "bounded {integral UNIV (U k) |k. True}"
hoelzl@56993
   910
      using bnd int_eq by (auto simp: bounded_real intro!: exI[of _ r])
wenzelm@61969
   911
    show "\<forall>x\<in>UNIV. (\<lambda>k. U k x) \<longlonglongrightarrow> f x"
hoelzl@56993
   912
      using seq by auto
hoelzl@41981
   913
  qed
wenzelm@61969
   914
  moreover have "(\<lambda>i. (\<integral>\<^sup>+x. U i x \<partial>lborel)) \<longlonglongrightarrow> (\<integral>\<^sup>+x. f x \<partial>lborel)"
hoelzl@62975
   915
    using seq f(2) U_le_f by (intro nn_integral_dominated_convergence[where w=f]) auto
hoelzl@56993
   916
  ultimately have "integral UNIV f = r"
hoelzl@62975
   917
    by (auto simp add: bnd int_eq p seq intro: LIMSEQ_unique)
hoelzl@56993
   918
  with * show ?case
hoelzl@56993
   919
    by (simp add: has_integral_integral)
hoelzl@40859
   920
qed
hoelzl@40859
   921
hoelzl@57447
   922
lemma nn_integral_lborel_eq_integral:
hoelzl@57447
   923
  fixes f::"'a::euclidean_space \<Rightarrow> real"
hoelzl@57447
   924
  assumes f: "f \<in> borel_measurable borel" "\<And>x. 0 \<le> f x" "(\<integral>\<^sup>+x. f x \<partial>lborel) < \<infinity>"
hoelzl@57447
   925
  shows "(\<integral>\<^sup>+x. f x \<partial>lborel) = integral UNIV f"
hoelzl@57447
   926
proof -
hoelzl@62975
   927
  from f(3) obtain r where r: "(\<integral>\<^sup>+x. f x \<partial>lborel) = ennreal r" "0 \<le> r"
hoelzl@62975
   928
    by (cases "\<integral>\<^sup>+x. f x \<partial>lborel" rule: ennreal_cases) auto
hoelzl@57447
   929
  then show ?thesis
hoelzl@57447
   930
    using nn_integral_has_integral[OF f(1,2) r] by (simp add: integral_unique)
hoelzl@57447
   931
qed
hoelzl@57447
   932
hoelzl@57447
   933
lemma nn_integral_integrable_on:
hoelzl@57447
   934
  fixes f::"'a::euclidean_space \<Rightarrow> real"
hoelzl@57447
   935
  assumes f: "f \<in> borel_measurable borel" "\<And>x. 0 \<le> f x" "(\<integral>\<^sup>+x. f x \<partial>lborel) < \<infinity>"
hoelzl@57447
   936
  shows "f integrable_on UNIV"
hoelzl@57447
   937
proof -
hoelzl@62975
   938
  from f(3) obtain r where r: "(\<integral>\<^sup>+x. f x \<partial>lborel) = ennreal r" "0 \<le> r"
hoelzl@62975
   939
    by (cases "\<integral>\<^sup>+x. f x \<partial>lborel" rule: ennreal_cases) auto
hoelzl@57447
   940
  then show ?thesis
hoelzl@57447
   941
    by (intro has_integral_integrable[where i=r] nn_integral_has_integral[where r=r] f)
hoelzl@57447
   942
qed
hoelzl@57447
   943
lp15@60615
   944
lemma nn_integral_has_integral_lborel:
hoelzl@57447
   945
  fixes f :: "'a::euclidean_space \<Rightarrow> real"
hoelzl@57447
   946
  assumes f_borel: "f \<in> borel_measurable borel" and nonneg: "\<And>x. 0 \<le> f x"
hoelzl@57447
   947
  assumes I: "(f has_integral I) UNIV"
hoelzl@57447
   948
  shows "integral\<^sup>N lborel f = I"
hoelzl@57447
   949
proof -
hoelzl@62975
   950
  from f_borel have "(\<lambda>x. ennreal (f x)) \<in> borel_measurable lborel" by auto
hoelzl@57447
   951
  from borel_measurable_implies_simple_function_sequence'[OF this] guess F . note F = this
hoelzl@57447
   952
  let ?B = "\<lambda>i::nat. box (- (real i *\<^sub>R One)) (real i *\<^sub>R One) :: 'a set"
hoelzl@57447
   953
hoelzl@57447
   954
  note F(1)[THEN borel_measurable_simple_function, measurable]
hoelzl@57447
   955
hoelzl@62975
   956
  have "0 \<le> I"
hoelzl@62975
   957
    using I by (rule has_integral_nonneg) (simp add: nonneg)
hoelzl@62975
   958
hoelzl@62975
   959
  have F_le_f: "enn2real (F i x) \<le> f x" for i x
hoelzl@62975
   960
    using F(3,4)[where x=x] nonneg SUP_upper[of i UNIV "\<lambda>i. F i x"]
hoelzl@62975
   961
    by (cases "F i x" rule: ennreal_cases) auto
hoelzl@57447
   962
  let ?F = "\<lambda>i x. F i x * indicator (?B i) x"
hoelzl@62975
   963
  have "(\<integral>\<^sup>+ x. ennreal (f x) \<partial>lborel) = (SUP i. integral\<^sup>N lborel (\<lambda>x. ?F i x))"
hoelzl@57447
   964
  proof (subst nn_integral_monotone_convergence_SUP[symmetric])
hoelzl@57447
   965
    { fix x
hoelzl@57447
   966
      obtain j where j: "x \<in> ?B j"
hoelzl@57447
   967
        using UN_box_eq_UNIV by auto
hoelzl@56993
   968
hoelzl@62975
   969
      have "ennreal (f x) = (SUP i. F i x)"
hoelzl@57447
   970
        using F(4)[of x] nonneg[of x] by (simp add: max_def)
hoelzl@57447
   971
      also have "\<dots> = (SUP i. ?F i x)"
hoelzl@57447
   972
      proof (rule SUP_eq)
hoelzl@57447
   973
        fix i show "\<exists>j\<in>UNIV. F i x \<le> ?F j x"
hoelzl@57447
   974
          using j F(2)
hoelzl@57447
   975
          by (intro bexI[of _ "max i j"])
hoelzl@57447
   976
             (auto split: split_max split_indicator simp: incseq_def le_fun_def box_def)
hoelzl@57447
   977
      qed (auto intro!: F split: split_indicator)
hoelzl@62975
   978
      finally have "ennreal (f x) =  (SUP i. ?F i x)" . }
hoelzl@62975
   979
    then show "(\<integral>\<^sup>+ x. ennreal (f x) \<partial>lborel) = (\<integral>\<^sup>+ x. (SUP i. ?F i x) \<partial>lborel)"
hoelzl@57447
   980
      by simp
hoelzl@57447
   981
  qed (insert F, auto simp: incseq_def le_fun_def box_def split: split_indicator)
hoelzl@62975
   982
  also have "\<dots> \<le> ennreal I"
hoelzl@57447
   983
  proof (rule SUP_least)
hoelzl@57447
   984
    fix i :: nat
hoelzl@62975
   985
    have finite_F: "(\<integral>\<^sup>+ x. ennreal (enn2real (F i x) * indicator (?B i) x) \<partial>lborel) < \<infinity>"
hoelzl@57447
   986
    proof (rule nn_integral_bound_simple_function)
hoelzl@62975
   987
      have "emeasure lborel {x \<in> space lborel. ennreal (enn2real (F i x) * indicator (?B i) x) \<noteq> 0} \<le>
hoelzl@57447
   988
        emeasure lborel (?B i)"
hoelzl@57447
   989
        by (intro emeasure_mono)  (auto split: split_indicator)
hoelzl@62975
   990
      then show "emeasure lborel {x \<in> space lborel. ennreal (enn2real (F i x) * indicator (?B i) x) \<noteq> 0} < \<infinity>"
hoelzl@62975
   991
        by (auto simp: less_top[symmetric] top_unique)
hoelzl@57447
   992
    qed (auto split: split_indicator
hoelzl@62975
   993
              intro!: F simple_function_compose1[where g="enn2real"] simple_function_ennreal)
hoelzl@57447
   994
hoelzl@62975
   995
    have int_F: "(\<lambda>x. enn2real (F i x) * indicator (?B i) x) integrable_on UNIV"
hoelzl@62975
   996
      using F(4) finite_F
hoelzl@62975
   997
      by (intro nn_integral_integrable_on) (auto split: split_indicator simp: enn2real_nonneg)
lp15@60615
   998
lp15@60615
   999
    have "(\<integral>\<^sup>+ x. F i x * indicator (?B i) x \<partial>lborel) =
hoelzl@62975
  1000
      (\<integral>\<^sup>+ x. ennreal (enn2real (F i x) * indicator (?B i) x) \<partial>lborel)"
hoelzl@62975
  1001
      using F(3,4)
hoelzl@62975
  1002
      by (intro nn_integral_cong) (auto simp: image_iff eq_commute split: split_indicator)
hoelzl@62975
  1003
    also have "\<dots> = ennreal (integral UNIV (\<lambda>x. enn2real (F i x) * indicator (?B i) x))"
hoelzl@57447
  1004
      using F
hoelzl@57447
  1005
      by (intro nn_integral_lborel_eq_integral[OF _ _ finite_F])
hoelzl@62975
  1006
         (auto split: split_indicator intro: enn2real_nonneg)
hoelzl@62975
  1007
    also have "\<dots> \<le> ennreal I"
hoelzl@57447
  1008
      by (auto intro!: has_integral_le[OF integrable_integral[OF int_F] I] nonneg F_le_f
hoelzl@62975
  1009
               simp: \<open>0 \<le> I\<close> split: split_indicator )
hoelzl@62975
  1010
    finally show "(\<integral>\<^sup>+ x. F i x * indicator (?B i) x \<partial>lborel) \<le> ennreal I" .
hoelzl@57447
  1011
  qed
hoelzl@62975
  1012
  finally have "(\<integral>\<^sup>+ x. ennreal (f x) \<partial>lborel) < \<infinity>"
hoelzl@62975
  1013
    by (auto simp: less_top[symmetric] top_unique)
hoelzl@57447
  1014
  from nn_integral_lborel_eq_integral[OF assms(1,2) this] I show ?thesis
hoelzl@57447
  1015
    by (simp add: integral_unique)
hoelzl@57447
  1016
qed
hoelzl@57447
  1017
hoelzl@57447
  1018
lemma has_integral_iff_emeasure_lborel:
hoelzl@57447
  1019
  fixes A :: "'a::euclidean_space set"
hoelzl@62975
  1020
  assumes A[measurable]: "A \<in> sets borel" and [simp]: "0 \<le> r"
hoelzl@62975
  1021
  shows "((\<lambda>x. 1) has_integral r) A \<longleftrightarrow> emeasure lborel A = ennreal r"
hoelzl@57447
  1022
proof cases
hoelzl@57447
  1023
  assume emeasure_A: "emeasure lborel A = \<infinity>"
hoelzl@57447
  1024
  have "\<not> (\<lambda>x. 1::real) integrable_on A"
hoelzl@57447
  1025
  proof
hoelzl@57447
  1026
    assume int: "(\<lambda>x. 1::real) integrable_on A"
hoelzl@57447
  1027
    then have "(indicator A::'a \<Rightarrow> real) integrable_on UNIV"
hoelzl@57447
  1028
      unfolding indicator_def[abs_def] integrable_restrict_univ .
hoelzl@57447
  1029
    then obtain r where "((indicator A::'a\<Rightarrow>real) has_integral r) UNIV"
hoelzl@57447
  1030
      by auto
hoelzl@57447
  1031
    from nn_integral_has_integral_lborel[OF _ _ this] emeasure_A show False
hoelzl@62975
  1032
      by (simp add: ennreal_indicator)
hoelzl@57447
  1033
  qed
hoelzl@57447
  1034
  with emeasure_A show ?thesis
hoelzl@57447
  1035
    by auto
hoelzl@57447
  1036
next
hoelzl@57447
  1037
  assume "emeasure lborel A \<noteq> \<infinity>"
hoelzl@57447
  1038
  moreover then have "((\<lambda>x. 1) has_integral measure lborel A) A"
hoelzl@62975
  1039
    by (simp add: has_integral_measure_lborel less_top)
hoelzl@57447
  1040
  ultimately show ?thesis
hoelzl@62975
  1041
    by (auto simp: emeasure_eq_ennreal_measure has_integral_unique)
hoelzl@57447
  1042
qed
hoelzl@57447
  1043
hoelzl@57447
  1044
lemma has_integral_integral_real:
hoelzl@57447
  1045
  fixes f::"'a::euclidean_space \<Rightarrow> real"
hoelzl@57447
  1046
  assumes f: "integrable lborel f"
hoelzl@57447
  1047
  shows "(f has_integral (integral\<^sup>L lborel f)) UNIV"
hoelzl@56993
  1048
using f proof induct
hoelzl@56993
  1049
  case (base A c) then show ?case
hoelzl@57447
  1050
    by (auto intro!: has_integral_mult_left simp: )
hoelzl@62975
  1051
       (simp add: emeasure_eq_ennreal_measure indicator_def has_integral_measure_lborel)
hoelzl@56993
  1052
next
hoelzl@56993
  1053
  case (add f g) then show ?case
hoelzl@56993
  1054
    by (auto intro!: has_integral_add)
hoelzl@56993
  1055
next
hoelzl@56993
  1056
  case (lim f s)
hoelzl@56993
  1057
  show ?case
hoelzl@56993
  1058
  proof (rule has_integral_dominated_convergence)
hoelzl@57447
  1059
    show "\<And>i. (s i has_integral integral\<^sup>L lborel (s i)) UNIV" by fact
hoelzl@56993
  1060
    show "(\<lambda>x. norm (2 * f x)) integrable_on UNIV"
wenzelm@61808
  1061
      using \<open>integrable lborel f\<close>
hoelzl@57447
  1062
      by (intro nn_integral_integrable_on)
hoelzl@62975
  1063
         (auto simp: integrable_iff_bounded abs_mult  nn_integral_cmult ennreal_mult ennreal_mult_less_top)
hoelzl@56993
  1064
    show "\<And>k. \<forall>x\<in>UNIV. norm (s k x) \<le> norm (2 * f x)"
hoelzl@56993
  1065
      using lim by (auto simp add: abs_mult)
wenzelm@61969
  1066
    show "\<forall>x\<in>UNIV. (\<lambda>k. s k x) \<longlonglongrightarrow> f x"
hoelzl@56993
  1067
      using lim by auto
wenzelm@61969
  1068
    show "(\<lambda>k. integral\<^sup>L lborel (s k)) \<longlonglongrightarrow> integral\<^sup>L lborel f"
hoelzl@57447
  1069
      using lim lim(1)[THEN borel_measurable_integrable]
hoelzl@57447
  1070
      by (intro integral_dominated_convergence[where w="\<lambda>x. 2 * norm (f x)"]) auto
hoelzl@56993
  1071
  qed
hoelzl@40859
  1072
qed
hoelzl@40859
  1073
hoelzl@57447
  1074
context
hoelzl@57447
  1075
  fixes f::"'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
hoelzl@57447
  1076
begin
hoelzl@41546
  1077
hoelzl@57447
  1078
lemma has_integral_integral_lborel:
hoelzl@57447
  1079
  assumes f: "integrable lborel f"
wenzelm@53015
  1080
  shows "(f has_integral (integral\<^sup>L lborel f)) UNIV"
hoelzl@41546
  1081
proof -
hoelzl@57447
  1082
  have "((\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) has_integral (\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b)) UNIV"
hoelzl@57447
  1083
    using f by (intro has_integral_setsum finite_Basis ballI has_integral_scaleR_left has_integral_integral_real) auto
hoelzl@57447
  1084
  also have eq_f: "(\<lambda>x. \<Sum>b\<in>Basis. (f x \<bullet> b) *\<^sub>R b) = f"
hoelzl@57447
  1085
    by (simp add: fun_eq_iff euclidean_representation)
hoelzl@57447
  1086
  also have "(\<Sum>b\<in>Basis. integral\<^sup>L lborel (\<lambda>x. f x \<bullet> b) *\<^sub>R b) = integral\<^sup>L lborel f"
hoelzl@57447
  1087
    using f by (subst (2) eq_f[symmetric]) simp
hoelzl@56993
  1088
  finally show ?thesis .
hoelzl@56993
  1089
qed
hoelzl@56993
  1090
hoelzl@57447
  1091
lemma integrable_on_lborel: "integrable lborel f \<Longrightarrow> f integrable_on UNIV"
hoelzl@62975
  1092
  using has_integral_integral_lborel by auto
lp15@60615
  1093
hoelzl@57447
  1094
lemma integral_lborel: "integrable lborel f \<Longrightarrow> integral UNIV f = (\<integral>x. f x \<partial>lborel)"
hoelzl@57447
  1095
  using has_integral_integral_lborel by auto
hoelzl@49777
  1096
hoelzl@57447
  1097
end
hoelzl@50418
  1098
wenzelm@61808
  1099
subsection \<open>Fundamental Theorem of Calculus for the Lebesgue integral\<close>
hoelzl@50418
  1100
hoelzl@57138
  1101
lemma emeasure_bounded_finite:
hoelzl@57138
  1102
  assumes "bounded A" shows "emeasure lborel A < \<infinity>"
hoelzl@57138
  1103
proof -
wenzelm@61808
  1104
  from bounded_subset_cbox[OF \<open>bounded A\<close>] obtain a b where "A \<subseteq> cbox a b"
hoelzl@57138
  1105
    by auto
hoelzl@57138
  1106
  then have "emeasure lborel A \<le> emeasure lborel (cbox a b)"
hoelzl@57138
  1107
    by (intro emeasure_mono) auto
hoelzl@57138
  1108
  then show ?thesis
hoelzl@62975
  1109
    by (auto simp: emeasure_lborel_cbox_eq setprod_nonneg less_top[symmetric] top_unique split: if_split_asm)
hoelzl@57138
  1110
qed
hoelzl@57138
  1111
hoelzl@57138
  1112
lemma emeasure_compact_finite: "compact A \<Longrightarrow> emeasure lborel A < \<infinity>"
hoelzl@57138
  1113
  using emeasure_bounded_finite[of A] by (auto intro: compact_imp_bounded)
hoelzl@57138
  1114
hoelzl@57138
  1115
lemma borel_integrable_compact:
hoelzl@57447
  1116
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::{banach, second_countable_topology}"
hoelzl@57138
  1117
  assumes "compact S" "continuous_on S f"
hoelzl@57138
  1118
  shows "integrable lborel (\<lambda>x. indicator S x *\<^sub>R f x)"
hoelzl@57138
  1119
proof cases
hoelzl@57138
  1120
  assume "S \<noteq> {}"
hoelzl@57138
  1121
  have "continuous_on S (\<lambda>x. norm (f x))"
hoelzl@57138
  1122
    using assms by (intro continuous_intros)
wenzelm@61808
  1123
  from continuous_attains_sup[OF \<open>compact S\<close> \<open>S \<noteq> {}\<close> this]
hoelzl@57138
  1124
  obtain M where M: "\<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> M"
hoelzl@57138
  1125
    by auto
hoelzl@57138
  1126
hoelzl@57138
  1127
  show ?thesis
hoelzl@57138
  1128
  proof (rule integrable_bound)
hoelzl@57138
  1129
    show "integrable lborel (\<lambda>x. indicator S x * M)"
hoelzl@57138
  1130
      using assms by (auto intro!: emeasure_compact_finite borel_compact integrable_mult_left)
hoelzl@57138
  1131
    show "(\<lambda>x. indicator S x *\<^sub>R f x) \<in> borel_measurable lborel"
hoelzl@57138
  1132
      using assms by (auto intro!: borel_measurable_continuous_on_indicator borel_compact)
hoelzl@57138
  1133
    show "AE x in lborel. norm (indicator S x *\<^sub>R f x) \<le> norm (indicator S x * M)"
hoelzl@57138
  1134
      by (auto split: split_indicator simp: abs_real_def dest!: M)
hoelzl@57138
  1135
  qed
hoelzl@57138
  1136
qed simp
hoelzl@57138
  1137
hoelzl@50418
  1138
lemma borel_integrable_atLeastAtMost:
hoelzl@56993
  1139
  fixes f :: "real \<Rightarrow> real"
hoelzl@50418
  1140
  assumes f: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> isCont f x"
hoelzl@50418
  1141
  shows "integrable lborel (\<lambda>x. f x * indicator {a .. b} x)" (is "integrable _ ?f")
hoelzl@57138
  1142
proof -
hoelzl@57138
  1143
  have "integrable lborel (\<lambda>x. indicator {a .. b} x *\<^sub>R f x)"
hoelzl@57138
  1144
  proof (rule borel_integrable_compact)
hoelzl@57138
  1145
    from f show "continuous_on {a..b} f"
hoelzl@57138
  1146
      by (auto intro: continuous_at_imp_continuous_on)
hoelzl@57138
  1147
  qed simp
hoelzl@57138
  1148
  then show ?thesis
haftmann@57512
  1149
    by (auto simp: mult.commute)
hoelzl@57138
  1150
qed
hoelzl@50418
  1151
wenzelm@61808
  1152
text \<open>
hoelzl@50418
  1153
lp15@60615
  1154
For the positive integral we replace continuity with Borel-measurability.
hoelzl@50418
  1155
wenzelm@61808
  1156
\<close>
hoelzl@50418
  1157
hoelzl@56993
  1158
lemma
hoelzl@56993
  1159
  fixes f :: "real \<Rightarrow> real"
hoelzl@57447
  1160
  assumes [measurable]: "f \<in> borel_measurable borel"
hoelzl@50418
  1161
  assumes f: "\<And>x. x \<in> {a..b} \<Longrightarrow> DERIV F x :> f x" "\<And>x. x \<in> {a..b} \<Longrightarrow> 0 \<le> f x" and "a \<le> b"
hoelzl@62975
  1162
  shows nn_integral_FTC_Icc: "(\<integral>\<^sup>+x. ennreal (f x) * indicator {a .. b} x \<partial>lborel) = F b - F a" (is ?nn)
hoelzl@57447
  1163
    and has_bochner_integral_FTC_Icc_nonneg:
hoelzl@57447
  1164
      "has_bochner_integral lborel (\<lambda>x. f x * indicator {a .. b} x) (F b - F a)" (is ?has)
hoelzl@57447
  1165
    and integral_FTC_Icc_nonneg: "(\<integral>x. f x * indicator {a .. b} x \<partial>lborel) = F b - F a" (is ?eq)
hoelzl@56993
  1166
    and integrable_FTC_Icc_nonneg: "integrable lborel (\<lambda>x. f x * indicator {a .. b} x)" (is ?int)
hoelzl@50418
  1167
proof -
hoelzl@57447
  1168
  have *: "(\<lambda>x. f x * indicator {a..b} x) \<in> borel_measurable borel" "\<And>x. 0 \<le> f x * indicator {a..b} x"
hoelzl@57447
  1169
    using f(2) by (auto split: split_indicator)
lp15@60615
  1170
hoelzl@62975
  1171
  have F_mono: "a \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> b\<Longrightarrow> F x \<le> F y" for x y
hoelzl@62975
  1172
    using f by (intro DERIV_nonneg_imp_nondecreasing[of x y F]) (auto intro: order_trans)
hoelzl@62975
  1173
hoelzl@57447
  1174
  have "(f has_integral F b - F a) {a..b}"
hoelzl@56181
  1175
    by (intro fundamental_theorem_of_calculus)
hoelzl@56181
  1176
       (auto simp: has_field_derivative_iff_has_vector_derivative[symmetric]
wenzelm@61808
  1177
             intro: has_field_derivative_subset[OF f(1)] \<open>a \<le> b\<close>)
hoelzl@57447
  1178
  then have i: "((\<lambda>x. f x * indicator {a .. b} x) has_integral F b - F a) UNIV"
hoelzl@57447
  1179
    unfolding indicator_def if_distrib[where f="\<lambda>x. a * x" for a]
hoelzl@57447
  1180
    by (simp cong del: if_cong del: atLeastAtMost_iff)
hoelzl@57447
  1181
  then have nn: "(\<integral>\<^sup>+x. f x * indicator {a .. b} x \<partial>lborel) = F b - F a"
hoelzl@57447
  1182
    by (rule nn_integral_has_integral_lborel[OF *])
hoelzl@57447
  1183
  then show ?has
hoelzl@62975
  1184
    by (rule has_bochner_integral_nn_integral[rotated 3]) (simp_all add: * F_mono \<open>a \<le> b\<close>)
hoelzl@57447
  1185
  then show ?eq ?int
hoelzl@57447
  1186
    unfolding has_bochner_integral_iff by auto
hoelzl@62975
  1187
  show ?nn
hoelzl@62975
  1188
    by (subst nn[symmetric])
hoelzl@62975
  1189
       (auto intro!: nn_integral_cong simp add: ennreal_mult f split: split_indicator)
hoelzl@56993
  1190
qed
hoelzl@56993
  1191
hoelzl@57447
  1192
lemma
hoelzl@57447
  1193
  fixes f :: "real \<Rightarrow> 'a :: euclidean_space"
hoelzl@57447
  1194
  assumes "a \<le> b"
hoelzl@57447
  1195
  assumes "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> (F has_vector_derivative f x) (at x within {a .. b})"
hoelzl@57447
  1196
  assumes cont: "continuous_on {a .. b} f"
hoelzl@57447
  1197
  shows has_bochner_integral_FTC_Icc:
hoelzl@57447
  1198
      "has_bochner_integral lborel (\<lambda>x. indicator {a .. b} x *\<^sub>R f x) (F b - F a)" (is ?has)
hoelzl@57447
  1199
    and integral_FTC_Icc: "(\<integral>x. indicator {a .. b} x *\<^sub>R f x \<partial>lborel) = F b - F a" (is ?eq)
hoelzl@56993
  1200
proof -
hoelzl@57447
  1201
  let ?f = "\<lambda>x. indicator {a .. b} x *\<^sub>R f x"
hoelzl@57447
  1202
  have int: "integrable lborel ?f"
hoelzl@57447
  1203
    using borel_integrable_compact[OF _ cont] by auto
hoelzl@57447
  1204
  have "(f has_integral F b - F a) {a..b}"
hoelzl@57447
  1205
    using assms(1,2) by (intro fundamental_theorem_of_calculus) auto
lp15@60615
  1206
  moreover
hoelzl@57447
  1207
  have "(f has_integral integral\<^sup>L lborel ?f) {a..b}"
hoelzl@57447
  1208
    using has_integral_integral_lborel[OF int]
hoelzl@57447
  1209
    unfolding indicator_def if_distrib[where f="\<lambda>x. x *\<^sub>R a" for a]
hoelzl@57447
  1210
    by (simp cong del: if_cong del: atLeastAtMost_iff)
hoelzl@57447
  1211
  ultimately show ?eq
hoelzl@57447
  1212
    by (auto dest: has_integral_unique)
hoelzl@57447
  1213
  then show ?has
hoelzl@57447
  1214
    using int by (auto simp: has_bochner_integral_iff)
hoelzl@57447
  1215
qed
hoelzl@57447
  1216
hoelzl@57447
  1217
lemma
hoelzl@57447
  1218
  fixes f :: "real \<Rightarrow> real"
hoelzl@57447
  1219
  assumes "a \<le> b"
hoelzl@57447
  1220
  assumes deriv: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> DERIV F x :> f x"
hoelzl@57447
  1221
  assumes cont: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> isCont f x"
hoelzl@57447
  1222
  shows has_bochner_integral_FTC_Icc_real:
hoelzl@57447
  1223
      "has_bochner_integral lborel (\<lambda>x. f x * indicator {a .. b} x) (F b - F a)" (is ?has)
hoelzl@57447
  1224
    and integral_FTC_Icc_real: "(\<integral>x. f x * indicator {a .. b} x \<partial>lborel) = F b - F a" (is ?eq)
hoelzl@57447
  1225
proof -
hoelzl@57447
  1226
  have 1: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> (F has_vector_derivative f x) (at x within {a .. b})"
hoelzl@57447
  1227
    unfolding has_field_derivative_iff_has_vector_derivative[symmetric]
hoelzl@57447
  1228
    using deriv by (auto intro: DERIV_subset)
hoelzl@57447
  1229
  have 2: "continuous_on {a .. b} f"
hoelzl@57447
  1230
    using cont by (intro continuous_at_imp_continuous_on) auto
hoelzl@57447
  1231
  show ?has ?eq
wenzelm@61808
  1232
    using has_bochner_integral_FTC_Icc[OF \<open>a \<le> b\<close> 1 2] integral_FTC_Icc[OF \<open>a \<le> b\<close> 1 2]
haftmann@57512
  1233
    by (auto simp: mult.commute)
hoelzl@50418
  1234
qed
hoelzl@50418
  1235
hoelzl@56996
  1236
lemma nn_integral_FTC_atLeast:
hoelzl@50418
  1237
  fixes f :: "real \<Rightarrow> real"
hoelzl@50418
  1238
  assumes f_borel: "f \<in> borel_measurable borel"
lp15@60615
  1239
  assumes f: "\<And>x. a \<le> x \<Longrightarrow> DERIV F x :> f x"
hoelzl@50418
  1240
  assumes nonneg: "\<And>x. a \<le> x \<Longrightarrow> 0 \<le> f x"
wenzelm@61973
  1241
  assumes lim: "(F \<longlongrightarrow> T) at_top"
hoelzl@62975
  1242
  shows "(\<integral>\<^sup>+x. ennreal (f x) * indicator {a ..} x \<partial>lborel) = T - F a"
hoelzl@50418
  1243
proof -
hoelzl@62975
  1244
  let ?f = "\<lambda>(i::nat) (x::real). ennreal (f x) * indicator {a..a + real i} x"
hoelzl@62975
  1245
  let ?fR = "\<lambda>x. ennreal (f x) * indicator {a ..} x"
hoelzl@50418
  1246
hoelzl@62975
  1247
  have F_mono: "a \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> F x \<le> F y" for x y
hoelzl@62975
  1248
    using f nonneg by (intro DERIV_nonneg_imp_nondecreasing[of x y F]) (auto intro: order_trans)
hoelzl@62975
  1249
  then have F_le_T: "a \<le> x \<Longrightarrow> F x \<le> T" for x
hoelzl@62975
  1250
    by (intro tendsto_le_const[OF _ lim])
hoelzl@62975
  1251
       (auto simp: trivial_limit_at_top_linorder eventually_at_top_linorder)
hoelzl@62975
  1252
hoelzl@62975
  1253
  have "(SUP i::nat. ?f i x) = ?fR x" for x
hoelzl@62975
  1254
  proof (rule LIMSEQ_unique[OF LIMSEQ_SUP])
hoelzl@50418
  1255
    from reals_Archimedean2[of "x - a"] guess n ..
hoelzl@50418
  1256
    then have "eventually (\<lambda>n. ?f n x = ?fR x) sequentially"
hoelzl@50418
  1257
      by (auto intro!: eventually_sequentiallyI[where c=n] split: split_indicator)
wenzelm@61969
  1258
    then show "(\<lambda>n. ?f n x) \<longlonglongrightarrow> ?fR x"
hoelzl@50418
  1259
      by (rule Lim_eventually)
hoelzl@62975
  1260
  qed (auto simp: nonneg incseq_def le_fun_def split: split_indicator)
hoelzl@56996
  1261
  then have "integral\<^sup>N lborel ?fR = (\<integral>\<^sup>+ x. (SUP i::nat. ?f i x) \<partial>lborel)"
hoelzl@50418
  1262
    by simp
wenzelm@53015
  1263
  also have "\<dots> = (SUP i::nat. (\<integral>\<^sup>+ x. ?f i x \<partial>lborel))"
hoelzl@56996
  1264
  proof (rule nn_integral_monotone_convergence_SUP)
hoelzl@50418
  1265
    show "incseq ?f"
hoelzl@50418
  1266
      using nonneg by (auto simp: incseq_def le_fun_def split: split_indicator)
hoelzl@50418
  1267
    show "\<And>i. (?f i) \<in> borel_measurable lborel"
hoelzl@50418
  1268
      using f_borel by auto
hoelzl@50418
  1269
  qed
hoelzl@62975
  1270
  also have "\<dots> = (SUP i::nat. ennreal (F (a + real i) - F a))"
hoelzl@57447
  1271
    by (subst nn_integral_FTC_Icc[OF f_borel f nonneg]) auto
hoelzl@50418
  1272
  also have "\<dots> = T - F a"
hoelzl@62975
  1273
  proof (rule LIMSEQ_unique[OF LIMSEQ_SUP])
wenzelm@61969
  1274
    have "(\<lambda>x. F (a + real x)) \<longlonglongrightarrow> T"
hoelzl@50418
  1275
      apply (rule filterlim_compose[OF lim filterlim_tendsto_add_at_top])
hoelzl@50418
  1276
      apply (rule LIMSEQ_const_iff[THEN iffD2, OF refl])
hoelzl@50418
  1277
      apply (rule filterlim_real_sequentially)
hoelzl@50418
  1278
      done
hoelzl@62975
  1279
    then show "(\<lambda>n. ennreal (F (a + real n) - F a)) \<longlonglongrightarrow> ennreal (T - F a)"
hoelzl@62975
  1280
      by (simp add: F_mono F_le_T tendsto_diff)
hoelzl@62975
  1281
  qed (auto simp: incseq_def intro!: ennreal_le_iff[THEN iffD2] F_mono)
hoelzl@50418
  1282
  finally show ?thesis .
hoelzl@50418
  1283
qed
hoelzl@50418
  1284
hoelzl@57447
  1285
lemma integral_power:
hoelzl@57447
  1286
  "a \<le> b \<Longrightarrow> (\<integral>x. x^k * indicator {a..b} x \<partial>lborel) = (b^Suc k - a^Suc k) / Suc k"
hoelzl@57447
  1287
proof (subst integral_FTC_Icc_real)
hoelzl@57447
  1288
  fix x show "DERIV (\<lambda>x. x^Suc k / Suc k) x :> x^k"
hoelzl@57447
  1289
    by (intro derivative_eq_intros) auto
lp15@61609
  1290
qed (auto simp: field_simps simp del: of_nat_Suc)
hoelzl@57447
  1291
wenzelm@61808
  1292
subsection \<open>Integration by parts\<close>
hoelzl@57235
  1293
hoelzl@57235
  1294
lemma integral_by_parts_integrable:
hoelzl@57235
  1295
  fixes f g F G::"real \<Rightarrow> real"
hoelzl@57235
  1296
  assumes "a \<le> b"
hoelzl@57235
  1297
  assumes cont_f[intro]: "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont f x"
hoelzl@57235
  1298
  assumes cont_g[intro]: "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont g x"
hoelzl@57235
  1299
  assumes [intro]: "!!x. DERIV F x :> f x"
hoelzl@57235
  1300
  assumes [intro]: "!!x. DERIV G x :> g x"
hoelzl@57235
  1301
  shows  "integrable lborel (\<lambda>x.((F x) * (g x) + (f x) * (G x)) * indicator {a .. b} x)"
hoelzl@57235
  1302
  by (auto intro!: borel_integrable_atLeastAtMost continuous_intros) (auto intro!: DERIV_isCont)
hoelzl@57235
  1303
hoelzl@57235
  1304
lemma integral_by_parts:
hoelzl@57235
  1305
  fixes f g F G::"real \<Rightarrow> real"
hoelzl@57235
  1306
  assumes [arith]: "a \<le> b"
hoelzl@57235
  1307
  assumes cont_f[intro]: "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont f x"
hoelzl@57235
  1308
  assumes cont_g[intro]: "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont g x"
hoelzl@57235
  1309
  assumes [intro]: "!!x. DERIV F x :> f x"
hoelzl@57235
  1310
  assumes [intro]: "!!x. DERIV G x :> g x"
hoelzl@57235
  1311
  shows "(\<integral>x. (F x * g x) * indicator {a .. b} x \<partial>lborel)
lp15@60615
  1312
            =  F b * G b - F a * G a - \<integral>x. (f x * G x) * indicator {a .. b} x \<partial>lborel"
hoelzl@57235
  1313
proof-
hoelzl@57235
  1314
  have 0: "(\<integral>x. (F x * g x + f x * G x) * indicator {a .. b} x \<partial>lborel) = F b * G b - F a * G a"
lp15@60615
  1315
    by (rule integral_FTC_Icc_real, auto intro!: derivative_eq_intros continuous_intros)
hoelzl@57235
  1316
      (auto intro!: DERIV_isCont)
hoelzl@57235
  1317
hoelzl@57235
  1318
  have "(\<integral>x. (F x * g x + f x * G x) * indicator {a .. b} x \<partial>lborel) =
hoelzl@57235
  1319
    (\<integral>x. (F x * g x) * indicator {a .. b} x \<partial>lborel) + \<integral>x. (f x * G x) * indicator {a .. b} x \<partial>lborel"
hoelzl@57235
  1320
    apply (subst integral_add[symmetric])
hoelzl@57235
  1321
    apply (auto intro!: borel_integrable_atLeastAtMost continuous_intros)
hoelzl@57235
  1322
    by (auto intro!: DERIV_isCont integral_cong split:split_indicator)
hoelzl@57235
  1323
hoelzl@57235
  1324
  thus ?thesis using 0 by auto
hoelzl@57235
  1325
qed
hoelzl@57235
  1326
hoelzl@57235
  1327
lemma integral_by_parts':
hoelzl@57235
  1328
  fixes f g F G::"real \<Rightarrow> real"
hoelzl@57235
  1329
  assumes "a \<le> b"
hoelzl@57235
  1330
  assumes "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont f x"
hoelzl@57235
  1331
  assumes "!!x. a \<le>x \<Longrightarrow> x\<le>b \<Longrightarrow> isCont g x"
hoelzl@57235
  1332
  assumes "!!x. DERIV F x :> f x"
hoelzl@57235
  1333
  assumes "!!x. DERIV G x :> g x"
hoelzl@57235
  1334
  shows "(\<integral>x. indicator {a .. b} x *\<^sub>R (F x * g x) \<partial>lborel)
lp15@60615
  1335
            =  F b * G b - F a * G a - \<integral>x. indicator {a .. b} x *\<^sub>R (f x * G x) \<partial>lborel"
haftmann@57514
  1336
  using integral_by_parts[OF assms] by (simp add: ac_simps)
hoelzl@57235
  1337
hoelzl@57275
  1338
lemma has_bochner_integral_even_function:
hoelzl@57275
  1339
  fixes f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@57275
  1340
  assumes f: "has_bochner_integral lborel (\<lambda>x. indicator {0..} x *\<^sub>R f x) x"
hoelzl@57275
  1341
  assumes even: "\<And>x. f (- x) = f x"
hoelzl@57275
  1342
  shows "has_bochner_integral lborel f (2 *\<^sub>R x)"
hoelzl@57275
  1343
proof -
hoelzl@57275
  1344
  have indicator: "\<And>x::real. indicator {..0} (- x) = indicator {0..} x"
hoelzl@57275
  1345
    by (auto split: split_indicator)
hoelzl@57275
  1346
  have "has_bochner_integral lborel (\<lambda>x. indicator {.. 0} x *\<^sub>R f x) x"
hoelzl@57275
  1347
    by (subst lborel_has_bochner_integral_real_affine_iff[where c="-1" and t=0])
hoelzl@57275
  1348
       (auto simp: indicator even f)
hoelzl@57275
  1349
  with f have "has_bochner_integral lborel (\<lambda>x. indicator {0..} x *\<^sub>R f x + indicator {.. 0} x *\<^sub>R f x) (x + x)"
hoelzl@57275
  1350
    by (rule has_bochner_integral_add)
hoelzl@57275
  1351
  then have "has_bochner_integral lborel f (x + x)"
hoelzl@57275
  1352
    by (rule has_bochner_integral_discrete_difference[where X="{0}", THEN iffD1, rotated 4])
hoelzl@57275
  1353
       (auto split: split_indicator)
hoelzl@57275
  1354
  then show ?thesis
hoelzl@57275
  1355
    by (simp add: scaleR_2)
hoelzl@57275
  1356
qed
hoelzl@57275
  1357
hoelzl@57275
  1358
lemma has_bochner_integral_odd_function:
hoelzl@57275
  1359
  fixes f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}"
hoelzl@57275
  1360
  assumes f: "has_bochner_integral lborel (\<lambda>x. indicator {0..} x *\<^sub>R f x) x"
hoelzl@57275
  1361
  assumes odd: "\<And>x. f (- x) = - f x"
hoelzl@57275
  1362
  shows "has_bochner_integral lborel f 0"
hoelzl@57275
  1363
proof -
hoelzl@57275
  1364
  have indicator: "\<And>x::real. indicator {..0} (- x) = indicator {0..} x"
hoelzl@57275
  1365
    by (auto split: split_indicator)
hoelzl@57275
  1366
  have "has_bochner_integral lborel (\<lambda>x. - indicator {.. 0} x *\<^sub>R f x) x"
hoelzl@57275
  1367
    by (subst lborel_has_bochner_integral_real_affine_iff[where c="-1" and t=0])
hoelzl@57275
  1368
       (auto simp: indicator odd f)
hoelzl@57275
  1369
  from has_bochner_integral_minus[OF this]
hoelzl@57275
  1370
  have "has_bochner_integral lborel (\<lambda>x. indicator {.. 0} x *\<^sub>R f x) (- x)"
lp15@60615
  1371
    by simp
hoelzl@57275
  1372
  with f have "has_bochner_integral lborel (\<lambda>x. indicator {0..} x *\<^sub>R f x + indicator {.. 0} x *\<^sub>R f x) (x + - x)"
hoelzl@57275
  1373
    by (rule has_bochner_integral_add)
hoelzl@57275
  1374
  then have "has_bochner_integral lborel f (x + - x)"
hoelzl@57275
  1375
    by (rule has_bochner_integral_discrete_difference[where X="{0}", THEN iffD1, rotated 4])
hoelzl@57275
  1376
       (auto split: split_indicator)
hoelzl@57275
  1377
  then show ?thesis
hoelzl@57275
  1378
    by simp
hoelzl@57275
  1379
qed
hoelzl@57235
  1380
hoelzl@38656
  1381
end
hoelzl@57447
  1382