src/HOL/Analysis/Henstock_Kurzweil_Integration.thy
changeset 66420 bc0dab0e7b40
parent 66409 f749d39c016b
child 66422 2891f33ed4c8
equal deleted inserted replaced
66409:f749d39c016b 66420:bc0dab0e7b40
     7 theory Henstock_Kurzweil_Integration
     7 theory Henstock_Kurzweil_Integration
     8 imports
     8 imports
     9   Lebesgue_Measure Tagged_Division
     9   Lebesgue_Measure Tagged_Division
    10 begin
    10 begin
    11 
    11 
    12 lemma norm_triangle_le_sub: "norm x + norm y \<le> e \<Longrightarrow> norm (x - y) \<le> e"
    12 (*MOVE ALL THESE*)
    13   apply (subst(asm)(2) norm_minus_cancel[symmetric])
    13 lemma abs_triangle_half_r:
    14   apply (drule norm_triangle_le)
    14   fixes y :: "'a::linordered_field"
    15   apply (auto simp add: algebra_simps)
    15   shows "abs (y - x1) < e / 2 \<Longrightarrow> abs (y - x2) < e / 2 \<Longrightarrow> abs (x1 - x2) < e"
    16   done
    16   by linarith
       
    17 
       
    18 lemma abs_triangle_half_l:
       
    19   fixes y :: "'a::linordered_field"
       
    20   assumes "abs (x - y) < e / 2"
       
    21     and "abs (x' - y) < e / 2"
       
    22   shows "abs (x - x') < e"
       
    23   using assms by linarith
    17 
    24 
    18 lemma eps_leI: 
    25 lemma eps_leI: 
    19   assumes "(\<And>e::'a::linordered_idom. 0 < e \<Longrightarrow> x < y + e)" shows "x \<le> y"
    26   assumes "(\<And>e::'a::linordered_idom. 0 < e \<Longrightarrow> x < y + e)" shows "x \<le> y"
    20   by (metis add_diff_eq assms diff_diff_add diff_gt_0_iff_gt linorder_not_less order_less_irrefl)
    27   by (metis add_diff_eq assms diff_diff_add diff_gt_0_iff_gt linorder_not_less order_less_irrefl)
    21 
    28 
  3773           by (auto simp add: k subset_eq dist_commute dist_real_def)
  3780           by (auto simp add: k subset_eq dist_commute dist_real_def)
  3774         have "norm ((v - u) *\<^sub>R f' (x) - (f (v) - f (u))) =
  3781         have "norm ((v - u) *\<^sub>R f' (x) - (f (v) - f (u))) =
  3775               norm ((f (u) - f (x) - (u - x) *\<^sub>R f' (x)) - (f (v) - f (x) - (v - x) *\<^sub>R f' (x)))"
  3782               norm ((f (u) - f (x) - (u - x) *\<^sub>R f' (x)) - (f (v) - f (x) - (v - x) *\<^sub>R f' (x)))"
  3776           by (rule arg_cong[where f=norm]) (auto simp: scaleR_left.diff)
  3783           by (rule arg_cong[where f=norm]) (auto simp: scaleR_left.diff)
  3777         also have "\<dots> \<le> e/2 * norm (u - x) + e/2 * norm (v - x)"
  3784         also have "\<dots> \<le> e/2 * norm (u - x) + e/2 * norm (v - x)"
  3778           by (metis norm_triangle_le_sub add_mono * xd)
  3785           by (metis norm_triangle_le_diff add_mono * xd)
  3779         also have "\<dots> \<le> e/2 * norm (v - u)"
  3786         also have "\<dots> \<le> e/2 * norm (v - u)"
  3780           using p(2)[OF xk] by (auto simp add: field_simps k)
  3787           using p(2)[OF xk] by (auto simp add: field_simps k)
  3781         also have "\<dots> < norm ((v - u) *\<^sub>R f' x - (f v - f u))"
  3788         also have "\<dots> < norm ((v - u) *\<^sub>R f' x - (f v - f u))"
  3782           using result by (simp add: \<open>u \<le> v\<close>)
  3789           using result by (simp add: \<open>u \<le> v\<close>)
  3783         finally have "e * (v - u) / 2 < e * (v - u) / 2"
  3790         finally have "e * (v - u) / 2 < e * (v - u) / 2"
  6271     using i * by auto
  6278     using i * by auto
  6272 qed
  6279 qed
  6273 
  6280 
  6274 lemma monotone_convergence_increasing:
  6281 lemma monotone_convergence_increasing:
  6275   fixes f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> real"
  6282   fixes f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> real"
  6276   assumes "\<And>k. (f k) integrable_on S"
  6283   assumes int_f: "\<And>k. (f k) integrable_on S"
  6277     and "\<And>k x. x \<in> S \<Longrightarrow> (f k x) \<le> (f (Suc k) x)"
  6284     and "\<And>k x. x \<in> S \<Longrightarrow> (f k x) \<le> (f (Suc k) x)"
  6278     and "\<And>x. x \<in> S \<Longrightarrow> ((\<lambda>k. f k x) \<longlongrightarrow> g x) sequentially"
  6285     and fg: "\<And>x. x \<in> S \<Longrightarrow> ((\<lambda>k. f k x) \<longlongrightarrow> g x) sequentially"
  6279     and "bounded (range (\<lambda>k. integral S (f k)))"
  6286     and bou: "bounded (range (\<lambda>k. integral S (f k)))"
  6280   shows "g integrable_on S \<and> ((\<lambda>k. integral S (f k)) \<longlongrightarrow> integral S g) sequentially"
  6287   shows "g integrable_on S \<and> ((\<lambda>k. integral S (f k)) \<longlongrightarrow> integral S g) sequentially"
  6281 proof -
  6288 proof -
  6282   have lem: "g integrable_on S \<and> ((\<lambda>k. integral S (f k)) \<longlongrightarrow> integral S g) sequentially"
  6289   have lem: "g integrable_on S \<and> ((\<lambda>k. integral S (f k)) \<longlongrightarrow> integral S g) sequentially"
  6283     if f0: "\<And>k x. x \<in> S \<Longrightarrow> 0 \<le> f k x"
  6290     if f0: "\<And>k x. x \<in> S \<Longrightarrow> 0 \<le> f k x"
  6284     and int_f: "\<And>k. (f k) integrable_on S"
  6291     and int_f: "\<And>k. (f k) integrable_on S"
  6285     and le: "\<And>k. \<forall>x\<in>S. f k x \<le> f (Suc k) x"
  6292     and le: "\<And>k x. x \<in> S \<Longrightarrow> f k x \<le> f (Suc k) x"
  6286     and lim: "\<And>x. x \<in> S \<Longrightarrow> ((\<lambda>k. f k x) \<longlongrightarrow> g x) sequentially"
  6293     and lim: "\<And>x. x \<in> S \<Longrightarrow> ((\<lambda>k. f k x) \<longlongrightarrow> g x) sequentially"
  6287     and bou: "bounded (range(\<lambda>k. integral S (f k)))"
  6294     and bou: "bounded (range(\<lambda>k. integral S (f k)))"
  6288     for f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> real" and g S
  6295     for f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> real" and g S
  6289   proof -
  6296   proof -
  6290     have fg: "(f k x)\<bullet>1 \<le> (g x)\<bullet>1" if "x \<in> S" for x k
  6297     have fg: "(f k x)\<bullet>1 \<le> (g x)\<bullet>1" if "x \<in> S" for x k
  6292       unfolding eventually_sequentially
  6299       unfolding eventually_sequentially
  6293       apply (rule_tac x=k in exI)
  6300       apply (rule_tac x=k in exI)
  6294       using le  by (force intro: transitive_stepwise_le that) 
  6301       using le  by (force intro: transitive_stepwise_le that) 
  6295 
  6302 
  6296     obtain i where i: "(\<lambda>k. integral S (f k)) \<longlonglongrightarrow> i"
  6303     obtain i where i: "(\<lambda>k. integral S (f k)) \<longlonglongrightarrow> i"
  6297       using bounded_increasing_convergent [OF bou]
  6304       using bounded_increasing_convergent [OF bou] le int_f integral_le by blast
  6298       using le int_f integral_le by blast
       
  6299     have i': "(integral S (f k))\<bullet>1 \<le> i\<bullet>1" for k
  6305     have i': "(integral S (f k))\<bullet>1 \<le> i\<bullet>1" for k
  6300     proof -
  6306     proof -
  6301       have *: "\<And>k. \<forall>x\<in>S. \<forall>n\<ge>k. f k x \<le> f n x"
  6307       have *: "\<And>k. \<forall>x\<in>S. \<forall>n\<ge>k. f k x \<le> f n x"
  6302         using le  by (force intro: transitive_stepwise_le)
  6308         using le  by (force intro: transitive_stepwise_le)
  6303       show ?thesis
  6309       show ?thesis
  6305         unfolding eventually_sequentially
  6311         unfolding eventually_sequentially
  6306         apply (rule_tac x=k in exI)
  6312         apply (rule_tac x=k in exI)
  6307         using * by (simp add: int_f integral_le)
  6313         using * by (simp add: int_f integral_le)
  6308     qed
  6314     qed
  6309 
  6315 
  6310     have int: "(\<lambda>x. if x \<in> S then f k x else 0) integrable_on cbox a b" for a b k
  6316     let ?f = "(\<lambda>k x. if x \<in> S then f k x else 0)"
       
  6317     let ?g = "(\<lambda>x. if x \<in> S then g x else 0)"
       
  6318     have int: "?f k integrable_on cbox a b" for a b k
  6311       by (simp add: int_f integrable_altD(1))
  6319       by (simp add: int_f integrable_altD(1))
  6312     have int': "\<And>k a b. f k integrable_on cbox a b \<inter> S"
  6320     have int': "\<And>k a b. f k integrable_on cbox a b \<inter> S"
  6313       using int by (simp add: Int_commute integrable_restrict_Int) 
  6321       using int by (simp add: Int_commute integrable_restrict_Int) 
  6314     have "(\<lambda>x. if x \<in> S then g x else 0) integrable_on cbox a b \<and>
  6322     have g: "?g integrable_on cbox a b \<and>
  6315           (\<lambda>k. integral (cbox a b) (\<lambda>x. if x \<in> S then f k x else 0))
  6323              (\<lambda>k. integral (cbox a b) (?f k)) \<longlonglongrightarrow> integral (cbox a b) ?g" for a b
  6316           \<longlonglongrightarrow> integral (cbox a b) (\<lambda>x. if x \<in> S then g x else 0)" for a b
  6324     proof (rule monotone_convergence_interval)
  6317     proof (rule monotone_convergence_interval, goal_cases)
  6325       have "norm (integral (cbox a b) (?f k)) \<le> norm (integral S (f k))" for k
  6318       case 1
       
  6319       show ?case by (rule int)
       
  6320     next
       
  6321       case 4
       
  6322       have "norm (integral (cbox a b) (\<lambda>x. if x \<in> S then f k x else 0)) \<le> norm (integral S (f k))" for k
       
  6323       proof -
  6326       proof -
  6324         have "0 \<le> integral (cbox a b) (\<lambda>x. if x \<in> S then f k x else 0)"
  6327         have "0 \<le> integral (cbox a b) (?f k)"
  6325           by (metis (no_types) integral_nonneg Int_iff f0 inf_commute integral_restrict_Int int')
  6328           by (metis (no_types) integral_nonneg Int_iff f0 inf_commute integral_restrict_Int int')
  6326         moreover have "0 \<le> integral S (f k)"
  6329         moreover have "0 \<le> integral S (f k)"
  6327           by (simp add: integral_nonneg f0 int_f)
  6330           by (simp add: integral_nonneg f0 int_f)
  6328         moreover have "integral (S \<inter> cbox a b) (f k) \<le> integral S (f k)"
  6331         moreover have "integral (S \<inter> cbox a b) (f k) \<le> integral S (f k)"
  6329           by (metis f0 inf_commute int' int_f integral_subset_le le_inf_iff order_refl)
  6332           by (metis f0 inf_commute int' int_f integral_subset_le le_inf_iff order_refl)
  6330         ultimately show ?thesis
  6333         ultimately show ?thesis
  6331           by (simp add: integral_restrict_Int)
  6334           by (simp add: integral_restrict_Int)
  6332       qed
  6335       qed
  6333       moreover obtain B where "\<And>x. x \<in> range (\<lambda>k. integral S (f k)) \<Longrightarrow> norm x \<le> B"
  6336       moreover obtain B where "\<And>x. x \<in> range (\<lambda>k. integral S (f k)) \<Longrightarrow> norm x \<le> B"
  6334         using bou unfolding bounded_iff by blast
  6337         using bou unfolding bounded_iff by blast
  6335       ultimately show ?case
  6338       ultimately show "bounded (range (\<lambda>k. integral (cbox a b) (?f k)))"
  6336         unfolding bounded_iff by (blast intro: order_trans)
  6339         unfolding bounded_iff by (blast intro: order_trans)
  6337     qed (use le lim in auto)
  6340     qed (use int le lim in auto)
  6338     note g = conjunctD2[OF this]
  6341     moreover have "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> cbox a b \<longrightarrow> norm (integral (cbox a b) ?g - i) < e"
  6339 
  6342       if "0 < e" for e
  6340     have "(g has_integral i) S"
  6343     proof -
  6341       unfolding has_integral_alt'
  6344       have "e/4>0"
  6342       apply safe
  6345         using that by auto
  6343       apply (rule g(1))
  6346       with LIMSEQ_D [OF i] obtain N where N: "\<And>n. n \<ge> N \<Longrightarrow> norm (integral S (f n) - i) < e/4"
  6344     proof goal_cases
  6347         by metis
  6345       case (1 e)
  6348       with int_f[of N, unfolded has_integral_integral has_integral_alt'[of "f N"]] 
  6346       then have "e/4>0"
  6349       obtain B where "0 < B" and B: 
  6347         by auto
  6350         "\<And>a b. ball 0 B \<subseteq> cbox a b \<Longrightarrow> norm (integral (cbox a b) (?f N) - integral S (f N)) < e / 4"
  6348       from LIMSEQ_D [OF i this] guess N..note N=this
  6351         by (meson \<open>0 < e / 4\<close>)
  6349       note that(2)[of N,unfolded has_integral_integral has_integral_alt'[of "f N"]]
  6352       have "norm (integral (cbox a b) ?g - i) < e" if  ab: "ball 0 B \<subseteq> cbox a b" for a b
  6350       from this[THEN conjunct2,rule_format,OF \<open>e/4>0\<close>] guess B..note B=conjunctD2[OF this]
       
  6351       show ?case
       
  6352         apply rule
       
  6353         apply rule
       
  6354         apply (rule B)
       
  6355         apply safe
       
  6356       proof -
  6353       proof -
  6357         fix a b :: 'n
  6354         obtain M where M: "\<And>n. n \<ge> M \<Longrightarrow> abs (integral (cbox a b) (?f n) - integral (cbox a b) ?g) < e / 2"
  6358         assume ab: "ball 0 B \<subseteq> cbox a b"
  6355           using \<open>e > 0\<close> g by (fastforce simp add: dest!: LIMSEQ_D [where r = "e/2"])
  6359         from \<open>e > 0\<close> have "e/2 > 0"
  6356         have *: "\<And>\<alpha> \<beta> g. \<lbrakk>\<bar>\<alpha> - i\<bar> < e/2; \<bar>\<beta> - g\<bar> < e/2; \<alpha> \<le> \<beta>; \<beta> \<le> i\<rbrakk> \<Longrightarrow> \<bar>g - i\<bar> < e"
  6360           by auto
       
  6361         from LIMSEQ_D [OF g(2)[of a b] this] guess M..note M=this
       
  6362         have **: "norm (integral (cbox a b) (\<lambda>x. if x \<in> S then f N x else 0) - i) < e/2"
       
  6363         proof (rule norm_triangle_half_l)
       
  6364           show "norm (integral (cbox a b) (\<lambda>x. if x \<in> S then f N x else 0) - integral S (f N))
       
  6365                 < e / 2 / 2"
       
  6366             using B(2)[rule_format,OF ab] by simp
       
  6367           show "norm (i - integral S (f N)) < e / 2 / 2"
       
  6368             using N by (simp add: abs_minus_commute)
       
  6369         qed
       
  6370         have *: "\<And>f1 f2 g. \<bar>f1 - i\<bar> < e/2 \<longrightarrow> \<bar>f2 - g\<bar> < e/2 \<longrightarrow>
       
  6371           f1 \<le> f2 \<longrightarrow> f2 \<le> i \<longrightarrow> \<bar>g - i\<bar> < e"
       
  6372           unfolding real_inner_1_right by arith
  6357           unfolding real_inner_1_right by arith
  6373         show "norm (integral (cbox a b) (\<lambda>x. if x \<in> S then g x else 0) - i) < e"
  6358         show "norm (integral (cbox a b) ?g - i) < e"
  6374           unfolding real_norm_def
  6359           unfolding real_norm_def
  6375           apply (rule *[rule_format])
  6360         proof (rule *)
  6376           apply (rule **[unfolded real_norm_def])
  6361           show "\<bar>integral (cbox a b) (?f N) - i\<bar> < e/2"
  6377           apply (rule M[rule_format,of "M + N",unfolded real_norm_def])
  6362           proof (rule abs_triangle_half_l)
  6378           apply (rule le_add1)
  6363             show "\<bar>integral (cbox a b) (?f N) - integral S (f N)\<bar> < e / 2 / 2"
  6379           apply (rule integral_le[OF int int])
  6364               using B[OF ab] by simp
  6380           defer
  6365             show "abs (i - integral S (f N)) < e / 2 / 2"
  6381            apply (rule order_trans[OF _ i'[rule_format,of "M + N",unfolded real_inner_1_right]])
  6366               using N by (simp add: abs_minus_commute)
  6382         proof (safe, goal_cases)
  6367           qed
  6383           case (2 x)
  6368           show "\<bar>integral (cbox a b) (?f (M + N)) - integral (cbox a b) ?g\<bar> < e / 2"
  6384           have "(f m x)\<bullet>1 \<le> (f n x)\<bullet>1" if "x \<in> S" "n \<ge> m" for m n
  6369             by (metis le_add1 M[of "M + N"])
  6385             apply (rule transitive_stepwise_le [OF \<open>n \<ge> m\<close> order_refl])
  6370           show "integral (cbox a b) (?f N) \<le> integral (cbox a b) (?f (M + N))"
  6386             using dual_order.trans apply blast
  6371           proof (intro ballI integral_le[OF int int])
  6387             by (simp add: le \<open>x \<in> S\<close>)
  6372             fix x assume "x \<in> cbox a b"
  6388           then show ?case
  6373             have "(f m x)\<bullet>1 \<le> (f n x)\<bullet>1" if "x \<in> S" "n \<ge> m" for m n
  6389             by auto
  6374               apply (rule transitive_stepwise_le [OF \<open>n \<ge> m\<close> order_refl])
  6390         next
  6375               using dual_order.trans apply blast
  6391           case 1
  6376               by (simp add: le \<open>x \<in> S\<close>)
       
  6377             then show "(?f N)x \<le> (?f (M+N))x"
       
  6378               by auto
       
  6379           qed
  6392           have "integral (cbox a b \<inter> S) (f (M + N)) \<le> integral S (f (M + N))"
  6380           have "integral (cbox a b \<inter> S) (f (M + N)) \<le> integral S (f (M + N))"
  6393             by (metis Int_lower1 f0 inf_commute int' int_f integral_subset_le)
  6381             by (metis Int_lower1 f0 inf_commute int' int_f integral_subset_le)
  6394           then show ?case
  6382           then have "integral (cbox a b) (?f (M + N)) \<le> integral S (f (M + N))"
  6395             by (simp add: inf_commute integral_restrict_Int)
  6383             by (metis (no_types) inf_commute integral_restrict_Int)
       
  6384           also have "... \<le> i"
       
  6385             using i'[of "M + N"] by auto
       
  6386           finally show "integral (cbox a b) (?f (M + N)) \<le> i" .
  6396         qed
  6387         qed
  6397       qed
  6388       qed
       
  6389       then show ?thesis
       
  6390         using \<open>0 < B\<close> by blast
  6398     qed
  6391     qed
       
  6392     ultimately have "(g has_integral i) S"
       
  6393       unfolding has_integral_alt' by auto
  6399     then show ?thesis
  6394     then show ?thesis
  6400       using has_integral_integrable_integral i integral_unique by metis
  6395       using has_integral_integrable_integral i integral_unique by metis
  6401   qed
  6396   qed
  6402 
  6397 
  6403   have sub: "\<And>k. integral S (\<lambda>x. f k x - f 0 x) = integral S (f k) - integral S (f 0)"
  6398   have sub: "\<And>k. integral S (\<lambda>x. f k x - f 0 x) = integral S (f k) - integral S (f 0)"
  6404     by (simp add: integral_diff assms(1))
  6399     by (simp add: integral_diff int_f)
  6405   have *: "\<And>x m n. x \<in> S \<Longrightarrow> n\<ge>m \<Longrightarrow> f m x \<le> f n x"
  6400   have *: "\<And>x m n. x \<in> S \<Longrightarrow> n\<ge>m \<Longrightarrow> f m x \<le> f n x"
  6406     using assms(2) by (force intro: transitive_stepwise_le)
  6401     using assms(2) by (force intro: transitive_stepwise_le)
  6407   have "(\<lambda>x. g x - f 0 x) integrable_on S \<and> ((\<lambda>k. integral S (\<lambda>x. f (Suc k) x - f 0 x)) \<longlongrightarrow>
  6402   have gf: "(\<lambda>x. g x - f 0 x) integrable_on S \<and> ((\<lambda>k. integral S (\<lambda>x. f (Suc k) x - f 0 x)) \<longlongrightarrow>
  6408     integral S (\<lambda>x. g x - f 0 x)) sequentially"
  6403     integral S (\<lambda>x. g x - f 0 x)) sequentially"
  6409     apply (rule lem)
  6404   proof (rule lem)
  6410     apply safe
  6405     show "\<And>k. (\<lambda>x. f (Suc k) x - f 0 x) integrable_on S"
  6411   proof goal_cases
  6406       by (simp add: integrable_diff int_f)
  6412     case (1 k x)
  6407     show "(\<lambda>k. f (Suc k) x - f 0 x) \<longlonglongrightarrow> g x - f 0 x" if "x \<in> S" for x
  6413     then show ?case
  6408     proof -
  6414       using *[of x 0 "Suc k"] by auto
  6409       have "(\<lambda>n. f (Suc n) x) \<longlonglongrightarrow> g x"
  6415   next
  6410         using LIMSEQ_ignore_initial_segment[OF fg[OF \<open>x \<in> S\<close>], of 1] by simp
  6416     case (2 k)
  6411       then show ?thesis
  6417     then show ?case
  6412         by (simp add: tendsto_diff)
  6418       by (simp add: integrable_diff assms(1))
  6413     qed
  6419   next
  6414     show "bounded (range (\<lambda>k. integral S (\<lambda>x. f (Suc k) x - f 0 x)))"
  6420     case (3 k x)
  6415     proof -
  6421     then show ?case
  6416       obtain B where B: "\<And>k. norm (integral S (f k)) \<le> B"
  6422       using *[of x "Suc k" "Suc (Suc k)"] by auto
  6417         using  bou by (auto simp: bounded_iff)
  6423   next
  6418       then have "norm (integral S (\<lambda>x. f (Suc k) x - f 0 x))
  6424     case (4 x)
  6419               \<le> B + norm (integral S (f 0))" for k
  6425     then show ?case
  6420         unfolding sub by (meson add_le_cancel_right norm_triangle_le_diff)
  6426       apply -
  6421       then show ?thesis
  6427       apply (rule tendsto_diff)
  6422         unfolding bounded_iff by blast
  6428       using LIMSEQ_ignore_initial_segment[OF assms(3)[rule_format],of x 1]
  6423     qed
  6429       apply auto
  6424   qed (use * in auto)
  6430       done
  6425   then have "(\<lambda>x. integral S (\<lambda>xa. f (Suc x) xa - f 0 xa) + integral S (f 0))
  6431   next
  6426              \<longlonglongrightarrow> integral S (\<lambda>x. g x - f 0 x) + integral S (f 0)"
  6432     case 5
  6427     by (auto simp add: tendsto_add)
  6433     then show ?case
  6428   moreover have "(\<lambda>x. g x - f 0 x + f 0 x) integrable_on S"
  6434       using assms(4)
  6429     using gf integrable_add int_f [of 0] by metis
  6435       unfolding bounded_iff
  6430   ultimately show ?thesis
  6436       apply safe
  6431     by (simp add: integral_diff int_f LIMSEQ_imp_Suc sub)
  6437       apply (rule_tac x="a + norm (integral S (\<lambda>x. f 0 x))" in exI)
       
  6438       apply safe
       
  6439       apply (erule_tac x="integral S (\<lambda>x. f (Suc k) x)" in ballE)
       
  6440       unfolding sub
       
  6441       apply (rule order_trans[OF norm_triangle_ineq4])
       
  6442       apply auto
       
  6443       done
       
  6444   qed
       
  6445   note conjunctD2[OF this]
       
  6446   note tendsto_add[OF this(2) tendsto_const[of "integral S (f 0)"]]
       
  6447     integrable_add[OF this(1) assms(1)[rule_format,of 0]]
       
  6448   then show ?thesis
       
  6449     by (simp add: integral_diff assms(1) LIMSEQ_imp_Suc sub)
       
  6450 qed
  6432 qed
  6451 
  6433 
  6452 lemma has_integral_monotone_convergence_increasing:
  6434 lemma has_integral_monotone_convergence_increasing:
  6453   fixes f :: "nat \<Rightarrow> 'a::euclidean_space \<Rightarrow> real"
  6435   fixes f :: "nat \<Rightarrow> 'a::euclidean_space \<Rightarrow> real"
  6454   assumes f: "\<And>k. (f k has_integral x k) s"
  6436   assumes f: "\<And>k. (f k has_integral x k) s"
  6577     assume "e > 0"
  6559     assume "e > 0"
  6578     then have e: "e/2 > 0"
  6560     then have e: "e/2 > 0"
  6579       by auto
  6561       by auto
  6580     let ?f = "(\<lambda>x. if x \<in> S then f x else 0)"
  6562     let ?f = "(\<lambda>x. if x \<in> S then f x else 0)"
  6581     let ?g = "(\<lambda>x. if x \<in> S then g x else 0)"
  6563     let ?g = "(\<lambda>x. if x \<in> S then g x else 0)"
  6582     have f: "?f integrable_on cbox a b" and g: "?g integrable_on cbox a b"
  6564     have f: "?f integrable_on cbox a b" and g: "?g integrable_on cbox a b" for a b
  6583       for a b
       
  6584       using int_f int_g integrable_altD by auto
  6565       using int_f int_g integrable_altD by auto
  6585     obtain Bf where "0 < Bf"
  6566     obtain Bf where "0 < Bf"
  6586       and Bf: "\<And>a b. ball 0 Bf \<subseteq> cbox a b \<Longrightarrow>
  6567       and Bf: "\<And>a b. ball 0 Bf \<subseteq> cbox a b \<Longrightarrow>
  6587         \<exists>z. (?f has_integral z) (cbox a b) \<and> norm (z - integral S f) < e/2"
  6568         \<exists>z. (?f has_integral z) (cbox a b) \<and> norm (z - integral S f) < e/2"
  6588       using integrable_integral [OF int_f,unfolded has_integral'[of f]] e that by blast
  6569       using integrable_integral [OF int_f,unfolded has_integral'[of f]] e that by blast
  6589     obtain Bg where "0 < Bg"
  6570     obtain Bg where "0 < Bg"
  6590       and Bg: "\<And>a b. ball 0 Bg \<subseteq> cbox a b \<Longrightarrow>
  6571       and Bg: "\<And>a b. ball 0 Bg \<subseteq> cbox a b \<Longrightarrow>
  6591         \<exists>z. (?g has_integral z) (cbox a b) \<and>
  6572         \<exists>z. (?g has_integral z) (cbox a b) \<and> norm (z - integral S g) < e/2"
  6592             norm (z - integral S g) < e/2"
       
  6593       using integrable_integral [OF int_g,unfolded has_integral'[of g]] e that by blast
  6573       using integrable_integral [OF int_g,unfolded has_integral'[of g]] e that by blast
  6594     obtain a b::'n where ab: "ball 0 Bf \<union> ball 0 Bg \<subseteq> cbox a b"
  6574     obtain a b::'n where ab: "ball 0 Bf \<union> ball 0 Bg \<subseteq> cbox a b"
  6595       using ball_max_Un bounded_subset_cbox[OF bounded_ball, of _ "max Bf Bg"] by blast
  6575       using ball_max_Un bounded_subset_cbox[OF bounded_ball, of _ "max Bf Bg"] by blast
  6596     have "ball 0 Bf \<subseteq> cbox a b"
  6576     have "ball 0 Bf \<subseteq> cbox a b"
  6597       using ab by auto
  6577       using ab by auto