# HG changeset patch # User paulson # Date 1525122784 -3600 # Node ID 69715dfdc2863237e4452856ba62b629fe98fb40 # Parent 9e077a90520957bfeeacdedbff1bed13b6ba8c7d more general tidying up diff -r 9e077a905209 -r 69715dfdc286 src/HOL/Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Analysis/Convex_Euclidean_Space.thy Sun Apr 29 21:26:57 2018 +0100 +++ b/src/HOL/Analysis/Convex_Euclidean_Space.thy Mon Apr 30 22:13:04 2018 +0100 @@ -2470,8 +2470,8 @@ proof show "convex hull (s \ t) \ (convex hull s) \ (convex hull t)" by (intro hull_minimal Sigma_mono hull_subset convex_Times convex_convex_hull) - have "\x\convex hull s. \y\convex hull t. (x, y) \ convex hull (s \ t)" - proof (intro hull_induct) + have "(x, y) \ convex hull (s \ t)" if x: "x \ convex hull s" and y: "y \ convex hull t" for x y + proof (rule hull_induct [OF x], rule hull_induct [OF y]) fix x y assume "x \ s" and "y \ t" then show "(x, y) \ convex hull (s \ t)" by (simp add: hull_inc) @@ -2484,8 +2484,8 @@ by (auto simp: image_def Bex_def) finally show "convex {y. (x, y) \ convex hull (s \ t)}" . next - show "convex {x. \y\convex hull t. (x, y) \ convex hull (s \ t)}" - proof (unfold Collect_ball_eq, rule convex_INT [rule_format]) + show "convex {x. (x, y) \ convex hull s \ t}" + proof - fix y let ?S = "((\x. (x, 0)) -` (\p. (0, - y) + p) ` (convex hull s \ t))" have "convex ?S" by (intro convex_linear_vimage convex_translation convex_convex_hull, @@ -2496,7 +2496,7 @@ qed qed then show "(convex hull s) \ (convex hull t) \ convex hull (s \ t)" - unfolding subset_eq split_paired_Ball_Sigma . + unfolding subset_eq split_paired_Ball_Sigma by blast qed @@ -2512,16 +2512,13 @@ fixes S :: "'a::real_vector set" assumes "S \ {}" shows "convex hull (insert a S) = - {x. \u\0. \v\0. \b. (u + v = 1) \ b \ (convex hull S) \ (x = u *\<^sub>R a + v *\<^sub>R b)}" + {x. \u\0. \v\0. \b. (u + v = 1) \ b \ (convex hull S) \ (x = u *\<^sub>R a + v *\<^sub>R b)}" (is "_ = ?hull") - apply (rule, rule hull_minimal, rule) +proof (intro equalityI hull_minimal subsetI) + fix x + assume "x \ insert a S" + then have "\u\0. \v\0. u + v = 1 \ (\b. b \ convex hull S \ x = u *\<^sub>R a + v *\<^sub>R b)" unfolding insert_iff - prefer 3 - apply rule -proof - - fix x - assume x: "x = a \ x \ S" - then have "\u\0. \v\0. u + v = 1 \ (\b. b \ convex hull S \ x = u *\<^sub>R a + v *\<^sub>R b)" proof assume "x = a" then show ?thesis @@ -2619,7 +2616,7 @@ lemma convex_hull_insert_alt: "convex hull (insert a S) = - (if S = {} then {a} + (if S = {} then {a} else {(1 - u) *\<^sub>R a + u *\<^sub>R x |x u. 0 \ u \ u \ 1 \ x \ convex hull S})" apply (auto simp: convex_hull_insert) using diff_eq_eq apply fastforce @@ -4371,7 +4368,7 @@ finally have "y \ S" apply (subst *) apply (rule assms(1)[unfolded convex_alt,rule_format]) - apply (rule d[unfolded subset_eq,rule_format]) + apply (rule d[THEN subsetD]) unfolding mem_ball using assms(3-5) ** apply auto @@ -4751,22 +4748,17 @@ lemma affine_hull_linear_image: assumes "bounded_linear f" shows "f ` (affine hull s) = affine hull f ` s" - apply rule - unfolding subset_eq ball_simps - apply (rule_tac[!] hull_induct, rule hull_inc) - prefer 3 - apply (erule imageE) - apply (rule_tac x=xa in image_eqI, assumption) - apply (rule hull_subset[unfolded subset_eq, rule_format], assumption) proof - interpret f: bounded_linear f by fact - show "affine {x. f x \ affine hull f ` s}" + have "affine {x. f x \ affine hull f ` s}" unfolding affine_def by (auto simp: f.scaleR f.add affine_affine_hull[unfolded affine_def, rule_format]) - show "affine {x. x \ f ` (affine hull s)}" + moreover have "affine {x. x \ f ` (affine hull s)}" using affine_affine_hull[unfolded affine_def, of s] unfolding affine_def by (auto simp: f.scaleR [symmetric] f.add [symmetric]) -qed auto + ultimately show ?thesis + by (auto simp: hull_inc elim!: hull_induct) +qed lemma rel_interior_injective_on_span_linear_image: @@ -6484,8 +6476,8 @@ show "convex (cbox x y)" by (rule convex_box) next - fix s assume "{x, y} \ s" and "convex s" - then show "cbox x y \ s" + fix S assume "{x, y} \ S" and "convex S" + then show "cbox x y \ S" unfolding is_interval_convex_1 [symmetric] is_interval_def Basis_real_def by - (clarify, simp (no_asm_use), fast) qed @@ -6516,66 +6508,53 @@ text \And this is a finite set of vertices.\ lemma unit_cube_convex_hull: - obtains s :: "'a::euclidean_space set" - where "finite s" and "cbox 0 (\Basis) = convex hull s" - apply (rule that[of "{x::'a. \i\Basis. x\i=0 \ x\i=1}"]) - apply (rule finite_subset[of _ "(\s. (\i\Basis. (if i\s then 1 else 0) *\<^sub>R i)::'a) ` Pow Basis"]) - prefer 3 - apply (rule unit_interval_convex_hull, rule) - unfolding mem_Collect_eq -proof - - fix x :: 'a - assume as: "\i\Basis. x \ i = 0 \ x \ i = 1" - show "x \ (\s. \i\Basis. (if i\s then 1 else 0) *\<^sub>R i) ` Pow Basis" - apply (rule image_eqI[where x="{i. i\Basis \ x\i = 1}"]) - using as - apply (subst euclidean_eq_iff, auto) - done -qed auto + obtains S :: "'a::euclidean_space set" + where "finite S" and "cbox 0 (\Basis) = convex hull S" +proof + show "finite {x::'a. \i\Basis. x \ i = 0 \ x \ i = 1}" + proof (rule finite_subset, clarify) + show "finite ((\S. \i\Basis. (if i \ S then 1 else 0) *\<^sub>R i) ` Pow Basis)" + using finite_Basis by blast + fix x :: 'a + assume as: "\i\Basis. x \ i = 0 \ x \ i = 1" + show "x \ (\S. \i\Basis. (if i\S then 1 else 0) *\<^sub>R i) ` Pow Basis" + apply (rule image_eqI[where x="{i. i\Basis \ x\i = 1}"]) + using as + apply (subst euclidean_eq_iff, auto) + done + qed + show "cbox 0 One = convex hull {x. \i\Basis. x \ i = 0 \ x \ i = 1}" + using unit_interval_convex_hull by blast +qed text \Hence any cube (could do any nonempty interval).\ lemma cube_convex_hull: assumes "d > 0" - obtains s :: "'a::euclidean_space set" where - "finite s" and "cbox (x - (\i\Basis. d*\<^sub>Ri)) (x + (\i\Basis. d*\<^sub>Ri)) = convex hull s" + obtains S :: "'a::euclidean_space set" where + "finite S" and "cbox (x - (\i\Basis. d*\<^sub>Ri)) (x + (\i\Basis. d*\<^sub>Ri)) = convex hull S" proof - - let ?d = "(\i\Basis. d*\<^sub>Ri)::'a" + let ?d = "(\i\Basis. d *\<^sub>R i)::'a" have *: "cbox (x - ?d) (x + ?d) = (\y. x - ?d + (2 * d) *\<^sub>R y) ` cbox 0 (\Basis)" - apply (rule set_eqI, rule) - unfolding image_iff - defer - apply (erule bexE) - proof - + proof (intro set_eqI iffI) fix y - assume as: "y\cbox (x - ?d) (x + ?d)" + assume "y \ cbox (x - ?d) (x + ?d)" then have "inverse (2 * d) *\<^sub>R (y - (x - ?d)) \ cbox 0 (\Basis)" using assms by (simp add: mem_box field_simps inner_simps) - with \0 < d\ show "\z\cbox 0 (\Basis). y = x - ?d + (2 * d) *\<^sub>R z" - by (intro bexI[of _ "inverse (2 * d) *\<^sub>R (y - (x - ?d))"]) auto + with \0 < d\ show "y \ (\y. x - sum (( *\<^sub>R) d) Basis + (2 * d) *\<^sub>R y) ` cbox 0 One" + by (auto intro: image_eqI[where x= "inverse (2 * d) *\<^sub>R (y - (x - ?d))"]) next - fix y z - assume as: "z\cbox 0 (\Basis)" "y = x - ?d + (2*d) *\<^sub>R z" - have "\i. i\Basis \ 0 \ d * (z \ i) \ d * (z \ i) \ d" - using assms as(1)[unfolded mem_box] + fix y + assume "y \ (\y. x - ?d + (2 * d) *\<^sub>R y) ` cbox 0 One" + then obtain z where z: "z \ cbox 0 One" "y = x - ?d + (2*d) *\<^sub>R z" by auto then show "y \ cbox (x - ?d) (x + ?d)" - unfolding as(2) mem_box - apply - - apply rule - using as(1)[unfolded mem_box] - apply (erule_tac x=i in ballE) - using assms - apply (auto simp: inner_simps) - done + using z assms by (auto simp: mem_box inner_simps) qed - obtain s where "finite s" "cbox 0 (\Basis::'a) = convex hull s" + obtain S where "finite S" "cbox 0 (\Basis::'a) = convex hull S" using unit_cube_convex_hull by auto then show ?thesis - apply (rule_tac that[of "(\y. x - ?d + (2 * d) *\<^sub>R y)` s"]) - unfolding * and convex_hull_affinity - apply auto - done + by (rule_tac that[of "(\y. x - ?d + (2 * d) *\<^sub>R y)` S"]) (auto simp: convex_hull_affinity *) qed subsection%unimportant\Representation of any interval as a finite convex hull\ @@ -6635,18 +6614,18 @@ lemma closed_interval_as_convex_hull: fixes a :: "'a::euclidean_space" - obtains s where "finite s" "cbox a b = convex hull s" + obtains S where "finite S" "cbox a b = convex hull S" proof (cases "cbox a b = {}") case True with convex_hull_empty that show ?thesis by blast next case False - obtain s::"'a set" where "finite s" and eq: "cbox 0 One = convex hull s" + obtain S::"'a set" where "finite S" and eq: "cbox 0 One = convex hull S" by (blast intro: unit_cube_convex_hull) have lin: "linear (\x. \k\Basis. ((b \ k - a \ k) * (x \ k)) *\<^sub>R k)" by (rule linear_compose_sum) (auto simp: algebra_simps linearI) - have "finite ((+) a ` (\x. \k\Basis. ((b \ k - a \ k) * (x \ k)) *\<^sub>R k) ` s)" - by (rule finite_imageI \finite s\)+ + have "finite ((+) a ` (\x. \k\Basis. ((b \ k - a \ k) * (x \ k)) *\<^sub>R k) ` S)" + by (rule finite_imageI \finite S\)+ then show ?thesis apply (rule that) apply (simp add: convex_hull_translation convex_hull_linear_image [OF lin, symmetric]) @@ -6658,31 +6637,23 @@ subsection%unimportant \Bounded convex function on open set is continuous\ lemma convex_on_bounded_continuous: - fixes s :: "('a::real_normed_vector) set" - assumes "open s" - and "convex_on s f" - and "\x\s. \f x\ \ b" - shows "continuous_on s f" + fixes S :: "('a::real_normed_vector) set" + assumes "open S" + and "convex_on S f" + and "\x\S. \f x\ \ b" + shows "continuous_on S f" apply (rule continuous_at_imp_continuous_on) unfolding continuous_at_real_range proof (rule,rule,rule) fix x and e :: real - assume "x \ s" "e > 0" + assume "x \ S" "e > 0" define B where "B = \b\ + 1" - have B: "0 < B" "\x. x\s \ \f x\ \ B" - unfolding B_def - defer - apply (drule assms(3)[rule_format]) - apply auto - done - obtain k where "k > 0" and k: "cball x k \ s" - using assms(1)[unfolded open_contains_cball, THEN bspec[where x=x]] - using \x\s\ by auto + then have B: "0 < B""\x. x\S \ \f x\ \ B" + using assms(3) by auto + obtain k where "k > 0" and k: "cball x k \ S" + using \x \ S\ assms(1) open_contains_cball_eq by blast show "\d>0. \x'. norm (x' - x) < d \ \f x' - f x\ < e" - apply (rule_tac x="min (k / 2) (e / (2 * B) * k)" in exI) - apply rule - defer - proof (rule, rule) + proof (intro exI conjI allI impI) fix y assume as: "norm (y - x) < min (k / 2) (e / (2 * B) * k)" show "\f y - f x\ < e" @@ -6692,22 +6663,16 @@ have "2 < t" "0k>0\ by (auto simp:field_simps) - have "y \ s" - apply (rule k[unfolded subset_eq,rule_format]) + have "y \ S" + apply (rule k[THEN subsetD]) unfolding mem_cball dist_norm apply (rule order_trans[of _ "2 * norm (x - y)"]) using as by (auto simp: field_simps norm_minus_commute) { define w where "w = x + t *\<^sub>R (y - x)" - have "w \ s" - unfolding w_def - apply (rule k[unfolded subset_eq,rule_format]) - unfolding mem_cball dist_norm - unfolding t_def - using \k>0\ - apply auto - done + have "w \ S" + using \k>0\ by (auto simp: dist_norm t_def w_def k[THEN subsetD]) have "(1 / t) *\<^sub>R x + - x + ((t - 1) / t) *\<^sub>R x = (1 / t - 1 + (t - 1) / t) *\<^sub>R x" by (auto simp: algebra_simps) also have "\ = 0" @@ -6720,23 +6685,17 @@ by (auto simp:field_simps) have "f y - f x \ (f w - f x) / t" using assms(2)[unfolded convex_on_def,rule_format,of w x "1/t" "(t - 1)/t", unfolded w] - using \0 < t\ \2 < t\ and \x \ s\ \w \ s\ + using \0 < t\ \2 < t\ and \x \ S\ \w \ S\ by (auto simp:field_simps) also have "... < e" - using B(2)[OF \w\s\] and B(2)[OF \x\s\] 2 \t > 0\ by (auto simp: field_simps) + using B(2)[OF \w\S\] and B(2)[OF \x\S\] 2 \t > 0\ by (auto simp: field_simps) finally have th1: "f y - f x < e" . } moreover { define w where "w = x - t *\<^sub>R (y - x)" - have "w \ s" - unfolding w_def - apply (rule k[unfolded subset_eq,rule_format]) - unfolding mem_cball dist_norm - unfolding t_def - using \k > 0\ - apply auto - done + have "w \ S" + using \k > 0\ by (auto simp: dist_norm t_def w_def k[THEN subsetD]) have "(1 / (1 + t)) *\<^sub>R x + (t / (1 + t)) *\<^sub>R x = (1 / (1 + t) + t / (1 + t)) *\<^sub>R x" by (auto simp: algebra_simps) also have "\ = x" @@ -6749,12 +6708,12 @@ using \0 < e\ \0 < k\ \B > 0\ and as and False by (auto simp:field_simps) then have *: "(f w - f y) / t < e" - using B(2)[OF \w\s\] and B(2)[OF \y\s\] + using B(2)[OF \w\S\] and B(2)[OF \y\S\] using \t > 0\ by (auto simp:field_simps) have "f x \ 1 / (1 + t) * f w + (t / (1 + t)) * f y" using assms(2)[unfolded convex_on_def,rule_format,of w y "1/(1+t)" "t / (1+t)",unfolded w] - using \0 < t\ \2 < t\ and \y \ s\ \w \ s\ + using \0 < t\ \2 < t\ and \y \ S\ \w \ S\ by (auto simp:field_simps) also have "\ = (f w + t * f y) / (1 + t)" using \t > 0\ by (auto simp: divide_simps) @@ -6843,11 +6802,7 @@ by (simp add: dist_norm abs_le_iff algebra_simps) show "cball x d \ convex hull c" unfolding 2 - apply clarsimp - apply (simp only: dist_norm) - apply (subst inner_diff_left [symmetric], simp) - apply (erule (1) order_trans [OF Basis_le_norm]) - done + by (clarsimp simp: dist_norm) (metis inner_commute inner_diff_right norm_bound_Basis_le) have e': "e = (\(i::'a)\Basis. d)" by (simp add: d_def DIM_positive) show "convex hull c \ cball x e" diff -r 9e077a905209 -r 69715dfdc286 src/HOL/Analysis/Derivative.thy --- a/src/HOL/Analysis/Derivative.thy Sun Apr 29 21:26:57 2018 +0100 +++ b/src/HOL/Analysis/Derivative.thy Mon Apr 30 22:13:04 2018 +0100 @@ -373,77 +373,76 @@ lemma frechet_derivative_unique_within: fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" - assumes "(f has_derivative f') (at x within s)" - and "(f has_derivative f'') (at x within s)" - and "\i\Basis. \e>0. \d. 0 < \d\ \ \d\ < e \ (x + d *\<^sub>R i) \ s" + assumes "(f has_derivative f') (at x within S)" + and "(f has_derivative f'') (at x within S)" + and "\i\Basis. \e>0. \d. 0 < \d\ \ \d\ < e \ (x + d *\<^sub>R i) \ S" shows "f' = f''" proof - note as = assms(1,2)[unfolded has_derivative_def] then interpret f': bounded_linear f' by auto from as interpret f'': bounded_linear f'' by auto - have "x islimpt s" unfolding islimpt_approachable + have "x islimpt S" unfolding islimpt_approachable proof (rule, rule) fix e :: real assume "e > 0" - obtain d where "0 < \d\" and "\d\ < e" and "x + d *\<^sub>R (SOME i. i \ Basis) \ s" + obtain d where "0 < \d\" and "\d\ < e" and "x + d *\<^sub>R (SOME i. i \ Basis) \ S" using assms(3) SOME_Basis \e>0\ by blast - then show "\x'\s. x' \ x \ dist x' x < e" + then show "\x'\S. x' \ x \ dist x' x < e" apply (rule_tac x="x + d *\<^sub>R (SOME i. i \ Basis)" in bexI) unfolding dist_norm apply (auto simp: SOME_Basis nonzero_Basis) done qed - then have *: "netlimit (at x within s) = x" + then have *: "netlimit (at x within S) = x" apply (auto intro!: netlimit_within) by (metis trivial_limit_within) show ?thesis - apply (rule linear_eq_stdbasis) - unfolding linear_conv_bounded_linear - apply (rule as(1,2)[THEN conjunct1])+ - proof (rule, rule ccontr) + proof (rule linear_eq_stdbasis) + show "linear f'" "linear f''" + unfolding linear_conv_bounded_linear using as by auto + next fix i :: 'a assume i: "i \ Basis" define e where "e = norm (f' i - f'' i)" - assume "f' i \ f'' i" - then have "e > 0" - unfolding e_def by auto - obtain d where d: - "0 < d" - "(\xa. xa\s \ 0 < dist xa x \ dist xa x < d \ - dist ((f xa - f x - f' (xa - x)) /\<^sub>R norm (xa - x) - - (f xa - f x - f'' (xa - x)) /\<^sub>R norm (xa - x)) (0 - 0) < e)" - using tendsto_diff [OF as(1,2)[THEN conjunct2]] - unfolding * Lim_within - using \e>0\ by blast - obtain c where c: "0 < \c\" "\c\ < d \ x + c *\<^sub>R i \ s" - using assms(3) i d(1) by blast - have *: "norm (- ((1 / \c\) *\<^sub>R f' (c *\<^sub>R i)) + (1 / \c\) *\<^sub>R f'' (c *\<^sub>R i)) = + show "f' i = f'' i" + proof (rule ccontr) + assume "f' i \ f'' i" + then have "e > 0" + unfolding e_def by auto + obtain d where d: + "0 < d" + "(\y. y\S \ 0 < dist y x \ dist y x < d \ + dist ((f y - f x - f' (y - x)) /\<^sub>R norm (y - x) - + (f y - f x - f'' (y - x)) /\<^sub>R norm (y - x)) (0 - 0) < e)" + using tendsto_diff [OF as(1,2)[THEN conjunct2]] + unfolding * Lim_within + using \e>0\ by blast + obtain c where c: "0 < \c\" "\c\ < d \ x + c *\<^sub>R i \ S" + using assms(3) i d(1) by blast + have *: "norm (- ((1 / \c\) *\<^sub>R f' (c *\<^sub>R i)) + (1 / \c\) *\<^sub>R f'' (c *\<^sub>R i)) = norm ((1 / \c\) *\<^sub>R (- (f' (c *\<^sub>R i)) + f'' (c *\<^sub>R i)))" - unfolding scaleR_right_distrib by auto - also have "\ = norm ((1 / \c\) *\<^sub>R (c *\<^sub>R (- (f' i) + f'' i)))" - unfolding f'.scaleR f''.scaleR - unfolding scaleR_right_distrib scaleR_minus_right - by auto - also have "\ = e" - unfolding e_def - using c(1) - using norm_minus_cancel[of "f' i - f'' i"] - by auto - finally show False - using c - using d(2)[of "x + c *\<^sub>R i"] - unfolding dist_norm - unfolding f'.scaleR f''.scaleR f'.add f''.add f'.diff f''.diff - scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib - using i - by (auto simp: inverse_eq_divide) + unfolding scaleR_right_distrib by auto + also have "\ = norm ((1 / \c\) *\<^sub>R (c *\<^sub>R (- (f' i) + f'' i)))" + unfolding f'.scaleR f''.scaleR + unfolding scaleR_right_distrib scaleR_minus_right + by auto + also have "\ = e" + unfolding e_def + using c(1) + using norm_minus_cancel[of "f' i - f'' i"] + by auto + finally show False + using c + using d(2)[of "x + c *\<^sub>R i"] + unfolding dist_norm + unfolding f'.scaleR f''.scaleR f'.add f''.add f'.diff f''.diff + scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib + using i + by (auto simp: inverse_eq_divide) + qed qed qed -lemma frechet_derivative_unique_at: - "(f has_derivative f') (at x) \ (f has_derivative f'') (at x) \ f' = f''" - by (rule has_derivative_unique) - lemma frechet_derivative_unique_within_closed_interval: fixes f::"'a::euclidean_space \ 'b::real_normed_vector" assumes "\i\Basis. a\i < b\i" @@ -506,12 +505,12 @@ from assms(1) have *: "at x within box a b = at x" by (metis at_within_interior interior_open open_box) from assms(2,3) [unfolded *] show "f' = f''" - by (rule frechet_derivative_unique_at) + by (rule has_derivative_unique) qed lemma frechet_derivative_at: "(f has_derivative f') (at x) \ f' = frechet_derivative f (at x)" - apply (rule frechet_derivative_unique_at[of f]) + apply (rule has_derivative_unique[of f]) apply assumption unfolding frechet_derivative_works[symmetric] using differentiable_def diff -r 9e077a905209 -r 69715dfdc286 src/HOL/Analysis/Linear_Algebra.thy --- a/src/HOL/Analysis/Linear_Algebra.thy Sun Apr 29 21:26:57 2018 +0100 +++ b/src/HOL/Analysis/Linear_Algebra.thy Mon Apr 30 22:13:04 2018 +0100 @@ -72,7 +72,7 @@ lemma hull_unique: "s \ t \ S t \ (\t'. s \ t' \ S t' \ t \ t') \ (S hull s = t)" unfolding hull_def by auto -lemma hull_induct: "(\x. x\ S \ P x) \ Q {x. P x} \ \x\ Q hull S. P x" +lemma hull_induct: "\a \ Q hull S; \x. x\ S \ P x; Q {x. P x}\ \ P a" using hull_minimal[of S "{x. P x}" Q] by (auto simp add: subset_eq) @@ -339,20 +339,12 @@ unfolding dependent_def by auto lemma (in real_vector) independent_mono: "independent A \ B \ A \ independent B" - apply (clarsimp simp add: dependent_def span_mono) - apply (subgoal_tac "span (B - {a}) \ span (A - {a})") - apply force - apply (rule span_mono) - apply auto - done + unfolding dependent_def span_mono + by (metis insert_Diff local.span_mono subsetCE subset_insert_iff) lemma (in real_vector) span_subspace: "A \ B \ B \ span A \ subspace B \ span A = B" by (metis order_antisym span_def hull_minimal) -lemma (in real_vector) span_induct': - "\x \ S. P x \ subspace {x. P x} \ \x \ span S. P x" - unfolding span_def by (rule hull_induct) auto - inductive_set (in real_vector) span_induct_alt_help for S :: "'a set" where span_induct_alt_help_0: "0 \ span_induct_alt_help S" @@ -1063,19 +1055,19 @@ done lemma linear_eq_0_span: - assumes lf: "linear f" and f0: "\x\B. f x = 0" - shows "\x \ span B. f x = 0" - using f0 subspace_kernel[OF lf] - by (rule span_induct') - -lemma linear_eq_0: "linear f \ S \ span B \ \x\B. f x = 0 \ \x\S. f x = 0" - using linear_eq_0_span[of f B] by auto - -lemma linear_eq_span: "linear f \ linear g \ \x\B. f x = g x \ \x \ span B. f x = g x" - using linear_eq_0_span[of "\x. f x - g x" B] by (auto simp: linear_compose_sub) - -lemma linear_eq: "linear f \ linear g \ S \ span B \ \x\B. f x = g x \ \x\S. f x = g x" - using linear_eq_span[of f g B] by auto + assumes x: "x \ span B" and lf: "linear f" and f0: "\x. x\B \ f x = 0" + shows "f x = 0" + using x f0 subspace_kernel[OF lf] span_induct + by blast + +lemma linear_eq_0: "\x \ S; linear f; S \ span B; \x. x\B \ f x = 0\ \ f x = 0" + using linear_eq_0_span[of x B f] by auto + +lemma linear_eq_span: "\x \ span B; linear f; linear g; \x. x\B \ f x = g x\ \ f x = g x" + using linear_eq_0_span[of x B "\x. f x - g x"] by (auto simp: linear_compose_sub) + +lemma linear_eq: "\x \ S; linear f; linear g; S \ span B; \x. x\B \ f x = g x\ \ f x = g x" + using linear_eq_span[of _ B f g] by auto text \The degenerate case of the Exchange Lemma.\ @@ -1174,13 +1166,13 @@ have fB: "inj_on f B" using fi by (auto simp: \span S = span B\ intro: subset_inj_on span_superset) - have "\x\span B. g (f x) = x" - proof (intro linear_eq_span) + have "g (f x) = x" if "x \ span B" for x + proof (rule linear_eq_span) show "linear (\x. x)" "linear (\x. g (f x))" using linear_id linear_compose[OF \linear f\ \linear g\] by (auto simp: id_def comp_def) - show "\x \ B. g (f x) = x" - using g fi \span S = span B\ by (auto simp: fB) - qed + show "g (f x) = x" if "x \ B" for x + using g fi \span S = span B\ by (simp add: fB that) + qed (rule that) moreover have "inv_into B f ` f ` B \ B" by (auto simp: fB) @@ -1210,8 +1202,7 @@ ultimately have "\x\B. f (g x) = x" by auto then have "\x\span B. f (g x) = x" - using linear_id linear_compose[OF \linear g\ \linear f\] - by (intro linear_eq_span) (auto simp: id_def comp_def) + using linear_id linear_compose[OF \linear g\ \linear f\] linear_eq_span by fastforce moreover have "inv_into (span S) f ` B \ span S" using \B \ T\ \span T \ f`span S\ by (auto intro: inv_into_into span_superset) then have "range g \ span S" @@ -2457,8 +2448,8 @@ done with a have a0:"?a \ 0" by auto - have "\x\span B. ?a \ x = 0" - proof (rule span_induct') + have "?a \ x = 0" if "x\span B" for x + proof (rule span_induct [OF that]) show "subspace {x. ?a \ x = 0}" by (auto simp add: subspace_def inner_add) next @@ -2481,9 +2472,9 @@ intro: B(5)[unfolded pairwise_def orthogonal_def, rule_format]) done } - then show "\x \ B. ?a \ x = 0" - by blast - qed + then show "?a \ x = 0" if "x \ B" for x + using that by blast + qed with a0 show ?thesis unfolding sSB by (auto intro: exI[where x="?a"]) qed @@ -2635,9 +2626,9 @@ fixes f :: "'a::euclidean_space \ _" assumes lf: "linear f" and lg: "linear g" - and fg: "\b\Basis. f b = g b" + and fg: "\b. b \ Basis \ f b = g b" shows "f = g" - using linear_eq[OF lf lg, of _ Basis] fg by auto + using linear_eq[OF _ lf lg, of _ _ Basis] fg by auto text \Similar results for bilinear functions.\ @@ -2646,8 +2637,9 @@ and bg: "bilinear g" and SB: "S \ span B" and TC: "T \ span C" - and fg: "\x\ B. \y\ C. f x y = g x y" - shows "\x\S. \y\T. f x y = g x y " + and "x\S" "y\T" + and fg: "\x y. \x \ B; y\ C\ \ f x y = g x y" + shows "f x y = g x y" proof - let ?P = "{x. \y\ span C. f x y = g x y}" from bf bg have sp: "subspace ?P" @@ -2655,27 +2647,30 @@ by (auto simp add: span_0 bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def intro: bilinear_ladd[OF bf]) - have "\x \ span B. \y\ span C. f x y = g x y" - apply (rule span_induct' [OF _ sp]) - apply (rule ballI) - apply (rule span_induct') - apply (simp add: fg) + have sfg: "\x. x \ B \ subspace {a. f x a = g x a}" apply (auto simp add: subspace_def) using bf bg unfolding bilinear_def linear_iff - apply (auto simp add: span_0 bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add Ball_def + apply (auto simp add: bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add intro: bilinear_ladd[OF bf]) done + have "\y\ span C. f x y = g x y" if "x \ span B" for x + apply (rule span_induct [OF that sp]) + apply (rule ballI) + apply (erule span_induct) + apply (simp_all add: sfg fg) + done then show ?thesis - using SB TC by auto + using SB TC assms by auto qed lemma bilinear_eq_stdbasis: fixes f :: "'a::euclidean_space \ 'b::euclidean_space \ _" assumes bf: "bilinear f" and bg: "bilinear g" - and fg: "\i\Basis. \j\Basis. f i j = g i j" + and fg: "\i j. i \ Basis \ j \ Basis \ f i j = g i j" shows "f = g" - using bilinear_eq[OF bf bg equalityD2[OF span_Basis] equalityD2[OF span_Basis] fg] by blast + using bilinear_eq[OF bf bg equalityD2[OF span_Basis] equalityD2[OF span_Basis]] fg + by blast text \An injective map @{typ "'a::euclidean_space \ 'b::euclidean_space"} is also surjective.\ @@ -2695,13 +2690,7 @@ apply (rule card_ge_dim_independent) apply blast apply (rule independent_injective_image[OF B(2) lf fi]) - apply (rule order_eq_refl) - apply (rule sym) - unfolding d - apply (rule card_image) - apply (rule subset_inj_on[OF fi]) - apply blast - done + by (metis card_image d fi inj_on_subset order_refl top_greatest) from th show ?thesis unfolding span_linear_image[OF lf] surj_def using B(3) by blast