author | blanchet |
Tue, 30 Aug 2011 16:23:25 +0200 | |
changeset 44598 | b054ca3f07b5 |
parent 44494 | a77901b3774e |
child 44651 | 5d6a11e166cf |
permissions | -rw-r--r-- |
43197 | 1 |
(* Title: HOL/Metis_Examples/Type_Encodings.thy |
43162 | 2 |
Author: Jasmin Blanchette, TU Muenchen |
3 |
||
43197 | 4 |
Example that exercises Metis's (and hence Sledgehammer's) type encodings. |
43162 | 5 |
*) |
6 |
||
43197 | 7 |
header {* |
8 |
Example that Exercises Metis's (and Hence Sledgehammer's) Type Encodings |
|
9 |
*} |
|
10 |
||
11 |
theory Type_Encodings |
|
44412
c8b847625584
include all encodings in tests, now that the incompleteness of some encodings has been addressed
blanchet
parents:
44408
diff
changeset
|
12 |
imports Main |
43162 | 13 |
begin |
14 |
||
43197 | 15 |
declare [[metis_new_skolemizer]] |
16 |
||
17 |
sledgehammer_params [prover = e, blocking, timeout = 10, preplay_timeout = 0] |
|
18 |
||
19 |
||
43162 | 20 |
text {* Setup for testing Metis exhaustively *} |
21 |
||
22 |
lemma fork: "P \<Longrightarrow> P \<Longrightarrow> P" by assumption |
|
23 |
||
24 |
ML {* |
|
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
25 |
val type_encs = |
43208 | 26 |
["erased", |
43989 | 27 |
"poly_guards", |
44402 | 28 |
"poly_guards_uniform", |
43208 | 29 |
"poly_tags", |
44402 | 30 |
"poly_tags_uniform", |
43208 | 31 |
"poly_args", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
32 |
"raw_mono_guards", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
33 |
"raw_mono_guards_uniform", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
34 |
"raw_mono_tags", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
35 |
"raw_mono_tags_uniform", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
36 |
"raw_mono_args", |
43989 | 37 |
"mono_guards", |
44402 | 38 |
"mono_guards_uniform", |
43208 | 39 |
"mono_tags", |
44402 | 40 |
"mono_tags_uniform", |
43208 | 41 |
"mono_args", |
43989 | 42 |
"poly_guards?", |
44402 | 43 |
"poly_guards_uniform?", |
43629 | 44 |
"poly_tags?", |
44412
c8b847625584
include all encodings in tests, now that the incompleteness of some encodings has been addressed
blanchet
parents:
44408
diff
changeset
|
45 |
"poly_tags_uniform?", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
46 |
"raw_mono_guards?", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
47 |
"raw_mono_guards_uniform?", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
48 |
"raw_mono_tags?", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
49 |
"raw_mono_tags_uniform?", |
43989 | 50 |
"mono_guards?", |
44402 | 51 |
"mono_guards_uniform?", |
43208 | 52 |
"mono_tags?", |
44402 | 53 |
"mono_tags_uniform?", |
43989 | 54 |
"poly_guards!", |
44402 | 55 |
"poly_guards_uniform!", |
44412
c8b847625584
include all encodings in tests, now that the incompleteness of some encodings has been addressed
blanchet
parents:
44408
diff
changeset
|
56 |
"poly_tags!", |
44402 | 57 |
"poly_tags_uniform!", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
58 |
"raw_mono_guards!", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
59 |
"raw_mono_guards_uniform!", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
60 |
"raw_mono_tags!", |
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
61 |
"raw_mono_tags_uniform!", |
43989 | 62 |
"mono_guards!", |
44402 | 63 |
"mono_guards_uniform!", |
43208 | 64 |
"mono_tags!", |
44598
b054ca3f07b5
"simple" was renamed "mono_simple" and there's now "poly_simple" as well -- but they are not needed here since for Metis they amount to the same as guards
blanchet
parents:
44494
diff
changeset
|
65 |
"mono_tags_uniform!"] |
43162 | 66 |
|
43212 | 67 |
fun metis_exhaust_tac ctxt ths = |
43162 | 68 |
let |
43172 | 69 |
fun tac [] st = all_tac st |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
70 |
| tac (type_enc :: type_encs) st = |
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
71 |
st (* |> tap (fn _ => tracing (PolyML.makestring type_enc)) *) |
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
72 |
|> ((if null type_encs then all_tac else rtac @{thm fork} 1) |
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
73 |
THEN Metis_Tactics.metis_tac [type_enc] ctxt ths 1 |
43172 | 74 |
THEN COND (has_fewer_prems 2) all_tac no_tac |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
75 |
THEN tac type_encs) |
43162 | 76 |
in tac end |
77 |
*} |
|
78 |
||
43212 | 79 |
method_setup metis_exhaust = {* |
43162 | 80 |
Attrib.thms >> |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
81 |
(fn ths => fn ctxt => SIMPLE_METHOD (metis_exhaust_tac ctxt ths type_encs)) |
43162 | 82 |
*} "exhaustively run the new Metis with all type encodings" |
83 |
||
84 |
||
43197 | 85 |
text {* Miscellaneous tests *} |
43162 | 86 |
|
87 |
lemma "x = y \<Longrightarrow> y = x" |
|
43212 | 88 |
by metis_exhaust |
43162 | 89 |
|
90 |
lemma "[a] = [1 + 1] \<Longrightarrow> a = 1 + (1::int)" |
|
43212 | 91 |
by (metis_exhaust last.simps) |
43162 | 92 |
|
93 |
lemma "map Suc [0] = [Suc 0]" |
|
43212 | 94 |
by (metis_exhaust map.simps) |
43162 | 95 |
|
96 |
lemma "map Suc [1 + 1] = [Suc 2]" |
|
43212 | 97 |
by (metis_exhaust map.simps nat_1_add_1) |
43162 | 98 |
|
99 |
lemma "map Suc [2] = [Suc (1 + 1)]" |
|
43212 | 100 |
by (metis_exhaust map.simps nat_1_add_1) |
43162 | 101 |
|
102 |
definition "null xs = (xs = [])" |
|
103 |
||
104 |
lemma "P (null xs) \<Longrightarrow> null xs \<Longrightarrow> xs = []" |
|
43212 | 105 |
by (metis_exhaust null_def) |
43162 | 106 |
|
107 |
lemma "(0::nat) + 0 = 0" |
|
43212 | 108 |
by (metis_exhaust arithmetic_simps(38)) |
43162 | 109 |
|
110 |
end |