src/HOL/Analysis/Derivative.thy
changeset 68058 69715dfdc286
parent 68055 2cab37094fc4
child 68073 fad29d2a17a5
equal deleted inserted replaced
68056:9e077a905209 68058:69715dfdc286
   371  limit point from any direction. But OK for nontrivial intervals etc.
   371  limit point from any direction. But OK for nontrivial intervals etc.
   372 \<close>
   372 \<close>
   373 
   373 
   374 lemma frechet_derivative_unique_within:
   374 lemma frechet_derivative_unique_within:
   375   fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
   375   fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
   376   assumes "(f has_derivative f') (at x within s)"
   376   assumes "(f has_derivative f') (at x within S)"
   377     and "(f has_derivative f'') (at x within s)"
   377     and "(f has_derivative f'') (at x within S)"
   378     and "\<forall>i\<in>Basis. \<forall>e>0. \<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> (x + d *\<^sub>R i) \<in> s"
   378     and "\<forall>i\<in>Basis. \<forall>e>0. \<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> (x + d *\<^sub>R i) \<in> S"
   379   shows "f' = f''"
   379   shows "f' = f''"
   380 proof -
   380 proof -
   381   note as = assms(1,2)[unfolded has_derivative_def]
   381   note as = assms(1,2)[unfolded has_derivative_def]
   382   then interpret f': bounded_linear f' by auto
   382   then interpret f': bounded_linear f' by auto
   383   from as interpret f'': bounded_linear f'' by auto
   383   from as interpret f'': bounded_linear f'' by auto
   384   have "x islimpt s" unfolding islimpt_approachable
   384   have "x islimpt S" unfolding islimpt_approachable
   385   proof (rule, rule)
   385   proof (rule, rule)
   386     fix e :: real
   386     fix e :: real
   387     assume "e > 0"
   387     assume "e > 0"
   388     obtain d where "0 < \<bar>d\<bar>" and "\<bar>d\<bar> < e" and "x + d *\<^sub>R (SOME i. i \<in> Basis) \<in> s"
   388     obtain d where "0 < \<bar>d\<bar>" and "\<bar>d\<bar> < e" and "x + d *\<^sub>R (SOME i. i \<in> Basis) \<in> S"
   389       using assms(3) SOME_Basis \<open>e>0\<close> by blast
   389       using assms(3) SOME_Basis \<open>e>0\<close> by blast
   390     then show "\<exists>x'\<in>s. x' \<noteq> x \<and> dist x' x < e"
   390     then show "\<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e"
   391       apply (rule_tac x="x + d *\<^sub>R (SOME i. i \<in> Basis)" in bexI)
   391       apply (rule_tac x="x + d *\<^sub>R (SOME i. i \<in> Basis)" in bexI)
   392       unfolding dist_norm
   392       unfolding dist_norm
   393       apply (auto simp: SOME_Basis nonzero_Basis)
   393       apply (auto simp: SOME_Basis nonzero_Basis)
   394       done
   394       done
   395   qed
   395   qed
   396   then have *: "netlimit (at x within s) = x"
   396   then have *: "netlimit (at x within S) = x"
   397     apply (auto intro!: netlimit_within)
   397     apply (auto intro!: netlimit_within)
   398     by (metis trivial_limit_within)
   398     by (metis trivial_limit_within)
   399   show ?thesis
   399   show ?thesis
   400     apply (rule linear_eq_stdbasis)
   400   proof (rule linear_eq_stdbasis)
   401     unfolding linear_conv_bounded_linear
   401     show "linear f'" "linear f''"
   402     apply (rule as(1,2)[THEN conjunct1])+
   402       unfolding linear_conv_bounded_linear using as by auto
   403   proof (rule, rule ccontr)
   403   next
   404     fix i :: 'a
   404     fix i :: 'a
   405     assume i: "i \<in> Basis"
   405     assume i: "i \<in> Basis"
   406     define e where "e = norm (f' i - f'' i)"
   406     define e where "e = norm (f' i - f'' i)"
   407     assume "f' i \<noteq> f'' i"
   407     show "f' i = f'' i"
   408     then have "e > 0"
   408     proof (rule ccontr)
   409       unfolding e_def by auto
   409       assume "f' i \<noteq> f'' i"
   410     obtain d where d:
   410       then have "e > 0"
   411       "0 < d"
   411         unfolding e_def by auto
   412       "(\<And>xa. xa\<in>s \<longrightarrow> 0 < dist xa x \<and> dist xa x < d \<longrightarrow>
   412       obtain d where d:
   413           dist ((f xa - f x - f' (xa - x)) /\<^sub>R norm (xa - x) -
   413         "0 < d"
   414               (f xa - f x - f'' (xa - x)) /\<^sub>R norm (xa - x)) (0 - 0) < e)"
   414         "(\<And>y. y\<in>S \<longrightarrow> 0 < dist y x \<and> dist y x < d \<longrightarrow>
   415       using tendsto_diff [OF as(1,2)[THEN conjunct2]]
   415           dist ((f y - f x - f' (y - x)) /\<^sub>R norm (y - x) -
   416       unfolding * Lim_within
   416               (f y - f x - f'' (y - x)) /\<^sub>R norm (y - x)) (0 - 0) < e)"
   417       using \<open>e>0\<close> by blast
   417         using tendsto_diff [OF as(1,2)[THEN conjunct2]]
   418     obtain c where c: "0 < \<bar>c\<bar>" "\<bar>c\<bar> < d \<and> x + c *\<^sub>R i \<in> s"
   418         unfolding * Lim_within
   419       using assms(3) i d(1) by blast
   419         using \<open>e>0\<close> by blast
   420     have *: "norm (- ((1 / \<bar>c\<bar>) *\<^sub>R f' (c *\<^sub>R i)) + (1 / \<bar>c\<bar>) *\<^sub>R f'' (c *\<^sub>R i)) =
   420       obtain c where c: "0 < \<bar>c\<bar>" "\<bar>c\<bar> < d \<and> x + c *\<^sub>R i \<in> S"
       
   421         using assms(3) i d(1) by blast
       
   422       have *: "norm (- ((1 / \<bar>c\<bar>) *\<^sub>R f' (c *\<^sub>R i)) + (1 / \<bar>c\<bar>) *\<^sub>R f'' (c *\<^sub>R i)) =
   421         norm ((1 / \<bar>c\<bar>) *\<^sub>R (- (f' (c *\<^sub>R i)) + f'' (c *\<^sub>R i)))"
   423         norm ((1 / \<bar>c\<bar>) *\<^sub>R (- (f' (c *\<^sub>R i)) + f'' (c *\<^sub>R i)))"
   422       unfolding scaleR_right_distrib by auto
   424         unfolding scaleR_right_distrib by auto
   423     also have "\<dots> = norm ((1 / \<bar>c\<bar>) *\<^sub>R (c *\<^sub>R (- (f' i) + f'' i)))"
   425       also have "\<dots> = norm ((1 / \<bar>c\<bar>) *\<^sub>R (c *\<^sub>R (- (f' i) + f'' i)))"
   424       unfolding f'.scaleR f''.scaleR
   426         unfolding f'.scaleR f''.scaleR
   425       unfolding scaleR_right_distrib scaleR_minus_right
   427         unfolding scaleR_right_distrib scaleR_minus_right
   426       by auto
   428         by auto
   427     also have "\<dots> = e"
   429       also have "\<dots> = e"
   428       unfolding e_def
   430         unfolding e_def
   429       using c(1)
   431         using c(1)
   430       using norm_minus_cancel[of "f' i - f'' i"]
   432         using norm_minus_cancel[of "f' i - f'' i"]
   431       by auto
   433         by auto
   432     finally show False
   434       finally show False
   433       using c
   435         using c
   434       using d(2)[of "x + c *\<^sub>R i"]
   436         using d(2)[of "x + c *\<^sub>R i"]
   435       unfolding dist_norm
   437         unfolding dist_norm
   436       unfolding f'.scaleR f''.scaleR f'.add f''.add f'.diff f''.diff
   438         unfolding f'.scaleR f''.scaleR f'.add f''.add f'.diff f''.diff
   437         scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib
   439           scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib
   438       using i
   440         using i
   439       by (auto simp: inverse_eq_divide)
   441         by (auto simp: inverse_eq_divide)
       
   442     qed
   440   qed
   443   qed
   441 qed
   444 qed
   442 
       
   443 lemma frechet_derivative_unique_at:
       
   444   "(f has_derivative f') (at x) \<Longrightarrow> (f has_derivative f'') (at x) \<Longrightarrow> f' = f''"
       
   445   by (rule has_derivative_unique)
       
   446 
   445 
   447 lemma frechet_derivative_unique_within_closed_interval:
   446 lemma frechet_derivative_unique_within_closed_interval:
   448   fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
   447   fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
   449   assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   448   assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
   450     and "x \<in> cbox a b"
   449     and "x \<in> cbox a b"
   504   shows "f' = f''"
   503   shows "f' = f''"
   505 proof -
   504 proof -
   506   from assms(1) have *: "at x within box a b = at x"
   505   from assms(1) have *: "at x within box a b = at x"
   507     by (metis at_within_interior interior_open open_box)
   506     by (metis at_within_interior interior_open open_box)
   508   from assms(2,3) [unfolded *] show "f' = f''"
   507   from assms(2,3) [unfolded *] show "f' = f''"
   509     by (rule frechet_derivative_unique_at)
   508     by (rule has_derivative_unique)
   510 qed
   509 qed
   511 
   510 
   512 lemma frechet_derivative_at:
   511 lemma frechet_derivative_at:
   513   "(f has_derivative f') (at x) \<Longrightarrow> f' = frechet_derivative f (at x)"
   512   "(f has_derivative f') (at x) \<Longrightarrow> f' = frechet_derivative f (at x)"
   514   apply (rule frechet_derivative_unique_at[of f])
   513   apply (rule has_derivative_unique[of f])
   515   apply assumption
   514   apply assumption
   516   unfolding frechet_derivative_works[symmetric]
   515   unfolding frechet_derivative_works[symmetric]
   517   using differentiable_def
   516   using differentiable_def
   518   apply auto
   517   apply auto
   519   done
   518   done