src/HOL/Multivariate_Analysis/Derivative.thy
changeset 35542 8f97d8caabfd
parent 35290 3707f625314f
child 36334 068a01b4bc56
equal deleted inserted replaced
35541:7b1179be2ac5 35542:8f97d8caabfd
     9 begin
     9 begin
    10 
    10 
    11 
    11 
    12 (* Because I do not want to type this all the time *)
    12 (* Because I do not want to type this all the time *)
    13 lemmas linear_linear = linear_conv_bounded_linear[THEN sym]
    13 lemmas linear_linear = linear_conv_bounded_linear[THEN sym]
       
    14 
       
    15 (** move this **)
       
    16 declare norm_vec1[simp]
    14 
    17 
    15 subsection {* Derivatives *}
    18 subsection {* Derivatives *}
    16 
    19 
    17 text {* The definition is slightly tricky since we make it work over
    20 text {* The definition is slightly tricky since we make it work over
    18   nets of a particular form. This lets us prove theorems generally and use 
    21   nets of a particular form. This lets us prove theorems generally and use 
   610     have "\<bar>(f (x + c *\<^sub>R basis j) - f x - D *v (c *\<^sub>R basis j)) $ k\<bar> \<le> norm (f (x + c *\<^sub>R basis j) - f x - D *v (c *\<^sub>R basis j))" by(rule component_le_norm)
   613     have "\<bar>(f (x + c *\<^sub>R basis j) - f x - D *v (c *\<^sub>R basis j)) $ k\<bar> \<le> norm (f (x + c *\<^sub>R basis j) - f x - D *v (c *\<^sub>R basis j))" by(rule component_le_norm)
   611     also have "\<dots> \<le> \<bar>D $ k $ j\<bar> / 2 * \<bar>c\<bar>" using e'[THEN conjunct2,rule_format,OF *] and norm_basis[of j] unfolding D_def[symmetric] by auto
   614     also have "\<dots> \<le> \<bar>D $ k $ j\<bar> / 2 * \<bar>c\<bar>" using e'[THEN conjunct2,rule_format,OF *] and norm_basis[of j] unfolding D_def[symmetric] by auto
   612     finally have "\<bar>(f (x + c *\<^sub>R basis j) - f x - D *v (c *\<^sub>R basis j)) $ k\<bar> \<le> \<bar>D $ k $ j\<bar> / 2 * \<bar>c\<bar>" by simp
   615     finally have "\<bar>(f (x + c *\<^sub>R basis j) - f x - D *v (c *\<^sub>R basis j)) $ k\<bar> \<le> \<bar>D $ k $ j\<bar> / 2 * \<bar>c\<bar>" by simp
   613     hence "\<bar>f (x + c *\<^sub>R basis j) $ k - f x $ k - c * D $ k $ j\<bar> \<le> \<bar>D $ k $ j\<bar> / 2 * \<bar>c\<bar>"
   616     hence "\<bar>f (x + c *\<^sub>R basis j) $ k - f x $ k - c * D $ k $ j\<bar> \<le> \<bar>D $ k $ j\<bar> / 2 * \<bar>c\<bar>"
   614       unfolding vector_component_simps matrix_vector_mul_component unfolding smult_conv_scaleR[symmetric] 
   617       unfolding vector_component_simps matrix_vector_mul_component unfolding smult_conv_scaleR[symmetric] 
   615       unfolding dot_rmult dot_basis unfolding smult_conv_scaleR by simp  } note * = this
   618       unfolding inner_simps dot_basis smult_conv_scaleR by simp  } note * = this
   616   have "x + d *\<^sub>R basis j \<in> ball x e" "x - d *\<^sub>R basis j \<in> ball x e"
   619   have "x + d *\<^sub>R basis j \<in> ball x e" "x - d *\<^sub>R basis j \<in> ball x e"
   617     unfolding mem_ball vector_dist_norm using norm_basis[of j] d by auto
   620     unfolding mem_ball vector_dist_norm using norm_basis[of j] d by auto
   618   hence **:"((f (x - d *\<^sub>R basis j))$k \<le> (f x)$k \<and> (f (x + d *\<^sub>R basis j))$k \<le> (f x)$k) \<or>
   621   hence **:"((f (x - d *\<^sub>R basis j))$k \<le> (f x)$k \<and> (f (x + d *\<^sub>R basis j))$k \<le> (f x)$k) \<or>
   619          ((f (x - d *\<^sub>R basis j))$k \<ge> (f x)$k \<and> (f (x + d *\<^sub>R basis j))$k \<ge> (f x)$k)" using assms(2) by auto
   622          ((f (x - d *\<^sub>R basis j))$k \<ge> (f x)$k \<and> (f (x + d *\<^sub>R basis j))$k \<ge> (f x)$k)" using assms(2) by auto
   620   have ***:"\<And>y y1 y2 d dx::real. (y1\<le>y\<and>y2\<le>y) \<or> (y\<le>y1\<and>y\<le>y2) \<Longrightarrow> d < abs dx \<Longrightarrow> abs(y1 - y - - dx) \<le> d \<Longrightarrow> (abs (y2 - y - dx) \<le> d) \<Longrightarrow> False" by arith
   623   have ***:"\<And>y y1 y2 d dx::real. (y1\<le>y\<and>y2\<le>y) \<or> (y\<le>y1\<and>y\<le>y2) \<Longrightarrow> d < abs dx \<Longrightarrow> abs(y1 - y - - dx) \<le> d \<Longrightarrow> (abs (y2 - y - dx) \<le> d) \<Longrightarrow> False" by arith
   700     unfolding True using zero by auto next
   703     unfolding True using zero by auto next
   701   case False thus ?thesis using mvt_simple[OF _ assms(2)] using assms(1) by auto qed
   704   case False thus ?thesis using mvt_simple[OF _ assms(2)] using assms(1) by auto qed
   702 
   705 
   703 subsection {* A nice generalization (see Havin's proof of 5.19 from Rudin's book). *}
   706 subsection {* A nice generalization (see Havin's proof of 5.19 from Rudin's book). *}
   704 
   707 
   705 lemma inner_eq_dot: fixes a::"real^'n"
       
   706   shows "a \<bullet> b = inner a b" unfolding inner_vector_def dot_def by auto
       
   707 
       
   708 lemma mvt_general: fixes f::"real\<Rightarrow>real^'n"
   708 lemma mvt_general: fixes f::"real\<Rightarrow>real^'n"
   709   assumes "a<b" "continuous_on {a..b} f" "\<forall>x\<in>{a<..<b}. (f has_derivative f'(x)) (at x)"
   709   assumes "a<b" "continuous_on {a..b} f" "\<forall>x\<in>{a<..<b}. (f has_derivative f'(x)) (at x)"
   710   shows "\<exists>x\<in>{a<..<b}. norm(f b - f a) \<le> norm(f'(x) (b - a))" proof-
   710   shows "\<exists>x\<in>{a<..<b}. norm(f b - f a) \<le> norm(f'(x) (b - a))" proof-
   711   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)"
   711   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)"
   712     apply(rule mvt) apply(rule assms(1))unfolding inner_eq_dot apply(rule continuous_on_inner continuous_on_intros assms(2))+ 
   712     apply(rule mvt) apply(rule assms(1)) apply(rule continuous_on_inner continuous_on_intros assms(2))+ 
   713     unfolding o_def apply(rule,rule has_derivative_lift_dot) using assms(3) by auto
   713     unfolding o_def apply(rule,rule has_derivative_lift_dot) using assms(3) by auto
   714   then guess x .. note x=this
   714   then guess x .. note x=this
   715   show ?thesis proof(cases "f a = f b")
   715   show ?thesis proof(cases "f a = f b")
   716     case False have "norm (f b - f a) * norm (f b - f a) = norm (f b - f a)^2" by(simp add:class_semiring.semiring_rules)
   716     case False have "norm (f b - f a) * norm (f b - f a) = norm (f b - f a)^2" by(simp add:class_semiring.semiring_rules)
   717     also have "\<dots> = (f b - f a) \<bullet> (f b - f a)" unfolding norm_pow_2 ..
   717     also have "\<dots> = (f b - f a) \<bullet> (f b - f a)" unfolding power2_norm_eq_inner ..
   718     also have "\<dots> = (f b - f a) \<bullet> f' x (b - a)" using x by auto
   718     also have "\<dots> = (f b - f a) \<bullet> f' x (b - a)" using x unfolding inner_simps by auto
   719     also have "\<dots> \<le> norm (f b - f a) * norm (f' x (b - a))" by(rule norm_cauchy_schwarz)
   719     also have "\<dots> \<le> norm (f b - f a) * norm (f' x (b - a))" by(rule norm_cauchy_schwarz)
   720     finally show ?thesis using False x(1) by(auto simp add: real_mult_left_cancel) next
   720     finally show ?thesis using False x(1) by(auto simp add: real_mult_left_cancel) next
   721     case True thus ?thesis using assms(1) apply(rule_tac x="(a + b) /2" in bexI) by auto qed qed
   721     case True thus ?thesis using assms(1) apply(rule_tac x="(a + b) /2" in bexI) by auto qed qed
   722 
   722 
   723 subsection {* Still more general bound theorem. *}
   723 subsection {* Still more general bound theorem. *}
   748   have "norm (f x - f y) = norm ((f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 1 - (f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 0)"
   748   have "norm (f x - f y) = norm ((f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 1 - (f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 0)"
   749     by(auto simp add:norm_minus_commute) 
   749     by(auto simp add:norm_minus_commute) 
   750   also have "\<dots> \<le> norm (f' (x + u *\<^sub>R (y - x)) (y - x))" using u by auto
   750   also have "\<dots> \<le> norm (f' (x + u *\<^sub>R (y - x)) (y - x))" using u by auto
   751   also have "\<dots> \<le> B * norm(y - x)" apply(rule **) using * and u by auto
   751   also have "\<dots> \<le> B * norm(y - x)" apply(rule **) using * and u by auto
   752   finally show ?thesis by(auto simp add:norm_minus_commute) qed 
   752   finally show ?thesis by(auto simp add:norm_minus_commute) qed 
   753 
       
   754 (** move this **)
       
   755 declare norm_vec1[simp]
       
   756 
   753 
   757 lemma onorm_vec1: fixes f::"real \<Rightarrow> real"
   754 lemma onorm_vec1: fixes f::"real \<Rightarrow> real"
   758   shows "onorm (\<lambda>x. vec1 (f (dest_vec1 x))) = onorm f" proof-
   755   shows "onorm (\<lambda>x. vec1 (f (dest_vec1 x))) = onorm f" proof-
   759   have "\<forall>x::real^1. norm x = 1 \<longleftrightarrow> x\<in>{vec1 -1, vec1 (1::real)}" unfolding forall_vec1 by(auto simp add:Cart_eq)
   756   have "\<forall>x::real^1. norm x = 1 \<longleftrightarrow> x\<in>{vec1 -1, vec1 (1::real)}" unfolding forall_vec1 by(auto simp add:Cart_eq)
   760   hence 1:"{x. norm x = 1} = {vec1 -1, vec1 (1::real)}" by(auto simp add:norm_vec1)
   757   hence 1:"{x. norm x = 1} = {vec1 -1, vec1 (1::real)}" by(auto simp add:norm_vec1)