author | wenzelm |
Thu, 18 Apr 2013 17:07:01 +0200 | |
changeset 51717 | 9e7d1c139569 |
parent 50705 | 0e943b33d907 |
child 51929 | 5e8a0b8bb070 |
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 |
||
50705
0e943b33d907
use new skolemizer for reconstructing skolemization steps in Isar proofs (because the old skolemizer messes up the order of the Skolem arguments)
blanchet
parents:
48664
diff
changeset
|
15 |
declare [[metis_new_skolem]] |
43197 | 16 |
|
48664
81755fd809be
never use MaSh in Metis examples, to avoid one dimension of nondeterminism
blanchet
parents:
48146
diff
changeset
|
17 |
sledgehammer_params [prover = spass, blocking, fact_filter = mepo, timeout = 30, |
46733
4a03b30e04cb
use SPASS instead of E for Metis examples -- it's seems faster for these small problems
blanchet
parents:
46436
diff
changeset
|
18 |
preplay_timeout = 0, dont_minimize] |
43197 | 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", |
44768 | 28 |
"poly_guards?", |
29 |
"poly_guards??", |
|
48146 | 30 |
"poly_guards@", |
43208 | 31 |
"poly_tags", |
44768 | 32 |
"poly_tags?", |
33 |
"poly_tags??", |
|
48146 | 34 |
"poly_tags@", |
43208 | 35 |
"poly_args", |
48092 | 36 |
"poly_args?", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
37 |
"raw_mono_guards", |
44768 | 38 |
"raw_mono_guards?", |
39 |
"raw_mono_guards??", |
|
48146 | 40 |
"raw_mono_guards@", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
41 |
"raw_mono_tags", |
44768 | 42 |
"raw_mono_tags?", |
43 |
"raw_mono_tags??", |
|
48146 | 44 |
"raw_mono_tags@", |
44494
a77901b3774e
rationalized option names -- mono becomes raw_mono and mangled becomes mono
blanchet
parents:
44412
diff
changeset
|
45 |
"raw_mono_args", |
48092 | 46 |
"raw_mono_args?", |
43989 | 47 |
"mono_guards", |
44768 | 48 |
"mono_guards?", |
49 |
"mono_guards??", |
|
43208 | 50 |
"mono_tags", |
51 |
"mono_tags?", |
|
44768 | 52 |
"mono_tags??", |
53 |
"mono_args"] |
|
43162 | 54 |
|
43212 | 55 |
fun metis_exhaust_tac ctxt ths = |
43162 | 56 |
let |
43172 | 57 |
fun tac [] st = all_tac st |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
58 |
| tac (type_enc :: type_encs) st = |
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
59 |
st (* |> tap (fn _ => tracing (PolyML.makestring type_enc)) *) |
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43212
diff
changeset
|
60 |
|> ((if null type_encs then all_tac else rtac @{thm fork} 1) |
46369 | 61 |
THEN Metis_Tactic.metis_tac [type_enc] |
62 |
ATP_Problem_Generate.combsN ctxt ths 1 |
|
43172 | 63 |
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
|
64 |
THEN tac type_encs) |
46436 | 65 |
in tac type_encs end |
43162 | 66 |
*} |
67 |
||
43212 | 68 |
method_setup metis_exhaust = {* |
43162 | 69 |
Attrib.thms >> |
46436 | 70 |
(fn ths => fn ctxt => SIMPLE_METHOD (metis_exhaust_tac ctxt ths)) |
71 |
*} "exhaustively run Metis with all type encodings" |
|
43162 | 72 |
|
43197 | 73 |
text {* Miscellaneous tests *} |
43162 | 74 |
|
75 |
lemma "x = y \<Longrightarrow> y = x" |
|
43212 | 76 |
by metis_exhaust |
43162 | 77 |
|
48098
dd611ab202a8
tweak Metis example to avoid glitch in proof reconstruction with a few guard-based, type-argument-less encodings
blanchet
parents:
48092
diff
changeset
|
78 |
lemma "[a] = [Suc 0] \<Longrightarrow> a = 1" |
dd611ab202a8
tweak Metis example to avoid glitch in proof reconstruction with a few guard-based, type-argument-less encodings
blanchet
parents:
48092
diff
changeset
|
79 |
by (metis_exhaust last.simps One_nat_def) |
43162 | 80 |
|
81 |
lemma "map Suc [0] = [Suc 0]" |
|
43212 | 82 |
by (metis_exhaust map.simps) |
43162 | 83 |
|
84 |
lemma "map Suc [1 + 1] = [Suc 2]" |
|
43212 | 85 |
by (metis_exhaust map.simps nat_1_add_1) |
43162 | 86 |
|
87 |
lemma "map Suc [2] = [Suc (1 + 1)]" |
|
43212 | 88 |
by (metis_exhaust map.simps nat_1_add_1) |
43162 | 89 |
|
90 |
definition "null xs = (xs = [])" |
|
91 |
||
92 |
lemma "P (null xs) \<Longrightarrow> null xs \<Longrightarrow> xs = []" |
|
43212 | 93 |
by (metis_exhaust null_def) |
43162 | 94 |
|
48098
dd611ab202a8
tweak Metis example to avoid glitch in proof reconstruction with a few guard-based, type-argument-less encodings
blanchet
parents:
48092
diff
changeset
|
95 |
lemma "(0\<Colon>nat) + 0 = 0" |
45502
6246bef495ff
avoid theorem references like 'semiring_norm(111)'
huffman
parents:
44815
diff
changeset
|
96 |
by (metis_exhaust add_0_left) |
43162 | 97 |
|
98 |
end |