# HG changeset patch # User paulson # Date 1530830237 -3600 # Node ID 57b9d993cc987e41f3898a64551a5b40d92a9205 # Parent 90381a0f54740c5e1417a3ca2f5b2777984f0315# Parent 5b05ede597b8d0004df01450f1b0feff667f4ada merged diff -r 90381a0f5474 -r 57b9d993cc98 src/HOL/Algebra/Module.thy --- a/src/HOL/Algebra/Module.thy Thu Jul 05 23:21:28 2018 +0200 +++ b/src/HOL/Algebra/Module.thy Thu Jul 05 23:37:17 2018 +0100 @@ -167,4 +167,85 @@ by (simp add: Pi_def smult_r_distr) qed + + +subsection \Submodules\ + +locale submodule = subgroup H "add_monoid M" for H and R :: "('a, 'b) ring_scheme" and M (structure) ++ assumes smult_closed [simp, intro]: + "\a \ carrier R; x \ H\ \ a \\<^bsub>M\<^esub> x \ H" + + +lemma (in module) submoduleI : + assumes subset: "H \ carrier M" + and zero: "\\<^bsub>M\<^esub> \ H" + and a_inv: "!!a. a \ H \ \\<^bsub>M\<^esub> a \ H" + and add : "\ a b. \a \ H ; b \ H\ \ a \\<^bsub>M\<^esub> b \ H" + and smult_closed : "\ a x. \a \ carrier R; x \ H\ \ a \\<^bsub>M\<^esub> x \ H" + shows "submodule H R M" + apply (intro submodule.intro subgroup.intro) + using assms unfolding submodule_axioms_def + by (simp_all add : a_inv_def) + + +lemma (in module) submoduleE : + assumes "submodule H R M" + shows "H \ carrier M" + and "H \ {}" + and "\a. a \ H \ \\<^bsub>M\<^esub> a \ H" + and "\a b. \a \ carrier R; b \ H\ \ a \\<^bsub>M\<^esub> b \ H" + and "\ a b. \a \ H ; b \ H\ \ a \\<^bsub>M\<^esub> b \ H" + and "\ x. x \ H \ (a_inv M x) \ H" + using group.subgroupE[of "add_monoid M" H, OF _ submodule.axioms(1)[OF assms]] a_comm_group + submodule.smult_closed[OF assms] + unfolding comm_group_def a_inv_def + by auto + + +lemma (in module) carrier_is_submodule : +"submodule (carrier M) R M" + apply (intro submoduleI) + using a_comm_group group.inv_closed unfolding comm_group_def a_inv_def group_def monoid_def + by auto + +lemma (in submodule) submodule_is_module : + assumes "module R M" + shows "module R (M\carrier := H\)" +proof (auto intro! : moduleI abelian_group.intro) + show "cring (R)" using assms unfolding module_def by auto + show "abelian_monoid (M\carrier := H\)" + using comm_monoid.submonoid_is_comm_monoid[OF _ subgroup_is_submonoid] assms + unfolding abelian_monoid_def module_def abelian_group_def + by auto + thus "abelian_group_axioms (M\carrier := H\)" + using subgroup_is_group assms + unfolding abelian_group_axioms_def comm_group_def abelian_monoid_def module_def abelian_group_def + by auto + show "\z. z \ H \ \\<^bsub>R\<^esub> \ z = z" + using subgroup_imp_subset[OF subgroup_axioms] module.smult_one[OF assms] + by auto + fix a b x y assume a : "a \ carrier R" and b : "b \ carrier R" and x : "x \ H" and y : "y \ H" + show "(a \\<^bsub>R\<^esub> b) \ x = a \ x \ b \ x" + using a b x module.smult_l_distr[OF assms] subgroup_imp_subset[OF subgroup_axioms] + by auto + show "a \ (x \ y) = a \ x \ a \ y" + using a x y module.smult_r_distr[OF assms] subgroup_imp_subset[OF subgroup_axioms] + by auto + show "a \\<^bsub>R\<^esub> b \ x = a \ (b \ x)" + using a b x module.smult_assoc1[OF assms] subgroup_imp_subset[OF subgroup_axioms] + by auto +qed + + +lemma (in module) module_incl_imp_submodule : + assumes "H \ carrier M" + and "module R (M\carrier := H\)" + shows "submodule H R M" + apply (intro submodule.intro) + using add.group_incl_imp_subgroup[OF assms(1)] assms module.axioms(2)[OF assms(2)] + module.smult_closed[OF assms(2)] + unfolding abelian_group_def abelian_group_axioms_def comm_group_def submodule_axioms_def + by simp_all + + end diff -r 90381a0f5474 -r 57b9d993cc98 src/HOL/Limits.thy --- a/src/HOL/Limits.thy Thu Jul 05 23:21:28 2018 +0200 +++ b/src/HOL/Limits.thy Thu Jul 05 23:37:17 2018 +0100 @@ -2442,7 +2442,7 @@ assumes "0 < R" and "\x. x \ a \ norm (x - a) < R \ f x = g x" shows "g \a\ l \ f \a\ l" - by (rule metric_LIM_equal2 [OF assms]) (simp_all add: dist_norm) + by (rule metric_LIM_equal2 [OF _ assms]) (simp_all add: dist_norm) lemma LIM_compose2: fixes a :: "'a::real_normed_vector" @@ -2556,15 +2556,7 @@ assumes "uniformly_continuous_on S f" "Cauchy X" "\n. X n \ S" shows "Cauchy (\n. f (X n))" using assms - apply (simp only: uniformly_continuous_on_def) - apply (rule metric_CauchyI) - apply (drule_tac x=e in spec) - apply safe - apply (drule_tac e=d in metric_CauchyD) - apply safe - apply (rule_tac x=M in exI) - apply simp - done + unfolding uniformly_continuous_on_def by (meson Cauchy_def) lemma isUCont_Cauchy: "isUCont f \ Cauchy X \ Cauchy (\n. f (X n))" by (rule uniformly_continuous_on_Cauchy[where S=UNIV and f=f]) simp_all diff -r 90381a0f5474 -r 57b9d993cc98 src/HOL/Real_Vector_Spaces.thy --- a/src/HOL/Real_Vector_Spaces.thy Thu Jul 05 23:21:28 2018 +0200 +++ b/src/HOL/Real_Vector_Spaces.thy Thu Jul 05 23:37:17 2018 +0100 @@ -54,7 +54,7 @@ global_interpretation real_vector?: vector_space "scaleR :: real \ 'a \ 'a::real_vector" rewrites "Vector_Spaces.linear ( *\<^sub>R) ( *\<^sub>R) = linear" - and "Vector_Spaces.linear ( * ) ( *\<^sub>R) = linear" + and "Vector_Spaces.linear ( *) ( *\<^sub>R) = linear" defines dependent_raw_def: dependent = real_vector.dependent and representation_raw_def: representation = real_vector.representation and subspace_raw_def: subspace = real_vector.subspace @@ -66,8 +66,8 @@ apply (rule scaleR_add_left) apply (rule scaleR_scaleR) apply (rule scaleR_one) - apply (force simp add: linear_def) - apply (force simp add: linear_def real_scaleR_def[abs_def]) + apply (force simp: linear_def) + apply (force simp: linear_def real_scaleR_def[abs_def]) done hide_const (open)\ \locale constants\ @@ -83,7 +83,7 @@ global_interpretation real_vector?: vector_space_pair "scaleR::_\_\'a::real_vector" "scaleR::_\_\'b::real_vector" rewrites "Vector_Spaces.linear ( *\<^sub>R) ( *\<^sub>R) = linear" - and "Vector_Spaces.linear ( * ) ( *\<^sub>R) = linear" + and "Vector_Spaces.linear ( *) ( *\<^sub>R) = linear" defines construct_raw_def: construct = real_vector.construct apply unfold_locales unfolding linear_def real_scaleR_def @@ -92,7 +92,7 @@ hide_const (open)\ \locale constants\ real_vector.construct -lemma linear_compose: "linear f \ linear g \ linear (g o f)" +lemma linear_compose: "linear f \ linear g \ linear (g \ f)" unfolding linear_def by (rule Vector_Spaces.linear_compose) text \Recover original theorem names\ @@ -161,12 +161,7 @@ lemma inverse_scaleR_distrib: "inverse (scaleR a x) = scaleR (inverse a) (inverse x)" for x :: "'a::{real_div_algebra,division_ring}" - apply (cases "a = 0") - apply simp - apply (cases "x = 0") - apply simp - apply (erule (1) nonzero_inverse_scaleR_distrib) - done + by (metis inverse_zero nonzero_inverse_scaleR_distrib scale_eq_0_iff) lemmas sum_constant_scaleR = real_vector.sum_constant_scale\ \legacy name\ @@ -367,56 +362,32 @@ lemma Reals_numeral [simp]: "numeral w \ \" by (subst of_real_numeral [symmetric], rule Reals_of_real) -lemma Reals_0 [simp]: "0 \ \" - apply (unfold Reals_def) - apply (rule range_eqI) - apply (rule of_real_0 [symmetric]) - done - -lemma Reals_1 [simp]: "1 \ \" - apply (unfold Reals_def) - apply (rule range_eqI) - apply (rule of_real_1 [symmetric]) - done +lemma Reals_0 [simp]: "0 \ \" and Reals_1 [simp]: "1 \ \" + by (simp_all add: Reals_def) lemma Reals_add [simp]: "a \ \ \ b \ \ \ a + b \ \" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (rule of_real_add [symmetric]) - done + by (metis (no_types, hide_lams) Reals_def Reals_of_real imageE of_real_add) lemma Reals_minus [simp]: "a \ \ \ - a \ \" - by (auto simp add: Reals_def) + by (auto simp: Reals_def) lemma Reals_minus_iff [simp]: "- a \ \ \ a \ \" apply (auto simp: Reals_def) by (metis add.inverse_inverse of_real_minus rangeI) lemma Reals_diff [simp]: "a \ \ \ b \ \ \ a - b \ \" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (rule of_real_diff [symmetric]) - done + by (metis Reals_add Reals_minus_iff add_uminus_conv_diff) lemma Reals_mult [simp]: "a \ \ \ b \ \ \ a * b \ \" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (rule of_real_mult [symmetric]) - done + by (metis (no_types, lifting) Reals_def Reals_of_real imageE of_real_mult) lemma nonzero_Reals_inverse: "a \ \ \ a \ 0 \ inverse a \ \" for a :: "'a::real_div_algebra" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (erule nonzero_of_real_inverse [symmetric]) - done + by (metis Reals_def Reals_of_real imageE of_real_inverse) lemma Reals_inverse: "a \ \ \ inverse a \ \" for a :: "'a::{real_div_algebra,division_ring}" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (rule of_real_inverse [symmetric]) - done + using nonzero_Reals_inverse by fastforce lemma Reals_inverse_iff [simp]: "inverse x \ \ \ x \ \" for x :: "'a::{real_div_algebra,division_ring}" @@ -424,24 +395,15 @@ lemma nonzero_Reals_divide: "a \ \ \ b \ \ \ b \ 0 \ a / b \ \" for a b :: "'a::real_field" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (erule nonzero_of_real_divide [symmetric]) - done + by (simp add: divide_inverse) lemma Reals_divide [simp]: "a \ \ \ b \ \ \ a / b \ \" for a b :: "'a::{real_field,field}" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (rule of_real_divide [symmetric]) - done + using nonzero_Reals_divide by fastforce lemma Reals_power [simp]: "a \ \ \ a ^ n \ \" for a :: "'a::real_algebra_1" - apply (auto simp add: Reals_def) - apply (rule range_eqI) - apply (rule of_real_power [symmetric]) - done + by (metis Reals_def Reals_of_real imageE of_real_power) lemma Reals_cases [cases set: Reals]: assumes "q \ \" @@ -478,11 +440,7 @@ begin lemma scaleR_mono: "a \ b \ x \ y \ 0 \ b \ 0 \ x \ a *\<^sub>R x \ b *\<^sub>R y" - apply (erule scaleR_right_mono [THEN order_trans]) - apply assumption - apply (erule scaleR_left_mono) - apply assumption - done + by (meson local.dual_order.trans local.scaleR_left_mono local.scaleR_right_mono) lemma scaleR_mono': "a \ b \ c \ d \ 0 \ a \ 0 \ c \ a *\<^sub>R c \ b *\<^sub>R d" by (rule scaleR_mono) (auto intro: order.trans) @@ -542,7 +500,7 @@ lemma split_scaleR_neg_le: "(0 \ a \ x \ 0) \ (a \ 0 \ 0 \ x) \ a *\<^sub>R x \ 0" for x :: "'a::ordered_real_vector" - by (auto simp add: scaleR_nonneg_nonpos scaleR_nonpos_nonneg) + by (auto simp: scaleR_nonneg_nonpos scaleR_nonpos_nonneg) lemma le_add_iff1: "a *\<^sub>R e + c \ b *\<^sub>R e + d \ (a - b) *\<^sub>R e + c \ d" for c d e :: "'a::ordered_real_vector" @@ -554,14 +512,12 @@ lemma scaleR_left_mono_neg: "b \ a \ c \ 0 \ c *\<^sub>R a \ c *\<^sub>R b" for a b :: "'a::ordered_real_vector" - apply (drule scaleR_left_mono [of _ _ "- c"]) - apply simp_all + apply (drule scaleR_left_mono [of _ _ "- c"], simp_all) done lemma scaleR_right_mono_neg: "b \ a \ c \ 0 \ a *\<^sub>R c \ b *\<^sub>R c" for c :: "'a::ordered_real_vector" - apply (drule scaleR_right_mono [of _ _ "- c"]) - apply simp_all + apply (drule scaleR_right_mono [of _ _ "- c"], simp_all) done lemma scaleR_nonpos_nonpos: "a \ 0 \ b \ 0 \ 0 \ a *\<^sub>R b" @@ -570,7 +526,7 @@ lemma split_scaleR_pos_le: "(0 \ a \ 0 \ b) \ (a \ 0 \ b \ 0) \ 0 \ a *\<^sub>R b" for b :: "'a::ordered_real_vector" - by (auto simp add: scaleR_nonneg_nonneg scaleR_nonpos_nonpos) + by (auto simp: scaleR_nonneg_nonneg scaleR_nonpos_nonpos) lemma zero_le_scaleR_iff: fixes b :: "'a::ordered_real_vector" @@ -612,7 +568,7 @@ lemma scaleR_le_cancel_left: "c *\<^sub>R a \ c *\<^sub>R b \ (0 < c \ a \ b) \ (c < 0 \ b \ a)" for b :: "'a::ordered_real_vector" - by (auto simp add: neq_iff scaleR_left_mono scaleR_left_mono_neg + by (auto simp: neq_iff scaleR_left_mono scaleR_left_mono_neg dest: scaleR_left_mono[where a="inverse c"] scaleR_left_mono_neg[where c="inverse c"]) lemma scaleR_le_cancel_left_pos: "0 < c \ c *\<^sub>R a \ c *\<^sub>R b \ a \ b" @@ -752,12 +708,14 @@ lemma norm_triangle_ineq3: "\norm a - norm b\ \ norm (a - b)" for a b :: "'a::real_normed_vector" - apply (subst abs_le_iff) - apply auto - apply (rule norm_triangle_ineq2) - apply (subst norm_minus_commute) - apply (rule norm_triangle_ineq2) - done +proof - + have "norm a - norm b \ norm (a - b)" + by (simp add: norm_triangle_ineq2) + moreover have "norm b - norm a \ norm (a - b)" + by (metis norm_minus_commute norm_triangle_ineq2) + ultimately show ?thesis + by (simp add: abs_le_iff) +qed lemma norm_triangle_ineq4: "norm (a - b) \ norm a + norm b" for a b :: "'a::real_normed_vector" @@ -854,22 +812,15 @@ by (subst of_real_of_int_eq [symmetric], rule norm_of_real) lemma norm_of_nat [simp]: "norm (of_nat n::'a::real_normed_algebra_1) = of_nat n" - apply (subst of_real_of_nat_eq [symmetric]) - apply (subst norm_of_real, simp) - done + by (metis abs_of_nat norm_of_real of_real_of_nat_eq) lemma nonzero_norm_inverse: "a \ 0 \ norm (inverse a) = inverse (norm a)" for a :: "'a::real_normed_div_algebra" - apply (rule inverse_unique [symmetric]) - apply (simp add: norm_mult [symmetric]) - done + by (metis inverse_unique norm_mult norm_one right_inverse) lemma norm_inverse: "norm (inverse a) = inverse (norm a)" for a :: "'a::{real_normed_div_algebra,division_ring}" - apply (cases "a = 0") - apply simp - apply (erule nonzero_norm_inverse) - done + by (metis inverse_zero nonzero_norm_inverse norm_zero) lemma nonzero_norm_divide: "b \ 0 \ norm (a / b) = norm a / norm b" for a b :: "'a::real_normed_field" @@ -982,7 +933,7 @@ have "norm ((\i\insert i I. z i) - (\i\insert i I. w i)) = norm ((\i\I. z i) * (z i - w i) + ((\i\I. z i) - (\i\I. w i)) * w i)" (is "_ = norm (?t1 + ?t2)") - by (auto simp add: field_simps) + by (auto simp: field_simps) also have "\ \ norm ?t1 + norm ?t2" by (rule norm_triangle_ineq) also have "norm ?t1 \ norm (\i\I. z i) * norm (z i - w i)" @@ -998,7 +949,7 @@ also have "norm ((\i\I. z i) - (\i\I. w i)) \ (\i\I. norm (z i - w i))" using insert by auto finally show ?case - by (auto simp add: ac_simps mult_right_mono mult_left_mono) + by (auto simp: ac_simps mult_right_mono mult_left_mono) next case infinite then show ?case by simp @@ -1012,7 +963,7 @@ have "norm (z^m - w^m) = norm ((\ i < m. z) - (\ i < m. w))" by (simp add: prod_constant) also have "\ \ (\i = m * norm (z - w)" by simp finally show ?thesis . @@ -1184,17 +1135,7 @@ definition real_norm_def [simp]: "norm r = \r\" instance - apply intro_classes - apply (unfold real_norm_def real_scaleR_def) - apply (rule dist_real_def) - apply (simp add: sgn_real_def) - apply (rule uniformity_real_def) - apply (rule open_real_def) - apply (rule abs_eq_0) - apply (rule abs_triangle_ineq) - apply (rule abs_mult) - apply (rule abs_mult) - done + by intro_classes (auto simp: abs_mult open_real_def dist_real_def sgn_real_def uniformity_real_def) end @@ -1369,7 +1310,7 @@ corollary real_linearD: fixes f :: "real \ real" - assumes "linear f" obtains c where "f = ( * ) c" + assumes "linear f" obtains c where "f = ( *) c" by (rule linear_imp_scaleR [OF assms]) (force simp: scaleR_conv_of_real) lemma linear_times_of_real: "linear (\x. a * of_real x)" @@ -1467,22 +1408,20 @@ lemma bounded_linear_left: "bounded_linear (\a. a ** b)" - apply (insert bounded) - apply safe - apply (rule_tac K="norm b * K" in bounded_linear_intro) - apply (rule add_left) - apply (rule scaleR_left) - apply (simp add: ac_simps) - done +proof - + obtain K where "\a b. norm (a ** b) \ norm a * norm b * K" + using pos_bounded by blast + then show ?thesis + by (rule_tac K="norm b * K" in bounded_linear_intro) (auto simp: algebra_simps scaleR_left add_left) +qed lemma bounded_linear_right: "bounded_linear (\b. a ** b)" - apply (insert bounded) - apply safe - apply (rule_tac K="norm a * K" in bounded_linear_intro) - apply (rule add_right) - apply (rule scaleR_right) - apply (simp add: ac_simps) - done +proof - + obtain K where "\a b. norm (a ** b) \ norm a * norm b * K" + using pos_bounded by blast + then show ?thesis + by (rule_tac K="norm a * K" in bounded_linear_intro) (auto simp: algebra_simps scaleR_right add_right) +qed lemma prod_diff_prod: "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)" by (simp add: diff_left diff_right) @@ -1493,14 +1432,11 @@ apply (rule add_left) apply (rule scaleR_right) apply (rule scaleR_left) - apply (subst mult.commute) - apply (insert bounded) - apply blast - done + by (metis bounded mult.commute) lemma comp1: assumes "bounded_linear g" - shows "bounded_bilinear (\x. ( ** ) (g x))" + shows "bounded_bilinear (\x. ( **) (g x))" proof unfold_locales interpret g: bounded_linear g by fact show "\a a' b. g (a + a') ** b = g a ** b + g a' ** b" @@ -1564,7 +1500,7 @@ lemma bounded_linear_sub: "bounded_linear f \ bounded_linear g \ bounded_linear (\x. f x - g x)" using bounded_linear_add[of f "\x. - g x"] bounded_linear_minus[of g] - by (auto simp add: algebra_simps) + by (auto simp: algebra_simps) lemma bounded_linear_sum: fixes f :: "'i \ 'a::real_normed_vector \ 'b::real_normed_vector" @@ -1602,13 +1538,10 @@ qed qed -lemma bounded_bilinear_mult: "bounded_bilinear (( * ) :: 'a \ 'a \ 'a::real_normed_algebra)" +lemma bounded_bilinear_mult: "bounded_bilinear (( *) :: 'a \ 'a \ 'a::real_normed_algebra)" apply (rule bounded_bilinear.intro) - apply (rule distrib_right) - apply (rule distrib_left) - apply (rule mult_scaleR_left) - apply (rule mult_scaleR_right) - apply (rule_tac x="1" in exI) + apply (auto simp: algebra_simps) + apply (rule_tac x=1 in exI) apply (simp add: norm_mult_ineq) done @@ -1632,12 +1565,8 @@ lemma bounded_bilinear_scaleR: "bounded_bilinear scaleR" apply (rule bounded_bilinear.intro) - apply (rule scaleR_left_distrib) - apply (rule scaleR_right_distrib) - apply simp - apply (rule scaleR_left_commute) - apply (rule_tac x="1" in exI) - apply simp + apply (auto simp: algebra_simps) + apply (rule_tac x=1 in exI, simp) done lemma bounded_linear_scaleR_left: "bounded_linear (\r. scaleR r x)" @@ -1674,8 +1603,7 @@ instance real_normed_algebra_1 \ perfect_space proof show "\ open {x}" for x :: 'a - apply (simp only: open_dist dist_norm) - apply clarsimp + apply (clarsimp simp: open_dist dist_norm) apply (rule_tac x = "x + of_real (e/2)" in exI) apply simp done @@ -1725,10 +1653,9 @@ lemma eventually_at_le: "eventually P (at a within S) \ (\d>0. \x\S. x \ a \ dist x a \ d \ P x)" for a :: "'a::metric_space" - apply (simp only: eventually_at_filter eventually_nhds_metric) - apply auto - apply (rule_tac x="d / 2" in exI) - apply auto + unfolding eventually_at_filter eventually_nhds_metric + apply safe + apply (rule_tac x="d / 2" in exI, auto) done lemma eventually_at_left_real: "a > (b :: real) \ eventually (\x. x \ {b<.. at_top" - apply (simp only: filterlim_at_top) - apply (intro allI) - apply (rule_tac c="nat \Z + 1\" in eventually_sequentiallyI) - apply linarith + apply (clarsimp simp: filterlim_at_top) + apply (rule_tac c="nat \Z + 1\" in eventually_sequentiallyI, linarith) done lemma filterlim_nat_sequentially: "filterlim nat sequentially at_top" - unfolding filterlim_at_top - apply (rule allI) - subgoal for Z by (auto intro!: eventually_at_top_linorderI[where c="int Z"]) - done +proof - + have "\\<^sub>F x in at_top. Z \ nat x" for Z + by (auto intro!: eventually_at_top_linorderI[where c="int Z"]) + then show ?thesis + unfolding filterlim_at_top .. +qed lemma filterlim_floor_sequentially: "filterlim floor at_top at_top" - unfolding filterlim_at_top - apply (rule allI) - subgoal for Z by (auto simp: le_floor_iff intro!: eventually_at_top_linorderI[where c="of_int Z"]) - done +proof - + have "\\<^sub>F x in at_top. Z \ \x\" for Z + by (auto simp: le_floor_iff intro!: eventually_at_top_linorderI[where c="of_int Z"]) + then show ?thesis + unfolding filterlim_at_top .. +qed lemma filterlim_sequentially_iff_filterlim_real: "filterlim f sequentially F \ filterlim (\x. real (f x)) at_top F" @@ -1847,22 +1776,22 @@ assumes f: "f \a\ l" and le: "\x. x \ a \ dist (g x) m \ dist (f x) l" shows "g \a\ m" - by (rule metric_tendsto_imp_tendsto [OF f]) (auto simp add: eventually_at_topological le) + by (rule metric_tendsto_imp_tendsto [OF f]) (auto simp: eventually_at_topological le) lemma metric_LIM_equal2: fixes a :: "'a::metric_space" - assumes "0 < R" + assumes "g \a\ l" "0 < R" and "\x. x \ a \ dist x a < R \ f x = g x" - shows "g \a\ l \ f \a\ l" - apply (rule topological_tendstoI) - apply (drule (2) topological_tendstoD) - apply (simp add: eventually_at) - apply safe - apply (rule_tac x="min d R" in exI) - apply safe - apply (simp add: assms(1)) - apply (simp add: assms(2)) - done + shows "f \a\ l" +proof - + have "\S. \open S; l \ S; \\<^sub>F x in at a. g x \ S\ \ \\<^sub>F x in at a. f x \ S" + apply (clarsimp simp add: eventually_at) + apply (rule_tac x="min d R" in exI) + apply (auto simp: assms) + done + then show ?thesis + using assms by (simp add: tendsto_def) +qed lemma metric_LIM_compose2: fixes a :: "'a::metric_space" @@ -1933,7 +1862,7 @@ lemma (in metric_space) Cauchy_altdef2: "Cauchy s \ (\e>0. \N::nat. \n\N. dist(s n)(s N) < e)" (is "?lhs = ?rhs") proof assume "Cauchy s" - then show ?rhs by (force simp add: Cauchy_def) + then show ?rhs by (force simp: Cauchy_def) next assume ?rhs { @@ -1971,19 +1900,8 @@ lemma (in metric_space) metric_Cauchy_iff2: "Cauchy X = (\j. (\M. \m \ M. \n \ M. dist (X m) (X n) < inverse(real (Suc j))))" - apply (simp add: Cauchy_def) - apply auto - apply (drule reals_Archimedean) - apply safe - apply (drule_tac x = n in spec) - apply auto - apply (rule_tac x = M in exI) - apply auto - apply (drule_tac x = m in spec) - apply simp - apply (drule_tac x = na in spec) - apply auto - done + apply (auto simp add: Cauchy_def) + by (metis less_trans of_nat_Suc reals_Archimedean) lemma Cauchy_iff2: "Cauchy X \ (\j. (\M. \m \ M. \n \ M. \X m - X n\ < inverse (real (Suc j))))" by (simp only: metric_Cauchy_iff2 dist_real_def) @@ -2092,12 +2010,12 @@ qed fact qed +text\apparently unused\ lemma (in metric_space) totally_bounded_metric: "totally_bounded S \ (\e>0. \k. finite k \ S \ (\x\k. {y. dist x y < e}))" - apply (simp only: totally_bounded_def eventually_uniformity_metric imp_ex) + unfolding totally_bounded_def eventually_uniformity_metric imp_ex apply (subst all_comm) - apply (intro arg_cong[where f=All] ext) - apply safe + apply (intro arg_cong[where f=All] ext, safe) subgoal for e apply (erule allE[of _ "\(x, y). dist x y < e"]) apply auto @@ -2125,7 +2043,7 @@ fixes u::"nat \ 'a::metric_space" assumes "Cauchy u" "strict_mono r" - "(u o r) \ l" + "(u \ r) \ l" shows "u \ l" proof - have *: "eventually (\n. dist (u n) l < e) sequentially" if "e > 0" for e @@ -2133,17 +2051,17 @@ have "e/2 > 0" using that by auto then obtain N1 where N1: "\m n. m \ N1 \ n \ N1 \ dist (u m) (u n) < e/2" using \Cauchy u\ unfolding Cauchy_def by blast - obtain N2 where N2: "\n. n \ N2 \ dist ((u o r) n) l < e / 2" - using order_tendstoD(2)[OF iffD1[OF tendsto_dist_iff \(u o r) \ l\] \e/2 > 0\] + obtain N2 where N2: "\n. n \ N2 \ dist ((u \ r) n) l < e / 2" + using order_tendstoD(2)[OF iffD1[OF tendsto_dist_iff \(u \ r) \ l\] \e/2 > 0\] unfolding eventually_sequentially by auto have "dist (u n) l < e" if "n \ max N1 N2" for n proof - - have "dist (u n) l \ dist (u n) ((u o r) n) + dist ((u o r) n) l" + have "dist (u n) l \ dist (u n) ((u \ r) n) + dist ((u \ r) n) l" by (rule dist_triangle) - also have "... < e/2 + e/2" + also have "\ < e/2 + e/2" apply (intro add_strict_mono) using N1[of n "r n"] N2[of n] that unfolding comp_def - by (auto simp add: less_imp_le) (meson assms(2) less_imp_le order.trans seq_suble) + by (auto simp: less_imp_le) (meson assms(2) less_imp_le order.trans seq_suble) finally show ?thesis by simp qed then show ?thesis unfolding eventually_sequentially by blast diff -r 90381a0f5474 -r 57b9d993cc98 src/HOL/Series.thy --- a/src/HOL/Series.thy Thu Jul 05 23:21:28 2018 +0200 +++ b/src/HOL/Series.thy Thu Jul 05 23:37:17 2018 +0100 @@ -28,7 +28,7 @@ text\Variants of the definition\ lemma sums_def': "f sums s \ (\n. \i = 0..n. f i) \ s" - apply (simp add: sums_def) + unfolding sums_def apply (subst LIMSEQ_Suc_iff [symmetric]) apply (simp only: lessThan_Suc_atMost atLeast0AtMost) done @@ -81,15 +81,9 @@ lemma sums_group: "f sums s \ 0 < k \ (\n. sum f {n * k ..< n * k + k}) sums s" apply (simp only: sums_def sum_nat_group tendsto_def eventually_sequentially) - apply safe - apply (erule_tac x=S in allE) - apply safe - apply (rule_tac x="N" in exI, safe) - apply (drule_tac x="n*k" in spec) - apply (erule mp) - apply (erule order_trans) - apply simp - done + apply (erule all_forward imp_forward exE| assumption)+ + apply (rule_tac x="N" in exI) + by (metis le_square mult.commute mult.left_neutral mult_le_cancel2 mult_le_mono) lemma suminf_cong: "(\n. f n = g n) \ suminf f = suminf g" by (rule arg_cong[of f g], rule ext) simp @@ -454,16 +448,7 @@ apply (drule summable_iff_convergent [THEN iffD1]) apply (drule convergent_Cauchy) apply (simp only: Cauchy_iff LIMSEQ_iff) - apply safe - apply (drule_tac x="r" in spec) - apply safe - apply (rule_tac x="M" in exI) - apply safe - apply (drule_tac x="Suc n" in spec) - apply simp - apply (drule_tac x="n" in spec) - apply simp - done + by (metis add.commute add_diff_cancel_right' diff_zero le_SucI sum_lessThan_Suc) lemma summable_imp_convergent: "summable f \ convergent f" by (force dest!: summable_LIMSEQ_zero simp: convergent_def) @@ -725,17 +710,9 @@ text \Absolute convergence imples normal convergence.\ lemma summable_norm_cancel: "summable (\n. norm (f n)) \ summable f" - apply (simp only: summable_Cauchy) - apply safe - apply (drule_tac x="e" in spec) - apply safe - apply (rule_tac x="N" in exI) - apply safe - apply (drule_tac x="m" in spec) - apply safe - apply (rule order_le_less_trans [OF norm_sum]) - apply (rule order_le_less_trans [OF abs_ge_self]) - apply simp + unfolding summable_Cauchy + apply (erule all_forward imp_forward ex_forward | assumption)+ + apply (fastforce simp add: order_le_less_trans [OF norm_sum] order_le_less_trans [OF abs_ge_self]) done lemma summable_norm: "summable (\n. norm (f n)) \ norm (suminf f) \ (\n. norm (f n))" @@ -834,16 +811,10 @@ shows "summable (\n. norm (a n) * r^n)" proof (rule summable_comparison_test') show "summable (\n. M * (r / r0) ^ n)" - using assms - by (auto simp add: summable_mult summable_geometric) + using assms by (auto simp add: summable_mult summable_geometric) show "norm (norm (a n) * r ^ n) \ M * (r / r0) ^ n" for n - using r r0 M [of n] - apply (auto simp add: abs_mult field_simps) - apply (cases "r = 0") - apply simp - apply (cases n) - apply auto - done + using r r0 M [of n] dual_order.order_iff_strict + by (fastforce simp add: abs_mult field_simps) qed diff -r 90381a0f5474 -r 57b9d993cc98 src/HOL/Transcendental.thy --- a/src/HOL/Transcendental.thy Thu Jul 05 23:21:28 2018 +0200 +++ b/src/HOL/Transcendental.thy Thu Jul 05 23:37:17 2018 +0100 @@ -626,38 +626,41 @@ fixes h :: "'a::field" assumes h: "h \ 0" shows "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) = - h * (\p< n - Suc 0. \q< n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))" + h * (\p< n - Suc 0. \q< n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))" (is "?lhs = ?rhs") - apply (subgoal_tac "h * ?lhs = h * ?rhs") - apply (simp add: h) - apply (simp add: right_diff_distrib diff_divide_distrib h) - apply (simp add: mult.assoc [symmetric]) - apply (cases n) - apply simp - apply (simp add: diff_power_eq_sum h right_diff_distrib [symmetric] mult.assoc - del: power_Suc sum_lessThan_Suc of_nat_Suc) - apply (subst lemma_realpow_rev_sumr) - apply (subst sumr_diff_mult_const2) - apply simp - apply (simp only: lemma_termdiff1 sum_distrib_left) - apply (rule sum.cong [OF refl]) - apply (simp add: less_iff_Suc_add) - apply clarify - apply (simp add: sum_distrib_left diff_power_eq_sum ac_simps - del: sum_lessThan_Suc power_Suc) - apply (subst mult.assoc [symmetric], subst power_add [symmetric]) - apply (simp add: ac_simps) - done +proof (cases n) + case (Suc n) + have 0: "\x k. (\njiijp::nat. p < n \ f p \ K" and K: "0 \ K" shows "sum f {.. of_nat n * K" - apply (rule order_trans [OF sum_mono]) - apply (rule f) - apply simp - apply (simp add: mult_right_mono K) + apply (rule order_trans [OF sum_mono [OF f]]) + apply (auto simp add: mult_right_mono K) done lemma lemma_termdiff3: @@ -775,9 +778,8 @@ also have "(\n. of_nat n * diffs (\n. norm (c n)) n * r ^ (n - Suc 0)) = (\n. diffs (\m. of_nat (m - Suc 0) * norm (c m) * inverse r) n * (r ^ n))" apply (rule ext) - apply (simp add: diffs_def) apply (case_tac n) - apply (simp_all add: r_neq_0) + apply (simp_all add: diffs_def r_neq_0) done finally have "summable (\n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))" @@ -874,12 +876,13 @@ apply (auto simp: norm_divide norm_mult norm_power field_simps) done have "summable (\n. (of_nat n * c n) * x ^ n)" - apply (rule summable_comparison_test' [of "\n. norm(c n * (of_real r) ^ n)" N]) - apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]]) - using N r norm_of_real [of "r + K", where 'a = 'a] - apply (auto simp add: norm_divide norm_mult norm_power field_simps) - apply (fastforce simp: less_eq_real_def) - done + proof (rule summable_comparison_test') + show "summable (\n. norm (c n * of_real r ^ n))" + apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]]) + using N r norm_of_real [of "r + K", where 'a = 'a] by auto + show "\n. N \ n \ norm (of_nat n * c n * x ^ n) \ norm (c n * of_real r ^ n)" + using N r by (fastforce simp add: norm_mult norm_power less_eq_real_def) + qed then have "summable (\n. (of_nat (Suc n) * c(Suc n)) * x ^ Suc n)" using summable_iff_shift [of "\n. of_nat n * c n * x ^ n" 1] by simp @@ -894,10 +897,7 @@ fixes x :: "'a::{real_normed_field,banach}" assumes "\x. summable (\n. c n * x^n)" shows "summable (\n. diffs c n * x^n)" - apply (rule termdiff_converges [where K = "1 + norm x"]) - using assms - apply auto - done + by (rule termdiff_converges [where K = "1 + norm x"]) (use assms in auto) lemma termdiffs_strong: fixes K x :: "'a::{real_normed_field,banach}" @@ -921,9 +921,9 @@ by (blast intro: sm termdiff_converges powser_inside) ultimately show ?thesis apply (rule termdiffs [where K = "of_real (norm x + norm K) / 2"]) + using K apply (auto simp: field_simps) - using K - apply (simp_all add: of_real_add [symmetric] del: of_real_add) + apply (simp flip: of_real_add) done qed