# HG changeset patch # User paulson # Date 1483546730 0 # Node ID 223b2ebdda791cbd506d31ec12bc644962e07426 # Parent 1ddc262514b8d5d6ccc8438fba175c340feec6bc Many new theorems, and more tidying diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Cauchy_Integral_Theorem.thy --- a/src/HOL/Analysis/Cauchy_Integral_Theorem.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Cauchy_Integral_Theorem.thy Wed Jan 04 16:18:50 2017 +0000 @@ -3271,165 +3271,6 @@ by (force simp: L contour_integral_integral) qed -subsection\Constancy of a function from a connected set into a finite, disconnected or discrete set\ - -text\Still missing: versions for a set that is smaller than R, or countable.\ - -lemma continuous_disconnected_range_constant: - assumes s: "connected s" - and conf: "continuous_on s f" - and fim: "f ` s \ t" - and cct: "\y. y \ t \ connected_component_set t y = {y}" - shows "\a. \x \ s. f x = a" -proof (cases "s = {}") - case True then show ?thesis by force -next - case False - { fix x assume "x \ s" - then have "f ` s \ {f x}" - by (metis connected_continuous_image conf connected_component_maximal fim image_subset_iff rev_image_eqI s cct) - } - with False show ?thesis - by blast -qed - -lemma discrete_subset_disconnected: - fixes s :: "'a::topological_space set" - fixes t :: "'b::real_normed_vector set" - assumes conf: "continuous_on s f" - and no: "\x. x \ s \ \e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x)" - shows "f ` s \ {y. connected_component_set (f ` s) y = {y}}" -proof - - { fix x assume x: "x \ s" - then obtain e where "e>0" and ele: "\y. \y \ s; f y \ f x\ \ e \ norm (f y - f x)" - using conf no [OF x] by auto - then have e2: "0 \ e / 2" - by simp - have "f y = f x" if "y \ s" and ccs: "f y \ connected_component_set (f ` s) (f x)" for y - apply (rule ccontr) - using connected_closed [of "connected_component_set (f ` s) (f x)"] \e>0\ - apply (simp add: del: ex_simps) - apply (drule spec [where x="cball (f x) (e / 2)"]) - apply (drule spec [where x="- ball(f x) e"]) - apply (auto simp: dist_norm open_closed [symmetric] simp del: le_divide_eq_numeral1 dest!: connected_component_in) - apply (metis diff_self e2 ele norm_minus_commute norm_zero not_less) - using centre_in_cball connected_component_refl_eq e2 x apply blast - using ccs - apply (force simp: cball_def dist_norm norm_minus_commute dest: ele [OF \y \ s\]) - done - moreover have "connected_component_set (f ` s) (f x) \ f ` s" - by (auto simp: connected_component_in) - ultimately have "connected_component_set (f ` s) (f x) = {f x}" - by (auto simp: x) - } - with assms show ?thesis - by blast -qed - -lemma finite_implies_discrete: - fixes s :: "'a::topological_space set" - assumes "finite (f ` s)" - shows "(\x \ s. \e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x))" -proof - - have "\e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x)" if "x \ s" for x - proof (cases "f ` s - {f x} = {}") - case True - with zero_less_numeral show ?thesis - by (fastforce simp add: Set.image_subset_iff cong: conj_cong) - next - case False - then obtain z where z: "z \ s" "f z \ f x" - by blast - have finn: "finite {norm (z - f x) |z. z \ f ` s - {f x}}" - using assms by simp - then have *: "0 < Inf{norm(z - f x) | z. z \ f ` s - {f x}}" - apply (rule finite_imp_less_Inf) - using z apply force+ - done - show ?thesis - by (force intro!: * cInf_le_finite [OF finn]) - qed - with assms show ?thesis - by blast -qed - -text\This proof requires the existence of two separate values of the range type.\ -lemma finite_range_constant_imp_connected: - assumes "\f::'a::topological_space \ 'b::real_normed_algebra_1. - \continuous_on s f; finite(f ` s)\ \ \a. \x \ s. f x = a" - shows "connected s" -proof - - { fix t u - assume clt: "closedin (subtopology euclidean s) t" - and clu: "closedin (subtopology euclidean s) u" - and tue: "t \ u = {}" and tus: "t \ u = s" - have conif: "continuous_on s (\x. if x \ t then 0 else 1)" - apply (subst tus [symmetric]) - apply (rule continuous_on_cases_local) - using clt clu tue - apply (auto simp: tus continuous_on_const) - done - have fi: "finite ((\x. if x \ t then 0 else 1) ` s)" - by (rule finite_subset [of _ "{0,1}"]) auto - have "t = {} \ u = {}" - using assms [OF conif fi] tus [symmetric] - by (auto simp: Ball_def) (metis IntI empty_iff one_neq_zero tue) - } - then show ?thesis - by (simp add: connected_closedin_eq) -qed - -lemma continuous_disconnected_range_constant_eq: - "(connected s \ - (\f::'a::topological_space \ 'b::real_normed_algebra_1. - \t. continuous_on s f \ f ` s \ t \ (\y \ t. connected_component_set t y = {y}) - \ (\a::'b. \x \ s. f x = a)))" (is ?thesis1) - and continuous_discrete_range_constant_eq: - "(connected s \ - (\f::'a::topological_space \ 'b::real_normed_algebra_1. - continuous_on s f \ - (\x \ s. \e. 0 < e \ (\y. y \ s \ (f y \ f x) \ e \ norm(f y - f x))) - \ (\a::'b. \x \ s. f x = a)))" (is ?thesis2) - and continuous_finite_range_constant_eq: - "(connected s \ - (\f::'a::topological_space \ 'b::real_normed_algebra_1. - continuous_on s f \ finite (f ` s) - \ (\a::'b. \x \ s. f x = a)))" (is ?thesis3) -proof - - have *: "\s t u v. \s \ t; t \ u; u \ v; v \ s\ - \ (s \ t) \ (s \ u) \ (s \ v)" - by blast - have "?thesis1 \ ?thesis2 \ ?thesis3" - apply (rule *) - using continuous_disconnected_range_constant apply metis - apply clarify - apply (frule discrete_subset_disconnected; blast) - apply (blast dest: finite_implies_discrete) - apply (blast intro!: finite_range_constant_imp_connected) - done - then show ?thesis1 ?thesis2 ?thesis3 - by blast+ -qed - -lemma continuous_discrete_range_constant: - fixes f :: "'a::topological_space \ 'b::real_normed_algebra_1" - assumes s: "connected s" - and "continuous_on s f" - and "\x. x \ s \ \e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x)" - shows "\a. \x \ s. f x = a" - using continuous_discrete_range_constant_eq [THEN iffD1, OF s] assms - by blast - -lemma continuous_finite_range_constant: - fixes f :: "'a::topological_space \ 'b::real_normed_algebra_1" - assumes "connected s" - and "continuous_on s f" - and "finite (f ` s)" - shows "\a. \x \ s. f x = a" - using assms continuous_finite_range_constant_eq - by blast - - text\We can treat even non-rectifiable paths as having a "length" for bounds on analytic functions in open sets.\ subsection\Winding Numbers\ diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Complex_Transcendental.thy --- a/src/HOL/Analysis/Complex_Transcendental.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Complex_Transcendental.thy Wed Jan 04 16:18:50 2017 +0000 @@ -6,6 +6,7 @@ imports Complex_Analysis_Basics Summation_Tests + "~~/src/HOL/Library/Periodic_Fun" begin (* TODO: Figure out what to do with Möbius transformations *) @@ -400,6 +401,89 @@ apply (simp add: real_sqrt_mult) done + +lemma complex_sin_eq: + fixes w :: complex + shows "sin w = sin z \ (\n \ \. w = z + of_real(2*n*pi) \ w = -z + of_real((2*n + 1)*pi))" + (is "?lhs = ?rhs") +proof + assume ?lhs + then have "sin w - sin z = 0" + by (auto simp: algebra_simps) + then have "sin ((w - z) / 2)*cos ((w + z) / 2) = 0" + by (auto simp: sin_diff_sin) + then consider "sin ((w - z) / 2) = 0" | "cos ((w + z) / 2) = 0" + using mult_eq_0_iff by blast + then show ?rhs + proof cases + case 1 + then show ?thesis + apply (auto simp: sin_eq_0 algebra_simps) + by (metis Ints_of_int of_real_of_int_eq) + next + case 2 + then show ?thesis + apply (auto simp: cos_eq_0 algebra_simps) + by (metis Ints_of_int of_real_of_int_eq) + qed +next + assume ?rhs + then obtain n::int where w: "w = z + of_real (2* of_int n*pi) \ + w = -z + of_real ((2* of_int n + 1)*pi)" + using Ints_cases by blast + then show ?lhs + using Periodic_Fun.sin.plus_of_int [of z n] + apply (auto simp: algebra_simps) + by (metis (no_types, hide_lams) add_diff_cancel_left add_diff_cancel_left' add_minus_cancel + mult.commute sin.plus_of_int sin_minus sin_plus_pi) +qed + +lemma complex_cos_eq: + fixes w :: complex + shows "cos w = cos z \ + (\n \ \. w = z + of_real(2*n*pi) \ w = -z + of_real(2*n*pi))" + (is "?lhs = ?rhs") +proof + assume ?lhs + then have "cos w - cos z = 0" + by (auto simp: algebra_simps) + then have "sin ((w + z) / 2) * sin ((z - w) / 2) = 0" + by (auto simp: cos_diff_cos) + then consider "sin ((w + z) / 2) = 0" | "sin ((z - w) / 2) = 0" + using mult_eq_0_iff by blast + then show ?rhs + proof cases + case 1 + then show ?thesis + apply (auto simp: sin_eq_0 algebra_simps) + by (metis Ints_of_int of_real_of_int_eq) + next + case 2 + then show ?thesis + apply (auto simp: sin_eq_0 algebra_simps) + by (metis Ints_of_int add_minus_cancel distrib_right mult_of_int_commute mult_zero_right of_int_0 of_int_add of_real_of_int_eq) + qed +next + assume ?rhs + then obtain n::int where w: "w = z + of_real (2* of_int n*pi) \ + w = -z + of_real(2*n*pi)" + using Ints_cases by (metis of_int_mult of_int_numeral) + then show ?lhs + using Periodic_Fun.cos.plus_of_int [of z n] + apply (auto simp: algebra_simps) + by (metis cos.plus_of_int cos_minus minus_add_cancel mult.commute) +qed + +lemma sin_eq: + "sin x = sin y \ (\n \ \. x = y + 2*n*pi \ x = -y + (2*n + 1)*pi)" + using complex_sin_eq [of x y] + by (simp only: sin_of_real Re_complex_of_real of_real_add [symmetric] of_real_minus [symmetric] of_real_mult [symmetric] of_real_eq_iff) + +lemma cos_eq: + "cos x = cos y \ (\n \ \. x = y + 2*n*pi \ x = -y + 2*n*pi)" + using complex_cos_eq [of x y] + by (simp only: cos_of_real Re_complex_of_real of_real_add [symmetric] of_real_minus [symmetric] of_real_mult [symmetric] of_real_eq_iff) + lemma sinh_complex: fixes z :: complex shows "(exp z - inverse (exp z)) / 2 = -\ * sin(\ * z)" @@ -2837,6 +2921,19 @@ lemma Re_Arccos_bound: "\Re(Arccos z)\ \ pi" by (meson Re_Arccos_bounds abs_le_iff less_eq_real_def minus_less_iff) +lemma Im_Arccos_bound: "\Im (Arccos w)\ \ cmod w" +proof - + have "(Im (Arccos w))\<^sup>2 \ (cmod (cos (Arccos w)))\<^sup>2 - (cos (Re (Arccos w)))\<^sup>2" + using norm_cos_squared [of "Arccos w"] real_le_abs_sinh [of "Im (Arccos w)"] + apply (simp only: abs_le_square_iff) + apply (simp add: divide_simps) + done + also have "... \ (cmod w)\<^sup>2" + by (auto simp: cmod_power2) + finally show ?thesis + using abs_le_square_iff by force +qed + lemma Re_Arcsin_bounds: "-pi < Re(Arcsin z) & Re(Arcsin z) \ pi" unfolding Re_Arcsin by (blast intro!: mpi_less_Im_Ln Im_Ln_le_pi Arcsin_body_lemma) @@ -2844,6 +2941,21 @@ lemma Re_Arcsin_bound: "\Re(Arcsin z)\ \ pi" by (meson Re_Arcsin_bounds abs_le_iff less_eq_real_def minus_less_iff) +lemma norm_Arccos_bounded: + fixes w :: complex + shows "norm (Arccos w) \ pi + norm w" +proof - + have Re: "(Re (Arccos w))\<^sup>2 \ pi\<^sup>2" "(Im (Arccos w))\<^sup>2 \ (cmod w)\<^sup>2" + using Re_Arccos_bound [of w] Im_Arccos_bound [of w] abs_le_square_iff by force+ + have "Arccos w \ Arccos w \ pi\<^sup>2 + (cmod w)\<^sup>2" + using Re by (simp add: dot_square_norm cmod_power2 [of "Arccos w"]) + then have "cmod (Arccos w) \ pi + cmod (cos (Arccos w))" + apply (simp add: norm_le_square) + by (metis dot_square_norm norm_ge_zero norm_le_square pi_ge_zero triangle_lemma) + then show "cmod (Arccos w) \ pi + cmod w" + by auto +qed + subsection\Interrelations between Arcsin and Arccos\ diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Analysis/Convex_Euclidean_Space.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Convex_Euclidean_Space.thy Wed Jan 04 16:18:50 2017 +0000 @@ -14,6 +14,20 @@ "~~/src/HOL/Library/Set_Algebras" begin +lemma swap_continuous: (*move to Topological_Spaces?*) + assumes "continuous_on (cbox (a,c) (b,d)) (\(x,y). f x y)" + shows "continuous_on (cbox (c,a) (d,b)) (\(x, y). f y x)" +proof - + have "(\(x, y). f y x) = (\(x, y). f x y) \ prod.swap" + by auto + then show ?thesis + apply (rule ssubst) + apply (rule continuous_on_compose) + apply (simp add: split_def) + apply (rule continuous_intros | simp add: assms)+ + done +qed + lemma dim_image_eq: fixes f :: "'n::euclidean_space \ 'm::euclidean_space" assumes lf: "linear f" @@ -4651,7 +4665,7 @@ ultimately show ?thesis by auto qed -lemma interior_atLeastAtMost_real: "interior {a..b} = {a<.. {..b}" by auto also have "interior ... = {a<..} \ {.. s" "b \ s" "a \ x" "x \ b" "x \ s" @@ -6630,6 +6647,10 @@ shows "is_interval s \ convex s" by (metis is_interval_convex convex_connected is_interval_connected_1) +lemma connected_compact_interval_1: + "connected S \ compact S \ (\a b. S = {a..b::real})" + by (auto simp: is_interval_connected_1 [symmetric] is_interval_compact) + lemma connected_convex_1: fixes s :: "real set" shows "connected s \ convex s" @@ -7315,6 +7336,12 @@ unfolding midpoint_def scaleR_2 [symmetric] by simp qed +lemma + fixes a::real + assumes "a \ b" shows ge_midpoint_1: "a \ midpoint a b" + and le_midpoint_1: "midpoint a b \ b" + by (simp_all add: midpoint_def assms) + lemma dist_midpoint: fixes a b :: "'a::real_normed_vector" shows "dist a (midpoint a b) = (dist a b) / 2" (is ?t1) @@ -7535,7 +7562,7 @@ proof - have "norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)" using \u \ 1\ by force - then show ?thesis + then show ?thesis by (simp add: dist_norm real_vector.scale_right_diff_distrib) qed also have "... \ dist a b" @@ -7639,6 +7666,19 @@ shows "a \ b \ a \ closed_segment (midpoint a b) b" by (auto simp: dist_midpoint dest!: dist_in_closed_segment) +lemma segment_to_closest_point: + fixes S :: "'a :: euclidean_space set" + shows "\closed S; S \ {}\ \ open_segment a (closest_point S a) \ S = {}" + apply (subst disjoint_iff_not_equal) + apply (clarify dest!: dist_in_open_segment) + by (metis closest_point_le dist_commute le_less_trans less_irrefl) + +lemma segment_to_point_exists: + fixes S :: "'a :: euclidean_space set" + assumes "closed S" "S \ {}" + obtains b where "b \ S" "open_segment a b \ S = {}" + by (metis assms segment_to_closest_point closest_point_exists that) + subsubsection\More lemmas, especially for working with the underlying formula\ lemma segment_eq_compose: @@ -8243,6 +8283,71 @@ finally show "(1 - u) *\<^sub>R a + u *\<^sub>R b \ interior S" . qed +lemma closure_open_Int_superset: + assumes "open S" "S \ closure T" + shows "closure(S \ T) = closure S" +proof - + have "closure S \ closure(S \ T)" + by (metis assms closed_closure closure_minimal inf.orderE open_Int_closure_subset) + then show ?thesis + by (simp add: closure_mono dual_order.antisym) +qed + +lemma convex_closure_interior: + fixes S :: "'a::euclidean_space set" + assumes "convex S" and int: "interior S \ {}" + shows "closure(interior S) = closure S" +proof - + obtain a where a: "a \ interior S" + using int by auto + have "closure S \ closure(interior S)" + proof + fix x + assume x: "x \ closure S" + show "x \ closure (interior S)" + proof (cases "x=a") + case True + then show ?thesis + using \a \ interior S\ closure_subset by blast + next + case False + show ?thesis + proof (clarsimp simp add: closure_def islimpt_approachable) + fix e::real + assume xnotS: "x \ interior S" and "0 < e" + show "\x'\interior S. x' \ x \ dist x' x < e" + proof (intro bexI conjI) + show "x - min (e/2 / norm (x - a)) 1 *\<^sub>R (x - a) \ x" + using False \0 < e\ by (auto simp: algebra_simps min_def) + show "dist (x - min (e/2 / norm (x - a)) 1 *\<^sub>R (x - a)) x < e" + using \0 < e\ by (auto simp: dist_norm min_def) + show "x - min (e/2 / norm (x - a)) 1 *\<^sub>R (x - a) \ interior S" + apply (clarsimp simp add: min_def a) + apply (rule mem_interior_closure_convex_shrink [OF \convex S\ a x]) + using \0 < e\ False apply (auto simp: divide_simps) + done + qed + qed + qed + qed + then show ?thesis + by (simp add: closure_mono interior_subset subset_antisym) +qed + +lemma closure_convex_Int_superset: + fixes S :: "'a::euclidean_space set" + assumes "convex S" "interior S \ {}" "interior S \ closure T" + shows "closure(S \ T) = closure S" +proof - + have "closure S \ closure(interior S)" + by (simp add: convex_closure_interior assms) + also have "... \ closure (S \ T)" + using interior_subset [of S] assms + by (metis (no_types, lifting) Int_assoc Int_lower2 closure_mono closure_open_Int_superset inf.orderE open_interior) + finally show ?thesis + by (simp add: closure_mono dual_order.antisym) +qed + subsection \Some obvious but surprisingly hard simplex lemmas\ @@ -14406,4 +14511,78 @@ using paracompact_closedin [of UNIV S \] assms by (auto simp: open_openin [symmetric] closed_closedin [symmetric]) + +subsection\Closed-graph characterization of continuity\ + +lemma continuous_closed_graph_gen: + fixes T :: "'b::real_normed_vector set" + assumes contf: "continuous_on S f" and fim: "f ` S \ T" + shows "closedin (subtopology euclidean (S \ T)) ((\x. Pair x (f x)) ` S)" +proof - + have eq: "((\x. Pair x (f x)) ` S) = {z. z \ S \ T \ (f \ fst)z - snd z \ {0}}" + using fim by auto + show ?thesis + apply (subst eq) + apply (intro continuous_intros continuous_closedin_preimage continuous_on_subset [OF contf]) + by auto +qed + +lemma continuous_closed_graph_eq: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "compact T" and fim: "f ` S \ T" + shows "continuous_on S f \ + closedin (subtopology euclidean (S \ T)) ((\x. Pair x (f x)) ` S)" + (is "?lhs = ?rhs") +proof - + have "?lhs" if ?rhs + proof (clarsimp simp add: continuous_on_closed_gen [OF fim]) + fix U + assume U: "closedin (subtopology euclidean T) U" + have eq: "{x. x \ S \ f x \ U} = fst ` (((\x. Pair x (f x)) ` S) \ (S \ U))" + by (force simp: image_iff) + show "closedin (subtopology euclidean S) {x \ S. f x \ U}" + by (simp add: U closedin_Int closedin_Times closed_map_fst [OF \compact T\] that eq) + qed + with continuous_closed_graph_gen assms show ?thesis by blast +qed + +lemma continuous_closed_graph: + fixes f :: "'a::topological_space \ 'b::real_normed_vector" + assumes "closed S" and contf: "continuous_on S f" + shows "closed ((\x. Pair x (f x)) ` S)" + apply (rule closedin_closed_trans) + apply (rule continuous_closed_graph_gen [OF contf subset_UNIV]) + by (simp add: \closed S\ closed_Times) + +lemma continuous_from_closed_graph: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "compact T" and fim: "f ` S \ T" and clo: "closed ((\x. Pair x (f x)) ` S)" + shows "continuous_on S f" + using fim clo + by (auto intro: closed_subset simp: continuous_closed_graph_eq [OF \compact T\ fim]) + +lemma continuous_on_Un_local_open: + assumes opS: "openin (subtopology euclidean (S \ T)) S" + and opT: "openin (subtopology euclidean (S \ T)) T" + and contf: "continuous_on S f" and contg: "continuous_on T f" + shows "continuous_on (S \ T) f" +using pasting_lemma [of "{S,T}" "S \ T" "\i. i" "\i. f" f] contf contg opS opT by blast + +lemma continuous_on_cases_local_open: + assumes opS: "openin (subtopology euclidean (S \ T)) S" + and opT: "openin (subtopology euclidean (S \ T)) T" + and contf: "continuous_on S f" and contg: "continuous_on T g" + and fg: "\x. x \ S \ ~P x \ x \ T \ P x \ f x = g x" + shows "continuous_on (S \ T) (\x. if P x then f x else g x)" +proof - + have "\x. x \ S \ (if P x then f x else g x) = f x" "\x. x \ T \ (if P x then f x else g x) = g x" + by (simp_all add: fg) + then have "continuous_on S (\x. if P x then f x else g x)" "continuous_on T (\x. if P x then f x else g x)" + by (simp_all add: contf contg cong: continuous_on_cong) + then show ?thesis + by (rule continuous_on_Un_local_open [OF opS opT]) +qed + + + end diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Euclidean_Space.thy --- a/src/HOL/Analysis/Euclidean_Space.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Euclidean_Space.thy Wed Jan 04 16:18:50 2017 +0000 @@ -53,6 +53,9 @@ lemma (in euclidean_space) SOME_Basis: "(SOME i. i \ Basis) \ Basis" by (metis ex_in_conv nonempty_Basis someI_ex) +lemma norm_some_Basis [simp]: "norm (SOME i. i \ Basis) = 1" + by (simp add: SOME_Basis) + lemma (in euclidean_space) inner_sum_left_Basis[simp]: "b \ Basis \ inner (\i\Basis. f i *\<^sub>R i) b = f b" by (simp add: inner_sum_left inner_Basis if_distrib comm_monoid_add_class.sum.If_cases) diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Henstock_Kurzweil_Integration.thy --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Wed Jan 04 16:18:50 2017 +0000 @@ -10,21 +10,6 @@ begin (* BEGIN MOVE *) -lemma swap_continuous: - assumes "continuous_on (cbox (a,c) (b,d)) (\(x,y). f x y)" - shows "continuous_on (cbox (c,a) (d,b)) (\(x, y). f y x)" -proof - - have "(\(x, y). f y x) = (\(x, y). f x y) \ prod.swap" - by auto - then show ?thesis - apply (rule ssubst) - apply (rule continuous_on_compose) - apply (simp add: split_def) - apply (rule continuous_intros | simp add: assms)+ - done -qed - - lemma norm_minus2: "norm (x1-x2, y1-y2) = norm (x2-x1, y2-y1)" by (simp add: norm_minus_eqI) @@ -44,10 +29,6 @@ lemma Sigma_Int_Paircomp2: "(Sigma A B) \ {(x, y). P y} = Sigma A (\z. B z \ {y. P y})" by blast - -lemma empty_as_interval: "{} = cbox One (0::'a::euclidean_space)" - using nonempty_Basis - by (fastforce simp add: set_eq_iff mem_box) (* END MOVE *) subsection \Content (length, area, volume...) of an interval.\ @@ -6191,7 +6172,6 @@ apply (rule le_less_trans[of _ "sum (\x. k / (real (card r) + 1)) r"]) unfolding sum_subtractf[symmetric] apply (rule sum_norm_le) - apply rule apply (drule qq) defer unfolding divide_inverse sum_distrib_right[symmetric] @@ -6536,7 +6516,7 @@ m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x))) < e / 2" apply (rule le_less_trans[of _ "sum (\i. e / 2^(i+2)) {0..s}"]) apply (rule sum_norm_le) - proof + proof - show "(\i = 0..s. e / 2 ^ (i + 2)) < e / 2" unfolding power_add divide_inverse inverse_mult_distrib unfolding sum_distrib_left[symmetric] sum_distrib_right[symmetric] diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Homeomorphism.thy --- a/src/HOL/Analysis/Homeomorphism.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Homeomorphism.thy Wed Jan 04 16:18:50 2017 +0000 @@ -1112,19 +1112,19 @@ lemma homeomorphic_convex_compact_lemma: - fixes s :: "'a::euclidean_space set" - assumes "convex s" - and "compact s" - and "cball 0 1 \ s" - shows "s homeomorphic (cball (0::'a) 1)" + fixes S :: "'a::euclidean_space set" + assumes "convex S" + and "compact S" + and "cball 0 1 \ S" + shows "S homeomorphic (cball (0::'a) 1)" proof (rule starlike_compact_projective_special[OF assms(2-3)]) fix x u - assume "x \ s" and "0 \ u" and "u < (1::real)" + assume "x \ S" and "0 \ u" and "u < (1::real)" have "open (ball (u *\<^sub>R x) (1 - u))" by (rule open_ball) moreover have "u *\<^sub>R x \ ball (u *\<^sub>R x) (1 - u)" unfolding centre_in_ball using \u < 1\ by simp - moreover have "ball (u *\<^sub>R x) (1 - u) \ s" + moreover have "ball (u *\<^sub>R x) (1 - u) \ S" proof fix y assume "y \ ball (u *\<^sub>R x) (1 - u)" @@ -1132,32 +1132,32 @@ unfolding mem_ball . with \u < 1\ have "inverse (1 - u) *\<^sub>R (y - u *\<^sub>R x) \ cball 0 1" by (simp add: dist_norm inverse_eq_divide norm_minus_commute) - with assms(3) have "inverse (1 - u) *\<^sub>R (y - u *\<^sub>R x) \ s" .. - with assms(1) have "(1 - u) *\<^sub>R ((y - u *\<^sub>R x) /\<^sub>R (1 - u)) + u *\<^sub>R x \ s" - using \x \ s\ \0 \ u\ \u < 1\ [THEN less_imp_le] by (rule convexD_alt) - then show "y \ s" using \u < 1\ + with assms(3) have "inverse (1 - u) *\<^sub>R (y - u *\<^sub>R x) \ S" .. + with assms(1) have "(1 - u) *\<^sub>R ((y - u *\<^sub>R x) /\<^sub>R (1 - u)) + u *\<^sub>R x \ S" + using \x \ S\ \0 \ u\ \u < 1\ [THEN less_imp_le] by (rule convexD_alt) + then show "y \ S" using \u < 1\ by simp qed - ultimately have "u *\<^sub>R x \ interior s" .. - then show "u *\<^sub>R x \ s - frontier s" + ultimately have "u *\<^sub>R x \ interior S" .. + then show "u *\<^sub>R x \ S - frontier S" using frontier_def and interior_subset by auto qed proposition homeomorphic_convex_compact_cball: fixes e :: real - and s :: "'a::euclidean_space set" - assumes "convex s" - and "compact s" - and "interior s \ {}" + and S :: "'a::euclidean_space set" + assumes "convex S" + and "compact S" + and "interior S \ {}" and "e > 0" - shows "s homeomorphic (cball (b::'a) e)" + shows "S homeomorphic (cball (b::'a) e)" proof - - obtain a where "a \ interior s" + obtain a where "a \ interior S" using assms(3) by auto - then obtain d where "d > 0" and d: "cball a d \ s" + then obtain d where "d > 0" and d: "cball a d \ S" unfolding mem_interior_cball by auto let ?d = "inverse d" and ?n = "0::'a" - have "cball ?n 1 \ (\x. inverse d *\<^sub>R (x - a)) ` s" + have "cball ?n 1 \ (\x. inverse d *\<^sub>R (x - a)) ` S" apply rule apply (rule_tac x="d *\<^sub>R x + a" in image_eqI) defer @@ -1166,25 +1166,25 @@ unfolding mem_cball dist_norm apply (auto simp add: mult_right_le_one_le) done - then have "(\x. inverse d *\<^sub>R (x - a)) ` s homeomorphic cball ?n 1" - using homeomorphic_convex_compact_lemma[of "(\x. ?d *\<^sub>R -a + ?d *\<^sub>R x) ` s", + then have "(\x. inverse d *\<^sub>R (x - a)) ` S homeomorphic cball ?n 1" + using homeomorphic_convex_compact_lemma[of "(\x. ?d *\<^sub>R -a + ?d *\<^sub>R x) ` S", OF convex_affinity compact_affinity] using assms(1,2) by (auto simp add: scaleR_right_diff_distrib) then show ?thesis apply (rule_tac homeomorphic_trans[OF _ homeomorphic_balls(2)[of 1 _ ?n]]) - apply (rule homeomorphic_trans[OF homeomorphic_affinity[of "?d" s "?d *\<^sub>R -a"]]) + apply (rule homeomorphic_trans[OF homeomorphic_affinity[of "?d" S "?d *\<^sub>R -a"]]) using \d>0\ \e>0\ apply (auto simp add: scaleR_right_diff_distrib) done qed corollary homeomorphic_convex_compact: - fixes s :: "'a::euclidean_space set" - and t :: "'a set" - assumes "convex s" "compact s" "interior s \ {}" - and "convex t" "compact t" "interior t \ {}" - shows "s homeomorphic t" + fixes S :: "'a::euclidean_space set" + and T :: "'a set" + assumes "convex S" "compact S" "interior S \ {}" + and "convex T" "compact T" "interior T \ {}" + shows "S homeomorphic T" using assms by (meson zero_less_one homeomorphic_trans homeomorphic_convex_compact_cball homeomorphic_sym) @@ -1193,31 +1193,31 @@ definition covering_space :: "'a::topological_space set \ ('a \ 'b) \ 'b::topological_space set \ bool" where - "covering_space c p s \ - continuous_on c p \ p ` c = s \ - (\x \ s. \t. x \ t \ openin (subtopology euclidean s) t \ - (\v. \v = {x. x \ c \ p x \ t} \ + "covering_space c p S \ + continuous_on c p \ p ` c = S \ + (\x \ S. \T. x \ T \ openin (subtopology euclidean S) T \ + (\v. \v = {x. x \ c \ p x \ T} \ (\u \ v. openin (subtopology euclidean c) u) \ pairwise disjnt v \ - (\u \ v. \q. homeomorphism u t p q)))" + (\u \ v. \q. homeomorphism u T p q)))" -lemma covering_space_imp_continuous: "covering_space c p s \ continuous_on c p" +lemma covering_space_imp_continuous: "covering_space c p S \ continuous_on c p" by (simp add: covering_space_def) -lemma covering_space_imp_surjective: "covering_space c p s \ p ` c = s" +lemma covering_space_imp_surjective: "covering_space c p S \ p ` c = S" by (simp add: covering_space_def) -lemma homeomorphism_imp_covering_space: "homeomorphism s t f g \ covering_space s f t" +lemma homeomorphism_imp_covering_space: "homeomorphism S T f g \ covering_space S f T" apply (simp add: homeomorphism_def covering_space_def, clarify) - apply (rule_tac x=t in exI, simp) - apply (rule_tac x="{s}" in exI, auto) + apply (rule_tac x=T in exI, simp) + apply (rule_tac x="{S}" in exI, auto) done lemma covering_space_local_homeomorphism: - assumes "covering_space c p s" "x \ c" - obtains t u q where "x \ t" "openin (subtopology euclidean c) t" - "p x \ u" "openin (subtopology euclidean s) u" - "homeomorphism t u p q" + assumes "covering_space c p S" "x \ c" + obtains T u q where "x \ T" "openin (subtopology euclidean c) T" + "p x \ u" "openin (subtopology euclidean S) u" + "homeomorphism T u p q" using assms apply (simp add: covering_space_def, clarify) apply (drule_tac x="p x" in bspec, force) @@ -1225,11 +1225,11 @@ lemma covering_space_local_homeomorphism_alt: - assumes p: "covering_space c p s" and "y \ s" - obtains x t u q where "p x = y" - "x \ t" "openin (subtopology euclidean c) t" - "y \ u" "openin (subtopology euclidean s) u" - "homeomorphism t u p q" + assumes p: "covering_space c p S" and "y \ S" + obtains x T u q where "p x = y" + "x \ T" "openin (subtopology euclidean c) T" + "y \ u" "openin (subtopology euclidean S) u" + "homeomorphism T u p q" proof - obtain x where "p x = y" "x \ c" using assms covering_space_imp_surjective by blast @@ -1239,50 +1239,50 @@ qed proposition covering_space_open_map: - fixes s :: "'a :: metric_space set" and t :: "'b :: metric_space set" - assumes p: "covering_space c p s" and t: "openin (subtopology euclidean c) t" - shows "openin (subtopology euclidean s) (p ` t)" + fixes S :: "'a :: metric_space set" and T :: "'b :: metric_space set" + assumes p: "covering_space c p S" and T: "openin (subtopology euclidean c) T" + shows "openin (subtopology euclidean S) (p ` T)" proof - - have pce: "p ` c = s" + have pce: "p ` c = S" and covs: - "\x. x \ s \ - \X VS. x \ X \ openin (subtopology euclidean s) X \ + "\x. x \ S \ + \X VS. x \ X \ openin (subtopology euclidean S) X \ \VS = {x. x \ c \ p x \ X} \ (\u \ VS. openin (subtopology euclidean c) u) \ pairwise disjnt VS \ (\u \ VS. \q. homeomorphism u X p q)" using p by (auto simp: covering_space_def) - have "t \ c" by (metis openin_euclidean_subtopology_iff t) - have "\T. openin (subtopology euclidean s) T \ y \ T \ T \ p ` t" - if "y \ p ` t" for y + have "T \ c" by (metis openin_euclidean_subtopology_iff T) + have "\X. openin (subtopology euclidean S) X \ y \ X \ X \ p ` T" + if "y \ p ` T" for y proof - - have "y \ s" using \t \ c\ pce that by blast - obtain U VS where "y \ U" and U: "openin (subtopology euclidean s) U" + have "y \ S" using \T \ c\ pce that by blast + obtain U VS where "y \ U" and U: "openin (subtopology euclidean S) U" and VS: "\VS = {x. x \ c \ p x \ U}" and openVS: "\V \ VS. openin (subtopology euclidean c) V" and homVS: "\V. V \ VS \ \q. homeomorphism V U p q" - using covs [OF \y \ s\] by auto - obtain x where "x \ c" "p x \ U" "x \ t" "p x = y" + using covs [OF \y \ S\] by auto + obtain x where "x \ c" "p x \ U" "x \ T" "p x = y" apply simp - using t [unfolded openin_euclidean_subtopology_iff] \y \ U\ \y \ p ` t\ by blast + using T [unfolded openin_euclidean_subtopology_iff] \y \ U\ \y \ p ` T\ by blast with VS obtain V where "x \ V" "V \ VS" by auto then obtain q where q: "homeomorphism V U p q" using homVS by blast - then have ptV: "p ` (t \ V) = U \ {z. q z \ (t \ V)}" + then have ptV: "p ` (T \ V) = U \ {z. q z \ (T \ V)}" using VS \V \ VS\ by (auto simp: homeomorphism_def) have ocv: "openin (subtopology euclidean c) V" by (simp add: \V \ VS\ openVS) - have "openin (subtopology euclidean U) {z \ U. q z \ t \ V}" + have "openin (subtopology euclidean U) {z \ U. q z \ T \ V}" apply (rule continuous_on_open [THEN iffD1, rule_format]) using homeomorphism_def q apply blast - using openin_subtopology_Int_subset [of c] q t unfolding homeomorphism_def + using openin_subtopology_Int_subset [of c] q T unfolding homeomorphism_def by (metis inf.absorb_iff2 Int_commute ocv openin_euclidean_subtopology_iff) - then have os: "openin (subtopology euclidean s) (U \ {z. q z \ t \ V})" + then have os: "openin (subtopology euclidean S) (U \ {z. q z \ T \ V})" using openin_trans [of U] by (simp add: Collect_conj_eq U) show ?thesis - apply (rule_tac x = "p ` (t \ V)" in exI) + apply (rule_tac x = "p ` (T \ V)" in exI) apply (rule conjI) apply (simp only: ptV os) - using \p x = y\ \x \ V\ \x \ t\ apply blast + using \p x = y\ \x \ V\ \x \ T\ apply blast done qed with openin_subopen show ?thesis by blast @@ -1291,73 +1291,73 @@ lemma covering_space_lift_unique_gen: fixes f :: "'a::topological_space \ 'b::topological_space" fixes g1 :: "'a \ 'c::real_normed_vector" - assumes cov: "covering_space c p s" + assumes cov: "covering_space c p S" and eq: "g1 a = g2 a" - and f: "continuous_on t f" "f ` t \ s" - and g1: "continuous_on t g1" "g1 ` t \ c" - and fg1: "\x. x \ t \ f x = p(g1 x)" - and g2: "continuous_on t g2" "g2 ` t \ c" - and fg2: "\x. x \ t \ f x = p(g2 x)" - and u_compt: "u \ components t" and "a \ u" "x \ u" + and f: "continuous_on T f" "f ` T \ S" + and g1: "continuous_on T g1" "g1 ` T \ c" + and fg1: "\x. x \ T \ f x = p(g1 x)" + and g2: "continuous_on T g2" "g2 ` T \ c" + and fg2: "\x. x \ T \ f x = p(g2 x)" + and u_compt: "U \ components T" and "a \ U" "x \ U" shows "g1 x = g2 x" proof - - have "u \ t" by (rule in_components_subset [OF u_compt]) - def G12 \ "{x \ u. g1 x - g2 x = 0}" - have "connected u" by (rule in_components_connected [OF u_compt]) - have contu: "continuous_on u g1" "continuous_on u g2" - using \u \ t\ continuous_on_subset g1 g2 by blast+ - have o12: "openin (subtopology euclidean u) G12" + have "U \ T" by (rule in_components_subset [OF u_compt]) + def G12 \ "{x \ U. g1 x - g2 x = 0}" + have "connected U" by (rule in_components_connected [OF u_compt]) + have contu: "continuous_on U g1" "continuous_on U g2" + using \U \ T\ continuous_on_subset g1 g2 by blast+ + have o12: "openin (subtopology euclidean U) G12" unfolding G12_def proof (subst openin_subopen, clarify) fix z - assume z: "z \ u" "g1 z - g2 z = 0" + assume z: "z \ U" "g1 z - g2 z = 0" obtain v w q where "g1 z \ v" and ocv: "openin (subtopology euclidean c) v" - and "p (g1 z) \ w" and osw: "openin (subtopology euclidean s) w" + and "p (g1 z) \ w" and osw: "openin (subtopology euclidean S) w" and hom: "homeomorphism v w p q" apply (rule_tac x = "g1 z" in covering_space_local_homeomorphism [OF cov]) - using \u \ t\ \z \ u\ g1(2) apply blast+ + using \U \ T\ \z \ U\ g1(2) apply blast+ done have "g2 z \ v" using \g1 z \ v\ z by auto - have gg: "{x \ u. g x \ v} = {x \ u. g x \ (v \ g ` u)}" for g + have gg: "{x \ U. g x \ v} = {x \ U. g x \ (v \ g ` U)}" for g by auto - have "openin (subtopology euclidean (g1 ` u)) (v \ g1 ` u)" - using ocv \u \ t\ g1 by (fastforce simp add: openin_open) - then have 1: "openin (subtopology euclidean u) {x \ u. g1 x \ v}" + have "openin (subtopology euclidean (g1 ` U)) (v \ g1 ` U)" + using ocv \U \ T\ g1 by (fastforce simp add: openin_open) + then have 1: "openin (subtopology euclidean U) {x \ U. g1 x \ v}" unfolding gg by (blast intro: contu continuous_on_open [THEN iffD1, rule_format]) - have "openin (subtopology euclidean (g2 ` u)) (v \ g2 ` u)" - using ocv \u \ t\ g2 by (fastforce simp add: openin_open) - then have 2: "openin (subtopology euclidean u) {x \ u. g2 x \ v}" + have "openin (subtopology euclidean (g2 ` U)) (v \ g2 ` U)" + using ocv \U \ T\ g2 by (fastforce simp add: openin_open) + then have 2: "openin (subtopology euclidean U) {x \ U. g2 x \ v}" unfolding gg by (blast intro: contu continuous_on_open [THEN iffD1, rule_format]) - show "\T. openin (subtopology euclidean u) T \ - z \ T \ T \ {z \ u. g1 z - g2 z = 0}" + show "\T. openin (subtopology euclidean U) T \ + z \ T \ T \ {z \ U. g1 z - g2 z = 0}" using z - apply (rule_tac x = "{x. x \ u \ g1 x \ v} \ {x. x \ u \ g2 x \ v}" in exI) + apply (rule_tac x = "{x. x \ U \ g1 x \ v} \ {x. x \ U \ g2 x \ v}" in exI) apply (intro conjI) apply (rule openin_Int [OF 1 2]) using \g1 z \ v\ \g2 z \ v\ apply (force simp:, clarify) - apply (metis \u \ t\ subsetD eq_iff_diff_eq_0 fg1 fg2 hom homeomorphism_def) + apply (metis \U \ T\ subsetD eq_iff_diff_eq_0 fg1 fg2 hom homeomorphism_def) done qed - have c12: "closedin (subtopology euclidean u) G12" + have c12: "closedin (subtopology euclidean U) G12" unfolding G12_def by (intro continuous_intros continuous_closedin_preimage_constant contu) - have "G12 = {} \ G12 = u" - by (intro connected_clopen [THEN iffD1, rule_format] \connected u\ conjI o12 c12) - with eq \a \ u\ have "\x. x \ u \ g1 x - g2 x = 0" by (auto simp: G12_def) + have "G12 = {} \ G12 = U" + by (intro connected_clopen [THEN iffD1, rule_format] \connected U\ conjI o12 c12) + with eq \a \ U\ have "\x. x \ U \ g1 x - g2 x = 0" by (auto simp: G12_def) then show ?thesis - using \x \ u\ by force + using \x \ U\ by force qed proposition covering_space_lift_unique: fixes f :: "'a::topological_space \ 'b::topological_space" fixes g1 :: "'a \ 'c::real_normed_vector" - assumes "covering_space c p s" + assumes "covering_space c p S" "g1 a = g2 a" - "continuous_on t f" "f ` t \ s" - "continuous_on t g1" "g1 ` t \ c" "\x. x \ t \ f x = p(g1 x)" - "continuous_on t g2" "g2 ` t \ c" "\x. x \ t \ f x = p(g2 x)" - "connected t" "a \ t" "x \ t" + "continuous_on T f" "f ` T \ S" + "continuous_on T g1" "g1 ` T \ c" "\x. x \ T \ f x = p(g1 x)" + "continuous_on T g2" "g2 ` T \ c" "\x. x \ T \ f x = p(g2 x)" + "connected T" "a \ T" "x \ T" shows "g1 x = g2 x" -using covering_space_lift_unique_gen [of c p s] in_components_self assms ex_in_conv by blast +using covering_space_lift_unique_gen [of c p S] in_components_self assms ex_in_conv by blast end diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Linear_Algebra.thy --- a/src/HOL/Analysis/Linear_Algebra.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Linear_Algebra.thy Wed Jan 04 16:18:50 2017 +0000 @@ -1482,14 +1482,14 @@ lemma sum_norm_le: fixes f :: "'a \ 'b::real_normed_vector" - assumes fg: "\x \ S. norm (f x) \ g x" + assumes fg: "\x. x \ S \ norm (f x) \ g x" shows "norm (sum f S) \ sum g S" by (rule order_trans [OF norm_sum sum_mono]) (simp add: fg) lemma sum_norm_bound: fixes f :: "'a \ 'b::real_normed_vector" - assumes K: "\x \ S. norm (f x) \ K" - shows "norm (sum f S) \ of_nat (card S) * K" + assumes K: "\x. x \ S \ norm (f x) \ K" + shows "norm (sum f S) \ of_nat (card S)*K" using sum_norm_le[OF K] sum_constant[symmetric] by simp @@ -1946,11 +1946,9 @@ also have "\ = norm (sum ?g Basis)" by (simp add: linear_sum [OF lf] linear_cmul [OF lf]) finally have th0: "norm (f x) = norm (sum ?g Basis)" . - have th: "\b\Basis. norm (?g b) \ norm (f b) * norm x" - proof - fix i :: 'a - assume i: "i \ Basis" - from Basis_le_norm[OF i, of x] + have th: "norm (?g i) \ norm (f i) * norm x" if "i \ Basis" for i + proof - + from Basis_le_norm[OF that, of x] show "norm (?g i) \ norm (f i) * norm x" unfolding norm_scaleR apply (subst mult.commute) @@ -2023,7 +2021,6 @@ show "norm (h x y) \ (\i\Basis. \j\Basis. norm (h i j)) * norm x * norm y" apply (auto simp add: sum_distrib_right th sum.cartesian_product) apply (rule sum_norm_le) - apply simp apply (auto simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] field_simps simp del: scaleR_scaleR) apply (rule mult_mono) diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Analysis/Topology_Euclidean_Space.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Analysis/Topology_Euclidean_Space.thy Wed Jan 04 16:18:50 2017 +0000 @@ -15,6 +15,23 @@ Norm_Arith begin +(* FIXME: move to HOL/Real_Vector_Spaces.thy *) + +lemma scaleR_2: + fixes x :: "'a::real_vector" + shows "scaleR 2 x = x + x" + unfolding one_add_one [symmetric] scaleR_left_distrib by simp + +lemma scaleR_half_double [simp]: + fixes a :: "'a::real_normed_vector" + shows "(1 / 2) *\<^sub>R (a + a) = a" +proof - + have "\r. r *\<^sub>R (a + a) = (r * 2) *\<^sub>R a" + by (metis scaleR_2 scaleR_scaleR) + then show ?thesis + by simp +qed + (* FIXME: move elsewhere *) @@ -1675,6 +1692,9 @@ lemma box01_nonempty [simp]: "box 0 One \ {}" by (simp add: box_ne_empty inner_Basis inner_sum_left) (simp add: sum.remove) +lemma empty_as_interval: "{} = cbox One (0::'a::euclidean_space)" + using nonempty_Basis box01_nonempty box_eq_empty(1) box_ne_empty(1) by blast + subsection \Connectedness\ @@ -4338,6 +4358,16 @@ using l unfolding islimpt_eq_acc_point by (rule acc_point_range_imp_convergent_subsequence) +lemma islimpt_eq_infinite_ball: "x islimpt S \ (\e>0. infinite(S \ ball x e))" + apply (simp add: islimpt_eq_acc_point, safe) + apply (metis Int_commute open_ball centre_in_ball) + by (metis open_contains_ball Int_mono finite_subset inf_commute subset_refl) + +lemma islimpt_eq_infinite_cball: "x islimpt S \ (\e>0. infinite(S \ cball x e))" + apply (simp add: islimpt_eq_infinite_ball, safe) + apply (meson Int_mono ball_subset_cball finite_subset order_refl) + by (metis open_ball centre_in_ball finite_Int inf.absorb_iff2 inf_assoc open_contains_cball_eq) + lemma sequence_unique_limpt: fixes f :: "nat \ 'a::t2_space" assumes "(f \ l) sequentially" @@ -4475,6 +4505,7 @@ \ openin (subtopology euclidean u) (s - {a})" by (metis Int_Diff open_delete openin_open) + text\Compactness expressed with filters\ lemma closure_iff_nhds_not_empty: @@ -5032,6 +5063,7 @@ "\t. infinite t \ t \ s \ (\x \ s. x islimpt t) \ bounded s" using compact_imp_bounded unfolding compact_eq_bolzano_weierstrass . + subsection \Metric spaces with the Heine-Borel property\ text \ @@ -5254,6 +5286,84 @@ show "\l r. subseq r \ ((f \ r) \ l) sequentially" using l r by fast qed + +subsubsection \Intersecting chains of compact sets\ + +proposition bounded_closed_chain: + fixes \ :: "'a::heine_borel set set" + assumes "B \ \" "bounded B" and \: "\S. S \ \ \ closed S" and "{} \ \" + and chain: "\S T. S \ \ \ T \ \ \ S \ T \ T \ S" + shows "\\ \ {}" +proof - + have "B \ \\ \ {}" + proof (rule compact_imp_fip) + show "compact B" "\T. T \ \ \ closed T" + by (simp_all add: assms compact_eq_bounded_closed) + show "\finite \; \ \ \\ \ B \ \\ \ {}" for \ + proof (induction \ rule: finite_induct) + case empty + with assms show ?case by force + next + case (insert U \) + then have "U \ \" and ne: "B \ \\ \ {}" by auto + then consider "B \ U" | "U \ B" + using \B \ \\ chain by blast + then show ?case + proof cases + case 1 + then show ?thesis + using Int_left_commute ne by auto + next + case 2 + have "U \ {}" + using \U \ \\ \{} \ \\ by blast + moreover + have False if "\x. x \ U \ \Y\\. x \ Y" + proof - + have "\x. x \ U \ \Y\\. Y \ U" + by (metis chain contra_subsetD insert.prems insert_subset that) + then obtain Y where "Y \ \" "Y \ U" + by (metis all_not_in_conv \U \ {}\) + moreover obtain x where "x \ \\" + by (metis Int_emptyI ne) + ultimately show ?thesis + by (metis Inf_lower subset_eq that) + qed + with 2 show ?thesis + by blast + qed + qed + qed + then show ?thesis by blast +qed + +corollary compact_chain: + fixes \ :: "'a::heine_borel set set" + assumes "\S. S \ \ \ compact S" "{} \ \" + "\S T. S \ \ \ T \ \ \ S \ T \ T \ S" + shows "\ \ \ {}" +proof (cases "\ = {}") + case True + then show ?thesis by auto +next + case False + show ?thesis + by (metis False all_not_in_conv assms compact_imp_bounded compact_imp_closed bounded_closed_chain) +qed + +lemma compact_nest: + fixes F :: "'a::linorder \ 'b::heine_borel set" + assumes F: "\n. compact(F n)" "\n. F n \ {}" and mono: "\m n. m \ n \ F n \ F m" + shows "\range F \ {}" +proof - + have *: "\S T. S \ range F \ T \ range F \ S \ T \ T \ S" + by (metis mono image_iff le_cases) + show ?thesis + apply (rule compact_chain [OF _ _ *]) + using F apply (blast intro: dest: *)+ + done +qed + subsubsection \Completeness\ @@ -7446,7 +7556,7 @@ qed -subsection \Topological stuff lifted from and dropped to R\ +subsection \Topological stuff about the set of Reals\ lemma open_real: fixes s :: "real set" @@ -7697,11 +7807,17 @@ using continuous_attains_sup[of "s \ s" "\x. dist (fst x) (snd x)"] by auto qed -text \We can state this in terms of diameter of a set.\ +subsection \The diameter of a set.\ definition diameter :: "'a::metric_space set \ real" where "diameter S = (if S = {} then 0 else SUP (x,y):S\S. dist x y)" +lemma diameter_empty [simp]: "diameter{} = 0" + by (auto simp: diameter_def) + +lemma diameter_singleton [simp]: "diameter{x} = 0" + by (auto simp: diameter_def) + lemma diameter_le: assumes "S \ {} \ 0 \ d" and no: "\x y. \x \ S; y \ S\ \ norm(x - y) \ d" @@ -7772,7 +7888,180 @@ by (metis b diameter_bounded_bound order_antisym xys) qed -text \Related results with closure as the conclusion.\ +lemma diameter_ge_0: + assumes "bounded S" shows "0 \ diameter S" + by (metis all_not_in_conv assms diameter_bounded_bound diameter_empty dist_self order_refl) + +lemma diameter_subset: + assumes "S \ T" "bounded T" + shows "diameter S \ diameter T" +proof (cases "S = {} \ T = {}") + case True + with assms show ?thesis + by (force simp: diameter_ge_0) +next + case False + then have "bdd_above ((\x. case x of (x, xa) \ dist x xa) ` (T \ T))" + using \bounded T\ diameter_bounded_bound by (force simp: bdd_above_def) + with False \S \ T\ show ?thesis + apply (simp add: diameter_def) + apply (rule cSUP_subset_mono, auto) + done +qed + +lemma diameter_closure: + assumes "bounded S" + shows "diameter(closure S) = diameter S" +proof (rule order_antisym) + have "False" if "diameter S < diameter (closure S)" + proof - + define d where "d = diameter(closure S) - diameter(S)" + have "d > 0" + using that by (simp add: d_def) + then have "diameter(closure(S)) - d / 2 < diameter(closure(S))" + by simp + have dd: "diameter (closure S) - d / 2 = (diameter(closure(S)) + diameter(S)) / 2" + by (simp add: d_def divide_simps) + have bocl: "bounded (closure S)" + using assms by blast + moreover have "0 \ diameter S" + using assms diameter_ge_0 by blast + ultimately obtain x y where "x \ closure S" "y \ closure S" and xy: "diameter(closure(S)) - d / 2 < dist x y" + using diameter_bounded(2) [OF bocl, rule_format, of "diameter(closure(S)) - d / 2"] \d > 0\ d_def by auto + then obtain x' y' where x'y': "x' \ S" "dist x' x < d/4" "y' \ S" "dist y' y < d/4" + using closure_approachable + by (metis \0 < d\ zero_less_divide_iff zero_less_numeral) + then have "dist x' y' \ diameter S" + using assms diameter_bounded_bound by blast + with x'y' have "dist x y \ d / 4 + diameter S + d / 4" + by (meson add_mono_thms_linordered_semiring(1) dist_triangle dist_triangle3 less_eq_real_def order_trans) + then show ?thesis + using xy d_def by linarith + qed + then show "diameter (closure S) \ diameter S" + by fastforce + next + show "diameter S \ diameter (closure S)" + by (simp add: assms bounded_closure closure_subset diameter_subset) +qed + +lemma diameter_cball [simp]: + fixes a :: "'a::euclidean_space" + shows "diameter(cball a r) = (if r < 0 then 0 else 2*r)" +proof - + have "diameter(cball a r) = 2*r" if "r \ 0" + proof (rule order_antisym) + show "diameter (cball a r) \ 2*r" + proof (rule diameter_le) + fix x y assume "x \ cball a r" "y \ cball a r" + then have "norm (x - a) \ r" "norm (a - y) \ r" + by (auto simp: dist_norm norm_minus_commute) + then have "norm (x - y) \ r+r" + using norm_diff_triangle_le by blast + then show "norm (x - y) \ 2*r" by simp + qed (simp add: that) + have "2*r = dist (a + r *\<^sub>R (SOME i. i \ Basis)) (a - r *\<^sub>R (SOME i. i \ Basis))" + apply (simp add: dist_norm) + by (metis abs_of_nonneg mult.right_neutral norm_numeral norm_scaleR norm_some_Basis real_norm_def scaleR_2 that) + also have "... \ diameter (cball a r)" + apply (rule diameter_bounded_bound) + using that by (auto simp: dist_norm) + finally show "2*r \ diameter (cball a r)" . + qed + then show ?thesis by simp +qed + +lemma diameter_ball [simp]: + fixes a :: "'a::euclidean_space" + shows "diameter(ball a r) = (if r < 0 then 0 else 2*r)" +proof - + have "diameter(ball a r) = 2*r" if "r > 0" + by (metis bounded_ball diameter_closure closure_ball diameter_cball less_eq_real_def linorder_not_less that) + then show ?thesis + by (simp add: diameter_def) +qed + +lemma diameter_closed_interval [simp]: "diameter {a..b} = (if b < a then 0 else b-a)" +proof - + have "{a .. b} = cball ((a+b)/2) ((b-a)/2)" + by (auto simp: dist_norm abs_if divide_simps split: if_split_asm) + then show ?thesis + by simp +qed + +lemma diameter_open_interval [simp]: "diameter {a<.. \ {}" "S \ \\" and ope: "\B. B \ \ \ open B" + obtains \ where "0 < \" "\T. \T \ S; diameter T < \\ \ \B \ \. T \ B" +proof (cases "S = {}") + case True + then show ?thesis + by (metis \\ \ {}\ zero_less_one empty_subsetI equals0I subset_trans that) +next + case False + { fix x assume "x \ S" + then obtain C where C: "x \ C" "C \ \" + using \S \ \\\ by blast + then obtain r where r: "r>0" "ball x (2*r) \ C" + by (metis mult.commute mult_2_right not_le ope openE real_sum_of_halves zero_le_numeral zero_less_mult_iff) + then have "\r C. r > 0 \ ball x (2*r) \ C \ C \ \" + using C by blast + } + then obtain r where r: "\x. x \ S \ r x > 0 \ (\C \ \. ball x (2*r x) \ C)" + by metis + then have "S \ (\x \ S. ball x (r x))" + by auto + then obtain \ where "finite \" "S \ \\" and \: "\ \ (\x. ball x (r x)) ` S" + by (rule compactE [OF \compact S\]) auto + then obtain S0 where "S0 \ S" "finite S0" and S0: "\ = (\x. ball x (r x)) ` S0" + by (meson finite_subset_image) + then have "S0 \ {}" + using False \S \ \\\ by auto + define \ where "\ = Inf (r ` S0)" + have "\ > 0" + using \finite S0\ \S0 \ S\ \S0 \ {}\ r by (auto simp: \_def finite_less_Inf_iff) + show ?thesis + proof + show "0 < \" + by (simp add: \0 < \\) + show "\B \ \. T \ B" if "T \ S" and dia: "diameter T < \" for T + proof (cases "T = {}") + case True + then show ?thesis + using \\ \ {}\ by blast + next + case False + then obtain y where "y \ T" by blast + then have "y \ S" + using \T \ S\ by auto + then obtain x where "x \ S0" and x: "y \ ball x (r x)" + using \S \ \\\ S0 that by blast + have "ball y \ \ ball y (r x)" + by (metis \_def \S0 \ {}\ \finite S0\ \x \ S0\ empty_is_image finite_imageI finite_less_Inf_iff imageI less_irrefl not_le subset_ball) + also have "... \ ball x (2*r x)" + by clarsimp (metis dist_commute dist_triangle_less_add mem_ball mult_2 x) + finally obtain C where "C \ \" "ball y \ \ C" + by (meson r \S0 \ S\ \x \ S0\ dual_order.trans subsetCE) + have "bounded T" + using \compact S\ bounded_subset compact_imp_bounded \T \ S\ by blast + then have "T \ ball y \" + using \y \ T\ dia diameter_bounded_bound by fastforce + then show ?thesis + apply (rule_tac x=C in bexI) + using \ball y \ \ C\ \C \ \\ by auto + qed + qed +qed + + +subsection \Compact sets and the closure operation.\ lemma closed_scaling: fixes s :: "'a::real_normed_vector set" @@ -8396,6 +8685,63 @@ using bounded_closed_imp_seq_compact[of "cbox a b"] using bounded_cbox[of a b] by (auto simp: compact_eq_seq_compact_metric) +proposition is_interval_compact: + "is_interval S \ compact S \ (\a b. S = cbox a b)" (is "?lhs = ?rhs") +proof (cases "S = {}") + case True + with empty_as_interval show ?thesis by auto +next + case False + show ?thesis + proof + assume L: ?lhs + then have "is_interval S" "compact S" by auto + define a where "a \ \i\Basis. (INF x:S. x \ i) *\<^sub>R i" + define b where "b \ \i\Basis. (SUP x:S. x \ i) *\<^sub>R i" + have 1: "\x i. \x \ S; i \ Basis\ \ (INF x:S. x \ i) \ x \ i" + by (simp add: cInf_lower bounded_inner_imp_bdd_below compact_imp_bounded L) + have 2: "\x i. \x \ S; i \ Basis\ \ x \ i \ (SUP x:S. x \ i)" + by (simp add: cSup_upper bounded_inner_imp_bdd_above compact_imp_bounded L) + have 3: "x \ S" if inf: "\i. i \ Basis \ (INF x:S. x \ i) \ x \ i" + and sup: "\i. i \ Basis \ x \ i \ (SUP x:S. x \ i)" for x + proof (rule mem_box_componentwiseI [OF \is_interval S\]) + fix i::'a + assume i: "i \ Basis" + have cont: "continuous_on S (\x. x \ i)" + by (intro continuous_intros) + obtain a where "a \ S" and a: "\y. y\S \ a \ i \ y \ i" + using continuous_attains_inf [OF \compact S\ False cont] by blast + obtain b where "b \ S" and b: "\y. y\S \ y \ i \ b \ i" + using continuous_attains_sup [OF \compact S\ False cont] by blast + have "a \ i \ (INF x:S. x \ i)" + by (simp add: False a cINF_greatest) + also have "\ \ x \ i" + by (simp add: i inf) + finally have ai: "a \ i \ x \ i" . + have "x \ i \ (SUP x:S. x \ i)" + by (simp add: i sup) + also have "(SUP x:S. x \ i) \ b \ i" + by (simp add: False b cSUP_least) + finally have bi: "x \ i \ b \ i" . + show "x \ i \ (\x. x \ i) ` S" + apply (rule_tac x="\j\Basis. (if j = i then x \ i else a \ j) *\<^sub>R j" in image_eqI) + apply (simp add: i) + apply (rule mem_is_intervalI [OF \is_interval S\ \a \ S\ \b \ S\]) + using i ai bi apply force + done + qed + have "S = cbox a b" + by (auto simp: a_def b_def mem_box intro: 1 2 3) + then show ?rhs + by blast + next + assume R: ?rhs + then show ?lhs + using compact_cbox is_interval_cbox by blast + qed +qed + + lemma box_midpoint: fixes a :: "'a::euclidean_space" assumes "box a b \ {}" @@ -9959,6 +10305,20 @@ compact T \ T \ S)" by (metis closedin_imp_subset closedin_compact closed_subset compact_imp_closed) +lemma continuous_imp_closed_map: + fixes f :: "'a::metric_space \ 'b::metric_space" + assumes "closedin (subtopology euclidean S) U" + "continuous_on S f" "image f S = T" "compact S" + shows "closedin (subtopology euclidean T) (image f U)" + by (metis assms closedin_compact_eq compact_continuous_image continuous_on_subset subset_image_iff) + +lemma continuous_imp_quotient_map: + fixes f :: "'a::metric_space \ 'b::metric_space" + assumes "continuous_on S f" "image f S = T" "compact S" "U \ T" + shows "openin (subtopology euclidean S) {x. x \ S \ f x \ U} \ + openin (subtopology euclidean T) U" + by (metis (no_types, lifting) Collect_cong assms closed_map_imp_quotient_map continuous_imp_closed_map) + subsection\ Finite intersection property\ text\Also developed in HOL's toplogical spaces theory, but the Heine-Borel type class isn't available there.\ @@ -10305,6 +10665,166 @@ qed from X0(1,2) this show ?thesis .. qed + + +subsection\Constancy of a function from a connected set into a finite, disconnected or discrete set\ + +text\Still missing: versions for a set that is smaller than R, or countable.\ + +lemma continuous_disconnected_range_constant: + assumes s: "connected s" + and conf: "continuous_on s f" + and fim: "f ` s \ t" + and cct: "\y. y \ t \ connected_component_set t y = {y}" + shows "\a. \x \ s. f x = a" +proof (cases "s = {}") + case True then show ?thesis by force +next + case False + { fix x assume "x \ s" + then have "f ` s \ {f x}" + by (metis connected_continuous_image conf connected_component_maximal fim image_subset_iff rev_image_eqI s cct) + } + with False show ?thesis + by blast +qed + +lemma discrete_subset_disconnected: + fixes s :: "'a::topological_space set" + fixes t :: "'b::real_normed_vector set" + assumes conf: "continuous_on s f" + and no: "\x. x \ s \ \e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x)" + shows "f ` s \ {y. connected_component_set (f ` s) y = {y}}" +proof - + { fix x assume x: "x \ s" + then obtain e where "e>0" and ele: "\y. \y \ s; f y \ f x\ \ e \ norm (f y - f x)" + using conf no [OF x] by auto + then have e2: "0 \ e / 2" + by simp + have "f y = f x" if "y \ s" and ccs: "f y \ connected_component_set (f ` s) (f x)" for y + apply (rule ccontr) + using connected_closed [of "connected_component_set (f ` s) (f x)"] \e>0\ + apply (simp add: del: ex_simps) + apply (drule spec [where x="cball (f x) (e / 2)"]) + apply (drule spec [where x="- ball(f x) e"]) + apply (auto simp: dist_norm open_closed [symmetric] simp del: le_divide_eq_numeral1 dest!: connected_component_in) + apply (metis diff_self e2 ele norm_minus_commute norm_zero not_less) + using centre_in_cball connected_component_refl_eq e2 x apply blast + using ccs + apply (force simp: cball_def dist_norm norm_minus_commute dest: ele [OF \y \ s\]) + done + moreover have "connected_component_set (f ` s) (f x) \ f ` s" + by (auto simp: connected_component_in) + ultimately have "connected_component_set (f ` s) (f x) = {f x}" + by (auto simp: x) + } + with assms show ?thesis + by blast +qed + +lemma finite_implies_discrete: + fixes s :: "'a::topological_space set" + assumes "finite (f ` s)" + shows "(\x \ s. \e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x))" +proof - + have "\e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x)" if "x \ s" for x + proof (cases "f ` s - {f x} = {}") + case True + with zero_less_numeral show ?thesis + by (fastforce simp add: Set.image_subset_iff cong: conj_cong) + next + case False + then obtain z where z: "z \ s" "f z \ f x" + by blast + have finn: "finite {norm (z - f x) |z. z \ f ` s - {f x}}" + using assms by simp + then have *: "0 < Inf{norm(z - f x) | z. z \ f ` s - {f x}}" + apply (rule finite_imp_less_Inf) + using z apply force+ + done + show ?thesis + by (force intro!: * cInf_le_finite [OF finn]) + qed + with assms show ?thesis + by blast +qed + +text\This proof requires the existence of two separate values of the range type.\ +lemma finite_range_constant_imp_connected: + assumes "\f::'a::topological_space \ 'b::real_normed_algebra_1. + \continuous_on s f; finite(f ` s)\ \ \a. \x \ s. f x = a" + shows "connected s" +proof - + { fix t u + assume clt: "closedin (subtopology euclidean s) t" + and clu: "closedin (subtopology euclidean s) u" + and tue: "t \ u = {}" and tus: "t \ u = s" + have conif: "continuous_on s (\x. if x \ t then 0 else 1)" + apply (subst tus [symmetric]) + apply (rule continuous_on_cases_local) + using clt clu tue + apply (auto simp: tus continuous_on_const) + done + have fi: "finite ((\x. if x \ t then 0 else 1) ` s)" + by (rule finite_subset [of _ "{0,1}"]) auto + have "t = {} \ u = {}" + using assms [OF conif fi] tus [symmetric] + by (auto simp: Ball_def) (metis IntI empty_iff one_neq_zero tue) + } + then show ?thesis + by (simp add: connected_closedin_eq) +qed + +lemma continuous_disconnected_range_constant_eq: + "(connected s \ + (\f::'a::topological_space \ 'b::real_normed_algebra_1. + \t. continuous_on s f \ f ` s \ t \ (\y \ t. connected_component_set t y = {y}) + \ (\a::'b. \x \ s. f x = a)))" (is ?thesis1) + and continuous_discrete_range_constant_eq: + "(connected s \ + (\f::'a::topological_space \ 'b::real_normed_algebra_1. + continuous_on s f \ + (\x \ s. \e. 0 < e \ (\y. y \ s \ (f y \ f x) \ e \ norm(f y - f x))) + \ (\a::'b. \x \ s. f x = a)))" (is ?thesis2) + and continuous_finite_range_constant_eq: + "(connected s \ + (\f::'a::topological_space \ 'b::real_normed_algebra_1. + continuous_on s f \ finite (f ` s) + \ (\a::'b. \x \ s. f x = a)))" (is ?thesis3) +proof - + have *: "\s t u v. \s \ t; t \ u; u \ v; v \ s\ + \ (s \ t) \ (s \ u) \ (s \ v)" + by blast + have "?thesis1 \ ?thesis2 \ ?thesis3" + apply (rule *) + using continuous_disconnected_range_constant apply metis + apply clarify + apply (frule discrete_subset_disconnected; blast) + apply (blast dest: finite_implies_discrete) + apply (blast intro!: finite_range_constant_imp_connected) + done + then show ?thesis1 ?thesis2 ?thesis3 + by blast+ +qed + +lemma continuous_discrete_range_constant: + fixes f :: "'a::topological_space \ 'b::real_normed_algebra_1" + assumes s: "connected s" + and "continuous_on s f" + and "\x. x \ s \ \e>0. \y. y \ s \ f y \ f x \ e \ norm (f y - f x)" + shows "\a. \x \ s. f x = a" + using continuous_discrete_range_constant_eq [THEN iffD1, OF s] assms + by blast + +lemma continuous_finite_range_constant: + fixes f :: "'a::topological_space \ 'b::real_normed_algebra_1" + assumes "connected s" + and "continuous_on s f" + and "finite (f ` s)" + shows "\a. \x \ s. f x = a" + using assms continuous_finite_range_constant_eq + by blast + no_notation eucl_less (infix " continuous F (\x. Re (f x)) \ continuous F (\x. Im (f x))" by (simp only: continuous_def tendsto_complex_iff) +lemma continuous_on_of_real_o_iff [simp]: + "continuous_on S (\x. complex_of_real (g x)) = continuous_on S g" + using continuous_on_Re continuous_on_of_real by fastforce + +lemma continuous_on_of_real_id [simp]: + "continuous_on S (of_real :: real \ 'a::real_normed_algebra_1)" + by (rule continuous_on_of_real [OF continuous_on_id]) + lemma has_vector_derivative_complex_iff: "(f has_vector_derivative x) F \ ((\x. Re (f x)) has_field_derivative (Re x)) F \ ((\x. Im (f x)) has_field_derivative (Im x)) F" diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Number_Theory/Primes.thy --- a/src/HOL/Number_Theory/Primes.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Number_Theory/Primes.thy Wed Jan 04 16:18:50 2017 +0000 @@ -194,6 +194,64 @@ using assms irreducible_altdef[of m] by (auto simp: prime_elem_iff_irreducible prime_def irreducible_altdef) + +subsection\Largest exponent of a prime factor\ +text\Possibly duplicates other material, but avoid the complexities of multisets.\ + +lemma prime_power_cancel_less: + assumes "prime p" and eq: "m * (p ^ k) = m' * (p ^ k')" and less: "k < k'" and "\ p dvd m" + shows False +proof - + obtain l where l: "k' = k + l" and "l > 0" + using less less_imp_add_positive by auto + have "m = m * (p ^ k) div (p ^ k)" + using \prime p\ by simp + also have "\ = m' * (p ^ k') div (p ^ k)" + using eq by simp + also have "\ = m' * (p ^ l) * (p ^ k) div (p ^ k)" + by (simp add: l mult.commute mult.left_commute power_add) + also have "... = m' * (p ^ l)" + using \prime p\ by simp + finally have "p dvd m" + using \l > 0\ by simp + with assms show False + by simp +qed + +lemma prime_power_cancel: + assumes "prime p" and eq: "m * (p ^ k) = m' * (p ^ k')" and "\ p dvd m" "\ p dvd m'" + shows "k = k'" + using prime_power_cancel_less [OF \prime p\] assms + by (metis linorder_neqE_nat) + +lemma prime_power_cancel2: + assumes "prime p" "m * (p ^ k) = m' * (p ^ k')" "\ p dvd m" "\ p dvd m'" + obtains "m = m'" "k = k'" + using prime_power_cancel [OF assms] assms by auto + +lemma prime_power_canonical: + fixes m::nat + assumes "prime p" "m > 0" + shows "\k n. \ p dvd n \ m = n * p^k" +using \m > 0\ +proof (induction m rule: less_induct) + case (less m) + show ?case + proof (cases "p dvd m") + case True + then obtain m' where m': "m = p * m'" + using dvdE by blast + with \prime p\ have "0 < m'" "m' < m" + using less.prems prime_nat_iff by auto + with m' less show ?thesis + by (metis power_Suc mult.left_commute) + next + case False + then show ?thesis + by (metis mult.right_neutral power_0) + qed +qed + subsubsection \Make prime naively executable\ diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Set_Interval.thy Wed Jan 04 16:18:50 2017 +0000 @@ -1090,6 +1090,19 @@ "!!f::nat=>nat. (!!n. n \ f n) ==> finite {n. f n \ u}" by (rule_tac B="{..u}" in finite_subset, auto intro: order_trans) +lemma bounded_Max_nat: + fixes P :: "nat \ bool" + assumes x: "P x" and M: "\x. P x \ x \ M" + obtains m where "P m" "\x. P x \ x \ m" +proof - + have "finite {x. P x}" + using M finite_nat_set_iff_bounded_le by auto + then have "Max {x. P x} \ {x. P x}" + using Max_in x by auto + then show ?thesis + by (simp add: \finite {x. P x}\ that) +qed + text\Any subset of an interval of natural numbers the size of the subset is exactly that interval.\ diff -r 1ddc262514b8 -r 223b2ebdda79 src/HOL/Topological_Spaces.thy --- a/src/HOL/Topological_Spaces.thy Tue Jan 03 23:21:09 2017 +0100 +++ b/src/HOL/Topological_Spaces.thy Wed Jan 04 16:18:50 2017 +0000 @@ -1530,9 +1530,6 @@ lemma tendsto_compose: "g \l\ g l \ (f \ l) F \ ((\x. g (f x)) \ g l) F" unfolding tendsto_at_iff_tendsto_nhds by (rule filterlim_compose[of g]) -lemma LIM_o: "g \l\ g l \ f \a\ l \ (g \ f) \a\ g l" - unfolding o_def by (rule tendsto_compose) - lemma tendsto_compose_eventually: "g \l\ m \ (f \ l) F \ eventually (\x. f x \ l) F \ ((\x. g (f x)) \ m) F" by (rule filterlim_compose[of g _ "at l"]) (auto simp add: filterlim_at)