author | blanchet |
Mon, 19 Apr 2010 18:44:12 +0200 | |
changeset 36231 | bede2d49ba3b |
parent 36223 | 217ca1273786 |
child 36235 | 61159615a0c5 |
permissions | -rw-r--r-- |
32327
0971cc0b6a57
src/HOL/Tools/ATP_Manager as separate component, with (almost) everything in one place;
wenzelm
parents:
32257
diff
changeset
|
1 |
(* Title: HOL/Tools/ATP_Manager/atp_wrapper.ML |
28592 | 2 |
Author: Fabian Immler, TU Muenchen |
3 |
||
4 |
Wrapper functions for external ATPs. |
|
5 |
*) |
|
6 |
||
7 |
signature ATP_WRAPPER = |
|
8 |
sig |
|
35867 | 9 |
type prover = ATP_Manager.prover |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
10 |
|
35867 | 11 |
(* hooks for problem files *) |
12 |
val destdir : string Config.T |
|
13 |
val problem_prefix : string Config.T |
|
14 |
val measure_runtime : bool Config.T |
|
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
15 |
|
35867 | 16 |
val refresh_systems_on_tptp : unit -> unit |
17 |
val setup : theory -> theory |
|
28592 | 18 |
end; |
19 |
||
35865 | 20 |
structure ATP_Wrapper : ATP_WRAPPER = |
28592 | 21 |
struct |
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
22 |
|
36187 | 23 |
open Sledgehammer_Util |
35969 | 24 |
open Sledgehammer_Fact_Preprocessor |
35865 | 25 |
open Sledgehammer_HOL_Clause |
26 |
open Sledgehammer_Fact_Filter |
|
27 |
open Sledgehammer_Proof_Reconstruct |
|
35867 | 28 |
open ATP_Manager |
35826 | 29 |
|
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
30 |
(** generic ATP wrapper **) |
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
31 |
|
32944
ecc0705174c2
clarified File.platform_path vs. File.shell_path;
wenzelm
parents:
32942
diff
changeset
|
32 |
(* external problem files *) |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
33 |
|
36001 | 34 |
val (destdir, destdir_setup) = Attrib.config_string "atp_destdir" (K ""); |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
35 |
(*Empty string means create files in Isabelle's temporary files directory.*) |
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
36 |
|
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
37 |
val (problem_prefix, problem_prefix_setup) = |
36001 | 38 |
Attrib.config_string "atp_problem_prefix" (K "prob"); |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
39 |
|
33247 | 40 |
val (measure_runtime, measure_runtime_setup) = |
36001 | 41 |
Attrib.config_bool "atp_measure_runtime" (K false); |
33247 | 42 |
|
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
43 |
|
35867 | 44 |
(* prover configuration *) |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
45 |
|
32941
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32936
diff
changeset
|
46 |
type prover_config = |
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32936
diff
changeset
|
47 |
{command: Path.T, |
35969 | 48 |
arguments: Time.time -> string, |
35865 | 49 |
failure_strs: string list, |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
50 |
max_new_clauses: int, |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
51 |
prefers_theory_relevant: bool, |
35969 | 52 |
supports_isar_proofs: bool}; |
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
53 |
|
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
54 |
|
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
55 |
(* basic template *) |
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
56 |
|
32458
de6834b20e9e
sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents:
32451
diff
changeset
|
57 |
fun with_path cleanup after f path = |
de6834b20e9e
sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents:
32451
diff
changeset
|
58 |
Exn.capture f path |
de6834b20e9e
sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents:
32451
diff
changeset
|
59 |
|> tap (fn _ => cleanup path) |
de6834b20e9e
sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents:
32451
diff
changeset
|
60 |
|> Exn.release |
32941
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32936
diff
changeset
|
61 |
|> tap (after path); |
32458
de6834b20e9e
sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents:
32451
diff
changeset
|
62 |
|
35865 | 63 |
fun find_failure strs proof = |
64 |
case filter (fn s => String.isSubstring s proof) strs of |
|
65 |
[] => if is_proof_well_formed proof then NONE |
|
66 |
else SOME "Ill-formed ATP output" |
|
67 |
| (failure :: _) => SOME failure |
|
68 |
||
36169
27b1cc58715e
store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents:
36167
diff
changeset
|
69 |
fun generic_prover overlord get_facts prepare write_file cmd args failure_strs |
36223
217ca1273786
make Sledgehammer's minimizer also minimize Isar proofs
blanchet
parents:
36222
diff
changeset
|
70 |
proof_text name ({debug, full_types, ...} : params) |
35969 | 71 |
({subgoal, goal, relevance_override, axiom_clauses, filtered_clauses} |
72 |
: problem) = |
|
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
73 |
let |
31750 | 74 |
(* get clauses and prepare them for writing *) |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
75 |
val (ctxt, (chain_ths, th)) = goal; |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
76 |
val thy = ProofContext.theory_of ctxt; |
35865 | 77 |
val chain_ths = map (Thm.put_name_hint chained_hint) chain_ths; |
35969 | 78 |
val goal_cls = #1 (neg_conjecture_clauses ctxt th subgoal); |
31752
19a5f1c8a844
use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents:
31751
diff
changeset
|
79 |
val the_filtered_clauses = |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
80 |
(case filtered_clauses of |
35969 | 81 |
NONE => get_facts relevance_override goal goal_cls |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
82 |
| SOME fcls => fcls); |
31409
d8537ba165b5
split preparing clauses and writing problemfile;
immler@in.tum.de
parents:
31368
diff
changeset
|
83 |
val the_axiom_clauses = |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
84 |
(case axiom_clauses of |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
85 |
NONE => the_filtered_clauses |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
86 |
| SOME axcls => axcls); |
35969 | 87 |
val (internal_thm_names, clauses) = |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
88 |
prepare goal_cls chain_ths the_axiom_clauses the_filtered_clauses thy; |
31750 | 89 |
|
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
90 |
(* path to unique problem file *) |
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
|
91 |
val destdir' = if overlord then getenv "ISABELLE_HOME_USER" |
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
|
92 |
else Config.get ctxt destdir; |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
93 |
val problem_prefix' = Config.get ctxt problem_prefix; |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
94 |
fun prob_pathname nr = |
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
|
95 |
let |
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 |
val probfile = |
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
|
97 |
Path.basic (problem_prefix' ^ |
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
|
98 |
(if overlord then "_" ^ name else serial_string ()) |
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
|
99 |
^ "_" ^ string_of_int nr) |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
100 |
in |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
101 |
if destdir' = "" then File.tmp_path probfile |
35570
0e30eef52d85
basic simplification of external_prover signature;
wenzelm
parents:
35010
diff
changeset
|
102 |
else if File.exists (Path.explode destdir') |
0e30eef52d85
basic simplification of external_prover signature;
wenzelm
parents:
35010
diff
changeset
|
103 |
then Path.append (Path.explode destdir') probfile |
36169
27b1cc58715e
store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents:
36167
diff
changeset
|
104 |
else error ("No such directory: " ^ destdir' ^ ".") |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
105 |
end; |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
106 |
|
31750 | 107 |
(* write out problem file and call prover *) |
33247 | 108 |
fun cmd_line probfile = |
109 |
if Config.get ctxt measure_runtime |
|
110 |
then (* Warning: suppresses error messages of ATPs *) |
|
111 |
"TIMEFORMAT='%3U'; { time " ^ space_implode " " [File.shell_path cmd, |
|
112 |
args, File.shell_path probfile] ^ " 2> /dev/null" ^ " ; } 2>&1" |
|
113 |
else |
|
114 |
space_implode " " ["exec", File.shell_path cmd, args, |
|
115 |
File.shell_path probfile]; |
|
32510 | 116 |
fun split_time s = |
117 |
let |
|
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
118 |
val split = String.tokens (fn c => str c = "\n"); |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
119 |
val (proof, t) = s |> split |> split_last |> apfst cat_lines; |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
120 |
fun as_num f = f >> (fst o read_int); |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
121 |
val num = as_num (Scan.many1 Symbol.is_ascii_digit); |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
122 |
val digit = Scan.one Symbol.is_ascii_digit; |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
123 |
val num3 = as_num (digit ::: digit ::: (digit >> single)); |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
124 |
val time = num --| Scan.$$ "." -- num3 >> (fn (a, b) => a * 1000 + b); |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
125 |
val as_time = the_default 0 o Scan.read Symbol.stopper time o explode; |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
126 |
in (proof, as_time t) end; |
33247 | 127 |
fun split_time' s = |
128 |
if Config.get ctxt measure_runtime then split_time s else (s, 0) |
|
32458
de6834b20e9e
sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents:
32451
diff
changeset
|
129 |
fun run_on probfile = |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
130 |
if File.exists cmd then |
36222
0e3e49bd658d
don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents:
36220
diff
changeset
|
131 |
write_file full_types probfile clauses |
35010
d6e492cea6e4
renamed system/system_out to bash/bash_output -- to emphasized that this is really GNU bash, not some undefined POSIX sh;
wenzelm
parents:
33316
diff
changeset
|
132 |
|> pair (apfst split_time' (bash_output (cmd_line probfile))) |
36167
c1a35be8e476
make Sledgehammer's output more debugging friendly
blanchet
parents:
36143
diff
changeset
|
133 |
else error ("Bad executable: " ^ Path.implode cmd ^ "."); |
28592 | 134 |
|
36167
c1a35be8e476
make Sledgehammer's output more debugging friendly
blanchet
parents:
36143
diff
changeset
|
135 |
(* If the problem file has not been exported, remove it; otherwise, export |
c1a35be8e476
make Sledgehammer's output more debugging friendly
blanchet
parents:
36143
diff
changeset
|
136 |
the proof file too. *) |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
137 |
fun cleanup probfile = if destdir' = "" then try File.rm probfile else NONE; |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
138 |
fun export probfile (((proof, _), _), _) = |
36187 | 139 |
if destdir' = "" then |
140 |
() |
|
141 |
else |
|
142 |
File.write (Path.explode (Path.implode probfile ^ "_proof")) |
|
36190 | 143 |
("% " ^ timestamp () ^ "\n" ^ proof) |
32257
bad5a99c16d8
neg_conjecture_clauses, neg_clausify_tac: proper context, eliminated METAHYPS;
wenzelm
parents:
32091
diff
changeset
|
144 |
|
36231
bede2d49ba3b
get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents:
36223
diff
changeset
|
145 |
val (((proof, atp_run_time_in_msecs), rc), _) = |
35570
0e30eef52d85
basic simplification of external_prover signature;
wenzelm
parents:
35010
diff
changeset
|
146 |
with_path cleanup export run_on (prob_pathname subgoal); |
32458
de6834b20e9e
sledgehammer's temporary files are removed properly (even in case of an exception occurs)
boehmes
parents:
32451
diff
changeset
|
147 |
|
36167
c1a35be8e476
make Sledgehammer's output more debugging friendly
blanchet
parents:
36143
diff
changeset
|
148 |
(* Check for success and print out some information on failure. *) |
35865 | 149 |
val failure = find_failure failure_strs proof; |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
150 |
val success = rc = 0 andalso is_none failure; |
35969 | 151 |
val (message, relevant_thm_names) = |
36231
bede2d49ba3b
get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents:
36223
diff
changeset
|
152 |
if is_some failure then ("ATP failed to find a proof.\n", []) |
bede2d49ba3b
get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents:
36223
diff
changeset
|
153 |
else if rc <> 0 then ("ATP error: " ^ proof ^ ".\n", []) |
bede2d49ba3b
get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents:
36223
diff
changeset
|
154 |
else proof_text name proof internal_thm_names ctxt th subgoal |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
155 |
in |
36231
bede2d49ba3b
get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents:
36223
diff
changeset
|
156 |
{success = success, message = message, |
35969 | 157 |
relevant_thm_names = relevant_thm_names, |
158 |
atp_run_time_in_msecs = atp_run_time_in_msecs, proof = proof, |
|
159 |
internal_thm_names = internal_thm_names, |
|
160 |
filtered_clauses = the_filtered_clauses} |
|
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
161 |
end; |
28592 | 162 |
|
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
163 |
|
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
164 |
(* generic TPTP-based provers *) |
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
165 |
|
35865 | 166 |
fun generic_tptp_prover |
167 |
(name, {command, arguments, failure_strs, max_new_clauses, |
|
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
168 |
prefers_theory_relevant, supports_isar_proofs}) |
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
|
169 |
(params as {overlord, respect_no_atp, relevance_threshold, convergence, |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
170 |
theory_relevant, higher_order, follow_defs, isar_proof, |
36064
48aec67c284f
added "modulus" and "sorts" options to control Sledgehammer's Isar proof output
blanchet
parents:
36059
diff
changeset
|
171 |
modulus, sorts, ...}) |
36059 | 172 |
timeout = |
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
|
173 |
generic_prover overlord |
36058
8256d5a185bd
added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents:
36001
diff
changeset
|
174 |
(get_relevant_facts respect_no_atp relevance_threshold convergence |
8256d5a185bd
added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents:
36001
diff
changeset
|
175 |
higher_order follow_defs max_new_clauses |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
176 |
(the_default prefers_theory_relevant theory_relevant)) |
36222
0e3e49bd658d
don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents:
36220
diff
changeset
|
177 |
(prepare_clauses higher_order false) |
0e3e49bd658d
don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents:
36220
diff
changeset
|
178 |
(write_tptp_file (overlord andalso not isar_proof)) command |
35969 | 179 |
(arguments timeout) failure_strs |
36223
217ca1273786
make Sledgehammer's minimizer also minimize Isar proofs
blanchet
parents:
36222
diff
changeset
|
180 |
(proof_text (supports_isar_proofs andalso isar_proof) false modulus sorts) |
217ca1273786
make Sledgehammer's minimizer also minimize Isar proofs
blanchet
parents:
36222
diff
changeset
|
181 |
name params |
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
182 |
|
35969 | 183 |
fun tptp_prover name p = (name, generic_tptp_prover (name, p)); |
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
184 |
|
32941
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32936
diff
changeset
|
185 |
|
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
186 |
(** common provers **) |
28592 | 187 |
|
36142
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36064
diff
changeset
|
188 |
fun generous_to_secs time = (Time.toMilliseconds time + 999) div 1000 |
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36064
diff
changeset
|
189 |
|
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
190 |
(* Vampire *) |
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
191 |
|
35969 | 192 |
(* NB: Vampire does not work without explicit time limit. *) |
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
193 |
|
35969 | 194 |
val vampire_config : prover_config = |
195 |
{command = Path.explode "$VAMPIRE_HOME/vampire", |
|
196 |
arguments = (fn timeout => "--output_syntax tptp --mode casc -t " ^ |
|
36142
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36064
diff
changeset
|
197 |
string_of_int (generous_to_secs timeout)), |
35969 | 198 |
failure_strs = |
199 |
["Satisfiability detected", "Refutation not found", "CANNOT PROVE"], |
|
200 |
max_new_clauses = 60, |
|
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
201 |
prefers_theory_relevant = false, |
35969 | 202 |
supports_isar_proofs = true} |
203 |
val vampire = tptp_prover "vampire" vampire_config |
|
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
204 |
|
28592 | 205 |
|
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
206 |
(* E prover *) |
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
207 |
|
35969 | 208 |
val e_config : prover_config = |
209 |
{command = Path.explode "$E_HOME/eproof", |
|
210 |
arguments = (fn timeout => "--tstp-in --tstp-out -l5 -xAutoDev \ |
|
211 |
\-tAutoDev --silent --cpu-limit=" ^ |
|
36142
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36064
diff
changeset
|
212 |
string_of_int (generous_to_secs timeout)), |
35969 | 213 |
failure_strs = |
214 |
["SZS status: Satisfiable", "SZS status Satisfiable", |
|
215 |
"SZS status: ResourceOut", "SZS status ResourceOut", |
|
216 |
"# Cannot determine problem status"], |
|
217 |
max_new_clauses = 100, |
|
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
218 |
prefers_theory_relevant = false, |
35969 | 219 |
supports_isar_proofs = true} |
220 |
val e = tptp_prover "e" e_config |
|
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
221 |
|
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
222 |
|
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
223 |
(* SPASS *) |
28592 | 224 |
|
35865 | 225 |
fun generic_dfg_prover |
226 |
(name, ({command, arguments, failure_strs, max_new_clauses, |
|
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
227 |
prefers_theory_relevant, ...} : prover_config)) |
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
|
228 |
(params as {overlord, respect_no_atp, relevance_threshold, convergence, |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
229 |
theory_relevant, higher_order, follow_defs, ...}) |
36059 | 230 |
timeout = |
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
|
231 |
generic_prover overlord |
36058
8256d5a185bd
added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents:
36001
diff
changeset
|
232 |
(get_relevant_facts respect_no_atp relevance_threshold convergence |
8256d5a185bd
added "respect_no_atp" and "convergence" options to Sledgehammer;
blanchet
parents:
36001
diff
changeset
|
233 |
higher_order follow_defs max_new_clauses |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
234 |
(the_default prefers_theory_relevant theory_relevant)) |
35969 | 235 |
(prepare_clauses higher_order true) write_dfg_file command |
36223
217ca1273786
make Sledgehammer's minimizer also minimize Isar proofs
blanchet
parents:
36222
diff
changeset
|
236 |
(arguments timeout) failure_strs (metis_proof_text false false) |
217ca1273786
make Sledgehammer's minimizer also minimize Isar proofs
blanchet
parents:
36222
diff
changeset
|
237 |
name params |
32869
159309603edc
recovered support for Spass: re-enabled writing problems in DFG format
boehmes
parents:
32864
diff
changeset
|
238 |
|
35865 | 239 |
fun dfg_prover (name, p) = (name, generic_dfg_prover (name, p)); |
32869
159309603edc
recovered support for Spass: re-enabled writing problems in DFG format
boehmes
parents:
32864
diff
changeset
|
240 |
|
36219
16670b4f0baa
set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents:
36190
diff
changeset
|
241 |
(* The "-VarWeight=3" option helps the higher-order problems, probably by |
16670b4f0baa
set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents:
36190
diff
changeset
|
242 |
counteracting the presence of "hAPP". *) |
36059 | 243 |
val spass_config : prover_config = |
35969 | 244 |
{command = Path.explode "$SPASS_HOME/SPASS", |
245 |
arguments = (fn timeout => "-Auto -SOS=1 -PGiven=0 -PProblem=0 -Splits=0" ^ |
|
36219
16670b4f0baa
set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents:
36190
diff
changeset
|
246 |
" -FullRed=0 -DocProof -VarWeight=3 -TimeLimit=" ^ |
36142
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36064
diff
changeset
|
247 |
string_of_int (generous_to_secs timeout)), |
35969 | 248 |
failure_strs = |
249 |
["SPASS beiseite: Completion found.", "SPASS beiseite: Ran out of time.", |
|
250 |
"SPASS beiseite: Maximal number of loops exceeded."], |
|
251 |
max_new_clauses = 40, |
|
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
252 |
prefers_theory_relevant = true, |
36059 | 253 |
supports_isar_proofs = false} |
35969 | 254 |
val spass = dfg_prover ("spass", spass_config) |
255 |
||
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
256 |
|
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
257 |
(* remote prover invocation via SystemOnTPTP *) |
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
258 |
|
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
259 |
val systems = Synchronized.var "atp_wrapper_systems" ([]: string list); |
31835 | 260 |
|
261 |
fun get_systems () = |
|
262 |
let |
|
35969 | 263 |
val (answer, rc) = bash_output "\"$ISABELLE_ATP_MANAGER/SystemOnTPTP\" -w" |
31835 | 264 |
in |
35969 | 265 |
if rc <> 0 then |
266 |
error ("Failed to get available systems at SystemOnTPTP:\n" ^ answer) |
|
267 |
else |
|
268 |
split_lines answer |
|
31835 | 269 |
end; |
270 |
||
35867 | 271 |
fun refresh_systems_on_tptp () = |
272 |
Synchronized.change systems (fn _ => get_systems ()); |
|
31835 | 273 |
|
274 |
fun get_system prefix = Synchronized.change_result systems (fn systems => |
|
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
275 |
(if null systems then get_systems () else systems) |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
276 |
|> `(find_first (String.isPrefix prefix))); |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
277 |
|
32948 | 278 |
fun the_system prefix = |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
279 |
(case get_system prefix of |
35826 | 280 |
NONE => error ("System " ^ quote prefix ^ " not available at SystemOnTPTP") |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
281 |
| SOME sys => sys); |
31835 | 282 |
|
35865 | 283 |
val remote_failure_strs = ["Remote-script could not extract proof"]; |
284 |
||
36059 | 285 |
fun remote_prover_config prover_prefix args |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
286 |
({failure_strs, max_new_clauses, prefers_theory_relevant, ...} |
36059 | 287 |
: prover_config) : prover_config = |
35969 | 288 |
{command = Path.explode "$ISABELLE_ATP_MANAGER/SystemOnTPTP", |
289 |
arguments = (fn timeout => |
|
36142
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36064
diff
changeset
|
290 |
args ^ " -t " ^ string_of_int (generous_to_secs timeout) ^ " -s " ^ |
35969 | 291 |
the_system prover_prefix), |
36059 | 292 |
failure_strs = remote_failure_strs @ failure_strs, |
35969 | 293 |
max_new_clauses = max_new_clauses, |
36220
f3655a3ae1ab
rename Sledgehammer "theory_const" option to "theory_relevant", now that I understand better what it does
blanchet
parents:
36219
diff
changeset
|
294 |
prefers_theory_relevant = prefers_theory_relevant, |
35969 | 295 |
supports_isar_proofs = false} |
28596
fcd463a6b6de
tuned interfaces -- plain prover function, without thread;
wenzelm
parents:
28592
diff
changeset
|
296 |
|
35969 | 297 |
val remote_vampire = |
298 |
tptp_prover "remote_vampire" |
|
36059 | 299 |
(remote_prover_config "Vampire---9" "" vampire_config) |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
300 |
|
35969 | 301 |
val remote_e = |
36059 | 302 |
tptp_prover "remote_e" (remote_prover_config "EP---" "" e_config) |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
303 |
|
35969 | 304 |
val remote_spass = |
36059 | 305 |
tptp_prover "remote_spass" (remote_prover_config "SPASS---" "-x" spass_config) |
28592 | 306 |
|
36059 | 307 |
val provers = [spass, vampire, e, remote_vampire, remote_spass, remote_e] |
35867 | 308 |
val prover_setup = fold add_prover provers |
309 |
||
310 |
val setup = |
|
311 |
destdir_setup |
|
312 |
#> problem_prefix_setup |
|
313 |
#> measure_runtime_setup |
|
314 |
#> prover_setup; |
|
315 |
||
28592 | 316 |
end; |