112 Exn.capture f path |
115 Exn.capture f path |
113 |> tap (fn _ => cleanup path) |
116 |> tap (fn _ => cleanup path) |
114 |> Exn.release |
117 |> Exn.release |
115 |> tap (after path); |
118 |> tap (after path); |
116 |
119 |
117 fun external_prover relevance_filter prepare write cmd args produce_answer name |
120 fun find_failure strs proof = |
118 ({with_full_types, subgoal, goal, axiom_clauses, filtered_clauses}: problem) = |
121 case filter (fn s => String.isSubstring s proof) strs of |
|
122 [] => if is_proof_well_formed proof then NONE |
|
123 else SOME "Ill-formed ATP output" |
|
124 | (failure :: _) => SOME failure |
|
125 |
|
126 fun external_prover relevance_filter prepare write cmd args failure_strs |
|
127 produce_answer name ({with_full_types, subgoal, goal, axiom_clauses, |
|
128 filtered_clauses}: problem) = |
119 let |
129 let |
120 (* get clauses and prepare them for writing *) |
130 (* get clauses and prepare them for writing *) |
121 val (ctxt, (chain_ths, th)) = goal; |
131 val (ctxt, (chain_ths, th)) = goal; |
122 val thy = ProofContext.theory_of ctxt; |
132 val thy = ProofContext.theory_of ctxt; |
123 val chain_ths = map (Thm.put_name_hint SPR.chained_hint) chain_ths; |
133 val chain_ths = map (Thm.put_name_hint chained_hint) chain_ths; |
124 val goal_cls = #1 (Sledgehammer_Fact_Preprocessor.neg_conjecture_clauses ctxt th subgoal); |
134 val goal_cls = #1 (Sledgehammer_Fact_Preprocessor.neg_conjecture_clauses ctxt th subgoal); |
125 val the_filtered_clauses = |
135 val the_filtered_clauses = |
126 (case filtered_clauses of |
136 (case filtered_clauses of |
127 NONE => relevance_filter goal goal_cls |
137 NONE => relevance_filter goal goal_cls |
128 | SOME fcls => fcls); |
138 | SOME fcls => fcls); |
198 end; |
208 end; |
199 |
209 |
200 |
210 |
201 (* generic TPTP-based provers *) |
211 (* generic TPTP-based provers *) |
202 |
212 |
203 fun gen_tptp_prover (name, prover_config) timeout problem = |
213 fun generic_tptp_prover |
204 let |
214 (name, {command, arguments, failure_strs, max_new_clauses, |
205 val {max_new_clauses, insert_theory_const, emit_structured_proof, command, arguments} = |
215 insert_theory_const, emit_structured_proof}) timeout = |
206 prover_config; |
216 external_prover (get_relevant_facts max_new_clauses insert_theory_const) |
207 in |
217 (prepare_clauses false) write_tptp_file command (arguments timeout) |
208 external_prover |
218 failure_strs |
209 (SFF.get_relevant max_new_clauses insert_theory_const) |
219 (if emit_structured_proof then structured_isar_proof |
210 (SFF.prepare_clauses false) |
220 else metis_lemma_list false) name; |
211 Sledgehammer_HOL_Clause.tptp_write_file |
221 |
212 command |
222 fun tptp_prover (name, p) = (name, generic_tptp_prover (name, p)); |
213 (arguments timeout) |
|
214 (if emit_structured_proof then SPR.structured_proof |
|
215 else SPR.lemma_list false) |
|
216 name |
|
217 problem |
|
218 end; |
|
219 |
|
220 fun tptp_prover (name, config) = (name, gen_tptp_prover (name, config)); |
|
221 |
|
222 |
223 |
223 |
224 |
224 (** common provers **) |
225 (** common provers **) |
225 |
226 |
226 (* Vampire *) |
227 (* Vampire *) |
227 |
228 |
228 (*NB: Vampire does not work without explicit timelimit*) |
229 (*NB: Vampire does not work without explicit timelimit*) |
229 |
230 |
|
231 val vampire_failure_strs = |
|
232 ["Satisfiability detected", "Refutation not found", "CANNOT PROVE"]; |
230 val vampire_max_new_clauses = 60; |
233 val vampire_max_new_clauses = 60; |
231 val vampire_insert_theory_const = false; |
234 val vampire_insert_theory_const = false; |
232 |
235 |
233 fun vampire_prover_config full : prover_config = |
236 fun vampire_prover_config full : prover_config = |
234 {command = Path.explode "$VAMPIRE_HOME/vampire", |
237 {command = Path.explode "$VAMPIRE_HOME/vampire", |
235 arguments = (fn timeout => "--output_syntax tptp --mode casc" ^ |
238 arguments = (fn timeout => "--output_syntax tptp --mode casc" ^ |
236 " -t " ^ string_of_int timeout), |
239 " -t " ^ string_of_int timeout), |
|
240 failure_strs = vampire_failure_strs, |
237 max_new_clauses = vampire_max_new_clauses, |
241 max_new_clauses = vampire_max_new_clauses, |
238 insert_theory_const = vampire_insert_theory_const, |
242 insert_theory_const = vampire_insert_theory_const, |
239 emit_structured_proof = full}; |
243 emit_structured_proof = full}; |
240 |
244 |
241 val vampire = tptp_prover ("vampire", vampire_prover_config false); |
245 val vampire = tptp_prover ("vampire", vampire_prover_config false); |
242 val vampire_full = tptp_prover ("vampire_full", vampire_prover_config true); |
246 val vampire_full = tptp_prover ("vampire_full", vampire_prover_config true); |
243 |
247 |
244 |
248 |
245 (* E prover *) |
249 (* E prover *) |
246 |
250 |
|
251 val eprover_failure_strs = |
|
252 ["SZS status: Satisfiable", "SZS status Satisfiable", |
|
253 "SZS status: ResourceOut", "SZS status ResourceOut", |
|
254 "# Cannot determine problem status"]; |
247 val eprover_max_new_clauses = 100; |
255 val eprover_max_new_clauses = 100; |
248 val eprover_insert_theory_const = false; |
256 val eprover_insert_theory_const = false; |
249 |
257 |
250 fun eprover_config full : prover_config = |
258 fun eprover_config full : prover_config = |
251 {command = Path.explode "$E_HOME/eproof", |
259 {command = Path.explode "$E_HOME/eproof", |
252 arguments = (fn timeout => "--tstp-in --tstp-out -l5 -xAutoDev -tAutoDev" ^ |
260 arguments = (fn timeout => "--tstp-in --tstp-out -l5 -xAutoDev -tAutoDev" ^ |
253 " --silent --cpu-limit=" ^ string_of_int timeout), |
261 " --silent --cpu-limit=" ^ string_of_int timeout), |
|
262 failure_strs = eprover_failure_strs, |
254 max_new_clauses = eprover_max_new_clauses, |
263 max_new_clauses = eprover_max_new_clauses, |
255 insert_theory_const = eprover_insert_theory_const, |
264 insert_theory_const = eprover_insert_theory_const, |
256 emit_structured_proof = full}; |
265 emit_structured_proof = full}; |
257 |
266 |
258 val eprover = tptp_prover ("e", eprover_config false); |
267 val eprover = tptp_prover ("e", eprover_config false); |
259 val eprover_full = tptp_prover ("e_full", eprover_config true); |
268 val eprover_full = tptp_prover ("e_full", eprover_config true); |
260 |
269 |
261 |
270 |
262 (* SPASS *) |
271 (* SPASS *) |
263 |
272 |
|
273 val spass_failure_strs = |
|
274 ["SPASS beiseite: Completion found.", "SPASS beiseite: Ran out of time.", |
|
275 "SPASS beiseite: Maximal number of loops exceeded."]; |
264 val spass_max_new_clauses = 40; |
276 val spass_max_new_clauses = 40; |
265 val spass_insert_theory_const = true; |
277 val spass_insert_theory_const = true; |
266 |
278 |
267 fun spass_config insert_theory_const: prover_config = |
279 fun spass_config insert_theory_const: prover_config = |
268 {command = Path.explode "$SPASS_HOME/SPASS", |
280 {command = Path.explode "$SPASS_HOME/SPASS", |
269 arguments = (fn timeout => "-Auto -SOS=1 -PGiven=0 -PProblem=0 -Splits=0" ^ |
281 arguments = (fn timeout => "-Auto -SOS=1 -PGiven=0 -PProblem=0 -Splits=0" ^ |
270 " -FullRed=0 -DocProof -TimeLimit=" ^ string_of_int timeout), |
282 " -FullRed=0 -DocProof -TimeLimit=" ^ string_of_int timeout), |
|
283 failure_strs = spass_failure_strs, |
271 max_new_clauses = spass_max_new_clauses, |
284 max_new_clauses = spass_max_new_clauses, |
272 insert_theory_const = insert_theory_const, |
285 insert_theory_const = insert_theory_const, |
273 emit_structured_proof = false}; |
286 emit_structured_proof = false}; |
274 |
287 |
275 fun gen_dfg_prover (name, prover_config: prover_config) timeout problem = |
288 fun generic_dfg_prover |
276 let |
289 (name, ({command, arguments, failure_strs, max_new_clauses, |
277 val {max_new_clauses, insert_theory_const, command, arguments, ...} = prover_config; |
290 insert_theory_const, ...} : prover_config)) timeout = |
278 in |
291 external_prover |
279 external_prover |
292 (get_relevant_facts max_new_clauses insert_theory_const) |
280 (SFF.get_relevant max_new_clauses insert_theory_const) |
293 (prepare_clauses true) |
281 (SFF.prepare_clauses true) |
294 write_dfg_file |
282 Sledgehammer_HOL_Clause.dfg_write_file |
295 command |
283 command |
296 (arguments timeout) |
284 (arguments timeout) |
297 failure_strs |
285 (SPR.lemma_list true) |
298 (metis_lemma_list true) |
286 name |
299 name; |
287 problem |
300 |
288 end; |
301 fun dfg_prover (name, p) = (name, generic_dfg_prover (name, p)); |
289 |
|
290 fun dfg_prover (name, config) = (name, gen_dfg_prover (name, config)); |
|
291 |
302 |
292 val spass = dfg_prover ("spass", spass_config spass_insert_theory_const); |
303 val spass = dfg_prover ("spass", spass_config spass_insert_theory_const); |
293 val spass_no_tc = dfg_prover ("spass_no_tc", spass_config false); |
304 val spass_no_tc = dfg_prover ("spass_no_tc", spass_config false); |
294 |
305 |
295 |
306 |