# HG changeset patch # User paulson # Date 1474555487 -3600 # Node ID f6ce08859d4c015a71dae3e5ba4e59f629960d27 # Parent d81fb5b46a5c01c2eb35a8524a0229f1c9c3c565 More mainly topological results diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Bounded_Linear_Function.thy --- a/src/HOL/Analysis/Bounded_Linear_Function.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Bounded_Linear_Function.thy Thu Sep 22 15:44:47 2016 +0100 @@ -391,7 +391,7 @@ also have "\ = (\i\Basis. (x \ i * (f i \ b)))" using b by (simp add: setsum.delta) also have "\ = f x \ b" - by (subst linear_componentwise[symmetric]) (unfold_locales, rule) + by (metis (mono_tags, lifting) Linear_Algebra.linear_componentwise linear_axioms) finally show "(\j\Basis. \i\Basis. (x \ i * (f i \ j)) *\<^sub>R j) \ b = f x \ b" . qed diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Cartesian_Euclidean_Space.thy --- a/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Thu Sep 22 15:44:47 2016 +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 (* Henstock_Kurzweil_Integration *) +imports Finite_Cartesian_Product Derivative begin lemma subspace_special_hyperplane: "subspace {x. x $ k = 0}" @@ -11,6 +11,7 @@ "(if k=a then 1 else (0::'a::semiring_1)) * (if k=a then 1 else 0) = (if k=a then 1 else 0)" by simp +(*move up?*) lemma setsum_UNIV_sum: fixes g :: "'a::finite + 'b::finite \ _" shows "(\x\UNIV. g x) = (\x\UNIV. g (Inl x)) + (\x\UNIV. g (Inr x))" @@ -33,7 +34,6 @@ qed simp qed simp - subsection\Basic componentwise operations on vectors.\ instantiation vec :: (times, finite) times @@ -598,7 +598,7 @@ lemma basis_expansion: "setsum (\i. (x$i) *s axis i 1) UNIV = (x::('a::ring_1) ^'n)" by (auto simp add: axis_def vec_eq_iff if_distrib setsum.If_cases cong del: if_weak_cong) -lemma linear_componentwise: +lemma linear_componentwise_expansion: fixes f:: "real ^'m \ real ^ _" assumes lf: "linear f" shows "(f x)$j = setsum (\i. (x$i) * (f (axis i 1)$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs") @@ -636,9 +636,7 @@ assumes lf: "linear f" shows "matrix f *v x = f (x::real ^ 'n)" apply (simp add: matrix_def matrix_vector_mult_def vec_eq_iff mult.commute) - apply clarify - apply (rule linear_componentwise[OF lf, symmetric]) - done + by (simp add: linear_componentwise_expansion lf) lemma matrix_vector_mul: "linear f ==> f = (\x. matrix f *v (x::real ^ 'n))" by (simp add: ext matrix_works) diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Cauchy_Integral_Theorem.thy --- a/src/HOL/Analysis/Cauchy_Integral_Theorem.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Cauchy_Integral_Theorem.thy Thu Sep 22 15:44:47 2016 +0100 @@ -2163,7 +2163,7 @@ { fix x y z n assume At: "At x y z n" then have contf': "continuous_on (convex hull {x,y,z}) f" - using contf At_def continuous_on_subset by blast + using contf At_def continuous_on_subset by metis have "\x' y' z'. At x' y' z' (Suc n) \ convex hull {x',y',z'} \ convex hull {x,y,z}" using At apply (simp add: At_def) @@ -3213,11 +3213,6 @@ using contour_integral_nearby [OF assms, where atends=False] unfolding linked_paths_def by simp_all -corollary differentiable_polynomial_function: - fixes p :: "real \ 'a::euclidean_space" - shows "polynomial_function p \ p differentiable_on s" -by (meson has_vector_derivative_polynomial_function differentiable_at_imp_differentiable_on differentiable_def has_vector_derivative_def) - lemma C1_differentiable_polynomial_function: fixes p :: "real \ 'a::euclidean_space" shows "polynomial_function p \ p C1_differentiable_on s" @@ -3255,7 +3250,7 @@ done then obtain p' where p': "polynomial_function p'" "\x. (p has_vector_derivative (p' x)) (at x)" - using has_vector_derivative_polynomial_function by force + by (blast intro: has_vector_derivative_polynomial_function that elim: ) then have "bounded(p' ` {0..1})" using continuous_on_polymonial_function by (force simp: intro!: compact_imp_bounded compact_continuous_image) diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Analysis/Convex_Euclidean_Space.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Convex_Euclidean_Space.thy Thu Sep 22 15:44:47 2016 +0100 @@ -1,5 +1,5 @@ -(* Title: HOL/Analysis/Convex_Euclidean_Space.thy - Authors: Robert Himmelmann, TU Muenchen; Bogdan Grechuk, University of Edinburgh; LCP +(* Author: L C Paulson, University of Cambridge + Authors: Robert Himmelmann, TU Muenchen; Bogdan Grechuk, University of Edinburgh *) section \Convex sets, functions and related things\ @@ -219,7 +219,7 @@ from gxy have th0: "g (x - y) = 0" by (simp add: linear_diff[OF g(1)]) have th1: "x - y \ span B" using x' y' - by (metis span_sub) + by (metis span_diff) have "x = y" using g0[OF th1 th0] by simp } then have giS: "inj_on g S" unfolding inj_on_def by blast @@ -2267,7 +2267,7 @@ apply (rule subset_le_dim) unfolding subset_eq using \a\s\ - apply (auto simp add:span_superset span_sub) + apply (auto simp add:span_superset span_diff) done also have "\ < dim s + 1" by auto also have "\ \ card (s - {a})" diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Derivative.thy --- a/src/HOL/Analysis/Derivative.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Derivative.thy Thu Sep 22 15:44:47 2016 +0100 @@ -9,29 +9,7 @@ imports Brouwer_Fixpoint Operator_Norm Uniform_Limit Bounded_Linear_Function begin -lemma bounded_linear_component [intro]: "bounded_linear (\x::'a::euclidean_space. x \ k)" - by (rule bounded_linear_inner_left) - -lemma onorm_inner_left: - assumes "bounded_linear r" - shows "onorm (\x. r x \ f) \ onorm r * norm f" -proof (rule onorm_bound) - fix x - have "norm (r x \ f) \ norm (r x) * norm f" - by (simp add: Cauchy_Schwarz_ineq2) - also have "\ \ onorm r * norm x * norm f" - by (intro mult_right_mono onorm assms norm_ge_zero) - finally show "norm (r x \ f) \ onorm r * norm f * norm x" - by (simp add: ac_simps) -qed (intro mult_nonneg_nonneg norm_ge_zero onorm_pos_le assms) - -lemma onorm_inner_right: - assumes "bounded_linear r" - shows "onorm (\x. f \ r x) \ norm f * onorm r" - apply (subst inner_commute) - apply (rule onorm_inner_left[OF assms, THEN order_trans]) - apply simp - done +declare bounded_linear_inner_left [intro] declare has_derivative_bounded_linear[dest] diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Euclidean_Space.thy --- a/src/HOL/Analysis/Euclidean_Space.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Euclidean_Space.thy Thu Sep 22 15:44:47 2016 +0100 @@ -105,10 +105,10 @@ apply (blast intro: assms) done -lemma DIM_positive: "0 < DIM('a::euclidean_space)" +lemma DIM_positive [simp]: "0 < DIM('a::euclidean_space)" by (simp add: card_gt_0_iff) -lemma DIM_ge_Suc0 [iff]: "Suc 0 \ card Basis" +lemma DIM_ge_Suc0 [simp]: "Suc 0 \ card Basis" by (meson DIM_positive Suc_leI) diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Henstock_Kurzweil_Integration.thy --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Thu Sep 22 15:44:47 2016 +0100 @@ -2902,7 +2902,7 @@ fixes f :: "'n::euclidean_space \ 'm::euclidean_space" assumes "f integrable_on s" shows "integral s (\x. f x \ k) = integral s f \ k" - unfolding integral_linear[OF assms(1) bounded_linear_component,unfolded o_def] .. + unfolding integral_linear[OF assms(1) bounded_linear_inner_left,unfolded o_def] .. lemma has_integral_setsum: assumes "finite t" @@ -3090,7 +3090,7 @@ shows "(f has_integral y) A \ (\b\Basis. ((\x. f x \ b) has_integral (y \ b)) A)" proof safe fix b :: 'b assume "(f has_integral y) A" - from has_integral_linear[OF this(1) bounded_linear_component, of b] + from has_integral_linear[OF this(1) bounded_linear_inner_left, of b] show "((\x. f x \ b) has_integral (y \ b)) A" by (simp add: o_def) next assume "(\b\Basis. ((\x. f x \ b) has_integral (y \ b)) A)" @@ -3148,7 +3148,7 @@ lemma integrable_component: "f integrable_on A \ (\x. f x \ (y :: 'b :: euclidean_space)) integrable_on A" - by (drule integrable_linear[OF _ bounded_linear_component[of y]]) (simp add: o_def) + by (drule integrable_linear[OF _ bounded_linear_inner_left[of y]]) (simp add: o_def) diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/L2_Norm.thy --- a/src/HOL/Analysis/L2_Norm.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/L2_Norm.thy Thu Sep 22 15:44:47 2016 +0100 @@ -165,12 +165,7 @@ done lemma member_le_setL2: "\finite A; i \ A\ \ f i \ setL2 f A" - apply (rule_tac s="insert i (A - {i})" and t="A" in subst) - apply fast - apply (subst setL2_insert) - apply simp - apply simp - apply simp - done + unfolding setL2_def + by (auto intro!: member_le_setsum real_le_rsqrt) end diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Linear_Algebra.thy --- a/src/HOL/Analysis/Linear_Algebra.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Linear_Algebra.thy Thu Sep 22 15:44:47 2016 +0100 @@ -457,7 +457,7 @@ lemma span_neg: "x \ span S \ - x \ span S" by (metis subspace_neg subspace_span) -lemma span_sub: "x \ span S \ y \ span S \ x - y \ span S" +lemma span_diff: "x \ span S \ y \ span S \ x - y \ span S" by (metis subspace_span subspace_diff) lemma (in real_vector) span_setsum: "(\x. x \ A \ f x \ span S) \ setsum f A \ span S" @@ -2615,7 +2615,7 @@ from gxy have th0: "g (x - y) = 0" by (simp add: linear_diff[OF g(1)]) have th1: "x - y \ span B" - using x' y' by (metis span_sub) + using x' y' by (metis span_diff) have "x = y" using g0[OF th1 th0] by simp } diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Analysis/Topology_Euclidean_Space.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Analysis/Topology_Euclidean_Space.thy Thu Sep 22 15:44:47 2016 +0100 @@ -1,4 +1,4 @@ -(* title: HOL/Library/Topology_Euclidian_Space.thy +(* Author: L C Paulson, University of Cambridge Author: Amine Chaieb, University of Cambridge Author: Robert Himmelmann, TU Muenchen Author: Brian Huffman, Portland State University @@ -4040,6 +4040,11 @@ by auto qed +corollary infinite_openin: + fixes S :: "'a :: t1_space set" + shows "\openin (subtopology euclidean U) S; x \ S; x islimpt U\ \ infinite S" + by (clarsimp simp add: openin_open islimpt_eq_acc_point inf_commute) + lemma islimpt_range_imp_convergent_subsequence: fixes l :: "'a :: {t1_space, first_countable_topology}" assumes l: "l islimpt (range f)" @@ -6906,7 +6911,7 @@ show "\e>0. \y. dist y (f x) < e \ y \ f ` A" proof (intro exI conjI) show "\ > 0" - using \e > 0\ \B > 0\ by (simp add: \_def divide_simps) (simp add: mult_less_0_iff) + using \e > 0\ \B > 0\ by (simp add: \_def divide_simps) have "y \ f ` A" if "dist y (f x) * (B * real DIM('b)) < e" for y proof - define u where "u \ y - f x" @@ -9712,6 +9717,126 @@ apply (simp add: convergent_imp_bounded) by (simp add: closed_limpt islimpt_insert sequence_unique_limpt) + +subsection\Componentwise limits and continuity\ + +text\But is the premise really necessary? Need to generalise @{thm euclidean_dist_l2}\ +lemma Euclidean_dist_upper: "i \ Basis \ dist (x \ i) (y \ i) \ dist x y" + by (metis (no_types) member_le_setL2 euclidean_dist_l2 finite_Basis) + +text\But is the premise @{term \i \ Basis\} really necessary?\ +lemma open_preimage_inner: + assumes "open S" "i \ Basis" + shows "open {x. x \ i \ S}" +proof (rule openI, simp) + fix x + assume x: "x \ i \ S" + with assms obtain e where "0 < e" and e: "ball (x \ i) e \ S" + by (auto simp: open_contains_ball_eq) + have "\e>0. ball (y \ i) e \ S" if dxy: "dist x y < e / 2" for y + proof (intro exI conjI) + have "dist (x \ i) (y \ i) < e / 2" + by (meson \i \ Basis\ dual_order.trans Euclidean_dist_upper not_le that) + then have "dist (x \ i) z < e" if "dist (y \ i) z < e / 2" for z + by (metis dist_commute dist_triangle_half_l that) + then have "ball (y \ i) (e / 2) \ ball (x \ i) e" + using mem_ball by blast + with e show "ball (y \ i) (e / 2) \ S" + by (metis order_trans) + qed (simp add: \0 < e\) + then show "\e>0. ball x e \ {s. s \ i \ S}" + by (metis (no_types, lifting) \0 < e\ \open S\ half_gt_zero_iff mem_Collect_eq mem_ball open_contains_ball_eq subsetI) +qed + +proposition tendsto_componentwise_iff: + fixes f :: "_ \ 'b::euclidean_space" + shows "(f \ l) F \ (\i \ Basis. ((\x. (f x \ i)) \ (l \ i)) F)" + (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + unfolding tendsto_def + apply clarify + apply (drule_tac x="{s. s \ i \ S}" in spec) + apply (auto simp: open_preimage_inner) + done +next + assume R: ?rhs + then have "\e. e > 0 \ \i\Basis. \\<^sub>F x in F. dist (f x \ i) (l \ i) < e" + unfolding tendsto_iff by blast + then have R': "\e. e > 0 \ \\<^sub>F x in F. \i\Basis. dist (f x \ i) (l \ i) < e" + by (simp add: eventually_ball_finite_distrib [symmetric]) + show ?lhs + unfolding tendsto_iff + proof clarify + fix e::real + assume "0 < e" + have *: "setL2 (\i. dist (f x \ i) (l \ i)) Basis < e" + if "\i\Basis. dist (f x \ i) (l \ i) < e / real DIM('b)" for x + proof - + have "setL2 (\i. dist (f x \ i) (l \ i)) Basis \ setsum (\i. dist (f x \ i) (l \ i)) Basis" + by (simp add: setL2_le_setsum) + also have "... < DIM('b) * (e / real DIM('b))" + apply (rule setsum_bounded_above_strict) + using that by auto + also have "... = e" + by (simp add: field_simps) + finally show "setL2 (\i. dist (f x \ i) (l \ i)) Basis < e" . + qed + have "\\<^sub>F x in F. \i\Basis. dist (f x \ i) (l \ i) < e / DIM('b)" + apply (rule R') + using \0 < e\ by simp + then show "\\<^sub>F x in F. dist (f x) l < e" + apply (rule eventually_mono) + apply (subst euclidean_dist_l2) + using * by blast + qed +qed + + +corollary continuous_componentwise: + "continuous F f \ (\i \ Basis. continuous F (\x. (f x \ i)))" +by (simp add: continuous_def tendsto_componentwise_iff [symmetric]) + +corollary continuous_on_componentwise: + fixes S :: "'a :: t2_space set" + shows "continuous_on S f \ (\i \ Basis. continuous_on S (\x. (f x \ i)))" + apply (simp add: continuous_on_eq_continuous_within) + using continuous_componentwise by blast + +lemma linear_componentwise_iff: + "(linear f') \ (\i\Basis. linear (\x. f' x \ i))" + apply (auto simp: linear_iff inner_left_distrib) + apply (metis inner_left_distrib euclidean_eq_iff) + by (metis euclidean_eqI inner_scaleR_left) + +lemma bounded_linear_componentwise_iff: + "(bounded_linear f') \ (\i\Basis. bounded_linear (\x. f' x \ i))" + (is "?lhs = ?rhs") +proof + assume ?lhs then show ?rhs + by (simp add: bounded_linear_inner_left_comp) +next + assume ?rhs + then have "(\i\Basis. \K. \x. \f' x \ i\ \ norm x * K)" "linear f'" + by (auto simp: bounded_linear_def bounded_linear_axioms_def linear_componentwise_iff [symmetric] ball_conj_distrib) + then obtain F where F: "\i x. i \ Basis \ \f' x \ i\ \ norm x * F i" + by metis + have "norm (f' x) \ norm x * setsum F Basis" for x + proof - + have "norm (f' x) \ (\i\Basis. \f' x \ i\)" + by (rule norm_le_l1) + also have "... \ (\i\Basis. norm x * F i)" + by (metis F setsum_mono) + also have "... = norm x * setsum F Basis" + by (simp add: setsum_distrib_left) + finally show ?thesis . + qed + then show ?lhs + by (force simp: bounded_linear_def bounded_linear_axioms_def \linear f'\) +qed + + no_notation eucl_less (infix "By L C Paulson (2015)\ theory Weierstrass_Theorems -imports Uniform_Limit Path_Connected +imports Uniform_Limit Path_Connected Derivative begin subsection \Bernstein polynomials\ @@ -171,13 +171,13 @@ DOI: 10.2307/2043993 http://www.jstor.org/stable/2043993\ locale function_ring_on = - fixes R :: "('a::t2_space \ real) set" and s :: "'a set" - assumes compact: "compact s" - assumes continuous: "f \ R \ continuous_on s f" + fixes R :: "('a::t2_space \ real) set" and S :: "'a set" + assumes compact: "compact S" + assumes continuous: "f \ R \ continuous_on S f" assumes add: "f \ R \ g \ R \ (\x. f x + g x) \ R" assumes mult: "f \ R \ g \ R \ (\x. f x * g x) \ R" assumes const: "(\_. c) \ R" - assumes separable: "x \ s \ y \ s \ x \ y \ \f\R. f x \ f y" + assumes separable: "x \ S \ y \ S \ x \ y \ \f\R. f x \ f y" begin lemma minus: "f \ R \ (\x. - f x) \ R" @@ -196,24 +196,24 @@ by (induct I rule: finite_induct; simp add: const mult) definition normf :: "('a::t2_space \ real) \ real" - where "normf f \ SUP x:s. \f x\" + where "normf f \ SUP x:S. \f x\" - lemma normf_upper: "\continuous_on s f; x \ s\ \ \f x\ \ normf f" + lemma normf_upper: "\continuous_on S f; x \ S\ \ \f x\ \ normf f" apply (simp add: normf_def) apply (rule cSUP_upper, assumption) by (simp add: bounded_imp_bdd_above compact compact_continuous_image compact_imp_bounded continuous_on_rabs) - lemma normf_least: "s \ {} \ (\x. x \ s \ \f x\ \ M) \ normf f \ M" + lemma normf_least: "S \ {} \ (\x. x \ S \ \f x\ \ M) \ normf f \ M" by (simp add: normf_def cSUP_least) end lemma (in function_ring_on) one: - assumes U: "open U" and t0: "t0 \ s" "t0 \ U" and t1: "t1 \ s-U" - shows "\V. open V \ t0 \ V \ s \ V \ U \ - (\e>0. \f \ R. f ` s \ {0..1} \ (\t \ s \ V. f t < e) \ (\t \ s - U. f t > 1 - e))" + assumes U: "open U" and t0: "t0 \ S" "t0 \ U" and t1: "t1 \ S-U" + shows "\V. open V \ t0 \ V \ S \ V \ U \ + (\e>0. \f \ R. f ` S \ {0..1} \ (\t \ S \ V. f t < e) \ (\t \ S - U. f t > 1 - e))" proof - - have "\pt \ R. pt t0 = 0 \ pt t > 0 \ pt ` s \ {0..1}" if t: "t \ s - U" for t + have "\pt \ R. pt t0 = 0 \ pt t > 0 \ pt ` S \ {0..1}" if t: "t \ S - U" for t proof - have "t \ t0" using t t0 by auto then obtain g where g: "g \ R" "g t \ g t0" @@ -239,28 +239,28 @@ by (simp add: p_def h_def) moreover have "p t > 0" using nfp ht2 by (simp add: p_def) - moreover have "\x. x \ s \ p x \ {0..1}" + moreover have "\x. x \ S \ p x \ {0..1}" using nfp normf_upper [OF continuous [OF hsq] ] by (auto simp: p_def) - ultimately show "\pt \ R. pt t0 = 0 \ pt t > 0 \ pt ` s \ {0..1}" + ultimately show "\pt \ R. pt t0 = 0 \ pt t > 0 \ pt ` S \ {0..1}" by auto qed - then obtain pf where pf: "\t. t \ s-U \ pf t \ R \ pf t t0 = 0 \ pf t t > 0" - and pf01: "\t. t \ s-U \ pf t ` s \ {0..1}" + then obtain pf where pf: "\t. t \ S-U \ pf t \ R \ pf t t0 = 0 \ pf t t > 0" + and pf01: "\t. t \ S-U \ pf t ` S \ {0..1}" by metis - have com_sU: "compact (s-U)" + have com_sU: "compact (S-U)" using compact closed_Int_compact U by (simp add: Diff_eq compact_Int_closed open_closed) - have "\t. t \ s-U \ \A. open A \ A \ s = {x\s. 0 < pf t x}" + have "\t. t \ S-U \ \A. open A \ A \ S = {x\S. 0 < pf t x}" apply (rule open_Collect_positive) by (metis pf continuous) - then obtain Uf where Uf: "\t. t \ s-U \ open (Uf t) \ (Uf t) \ s = {x\s. 0 < pf t x}" + then obtain Uf where Uf: "\t. t \ S-U \ open (Uf t) \ (Uf t) \ S = {x\S. 0 < pf t x}" by metis - then have open_Uf: "\t. t \ s-U \ open (Uf t)" + then have open_Uf: "\t. t \ S-U \ open (Uf t)" by blast - have tUft: "\t. t \ s-U \ t \ Uf t" + have tUft: "\t. t \ S-U \ t \ Uf t" using pf Uf by blast - then have *: "s-U \ (\x \ s-U. Uf x)" + then have *: "S-U \ (\x \ S-U. Uf x)" by blast - obtain subU where subU: "subU \ s - U" "finite subU" "s - U \ (\x \ subU. Uf x)" + obtain subU where subU: "subU \ S - U" "finite subU" "S - U \ (\x \ subU. Uf x)" by (blast intro: that open_Uf compactE_image [OF com_sU _ *]) then have [simp]: "subU \ {}" using t1 by auto @@ -271,7 +271,7 @@ unfolding p_def using subU pf by (fast intro: pf const mult setsum) have pt0 [simp]: "p t0 = 0" using subU pf by (auto simp: p_def intro: setsum.neutral) - have pt_pos: "p t > 0" if t: "t \ s-U" for t + have pt_pos: "p t > 0" if t: "t \ S-U" for t proof - obtain i where i: "i \ subU" "t \ Uf i" using subU t by blast show ?thesis @@ -282,7 +282,7 @@ apply (force elim!: subsetCE) done qed - have p01: "p x \ {0..1}" if t: "x \ s" for x + have p01: "p x \ {0..1}" if t: "x \ S" for x proof - have "0 \ p x" using subU cardp t @@ -297,26 +297,26 @@ ultimately show ?thesis by auto qed - have "compact (p ` (s-U))" + have "compact (p ` (S-U))" by (meson Diff_subset com_sU compact_continuous_image continuous continuous_on_subset pR) - then have "open (- (p ` (s-U)))" + then have "open (- (p ` (S-U)))" by (simp add: compact_imp_closed open_Compl) - moreover have "0 \ - (p ` (s-U))" + moreover have "0 \ - (p ` (S-U))" by (metis (no_types) ComplI image_iff not_less_iff_gr_or_eq pt_pos) - ultimately obtain delta0 where delta0: "delta0 > 0" "ball 0 delta0 \ - (p ` (s-U))" + ultimately obtain delta0 where delta0: "delta0 > 0" "ball 0 delta0 \ - (p ` (S-U))" by (auto simp: elim!: openE) - then have pt_delta: "\x. x \ s-U \ p x \ delta0" + then have pt_delta: "\x. x \ S-U \ p x \ delta0" by (force simp: ball_def dist_norm dest: p01) define \ where "\ = delta0/2" have "delta0 \ 1" using delta0 p01 [of t1] t1 by (force simp: ball_def dist_norm dest: p01) with delta0 have \01: "0 < \" "\ < 1" by (auto simp: \_def) - have pt_\: "\x. x \ s-U \ p x \ \" + have pt_\: "\x. x \ S-U \ p x \ \" using pt_delta delta0 by (force simp: \_def) - have "\A. open A \ A \ s = {x\s. p x < \/2}" + have "\A. open A \ A \ S = {x\S. p x < \/2}" by (rule open_Collect_less_Int [OF continuous [OF pR] continuous_on_const]) - then obtain V where V: "open V" "V \ s = {x\s. p x < \/2}" + then obtain V where V: "open V" "V \ S = {x\S. p x < \/2}" by blast define k where "k = nat\1/\\ + 1" have "k>0" by (simp add: k_def) @@ -334,12 +334,12 @@ define q where [abs_def]: "q n t = (1 - p t ^ n) ^ (k^n)" for n t have qR: "q n \ R" for n by (simp add: q_def const diff power pR) - have q01: "\n t. t \ s \ q n t \ {0..1}" + have q01: "\n t. t \ S \ q n t \ {0..1}" using p01 by (simp add: q_def power_le_one algebra_simps) have qt0 [simp]: "\n. n>0 \ q n t0 = 1" using t0 pf by (simp add: q_def power_0_left) { fix t and n::nat - assume t: "t \ s \ V" + assume t: "t \ S \ V" with \k>0\ V have "k * p t < k * \ / 2" by force then have "1 - (k * \ / 2)^n \ 1 - (k * p t)^n" @@ -351,7 +351,7 @@ finally have "1 - (k * \ / 2) ^ n \ q n t" . } note limitV = this { fix t and n::nat - assume t: "t \ s - U" + assume t: "t \ S - U" with \k>0\ U have "k * \ \ k * p t" by (simp add: pt_\) with k\ have kpt: "1 < k * p t" @@ -406,20 +406,20 @@ done { fix t and e::real assume "e>0" - have "t \ s \ V \ 1 - q (NN e) t < e" "t \ s - U \ q (NN e) t < e" + have "t \ S \ V \ 1 - q (NN e) t < e" "t \ S - U \ q (NN e) t < e" proof - - assume t: "t \ s \ V" + assume t: "t \ S \ V" show "1 - q (NN e) t < e" by (metis add.commute diff_le_eq not_le limitV [OF t] less_le_trans [OF NN1 [OF \e>0\]]) next - assume t: "t \ s - U" + assume t: "t \ S - U" show "q (NN e) t < e" using limitNonU [OF t] less_le_trans [OF NN0 [OF \e>0\]] not_le by blast qed - } then have "\e. e > 0 \ \f\R. f ` s \ {0..1} \ (\t \ s \ V. f t < e) \ (\t \ s - U. 1 - e < f t)" + } then have "\e. e > 0 \ \f\R. f ` S \ {0..1} \ (\t \ S \ V. f t < e) \ (\t \ S - U. 1 - e < f t)" using q01 by (rule_tac x="\x. 1 - q (NN e) x" in bexI) (auto simp: algebra_simps intro: diff const qR) - moreover have t0V: "t0 \ V" "s \ V \ U" + moreover have t0V: "t0 \ V" "S \ V \ U" using pt_\ t0 U V \01 by fastforce+ ultimately show ?thesis using V t0V by blast @@ -427,23 +427,23 @@ text\Non-trivial case, with @{term A} and @{term B} both non-empty\ lemma (in function_ring_on) two_special: - assumes A: "closed A" "A \ s" "a \ A" - and B: "closed B" "B \ s" "b \ B" + assumes A: "closed A" "A \ S" "a \ A" + and B: "closed B" "B \ S" "b \ B" and disj: "A \ B = {}" and e: "0 < e" "e < 1" - shows "\f \ R. f ` s \ {0..1} \ (\x \ A. f x < e) \ (\x \ B. f x > 1 - e)" + shows "\f \ R. f ` S \ {0..1} \ (\x \ A. f x < e) \ (\x \ B. f x > 1 - e)" proof - { fix w assume "w \ A" - then have "open ( - B)" "b \ s" "w \ B" "w \ s" + then have "open ( - B)" "b \ S" "w \ B" "w \ S" using assms by auto - then have "\V. open V \ w \ V \ s \ V \ -B \ - (\e>0. \f \ R. f ` s \ {0..1} \ (\x \ s \ V. f x < e) \ (\x \ s \ B. f x > 1 - e))" + then have "\V. open V \ w \ V \ S \ V \ -B \ + (\e>0. \f \ R. f ` S \ {0..1} \ (\x \ S \ V. f x < e) \ (\x \ S \ B. f x > 1 - e))" using one [of "-B" w b] assms \w \ A\ by simp } then obtain Vf where Vf: - "\w. w \ A \ open (Vf w) \ w \ Vf w \ s \ Vf w \ -B \ - (\e>0. \f \ R. f ` s \ {0..1} \ (\x \ s \ Vf w. f x < e) \ (\x \ s \ B. f x > 1 - e))" + "\w. w \ A \ open (Vf w) \ w \ Vf w \ S \ Vf w \ -B \ + (\e>0. \f \ R. f ` S \ {0..1} \ (\x \ S \ Vf w. f x < e) \ (\x \ S \ B. f x > 1 - e))" by metis then have open_Vf: "\w. w \ A \ open (Vf w)" by blast @@ -459,17 +459,17 @@ using \a \ A\ by auto then have cardp: "card subA > 0" using subA by (simp add: card_gt_0_iff) - have "\w. w \ A \ \f \ R. f ` s \ {0..1} \ (\x \ s \ Vf w. f x < e / card subA) \ (\x \ s \ B. f x > 1 - e / card subA)" + have "\w. w \ A \ \f \ R. f ` S \ {0..1} \ (\x \ S \ Vf w. f x < e / card subA) \ (\x \ S \ B. f x > 1 - e / card subA)" using Vf e cardp by simp then obtain ff where ff: - "\w. w \ A \ ff w \ R \ ff w ` s \ {0..1} \ - (\x \ s \ Vf w. ff w x < e / card subA) \ (\x \ s \ B. ff w x > 1 - e / card subA)" + "\w. w \ A \ ff w \ R \ ff w ` S \ {0..1} \ + (\x \ S \ Vf w. ff w x < e / card subA) \ (\x \ S \ B. ff w x > 1 - e / card subA)" by metis define pff where [abs_def]: "pff x = (\w \ subA. ff w x)" for x have pffR: "pff \ R" unfolding pff_def using subA ff by (auto simp: intro: setprod) moreover - have pff01: "pff x \ {0..1}" if t: "x \ s" for x + have pff01: "pff x \ {0..1}" if t: "x \ S" for x proof - have "0 \ pff x" using subA cardp t @@ -486,7 +486,7 @@ qed moreover { fix v x - assume v: "v \ subA" and x: "x \ Vf v" "x \ s" + assume v: "v \ subA" and x: "x \ Vf v" "x \ S" from subA v have "pff x = ff v x * (\w \ subA - {v}. ff w x)" unfolding pff_def by (metis setprod.remove) also have "... \ ff v x * 1" @@ -509,7 +509,7 @@ moreover { fix x assume x: "x \ B" - then have "x \ s" + then have "x \ S" using B by auto have "1 - e \ (1 - e / card subA) ^ card subA" using Bernoulli_inequality [of "-e / card subA" "card subA"] e cardp @@ -532,11 +532,11 @@ qed lemma (in function_ring_on) two: - assumes A: "closed A" "A \ s" - and B: "closed B" "B \ s" + assumes A: "closed A" "A \ S" + and B: "closed B" "B \ S" and disj: "A \ B = {}" and e: "0 < e" "e < 1" - shows "\f \ R. f ` s \ {0..1} \ (\x \ A. f x < e) \ (\x \ B. f x > 1 - e)" + shows "\f \ R. f ` S \ {0..1} \ (\x \ A. f x < e) \ (\x \ B. f x > 1 - e)" proof (cases "A \ {} \ B \ {}") case True then show ?thesis apply (simp add: ex_in_conv [symmetric]) @@ -556,57 +556,57 @@ text\The special case where @{term f} is non-negative and @{term"e<1/3"}\ lemma (in function_ring_on) Stone_Weierstrass_special: - assumes f: "continuous_on s f" and fpos: "\x. x \ s \ f x \ 0" + assumes f: "continuous_on S f" and fpos: "\x. x \ S \ f x \ 0" and e: "0 < e" "e < 1/3" - shows "\g \ R. \x\s. \f x - g x\ < 2*e" + shows "\g \ R. \x\S. \f x - g x\ < 2*e" proof - define n where "n = 1 + nat \normf f / e\" - define A where "A j = {x \ s. f x \ (j - 1/3)*e}" for j :: nat - define B where "B j = {x \ s. f x \ (j + 1/3)*e}" for j :: nat + define A where "A j = {x \ S. f x \ (j - 1/3)*e}" for j :: nat + define B where "B j = {x \ S. f x \ (j + 1/3)*e}" for j :: nat have ngt: "(n-1) * e \ normf f" "n\1" using e apply (simp_all add: n_def field_simps of_nat_Suc) by (metis real_nat_ceiling_ge mult.commute not_less pos_less_divide_eq) - then have ge_fx: "(n-1) * e \ f x" if "x \ s" for x + then have ge_fx: "(n-1) * e \ f x" if "x \ S" for x using f normf_upper that by fastforce { fix j - have A: "closed (A j)" "A j \ s" + have A: "closed (A j)" "A j \ S" apply (simp_all add: A_def Collect_restrict) apply (rule continuous_on_closed_Collect_le [OF f continuous_on_const]) apply (simp add: compact compact_imp_closed) done - have B: "closed (B j)" "B j \ s" + have B: "closed (B j)" "B j \ S" apply (simp_all add: B_def Collect_restrict) apply (rule continuous_on_closed_Collect_le [OF continuous_on_const f]) apply (simp add: compact compact_imp_closed) done have disj: "(A j) \ (B j) = {}" using e by (auto simp: A_def B_def field_simps) - have "\f \ R. f ` s \ {0..1} \ (\x \ A j. f x < e/n) \ (\x \ B j. f x > 1 - e/n)" + have "\f \ R. f ` S \ {0..1} \ (\x \ A j. f x < e/n) \ (\x \ B j. f x > 1 - e/n)" apply (rule two) using e A B disj ngt apply simp_all done } - then obtain xf where xfR: "\j. xf j \ R" and xf01: "\j. xf j ` s \ {0..1}" + then obtain xf where xfR: "\j. xf j \ R" and xf01: "\j. xf j ` S \ {0..1}" and xfA: "\x j. x \ A j \ xf j x < e/n" and xfB: "\x j. x \ B j \ xf j x > 1 - e/n" by metis define g where [abs_def]: "g x = e * (\i\n. xf i x)" for x have gR: "g \ R" unfolding g_def by (fast intro: mult const setsum xfR) - have gge0: "\x. x \ s \ g x \ 0" + have gge0: "\x. x \ S \ g x \ 0" using e xf01 by (simp add: g_def zero_le_mult_iff image_subset_iff setsum_nonneg) have A0: "A 0 = {}" using fpos e by (fastforce simp: A_def) - have An: "A n = s" + have An: "A n = S" using e ngt f normf_upper by (fastforce simp: A_def field_simps of_nat_diff) have Asub: "A j \ A i" if "i\j" for i j using e that apply (clarsimp simp: A_def) apply (erule order_trans, simp) done { fix t - assume t: "t \ s" + assume t: "t \ S" define j where "j = (LEAST j. t \ A j)" have jn: "j \ n" using t An by (simp add: Least_le j_def) @@ -701,16 +701,16 @@ text\The ``unpretentious'' formulation\ lemma (in function_ring_on) Stone_Weierstrass_basic: - assumes f: "continuous_on s f" and e: "e > 0" - shows "\g \ R. \x\s. \f x - g x\ < e" + assumes f: "continuous_on S f" and e: "e > 0" + shows "\g \ R. \x\S. \f x - g x\ < e" proof - - have "\g \ R. \x\s. \(f x + normf f) - g x\ < 2 * min (e/2) (1/4)" + have "\g \ R. \x\S. \(f x + normf f) - g x\ < 2 * min (e/2) (1/4)" apply (rule Stone_Weierstrass_special) apply (rule Limits.continuous_on_add [OF f Topological_Spaces.continuous_on_const]) using normf_upper [OF f] apply force apply (simp add: e, linarith) done - then obtain g where "g \ R" "\x\s. \g x - (f x + normf f)\ < e" + then obtain g where "g \ R" "\x\S. \g x - (f x + normf f)\ < e" by force then show ?thesis apply (rule_tac x="\x. g x - normf f" in bexI) @@ -720,16 +720,16 @@ theorem (in function_ring_on) Stone_Weierstrass: - assumes f: "continuous_on s f" - shows "\F\UNIV \ R. LIM n sequentially. F n :> uniformly_on s f" + assumes f: "continuous_on S f" + shows "\F\UNIV \ R. LIM n sequentially. F n :> uniformly_on S f" proof - { fix e::real assume e: "0 < e" then obtain N::nat where N: "0 < N" "0 < inverse N" "inverse N < e" by (auto simp: real_arch_inverse [of e]) { fix n :: nat and x :: 'a and g :: "'a \ real" - assume n: "N \ n" "\x\s. \f x - g x\ < 1 / (1 + real n)" - assume x: "x \ s" + assume n: "N \ n" "\x\S. \f x - g x\ < 1 / (1 + real n)" + assume x: "x \ S" have "\ real (Suc n) < inverse e" using \N \ n\ N using less_imp_inverse_less by force then have "1 / (1 + real n) \ e" @@ -737,13 +737,13 @@ then have "\f x - g x\ < e" using n(2) x by auto } note * = this - have "\\<^sub>F n in sequentially. \x\s. \f x - (SOME g. g \ R \ (\x\s. \f x - g x\ < 1 / (1 + real n))) x\ < e" + have "\\<^sub>F n in sequentially. \x\S. \f x - (SOME g. g \ R \ (\x\S. \f x - g x\ < 1 / (1 + real n))) x\ < e" apply (rule eventually_sequentiallyI [of N]) apply (auto intro: someI2_bex [OF Stone_Weierstrass_basic [OF f]] *) done } then show ?thesis - apply (rule_tac x="\n::nat. SOME g. g \ R \ (\x\s. \f x - g x\ < 1 / (1 + n))" in bexI) + apply (rule_tac x="\n::nat. SOME g. g \ R \ (\x\S. \f x - g x\ < 1 / (1 + n))" in bexI) prefer 2 apply (force intro: someI2_bex [OF Stone_Weierstrass_basic [OF f]]) unfolding uniform_limit_iff apply (auto simp: dist_norm abs_minus_commute) @@ -752,21 +752,21 @@ text\A HOL Light formulation\ corollary Stone_Weierstrass_HOL: - fixes R :: "('a::t2_space \ real) set" and s :: "'a set" - assumes "compact s" "\c. P(\x. c::real)" - "\f. P f \ continuous_on s f" + fixes R :: "('a::t2_space \ real) set" and S :: "'a set" + assumes "compact S" "\c. P(\x. c::real)" + "\f. P f \ continuous_on S f" "\f g. P(f) \ P(g) \ P(\x. f x + g x)" "\f g. P(f) \ P(g) \ P(\x. f x * g x)" - "\x y. x \ s \ y \ s \ ~(x = y) \ \f. P(f) \ ~(f x = f y)" - "continuous_on s f" + "\x y. x \ S \ y \ S \ ~(x = y) \ \f. P(f) \ ~(f x = f y)" + "continuous_on S f" "0 < e" - shows "\g. P(g) \ (\x \ s. \f x - g x\ < e)" + shows "\g. P(g) \ (\x \ S. \f x - g x\ < e)" proof - interpret PR: function_ring_on "Collect P" apply unfold_locales using assms by auto show ?thesis - using PR.Stone_Weierstrass_basic [OF \continuous_on s f\ \0 < e\] + using PR.Stone_Weierstrass_basic [OF \continuous_on S f\ \0 < e\] by blast qed @@ -994,7 +994,7 @@ lemma continuous_on_polymonial_function: fixes f :: "'a::real_normed_vector \ 'b::euclidean_space" assumes "polynomial_function f" - shows "continuous_on s f" + shows "continuous_on S f" using continuous_polymonial_function [OF assms] continuous_at_imp_continuous_on by blast @@ -1035,8 +1035,7 @@ lemma has_vector_derivative_polynomial_function: fixes p :: "real \ 'a::euclidean_space" assumes "polynomial_function p" - shows "\p'. polynomial_function p' \ - (\x. (p has_vector_derivative (p' x)) (at x))" + obtains p' where "polynomial_function p'" "\x. (p has_vector_derivative (p' x)) (at x)" proof - { fix b :: 'a assume "b \ Basis" @@ -1057,9 +1056,10 @@ "\b x. b \ Basis \ ((\u. (p u \ b) *\<^sub>R b) has_vector_derivative qf b x) (at x)" by metis show ?thesis + apply (rule_tac p'="\x. \b\Basis. qf b x" in that) + apply (force intro: qf) apply (subst euclidean_representation_setsum_fun [of p, symmetric]) - apply (rule_tac x="\x. \b\Basis. qf b x" in exI) - apply (auto intro: has_vector_derivative_setsum qf) + apply (auto intro: has_vector_derivative_setsum qf) done qed @@ -1081,8 +1081,8 @@ lemma Stone_Weierstrass_real_polynomial_function: fixes f :: "'a::euclidean_space \ real" - assumes "compact s" "continuous_on s f" "0 < e" - shows "\g. real_polynomial_function g \ (\x \ s. \f x - g x\ < e)" + assumes "compact S" "continuous_on S f" "0 < e" + obtains g where "real_polynomial_function g" "\x. x \ S \ \f x - g x\ < e" proof - interpret PR: function_ring_on "Collect real_polynomial_function" apply unfold_locales @@ -1090,27 +1090,27 @@ apply (auto intro: real_polynomial_function_separable) done show ?thesis - using PR.Stone_Weierstrass_basic [OF \continuous_on s f\ \0 < e\] + using PR.Stone_Weierstrass_basic [OF \continuous_on S f\ \0 < e\] that by blast qed lemma Stone_Weierstrass_polynomial_function: fixes f :: "'a::euclidean_space \ 'b::euclidean_space" - assumes s: "compact s" - and f: "continuous_on s f" + assumes S: "compact S" + and f: "continuous_on S f" and e: "0 < e" - shows "\g. polynomial_function g \ (\x \ s. norm(f x - g x) < e)" + shows "\g. polynomial_function g \ (\x \ S. norm(f x - g x) < e)" proof - { fix b :: 'b assume "b \ Basis" - have "\p. real_polynomial_function p \ (\x \ s. \f x \ b - p x\ < e / DIM('b))" - apply (rule exE [OF Stone_Weierstrass_real_polynomial_function [OF s _, of "\x. f x \ b" "e / card Basis"]]) + have "\p. real_polynomial_function p \ (\x \ S. \f x \ b - p x\ < e / DIM('b))" + apply (rule exE [OF Stone_Weierstrass_real_polynomial_function [OF S _, of "\x. f x \ b" "e / card Basis"]]) using e f apply (auto simp: Euclidean_Space.DIM_positive intro: continuous_intros) done } then obtain pf where pf: - "\b. b \ Basis \ real_polynomial_function (pf b) \ (\x \ s. \f x \ b - pf b x\ < e / DIM('b))" + "\b. b \ Basis \ real_polynomial_function (pf b) \ (\x \ S. \f x \ b - pf b x\ < e / DIM('b))" apply (rule bchoice [rule_format, THEN exE]) apply assumption apply (force simp add: intro: that) @@ -1120,12 +1120,12 @@ by (simp add: polynomial_function_setsum polynomial_function_mult real_polynomial_function_eq) moreover { fix x - assume "x \ s" + assume "x \ S" have "norm (\b\Basis. (f x \ b) *\<^sub>R b - pf b x *\<^sub>R b) \ (\b\Basis. norm ((f x \ b) *\<^sub>R b - pf b x *\<^sub>R b))" by (rule norm_setsum) also have "... < of_nat DIM('b) * (e / DIM('b))" apply (rule setsum_bounded_above_strict) - apply (simp add: Real_Vector_Spaces.scaleR_diff_left [symmetric] pf \x \ s\) + apply (simp add: Real_Vector_Spaces.scaleR_diff_left [symmetric] pf \x \ S\) apply (rule DIM_positive) done also have "... = e" @@ -1178,31 +1178,31 @@ qed lemma connected_open_polynomial_connected: - fixes s :: "'a::euclidean_space set" - assumes s: "open s" "connected s" - and "x \ s" "y \ s" - shows "\g. polynomial_function g \ path_image g \ s \ + fixes S :: "'a::euclidean_space set" + assumes S: "open S" "connected S" + and "x \ S" "y \ S" + shows "\g. polynomial_function g \ path_image g \ S \ pathstart g = x \ pathfinish g = y" proof - - have "path_connected s" using assms + have "path_connected S" using assms by (simp add: connected_open_path_connected) - with \x \ s\ \y \ s\ obtain p where p: "path p" "path_image p \ s" "pathstart p = x" "pathfinish p = y" + with \x \ S\ \y \ S\ obtain p where p: "path p" "path_image p \ S" "pathstart p = x" "pathfinish p = y" by (force simp: path_connected_def) - have "\e. 0 < e \ (\x \ path_image p. ball x e \ s)" - proof (cases "s = UNIV") + have "\e. 0 < e \ (\x \ path_image p. ball x e \ S)" + proof (cases "S = UNIV") case True then show ?thesis by (simp add: gt_ex) next case False - then have "- s \ {}" by blast + then have "- S \ {}" by blast then show ?thesis - apply (rule_tac x="setdist (path_image p) (-s)" in exI) - using s p + apply (rule_tac x="setdist (path_image p) (-S)" in exI) + using S p apply (simp add: setdist_gt_0_compact_closed compact_path_image open_closed) - using setdist_le_dist [of _ "path_image p" _ "-s"] + using setdist_le_dist [of _ "path_image p" _ "-S"] by fastforce qed - then obtain e where "0 < e"and eb: "\x. x \ path_image p \ ball x e \ s" + then obtain e where "0 < e"and eb: "\x. x \ path_image p \ ball x e \ S" by auto show ?thesis using path_approx_polynomial_function [OF \path p\ \0 < e\] @@ -1213,6 +1213,179 @@ done qed +lemma has_derivative_componentwise_within: + "(f has_derivative f') (at a within S) \ + (\i \ Basis. ((\x. f x \ i) has_derivative (\x. f' x \ i)) (at a within S))" + apply (simp add: has_derivative_within) + apply (subst tendsto_componentwise_iff) + apply (simp add: bounded_linear_componentwise_iff [symmetric] ball_conj_distrib) + apply (simp add: algebra_simps) + done + +lemma differentiable_componentwise_within: + "f differentiable (at a within S) \ + (\i \ Basis. (\x. f x \ i) differentiable at a within S)" +proof - + { assume "\i\Basis. \D. ((\x. f x \ i) has_derivative D) (at a within S)" + then obtain f' where f': + "\i. i \ Basis \ ((\x. f x \ i) has_derivative f' i) (at a within S)" + by metis + have eq: "(\x. (\j\Basis. f' j x *\<^sub>R j) \ i) = f' i" if "i \ Basis" for i + using that by (simp add: inner_add_left inner_add_right) + have "\D. \i\Basis. ((\x. f x \ i) has_derivative (\x. D x \ i)) (at a within S)" + apply (rule_tac x="\x::'a. (\j\Basis. f' j x *\<^sub>R j) :: 'b" in exI) + apply (simp add: eq f') + done + } + then show ?thesis + apply (simp add: differentiable_def) + using has_derivative_componentwise_within + by blast +qed + +lemma polynomial_function_inner [intro]: + fixes i :: "'a::euclidean_space" + shows "polynomial_function g \ polynomial_function (\x. g x \ i)" + apply (subst euclidean_representation [where x=i, symmetric]) + apply (force simp: inner_setsum_right polynomial_function_iff_Basis_inner polynomial_function_setsum) + done + +text\ Differentiability of real and vector polynomial functions.\ + +lemma differentiable_at_real_polynomial_function: + "real_polynomial_function f \ f differentiable (at a within S)" + by (induction f rule: real_polynomial_function.induct) + (simp_all add: bounded_linear_imp_differentiable) + +lemma differentiable_on_real_polynomial_function: + "real_polynomial_function p \ p differentiable_on S" +by (simp add: differentiable_at_imp_differentiable_on differentiable_at_real_polynomial_function) + +lemma differentiable_at_polynomial_function: + fixes f :: "_ \ 'a::euclidean_space" + shows "polynomial_function f \ f differentiable (at a within S)" + by (metis differentiable_at_real_polynomial_function polynomial_function_iff_Basis_inner differentiable_componentwise_within) + +lemma differentiable_on_polynomial_function: + fixes f :: "_ \ 'a::euclidean_space" + shows "polynomial_function f \ f differentiable_on S" +by (simp add: differentiable_at_polynomial_function differentiable_on_def) + +lemma vector_eq_dot_span: + assumes "x \ span B" "y \ span B" and i: "\i. i \ B \ i \ x = i \ y" + shows "x = y" +proof - + have "\i. i \ B \ orthogonal (x - y) i" + by (simp add: i inner_commute inner_diff_right orthogonal_def) + moreover have "x - y \ span B" + by (simp add: assms span_diff) + ultimately have "x - y = 0" + using orthogonal_to_span orthogonal_self by blast + then show ?thesis by simp +qed + +lemma orthonormal_basis_expand: + assumes B: "pairwise orthogonal B" + and 1: "\i. i \ B \ norm i = 1" + and "x \ span B" + and "finite B" + shows "(\i\B. (x \ i) *\<^sub>R i) = x" +proof (rule vector_eq_dot_span [OF _ \x \ span B\]) + show "(\i\B. (x \ i) *\<^sub>R i) \ span B" + by (simp add: span_clauses span_setsum) + show "i \ (\i\B. (x \ i) *\<^sub>R i) = i \ x" if "i \ B" for i + proof - + have [simp]: "i \ j = (if j = i then 1 else 0)" if "j \ B" for j + using B 1 that \i \ B\ + by (force simp: norm_eq_1 orthogonal_def pairwise_def) + have "i \ (\i\B. (x \ i) *\<^sub>R i) = (\j\B. x \ j * (i \ j))" + by (simp add: inner_setsum_right) + also have "... = (\j\B. if j = i then x \ i else 0)" + by (rule setsum.cong; simp) + also have "... = i \ x" + by (simp add: \finite B\ that inner_commute setsum.delta) + finally show ?thesis . + qed +qed + + +lemma Stone_Weierstrass_polynomial_function_subspace: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "compact S" + and contf: "continuous_on S f" + and "0 < e" + and "subspace T" "f ` S \ T" + obtains g where "polynomial_function g" "g ` S \ T" + "\x. x \ S \ norm(f x - g x) < e" +proof - + obtain B where "B \ T" and orthB: "pairwise orthogonal B" + and B1: "\x. x \ B \ norm x = 1" + and "independent B" and cardB: "card B = dim T" + and spanB: "span B = T" + using orthonormal_basis_subspace \subspace T\ by metis + then have "finite B" + by (simp add: independent_imp_finite) + then obtain n::nat and b where "B = b ` {i. i < n}" "inj_on b {i. i < n}" + using finite_imp_nat_seg_image_inj_on by metis + with cardB have "n = card B" "dim T = n" + by (auto simp: card_image) + have fx: "(\i\B. (f x \ i) *\<^sub>R i) = f x" if "x \ S" for x + apply (rule orthonormal_basis_expand [OF orthB B1 _ \finite B\]) + using \f ` S \ T\ spanB that by auto + have cont: "continuous_on S (\x. \i\B. (f x \ i) *\<^sub>R i)" + by (intro continuous_intros contf) + obtain g where "polynomial_function g" + and g: "\x. x \ S \ norm ((\i\B. (f x \ i) *\<^sub>R i) - g x) < e / (n+2)" + using Stone_Weierstrass_polynomial_function [OF \compact S\ cont, of "e / real (n + 2)"] \0 < e\ + by auto + with fx have g: "\x. x \ S \ norm (f x - g x) < e / (n+2)" + by auto + show ?thesis + proof + show "polynomial_function (\x. \i\B. (g x \ i) *\<^sub>R i)" + apply (rule polynomial_function_setsum) + apply (simp add: \finite B\) + using \polynomial_function g\ by auto + show "(\x. \i\B. (g x \ i) *\<^sub>R i) ` S \ T" + using \B \ T\ by (blast intro: subspace_setsum subspace_mul \subspace T\) + show "norm (f x - (\i\B. (g x \ i) *\<^sub>R i)) < e" if "x \ S" for x + proof - + have orth': "pairwise (\i j. orthogonal ((f x \ i) *\<^sub>R i - (g x \ i) *\<^sub>R i) + ((f x \ j) *\<^sub>R j - (g x \ j) *\<^sub>R j)) B" + apply (rule pairwise_mono [OF orthB]) + apply (auto simp: orthogonal_def inner_diff_right inner_diff_left) + done + then have "(norm (\i\B. (f x \ i) *\<^sub>R i - (g x \ i) *\<^sub>R i))\<^sup>2 = + (\i\B. (norm ((f x \ i) *\<^sub>R i - (g x \ i) *\<^sub>R i))\<^sup>2)" + by (simp add: norm_setsum_Pythagorean [OF \finite B\ orth']) + also have "... = (\i\B. (norm (((f x - g x) \ i) *\<^sub>R i))\<^sup>2)" + by (simp add: algebra_simps) + also have "... \ (\i\B. (norm (f x - g x))\<^sup>2)" + apply (rule setsum_mono) + apply (simp add: B1) + apply (rule order_trans [OF Cauchy_Schwarz_ineq]) + by (simp add: B1 dot_square_norm) + also have "... = n * norm (f x - g x)^2" + by (simp add: \n = card B\) + also have "... \ n * (e / (n+2))^2" + apply (rule mult_left_mono) + apply (meson dual_order.order_iff_strict g norm_ge_zero power_mono that, simp) + done + also have "... \ e^2 / (n+2)" + using \0 < e\ by (simp add: divide_simps power2_eq_square) + also have "... < e^2" + using \0 < e\ by (simp add: divide_simps) + finally have "(norm (\i\B. (f x \ i) *\<^sub>R i - (g x \ i) *\<^sub>R i))\<^sup>2 < e^2" . + then have "(norm (\i\B. (f x \ i) *\<^sub>R i - (g x \ i) *\<^sub>R i)) < e" + apply (rule power2_less_imp_less) + using \0 < e\ by auto + then show ?thesis + using fx that by (simp add: setsum_subtractf) + qed + qed +qed + + hide_fact linear add mult const end diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Groups_Big.thy --- a/src/HOL/Groups_Big.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Groups_Big.thy Thu Sep 22 15:44:47 2016 +0100 @@ -624,6 +624,24 @@ with eq show False by simp qed +lemma member_le_setsum: + fixes f :: "_ \ 'b::{semiring_1, ordered_comm_monoid_add}" + assumes le: "\x. x \ A \ 0 \ f x" + and "i \ A" + and "finite A" + shows "f i \ setsum f A" +proof - + have "f i \ setsum f (A \ {i})" + by (simp add: assms) + also have "... = (\x\A. if x \ {i} then f x else 0)" + using assms setsum.inter_restrict by blast + also have "... \ setsum f A" + apply (rule setsum_mono) + apply (auto simp: le) + done + finally show ?thesis . +qed + lemma setsum_negf: "(\x\A. - f x) = - (\x\A. f x)" for f :: "'b \ 'a::ab_group_add" by (induct A rule: infinite_finite_induct) auto diff -r d81fb5b46a5c -r f6ce08859d4c src/HOL/Set.thy --- a/src/HOL/Set.thy Wed Sep 21 16:59:51 2016 +0100 +++ b/src/HOL/Set.thy Thu Sep 22 15:44:47 2016 +0100 @@ -1852,6 +1852,9 @@ lemma pairwise_subset: "pairwise P S \ T \ S \ pairwise P T" by (force simp: pairwise_def) +lemma pairwise_mono: "\pairwise P A; \x y. P x y \ Q x y\ \ pairwise Q A" + by (auto simp: pairwise_def) + definition disjnt :: "'a set \ 'a set \ bool" where "disjnt A B \ A \ B = {}"