# HG changeset patch # User immler # Date 1519309045 -3600 # Node ID bdff8bf0a75bff999eaccd5ed2ae1f913f0b23bf # Parent 00c43648839802ef0899ecd019427a0e6d7ac719 moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Borel_Space.thy --- a/src/HOL/Analysis/Borel_Space.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Borel_Space.thy Thu Feb 22 15:17:25 2018 +0100 @@ -242,6 +242,11 @@ shows "S \ {} \ bdd_above S \ closed S \ Sup S \ S" by (subst closure_closed[symmetric], assumption, rule closure_contains_Sup) +lemma closed_subset_contains_Sup: + fixes A C :: "real set" + shows "closed C \ A \ C \ A \ {} \ bdd_above A \ Sup A \ C" + by (metis closure_contains_Sup closure_minimal subset_eq) + lemma deriv_nonneg_imp_mono: assumes deriv: "\x. x \ {a..b} \ (g has_real_derivative g' x) (at x)" assumes nonneg: "\x. x \ {a..b} \ g' x \ 0" diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Bounded_Linear_Function.thy --- a/src/HOL/Analysis/Bounded_Linear_Function.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Bounded_Linear_Function.thy Thu Feb 22 15:17:25 2018 +0100 @@ -8,8 +8,35 @@ imports Topology_Euclidean_Space Operator_Norm + Uniform_Limit begin +lemma onorm_componentwise: + assumes "bounded_linear f" + shows "onorm f \ (\i\Basis. norm (f i))" +proof - + { + fix i::'a + assume "i \ Basis" + hence "onorm (\x. (x \ i) *\<^sub>R f i) \ onorm (\x. (x \ i)) * norm (f i)" + by (auto intro!: onorm_scaleR_left_lemma bounded_linear_inner_left) + also have "\ \ norm i * norm (f i)" + by (rule mult_right_mono) + (auto simp: ac_simps Cauchy_Schwarz_ineq2 intro!: onorm_le) + finally have "onorm (\x. (x \ i) *\<^sub>R f i) \ norm (f i)" using \i \ Basis\ + by simp + } hence "onorm (\x. \i\Basis. (x \ i) *\<^sub>R f i) \ (\i\Basis. norm (f i))" + by (auto intro!: order_trans[OF onorm_sum_le] bounded_linear_scaleR_const + sum_mono bounded_linear_inner_left) + also have "(\x. \i\Basis. (x \ i) *\<^sub>R f i) = (\x. f (\i\Basis. (x \ i) *\<^sub>R i))" + by (simp add: linear_sum bounded_linear.linear assms linear_simps) + also have "\ = f" + by (simp add: euclidean_representation) + finally show ?thesis . +qed + +lemmas onorm_componentwise_le = order_trans[OF onorm_componentwise] + subsection \Intro rules for @{term bounded_linear}\ named_theorems bounded_linear_intros @@ -447,6 +474,15 @@ shows "continuous F f" using assms by (auto simp: continuous_def intro!: tendsto_componentwise1) +lemma + continuous_on_blinfun_componentwise: + fixes f:: "'d::t2_space \ 'e::euclidean_space \\<^sub>L 'f::real_normed_vector" + assumes "\i. i \ Basis \ continuous_on s (\x. f x i)" + shows "continuous_on s f" + using assms + by (auto intro!: continuous_at_imp_continuous_on intro!: tendsto_componentwise1 + simp: continuous_on_eq_continuous_within continuous_def) + lemma bounded_linear_blinfun_matrix: "bounded_linear (\x. (x::_\\<^sub>L _) j \ i)" by (auto intro!: bounded_linearI' bounded_linear_intros) @@ -692,4 +728,9 @@ lemma bounded_linear_blinfun_mult_left[bounded_linear]: "bounded_linear blinfun_mult_left" by transfer (rule bounded_bilinear.flip[OF bounded_bilinear_mult]) +lemmas bounded_linear_function_uniform_limit_intros[uniform_limit_intros] = + bounded_linear.uniform_limit[OF bounded_linear_apply_blinfun] + bounded_linear.uniform_limit[OF bounded_linear_blinfun_apply] + bounded_linear.uniform_limit[OF bounded_linear_blinfun_matrix] + end diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Cartesian_Euclidean_Space.thy --- a/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Thu Feb 22 15:17:25 2018 +0100 @@ -1,7 +1,7 @@ section \Instantiates the finite Cartesian product of Euclidean spaces as a Euclidean space.\ theory Cartesian_Euclidean_Space -imports Finite_Cartesian_Product Derivative +imports Finite_Cartesian_Product Derivative begin lemma subspace_special_hyperplane: "subspace {x. x $ k = 0}" @@ -1455,4 +1455,9 @@ unfolding vec_lambda_beta by auto +lemmas cartesian_euclidean_space_uniform_limit_intros[uniform_limit_intros] = + bounded_linear.uniform_limit[OF blinfun.bounded_linear_right] + bounded_linear.uniform_limit[OF bounded_linear_vec_nth] + bounded_linear.uniform_limit[OF bounded_linear_component_cart] + end diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Cauchy_Integral_Theorem.thy --- a/src/HOL/Analysis/Cauchy_Integral_Theorem.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Cauchy_Integral_Theorem.thy Thu Feb 22 15:17:25 2018 +0100 @@ -1199,7 +1199,7 @@ lemma vector_derivative_linepath_within: "x \ {0..1} \ vector_derivative (linepath a b) (at x within {0..1}) = b - a" - apply (rule vector_derivative_within_closed_interval [of 0 "1::real", simplified]) + apply (rule vector_derivative_within_cbox [of 0 "1::real", simplified]) apply (auto simp: has_vector_derivative_linepath_within) done @@ -2695,7 +2695,7 @@ then have *: "(\y. (?pathint x y - f x * (y - x)) /\<^sub>R cmod (y - x)) \x\ 0" by (simp add: Lim_at dist_norm inverse_eq_divide) show ?thesis - apply (simp add: has_field_derivative_def has_derivative_at bounded_linear_mult_right) + apply (simp add: has_field_derivative_def has_derivative_at2 bounded_linear_mult_right) apply (rule Lim_transform [OF * Lim_eventually]) apply (simp add: inverse_eq_divide [symmetric] eventually_at) using \open s\ x @@ -3573,7 +3573,7 @@ if "x \ {0..1} - S" for x proof - have "vector_derivative (uminus \ \) (at x within cbox 0 1) = - vector_derivative \ (at x within cbox 0 1)" - apply (rule vector_derivative_within_closed_interval) + apply (rule vector_derivative_within_cbox) using that apply (auto simp: o_def) apply (rule has_vector_derivative_minus) diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Connected.thy --- a/src/HOL/Analysis/Connected.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Connected.thy Thu Feb 22 15:17:25 2018 +0100 @@ -1095,6 +1095,43 @@ qed qed +text \Hence some handy theorems on distance, diameter etc. of/from a set.\ + +lemma distance_attains_sup: + assumes "compact s" "s \ {}" + shows "\x\s. \y\s. dist a y \ dist a x" +proof (rule continuous_attains_sup [OF assms]) + { + fix x + assume "x\s" + have "(dist a \ dist a x) (at x within s)" + by (intro tendsto_dist tendsto_const tendsto_ident_at) + } + then show "continuous_on s (dist a)" + unfolding continuous_on .. +qed + +text \For \emph{minimal} distance, we only need closure, not compactness.\ + +lemma distance_attains_inf: + fixes a :: "'a::heine_borel" + assumes "closed s" and "s \ {}" + obtains x where "x\s" "\y. y \ s \ dist a x \ dist a y" +proof - + from assms obtain b where "b \ s" by auto + let ?B = "s \ cball a (dist b a)" + have "?B \ {}" using \b \ s\ + by (auto simp: dist_commute) + moreover have "continuous_on ?B (dist a)" + by (auto intro!: continuous_at_imp_continuous_on continuous_dist continuous_ident continuous_const) + moreover have "compact ?B" + by (intro closed_Int_compact \closed s\ compact_cball) + ultimately obtain x where "x \ ?B" "\y\?B. dist a x \ dist a y" + by (metis continuous_attains_inf) + with that show ?thesis by fastforce +qed + + subsection\Relations among convergence and absolute convergence for power series.\ lemma summable_imp_bounded: @@ -1353,6 +1390,24 @@ shows "infdist x S > 0" using in_closed_iff_infdist_zero[OF assms(1) assms(2), of x] assms(3) infdist_nonneg le_less by fastforce +lemma + infdist_attains_inf: + fixes X::"'a::heine_borel set" + assumes "closed X" + assumes "X \ {}" + obtains x where "x \ X" "infdist y X = dist y x" +proof - + have "bdd_below (dist y ` X)" + by auto + from distance_attains_inf[OF assms, of y] + obtain x where INF: "x \ X" "\z. z \ X \ dist y x \ dist y z" by auto + have "infdist y X = dist y x" + by (auto simp: infdist_def assms + intro!: antisym cINF_lower[OF _ \x \ X\] cINF_greatest[OF assms(2) INF(2)]) + with \x \ X\ show ?thesis .. +qed + + text \Every metric space is a T4 space:\ instance metric_space \ t4_space @@ -1423,6 +1478,36 @@ shows "continuous F (\x. infdist (f x) A)" using assms unfolding continuous_def by (rule tendsto_infdist) +lemma compact_infdist_le: + fixes A::"'a::heine_borel set" + assumes "A \ {}" + assumes "compact A" + assumes "e > 0" + shows "compact {x. infdist x A \ e}" +proof - + from continuous_closed_vimage[of "{0..e}" "\x. infdist x A"] + continuous_infdist[OF continuous_ident, of _ UNIV A] + have "closed {x. infdist x A \ e}" by (auto simp: vimage_def infdist_nonneg) + moreover + from assms obtain x0 b where b: "\x. x \ A \ dist x0 x \ b" "closed A" + by (auto simp: compact_eq_bounded_closed bounded_def) + { + fix y + assume le: "infdist y A \ e" + from infdist_attains_inf[OF \closed A\ \A \ {}\, of y] + obtain z where z: "z \ A" "infdist y A = dist y z" by blast + have "dist x0 y \ dist y z + dist x0 z" + by (metis dist_commute dist_triangle) + also have "dist y z \ e" using le z by simp + also have "dist x0 z \ b" using b z by simp + finally have "dist x0 y \ b + e" by arith + } then + have "bounded {x. infdist x A \ e}" + by (auto simp: bounded_any_center[where a=x0] intro!: exI[where x="b + e"]) + ultimately show "compact {x. infdist x A \ e}" + by (simp add: compact_eq_bounded_closed) +qed + subsection \Equality of continuous functions on closure and related results.\ lemma continuous_closedin_preimage_constant: @@ -2209,6 +2294,13 @@ by (metis assms continuous_open_vimage vimage_def) qed +lemma open_neg_translation: + fixes s :: "'a::real_normed_vector set" + assumes "open s" + shows "open((\x. a - x) ` s)" + using open_translation[OF open_negations[OF assms], of a] + by (auto simp: image_image) + lemma open_affinity: fixes S :: "'a::real_normed_vector set" assumes "open S" "c \ 0" @@ -2392,42 +2484,6 @@ (\x \ s. \e>0. \d>0. (\x' \ s. norm(x' - x) < d \ \f x' - f x\ < e))" unfolding continuous_on_iff dist_norm by simp -text \Hence some handy theorems on distance, diameter etc. of/from a set.\ - -lemma distance_attains_sup: - assumes "compact s" "s \ {}" - shows "\x\s. \y\s. dist a y \ dist a x" -proof (rule continuous_attains_sup [OF assms]) - { - fix x - assume "x\s" - have "(dist a \ dist a x) (at x within s)" - by (intro tendsto_dist tendsto_const tendsto_ident_at) - } - then show "continuous_on s (dist a)" - unfolding continuous_on .. -qed - -text \For \emph{minimal} distance, we only need closure, not compactness.\ - -lemma distance_attains_inf: - fixes a :: "'a::heine_borel" - assumes "closed s" and "s \ {}" - obtains x where "x\s" "\y. y \ s \ dist a x \ dist a y" -proof - - from assms obtain b where "b \ s" by auto - let ?B = "s \ cball a (dist b a)" - have "?B \ {}" using \b \ s\ - by (auto simp: dist_commute) - moreover have "continuous_on ?B (dist a)" - by (auto intro!: continuous_at_imp_continuous_on continuous_dist continuous_ident continuous_const) - moreover have "compact ?B" - by (intro closed_Int_compact \closed s\ compact_cball) - ultimately obtain x where "x \ ?B" "\y\?B. dist a x \ dist a y" - by (metis continuous_attains_inf) - with that show ?thesis by fastforce -qed - subsection \Cartesian products\ @@ -2911,6 +2967,38 @@ using separate_compact_closed[OF assms(2,1) *] by (force simp: dist_commute) qed +lemma compact_in_open_separated: + fixes A::"'a::heine_borel set" + assumes "A \ {}" + assumes "compact A" + assumes "open B" + assumes "A \ B" + obtains e where "e > 0" "{x. infdist x A \ e} \ B" +proof atomize_elim + have "closed (- B)" "compact A" "- B \ A = {}" + using assms by (auto simp: open_Diff compact_eq_bounded_closed) + from separate_closed_compact[OF this] + obtain d'::real where d': "d'>0" "\x y. x \ B \ y \ A \ d' \ dist x y" + by auto + define d where "d = d' / 2" + hence "d>0" "d < d'" using d' by auto + with d' have d: "\x y. x \ B \ y \ A \ d < dist x y" + by force + show "\e>0. {x. infdist x A \ e} \ B" + proof (rule ccontr) + assume "\e. 0 < e \ {x. infdist x A \ e} \ B" + with \d > 0\ obtain x where x: "infdist x A \ d" "x \ B" + by auto + from assms have "closed A" "A \ {}" by (auto simp: compact_eq_bounded_closed) + from infdist_attains_inf[OF this] + obtain y where y: "y \ A" "infdist x A = dist x y" + by auto + have "dist x y \ d" using x y by simp + also have "\ < dist x y" using y d x by auto + finally show False by simp + qed +qed + subsection \Compact sets and the closure operation.\ @@ -4221,6 +4309,14 @@ using \x\s\ by blast qed +lemma banach_fix_type: + fixes f::"'a::complete_space\'a" + assumes c:"0 \ c" "c < 1" + and lipschitz:"\x. \y. dist (f x) (f y) \ c * dist x y" + shows "\!x. (f x = x)" + using assms banach_fix[OF complete_UNIV UNIV_not_empty assms(1,2) subset_UNIV, of f] + by auto + subsection \Edelstein fixed point theorem\ diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Analysis/Convex_Euclidean_Space.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Convex_Euclidean_Space.thy Thu Feb 22 15:17:25 2018 +0100 @@ -6659,9 +6659,13 @@ subsection \On \real\, \is_interval\, \convex\ and \connected\ are all equivalent.\ -lemma is_interval_1: - "is_interval (s::real set) \ (\a\s. \b\s. \ x. a \ x \ x \ b \ x \ s)" - unfolding is_interval_def by auto +lemma mem_is_interval_1_I: + fixes a b c::real + assumes "is_interval S" + assumes "a \ S" "c \ S" + assumes "a \ b" "b \ c" + shows "b \ S" + using assms is_interval_1 by blast lemma is_interval_connected_1: fixes s :: "real set" @@ -6708,6 +6712,9 @@ shows "is_interval s \ convex s" by (metis is_interval_convex convex_connected is_interval_connected_1) +lemma is_interval_ball_real: "is_interval (ball a b)" for a b::real + by (metis connected_ball is_interval_connected_1) + lemma connected_compact_interval_1: "connected S \ compact S \ (\a b. S = {a..b::real})" by (auto simp: is_interval_connected_1 [symmetric] is_interval_compact) @@ -6731,6 +6738,10 @@ by (metis connected_convex_1 convex_linear_vimage linf convex_connected connected_linear_image) qed +lemma is_interval_cball_1[intro, simp]: "is_interval (cball a b)" for a b::real + by (auto simp: is_interval_convex_1 convex_cball) + + subsection \Another intermediate value theorem formulation\ lemma ivt_increasing_component_on_1: diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Derivative.thy --- a/src/HOL/Analysis/Derivative.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Derivative.thy Thu Feb 22 15:17:25 2018 +0100 @@ -48,18 +48,6 @@ shows "((\x. h (f x) (g x)) has_derivative (\d. h (f x) (g' d) + h (f' d) (g x))) (at x)" using has_derivative_bilinear_within[of f f' x UNIV g g' h] assms by simp -text \These are the only cases we'll care about, probably.\ - -lemma has_derivative_within: "(f has_derivative f') (at x within s) \ - bounded_linear f' \ ((\y. (1 / norm(y - x)) *\<^sub>R (f y - (f x + f' (y - x)))) \ 0) (at x within s)" - unfolding has_derivative_def Lim - by (auto simp add: netlimit_within field_simps) - -lemma has_derivative_at: "(f has_derivative f') (at x) \ - bounded_linear f' \ ((\y. (1 / (norm(y - x))) *\<^sub>R (f y - (f x + f' (y - x)))) \ 0) (at x)" - using has_derivative_within [of f f' x UNIV] - by simp - text \More explicit epsilon-delta forms.\ lemma has_derivative_within': @@ -131,27 +119,6 @@ by (auto simp add: continuous_within DERIV_within_iff cong: Lim_cong_within) qed -subsubsection \Limit transformation for derivatives\ - -lemma has_derivative_transform_within: - assumes "(f has_derivative f') (at x within s)" - and "0 < d" - and "x \ s" - and "\x'. \x' \ s; dist x' x < d\ \ f x' = g x'" - shows "(g has_derivative f') (at x within s)" - using assms - unfolding has_derivative_within - by (force simp add: intro: Lim_transform_within) - -lemma has_derivative_transform_within_open: - assumes "(f has_derivative f') (at x)" - and "open s" - and "x \ s" - and "\x. x\s \ f x = g x" - shows "(g has_derivative f') (at x)" - using assms unfolding has_derivative_at - by (force simp add: intro: Lim_transform_within_open) - subsection \Differentiability\ definition @@ -304,6 +271,10 @@ unfolding differentiable_on_def by auto +lemma has_derivative_continuous_on: + "(\x. x \ s \ (f has_derivative f' x) (at x within s)) \ continuous_on s f" + by (auto intro!: differentiable_imp_continuous_on differentiableI simp: differentiable_on_def) + text \Results about neighborhoods filter.\ lemma eventually_nhds_metric_le: @@ -1143,6 +1114,20 @@ by (simp add: g_def field_simps linear_diff[OF has_derivative_linear[OF f']]) qed +lemma vector_differentiable_bound_linearization: + fixes f::"real \ 'b::real_normed_vector" + assumes f': "\x. x \ S \ (f has_vector_derivative f' x) (at x within S)" + assumes "closed_segment a b \ S" + assumes B: "\x\S. norm (f' x - f' x0) \ B" + assumes "x0 \ S" + shows "norm (f b - f a - (b - a) *\<^sub>R f' x0) \ norm (b - a) * B" + using assms + by (intro differentiable_bound_linearization[of a b S f "\x h. h *\<^sub>R f' x" x0 B]) + (force simp: closed_segment_real_eq has_vector_derivative_def + scaleR_diff_right[symmetric] mult.commute[of B] + intro!: onorm_le mult_left_mono)+ + + text \In particular.\ lemma has_derivative_zero_constant: @@ -1169,6 +1154,14 @@ using assms(2)[of x] by (simp add: has_field_derivative_def A) qed fact +lemma + has_vector_derivative_zero_constant: + assumes "convex s" + assumes "\x. x \ s \ (f has_vector_derivative 0) (at x within s)" + obtains c where "\x. x \ s \ f x = c" + using has_derivative_zero_constant[of s f] assms + by (auto simp: has_vector_derivative_def) + lemma has_derivative_zero_unique: fixes f :: "'a::real_normed_vector \ 'b::real_normed_vector" assumes "convex s" @@ -2510,7 +2503,7 @@ apply (auto simp: vector_derivative_works has_vector_derivative_def has_field_derivative_def mult_commute_abs) done -lemma vector_derivative_within_closed_interval: +lemma vector_derivative_within_cbox: assumes ab: "a < b" "x \ cbox a b" assumes f: "(f has_vector_derivative f') (at x within cbox a b)" shows "vector_derivative f (at x within cbox a b) = f'" @@ -2518,6 +2511,14 @@ vector_derivative_works[THEN iffD1] differentiableI_vector) fact +lemma vector_derivative_within_closed_interval: + fixes f::"real \ 'a::euclidean_space" + assumes "a < b" and "x \ {a .. b}" + assumes "(f has_vector_derivative f') (at x within {a .. b})" + shows "vector_derivative f (at x within {a .. b}) = f'" + using assms vector_derivative_within_cbox + by fastforce + lemma has_vector_derivative_within_subset: "(f has_vector_derivative f') (at x within s) \ t \ s \ (f has_vector_derivative f') (at x within t)" by (auto simp: has_vector_derivative_def intro: has_derivative_within_subset) @@ -2561,6 +2562,14 @@ unfolding has_vector_derivative_def by (rule has_derivative_transform_within_open) +lemma has_vector_derivative_transform: + assumes "x \ s" "\x. x \ s \ g x = f x" + assumes f': "(f has_vector_derivative f') (at x within s)" + shows "(g has_vector_derivative f') (at x within s)" + using assms + unfolding has_vector_derivative_def + by (rule has_derivative_transform) + lemma vector_diff_chain_at: assumes "(f has_vector_derivative f') (at x)" and "(g has_vector_derivative g') (at (f x))" @@ -2589,7 +2598,7 @@ lemma vector_derivative_at_within_ivl: "(f has_vector_derivative f') (at x) \ a \ x \ x \ b \ a vector_derivative f (at x within {a..b}) = f'" -using has_vector_derivative_at_within vector_derivative_within_closed_interval by fastforce + using has_vector_derivative_at_within vector_derivative_within_cbox by fastforce lemma vector_derivative_chain_at: assumes "f differentiable at x" "(g differentiable at (f x))" @@ -2917,21 +2926,19 @@ qed lemma has_derivative_partialsI: - assumes fx: "\x y. x \ X \ y \ Y \ ((\x. f x y) has_derivative blinfun_apply (fx x y)) (at x within X)" + fixes f::"'a::real_normed_vector \ 'b::real_normed_vector \ 'c::real_normed_vector" + assumes fx: "((\x. f x y) has_derivative fx) (at x within X)" assumes fy: "\x y. x \ X \ y \ Y \ ((\y. f x y) has_derivative blinfun_apply (fy x y)) (at y within Y)" - assumes fx_cont: "continuous_on (X \ Y) (\(x, y). fx x y)" - assumes fy_cont: "continuous_on (X \ Y) (\(x, y). fy x y)" - assumes "x \ X" "y \ Y" - assumes "convex X" "convex Y" - shows "((\(x, y). f x y) has_derivative (\(tx, ty). fx x y tx + fy x y ty)) (at (x, y) within X \ Y)" + assumes fy_cont[unfolded continuous_within]: "continuous (at (x, y) within X \ Y) (\(x, y). fy x y)" + assumes "y \ Y" "convex Y" + shows "((\(x, y). f x y) has_derivative (\(tx, ty). fx tx + fy x y ty)) (at (x, y) within X \ Y)" proof (safe intro!: has_derivativeI tendstoI, goal_cases) case (2 e') + interpret fx: bounded_linear "fx" using fx by (rule has_derivative_bounded_linear) define e where "e = e' / 9" have "e > 0" using \e' > 0\ by (simp add: e_def) - have "(x, y) \ X \ Y" using assms by auto - from fy_cont[unfolded continuous_on_eq_continuous_within, rule_format, OF this, - unfolded continuous_within, THEN tendstoD, OF \e > 0\] + from fy_cont[THEN tendstoD, OF \e > 0\] have "\\<^sub>F (x', y') in at (x, y) within X \ Y. dist (fy x' y') (fy x y) < e" by (auto simp: split_beta') from this[unfolded eventually_at] obtain d' where @@ -2971,12 +2978,12 @@ } note onorm = this have ev_mem: "\\<^sub>F (x', y') in at (x, y) within X \ Y. (x', y') \ X \ Y" - using \x \ X\ \y \ Y\ + using \y \ Y\ by (auto simp: eventually_at intro!: zero_less_one) moreover have ev_dist: "\\<^sub>F xy in at (x, y) within X \ Y. dist xy (x, y) < d" if "d > 0" for d using eventually_at_ball[OF that] - by (rule eventually_elim2) (auto simp: dist_commute intro!: eventually_True) + by (rule eventually_elim2) (auto simp: dist_commute mem_ball intro!: eventually_True) note ev_dist[OF \0 < d\] ultimately have "\\<^sub>F (x', y') in at (x, y) within X \ Y. @@ -2997,32 +3004,31 @@ have "\ \ ball y d \ Y" using \y \ Y\ \0 < d\ dy y' by (intro \convex ?S\[unfolded convex_contains_segment, rule_format, of y y']) - (auto simp: dist_commute) + (auto simp: dist_commute mem_ball) finally have "y + t *\<^sub>R (y' - y) \ ?S" . } note seg = this have "\x\ball y d \ Y. onorm (blinfun_apply (fy x' x) - blinfun_apply (fy x' y)) \ e + e" - by (safe intro!: onorm less_imp_le \x' \ X\ dx) (auto simp: dist_commute \0 < d\ \y \ Y\) + by (safe intro!: onorm less_imp_le \x' \ X\ dx) (auto simp: mem_ball dist_commute \0 < d\ \y \ Y\) with seg has_derivative_within_subset[OF assms(2)[OF \x' \ X\]] show "norm (f x' y' - f x' y - (fy x' y) (y' - y)) \ norm (y' - y) * (e + e)" by (rule differentiable_bound_linearization[where S="?S"]) (auto intro!: \0 < d\ \y \ Y\) qed moreover - let ?le = "\x'. norm (f x' y - f x y - (fx x y) (x' - x)) \ norm (x' - x) * e" - from fx[OF \x \ X\ \y \ Y\, unfolded has_derivative_within, THEN conjunct2, THEN tendstoD, OF \0 < e\] + let ?le = "\x'. norm (f x' y - f x y - (fx) (x' - x)) \ norm (x' - x) * e" + from fx[unfolded has_derivative_within, THEN conjunct2, THEN tendstoD, OF \0 < e\] have "\\<^sub>F x' in at x within X. ?le x'" by eventually_elim - (auto simp: dist_norm divide_simps blinfun.bilinear_simps field_simps split: if_split_asm) + (auto simp: dist_norm divide_simps blinfun.bilinear_simps field_simps fx.zero split: if_split_asm) then have "\\<^sub>F (x', y') in at (x, y) within X \ Y. ?le x'" by (rule eventually_at_Pair_within_TimesI1) - (simp add: blinfun.bilinear_simps) + (simp add: blinfun.bilinear_simps fx.zero) moreover have "\\<^sub>F (x', y') in at (x, y) within X \ Y. norm ((x', y') - (x, y)) \ 0" unfolding norm_eq_zero right_minus_eq by (auto simp: eventually_at intro!: zero_less_one) moreover - from fy_cont[unfolded continuous_on_eq_continuous_within, rule_format, OF SigmaI[OF \x \ X\ \y \ Y\], - unfolded continuous_within, THEN tendstoD, OF \0 < e\] + from fy_cont[THEN tendstoD, OF \0 < e\] have "\\<^sub>F x' in at x within X. norm (fy x' y - fy x y) < e" unfolding eventually_at using \y \ Y\ @@ -3032,22 +3038,22 @@ (simp add: blinfun.bilinear_simps \0 < e\) ultimately have "\\<^sub>F (x', y') in at (x, y) within X \ Y. - norm ((f x' y' - f x y - (fx x y (x' - x) + fy x y (y' - y))) /\<^sub>R + norm ((f x' y' - f x y - (fx (x' - x) + fy x y (y' - y))) /\<^sub>R norm ((x', y') - (x, y))) < e'" apply eventually_elim proof safe fix x' y' - have "norm (f x' y' - f x y - (fx x y (x' - x) + fy x y (y' - y))) \ + have "norm (f x' y' - f x y - (fx (x' - x) + fy x y (y' - y))) \ norm (f x' y' - f x' y - fy x' y (y' - y)) + norm (fy x y (y' - y) - fy x' y (y' - y)) + - norm (f x' y - f x y - fx x y (x' - x))" + norm (f x' y - f x y - fx (x' - x))" by norm also assume nz: "norm ((x', y') - (x, y)) \ 0" and nfy: "norm (fy x' y - fy x y) < e" assume "norm (f x' y' - f x' y - blinfun_apply (fy x' y) (y' - y)) \ norm (y' - y) * (e + e)" - also assume "norm (f x' y - f x y - blinfun_apply (fx x y) (x' - x)) \ norm (x' - x) * e" + also assume "norm (f x' y - f x y - (fx) (x' - x)) \ norm (x' - x) * e" also have "norm ((fy x y) (y' - y) - (fy x' y) (y' - y)) \ norm ((fy x y) - (fy x' y)) * norm (y' - y)" by (auto simp: blinfun.bilinear_simps[symmetric] intro!: norm_blinfun) @@ -3070,11 +3076,80 @@ also have "\ < norm ((x', y') - (x, y)) * e'" using \0 < e'\ nz by (auto simp: e_def) - finally show "norm ((f x' y' - f x y - (fx x y (x' - x) + fy x y (y' - y))) /\<^sub>R norm ((x', y') - (x, y))) < e'" + finally show "norm ((f x' y' - f x y - (fx (x' - x) + fy x y (y' - y))) /\<^sub>R norm ((x', y') - (x, y))) < e'" by (auto simp: divide_simps dist_norm mult.commute) qed then show ?case by eventually_elim (auto simp: dist_norm field_simps) -qed (auto intro!: bounded_linear_intros simp: split_beta') +next + from has_derivative_bounded_linear[OF fx] + obtain fxb where "fx = blinfun_apply fxb" + by (metis bounded_linear_Blinfun_apply) + then show "bounded_linear (\(tx, ty). fx tx + blinfun_apply (fy x y) ty)" + by (auto intro!: bounded_linear_intros simp: split_beta') +qed + + +subsection \Differentiable case distinction\ + +lemma has_derivative_within_If_eq: + "((\x. if P x then f x else g x) has_derivative f') (at x within s) = + (bounded_linear f' \ + ((\y.(if P y then (f y - ((if P x then f x else g x) + f' (y - x)))/\<^sub>R norm (y - x) + else (g y - ((if P x then f x else g x) + f' (y - x)))/\<^sub>R norm (y - x))) + \ 0) (at x within s))" + (is "_ = (_ \ (?if \ 0) _)") +proof - + have "(\y. (1 / norm (y - x)) *\<^sub>R + ((if P y then f y else g y) - + ((if P x then f x else g x) + f' (y - x)))) = ?if" + by (auto simp: inverse_eq_divide) + thus ?thesis by (auto simp: has_derivative_within) +qed + +lemma has_derivative_If_within_closures: + assumes f': "x \ s \ (closure s \ closure t) \ + (f has_derivative f' x) (at x within s \ (closure s \ closure t))" + assumes g': "x \ t \ (closure s \ closure t) \ + (g has_derivative g' x) (at x within t \ (closure s \ closure t))" + assumes connect: "x \ closure s \ x \ closure t \ f x = g x" + assumes connect': "x \ closure s \ x \ closure t \ f' x = g' x" + assumes x_in: "x \ s \ t" + shows "((\x. if x \ s then f x else g x) has_derivative + (if x \ s then f' x else g' x)) (at x within (s \ t))" +proof - + from f' x_in interpret f': bounded_linear "if x \ s then f' x else (\x. 0)" + by (auto simp add: has_derivative_within) + from g' interpret g': bounded_linear "if x \ t then g' x else (\x. 0)" + by (auto simp add: has_derivative_within) + have bl: "bounded_linear (if x \ s then f' x else g' x)" + using f'.scaleR f'.bounded f'.add g'.scaleR g'.bounded g'.add x_in + by (unfold_locales; force) + show ?thesis + using f' g' closure_subset[of t] closure_subset[of s] + unfolding has_derivative_within_If_eq + by (intro conjI bl tendsto_If_within_closures x_in) + (auto simp: has_derivative_within inverse_eq_divide connect connect' set_mp) +qed + +lemma has_vector_derivative_If_within_closures: + assumes x_in: "x \ s \ t" + assumes "u = s \ t" + assumes f': "x \ s \ (closure s \ closure t) \ + (f has_vector_derivative f' x) (at x within s \ (closure s \ closure t))" + assumes g': "x \ t \ (closure s \ closure t) \ + (g has_vector_derivative g' x) (at x within t \ (closure s \ closure t))" + assumes connect: "x \ closure s \ x \ closure t \ f x = g x" + assumes connect': "x \ closure s \ x \ closure t \ f' x = g' x" + shows "((\x. if x \ s then f x else g x) has_vector_derivative + (if x \ s then f' x else g' x)) (at x within u)" + unfolding has_vector_derivative_def assms + using x_in + apply (intro has_derivative_If_within_closures[where + ?f' = "\x a. a *\<^sub>R f' x" and ?g' = "\x a. a *\<^sub>R g' x", + THEN has_derivative_eq_rhs]) + subgoal by (rule f'[unfolded has_vector_derivative_def]; assumption) + subgoal by (rule g'[unfolded has_vector_derivative_def]; assumption) + by (auto simp: assms) end diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Euclidean_Space.thy --- a/src/HOL/Analysis/Euclidean_Space.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Euclidean_Space.thy Thu Feb 22 15:17:25 2018 +0100 @@ -84,6 +84,10 @@ lemma (in euclidean_space) euclidean_representation: "(\b\Basis. inner x b *\<^sub>R b) = x" unfolding euclidean_representation_sum by simp +lemma (in euclidean_space) euclidean_inner: "inner x y = (\b\Basis. (inner x b) * (inner y b))" + by (subst (1 2) euclidean_representation [symmetric]) + (simp add: inner_sum_right inner_Basis ac_simps) + lemma (in euclidean_space) choice_Basis_iff: fixes P :: "'a \ real \ bool" shows "(\i\Basis. \x. P i x) \ (\x. \i\Basis. P i (inner x i))" diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Finite_Cartesian_Product.thy --- a/src/HOL/Analysis/Finite_Cartesian_Product.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Finite_Cartesian_Product.thy Thu Feb 22 15:17:25 2018 +0100 @@ -20,9 +20,19 @@ declare vec_lambda_inject [simplified, simp] +bundle vec_syntax begin notation vec_nth (infixl "$" 90) and vec_lambda (binder "\" 10) +end + +bundle no_vec_syntax begin +no_notation + vec_nth (infixl "$" 90) and + vec_lambda (binder "\" 10) +end + +unbundle vec_syntax (* Translate "'b ^ 'n" into "'b ^ ('n :: finite)". When 'n has already more than diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Henstock_Kurzweil_Integration.thy --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Thu Feb 22 15:17:25 2018 +0100 @@ -621,6 +621,11 @@ with False show ?thesis by (simp add: not_integrable_integral) qed +lemma integral_mult: + fixes K::real + shows "f integrable_on X \ K * integral X f = integral X (\x. K * f x)" + unfolding real_scaleR_def[symmetric] integral_cmul .. + lemma integral_neg [simp]: "integral S (\x. - f x) = - integral S f" proof (cases "f integrable_on S") case True then show ?thesis @@ -2549,6 +2554,13 @@ lemmas integrable_continuous_real = integrable_continuous_interval[where 'b=real] +lemma integrable_continuous_closed_segment: + fixes f :: "real \ 'a::banach" + assumes "continuous_on (closed_segment a b) f" + shows "f integrable_on (closed_segment a b)" + using assms + by (auto intro!: integrable_continuous_interval simp: closed_segment_eq_real_ivl) + subsection \Specialization of additivity to one dimension.\ @@ -2722,6 +2734,32 @@ subsection \Taylor series expansion\ +lemma mvt_integral: + fixes f::"'a::real_normed_vector\'b::banach" + assumes f'[derivative_intros]: + "\x. x \ S \ (f has_derivative f' x) (at x within S)" + assumes line_in: "\t. t \ {0..1} \ x + t *\<^sub>R y \ S" + shows "f (x + y) - f x = integral {0..1} (\t. f' (x + t *\<^sub>R y) y)" (is ?th1) +proof - + from assms have subset: "(\xa. x + xa *\<^sub>R y) ` {0..1} \ S" by auto + note [derivative_intros] = + has_derivative_subset[OF _ subset] + has_derivative_in_compose[where f="(\xa. x + xa *\<^sub>R y)" and g = f] + note [continuous_intros] = + continuous_on_compose2[where f="(\xa. x + xa *\<^sub>R y)"] + continuous_on_subset[OF _ subset] + have "\t. t \ {0..1} \ + ((\t. f (x + t *\<^sub>R y)) has_vector_derivative f' (x + t *\<^sub>R y) y) + (at t within {0..1})" + using assms + by (auto simp: has_vector_derivative_def + linear_cmul[OF has_derivative_linear[OF f'], symmetric] + intro!: derivative_eq_intros) + from fundamental_theorem_of_calculus[rule_format, OF _ this] + show ?th1 + by (auto intro!: integral_unique[symmetric]) +qed + lemma (in bounded_bilinear) sum_prod_derivatives_has_vector_derivative: assumes "p>0" and f0: "Df 0 = f" @@ -2835,7 +2873,6 @@ qed - subsection \Only need trivial subintervals if the interval itself is trivial.\ proposition division_of_nontrivial: @@ -3024,6 +3061,21 @@ unfolding integrable_on_def by (auto intro!: has_integral_combine) +lemma integral_minus_sets: + fixes f::"real \ 'a::banach" + shows "c \ a \ c \ b \ f integrable_on {c .. max a b} \ + integral {c .. a} f - integral {c .. b} f = + (if a \ b then - integral {a .. b} f else integral {b .. a} f)" + using integral_combine[of c a b f] integral_combine[of c b a f] + by (auto simp: algebra_simps max_def) + +lemma integral_minus_sets': + fixes f::"real \ 'a::banach" + shows "c \ a \ c \ b \ f integrable_on {min a b .. c} \ + integral {a .. c} f - integral {b .. c} f = + (if a \ b then integral {a .. b} f else - integral {b .. a} f)" + using integral_combine[of b a c f] integral_combine[of a b c f] + by (auto simp: algebra_simps min_def) subsection \Reduce integrability to "local" integrability.\ @@ -3129,13 +3181,19 @@ using assms integral_has_vector_derivative_continuous_at [OF integrable_continuous_real] by (fastforce simp: continuous_on_eq_continuous_within) +lemma integral_has_real_derivative: + assumes "continuous_on {a..b} g" + assumes "t \ {a..b}" + shows "((\x. integral {a..x} g) has_real_derivative g t) (at t within {a..b})" + using integral_has_vector_derivative[of a b g t] assms + by (auto simp: has_field_derivative_iff_has_vector_derivative) + lemma antiderivative_continuous: fixes q b :: real assumes "continuous_on {a..b} f" obtains g where "\x. x \ {a..b} \ (g has_vector_derivative (f x::_::banach)) (at x within {a..b})" using integral_has_vector_derivative[OF assms] by auto - subsection \Combined fundamental theorem of calculus.\ lemma antiderivative_integral_continuous: @@ -3149,7 +3207,8 @@ have "(f has_integral g v - g u) {u..v}" if "u \ {a..b}" "v \ {a..b}" "u \ v" for u v proof - have "\x. x \ cbox u v \ (g has_vector_derivative f x) (at x within cbox u v)" - by (meson g has_vector_derivative_within_subset interval_subset_is_interval is_interval_closed_interval subsetCE that(1) that(2)) + by (metis atLeastAtMost_iff atLeastatMost_subset_iff box_real(2) g + has_vector_derivative_within_subset subsetCE that(1,2)) then show ?thesis by (metis box_real(2) that(3) fundamental_theorem_of_calculus) qed @@ -4125,6 +4184,28 @@ by (rule continuous_on_eq) (auto intro!: continuous_intros indefinite_integral_continuous_1 assms) qed +theorem integral_has_vector_derivative': + fixes f :: "real \ 'b::banach" + assumes "continuous_on {a..b} f" + and "x \ {a..b}" + shows "((\u. integral {u..b} f) has_vector_derivative - f x) (at x within {a..b})" +proof - + have *: "integral {x..b} f = integral {a .. b} f - integral {a .. x} f" if "a \ x" "x \ b" for x + using integral_combine[of a x b for x, OF that integrable_continuous_real[OF assms(1)]] + by (simp add: algebra_simps) + show ?thesis + using \x \ _\ * + by (rule has_vector_derivative_transform) + (auto intro!: derivative_eq_intros assms integral_has_vector_derivative) +qed + +lemma integral_has_real_derivative': + assumes "continuous_on {a..b} g" + assumes "t \ {a..b}" + shows "((\x. integral {x..b} g) has_real_derivative -g t) (at t within {a..b})" + using integral_has_vector_derivative'[OF assms] + by (auto simp: has_field_derivative_iff_has_vector_derivative) + subsection \This doesn't directly involve integration, but that gives an easy proof.\ @@ -4661,6 +4742,10 @@ shows "f integrable_on S \ f integrable_on T" by (blast intro: integrable_spike_set assms negligible_subset) +lemma integrable_on_insert_iff: "f integrable_on (insert x X) \ f integrable_on X" + for f::"_ \ 'a::banach" + by (rule integrable_spike_set_eq) (auto simp: insert_Diff_if) + lemma has_integral_interior: fixes f :: "'a :: euclidean_space \ 'b :: banach" shows "negligible(frontier S) \ (f has_integral y) (interior S) \ (f has_integral y) S" @@ -6049,6 +6134,26 @@ qed qed +lemma continuous_on_imp_absolutely_integrable_on: + fixes f::"real \ 'a::banach" + shows "continuous_on {a..b} f \ + norm (integral {a..b} f) \ integral {a..b} (\x. norm (f x))" + by (intro integral_norm_bound_integral integrable_continuous_real continuous_on_norm) auto + +lemma integral_bound: + fixes f::"real \ 'a::banach" + assumes "a \ b" + assumes "continuous_on {a .. b} f" + assumes "\t. t \ {a .. b} \ norm (f t) \ B" + shows "norm (integral {a .. b} f) \ B * (b - a)" +proof - + note continuous_on_imp_absolutely_integrable_on[OF assms(2)] + also have "integral {a..b} (\x. norm (f x)) \ integral {a..b} (\_. B)" + by (rule integral_le) + (auto intro!: integrable_continuous_real continuous_intros assms) + also have "\ = B * (b - a)" using assms by simp + finally show ?thesis . +qed lemma integral_norm_bound_integral_component: fixes f :: "'n::euclidean_space \ 'a::banach" diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/L2_Norm.thy --- a/src/HOL/Analysis/L2_Norm.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/L2_Norm.thy Thu Feb 22 15:17:25 2018 +0100 @@ -98,13 +98,6 @@ qed qed -lemma sqrt_sum_squares_le_sum: - "\0 \ x; 0 \ y\ \ sqrt (x\<^sup>2 + y\<^sup>2) \ x + y" - apply (rule power2_le_imp_le) - apply (simp add: power2_sum) - apply simp - done - lemma L2_set_le_sum [rule_format]: "(\i\A. 0 \ f i) \ L2_set f A \ sum f A" apply (cases "finite A") diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Linear_Algebra.thy --- a/src/HOL/Analysis/Linear_Algebra.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Linear_Algebra.thy Thu Feb 22 15:17:25 2018 +0100 @@ -2987,10 +2987,6 @@ lemma infnorm_le_norm: "infnorm x \ norm x" by (simp add: Basis_le_norm infnorm_Max) -lemma (in euclidean_space) euclidean_inner: "inner x y = (\b\Basis. (x \ b) * (y \ b))" - by (subst (1 2) euclidean_representation [symmetric]) - (simp add: inner_sum_right inner_Basis ac_simps) - lemma norm_le_infnorm: fixes x :: "'a::euclidean_space" shows "norm x \ sqrt DIM('a) * infnorm x" diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Operator_Norm.thy --- a/src/HOL/Analysis/Operator_Norm.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Operator_Norm.thy Thu Feb 22 15:17:25 2018 +0100 @@ -235,4 +235,13 @@ shows "onorm (\x. f x + g x) < e" using assms by (rule onorm_triangle [THEN order_le_less_trans]) +lemma onorm_sum: + assumes "finite S" + assumes "\s. s \ S \ bounded_linear (f s)" + shows "onorm (\x. sum (\s. f s x) S) \ sum (\s. onorm (f s)) S" + using assms + by (induction) (auto simp: onorm_zero intro!: onorm_triangle_le bounded_linear_sum) + +lemmas onorm_sum_le = onorm_sum[THEN order_trans] + end diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Ordered_Euclidean_Space.thy --- a/src/HOL/Analysis/Ordered_Euclidean_Space.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Ordered_Euclidean_Space.thy Thu Feb 22 15:17:25 2018 +0100 @@ -214,9 +214,20 @@ using image_smult_cbox[of m a b] by (simp add: cbox_interval) -lemma is_interval_closed_interval [simp]: - "is_interval {a .. (b::'a::ordered_euclidean_space)}" - by (metis cbox_interval is_interval_cbox) +lemma [simp]: + fixes a b::"'a::ordered_euclidean_space" and r s::real + shows is_interval_io: "is_interval {.. g differentiable at x within s \ + (\x. (f x, g x)) differentiable at x within s" + unfolding differentiable_def by (blast intro: has_derivative_Pair) + lemmas has_derivative_fst [derivative_intros] = bounded_linear.has_derivative [OF bounded_linear_fst] lemmas has_derivative_snd [derivative_intros] = bounded_linear.has_derivative [OF bounded_linear_snd] @@ -313,6 +318,17 @@ "((\p. f (fst p) (snd p)) has_derivative f') F \ ((\(a, b). f a b) has_derivative f') F" unfolding split_beta' . + +subsubsection \Vector derivatives involving pairs\ + +lemma has_vector_derivative_Pair[derivative_intros]: + assumes "(f has_vector_derivative f') (at x within s)" + "(g has_vector_derivative g') (at x within s)" + shows "((\x. (f x, g x)) has_vector_derivative (f', g')) (at x within s)" + using assms + by (auto simp: has_vector_derivative_def intro!: derivative_eq_intros) + + subsection \Product is an inner product space\ instantiation prod :: (real_inner, real_inner) real_inner @@ -368,4 +384,9 @@ lemma norm_snd_le: "norm y \ norm (x,y)" by (metis dist_snd_le snd_conv snd_zero norm_conv_dist) +lemma norm_Pair_le: + shows "norm (x, y) \ norm x + norm y" + unfolding norm_Pair + by (metis norm_ge_zero sqrt_sum_squares_le_sum) + end diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Riemann_Mapping.thy --- a/src/HOL/Analysis/Riemann_Mapping.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Riemann_Mapping.thy Thu Feb 22 15:17:25 2018 +0100 @@ -489,7 +489,7 @@ let ?g = "\z. (SOME g. polynomial_function g \ path_image g \ S \ pathstart g = a \ pathfinish g = z)" show "((\z. contour_integral (?g z) f) has_field_derivative f x) (at x)" - proof (simp add: has_field_derivative_def has_derivative_at bounded_linear_mult_right, rule Lim_transform) + proof (simp add: has_field_derivative_def has_derivative_at2 bounded_linear_mult_right, rule Lim_transform) show "(\y. inverse(norm(y - x)) *\<^sub>R (contour_integral(linepath x y) f - f x * (y - x))) \x\ 0" proof (clarsimp simp add: Lim_at) fix e::real assume "e > 0" diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Starlike.thy --- a/src/HOL/Analysis/Starlike.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Starlike.thy Thu Feb 22 15:17:25 2018 +0100 @@ -13,9 +13,87 @@ begin +subsection \Midpoint\ + definition midpoint :: "'a::real_vector \ 'a \ 'a" where "midpoint a b = (inverse (2::real)) *\<^sub>R (a + b)" +lemma midpoint_idem [simp]: "midpoint x x = x" + unfolding midpoint_def + unfolding scaleR_right_distrib + unfolding scaleR_left_distrib[symmetric] + by auto + +lemma midpoint_sym: "midpoint a b = midpoint b a" + unfolding midpoint_def by (auto simp add: scaleR_right_distrib) + +lemma midpoint_eq_iff: "midpoint a b = c \ a + b = c + c" +proof - + have "midpoint a b = c \ scaleR 2 (midpoint a b) = scaleR 2 c" + by simp + then show ?thesis + unfolding midpoint_def scaleR_2 [symmetric] by simp +qed + +lemma + fixes a::real + assumes "a \ b" shows ge_midpoint_1: "a \ midpoint a b" + and le_midpoint_1: "midpoint a b \ b" + by (simp_all add: midpoint_def assms) + +lemma dist_midpoint: + fixes a b :: "'a::real_normed_vector" shows + "dist a (midpoint a b) = (dist a b) / 2" (is ?t1) + "dist b (midpoint a b) = (dist a b) / 2" (is ?t2) + "dist (midpoint a b) a = (dist a b) / 2" (is ?t3) + "dist (midpoint a b) b = (dist a b) / 2" (is ?t4) +proof - + have *: "\x y::'a. 2 *\<^sub>R x = - y \ norm x = (norm y) / 2" + unfolding equation_minus_iff by auto + have **: "\x y::'a. 2 *\<^sub>R x = y \ norm x = (norm y) / 2" + by auto + note scaleR_right_distrib [simp] + show ?t1 + unfolding midpoint_def dist_norm + apply (rule **) + apply (simp add: scaleR_right_diff_distrib) + apply (simp add: scaleR_2) + done + show ?t2 + unfolding midpoint_def dist_norm + apply (rule *) + apply (simp add: scaleR_right_diff_distrib) + apply (simp add: scaleR_2) + done + show ?t3 + unfolding midpoint_def dist_norm + apply (rule *) + apply (simp add: scaleR_right_diff_distrib) + apply (simp add: scaleR_2) + done + show ?t4 + unfolding midpoint_def dist_norm + apply (rule **) + apply (simp add: scaleR_right_diff_distrib) + apply (simp add: scaleR_2) + done +qed + +lemma midpoint_eq_endpoint [simp]: + "midpoint a b = a \ a = b" + "midpoint a b = b \ a = b" + unfolding midpoint_eq_iff by auto + +lemma midpoint_plus_self [simp]: "midpoint a b + midpoint a b = a + b" + using midpoint_eq_iff by metis + +lemma midpoint_linear_image: + "linear f \ midpoint(f a)(f b) = f(midpoint a b)" +by (simp add: linear_iff midpoint_def) + + +subsection \Line segments\ + definition closed_segment :: "'a::real_vector \ 'a \ 'a set" where "closed_segment a b = {(1 - u) *\<^sub>R a + u *\<^sub>R b | u::real. 0 \ u \ u \ 1}" @@ -106,86 +184,6 @@ apply (auto simp: in_segment scaleR_conv_of_real elim!: ex_forward del: exE) using of_real_eq_iff by fastforce -lemma midpoint_idem [simp]: "midpoint x x = x" - unfolding midpoint_def - unfolding scaleR_right_distrib - unfolding scaleR_left_distrib[symmetric] - by auto - -lemma midpoint_sym: "midpoint a b = midpoint b a" - unfolding midpoint_def by (auto simp add: scaleR_right_distrib) - -lemma midpoint_eq_iff: "midpoint a b = c \ a + b = c + c" -proof - - have "midpoint a b = c \ scaleR 2 (midpoint a b) = scaleR 2 c" - by simp - then show ?thesis - unfolding midpoint_def scaleR_2 [symmetric] by simp -qed - -lemma - fixes a::real - assumes "a \ b" shows ge_midpoint_1: "a \ midpoint a b" - and le_midpoint_1: "midpoint a b \ b" - by (simp_all add: midpoint_def assms) - -lemma dist_midpoint: - fixes a b :: "'a::real_normed_vector" shows - "dist a (midpoint a b) = (dist a b) / 2" (is ?t1) - "dist b (midpoint a b) = (dist a b) / 2" (is ?t2) - "dist (midpoint a b) a = (dist a b) / 2" (is ?t3) - "dist (midpoint a b) b = (dist a b) / 2" (is ?t4) -proof - - have *: "\x y::'a. 2 *\<^sub>R x = - y \ norm x = (norm y) / 2" - unfolding equation_minus_iff by auto - have **: "\x y::'a. 2 *\<^sub>R x = y \ norm x = (norm y) / 2" - by auto - note scaleR_right_distrib [simp] - show ?t1 - unfolding midpoint_def dist_norm - apply (rule **) - apply (simp add: scaleR_right_diff_distrib) - apply (simp add: scaleR_2) - done - show ?t2 - unfolding midpoint_def dist_norm - apply (rule *) - apply (simp add: scaleR_right_diff_distrib) - apply (simp add: scaleR_2) - done - show ?t3 - unfolding midpoint_def dist_norm - apply (rule *) - apply (simp add: scaleR_right_diff_distrib) - apply (simp add: scaleR_2) - done - show ?t4 - unfolding midpoint_def dist_norm - apply (rule **) - apply (simp add: scaleR_right_diff_distrib) - apply (simp add: scaleR_2) - done -qed - -lemma midpoint_eq_endpoint [simp]: - "midpoint a b = a \ a = b" - "midpoint a b = b \ a = b" - unfolding midpoint_eq_iff by auto - -lemma midpoint_plus_self [simp]: "midpoint a b + midpoint a b = a + b" - using midpoint_eq_iff by metis - -lemma midpoint_linear_image: - "linear f \ midpoint(f a)(f b) = f(midpoint a b)" -by (simp add: linear_iff midpoint_def) - -subsection\Starlike sets\ - -definition "starlike S \ (\a\S. \x\S. closed_segment a x \ S)" - -lemma starlike_UNIV [simp]: "starlike UNIV" - by (simp add: starlike_def) - lemma convex_contains_segment: "convex S \ (\a\S. \b\S. closed_segment a b \ S)" unfolding convex_alt closed_segment_def by auto @@ -197,10 +195,6 @@ "\x \ convex hull S; y \ convex hull S\ \ closed_segment x y \ convex hull S" using convex_contains_segment by blast -lemma convex_imp_starlike: - "convex S \ S \ {} \ starlike S" - unfolding convex_contains_segment starlike_def by auto - lemma segment_convex_hull: "closed_segment a b = convex hull {a,b}" proof - @@ -349,7 +343,7 @@ proof - have "norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)" using \u \ 1\ by force - then show ?thesis + then show ?thesis by (simp add: dist_norm real_vector.scale_right_diff_distrib) qed also have "... \ dist a b" @@ -581,7 +575,6 @@ by (metis image_comp convex_translation) qed - lemmas convex_segment = convex_closed_segment convex_open_segment lemma connected_segment [iff]: @@ -589,6 +582,33 @@ shows "connected (closed_segment x y)" by (simp add: convex_connected) +lemma is_interval_closed_segment_1[intro, simp]: "is_interval (closed_segment a b)" for a b::real + by (auto simp: is_interval_convex_1) + +lemma IVT'_closed_segment_real: + fixes f :: "real \ real" + assumes "y \ closed_segment (f a) (f b)" + assumes "continuous_on (closed_segment a b) f" + shows "\x \ closed_segment a b. f x = y" + using IVT'[of f a y b] + IVT'[of "-f" a "-y" b] + IVT'[of f b y a] + IVT'[of "-f" b "-y" a] assms + by (cases "a \ b"; cases "f b \ f a") (auto simp: closed_segment_eq_real_ivl continuous_on_minus) + + +subsection\Starlike sets\ + +definition "starlike S \ (\a\S. \x\S. closed_segment a x \ S)" + +lemma starlike_UNIV [simp]: "starlike UNIV" + by (simp add: starlike_def) + +lemma convex_imp_starlike: + "convex S \ S \ {} \ starlike S" + unfolding convex_contains_segment starlike_def by auto + + lemma affine_hull_closed_segment [simp]: "affine hull (closed_segment a b) = affine hull {a,b}" by (simp add: segment_convex_hull) diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Analysis/Topology_Euclidean_Space.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Topology_Euclidean_Space.thy Thu Feb 22 15:17:25 2018 +0100 @@ -7,7 +7,7 @@ section \Elementary topology in Euclidean space.\ theory Topology_Euclidean_Space -imports +imports "HOL-Library.Indicator_Function" "HOL-Library.Countable_Set" "HOL-Library.FuncSet" @@ -1112,6 +1112,9 @@ lemma ball_subset_cball [simp, intro]: "ball x e \ cball x e" by (simp add: subset_eq) +lemma mem_ball_imp_mem_cball: "x \ ball y e \ x \ cball y e" + by (auto simp: mem_ball mem_cball) + lemma sphere_cball [simp,intro]: "sphere z r \ cball z r" by force @@ -1124,6 +1127,22 @@ lemma subset_cball[intro]: "d \ e \ cball x d \ cball x e" by (simp add: subset_eq) +lemma mem_ball_leI: "x \ ball y e \ e \ f \ x \ ball y f" + by (auto simp: mem_ball mem_cball) + +lemma mem_cball_leI: "x \ cball y e \ e \ f \ x \ cball y f" + by (auto simp: mem_ball mem_cball) + +lemma cball_trans: "y \ cball z b \ x \ cball y a \ x \ cball z (b + a)" + unfolding mem_cball +proof - + have "dist z x \ dist z y + dist y x" + by (rule dist_triangle) + also assume "dist z y \ b" + also assume "dist y x \ a" + finally show "dist z x \ b + a" by arith +qed + lemma ball_max_Un: "ball a (max r s) = ball a r \ ball a s" by (simp add: set_eq_iff) arith @@ -1253,6 +1272,17 @@ unfolding dist_norm norm_eq_sqrt_inner L2_set_def by (subst euclidean_inner) (simp add: power2_eq_square inner_diff_left) +lemma norm_nth_le: "norm (x \ i) \ norm x" if "i \ Basis" +proof - + have "(x \ i)\<^sup>2 = (\i\{i}. (x \ i)\<^sup>2)" + by simp + also have "\ \ (\i\Basis. (x \ i)\<^sup>2)" + by (intro sum_mono2) (auto simp: that) + finally show ?thesis + unfolding norm_conv_dist euclidean_dist_l2[of x] L2_set_def + by (auto intro!: real_le_rsqrt) +qed + lemma eventually_nhds_ball: "d > 0 \ eventually (\x. x \ ball z d) (nhds z)" by (rule eventually_nhds_in_open) simp_all @@ -1262,6 +1292,20 @@ lemma eventually_at_ball': "d > 0 \ eventually (\t. t \ ball z d \ t \ z \ t \ A) (at z within A)" unfolding eventually_at by (intro exI[of _ d]) (simp_all add: dist_commute) +lemma at_within_ball: "e > 0 \ dist x y < e \ at y within ball x e = at y" + by (subst at_within_open) auto + +lemma atLeastAtMost_eq_cball: + fixes a b::real + shows "{a .. b} = cball ((a + b)/2) ((b - a)/2)" + by (auto simp: dist_real_def field_simps mem_cball) + +lemma greaterThanLessThan_eq_ball: + fixes a b::real + shows "{a <..< b} = ball ((a + b)/2) ((b - a)/2)" + by (auto simp: dist_real_def field_simps mem_ball) + + subsection \Boxes\ abbreviation One :: "'a::euclidean_space" @@ -1834,6 +1878,14 @@ definition "is_interval (s::('a::euclidean_space) set) \ (\a\s. \b\s. \x. (\i\Basis. ((a\i \ x\i \ x\i \ b\i) \ (b\i \ x\i \ x\i \ a\i))) \ x \ s)" +lemma is_interval_1: + "is_interval (s::real set) \ (\a\s. \b\s. \ x. a \ x \ x \ b \ x \ s)" + unfolding is_interval_def by auto + +lemma is_interval_inter: "is_interval X \ is_interval Y \ is_interval (X \ Y)" + unfolding is_interval_def + by blast + lemma is_interval_cbox [simp]: "is_interval (cbox a (b::'a::euclidean_space))" (is ?th1) and is_interval_box [simp]: "is_interval (box a b)" (is ?th2) unfolding is_interval_def mem_box Ball_def atLeastAtMost_iff @@ -1916,6 +1968,88 @@ by blast qed +lemma is_real_interval_union: + "is_interval (X \ Y)" + if X: "is_interval X" and Y: "is_interval Y" and I: "(X \ {} \ Y \ {} \ X \ Y \ {})" + for X Y::"real set" +proof - + consider "X \ {}" "Y \ {}" | "X = {}" | "Y = {}" by blast + then show ?thesis + proof cases + case 1 + then obtain r where "r \ X \ X \ Y = {}" "r \ Y \ X \ Y = {}" + by blast + then show ?thesis + using I 1 X Y unfolding is_interval_1 + by (metis (full_types) Un_iff le_cases) + qed (use that in auto) +qed + +lemma is_interval_translationI: + assumes "is_interval X" + shows "is_interval ((+) x ` X)" + unfolding is_interval_def +proof safe + fix b d e + assume "b \ X" "d \ X" + "\i\Basis. (x + b) \ i \ e \ i \ e \ i \ (x + d) \ i \ + (x + d) \ i \ e \ i \ e \ i \ (x + b) \ i" + hence "e - x \ X" + by (intro mem_is_intervalI[OF assms \b \ X\ \d \ X\, of "e - x"]) + (auto simp: algebra_simps) + thus "e \ (+) x ` X" by force +qed + +lemma is_interval_uminusI: + assumes "is_interval X" + shows "is_interval (uminus ` X)" + unfolding is_interval_def +proof safe + fix b d e + assume "b \ X" "d \ X" + "\i\Basis. (- b) \ i \ e \ i \ e \ i \ (- d) \ i \ + (- d) \ i \ e \ i \ e \ i \ (- b) \ i" + hence "- e \ X" + by (intro mem_is_intervalI[OF assms \b \ X\ \d \ X\, of "- e"]) + (auto simp: algebra_simps) + thus "e \ uminus ` X" by force +qed + +lemma is_interval_uminus[simp]: "is_interval (uminus ` x) = is_interval x" + using is_interval_uminusI[of x] is_interval_uminusI[of "uminus ` x"] + by (auto simp: image_image) + +lemma is_interval_neg_translationI: + assumes "is_interval X" + shows "is_interval ((-) x ` X)" +proof - + have "(-) x ` X = (+) x ` uminus ` X" + by (force simp: algebra_simps) + also have "is_interval \" + by (metis is_interval_uminusI is_interval_translationI assms) + finally show ?thesis . +qed + +lemma is_interval_translation[simp]: + "is_interval ((+) x ` X) = is_interval X" + using is_interval_neg_translationI[of "(+) x ` X" x] + by (auto intro!: is_interval_translationI simp: image_image) + +lemma is_interval_minus_translation[simp]: + shows "is_interval ((-) x ` X) = is_interval X" +proof - + have "(-) x ` X = (+) x ` uminus ` X" + by (force simp: algebra_simps) + also have "is_interval \ = is_interval X" + by simp + finally show ?thesis . +qed + +lemma is_interval_minus_translation'[simp]: + shows "is_interval ((\x. x - c) ` X) = is_interval X" + using is_interval_translation[of "-c" X] + by (metis image_cong uminus_add_conv_diff) + subsection \Limit points\ @@ -2629,6 +2763,15 @@ lemma not_trivial_limit_within: "\ trivial_limit (at x within S) = (x \ closure (S - {x}))" using islimpt_in_closure by (metis trivial_limit_within) +lemma not_in_closure_trivial_limitI: + "x \ closure s \ trivial_limit (at x within s)" + using not_trivial_limit_within[of x s] + by safe (metis Diff_empty Diff_insert0 closure_subset contra_subsetD) + +lemma filterlim_at_within_closure_implies_filterlim: "filterlim f l (at x within s)" + if "x \ closure s \ filterlim f l (at x within s)" + by (metis bot.extremum filterlim_filtercomap filterlim_mono not_in_closure_trivial_limitI that) + lemma at_within_eq_bot_iff: "at c within A = bot \ c \ closure (A - {c})" using not_trivial_limit_within[of c A] by blast @@ -3229,6 +3372,28 @@ qed qed +lemma tendsto_If_within_closures: + assumes f: "x \ s \ (closure s \ closure t) \ + (f \ l x) (at x within s \ (closure s \ closure t))" + assumes g: "x \ t \ (closure s \ closure t) \ + (g \ l x) (at x within t \ (closure s \ closure t))" + assumes "x \ s \ t" + shows "((\x. if x \ s then f x else g x) \ l x) (at x within s \ t)" +proof - + have *: "(s \ t) \ {x. x \ s} = s" "(s \ t) \ {x. x \ s} = t - s" + by auto + have "(f \ l x) (at x within s)" + by (rule filterlim_at_within_closure_implies_filterlim) + (use \x \ _\ in \auto simp: inf_commute closure_def intro: tendsto_within_subset[OF f]\) + moreover + have "(g \ l x) (at x within t - s)" + by (rule filterlim_at_within_closure_implies_filterlim) + (use \x \ _\ in + \auto intro!: tendsto_within_subset[OF g] simp: closure_def intro: islimpt_subset\) + ultimately show ?thesis + by (intro filterlim_at_within_If) (simp_all only: *) +qed + subsection \Boundedness\ diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Analysis/Uniform_Limit.thy --- a/src/HOL/Analysis/Uniform_Limit.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Analysis/Uniform_Limit.thy Thu Feb 22 15:17:25 2018 +0100 @@ -438,6 +438,7 @@ bounded_linear.uniform_limit[OF bounded_linear_mult_right] bounded_linear.uniform_limit[OF bounded_linear_scaleR_left] + lemmas uniform_limit_uminus[uniform_limit_intros] = bounded_linear.uniform_limit[OF bounded_linear_minus[OF bounded_linear_ident]] @@ -728,5 +729,7 @@ apply (rule continuous_on_cong [THEN iffD1, OF refl _ powser_continuous_suminf [OF r]]) using sm sums_unique by fastforce +lemmas uniform_limit_subset_union = uniform_limit_on_subset[OF uniform_limit_on_Union] + end diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Deriv.thy --- a/src/HOL/Deriv.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Deriv.thy Thu Feb 22 15:17:25 2018 +0100 @@ -26,6 +26,13 @@ most cases @{term s} is either a variable or @{term UNIV}. \ +text \These are the only cases we'll care about, probably.\ + +lemma has_derivative_within: "(f has_derivative f') (at x within s) \ + bounded_linear f' \ ((\y. (1 / norm(y - x)) *\<^sub>R (f y - (f x + f' (y - x)))) \ 0) (at x within s)" + unfolding has_derivative_def tendsto_iff + by (subst eventually_Lim_ident_at) (auto simp add: field_simps) + lemma has_derivative_eq_rhs: "(f has_derivative f') F \ f' = g' \ (f has_derivative g') F" by simp @@ -189,6 +196,52 @@ lemmas has_derivative_within_subset = has_derivative_subset +lemma has_derivative_within_singleton_iff: + "(f has_derivative g) (at x within {x}) \ bounded_linear g" + by (auto intro!: has_derivativeI_sandwich[where e=1] has_derivative_bounded_linear) + + +subsubsection \Limit transformation for derivatives\ + +lemma has_derivative_transform_within: + assumes "(f has_derivative f') (at x within s)" + and "0 < d" + and "x \ s" + and "\x'. \x' \ s; dist x' x < d\ \ f x' = g x'" + shows "(g has_derivative f') (at x within s)" + using assms + unfolding has_derivative_within + by (force simp add: intro: Lim_transform_within) + +lemma has_derivative_transform_within_open: + assumes "(f has_derivative f') (at x within t)" + and "open s" + and "x \ s" + and "\x. x\s \ f x = g x" + shows "(g has_derivative f') (at x within t)" + using assms unfolding has_derivative_within + by (force simp add: intro: Lim_transform_within_open) + +lemma has_derivative_transform: + assumes "x \ s" "\x. x \ s \ g x = f x" + assumes "(f has_derivative f') (at x within s)" + shows "(g has_derivative f') (at x within s)" + using assms + by (intro has_derivative_transform_within[OF _ zero_less_one, where g=g]) auto + +lemma has_derivative_transform_eventually: + assumes "(f has_derivative f') (at x within s)" + "(\\<^sub>F x' in at x within s. f x' = g x')" + assumes "f x = g x" "x \ s" + shows "(g has_derivative f') (at x within s)" + using assms +proof - + from assms(2,3) obtain d where "d > 0" "\x'. x' \ s \ dist x' x < d \ f x' = g x'" + by (force simp: eventually_at) + from has_derivative_transform_within[OF assms(1) this(1) assms(4) this(2)] + show ?thesis . +qed + subsection \Continuity\ @@ -295,6 +348,14 @@ ((\x. g (f x)) has_derivative (\x. g' (f' x))) (at x within s)" by (blast intro: has_derivative_in_compose has_derivative_subset) +lemma has_derivative_in_compose2: + assumes "\x. x \ t \ (g has_derivative g' x) (at x within t)" + assumes "f ` s \ t" "x \ s" + assumes "(f has_derivative f') (at x within s)" + shows "((\x. g (f x)) has_derivative (\y. g' (f x) (f' y))) (at x within s)" + using assms + by (auto intro: has_derivative_within_subset intro!: has_derivative_in_compose[of f f' x s g]) + lemma (in bounded_bilinear) FDERIV: assumes f: "(f has_derivative f') (at x within s)" and g: "(g has_derivative g') (at x within s)" shows "((\x. f x ** g x) has_derivative (\h. f x ** g' h + f' h ** g x)) (at x within s)" @@ -467,6 +528,10 @@ all directions. There is a proof in \Analysis\ for \euclidean_space\. \ +lemma has_derivative_at2: "(f has_derivative f') (at x) \ + bounded_linear f' \ ((\y. (1 / (norm(y - x))) *\<^sub>R (f y - (f x + f' (y - x)))) \ 0) (at x)" + using has_derivative_within [of f f' x UNIV] + by simp lemma has_derivative_zero_unique: assumes "((\x. 0) has_derivative F) (at x)" shows "F = (\h. 0)" @@ -542,10 +607,19 @@ (\x. f (g x)) differentiable (at x within s)" by (blast intro: differentiable_in_compose differentiable_subset) -lemma differentiable_sum [simp, derivative_intros]: +lemma differentiable_add [simp, derivative_intros]: "f differentiable F \ g differentiable F \ (\x. f x + g x) differentiable F" unfolding differentiable_def by (blast intro: has_derivative_add) +lemma differentiable_sum[simp, derivative_intros]: + assumes "finite s" "\a\s. (f a) differentiable net" + shows "(\x. sum (\a. f a x) s) differentiable net" +proof - + from bchoice[OF assms(2)[unfolded differentiable_def]] + show ?thesis + by (auto intro!: has_derivative_sum simp: differentiable_def) +qed + lemma differentiable_minus [simp, derivative_intros]: "f differentiable F \ (\x. - f x) differentiable F" unfolding differentiable_def by (blast intro: has_derivative_minus) @@ -651,6 +725,14 @@ for c :: "'a::ab_semigroup_mult" by (simp add: fun_eq_iff mult.commute) +lemma DERIV_compose_FDERIV: + fixes f::"real\real" + assumes "DERIV f (g x) :> f'" + assumes "(g has_derivative g') (at x within s)" + shows "((\x. f (g x)) has_derivative (\x. g' x * f')) (at x within s)" + using assms has_derivative_compose[of g g' x s f "( * ) f'"] + by (auto simp: has_field_derivative_def ac_simps) + subsection \Vector derivative\ @@ -998,6 +1080,8 @@ by eventually_elim auto qed +lemmas has_derivative_floor[derivative_intros] = + floor_has_real_derivative[THEN DERIV_compose_FDERIV] text \Caratheodory formulation of derivative at a point\ diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Library/Extended_Real.thy --- a/src/HOL/Library/Extended_Real.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Library/Extended_Real.thy Thu Feb 22 15:17:25 2018 +0100 @@ -1800,8 +1800,176 @@ lemma max_MInf2 [simp]: "max x (-\::ereal) = x" by (metis max_bot2 bot_ereal_def) - -subsubsection "Topological space" +subsection \Extended real intervals\ + +lemma real_greaterThanLessThan_infinity_eq: + "real_of_ereal ` {N::ereal<..<\} = + (if N = \ then {} else if N = -\ then UNIV else {real_of_ereal N<..})" +proof - + { + fix x::real + have "x \ real_of_ereal ` {- \<..<\::ereal}" + by (auto intro!: image_eqI[where x="ereal x"]) + } moreover { + fix x::ereal + assume "N \ - \" "N < x" "x \ \" + then have "real_of_ereal N < real_of_ereal x" + by (cases N; cases x; simp) + } moreover { + fix x::real + assume "N \ \" "real_of_ereal N < x" + then have "x \ real_of_ereal ` {N<..<\}" + by (cases N) (auto intro!: image_eqI[where x="ereal x"]) + } ultimately show ?thesis by auto +qed + +lemma real_greaterThanLessThan_minus_infinity_eq: + "real_of_ereal ` {-\<.. then UNIV else if N = -\ then {} else {..<..}" + by (auto simp: ereal_uminus_less_reorder intro!: image_eqI[where x="-x" for x]) + also note real_greaterThanLessThan_infinity_eq + finally show ?thesis by (auto intro!: image_eqI[where x="-x" for x]) +qed + +lemma real_greaterThanLessThan_inter: + "real_of_ereal ` {N<..<.. real_of_ereal ` {N<..<\}" + apply safe + subgoal by force + subgoal by force + subgoal for x y z + by (cases y; cases z) (auto intro!: image_eqI[where x=z] simp: ) + done + +lemma real_atLeastGreaterThan_eq: "real_of_ereal ` {N<.. then {} else + if N = -\ then + (if M = \ then UNIV + else if M = -\ then {} + else {..< real_of_ereal M}) + else if M = - \ then {} + else if M = \ then {real_of_ereal N<..} + else {real_of_ereal N <..< real_of_ereal M})" + apply (subst real_greaterThanLessThan_inter) + apply (subst real_greaterThanLessThan_minus_infinity_eq) + apply (subst real_greaterThanLessThan_infinity_eq) + apply auto + done + +lemma real_image_ereal_ivl: + fixes a b::ereal + shows + "real_of_ereal ` {a<.. then if b = \ then UNIV else {.. then {real_of_ereal a<..} else {real_of_ereal a <..< real_of_ereal b}) else {})" + by (cases a; cases b; simp add: real_atLeastGreaterThan_eq not_less) + +lemma fixes a b c::ereal + shows not_inftyI: "a < b \ b < c \ abs b \ \" + by force + +lemma + interval_neqs: + fixes r s t::real + shows "{r<.. {t<..}" + and "{r<.. {.. UNIV" + and "{r<..} \ {.. UNIV" + and "{.. UNIV" + and "{} \ {r<..}" + and "{} \ {.. s \ u \ t \ r = t \ s = u)" + by (metis cInf_greaterThanLessThan cSup_greaterThanLessThan greaterThanLessThan_empty_iff not_le) + +lemma real_of_ereal_image_greaterThanLessThan_iff: + "real_of_ereal ` {a <..< b} = real_of_ereal ` {c <..< d} \ (a \ b \ c \ d \ a = c \ b = d)" + unfolding real_atLeastGreaterThan_eq + by (cases a; cases b; cases c; cases d; + simp add: greaterThanLessThan_eq_iff interval_neqs interval_neqs[symmetric]) + +lemma uminus_image_real_of_ereal_image_greaterThanLessThan: + "uminus ` real_of_ereal ` {l <..< u} = real_of_ereal ` {-u <..< -l}" + by (force simp: algebra_simps ereal_less_uminus_reorder + ereal_uminus_less_reorder intro: image_eqI[where x="-x" for x]) + +lemma add_image_real_of_ereal_image_greaterThanLessThan: + "(+) c ` real_of_ereal ` {l <..< u} = real_of_ereal ` {c + l <..< c + u}" + apply safe + subgoal for x + using ereal_less_add[of c] + by (force simp: real_of_ereal_add add.commute) + subgoal for _ x + by (force simp: add.commute real_of_ereal_minus ereal_minus_less ereal_less_minus + intro: image_eqI[where x="x - c"]) + done + +lemma add2_image_real_of_ereal_image_greaterThanLessThan: + "(\x. x + c) ` real_of_ereal ` {l <..< u} = real_of_ereal ` {l + c <..< u + c}" + using add_image_real_of_ereal_image_greaterThanLessThan[of c l u] + by (metis add.commute image_cong) + +lemma minus_image_real_of_ereal_image_greaterThanLessThan: + "(-) c ` real_of_ereal ` {l <..< u} = real_of_ereal ` {c - u <..< c - l}" + (is "?l = ?r") +proof - + have "?l = (+) c ` uminus ` real_of_ereal ` {l <..< u}" by auto + also note uminus_image_real_of_ereal_image_greaterThanLessThan + also note add_image_real_of_ereal_image_greaterThanLessThan + finally show ?thesis by (simp add: minus_ereal_def) +qed + +lemma real_ereal_bound_lemma_up: + assumes "s \ real_of_ereal ` {a<.. real_of_ereal ` {a<.. t" + shows "b \ \" + using assms + apply (cases b) + subgoal by force + subgoal by (metis PInfty_neq_ereal(2) assms dual_order.strict_trans1 ereal_infty_less(1) + ereal_less_ereal_Ex greaterThanLessThan_empty_iff greaterThanLessThan_iff greaterThan_iff + image_eqI less_imp_le linordered_field_no_ub not_less order_trans + real_greaterThanLessThan_infinity_eq real_image_ereal_ivl real_of_ereal.simps(1)) + subgoal by force + done + +lemma real_ereal_bound_lemma_down: + assumes "s \ real_of_ereal ` {a<.. real_of_ereal ` {a<.. s" + shows "a \ - \" + using assms + apply (cases b) + subgoal + apply safe + using assms(1) + apply (auto simp: real_greaterThanLessThan_minus_infinity_eq) + done + subgoal by (auto simp: real_greaterThanLessThan_minus_infinity_eq) + subgoal by auto + done + + +subsection "Topological space" instantiation ereal :: linear_continuum_topology begin @@ -2469,6 +2637,21 @@ by auto qed (auto simp add: image_Union image_Int) +lemma open_image_real_of_ereal: + fixes X::"ereal set" + assumes "open X" + assumes "\ \ X" + assumes "-\ \ X" + shows "open (real_of_ereal ` X)" +proof - + have "real_of_ereal ` X = ereal -` X" + apply safe + subgoal by (metis assms(2) assms(3) real_of_ereal.elims vimageI) + subgoal using image_iff by fastforce + done + thus ?thesis + by (auto intro!: open_ereal_vimage assms) +qed lemma eventually_finite: fixes x :: ereal diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Limits.thy --- a/src/HOL/Limits.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Limits.thy Thu Feb 22 15:17:25 2018 +0100 @@ -52,6 +52,9 @@ for f :: "_ \ real" by (rule filterlim_mono[OF _ at_top_le_at_infinity order_refl]) +lemma filterlim_real_at_infinity_sequentially: "filterlim real at_infinity sequentially" + by (simp add: filterlim_at_top_imp_at_infinity filterlim_real_sequentially) + lemma lim_infinity_imp_sequentially: "(f \ l) at_infinity \ ((\n. f(n)) \ l) sequentially" by (simp add: filterlim_at_top_imp_at_infinity filterlim_compose filterlim_real_sequentially) @@ -1256,6 +1259,20 @@ for a :: real unfolding at_right_to_0[of a] by (simp add: eventually_filtermap) +lemma at_to_0: "at a = filtermap (\x. x + a) (at 0)" + for a :: "'a::real_normed_vector" + using filtermap_at_shift[of "-a" 0] by simp + +lemma filterlim_at_to_0: + "filterlim f F (at a) \ filterlim (\x. f (x + a)) F (at 0)" + for a :: "'a::real_normed_vector" + unfolding filterlim_def filtermap_filtermap at_to_0[of a] .. + +lemma eventually_at_to_0: + "eventually P (at a) \ eventually (\x. P (x + a)) (at 0)" + for a :: "'a::real_normed_vector" + unfolding at_to_0[of a] by (simp add: eventually_filtermap) + lemma filtermap_at_minus: "filtermap (\x. - x) (at a) = at (- a)" for a :: "'a::real_normed_vector" by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_minus[symmetric]) @@ -1268,6 +1285,7 @@ for a :: real by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_minus[symmetric]) + lemma filterlim_at_left_to_right: "filterlim f F (at_left a) \ filterlim (\x. f (- x)) F (at_right (-a))" for a :: real @@ -1486,6 +1504,36 @@ for c :: nat by (rule filterlim_subseq) (auto simp: strict_mono_def) +lemma filterlim_times_pos: + "LIM x F1. c * f x :> at_right l" + if "filterlim f (at_right p) F1" "0 < c" "l = c * p" + for c::"'a::{linordered_field, linorder_topology}" + unfolding filterlim_iff +proof safe + fix P + assume "\\<^sub>F x in at_right l. P x" + then obtain d where "c * p < d" "\y. y > c * p \ y < d \ P y" + unfolding \l = _ \ eventually_at_right_field + by auto + then have "\\<^sub>F a in at_right p. P (c * a)" + by (auto simp: eventually_at_right_field \0 < c\ field_simps intro!: exI[where x="d/c"]) + from that(1)[unfolded filterlim_iff, rule_format, OF this] + show "\\<^sub>F x in F1. P (c * f x)" . +qed + +lemma filtermap_nhds_times: "c \ 0 \ filtermap (times c) (nhds a) = nhds (c * a)" + for a c :: "'a::real_normed_field" + by (rule filtermap_fun_inverse[where g="\x. inverse c * x"]) + (auto intro!: tendsto_eq_intros filterlim_ident) + +lemma filtermap_times_pos_at_right: + fixes c::"'a::{linordered_field, linorder_topology}" + assumes "c > 0" + shows "filtermap (times c) (at_right p) = at_right (c * p)" + using assms + by (intro filtermap_fun_inverse[where g="\x. inverse c * x"]) + (auto intro!: filterlim_ident filterlim_times_pos) + lemma at_to_infinity: "(at (0::'a::{real_normed_field,field})) = filtermap inverse at_infinity" proof (rule antisym) have "(inverse \ (0::'a)) at_infinity" @@ -1936,6 +1984,10 @@ lemma lim_inverse_n: "((\n. inverse(of_nat n)) \ (0::'a::real_normed_field)) sequentially" using lim_1_over_n by (simp add: inverse_eq_divide) +lemma lim_inverse_n': "((\n. 1 / n) \ 0) sequentially" + using lim_inverse_n + by (simp add: inverse_eq_divide) + lemma LIMSEQ_Suc_n_over_n: "(\n. of_nat (Suc n) / of_nat n :: 'a :: real_normed_field) \ 1" proof (rule Lim_transform_eventually) show "eventually (\n. 1 + inverse (of_nat n :: 'a) = of_nat (Suc n) / of_nat n) sequentially" diff -r 00c436488398 -r bdff8bf0a75b src/HOL/NthRoot.thy --- a/src/HOL/NthRoot.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/NthRoot.thy Thu Feb 22 15:17:25 2018 +0100 @@ -480,6 +480,9 @@ lemma sqrt_le_D: "sqrt x \ y \ x \ y\<^sup>2" by (meson not_le real_less_rsqrt) +lemma sqrt_ge_absD: "\x\ \ sqrt y \ x\<^sup>2 \ y" + using real_sqrt_le_iff[of "x\<^sup>2"] by simp + lemma sqrt_even_pow2: assumes n: "even n" shows "sqrt (2 ^ n) = 2 ^ (n div 2)" @@ -538,6 +541,8 @@ DERIV_real_sqrt_generic[THEN DERIV_chain2, derivative_intros] DERIV_real_root_generic[THEN DERIV_chain2, derivative_intros] +lemmas has_derivative_real_sqrt[derivative_intros] = DERIV_real_sqrt[THEN DERIV_compose_FDERIV] + lemma not_real_square_gt_zero [simp]: "\ 0 < x * x \ x = 0" for x :: real apply auto @@ -658,6 +663,13 @@ lemma le_real_sqrt_sumsq [simp]: "x \ sqrt (x * x + y * y)" by (simp add: power2_eq_square [symmetric]) +lemma sqrt_sum_squares_le_sum: + "\0 \ x; 0 \ y\ \ sqrt (x\<^sup>2 + y\<^sup>2) \ x + y" + apply (rule power2_le_imp_le) + apply (simp add: power2_sum) + apply simp + done + lemma real_sqrt_sum_squares_triangle_ineq: "sqrt ((a + c)\<^sup>2 + (b + d)\<^sup>2) \ sqrt (a\<^sup>2 + b\<^sup>2) + sqrt (c\<^sup>2 + d\<^sup>2)" apply (rule power2_le_imp_le) diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Set_Interval.thy Thu Feb 22 15:17:25 2018 +0100 @@ -222,6 +222,10 @@ "{a..Emptyness, singletons, subset\ @@ -869,6 +873,19 @@ context linordered_semidom begin +lemma image_add_atLeast[simp]: "plus k ` {i..} = {k + i..}" +proof - + have "n = k + (n - k)" if "i + k \ n" for n + proof - + have "n = (n - (k + i)) + (k + i)" using that + by (metis add_commute le_add_diff_inverse) + then show "n = k + (n - k)" + by (metis local.add_diff_cancel_left' add_assoc add_commute) + qed + then show ?thesis + by (fastforce simp: add_le_imp_le_diff add.commute) +qed + lemma image_add_atLeastAtMost [simp]: "plus k ` {i..j} = {i + k..j + k}" (is "?A = ?B") proof @@ -911,112 +928,11 @@ "(\n. n + k) ` {i..0" shows "(( * ) d ` {a..b}) = {d*a..d*b}" - using assms - by (auto simp: field_simps mult_le_cancel_right intro: rev_image_eqI [where x="x/d" for x]) - -lemma image_affinity_atLeastAtMost: - fixes c :: "'a::linordered_field" - shows "((\x. m*x + c) ` {a..b}) = (if {a..b}={} then {} - else if 0 \ m then {m*a + c .. m *b + c} - else {m*b + c .. m*a + c})" - apply (case_tac "m=0", auto simp: mult_le_cancel_left) - apply (rule_tac x="inverse m*(x-c)" in rev_image_eqI, auto simp: field_simps) - apply (rule_tac x="inverse m*(x-c)" in rev_image_eqI, auto simp: field_simps) - done - -lemma image_affinity_atLeastAtMost_diff: - fixes c :: "'a::linordered_field" - shows "((\x. m*x - c) ` {a..b}) = (if {a..b}={} then {} - else if 0 \ m then {m*a - c .. m*b - c} - else {m*b - c .. m*a - c})" - using image_affinity_atLeastAtMost [of m "-c" a b] - by simp - -lemma image_affinity_atLeastAtMost_div: - fixes c :: "'a::linordered_field" - shows "((\x. x/m + c) ` {a..b}) = (if {a..b}={} then {} - else if 0 \ m then {a/m + c .. b/m + c} - else {b/m + c .. a/m + c})" - using image_affinity_atLeastAtMost [of "inverse m" c a b] - by (simp add: field_class.field_divide_inverse algebra_simps) - -lemma image_affinity_atLeastAtMost_div_diff: - fixes c :: "'a::linordered_field" - shows "((\x. x/m - c) ` {a..b}) = (if {a..b}={} then {} - else if 0 \ m then {a/m - c .. b/m - c} - else {b/m - c .. a/m - c})" - using image_affinity_atLeastAtMost_diff [of "inverse m" c a b] - by (simp add: field_class.field_divide_inverse algebra_simps) - -lemma atLeast1_lessThan_eq_remove0: - "{Suc 0..i. i - c) ` {x ..< y} = - (if c < y then {x - c ..< y - c} else if x < y then {0} else {})" - (is "_ = ?right") -proof safe - fix a assume a: "a \ ?right" - show "a \ (\i. i - c) ` {x ..< y}" - proof cases - assume "c < y" with a show ?thesis - by (auto intro!: image_eqI[of _ _ "a + c"]) - next - assume "\ c < y" with a show ?thesis - by (auto intro!: image_eqI[of _ _ x] split: if_split_asm) - qed -qed auto - -lemma image_int_atLeastLessThan: - "int ` {a.. = {c - b<..c - a}" by simp + finally show ?thesis by simp +qed + +lemma image_minus_const_greaterThanAtMost_real[simp]: + fixes a b c::"'a::linordered_idom" + shows "(-) c ` {a<..b} = {c - b.. = {c - b.. = {..c - a}" by simp + finally show ?thesis by simp +qed + +lemma image_minus_const_AtMost_real[simp]: + fixes b c::"'a::linordered_idom" + shows "(-) c ` {..b} = {c - b..}" +proof - + have "(-) c ` {..b} = (+) c ` uminus ` {..b}" + unfolding image_image by simp + also have "\ = {c - b..}" by simp + finally show ?thesis by simp +qed + +context linordered_field begin + +lemma image_mult_atLeastAtMost [simp]: + "(( * ) d ` {a..b}) = {d*a..d*b}" if "d>0" + using that + by (auto simp: field_simps mult_le_cancel_right intro: rev_image_eqI [where x="x/d" for x]) + +lemma image_mult_atLeastAtMost_if: + "( * ) c ` {x .. y} = + (if c > 0 then {c * x .. c * y} else if x \ y then {c * y .. c * x} else {})" +proof - + consider "c < 0" "x \ y" | "c = 0" "x \ y" | "c > 0" "x \ y" | "x > y" + using local.antisym_conv3 local.leI by blast + then show ?thesis + proof cases + case 1 + have "( * ) c ` {x .. y} = uminus ` ( * ) (- c) ` {x .. y}" + by (simp add: image_image) + also have "\ = {c * y .. c * x}" + using \c < 0\ + by simp + finally show ?thesis + using \c < 0\ by auto + qed (auto simp: not_le local.mult_less_cancel_left_pos) +qed + +lemma image_mult_atLeastAtMost_if': + "(\x. x * c) ` {x..y} = + (if x \ y then if c > 0 then {x * c .. y * c} else {y * c .. x * c} else {})" + by (subst mult.commute) + (simp add: image_mult_atLeastAtMost_if mult.commute mult_le_cancel_left_pos) + +lemma image_affinity_atLeastAtMost: + "((\x. m*x + c) ` {a..b}) = (if {a..b}={} then {} + else if 0 \ m then {m*a + c .. m *b + c} + else {m*b + c .. m*a + c})" +proof - + have "(\x. m*x + c) = ((\x. x + c) o ( * ) m)" + unfolding image_comp[symmetric] + by (simp add: o_def) + then show ?thesis + by (auto simp add: image_comp[symmetric] image_mult_atLeastAtMost_if mult_le_cancel_left) +qed + +lemma image_affinity_atLeastAtMost_diff: + "((\x. m*x - c) ` {a..b}) = (if {a..b}={} then {} + else if 0 \ m then {m*a - c .. m*b - c} + else {m*b - c .. m*a - c})" + using image_affinity_atLeastAtMost [of m "-c" a b] + by simp + +lemma image_affinity_atLeastAtMost_div: + "((\x. x/m + c) ` {a..b}) = (if {a..b}={} then {} + else if 0 \ m then {a/m + c .. b/m + c} + else {b/m + c .. a/m + c})" + using image_affinity_atLeastAtMost [of "inverse m" c a b] + by (simp add: field_class.field_divide_inverse algebra_simps inverse_eq_divide) + +lemma image_affinity_atLeastAtMost_div_diff: + "((\x. x/m - c) ` {a..b}) = (if {a..b}={} then {} + else if 0 \ m then {a/m - c .. b/m - c} + else {b/m - c .. a/m - c})" + using image_affinity_atLeastAtMost_diff [of "inverse m" c a b] + by (simp add: field_class.field_divide_inverse algebra_simps inverse_eq_divide) + +end + +lemma atLeast1_lessThan_eq_remove0: + "{Suc 0..i. i - c) ` {x ..< y} = + (if c < y then {x - c ..< y - c} else if x < y then {0} else {})" + (is "_ = ?right") +proof safe + fix a assume a: "a \ ?right" + show "a \ (\i. i - c) ` {x ..< y}" + proof cases + assume "c < y" with a show ?thesis + by (auto intro!: image_eqI[of _ _ "a + c"]) + next + assume "\ c < y" with a show ?thesis + by (auto intro!: image_eqI[of _ _ x] split: if_split_asm) + qed +qed auto + +lemma image_int_atLeastLessThan: + "int ` {a..Finiteness\ lemma finite_lessThan [iff]: fixes k :: nat shows "finite {..P x})" shows "filterlim (\x. if P x then f x else g x) G (at x)" using assms by (intro filterlim_at_within_If) simp_all - lemma (in linorder_topology) at_within_order: assumes "UNIV \ {x}" shows "at x within s = @@ -692,7 +691,18 @@ (\S. open S \ A \ S \ (\x. f x \ S \ B - {A} \ P x))" (is "?lhs = ?rhs") unfolding at_within_def filtercomap_inf eventually_inf_principal filtercomap_principal eventually_filtercomap_nhds eventually_principal by blast - + +lemma eventually_at_right_field: + "eventually P (at_right x) \ (\b>x. \y>x. y < b \ P y)" + for x :: "'a::{linordered_field, linorder_topology}" + using linordered_field_no_ub[rule_format, of x] + by (auto simp: eventually_at_right) + +lemma eventually_at_left_field: + "eventually P (at_left x) \ (\by>b. y < x \ P y)" + for x :: "'a::{linordered_field, linorder_topology}" + using linordered_field_no_lb[rule_format, of x] + by (auto simp: eventually_at_left) subsubsection \Tendsto\ @@ -762,9 +772,11 @@ end -lemma tendsto_within_subset: - "(f \ l) (at x within S) \ T \ S \ (f \ l) (at x within T)" - by (blast intro: tendsto_mono at_le) +lemma (in topological_space) filterlim_within_subset: + "filterlim f l (at x within S) \ T \ S \ filterlim f l (at x within T)" + by (blast intro: filterlim_mono at_le) + +lemmas tendsto_within_subset = filterlim_within_subset lemma (in order_topology) order_tendsto_iff: "(f \ x) F \ (\lx. l < f x) F) \ (\u>x. eventually (\x. f x < u) F)" @@ -963,6 +975,11 @@ lemma Lim_ident_at: "\ trivial_limit (at x within s) \ Lim (at x within s) (\x. x) = x" by (rule tendsto_Lim[OF _ tendsto_ident_at]) auto +lemma eventually_Lim_ident_at: + "(\\<^sub>F y in at x within X. P (Lim (at x within X) (\x. x)) y) \ + (\\<^sub>F y in at x within X. P x y)" for x::"'a::t2_space" + by (cases "at x within X = bot") (auto simp: Lim_ident_at) + lemma filterlim_at_bot_at_right: fixes f :: "'a::linorder_topology \ 'b::linorder" assumes mono: "\x y. Q x \ Q y \ x \ y \ f x \ f y" @@ -2612,6 +2629,37 @@ by (metis less_le) qed +lemma (in linorder_topology) not_in_connected_cases: + assumes conn: "connected S" + assumes nbdd: "x \ S" + assumes ne: "S \ {}" + obtains "bdd_above S" "\y. y \ S \ x \ y" | "bdd_below S" "\y. y \ S \ x \ y" +proof - + obtain s where "s \ S" using ne by blast + { + assume "s \ x" + have "False" if "x \ y" "y \ S" for y + using connectedD_interval[OF conn \s \ S\ \y \ S\ \s \ x\ \x \ y\] \x \ S\ + by simp + then have wit: "y \ S \ x \ y" for y + using le_cases by blast + then have "bdd_above S" + by (rule local.bdd_aboveI) + note this wit + } moreover { + assume "x \ s" + have "False" if "x \ y" "y \ S" for y + using connectedD_interval[OF conn \y \ S\ \s \ S\ \x \ y\ \s \ x\ ] \x \ S\ + by simp + then have wit: "y \ S \ x \ y" for y + using le_cases by blast + then have "bdd_below S" + by (rule bdd_belowI) + note this wit + } ultimately show ?thesis + by (meson le_cases that) +qed + lemma connected_continuous_image: assumes *: "continuous_on s f" and "connected s" @@ -3454,6 +3502,15 @@ lemma isCont_Pair [simp]: "\isCont f a; isCont g a\ \ isCont (\x. (f x, g x)) a" by (fact continuous_Pair) +lemma continuous_on_compose_Pair: + assumes f: "continuous_on (Sigma A B) (\(a, b). f a b)" + assumes g: "continuous_on C g" + assumes h: "continuous_on C h" + assumes subset: "\c. c \ C \ g c \ A" "\c. c \ C \ h c \ B (g c)" + shows "continuous_on C (\c. f (g c) (h c))" + using continuous_on_compose2[OF f continuous_on_Pair[OF g h]] subset + by auto + subsubsection \Connectedness of products\ diff -r 00c436488398 -r bdff8bf0a75b src/HOL/Transcendental.thy --- a/src/HOL/Transcendental.thy Tue Feb 20 22:25:23 2018 +0100 +++ b/src/HOL/Transcendental.thy Thu Feb 22 15:17:25 2018 +0100 @@ -1389,6 +1389,8 @@ declare DERIV_exp[THEN DERIV_chain2, derivative_intros] and DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] +lemmas has_derivative_exp[derivative_intros] = DERIV_exp[THEN DERIV_compose_FDERIV] + lemma norm_exp: "norm (exp x) \ exp (norm x)" proof - from summable_norm[OF summable_norm_exp, of x] @@ -1883,6 +1885,8 @@ declare DERIV_ln_divide[THEN DERIV_chain2, derivative_intros] and DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] +lemmas has_derivative_ln[derivative_intros] = DERIV_ln[THEN DERIV_compose_FDERIV] + lemma ln_series: assumes "0 < x" and "x < 2" shows "ln x = (\ n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))" @@ -3094,24 +3098,33 @@ shows "((\x. f x powr g x) \ a powr b) F" using tendsto_powr'[of f a F g b] assms by auto +lemma has_derivative_powr[derivative_intros]: + assumes g[derivative_intros]: "(g has_derivative g') (at x within X)" + and f[derivative_intros]:"(f has_derivative f') (at x within X)" + assumes pos: "0 < g x" and "x \ X" + shows "((\x. g x powr f x::real) has_derivative (\h. (g x powr f x) * (f' h * ln (g x) + g' h * f x / g x))) (at x within X)" +proof - + have "\\<^sub>F x in at x within X. g x > 0" + by (rule order_tendstoD[OF _ pos]) + (rule has_derivative_continuous[OF g, unfolded continuous_within]) + then obtain d where "d > 0" and pos': "\x'. x' \ X \ dist x' x < d \ 0 < g x'" + using pos unfolding eventually_at by force + have "((\x. exp (f x * ln (g x))) has_derivative + (\h. (g x powr f x) * (f' h * ln (g x) + g' h * f x / g x))) (at x within X)" + using pos + by (auto intro!: derivative_eq_intros simp: divide_simps powr_def) + then show ?thesis + by (rule has_derivative_transform_within[OF _ \d > 0\ \x \ X\]) (auto simp: powr_def dest: pos') +qed + lemma DERIV_powr: fixes r :: real assumes g: "DERIV g x :> m" and pos: "g x > 0" and f: "DERIV f x :> r" shows "DERIV (\x. g x powr f x) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)" -proof - - have "DERIV (\x. exp (f x * ln (g x))) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)" - using pos - by (auto intro!: derivative_eq_intros g pos f simp: powr_def field_simps exp_diff) - then show ?thesis - proof (rule DERIV_cong_ev[OF refl _ refl, THEN iffD1, rotated]) - from DERIV_isCont[OF g] pos have "\\<^sub>F x in at x. 0 < g x" - unfolding isCont_def by (rule order_tendstoD(1)) - with pos show "\\<^sub>F x in nhds x. exp (f x * ln (g x)) = g x powr f x" - by (auto simp: eventually_at_filter powr_def elim: eventually_mono) - qed -qed + using assms + by (auto intro!: derivative_eq_intros ext simp: has_field_derivative_def algebra_simps) lemma DERIV_fun_powr: fixes r :: real @@ -3344,6 +3357,8 @@ declare DERIV_sin[THEN DERIV_chain2, derivative_intros] and DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] +lemmas has_derivative_sin[derivative_intros] = DERIV_sin[THEN DERIV_compose_FDERIV] + lemma DERIV_cos [simp]: "DERIV cos x :> - sin x" for x :: "'a::{real_normed_field,banach}" unfolding sin_def cos_def scaleR_conv_of_real @@ -3359,6 +3374,8 @@ declare DERIV_cos[THEN DERIV_chain2, derivative_intros] and DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] +lemmas has_derivative_cos[derivative_intros] = DERIV_cos[THEN DERIV_compose_FDERIV] + lemma isCont_sin: "isCont sin x" for x :: "'a::{real_normed_field,banach}" by (rule DERIV_sin [THEN DERIV_isCont]) @@ -4598,6 +4615,8 @@ unfolding tan_def by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square) +lemmas has_derivative_tan[derivative_intros] = DERIV_tan[THEN DERIV_compose_FDERIV] + lemma isCont_tan: "cos x \ 0 \ isCont tan x" for x :: "'a::{real_normed_field,banach}" by (rule DERIV_tan [THEN DERIV_isCont]) @@ -5265,6 +5284,10 @@ DERIV_arctan[THEN DERIV_chain2, derivative_intros] DERIV_arctan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] +lemmas has_derivative_arctan[derivative_intros] = DERIV_arctan[THEN DERIV_compose_FDERIV] + and has_derivative_arccos[derivative_intros] = DERIV_arccos[THEN DERIV_compose_FDERIV] + and has_derivative_arcsin[derivative_intros] = DERIV_arcsin[THEN DERIV_compose_FDERIV] + lemma filterlim_tan_at_right: "filterlim tan at_bot (at_right (- (pi/2)))" by (rule filterlim_at_bot_at_right[where Q="\x. - pi/2 < x \ x < pi/2" and P="\x. True" and g=arctan]) (auto simp: arctan le_less eventually_at dist_real_def simp del: less_divide_eq_numeral1