author | blanchet |
Wed, 01 Sep 2010 16:46:11 +0200 | |
changeset 38996 | 6905ba37376c |
parent 38988 | 483879af0643 |
child 38997 | 78ac4468cf9d |
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 |
|
38021
e024504943d1
rename "ATP_Manager" ML module to "Sledgehammer";
blanchet
parents:
37926
diff
changeset
|
9 |
type params = Sledgehammer.params |
35963 | 10 |
|
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
11 |
val atps: string Unsynchronized.ref |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
12 |
val timeout: int Unsynchronized.ref |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
13 |
val full_types: bool Unsynchronized.ref |
35963 | 14 |
val default_params : theory -> (string * string) list -> params |
15 |
end; |
|
16 |
||
35971 | 17 |
structure Sledgehammer_Isar : SLEDGEHAMMER_ISAR = |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
18 |
struct |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
19 |
|
38028 | 20 |
open ATP_Systems |
35971 | 21 |
open Sledgehammer_Util |
38021
e024504943d1
rename "ATP_Manager" ML module to "Sledgehammer";
blanchet
parents:
37926
diff
changeset
|
22 |
open Sledgehammer |
38988 | 23 |
open Sledgehammer_Minimize |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
24 |
|
36394
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
25 |
(** Sledgehammer commands **) |
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
26 |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
27 |
fun add_to_relevance_override ns : relevance_override = |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
28 |
{add = ns, del = [], only = false} |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
29 |
fun del_from_relevance_override ns : relevance_override = |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
30 |
{add = [], del = ns, only = false} |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
31 |
fun only_relevance_override ns : relevance_override = |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
32 |
{add = ns, del = [], only = true} |
36003 | 33 |
fun merge_relevance_override_pairwise (r1 : relevance_override) |
34 |
(r2 : relevance_override) = |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
35 |
{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
|
36 |
only = #only r1 andalso #only r2} |
36188 | 37 |
fun merge_relevance_overrides rs = |
38 |
fold merge_relevance_override_pairwise rs (only_relevance_override []) |
|
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
39 |
|
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
40 |
(*** parameters ***) |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
41 |
|
36908
fb18db78be80
delect installed ATPs dynamically, _not_ at image built time
blanchet
parents:
36607
diff
changeset
|
42 |
val atps = Unsynchronized.ref "" |
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
43 |
val timeout = Unsynchronized.ref 60 |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
44 |
val full_types = Unsynchronized.ref false |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
45 |
|
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
46 |
val _ = |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
47 |
ProofGeneralPgip.add_preference Preferences.category_proof |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
48 |
(Preferences.string_pref atps |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
49 |
"Sledgehammer: ATPs" |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
50 |
"Default automatic provers (separated by whitespace)") |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
51 |
|
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
52 |
val _ = |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
53 |
ProofGeneralPgip.add_preference Preferences.category_proof |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
54 |
(Preferences.int_pref timeout |
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
55 |
"Sledgehammer: Time Limit" |
36371
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
56 |
"ATPs will be interrupted after this time (in seconds)") |
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 |
8c83ea1a7740
move the Sledgehammer menu options to "sledgehammer_isar.ML"
blanchet
parents:
36290
diff
changeset
|
60 |
(Preferences.bool_pref full_types |
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
61 |
"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
|
62 |
|
35963 | 63 |
type raw_param = string * string list |
64 |
||
65 |
val default_default_params = |
|
38982
820b8221ed48
added "blocking" option to Sledgehammer to run in synchronous mode;
blanchet
parents:
38939
diff
changeset
|
66 |
[("blocking", "false"), |
820b8221ed48
added "blocking" option to Sledgehammer to run in synchronous mode;
blanchet
parents:
38939
diff
changeset
|
67 |
("debug", "false"), |
35963 | 68 |
("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
|
69 |
("overlord", "false"), |
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
|
70 |
("explicit_apply", "false"), |
38939 | 71 |
("relevance_thresholds", "45 85"), |
38744
2b6333f78a9e
make relevance filter work in term of a "max_relevant" option + use Vampire SOS;
blanchet
parents:
38741
diff
changeset
|
72 |
("max_relevant", "smart"), |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36189
diff
changeset
|
73 |
("theory_relevant", "smart"), |
35963 | 74 |
("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
|
75 |
("isar_shrink_factor", "1")] |
35963 | 76 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
77 |
val alias_params = |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
78 |
[("atp", "atps")] |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
79 |
val negated_alias_params = |
38982
820b8221ed48
added "blocking" option to Sledgehammer to run in synchronous mode;
blanchet
parents:
38939
diff
changeset
|
80 |
[("non_blocking", "blocking"), |
820b8221ed48
added "blocking" option to Sledgehammer to run in synchronous mode;
blanchet
parents:
38939
diff
changeset
|
81 |
("no_debug", "debug"), |
35963 | 82 |
("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
|
83 |
("no_overlord", "overlord"), |
36399 | 84 |
("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
|
85 |
("implicit_apply", "explicit_apply"), |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36189
diff
changeset
|
86 |
("theory_irrelevant", "theory_relevant"), |
36908
fb18db78be80
delect installed ATPs dynamically, _not_ at image built time
blanchet
parents:
36607
diff
changeset
|
87 |
("no_isar_proof", "isar_proof")] |
35963 | 88 |
|
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
89 |
val params_for_minimize = |
38100
e458a0dd3dc1
use "explicit_apply" in the minimizer whenever it might make a difference to prevent freak failures;
blanchet
parents:
38045
diff
changeset
|
90 |
["debug", "verbose", "overlord", "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
|
91 |
"isar_shrink_factor", "timeout"] |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
92 |
|
35971 | 93 |
val property_dependent_params = ["atps", "full_types", "timeout"] |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
94 |
|
35963 | 95 |
fun is_known_raw_param s = |
96 |
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
|
97 |
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
|
98 |
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
|
99 |
member (op =) property_dependent_params s orelse s = "expect" |
35963 | 100 |
|
101 |
fun check_raw_param (s, _) = |
|
102 |
if is_known_raw_param s then () |
|
103 |
else error ("Unknown parameter: " ^ quote s ^ ".") |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
104 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
SOME name' => (name', value) |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
108 |
| NONE => |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
109 |
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
|
110 |
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
|
111 |
["false"] => ["true"] |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
112 |
| ["true"] => ["false"] |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
113 |
| [] => ["false"] |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
114 |
| _ => value) |
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
115 |
| NONE => (name, value) |
35963 | 116 |
|
117 |
structure Data = Theory_Data( |
|
118 |
type T = raw_param list |
|
119 |
val empty = default_default_params |> map (apsnd single) |
|
120 |
val extend = I |
|
121 |
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
|
122 |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
123 |
val set_default_raw_param = Data.map o AList.update (op =) o unalias_raw_param |
35963 | 124 |
fun default_raw_params thy = |
125 |
Data.get thy |
|
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
126 |
|> fold (AList.default (op =)) |
36908
fb18db78be80
delect installed ATPs dynamically, _not_ at image built time
blanchet
parents:
36607
diff
changeset
|
127 |
[("atps", [case !atps of "" => default_atps_param_value () | s => s]), |
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
128 |
("full_types", [if !full_types then "true" else "false"]), |
36142
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36141
diff
changeset
|
129 |
("timeout", let val timeout = !timeout in |
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36141
diff
changeset
|
130 |
[if timeout <= 0 then "none" |
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36141
diff
changeset
|
131 |
else string_of_int timeout ^ " s"] |
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36141
diff
changeset
|
132 |
end)] |
35963 | 133 |
|
134 |
val infinity_time_in_secs = 60 * 60 * 24 * 365 |
|
135 |
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
|
136 |
|
37498
b426cbdb5a23
removed Sledgehammer's support for the DFG syntax;
blanchet
parents:
37399
diff
changeset
|
137 |
fun extract_params default_params override_params = |
35963 | 138 |
let |
36140
08b2a7ecb6c3
fixed handling of "sledgehammer_params" that get a default value from Isabelle menu;
blanchet
parents:
36064
diff
changeset
|
139 |
val override_params = map unalias_raw_param override_params |
35963 | 140 |
val raw_params = rev override_params @ rev default_params |
141 |
val lookup = Option.map (space_implode " ") o AList.lookup (op =) raw_params |
|
142 |
val lookup_string = the_default "" o lookup |
|
143 |
fun general_lookup_bool option default_value name = |
|
144 |
case lookup name of |
|
35970
3d41a2a490f0
revert debugging output that shouldn't have been submitted in the first place
blanchet
parents:
35966
diff
changeset
|
145 |
SOME s => parse_bool_option option name s |
35963 | 146 |
| NONE => default_value |
147 |
val lookup_bool = the o general_lookup_bool false (SOME false) |
|
148 |
val lookup_bool_option = general_lookup_bool true NONE |
|
149 |
fun lookup_time name = |
|
150 |
the_timeout (case lookup name of |
|
151 |
NONE => NONE |
|
152 |
| SOME s => parse_time_option name s) |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
153 |
fun lookup_int name = |
35963 | 154 |
case lookup name of |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
155 |
NONE => 0 |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
156 |
| SOME s => case Int.fromString s of |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
157 |
SOME n => n |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
158 |
| NONE => error ("Parameter " ^ quote name ^ |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
159 |
" must be assigned an integer value.") |
38745
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
160 |
fun lookup_int_pair name = |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
161 |
case lookup name of |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
162 |
NONE => (0, 0) |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
163 |
| SOME s => case s |> space_explode " " |> map Int.fromString of |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
164 |
[SOME n1, SOME n2] => (n1, n2) |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
165 |
| _ => error ("Parameter " ^ quote name ^ |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
166 |
"must be assigned a pair of integer values \ |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
167 |
\(e.g., \"60 95\")") |
38589
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
168 |
fun lookup_int_option name = |
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
169 |
case lookup name of |
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
170 |
SOME "smart" => NONE |
b03f8fe043ec
added "max_relevant_per_iter" option to Sledgehammer
blanchet
parents:
38282
diff
changeset
|
171 |
| _ => SOME (lookup_int name) |
38982
820b8221ed48
added "blocking" option to Sledgehammer to run in synchronous mode;
blanchet
parents:
38939
diff
changeset
|
172 |
val blocking = lookup_bool "blocking" |
35963 | 173 |
val debug = lookup_bool "debug" |
174 |
val verbose = debug orelse 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
|
175 |
val overlord = lookup_bool "overlord" |
35963 | 176 |
val atps = lookup_string "atps" |> space_explode " " |
177 |
val full_types = lookup_bool "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
|
178 |
val explicit_apply = lookup_bool "explicit_apply" |
38745
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
179 |
val relevance_thresholds = |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
180 |
lookup_int_pair "relevance_thresholds" |
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
181 |
|> pairself (fn n => 0.01 * Real.fromInt n) |
38744
2b6333f78a9e
make relevance filter work in term of a "max_relevant" option + use Vampire SOS;
blanchet
parents:
38741
diff
changeset
|
182 |
val max_relevant = lookup_int_option "max_relevant" |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36189
diff
changeset
|
183 |
val theory_relevant = lookup_bool_option "theory_relevant" |
35963 | 184 |
val isar_proof = lookup_bool "isar_proof" |
36924 | 185 |
val isar_shrink_factor = Int.max (1, lookup_int "isar_shrink_factor") |
35963 | 186 |
val timeout = lookup_time "timeout" |
38985
162bbbea4e4d
added "expect" feature of Nitpick to Sledgehammer, for regression testing
blanchet
parents:
38982
diff
changeset
|
187 |
val expect = lookup_string "expect" |
35963 | 188 |
in |
38982
820b8221ed48
added "blocking" option to Sledgehammer to run in synchronous mode;
blanchet
parents:
38939
diff
changeset
|
189 |
{blocking = blocking, debug = debug, verbose = verbose, overlord = overlord, |
820b8221ed48
added "blocking" option to Sledgehammer to run in synchronous mode;
blanchet
parents:
38939
diff
changeset
|
190 |
atps = atps, full_types = full_types, explicit_apply = explicit_apply, |
38745
ad577fd62ee4
reorganize options regarding to the relevance threshold and decay
blanchet
parents:
38744
diff
changeset
|
191 |
relevance_thresholds = relevance_thresholds, max_relevant = max_relevant, |
38741 | 192 |
theory_relevant = theory_relevant, isar_proof = isar_proof, |
38985
162bbbea4e4d
added "expect" feature of Nitpick to Sledgehammer, for regression testing
blanchet
parents:
38982
diff
changeset
|
193 |
isar_shrink_factor = isar_shrink_factor, timeout = timeout, |
162bbbea4e4d
added "expect" feature of Nitpick to Sledgehammer, for regression testing
blanchet
parents:
38982
diff
changeset
|
194 |
expect = expect} |
35963 | 195 |
end |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
196 |
|
37498
b426cbdb5a23
removed Sledgehammer's support for the DFG syntax;
blanchet
parents:
37399
diff
changeset
|
197 |
fun get_params thy = extract_params (default_raw_params thy) |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
198 |
fun default_params thy = get_params thy o map (apsnd single) |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
199 |
|
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
200 |
(* Sledgehammer the given subgoal *) |
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
201 |
|
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
202 |
val sledgehammerN = "sledgehammer" |
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
203 |
val sledgehammer_paramsN = "sledgehammer_params" |
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
204 |
|
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
205 |
val runN = "run" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
206 |
val minimizeN = "minimize" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
207 |
val messagesN = "messages" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
208 |
val available_atpsN = "available_atps" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
209 |
val running_atpsN = "running_atps" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
210 |
val kill_atpsN = "kill_atps" |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
211 |
val refresh_tptpN = "refresh_tptp" |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
212 |
|
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
213 |
val is_raw_param_relevant_for_minimize = |
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
214 |
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
|
215 |
fun string_for_raw_param (key, values) = |
36481
af99c98121d6
make Sledgehammer more friendly if no subgoal is left
blanchet
parents:
36473
diff
changeset
|
216 |
key ^ (case space_implode " " values of "" => "" | value => " = " ^ value) |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
217 |
|
37171
fc1e20373e6a
make sure chained facts appear in Isar proofs generated by Sledgehammer -- otherwise the proof won't work
blanchet
parents:
36960
diff
changeset
|
218 |
fun minimize_command override_params i atp_name fact_names = |
36373
66af0a49de39
move some sledgehammer stuff out of "atp_manager.ML"
blanchet
parents:
36371
diff
changeset
|
219 |
sledgehammerN ^ " " ^ minimizeN ^ " [atp = " ^ atp_name ^ |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
220 |
(override_params |> filter is_raw_param_relevant_for_minimize |
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
221 |
|> 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
|
222 |
"] (" ^ space_implode " " fact_names ^ ")" ^ |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
223 |
(if i = 1 then "" else " " ^ string_of_int i) |
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
224 |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
225 |
fun hammer_away override_params subcommand opt_i relevance_override state = |
35963 | 226 |
let |
227 |
val thy = Proof.theory_of state |
|
36481
af99c98121d6
make Sledgehammer more friendly if no subgoal is left
blanchet
parents:
36473
diff
changeset
|
228 |
val _ = app check_raw_param override_params |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
229 |
in |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
230 |
if subcommand = runN then |
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
231 |
let val i = the_default 1 opt_i in |
38044 | 232 |
run_sledgehammer (get_params thy override_params) i relevance_override |
233 |
(minimize_command override_params i) state |
|
36281
dbbf4d5d584d
pass relevant options from "sledgehammer" to "sledgehammer minimize";
blanchet
parents:
36235
diff
changeset
|
234 |
end |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
235 |
else if subcommand = minimizeN then |
38590
bd443b426d56
get rid of "minimize_timeout", now that there's an automatic adaptive timeout mechanism in "minimize"
blanchet
parents:
38589
diff
changeset
|
236 |
run_minimize (get_params thy override_params) (the_default 1 opt_i) |
bd443b426d56
get rid of "minimize_timeout", now that there's an automatic adaptive timeout mechanism in "minimize"
blanchet
parents:
38589
diff
changeset
|
237 |
(#add relevance_override) state |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
238 |
else if subcommand = messagesN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
239 |
messages opt_i |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
240 |
else if subcommand = available_atpsN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
241 |
available_atps thy |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
242 |
else if subcommand = running_atpsN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
243 |
running_atps () |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
244 |
else if subcommand = kill_atpsN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
245 |
kill_atps () |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
246 |
else if subcommand = refresh_tptpN then |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
247 |
refresh_systems_on_tptp () |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
248 |
else |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
249 |
error ("Unknown subcommand: " ^ quote subcommand ^ ".") |
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
250 |
end |
35963 | 251 |
|
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
252 |
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
|
253 |
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
|
254 |
o Toplevel.proof_of) |
35963 | 255 |
|
256 |
fun string_for_raw_param (name, value) = name ^ " = " ^ space_implode " " value |
|
257 |
||
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
258 |
fun sledgehammer_params_trans params = |
35963 | 259 |
Toplevel.theory |
35965
0fce6db7babd
added a syntax for specifying facts to Sledgehammer;
blanchet
parents:
35963
diff
changeset
|
260 |
(fold set_default_raw_param params |
35963 | 261 |
#> tap (fn thy => |
262 |
writeln ("Default parameters for Sledgehammer:\n" ^ |
|
263 |
(case rev (default_raw_params thy) of |
|
264 |
[] => "none" |
|
265 |
| params => |
|
266 |
(map check_raw_param params; |
|
267 |
params |> map string_for_raw_param |
|
268 |
|> sort_strings |> cat_lines))))) |
|
269 |
||
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
270 |
val parse_key = Scan.repeat1 Parse.typ_group >> space_implode " " |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
271 |
val parse_value = Scan.repeat1 Parse.xname |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
272 |
val parse_param = parse_key -- Scan.optional (Parse.$$$ "=" |-- parse_value) [] |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
273 |
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
|
274 |
val parse_fact_refs = |
38996 | 275 |
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
|
276 |
val parse_relevance_chunk = |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
277 |
(Args.add |-- Args.colon |-- parse_fact_refs >> add_to_relevance_override) |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
278 |
|| (Args.del |-- Args.colon |-- parse_fact_refs |
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
279 |
>> del_from_relevance_override) |
36188 | 280 |
|| (parse_fact_refs >> only_relevance_override) |
35966
f8c738abaed8
honor the newly introduced Sledgehammer parameters and fixed the parsing;
blanchet
parents:
35965
diff
changeset
|
281 |
val parse_relevance_override = |
36188 | 282 |
Scan.optional (Args.parens (Scan.repeat parse_relevance_chunk |
283 |
>> merge_relevance_overrides)) |
|
284 |
(add_to_relevance_override []) |
|
35963 | 285 |
val parse_sledgehammer_command = |
37399
34f080a12063
proper polymorphic Skolemization of uncached facts + synchronization of caching and relevance filter
blanchet
parents:
37344
diff
changeset
|
286 |
(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
|
287 |
-- parse_relevance_override -- Scan.option Parse.nat) #>> sledgehammer_trans |
35963 | 288 |
val parse_sledgehammer_params_command = |
289 |
parse_params #>> sledgehammer_params_trans |
|
290 |
||
291 |
val _ = |
|
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
292 |
Outer_Syntax.improper_command sledgehammerN |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
293 |
"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
|
294 |
parse_sledgehammer_command |
35963 | 295 |
val _ = |
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
296 |
Outer_Syntax.command sledgehammer_paramsN |
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36924
diff
changeset
|
297 |
"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
|
298 |
parse_sledgehammer_params_command |
1a48d18449d8
move "neg_clausify" method and "clausify" attribute to "sledgehammer_isar.ML"
blanchet
parents:
36378
diff
changeset
|
299 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
diff
changeset
|
300 |
end; |