src/HOL/Multivariate_Analysis/Derivative.thy
changeset 56188 0268784f60da
parent 56183 f998bdd40763
child 56193 c726ecfb22b6
equal deleted inserted replaced
56187:2666cd7d380c 56188:0268784f60da
   456 lemma frechet_derivative_unique_at:
   456 lemma frechet_derivative_unique_at:
   457   "(f has_derivative f') (at x) \<Longrightarrow> (f has_derivative f'') (at x) \<Longrightarrow> f' = f''"
   457   "(f has_derivative f') (at x) \<Longrightarrow> (f has_derivative f'') (at x) \<Longrightarrow> f' = f''"
   458   by (rule has_derivative_unique)
   458   by (rule has_derivative_unique)
   459 
   459 
   460 lemma frechet_derivative_unique_within_closed_interval:
   460 lemma frechet_derivative_unique_within_closed_interval:
   461   fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
   461   fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
   462   assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   462   assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   463     and "x \<in> {a..b}"
   463     and "x \<in> cbox a b"
   464     and "(f has_derivative f' ) (at x within {a..b})"
   464     and "(f has_derivative f' ) (at x within cbox a b)"
   465     and "(f has_derivative f'') (at x within {a..b})"
   465     and "(f has_derivative f'') (at x within cbox a b)"
   466   shows "f' = f''"
   466   shows "f' = f''"
   467   apply(rule frechet_derivative_unique_within)
   467   apply(rule frechet_derivative_unique_within)
   468   apply(rule assms(3,4))+
   468   apply(rule assms(3,4))+
   469 proof (rule, rule, rule)
   469 proof (rule, rule, rule)
   470   fix e :: real
   470   fix e :: real
   471   fix i :: 'a
   471   fix i :: 'a
   472   assume "e > 0" and i: "i \<in> Basis"
   472   assume "e > 0" and i: "i \<in> Basis"
   473   then show "\<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R i \<in> {a..b}"
   473   then show "\<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R i \<in> cbox a b"
   474   proof (cases "x\<bullet>i = a\<bullet>i")
   474   proof (cases "x\<bullet>i = a\<bullet>i")
   475     case True
   475     case True
   476     then show ?thesis
   476     then show ?thesis
   477       apply (rule_tac x="(min (b\<bullet>i - a\<bullet>i)  e) / 2" in exI)
   477       apply (rule_tac x="(min (b\<bullet>i - a\<bullet>i)  e) / 2" in exI)
   478       using assms(1)[THEN bspec[where x=i]] and `e>0` and assms(2)
   478       using assms(1)[THEN bspec[where x=i]] and `e>0` and assms(2)
   479       unfolding mem_interval
   479       unfolding mem_box
   480       using i
   480       using i
   481       apply (auto simp add: field_simps inner_simps inner_Basis)
   481       apply (auto simp add: field_simps inner_simps inner_Basis)
   482       done
   482       done
   483   next
   483   next
   484     note * = assms(2)[unfolded mem_interval, THEN bspec, OF i]
   484     note * = assms(2)[unfolded mem_box, THEN bspec, OF i]
   485     case False
   485     case False
   486     moreover have "a \<bullet> i < x \<bullet> i"
   486     moreover have "a \<bullet> i < x \<bullet> i"
   487       using False * by auto
   487       using False * by auto
   488     moreover {
   488     moreover {
   489       have "a \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e \<le> a\<bullet>i *2 + x\<bullet>i - a\<bullet>i"
   489       have "a \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e \<le> a\<bullet>i *2 + x\<bullet>i - a\<bullet>i"
   500     then have "x \<bullet> i * 2 \<le> b \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e"
   500     then have "x \<bullet> i * 2 \<le> b \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e"
   501       using * by auto
   501       using * by auto
   502     ultimately show ?thesis
   502     ultimately show ?thesis
   503       apply (rule_tac x="- (min (x\<bullet>i - a\<bullet>i) e) / 2" in exI)
   503       apply (rule_tac x="- (min (x\<bullet>i - a\<bullet>i) e) / 2" in exI)
   504       using assms(1)[THEN bspec, OF i] and `e>0` and assms(2)
   504       using assms(1)[THEN bspec, OF i] and `e>0` and assms(2)
   505       unfolding mem_interval
   505       unfolding mem_box
   506       using i
   506       using i
   507       apply (auto simp add: field_simps inner_simps inner_Basis)
   507       apply (auto simp add: field_simps inner_simps inner_Basis)
   508       done
   508       done
   509   qed
   509   qed
   510 qed
   510 qed
   511 
   511 
   512 lemma frechet_derivative_unique_within_open_interval:
   512 lemma frechet_derivative_unique_within_open_interval:
   513   fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
   513   fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
   514   assumes "x \<in> box a b"
   514   assumes "x \<in> box a b"
   515     and "(f has_derivative f' ) (at x within box a b)"
   515     and "(f has_derivative f' ) (at x within box a b)"
   516     and "(f has_derivative f'') (at x within box a b)"
   516     and "(f has_derivative f'') (at x within box a b)"
   517   shows "f' = f''"
   517   shows "f' = f''"
   518 proof -
   518 proof -
   519   from assms(1) have *: "at x within box a b = at x"
   519   from assms(1) have *: "at x within box a b = at x"
   520     by (metis at_within_interior interior_open open_interval)
   520     by (metis at_within_interior interior_open open_box)
   521   from assms(2,3) [unfolded *] show "f' = f''"
   521   from assms(2,3) [unfolded *] show "f' = f''"
   522     by (rule frechet_derivative_unique_at)
   522     by (rule frechet_derivative_unique_at)
   523 qed
   523 qed
   524 
   524 
   525 lemma frechet_derivative_at:
   525 lemma frechet_derivative_at:
   529   unfolding frechet_derivative_works[symmetric]
   529   unfolding frechet_derivative_works[symmetric]
   530   using differentiable_def
   530   using differentiable_def
   531   apply auto
   531   apply auto
   532   done
   532   done
   533 
   533 
   534 lemma frechet_derivative_within_closed_interval:
   534 lemma frechet_derivative_within_cbox:
   535   fixes f :: "'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
   535   fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
   536   assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   536   assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   537     and "x \<in> {a..b}"
   537     and "x \<in> cbox a b"
   538     and "(f has_derivative f') (at x within {a..b})"
   538     and "(f has_derivative f') (at x within cbox a b)"
   539   shows "frechet_derivative f (at x within {a..b}) = f'"
   539   shows "frechet_derivative f (at x within cbox a b) = f'"
   540   using assms
   540   using assms
   541   by (metis Derivative.differentiableI frechet_derivative_unique_within_closed_interval frechet_derivative_works)
   541   by (metis Derivative.differentiableI frechet_derivative_unique_within_closed_interval frechet_derivative_works)
   542 
   542 
   543 
   543 
   544 subsection {* The traditional Rolle theorem in one dimension *}
   544 subsection {* The traditional Rolle theorem in one dimension *}
   639 
   639 
   640 lemma rolle:
   640 lemma rolle:
   641   fixes f :: "real \<Rightarrow> real"
   641   fixes f :: "real \<Rightarrow> real"
   642   assumes "a < b"
   642   assumes "a < b"
   643     and "f a = f b"
   643     and "f a = f b"
   644     and "continuous_on {a..b} f"
   644     and "continuous_on {a .. b} f"
   645     and "\<forall>x\<in>box a b. (f has_derivative f' x) (at x)"
   645     and "\<forall>x\<in>{a <..< b}. (f has_derivative f' x) (at x)"
   646   shows "\<exists>x\<in>box a b. f' x = (\<lambda>v. 0)"
   646   shows "\<exists>x\<in>{a <..< b}. f' x = (\<lambda>v. 0)"
   647 proof -
   647 proof -
   648   have "\<exists>x\<in>box a b. (\<forall>y\<in>box a b. f x \<le> f y) \<or> (\<forall>y\<in>box a b. f y \<le> f x)"
   648   have "\<exists>x\<in>box a b. (\<forall>y\<in>box a b. f x \<le> f y) \<or> (\<forall>y\<in>box a b. f y \<le> f x)"
   649   proof -
   649   proof -
   650     have "(a + b) / 2 \<in> {a .. b}"
   650     have "(a + b) / 2 \<in> {a .. b}"
   651       using assms(1) by auto
   651       using assms(1) by auto
   652     then have *: "{a..b} \<noteq> {}"
   652     then have *: "{a .. b} \<noteq> {}"
   653       by auto
   653       by auto
   654     obtain d where d:
   654     obtain d where d:
   655         "d \<in> {a..b}"
   655         "d \<in>cbox a b"
   656         "\<forall>y\<in>{a..b}. f y \<le> f d"
   656         "\<forall>y\<in>cbox a b. f y \<le> f d"
   657       using continuous_attains_sup[OF compact_interval * assms(3)] ..
   657       using continuous_attains_sup[OF compact_Icc * assms(3)] by auto
   658     obtain c where c:
   658     obtain c where c:
   659         "c \<in> {a..b}"
   659         "c \<in> cbox a b"
   660         "\<forall>y\<in>{a..b}. f c \<le> f y"
   660         "\<forall>y\<in>cbox a b. f c \<le> f y"
   661       using continuous_attains_inf[OF compact_interval * assms(3)] ..
   661       using continuous_attains_inf[OF compact_Icc * assms(3)] by auto
   662     show ?thesis
   662     show ?thesis
   663     proof (cases "d \<in> box a b \<or> c \<in> box a b")
   663     proof (cases "d \<in> box a b \<or> c \<in> box a b")
   664       case True
   664       case True
   665       then show ?thesis
   665       then show ?thesis
   666         by (metis c(2) d(2) interval_open_subset_closed subset_iff)
   666         by (metis c(2) d(2) box_subset_cbox subset_iff)
   667     next
   667     next
   668       def e \<equiv> "(a + b) /2"
   668       def e \<equiv> "(a + b) /2"
   669       case False
   669       case False
   670       then have "f d = f c"
   670       then have "f d = f c"
   671         using d c assms(2) by (auto simp: box_real)
   671         using d c assms(2) by auto
   672       then have "\<And>x. x \<in> {a..b} \<Longrightarrow> f x = f d"
   672       then have "\<And>x. x \<in> {a..b} \<Longrightarrow> f x = f d"
   673         using c d
   673         using c d
   674         by force
   674         by force
   675       then show ?thesis
   675       then show ?thesis
   676         apply (rule_tac x=e in bexI)
   676         apply (rule_tac x=e in bexI)
   677         unfolding e_def
   677         unfolding e_def
   678         using assms(1)
   678         using assms(1)
   679         apply (auto simp: box_real)
   679         apply auto
   680         done
   680         done
   681     qed
   681     qed
   682   qed
   682   qed
   683   then obtain x where x: "x \<in> box a b" "(\<forall>y\<in>box a b. f x \<le> f y) \<or> (\<forall>y\<in>box a b. f y \<le> f x)" ..
   683   then obtain x where x: "x \<in> {a <..< b}" "(\<forall>y\<in>{a <..< b}. f x \<le> f y) \<or> (\<forall>y\<in>{a <..< b}. f y \<le> f x)"
       
   684     by auto
   684   then have "f' x = (\<lambda>v. 0)"
   685   then have "f' x = (\<lambda>v. 0)"
   685     apply (rule_tac differential_zero_maxmin[of x "box a b" f "f' x"])
   686     apply (rule_tac differential_zero_maxmin[of x "box a b" f "f' x"])
   686     using assms
   687     using assms
   687     apply auto
   688     apply auto
   688     done
   689     done
   698   assumes "a < b"
   699   assumes "a < b"
   699     and "continuous_on {a..b} f"
   700     and "continuous_on {a..b} f"
   700   assumes "\<forall>x\<in>{a<..<b}. (f has_derivative (f' x)) (at x)"
   701   assumes "\<forall>x\<in>{a<..<b}. (f has_derivative (f' x)) (at x)"
   701   shows "\<exists>x\<in>{a<..<b}. f b - f a = (f' x) (b - a)"
   702   shows "\<exists>x\<in>{a<..<b}. f b - f a = (f' x) (b - a)"
   702 proof -
   703 proof -
   703   have "\<exists>x\<in>box a b. (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)"
   704   have "\<exists>x\<in>{a <..< b}. (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)"
   704   proof (intro rolle[OF assms(1), of "\<lambda>x. f x - (f b - f a) / (b - a) * x"] ballI)
   705   proof (intro rolle[OF assms(1), of "\<lambda>x. f x - (f b - f a) / (b - a) * x"] ballI)
   705     fix x
   706     fix x
   706     assume "x \<in> box a b" hence x: "x \<in> {a<..<b}" by (simp add: box_real)
   707     assume x: "x \<in> {a <..< b}"
   707     show "((\<lambda>x. f x - (f b - f a) / (b - a) * x) has_derivative
   708     show "((\<lambda>x. f x - (f b - f a) / (b - a) * x) has_derivative
   708         (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa)) (at x)"
   709         (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa)) (at x)"
   709       by (intro has_derivative_intros assms(3)[rule_format,OF x] mult_right_has_derivative)
   710       by (intro has_derivative_intros assms(3)[rule_format,OF x] mult_right_has_derivative)
   710   qed (insert assms(1,2), auto intro!: continuous_on_intros simp: field_simps)
   711   qed (insert assms(1,2), auto intro!: continuous_on_intros simp: field_simps)
   711   then obtain x where
   712   then obtain x where
   712     "x \<in> box a b"
   713     "x \<in> {a <..< b}"
   713     "(\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)" ..
   714     "(\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)" ..
   714   then show ?thesis
   715   then show ?thesis
   715     by (metis (erased, hide_lams) assms(1) box_real diff_less_iff(1) eq_iff_diff_eq_0 linordered_field_class.sign_simps(41) nonzero_mult_divide_cancel_right not_real_square_gt_zero times_divide_eq_left)
   716     by (metis (erased, hide_lams) assms(1) diff_less_iff(1) eq_iff_diff_eq_0
       
   717       linordered_field_class.sign_simps(41) nonzero_mult_divide_cancel_right not_real_square_gt_zero
       
   718       times_divide_eq_left)
   716 qed
   719 qed
   717 
   720 
   718 lemma mvt_simple:
   721 lemma mvt_simple:
   719   fixes f :: "real \<Rightarrow> real"
   722   fixes f :: "real \<Rightarrow> real"
   720   assumes "a < b"
   723   assumes "a < b"
   725   apply (rule differentiable_imp_continuous_on)
   728   apply (rule differentiable_imp_continuous_on)
   726   unfolding differentiable_on_def differentiable_def
   729   unfolding differentiable_on_def differentiable_def
   727   defer
   730   defer
   728 proof
   731 proof
   729   fix x
   732   fix x
   730   assume x: "x \<in> {a<..<b}" hence x: "x \<in> box a b" by (simp add: box_real)
   733   assume x: "x \<in> {a <..< b}"
   731   show "(f has_derivative f' x) (at x)"
   734   show "(f has_derivative f' x) (at x)"
   732     unfolding has_derivative_within_open[OF x open_interval,symmetric]
   735     unfolding has_derivative_within_open[OF x open_greaterThanLessThan,symmetric]
   733     apply (rule has_derivative_within_subset)
   736     apply (rule has_derivative_within_subset)
   734     apply (rule assms(2)[rule_format])
   737     apply (rule assms(2)[rule_format])
   735     using x
   738     using x
   736     apply (auto simp: box_real)
   739     apply auto
   737     done
   740     done
   738 qed (insert assms(2), auto)
   741 qed (insert assms(2), auto)
   739 
   742 
   740 lemma mvt_very_simple:
   743 lemma mvt_very_simple:
   741   fixes f :: "real \<Rightarrow> real"
   744   fixes f :: "real \<Rightarrow> real"
   742   assumes "a \<le> b"
   745   assumes "a \<le> b"
   743     and "\<forall>x\<in>{a..b}. (f has_derivative f' x) (at x within {a..b})"
   746     and "\<forall>x\<in>{a .. b}. (f has_derivative f' x) (at x within {a .. b})"
   744   shows "\<exists>x\<in>{a..b}. f b - f a = f' x (b - a)"
   747   shows "\<exists>x\<in>{a .. b}. f b - f a = f' x (b - a)"
   745 proof (cases "a = b")
   748 proof (cases "a = b")
   746   interpret bounded_linear "f' b"
   749   interpret bounded_linear "f' b"
   747     using assms(2) assms(1) by auto
   750     using assms(2) assms(1) by auto
   748   case True
   751   case True
   749   then show ?thesis
   752   then show ?thesis
   765 text {* A nice generalization (see Havin's proof of 5.19 from Rudin's book). *}
   768 text {* A nice generalization (see Havin's proof of 5.19 from Rudin's book). *}
   766 
   769 
   767 lemma mvt_general:
   770 lemma mvt_general:
   768   fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   771   fixes f :: "real \<Rightarrow> 'a::euclidean_space"
   769   assumes "a < b"
   772   assumes "a < b"
   770     and "continuous_on {a..b} f"
   773     and "continuous_on {a .. b} f"
   771     and "\<forall>x\<in>{a<..<b}. (f has_derivative f'(x)) (at x)"
   774     and "\<forall>x\<in>{a<..<b}. (f has_derivative f'(x)) (at x)"
   772   shows "\<exists>x\<in>{a<..<b}. norm (f b - f a) \<le> norm (f' x (b - a))"
   775   shows "\<exists>x\<in>{a<..<b}. norm (f b - f a) \<le> norm (f' x (b - a))"
   773 proof -
   776 proof -
   774   have "\<exists>x\<in>{a<..<b}. (op \<bullet> (f b - f a) \<circ> f) b - (op \<bullet> (f b - f a) \<circ> f) a = (f b - f a) \<bullet> f' x (b - a)"
   777   have "\<exists>x\<in>{a<..<b}. (op \<bullet> (f b - f a) \<circ> f) b - (op \<bullet> (f b - f a) \<circ> f) a = (f b - f a) \<bullet> f' x (b - a)"
   775     apply (rule mvt)
   778     apply (rule mvt)
   823   let ?p = "\<lambda>u. x + u *\<^sub>R (y - x)"
   826   let ?p = "\<lambda>u. x + u *\<^sub>R (y - x)"
   824   have *: "\<And>u. u\<in>{0..1} \<Longrightarrow> x + u *\<^sub>R (y - x) \<in> s"
   827   have *: "\<And>u. u\<in>{0..1} \<Longrightarrow> x + u *\<^sub>R (y - x) \<in> s"
   825     using assms(1)[unfolded convex_alt,rule_format,OF x y]
   828     using assms(1)[unfolded convex_alt,rule_format,OF x y]
   826     unfolding scaleR_left_diff_distrib scaleR_right_diff_distrib
   829     unfolding scaleR_left_diff_distrib scaleR_right_diff_distrib
   827     by (auto simp add: algebra_simps)
   830     by (auto simp add: algebra_simps)
   828   then have 1: "continuous_on {0..1} (f \<circ> ?p)"
   831   then have 1: "continuous_on {0 .. 1} (f \<circ> ?p)"
   829     apply -
   832     apply -
   830     apply (rule continuous_on_intros)+
   833     apply (rule continuous_on_intros)+
   831     unfolding continuous_on_eq_continuous_within
   834     unfolding continuous_on_eq_continuous_within
   832     apply rule
   835     apply rule
   833     apply (rule differentiable_imp_continuous_within)
   836     apply (rule differentiable_imp_continuous_within)
   835     apply (rule_tac x="f' xa" in exI)
   838     apply (rule_tac x="f' xa" in exI)
   836     apply (rule has_derivative_within_subset)
   839     apply (rule has_derivative_within_subset)
   837     apply (rule assms(2)[rule_format])
   840     apply (rule assms(2)[rule_format])
   838     apply auto
   841     apply auto
   839     done
   842     done
   840   have 2: "\<forall>u\<in>{0<..<1}.
   843   have 2: "\<forall>u\<in>{0 <..< 1}.
   841     ((f \<circ> ?p) has_derivative f' (x + u *\<^sub>R (y - x)) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u)"
   844     ((f \<circ> ?p) has_derivative f' (x + u *\<^sub>R (y - x)) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u)"
   842   proof rule
   845   proof rule
   843     case goal1
   846     case goal1
   844     let ?u = "x + u *\<^sub>R (y - x)"
   847     let ?u = "x + u *\<^sub>R (y - x)"
   845     have "(f \<circ> ?p has_derivative (f' ?u) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u within {0<..<1})"
   848     have "(f \<circ> ?p has_derivative (f' ?u) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u within box 0 1)"
   846       apply (rule diff_chain_within)
   849       apply (rule diff_chain_within)
   847       apply (rule has_derivative_intros)+
   850       apply (rule has_derivative_intros)+
   848       apply (rule has_derivative_within_subset)
   851       apply (rule has_derivative_within_subset)
   849       apply (rule assms(2)[rule_format])
   852       apply (rule assms(2)[rule_format])
   850       using goal1 *
   853       using goal1 *
   851       apply auto
   854       apply auto
   852       done
   855       done
   853     then show ?case
   856     then show ?case
   854       unfolding has_derivative_within_open[OF goal1 open_greaterThanLessThan] .
   857       by (simp add: has_derivative_within_open[OF goal1 open_greaterThanLessThan])
   855   qed
   858   qed
   856   obtain u where u:
   859   obtain u where u:
   857       "u \<in> {0<..<1}"
   860       "u \<in> {0<..<1}"
   858       "norm ((f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 1 - (f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 0)
   861       "norm ((f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 1 - (f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 0)
   859         \<le> norm ((f' (x + u *\<^sub>R (y - x)) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (1 - 0))"
   862         \<le> norm ((f' (x + u *\<^sub>R (y - x)) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (1 - 0))"
  2049     unfolding fun_eq_iff by auto
  2052     unfolding fun_eq_iff by auto
  2050 qed
  2053 qed
  2051 
  2054 
  2052 lemma vector_derivative_unique_within_closed_interval:
  2055 lemma vector_derivative_unique_within_closed_interval:
  2053   assumes "a < b"
  2056   assumes "a < b"
  2054     and "x \<in> {a..b}"
  2057     and "x \<in> cbox a b"
  2055   assumes "(f has_vector_derivative f') (at x within {a..b})"
  2058   assumes "(f has_vector_derivative f') (at x within cbox a b)"
  2056   assumes "(f has_vector_derivative f'') (at x within {a..b})"
  2059   assumes "(f has_vector_derivative f'') (at x within cbox a b)"
  2057   shows "f' = f''"
  2060   shows "f' = f''"
  2058 proof -
  2061 proof -
  2059   have *: "(\<lambda>x. x *\<^sub>R f') = (\<lambda>x. x *\<^sub>R f'')"
  2062   have *: "(\<lambda>x. x *\<^sub>R f') = (\<lambda>x. x *\<^sub>R f'')"
  2060     apply (rule frechet_derivative_unique_within_closed_interval[of "a" "b"])
  2063     apply (rule frechet_derivative_unique_within_closed_interval[of "a" "b"])
  2061     using assms(3-)[unfolded has_vector_derivative_def]
  2064     using assms(3-)[unfolded has_vector_derivative_def]
  2082   apply auto
  2085   apply auto
  2083   done
  2086   done
  2084 
  2087 
  2085 lemma vector_derivative_within_closed_interval:
  2088 lemma vector_derivative_within_closed_interval:
  2086   assumes "a < b"
  2089   assumes "a < b"
  2087     and "x \<in> {a..b}"
  2090     and "x \<in> cbox a b"
  2088   assumes "(f has_vector_derivative f') (at x within {a..b})"
  2091   assumes "(f has_vector_derivative f') (at x within cbox a b)"
  2089   shows "vector_derivative f (at x within {a..b}) = f'"
  2092   shows "vector_derivative f (at x within cbox a b) = f'"
  2090   apply (rule vector_derivative_unique_within_closed_interval)
  2093   apply (rule vector_derivative_unique_within_closed_interval)
  2091   using vector_derivative_works[unfolded differentiable_def]
  2094   using vector_derivative_works[unfolded differentiable_def]
  2092   using assms
  2095   using assms
  2093   apply (auto simp add:has_vector_derivative_def)
  2096   apply (auto simp add:has_vector_derivative_def)
  2094   done
  2097   done