# HG changeset patch # User huffman # Date 1313165850 25200 # Node ID 75ea0e390a92799a31dfb4073e0dc41930301de2 # Parent 510ac30f44c088598e5a9e799de0002c5e0162a3# Parent 238c5ea1e2ceba8660b2e5e96202ef2ab13d611c merged diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/HOLCF/Tools/domaindef.ML --- a/src/HOL/HOLCF/Tools/domaindef.ML Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/HOLCF/Tools/domaindef.ML Fri Aug 12 09:17:30 2011 -0700 @@ -109,7 +109,7 @@ |> the_default (Binding.prefix_name "Rep_" name, Binding.prefix_name "Abs_" name) (*set*) - val set = @{term "defl_set :: udom defl => udom => bool"} $ defl + val set = @{term "defl_set :: udom defl => udom set"} $ defl (*pcpodef*) val tac1 = rtac @{thm defl_set_bottom} 1 diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/HOLCF/Tools/holcf_library.ML --- a/src/HOL/HOLCF/Tools/holcf_library.ML Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/HOLCF/Tools/holcf_library.ML Fri Aug 12 09:17:30 2011 -0700 @@ -15,6 +15,7 @@ val boolT = HOLogic.boolT val natT = HOLogic.natT +val mk_setT = HOLogic.mk_setT val mk_equals = Logic.mk_equals val mk_eq = HOLogic.mk_eq @@ -56,9 +57,9 @@ fun mk_lub t = let val T = Term.range_type (Term.fastype_of t) - val lub_const = Const (@{const_name lub}, (T --> boolT) --> T) + val lub_const = Const (@{const_name lub}, mk_setT T --> T) val UNIV_const = @{term "UNIV :: nat set"} - val image_type = (natT --> T) --> (natT --> boolT) --> T --> boolT + val image_type = (natT --> T) --> mk_setT natT --> mk_setT T val image_const = Const (@{const_name image}, image_type) in lub_const $ (image_const $ t $ UNIV_const) diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Library/Extended_Real.thy --- a/src/HOL/Library/Extended_Real.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Library/Extended_Real.thy Fri Aug 12 09:17:30 2011 -0700 @@ -1370,7 +1370,7 @@ } moreover { assume "?lhs" hence "?rhs" - by (metis Collect_def Collect_mem_eq SUP_leI assms atLeastatMost_empty atLeastatMost_empty_iff + by (metis SUP_leI assms atLeastatMost_empty atLeastatMost_empty_iff inf_sup_ord(4) linorder_le_cases sup_absorb1 xt1(8)) } ultimately show ?thesis by auto qed @@ -1390,7 +1390,7 @@ } moreover { assume "?lhs" hence "?rhs" - by (metis Collect_def Collect_mem_eq le_INFI assms atLeastatMost_empty atLeastatMost_empty_iff + by (metis le_INFI assms atLeastatMost_empty atLeastatMost_empty_iff inf_sup_ord(4) linorder_le_cases sup_absorb1 xt1(8)) } ultimately show ?thesis by auto qed @@ -2210,21 +2210,20 @@ qed qed auto -lemma (in order) mono_set: - "mono S \ (\x y. x \ y \ x \ S \ y \ S)" - by (auto simp: mono_def mem_def) +definition (in order) mono_set: + "mono_set S \ (\x y. x \ y \ x \ S \ y \ S)" -lemma (in order) mono_greaterThan [intro, simp]: "mono {B<..}" unfolding mono_set by auto -lemma (in order) mono_atLeast [intro, simp]: "mono {B..}" unfolding mono_set by auto -lemma (in order) mono_UNIV [intro, simp]: "mono UNIV" unfolding mono_set by auto -lemma (in order) mono_empty [intro, simp]: "mono {}" unfolding mono_set by auto +lemma (in order) mono_greaterThan [intro, simp]: "mono_set {B<..}" unfolding mono_set by auto +lemma (in order) mono_atLeast [intro, simp]: "mono_set {B..}" unfolding mono_set by auto +lemma (in order) mono_UNIV [intro, simp]: "mono_set UNIV" unfolding mono_set by auto +lemma (in order) mono_empty [intro, simp]: "mono_set {}" unfolding mono_set by auto lemma (in complete_linorder) mono_set_iff: fixes S :: "'a set" defines "a \ Inf S" - shows "mono S \ (S = {a <..} \ S = {a..})" (is "_ = ?c") + shows "mono_set S \ (S = {a <..} \ S = {a..})" (is "_ = ?c") proof - assume "mono S" + assume "mono_set S" then have mono: "\x y. x \ y \ x \ S \ y \ S" by (auto simp: mono_set) show ?c proof cases diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Library/Infinite_Set.thy --- a/src/HOL/Library/Infinite_Set.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Library/Infinite_Set.thy Fri Aug 12 09:17:30 2011 -0700 @@ -546,7 +546,7 @@ apply (induct n arbitrary: S) apply (fastsimp intro: LeastI dest!: infinite_imp_nonempty) apply simp -apply (metis Collect_def Collect_mem_eq DiffE infinite_remove) +apply (metis Collect_mem_eq DiffE infinite_remove) done declare enumerate_0 [simp del] enumerate_Suc [simp del] diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy Fri Aug 12 09:17:30 2011 -0700 @@ -467,7 +467,7 @@ text {* some lemmas to map between Eucl and Cart *} lemma basis_real_n[simp]:"(basis (\' i)::real^'a) = cart_basis i" unfolding basis_vec_def using pi'_range[where 'n='a] - by (auto simp: vec_eq_iff) + by (auto simp: vec_eq_iff axis_def) subsection {* Orthogonality on cartesian products *} @@ -762,7 +762,7 @@ apply auto apply (rule span_mul) apply (rule span_superset) -apply (auto simp add: Collect_def mem_def) +apply auto done lemma finite_stdbasis: "finite {cart_basis i ::real^'n |i. i\ (UNIV:: 'n set)}" (is "finite ?S") @@ -785,12 +785,12 @@ proof- let ?U = "UNIV :: 'n set" let ?B = "cart_basis ` S" - let ?P = "\(x::real^_). \i\ ?U. i \ S \ x$i =0" + let ?P = "{(x::real^_). \i\ ?U. i \ S \ x$i =0}" {fix x::"real^_" assume xS: "x\ ?B" - from xS have "?P x" by auto} + from xS have "x \ ?P" by auto} moreover have "subspace ?P" - by (auto simp add: subspace_def Collect_def mem_def) + by (auto simp add: subspace_def) ultimately show ?thesis using x span_induct[of ?B ?P x] iS by blast qed @@ -830,7 +830,7 @@ from equalityD2[OF span_stdbasis] have IU: " (UNIV :: (real^'m) set) \ span ?I" by blast from linear_eq[OF lf lg IU] fg x - have "f x = g x" unfolding Collect_def Ball_def mem_def by metis} + have "f x = g x" unfolding Ball_def mem_Collect_eq by metis} then show ?thesis by (auto intro: ext) qed @@ -866,7 +866,7 @@ obtain g where g: "linear g" "g o op *v A = id" by blast have "matrix g ** A = mat 1" unfolding matrix_eq matrix_vector_mul_lid matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)] - using g(2) by (simp add: o_def id_def stupid_ext) + using g(2) by (simp add: fun_eq_iff) then have "\B. (B::real ^'m^'n) ** A = mat 1" by blast} ultimately show ?thesis by blast qed @@ -894,7 +894,7 @@ have "A ** (matrix g) = mat 1" unfolding matrix_eq matrix_vector_mul_lid matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)] - using g(2) unfolding o_def stupid_ext[symmetric] id_def + using g(2) unfolding o_def fun_eq_iff id_def . hence "\B. A ** (B::real^'m^'n) = mat 1" by blast } @@ -1635,11 +1635,8 @@ abbreviation dest_vec1:: "'a ^1 \ 'a" where "dest_vec1 x \ (x$1)" -lemma vec1_dest_vec1[simp]: "vec1(dest_vec1 x) = x" "dest_vec1(vec1 y) = y" - by (simp_all add: vec_eq_iff) - -lemma vec1_component[simp]: "(vec1 x)$1 = x" - by (simp_all add: vec_eq_iff) +lemma vec1_dest_vec1[simp]: "vec1(dest_vec1 x) = x" + by (simp add: vec_eq_iff) lemma forall_vec1: "(\x. P x) \ (\x. P (vec1 x))" by (metis vec1_dest_vec1(1)) @@ -1647,9 +1644,6 @@ lemma exists_vec1: "(\x. P x) \ (\x. P(vec1 x))" by (metis vec1_dest_vec1(1)) -lemma vec1_eq[simp]: "vec1 x = vec1 y \ x = y" - by (metis vec1_dest_vec1(2)) - lemma dest_vec1_eq[simp]: "dest_vec1 x = dest_vec1 y \ x = y" by (metis vec1_dest_vec1(1)) @@ -1741,12 +1735,12 @@ by (simp add: vec_def norm_real) lemma dist_vec1: "dist(vec1 x) (vec1 y) = abs(x - y)" - by (simp only: dist_real vec1_component) + by (simp only: dist_real vec_component) lemma abs_dest_vec1: "norm x = \dest_vec1 x\" by (metis vec1_dest_vec1(1) norm_vec1) lemmas vec1_dest_vec1_simps = forall_vec1 vec_add[THEN sym] dist_vec1 vec_sub[THEN sym] vec1_dest_vec1 norm_vec1 vector_smult_component - vec1_eq vec_cmul[THEN sym] smult_conv_scaleR[THEN sym] o_def dist_real_def real_norm_def + vec_inj[where 'b=1] vec_cmul[THEN sym] smult_conv_scaleR[THEN sym] o_def dist_real_def real_norm_def lemma bounded_linear_vec1:"bounded_linear (vec1::real\real^1)" unfolding bounded_linear_def additive_def bounded_linear_axioms_def diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Fri Aug 12 09:17:30 2011 -0700 @@ -101,9 +101,9 @@ lemma span_eq[simp]: "(span s = s) <-> subspace s" proof- - { fix f assume "f <= subspace" - hence "subspace (Inter f)" using subspace_Inter[of f] unfolding subset_eq mem_def by auto } - thus ?thesis using hull_eq[unfolded mem_def, of subspace s] span_def by auto + { fix f assume "Ball f subspace" + hence "subspace (Inter f)" using subspace_Inter[of f] unfolding Ball_def by auto } + thus ?thesis using hull_eq[of subspace s] span_def by auto qed lemma basis_inj_on: "d \ {.. inj_on (basis :: nat => 'n::euclidean_space) d" @@ -391,11 +391,11 @@ unfolding affine_def by auto lemma affine_affine_hull: "affine(affine hull s)" - unfolding hull_def using affine_Inter[of "{t \ affine. s \ t}"] - unfolding mem_def by auto + unfolding hull_def using affine_Inter[of "{t. affine t \ s \ t}"] + by auto lemma affine_hull_eq[simp]: "(affine hull s = s) \ affine s" -by (metis affine_affine_hull hull_same mem_def) +by (metis affine_affine_hull hull_same) subsection {* Some explicit formulations (from Lars Schewe). *} @@ -459,7 +459,7 @@ lemma affine_hull_explicit: "affine hull p = {y. \s u. finite s \ s \ {} \ s \ p \ setsum u s = 1 \ setsum (\v. (u v) *\<^sub>R v) s = y}" - apply(rule hull_unique) apply(subst subset_eq) prefer 3 apply rule unfolding mem_Collect_eq and mem_def[of _ affine] + apply(rule hull_unique) apply(subst subset_eq) prefer 3 apply rule unfolding mem_Collect_eq apply (erule exE)+ apply(erule conjE)+ prefer 2 apply rule proof- fix x assume "x\p" thus "\s u. finite s \ s \ {} \ s \ p \ setsum u s = 1 \ (\v\s. u v *\<^sub>R v) = x" apply(rule_tac x="{x}" in exI, rule_tac x="\x. 1" in exI) by auto @@ -500,7 +500,7 @@ subsection {* Stepping theorems and hence small special cases. *} lemma affine_hull_empty[simp]: "affine hull {} = {}" - apply(rule hull_unique) unfolding mem_def by auto + apply(rule hull_unique) by auto lemma affine_hull_finite_step: fixes y :: "'a::real_vector" @@ -812,12 +812,11 @@ subsection {* Conic hull. *} lemma cone_cone_hull: "cone (cone hull s)" - unfolding hull_def using cone_Inter[of "{t \ conic. s \ t}"] - by (auto simp add: mem_def) + unfolding hull_def by auto lemma cone_hull_eq: "(cone hull s = s) \ cone s" - apply(rule hull_eq[unfolded mem_def]) - using cone_Inter unfolding subset_eq by (auto simp add: mem_def) + apply(rule hull_eq) + using cone_Inter unfolding subset_eq by auto lemma mem_cone: assumes "cone S" "x : S" "c>=0" @@ -888,7 +887,7 @@ lemma mem_cone_hull: assumes "x : S" "c>=0" shows "c *\<^sub>R x : cone hull S" -by (metis assms cone_cone_hull hull_inc mem_cone mem_def) +by (metis assms cone_cone_hull hull_inc mem_cone) lemma cone_hull_expl: fixes S :: "('m::euclidean_space) set" @@ -901,11 +900,11 @@ moreover have "(c*cx) >= 0" using c_def x_def using mult_nonneg_nonneg by auto ultimately have "c *\<^sub>R x : ?rhs" using x_def by auto } hence "cone ?rhs" unfolding cone_def by auto - hence "?rhs : cone" unfolding mem_def by auto + hence "?rhs : Collect cone" unfolding mem_Collect_eq by auto { fix x assume "x : S" hence "1 *\<^sub>R x : ?rhs" apply auto apply(rule_tac x="1" in exI) by auto hence "x : ?rhs" by auto } hence "S <= ?rhs" by auto -hence "?lhs <= ?rhs" using `?rhs : cone` hull_minimal[of S "?rhs" "cone"] by auto +hence "?lhs <= ?rhs" using `?rhs : Collect cone` hull_minimal[of S "?rhs" "cone"] by auto moreover { fix x assume "x : ?rhs" from this obtain cx xx where x_def: "x= cx *\<^sub>R xx & (cx :: real)>=0 & xx : S" by auto @@ -1081,18 +1080,18 @@ subsection {* Convex hull. *} lemma convex_convex_hull: "convex(convex hull s)" - unfolding hull_def using convex_Inter[of "{t\convex. s\t}"] - unfolding mem_def by auto + unfolding hull_def using convex_Inter[of "{t. convex t \ s \ t}"] + by auto lemma convex_hull_eq: "convex hull s = s \ convex s" -by (metis convex_convex_hull hull_same mem_def) +by (metis convex_convex_hull hull_same) lemma bounded_convex_hull: fixes s :: "'a::real_normed_vector set" assumes "bounded s" shows "bounded(convex hull s)" proof- from assms obtain B where B:"\x\s. norm x \ B" unfolding bounded_iff by auto show ?thesis apply(rule bounded_subset[OF bounded_cball, of _ 0 B]) - unfolding subset_hull[unfolded mem_def, of convex, OF convex_cball] + unfolding subset_hull[of convex, OF convex_cball] unfolding subset_eq mem_cball dist_norm using B by auto qed lemma finite_imp_bounded_convex_hull: @@ -1125,17 +1124,17 @@ subsection {* Stepping theorems for convex hulls of finite sets. *} lemma convex_hull_empty[simp]: "convex hull {} = {}" - apply(rule hull_unique) unfolding mem_def by auto + apply(rule hull_unique) by auto lemma convex_hull_singleton[simp]: "convex hull {a} = {a}" - apply(rule hull_unique) unfolding mem_def by auto + apply(rule hull_unique) by auto lemma convex_hull_insert: fixes s :: "'a::real_vector set" assumes "s \ {}" shows "convex hull (insert a s) = {x. \u\0. \v\0. \b. (u + v = 1) \ b \ (convex hull s) \ (x = u *\<^sub>R a + v *\<^sub>R b)}" (is "?xyz = ?hull") - apply(rule,rule hull_minimal,rule) unfolding mem_def[of _ convex] and insert_iff prefer 3 apply rule proof- + apply(rule,rule hull_minimal,rule) unfolding insert_iff prefer 3 apply rule proof- fix x assume x:"x = a \ x \ s" thus "x\?hull" apply rule unfolding mem_Collect_eq apply(rule_tac x=1 in exI) defer apply(rule_tac x=0 in exI) using assms hull_subset[of s convex] by auto @@ -1192,7 +1191,7 @@ shows "convex hull s = {y. \k u x. (\i\{1::nat .. k}. 0 \ u i \ x i \ s) \ (setsum u {1..k} = 1) \ (setsum (\i. u i *\<^sub>R x i) {1..k} = y)}" (is "?xyz = ?hull") - apply(rule hull_unique) unfolding mem_def[of _ convex] apply(rule) defer + apply(rule hull_unique) apply(rule) defer apply(subst convex_def) apply(rule,rule,rule,rule,rule,rule,rule) proof- fix x assume "x\s" @@ -1232,7 +1231,7 @@ assumes "finite s" shows "convex hull s = {y. \u. (\x\s. 0 \ u x) \ setsum u s = 1 \ setsum (\x. u x *\<^sub>R x) s = y}" (is "?HULL = ?set") -proof(rule hull_unique, auto simp add: mem_def[of _ convex] convex_def[of ?set]) +proof(rule hull_unique, auto simp add: convex_def[of ?set]) fix x assume "x\s" thus " \u. (\x\s. 0 \ u x) \ setsum u s = 1 \ (\x\s. u x *\<^sub>R x) = x" apply(rule_tac x="\y. if x=y then 1 else 0" in exI) apply auto unfolding setsum_delta'[OF assms] and setsum_delta''[OF assms] by auto @@ -1356,8 +1355,8 @@ apply(rule_tac x=u in exI) apply simp apply(rule_tac x="\x. v" in exI) by simp qed lemma convex_hull_2_alt: "convex hull {a,b} = {a + u *\<^sub>R (b - a) | u. 0 \ u \ u \ 1}" - unfolding convex_hull_2 unfolding Collect_def -proof(rule ext) have *:"\x y ::real. x + y = 1 \ x = 1 - y" by auto + unfolding convex_hull_2 +proof(rule Collect_cong) have *:"\x y ::real. x + y = 1 \ x = 1 - y" by auto fix x show "(\v u. x = v *\<^sub>R a + u *\<^sub>R b \ 0 \ v \ 0 \ u \ v + u = 1) = (\u. x = a + u *\<^sub>R (b - a) \ 0 \ u \ u \ 1)" unfolding * apply auto apply(rule_tac[!] x=u in exI) by (auto simp add: algebra_simps) qed @@ -1367,8 +1366,8 @@ have fin:"finite {a,b,c}" "finite {b,c}" "finite {c}" by auto have *:"\x y z ::real. x + y + z = 1 \ x = 1 - y - z" "\x y z ::_::euclidean_space. x + y + z = 1 \ x = 1 - y - z" by (auto simp add: field_simps) - show ?thesis unfolding convex_hull_finite[OF fin(1)] and Collect_def and convex_hull_finite_step[OF fin(2)] and * - unfolding convex_hull_finite_step[OF fin(3)] apply(rule ext) apply simp apply auto + show ?thesis unfolding convex_hull_finite[OF fin(1)] and convex_hull_finite_step[OF fin(2)] and * + unfolding convex_hull_finite_step[OF fin(3)] apply(rule Collect_cong) apply simp apply auto apply(rule_tac x=va in exI) apply (rule_tac x="u c" in exI) apply simp apply(rule_tac x="1 - v - w" in exI) apply simp apply(rule_tac x=v in exI) apply simp apply(rule_tac x="\x. w" in exI) by simp qed @@ -1392,14 +1391,14 @@ lemma affine_hull_subset_span: fixes s :: "(_::euclidean_space) set" shows "(affine hull s) \ (span s)" -by (metis hull_minimal mem_def span_inc subspace_imp_affine subspace_span) +by (metis hull_minimal span_inc subspace_imp_affine subspace_span) lemma convex_hull_subset_span: fixes s :: "(_::euclidean_space) set" shows "(convex hull s) \ (span s)" -by (metis hull_minimal mem_def span_inc subspace_imp_convex subspace_span) +by (metis hull_minimal span_inc subspace_imp_convex subspace_span) lemma convex_hull_subset_affine_hull: "(convex hull s) \ (affine hull s)" -by (metis affine_affine_hull affine_imp_convex hull_minimal hull_subset mem_def) +by (metis affine_affine_hull affine_imp_convex hull_minimal hull_subset) lemma affine_dependent_imp_dependent: @@ -1572,11 +1571,11 @@ proof- have "affine ((%x. a + x) ` (affine hull S))" using affine_translation affine_affine_hull by auto moreover have "(%x. a + x) ` S <= (%x. a + x) ` (affine hull S)" using hull_subset[of S] by auto -ultimately have h1: "affine hull ((%x. a + x) ` S) <= (%x. a + x) ` (affine hull S)" by (metis hull_minimal mem_def) +ultimately have h1: "affine hull ((%x. a + x) ` S) <= (%x. a + x) ` (affine hull S)" by (metis hull_minimal) have "affine((%x. -a + x) ` (affine hull ((%x. a + x) ` S)))" using affine_translation affine_affine_hull by auto moreover have "(%x. -a + x) ` (%x. a + x) ` S <= (%x. -a + x) ` (affine hull ((%x. a + x) ` S))" using hull_subset[of "(%x. a + x) ` S"] by auto moreover have "S=(%x. -a + x) ` (%x. a + x) ` S" using translation_assoc[of "-a" a] by auto -ultimately have "(%x. -a + x) ` (affine hull ((%x. a + x) ` S)) >= (affine hull S)" by (metis hull_minimal mem_def) +ultimately have "(%x. -a + x) ` (affine hull ((%x. a + x) ` S)) >= (affine hull S)" by (metis hull_minimal) hence "affine hull ((%x. a + x) ` S) >= (%x. a + x) ` (affine hull S)" by auto from this show ?thesis using h1 by auto qed @@ -3016,7 +3015,7 @@ then obtain a b where ab:"a \ 0" "0 < b" "\x\convex hull c. b < inner a x" using separating_hyperplane_closed_0[OF convex_convex_hull, of c] using finite_imp_compact_convex_hull[OF c(3), THEN compact_imp_closed] and assms(2) - using subset_hull[unfolded mem_def, of convex, OF assms(1), THEN sym, of c] by auto + using subset_hull[of convex, OF assms(1), THEN sym, of c] by auto hence "\x. norm x = 1 \ (\y\c. 0 \ inner y x)" apply(rule_tac x="inverse(norm a) *\<^sub>R a" in exI) using hull_subset[of c convex] unfolding subset_eq and inner_scaleR apply- apply rule defer apply rule apply(rule mult_nonneg_nonneg) @@ -3077,7 +3076,7 @@ lemma convex_hull_translation_lemma: "convex hull ((\x. a + x) ` s) \ (\x. a + x) ` (convex hull s)" -by (metis convex_convex_hull convex_translation hull_minimal hull_subset image_mono mem_def) +by (metis convex_convex_hull convex_translation hull_minimal hull_subset image_mono) lemma convex_hull_bilemma: fixes neg assumes "(\s a. (convex hull (up a s)) \ up a (convex hull s))" @@ -3091,7 +3090,7 @@ lemma convex_hull_scaling_lemma: "(convex hull ((\x. c *\<^sub>R x) ` s)) \ (\x. c *\<^sub>R x) ` (convex hull s)" -by (metis convex_convex_hull convex_scaling hull_subset mem_def subset_hull subset_image_iff) +by (metis convex_convex_hull convex_scaling hull_subset subset_hull subset_image_iff) lemma convex_hull_scaling: "convex hull ((\x. c *\<^sub>R x) ` s) = (\x. c *\<^sub>R x) ` (convex hull s)" @@ -3269,7 +3268,7 @@ unfolding mp(2)[unfolded image_Un[THEN sym] gh] by auto have *:"g \ h = {}" using mp(1) unfolding gh using inj_on_image_Int[OF True gh(3,4)] by auto have "convex hull (X ` h) \ \ g" "convex hull (X ` g) \ \ h" - apply(rule_tac [!] hull_minimal) using Suc gh(3-4) unfolding mem_def unfolding subset_eq + apply(rule_tac [!] hull_minimal) using Suc gh(3-4) unfolding subset_eq apply(rule_tac [2] convex_Inter, rule_tac [4] convex_Inter) apply rule prefer 3 apply rule proof- fix x assume "x\X ` g" then guess y unfolding image_iff .. thus "x\\h" using X[THEN bspec[where x=y]] using * f by auto next @@ -3710,7 +3709,7 @@ apply(rule_tac n2="DIM('a)" in *) prefer 3 apply(subst(2) **) apply(rule card_mono) using 01 and convex_interval(1) prefer 5 apply - apply rule unfolding mem_interval apply rule unfolding mem_Collect_eq apply(erule_tac x=i in allE) - by(auto simp add: mem_def[of _ convex]) qed + by auto qed subsection {* And this is a finite set of vertices. *} @@ -3883,7 +3882,7 @@ closed_segment :: "'a::real_vector \ 'a \ 'a set" where "closed_segment a b = {(1 - u) *\<^sub>R a + u *\<^sub>R b | u::real. 0 \ u \ u \ 1}" -definition "between = (\ (a,b). closed_segment a b)" +definition "between = (\ (a,b) x. x \ closed_segment a b)" lemmas segment = open_segment_def closed_segment_def @@ -3968,15 +3967,15 @@ lemma segment_refl:"closed_segment a a = {a}" unfolding segment by (auto simp add: algebra_simps) lemma between_mem_segment: "between (a,b) x \ x \ closed_segment a b" - unfolding between_def mem_def by auto + unfolding between_def by auto lemma between:"between (a,b) (x::'a::euclidean_space) \ dist a b = (dist a x) + (dist x b)" proof(cases "a = b") - case True thus ?thesis unfolding between_def split_conv mem_def[of x, symmetric] + case True thus ?thesis unfolding between_def split_conv by(auto simp add:segment_refl dist_commute) next case False hence Fal:"norm (a - b) \ 0" and Fal2: "norm (a - b) > 0" by auto have *:"\u. a - ((1 - u) *\<^sub>R a + u *\<^sub>R b) = u *\<^sub>R (a - b)" by (auto simp add: algebra_simps) - show ?thesis unfolding between_def split_conv mem_def[of x, symmetric] closed_segment_def mem_Collect_eq + show ?thesis unfolding between_def split_conv closed_segment_def mem_Collect_eq apply rule apply(erule exE, (erule conjE)+) apply(subst dist_triangle_eq) proof- fix u assume as:"x = (1 - u) *\<^sub>R a + u *\<^sub>R b" "0 \ u" "u \ 1" hence *:"a - x = u *\<^sub>R (a - b)" "x - b = (1 - u) *\<^sub>R (a - b)" @@ -4743,8 +4742,8 @@ { fix S assume "S : I" hence "y : closure S" using closure_subset y_def by auto } hence "y : Inter {closure S |S. S : I}" by auto } hence "Inter I <= Inter {closure S |S. S : I}" by auto -moreover have "Inter {closure S |S. S : I} : closed" - unfolding mem_def closed_Inter closed_closure by auto +moreover have "closed (Inter {closure S |S. S : I})" + unfolding closed_Inter closed_closure by auto ultimately show ?thesis using closure_hull[of "Inter I"] hull_minimal[of "Inter I" "Inter {closure S |S. S : I}" "closed"] by auto qed @@ -5074,8 +5073,8 @@ using I_def u_def by auto } hence "convex hull (S <*> T) >= (convex hull S) <*> (convex hull T)" by auto -moreover have "(convex hull S) <*> (convex hull T) : convex" - unfolding mem_def by (simp add: convex_direct_sum convex_convex_hull) +moreover have "convex ((convex hull S) <*> (convex hull T))" + by (simp add: convex_direct_sum convex_convex_hull) ultimately show ?thesis using hull_minimal[of "S <*> T" "(convex hull S) <*> (convex hull T)" "convex"] hull_subset[of S convex] hull_subset[of T convex] by auto @@ -5384,7 +5383,6 @@ finally have "u *\<^sub>R x + v *\<^sub>R y = setsum (%i. (e i) *\<^sub>R (q i)) I" by auto hence "u *\<^sub>R x + v *\<^sub>R y : ?rhs" using ge0 sum1 qs by auto } hence "convex ?rhs" unfolding convex_def by auto -hence "?rhs : convex" unfolding mem_def by auto from this show ?thesis using `?lhs >= ?rhs` * hull_minimal[of "Union (S ` I)" "?rhs" "convex"] by blast qed @@ -5578,7 +5576,7 @@ hence "K0 >= K i" unfolding K0_def K_def apply (subst hull_mono) using `!i:I. C0 >= S i` by auto } hence "K0 >= Union (K ` I)" by auto - moreover have "K0 : convex" unfolding mem_def K0_def + moreover have "convex K0" unfolding K0_def apply (subst convex_cone_hull) apply (subst convex_direct_sum) unfolding C0_def using convex_convex_hull by auto ultimately have geq: "K0 >= convex hull (Union (K ` I))" using hull_minimal[of _ "K0" "convex"] by blast @@ -5587,7 +5585,7 @@ hence "convex hull Union (K ` I) >= convex hull ({(1 :: real)} <*> Union (S ` I))" by (simp add: hull_mono) hence "convex hull Union (K ` I) >= {(1 :: real)} <*> C0" unfolding C0_def using convex_hull_direct_sum[of "{(1 :: real)}" "Union (S ` I)"] convex_hull_singleton by auto - moreover have "convex hull(Union (K ` I)) : cone" unfolding mem_def apply (subst cone_convex_hull) + moreover have "cone (convex hull(Union (K ` I)))" apply (subst cone_convex_hull) using cone_Union[of "K ` I"] apply auto unfolding K_def using cone_cone_hull by auto ultimately have "convex hull (Union (K ` I)) >= K0" unfolding K0_def using hull_minimal[of _ "convex hull (Union (K ` I))" "cone"] by blast diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Fri Aug 12 09:17:30 2011 -0700 @@ -15,22 +15,75 @@ subsection {* Type class of Euclidean spaces *} class euclidean_space = real_inner + + fixes Basis :: "'a set" + assumes nonempty_Basis [simp]: "Basis \ {}" + assumes finite_Basis [simp]: "finite Basis" + assumes inner_Basis: + "\u \ Basis; v \ Basis\ \ inner u v = (if u = v then 1 else 0)" + assumes euclidean_all_zero_iff: + "(\u\Basis. inner x u = 0) \ (x = 0)" + + -- "FIXME: make this a separate definition" fixes dimension :: "'a itself \ nat" + assumes dimension_def: "dimension TYPE('a) = card Basis" + + -- "FIXME: eventually basis function can be removed" fixes basis :: "nat \ 'a" - assumes DIM_positive [intro]: - "0 < dimension TYPE('a)" - assumes basis_zero [simp]: - "dimension TYPE('a) \ i \ basis i = 0" - assumes basis_orthonormal: - "\iji (x = 0)" + assumes image_basis: "basis ` {.. nat" ("(1DIM/(1'(_')))") translations "DIM('t)" == "CONST dimension (TYPE('t))" +lemma (in euclidean_space) norm_Basis: "u \ Basis \ norm u = 1" + unfolding norm_eq_sqrt_inner by (simp add: inner_Basis) + +lemma (in euclidean_space) sgn_Basis: "u \ Basis \ sgn u = u" + unfolding sgn_div_norm by (simp add: norm_Basis scaleR_one) + +lemma (in euclidean_space) Basis_zero [simp]: "0 \ Basis" +proof + assume "0 \ Basis" thus "False" + using inner_Basis [of 0 0] by simp +qed + +lemma (in euclidean_space) nonzero_Basis: "u \ Basis \ u \ 0" + by clarsimp + +text {* Lemmas related to @{text basis} function. *} + +lemma (in euclidean_space) euclidean_all_zero: + "(\i (x = 0)" + using euclidean_all_zero_iff [of x, folded image_basis] + unfolding ball_simps by (simp add: Ball_def inner_commute) + +lemma (in euclidean_space) basis_zero [simp]: + "DIM('a) \ i \ basis i = 0" + using basis_finite by auto + +lemma (in euclidean_space) DIM_positive [intro]: "0 < DIM('a)" + unfolding dimension_def by (simp add: card_gt_0_iff) + +lemma (in euclidean_space) basis_inj [simp, intro]: "inj_on basis {.. Basis \ i < DIM('a)" + by (cases "i < DIM('a)", simp add: image_basis [symmetric], simp) + +lemma (in euclidean_space) Basis_elim: + assumes "u \ Basis" obtains i where "i < DIM('a)" and "u = basis i" + using assms unfolding image_basis [symmetric] by fast + +lemma (in euclidean_space) basis_orthonormal: + "\ij i < DIM('a) then 1 else 0)" proof (cases "(i < DIM('a) \ j < DIM('a))") @@ -161,6 +214,9 @@ begin definition + "Basis = {1::real}" + +definition "dimension (t::real itself) = 1" definition [simp]: @@ -170,42 +226,44 @@ by (rule dimension_real_def) instance - by default simp+ + by default (auto simp add: Basis_real_def) end subsubsection {* Type @{typ complex} *} + (* TODO: move these to Complex.thy/Inner_Product.thy *) + +lemma norm_ii [simp]: "norm ii = 1" + unfolding i_def by simp + +lemma complex_inner_1 [simp]: "inner 1 x = Re x" + unfolding inner_complex_def by simp + +lemma complex_inner_1_right [simp]: "inner x 1 = Re x" + unfolding inner_complex_def by simp + +lemma complex_inner_ii_left [simp]: "inner ii x = Im x" + unfolding inner_complex_def by simp + +lemma complex_inner_ii_right [simp]: "inner x ii = Im x" + unfolding inner_complex_def by simp + instantiation complex :: euclidean_space begin +definition Basis_complex_def: + "Basis = {1, ii}" + definition "dimension (t::complex itself) = 2" definition "basis i = (if i = 0 then 1 else if i = 1 then ii else 0)" -lemma all_less_Suc: "(\i (\i P n" - by (auto simp add: less_Suc_eq) - -instance proof - show "0 < DIM(complex)" - unfolding dimension_complex_def by simp -next - fix i :: nat - assume "DIM(complex) \ i" thus "basis i = (0::complex)" - unfolding dimension_complex_def basis_complex_def by simp -next - show "\iji x = 0" - unfolding dimension_complex_def basis_complex_def inner_complex_def - by (simp add: numeral_2_eq_2 all_less_Suc complex_eq_iff) -qed +instance + by default (auto simp add: Basis_complex_def dimension_complex_def + basis_complex_def intro: complex_eqI split: split_if_asm) end @@ -214,40 +272,50 @@ subsubsection {* Type @{typ "'a \ 'b"} *} +lemma disjoint_iff: "A \ B = {} \ (\x\A. \y\B. x \ y)" + by auto (* TODO: move elsewhere *) + instantiation prod :: (euclidean_space, euclidean_space) euclidean_space begin definition + "Basis = (\u. (u, 0)) ` Basis \ (\v. (0, v)) ` Basis" + +definition "dimension (t::('a \ 'b) itself) = DIM('a) + DIM('b)" definition "basis i = (if i < DIM('a) then (basis i, 0) else (0, basis (i - DIM('a))))" -lemma all_less_sum: - fixes m n :: nat - shows "(\i<(m + n). P i) \ (\i (\i 'b)" - unfolding dimension_prod_def by (intro add_pos_pos DIM_positive) + show "(Basis :: ('a \ 'b) set) \ {}" + unfolding Basis_prod_def by simp next - fix i :: nat - assume "DIM('a \ 'b) \ i" thus "basis i = (0::'a \ 'b)" - unfolding dimension_prod_def basis_prod_def zero_prod_def - by simp + show "finite (Basis :: ('a \ 'b) set)" + unfolding Basis_prod_def by simp next - show "\i 'b). \j 'b). - inner (basis i::'a \ 'b) (basis j) = (if i = j then 1 else 0)" - unfolding dimension_prod_def basis_prod_def inner_prod_def - unfolding all_less_sum prod_eq_iff - by (simp add: basis_orthonormal) + fix u v :: "'a \ 'b" + assume "u \ Basis" and "v \ Basis" + thus "inner u v = (if u = v then 1 else 0)" + unfolding Basis_prod_def inner_prod_def + by (auto simp add: inner_Basis split: split_if_asm) next fix x :: "'a \ 'b" - show "(\i 'b). inner (basis i) x = 0) \ x = 0" - unfolding dimension_prod_def basis_prod_def inner_prod_def - unfolding all_less_sum prod_eq_iff - by (simp add: euclidean_all_zero) + show "(\u\Basis. inner x u = 0) \ x = 0" + unfolding Basis_prod_def ball_Un ball_simps + by (simp add: inner_prod_def prod_eq_iff euclidean_all_zero_iff) +next + show "DIM('a \ 'b) = card (Basis :: ('a \ 'b) set)" + unfolding dimension_prod_def Basis_prod_def + by (simp add: card_Un_disjoint disjoint_iff + card_image inj_on_def dimension_def) +next + show "basis ` {.. 'b)} = (Basis :: ('a \ 'b) set)" + by (auto simp add: Basis_prod_def dimension_prod_def basis_prod_def + image_def elim!: Basis_elim) +next + show "basis ` {DIM('a \ 'b)..} = {0::('a \ 'b)}" + by (auto simp add: dimension_prod_def basis_prod_def prod_eq_iff image_def) qed end diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy --- a/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Fri Aug 12 09:17:30 2011 -0700 @@ -102,7 +102,7 @@ then show False using MInf by auto next case PInf then have "S={\}" by (metis Inf_eq_PInfty assms(2)) - then show False by (metis `Inf S ~: S` insert_code mem_def PInf) + then show False using `Inf S ~: S` by simp next case (real r) then have fin: "\Inf S\ \ \" by simp from ereal_open_cont_interval[OF a this] guess e . note e = this @@ -284,22 +284,22 @@ lemma ereal_open_mono_set: fixes S :: "ereal set" defines "a \ Inf S" - shows "(open S \ mono S) \ (S = UNIV \ S = {a <..})" + shows "(open S \ mono_set S) \ (S = UNIV \ S = {a <..})" by (metis Inf_UNIV a_def atLeast_eq_UNIV_iff ereal_open_atLeast ereal_open_closed mono_set_iff open_ereal_greaterThan) lemma ereal_closed_mono_set: fixes S :: "ereal set" - shows "(closed S \ mono S) \ (S = {} \ S = {Inf S ..})" + shows "(closed S \ mono_set S) \ (S = {} \ S = {Inf S ..})" by (metis Inf_UNIV atLeast_eq_UNIV_iff closed_ereal_atLeast ereal_open_closed mono_empty mono_set_iff open_ereal_greaterThan) lemma ereal_Liminf_Sup_monoset: fixes f :: "'a => ereal" - shows "Liminf net f = Sup {l. \S. open S \ mono S \ l \ S \ eventually (\x. f x \ S) net}" + shows "Liminf net f = Sup {l. \S. open S \ mono_set S \ l \ S \ eventually (\x. f x \ S) net}" unfolding Liminf_Sup proof (intro arg_cong[where f="\P. Sup (Collect P)"] ext iffI allI impI) - fix l S assume ev: "\yx. y < f x) net" and "open S" "mono S" "l \ S" + fix l S assume ev: "\yx. y < f x) net" and "open S" "mono_set S" "l \ S" then have "S = UNIV \ S = {Inf S <..}" using ereal_open_mono_set[of S] by auto then show "eventually (\x. f x \ S) net" @@ -310,7 +310,7 @@ then show "eventually (\x. f x \ S) net" by (subst S) auto qed auto next - fix l y assume S: "\S. open S \ mono S \ l \ S \ eventually (\x. f x \ S) net" "y < l" + fix l y assume S: "\S. open S \ mono_set S \ l \ S \ eventually (\x. f x \ S) net" "y < l" have "eventually (\x. f x \ {y <..}) net" using `y < l` by (intro S[rule_format]) auto then show "eventually (\x. y < f x) net" by auto @@ -318,11 +318,11 @@ lemma ereal_Limsup_Inf_monoset: fixes f :: "'a => ereal" - shows "Limsup net f = Inf {l. \S. open S \ mono (uminus ` S) \ l \ S \ eventually (\x. f x \ S) net}" + shows "Limsup net f = Inf {l. \S. open S \ mono_set (uminus ` S) \ l \ S \ eventually (\x. f x \ S) net}" unfolding Limsup_Inf proof (intro arg_cong[where f="\P. Inf (Collect P)"] ext iffI allI impI) - fix l S assume ev: "\y>l. eventually (\x. f x < y) net" and "open S" "mono (uminus`S)" "l \ S" - then have "open (uminus`S) \ mono (uminus`S)" by (simp add: ereal_open_uminus) + fix l S assume ev: "\y>l. eventually (\x. f x < y) net" and "open S" "mono_set (uminus`S)" "l \ S" + then have "open (uminus`S) \ mono_set (uminus`S)" by (simp add: ereal_open_uminus) then have "S = UNIV \ S = {..< Sup S}" unfolding ereal_open_mono_set ereal_Inf_uminus_image_eq ereal_image_uminus_shift by simp then show "eventually (\x. f x \ S) net" @@ -333,7 +333,7 @@ then show "eventually (\x. f x \ S) net" by (subst S) auto qed auto next - fix l y assume S: "\S. open S \ mono (uminus`S) \ l \ S \ eventually (\x. f x \ S) net" "l < y" + fix l y assume S: "\S. open S \ mono_set (uminus`S) \ l \ S \ eventually (\x. f x \ S) net" "l < y" have "eventually (\x. f x \ {..< y}) net" using `l < y` by (intro S[rule_format]) auto then show "eventually (\x. f x < y) net" by auto @@ -469,7 +469,7 @@ lemma liminf_bounded_open: fixes x :: "nat \ ereal" - shows "x0 \ liminf x \ (\S. open S \ mono S \ x0 \ S \ (\N. \n\N. x n \ S))" + shows "x0 \ liminf x \ (\S. open S \ mono_set S \ x0 \ S \ (\N. \n\N. x n \ S))" (is "_ \ ?P x0") proof assume "?P x0" then show "x0 \ liminf x" @@ -477,7 +477,7 @@ by (intro complete_lattice_class.Sup_upper) auto next assume "x0 \ liminf x" - { fix S :: "ereal set" assume om: "open S & mono S & x0:S" + { fix S :: "ereal set" assume om: "open S & mono_set S & x0:S" { assume "S = UNIV" hence "EX N. (ALL n>=N. x n : S)" by auto } moreover { assume "~(S=UNIV)" @@ -641,7 +641,7 @@ shows "Liminf (at x within S) f = (SUP e:{0<..}. INF y:(S Int ball x e - {x}). f y)" proof- let ?l="(SUP e:{0<..}. INF y:(S Int ball x e - {x}). f y)" -{ fix T assume T_def: "open T & mono T & ?l:T" +{ fix T assume T_def: "open T & mono_set T & ?l:T" have "EX d>0. ALL y:S. 0 < dist y x & dist y x < d --> f y : T" proof- { assume "T=UNIV" hence ?thesis by (simp add: gt_ex) } @@ -660,7 +660,7 @@ } moreover { fix z - assume a: "ALL T. open T --> mono T --> z : T --> + assume a: "ALL T. open T --> mono_set T --> z : T --> (EX d>0. ALL y:S. 0 < dist y x & dist y x < d --> f y : T)" { fix B assume "B0 & (ALL y:S. 0 < dist y x & dist y x < d --> B < f y)" @@ -683,7 +683,7 @@ shows "Limsup (at x within S) f = (INF e:{0<..}. SUP y:(S Int ball x e - {x}). f y)" proof- let ?l="(INF e:{0<..}. SUP y:(S Int ball x e - {x}). f y)" -{ fix T assume T_def: "open T & mono (uminus ` T) & ?l:T" +{ fix T assume T_def: "open T & mono_set (uminus ` T) & ?l:T" have "EX d>0. ALL y:S. 0 < dist y x & dist y x < d --> f y : T" proof- { assume "T=UNIV" hence ?thesis by (simp add: gt_ex) } @@ -707,7 +707,7 @@ } moreover { fix z - assume a: "ALL T. open T --> mono (uminus ` T) --> z : T --> + assume a: "ALL T. open T --> mono_set (uminus ` T) --> z : T --> (EX d>0. ALL y:S. 0 < dist y x & dist y x < d --> f y : T)" { fix B assume "z0 & (ALL y:S. 0 < dist y x & dist y x < d --> f yNi. 0) = (0::'a::{comm_monoid_add,t2_space})" - using suminf_finite[of 0 "\x. 0"] by simp - lemma suminf_upper: fixes f :: "nat \ ereal" assumes "\n. 0 \ f n" shows "(\n (\n. f n)" diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Finite_Cartesian_Product.thy --- a/src/HOL/Multivariate_Analysis/Finite_Cartesian_Product.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Finite_Cartesian_Product.thy Fri Aug 12 09:17:30 2011 -0700 @@ -41,9 +41,6 @@ end *} -lemma stupid_ext: "(\x. f x = g x) \ (f = g)" - by auto - lemma vec_eq_iff: "(x = y) \ (\i. x$i = y$i)" by (simp add: vec_nth_inject [symmetric] fun_eq_iff) @@ -445,8 +442,44 @@ end + subsection {* Euclidean space *} +text {* Vectors pointing along a single axis. *} + +definition "axis k x = (\ i. if i = k then x else 0)" + +lemma axis_nth [simp]: "axis i x $ i = x" + unfolding axis_def by simp + +lemma axis_eq_axis: "axis i x = axis j y \ x = y \ i = j \ x = 0 \ y = 0" + unfolding axis_def vec_eq_iff by auto + +lemma inner_axis_axis: + "inner (axis i x) (axis j y) = (if i = j then inner x y else 0)" + unfolding inner_vec_def + apply (cases "i = j") + apply clarsimp + apply (subst setsum_diff1' [where a=j], simp_all) + apply (rule setsum_0', simp add: axis_def) + apply (rule setsum_0', simp add: axis_def) + done + +lemma setsum_single: + assumes "finite A" and "k \ A" and "f k = y" + assumes "\i. i \ A \ i \ k \ f i = 0" + shows "(\i\A. f i) = y" + apply (subst setsum_diff1' [OF assms(1,2)]) + apply (simp add: setsum_0' assms(3,4)) + done + +lemma inner_axis: "inner x (axis i y) = inner (x $ i) y" + unfolding inner_vec_def + apply (rule_tac k=i in setsum_single) + apply simp_all + apply (simp add: axis_def) + done + text {* A bijection between @{text "'n::finite"} and @{text "{.. ('n::finite)" where @@ -485,16 +518,18 @@ instantiation vec :: (euclidean_space, finite) euclidean_space begin +definition "Basis = (\i. \u\Basis. {axis i u})" + definition "dimension (t :: ('a ^ 'b) itself) = CARD('b) * DIM('a)" -definition "(basis i::'a^'b) = +definition "basis i = (if i < (CARD('b) * DIM('a)) - then (\ j::'b. if j = \(i div DIM('a)) then basis (i mod DIM('a)) else 0) + then axis (\(i div DIM('a))) (basis (i mod DIM('a))) else 0)" lemma basis_eq: assumes "i < CARD('b)" and "j < DIM('a)" - shows "basis (j + i * DIM('a)) = (\ k. if k = \ i then basis j else 0)" + shows "basis (j + i * DIM('a)) = axis (\ i) (basis j)" proof - have "j + i * DIM('a) < DIM('a) * (i + 1)" using assms by (auto simp: field_simps) also have "\ \ DIM('a) * CARD('b)" using assms unfolding mult_le_cancel1 by auto @@ -506,7 +541,7 @@ assumes "j < DIM('a)" shows "basis (j + \' i * DIM('a)) $ k = (if k = i then basis j else 0)" apply (subst basis_eq) - using pi'_range assms by simp_all + using pi'_range assms by (simp_all add: axis_def) lemma split_times_into_modulo[consumes 1]: fixes k :: nat @@ -523,20 +558,6 @@ finally show "k div B < A" by auto qed simp -lemma split_CARD_DIM[consumes 1]: - fixes k :: nat - assumes k: "k < CARD('b) * DIM('a)" - obtains i and j::'b where "i < DIM('a)" "k = i + \' j * DIM('a)" -proof - - from split_times_into_modulo[OF k] guess i j . note ij = this - show thesis - proof - show "j < DIM('a)" using ij by simp - show "k = j + \' (\ i :: 'b) * DIM('a)" - using ij by simp - qed -qed - lemma linear_less_than_times: fixes i j A B :: nat assumes "i < B" "j < A" shows "j + i * A < B * A" @@ -549,64 +570,43 @@ lemma DIM_cart[simp]: "DIM('a^'b) = CARD('b) * DIM('a)" by (rule dimension_vec_def) -lemma all_less_DIM_cart: - fixes m n :: nat - shows "(\i (\x::'b. \i' x * DIM('a)))" -unfolding DIM_cart -apply safe -apply (drule spec, erule mp, erule linear_less_than_times [OF pi'_range]) -apply (erule split_CARD_DIM, simp) -done - -lemma eq_pi_iff: - fixes x :: "'c::finite" - shows "i < CARD('c::finite) \ x = \ i \ \' x = i" - by auto - -lemma all_less_mult: - fixes m n :: nat - shows "(\i<(m * n). P i) \ (\ij {}" + unfolding Basis_vec_def by simp +next + show "finite (Basis :: ('a ^ 'b) set)" + unfolding Basis_vec_def by simp next - fix i :: nat - assume "DIM('a ^ 'b) \ i" thus "basis i = (0::'a^'b)" - unfolding dimension_vec_def basis_vec_def - by simp + fix u v :: "'a ^ 'b" + assume "u \ Basis" and "v \ Basis" + thus "inner u v = (if u = v then 1 else 0)" + unfolding Basis_vec_def + by (auto simp add: inner_axis_axis axis_eq_axis inner_Basis) next - show "\iju\Basis. inner x u = 0) \ x = 0" + unfolding Basis_vec_def + by (simp add: inner_axis euclidean_all_zero_iff vec_eq_iff) +next + show "DIM('a ^ 'b) = card (Basis :: ('a ^ 'b) set)" + unfolding Basis_vec_def dimension_vec_def dimension_def + by (simp add: card_UN_disjoint [unfolded disjoint_iff] + axis_eq_axis nonzero_Basis) +next + show "basis ` {..i x = 0" - unfolding all_less_DIM_cart - unfolding inner_vec_def - apply (simp add: basis_eq_pi') - apply (simp add: inner_if setsum_delta cong: if_cong) - apply (simp add: euclidean_all_zero) - apply (simp add: vec_eq_iff) - done + show "basis ` {DIM('a ^ 'b)..} = {0::'a ^ 'b}" + by (auto simp add: image_def basis_vec_def) qed end diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Integration.thy --- a/src/HOL/Multivariate_Analysis/Integration.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Integration.thy Fri Aug 12 09:17:30 2011 -0700 @@ -23,8 +23,6 @@ by(subst(asm) real_arch_inv) subsection {* Sundries *} -(*declare basis_component[simp]*) - lemma conjunctD2: assumes "a \ b" shows a b using assms by auto lemma conjunctD3: assumes "a \ b \ c" shows a b c using assms by auto lemma conjunctD4: assumes "a \ b \ c \ d" shows a b c d using assms by auto @@ -142,7 +140,7 @@ let ?z = "x - (e/2) *\<^sub>R basis k" assume as:"x$$k = a$$k" have "ball ?z (e / 2) \ i = {}" apply(rule ccontr) unfolding ex_in_conv[THEN sym] proof(erule exE) fix y assume "y \ ball ?z (e / 2) \ i" hence "dist ?z y < e/2" and yi:"y\i" by auto hence "\(?z - y) $$ k\ < e/2" using component_le_norm[of "?z - y" k] unfolding dist_norm by auto - hence "y$$k < a$$k" using e[THEN conjunct1] k by(auto simp add:field_simps basis_component as) + hence "y$$k < a$$k" using e[THEN conjunct1] k by(auto simp add:field_simps as) hence "y \ i" unfolding ab mem_interval not_all apply(rule_tac x=k in exI) using k by auto thus False using yi by auto qed moreover have "ball ?z (e/2) \ s \ (\insert i f)" apply(rule order_trans[OF _ e[THEN conjunct2, unfolded lem1]]) proof fix y assume as:"y\ ball ?z (e/2)" have "norm (x - y) \ \e\ / 2 + norm (x - y - (e / 2) *\<^sub>R basis k)" @@ -417,10 +415,6 @@ fix k assume k:"k \ p1 \ p2" show "k \ s1 \ s2" using k d1(2) d2(2) by auto show "k \ {}" using k d1(3) d2(3) by auto show "\a b. k = {a..b}" using k d1(4) d2(4) by auto qed -(* move *) -lemma Eucl_nth_inverse[simp]: fixes x::"'a::euclidean_space" shows "(\\ i. x $$ i) = x" - apply(subst euclidean_eq) by auto - lemma partial_division_extend_1: assumes "{c..d} \ {a..b::'a::ordered_euclidean_space}" "{c..d} \ {}" obtains p where "p division_of {a..b}" "{c..d} \ p" @@ -737,7 +731,7 @@ "(s tagged_division_of i) \ (s tagged_partial_division_of i) \ (\{k. \x. (x,k) \ s} = i)" -lemma tagged_division_of_finite[dest]: "s tagged_division_of i \ finite s" +lemma tagged_division_of_finite: "s tagged_division_of i \ finite s" unfolding tagged_division_of_def tagged_partial_division_of_def by auto lemma tagged_division_of: @@ -1590,11 +1584,11 @@ have lem1: "\f P Q. (\x k. (x,k) \ {(x,f k) | x k. P x k} \ Q x k) \ (\x k. P x k \ Q x (f k))" by auto have lem2: "\f s P f. finite s \ finite {(x,f k) | x k. (x,k) \ s \ P x k}" proof- case goal1 thus ?case apply-apply(rule finite_subset[of _ "(\(x,k). (x,f k)) ` s"]) by auto qed - have lem3: "\g::('a \ bool) \ 'a \ bool. finite p \ + have lem3: "\g::'a set \ 'a set. finite p \ setsum (\(x,k). content k *\<^sub>R f x) {(x,g k) |x k. (x,k) \ p \ ~(g k = {})} = setsum (\(x,k). content k *\<^sub>R f x) ((\(x,k). (x,g k)) ` p)" apply(rule setsum_mono_zero_left) prefer 3 - proof fix g::"('a \ bool) \ 'a \ bool" and i::"('a) \ (('a) set)" + proof fix g::"'a set \ 'a set" and i::"('a) \ (('a) set)" assume "i \ (\(x, k). (x, g k)) ` p - {(x, g k) |x k. (x, k) \ p \ g k \ {}}" then obtain x k where xk:"i=(x,g k)" "(x,k)\p" "(x,g k) \ {(x, g k) |x k. (x, k) \ p \ g k \ {}}" by auto have "content (g k) = 0" using xk using content_empty by auto @@ -3010,9 +3004,9 @@ lemma gauge_modify: assumes "(\s. open s \ open {x. f(x) \ s})" "gauge d" - shows "gauge (\x y. d (f x) (f y))" + shows "gauge (\x. {y. f y \ d (f x)})" using assms unfolding gauge_def apply safe defer apply(erule_tac x="f x" in allE) - apply(erule_tac x="d (f x)" in allE) unfolding mem_def Collect_def by auto + apply(erule_tac x="d (f x)" in allE) by auto subsection {* Only need trivial subintervals if the interval itself is trivial. *} @@ -3200,7 +3194,7 @@ show ?thesis unfolding has_integral_def has_integral_compact_interval_def apply(subst if_P) apply(rule,rule,rule wz) proof safe fix e::real assume e:"e>0" hence "e * r > 0" using assms(1) by(rule mult_pos_pos) from assms(8)[unfolded has_integral,rule_format,OF this] guess d apply-by(erule exE conjE)+ note d=this[rule_format] - def d' \ "\x y. d (g x) (g y)" have d':"\x. d' x = {y. g y \ (d (g x))}" unfolding d'_def by(auto simp add:mem_def) + def d' \ "\x. {y. g y \ d (g x)}" have d':"\x. d' x = {y. g y \ (d (g x))}" unfolding d'_def .. show "\d. gauge d \ (\p. p tagged_division_of h ` {a..b} \ d fine p \ norm ((\(x, k)\p. content k *\<^sub>R f (g x)) - (1 / r) *\<^sub>R i) < e)" proof(rule_tac x=d' in exI,safe) show "gauge d'" using d(1) unfolding gauge_def d' using continuous_open_preimage_univ[OF assms(4)] by auto fix p assume as:"p tagged_division_of h ` {a..b}" "d' fine p" note p = tagged_division_ofD[OF as(1)] diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Linear_Algebra.thy --- a/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Aug 12 09:17:30 2011 -0700 @@ -648,17 +648,17 @@ subsection {* A generic notion of "hull" (convex, affine, conic hull and closure). *} -definition hull :: "'a set set \ 'a set \ 'a set" (infixl "hull" 75) where - "S hull s = Inter {t. t \ S \ s \ t}" - -lemma hull_same: "s \ S \ S hull s = s" +definition hull :: "('a set \ bool) \ 'a set \ 'a set" (infixl "hull" 75) where + "S hull s = Inter {t. S t \ s \ t}" + +lemma hull_same: "S s \ S hull s = s" unfolding hull_def by auto -lemma hull_in: "(\T. T \ S ==> Inter T \ S) ==> (S hull s) \ S" -unfolding hull_def subset_iff by auto - -lemma hull_eq: "(\T. T \ S ==> Inter T \ S) ==> (S hull s) = s \ s \ S" -using hull_same[of s S] hull_in[of S s] by metis +lemma hull_in: "(\T. Ball T S ==> S (Inter T)) ==> S (S hull s)" +unfolding hull_def Ball_def by auto + +lemma hull_eq: "(\T. Ball T S ==> S (Inter T)) ==> (S hull s) = s \ S s" +using hull_same[of S s] hull_in[of S s] by metis lemma hull_hull: "S hull (S hull s) = S hull s" @@ -670,29 +670,29 @@ lemma hull_mono: " s \ t ==> (S hull s) \ (S hull t)" unfolding hull_def by blast -lemma hull_antimono: "S \ T ==> (T hull s) \ (S hull s)" +lemma hull_antimono: "\x. S x \ T x ==> (T hull s) \ (S hull s)" unfolding hull_def by blast -lemma hull_minimal: "s \ t \ t \ S ==> (S hull s) \ t" +lemma hull_minimal: "s \ t \ S t ==> (S hull s) \ t" unfolding hull_def by blast -lemma subset_hull: "t \ S ==> S hull s \ t \ s \ t" +lemma subset_hull: "S t ==> S hull s \ t \ s \ t" unfolding hull_def by blast -lemma hull_unique: "s \ t \ t \ S \ (\t'. s \ t' \ t' \ S ==> t \ t') +lemma hull_unique: "s \ t \ S t \ (\t'. s \ t' \ S t' ==> t \ t') ==> (S hull s = t)" unfolding hull_def by auto lemma hull_induct: "(\x. x\ S \ P x) \ Q {x. P x} \ \x\ Q hull S. P x" using hull_minimal[of S "{x. P x}" Q] - by (auto simp add: subset_eq Collect_def mem_def) + by (auto simp add: subset_eq) lemma hull_inc: "x \ S \ x \ P hull S" by (metis hull_subset subset_eq) lemma hull_union_subset: "(S hull s) \ (S hull t) \ (S hull (s \ t))" unfolding Un_subset_iff by (metis hull_mono Un_upper1 Un_upper2) -lemma hull_union: assumes T: "\T. T \ S ==> Inter T \ S" +lemma hull_union: assumes T: "\T. Ball T S ==> S (Inter T)" shows "S hull (s \ t) = S hull (S hull s \ S hull t)" apply rule apply (rule hull_mono) @@ -907,24 +907,9 @@ lemma (in real_vector) subspace_span: "subspace(span S)" unfolding span_def - apply (rule hull_in[unfolded mem_def]) + apply (rule hull_in) apply (simp only: subspace_def Inter_iff Int_iff subset_eq) apply auto - apply (erule_tac x="X" in ballE) - apply (simp add: mem_def) - apply blast - apply (erule_tac x="X" in ballE) - apply (erule_tac x="X" in ballE) - apply (erule_tac x="X" in ballE) - apply (clarsimp simp add: mem_def) - apply simp - apply simp - apply simp - apply (erule_tac x="X" in ballE) - apply (erule_tac x="X" in ballE) - apply (simp add: mem_def) - apply simp - apply simp done lemma (in real_vector) span_clauses: @@ -935,21 +920,18 @@ by (metis span_def hull_subset subset_eq) (metis subspace_span subspace_def)+ -lemma (in real_vector) span_induct: assumes SP: "\x. x \ S ==> P x" - and P: "subspace P" and x: "x \ span S" shows "P x" +lemma (in real_vector) span_induct: assumes SP: "\x. x \ S ==> x \ P" + and P: "subspace P" and x: "x \ span S" shows "x \ P" proof- - from SP have SP': "S \ P" by (simp add: mem_def subset_eq) - from P have P': "P \ subspace" by (simp add: mem_def) - from x hull_minimal[OF SP' P', unfolded span_def[symmetric]] - show "P x" by (metis mem_def subset_eq) + from SP have SP': "S \ P" by (simp add: subset_eq) + from x hull_minimal[where S=subspace, OF SP' P, unfolded span_def[symmetric]] + show "x \ P" by (metis subset_eq) qed lemma span_empty[simp]: "span {} = {0}" apply (simp add: span_def) apply (rule hull_unique) - apply (auto simp add: mem_def subspace_def) - unfolding mem_def[of "0::'a", symmetric] - apply simp + apply (auto simp add: subspace_def) done lemma (in real_vector) independent_empty[intro]: "independent {}" @@ -968,21 +950,21 @@ done lemma (in real_vector) span_subspace: "A \ B \ B \ span A \ subspace B \ span A = B" - by (metis order_antisym span_def hull_minimal mem_def) + by (metis order_antisym span_def hull_minimal) lemma (in real_vector) span_induct': assumes SP: "\x \ S. P x" - and P: "subspace P" shows "\x \ span S. P x" + and P: "subspace {x. P x}" shows "\x \ span S. P x" using span_induct SP P by blast -inductive (in real_vector) span_induct_alt_help for S:: "'a \ bool" +inductive_set (in real_vector) span_induct_alt_help for S:: "'a set" where - span_induct_alt_help_0: "span_induct_alt_help S 0" - | span_induct_alt_help_S: "x \ S \ span_induct_alt_help S z \ span_induct_alt_help S (c *\<^sub>R x + z)" + span_induct_alt_help_0: "0 \ span_induct_alt_help S" + | span_induct_alt_help_S: "x \ S \ z \ span_induct_alt_help S \ (c *\<^sub>R x + z) \ span_induct_alt_help S" lemma span_induct_alt': assumes h0: "h 0" and hS: "\c x y. x \ S \ h y \ h (c *\<^sub>R x + y)" shows "\x \ span S. h x" proof- - {fix x:: "'a" assume x: "span_induct_alt_help S x" + {fix x:: "'a" assume x: "x \ span_induct_alt_help S" have "h x" apply (rule span_induct_alt_help.induct[OF x]) apply (rule h0) @@ -991,19 +973,19 @@ note th0 = this {fix x assume x: "x \ span S" - have "span_induct_alt_help S x" + have "x \ span_induct_alt_help S" proof(rule span_induct[where x=x and S=S]) show "x \ span S" using x . next fix x assume xS : "x \ S" from span_induct_alt_help_S[OF xS span_induct_alt_help_0, of 1] - show "span_induct_alt_help S x" by simp + show "x \ span_induct_alt_help S" by simp next - have "span_induct_alt_help S 0" by (rule span_induct_alt_help_0) + have "0 \ span_induct_alt_help S" by (rule span_induct_alt_help_0) moreover - {fix x y assume h: "span_induct_alt_help S x" "span_induct_alt_help S y" + {fix x y assume h: "x \ span_induct_alt_help S" "y \ span_induct_alt_help S" from h - have "span_induct_alt_help S (x + y)" + have "(x + y) \ span_induct_alt_help S" apply (induct rule: span_induct_alt_help.induct) apply simp unfolding add_assoc @@ -1012,8 +994,8 @@ apply simp done} moreover - {fix c x assume xt: "span_induct_alt_help S x" - then have "span_induct_alt_help S (c *\<^sub>R x)" + {fix c x assume xt: "x \ span_induct_alt_help S" + then have "(c *\<^sub>R x) \ span_induct_alt_help S" apply (induct rule: span_induct_alt_help.induct) apply (simp add: span_induct_alt_help_0) apply (simp add: scaleR_right_distrib) @@ -1023,7 +1005,7 @@ done } ultimately show "subspace (span_induct_alt_help S)" - unfolding subspace_def mem_def Ball_def by blast + unfolding subspace_def Ball_def by blast qed} with th0 show ?thesis by blast qed @@ -1081,23 +1063,22 @@ apply (clarsimp simp add: image_iff) apply (frule span_superset) apply blast - apply (simp only: mem_def) apply (rule subspace_linear_image[OF lf]) apply (rule subspace_span) apply (rule x) done} moreover {fix x assume x: "x \ span S" - have th0:"(\a. f a \ span (f ` S)) = {x. f x \ span (f ` S)}" apply (rule set_eqI) - unfolding mem_def Collect_def .. - have "f x \ span (f ` S)" + have "x \ {x. f x \ span (f ` S)}" apply (rule span_induct[where S=S]) + apply simp apply (rule span_superset) apply simp - apply (subst th0) apply (rule subspace_linear_preimage[OF lf subspace_span, of "f ` S"]) apply (rule x) - done} + done + hence "f x \ span (f ` S)" by simp + } ultimately show ?thesis by blast qed @@ -1120,29 +1101,27 @@ apply (rule exI[where x=0]) apply (rule span_superset) by simp} - ultimately have "?P x" by blast} - moreover have "subspace ?P" + ultimately have "x \ Collect ?P" by blast} + moreover have "subspace (Collect ?P)" unfolding subspace_def apply auto - apply (simp add: mem_def) apply (rule exI[where x=0]) using span_0[of "S - {b}"] - apply (simp add: mem_def) - apply (clarsimp simp add: mem_def) + apply simp apply (rule_tac x="k + ka" in exI) apply (subgoal_tac "x + y - (k + ka) *\<^sub>R b = (x - k*\<^sub>R b) + (y - ka *\<^sub>R b)") apply (simp only: ) - apply (rule span_add[unfolded mem_def]) + apply (rule span_add) apply assumption+ apply (simp add: algebra_simps) - apply (clarsimp simp add: mem_def) apply (rule_tac x= "c*k" in exI) apply (subgoal_tac "c *\<^sub>R x - (c * k) *\<^sub>R b = c*\<^sub>R (x - k*\<^sub>R b)") apply (simp only: ) - apply (rule span_mul[unfolded mem_def]) + apply (rule span_mul) apply assumption by (simp add: algebra_simps) - ultimately show "?P a" using aS span_induct[where S=S and P= "?P"] by metis + ultimately have "a \ Collect ?P" using aS by (rule span_induct) + thus "?P a" by simp qed lemma span_breakdown_eq: @@ -1266,13 +1245,13 @@ by (auto intro: span_superset span_mul)} moreover have "\x \ span P. x \ ?E" - unfolding mem_def Collect_def proof(rule span_induct_alt') - show "?h 0" + show "0 \ Collect ?h" + unfolding mem_Collect_eq apply (rule exI[where x="{}"]) by simp next fix c x y - assume x: "x \ P" and hy: "?h y" + assume x: "x \ P" and hy: "y \ Collect ?h" from hy obtain S u where fS: "finite S" and SP: "S\P" and u: "setsum (\v. u v *\<^sub>R v) S = y" by blast let ?S = "insert x S" @@ -1303,7 +1282,8 @@ by (simp add: th00 setsum_clauses add_commute cong del: if_weak_cong)} ultimately have "?Q ?S ?u (c*\<^sub>R x + y)" by (cases "x \ S", simp, simp) - then show "?h (c*\<^sub>R x + y)" + then show "(c*\<^sub>R x + y) \ Collect ?h" + unfolding mem_Collect_eq apply - apply (rule exI[where x="?S"]) apply (rule exI[where x="?u"]) by metis @@ -1581,12 +1561,6 @@ subsection{* Euclidean Spaces as Typeclass*} -lemma (in euclidean_space) basis_inj[simp, intro]: "inj_on basis {.. 'c::real_vector" assumes *: "inj_on f {.. (\a u. a < D \ (\i\{..R f i) \ f a)" @@ -2274,7 +2248,7 @@ with a have a0:"?a \ 0" by auto have "\x\span B. ?a \ x = 0" proof(rule span_induct') - show "subspace (\x. ?a \ x = 0)" by (auto simp add: subspace_def mem_def inner_simps) + show "subspace {x. ?a \ x = 0}" by (auto simp add: subspace_def inner_simps) next {fix x assume x: "x \ B" from x have B': "B = insert x (B - {x})" by blast @@ -2554,12 +2528,8 @@ lemma linear_eq_0_span: assumes lf: "linear f" and f0: "\x\B. f x = 0" shows "\x \ span B. f x = 0" -proof - fix x assume x: "x \ span B" - let ?P = "\x. f x = 0" - from subspace_kernel[OF lf] have "subspace ?P" unfolding Collect_def . - with x f0 span_induct[of B "?P" x] show "f x = 0" by blast -qed + using f0 subspace_kernel[OF lf] + by (rule span_induct') lemma linear_eq_0: assumes lf: "linear f" and SB: "S \ span B" and f0: "\x\B. f x = 0" @@ -2600,24 +2570,19 @@ and fg: "\x\ B. \y\ C. f x y = g x y" shows "\x\S. \y\T. f x y = g x y " proof- - let ?P = "\x. \y\ span C. f x y = g x y" + let ?P = "{x. \y\ span C. f x y = g x y}" from bf bg have sp: "subspace ?P" unfolding bilinear_def linear_def subspace_def bf bg - by(auto simp add: span_0 mem_def bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def intro: bilinear_ladd[OF bf]) + by(auto simp add: span_0 bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def intro: bilinear_ladd[OF bf]) have "\x \ span B. \y\ span C. f x y = g x y" - apply - + apply (rule span_induct' [OF _ sp]) apply (rule ballI) - apply (rule span_induct[of B ?P]) - defer - apply (rule sp) - apply assumption - apply (clarsimp simp add: Ball_def) - apply (rule_tac P="\y. f xa y = g xa y" and S=C in span_induct) - using fg + apply (rule span_induct') + apply (simp add: fg) apply (auto simp add: subspace_def) using bf bg unfolding bilinear_def linear_def - by(auto simp add: span_0 mem_def bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add Ball_def intro: bilinear_ladd[OF bf]) + by(auto simp add: span_0 bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add Ball_def intro: bilinear_ladd[OF bf]) then show ?thesis using SB TC by (auto intro: ext) qed diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Path_Connected.thy --- a/src/HOL/Multivariate_Analysis/Path_Connected.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Path_Connected.thy Fri Aug 12 09:17:30 2011 -0700 @@ -387,16 +387,14 @@ subsection {* Can also consider it as a set, as the name suggests. *} -lemma path_component_set: "path_component s x = { y. (\g. path g \ path_image g \ s \ pathstart g = x \ pathfinish g = y )}" - apply(rule set_eqI) unfolding mem_Collect_eq unfolding mem_def path_component_def by auto - -lemma mem_path_component_set:"x \ path_component s y \ path_component s y x" unfolding mem_def by auto +lemma path_component_set: "{y. path_component s x y} = { y. (\g. path g \ path_image g \ s \ pathstart g = x \ pathfinish g = y )}" + apply(rule set_eqI) unfolding mem_Collect_eq unfolding path_component_def by auto -lemma path_component_subset: "(path_component s x) \ s" - apply(rule, rule path_component_mem(2)) by(auto simp add:mem_def) +lemma path_component_subset: "{y. path_component s x y} \ s" + apply(rule, rule path_component_mem(2)) by auto -lemma path_component_eq_empty: "path_component s x = {} \ x \ s" - apply rule apply(drule equals0D[of _ x]) defer apply(rule equals0I) unfolding mem_path_component_set +lemma path_component_eq_empty: "{y. path_component s x y} = {} \ x \ s" + apply rule apply(drule equals0D[of _ x]) defer apply(rule equals0I) unfolding mem_Collect_eq apply(drule path_component_mem(1)) using path_component_refl by auto subsection {* Path connectedness of a space. *} @@ -406,9 +404,9 @@ lemma path_connected_component: "path_connected s \ (\x\s. \y\s. path_component s x y)" unfolding path_connected_def path_component_def by auto -lemma path_connected_component_set: "path_connected s \ (\x\s. path_component s x = s)" +lemma path_connected_component_set: "path_connected s \ (\x\s. {y. path_component s x y} = s)" unfolding path_connected_component apply(rule, rule, rule, rule path_component_subset) - unfolding subset_eq mem_path_component_set Ball_def mem_def by auto + unfolding subset_eq mem_Collect_eq Ball_def by auto subsection {* Some useful lemmas about path-connectedness. *} @@ -435,25 +433,25 @@ lemma open_path_component: fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*) - assumes "open s" shows "open(path_component s x)" + assumes "open s" shows "open {y. path_component s x y}" unfolding open_contains_ball proof - fix y assume as:"y \ path_component s x" - hence "y\s" apply- apply(rule path_component_mem(2)) unfolding mem_def by auto + fix y assume as:"y \ {y. path_component s x y}" + hence "y\s" apply- apply(rule path_component_mem(2)) unfolding mem_Collect_eq by auto then obtain e where e:"e>0" "ball y e \ s" using assms[unfolded open_contains_ball] by auto - show "\e>0. ball y e \ path_component s x" apply(rule_tac x=e in exI) apply(rule,rule `e>0`,rule) unfolding mem_ball mem_path_component_set proof- + show "\e>0. ball y e \ {y. path_component s x y}" apply(rule_tac x=e in exI) apply(rule,rule `e>0`,rule) unfolding mem_ball mem_Collect_eq proof- fix z assume "dist y z < e" thus "path_component s x z" apply(rule_tac path_component_trans[of _ _ y]) defer apply(rule path_component_of_subset[OF e(2)]) apply(rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format]) using `e>0` - using as[unfolded mem_def] by auto qed qed + using as by auto qed qed lemma open_non_path_component: fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*) - assumes "open s" shows "open(s - path_component s x)" + assumes "open s" shows "open(s - {y. path_component s x y})" unfolding open_contains_ball proof - fix y assume as:"y\s - path_component s x" + fix y assume as:"y\s - {y. path_component s x y}" then obtain e where e:"e>0" "ball y e \ s" using assms[unfolded open_contains_ball] by auto - show "\e>0. ball y e \ s - path_component s x" apply(rule_tac x=e in exI) apply(rule,rule `e>0`,rule,rule) defer proof(rule ccontr) - fix z assume "z\ball y e" "\ z \ path_component s x" - hence "y \ path_component s x" unfolding not_not mem_path_component_set using `e>0` + show "\e>0. ball y e \ s - {y. path_component s x y}" apply(rule_tac x=e in exI) apply(rule,rule `e>0`,rule,rule) defer proof(rule ccontr) + fix z assume "z\ball y e" "\ z \ {y. path_component s x y}" + hence "y \ {y. path_component s x y}" unfolding not_not mem_Collect_eq using `e>0` apply- apply(rule path_component_trans,assumption) apply(rule path_component_of_subset[OF e(2)]) apply(rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format]) by auto thus False using as by auto qed(insert e(2), auto) qed @@ -462,11 +460,11 @@ fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*) assumes "open s" "connected s" shows "path_connected s" unfolding path_connected_component_set proof(rule,rule,rule path_component_subset, rule) - fix x y assume "x \ s" "y \ s" show "y \ path_component s x" proof(rule ccontr) - assume "y \ path_component s x" moreover - have "path_component s x \ s \ {}" using `x\s` path_component_eq_empty path_component_subset[of s x] by auto + fix x y assume "x \ s" "y \ s" show "y \ {y. path_component s x y}" proof(rule ccontr) + assume "y \ {y. path_component s x y}" moreover + have "{y. path_component s x y} \ s \ {}" using `x\s` path_component_eq_empty path_component_subset[of s x] by auto ultimately show False using `y\s` open_non_path_component[OF assms(1)] open_path_component[OF assms(1)] - using assms(2)[unfolded connected_def not_ex, rule_format, of"path_component s x" "s - path_component s x"] by auto + using assms(2)[unfolded connected_def not_ex, rule_format, of"{y. path_component s x y}" "s - {y. path_component s x y}"] by auto qed qed lemma path_connected_continuous_image: diff -r 238c5ea1e2ce -r 75ea0e390a92 src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Fri Aug 12 17:01:30 2011 +0200 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Fri Aug 12 09:17:30 2011 -0700 @@ -22,8 +22,8 @@ subsection{* General notion of a topology *} -definition "istopology L \ {} \ L \ (\S \L. \T \L. S \ T \ L) \ (\K. K \L \ \ K \ L)" -typedef (open) 'a topology = "{L::('a set) set. istopology L}" +definition "istopology L \ L {} \ (\S T. L S \ L T \ L (S \ T)) \ (\K. Ball K L \ L (\ K))" +typedef (open) 'a topology = "{L::('a set) \ bool. istopology L}" morphisms "openin" "topology" unfolding istopology_def by blast @@ -31,7 +31,7 @@ using openin[of U] by blast lemma topology_inverse': "istopology U \ openin (topology U) = U" - using topology_inverse[unfolded mem_def Collect_def] . + using topology_inverse[unfolded mem_Collect_eq] . lemma topology_inverse_iff: "istopology U \ openin (topology U) = U" using topology_inverse[of U] istopology_open_in[of "topology U"] by auto @@ -41,7 +41,7 @@ {assume "T1=T2" hence "\S. openin T1 S \ openin T2 S" by simp} moreover {assume H: "\S. openin T1 S \ openin T2 S" - hence "openin T1 = openin T2" by (metis mem_def set_eqI) + hence "openin T1 = openin T2" by (simp add: fun_eq_iff) hence "topology (openin T1) = topology (openin T2)" by simp hence "T1 = T2" unfolding openin_inverse .} ultimately show ?thesis by blast @@ -58,8 +58,8 @@ shows "openin U {}" "\S T. openin U S \ openin U T \ openin U (S\T)" "\K. (\S \ K. openin U S) \ openin U (\K)" - using openin[of U] unfolding istopology_def Collect_def mem_def - unfolding subset_eq Ball_def mem_def by auto + using openin[of U] unfolding istopology_def mem_Collect_eq + by fast+ lemma openin_subset[intro]: "openin U S \ S \ topspace U" unfolding topspace_def by blast @@ -130,33 +130,38 @@ subsection{* Subspace topology. *} -definition "subtopology U V = topology {S \ V |S. openin U S}" - -lemma istopology_subtopology: "istopology {S \ V |S. openin U S}" (is "istopology ?L") +term "{f x |x. P x}" +term "{y. \x. y = f x \ P x}" + +definition "subtopology U V = topology (\T. \S. T = S \ V \ openin U S)" + +lemma istopology_subtopology: "istopology (\T. \S. T = S \ V \ openin U S)" + (is "istopology ?L") proof- - have "{} \ ?L" by blast - {fix A B assume A: "A \ ?L" and B: "B \ ?L" + have "?L {}" by blast + {fix A B assume A: "?L A" and B: "?L B" from A B obtain Sa and Sb where Sa: "openin U Sa" "A = Sa \ V" and Sb: "openin U Sb" "B = Sb \ V" by blast have "A\B = (Sa \ Sb) \ V" "openin U (Sa \ Sb)" using Sa Sb by blast+ - then have "A \ B \ ?L" by blast} + then have "?L (A \ B)" by blast} moreover - {fix K assume K: "K \ ?L" - have th0: "?L = (\S. S \ V) ` openin U " + {fix K assume K: "K \ Collect ?L" + have th0: "Collect ?L = (\S. S \ V) ` Collect (openin U)" apply (rule set_eqI) apply (simp add: Ball_def image_iff) - by (metis mem_def) + by metis from K[unfolded th0 subset_image_iff] - obtain Sk where Sk: "Sk \ openin U" "K = (\S. S \ V) ` Sk" by blast + obtain Sk where Sk: "Sk \ Collect (openin U)" "K = (\S. S \ V) ` Sk" by blast have "\K = (\Sk) \ V" using Sk by auto - moreover have "openin U (\ Sk)" using Sk by (auto simp add: subset_eq mem_def) - ultimately have "\K \ ?L" by blast} - ultimately show ?thesis unfolding istopology_def by blast + moreover have "openin U (\ Sk)" using Sk by (auto simp add: subset_eq) + ultimately have "?L (\K)" by blast} + ultimately show ?thesis + unfolding subset_eq mem_Collect_eq istopology_def by blast qed lemma openin_subtopology: "openin (subtopology U V) S \ (\ T. (openin U T) \ (S = T \ V))" unfolding subtopology_def topology_inverse'[OF istopology_subtopology] - by (auto simp add: Collect_def) + by auto lemma topspace_subtopology: "topspace(subtopology U V) = topspace U \ V" by (auto simp add: topspace_def openin_subtopology) @@ -210,7 +215,7 @@ apply (rule cong[where x=S and y=S]) apply (rule topology_inverse[symmetric]) apply (auto simp add: istopology_def) - by (auto simp add: mem_def subset_eq) + done lemma topspace_euclidean: "topspace euclidean = UNIV" apply (simp add: topspace_def) @@ -266,7 +271,7 @@ "a - b \ c \ a \ c +b" "a - b \ c \ a \ c +b" by arith+ lemma open_ball[intro, simp]: "open (ball x e)" - unfolding open_dist ball_def Collect_def Ball_def mem_def + unfolding open_dist ball_def mem_Collect_eq Ball_def unfolding dist_commute apply clarify apply (rule_tac x="e - dist xa x" in exI) @@ -479,7 +484,7 @@ { fix e :: real assume "0 < e" def y \ "x + scaleR (e/2) (sgn (basis 0))" from `0 < e` have "y \ x" - unfolding y_def by (simp add: sgn_zero_iff basis_eq_0_iff DIM_positive) + unfolding y_def by (simp add: sgn_zero_iff DIM_positive) from `0 < e` have "dist y x < e" unfolding y_def by (simp add: dist_norm norm_sgn) from `y \ x` and `dist y x < e` @@ -492,7 +497,7 @@ unfolding closed_def apply (subst open_subopen) apply (simp add: islimpt_def subset_eq) - by (metis ComplE ComplI insertCI insert_absorb mem_def) + by (metis ComplE ComplI) lemma islimpt_EMPTY[simp]: "\ x islimpt {}" unfolding islimpt_def by auto @@ -691,14 +696,13 @@ } ultimately show ?thesis using hull_unique[of S, of "closure S", of closed] - unfolding mem_def by simp qed lemma closure_eq: "closure S = S \ closed S" unfolding closure_hull - using hull_eq[of closed, unfolded mem_def, OF closed_Inter, of S] - by (metis mem_def subset_eq) + using hull_eq[of closed, OF closed_Inter, of S] + by metis lemma closure_closed[simp]: "closed S \ closure S = S" using closure_eq[of S] @@ -721,12 +725,12 @@ lemma closure_minimal: "S \ T \ closed T \ closure S \ T" using hull_minimal[of S T closed] - unfolding closure_hull mem_def + unfolding closure_hull by simp lemma closure_unique: "S \ T \ closed T \ (\ T'. S \ T' \ closed T' \ T \ T') \ closure S = T" using hull_unique[of S T closed] - unfolding closure_hull mem_def + unfolding closure_hull by simp lemma closure_empty[simp]: "closure {} = {}" @@ -1623,7 +1627,7 @@ qed lemma open_contains_cball_eq: "open S ==> (\x. x \ S \ (\e>0. cball x e \ S))" - by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball mem_def) + by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball) lemma mem_interior_cball: "x \ interior S \ (\e>0. cball x e \ S)" apply (simp add: interior_def, safe) @@ -5646,7 +5650,7 @@ lemma subspace_substandard: "subspace {x::'a::euclidean_space. (\i x$$i = 0)}" - unfolding subspace_def by(auto simp add: euclidean_simps) + unfolding subspace_def by(auto simp add: euclidean_simps) (* FIXME: duplicate rewrite rule *) lemma closed_substandard: "closed {x::'a::euclidean_space. \i x$$i = 0}" (is "closed ?A") @@ -5674,7 +5678,7 @@ let ?D = "{.. ?A" by(auto simp add:basis_component) + have "?B \ ?A" by auto moreover { fix x::"'a" assume "x\?A" hence "finite d" "x\?A" using assms by(auto intro:finite_subset) @@ -5690,7 +5694,7 @@ have y:"x = y + (x$$k) *\<^sub>R basis k" unfolding y_def by auto { fix i assume i':"i \ F" hence "y $$ i = 0" unfolding y_def - using *[THEN spec[where x=i]] by(auto simp add: euclidean_simps basis_component) } + using *[THEN spec[where x=i]] by(auto simp add: euclidean_simps) } hence "y \ span (basis ` F)" using insert(3) by auto hence "y \ span (basis ` (insert k F))" using span_mono[of "?bas ` F" "?bas ` (insert k F)"] @@ -6025,7 +6029,7 @@ have lima:"((fst \ (h \ r)) ---> a) sequentially" and limb:"((snd \ (h \ r)) ---> b) sequentially" using lr - unfolding o_def a_def b_def by (simp_all add: tendsto_intros) + unfolding o_def a_def b_def by (rule tendsto_intros)+ { fix n::nat have *:"\fx fy (x::'a) y. dist fx fy \ dist x y \ \ (dist (fx - fy) (a - b) < dist a b - dist x y)" unfolding dist_norm by norm