1 (* Title: HOL/Metis_Examples/Type_Encodings.thy
2 Author: Jasmin Blanchette, TU Muenchen
4 Example that exercises Metis's (and hence Sledgehammer's) type encodings.
8 Example that Exercises Metis's (and Hence Sledgehammer's) Type Encodings
12 imports "~~/src/HOL/Sledgehammer2d"(*###*)
15 declare [[metis_new_skolemizer]]
17 sledgehammer_params [prover = e, blocking, timeout = 10, preplay_timeout = 0]
20 text {* Setup for testing Metis exhaustively *}
22 lemma fork: "P \<Longrightarrow> P \<Longrightarrow> P" by assumption
25 (* The commented-out type systems are too incomplete for our exhaustive
30 "poly_guards_uniform",
35 "mono_guards_uniform",
40 "mangled_guards_uniform",
42 "mangled_tags_uniform",
46 "poly_guards_uniform?",
48 (* "poly_tags_uniform?", *)
50 "mono_guards_uniform?",
54 "mangled_guards_uniform?",
56 "mangled_tags_uniform?",
59 "poly_guards_uniform!",
63 "mono_guards_uniform!",
67 "mangled_guards_uniform!",
69 "mangled_tags_uniform!",
72 fun metis_exhaust_tac ctxt ths =
74 fun tac [] st = all_tac st
75 | tac (type_enc :: type_encs) st =
76 st (* |> tap (fn _ => tracing (PolyML.makestring type_enc)) *)
77 |> ((if null type_encs then all_tac else rtac @{thm fork} 1)
78 THEN Metis_Tactics.metis_tac [type_enc] ctxt ths 1
79 THEN COND (has_fewer_prems 2) all_tac no_tac
84 method_setup metis_exhaust = {*
86 (fn ths => fn ctxt => SIMPLE_METHOD (metis_exhaust_tac ctxt ths type_encs))
87 *} "exhaustively run the new Metis with all type encodings"
90 text {* Miscellaneous tests *}
92 lemma "x = y \<Longrightarrow> y = x"
95 lemma "[a] = [1 + 1] \<Longrightarrow> a = 1 + (1::int)"
96 by (metis_exhaust last.simps)
98 lemma "map Suc [0] = [Suc 0]"
99 by (metis_exhaust map.simps)
101 lemma "map Suc [1 + 1] = [Suc 2]"
102 by (metis_exhaust map.simps nat_1_add_1)
104 lemma "map Suc [2] = [Suc (1 + 1)]"
105 by (metis_exhaust map.simps nat_1_add_1)
107 definition "null xs = (xs = [])"
109 lemma "P (null xs) \<Longrightarrow> null xs \<Longrightarrow> xs = []"
110 by (metis_exhaust null_def)
112 lemma "(0::nat) + 0 = 0"
113 by (metis_exhaust arithmetic_simps(38))