| author | blanchet |
| Sun, 04 May 2014 21:35:04 +0200 | |
| changeset 56856 | d940ad3959c5 |
| parent 56852 | b38c5b9cf590 |
| child 56951 | 4fca7e1470e2 |
| permissions | -rw-r--r-- |
| 55287 | 1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_proof_methods.ML |
| 52555 | 2 |
Author: Jasmin Blanchette, TU Muenchen |
3 |
Author: Steffen Juilf Smolka, TU Muenchen |
|
4 |
||
5 |
Reconstructors. |
|
6 |
*) |
|
7 |
||
| 55287 | 8 |
signature SLEDGEHAMMER_PROOF_METHODS = |
| 52555 | 9 |
sig |
10 |
type stature = ATP_Problem_Generate.stature |
|
11 |
||
| 55285 | 12 |
datatype proof_method = |
13 |
Metis_Method of string option * string option | |
|
14 |
Meson_Method | |
|
| 56081 | 15 |
SMT2_Method | |
|
56852
b38c5b9cf590
added 'satx' to Sledgehammer's portfolio (cf. 'isar_try0')
blanchet
parents:
56093
diff
changeset
|
16 |
SATx_Method | |
|
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
17 |
Blast_Method | |
| 55285 | 18 |
Simp_Method | |
19 |
Simp_Size_Method | |
|
20 |
Auto_Method | |
|
21 |
Fastforce_Method | |
|
22 |
Force_Method | |
|
|
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
23 |
Linarith_Method | |
|
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
24 |
Presburger_Method | |
| 55285 | 25 |
Algebra_Method |
| 52555 | 26 |
|
| 54824 | 27 |
datatype play_outcome = |
28 |
Played of Time.time | |
|
29 |
Play_Timed_Out of Time.time | |
|
| 56093 | 30 |
Play_Failed |
| 52555 | 31 |
|
32 |
type minimize_command = string list -> string |
|
| 54824 | 33 |
type one_line_params = |
| 55285 | 34 |
(proof_method * play_outcome) * string * (string * stature) list * minimize_command * int * int |
| 52555 | 35 |
|
| 55285 | 36 |
val string_of_proof_method : proof_method -> string |
|
55452
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
37 |
val tac_of_proof_method : Proof.context -> bool -> thm list * thm list -> proof_method -> int -> |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
38 |
tactic |
| 55211 | 39 |
val string_of_play_outcome : play_outcome -> string |
| 55269 | 40 |
val play_outcome_ord : play_outcome * play_outcome -> order |
| 55211 | 41 |
val one_line_proof_text : int -> one_line_params -> string |
| 54495 | 42 |
end; |
| 52555 | 43 |
|
| 55287 | 44 |
structure Sledgehammer_Proof_Methods : SLEDGEHAMMER_PROOF_METHODS = |
| 52555 | 45 |
struct |
46 |
||
| 54828 | 47 |
open ATP_Util |
| 52555 | 48 |
open ATP_Problem_Generate |
| 55211 | 49 |
open ATP_Proof_Reconstruct |
| 52555 | 50 |
|
| 55285 | 51 |
datatype proof_method = |
52 |
Metis_Method of string option * string option | |
|
53 |
Meson_Method | |
|
| 56081 | 54 |
SMT2_Method | |
|
56852
b38c5b9cf590
added 'satx' to Sledgehammer's portfolio (cf. 'isar_try0')
blanchet
parents:
56093
diff
changeset
|
55 |
SATx_Method | |
|
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
56 |
Blast_Method | |
| 55285 | 57 |
Simp_Method | |
58 |
Simp_Size_Method | |
|
59 |
Auto_Method | |
|
60 |
Fastforce_Method | |
|
61 |
Force_Method | |
|
|
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
62 |
Linarith_Method | |
|
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
63 |
Presburger_Method | |
| 55285 | 64 |
Algebra_Method |
| 52555 | 65 |
|
| 54824 | 66 |
datatype play_outcome = |
67 |
Played of Time.time | |
|
68 |
Play_Timed_Out of Time.time | |
|
| 56093 | 69 |
Play_Failed |
| 52555 | 70 |
|
| 55211 | 71 |
type minimize_command = string list -> string |
72 |
type one_line_params = |
|
| 55285 | 73 |
(proof_method * play_outcome) * string * (string * stature) list * minimize_command * int * int |
| 55211 | 74 |
|
| 55285 | 75 |
fun string_of_proof_method meth = |
76 |
(case meth of |
|
77 |
Metis_Method (NONE, NONE) => "metis" |
|
78 |
| Metis_Method (type_enc_opt, lam_trans_opt) => |
|
79 |
"metis (" ^ commas (map_filter I [type_enc_opt, lam_trans_opt]) ^ ")"
|
|
80 |
| Meson_Method => "meson" |
|
| 56081 | 81 |
| SMT2_Method => "smt2" |
|
56852
b38c5b9cf590
added 'satx' to Sledgehammer's portfolio (cf. 'isar_try0')
blanchet
parents:
56093
diff
changeset
|
82 |
| SATx_Method => "satx" |
|
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
83 |
| Blast_Method => "blast" |
| 55285 | 84 |
| Simp_Method => "simp" |
85 |
| Simp_Size_Method => "simp add: size_ne_size_imp_ne" |
|
86 |
| Auto_Method => "auto" |
|
87 |
| Fastforce_Method => "fastforce" |
|
88 |
| Force_Method => "force" |
|
|
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
89 |
| Linarith_Method => "linarith" |
|
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
90 |
| Presburger_Method => "presburger" |
| 55285 | 91 |
| Algebra_Method => "algebra") |
92 |
||
|
55452
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
93 |
(* Makes proof methods as silent as possible. The "set_visible" calls suppresses "Unification bound |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
94 |
exceeded" warnings and the like. *) |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
95 |
fun silence_proof_methods debug = |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
96 |
Try0.silence_methods debug |
| 56081 | 97 |
#> Config.put SMT2_Config.verbose debug |
|
55452
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
98 |
|
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
99 |
fun tac_of_proof_method ctxt0 debug (local_facts, global_facts) meth = |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
100 |
let val ctxt = silence_proof_methods debug ctxt0 in |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
101 |
Method.insert_tac local_facts THEN' |
| 55285 | 102 |
(case meth of |
|
55452
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
103 |
Metis_Method (type_enc_opt, lam_trans_opt) => |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
104 |
Metis_Tactic.metis_tac [type_enc_opt |> the_default (hd partial_type_encs)] |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
105 |
(lam_trans_opt |> the_default default_metis_lam_trans) ctxt global_facts |
| 56856 | 106 |
| Meson_Method => Meson_Tactic.meson_general_tac ctxt global_facts |
| 56081 | 107 |
| SMT2_Method => SMT2_Solver.smt2_tac ctxt global_facts |
|
55452
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
108 |
| _ => |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
109 |
Method.insert_tac global_facts THEN' |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
110 |
(case meth of |
|
56852
b38c5b9cf590
added 'satx' to Sledgehammer's portfolio (cf. 'isar_try0')
blanchet
parents:
56093
diff
changeset
|
111 |
SATx_Method => SAT.satx_tac ctxt |
|
b38c5b9cf590
added 'satx' to Sledgehammer's portfolio (cf. 'isar_try0')
blanchet
parents:
56093
diff
changeset
|
112 |
| Blast_Method => blast_tac ctxt |
|
55452
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
113 |
| Simp_Method => Simplifier.asm_full_simp_tac ctxt |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
114 |
| Simp_Size_Method => |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
115 |
Simplifier.asm_full_simp_tac (Simplifier.add_simp @{thm size_ne_size_imp_ne} ctxt)
|
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
116 |
| Auto_Method => K (Clasimp.auto_tac ctxt) |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
117 |
| Fastforce_Method => Clasimp.fast_force_tac ctxt |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
118 |
| Force_Method => Clasimp.force_tac ctxt |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
119 |
| Linarith_Method => Lin_Arith.tac ctxt |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
120 |
| Presburger_Method => Cooper.tac true [] [] ctxt |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
121 |
| Algebra_Method => Groebner.algebra_tac [] [] ctxt)) |
|
29ec8680e61f
avoid changing the state's context -- this results in transfer problems later with SMT, and hence preplay tactic failures
blanchet
parents:
55451
diff
changeset
|
122 |
end |
| 55211 | 123 |
|
| 54828 | 124 |
fun string_of_play_outcome (Played time) = string_of_ext_time (false, time) |
| 56093 | 125 |
| string_of_play_outcome (Play_Timed_Out time) = |
126 |
if time = Time.zeroTime then "" else string_of_ext_time (true, time) ^ ", timed out" |
|
| 54828 | 127 |
| string_of_play_outcome Play_Failed = "failed" |
128 |
||
| 55269 | 129 |
fun play_outcome_ord (Played time1, Played time2) = |
130 |
int_ord (pairself Time.toMilliseconds (time1, time2)) |
|
131 |
| play_outcome_ord (Played _, _) = LESS |
|
132 |
| play_outcome_ord (_, Played _) = GREATER |
|
133 |
| play_outcome_ord (Play_Timed_Out time1, Play_Timed_Out time2) = |
|
134 |
int_ord (pairself Time.toMilliseconds (time1, time2)) |
|
135 |
| play_outcome_ord (Play_Timed_Out _, _) = LESS |
|
136 |
| play_outcome_ord (_, Play_Timed_Out _) = GREATER |
|
137 |
| play_outcome_ord (Play_Failed, Play_Failed) = EQUAL |
|
138 |
||
| 55211 | 139 |
(* FIXME: Various bugs, esp. with "unfolding" |
140 |
fun unusing_chained_facts _ 0 = "" |
|
141 |
| unusing_chained_facts used_chaineds num_chained = |
|
142 |
if length used_chaineds = num_chained then "" |
|
143 |
else if null used_chaineds then "(* using no facts *) " |
|
144 |
else "(* using only " ^ space_implode " " used_chaineds ^ " *) " |
|
145 |
*) |
|
146 |
||
147 |
fun apply_on_subgoal _ 1 = "by " |
|
148 |
| apply_on_subgoal 1 _ = "apply " |
|
149 |
| apply_on_subgoal i n = |
|
150 |
"prefer " ^ string_of_int i ^ " " ^ apply_on_subgoal 1 n |
|
151 |
||
152 |
fun command_call name [] = |
|
153 |
name |> not (Symbol_Pos.is_identifier name) ? enclose "(" ")"
|
|
154 |
| command_call name args = "(" ^ name ^ " " ^ space_implode " " args ^ ")"
|
|
155 |
||
| 55285 | 156 |
(* FIXME *) |
157 |
fun proof_method_command meth i n used_chaineds num_chained ss = |
|
| 55211 | 158 |
(* unusing_chained_facts used_chaineds num_chained ^ *) |
| 55285 | 159 |
apply_on_subgoal i n ^ command_call (string_of_proof_method meth) ss |
| 55211 | 160 |
|
| 56093 | 161 |
fun try_command_line banner play command = |
162 |
let val s = string_of_play_outcome play in |
|
163 |
banner ^ ": " ^ Active.sendback_markup [Markup.padding_command] command ^ |
|
164 |
(s |> s <> "" ? enclose " (" ")") ^ "."
|
|
165 |
end |
|
| 52555 | 166 |
|
| 55211 | 167 |
fun minimize_line _ [] = "" |
168 |
| minimize_line minimize_command ss = |
|
169 |
(case minimize_command ss of |
|
170 |
"" => "" |
|
171 |
| command => "\nTo minimize: " ^ Active.sendback_markup [Markup.padding_command] command ^ ".") |
|
172 |
||
173 |
fun split_used_facts facts = |
|
174 |
facts |
|
175 |
|> List.partition (fn (_, (sc, _)) => sc = Chained) |
|
176 |
|> pairself (sort_distinct (string_ord o pairself fst)) |
|
177 |
||
178 |
fun one_line_proof_text num_chained |
|
| 55285 | 179 |
((meth, play), banner, used_facts, minimize_command, subgoal, subgoal_count) = |
| 55211 | 180 |
let |
181 |
val (chained, extra) = split_used_facts used_facts |
|
182 |
||
183 |
val try_line = |
|
184 |
map fst extra |
|
| 55285 | 185 |
|> proof_method_command meth subgoal subgoal_count (map fst chained) num_chained |
| 56093 | 186 |
|> (if play = Play_Failed then enclose "One-line proof reconstruction failed: " "." |
187 |
else try_command_line banner play) |
|
| 55211 | 188 |
in |
189 |
try_line ^ minimize_line minimize_command (map fst (extra @ chained)) |
|
190 |
end |
|
| 52555 | 191 |
|
| 54495 | 192 |
end; |