546 by (drule_tac c="-1" in has_integral_cmul) auto |
546 by (drule_tac c="-1" in has_integral_cmul) auto |
547 |
547 |
548 lemma has_integral_neg_iff: "((\<lambda>x. - f x) has_integral k) S \<longleftrightarrow> (f has_integral - k) S" |
548 lemma has_integral_neg_iff: "((\<lambda>x. - f x) has_integral k) S \<longleftrightarrow> (f has_integral - k) S" |
549 using has_integral_neg[of f "- k"] has_integral_neg[of "\<lambda>x. - f x" k] by auto |
549 using has_integral_neg[of f "- k"] has_integral_neg[of "\<lambda>x. - f x" k] by auto |
550 |
550 |
|
551 lemma has_integral_add_cbox: |
|
552 fixes f :: "'n::euclidean_space \<Rightarrow> 'a::real_normed_vector" |
|
553 assumes "(f has_integral k) (cbox a b)" "(g has_integral l) (cbox a b)" |
|
554 shows "((\<lambda>x. f x + g x) has_integral (k + l)) (cbox a b)" |
|
555 using assms |
|
556 unfolding has_integral_cbox |
|
557 by (simp add: split_beta' scaleR_add_right sum.distrib[abs_def] tendsto_add) |
|
558 |
551 lemma has_integral_add: |
559 lemma has_integral_add: |
552 fixes f :: "'n::euclidean_space \<Rightarrow> 'a::real_normed_vector" |
560 fixes f :: "'n::euclidean_space \<Rightarrow> 'a::real_normed_vector" |
553 assumes "(f has_integral k) S" |
561 assumes f: "(f has_integral k) S" and g: "(g has_integral l) S" |
554 and "(g has_integral l) S" |
|
555 shows "((\<lambda>x. f x + g x) has_integral (k + l)) S" |
562 shows "((\<lambda>x. f x + g x) has_integral (k + l)) S" |
556 proof - |
563 proof (cases "\<exists>a b. S = cbox a b") |
557 have lem: "(f has_integral k) (cbox a b) \<Longrightarrow> (g has_integral l) (cbox a b) \<Longrightarrow> |
564 case True with has_integral_add_cbox assms show ?thesis |
558 ((\<lambda>x. f x + g x) has_integral (k + l)) (cbox a b)" |
565 by blast |
559 for f :: "'n \<Rightarrow> 'a" and g a b k l |
566 next |
560 unfolding has_integral_cbox |
567 let ?S = "\<lambda>f x. if x \<in> S then f x else 0" |
561 by (simp add: split_beta' scaleR_add_right sum.distrib[abs_def] tendsto_add) |
568 case False |
562 { |
|
563 presume "\<not> (\<exists>a b. S = cbox a b) \<Longrightarrow> ?thesis" |
|
564 then show ?thesis |
|
565 using assms lem by force |
|
566 } |
|
567 assume nonbox: "\<not> (\<exists>a b. S = cbox a b)" |
|
568 then show ?thesis |
569 then show ?thesis |
569 proof (subst has_integral_alt, clarsimp, goal_cases) |
570 proof (subst has_integral_alt, clarsimp, goal_cases) |
570 case (1 e) |
571 case (1 e) |
571 then have *: "e/2 > 0" |
572 then have e2: "e/2 > 0" |
572 by auto |
573 by auto |
573 from has_integral_altD[OF assms(1) nonbox *] |
574 obtain Bf where "0 < Bf" |
574 obtain B1 where B1: |
575 and Bf: "\<And>a b. ball 0 Bf \<subseteq> cbox a b \<Longrightarrow> |
575 "0 < B1" |
576 \<exists>z. (?S f has_integral z) (cbox a b) \<and> norm (z - k) < e/2" |
576 "\<And>a b. ball 0 B1 \<subseteq> cbox a b \<Longrightarrow> |
577 using has_integral_altD[OF f False e2] by blast |
577 \<exists>z. ((\<lambda>x. if x \<in> S then f x else 0) has_integral z) (cbox a b) \<and> norm (z - k) < e/2" |
578 obtain Bg where "0 < Bg" |
578 by blast |
579 and Bg: "\<And>a b. ball 0 Bg \<subseteq> (cbox a b) \<Longrightarrow> |
579 from has_integral_altD[OF assms(2) nonbox *] |
580 \<exists>z. (?S g has_integral z) (cbox a b) \<and> norm (z - l) < e/2" |
580 obtain B2 where B2: |
581 using has_integral_altD[OF g False e2] by blast |
581 "0 < B2" |
|
582 "\<And>a b. ball 0 B2 \<subseteq> (cbox a b) \<Longrightarrow> |
|
583 \<exists>z. ((\<lambda>x. if x \<in> S then g x else 0) has_integral z) (cbox a b) \<and> norm (z - l) < e/2" |
|
584 by blast |
|
585 show ?case |
582 show ?case |
586 proof (rule_tac x="max B1 B2" in exI, clarsimp simp add: max.strict_coboundedI1 B1) |
583 proof (rule_tac x="max Bf Bg" in exI, clarsimp simp add: max.strict_coboundedI1 \<open>0 < Bf\<close>) |
587 fix a b |
584 fix a b |
588 assume "ball 0 (max B1 B2) \<subseteq> cbox a (b::'n)" |
585 assume "ball 0 (max Bf Bg) \<subseteq> cbox a (b::'n)" |
589 then have *: "ball 0 B1 \<subseteq> cbox a (b::'n)" "ball 0 B2 \<subseteq> cbox a (b::'n)" |
586 then have fs: "ball 0 Bf \<subseteq> cbox a (b::'n)" and gs: "ball 0 Bg \<subseteq> cbox a (b::'n)" |
590 by auto |
587 by auto |
591 obtain w where w: |
588 obtain w where w: "(?S f has_integral w) (cbox a b)" "norm (w - k) < e/2" |
592 "((\<lambda>x. if x \<in> S then f x else 0) has_integral w) (cbox a b)" |
589 using Bf[OF fs] by blast |
593 "norm (w - k) < e/2" |
590 obtain z where z: "(?S g has_integral z) (cbox a b)" "norm (z - l) < e/2" |
594 using B1(2)[OF *(1)] by blast |
591 using Bg[OF gs] by blast |
595 obtain z where z: |
592 have *: "\<And>x. (if x \<in> S then f x + g x else 0) = (?S f x) + (?S g x)" |
596 "((\<lambda>x. if x \<in> S then g x else 0) has_integral z) (cbox a b)" |
|
597 "norm (z - l) < e/2" |
|
598 using B2(2)[OF *(2)] by blast |
|
599 have *: "\<And>x. (if x \<in> S then f x + g x else 0) = |
|
600 (if x \<in> S then f x else 0) + (if x \<in> S then g x else 0)" |
|
601 by auto |
593 by auto |
602 show "\<exists>z. ((\<lambda>x. if x \<in> S then f x + g x else 0) has_integral z) (cbox a b) \<and> norm (z - (k + l)) < e" |
594 show "\<exists>z. (?S(\<lambda>x. f x + g x) has_integral z) (cbox a b) \<and> norm (z - (k + l)) < e" |
603 apply (rule_tac x="w + z" in exI) |
595 apply (rule_tac x="w + z" in exI) |
604 apply (simp add: lem[OF w(1) z(1), unfolded *[symmetric]]) |
596 apply (simp add: has_integral_add_cbox[OF w(1) z(1), unfolded *[symmetric]]) |
605 using norm_triangle_ineq[of "w - k" "z - l"] w(2) z(2) |
597 using norm_triangle_ineq[of "w - k" "z - l"] w(2) z(2) |
606 apply (auto simp add: field_simps) |
598 apply (auto simp add: field_simps) |
607 done |
599 done |
608 qed |
600 qed |
609 qed |
601 qed |
2875 |
2867 |
2876 subsection \<open>Only need trivial subintervals if the interval itself is trivial.\<close> |
2868 subsection \<open>Only need trivial subintervals if the interval itself is trivial.\<close> |
2877 |
2869 |
2878 lemma division_of_nontrivial: |
2870 lemma division_of_nontrivial: |
2879 fixes s :: "'a::euclidean_space set set" |
2871 fixes s :: "'a::euclidean_space set set" |
2880 assumes "s division_of (cbox a b)" |
2872 assumes s: "s division_of (cbox a b)" |
2881 and "content (cbox a b) \<noteq> 0" |
2873 and "content (cbox a b) \<noteq> 0" |
2882 shows "{k. k \<in> s \<and> content k \<noteq> 0} division_of (cbox a b)" |
2874 shows "{k. k \<in> s \<and> content k \<noteq> 0} division_of (cbox a b)" |
2883 using assms(1) |
2875 using s |
2884 apply - |
2876 proof (induction "card s" arbitrary: s rule: less_induct) |
2885 proof (induct "card s" arbitrary: s rule: nat_less_induct) |
2877 case less |
2886 fix s::"'a set set" |
2878 note s = division_ofD[OF less.prems] |
2887 assume assm: "s division_of (cbox a b)" |
|
2888 "\<forall>m<card s. \<forall>x. m = card x \<longrightarrow> |
|
2889 x division_of (cbox a b) \<longrightarrow> {k \<in> x. content k \<noteq> 0} division_of (cbox a b)" |
|
2890 note s = division_ofD[OF assm(1)] |
|
2891 let ?thesis = "{k \<in> s. content k \<noteq> 0} division_of (cbox a b)" |
|
2892 { |
2879 { |
2893 presume *: "{k \<in> s. content k \<noteq> 0} \<noteq> s \<Longrightarrow> ?thesis" |
2880 presume *: "{k \<in> s. content k \<noteq> 0} \<noteq> s \<Longrightarrow> ?case" |
2894 show ?thesis |
2881 then show ?case |
2895 apply cases |
2882 using less.prems by fastforce |
2896 defer |
|
2897 apply (rule *) |
|
2898 apply assumption |
|
2899 using assm(1) |
|
2900 apply auto |
|
2901 done |
|
2902 } |
2883 } |
2903 assume noteq: "{k \<in> s. content k \<noteq> 0} \<noteq> s" |
2884 assume noteq: "{k \<in> s. content k \<noteq> 0} \<noteq> s" |
2904 then obtain k c d where k: "k \<in> s" "content k = 0" "k = cbox c d" |
2885 then obtain k c d where "k \<in> s" and contk: "content k = 0" and keq: "k = cbox c d" |
2905 using s(4) by blast |
2886 using s(4) by blast |
2906 then have "card s > 0" |
2887 then have "card s > 0" |
2907 unfolding card_gt_0_iff using assm(1) by auto |
2888 unfolding card_gt_0_iff using less by auto |
2908 then have card: "card (s - {k}) < card s" |
2889 then have card: "card (s - {k}) < card s" |
2909 using assm(1) k(1) |
2890 using less \<open>k \<in> s\<close> by (simp add: s(1)) |
2910 apply (subst card_Diff_singleton_if) |
2891 have closed: "closed (\<Union>(s - {k}))" |
2911 apply auto |
2892 using less.prems by auto |
2912 done |
|
2913 have *: "closed (\<Union>(s - {k}))" |
|
2914 apply (rule closed_Union) |
|
2915 defer |
|
2916 apply rule |
|
2917 apply (drule DiffD1,drule s(4)) |
|
2918 using assm(1) |
|
2919 apply auto |
|
2920 done |
|
2921 have "k \<subseteq> \<Union>(s - {k})" |
2893 have "k \<subseteq> \<Union>(s - {k})" |
2922 apply safe |
2894 apply safe |
2923 apply (rule *[unfolded closed_limpt,rule_format]) |
2895 apply (rule closed[unfolded closed_limpt,rule_format]) |
2924 unfolding islimpt_approachable |
2896 unfolding islimpt_approachable |
2925 proof safe |
2897 proof safe |
2926 fix x |
2898 fix x and e :: real |
2927 fix e :: real |
2899 assume "x \<in> k" "e > 0" |
2928 assume as: "x \<in> k" "e > 0" |
|
2929 obtain i where i: "c\<bullet>i = d\<bullet>i" "i\<in>Basis" |
2900 obtain i where i: "c\<bullet>i = d\<bullet>i" "i\<in>Basis" |
2930 using k(2) s(3)[OF k(1)] unfolding box_ne_empty k |
2901 using contk s(3) [OF \<open>k \<in> s\<close>] unfolding box_ne_empty keq |
2931 by (metis dual_order.antisym content_eq_0) |
2902 by (meson content_eq_0 dual_order.antisym) |
2932 then have xi: "x\<bullet>i = d\<bullet>i" |
2903 then have xi: "x\<bullet>i = d\<bullet>i" |
2933 using as unfolding k mem_box by (metis antisym) |
2904 using \<open>x \<in> k\<close> unfolding keq mem_box by (metis antisym) |
2934 define y where "y = (\<Sum>j\<in>Basis. (if j = i then if c\<bullet>i \<le> (a\<bullet>i + b\<bullet>i) / 2 then c\<bullet>i + |
2905 define y where "y = (\<Sum>j\<in>Basis. (if j = i then if c\<bullet>i \<le> (a\<bullet>i + b\<bullet>i) / 2 then c\<bullet>i + |
2935 min e (b\<bullet>i - c\<bullet>i) / 2 else c\<bullet>i - min e (c\<bullet>i - a\<bullet>i) / 2 else x\<bullet>j) *\<^sub>R j)" |
2906 min e (b\<bullet>i - c\<bullet>i) / 2 else c\<bullet>i - min e (c\<bullet>i - a\<bullet>i) / 2 else x\<bullet>j) *\<^sub>R j)" |
2936 show "\<exists>x'\<in>\<Union>(s - {k}). x' \<noteq> x \<and> dist x' x < e" |
2907 show "\<exists>x'\<in>\<Union>(s - {k}). x' \<noteq> x \<and> dist x' x < e" |
2937 apply (rule_tac x=y in bexI) |
2908 apply (rule_tac x=y in bexI) |
2938 proof |
2909 proof |
2939 have "d \<in> cbox c d" |
2910 have "d \<in> cbox c d" |
2940 using s(3)[OF k(1)] |
2911 using s(3)[OF \<open>k \<in> s\<close>] by (simp add: box_ne_empty(1) keq mem_box(2)) |
2941 unfolding k box_eq_empty mem_box |
|
2942 by (fastforce simp add: not_less) |
|
2943 then have "d \<in> cbox a b" |
2912 then have "d \<in> cbox a b" |
2944 using s(2)[OF k(1)] |
2913 using s(2)[OF \<open>k \<in> s\<close>] |
2945 unfolding k |
2914 unfolding keq |
2946 by auto |
2915 by auto |
2947 note di = this[unfolded mem_box,THEN bspec[where x=i]] |
2916 note di = this[unfolded mem_box,THEN bspec[where x=i]] |
2948 then have xyi: "y\<bullet>i \<noteq> x\<bullet>i" |
2917 then have xyi: "y\<bullet>i \<noteq> x\<bullet>i" |
2949 unfolding y_def i xi |
2918 unfolding y_def i xi |
2950 using as(2) assms(2)[unfolded content_eq_0] i(2) |
2919 using \<open>e > 0\<close> assms(2)[unfolded content_eq_0] i(2) |
2951 by (auto elim!: ballE[of _ _ i]) |
2920 by (auto elim!: ballE[of _ _ i]) |
2952 then show "y \<noteq> x" |
2921 then show "y \<noteq> x" |
2953 unfolding euclidean_eq_iff[where 'a='a] using i by auto |
2922 unfolding euclidean_eq_iff[where 'a='a] using i by auto |
2954 have *: "Basis = insert i (Basis - {i})" |
2923 have "norm (y-x) \<le> (\<Sum>b\<in>Basis. \<bar>(y - x) \<bullet> b\<bar>)" |
2955 using i by auto |
2924 by (rule norm_le_l1) |
2956 have "norm (y-x) < e + sum (\<lambda>i. 0) Basis" |
2925 also have "... = \<bar>(y - x) \<bullet> i\<bar> + (\<Sum>b \<in> Basis - {i}. \<bar>(y - x) \<bullet> b\<bar>)" |
2957 apply (rule le_less_trans[OF norm_le_l1]) |
2926 by (meson finite_Basis i(2) sum.remove) |
2958 apply (subst *) |
2927 also have "... < e + sum (\<lambda>i. 0) Basis" |
2959 apply (subst sum.insert) |
2928 proof (rule add_less_le_mono) |
2960 prefer 3 |
|
2961 apply (rule add_less_le_mono) |
|
2962 proof - |
|
2963 show "\<bar>(y-x) \<bullet> i\<bar> < e" |
2929 show "\<bar>(y-x) \<bullet> i\<bar> < e" |
2964 using di as(2) y_def i xi by (auto simp: inner_simps) |
2930 using di \<open>e > 0\<close> y_def i xi by (auto simp: inner_simps) |
2965 show "(\<Sum>i\<in>Basis - {i}. \<bar>(y-x) \<bullet> i\<bar>) \<le> (\<Sum>i\<in>Basis. 0)" |
2931 show "(\<Sum>i\<in>Basis - {i}. \<bar>(y-x) \<bullet> i\<bar>) \<le> (\<Sum>i\<in>Basis. 0)" |
2966 unfolding y_def by (auto simp: inner_simps) |
2932 unfolding y_def by (auto simp: inner_simps) |
2967 qed auto |
2933 qed |
|
2934 finally have "norm (y-x) < e + sum (\<lambda>i. 0) Basis" . |
2968 then show "dist y x < e" |
2935 then show "dist y x < e" |
2969 unfolding dist_norm by auto |
2936 unfolding dist_norm by auto |
2970 have "y \<notin> k" |
2937 have "y \<notin> k" |
2971 unfolding k mem_box |
2938 unfolding keq mem_box using i(1) i(2) xi xyi by fastforce |
2972 apply rule |
|
2973 apply (erule_tac x=i in ballE) |
|
2974 using xyi k i xi |
|
2975 apply auto |
|
2976 done |
|
2977 moreover |
2939 moreover |
2978 have "y \<in> \<Union>s" |
2940 have "y \<in> \<Union>s" |
2979 using set_rev_mp[OF as(1) s(2)[OF k(1)]] as(2) di i |
2941 using subsetD[OF s(2)[OF \<open>k \<in> s\<close>] \<open>x \<in> k\<close>] \<open>e > 0\<close> di i |
2980 unfolding s mem_box y_def |
2942 unfolding s mem_box y_def |
2981 by (auto simp: field_simps elim!: ballE[of _ _ i]) |
2943 by (auto simp: field_simps elim!: ballE[of _ _ i]) |
2982 ultimately |
2944 ultimately |
2983 show "y \<in> \<Union>(s - {k})" by auto |
2945 show "y \<in> \<Union>(s - {k})" by auto |
2984 qed |
2946 qed |
2985 qed |
2947 qed |
2986 then have "\<Union>(s - {k}) = cbox a b" |
2948 then have "\<Union>(s - {k}) = cbox a b" |
2987 unfolding s(6)[symmetric] by auto |
2949 unfolding s(6)[symmetric] by auto |
2988 then have "{ka \<in> s - {k}. content ka \<noteq> 0} division_of (cbox a b)" |
2950 then have "s - {k} division_of cbox a b" |
2989 apply - |
2951 by (metis Diff_subset less.prems division_of_subset s(6)) |
2990 apply (rule assm(2)[rule_format,OF card refl]) |
2952 then have "{ka \<in> s - {k}. content ka \<noteq> 0} division_of (cbox a b)" |
2991 apply (rule division_ofI) |
2953 using card less.hyps by blast |
2992 defer |
|
2993 apply (rule_tac[1-4] s) |
|
2994 using assm(1) |
|
2995 apply auto |
|
2996 done |
|
2997 moreover |
2954 moreover |
2998 have "{ka \<in> s - {k}. content ka \<noteq> 0} = {k \<in> s. content k \<noteq> 0}" |
2955 have "{ka \<in> s - {k}. content ka \<noteq> 0} = {k \<in> s. content k \<noteq> 0}" |
2999 using k by auto |
2956 using contk by auto |
3000 ultimately show ?thesis by auto |
2957 ultimately show ?case by auto |
3001 qed |
2958 qed |
3002 |
2959 |
3003 |
2960 |
3004 subsection \<open>Integrability on subintervals.\<close> |
2961 subsection \<open>Integrability on subintervals.\<close> |
3005 |
2962 |