author | Lukas Bartl |
Mon, 23 Dec 2024 19:38:16 +0100 | |
changeset 81746 | 8b4340d82248 |
parent 81610 | ed9ffd8e9e40 |
permissions | -rw-r--r-- |
55198 | 1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_commands.ML |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
2 |
Author: Jasmin Blanchette, TU Muenchen |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
3 |
|
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
4 |
Adds "sledgehammer" and related commands to Isabelle/Isar's outer syntax. |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
5 |
*) |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
6 |
|
55198 | 7 |
signature SLEDGEHAMMER_COMMANDS = |
35963 | 8 |
sig |
55201 | 9 |
type params = Sledgehammer_Prover.params |
35963 | 10 |
|
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
11 |
val provers : string Unsynchronized.ref |
55205 | 12 |
val default_params : theory -> (string * string) list -> params |
73691
2f9877db82a1
reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents:
72400
diff
changeset
|
13 |
val parse_params: (string * string) list parser |
35963 | 14 |
end; |
15 |
||
55198 | 16 |
structure Sledgehammer_Commands : SLEDGEHAMMER_COMMANDS = |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
17 |
struct |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
18 |
|
44784 | 19 |
open ATP_Util |
46320 | 20 |
open ATP_Problem_Generate |
57154 | 21 |
open ATP_Proof |
46320 | 22 |
open ATP_Proof_Reconstruct |
35971 | 23 |
open Sledgehammer_Util |
48250
1065c307fafe
further ML structure split to permit finer-grained loading/reordering (problem to solve: MaSh needs most of Sledgehammer)
blanchet
parents:
47962
diff
changeset
|
24 |
open Sledgehammer_Fact |
72400 | 25 |
open Sledgehammer_ATP_Systems |
55201 | 26 |
open Sledgehammer_Prover |
75036 | 27 |
open Sledgehammer_Prover_SMT |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
28 |
open Sledgehammer_Prover_Minimize |
48381 | 29 |
open Sledgehammer_MaSh |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
30 |
open Sledgehammer |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
31 |
|
43020
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
blanchet
parents:
43018
diff
changeset
|
32 |
val runN = "run" |
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
blanchet
parents:
43018
diff
changeset
|
33 |
val supported_proversN = "supported_provers" |
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
blanchet
parents:
43018
diff
changeset
|
34 |
val refresh_tptpN = "refresh_tptp" |
48301 | 35 |
|
36394
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
36 |
(** Sledgehammer commands **) |
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
37 |
|
48292 | 38 |
fun add_fact_override ns : fact_override = {add = ns, del = [], only = false} |
39 |
fun del_fact_override ns : fact_override = {add = [], del = ns, only = false} |
|
40 |
fun only_fact_override ns : fact_override = {add = ns, del = [], only = true} |
|
41 |
fun merge_fact_override_pairwise (r1 : fact_override) (r2 : fact_override) = |
|
57273
01b68f625550
automatically learn MaSh facts also in 'blocking' mode
blanchet
parents:
57245
diff
changeset
|
42 |
{add = #add r1 @ #add r2, del = #del r1 @ #del r2, only = #only r1 andalso #only r2} |
01b68f625550
automatically learn MaSh facts also in 'blocking' mode
blanchet
parents:
57245
diff
changeset
|
43 |
fun merge_fact_overrides rs = fold merge_fact_override_pairwise rs (only_fact_override []) |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
44 |
|
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
45 |
(*** parameters ***) |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
46 |
|
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
47 |
val provers = Unsynchronized.ref "" |
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
48 |
|
35963 | 49 |
type raw_param = string * string list |
50 |
||
51 |
val default_default_params = |
|
41208
1b28c43a7074
make "debug" imply "blocking", since in blocking mode the exceptions flow through and are more instructive
blanchet
parents:
41153
diff
changeset
|
52 |
[("debug", "false"), |
35963 | 53 |
("verbose", "false"), |
36143
6490319b1703
added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents:
36142
diff
changeset
|
54 |
("overlord", "false"), |
53800 | 55 |
("spy", "false"), |
78149
d3122089b67c
disable 'falsify' and 'abduce' in Sledgehammer by default, since they don't seem to be very useful in practice
blanchet
parents:
77428
diff
changeset
|
56 |
("abduce", "0"), |
d3122089b67c
disable 'falsify' and 'abduce' in Sledgehammer by default, since they don't seem to be very useful in practice
blanchet
parents:
77428
diff
changeset
|
57 |
("falsify", "false"), |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43572
diff
changeset
|
58 |
("type_enc", "smart"), |
46301 | 59 |
("strict", "false"), |
45514 | 60 |
("lam_trans", "smart"), |
46409
d4754183ccce
made option available to users (mostly for experiments)
blanchet
parents:
46398
diff
changeset
|
61 |
("uncurried_aliases", "smart"), |
48321 | 62 |
("learn", "true"), |
48314
ee33ba3c0e05
added option to control which fact filter is used
blanchet
parents:
48308
diff
changeset
|
63 |
("fact_filter", "smart"), |
73940
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
64 |
("induction_rules", "smart"), |
48314
ee33ba3c0e05
added option to control which fact filter is used
blanchet
parents:
48308
diff
changeset
|
65 |
("max_facts", "smart"), |
48293 | 66 |
("fact_thresholds", "0.45 0.85"), |
47962
137883567114
lower the monomorphization thresholds for less scalable provers
blanchet
parents:
47642
diff
changeset
|
67 |
("max_mono_iters", "smart"), |
137883567114
lower the monomorphization thresholds for less scalable provers
blanchet
parents:
47642
diff
changeset
|
68 |
("max_new_mono_instances", "smart"), |
75031 | 69 |
("max_proofs", "4"), |
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51189
diff
changeset
|
70 |
("isar_proofs", "smart"), |
57783 | 71 |
("compress", "smart"), |
57245 | 72 |
("try0", "true"), |
71931
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
70934
diff
changeset
|
73 |
("smt_proofs", "true"), |
81746 | 74 |
("instantiate", "smart"), |
57721 | 75 |
("minimize", "true"), |
75872
8bfad7bc74cb
tweak Sledgehammer's slicing mechanism -- updated Zipperposition's slices and make them half as long as other provers' to pack more of them in 30 s
blanchet
parents:
75465
diff
changeset
|
76 |
("slices", string_of_int (12 * Multithreading.max_threads ())), |
81610 | 77 |
("preplay_timeout", "1"), |
78 |
("cache_dir", "")] |
|
35963 | 79 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
80 |
val alias_params = |
51138 | 81 |
[("prover", ("provers", [])), (* undocumented *) |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
82 |
("dont_abduce", ("abduce", ["0"])), |
51189 | 83 |
("dont_preplay", ("preplay_timeout", ["0"])), |
57783 | 84 |
("dont_compress", ("compress", ["1"])), |
75023 | 85 |
("dont_slice", ("slices", ["1"])), |
52093 | 86 |
("isar_proof", ("isar_proofs", [])) (* legacy *)] |
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
87 |
val negated_alias_params = |
41208
1b28c43a7074
make "debug" imply "blocking", since in blocking mode the exceptions flow through and are more instructive
blanchet
parents:
41153
diff
changeset
|
88 |
[("no_debug", "debug"), |
35963 | 89 |
("quiet", "verbose"), |
36143
6490319b1703
added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents:
36142
diff
changeset
|
90 |
("no_overlord", "overlord"), |
53800 | 91 |
("dont_spy", "spy"), |
77428 | 92 |
("dont_falsify", "falsify"), |
46301 | 93 |
("non_strict", "strict"), |
46409
d4754183ccce
made option available to users (mostly for experiments)
blanchet
parents:
46398
diff
changeset
|
94 |
("no_uncurried_aliases", "uncurried_aliases"), |
48321 | 95 |
("dont_learn", "learn"), |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49632
diff
changeset
|
96 |
("no_isar_proofs", "isar_proofs"), |
51879 | 97 |
("dont_minimize", "minimize"), |
57245 | 98 |
("dont_try0", "try0"), |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
99 |
("no_smt_proofs", "smt_proofs"), |
81746 | 100 |
("dont_instantiate", "instantiate")] |
35963 | 101 |
|
43569
b342cd125533
removed "full_types" option from Sledgehammer, now that virtually sound encodings are used as the default anyway
blanchet
parents:
43353
diff
changeset
|
102 |
val property_dependent_params = ["provers", "timeout"] |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
103 |
|
35963 | 104 |
fun is_known_raw_param s = |
105 |
AList.defined (op =) default_default_params s orelse |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
106 |
AList.defined (op =) alias_params s orelse |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
107 |
AList.defined (op =) negated_alias_params s orelse |
67405
e9ab4ad7bd15
uniform use of Standard ML op-infix -- eliminated warnings;
wenzelm
parents:
67399
diff
changeset
|
108 |
member (op =) property_dependent_params s orelse s = "expect" |
35963 | 109 |
|
41258
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
110 |
fun is_prover_list ctxt s = |
55286 | 111 |
(case space_explode " " s of |
41727
ab3f6d76fb23
available_provers ~> supported_provers (for clarity)
blanchet
parents:
41472
diff
changeset
|
112 |
ss as _ :: _ => forall (is_prover_supported ctxt) ss |
55286 | 113 |
| _ => false) |
41258
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
114 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
115 |
fun unalias_raw_param (name, value) = |
55286 | 116 |
(case AList.lookup (op =) alias_params name of |
47037 | 117 |
SOME (name', []) => (name', value) |
118 |
| SOME (param' as (name', _)) => |
|
119 |
if value <> ["false"] then |
|
120 |
param' |
|
121 |
else |
|
63692 | 122 |
error ("Parameter " ^ quote name ^ " cannot be set to \"false\" (cf. " ^ quote name' ^ ")") |
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
123 |
| NONE => |
55286 | 124 |
(case AList.lookup (op =) negated_alias_params name of |
125 |
SOME name' => (name', |
|
126 |
(case value of |
|
127 |
["false"] => ["true"] |
|
128 |
| ["true"] => ["false"] |
|
129 |
| [] => ["false"] |
|
130 |
| _ => value)) |
|
131 |
| NONE => (name, value))) |
|
35963 | 132 |
|
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
52018
diff
changeset
|
133 |
val any_type_enc = type_enc_of_string Strict "erased" |
45514 | 134 |
|
48397 | 135 |
(* "provers =", "type_enc =", "lam_trans =", "fact_filter =", and "max_facts =" |
136 |
can be omitted. For the last four, this is a secret feature. *) |
|
44720
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
137 |
fun normalize_raw_param ctxt = |
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
138 |
unalias_raw_param |
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
139 |
#> (fn (name, value) => |
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
140 |
if is_known_raw_param name then |
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
141 |
(name, value) |
48533 | 142 |
else if null value then |
143 |
if is_prover_list ctxt name then |
|
144 |
("provers", [name]) |
|
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
52018
diff
changeset
|
145 |
else if can (type_enc_of_string Strict) name then |
48533 | 146 |
("type_enc", [name]) |
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
52018
diff
changeset
|
147 |
else if can (trans_lams_of_string ctxt any_type_enc) name then |
48533 | 148 |
("lam_trans", [name]) |
149 |
else if member (op =) fact_filters name then |
|
150 |
("fact_filter", [name]) |
|
151 |
else if is_some (Int.fromString name) then |
|
152 |
("max_facts", [name]) |
|
153 |
else |
|
63692 | 154 |
error ("Unknown parameter: " ^ quote name) |
48400 | 155 |
else |
63692 | 156 |
error ("Unknown parameter: " ^ quote name)) |
44720
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
157 |
|
46435 | 158 |
(* Ensures that type encodings such as "mono_native?" and "poly_guards!!" are |
44785 | 159 |
read correctly. *) |
80910 | 160 |
val implode_param = strip_spaces_except_between_idents o implode_space |
43009
f58bab6be6a9
reintroduced Waldmeister but limit the number of remote threads created
blanchet
parents:
43008
diff
changeset
|
161 |
|
54059 | 162 |
(* FIXME: use "Generic_Data" *) |
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
41258
diff
changeset
|
163 |
structure Data = Theory_Data |
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
41258
diff
changeset
|
164 |
( |
35963 | 165 |
type T = raw_param list |
54546
8b403a7a8c44
fixed spying so that the envirnoment variables are queried at run-time not at build-time
blanchet
parents:
54503
diff
changeset
|
166 |
val empty = default_default_params |> map (apsnd single) |
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
41258
diff
changeset
|
167 |
fun merge data : T = AList.merge (op =) (K true) data |
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
41258
diff
changeset
|
168 |
) |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
169 |
|
57677 | 170 |
(* The first ATP of the list is used by Auto Sledgehammer. *) |
75016
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
171 |
fun default_provers_param_value ctxt = |
75465
d9b23902692d
excluded dummy ATPs from Sledgehammer's default provers
desharna
parents:
75065
diff
changeset
|
172 |
\<comment> \<open>see also \<^system_option>\<open>sledgehammer_provers\<close>\<close> |
76939
0a46b3dbd5ad
tuned sledgehammer default provers to only include local ones
desharna
parents:
75872
diff
changeset
|
173 |
filter (is_prover_installed ctxt) (smts ctxt @ local_atps) |
42776 | 174 |
|> implode_param |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
175 |
|
44720
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
176 |
fun set_default_raw_param param thy = |
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
177 |
let val ctxt = Proof_Context.init_global thy in |
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
178 |
thy |> Data.map (AList.update (op =) (normalize_raw_param ctxt param)) |
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
179 |
end |
54059 | 180 |
|
75016
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
181 |
fun default_raw_params thy = |
55475
b8ebbcc5e49a
restored old 'remotify' logic -- too many bugs were introduced when refactoring the code
blanchet
parents:
55458
diff
changeset
|
182 |
let val ctxt = Proof_Context.init_global thy in |
b8ebbcc5e49a
restored old 'remotify' logic -- too many bugs were introduced when refactoring the code
blanchet
parents:
55458
diff
changeset
|
183 |
Data.get thy |
b8ebbcc5e49a
restored old 'remotify' logic -- too many bugs were introduced when refactoring the code
blanchet
parents:
55458
diff
changeset
|
184 |
|> fold (AList.default (op =)) |
75016
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
185 |
[("provers", [(case !provers of "" => default_provers_param_value ctxt | s => s)]), |
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
186 |
("timeout", |
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
187 |
let val timeout = Options.default_int \<^system_option>\<open>sledgehammer_timeout\<close> in |
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
188 |
[if timeout <= 0 then "none" else string_of_int timeout] |
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
189 |
end)] |
55475
b8ebbcc5e49a
restored old 'remotify' logic -- too many bugs were introduced when refactoring the code
blanchet
parents:
55458
diff
changeset
|
190 |
end |
35963 | 191 |
|
43021 | 192 |
fun extract_params mode default_params override_params = |
35963 | 193 |
let |
194 |
val raw_params = rev override_params @ rev default_params |
|
42776 | 195 |
val lookup = Option.map implode_param o AList.lookup (op =) raw_params |
35963 | 196 |
val lookup_string = the_default "" o lookup |
57290
bc06471cb7b7
move method silencing code closer to the methods it is trying to silence, to reduce bad side-effects
blanchet
parents:
57274
diff
changeset
|
197 |
|
35963 | 198 |
fun general_lookup_bool option default_value name = |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
199 |
(case lookup name of |
35970
3d41a2a490f0
revert debugging output that shouldn't have been submitted in the first place
blanchet
parents:
35966
diff
changeset
|
200 |
SOME s => parse_bool_option option name s |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
201 |
| NONE => default_value) |
35963 | 202 |
val lookup_bool = the o general_lookup_bool false (SOME false) |
203 |
fun lookup_time name = |
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
204 |
(case lookup name of |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
205 |
SOME s => parse_time name s |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
206 |
| NONE => Time.zeroTime) |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
207 |
fun lookup_int name = |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
208 |
(case lookup name of |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
209 |
NONE => 0 |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
210 |
| SOME s => |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
211 |
(case Int.fromString s of |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
212 |
SOME n => n |
63692 | 213 |
| NONE => error ("Parameter " ^ quote name ^ " must be assigned an integer value"))) |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49632
diff
changeset
|
214 |
fun lookup_real name = |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
215 |
(case lookup name of |
49918
cf441f4a358b
renamed Isar-proof related options + changed semantics of Isar shrinking
blanchet
parents:
49632
diff
changeset
|
216 |
NONE => 0.0 |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
217 |
| SOME s => |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
218 |
(case Real.fromString s of |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
219 |
SOME n => n |
63692 | 220 |
| NONE => error ("Parameter " ^ quote name ^ " must be assigned a real value"))) |
40343
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
221 |
fun lookup_real_pair name = |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
222 |
(case lookup name of |
40343
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
223 |
NONE => (0.0, 0.0) |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
224 |
| SOME s => |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
225 |
(case s |> space_explode " " |> map Real.fromString of |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
226 |
[SOME r1, SOME r2] => (r1, r2) |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
227 |
| _ => error ("Parameter " ^ quote name ^ " must be assigned a pair of floating-point \ |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
228 |
\values (e.g., \"0.6 0.95\")"))) |
43064
b6e61d22fa61
made "explicit_apply" smarter -- no need to force explicit applications in minimizer on all constants, better do it more fine granularly
blanchet
parents:
43057
diff
changeset
|
229 |
fun lookup_option lookup' name = |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
230 |
(case lookup name of |
38589
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
231 |
SOME "smart" => NONE |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
232 |
| _ => SOME (lookup' name)) |
43021 | 233 |
val debug = mode <> Auto_Try andalso lookup_bool "debug" |
234 |
val verbose = debug orelse (mode <> Auto_Try andalso lookup_bool "verbose") |
|
36143
6490319b1703
added "overlord" option (to get easy access to output files for debugging) + systematically use "raw_goal" rather than an inconsistent mixture
blanchet
parents:
36142
diff
changeset
|
235 |
val overlord = lookup_bool "overlord" |
54546
8b403a7a8c44
fixed spying so that the envirnoment variables are queried at run-time not at build-time
blanchet
parents:
54503
diff
changeset
|
236 |
val spy = getenv "SLEDGEHAMMER_SPY" = "yes" orelse lookup_bool "spy" |
57290
bc06471cb7b7
move method silencing code closer to the methods it is trying to silence, to reduce bad side-effects
blanchet
parents:
57274
diff
changeset
|
237 |
val provers = lookup_string "provers" |> space_explode " " |> mode = Auto_Try ? single o hd |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
238 |
val abduce = |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
239 |
if mode = Auto_Try then SOME 0 |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
240 |
else lookup_option lookup_int "abduce" |
77428 | 241 |
val falsify = |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
242 |
if mode = Auto_Try then SOME false |
77428 | 243 |
else lookup_option lookup_bool "falsify" |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43572
diff
changeset
|
244 |
val type_enc = |
43021 | 245 |
if mode = Auto_Try then |
43569
b342cd125533
removed "full_types" option from Sledgehammer, now that virtually sound encodings are used as the default anyway
blanchet
parents:
43353
diff
changeset
|
246 |
NONE |
55286 | 247 |
else |
248 |
(case lookup_string "type_enc" of |
|
249 |
"smart" => NONE |
|
250 |
| s => (type_enc_of_string Strict s; SOME s)) |
|
46301 | 251 |
val strict = mode = Auto_Try orelse lookup_bool "strict" |
45520 | 252 |
val lam_trans = lookup_option lookup_string "lam_trans" |
46409
d4754183ccce
made option available to users (mostly for experiments)
blanchet
parents:
46398
diff
changeset
|
253 |
val uncurried_aliases = lookup_option lookup_bool "uncurried_aliases" |
48321 | 254 |
val learn = lookup_bool "learn" |
54113
df080dfefddc
use MePo with Auto Sledgehammer, because it's lighter than MaSh and always available
blanchet
parents:
54059
diff
changeset
|
255 |
val fact_filter = |
df080dfefddc
use MePo with Auto Sledgehammer, because it's lighter than MaSh and always available
blanchet
parents:
54059
diff
changeset
|
256 |
lookup_option lookup_string "fact_filter" |
df080dfefddc
use MePo with Auto Sledgehammer, because it's lighter than MaSh and always available
blanchet
parents:
54059
diff
changeset
|
257 |
|> mode = Auto_Try ? (fn NONE => SOME mepoN | sf => sf) |
73940
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
258 |
val induction_rules = |
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
259 |
lookup_option (the o induction_rules_of_string o lookup_string) "induction_rules" |
48314
ee33ba3c0e05
added option to control which fact filter is used
blanchet
parents:
48308
diff
changeset
|
260 |
val max_facts = lookup_option lookup_int "max_facts" |
48293 | 261 |
val fact_thresholds = lookup_real_pair "fact_thresholds" |
47962
137883567114
lower the monomorphization thresholds for less scalable provers
blanchet
parents:
47642
diff
changeset
|
262 |
val max_mono_iters = lookup_option lookup_int "max_mono_iters" |
137883567114
lower the monomorphization thresholds for less scalable provers
blanchet
parents:
47642
diff
changeset
|
263 |
val max_new_mono_instances = |
137883567114
lower the monomorphization thresholds for less scalable provers
blanchet
parents:
47642
diff
changeset
|
264 |
lookup_option lookup_int "max_new_mono_instances" |
75031 | 265 |
val max_proofs = lookup_int "max_proofs" |
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51189
diff
changeset
|
266 |
val isar_proofs = lookup_option lookup_bool "isar_proofs" |
57783 | 267 |
val compress = Option.map (curry Real.max 1.0) (lookup_option lookup_real "compress") |
57245 | 268 |
val try0 = lookup_bool "try0" |
71931
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
70934
diff
changeset
|
269 |
val smt_proofs = lookup_bool "smt_proofs" |
81746 | 270 |
val instantiate = lookup_option lookup_bool "instantiate" |
75040 | 271 |
val minimize = mode <> Auto_Try andalso lookup_bool "minimize" |
75023 | 272 |
val slices = if mode = Auto_Try then 1 else Int.max (1, lookup_int "slices") |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54546
diff
changeset
|
273 |
val timeout = lookup_time "timeout" |
60306
6b7c64ab8bd2
made Auto Sledgehammer behave more like the real thing
blanchet
parents:
60277
diff
changeset
|
274 |
val preplay_timeout = lookup_time "preplay_timeout" |
38985
162bbbea4e4d
added "expect" feature of Nitpick to Sledgehammer, for regression testing
blanchet
parents:
38982
diff
changeset
|
275 |
val expect = lookup_string "expect" |
81610 | 276 |
val cache_dir = Option.mapPartial |
277 |
(fn str => if str = "" then NONE else SOME (Path.explode str)) (lookup "cache_dir") |
|
35963 | 278 |
in |
61311
150aa3015c47
removed legacy asynchronous mode in Sledgehammer
blanchet
parents:
61223
diff
changeset
|
279 |
{debug = debug, verbose = verbose, overlord = overlord, spy = spy, provers = provers, |
77428 | 280 |
abduce = abduce, falsify = falsify, type_enc = type_enc, strict = strict, |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76939
diff
changeset
|
281 |
lam_trans = lam_trans, uncurried_aliases = uncurried_aliases, learn = learn, |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76939
diff
changeset
|
282 |
fact_filter = fact_filter, induction_rules = induction_rules, max_facts = max_facts, |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76939
diff
changeset
|
283 |
fact_thresholds = fact_thresholds, max_mono_iters = max_mono_iters, |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76939
diff
changeset
|
284 |
max_new_mono_instances = max_new_mono_instances, max_proofs = max_proofs, |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76939
diff
changeset
|
285 |
isar_proofs = isar_proofs, compress = compress, try0 = try0, smt_proofs = smt_proofs, |
81746 | 286 |
instantiate = instantiate, minimize = minimize, slices = slices, timeout = timeout, |
81610 | 287 |
preplay_timeout = preplay_timeout, expect = expect, cache_dir = cache_dir} |
35963 | 288 |
end |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
289 |
|
75016
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
290 |
fun get_params mode = extract_params mode o default_raw_params |
43021 | 291 |
fun default_params thy = get_params Normal thy o map (apsnd single) |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
292 |
|
60564 | 293 |
val silence_state = |
294 |
Proof.map_contexts (Try0.silence_methods false #> Config.put SMT_Config.verbose false) |
|
295 |
||
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
296 |
(* Sledgehammer the given subgoal *) |
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
297 |
|
50604 | 298 |
val default_learn_prover_timeout = 2.0 |
48392
ca998fa08cd9
added "learn_from_atp" command to MaSh, for patient users
blanchet
parents:
48388
diff
changeset
|
299 |
|
61223 | 300 |
fun hammer_away override_params writeln_result subcommand opt_i fact_override state0 = |
35963 | 301 |
let |
79140
2413181b10bb
removed hack in Sledgehammer that confuses preplay and gives Sledgehammer a strange semantics
blanchet
parents:
78149
diff
changeset
|
302 |
val state = silence_state state0 |
55205 | 303 |
val thy = Proof.theory_of state |
40069 | 304 |
val ctxt = Proof.context_of state |
55205 | 305 |
|
44720
f3a8c19708c8
fixed handling of "sledgehammer_params", so that "sledgehammer_params [e]" is really the same as "sledgehammer_params [provers = e]"
blanchet
parents:
44651
diff
changeset
|
306 |
val override_params = override_params |> map (normalize_raw_param ctxt) |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
307 |
in |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
308 |
if subcommand = runN then |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
309 |
let val i = the_default 1 opt_i in |
60564 | 310 |
ignore (run_sledgehammer |
61223 | 311 |
(get_params Normal thy override_params) Normal writeln_result i fact_override state) |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
312 |
end |
41727
ab3f6d76fb23
available_provers ~> supported_provers (for clarity)
blanchet
parents:
41472
diff
changeset
|
313 |
else if subcommand = supported_proversN then |
ab3f6d76fb23
available_provers ~> supported_provers (for clarity)
blanchet
parents:
41472
diff
changeset
|
314 |
supported_provers ctxt |
48383 | 315 |
else if subcommand = unlearnN then |
64522
b66f8caf86b6
made MaSh faster and less likely to hang seemingly forever
blanchet
parents:
63692
diff
changeset
|
316 |
mash_unlearn ctxt |
50484
8ec31bdb9d36
adopt the neutral "prover" terminology for MaSh rather than the ambiguous/wrong ATP terminology (which sometimes excludes SMT solvers)
blanchet
parents:
50052
diff
changeset
|
317 |
else if subcommand = learn_isarN orelse subcommand = learn_proverN orelse |
8ec31bdb9d36
adopt the neutral "prover" terminology for MaSh rather than the ambiguous/wrong ATP terminology (which sometimes excludes SMT solvers)
blanchet
parents:
50052
diff
changeset
|
318 |
subcommand = relearn_isarN orelse subcommand = relearn_proverN then |
64522
b66f8caf86b6
made MaSh faster and less likely to hang seemingly forever
blanchet
parents:
63692
diff
changeset
|
319 |
(if subcommand = relearn_isarN orelse subcommand = relearn_proverN then mash_unlearn ctxt |
57433 | 320 |
else (); |
50484
8ec31bdb9d36
adopt the neutral "prover" terminology for MaSh rather than the ambiguous/wrong ATP terminology (which sometimes excludes SMT solvers)
blanchet
parents:
50052
diff
changeset
|
321 |
mash_learn ctxt |
79140
2413181b10bb
removed hack in Sledgehammer that confuses preplay and gives Sledgehammer a strange semantics
blanchet
parents:
78149
diff
changeset
|
322 |
(* TODO: Use MaSh mode instead and have the special defaults hardcoded in "get_params". *) |
55205 | 323 |
(get_params Normal thy |
324 |
([("timeout", [string_of_real default_learn_prover_timeout]), |
|
50484
8ec31bdb9d36
adopt the neutral "prover" terminology for MaSh rather than the ambiguous/wrong ATP terminology (which sometimes excludes SMT solvers)
blanchet
parents:
50052
diff
changeset
|
325 |
("slice", ["false"])] @ |
8ec31bdb9d36
adopt the neutral "prover" terminology for MaSh rather than the ambiguous/wrong ATP terminology (which sometimes excludes SMT solvers)
blanchet
parents:
50052
diff
changeset
|
326 |
override_params @ |
57721 | 327 |
[("preplay_timeout", ["0"])])) |
50484
8ec31bdb9d36
adopt the neutral "prover" terminology for MaSh rather than the ambiguous/wrong ATP terminology (which sometimes excludes SMT solvers)
blanchet
parents:
50052
diff
changeset
|
328 |
fact_override (#facts (Proof.goal state)) |
8ec31bdb9d36
adopt the neutral "prover" terminology for MaSh rather than the ambiguous/wrong ATP terminology (which sometimes excludes SMT solvers)
blanchet
parents:
50052
diff
changeset
|
329 |
(subcommand = learn_proverN orelse subcommand = relearn_proverN)) |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
330 |
else if subcommand = refresh_tptpN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
331 |
refresh_systems_on_tptp () |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
332 |
else |
63692 | 333 |
error ("Unknown subcommand: " ^ quote subcommand) |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
334 |
end |
35963 | 335 |
|
57735
056a55b44ec7
eliminated Sledgehammer's "min" subcommand (and lots of complications in the code)
blanchet
parents:
57732
diff
changeset
|
336 |
fun string_of_raw_param (key, values) = |
056a55b44ec7
eliminated Sledgehammer's "min" subcommand (and lots of complications in the code)
blanchet
parents:
57732
diff
changeset
|
337 |
key ^ (case implode_param values of "" => "" | value => " = " ^ value) |
35963 | 338 |
|
69593 | 339 |
val parse_query_bang = \<^keyword>\<open>?\<close> || \<^keyword>\<open>!\<close> || \<^keyword>\<open>!!\<close> |
63136 | 340 |
val parse_key = Scan.repeat1 (Parse.embedded || parse_query_bang) >> implode_param |
62969 | 341 |
val parse_value = Scan.repeat1 (Parse.name || Parse.float_number || parse_query_bang) |
69593 | 342 |
val parse_param = parse_key -- Scan.optional (\<^keyword>\<open>=\<close> |-- parse_value) [] |
73691
2f9877db82a1
reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents:
72400
diff
changeset
|
343 |
val parse_raw_params = Scan.optional (Args.bracks (Parse.list parse_param)) [] |
2f9877db82a1
reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents:
72400
diff
changeset
|
344 |
val parse_params = parse_raw_params >> map (apsnd implode_param) |
62969 | 345 |
val parse_fact_refs = Scan.repeat1 (Scan.unless (Parse.name -- Args.colon) Parse.thm) |
48293 | 346 |
val parse_fact_override_chunk = |
48292 | 347 |
(Args.add |-- Args.colon |-- parse_fact_refs >> add_fact_override) |
75065
7cadf5a7ed5b
more liberal parsing of Sledgehammer options to allow empty lists (as suggested by Larry Paulson)
blanchet
parents:
75064
diff
changeset
|
348 |
|| (Args.add |-- Args.colon |-- Scan.succeed [] >> add_fact_override) |
48292 | 349 |
|| (Args.del |-- Args.colon |-- parse_fact_refs >> del_fact_override) |
75065
7cadf5a7ed5b
more liberal parsing of Sledgehammer options to allow empty lists (as suggested by Larry Paulson)
blanchet
parents:
75064
diff
changeset
|
350 |
|| (Args.del |-- Args.colon |-- Scan.succeed [] >> del_fact_override) |
48292 | 351 |
|| (parse_fact_refs >> only_fact_override) |
352 |
val parse_fact_override = |
|
57290
bc06471cb7b7
move method silencing code closer to the methods it is trying to silence, to reduce bad side-effects
blanchet
parents:
57274
diff
changeset
|
353 |
Scan.optional (Args.parens (Scan.repeat parse_fact_override_chunk >> merge_fact_overrides)) |
57433 | 354 |
no_fact_override |
35963 | 355 |
|
356 |
val _ = |
|
69593 | 357 |
Outer_Syntax.command \<^command_keyword>\<open>sledgehammer\<close> |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46949
diff
changeset
|
358 |
"search for first-order proof using automatic theorem provers" |
73691
2f9877db82a1
reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents:
72400
diff
changeset
|
359 |
(Scan.optional Parse.name runN -- parse_raw_params |
60277
bcd9a70342be
sledgehammer panel operation re-uses more of the Isar command, notably Try0.silence_methods to avoid spurious warnings intruding the document view;
wenzelm
parents:
60276
diff
changeset
|
360 |
-- parse_fact_override -- Scan.option Parse.nat >> |
60276 | 361 |
(fn (((subcommand, params), fact_override), opt_i) => |
60277
bcd9a70342be
sledgehammer panel operation re-uses more of the Isar command, notably Try0.silence_methods to avoid spurious warnings intruding the document view;
wenzelm
parents:
60276
diff
changeset
|
362 |
Toplevel.keep_proof |
bcd9a70342be
sledgehammer panel operation re-uses more of the Isar command, notably Try0.silence_methods to avoid spurious warnings intruding the document view;
wenzelm
parents:
60276
diff
changeset
|
363 |
(hammer_away params NONE subcommand opt_i fact_override o Toplevel.proof_of))) |
35963 | 364 |
val _ = |
69593 | 365 |
Outer_Syntax.command \<^command_keyword>\<open>sledgehammer_params\<close> |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46949
diff
changeset
|
366 |
"set and display the default parameters for Sledgehammer" |
73691
2f9877db82a1
reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents:
72400
diff
changeset
|
367 |
(parse_raw_params >> (fn params => |
60276 | 368 |
Toplevel.theory (fold set_default_raw_param params #> tap (fn thy => |
369 |
writeln ("Default parameters for Sledgehammer:\n" ^ |
|
75016
873b581fd690
generalized the 'slice' option towards more flexible slicing
blanchet
parents:
74953
diff
changeset
|
370 |
(case rev (default_raw_params thy) of |
60276 | 371 |
[] => "none" |
372 |
| params => params |> map string_of_raw_param |> sort_strings |> cat_lines)))))) |
|
36394
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
373 |
|
74508 | 374 |
val _ = |
375 |
Try.tool_setup |
|
376 |
{name = sledgehammerN, weight = 40, auto_option = \<^system_option>\<open>auto_sledgehammer\<close>, |
|
377 |
body = fn auto => fn state => |
|
378 |
let |
|
379 |
val thy = Proof.theory_of state |
|
380 |
val mode = if auto then Auto_Try else Try |
|
381 |
val i = 1 |
|
382 |
in |
|
383 |
run_sledgehammer (get_params mode thy []) mode NONE i no_fact_override (silence_state state) |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74561
diff
changeset
|
384 |
|> apsnd (map_prod short_string_of_sledgehammer_outcome single) |
74508 | 385 |
end} |
39318 | 386 |
|
52908
3461985dcbc3
dockable window for Sledgehammer, based on asynchronous/parallel query operation;
wenzelm
parents:
52653
diff
changeset
|
387 |
val _ = |
61223 | 388 |
Query_Operation.register {name = sledgehammerN, pri = 0} |
389 |
(fn {state = st, args, writeln_result, ...} => |
|
390 |
(case try Toplevel.proof_of st of |
|
391 |
SOME state => |
|
392 |
let |
|
393 |
val [provers_arg, isar_proofs_arg, try0_arg] = args |
|
394 |
val override_params = |
|
395 |
((if provers_arg = "" then [] else [("provers", space_explode " " provers_arg)]) @ |
|
396 |
[("isar_proofs", [if isar_proofs_arg = "true" then "true" else "smart"]), |
|
397 |
("try0", [try0_arg]), |
|
398 |
("debug", ["false"]), |
|
399 |
("verbose", ["false"]), |
|
400 |
("overlord", ["false"])]); |
|
401 |
in hammer_away override_params (SOME writeln_result) runN NONE no_fact_override state end |
|
402 |
| NONE => error "Unknown proof context")) |
|
53055
0fe8a9972eda
some protocol to determine provers according to ML;
wenzelm
parents:
53053
diff
changeset
|
403 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
404 |
end; |