# HG changeset patch # User wenzelm # Date 1393022563 -3600 # Node ID 4381a2b622ea588978dc36f189e9319ede3b06b6 # Parent bab10fb557c2b9bd40454a73468c12cdcf44a785 tuned proofs; diff -r bab10fb557c2 -r 4381a2b622ea src/HOL/Multivariate_Analysis/Derivative.thy --- a/src/HOL/Multivariate_Analysis/Derivative.thy Fri Feb 21 21:27:55 2014 +0100 +++ b/src/HOL/Multivariate_Analysis/Derivative.thy Fri Feb 21 23:42:43 2014 +0100 @@ -479,7 +479,8 @@ proof (rule, rule) fix e :: real assume "e > 0" - guess d using assms(3)[rule_format,OF SOME_Basis `e>0`] .. + obtain d where "0 < \d\" and "\d\ < e" and "x + d *\<^sub>R (SOME i. i \ Basis) \ s" + using assms(3) SOME_Basis `e>0` by blast then show "\x'\s. x' \ x \ dist x' x < e" apply (rule_tac x="x + d *\<^sub>R (SOME i. i \ Basis)" in bexI) unfolding dist_norm @@ -503,8 +504,16 @@ assume "f' i \ f'' i" then have "e > 0" unfolding e_def by auto - guess d using tendsto_diff [OF as(1,2)[THEN conjunct2], unfolded * Lim_within,rule_format,OF `e>0`] .. note d=this - guess c using assms(3)[rule_format,OF i d[THEN conjunct1]] .. note c=this + obtain d where d: + "0 < d" + "(\xa. xa\s \ 0 < dist xa x \ dist xa x < d \ + dist ((f xa - f x - f' (xa - x)) /\<^sub>R norm (xa - x) - + (f xa - f x - f'' (xa - x)) /\<^sub>R norm (xa - x)) (0 - 0) < e)" + using tendsto_diff [OF as(1,2)[THEN conjunct2]] + unfolding * Lim_within + using `e>0` by blast + obtain c where c: "0 < \c\" "\c\ < d \ x + c *\<^sub>R i \ s" + using assms(3) i d(1) by blast have *: "norm (- ((1 / \c\) *\<^sub>R f' (c *\<^sub>R i)) + (1 / \c\) *\<^sub>R f'' (c *\<^sub>R i)) = norm ((1 / abs c) *\<^sub>R (- (f' (c *\<^sub>R i)) + f'' (c *\<^sub>R i)))" unfolding scaleR_right_distrib by auto @@ -514,12 +523,12 @@ by auto also have "\ = e" unfolding e_def - using c[THEN conjunct1] + using c(1) using norm_minus_cancel[of "f' i - f'' i"] by auto finally show False using c - using d[THEN conjunct2,rule_format,of "x + c *\<^sub>R i"] + using d(2)[of "x + c *\<^sub>R i"] unfolding dist_norm unfolding f'.scaleR f''.scaleR f'.add f''.add f'.diff f''.diff scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib @@ -671,8 +680,15 @@ then have *: "\?D k \ j\ / 2 > 0" by auto note as = diff[unfolded jacobian_works has_derivative_at_alt] - guess e' using as[THEN conjunct2, rule_format, OF *] .. note e' = this - guess d using real_lbound_gt_zero[OF ball(1) e'[THEN conjunct1]] .. note d = this + obtain e' where e': + "0 < e'" + "(\y. norm (y - x) < e' \ + norm (f y - f x - + (\i\Basis. (\j\Basis. frechet_derivative f (at x) j \ i * ((y - x) \ j)) *\<^sub>R i)) + \ \(\j\Basis. (frechet_derivative f (at x) j \ k) *\<^sub>R j) \ j\ / 2 * norm (y - x))" + using as[THEN conjunct2] * by blast + obtain d where d: "0 < d" "d < e" "d < e'" + using real_lbound_gt_zero[OF ball(1) e'(1)] by blast { fix c assume "abs c \ d" @@ -684,7 +700,7 @@ have "\(f (x + c *\<^sub>R j) - f x - ?v) \ k\ \ norm (f (x + c *\<^sub>R j) - f x - ?v)" by (rule Basis_le_norm[OF k]) also have "\ \ \?D k \ j\ / 2 * \c\" - using e'[THEN conjunct2, rule_format, OF *] and norm_Basis[OF j(2)] j + using e'(2)[OF *] and norm_Basis[OF j(2)] j by simp finally have "\(f (x + c *\<^sub>R j) - f x - ?v) \ k\ \ \?D k \ j\ / 2 * \c\" by simp @@ -705,7 +721,7 @@ 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 + using *[of "-d"] and *[of d] and d(1) and j unfolding mult_minus_left unfolding abs_mult diff_minus_eq_add scaleR_minus_left unfolding algebra_simps @@ -750,8 +766,14 @@ using assms(1) by auto then have *: "{a..b} \ {}" by auto - guess d using continuous_attains_sup[OF compact_interval * assms(3)] .. note d=this - guess c using continuous_attains_inf[OF compact_interval * assms(3)] .. note c=this + obtain d where d: + "d \ {a..b}" + "\y\{a..b}. f y \ f d" + using continuous_attains_sup[OF compact_interval * assms(3)] .. + obtain c where c: + "c \ {a..b}" + "\y\{a..b}. f c \ f y" + using continuous_attains_inf[OF compact_interval * assms(3)] .. show ?thesis proof (cases "d \ box a b \ c \ box a b") case True @@ -781,7 +803,7 @@ done qed qed - then guess x .. note x=this + then obtain x where x: "x \ box a b" "(\y\box a b. f x \ f y) \ (\y\box a b. f y \ f x)" .. then have "f' x = (\v. 0)" apply (rule_tac differential_zero_maxmin[of x "box a b" f "f' x"]) defer @@ -821,7 +843,9 @@ (\xa. f' x xa - (f b - f a) / (b - a) * xa)) (at x)" by (intro FDERIV_intros assms(3)[rule_format,OF x] mult_right_has_derivative) qed (insert assms(1,2), auto intro!: continuous_on_intros simp: field_simps) - then guess x .. + then obtain x where + "x \ box a b" + "(\xa. f' x xa - (f b - f a) / (b - a) * xa) = (\v. 0)" .. then show ?thesis apply (rule_tac x=x in bexI) apply (drule fun_cong[of _ _ "b - a"]) @@ -894,7 +918,9 @@ using assms(3) apply auto done - then guess x .. note x=this + then obtain x where x: + "x \ {a<.. (f b - f a) \ f) b - (op \ (f b - f a) \ f) a = (f b - f a) \ f' x (b - a)" .. show ?thesis proof (cases "f a = f b") case False @@ -965,7 +991,11 @@ then show ?case unfolding has_derivative_within_open[OF goal1 open_greaterThanLessThan] . qed - guess u using mvt_general[OF zero_less_one 1 2] .. note u = this + obtain u where u: + "u \ {0<..<1}" + "norm ((f \ (\u. x + u *\<^sub>R (y - x))) 1 - (f \ (\u. x + u *\<^sub>R (y - x))) 0) + \ norm ((f' (x + u *\<^sub>R (y - x)) \ (\u. 0 + u *\<^sub>R (y - x))) (1 - 0))" + using mvt_general[OF zero_less_one 1 2] .. have **: "\x y. x \ s \ norm (f' x y) \ B * norm y" proof - case goal1 @@ -1063,20 +1093,37 @@ using assms unfolding has_derivative_def by auto interpret g': bounded_linear g' using assms by auto - guess C using bounded_linear.pos_bounded[OF assms(2)] .. note C = this + obtain C where C: "0 < C" "\x. norm (g' x) \ norm x * C" + using bounded_linear.pos_bounded[OF assms(2)] by blast have lem1: "\e>0. \d>0. \z. norm (z - y) < d \ norm (g z - g y - g'(z - y)) \ e * norm (g z - g y)" proof (rule, rule) case goal1 have *: "e / C > 0" apply (rule divide_pos_pos) - using `e > 0` C + using `e > 0` C(1) apply auto done - guess d0 using assms(1)[unfolded has_derivative_at_alt,THEN conjunct2,rule_format,OF *] .. note d0=this - guess d1 using assms(4)[unfolded continuous_at Lim_at,rule_format,OF d0[THEN conjunct1]] .. note d1=this - guess d2 using assms(5)[unfolded open_dist,rule_format,OF assms(6)] .. note d2=this - guess d using real_lbound_gt_zero[OF d1[THEN conjunct1] d2[THEN conjunct1]] .. note d=this + obtain d0 where d0: + "0 < d0" + "\ya. norm (ya - g y) < d0 \ norm (f ya - f (g y) - f' (ya - g y)) \ e / C * norm (ya - g y)" + using assms(1) + unfolding has_derivative_at_alt + using * by blast + obtain d1 where d1: + "0 < d1" + "\x. 0 < dist x y \ dist x y < d1 \ dist (g x) (g y) < d0" + using assms(4) + unfolding continuous_at Lim_at + using d0(1) by blast + obtain d2 where d2: + "0 < d2" + "\ya. dist ya y < d2 \ ya \ t" + using assms(5) + unfolding open_dist + using assms(6) by blast + obtain d where d: "0 < d" "d < d1" "d < d2" + using real_lbound_gt_zero[OF d1(1) d2(1)] by blast then show ?case apply (rule_tac x=d in exI) apply rule @@ -1096,13 +1143,13 @@ apply auto done also have "\ \ norm (f (g z) - y - f' (g z - g y)) * C" - by (rule C [THEN conjunct2, rule_format]) + by (rule C(2)) also have "\ \ (e / C) * norm (g z - g y) * C" apply (rule mult_right_mono) - apply (rule d0[THEN conjunct2,rule_format,unfolded assms(7)[rule_format,OF `y\t`]]) + apply (rule d0(2)[rule_format,unfolded assms(7)[rule_format,OF `y\t`]]) apply (cases "z = y") defer - apply (rule d1[THEN conjunct2, unfolded dist_norm,rule_format]) + apply (rule d1(2)[unfolded dist_norm,rule_format]) using as d C d0 apply auto done @@ -1114,8 +1161,11 @@ qed have *: "(0::real) < 1 / 2" by auto - guess d using lem1[rule_format,OF *] .. note d=this - def B\"C * 2" + obtain d where d: + "0 < d" + "\z. norm (z - y) < d \ norm (g z - g y - g' (z - y)) \ 1 / 2 * norm (g z - g y)" + using lem1 * by blast + def B \ "C * 2" have "B > 0" unfolding B_def using C by auto have lem2: "\z. norm(z - y) < d \ norm (g z - g y) \ B * norm (z - y)" @@ -1151,8 +1201,12 @@ using `B > 0` apply auto done - guess d' using lem1[rule_format,OF *] .. note d'=this - guess k using real_lbound_gt_zero[OF d[THEN conjunct1] d'[THEN conjunct1]] .. note k=this + obtain d' where d': + "0 < d'" + "\z. norm (z - y) < d' \ norm (g z - g y - g' (z - y)) \ e / B * norm (g z - g y)" + using lem1 * by blast + obtain k where k: "0 < k" "k < d" "k < d'" + using real_lbound_gt_zero[OF d(1) d'(1)] by blast show ?case apply (rule_tac x=k in exI) apply rule @@ -1306,17 +1360,27 @@ interpret g': bounded_linear g' using assms by auto - guess B using bounded_linear.pos_bounded[OF assms(5)] .. note B=this + obtain B where B: "0 < B" "\x. norm (g' x) \ norm x * B" + using bounded_linear.pos_bounded[OF assms(5)] by blast then have *: "1 / (2 * B) > 0" by (auto intro!: divide_pos_pos) - guess e0 using assms(4)[unfolded has_derivative_at_alt,THEN conjunct2,rule_format,OF *] .. note e0=this - guess e1 using assms(8)[unfolded mem_interior_cball] .. note e1=this + obtain e0 where e0: + "0 < e0" + "\y. norm (y - x) < e0 \ norm (f y - f x - f' (y - x)) \ 1 / (2 * B) * norm (y - x)" + using assms(4) + unfolding has_derivative_at_alt + using * by blast + obtain e1 where e1: "0 < e1" "cball x e1 \ t" + using assms(8) + unfolding mem_interior_cball + by blast have *: "0 < e0 / B" "0 < e1 / B" apply (rule_tac[!] divide_pos_pos) using e0 e1 B apply auto done - guess e using real_lbound_gt_zero[OF *] .. note e=this + obtain e where e: "0 < e" "e < e0 / B" "e < e1 / B" + using real_lbound_gt_zero[OF *] by blast have "\z\cball (f x) (e / 2). \y\cball (f x) e. f (x + g' (y - f x)) = z" apply rule apply (rule brouwer_surjective_cball[where s="cball (f x) (e/2)"]) @@ -1381,7 +1445,7 @@ 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 *] + using e0(2)[rule_format, OF *] unfolding algebra_simps ** by auto also have "\ \ 1 / (B * 2) * norm (g' (z - f x)) + e/2" @@ -1413,7 +1477,8 @@ assume "y \ ball (f x) (e / 2)" then have *: "y \ cball (f x) (e / 2)" by auto - guess z using lem[rule_format,OF *] .. note z=this + obtain z where z: "z \ cball (f x) e" "f (x + g' (z - f x)) = y" + using lem * by blast then have "norm (g' (z - f x)) \ norm (z - f x) * B" using B by (auto simp add: field_simps) @@ -1428,7 +1493,7 @@ using e B unfolding less_divide_eq by auto finally have "x + g'(z - f x) \ t" apply - - apply (rule e1[THEN conjunct2,unfolded subset_eq,rule_format]) + apply (rule e1(2)[unfolded subset_eq,rule_format]) unfolding mem_cball dist_norm apply auto done @@ -1504,17 +1569,18 @@ then have "f x \ interior (f ` (ball x e \ s))" using *[rule_format,of "ball x e \ s"] `x \ s` by (auto simp add: interior_open[OF open_ball] interior_open[OF assms(1)]) - then guess d unfolding mem_interior .. note d=this + then obtain d where d: "0 < d" "ball (f x) d \ f ` (ball x e \ s)" + unfolding mem_interior by blast show "\d>0. \y. 0 < dist y (f x) \ dist y (f x) < d \ dist (g y) (g (f x)) < e" apply (rule_tac x=d in exI) apply rule - apply (rule d[THEN conjunct1]) + apply (rule d(1)) apply rule apply rule proof - case goal1 then have "g y \ g ` f ` (ball x e \ s)" - using d[THEN conjunct2,unfolded subset_eq,THEN bspec[where x=y]] + using d(2)[unfolded subset_eq,THEN bspec[where x=y]] by (auto simp add: dist_commute) then have "g y \ ball x e \ s" using assms(4) by auto @@ -1534,7 +1600,7 @@ case goal1 then have "y \ f ` s" using interior_subset by auto - then guess z unfolding image_iff .. + then obtain z where "z \ s" "y = f z" unfolding image_iff .. then show ?case using assms(4) by auto qed @@ -1617,15 +1683,20 @@ def k \ "1 / onorm g' / 2" have *: "k > 0" unfolding k_def using * by auto - guess d1 using assms(6)[rule_format,OF *] .. note d1=this + obtain d1 where d1: + "0 < d1" + "\x. dist a x < d1 \ onorm (\v. f' x v - f' a v) < k" + using assms(6) * by blast from `open s` obtain d2 where "d2 > 0" "ball a d2 \ s" using `a\s` .. obtain d2 where "d2 > 0" "ball a d2 \ s" using assms(2,1) .. - guess d2 using assms(2)[unfolded open_contains_ball,rule_format,OF `a\s`] .. - note d2=this - guess d using real_lbound_gt_zero[OF d1[THEN conjunct1] d2[THEN conjunct1]] .. - note d = this + obtain d2 where d2: "0 < d2" "ball a d2 \ s" + using assms(2) + unfolding open_contains_ball + using `a\s` by blast + obtain d where d: "0 < d" "d < d1" "d < d2" + using real_lbound_gt_zero[OF d1(1) d2(1)] by blast show ?thesis proof show "a \ ball a d" @@ -1676,7 +1747,7 @@ done also have "\ \ onorm g' * k" apply (rule mult_left_mono) - using d1[THEN conjunct2,rule_format,of u] + using d1(2)[of u] using onorm_neg[OF **(1)[unfolded linear_linear]] using d and u and onorm_pos_le[OF assms(3)[unfolded linear_linear]] apply (auto simp add: algebra_simps) @@ -1753,7 +1824,8 @@ proof (rule, rule) case goal1 have *: "2 * (1/2* e) = e" "1/2 * e >0" using `e > 0` by auto - guess N using assms(3)[rule_format,OF *(2)] .. + obtain N where "\n\N. \x\s. \h. norm (f' n x h - g' x h) \ 1 / 2 * e * norm h" + using assms(3) *(2) by blast then show ?case apply (rule_tac x=N in exI) apply (rule has_derivative_sequence_lipschitz_lemma[where e="1/2 *e", unfolded *]) @@ -1797,8 +1869,15 @@ assume "e > 0" then have *: "e / 2 > 0" "e / 2 / norm (x - x0) > 0" using False by (auto intro!: divide_pos_pos) - guess M using LIMSEQ_imp_Cauchy[OF assms(5), unfolded Cauchy_def, rule_format,OF *(1)] .. note M=this - guess N using lem1[rule_format,OF *(2)] .. note N = this + obtain M where M: "\m\M. \n\M. dist (f m x0) (f n x0) < e / 2" + using LIMSEQ_imp_Cauchy[OF assms(5)] + unfolding Cauchy_def + using *(1) by blast + obtain N where N: + "\m\N. \n\N. + \xa\s. \y\s. norm (f m xa - f n xa - (f m y - f n y)) \ + e / 2 / norm (x - x0) * norm (xa - y)" + using lem1 *(2) by blast show "\M. \m\M. \n\M. dist (f m x) (f n x) < e" apply (rule_tac x="max M N" in exI) proof rule+ @@ -1823,12 +1902,14 @@ qed qed qed - then guess g .. note g = this + then obtain g where g: "\x\s. (\n. f n x) ----> g x" .. have lem2: "\e>0. \N. \n\N. \x\s. \y\s. norm ((f n x - f n y) - (g x - g y)) \ e * norm (x - y)" proof (rule, rule) fix e :: real assume *: "e > 0" - guess N using lem1[rule_format,OF *] .. note N=this + obtain N where + N: "\m\N. \n\N. \x\s. \y\s. norm (f m x - f n x - (f m y - f n y)) \ e * norm (x - y)" + using lem1 * by blast show "\N. \n\N. \x\s. \y\s. norm (f n x - f n y - (g x - g y)) \ e * norm (x - y)" apply (rule_tac x=N in exI) proof rule+ @@ -1873,7 +1954,8 @@ show "\N. \n\N. dist (f' n x u) (g' x u) < e" proof (cases "u = 0") case True - guess N using assms(3)[rule_format,OF `e>0`] .. note N=this + obtain N where N: "\n\N. \x\s. \h. norm (f' n x h - g' x h) \ e * norm h" + using assms(3) `e>0` by blast show ?thesis apply (rule_tac x=N in exI) unfolding True @@ -1885,7 +1967,8 @@ then have *: "e / 2 / norm u > 0" using `e > 0` by (auto intro!: divide_pos_pos) - guess N using assms(3)[rule_format,OF *] .. note N=this + obtain N where N: "\n\N. \x\s. \h. norm (f' n x h - g' x h) \ e / 2 / norm u * norm h" + using assms(3) * by blast show ?thesis apply (rule_tac x=N in exI) apply rule @@ -1931,13 +2014,23 @@ case goal1 have *: "e / 3 > 0" using goal1 by auto - guess N1 using assms(3)[rule_format,OF *] .. note N1=this - guess N2 using lem2[rule_format,OF *] .. note N2=this - guess d1 using assms(2)[unfolded has_derivative_within_alt, rule_format,OF `x\s`, of "max N1 N2",THEN conjunct2,rule_format,OF *] .. note d1=this + obtain N1 where N1: "\n\N1. \x\s. \h. norm (f' n x h - g' x h) \ e / 3 * norm h" + using assms(3) * by blast + obtain N2 where + N2: "\n\N2. \x\s. \y\s. norm (f n x - f n y - (g x - g y)) \ e / 3 * norm (x - y)" + using lem2 * by blast + obtain d1 where d1: + "0 < d1" + "\y\s. norm (y - x) < d1 \ + norm (f (max N1 N2) y - f (max N1 N2) x - f' (max N1 N2) x (y - x)) \ + e / 3 * norm (y - x)" + using assms(2)[unfolded has_derivative_within_alt, rule_format, + OF `x\s`, of "max N1 N2", THEN conjunct2, rule_format, OF *] + by blast show ?case apply (rule_tac x=d1 in exI) apply rule - apply (rule d1[THEN conjunct1]) + apply (rule d1(1)) apply rule apply rule proof - @@ -2009,8 +2102,14 @@ apply (erule_tac x="inverse (real (Suc n))" in allE) apply auto done - guess f using *[THEN choice] .. note * = this - guess f' using *[THEN choice] .. note f = this + obtain f where + *: "\x. \f'. \xa\s. FDERIV (f x) xa : s :> f' xa \ + (\h. norm (f' xa h - g' xa h) \ inverse (real (Suc x)) * norm h)" + using *[THEN choice] .. + obtain f' where + f: "\x. \xa\s. FDERIV (f x) xa : s :> f' x xa \ + (\h. norm (f' x xa h - g' xa h) \ inverse (real (Suc x)) * norm h)" + using *[THEN choice] .. show ?thesis apply (rule has_antiderivative_sequence[OF assms(1), of f f']) defer @@ -2019,7 +2118,8 @@ proof - fix e :: real assume "e > 0" - guess N using reals_Archimedean[OF `e>0`] .. note N=this + obtain N where N: "inverse (real (Suc N)) < e" + using reals_Archimedean[OF `e>0`] .. show "\N. \n\N. \x\s. \h. norm (f' n x h - g' x h) \ e * norm h" apply (rule_tac x=N in exI) proof rule+ @@ -2082,7 +2182,8 @@ (is "?l = ?r") proof assume ?l - guess f' using `?l`[unfolded differentiable_def] .. note f' = this + obtain f' where f': "(f has_derivative f') net" + using `?l` unfolding differentiable_def .. then interpret bounded_linear f' by auto show ?r