src/HOL/Multivariate_Analysis/Integration.thy
changeset 36362 06475a1547cb
parent 36359 e5c785c166b2
child 36365 18bf20d0c2df
equal deleted inserted replaced
36361:1debc8e29f6a 36362:06475a1547cb
   931   by auto
   931   by auto
   932 
   932 
   933 lemma has_integral_vec1: assumes "(f has_integral k) {a..b}"
   933 lemma has_integral_vec1: assumes "(f has_integral k) {a..b}"
   934   shows "((\<lambda>x. vec1 (f x)) has_integral (vec1 k)) {a..b}"
   934   shows "((\<lambda>x. vec1 (f x)) has_integral (vec1 k)) {a..b}"
   935 proof- have *:"\<And>p. (\<Sum>(x, k)\<in>p. content k *\<^sub>R vec1 (f x)) - vec1 k = vec1 ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k)"
   935 proof- have *:"\<And>p. (\<Sum>(x, k)\<in>p. content k *\<^sub>R vec1 (f x)) - vec1 k = vec1 ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k)"
   936     unfolding vec_sub Cart_eq by(auto simp add:vec1_dest_vec1_simps split_beta)
   936     unfolding vec_sub Cart_eq by(auto simp add: split_beta)
   937   show ?thesis using assms unfolding has_integral apply safe
   937   show ?thesis using assms unfolding has_integral apply safe
   938     apply(erule_tac x=e in allE,safe) apply(rule_tac x=d in exI,safe)
   938     apply(erule_tac x=e in allE,safe) apply(rule_tac x=d in exI,safe)
   939     apply(erule_tac x=p in allE,safe) unfolding * norm_vector_1 by auto qed
   939     apply(erule_tac x=p in allE,safe) unfolding * norm_vector_1 by auto qed
   940 
   940 
   941 lemma setsum_content_null:
   941 lemma setsum_content_null:
  1354   shows "\<forall>x\<in>s. f x = g x \<Longrightarrow> f integrable_on s \<Longrightarrow> g integrable_on s"
  1354   shows "\<forall>x\<in>s. f x = g x \<Longrightarrow> f integrable_on s \<Longrightarrow> g integrable_on s"
  1355   unfolding integrable_on_def using has_integral_eq[of s f g] by auto
  1355   unfolding integrable_on_def using has_integral_eq[of s f g] by auto
  1356 
  1356 
  1357 lemma has_integral_eq_eq:
  1357 lemma has_integral_eq_eq:
  1358   shows "\<forall>x\<in>s. f x = g x \<Longrightarrow> ((f has_integral k) s \<longleftrightarrow> (g has_integral k) s)"
  1358   shows "\<forall>x\<in>s. f x = g x \<Longrightarrow> ((f has_integral k) s \<longleftrightarrow> (g has_integral k) s)"
  1359   using has_integral_eq[of s f g] has_integral_eq[of s g f] by auto 
  1359   using has_integral_eq[of s f g] has_integral_eq[of s g f] by rule auto
  1360 
  1360 
  1361 lemma has_integral_null[dest]:
  1361 lemma has_integral_null[dest]:
  1362   assumes "content({a..b}) = 0" shows  "(f has_integral 0) ({a..b})"
  1362   assumes "content({a..b}) = 0" shows  "(f has_integral 0) ({a..b})"
  1363   unfolding has_integral apply(rule,rule,rule_tac x="\<lambda>x. ball x 1" in exI,rule) defer
  1363   unfolding has_integral apply(rule,rule,rule_tac x="\<lambda>x. ball x 1" in exI,rule) defer
  1364 proof(rule,rule,erule conjE) fix e::real assume e:"e>0" thus "gauge (\<lambda>x. ball x 1)" by auto
  1364 proof(rule,rule,erule conjE) fix e::real assume e:"e>0" thus "gauge (\<lambda>x. ball x 1)" by auto
  1651   assumes "p1 tagged_division_of ({a..b} \<inter> {x::real^'n. x$k \<le> (c::real)})"  "p2 tagged_division_of ({a..b} \<inter> {x. x$k \<ge> c})"
  1651   assumes "p1 tagged_division_of ({a..b} \<inter> {x::real^'n. x$k \<le> (c::real)})"  "p2 tagged_division_of ({a..b} \<inter> {x. x$k \<ge> c})"
  1652   shows "(p1 \<union> p2) tagged_division_of ({a..b})"
  1652   shows "(p1 \<union> p2) tagged_division_of ({a..b})"
  1653 proof- have *:"{a..b} = ({a..b} \<inter> {x. x$k \<le> c}) \<union> ({a..b} \<inter> {x. x$k \<ge> c})" by auto
  1653 proof- have *:"{a..b} = ({a..b} \<inter> {x. x$k \<le> c}) \<union> ({a..b} \<inter> {x. x$k \<ge> c})" by auto
  1654   show ?thesis apply(subst *) apply(rule tagged_division_union[OF assms])
  1654   show ?thesis apply(subst *) apply(rule tagged_division_union[OF assms])
  1655     unfolding interval_split interior_closed_interval
  1655     unfolding interval_split interior_closed_interval
  1656     by(auto simp add: vector_less_def Cart_lambda_beta elim!:allE[where x=k]) qed
  1656     by(auto simp add: vector_less_def elim!:allE[where x=k]) qed
  1657 
  1657 
  1658 lemma has_integral_separate_sides: fixes f::"real^'m \<Rightarrow> 'a::real_normed_vector"
  1658 lemma has_integral_separate_sides: fixes f::"real^'m \<Rightarrow> 'a::real_normed_vector"
  1659   assumes "(f has_integral i) ({a..b})" "e>0"
  1659   assumes "(f has_integral i) ({a..b})" "e>0"
  1660   obtains d where "gauge d" "(\<forall>p1 p2. p1 tagged_division_of ({a..b} \<inter> {x. x$k \<le> c}) \<and> d fine p1 \<and>
  1660   obtains d where "gauge d" "(\<forall>p1 p2. p1 tagged_division_of ({a..b} \<inter> {x. x$k \<le> c}) \<and> d fine p1 \<and>
  1661                                 p2 tagged_division_of ({a..b} \<inter> {x. x$k \<ge> c}) \<and> d fine p2
  1661                                 p2 tagged_division_of ({a..b} \<inter> {x. x$k \<ge> c}) \<and> d fine p2
  1741   unfolding operative_def apply(rule property_empty_interval) by auto
  1741   unfolding operative_def apply(rule property_empty_interval) by auto
  1742 
  1742 
  1743 subsection {* Using additivity of lifted function to encode definedness. *}
  1743 subsection {* Using additivity of lifted function to encode definedness. *}
  1744 
  1744 
  1745 lemma forall_option: "(\<forall>x. P x) \<longleftrightarrow> P None \<and> (\<forall>x. P(Some x))"
  1745 lemma forall_option: "(\<forall>x. P x) \<longleftrightarrow> P None \<and> (\<forall>x. P(Some x))"
  1746   by (metis map_of.simps option.nchotomy)
  1746   by (metis option.nchotomy)
  1747 
  1747 
  1748 lemma exists_option:
  1748 lemma exists_option:
  1749  "(\<exists>x. P x) \<longleftrightarrow> P None \<or> (\<exists>x. P(Some x))" 
  1749  "(\<exists>x. P x) \<longleftrightarrow> P None \<or> (\<exists>x. P(Some x))" 
  1750   by (metis map_of.simps option.nchotomy)
  1750   by (metis option.nchotomy)
  1751 
  1751 
  1752 fun lifted where 
  1752 fun lifted where 
  1753   "lifted (opp::'a\<Rightarrow>'a\<Rightarrow>'b) (Some x) (Some y) = Some(opp x y)" |
  1753   "lifted (opp::'a\<Rightarrow>'a\<Rightarrow>'b) (Some x) (Some y) = Some(opp x y)" |
  1754   "lifted opp None _ = (None::'b option)" |
  1754   "lifted opp None _ = (None::'b option)" |
  1755   "lifted opp _ None = None"
  1755   "lifted opp _ None = None"
  1840   apply(rule some_equality) defer apply(erule_tac x=0 in allE) by auto
  1840   apply(rule some_equality) defer apply(erule_tac x=0 in allE) by auto
  1841 
  1841 
  1842 lemma operative_content[intro]: "operative (op +) content"
  1842 lemma operative_content[intro]: "operative (op +) content"
  1843   unfolding operative_def content_split[THEN sym] neutral_add by auto
  1843   unfolding operative_def content_split[THEN sym] neutral_add by auto
  1844 
  1844 
  1845 lemma neutral_monoid[simp]: "neutral ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a) = 0"
  1845 lemma neutral_monoid: "neutral ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a) = 0"
  1846   unfolding neutral_def apply(rule some_equality) defer
  1846   by (rule neutral_add) (* FIXME: duplicate *)
  1847   apply(erule_tac x=0 in allE) by auto
       
  1848 
  1847 
  1849 lemma monoidal_monoid[intro]:
  1848 lemma monoidal_monoid[intro]:
  1850   shows "monoidal ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a)"
  1849   shows "monoidal ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a)"
  1851   unfolding monoidal_def neutral_monoid by(auto simp add: group_simps) 
  1850   unfolding monoidal_def neutral_monoid by(auto simp add: group_simps) 
  1852 
  1851 
  1939     unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab by auto
  1938     unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab by auto
  1940   have "\<exists>x. x \<in> ?D - ?D1" using assms(2-) apply-apply(erule disjE)
  1939   have "\<exists>x. x \<in> ?D - ?D1" using assms(2-) apply-apply(erule disjE)
  1941     apply(rule_tac x="(k,(interval_lowerbound l)$k)" in exI) defer
  1940     apply(rule_tac x="(k,(interval_lowerbound l)$k)" in exI) defer
  1942     apply(rule_tac x="(k,(interval_upperbound l)$k)" in exI)
  1941     apply(rule_tac x="(k,(interval_upperbound l)$k)" in exI)
  1943     unfolding division_points_def unfolding interval_bounds[OF ab]
  1942     unfolding division_points_def unfolding interval_bounds[OF ab]
  1944     apply (auto simp add:interval_bounds) unfolding * by auto
  1943     apply auto unfolding * by auto
  1945   thus "?D1 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4)]) by auto
  1944   thus "?D1 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4)]) by auto
  1946 
  1945 
  1947   have *:"interval_lowerbound ({a..b} \<inter> {x. x $ k \<ge> interval_lowerbound l $ k}) $ k = interval_lowerbound l $ k"
  1946   have *:"interval_lowerbound ({a..b} \<inter> {x. x $ k \<ge> interval_lowerbound l $ k}) $ k = interval_lowerbound l $ k"
  1948          "interval_lowerbound ({a..b} \<inter> {x. x $ k \<ge> interval_upperbound l $ k}) $ k = interval_upperbound l $ k"
  1947          "interval_lowerbound ({a..b} \<inter> {x. x $ k \<ge> interval_upperbound l $ k}) $ k = interval_upperbound l $ k"
  1949     unfolding interval_split apply(subst interval_bounds) prefer 3 apply(subst interval_bounds)
  1948     unfolding interval_split apply(subst interval_bounds) prefer 3 apply(subst interval_bounds)
  1950     unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab by auto
  1949     unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab by auto
  1951   have "\<exists>x. x \<in> ?D - ?D2" using assms(2-) apply-apply(erule disjE)
  1950   have "\<exists>x. x \<in> ?D - ?D2" using assms(2-) apply-apply(erule disjE)
  1952     apply(rule_tac x="(k,(interval_lowerbound l)$k)" in exI) defer
  1951     apply(rule_tac x="(k,(interval_lowerbound l)$k)" in exI) defer
  1953     apply(rule_tac x="(k,(interval_upperbound l)$k)" in exI)
  1952     apply(rule_tac x="(k,(interval_upperbound l)$k)" in exI)
  1954     unfolding division_points_def unfolding interval_bounds[OF ab]
  1953     unfolding division_points_def unfolding interval_bounds[OF ab]
  1955     apply (auto simp add:interval_bounds) unfolding * by auto
  1954     apply auto unfolding * by auto
  1956   thus "?D2 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4)]) by auto qed
  1955   thus "?D2 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4)]) by auto qed
  1957 
  1956 
  1958 subsection {* Preservation by divisions and tagged divisions. *}
  1957 subsection {* Preservation by divisions and tagged divisions. *}
  1959 
  1958 
  1960 lemma support_support[simp]:"support opp f (support opp f s) = support opp f s"
  1959 lemma support_support[simp]:"support opp f (support opp f s) = support opp f s"
  2252 
  2251 
  2253 lemma rsum_component_le: fixes f::"real^'n \<Rightarrow> real^'m"
  2252 lemma rsum_component_le: fixes f::"real^'n \<Rightarrow> real^'m"
  2254   assumes "p tagged_division_of {a..b}"  "\<forall>x\<in>{a..b}. (f x)$i \<le> (g x)$i"
  2253   assumes "p tagged_division_of {a..b}"  "\<forall>x\<in>{a..b}. (f x)$i \<le> (g x)$i"
  2255   shows "(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p)$i \<le> (setsum (\<lambda>(x,k). content k *\<^sub>R g x) p)$i"
  2254   shows "(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p)$i \<le> (setsum (\<lambda>(x,k). content k *\<^sub>R g x) p)$i"
  2256   unfolding setsum_component apply(rule setsum_mono)
  2255   unfolding setsum_component apply(rule setsum_mono)
  2257   apply(rule mp) defer apply assumption apply(induct_tac x,rule) unfolding split_conv
  2256   apply(rule mp) defer apply assumption unfolding split_paired_all apply rule unfolding split_conv
  2258 proof- fix a b assume ab:"(a,b) \<in> p" note assm = tagged_division_ofD(2-4)[OF assms(1) ab]
  2257 proof- fix a b assume ab:"(a,b) \<in> p" note assm = tagged_division_ofD(2-4)[OF assms(1) ab]
  2259   from this(3) guess u v apply-by(erule exE)+ note b=this
  2258   from this(3) guess u v apply-by(erule exE)+ note b=this
  2260   show "(content b *\<^sub>R f a) $ i \<le> (content b *\<^sub>R g a) $ i" unfolding b
  2259   show "(content b *\<^sub>R f a) $ i \<le> (content b *\<^sub>R g a) $ i" unfolding b
  2261     unfolding Cart_nth.scaleR real_scaleR_def apply(rule mult_left_mono)
  2260     unfolding Cart_nth.scaleR real_scaleR_def apply(rule mult_left_mono)
  2262     defer apply(rule content_pos_le,rule assms(2)[rule_format]) using assm by auto qed
  2261     defer apply(rule content_pos_le,rule assms(2)[rule_format]) using assm by auto qed
  2901 lemma additive_tagged_division_1: fixes f::"real^1 \<Rightarrow> 'a::real_normed_vector"
  2900 lemma additive_tagged_division_1: fixes f::"real^1 \<Rightarrow> 'a::real_normed_vector"
  2902   assumes "dest_vec1 a \<le> dest_vec1 b" "p tagged_division_of {a..b}"
  2901   assumes "dest_vec1 a \<le> dest_vec1 b" "p tagged_division_of {a..b}"
  2903   shows "setsum (\<lambda>(x,k). f(interval_upperbound k) - f(interval_lowerbound k)) p = f b - f a"
  2902   shows "setsum (\<lambda>(x,k). f(interval_upperbound k) - f(interval_lowerbound k)) p = f b - f a"
  2904 proof- let ?f = "(\<lambda>k::(real^1) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
  2903 proof- let ?f = "(\<lambda>k::(real^1) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
  2905   have *:"operative op + ?f" unfolding operative_1_lt[OF monoidal_monoid] interval_eq_empty_1
  2904   have *:"operative op + ?f" unfolding operative_1_lt[OF monoidal_monoid] interval_eq_empty_1
  2906     by(auto simp add:not_less interval_bound_1 vector_less_def)
  2905     by(auto simp add:not_less vector_less_def)
  2907   have **:"{a..b} \<noteq> {}" using assms(1) by auto note operative_tagged_division[OF monoidal_monoid * assms(2)]
  2906   have **:"{a..b} \<noteq> {}" using assms(1) by auto note operative_tagged_division[OF monoidal_monoid * assms(2)]
  2908   note * = this[unfolded if_not_P[OF **] interval_bound_1[OF assms(1)],THEN sym ]
  2907   note * = this[unfolded if_not_P[OF **] interval_bound_1[OF assms(1)],THEN sym ]
  2909   show ?thesis unfolding * apply(subst setsum_iterate[THEN sym]) defer
  2908   show ?thesis unfolding * apply(subst setsum_iterate[THEN sym]) defer
  2910     apply(rule setsum_cong2) unfolding split_paired_all split_conv using assms(2) by auto qed
  2909     apply(rule setsum_cong2) unfolding split_paired_all split_conv using assms(2) by auto qed
  2911 
  2910 
  3338   assumes"a \<le> b" "continuous_on {a..b} f" "\<forall>x\<in>{a<..<b}. (f has_vector_derivative f'(x)) (at x)"
  3337   assumes"a \<le> b" "continuous_on {a..b} f" "\<forall>x\<in>{a<..<b}. (f has_vector_derivative f'(x)) (at x)"
  3339   shows "((f' o dest_vec1) has_integral (f b - f a)) {vec a..vec b}"
  3338   shows "((f' o dest_vec1) has_integral (f b - f a)) {vec a..vec b}"
  3340 proof- { presume *:"a < b \<Longrightarrow> ?thesis" 
  3339 proof- { presume *:"a < b \<Longrightarrow> ?thesis" 
  3341     show ?thesis proof(cases,rule *,assumption)
  3340     show ?thesis proof(cases,rule *,assumption)
  3342       assume "\<not> a < b" hence "a = b" using assms(1) by auto
  3341       assume "\<not> a < b" hence "a = b" using assms(1) by auto
  3343       hence *:"{vec a .. vec b} = {vec b}" "f b - f a = 0" apply(auto simp add: Cart_simps) by smt
  3342       hence *:"{vec a .. vec b} = {vec b}" "f b - f a = 0" by(auto simp add: Cart_eq vector_le_def order_antisym)
  3344       show ?thesis unfolding *(2) apply(rule has_integral_null) unfolding content_eq_0_1 using * `a=b` by auto
  3343       show ?thesis unfolding *(2) apply(rule has_integral_null) unfolding content_eq_0_1 using * `a=b` by auto
  3345     qed } assume ab:"a < b"
  3344     qed } assume ab:"a < b"
  3346   let ?P = "\<lambda>e. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {vec1 a..vec1 b} \<and> d fine p \<longrightarrow>
  3345   let ?P = "\<lambda>e. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {vec1 a..vec1 b} \<and> d fine p \<longrightarrow>
  3347                    norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (f' \<circ> dest_vec1) x) - (f b - f a)) \<le> e * content {vec1 a..vec1 b})"
  3346                    norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (f' \<circ> dest_vec1) x) - (f b - f a)) \<le> e * content {vec1 a..vec1 b})"
  3348   { presume "\<And>e. e>0 \<Longrightarrow> ?P e" thus ?thesis unfolding has_integral_factor_content by auto }
  3347   { presume "\<And>e. e>0 \<Longrightarrow> ?P e" thus ?thesis unfolding has_integral_factor_content by auto }
  3420           < norm (content k *\<^sub>R f' (dest_vec1 x) - (f (dest_vec1 (interval_upperbound k)) - f (dest_vec1 (interval_lowerbound k))))"
  3419           < norm (content k *\<^sub>R f' (dest_vec1 x) - (f (dest_vec1 (interval_upperbound k)) - f (dest_vec1 (interval_lowerbound k))))"
  3421         from p(4)[OF this(1)] guess u v apply-by(erule exE)+ note k=this
  3420         from p(4)[OF this(1)] guess u v apply-by(erule exE)+ note k=this
  3422         hence "\<forall>i. u$i \<le> v$i" and uv:"{u,v}\<subseteq>{u..v}" using p(2)[OF as(1)] by auto note this(1) this(1)[unfolded forall_1]
  3421         hence "\<forall>i. u$i \<le> v$i" and uv:"{u,v}\<subseteq>{u..v}" using p(2)[OF as(1)] by auto note this(1) this(1)[unfolded forall_1]
  3423         note result = as(2)[unfolded k interval_bounds[OF this(1)] content_1[OF this(2)]]
  3422         note result = as(2)[unfolded k interval_bounds[OF this(1)] content_1[OF this(2)]]
  3424 
  3423 
  3425         assume as':"x \<noteq> vec1 a" "x \<noteq> vec1 b" hence "x$1 \<in> {a<..<b}" using p(2-3)[OF as(1)] by(auto simp add:Cart_simps) note  * = d(2)[OF this] 
  3424         assume as':"x \<noteq> vec1 a" "x \<noteq> vec1 b" hence "x$1 \<in> {a<..<b}" using p(2-3)[OF as(1)] by(auto simp add: Cart_eq) note  * = d(2)[OF this]
  3426         have "norm ((v$1 - u$1) *\<^sub>R f' (x$1) - (f (v$1) - f (u$1))) =
  3425         have "norm ((v$1 - u$1) *\<^sub>R f' (x$1) - (f (v$1) - f (u$1))) =
  3427           norm ((f (u$1) - f (x$1) - (u$1 - x$1) *\<^sub>R f' (x$1)) - (f (v$1) - f (x$1) - (v$1 - x$1) *\<^sub>R f' (x$1)))" 
  3426           norm ((f (u$1) - f (x$1) - (u$1 - x$1) *\<^sub>R f' (x$1)) - (f (v$1) - f (x$1) - (v$1 - x$1) *\<^sub>R f' (x$1)))" 
  3428           apply(rule arg_cong[of _ _ norm]) unfolding scaleR_left.diff by auto 
  3427           apply(rule arg_cong[of _ _ norm]) unfolding scaleR_left.diff by auto 
  3429         also have "... \<le> e / 2 * norm (u$1 - x$1) + e / 2 * norm (v$1 - x$1)" apply(rule norm_triangle_le_sub)
  3428         also have "... \<le> e / 2 * norm (u$1 - x$1) + e / 2 * norm (v$1 - x$1)" apply(rule norm_triangle_le_sub)
  3430           apply(rule add_mono) apply(rule_tac[!] *) using fineD[OF goal2(2) as(1)] as' unfolding k subset_eq
  3429           apply(rule add_mono) apply(rule_tac[!] *) using fineD[OF goal2(2) as(1)] as' unfolding k subset_eq
  3667       unfolding `x=a` vector_dist_norm apply(rule d(2)[rule_format]) unfolding norm_real by auto
  3666       unfolding `x=a` vector_dist_norm apply(rule d(2)[rule_format]) unfolding norm_real by auto
  3668   next   assume "x=b" have "b \<le> b" by auto
  3667   next   assume "x=b" have "b \<le> b" by auto
  3669     from indefinite_integral_continuous_left[OF assms(1) `a<b` this `e>0`] guess d . note d=this
  3668     from indefinite_integral_continuous_left[OF assms(1) `a<b` this `e>0`] guess d . note d=this
  3670     show ?thesis apply(rule,rule,rule d,safe) apply(subst dist_commute)
  3669     show ?thesis apply(rule,rule,rule d,safe) apply(subst dist_commute)
  3671       unfolding `x=b` vector_dist_norm apply(rule d(2)[rule_format]) unfolding norm_real by auto
  3670       unfolding `x=b` vector_dist_norm apply(rule d(2)[rule_format]) unfolding norm_real by auto
  3672   next assume "a<x \<and> x<b" hence xl:"a<x" "x\<le>b" and xr:"a\<le>x" "x<b" by(auto simp add:Cart_simps)
  3671   next assume "a<x \<and> x<b" hence xl:"a<x" "x\<le>b" and xr:"a\<le>x" "x<b" by(auto simp add: vector_less_def)
  3673     from indefinite_integral_continuous_left [OF assms(1) xl `e>0`] guess d1 . note d1=this
  3672     from indefinite_integral_continuous_left [OF assms(1) xl `e>0`] guess d1 . note d1=this
  3674     from indefinite_integral_continuous_right[OF assms(1) xr `e>0`] guess d2 . note d2=this
  3673     from indefinite_integral_continuous_right[OF assms(1) xr `e>0`] guess d2 . note d2=this
  3675     show ?thesis apply(rule_tac x="min d1 d2" in exI)
  3674     show ?thesis apply(rule_tac x="min d1 d2" in exI)
  3676     proof safe show "0 < min d1 d2" using d1 d2 by auto
  3675     proof safe show "0 < min d1 d2" using d1 d2 by auto
  3677       fix y assume "y\<in>{a..b}" "dist y x < min d1 d2"
  3676       fix y assume "y\<in>{a..b}" "dist y x < min d1 d2"
  3724   have "(f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x)) 1 = y"
  3723   have "(f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x)) 1 = y"
  3725     apply(rule has_derivative_zero_unique_strong_interval[OF as2 as1, of ])
  3724     apply(rule has_derivative_zero_unique_strong_interval[OF as2 as1, of ])
  3726     unfolding o_def using assms(5) defer apply-apply(rule)
  3725     unfolding o_def using assms(5) defer apply-apply(rule)
  3727   proof- fix t assume as:"t\<in>{0..1} - {t. (1 - t) *\<^sub>R c + t *\<^sub>R x \<in> k}"
  3726   proof- fix t assume as:"t\<in>{0..1} - {t. (1 - t) *\<^sub>R c + t *\<^sub>R x \<in> k}"
  3728     have *:"c - t *\<^sub>R c + t *\<^sub>R x \<in> s - k" apply safe apply(rule conv[unfolded scaleR_simps]) 
  3727     have *:"c - t *\<^sub>R c + t *\<^sub>R x \<in> s - k" apply safe apply(rule conv[unfolded scaleR_simps]) 
  3729       using `x\<in>s` `c\<in>s` as by(auto simp add:scaleR_simps)
  3728       using `x\<in>s` `c\<in>s` as by(auto simp add: algebra_simps)
  3730     have "(f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x) has_derivative (\<lambda>x. 0) \<circ> (\<lambda>z. (0 - z *\<^sub>R c) + z *\<^sub>R x)) (at t within {0..1})"
  3729     have "(f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x) has_derivative (\<lambda>x. 0) \<circ> (\<lambda>z. (0 - z *\<^sub>R c) + z *\<^sub>R x)) (at t within {0..1})"
  3731       apply(rule diff_chain_within) apply(rule has_derivative_add)
  3730       apply(rule diff_chain_within) apply(rule has_derivative_add)
  3732       unfolding scaleR_simps apply(rule has_derivative_sub) apply(rule has_derivative_const)
  3731       unfolding scaleR_simps apply(rule has_derivative_sub) apply(rule has_derivative_const)
  3733       apply(rule has_derivative_vmul_within,rule has_derivative_id)+ 
  3732       apply(rule has_derivative_vmul_within,rule has_derivative_id)+ 
  3734       apply(rule has_derivative_within_subset,rule assms(6)[rule_format])
  3733       apply(rule has_derivative_within_subset,rule assms(6)[rule_format])
  3947   proof safe case goal1 show ?case apply(rule has_integral_negligible[OF `?r`[rule_format,of a b]])
  3946   proof safe case goal1 show ?case apply(rule has_integral_negligible[OF `?r`[rule_format,of a b]])
  3948       unfolding indicator_def by auto qed qed auto
  3947       unfolding indicator_def by auto qed qed auto
  3949 
  3948 
  3950 lemma has_integral_spike_set_eq: fixes f::"real^'n \<Rightarrow> 'a::banach" 
  3949 lemma has_integral_spike_set_eq: fixes f::"real^'n \<Rightarrow> 'a::banach" 
  3951   assumes "negligible((s - t) \<union> (t - s))" shows "((f has_integral y) s \<longleftrightarrow> (f has_integral y) t)"
  3950   assumes "negligible((s - t) \<union> (t - s))" shows "((f has_integral y) s \<longleftrightarrow> (f has_integral y) t)"
  3952   unfolding has_integral_restrict_univ[THEN sym,of f] apply(rule has_integral_spike_eq[OF assms]) by auto
  3951   unfolding has_integral_restrict_univ[THEN sym,of f] apply(rule has_integral_spike_eq[OF assms]) by (safe, auto split: split_if_asm)
  3953 
  3952 
  3954 lemma has_integral_spike_set[dest]: fixes f::"real^'n \<Rightarrow> 'a::banach"
  3953 lemma has_integral_spike_set[dest]: fixes f::"real^'n \<Rightarrow> 'a::banach"
  3955   assumes "negligible((s - t) \<union> (t - s))" "(f has_integral y) s"
  3954   assumes "negligible((s - t) \<union> (t - s))" "(f has_integral y) s"
  3956   shows "(f has_integral y) t"
  3955   shows "(f has_integral y) t"
  3957   using assms has_integral_spike_set_eq by auto
  3956   using assms has_integral_spike_set_eq by auto