# HG changeset patch # User paulson # Date 1503924041 -3600 # Node ID c485474cd91dff8915d6d4a83fb55777bf842865 # Parent 8a6ce2d9a9f54f8862f2a6a6f223d9f6c7c8bc8f Giant cleanup of fundamental_theorem_of_calculus_interior diff -r 8a6ce2d9a9f5 -r c485474cd91d src/HOL/Analysis/Henstock_Kurzweil_Integration.thy --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Mon Aug 28 00:12:07 2017 +0100 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Mon Aug 28 13:40:41 2017 +0100 @@ -3758,7 +3758,7 @@ let ?C = "{t \ p. fst t \ {a, b} \ content (snd t) \ 0}" have "norm (\(x, k)\p \ {t. fst t \ {a, b}}. content k *\<^sub>R f' x - (f (Sup k) - f (Inf k))) \ e * (b-a)/2" proof - - have *: "\s f e. sum f s = sum f (p \ ?C) \ norm (sum f (p \ ?C)) \ e \ norm (sum f s) \ e" + have *: "\S f e. sum f S = sum f (p \ ?C) \ norm (sum f (p \ ?C)) \ e \ norm (sum f S) \ e" by auto have 1: "content K *\<^sub>R (f' x) - (f ((Sup K)) - f ((Inf K))) = 0" if "(x,K) \ p \ {t. fst t \ {a, b}} - p \ ?C" for x K @@ -3774,39 +3774,36 @@ qed have 2: "norm(\(x,K)\p \ ?C. content K *\<^sub>R f' x - (f (Sup K) - f (Inf K))) \ e * (b-a)/2" proof - - have *: "p \ ?C = ?B a \ ?B b" - by blast - have norm_le: "norm (sum f s) \ e" - if "\x y. x \ s \ y \ s \ x = y" "\x. x \ s \ norm (f x) \ e" "e > 0" - for s f and e :: real - proof (cases "s = {}") + have norm_le: "norm (sum f S) \ e" + if "\x y. \x \ S; y \ S\ \ x = y" "\x. x \ S \ norm (f x) \ e" "e > 0" + for S f and e :: real + proof (cases "S = {}") case True with that show ?thesis by auto next - case False then obtain x where "x \ s" + case False then obtain x where "x \ S" by auto - then have "s = {x}" + then have "S = {x}" using that(1) by auto then show ?thesis - using \x \ s\ that(2) by auto + using \x \ S\ that(2) by auto qed - show "norm (\(x,k)\p \ ?C. - content k *\<^sub>R f' x - (f (Sup k) - f (Inf k))) \ e * (b-a)/2" - apply (subst *) + have *: "p \ ?C = ?B a \ ?B b" + by blast + then have "norm (\(x,K)\p \ ?C. content K *\<^sub>R f' x - (f (Sup K) - f (Inf K))) = + norm (\(x,K) \ ?B a \ ?B b. content K *\<^sub>R f' x - (f (Sup K) - f (Inf K)))" + by simp + also have "... = norm ((\(x,K) \ ?B a. content K *\<^sub>R f' x - (f (Sup K) - f (Inf K))) + + (\(x,K) \ ?B b. content K *\<^sub>R f' x - (f (Sup K) - f (Inf K))))" apply (subst sum.union_disjoint) - prefer 4 - apply (rule order_trans[of _ "e * (b-a)/4 + e * (b-a)/4"]) - apply (rule norm_triangle_le,rule add_mono) - apply (rule_tac[1-2] norm_le) - - proof - + using p(1) ab e by auto + also have "... \ e * (b - a) / 4 + e * (b - a) / 4" + proof (rule norm_triangle_le [OF add_mono]) have pa: "\v. k = cbox a v \ a \ v" if "(a, k) \ p" for k using p(2) p(3) p(4) that by fastforce - have pb: "\v. k = cbox v b \ b \ v" if "(b, k) \ p" for k - using p(2) p(3) p(4) that by fastforce - show "\x y. x \ ?B a \ y \ ?B a \ x = y" - proof (safe; clarsimp) - fix x K K' + show "norm (\(x,K) \ ?B a. content K *\<^sub>R f' x - (f (Sup K) - f (Inf K))) \ e * (b - a) / 4" + proof (intro norm_le; clarsimp) + fix K K' assume K: "(a, K) \ p" "(a, K') \ p" and ne0: "content K \ 0" "content K' \ 0" with pa obtain v v' where v: "K = cbox a v" "a \ v" and v': "K' = cbox a v'" "a \ v'" by blast @@ -3820,14 +3817,31 @@ by (auto simp add: mem_box) ultimately have "(a + ?v)/2 \ interior K \ interior K'" unfolding interior_open[OF open_box] by auto - then have eq: "K = K'" + then show "K = K'" using p(5)[OF K] by auto - then show "x \ K \ x \ K'" "x \ K' \ x \ K" - using eq by auto - qed - show "\x y. x \ ?B b \ y \ ?B b \ x = y" - proof (safe; clarsimp) - fix x K K' + next + fix K + assume K: "(a, K) \ p" and ne0: "content K \ 0" + show "norm (content c *\<^sub>R f' a - (f (Sup c) - f (Inf c))) * 4 \ e * (b-a)" + if "(a, c) \ p" and ne0: "content c \ 0" for c + proof - + obtain v where v: "c = cbox a v" and "a \ v" + using pa[OF \(a, c) \ p\] by metis + then have "a \ {a..v}" "v \ b" + using p(3)[OF \(a, c) \ p\] by auto + moreover have "{a..v} \ ball a da" + using fineD[OF \?d fine p\ \(a, c) \ p\] by (simp add: v split: if_split_asm) + ultimately show ?thesis + unfolding v interval_bounds_real[OF \a \ v\] box_real + using da \a \ v\ by auto + qed + qed (use ab e in auto) + next + have pb: "\v. k = cbox v b \ b \ v" if "(b, k) \ p" for k + using p(2) p(3) p(4) that by fastforce + show "norm (\(x,K) \ ?B b. content K *\<^sub>R f' x - (f (Sup K) - f (Inf K))) \ e * (b - a) / 4" + proof (intro norm_le; clarsimp) + fix K K' assume K: "(b, K) \ p" "(b, K') \ p" and ne0: "content K \ 0" "content K' \ 0" with pb obtain v v' where v: "K = cbox v b" "v \ b" and v': "K' = cbox v' b" "v' \ b" by blast @@ -3840,31 +3854,14 @@ using ne0 unfolding v v' content_eq_0 not_le by (auto simp: mem_box) ultimately have "((b + ?v)/2) \ interior K \ interior K'" unfolding interior_open[OF open_box] by auto - then have eq: "K = K'" + then show "K = K'" using p(5)[OF K] by auto - then show "x \ K \ x \ K'" "x \ K' \ x \ K" - using eq by auto - qed - have "norm (content c *\<^sub>R f' a - (f (Sup c) - f (Inf c))) \ e * (b-a) / 4" - if "(a, c) \ p" and ne0: "content c \ 0" for c - proof - - obtain v where v: "c = cbox a v" and "a \ v" - using pa[OF \(a, c) \ p\] by metis - then have "a \ {a..v}" "v \ b" - using p(3)[OF \(a, c) \ p\] by auto - moreover have "{a..v} \ ball a da" - using fineD[OF \?d fine p\ \(a, c) \ p\] by (simp add: v split: if_split_asm) - ultimately show ?thesis - unfolding v interval_bounds_real[OF \a \ v\] box_real - using da \a \ v\ by auto - qed - then show "\x. x \ ?B a \ norm ((\(x, k). content k *\<^sub>R f' x - (f (Sup k) - - f (Inf k))) x) \ e * (b-a) / 4" - by auto - - have "norm (content c *\<^sub>R f' b - (f (Sup c) - f (Inf c))) \ e * (b-a) / 4" - if "(b, c) \ p" and ne0: "content c \ 0" for c - proof - + next + fix K + assume K: "(b, K) \ p" and ne0: "content K \ 0" + show "norm (content c *\<^sub>R f' b - (f (Sup c) - f (Inf c))) * 4 \ e * (b-a)" + if "(b, c) \ p" and ne0: "content c \ 0" for c + proof - obtain v where v: "c = cbox v b" and "v \ b" using \(b, c) \ p\ pb by blast then have "v \ a""b \ {v.. b}" @@ -3873,12 +3870,13 @@ using fineD[OF \?d fine p\ \(b, c) \ p\] box_real(2) v False by force ultimately show ?thesis using db v by auto - qed - then show "\x. x \ ?B b \ - norm ((\(x, k). content k *\<^sub>R f' x - (f (Sup k) - f (Inf k))) x) - \ e * (b-a) / 4" - by auto - qed (insert p(1) ab e, auto simp add: field_simps) + qed + qed (use ab e in auto) + qed + also have "... = e * (b-a)/2" + by simp + finally show "norm (\(x,k)\p \ ?C. + content k *\<^sub>R f' x - (f (Sup k) - f (Inf k))) \ e * (b-a)/2" . qed show "norm (\(x, k)\p \ ?A. content k *\<^sub>R f' x - (f ((Sup k)) - f ((Inf k)))) \ e * (b-a)/2" apply (rule * [OF sum.mono_neutral_right[OF pA(2)]]) @@ -4006,109 +4004,101 @@ by (meson gauge_def open_contains_ball) let ?d = "min k (c - a)/2" - show ?thesis + show thesis proof (intro that[of ?d] allI impI, safe) show "?d > 0" - using \0 < k\ using assms(2) by auto + using \0 < k\ \a < c\ by auto + next fix t - assume as: "c - ?d < t" "t \ c" - let ?thesis = "norm (integral ({a..c}) f - integral ({a..t}) f) < e" - { - presume *: "t < c \ ?thesis" - show ?thesis - proof (cases "t = c") - case True - then show ?thesis - by (simp add: \e > 0\) + assume t: "c - ?d < t" "t \ c" + show "norm (integral ({a..c}) f - integral ({a..t}) f) < e" + proof (cases "t < c") + case False with \t \ c\ show ?thesis + by (simp add: \e > 0\) + next + case True + have "f integrable_on {a..t}" + apply (rule integrable_subinterval_real[OF intf]) + using \t < c\ \c \ b\ by auto + then obtain d2 where d2: "gauge d2" + "\p. p tagged_division_of {a..t} \ d2 fine p \ norm (?SUM p - integral {a..t} f) < e/3" + using integrable_integral has_integral_real e3 by metis + define d3 where "d3 x = (if x \ t then d1 x \ d2 x else d1 x)" for x + have "gauge d3" + using \gauge d1\ \gauge d2\ unfolding d3_def gauge_def by auto + then obtain p where ptag: "p tagged_division_of {a..t}" and pfine: "d3 fine p" + by (metis box_real(2) fine_division_exists) + note p' = tagged_division_ofD[OF ptag] + have pt: "(x,K)\p \ x \ t" for x K + by (meson atLeastAtMost_iff p'(2) p'(3) subsetCE) + with pfine have "d2 fine p" + unfolding fine_def d3_def by fastforce + then have d2_fin: "norm (?SUM p - integral {a..t} f) < e/3" + using d2(2) ptag by auto + have eqs: "{a..c} \ {x. x \ t} = {a..t}" "{a..c} \ {x. x \ t} = {t..c}" + using t by (auto simp add: field_simps) + have "p \ {(c, {t..c})} tagged_division_of {a..c}" + apply (rule tagged_division_Un_interval_real[of _ _ _ 1 "t"]) + using \t \ c\ by (auto simp: eqs ptag tagged_division_of_self_real) + moreover + have "d1 fine p \ {(c, {t..c})}" + unfolding fine_def + proof safe + fix x K y + assume "(x,K) \ p" and "y \ K" then show "y \ d1 x" + by (metis Int_iff d3_def subsetD fineD pfine) next - case False - then show ?thesis - using "*" \t \ c\ by linarith + fix x assume "x \ {t..c}" + then have "dist c x < k" + using t(1) by (auto simp add: field_simps dist_real_def) + with k show "x \ d1 c" + unfolding d_def by auto + qed + ultimately have d1_fin: "norm (?SUM(p \ {(c, {t..c})}) - integral {a..c} f) < e/3" + using d1 by metis + have SUMEQ: "?SUM(p \ {(c, {t..c})}) = (c - t) *\<^sub>R f c + ?SUM p" + proof - + have "?SUM(p \ {(c, {t..c})}) = (content{t..c} *\<^sub>R f c) + ?SUM p" + proof (subst sum.union_disjoint) + show "p \ {(c, {t..c})} = {}" + using \t < c\ pt by force + qed (use p'(1) in auto) + also have "... = (c - t) *\<^sub>R f c + ?SUM p" + using \t \ c\ by auto + finally show ?thesis . qed - } - assume "t < c" - - have "f integrable_on {a..t}" - apply (rule integrable_subinterval_real[OF intf]) - using \t < c\ \c \ b\ by auto - then obtain d2 where d2: "gauge d2" - "\p. p tagged_division_of {a..t} \ d2 fine p \ norm (?SUM p - integral {a..t} f) < e/3" - using integrable_integral has_integral_real e3 by metis - define d3 where "d3 x = (if x \ t then d1 x \ d2 x else d1 x)" for x - have "gauge d3" - using \gauge d1\ \gauge d2\ unfolding d3_def gauge_def by auto - then obtain p where ptag: "p tagged_division_of {a..t}" and pfine: "d3 fine p" - by (metis box_real(2) fine_division_exists) - note p'=tagged_division_ofD[OF ptag] - have pt: "(x,k)\p \ x \ t" for x k - by (meson atLeastAtMost_iff p'(2) p'(3) subsetCE) - with pfine have "d2 fine p" - unfolding fine_def d3_def by fastforce - then have d2_fin: "norm (?SUM p - integral {a..t} f) < e/3" - using d2(2) ptag by auto - have eqs: "{a..c} \ {x. x \ t} = {a..t}" "{a..c} \ {x. x \ t} = {t..c}" - using as by (auto simp add: field_simps) - have "p \ {(c, {t..c})} tagged_division_of {a..c}" - apply (rule tagged_division_Un_interval_real[of _ _ _ 1 "t"]) - using \t \ c\ by (auto simp: eqs ptag tagged_division_of_self_real) - moreover - have "d1 fine p \ {(c, {t..c})}" - unfolding fine_def - proof safe - fix x K y - assume "(x,K) \ p" and "y \ K" then show "y \ d1 x" - by (metis Int_iff d3_def subsetD fineD pfine) - next - fix x assume "x \ {t..c}" - then have "dist c x < k" - using as(1) by (auto simp add: field_simps dist_real_def) - with k show "x \ d1 c" - unfolding d_def by auto - qed - ultimately have d1_fin: "norm (?SUM(p \ {(c, {t..c})}) - integral {a..c} f) < e/3" - using d1 by metis - have 1: "integral {a..c} f - integral {a..t} f = -(((c - t) *\<^sub>R f c + ?SUM p) - + have "c - k < t" + using \k>0\ t(1) by (auto simp add: field_simps) + moreover have "k \ w" + proof (rule ccontr) + assume "\ k \ w" + then have "c + (k + w) / 2 \ d c" + by (auto simp add: field_simps not_le not_less dist_real_def d_def) + then have "c + (k + w) / 2 \ ball c k" + using k by blast + then show False + using \0 < w\ \\ k \ w\ dist_real_def by auto + qed + ultimately have cwt: "c - w < t" + by (auto simp add: field_simps) + have eq: "integral {a..c} f - integral {a..t} f = -(((c - t) *\<^sub>R f c + ?SUM p) - integral {a..c} f) + (?SUM p - integral {a..t} f) + (c - t) *\<^sub>R f c" - and 2: "e = (e/3 + e/3) + e/3" - by auto - have **: "?SUM(p \ {(c, {t..c})}) = (c - t) *\<^sub>R f c + ?SUM p" - proof - - have "?SUM(p \ {(c, {t..c})}) = (content{t..c} *\<^sub>R f c) + ?SUM p" - proof (subst sum.union_disjoint) - show "p \ {(c, {t..c})} = {}" - using \t < c\ pt by force - qed (use p'(1) in auto) - also have "... = (c - t) *\<^sub>R f c + ?SUM p" - using \t \ c\ by auto - finally show ?thesis . + by auto + have "norm (integral {a..c} f - integral {a..t} f) < e/3 + e/3 + e/3" + unfolding eq + proof (intro norm_triangle_lt add_strict_mono) + show "norm (- ((c - t) *\<^sub>R f c + ?SUM p - integral {a..c} f)) < e/3" + by (metis SUMEQ d1_fin norm_minus_cancel) + show "norm (?SUM p - integral {a..t} f) < e/3" + using d2_fin by blast + show "norm ((c - t) *\<^sub>R f c) < e/3" + using w cwt \t < c\ by (auto simp add: field_simps) + qed + then show ?thesis by simp qed - have "c - k < t" - using \k>0\ as(1) by (auto simp add: field_simps) - moreover have "k \ w" - proof (rule ccontr) - assume "\ k \ w" - then have "c + (k + w) / 2 \ d c" - by (auto simp add: field_simps not_le not_less dist_real_def d_def) - then have "c + (k + w) / 2 \ ball c k" - using k by blast - then show False - using \0 < w\ \\ k \ w\ dist_real_def by auto - qed - ultimately have cwt: "c - w < t" - by (auto simp add: field_simps) - show ?thesis - unfolding 1 - apply (subst 2) - apply (rule norm_triangle_lt add_strict_mono)+ - apply (metis "**" d1_fin norm_minus_cancel) - using d2_fin apply blast - using w cwt \t < c\ - apply (auto simp add: field_simps) - done qed qed - lemma indefinite_integral_continuous_right: fixes f :: "real \ 'a::banach" assumes "f integrable_on {a..b}"