author | blanchet |
Fri, 17 Dec 2010 21:47:13 +0100 | |
changeset 41258 | 73401632a80c |
parent 41208 | 1b28c43a7074 |
child 41472 | f6ab14e61604 |
permissions | -rw-r--r-- |
36375
2482446a604c
move the minimizer to the Sledgehammer directory
blanchet
parents:
36373
diff
changeset
|
1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_isar.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 |
|
35963 | 7 |
signature SLEDGEHAMMER_ISAR = |
8 |
sig |
|
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40941
diff
changeset
|
9 |
type params = Sledgehammer_Provers.params |
35963 | 10 |
|
39318 | 11 |
val auto : bool Unsynchronized.ref |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
12 |
val provers : string Unsynchronized.ref |
39318 | 13 |
val timeout : int Unsynchronized.ref |
14 |
val full_types : bool Unsynchronized.ref |
|
40069 | 15 |
val default_params : Proof.context -> (string * string) list -> params |
39318 | 16 |
val setup : theory -> theory |
35963 | 17 |
end; |
18 |
||
35971 | 19 |
structure Sledgehammer_Isar : SLEDGEHAMMER_ISAR = |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
20 |
struct |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
21 |
|
38028 | 22 |
open ATP_Systems |
35971 | 23 |
open Sledgehammer_Util |
41138
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41136
diff
changeset
|
24 |
open Sledgehammer_ATP_Translate |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40941
diff
changeset
|
25 |
open Sledgehammer_Provers |
38988 | 26 |
open Sledgehammer_Minimize |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40941
diff
changeset
|
27 |
open Sledgehammer_Run |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
28 |
|
39318 | 29 |
val auto = Unsynchronized.ref false |
30 |
||
31 |
val _ = |
|
32 |
ProofGeneralPgip.add_preference Preferences.category_tracing |
|
33 |
(Preferences.bool_pref auto "auto-sledgehammer" |
|
39327 | 34 |
"Run Sledgehammer automatically.") |
39318 | 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 |
|
39318 | 38 |
val no_relevance_override = {add = [], del = [], only = false} |
39 |
fun add_relevance_override ns : relevance_override = |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
40 |
{add = ns, del = [], only = false} |
39318 | 41 |
fun del_relevance_override ns : relevance_override = |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
42 |
{add = [], del = ns, only = false} |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
43 |
fun only_relevance_override ns : relevance_override = |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
44 |
{add = ns, del = [], only = true} |
36003 | 45 |
fun merge_relevance_override_pairwise (r1 : relevance_override) |
46 |
(r2 : relevance_override) = |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
47 |
{add = #add r1 @ #add r2, del = #del r1 @ #del r2, |
36183
f723348b2231
Sledgehammer: the empty set of fact () should mean nothing, not unchanged
blanchet
parents:
36143
diff
changeset
|
48 |
only = #only r1 andalso #only r2} |
36188 | 49 |
fun merge_relevance_overrides rs = |
50 |
fold merge_relevance_override_pairwise rs (only_relevance_override []) |
|
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
51 |
|
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
52 |
(*** parameters ***) |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
53 |
|
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
54 |
val provers = Unsynchronized.ref "" |
39335
87a9ff4d5817
use 30 s instead of 60 s as the default Sledgehammer timeout;
blanchet
parents:
39327
diff
changeset
|
55 |
val timeout = Unsynchronized.ref 30 |
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
56 |
val full_types = Unsynchronized.ref false |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
57 |
|
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
58 |
val _ = |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
59 |
ProofGeneralPgip.add_preference Preferences.category_proof |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
60 |
(Preferences.string_pref provers |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
61 |
"Sledgehammer: Provers" |
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
62 |
"Default automatic provers (separated by whitespace)") |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
63 |
|
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
64 |
val _ = |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
65 |
ProofGeneralPgip.add_preference Preferences.category_proof |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
66 |
(Preferences.int_pref timeout |
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
67 |
"Sledgehammer: Time Limit" |
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
68 |
"ATPs will be interrupted after this time (in seconds)") |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
69 |
|
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
70 |
val _ = |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
71 |
ProofGeneralPgip.add_preference Preferences.category_proof |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
72 |
(Preferences.bool_pref full_types |
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
73 |
"Sledgehammer: Full Types" "ATPs will use full type information") |
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
74 |
|
35963 | 75 |
type raw_param = string * string list |
76 |
||
77 |
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
|
78 |
[("debug", "false"), |
35963 | 79 |
("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
|
80 |
("overlord", "false"), |
41208
1b28c43a7074
make "debug" imply "blocking", since in blocking mode the exceptions flow through and are more instructive
blanchet
parents:
41153
diff
changeset
|
81 |
("blocking", "false"), |
41134 | 82 |
("type_sys", "smart"), |
36235
61159615a0c5
added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents:
36223
diff
changeset
|
83 |
("explicit_apply", "false"), |
40343
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
84 |
("relevance_thresholds", "0.45 0.85"), |
38744
2b6333f78a9e
make relevance filter work in term of a "max_relevant" option + use Vampire SOS;
blanchet
parents:
38741
diff
changeset
|
85 |
("max_relevant", "smart"), |
35963 | 86 |
("isar_proof", "false"), |
38590
bd443b426d56
get rid of "minimize_timeout", now that there's an automatic adaptive timeout mechanism in "minimize"
blanchet
parents:
38589
diff
changeset
|
87 |
("isar_shrink_factor", "1")] |
35963 | 88 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
89 |
val alias_params = |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
90 |
[("prover", "provers"), |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
91 |
("atps", "provers"), (* FIXME: legacy *) |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
92 |
("atp", "provers")] (* FIXME: legacy *) |
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
93 |
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
|
94 |
[("no_debug", "debug"), |
35963 | 95 |
("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
|
96 |
("no_overlord", "overlord"), |
41208
1b28c43a7074
make "debug" imply "blocking", since in blocking mode the exceptions flow through and are more instructive
blanchet
parents:
41153
diff
changeset
|
97 |
("non_blocking", "blocking"), |
36399 | 98 |
("partial_types", "full_types"), |
36235
61159615a0c5
added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents:
36223
diff
changeset
|
99 |
("implicit_apply", "explicit_apply"), |
36908
fb18db78be80
delect installed ATPs dynamically, _not_ at image built time
blanchet
parents:
36607
diff
changeset
|
100 |
("no_isar_proof", "isar_proof")] |
35963 | 101 |
|
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
102 |
val params_for_minimize = |
41136
30bedf58b177
implemented new type system encoding "overload_args", which is more lightweight than "const_args" (the unsound default) and hopefully almost as sound
blanchet
parents:
41134
diff
changeset
|
103 |
["debug", "verbose", "overlord", "type_sys", "full_types", "isar_proof", |
38590
bd443b426d56
get rid of "minimize_timeout", now that there's an automatic adaptive timeout mechanism in "minimize"
blanchet
parents:
38589
diff
changeset
|
104 |
"isar_shrink_factor", "timeout"] |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
105 |
|
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
106 |
val property_dependent_params = ["provers", "full_types", "timeout"] |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
107 |
|
35963 | 108 |
fun is_known_raw_param s = |
109 |
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
|
110 |
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
|
111 |
AList.defined (op =) negated_alias_params s orelse |
38985
162bbbea4e4d
added "expect" feature of Nitpick to Sledgehammer, for regression testing
blanchet
parents:
38982
diff
changeset
|
112 |
member (op =) property_dependent_params s orelse s = "expect" |
35963 | 113 |
|
41258
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
114 |
fun is_prover_list ctxt s = |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
115 |
case space_explode " " s of |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
116 |
ss as _ :: _ => forall (is_prover_available ctxt) ss |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
117 |
| _ => false |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
118 |
|
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
119 |
fun check_and_repair_raw_param ctxt (name, value) = |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
120 |
if is_known_raw_param name then (name, value) |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
121 |
else if is_prover_list ctxt name andalso null value then ("provers", [name]) |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
122 |
else error ("Unknown parameter: " ^ quote name ^ ".") |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
123 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
124 |
fun unalias_raw_param (name, value) = |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
125 |
case AList.lookup (op =) alias_params name of |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
126 |
SOME name' => (name', value) |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
127 |
| NONE => |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
128 |
case AList.lookup (op =) negated_alias_params name of |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
129 |
SOME name' => (name', case value of |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
130 |
["false"] => ["true"] |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
131 |
| ["true"] => ["false"] |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
132 |
| [] => ["false"] |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
133 |
| _ => value) |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
134 |
| NONE => (name, value) |
35963 | 135 |
|
136 |
structure Data = Theory_Data( |
|
137 |
type T = raw_param list |
|
138 |
val empty = default_default_params |> map (apsnd single) |
|
139 |
val extend = I |
|
140 |
fun merge p : T = AList.merge (op =) (K true) p) |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
141 |
|
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
142 |
fun remotify_prover_if_available_and_not_already_remote ctxt name = |
40072
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
143 |
if String.isPrefix remote_prefix name then |
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
144 |
SOME name |
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
145 |
else |
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
146 |
let val remote_name = remote_prefix ^ name in |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
147 |
if is_prover_available ctxt remote_name then SOME remote_name else NONE |
40072
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
148 |
end |
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
149 |
|
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
150 |
fun remotify_prover_if_not_installed ctxt name = |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
151 |
if is_prover_available ctxt name andalso is_prover_installed ctxt name then |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
152 |
SOME name |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
153 |
else |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
154 |
remotify_prover_if_available_and_not_already_remote ctxt name |
40072
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
155 |
|
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
156 |
fun avoid_too_many_local_threads _ _ [] = [] |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
157 |
| avoid_too_many_local_threads ctxt 0 provers = |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
158 |
map_filter (remotify_prover_if_available_and_not_already_remote ctxt) |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
159 |
provers |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
160 |
| avoid_too_many_local_threads ctxt n (prover :: provers) = |
40072
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
161 |
let val n = if String.isPrefix remote_prefix prover then n else n - 1 in |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
162 |
prover :: avoid_too_many_local_threads ctxt n provers |
40072
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40069
diff
changeset
|
163 |
end |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
164 |
|
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
165 |
(* The first ATP of the list is used by Auto Sledgehammer. Because of the low |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
166 |
timeout, it makes sense to put SPASS first. *) |
40069 | 167 |
fun default_provers_param_value ctxt = |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
168 |
[spassN, eN, vampireN, sine_eN, SMT_Solver.solver_name_of ctxt] |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
169 |
|> map_filter (remotify_prover_if_not_installed ctxt) |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
170 |
|> avoid_too_many_local_threads ctxt (Multithreading.max_threads_value ()) |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
171 |
|> space_implode " " |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
172 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
173 |
val set_default_raw_param = Data.map o AList.update (op =) o unalias_raw_param |
40069 | 174 |
fun default_raw_params ctxt = |
175 |
let val thy = ProofContext.theory_of ctxt in |
|
176 |
Data.get thy |
|
177 |
|> fold (AList.default (op =)) |
|
178 |
[("provers", [case !provers of |
|
179 |
"" => default_provers_param_value ctxt |
|
180 |
| s => s]), |
|
181 |
("full_types", [if !full_types then "true" else "false"]), |
|
182 |
("timeout", let val timeout = !timeout in |
|
183 |
[if timeout <= 0 then "none" |
|
40341
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
blanchet
parents:
40181
diff
changeset
|
184 |
else string_of_int timeout] |
40069 | 185 |
end)] |
186 |
end |
|
35963 | 187 |
|
41153
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
188 |
val smart_full_type_sys = Tags true |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
189 |
val smart_partial_type_sys = Const_Args |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
190 |
|
35963 | 191 |
val infinity_time_in_secs = 60 * 60 * 24 * 365 |
192 |
val the_timeout = the_default (Time.fromSeconds infinity_time_in_secs) |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
193 |
|
39318 | 194 |
fun extract_params auto default_params override_params = |
35963 | 195 |
let |
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
196 |
val override_params = map unalias_raw_param override_params |
35963 | 197 |
val raw_params = rev override_params @ rev default_params |
198 |
val lookup = Option.map (space_implode " ") o AList.lookup (op =) raw_params |
|
199 |
val lookup_string = the_default "" o lookup |
|
200 |
fun general_lookup_bool option default_value name = |
|
201 |
case lookup name of |
|
35970
3d41a2a490f0
revert debugging output that shouldn't have been submitted in the first place
blanchet
parents:
35966
diff
changeset
|
202 |
SOME s => parse_bool_option option name s |
35963 | 203 |
| NONE => default_value |
204 |
val lookup_bool = the o general_lookup_bool false (SOME false) |
|
205 |
fun lookup_time name = |
|
39318 | 206 |
case lookup name of |
207 |
SOME s => parse_time_option name s |
|
208 |
| NONE => NONE |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
209 |
fun lookup_int name = |
35963 | 210 |
case lookup name of |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
211 |
NONE => 0 |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
212 |
| SOME s => case Int.fromString s of |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
213 |
SOME n => n |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
214 |
| NONE => error ("Parameter " ^ quote name ^ |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
215 |
" must be assigned an integer value.") |
40343
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
216 |
fun lookup_real_pair name = |
38745
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
217 |
case lookup name of |
40343
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
218 |
NONE => (0.0, 0.0) |
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
219 |
| SOME s => case s |> space_explode " " |> map Real.fromString of |
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
220 |
[SOME r1, SOME r2] => (r1, r2) |
38745
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
221 |
| _ => error ("Parameter " ^ quote name ^ |
40343
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
222 |
"must be assigned a pair of floating-point \ |
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
223 |
\values (e.g., \"0.6 0.95\")") |
38589
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
224 |
fun lookup_int_option name = |
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
225 |
case lookup name of |
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
226 |
SOME "smart" => NONE |
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
227 |
| _ => SOME (lookup_int name) |
39318 | 228 |
val debug = not auto andalso lookup_bool "debug" |
229 |
val verbose = debug orelse (not auto 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
|
230 |
val overlord = lookup_bool "overlord" |
41208
1b28c43a7074
make "debug" imply "blocking", since in blocking mode the exceptions flow through and are more instructive
blanchet
parents:
41153
diff
changeset
|
231 |
val blocking = auto orelse debug orelse lookup_bool "blocking" |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
232 |
val provers = lookup_string "provers" |> space_explode " " |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
233 |
|> auto ? single o hd |
41153
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
234 |
val type_sys = |
41138
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41136
diff
changeset
|
235 |
case (lookup_string "type_sys", lookup_bool "full_types") of |
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41136
diff
changeset
|
236 |
("tags", full_types) => Tags full_types |
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41136
diff
changeset
|
237 |
| ("preds", full_types) => Preds full_types |
41153
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
238 |
| ("const_args", false) => Const_Args |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
239 |
| ("none", false) => No_Types |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
240 |
| (type_sys, full_types) => |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
241 |
if member (op =) ["const_args", "none", "smart"] type_sys then |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
242 |
if full_types then smart_full_type_sys else smart_partial_type_sys |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
243 |
else |
626a58993122
make "full_types" take precedence over "type_sys"
blanchet
parents:
41138
diff
changeset
|
244 |
error ("Unknown type system: " ^ quote type_sys ^ ".") |
36235
61159615a0c5
added "explicit_apply" option to Sledgehammer, to control whether an explicit apply function should be used as much or as little as possible (replaces a previous global variable)
blanchet
parents:
36223
diff
changeset
|
245 |
val explicit_apply = lookup_bool "explicit_apply" |
40343
4521d56aef63
use floating-point numbers for Sledgehammer's "thresholds" option rather than percentages;
blanchet
parents:
40341
diff
changeset
|
246 |
val relevance_thresholds = lookup_real_pair "relevance_thresholds" |
38744
2b6333f78a9e
make relevance filter work in term of a "max_relevant" option + use Vampire SOS;
blanchet
parents:
38741
diff
changeset
|
247 |
val max_relevant = lookup_int_option "max_relevant" |
35963 | 248 |
val isar_proof = lookup_bool "isar_proof" |
36924 | 249 |
val isar_shrink_factor = Int.max (1, lookup_int "isar_shrink_factor") |
39318 | 250 |
val timeout = (if auto then NONE else lookup_time "timeout") |> the_timeout |
38985
162bbbea4e4d
added "expect" feature of Nitpick to Sledgehammer, for regression testing
blanchet
parents:
38982
diff
changeset
|
251 |
val expect = lookup_string "expect" |
35963 | 252 |
in |
41208
1b28c43a7074
make "debug" imply "blocking", since in blocking mode the exceptions flow through and are more instructive
blanchet
parents:
41153
diff
changeset
|
253 |
{debug = debug, verbose = verbose, overlord = overlord, blocking = blocking, |
41138
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41136
diff
changeset
|
254 |
provers = provers, type_sys = type_sys, explicit_apply = explicit_apply, |
38745
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
255 |
relevance_thresholds = relevance_thresholds, max_relevant = max_relevant, |
38997 | 256 |
isar_proof = isar_proof, isar_shrink_factor = isar_shrink_factor, |
257 |
timeout = timeout, expect = expect} |
|
35963 | 258 |
end |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
259 |
|
40069 | 260 |
fun get_params auto ctxt = extract_params auto (default_raw_params ctxt) |
39318 | 261 |
fun default_params thy = get_params false thy o map (apsnd single) |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
262 |
|
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
263 |
(* Sledgehammer the given subgoal *) |
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
264 |
|
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
265 |
val sledgehammerN = "sledgehammer" |
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
266 |
val sledgehammer_paramsN = "sledgehammer_params" |
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
267 |
|
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
268 |
val runN = "run" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
269 |
val minimizeN = "minimize" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
270 |
val messagesN = "messages" |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
271 |
val available_proversN = "available_provers" |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
272 |
val running_proversN = "running_provers" |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
273 |
val kill_proversN = "kill_provers" |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
274 |
val refresh_tptpN = "refresh_tptp" |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
275 |
|
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
276 |
val is_raw_param_relevant_for_minimize = |
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
277 |
member (op =) params_for_minimize o fst o unalias_raw_param |
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
278 |
fun string_for_raw_param (key, values) = |
36481
af99c98121d6
make Sledgehammer more friendly if no subgoal is left
blanchet
parents:
36473
diff
changeset
|
279 |
key ^ (case space_implode " " values of "" => "" | value => " = " ^ value) |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
280 |
|
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
281 |
fun minimize_command override_params i prover_name fact_names = |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
282 |
sledgehammerN ^ " " ^ minimizeN ^ " [prover = " ^ prover_name ^ |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
283 |
(override_params |> filter is_raw_param_relevant_for_minimize |
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
284 |
|> implode o map (prefix ", " o string_for_raw_param)) ^ |
37171
fc1e20373e6a
make sure chained facts appear in Isar proofs generated by Sledgehammer -- otherwise the proof won't work
blanchet
parents:
36960
diff
changeset
|
285 |
"] (" ^ space_implode " " fact_names ^ ")" ^ |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
286 |
(if i = 1 then "" else " " ^ string_of_int i) |
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
287 |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
288 |
fun hammer_away override_params subcommand opt_i relevance_override state = |
35963 | 289 |
let |
40069 | 290 |
val ctxt = Proof.context_of state |
41258
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
291 |
val override_params = |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
292 |
override_params |> map (check_and_repair_raw_param ctxt) |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
293 |
in |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
294 |
if subcommand = runN then |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
295 |
let val i = the_default 1 opt_i in |
40069 | 296 |
run_sledgehammer (get_params false ctxt override_params) false i |
39318 | 297 |
relevance_override (minimize_command override_params i) |
298 |
state |
|
299 |
|> K () |
|
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
300 |
end |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
301 |
else if subcommand = minimizeN then |
40069 | 302 |
run_minimize (get_params false ctxt override_params) (the_default 1 opt_i) |
38590
bd443b426d56
get rid of "minimize_timeout", now that there's an automatic adaptive timeout mechanism in "minimize"
blanchet
parents:
38589
diff
changeset
|
303 |
(#add relevance_override) state |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
304 |
else if subcommand = messagesN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
305 |
messages opt_i |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
306 |
else if subcommand = available_proversN then |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40931
diff
changeset
|
307 |
available_provers ctxt |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
308 |
else if subcommand = running_proversN then |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
309 |
running_provers () |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
310 |
else if subcommand = kill_proversN then |
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39335
diff
changeset
|
311 |
kill_provers () |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
312 |
else if subcommand = refresh_tptpN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
313 |
refresh_systems_on_tptp () |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
314 |
else |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
315 |
error ("Unknown subcommand: " ^ quote subcommand ^ ".") |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
316 |
end |
35963 | 317 |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
318 |
fun sledgehammer_trans (((subcommand, params), relevance_override), opt_i) = |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
319 |
Toplevel.keep (hammer_away params subcommand opt_i relevance_override |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
320 |
o Toplevel.proof_of) |
35963 | 321 |
|
322 |
fun string_for_raw_param (name, value) = name ^ " = " ^ space_implode " " value |
|
323 |
||
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
324 |
fun sledgehammer_params_trans params = |
35963 | 325 |
Toplevel.theory |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
326 |
(fold set_default_raw_param params |
39318 | 327 |
#> tap (fn thy => |
40069 | 328 |
let val ctxt = ProofContext.init_global thy in |
329 |
writeln ("Default parameters for Sledgehammer:\n" ^ |
|
330 |
(case default_raw_params ctxt |> rev of |
|
331 |
[] => "none" |
|
332 |
| params => |
|
41258
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
333 |
params |> map (check_and_repair_raw_param ctxt) |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
334 |
|> map string_for_raw_param |
73401632a80c
convenient syntax for setting provers -- useful for debugging, not for general consumption and hence not documented
blanchet
parents:
41208
diff
changeset
|
335 |
|> sort_strings |> cat_lines)) |
40069 | 336 |
end)) |
35963 | 337 |
|
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
338 |
val parse_key = Scan.repeat1 Parse.typ_group >> space_implode " " |
40341
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
blanchet
parents:
40181
diff
changeset
|
339 |
val parse_value = Scan.repeat1 (Parse.xname || Parse.float_number) |
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
340 |
val parse_param = parse_key -- Scan.optional (Parse.$$$ "=" |-- parse_value) [] |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
341 |
val parse_params = Scan.optional (Args.bracks (Parse.list parse_param)) [] |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
342 |
val parse_fact_refs = |
38996 | 343 |
Scan.repeat1 (Scan.unless (Parse.name -- Args.colon) Parse_Spec.xthm) |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
344 |
val parse_relevance_chunk = |
39318 | 345 |
(Args.add |-- Args.colon |-- parse_fact_refs >> add_relevance_override) |
346 |
|| (Args.del |-- Args.colon |-- parse_fact_refs >> del_relevance_override) |
|
36188 | 347 |
|| (parse_fact_refs >> only_relevance_override) |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
348 |
val parse_relevance_override = |
36188 | 349 |
Scan.optional (Args.parens (Scan.repeat parse_relevance_chunk |
350 |
>> merge_relevance_overrides)) |
|
39318 | 351 |
no_relevance_override |
35963 | 352 |
val parse_sledgehammer_command = |
37399
34f080a12063
proper polymorphic Skolemization of uncached facts + synchronization of caching and relevance filter
blanchet
parents:
37344
diff
changeset
|
353 |
(Scan.optional Parse.short_ident runN -- parse_params |
34f080a12063
proper polymorphic Skolemization of uncached facts + synchronization of caching and relevance filter
blanchet
parents:
37344
diff
changeset
|
354 |
-- parse_relevance_override -- Scan.option Parse.nat) #>> sledgehammer_trans |
35963 | 355 |
val parse_sledgehammer_params_command = |
356 |
parse_params #>> sledgehammer_params_trans |
|
357 |
||
358 |
val _ = |
|
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
359 |
Outer_Syntax.improper_command sledgehammerN |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
360 |
"search for first-order proof using automatic theorem provers" Keyword.diag |
36394
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
361 |
parse_sledgehammer_command |
35963 | 362 |
val _ = |
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
363 |
Outer_Syntax.command sledgehammer_paramsN |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
364 |
"set and display the default parameters for Sledgehammer" Keyword.thy_decl |
36394
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
365 |
parse_sledgehammer_params_command |
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
366 |
|
39318 | 367 |
fun auto_sledgehammer state = |
40931 | 368 |
let val ctxt = Proof.context_of state in |
369 |
run_sledgehammer (get_params true ctxt []) true 1 no_relevance_override |
|
370 |
(minimize_command [] 1) state |
|
371 |
end |
|
39318 | 372 |
|
40931 | 373 |
val setup = Auto_Tools.register_tool (auto, auto_sledgehammer) |
39318 | 374 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
375 |
end; |