# HG changeset patch # User traytel # Date 1393606492 -3600 # Node ID aa1acc25126b03b104a5c5d2096eb031c047e29e # Parent 63d63d854fae399d27ec9df41bdf6f4b7d4ae13b load Metis a little later diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_Cardinal_Arithmetic.thy --- a/src/HOL/BNF_Cardinal_Arithmetic.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_Cardinal_Arithmetic.thy Fri Feb 28 17:54:52 2014 +0100 @@ -57,15 +57,19 @@ \x. if x \ A then snd (fg x) else undefined)" let ?G = "\(f, g) x. if x \ A then (f x, g x) else undefined" have "bij_betw ?F ?LHS ?RHS" unfolding bij_betw_def inj_on_def - apply safe - apply (simp add: Func_def fun_eq_iff) - apply (metis (no_types) pair_collapse) - apply (auto simp: Func_def fun_eq_iff)[2] - proof - - fix f g assume "f \ Func A B" "g \ Func A C" - thus "(f, g) \ ?F ` Func A (B \ C)" - by (intro image_eqI[of _ _ "?G (f, g)"]) (auto simp: Func_def) - qed + proof (intro conjI impI ballI equalityI subsetI) + fix f g assume *: "f \ Func A (B \ C)" "g \ Func A (B \ C)" "?F f = ?F g" + show "f = g" + proof + fix x from * have "fst (f x) = fst (g x) \ snd (f x) = snd (g x)" + by (case_tac "x \ A") (auto simp: Func_def fun_eq_iff split: if_splits) + then show "f x = g x" by (subst (1 2) surjective_pairing) simp + qed + next + fix fg assume "fg \ Func A B \ Func A C" + thus "fg \ ?F ` Func A (B \ C)" + by (intro image_eqI[of _ _ "?G fg"]) (auto simp: Func_def) + qed (auto simp: Func_def fun_eq_iff) thus ?thesis using card_of_ordIso by blast qed @@ -89,7 +93,7 @@ (*helper*) lemma Cnotzero_imp_not_empty: "Cnotzero r \ Field r \ {}" -by (metis Card_order_iff_ordIso_card_of czero_def) + unfolding Card_order_iff_ordIso_card_of czero_def by force lemma czeroI: "\Card_order r; Field r = {}\ \ r =o czero" @@ -127,33 +131,35 @@ lemma Cfinite_ordLess_Cinfinite: "\Cfinite r; Cinfinite s\ \ r o r" proof - - from inf have "natLeq \o |Field r|" by (metis cinfinite_def infinite_iff_natLeq_ordLeq) + from inf have "natLeq \o |Field r|" unfolding cinfinite_def + using infinite_iff_natLeq_ordLeq by blast also from inf have "|Field r| =o r" by (simp add: card_of_unique ordIso_symmetric) finally show ?thesis . qed lemma cinfinite_not_czero: "cinfinite r \ \ (r =o (czero :: 'a rel))" -unfolding cinfinite_def by (metis czeroE finite.emptyI) +unfolding cinfinite_def by (cases "Field r = {}") (auto dest: czeroE) lemma Cinfinite_Cnotzero: "Cinfinite r \ Cnotzero r" -by (metis cinfinite_not_czero) +by (rule conjI[OF cinfinite_not_czero]) simp_all lemma Cinfinite_cong: "\r1 =o r2; Cinfinite r1\ \ Cinfinite r2" -by (metis Card_order_ordIso2 card_of_mono2 card_of_ordLeq_infinite cinfinite_def ordIso_iff_ordLeq) +using Card_order_ordIso2[of r1 r2] unfolding cinfinite_def ordIso_iff_ordLeq +by (auto dest: card_of_ordLeq_infinite[OF card_of_mono2]) lemma cinfinite_mono: "\r1 \o r2; cinfinite r1\ \ cinfinite r2" -by (metis card_of_mono2 card_of_ordLeq_infinite cinfinite_def) +unfolding cinfinite_def by (auto dest: card_of_ordLeq_infinite[OF card_of_mono2]) subsection {* Binary sum *} @@ -170,8 +176,8 @@ lemma csum_Cnotzero1: "Cnotzero r1 \ Cnotzero (r1 +c r2)" -unfolding csum_def -by (metis Cnotzero_imp_not_empty Plus_eq_empty_conv card_of_Card_order card_of_ordIso_czero_iff_empty) +unfolding csum_def using Cnotzero_imp_not_empty[of r1] Plus_eq_empty_conv[of "Field r1" "Field r2"] + card_of_ordIso_czero_iff_empty[of "Field r1 <+> Field r2"] by (auto intro: card_of_Card_order) lemma card_order_csum: assumes "card_order r1" "card_order r2" @@ -187,15 +193,15 @@ lemma Cinfinite_csum1: "Cinfinite r1 \ Cinfinite (r1 +c r2)" -unfolding cinfinite_def csum_def by (metis Field_card_of card_of_Card_order finite_Plus_iff) +unfolding cinfinite_def csum_def by (rule conjI[OF _ card_of_Card_order]) (auto simp: Field_card_of) lemma Cinfinite_csum: "Cinfinite r1 \ Cinfinite r2 \ Cinfinite (r1 +c r2)" -unfolding cinfinite_def csum_def by (metis Field_card_of card_of_Card_order finite_Plus_iff) +unfolding cinfinite_def csum_def by (rule conjI[OF _ card_of_Card_order]) (auto simp: Field_card_of) lemma Cinfinite_csum_strong: "\Cinfinite r1; Cinfinite r2\ \ Cinfinite (r1 +c r2)" -by (metis Cinfinite_csum) +by (erule Cinfinite_csum1) lemma csum_cong: "\p1 =o r1; p2 =o r2\ \ p1 +c p2 =o r1 +c r2" by (simp only: csum_def ordIso_Plus_cong) @@ -233,15 +239,15 @@ lemma csum_csum: "(r1 +c r2) +c (r3 +c r4) =o (r1 +c r3) +c (r2 +c r4)" proof - have "(r1 +c r2) +c (r3 +c r4) =o r1 +c r2 +c (r3 +c r4)" - by (metis csum_assoc) + by (rule csum_assoc) also have "r1 +c r2 +c (r3 +c r4) =o r1 +c (r2 +c r3) +c r4" - by (metis csum_assoc csum_cong2 ordIso_symmetric) + by (intro csum_assoc csum_cong2 ordIso_symmetric) also have "r1 +c (r2 +c r3) +c r4 =o r1 +c (r3 +c r2) +c r4" - by (metis csum_com csum_cong1 csum_cong2) + by (intro csum_com csum_cong1 csum_cong2) also have "r1 +c (r3 +c r2) +c r4 =o r1 +c r3 +c r2 +c r4" - by (metis csum_assoc csum_cong2 ordIso_symmetric) + by (intro csum_assoc csum_cong2 ordIso_symmetric) also have "r1 +c r3 +c r2 +c r4 =o (r1 +c r3) +c (r2 +c r4)" - by (metis csum_assoc ordIso_symmetric) + by (intro csum_assoc ordIso_symmetric) finally show ?thesis . qed @@ -264,10 +270,10 @@ unfolding cfinite_def by (simp add: Card_order_cone) lemma cone_not_czero: "\ (cone =o czero)" -unfolding czero_def cone_def by (metis empty_not_insert card_of_empty3[of "{()}"] ordIso_iff_ordLeq) +unfolding czero_def cone_def ordIso_iff_ordLeq using card_of_empty3 empty_not_insert by blast lemma cone_ordLeq_Cnotzero: "Cnotzero r \ cone \o r" -unfolding cone_def by (metis Card_order_singl_ordLeq czeroI) +unfolding cone_def by (rule Card_order_singl_ordLeq) (auto intro: czeroI) subsection {* Two *} @@ -280,7 +286,7 @@ lemma ctwo_not_czero: "\ (ctwo =o czero)" using card_of_empty3[of "UNIV :: bool set"] ordIso_iff_ordLeq -unfolding czero_def ctwo_def by (metis UNIV_not_empty) +unfolding czero_def ctwo_def using UNIV_not_empty by auto lemma ctwo_Cnotzero: "Cnotzero ctwo" by (simp add: ctwo_not_czero Card_order_ctwo) @@ -330,13 +336,13 @@ by (simp only: cprod_def ordLeq_Times_mono2) lemma ordLeq_cprod2: "\Cnotzero p1; Card_order p2\ \ p2 \o p1 *c p2" -unfolding cprod_def by (metis Card_order_Times2 czeroI) +unfolding cprod_def by (rule Card_order_Times2) (auto intro: czeroI) lemma cinfinite_cprod: "\cinfinite r1; cinfinite r2\ \ cinfinite (r1 *c r2)" by (simp add: cinfinite_def cprod_def Field_card_of infinite_cartesian_product) lemma cinfinite_cprod2: "\Cnotzero r1; Cinfinite r2\ \ cinfinite (r1 *c r2)" -by (metis cinfinite_mono ordLeq_cprod2) +by (rule cinfinite_mono) (auto intro: ordLeq_cprod2) lemma Cinfinite_cprod2: "\Cnotzero r1; Cinfinite r2\ \ Cinfinite (r1 *c r2)" by (blast intro: cinfinite_cprod2 Card_order_cprod) @@ -364,7 +370,8 @@ unfolding csum_def cprod_def by (simp add: Field_card_of card_of_Times_Plus_distrib ordIso_symmetric) lemma csum_absorb2': "\Card_order r2; r1 \o r2; cinfinite r1 \ cinfinite r2\ \ r1 +c r2 =o r2" -unfolding csum_def by (metis Card_order_Plus_infinite cinfinite_def cinfinite_mono) +unfolding csum_def by (rule conjunct2[OF Card_order_Plus_infinite]) + (auto simp: cinfinite_def dest: cinfinite_mono) lemma csum_absorb1': assumes card: "Card_order r2" @@ -390,10 +397,10 @@ shows "p1 ^c p2 \o r1 ^c r2" proof(cases "Field p1 = {}") case True - hence "|Field |Func (Field p2) (Field p1)|| \o cone" + hence "Field p2 \ {} \ Func (Field p2) {} = {}" unfolding Func_is_emp by simp + with True have "|Field |Func (Field p2) (Field p1)|| \o cone" unfolding cone_def Field_card_of - by (cases "Field p2 = {}", auto intro: card_of_ordLeqI2 simp: Func_empty) - (metis Func_is_emp card_of_empty ex_in_conv) + by (cases "Field p2 = {}", auto intro: surj_imp_ordLeq simp: Func_empty) hence "|Func (Field p2) (Field p1)| \o cone" by (simp add: Field_card_of cexp_def) hence "p1 ^c p2 \o cone" unfolding cexp_def . thus ?thesis @@ -429,7 +436,7 @@ assumes 1: "p1 \o r1" and 2: "p2 \o r2" and n: "p2 =o czero \ r2 =o czero" and card: "Card_order p2" shows "p1 ^c p2 \o r1 ^c r2" - by (metis (full_types) "1" "2" card cexp_mono' czeroE czeroI n) + by (rule cexp_mono'[OF 1 2 czeroE[OF n[OF czeroI[OF card]]]]) lemma cexp_mono1: assumes 1: "p1 \o r1" and q: "Card_order q" @@ -451,7 +458,7 @@ lemma cexp_mono2_Cnotzero: assumes "p2 \o r2" "Card_order q" "Cnotzero p2" shows "q ^c p2 \o q ^c r2" -by (metis assms cexp_mono2' czeroI) +using assms(3) czeroI by (blast intro: cexp_mono2'[OF assms(1,2)]) lemma cexp_cong: assumes 1: "p1 =o r1" and 2: "p2 =o r2" @@ -466,7 +473,7 @@ and p: "r2 =o czero \ p2 =o czero" using 0 Cr Cp czeroE czeroI by auto show ?thesis using 0 1 2 unfolding ordIso_iff_ordLeq - using r p cexp_mono[OF _ _ _ Cp] cexp_mono[OF _ _ _ Cr] by metis + using r p cexp_mono[OF _ _ _ Cp] cexp_mono[OF _ _ _ Cr] by blast qed lemma cexp_cong1: @@ -575,7 +582,7 @@ qed lemma cinfinite_cexp: "\ctwo \o q; Cinfinite r\ \ cinfinite (q ^c r)" -by (metis assms cinfinite_mono ordLeq_cexp2) +by (rule cinfinite_mono[OF ordLeq_cexp2]) simp_all lemma Cinfinite_cexp: "\ctwo \o q; Cinfinite r\ \ Cinfinite (q ^c r)" @@ -586,7 +593,7 @@ by (intro Cfinite_ordLess_Cinfinite) (auto simp: cfinite_def card_of_Card_order) lemma ctwo_ordLess_Cinfinite: "Cinfinite r \ ctwo o s" by (metis card_order_on_well_order_on ctwo_Cnotzero ordLeq_total s) - hence "Cnotzero s" by (metis Cnotzero_mono ctwo_Cnotzero s) - hence st: "Cnotzero (s *c t)" by (metis Cinfinite_cprod2 cinfinite_not_czero t) + hence "ctwo \o s" using ordLeq_total[of s ctwo] Card_order_ctwo s + by (auto intro: card_order_on_well_order_on) + hence "Cnotzero s" using Cnotzero_mono[OF ctwo_Cnotzero] s by blast + hence st: "Cnotzero (s *c t)" by (intro Cinfinite_Cnotzero[OF Cinfinite_cprod2]) (auto simp: t) have "s ^c t \o (ctwo ^c s) ^c t" using assms by (blast intro: cexp_mono1 ordLess_imp_ordLeq[OF ordLess_ctwo_cexp]) also have "(ctwo ^c s) ^c t =o ctwo ^c (s *c t)" diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_Cardinal_Order_Relation.thy --- a/src/HOL/BNF_Cardinal_Order_Relation.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_Cardinal_Order_Relation.thy Fri Feb 28 17:54:52 2014 +0100 @@ -394,18 +394,13 @@ qed lemma surj_imp_ordLeq: -assumes "B <= f ` A" -shows "|B| <=o |A|" +assumes "B \ f ` A" +shows "|B| \o |A|" proof- have "|B| <=o |f ` A|" using assms card_of_mono1 by auto thus ?thesis using card_of_image ordLeq_transitive by blast qed -lemma card_of_ordLeqI2: -assumes "B \ f ` A" -shows "|B| \o |A|" -using assms by (metis surj_imp_ordLeq) - lemma card_of_singl_ordLeq: assumes "A \ {}" shows "|{b}| \o |A|" @@ -529,7 +524,7 @@ } ultimately show ?thesis unfolding inj_on_def by auto qed - thus ?thesis using card_of_ordLeq by metis + thus ?thesis using card_of_ordLeq by blast qed corollary ordLeq_Plus_mono1: @@ -678,7 +673,7 @@ "g = (\(a,c::'c). (f a,c))" by blast have "inj_on g (A \ C) \ g ` (A \ C) \ (B \ C)" using 1 unfolding inj_on_def using g_def by auto - thus ?thesis using card_of_ordLeq by metis + thus ?thesis using card_of_ordLeq by blast qed corollary ordLeq_Times_mono1: @@ -706,11 +701,12 @@ have "\i. i \ I \ (\f. inj_on f (A i) \ f ` (A i) \ B i)" using assms by (auto simp add: card_of_ordLeq) with choice[of "\ i f. i \ I \ inj_on f (A i) \ f ` (A i) \ B i"] - obtain F where 1: "\i \ I. inj_on (F i) (A i) \ (F i) ` (A i) \ B i" by metis + obtain F where 1: "\i \ I. inj_on (F i) (A i) \ (F i) ` (A i) \ B i" + by atomize_elim (auto intro: bchoice) obtain g where g_def: "g = (\(i,a::'b). (i,F i a))" by blast have "inj_on g (Sigma I A) \ g ` (Sigma I A) \ (Sigma I B)" using 1 unfolding inj_on_def using g_def by force - thus ?thesis using card_of_ordLeq by metis + thus ?thesis using card_of_ordLeq by blast qed corollary card_of_Sigma_Times: @@ -719,7 +715,7 @@ lemma card_of_UNION_Sigma: "|\i \ I. A i| \o |SIGMA i : I. A i|" -using Ex_inj_on_UNION_Sigma[of I A] card_of_ordLeq by metis +using Ex_inj_on_UNION_Sigma[of I A] card_of_ordLeq by blast lemma card_of_bool: assumes "a1 \ a2" @@ -745,8 +741,7 @@ hence "?f False = a" by auto thus ?thesis by blast qed } - ultimately show ?thesis unfolding bij_betw_def inj_on_def - by (metis (no_types) image_subsetI order_eq_iff subsetI) + ultimately show ?thesis unfolding bij_betw_def inj_on_def by blast qed thus ?thesis using card_of_ordIso by blast qed @@ -758,7 +753,7 @@ proof- have 1: "|UNIV::bool set| \o |A|" using A2 card_of_mono1[of "{a1,a2}"] card_of_bool[of a1 a2] - ordIso_ordLeq_trans[of "|UNIV::bool set|"] by metis + ordIso_ordLeq_trans[of "|UNIV::bool set|"] by blast (* *) have "|A <+> B| \o |B <+> B|" using LEQ card_of_Plus_mono1 by blast @@ -789,11 +784,11 @@ using assms by (auto simp add: card_of_Plus_Times_aux) hence ?thesis using card_of_Plus_commute card_of_Times_commute - ordIso_ordLeq_trans ordLeq_ordIso_trans by metis + ordIso_ordLeq_trans ordLeq_ordIso_trans by blast } ultimately show ?thesis using card_of_Well_order[of A] card_of_Well_order[of B] - ordLeq_total[of "|A|"] by metis + ordLeq_total[of "|A|"] by blast qed lemma card_of_ordLeq_finite: @@ -852,7 +847,7 @@ let ?r' = "Restr r (underS r a)" assume Case2: "a \ Field r" hence 1: "under r a = underS r a \ {a} \ a \ underS r a" - using 0 Refl_under_underS underS_notIn by metis + using 0 Refl_under_underS[of r a] underS_notIn[of a r] by blast have 2: "wo_rel.ofilter r (underS r a) \ underS r a < Field r" using 0 wo_rel.underS_ofilter * 1 Case2 by fast hence "?r' finite (Field r)" using 1 unfolding phi_def by simp hence "\ finite ?B" using 8 3 card_of_ordIso_finite_Field[of r ?B] by blast - hence "\ finite A1" using 9 finite_cartesian_product finite_subset by metis + hence "\ finite A1" using 9 finite_cartesian_product finite_subset by blast moreover have temp4: "Field |A1| = A1 \ Well_order |A1| \ Card_order |A1|" using card_of_Card_order[of A1] card_of_Well_order[of A1] by (simp add: Field_card_of) @@ -1110,7 +1105,7 @@ by (auto simp add: card_of_Plus_Times) moreover have "|A \ B| =o |A|" using assms * by (simp add: card_of_Times_infinite_simps) - ultimately have "|A <+> B| \o |A|" using ordLeq_ordIso_trans by metis + ultimately have "|A <+> B| \o |A|" using ordLeq_ordIso_trans by blast thus ?thesis using card_of_Plus1 ordIso_iff_ordLeq by blast qed qed @@ -1256,7 +1251,7 @@ corollary finite_iff_ordLess_natLeq: "finite A = ( |A| o |Pow A|" - by (metis cardSuc_ordLess_ordLeq card_of_Card_order card_of_Pow) + by (rule iffD1[OF cardSuc_ordLess_ordLeq card_of_Pow]) (simp_all add: card_of_Card_order) qed qed @@ -1655,7 +1650,7 @@ unfolding bij_betw_def inj_on_def proof safe fix h :: "'a \ 'b" assume h: "h \ Func UNIV B" hence "\ a. \ b. h a = b" unfolding Func_def by auto - then obtain f where f: "\ a. h a = f a" by metis + then obtain f where f: "\ a. h a = f a" by blast hence "range f \ B" using h unfolding Func_def by auto thus "h \ (\f a. f a) ` {f. range f \ B}" using f unfolding image_def by auto qed(unfold Func_def fun_eq_iff, auto) diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_Comp.thy --- a/src/HOL/BNF_Comp.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_Comp.thy Fri Feb 28 17:54:52 2014 +0100 @@ -90,26 +90,41 @@ lemma type_copy_map_id0: "M = id \ Abs o M o Rep = id" using type_definition.Rep_inverse[OF type_copy] by auto + lemma type_copy_map_comp0: "M = M1 o M2 \ f o M o g = (f o M1 o Rep) o (Abs o M2 o g)" using type_definition.Abs_inverse[OF type_copy UNIV_I] by auto + lemma type_copy_set_map0: "S o M = image f o S' \ (S o Rep) o (Abs o M o g) = image f o (S' o g)" using type_definition.Abs_inverse[OF type_copy UNIV_I] by (auto simp: o_def fun_eq_iff) + lemma type_copy_wit: "x \ (S o Rep) (Abs y) \ x \ S y" using type_definition.Abs_inverse[OF type_copy UNIV_I] by auto + lemma type_copy_vimage2p_Grp_Rep: "vimage2p f Rep (Grp (Collect P) h) = Grp (Collect (\x. P (f x))) (Abs o h o f)" unfolding vimage2p_def Grp_def fun_eq_iff by (auto simp: type_definition.Abs_inverse[OF type_copy UNIV_I] type_definition.Rep_inverse[OF type_copy] dest: sym) + lemma type_copy_vimage2p_Grp_Abs: "\h. vimage2p g Abs (Grp (Collect P) h) = Grp (Collect (\x. P (g x))) (Rep o h o g)" unfolding vimage2p_def Grp_def fun_eq_iff by (auto simp: type_definition.Abs_inverse[OF type_copy UNIV_I] type_definition.Rep_inverse[OF type_copy] dest: sym) + +lemma type_copy_ex_RepI: "(\b. F b) = (\b. F (Rep b))" +proof safe + fix b assume "F b" + show "\b'. F (Rep b')" + proof (rule exI) + from `F b` show "F (Rep (Abs b))" using type_definition.Abs_inverse[OF type_copy] by auto + qed +qed blast + lemma vimage2p_relcompp_converse: "vimage2p f g (R^--1 OO S) = (vimage2p Rep f R)^--1 OO vimage2p Rep g S" unfolding vimage2p_def relcompp.simps conversep.simps fun_eq_iff image_def - by (metis surjD[OF type_definition.Rep_range[OF type_copy]]) + by (auto simp: type_copy_ex_RepI) end diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_Constructions_on_Wellorders.thy --- a/src/HOL/BNF_Constructions_on_Wellorders.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_Constructions_on_Wellorders.thy Fri Feb 28 17:54:52 2014 +0100 @@ -793,7 +793,7 @@ {assume "r' \o r" then obtain h where "inj_on h (Field r') \ h ` (Field r') \ Field r" unfolding ordLeq_def using assms embed_inj_on embed_Field by blast - hence False using finite_imageD finite_subset FIN INF by metis + hence False using finite_imageD finite_subset FIN INF by blast } thus ?thesis using WELL WELL' ordLess_or_ordLeq by blast qed @@ -819,7 +819,7 @@ hence "bij_betw f A A" unfolding bij_betw_def using FIN endo_inj_surj by blast thus "r =o r'" unfolding ordIso_def iso_def[abs_def] using 1 2 by auto qed - ultimately show ?thesis using assms ordLeq_total ordIso_symmetric by metis + ultimately show ?thesis using assms ordLeq_total ordIso_symmetric by blast qed subsection{* @{text " {} \ A \ Field r" using A_def dir_image_Field[of r f] SUB NE by blast then obtain a where 1: "a \ A \ (\b \ A. (b,a) \ r)" - using WF unfolding wf_eq_minimal2 by metis + using WF unfolding wf_eq_minimal2 by blast have "\b' \ A'. (b',f a) \ dir_image r f" proof(clarify) fix b' assume *: "b' \ A'" and **: "(b',f a) \ dir_image r f" @@ -1597,7 +1597,7 @@ proof assume L: ?L moreover {assume "A = {}" hence False using L Func_empty by auto} - moreover {assume "B \ {}" hence False using L Func_non_emp by metis} + moreover {assume "B \ {}" hence False using L Func_non_emp[of B A] by simp } ultimately show ?R by blast next assume R: ?R @@ -1624,7 +1624,8 @@ fix h assume h: "h \ Func B2 B1" def j1 \ "inv_into A1 f1" have "\ a2 \ f2 ` B2. \ b2. b2 \ B2 \ f2 b2 = a2" by blast - then obtain k where k: "\ a2 \ f2 ` B2. k a2 \ B2 \ f2 (k a2) = a2" by metis + then obtain k where k: "\ a2 \ f2 ` B2. k a2 \ B2 \ f2 (k a2) = a2" + by atomize_elim (rule bchoice) {fix b2 assume b2: "b2 \ B2" hence "f2 (k (f2 b2)) = f2 b2" using k A2(2) by auto moreover have "k (f2 b2) \ B2" using b2 A2(2) k by auto diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_Def.thy --- a/src/HOL/BNF_Def.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_Def.thy Fri Feb 28 17:54:52 2014 +0100 @@ -116,7 +116,7 @@ lemma predicate2_eqD: "A = B \ A a b \ B a b" -by metis +by simp lemma case_sum_o_inj: "case_sum f g \ Inl = f" diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_FP_Base.thy --- a/src/HOL/BNF_FP_Base.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_FP_Base.thy Fri Feb 28 17:54:52 2014 +0100 @@ -65,13 +65,16 @@ by blast lemma type_copy_obj_one_point_absE: - assumes "type_definition Rep Abs UNIV" - shows "\x. s = Abs x \ P \ P" - using type_definition.Rep_inverse[OF assms] by metis + assumes "type_definition Rep Abs UNIV" "\x. s = Abs x \ P" shows P + using type_definition.Rep_inverse[OF assms(1)] + by (intro mp[OF spec[OF assms(2), of "Rep s"]]) simp lemma obj_sumE_f: -"\\x. s = f (Inl x) \ P; \x. s = f (Inr x) \ P\ \ \x. s = f x \ P" -by (rule allI) (metis sumE) + assumes "\x. s = f (Inl x) \ P" "\x. s = f (Inr x) \ P" + shows "\x. s = f x \ P" +proof + fix x from assms show "s = f x \ P" by (cases x) auto +qed lemma obj_sumE: "\\x. s = Inl x \ P; \x. s = Inr x \ P\ \ P" by (cases s) auto diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_LFP.thy --- a/src/HOL/BNF_LFP.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_LFP.thy Fri Feb 28 17:54:52 2014 +0100 @@ -50,8 +50,16 @@ lemma convol_expand_snd: "fst o f = g \ = f" unfolding convol_def by auto -lemma convol_expand_snd': "(fst o f = g) \ (h = snd o f) \ ( = f)" - by (metis convol_expand_snd snd_convol) +lemma convol_expand_snd': + assumes "(fst o f = g)" + shows "h = snd o f \ = f" +proof - + from assms have *: " = f" by (rule convol_expand_snd) + then have "h = snd o f \ h = snd o " by simp + moreover have "\ \ h = snd o f" by (simp add: snd_convol) + moreover have "\ \ = f" by (subst (2) *[symmetric]) (auto simp: convol_def fun_eq_iff) + ultimately show ?thesis by simp +qed definition inver where "inver g f A = (ALL a : A. g (f a) = a)" @@ -67,7 +75,11 @@ using bchoice[of B ?phi] by blast hence gg: "ALL b : f ` A. g b : A \ f (g b) = b" using f by blast have gf: "inver g f A" unfolding inver_def - by (metis (no_types) gg imageI[of _ A f] the_inv_into_f_f[OF inj_f]) + proof + fix a assume "a \ A" + then show "g (f a) = a" using the_inv_into_f_f[OF inj_f, of "g (f a)"] + the_inv_into_f_f[OF inj_f, of a] gg imageI[of a A f] by auto + qed moreover have "g ` B \ A \ inver f g B" using g unfolding inver_def by blast moreover have "A \ g ` B" proof safe @@ -224,8 +236,13 @@ by (rule assms) lemma nchotomy_relcomppE: - "\\y. \x. y = f x; (r OO s) a c; \b. r a (f b) \ s (f b) c \ P\ \ P" - by (metis relcompp.cases) + assumes "\y. \x. y = f x" "(r OO s) a c" "\b. r a (f b) \ s (f b) c \ P" + shows P +proof (rule relcompp.cases[OF assms(2)], hypsubst) + fix b assume "r a b" "s b c" + moreover from assms(1) obtain b' where "b = f b'" by blast + ultimately show P by (blast intro: assms(3)) +qed lemma vimage2p_fun_rel: "fun_rel (vimage2p f g R) R f g" unfolding fun_rel_def vimage2p_def by auto diff -r 63d63d854fae -r aa1acc25126b src/HOL/BNF_Wellorder_Embedding.thy --- a/src/HOL/BNF_Wellorder_Embedding.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/BNF_Wellorder_Embedding.thy Fri Feb 28 17:54:52 2014 +0100 @@ -305,8 +305,7 @@ (* Main proof *) show "bij_betw f (under r a) (under r' (f a))" proof(unfold bij_betw_def, auto) - show "inj_on f (under r a)" - using * by (metis (no_types) under_Field subset_inj_on) + show "inj_on f (under r a)" by (rule subset_inj_on[OF * under_Field]) next fix b assume "b \ under r a" thus "f b \ under r' (f a)" @@ -1035,8 +1034,7 @@ {fix a assume ***: "a \ Field r" have "bij_betw f (under r a) (under r' (f a))" proof(unfold bij_betw_def, auto) - show "inj_on f (under r a)" - using 1 2 by (metis subset_inj_on) + show "inj_on f (under r a)" using 1 2 subset_inj_on by blast next fix b assume "b \ under r a" hence "a \ Field r \ b \ Field r \ (b,a) \ r" diff -r 63d63d854fae -r aa1acc25126b src/HOL/Basic_BNFs.thy --- a/src/HOL/Basic_BNFs.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Basic_BNFs.thy Fri Feb 28 17:54:52 2014 +0100 @@ -158,11 +158,11 @@ next fix x show "|{fst x}| \o natLeq" - by (metis ordLess_imp_ordLeq finite_iff_ordLess_natLeq finite.emptyI finite_insert) + by (rule ordLess_imp_ordLeq) (simp add: finite_iff_ordLess_natLeq[symmetric]) next fix x show "|{snd x}| \o natLeq" - by (metis ordLess_imp_ordLeq finite_iff_ordLess_natLeq finite.emptyI finite_insert) + by (rule ordLess_imp_ordLeq) (simp add: finite_iff_ordLess_natLeq[symmetric]) next fix R1 R2 S1 S2 show "prod_rel R1 R2 OO prod_rel S1 S2 \ prod_rel (R1 OO S1) (R2 OO S2)" by auto @@ -215,8 +215,14 @@ show "fun_rel op = R = (Grp {x. range x \ Collect (split R)} (op \ fst))\\ OO Grp {x. range x \ Collect (split R)} (op \ snd)" - unfolding fun_rel_def Grp_def fun_eq_iff relcompp.simps conversep.simps subset_iff image_iff - by auto (force, metis (no_types) pair_collapse) + unfolding fun_rel_def Grp_def fun_eq_iff relcompp.simps conversep.simps subset_iff image_iff + comp_apply mem_Collect_eq split_beta bex_UNIV + proof (safe, unfold fun_eq_iff[symmetric]) + fix x xa a b c xb y aa ba + assume *: "x = a" "xa = c" "a = ba" "b = aa" "c = (\x. snd (b x))" "ba = (\x. fst (aa x))" and + **: "\t. (\x. t = aa x) \ R (fst t) (snd t)" + show "R (x y) (xa y)" unfolding * by (rule mp[OF spec[OF **]]) blast + qed force qed end diff -r 63d63d854fae -r aa1acc25126b src/HOL/Cardinals/Wellorder_Extension.thy --- a/src/HOL/Cardinals/Wellorder_Extension.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Cardinals/Wellorder_Extension.thy Fri Feb 28 17:54:52 2014 +0100 @@ -5,7 +5,7 @@ header {* Extending Well-founded Relations to Wellorders *} theory Wellorder_Extension -imports Zorn Order_Union +imports Main Order_Union begin subsection {* Extending Well-founded Relations to Wellorders *} diff -r 63d63d854fae -r aa1acc25126b src/HOL/Hilbert_Choice.thy --- a/src/HOL/Hilbert_Choice.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Hilbert_Choice.thy Fri Feb 28 17:54:52 2014 +0100 @@ -6,7 +6,7 @@ header {* Hilbert's Epsilon-Operator and the Axiom of Choice *} theory Hilbert_Choice -imports Nat Wellfounded Metis +imports Nat Wellfounded keywords "specification" "ax_specification" :: thy_goal begin @@ -292,12 +292,13 @@ def Sseq \ "rec_nat S (\n T. T - {SOME e. e \ T})" def pick \ "\n. (SOME e. e \ Sseq n)" { fix n have "Sseq n \ S" "\ finite (Sseq n)" by (induct n) (auto simp add: Sseq_def inf) } - moreover then have *: "\n. pick n \ Sseq n" by (metis someI_ex pick_def ex_in_conv finite.simps) + moreover then have *: "\n. pick n \ Sseq n" + unfolding pick_def by (subst (asm) finite.simps) (auto simp add: ex_in_conv intro: someI_ex) ultimately have "range pick \ S" by auto moreover { fix n m have "pick n \ Sseq (n + Suc m)" by (induct m) (auto simp add: Sseq_def pick_def) - hence "pick n \ pick (n + Suc m)" by (metis *) + with * have "pick n \ pick (n + Suc m)" by auto } then have "inj pick" by (intro linorder_injI) (auto simp add: less_iff_Suc_add) ultimately show ?thesis by blast @@ -305,7 +306,7 @@ lemma infinite_iff_countable_subset: "\ finite S \ (\f. inj (f::nat \ 'a) \ range f \ S)" -- {* Courtesy of Stephan Merz *} - by (metis finite_imageD finite_subset infinite_UNIV_char_0 infinite_countable_subset) + using finite_imageD finite_subset infinite_UNIV_char_0 infinite_countable_subset by auto lemma image_inv_into_cancel: assumes SURJ: "f`A=A'" and SUB: "B' \ A'" @@ -706,9 +707,13 @@ then have "\n. f n < f (Suc n)" using `mono f` by (auto simp: le_less mono_iff_le_Suc) with lift_Suc_mono_less_iff[of f] - have "\n m. n < m \ f n < f m" by auto - then have "inj f" - by (auto simp: inj_on_def) (metis linorder_less_linear order_less_imp_not_eq) + have *: "\n m. n < m \ f n < f m" by auto + have "inj f" + proof (intro injI) + fix x y + assume "f x = f y" + then show "x = y" by (cases x y rule: linorder_cases) (auto dest: *) + qed with `finite (range f)` have "finite (UNIV::nat set)" by (rule finite_imageD) then show False by simp diff -r 63d63d854fae -r aa1acc25126b src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Library/Multiset.thy Fri Feb 28 17:54:52 2014 +0100 @@ -2314,7 +2314,7 @@ lemma card_of_set_of: "(card_of {M. set_of M \ A}, card_of {as. set as \ A}) \ ordLeq" -apply(rule card_of_ordLeqI2[of _ multiset_of]) using multiset_of_surj by auto +apply(rule surj_imp_ordLeq[of _ multiset_of]) using multiset_of_surj by auto lemma nat_sum_induct: assumes "\n1 n2. (\ m1 m2. m1 + m2 < n1 + n2 \ phi m1 m2) \ phi n1 n2" diff -r 63d63d854fae -r aa1acc25126b src/HOL/List.thy --- a/src/HOL/List.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/List.thy Fri Feb 28 17:54:52 2014 +0100 @@ -3117,7 +3117,7 @@ proof(induct i j rule:upto.induct) case (1 i j) from this show ?case - unfolding upto.simps[of i j] simp_from_to[of i j] by auto + unfolding upto.simps[of i j] by auto qed text{* Tail recursive version for code generation: *} diff -r 63d63d854fae -r aa1acc25126b src/HOL/Power.thy --- a/src/HOL/Power.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Power.thy Fri Feb 28 17:54:52 2014 +0100 @@ -613,7 +613,7 @@ lemma self_le_power: fixes x::"'a::linordered_semidom" shows "1 \ x \ 0 < n \ x \ x ^ n" - by (metis gr_implies_not0 le_eq_less_or_eq less_one nat_le_linear power_increasing power_one_right) + using power_increasing[of 1 n x] power_one_right[of x] by auto lemma power_eq_if: "p ^ m = (if m=0 then 1 else p * (p ^ (m - 1)))" unfolding One_nat_def by (cases m) simp_all diff -r 63d63d854fae -r aa1acc25126b src/HOL/Tools/BNF/bnf_fp_util.ML --- a/src/HOL/Tools/BNF/bnf_fp_util.ML Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Tools/BNF/bnf_fp_util.ML Fri Feb 28 17:54:52 2014 +0100 @@ -232,7 +232,8 @@ fun co_rec_of [_, r] = r; fun time ctxt timer msg = (if Config.get ctxt bnf_timing - then warning (msg ^ ": " ^ ATP_Util.string_of_time (Timer.checkRealTimer timer)) + then warning (msg ^ ": " ^ string_of_int (Time.toMilliseconds (Timer.checkRealTimer timer)) ^ + "ms") else (); Timer.startRealTimer ()); val preN = "pre_" diff -r 63d63d854fae -r aa1acc25126b src/HOL/Transfer.thy --- a/src/HOL/Transfer.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Transfer.thy Fri Feb 28 17:54:52 2014 +0100 @@ -6,7 +6,7 @@ header {* Generic theorem transfer using relations *} theory Transfer -imports Hilbert_Choice Basic_BNFs +imports Hilbert_Choice Basic_BNFs Metis begin subsection {* Relator for function space *} diff -r 63d63d854fae -r aa1acc25126b src/HOL/Zorn.thy --- a/src/HOL/Zorn.thy Fri Feb 28 22:00:13 2014 +0100 +++ b/src/HOL/Zorn.thy Fri Feb 28 17:54:52 2014 +0100 @@ -70,7 +70,7 @@ lemma suc_not_equals: "chain C \ \ maxchain C \ suc C \ C" - by (auto simp: suc_def) (metis (no_types) less_irrefl not_maxchain_Some) + using not_maxchain_Some by (auto simp: suc_def) lemma subset_suc: assumes "X \ Y" shows "X \ suc Y" @@ -257,7 +257,7 @@ shows "chain X" using assms proof (induct) - case (suc X) then show ?case by (simp add: suc_def) (metis (no_types) not_maxchain_Some) + case (suc X) then show ?case using not_maxchain_Some by (simp add: suc_def) next case (Union X) then have "\X \ A" by (auto dest: suc_Union_closed_in_carrier) @@ -377,7 +377,7 @@ using `subset.maxchain A M` by (auto simp: subset.maxchain_def) qed qed - ultimately show ?thesis by metis + ultimately show ?thesis by blast qed text{*Alternative version of Zorn's lemma for the subset relation.*} @@ -440,8 +440,7 @@ lemma Chains_alt_def: assumes "refl r" shows "Chains r = {C. pred_on.chain UNIV (\x y. (x, y) \ r) C}" - using assms - by (metis Chains_subset Chains_subset' subset_antisym) + using assms Chains_subset Chains_subset' by blast lemma Zorn_Lemma: "\C\chains A. \C \ A \ \M\A. \X\A. M \ X \ X = M" @@ -534,16 +533,28 @@ by (auto simp: init_seg_of_def Ball_def Chains_def) blast lemma chain_subset_trans_Union: - "chain\<^sub>\ R \ \r\R. trans r \ trans (\R)" -apply (auto simp add: chain_subset_def) -apply (simp (no_asm_use) add: trans_def) -by (metis subsetD) + assumes "chain\<^sub>\ R" "\r\R. trans r" + shows "trans (\R)" +proof (intro transI, elim UnionE) + fix S1 S2 :: "'a rel" and x y z :: 'a + assume "S1 \ R" "S2 \ R" + with assms(1) have "S1 \ S2 \ S2 \ S1" unfolding chain_subset_def by blast + moreover assume "(x, y) \ S1" "(y, z) \ S2" + ultimately have "((x, y) \ S1 \ (y, z) \ S1) \ ((x, y) \ S2 \ (y, z) \ S2)" by blast + with `S1 \ R` `S2 \ R` assms(2) show "(x, z) \ \R" by (auto elim: transE) +qed lemma chain_subset_antisym_Union: - "chain\<^sub>\ R \ \r\R. antisym r \ antisym (\R)" -unfolding chain_subset_def antisym_def -apply simp -by (metis (no_types) subsetD) + assumes "chain\<^sub>\ R" "\r\R. antisym r" + shows "antisym (\R)" +proof (intro antisymI, elim UnionE) + fix S1 S2 :: "'a rel" and x y :: 'a + assume "S1 \ R" "S2 \ R" + with assms(1) have "S1 \ S2 \ S2 \ S1" unfolding chain_subset_def by blast + moreover assume "(x, y) \ S1" "(y, x) \ S2" + ultimately have "((x, y) \ S1 \ (y, x) \ S1) \ ((x, y) \ S2 \ (y, x) \ S2)" by blast + with `S1 \ R` `S2 \ R` assms(2) show "x = y" unfolding antisym_def by auto +qed lemma chain_subset_Total_Union: assumes "chain\<^sub>\ R" and "\r\R. Total r" @@ -554,12 +565,12 @@ by (auto simp add: chain_subset_def) thus "(\r\R. (a, b) \ r) \ (\r\R. (b, a) \ r)" proof - assume "r \ s" hence "(a, b) \ s \ (b, a) \ s" using assms(2) A - by (simp add: total_on_def) (metis (no_types) mono_Field subsetD) + assume "r \ s" hence "(a, b) \ s \ (b, a) \ s" using assms(2) A mono_Field[of r s] + by (auto simp add: total_on_def) thus ?thesis using `s \ R` by blast next - assume "s \ r" hence "(a, b) \ r \ (b, a) \ r" using assms(2) A - by (simp add: total_on_def) (metis (no_types) mono_Field subsetD) + assume "s \ r" hence "(a, b) \ r \ (b, a) \ r" using assms(2) A mono_Field[of s r] + by (fastforce simp add: total_on_def) thus ?thesis using `r \ R` by blast qed qed @@ -633,8 +644,8 @@ moreover have "\r \ R. r initial_segment_of \R" using Ris by(simp add: Chains_init_seg_of_Union) ultimately have "\R \ ?WO \ (\r\R. (r, \R) \ I)" - using mono_Chains [OF I_init] and `R \ Chains I` - by (simp (no_asm) add: I_def del: Field_Union) (metis Chains_wo) + using mono_Chains [OF I_init] Chains_wo[of R] and `R \ Chains I` + unfolding I_def by blast } hence 1: "\R \ Chains I. \u\Field I. \r\R. (r, u) \ I" by (subst FI) blast --{*Zorn's Lemma yields a maximal well-order m:*} @@ -671,8 +682,8 @@ moreover have "Total ?m" using `Total m` and Fm by (auto simp: total_on_def) moreover have "wf (?m - Id)" proof - - have "wf ?s" using `x \ Field m` - by (auto simp add: wf_eq_minimal Field_def) metis + have "wf ?s" using `x \ Field m` unfolding wf_eq_minimal Field_def + by (auto simp: Bex_def) thus ?thesis using `wf (m - Id)` and `x \ Field m` wf_subset [OF `wf ?s` Diff_subset] unfolding Un_Diff Field_def by (auto intro: wf_Un)