diff -r 0e2679025aeb -r 18bf20d0c2df src/HOL/Multivariate_Analysis/Derivative.thy --- a/src/HOL/Multivariate_Analysis/Derivative.thy Mon Apr 26 09:37:46 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Derivative.thy Mon Apr 26 09:45:22 2010 -0700 @@ -1,11 +1,12 @@ -(* Title: HOL/Library/Convex_Euclidean_Space.thy - Author: John Harrison - Translation from HOL light: Robert Himmelmann, TU Muenchen *) +(* Title: HOL/Multivariate_Analysis/Derivative.thy + Author: John Harrison + Translation from HOL Light: Robert Himmelmann, TU Muenchen +*) header {* Multivariate calculus in Euclidean space. *} theory Derivative - imports Brouwer_Fixpoint RealVector +imports Brouwer_Fixpoint RealVector begin @@ -40,7 +41,7 @@ show ?l unfolding deriv_def LIM_def apply safe apply(drule as,safe) apply(rule_tac x=d in exI,safe) apply(erule_tac x="xa + x" in allE) unfolding vector_dist_norm diff_0_right norm_scaleR - unfolding vector_dist_norm netlimit_at[of x] by(auto simp add:group_simps *) qed + unfolding vector_dist_norm netlimit_at[of x] by(auto simp add:algebra_simps *) qed lemma FDERIV_conv_has_derivative:"FDERIV f (x::'a::{real_normed_vector,perfect_space}) :> f' = (f has_derivative f') (at x)" (is "?l = ?r") proof assume ?l note as = this[unfolded fderiv_def] @@ -50,14 +51,14 @@ thus "\d>0. \xa. 0 < dist xa x \ dist xa x < d \ dist ((1 / norm (xa - netlimit (at x))) *\<^sub>R (f xa - (f (netlimit (at x)) + f' (xa - netlimit (at x))))) (0) < e" apply(rule_tac x=d in exI) apply(erule conjE,rule,assumption) apply rule apply(erule_tac x="xa - x" in allE) - unfolding vector_dist_norm netlimit_at[of x] by(auto simp add:group_simps) qed next + unfolding vector_dist_norm netlimit_at[of x] by (auto simp add: diff_diff_eq) qed next assume ?r note as = this[unfolded has_derivative_def] show ?l unfolding fderiv_def LIM_def apply-apply(rule,rule as[THEN conjunct1]) proof(rule,rule) fix e::real assume "e>0" guess d using as[THEN conjunct2,unfolded Lim_at,rule_format,OF`e>0`] .. thus "\s>0. \xa. xa \ 0 \ dist xa 0 < s \ dist (norm (f (x + xa) - f x - f' xa) / norm xa) 0 < e" apply- apply(rule_tac x=d in exI) apply(erule conjE,rule,assumption) apply rule apply(erule_tac x="xa + x" in allE) - unfolding vector_dist_norm netlimit_at[of x] by(auto simp add:group_simps) qed qed + unfolding vector_dist_norm netlimit_at[of x] by (auto simp add: diff_diff_eq add.commute) qed qed subsection {* These are the only cases we'll care about, probably. *} @@ -76,7 +77,7 @@ (\e>0. \d>0. \x'\s. 0 < norm(x' - x) \ norm(x' - x) < d \ norm(f x' - f x - f'(x' - x)) / norm(x' - x) < e)" unfolding has_derivative_within Lim_within vector_dist_norm - unfolding diff_0_right norm_mul by(simp add: group_simps) + unfolding diff_0_right norm_mul by (simp add: diff_diff_eq) lemma has_derivative_at': "(f has_derivative f') (at x) \ bounded_linear f' \ @@ -186,14 +187,14 @@ note as = assms[unfolded has_derivative_def] show ?thesis unfolding has_derivative_def apply(rule,rule bounded_linear_add) using Lim_add[OF as(1)[THEN conjunct2] as(2)[THEN conjunct2]] and as - by(auto simp add:group_simps scaleR_right_diff_distrib scaleR_right_distrib) qed + by (auto simp add:algebra_simps scaleR_right_diff_distrib scaleR_right_distrib) qed lemma has_derivative_add_const:"(f has_derivative f') net \ ((\x. f x + c) has_derivative f') net" apply(drule has_derivative_add) apply(rule has_derivative_const) by auto lemma has_derivative_sub: "(f has_derivative f') net \ (g has_derivative g') net \ ((\x. f(x) - g(x)) has_derivative (\h. f'(h) - g'(h))) net" - apply(drule has_derivative_add) apply(drule has_derivative_neg,assumption) by(simp add:group_simps) + apply(drule has_derivative_add) apply(drule has_derivative_neg,assumption) by(simp add:algebra_simps) lemma has_derivative_setsum: assumes "finite s" "\a\s. ((f a) has_derivative (f' a)) net" shows "((\x. setsum (\a. f a x) s) has_derivative (\h. setsum (\a. f' a h) s)) net" @@ -393,8 +394,8 @@ case False hence "norm (f y - (f x + f' (y - x))) < e * norm (y - x)" using as(4)[rule_format, OF `y\s`] unfolding vector_dist_norm diff_0_right norm_mul using as(3) using pos_divide_less_eq[OF False[unfolded dist_nz], unfolded vector_dist_norm] - by(auto simp add:linear_0 linear_sub group_simps) - thus ?thesis by(auto simp add:group_simps) qed qed next + by (auto simp add: linear_0 linear_sub) + thus ?thesis by(auto simp add:algebra_simps) qed qed next assume ?rhs thus ?lhs unfolding has_derivative_within Lim_within apply-apply(erule conjE,rule,assumption) apply(rule,erule_tac x="e/2" in allE,rule,erule impE) defer apply(erule exE,rule_tac x=d in exI) apply(erule conjE,rule,assumption,rule,rule) unfolding vector_dist_norm diff_0_right norm_scaleR @@ -402,7 +403,7 @@ fix e d y assume "bounded_linear f'" "0 < e" "0 < d" "y \ s" "0 < norm (y - x) \ norm (y - x) < d" "norm (f y - f x - f' (y - x)) \ e / 2 * norm (y - x)" thus "\1 / norm (y - x)\ * norm (f y - (f x + f' (y - x))) < e" - apply(rule_tac le_less_trans[of _ "e/2"]) by(auto intro!:mult_imp_div_pos_le simp add:group_simps) qed auto qed + apply(rule_tac le_less_trans[of _ "e/2"]) by(auto intro!:mult_imp_div_pos_le simp add:algebra_simps) qed auto qed lemma has_derivative_at_alt: "(f has_derivative f') (at x) \ bounded_linear f' \ @@ -437,8 +438,8 @@ hence 1:"norm (f y - f x - f' (y - x)) \ min (norm (y - x)) (e / 2 / B2 * norm (y - x))" using d1 d2 d by auto have "norm (f y - f x) \ norm (f y - f x - f' (y - x)) + norm (f' (y - x))" - using norm_triangle_sub[of "f y - f x" "f' (y - x)"] by(auto simp add:group_simps) - also have "\ \ norm (f y - f x - f' (y - x)) + B1 * norm (y - x)" apply(rule add_left_mono) using B1 by(auto simp add:group_simps) + using norm_triangle_sub[of "f y - f x" "f' (y - x)"] by(auto simp add:algebra_simps) + also have "\ \ norm (f y - f x - f' (y - x)) + B1 * norm (y - x)" apply(rule add_left_mono) using B1 by(auto simp add:algebra_simps) also have "\ \ min (norm (y - x)) (e / 2 / B2 * norm (y - x)) + B1 * norm (y - x)" apply(rule add_right_mono) using d1 d2 d as by auto also have "\ \ norm (y - x) + B1 * norm (y - x)" by auto also have "\ = norm (y - x) * (1 + B1)" by(auto simp add:field_simps) @@ -455,8 +456,8 @@ interpret g': bounded_linear g' using assms(2) by auto interpret f': bounded_linear f' using assms(1) by auto have "norm (- g' (f' (y - x)) + g' (f y - f x)) = norm (g' (f y - f x - f' (y - x)))" - by(auto simp add:group_simps f'.diff g'.diff g'.add) - also have "\ \ B2 * norm (f y - f x - f' (y - x))" using B2 by(auto simp add:group_simps) + by(auto simp add:algebra_simps f'.diff g'.diff g'.add) + also have "\ \ B2 * norm (f y - f x - f' (y - x))" using B2 by(auto simp add:algebra_simps) also have "\ \ B2 * (e / 2 / B2 * norm (y - x))" apply(rule mult_left_mono) using as d1 d2 d B2 by auto also have "\ \ e / 2 * norm (y - x)" using B2 by auto finally have 5:"norm (- g' (f' (y - x)) + g' (f y - f x)) \ e / 2 * norm (y - x)" by auto @@ -537,7 +538,7 @@ unfolding scaleR_right_distrib by auto also have "\ = norm ((1 / abs c) *\<^sub>R (c *\<^sub>R (- (f' (basis i)) + f'' (basis i))))" unfolding f'.scaleR f''.scaleR unfolding scaleR_right_distrib scaleR_minus_right by auto - also have "\ = e" unfolding e_def norm_mul using c[THEN conjunct1] using norm_minus_cancel[of "f' (basis i) - f'' (basis i)"] by(auto simp add:group_simps) + also have "\ = e" unfolding e_def norm_mul using c[THEN conjunct1] using norm_minus_cancel[of "f' (basis i) - f'' (basis i)"] by (auto simp add: add.commute ab_diff_minus) finally show False using c using d[THEN conjunct2,rule_format,of "x + c *\<^sub>R basis i"] using norm_basis[of i] unfolding vector_dist_norm unfolding f'.scaleR f''.scaleR f'.add f''.add f'.diff f''.diff scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib by auto qed qed @@ -625,7 +626,7 @@ have ***:"\y y1 y2 d dx::real. (y1\y\y2\y) \ (y\y1\y\y2) \ d < abs dx \ abs(y1 - y - - dx) \ d \ (abs (y2 - y - dx) \ d) \ False" by arith show False apply(rule ***[OF **, where dx="d * D $ k $ j" and d="\D $ k $ j\ / 2 * \d\"]) using *[of "-d"] and *[of d] and d[THEN conjunct1] and j unfolding mult_minus_left - unfolding abs_mult diff_minus_eq_add scaleR.minus_left unfolding group_simps by (auto intro: mult_pos_pos) + unfolding abs_mult diff_minus_eq_add scaleR.minus_left unfolding algebra_simps by (auto intro: mult_pos_pos) qed subsection {* In particular if we have a mapping into @{typ "real^1"}. *} @@ -729,7 +730,7 @@ shows "norm(f x - f y) \ B * norm(x - y)" proof- let ?p = "\u. x + u *\<^sub>R (y - x)" have *:"\u. u\{0..1} \ x + u *\<^sub>R (y - x) \ s" - using assms(1)[unfolded convex_alt,rule_format,OF x y] unfolding scaleR_left_diff_distrib scaleR_right_diff_distrib by(auto simp add:group_simps) + using assms(1)[unfolded convex_alt,rule_format,OF x y] unfolding scaleR_left_diff_distrib scaleR_right_diff_distrib by(auto simp add:algebra_simps) hence 1:"continuous_on {0..1} (f \ ?p)" apply- apply(rule continuous_on_intros continuous_on_vmul)+ unfolding continuous_on_eq_continuous_within apply(rule,rule differentiable_imp_continuous_within) unfolding differentiable_def apply(rule_tac x="f' xa" in exI) @@ -864,7 +865,7 @@ assumes "compact t" "convex t" "t \ {}" "continuous_on t f" "\x\s. \y\t. x + (y - f y) \ t" "x\s" shows "\y\t. f y = x" proof- - have *:"\x y. f y = x \ x + (y - f y) = y" by(auto simp add:group_simps) + have *:"\x y. f y = x \ x + (y - f y) = y" by(auto simp add:algebra_simps) show ?thesis unfolding * apply(rule brouwer[OF assms(1-3), of "\y. x + (y - f y)"]) apply(rule continuous_on_intros assms)+ using assms(4-6) by auto qed @@ -909,8 +910,8 @@ finally have *:"norm (x + g' (z - f x) - x) < e0" by auto have **:"f x + f' (x + g' (z - f x) - x) = z" using assms(6)[unfolded o_def id_def,THEN cong] by auto have "norm (f x - (y + (z - f (x + g' (z - f x))))) \ norm (f (x + g' (z - f x)) - z) + norm (f x - y)" - using norm_triangle_ineq[of "f (x + g'(z - f x)) - z" "f x - y"] by(auto simp add:group_simps) - also have "\ \ 1 / (B * 2) * norm (g' (z - f x)) + norm (f x - y)" using e0[THEN conjunct2,rule_format,OF *] unfolding group_simps ** by auto + using norm_triangle_ineq[of "f (x + g'(z - f x)) - z" "f x - y"] by(auto simp add:algebra_simps) + also have "\ \ 1 / (B * 2) * norm (g' (z - f x)) + norm (f x - y)" using e0[THEN conjunct2,rule_format,OF *] unfolding algebra_simps ** by auto also have "\ \ 1 / (B * 2) * norm (g' (z - f x)) + e/2" using as(1)[unfolded mem_cball vector_dist_norm] by auto also have "\ \ 1 / (B * 2) * B * norm (z - f x) + e/2" using * and B by(auto simp add:field_simps) also have "\ \ 1 / 2 * norm (z - f x) + e/2" by auto @@ -985,7 +986,7 @@ (* we know for some other reason that the inverse function exists, it's OK. *} lemma bounded_linear_sub: "bounded_linear f \ bounded_linear g ==> bounded_linear (\x. f x - g x)" - using bounded_linear_add[of f "\x. - g x"] bounded_linear_minus[of g] by(auto simp add:group_simps) + using bounded_linear_add[of f "\x. - g x"] bounded_linear_minus[of g] by(auto simp add:algebra_simps) lemma has_derivative_locally_injective: fixes f::"real^'n \ real^'m" assumes "a \ s" "open s" "bounded_linear g'" "g' o f'(a) = id" @@ -1006,7 +1007,7 @@ show "\x\ball a d. \x'\ball a d. f x' = f x \ x' = x" proof(intro strip) fix x y assume as:"x\ball a d" "y\ball a d" "f x = f y" def ph \ "\w. w - g'(f w - f x)" have ph':"ph = g' \ (\w. f' a w - (f w - f x))" - unfolding ph_def o_def unfolding diff using f'g' by(auto simp add:group_simps) + unfolding ph_def o_def unfolding diff using f'g' by(auto simp add:algebra_simps) have "norm (ph x - ph y) \ (1/2) * norm (x - y)" apply(rule differentiable_bound[OF convex_ball _ _ as(1-2), where f'="\x v. v - g'(f' x v)"]) apply(rule_tac[!] ballI) proof- fix u assume u:"u \ ball a d" hence "u\s" using d d2 by auto @@ -1022,7 +1023,7 @@ unfolding linear_conv_bounded_linear by(rule assms(3) **)+ also have "\ \ onorm g' * k" apply(rule mult_left_mono) using d1[THEN conjunct2,rule_format,of u] using onorm_neg[OF **(1)[unfolded linear_linear]] - using d and u and onorm_pos_le[OF assms(3)[unfolded linear_linear]] by(auto simp add:group_simps) + using d and u and onorm_pos_le[OF assms(3)[unfolded linear_linear]] by(auto simp add:algebra_simps) also have "\ \ 1/2" unfolding k_def by auto finally show "onorm (\v. v - g' (f' u v)) \ 1 / 2" by assumption qed moreover have "norm (ph y - ph x) = norm (y - x)" apply(rule arg_cong[where f=norm]) @@ -1041,7 +1042,7 @@ fix x assume "x\s" show "((\a. f m a - f n a) has_derivative (\h. f' m x h - f' n x h)) (at x within s)" by(rule has_derivative_intros assms(2)[rule_format] `x\s`)+ { fix h have "norm (f' m x h - f' n x h) \ norm (f' m x h - g' x h) + norm (f' n x h - g' x h)" - using norm_triangle_ineq[of "f' m x h - g' x h" "- f' n x h + g' x h"] unfolding norm_minus_commute by(auto simp add:group_simps) + using norm_triangle_ineq[of "f' m x h - g' x h" "- f' n x h + g' x h"] unfolding norm_minus_commute by(auto simp add:algebra_simps) also have "\ \ e * norm h+ e * norm h" using assms(3)[rule_format,OF `N\m` `x\s`, of h] assms(3)[rule_format,OF `N\n` `x\s`, of h] by(auto simp add:field_simps) finally have "norm (f' m x h - f' n x h) \ 2 * e * norm h" by auto } @@ -1085,7 +1086,7 @@ have "eventually (\xa. norm (f n x - f n y - (f xa x - f xa y)) \ e * norm (x - y)) sequentially" unfolding eventually_sequentially apply(rule_tac x=N in exI) proof(rule,rule) fix m assume "N\m" thus "norm (f n x - f n y - (f m x - f m y)) \ e * norm (x - y)" - using N[rule_format, of n m x y] and as by(auto simp add:group_simps) qed + using N[rule_format, of n m x y] and as by(auto simp add:algebra_simps) qed thus "norm (f n x - f n y - (g x - g y)) \ e * norm (x - y)" apply- apply(rule Lim_norm_ubound[OF trivial_limit_sequentially, where f="\m. (f n x - f n y) - (f m x - f m y)"]) apply(rule Lim_sub Lim_const g[rule_format] as)+ by assumption qed qed @@ -1122,10 +1123,10 @@ have "norm (f ?N y - f ?N x - f' ?N x (y - x)) \ e / 3 * norm (y - x)" using d1 and as by auto ultimately have "norm (g y - g x - f' ?N x (y - x)) \ 2 * e / 3 * norm (y - x)" using norm_triangle_le[of "g y - g x - (f ?N y - f ?N x)" "f ?N y - f ?N x - f' ?N x (y - x)" "2 * e / 3 * norm (y - x)"] - by (auto simp add:group_simps) moreover + by (auto simp add:algebra_simps) moreover have " norm (f' ?N x (y - x) - g' x (y - x)) \ e / 3 * norm (y - x)" using N1 `x\s` by auto ultimately show "norm (g y - g x - g' x (y - x)) \ e * norm (y - x)" - using norm_triangle_le[of "g y - g x - f' (max N1 N2) x (y - x)" "f' (max N1 N2) x (y - x) - g' x (y - x)"] by(auto simp add:group_simps) + using norm_triangle_le[of "g y - g x - f' (max N1 N2) x (y - x)" "f' (max N1 N2) x (y - x) - g' x (y - x)"] by(auto simp add:algebra_simps) qed qed qed qed subsection {* Can choose to line up antiderivatives if we want. *} @@ -1276,7 +1277,7 @@ unfolding has_vector_derivative_def using has_derivative_id by auto lemma has_vector_derivative_cmul: "(f has_vector_derivative f') net \ ((\x. c *\<^sub>R f x) has_vector_derivative (c *\<^sub>R f')) net" - unfolding has_vector_derivative_def apply(drule has_derivative_cmul) by(auto simp add:group_simps) + unfolding has_vector_derivative_def apply(drule has_derivative_cmul) by(auto simp add:algebra_simps) lemma has_vector_derivative_cmul_eq: assumes "c \ 0" shows "(((\x. c *\<^sub>R f x) has_vector_derivative (c *\<^sub>R f')) net \ (f has_vector_derivative f') net)"