author | blanchet |
Mon, 06 Feb 2012 23:01:02 +0100 | |
changeset 46436 | 6f0f2b71fd69 |
parent 46369 | 9ac0c64ad8e7 |
child 46733 | 4a03b30e04cb |
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 |
||
43162 | 19 |
text {* Setup for testing Metis exhaustively *} |
20 |
||
21 |
lemma fork: "P \<Longrightarrow> P \<Longrightarrow> P" by assumption |
|
22 |
||
23 |
ML {* |
|
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
24 |
val type_encs = |
43208 | 25 |
["erased", |
43989 | 26 |
"poly_guards", |
44768 | 27 |
"poly_guards?", |
28 |
"poly_guards??", |
|
44813 | 29 |
"poly_guards@?", |
44768 | 30 |
"poly_guards!", |
31 |
"poly_guards!!", |
|
44813 | 32 |
"poly_guards@!", |
43208 | 33 |
"poly_tags", |
44768 | 34 |
"poly_tags?", |
35 |
"poly_tags??", |
|
36 |
"poly_tags!", |
|
37 |
"poly_tags!!", |
|
43208 | 38 |
"poly_args", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
39 |
"raw_mono_guards", |
44768 | 40 |
"raw_mono_guards?", |
41 |
"raw_mono_guards??", |
|
44813 | 42 |
"raw_mono_guards@?", |
44768 | 43 |
"raw_mono_guards!", |
44 |
"raw_mono_guards!!", |
|
44813 | 45 |
"raw_mono_guards@!", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
46 |
"raw_mono_tags", |
44768 | 47 |
"raw_mono_tags?", |
48 |
"raw_mono_tags??", |
|
49 |
"raw_mono_tags!", |
|
50 |
"raw_mono_tags!!", |
|
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
51 |
"raw_mono_args", |
43989 | 52 |
"mono_guards", |
44768 | 53 |
"mono_guards?", |
54 |
"mono_guards??", |
|
55 |
"mono_guards!", |
|
56 |
"mono_guards!!", |
|
43208 | 57 |
"mono_tags", |
58 |
"mono_tags?", |
|
44768 | 59 |
"mono_tags??", |
43208 | 60 |
"mono_tags!", |
44768 | 61 |
"mono_tags!!", |
62 |
"mono_args"] |
|
43162 | 63 |
|
43212 | 64 |
fun metis_exhaust_tac ctxt ths = |
43162 | 65 |
let |
43172 | 66 |
fun tac [] st = all_tac st |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
67 |
| tac (type_enc :: type_encs) st = |
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
68 |
st (* |> tap (fn _ => tracing (PolyML.makestring type_enc)) *) |
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
69 |
|> ((if null type_encs then all_tac else rtac @{thm fork} 1) |
46369 | 70 |
THEN Metis_Tactic.metis_tac [type_enc] |
71 |
ATP_Problem_Generate.combsN ctxt ths 1 |
|
43172 | 72 |
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
|
73 |
THEN tac type_encs) |
46436 | 74 |
in tac type_encs end |
43162 | 75 |
*} |
76 |
||
43212 | 77 |
method_setup metis_exhaust = {* |
43162 | 78 |
Attrib.thms >> |
46436 | 79 |
(fn ths => fn ctxt => SIMPLE_METHOD (metis_exhaust_tac ctxt ths)) |
80 |
*} "exhaustively run Metis with all type encodings" |
|
43162 | 81 |
|
43197 | 82 |
text {* Miscellaneous tests *} |
43162 | 83 |
|
84 |
lemma "x = y \<Longrightarrow> y = x" |
|
43212 | 85 |
by metis_exhaust |
43162 | 86 |
|
87 |
lemma "[a] = [1 + 1] \<Longrightarrow> a = 1 + (1::int)" |
|
43212 | 88 |
by (metis_exhaust last.simps) |
43162 | 89 |
|
90 |
lemma "map Suc [0] = [Suc 0]" |
|
43212 | 91 |
by (metis_exhaust map.simps) |
43162 | 92 |
|
93 |
lemma "map Suc [1 + 1] = [Suc 2]" |
|
43212 | 94 |
by (metis_exhaust map.simps nat_1_add_1) |
43162 | 95 |
|
96 |
lemma "map Suc [2] = [Suc (1 + 1)]" |
|
43212 | 97 |
by (metis_exhaust map.simps nat_1_add_1) |
43162 | 98 |
|
99 |
definition "null xs = (xs = [])" |
|
100 |
||
101 |
lemma "P (null xs) \<Longrightarrow> null xs \<Longrightarrow> xs = []" |
|
43212 | 102 |
by (metis_exhaust null_def) |
43162 | 103 |
|
104 |
lemma "(0::nat) + 0 = 0" |
|
45502
6246bef495ff
avoid theorem references like 'semiring_norm(111)'
huffman
parents:
44815
diff
changeset
|
105 |
by (metis_exhaust add_0_left) |
43162 | 106 |
|
107 |
end |