src/HOL/Analysis/Interval_Integral.thy
changeset 67974 3f352a91b45a
parent 66164 2d79288b042c
child 68046 6aba668aea78
equal deleted inserted replaced
67971:e9f66b35d636 67974:3f352a91b45a
    49      (auto simp: einterval_def intro!: open_Collect_conj open_Collect_less continuous_intros)
    49      (auto simp: einterval_def intro!: open_Collect_conj open_Collect_less continuous_intros)
    50 
    50 
    51 lemma borel_einterval[measurable]: "einterval a b \<in> sets borel"
    51 lemma borel_einterval[measurable]: "einterval a b \<in> sets borel"
    52   unfolding einterval_def by measurable
    52   unfolding einterval_def by measurable
    53 
    53 
    54 (*
    54 subsection\<open>Approximating a (possibly infinite) interval\<close>
    55     Approximating a (possibly infinite) interval
       
    56 *)
       
    57 
    55 
    58 lemma filterlim_sup1: "(LIM x F. f x :> G1) \<Longrightarrow> (LIM x F. f x :> (sup G1 G2))"
    56 lemma filterlim_sup1: "(LIM x F. f x :> G1) \<Longrightarrow> (LIM x F. f x :> (sup G1 G2))"
    59  unfolding filterlim_def by (auto intro: le_supI1)
    57  unfolding filterlim_def by (auto intro: le_supI1)
    60 
    58 
    61 lemma ereal_incseq_approx:
    59 lemma ereal_incseq_approx:
   173   ("(4LBINT _=_.._. _)" [0,60,60,61] 60)
   171   ("(4LBINT _=_.._. _)" [0,60,60,61] 60)
   174 
   172 
   175 translations
   173 translations
   176   "LBINT x=a..b. f" == "CONST interval_lebesgue_integral CONST lborel a b (\<lambda>x. f)"
   174   "LBINT x=a..b. f" == "CONST interval_lebesgue_integral CONST lborel a b (\<lambda>x. f)"
   177 
   175 
   178 (*
   176 subsection\<open>Basic properties of integration over an interval\<close>
   179     Basic properties of integration over an interval.
       
   180 *)
       
   181 
   177 
   182 lemma interval_lebesgue_integral_cong:
   178 lemma interval_lebesgue_integral_cong:
   183   "a \<le> b \<Longrightarrow> (\<And>x. x \<in> einterval a b \<Longrightarrow> f x = g x) \<Longrightarrow> einterval a b \<in> sets M \<Longrightarrow>
   179   "a \<le> b \<Longrightarrow> (\<And>x. x \<in> einterval a b \<Longrightarrow> f x = g x) \<Longrightarrow> einterval a b \<in> sets M \<Longrightarrow>
   184     interval_lebesgue_integral M a b f = interval_lebesgue_integral M a b g"
   180     interval_lebesgue_integral M a b f = interval_lebesgue_integral M a b g"
   185   by (auto intro: set_lebesgue_integral_cong simp: interval_lebesgue_integral_def)
   181   by (auto intro: set_lebesgue_integral_cong simp: interval_lebesgue_integral_def)
   198     for a b :: ereal and x :: real
   194     for a b :: ereal and x :: real
   199     by (cases a b rule: ereal2_cases) (auto simp: einterval_def split: split_indicator)
   195     by (cases a b rule: ereal2_cases) (auto simp: einterval_def split: split_indicator)
   200   show ?thesis
   196   show ?thesis
   201     unfolding interval_lebesgue_integrable_def
   197     unfolding interval_lebesgue_integrable_def
   202     using lborel_integrable_real_affine_iff[symmetric, of "-1" "\<lambda>x. indicator (einterval _ _) x *\<^sub>R f x" 0]
   198     using lborel_integrable_real_affine_iff[symmetric, of "-1" "\<lambda>x. indicator (einterval _ _) x *\<^sub>R f x" 0]
   203     by (simp add: *)
   199     by (simp add: * set_integrable_def)
   204 qed
   200 qed
   205 
   201 
   206 lemma interval_lebesgue_integral_add [intro, simp]:
   202 lemma interval_lebesgue_integral_add [intro, simp]:
   207   fixes M a b f
   203   fixes M a b f
   208   assumes "interval_lebesgue_integrable M a b f" "interval_lebesgue_integrable M a b g"
   204   assumes "interval_lebesgue_integrable M a b f" "interval_lebesgue_integrable M a b g"
   258     interval_lebesgue_integral M a b f / c"
   254     interval_lebesgue_integral M a b f / c"
   259   by (simp add: interval_lebesgue_integral_def)
   255   by (simp add: interval_lebesgue_integral_def)
   260 
   256 
   261 lemma interval_lebesgue_integral_uminus:
   257 lemma interval_lebesgue_integral_uminus:
   262   "interval_lebesgue_integral M a b (\<lambda>x. - f x) = - interval_lebesgue_integral M a b f"
   258   "interval_lebesgue_integral M a b (\<lambda>x. - f x) = - interval_lebesgue_integral M a b f"
   263   by (auto simp add: interval_lebesgue_integral_def interval_lebesgue_integrable_def)
   259   by (auto simp add: interval_lebesgue_integral_def interval_lebesgue_integrable_def set_lebesgue_integral_def)
   264 
   260 
   265 lemma interval_lebesgue_integral_of_real:
   261 lemma interval_lebesgue_integral_of_real:
   266   "interval_lebesgue_integral M a b (\<lambda>x. complex_of_real (f x)) =
   262   "interval_lebesgue_integral M a b (\<lambda>x. complex_of_real (f x)) =
   267     of_real (interval_lebesgue_integral M a b f)"
   263     of_real (interval_lebesgue_integral M a b f)"
   268   unfolding interval_lebesgue_integral_def
   264   unfolding interval_lebesgue_integral_def
   285   assumes "a > b"
   281   assumes "a > b"
   286   shows "interval_lebesgue_integral M a b f = - interval_lebesgue_integral M b a f"
   282   shows "interval_lebesgue_integral M a b f = - interval_lebesgue_integral M b a f"
   287 using assms by (auto simp add: interval_lebesgue_integral_def less_imp_le einterval_def)
   283 using assms by (auto simp add: interval_lebesgue_integral_def less_imp_le einterval_def)
   288 
   284 
   289 lemma interval_integral_endpoints_same [simp]: "(LBINT x=a..a. f x) = 0"
   285 lemma interval_integral_endpoints_same [simp]: "(LBINT x=a..a. f x) = 0"
   290   by (simp add: interval_lebesgue_integral_def einterval_same)
   286   by (simp add: interval_lebesgue_integral_def set_lebesgue_integral_def einterval_same)
   291 
   287 
   292 lemma interval_integral_endpoints_reverse: "(LBINT x=a..b. f x) = -(LBINT x=b..a. f x)"
   288 lemma interval_integral_endpoints_reverse: "(LBINT x=a..b. f x) = -(LBINT x=b..a. f x)"
   293   by (cases a b rule: linorder_cases) (auto simp: interval_lebesgue_integral_def einterval_same)
   289   by (cases a b rule: linorder_cases) (auto simp: interval_lebesgue_integral_def set_lebesgue_integral_def einterval_same)
   294 
   290 
   295 lemma interval_integrable_endpoints_reverse:
   291 lemma interval_integrable_endpoints_reverse:
   296   "interval_lebesgue_integrable lborel a b f \<longleftrightarrow>
   292   "interval_lebesgue_integrable lborel a b f \<longleftrightarrow>
   297     interval_lebesgue_integrable lborel b a f"
   293     interval_lebesgue_integrable lborel b a f"
   298   by (cases a b rule: linorder_cases) (auto simp: interval_lebesgue_integrable_def einterval_same)
   294   by (cases a b rule: linorder_cases) (auto simp: interval_lebesgue_integrable_def einterval_same)
   302 proof (induct a b rule: linorder_wlog)
   298 proof (induct a b rule: linorder_wlog)
   303   case (sym a b) then show ?case
   299   case (sym a b) then show ?case
   304     by (auto simp add: interval_lebesgue_integral_def interval_integrable_endpoints_reverse
   300     by (auto simp add: interval_lebesgue_integral_def interval_integrable_endpoints_reverse
   305              split: if_split_asm)
   301              split: if_split_asm)
   306 next
   302 next
   307   case (le a b) then show ?case
   303   case (le a b) 
   308     unfolding interval_lebesgue_integral_def
   304   have "LBINT x:{x. - x \<in> einterval a b}. f (- x) = LBINT x:einterval (- b) (- a). f (- x)"
   309     by (subst set_integral_reflect)
   305     unfolding interval_lebesgue_integrable_def set_lebesgue_integral_def
   310        (auto simp: interval_lebesgue_integrable_def einterval_iff
   306     apply (rule Bochner_Integration.integral_cong [OF refl])
   311                    ereal_uminus_le_reorder ereal_uminus_less_reorder not_less
   307     by (auto simp: einterval_iff ereal_uminus_le_reorder ereal_uminus_less_reorder not_less uminus_ereal.simps[symmetric]
   312                    uminus_ereal.simps[symmetric]
       
   313              simp del: uminus_ereal.simps
   308              simp del: uminus_ereal.simps
   314              intro!: Bochner_Integration.integral_cong
       
   315              split: split_indicator)
   309              split: split_indicator)
       
   310   then show ?case
       
   311     unfolding interval_lebesgue_integral_def 
       
   312     by (subst set_integral_reflect) (simp add: le)
   316 qed
   313 qed
   317 
   314 
   318 lemma interval_lebesgue_integral_0_infty:
   315 lemma interval_lebesgue_integral_0_infty:
   319   "interval_lebesgue_integrable M 0 \<infinity> f \<longleftrightarrow> set_integrable M {0<..} f"
   316   "interval_lebesgue_integrable M 0 \<infinity> f \<longleftrightarrow> set_integrable M {0<..} f"
   320   "interval_lebesgue_integral M 0 \<infinity> f = (LINT x:{0<..}|M. f x)"
   317   "interval_lebesgue_integral M 0 \<infinity> f = (LINT x:{0<..}|M. f x)"
   326 
   323 
   327 lemma interval_integrable_to_infinity_eq: "(interval_lebesgue_integrable M a \<infinity> f) =
   324 lemma interval_integrable_to_infinity_eq: "(interval_lebesgue_integrable M a \<infinity> f) =
   328   (set_integrable M {a<..} f)"
   325   (set_integrable M {a<..} f)"
   329   unfolding interval_lebesgue_integrable_def by auto
   326   unfolding interval_lebesgue_integrable_def by auto
   330 
   327 
   331 (*
   328 subsection\<open>Basic properties of integration over an interval wrt lebesgue measure\<close>
   332     Basic properties of integration over an interval wrt lebesgue measure.
       
   333 *)
       
   334 
   329 
   335 lemma interval_integral_zero [simp]:
   330 lemma interval_integral_zero [simp]:
   336   fixes a b :: ereal
   331   fixes a b :: ereal
   337   shows"LBINT x=a..b. 0 = 0"
   332   shows"LBINT x=a..b. 0 = 0"
   338 unfolding interval_lebesgue_integral_def einterval_eq
   333 unfolding interval_lebesgue_integral_def set_lebesgue_integral_def einterval_eq
   339 by simp
   334 by simp
   340 
   335 
   341 lemma interval_integral_const [intro, simp]:
   336 lemma interval_integral_const [intro, simp]:
   342   fixes a b c :: real
   337   fixes a b c :: real
   343   shows "interval_lebesgue_integrable lborel a b (\<lambda>x. c)" and "LBINT x=a..b. c = c * (b - a)"
   338   shows "interval_lebesgue_integrable lborel a b (\<lambda>x. c)" and "LBINT x=a..b. c = c * (b - a)"
   344 unfolding interval_lebesgue_integral_def interval_lebesgue_integrable_def einterval_eq
   339   unfolding interval_lebesgue_integral_def interval_lebesgue_integrable_def einterval_eq
   345 by (auto simp add:  less_imp_le field_simps measure_def)
   340   by (auto simp add: less_imp_le field_simps measure_def set_integrable_def set_lebesgue_integral_def)
   346 
   341 
   347 lemma interval_integral_cong_AE:
   342 lemma interval_integral_cong_AE:
   348   assumes [measurable]: "f \<in> borel_measurable borel" "g \<in> borel_measurable borel"
   343   assumes [measurable]: "f \<in> borel_measurable borel" "g \<in> borel_measurable borel"
   349   assumes "AE x \<in> einterval (min a b) (max a b) in lborel. f x = g x"
   344   assumes "AE x \<in> einterval (min a b) (max a b) in lborel. f x = g x"
   350   shows "interval_lebesgue_integral lborel a b f = interval_lebesgue_integral lborel a b g"
   345   shows "interval_lebesgue_integral lborel a b f = interval_lebesgue_integral lborel a b g"
   427   assumes "countable X"
   422   assumes "countable X"
   428   and eq: "\<And>x. a \<le> b \<Longrightarrow> a < x \<Longrightarrow> x < b \<Longrightarrow> x \<notin> X \<Longrightarrow> f x = g x"
   423   and eq: "\<And>x. a \<le> b \<Longrightarrow> a < x \<Longrightarrow> x < b \<Longrightarrow> x \<notin> X \<Longrightarrow> f x = g x"
   429   and anti_eq: "\<And>x. b \<le> a \<Longrightarrow> b < x \<Longrightarrow> x < a \<Longrightarrow> x \<notin> X \<Longrightarrow> f x = g x"
   424   and anti_eq: "\<And>x. b \<le> a \<Longrightarrow> b < x \<Longrightarrow> x < a \<Longrightarrow> x \<notin> X \<Longrightarrow> f x = g x"
   430   assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
   425   assumes "\<And>x. x \<in> X \<Longrightarrow> emeasure M {x} = 0" "\<And>x. x \<in> X \<Longrightarrow> {x} \<in> sets M"
   431   shows "interval_lebesgue_integral M a b f = interval_lebesgue_integral M a b g"
   426   shows "interval_lebesgue_integral M a b f = interval_lebesgue_integral M a b g"
   432   unfolding interval_lebesgue_integral_def
   427   unfolding interval_lebesgue_integral_def set_lebesgue_integral_def
   433   apply (intro if_cong refl arg_cong[where f="\<lambda>x. - x"] integral_discrete_difference[of X] assms)
   428   apply (intro if_cong refl arg_cong[where f="\<lambda>x. - x"] integral_discrete_difference[of X] assms)
   434   apply (auto simp: eq anti_eq einterval_iff split: split_indicator)
   429   apply (auto simp: eq anti_eq einterval_iff split: split_indicator)
   435   done
   430   done
   436 
   431 
   437 lemma interval_integral_sum:
   432 lemma interval_integral_sum:
   442   let ?I = "\<lambda>a b. LBINT x=a..b. f x"
   437   let ?I = "\<lambda>a b. LBINT x=a..b. f x"
   443   { fix a b c :: ereal assume "interval_lebesgue_integrable lborel a c f" "a \<le> b" "b \<le> c"
   438   { fix a b c :: ereal assume "interval_lebesgue_integrable lborel a c f" "a \<le> b" "b \<le> c"
   444     then have ord: "a \<le> b" "b \<le> c" "a \<le> c" and f': "set_integrable lborel (einterval a c) f"
   439     then have ord: "a \<le> b" "b \<le> c" "a \<le> c" and f': "set_integrable lborel (einterval a c) f"
   445       by (auto simp: interval_lebesgue_integrable_def)
   440       by (auto simp: interval_lebesgue_integrable_def)
   446     then have f: "set_borel_measurable borel (einterval a c) f"
   441     then have f: "set_borel_measurable borel (einterval a c) f"
       
   442       unfolding set_integrable_def set_borel_measurable_def
   447       by (drule_tac borel_measurable_integrable) simp
   443       by (drule_tac borel_measurable_integrable) simp
   448     have "(LBINT x:einterval a c. f x) = (LBINT x:einterval a b \<union> einterval b c. f x)"
   444     have "(LBINT x:einterval a c. f x) = (LBINT x:einterval a b \<union> einterval b c. f x)"
   449     proof (rule set_integral_cong_set)
   445     proof (rule set_integral_cong_set)
   450       show "AE x in lborel. (x \<in> einterval a b \<union> einterval b c) = (x \<in> einterval a c)"
   446       show "AE x in lborel. (x \<in> einterval a b \<union> einterval b c) = (x \<in> einterval a c)"
   451         using AE_lborel_singleton[of "real_of_ereal b"] ord
   447         using AE_lborel_singleton[of "real_of_ereal b"] ord
   452         by (cases a b c rule: ereal3_cases) (auto simp: einterval_iff)
   448         by (cases a b c rule: ereal3_cases) (auto simp: einterval_iff)
   453     qed (insert ord, auto intro!: set_borel_measurable_subset[OF f] simp: einterval_iff)
   449       show "set_borel_measurable lborel (einterval a c) f" "set_borel_measurable lborel (einterval a b \<union> einterval b c) f"
       
   450         unfolding set_borel_measurable_def
       
   451         using ord by (auto simp: einterval_iff intro!: set_borel_measurable_subset[OF f, unfolded set_borel_measurable_def])
       
   452     qed
   454     also have "\<dots> = (LBINT x:einterval a b. f x) + (LBINT x:einterval b c. f x)"
   453     also have "\<dots> = (LBINT x:einterval a b. f x) + (LBINT x:einterval b c. f x)"
   455       using ord
   454       using ord
   456       by (intro set_integral_Un_AE) (auto intro!: set_integrable_subset[OF f'] simp: einterval_iff not_less)
   455       by (intro set_integral_Un_AE) (auto intro!: set_integrable_subset[OF f'] simp: einterval_iff not_less)
   457     finally have "?I a b + ?I b c = ?I a c"
   456     finally have "?I a b + ?I b c = ?I a c"
   458       using ord by (simp add: interval_lebesgue_integral_def)
   457       using ord by (simp add: interval_lebesgue_integral_def)
   473   fixes a b and f :: "real \<Rightarrow> 'a::{banach, second_countable_topology}"
   472   fixes a b and f :: "real \<Rightarrow> 'a::{banach, second_countable_topology}"
   474   shows "(\<And>x. min a b \<le> x \<Longrightarrow> x \<le> max a b \<Longrightarrow> isCont f x) \<Longrightarrow>
   473   shows "(\<And>x. min a b \<le> x \<Longrightarrow> x \<le> max a b \<Longrightarrow> isCont f x) \<Longrightarrow>
   475     interval_lebesgue_integrable lborel a b f"
   474     interval_lebesgue_integrable lborel a b f"
   476 proof (induct a b rule: linorder_wlog)
   475 proof (induct a b rule: linorder_wlog)
   477   case (le a b) then show ?case
   476   case (le a b) then show ?case
       
   477     unfolding interval_lebesgue_integrable_def set_integrable_def
   478     by (auto simp: interval_lebesgue_integrable_def
   478     by (auto simp: interval_lebesgue_integrable_def
   479              intro!: set_integrable_subset[OF borel_integrable_compact[of "{a .. b}"]]
   479         intro!: set_integrable_subset[unfolded set_integrable_def, OF borel_integrable_compact[of "{a .. b}"]]
   480                      continuous_at_imp_continuous_on)
   480         continuous_at_imp_continuous_on)
   481 qed (auto intro: interval_integrable_endpoints_reverse[THEN iffD1])
   481 qed (auto intro: interval_integrable_endpoints_reverse[THEN iffD1])
   482 
   482 
   483 lemma interval_integrable_continuous_on:
   483 lemma interval_integrable_continuous_on:
   484   fixes a b :: real and f
   484   fixes a b :: real and f
   485   assumes "a \<le> b" and "continuous_on {a..b} f"
   485   assumes "a \<le> b" and "continuous_on {a..b} f"
   495 lemma interval_integral_eq_integral':
   495 lemma interval_integral_eq_integral':
   496   fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   496   fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   497   shows "a \<le> b \<Longrightarrow> set_integrable lborel (einterval a b) f \<Longrightarrow> LBINT x=a..b. f x = integral (einterval a b) f"
   497   shows "a \<le> b \<Longrightarrow> set_integrable lborel (einterval a b) f \<Longrightarrow> LBINT x=a..b. f x = integral (einterval a b) f"
   498   by (subst interval_lebesgue_integral_le_eq, simp) (rule set_borel_integral_eq_integral)
   498   by (subst interval_lebesgue_integral_le_eq, simp) (rule set_borel_integral_eq_integral)
   499 
   499 
   500 (*
   500 
   501     General limit approximation arguments
   501 subsection\<open>General limit approximation arguments\<close>
   502 *)
       
   503 
   502 
   504 lemma interval_integral_Icc_approx_nonneg:
   503 lemma interval_integral_Icc_approx_nonneg:
   505   fixes a b :: ereal
   504   fixes a b :: ereal
   506   assumes "a < b"
   505   assumes "a < b"
   507   fixes u l :: "nat \<Rightarrow> real"
   506   fixes u l :: "nat \<Rightarrow> real"
   515   assumes lbint_lim: "(\<lambda>i. LBINT x=l i.. u i. f x) \<longlonglongrightarrow> C"
   514   assumes lbint_lim: "(\<lambda>i. LBINT x=l i.. u i. f x) \<longlonglongrightarrow> C"
   516   shows
   515   shows
   517     "set_integrable lborel (einterval a b) f"
   516     "set_integrable lborel (einterval a b) f"
   518     "(LBINT x=a..b. f x) = C"
   517     "(LBINT x=a..b. f x) = C"
   519 proof -
   518 proof -
   520   have 1: "\<And>i. set_integrable lborel {l i..u i} f" by (rule f_integrable)
   519   have 1 [unfolded set_integrable_def]: "\<And>i. set_integrable lborel {l i..u i} f" by (rule f_integrable)
   521   have 2: "AE x in lborel. mono (\<lambda>n. indicator {l n..u n} x *\<^sub>R f x)"
   520   have 2: "AE x in lborel. mono (\<lambda>n. indicator {l n..u n} x *\<^sub>R f x)"
   522   proof -
   521   proof -
   523      from f_nonneg have "AE x in lborel. \<forall>i. l i \<le> x \<longrightarrow> x \<le> u i \<longrightarrow> 0 \<le> f x"
   522      from f_nonneg have "AE x in lborel. \<forall>i. l i \<le> x \<longrightarrow> x \<le> u i \<longrightarrow> 0 \<le> f x"
   524       by eventually_elim
   523       by eventually_elim
   525          (metis approx(5) approx(6) dual_order.strict_trans1 ereal_less_eq(3) le_less_trans)
   524          (metis approx(5) approx(6) dual_order.strict_trans1 ereal_less_eq(3) le_less_trans)
   542         by eventually_elim auto }
   541         by eventually_elim auto }
   543     then show ?thesis
   542     then show ?thesis
   544       unfolding approx(1) by (auto intro!: AE_I2 Lim_eventually split: split_indicator)
   543       unfolding approx(1) by (auto intro!: AE_I2 Lim_eventually split: split_indicator)
   545   qed
   544   qed
   546   have 4: "(\<lambda>i. \<integral> x. indicator {l i..u i} x *\<^sub>R f x \<partial>lborel) \<longlonglongrightarrow> C"
   545   have 4: "(\<lambda>i. \<integral> x. indicator {l i..u i} x *\<^sub>R f x \<partial>lborel) \<longlonglongrightarrow> C"
   547     using lbint_lim by (simp add: interval_integral_Icc approx less_imp_le)
   546     using lbint_lim by (simp add: interval_integral_Icc [unfolded set_lebesgue_integral_def] approx less_imp_le)
   548   have 5: "set_borel_measurable lborel (einterval a b) f" by (rule assms)
   547   have 5: "(\<lambda>x. indicat_real (einterval a b) x *\<^sub>R f x) \<in> borel_measurable lborel"
       
   548     using f_measurable set_borel_measurable_def by blast
   549   have "(LBINT x=a..b. f x) = lebesgue_integral lborel (\<lambda>x. indicator (einterval a b) x *\<^sub>R f x)"
   549   have "(LBINT x=a..b. f x) = lebesgue_integral lborel (\<lambda>x. indicator (einterval a b) x *\<^sub>R f x)"
   550     using assms by (simp add: interval_lebesgue_integral_def less_imp_le)
   550     using assms by (simp add: interval_lebesgue_integral_def set_lebesgue_integral_def less_imp_le)
   551   also have "... = C" by (rule integral_monotone_convergence [OF 1 2 3 4 5])
   551   also have "... = C"
       
   552     by (rule integral_monotone_convergence [OF 1 2 3 4 5])
   552   finally show "(LBINT x=a..b. f x) = C" .
   553   finally show "(LBINT x=a..b. f x) = C" .
   553 
       
   554   show "set_integrable lborel (einterval a b) f"
   554   show "set_integrable lborel (einterval a b) f"
       
   555     unfolding set_integrable_def
   555     by (rule integrable_monotone_convergence[OF 1 2 3 4 5])
   556     by (rule integrable_monotone_convergence[OF 1 2 3 4 5])
   556 qed
   557 qed
   557 
   558 
   558 lemma interval_integral_Icc_approx_integrable:
   559 lemma interval_integral_Icc_approx_integrable:
   559   fixes u l :: "nat \<Rightarrow> real" and a b :: ereal
   560   fixes u l :: "nat \<Rightarrow> real" and a b :: ereal
   564     "l \<longlonglongrightarrow> a" "u \<longlonglongrightarrow> b"
   565     "l \<longlonglongrightarrow> a" "u \<longlonglongrightarrow> b"
   565   assumes f_integrable: "set_integrable lborel (einterval a b) f"
   566   assumes f_integrable: "set_integrable lborel (einterval a b) f"
   566   shows "(\<lambda>i. LBINT x=l i.. u i. f x) \<longlonglongrightarrow> (LBINT x=a..b. f x)"
   567   shows "(\<lambda>i. LBINT x=l i.. u i. f x) \<longlonglongrightarrow> (LBINT x=a..b. f x)"
   567 proof -
   568 proof -
   568   have "(\<lambda>i. LBINT x:{l i.. u i}. f x) \<longlonglongrightarrow> (LBINT x:einterval a b. f x)"
   569   have "(\<lambda>i. LBINT x:{l i.. u i}. f x) \<longlonglongrightarrow> (LBINT x:einterval a b. f x)"
       
   570     unfolding set_lebesgue_integral_def
   569   proof (rule integral_dominated_convergence)
   571   proof (rule integral_dominated_convergence)
   570     show "integrable lborel (\<lambda>x. norm (indicator (einterval a b) x *\<^sub>R f x))"
   572     show "integrable lborel (\<lambda>x. norm (indicator (einterval a b) x *\<^sub>R f x))"
   571       by (rule integrable_norm) fact
   573       using f_integrable integrable_norm set_integrable_def by blast
   572     show "set_borel_measurable lborel (einterval a b) f"
   574     show "(\<lambda>x. indicat_real (einterval a b) x *\<^sub>R f x) \<in> borel_measurable lborel"
   573       using f_integrable by (rule borel_measurable_integrable)
   575       using f_integrable by (simp add: set_integrable_def)
   574     then show "\<And>i. set_borel_measurable lborel {l i..u i} f"
   576     then show "\<And>i. (\<lambda>x. indicat_real {l i..u i} x *\<^sub>R f x) \<in> borel_measurable lborel"
   575       by (rule set_borel_measurable_subset) (auto simp: approx)
   577       by (rule set_borel_measurable_subset [unfolded set_borel_measurable_def]) (auto simp: approx)
   576     show "\<And>i. AE x in lborel. norm (indicator {l i..u i} x *\<^sub>R f x) \<le> norm (indicator (einterval a b) x *\<^sub>R f x)"
   578     show "\<And>i. AE x in lborel. norm (indicator {l i..u i} x *\<^sub>R f x) \<le> norm (indicator (einterval a b) x *\<^sub>R f x)"
   577       by (intro AE_I2) (auto simp: approx split: split_indicator)
   579       by (intro AE_I2) (auto simp: approx split: split_indicator)
   578     show "AE x in lborel. (\<lambda>i. indicator {l i..u i} x *\<^sub>R f x) \<longlonglongrightarrow> indicator (einterval a b) x *\<^sub>R f x"
   580     show "AE x in lborel. (\<lambda>i. indicator {l i..u i} x *\<^sub>R f x) \<longlonglongrightarrow> indicator (einterval a b) x *\<^sub>R f x"
   579     proof (intro AE_I2 tendsto_intros Lim_eventually)
   581     proof (intro AE_I2 tendsto_intros Lim_eventually)
   580       fix x
   582       fix x
   589   qed
   591   qed
   590   with \<open>a < b\<close> \<open>\<And>i. l i < u i\<close> show ?thesis
   592   with \<open>a < b\<close> \<open>\<And>i. l i < u i\<close> show ?thesis
   591     by (simp add: interval_lebesgue_integral_le_eq[symmetric] interval_integral_Icc less_imp_le)
   593     by (simp add: interval_lebesgue_integral_le_eq[symmetric] interval_integral_Icc less_imp_le)
   592 qed
   594 qed
   593 
   595 
       
   596 subsection\<open>A slightly stronger Fundamental Theorem of Calculus\<close>
       
   597 
       
   598 text\<open>Three versions: first, for finite intervals, and then two versions for
       
   599     arbitrary intervals.\<close>
       
   600 
   594 (*
   601 (*
   595   A slightly stronger version of integral_FTC_atLeastAtMost and related facts,
       
   596   with continuous_on instead of isCont
       
   597 
       
   598   TODO: make the older versions corollaries of these (using continuous_at_imp_continuous_on, etc.)
   602   TODO: make the older versions corollaries of these (using continuous_at_imp_continuous_on, etc.)
   599 *)
   603 *)
   600 
   604 
   601 (*
   605 (*
   602 TODO: many proofs below require inferences like
   606 TODO: many proofs below require inferences like
   603 
   607 
   604   a < ereal x \<Longrightarrow> x < y \<Longrightarrow> a < ereal y
   608   a < ereal x \<Longrightarrow> x < y \<Longrightarrow> a < ereal y
   605 
   609 
   606 where x and y are real. These should be better automated.
   610 where x and y are real. These should be better automated.
   607 *)
       
   608 
       
   609 (*
       
   610     The first Fundamental Theorem of Calculus
       
   611 
       
   612     First, for finite intervals, and then two versions for arbitrary intervals.
       
   613 *)
   611 *)
   614 
   612 
   615 lemma interval_integral_FTC_finite:
   613 lemma interval_integral_FTC_finite:
   616   fixes f F :: "real \<Rightarrow> 'a::euclidean_space" and a b :: real
   614   fixes f F :: "real \<Rightarrow> 'a::euclidean_space" and a b :: real
   617   assumes f: "continuous_on {min a b..max a b} f"
   615   assumes f: "continuous_on {min a b..max a b} f"
   618   assumes F: "\<And>x. min a b \<le> x \<Longrightarrow> x \<le> max a b \<Longrightarrow> (F has_vector_derivative (f x)) (at x within
   616   assumes F: "\<And>x. min a b \<le> x \<Longrightarrow> x \<le> max a b \<Longrightarrow> (F has_vector_derivative (f x)) (at x within
   619     {min a b..max a b})"
   617     {min a b..max a b})"
   620   shows "(LBINT x=a..b. f x) = F b - F a"
   618   shows "(LBINT x=a..b. f x) = F b - F a"
   621   apply (case_tac "a \<le> b")
   619 proof (cases "a \<le> b")
   622   apply (subst interval_integral_Icc, simp)
   620   case True
   623   apply (rule integral_FTC_atLeastAtMost, assumption)
   621   have "(LBINT x=a..b. f x) = (LBINT x. indicat_real {a..b} x *\<^sub>R f x)"
   624   apply (metis F max_def min_def)
   622     by (simp add: True interval_integral_Icc set_lebesgue_integral_def)
   625   using f apply (simp add: min_absorb1 max_absorb2)
   623   also have "... = F b - F a"
   626   apply (subst interval_integral_endpoints_reverse)
   624   proof (rule integral_FTC_atLeastAtMost [OF True])
   627   apply (subst interval_integral_Icc, simp)
   625     show "continuous_on {a..b} f"
   628   apply (subst integral_FTC_atLeastAtMost, auto)
   626       using True f by linarith
   629   apply (metis F max_def min_def)
   627     show "\<And>x. \<lbrakk>a \<le> x; x \<le> b\<rbrakk> \<Longrightarrow> (F has_vector_derivative f x) (at x within {a..b})"
   630 using f by (simp add: min_absorb2 max_absorb1)
   628       by (metis F True max.commute max_absorb1 min_def)
       
   629   qed
       
   630   finally show ?thesis .
       
   631 next
       
   632   case False
       
   633   then have "b \<le> a"
       
   634     by simp
       
   635   have "- interval_lebesgue_integral lborel (ereal b) (ereal a) f = - (LBINT x. indicat_real {b..a} x *\<^sub>R f x)"
       
   636     by (simp add: \<open>b \<le> a\<close> interval_integral_Icc set_lebesgue_integral_def)
       
   637   also have "... = F b - F a"
       
   638   proof (subst integral_FTC_atLeastAtMost [OF \<open>b \<le> a\<close>])
       
   639     show "continuous_on {b..a} f"
       
   640       using False f by linarith
       
   641     show "\<And>x. \<lbrakk>b \<le> x; x \<le> a\<rbrakk>
       
   642          \<Longrightarrow> (F has_vector_derivative f x) (at x within {b..a})"
       
   643       by (metis F False max_def min_def)
       
   644   qed auto
       
   645   finally show ?thesis
       
   646     by (metis interval_integral_endpoints_reverse)
       
   647 qed
       
   648 
       
   649 
   631 
   650 
   632 lemma interval_integral_FTC_nonneg:
   651 lemma interval_integral_FTC_nonneg:
   633   fixes f F :: "real \<Rightarrow> real" and a b :: ereal
   652   fixes f F :: "real \<Rightarrow> real" and a b :: ereal
   634   assumes "a < b"
   653   assumes "a < b"
   635   assumes F: "\<And>x. a < ereal x \<Longrightarrow> ereal x < b \<Longrightarrow> DERIV F x :> f x"
   654   assumes F: "\<And>x. a < ereal x \<Longrightarrow> ereal x < b \<Longrightarrow> DERIV F x :> f x"
   653     apply (rule continuous_at_imp_continuous_on, auto intro!: f)
   672     apply (rule continuous_at_imp_continuous_on, auto intro!: f)
   654     by (rule DERIV_subset [OF F], auto)
   673     by (rule DERIV_subset [OF F], auto)
   655   have 1: "\<And>i. set_integrable lborel {l i..u i} f"
   674   have 1: "\<And>i. set_integrable lborel {l i..u i} f"
   656   proof -
   675   proof -
   657     fix i show "set_integrable lborel {l i .. u i} f"
   676     fix i show "set_integrable lborel {l i .. u i} f"
   658       using \<open>a < l i\<close> \<open>u i < b\<close>
   677       using \<open>a < l i\<close> \<open>u i < b\<close> unfolding set_integrable_def
   659       by (intro borel_integrable_compact f continuous_at_imp_continuous_on compact_Icc ballI)
   678       by (intro borel_integrable_compact f continuous_at_imp_continuous_on compact_Icc ballI)
   660          (auto simp del: ereal_less_eq simp add: ereal_less_eq(3)[symmetric])
   679          (auto simp del: ereal_less_eq simp add: ereal_less_eq(3)[symmetric])
   661   qed
   680   qed
   662   have 2: "set_borel_measurable lborel (einterval a b) f"
   681   have 2: "set_borel_measurable lborel (einterval a b) f"
       
   682     unfolding set_borel_measurable_def
   663     by (auto simp del: real_scaleR_def intro!: borel_measurable_continuous_on_indicator
   683     by (auto simp del: real_scaleR_def intro!: borel_measurable_continuous_on_indicator
   664              simp: continuous_on_eq_continuous_at einterval_iff f)
   684              simp: continuous_on_eq_continuous_at einterval_iff f)
   665   have 3: "(\<lambda>i. LBINT x=l i..u i. f x) \<longlonglongrightarrow> B - A"
   685   have 3: "(\<lambda>i. LBINT x=l i..u i. f x) \<longlonglongrightarrow> B - A"
   666     apply (subst FTCi)
   686     apply (subst FTCi)
   667     apply (intro tendsto_intros)
   687     apply (intro tendsto_intros)
   777       apply (rule order_le_less_trans) prefer 2
   797       apply (rule order_le_less_trans) prefer 2
   778       by (rule \<open>e < b\<close>, auto)
   798       by (rule \<open>e < b\<close>, auto)
   779   qed
   799   qed
   780 qed
   800 qed
   781 
   801 
   782 (*
   802 subsection\<open>The substitution theorem\<close>
   783     The substitution theorem
   803 
   784 
   804 text\<open>Once again, three versions: first, for finite intervals, and then two versions for
   785     Once again, three versions: first, for finite intervals, and then two versions for
   805     arbitrary intervals.\<close>
   786     arbitrary intervals.
       
   787 *)
       
   788 
   806 
   789 lemma interval_integral_substitution_finite:
   807 lemma interval_integral_substitution_finite:
   790   fixes a b :: real and f :: "real \<Rightarrow> 'a::euclidean_space"
   808   fixes a b :: real and f :: "real \<Rightarrow> 'a::euclidean_space"
   791   assumes "a \<le> b"
   809   assumes "a \<le> b"
   792   and derivg: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> (g has_real_derivative (g' x)) (at x within {a..b})"
   810   and derivg: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> (g has_real_derivative (g' x)) (at x within {a..b})"
   822     by (erule 1)
   840     by (erule 1)
   823   have contfg: "continuous_on {a..b} (\<lambda>x. f (g x))"
   841   have contfg: "continuous_on {a..b} (\<lambda>x. f (g x))"
   824     by (blast intro: continuous_on_compose2 contf contg)
   842     by (blast intro: continuous_on_compose2 contf contg)
   825   have "LBINT x=a..b. g' x *\<^sub>R f (g x) = F (g b) - F (g a)"
   843   have "LBINT x=a..b. g' x *\<^sub>R f (g x) = F (g b) - F (g a)"
   826     apply (subst interval_integral_Icc, simp add: assms)
   844     apply (subst interval_integral_Icc, simp add: assms)
       
   845     unfolding set_lebesgue_integral_def
   827     apply (rule integral_FTC_atLeastAtMost[of a b "\<lambda>x. F (g x)", OF \<open>a \<le> b\<close>])
   846     apply (rule integral_FTC_atLeastAtMost[of a b "\<lambda>x. F (g x)", OF \<open>a \<le> b\<close>])
   828     apply (rule vector_diff_chain_within[OF v_derivg derivF, unfolded comp_def])
   847     apply (rule vector_diff_chain_within[OF v_derivg derivF, unfolded comp_def])
   829     apply (auto intro!: continuous_on_scaleR contg' contfg)
   848     apply (auto intro!: continuous_on_scaleR contg' contfg)
   830     done
   849     done
   831   moreover have "LBINT y=(g a)..(g b). f y = F (g b) - F (g a)"
   850   moreover have "LBINT y=(g a)..(g b). f y = F (g b) - F (g a)"
  1091 lemma interval_integral_norm:
  1110 lemma interval_integral_norm:
  1092   fixes f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}"
  1111   fixes f :: "real \<Rightarrow> 'a :: {banach, second_countable_topology}"
  1093   shows "interval_lebesgue_integrable lborel a b f \<Longrightarrow> a \<le> b \<Longrightarrow>
  1112   shows "interval_lebesgue_integrable lborel a b f \<Longrightarrow> a \<le> b \<Longrightarrow>
  1094     norm (LBINT t=a..b. f t) \<le> LBINT t=a..b. norm (f t)"
  1113     norm (LBINT t=a..b. f t) \<le> LBINT t=a..b. norm (f t)"
  1095   using integral_norm_bound[of lborel "\<lambda>x. indicator (einterval a b) x *\<^sub>R f x"]
  1114   using integral_norm_bound[of lborel "\<lambda>x. indicator (einterval a b) x *\<^sub>R f x"]
  1096   by (auto simp add: interval_lebesgue_integral_def interval_lebesgue_integrable_def)
  1115   by (auto simp add: interval_lebesgue_integral_def interval_lebesgue_integrable_def set_lebesgue_integral_def)
  1097 
  1116 
  1098 lemma interval_integral_norm2:
  1117 lemma interval_integral_norm2:
  1099   "interval_lebesgue_integrable lborel a b f \<Longrightarrow>
  1118   "interval_lebesgue_integrable lborel a b f \<Longrightarrow>
  1100     norm (LBINT t=a..b. f t) \<le> \<bar>LBINT t=a..b. norm (f t)\<bar>"
  1119     norm (LBINT t=a..b. f t) \<le> \<bar>LBINT t=a..b. norm (f t)\<bar>"
  1101 proof (induct a b rule: linorder_wlog)
  1120 proof (induct a b rule: linorder_wlog)
  1103     by (simp add: interval_integral_endpoints_reverse[of a b] interval_integrable_endpoints_reverse[of a b])
  1122     by (simp add: interval_integral_endpoints_reverse[of a b] interval_integrable_endpoints_reverse[of a b])
  1104 next
  1123 next
  1105   case (le a b)
  1124   case (le a b)
  1106   then have "\<bar>LBINT t=a..b. norm (f t)\<bar> = LBINT t=a..b. norm (f t)"
  1125   then have "\<bar>LBINT t=a..b. norm (f t)\<bar> = LBINT t=a..b. norm (f t)"
  1107     using integrable_norm[of lborel "\<lambda>x. indicator (einterval a b) x *\<^sub>R f x"]
  1126     using integrable_norm[of lborel "\<lambda>x. indicator (einterval a b) x *\<^sub>R f x"]
  1108     by (auto simp add: interval_lebesgue_integral_def interval_lebesgue_integrable_def
  1127     by (auto simp add: interval_lebesgue_integral_def interval_lebesgue_integrable_def set_lebesgue_integral_def
  1109              intro!: integral_nonneg_AE abs_of_nonneg)
  1128              intro!: integral_nonneg_AE abs_of_nonneg)
  1110   then show ?case
  1129   then show ?case
  1111     using le by (simp add: interval_integral_norm)
  1130     using le by (simp add: interval_integral_norm)
  1112 qed
  1131 qed
  1113 
  1132