# HG changeset patch # User blanchet # Date 1321613232 -3600 # Node ID 08970468f99b01861fd4d024ac3eba8629c5dcb7 # Parent ccb904a09e70dcdd257c04cdea28690cf7bb025e more "metis" calls in example diff -r ccb904a09e70 -r 08970468f99b src/HOL/Metis_Examples/Abstraction.thy --- a/src/HOL/Metis_Examples/Abstraction.thy Fri Nov 18 11:47:12 2011 +0100 +++ b/src/HOL/Metis_Examples/Abstraction.thy Fri Nov 18 11:47:12 2011 +0100 @@ -8,16 +8,14 @@ header {* Example Featuring Metis's Support for Lambda-Abstractions *} theory Abstraction -imports Main "~~/src/HOL/Library/FuncSet" +imports "~~/src/HOL/Library/FuncSet" begin -declare [[metis_new_skolemizer]] - (* For Christoph Benzmüller *) lemma "x < 1 \ ((op =) = (op =)) \ ((op =) = (op =)) \ x < (2::nat)" by (metis nat_1_add_1 trans_less_add2) -lemma "(op = ) = (%x y. y = x)" +lemma "(op = ) = (\x y. y = x)" by metis consts @@ -25,20 +23,20 @@ pset :: "'a set => 'a set" order :: "'a set => ('a * 'a) set" -lemma (*Collect_triv:*) "a \ {x. P x} ==> P a" +lemma "a \ {x. P x} \ P a" proof - assume "a \ {x. P x}" hence "a \ P" by (metis Collect_def) thus "P a" by (metis mem_def) qed -lemma Collect_triv: "a \ {x. P x} ==> P a" +lemma Collect_triv: "a \ {x. P x} \ P a" by (metis mem_Collect_eq) -lemma "a \ {x. P x --> Q x} ==> a \ {x. P x} ==> a \ {x. Q x}" +lemma "a \ {x. P x --> Q x} \ a \ {x. P x} \ a \ {x. Q x}" by (metis Collect_imp_eq ComplD UnE) -lemma "(a, b) \ Sigma A B ==> a \ A & b \ B a" +lemma "(a, b) \ Sigma A B \ a \ A & b \ B a" proof - assume A1: "(a, b) \ Sigma A B" hence F1: "b \ B a" by (metis mem_Sigma_iff) @@ -47,17 +45,11 @@ thus "a \ A \ b \ B a" by (metis F2) qed -lemma Sigma_triv: "(a,b) \ Sigma A B ==> a \ A & b \ B a" +lemma Sigma_triv: "(a, b) \ Sigma A B \ a \ A & b \ B a" by (metis SigmaD1 SigmaD2) lemma "(a, b) \ (SIGMA x:A. {y. x = f y}) \ a \ A \ a = f b" -(* Metis says this is satisfiable! -by (metis CollectD SigmaD1 SigmaD2) -*) -by (meson CollectD SigmaD1 SigmaD2) - -lemma "(a, b) \ (SIGMA x:A. {y. x = f y}) \ a \ A \ a = f b" -by (metis mem_Sigma_iff singleton_conv2 vimage_Collect_eq vimage_singleton_eq) +by (metis (full_types, lam_lifting) CollectD SigmaD1 SigmaD2) lemma "(a, b) \ (SIGMA x:A. {y. x = f y}) \ a \ A \ a = f b" proof - @@ -69,44 +61,42 @@ thus "a \ A \ a = f b" by (metis F1) qed -lemma "(cl,f) \ CLF ==> CLF = (SIGMA cl: CL.{f. f \ pset cl}) ==> f \ pset cl" +lemma "(cl, f) \ CLF \ CLF = (SIGMA cl: CL.{f. f \ pset cl}) \ f \ pset cl" by (metis Collect_mem_eq SigmaD2) -lemma "(cl,f) \ CLF ==> CLF = (SIGMA cl: CL.{f. f \ pset cl}) ==> f \ pset cl" +lemma "(cl, f) \ CLF \ CLF = (SIGMA cl: CL.{f. f \ pset cl}) \ f \ pset cl" proof - assume A1: "(cl, f) \ CLF" assume A2: "CLF = (SIGMA cl:CL. {f. f \ pset cl})" have F1: "\v. (\R. R \ v) = v" by (metis Collect_mem_eq Collect_def) have "\v u. (u, v) \ CLF \ v \ {R. R \ pset u}" by (metis A2 mem_Sigma_iff) hence "\v u. (u, v) \ CLF \ v \ pset u" by (metis F1 Collect_def) - hence "f \ pset cl" by (metis A1) - thus "f \ pset cl" by metis + thus "f \ pset cl" by (metis A1) qed lemma - "(cl,f) \ (SIGMA cl: CL. {f. f \ pset cl \ pset cl}) ==> - f \ pset cl \ pset cl" + "(cl, f) \ (SIGMA cl: CL. {f. f \ pset cl \ pset cl}) \ + f \ pset cl \ pset cl" by (metis (no_types) Collect_def Sigma_triv mem_def) lemma - "(cl,f) \ (SIGMA cl: CL. {f. f \ pset cl \ pset cl}) ==> - f \ pset cl \ pset cl" + "(cl, f) \ (SIGMA cl: CL. {f. f \ pset cl \ pset cl}) \ + f \ pset cl \ pset cl" proof - assume A1: "(cl, f) \ (SIGMA cl:CL. {f. f \ pset cl \ pset cl})" have F1: "\v. (\R. R \ v) = v" by (metis Collect_mem_eq Collect_def) have "f \ {R. R \ pset cl \ pset cl}" using A1 by simp - hence "f \ pset cl \ pset cl" by (metis F1 Collect_def) - thus "f \ pset cl \ pset cl" by metis + thus "f \ pset cl \ pset cl" by (metis F1 Collect_def) qed lemma - "(cl,f) \ (SIGMA cl: CL. {f. f \ pset cl \ cl}) ==> - f \ pset cl \ cl" + "(cl, f) \ (SIGMA cl: CL. {f. f \ pset cl \ cl}) \ + f \ pset cl \ cl" by (metis (no_types) Collect_conj_eq Int_def Sigma_triv inf_idem) lemma - "(cl,f) \ (SIGMA cl: CL. {f. f \ pset cl \ cl}) ==> - f \ pset cl \ cl" + "(cl, f) \ (SIGMA cl: CL. {f. f \ pset cl \ cl}) \ + f \ pset cl \ cl" proof - assume A1: "(cl, f) \ (SIGMA cl:CL. {f. f \ pset cl \ cl})" have F1: "\v. (\R. R \ v) = v" by (metis Collect_mem_eq Collect_def) @@ -118,71 +108,73 @@ qed lemma - "(cl,f) \ (SIGMA cl: CL. {f. f \ pset cl \ pset cl & monotone f (pset cl) (order cl)}) ==> + "(cl, f) \ (SIGMA cl: CL. {f. f \ pset cl \ pset cl & monotone f (pset cl) (order cl)}) \ (f \ pset cl \ pset cl) & (monotone f (pset cl) (order cl))" by auto -lemma "(cl,f) \ CLF ==> - CLF \ (SIGMA cl: CL. {f. f \ pset cl \ cl}) ==> +lemma + "(cl, f) \ CLF \ + CLF \ (SIGMA cl: CL. {f. f \ pset cl \ cl}) \ f \ pset cl \ cl" +by (metis (lam_lifting) Collect_def Sigma_triv mem_def subsetD) + +lemma + "(cl, f) \ CLF \ + CLF = (SIGMA cl: CL. {f. f \ pset cl \ cl}) \ + f \ pset cl \ cl" +by (metis (lam_lifting) Int_Collect SigmaD2 inf1I mem_def) + +lemma + "(cl, f) \ CLF \ + CLF \ (SIGMA cl': CL. {f. f \ pset cl' \ pset cl'}) \ + f \ pset cl \ pset cl" +by (metis (lam_lifting) Collect_def Sigma_triv mem_def subsetD) + +lemma + "(cl, f) \ CLF \ + CLF = (SIGMA cl: CL. {f. f \ pset cl \ pset cl}) \ + f \ pset cl \ pset cl" +by (metis (lam_lifting) Collect_def Sigma_triv mem_def) + +lemma + "(cl, f) \ CLF \ + CLF = (SIGMA cl: CL. {f. f \ pset cl \ pset cl & monotone f (pset cl) (order cl)}) \ + (f \ pset cl \ pset cl) & (monotone f (pset cl) (order cl))" by auto -lemma "(cl,f) \ CLF ==> - CLF = (SIGMA cl: CL. {f. f \ pset cl \ cl}) ==> - f \ pset cl \ cl" -by auto - -lemma - "(cl,f) \ CLF ==> - CLF \ (SIGMA cl': CL. {f. f \ pset cl' \ pset cl'}) ==> - f \ pset cl \ pset cl" -by fast - -lemma - "(cl,f) \ CLF ==> - CLF = (SIGMA cl: CL. {f. f \ pset cl \ pset cl}) ==> - f \ pset cl \ pset cl" -by auto - -lemma - "(cl,f) \ CLF ==> - CLF = (SIGMA cl: CL. {f. f \ pset cl \ pset cl & monotone f (pset cl) (order cl)}) ==> - (f \ pset cl \ pset cl) & (monotone f (pset cl) (order cl))" -by auto - -lemma "map (%x. (f x, g x)) xs = zip (map f xs) (map g xs)" -apply (induct xs) - apply (metis map.simps(1) zip_Nil) -by (metis (lam_lifting, no_types) map.simps(2) zip_Cons_Cons) - -lemma "map (%w. (w -> w, w \ w)) xs = - zip (map (%w. w -> w) xs) (map (%w. w \ w) xs)" +lemma "map (\x. (f x, g x)) xs = zip (map f xs) (map g xs)" apply (induct xs) apply (metis map.simps(1) zip_Nil) by auto -lemma "(%x. Suc (f x)) ` {x. even x} <= A ==> \x. even x --> Suc (f x) \ A" +lemma + "map (\w. (w -> w, w \ w)) xs = + zip (map (\w. w -> w) xs) (map (\w. w \ w) xs)" +apply (induct xs) + apply (metis map.simps(1) zip_Nil) +by auto + +lemma "(\x. Suc (f x)) ` {x. even x} \ A \ \x. even x --> Suc (f x) \ A" by (metis Collect_def image_eqI mem_def subsetD) -lemma "(%x. f (f x)) ` ((%x. Suc(f x)) ` {x. even x}) <= A - ==> (\x. even x --> f (f (Suc(f x))) \ A)" +lemma + "(\x. f (f x)) ` ((\x. Suc(f x)) ` {x. even x}) \ A \ + (\x. even x --> f (f (Suc(f x))) \ A)" by (metis Collect_def imageI mem_def set_rev_mp) -lemma "f \ (%u v. b \ u \ v) ` A ==> \u v. P (b \ u \ v) ==> P(f y)" -(* sledgehammer *) -by auto +lemma "f \ (\u v. b \ u \ v) ` A \ \u v. P (b \ u \ v) \ P(f y)" +by (metis (lam_lifting) imageE) -lemma image_TimesA: "(%(x,y). (f x, g y)) ` (A \ B) = (f`A) \ (g`B)" +lemma image_TimesA: "(\(x, y). (f x, g y)) ` (A \ B) = (f ` A) \ (g ` B)" by (metis map_pair_def map_pair_surj_on) lemma image_TimesB: - "(%(x,y,z). (f x, g y, h z)) ` (A \ B \ C) = (f`A) \ (g`B) \ (h`C)" -(* sledgehammer *) + "(\(x, y, z). (f x, g y, h z)) ` (A \ B \ C) = (f ` A) \ (g ` B) \ (h ` C)" by force lemma image_TimesC: - "(%(x,y). (x \ x, y \ y)) ` (A \ B) = - ((%x. x \ x) ` A) \ ((%y. y \ y) ` B)" + "(\(x, y). (x \ x, y \ y)) ` (A \ B) = + ((\x. x \ x) ` A) \ ((\y. y \ y) ` B)" by (metis image_TimesA) end